Documentation
¶
Overview ¶
Package songya stores connected Markdown records.
Index ¶
- Constants
- Variables
- func NewID(prefix string) (string, error)
- func TypeInstructions(cfg TypeConfiguration) string
- func TypeUser(ctx context.Context) string
- func TypeUsers(ctx context.Context, s *Store) ([]string, error)
- func ValidID(id string) bool
- func WithOriginalText(ctx context.Context, text string) context.Context
- func WithTypeUser(ctx context.Context, user string) context.Context
- type Ambiguity
- type BatchRequest
- type Catalog
- type Change
- type Configuration
- type DeleteBlocked
- type Destination
- type Diagnostic
- type Document
- func (d *Document) Diagnostics() []string
- func (d *Document) EditConnection(relation Relation, remove bool) error
- func (d *Document) Marshal() ([]byte, error)
- func (d *Document) Metadata() Metadata
- func (d *Document) MoveConnection(relation Relation, step int) error
- func (d *Document) OriginalSource() []byte
- func (d *Document) Record(kind Destination) Record
- func (d *Document) Set(name string, value any) (err error)
- func (d *Document) SetType(user, typ string) error
- func (d *Document) TypeFor(user string) string
- func (d *Document) Types() map[string]string
- type Edge
- type EmbeddingConfig
- type EmbeddingStatus
- type EpisodeTime
- type GraphQuery
- type GraphResult
- type ImportCandidate
- type ImportMapping
- type ImportPart
- type ImportPreview
- type ImportRequest
- type ImportedPart
- type Match
- type MemoryInput
- type MergeRequest
- type Metadata
- type NamedInput
- type Part
- type Preparation
- type Query
- type RecallHop
- type RecallPage
- type RecallPolicy
- type RecallQuery
- type RecallRequest
- type RecallResponse
- type Receipt
- type Recollection
- type Record
- type Relation
- type RelationInput
- type Resolution
- type SavedRecord
- type SearchResult
- type SemanticRecallResult
- type Span
- type SplitRequest
- type Store
- func (s *Store) AbandonBatch(ctx context.Context, key string) (Receipt, error)
- func (s *Store) ApplyBatch(ctx context.Context, request BatchRequest) (Receipt, error)
- func (s *Store) BatchData(ctx context.Context, key, id, view string) ([]byte, error)
- func (s *Store) BatchStatus(ctx context.Context, key string) (Receipt, error)
- func (s *Store) Compose(ctx context.Context, id string, offset, limit int) (StoryPage, error)
- func (s *Store) Configuration() (Configuration, error)
- func (s *Store) ConfigurationSnapshot() (Configuration, []byte, error)
- func (s *Store) Create(destination Destination, fields map[string]any, body string) (*Document, error)
- func (s *Store) Delete(ctx context.Context, id, revision string) error
- func (s *Store) Diagnostics() []string
- func (s *Store) Directory() string
- func (s *Store) Graph(ctx context.Context, q GraphQuery) (GraphResult, error)
- func (s *Store) Import(ctx context.Context, sourceRoot string, request ImportRequest) (ImportMapping, error)
- func (s *Store) ImportSource(sourceRoot, source string) ([]byte, string, error)
- func (s *Store) IndexEmbeddings(ctx context.Context) (EmbeddingStatus, error)
- func (s *Store) Merge(ctx context.Context, request MergeRequest) (Receipt, error)
- func (s *Store) Prepare(ctx context.Context, account, user string, limit int) (Preparation, error)
- func (s *Store) PreviewImports(ctx context.Context, sourceRoot string, offset, limit int) (ImportPreview, error)
- func (s *Store) Read(id string) (*Document, error)
- func (s *Store) ReadArchive(revision string) ([]byte, error)
- func (s *Store) ReadSource(source string) ([]byte, error)
- func (s *Store) Rebuild(ctx context.Context) (Catalog, error)
- func (s *Store) Recall(ctx context.Context, q RecallQuery) (RecallPage, error)
- func (s *Store) Recover() error
- func (s *Store) Resolve(ctx context.Context, id string) (Resolution, error)
- func (s *Store) Retrieve(ctx context.Context, request RecallRequest) (RecallResponse, error)
- func (s *Store) RetrieveWithConfiguration(ctx context.Context, request RecallRequest, config Configuration, ...) (RecallResponse, error)
- func (s *Store) SaveMemory(ctx context.Context, input MemoryInput) (Receipt, error)
- func (s *Store) SaveNamed(ctx context.Context, kind Destination, input NamedInput) (Receipt, error)
- func (s *Store) SaveSource(ctx context.Context, key, id string, kind Destination, revision, source string) (Receipt, error)
- func (s *Store) SaveStory(ctx context.Context, input StoryInput) (Receipt, error)
- func (s *Store) SaveTypeConfiguration(ctx context.Context, cfg TypeConfiguration, version string, ...) (Receipt, error)
- func (s *Store) Scan(ctx context.Context) (Catalog, error)
- func (s *Store) Search(ctx context.Context, q Query) (SearchResult, error)
- func (s *Store) Split(ctx context.Context, request SplitRequest) (Receipt, error)
- func (s *Store) Timeline(ctx context.Context, q Query) (Timeline, error)
- func (s *Store) TypeConfiguration(ctx context.Context, user string) (TypeConfiguration, error)
- func (s *Store) Update(id, revision string, fields map[string]any, body string) (*Document, error)
- func (s *Store) UseConfiguration(path string)
- type StoryInput
- type StoryPage
- type TemporalConstraint
- type TemporalRecord
- type Timeline
- type TypeConfiguration
- type TypeDefinition
- type Version
Examples ¶
Constants ¶
const IDLength = 2 + IDSuffixLength
IDLength includes the two-character prefix and the random suffix.
const IDSuffixLength = 12
IDSuffixLength is the number of random characters after a record's prefix.
Variables ¶
var ErrConflict = errors.New("record changed since it was read")
ErrConflict means the committed bytes differ from the update's base revision.
var RelationTypes = [...]string{"after", "caused_by", "part_of", "related_to", "possibly_same_as"}
Functions ¶
func TypeInstructions ¶
func TypeInstructions(cfg TypeConfiguration) string
func WithOriginalText ¶
WithOriginalText attaches the person's exact words, supplied by the client, not by the model. Generated record text remains in the before/after journal.
Types ¶
type Ambiguity ¶
type Ambiguity struct {
Name string `json:"name"`
Kind Destination `json:"kind"`
Candidates []string `json:"candidates"`
Truncated bool `json:"truncated,omitempty"`
}
type BatchRequest ¶
type Catalog ¶
type Catalog struct {
Records []Record `json:"records"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
func (Catalog) Connections ¶
Connections returns all direct source links touching id, without paging or redirect resolution. Editors use the actual stored targets when changing links.
type Change ¶
type Change struct {
Ref string `json:"ref,omitempty"`
ID string `json:"id,omitempty"`
Kind Destination `json:"kind,omitempty"`
Revision string `json:"-"`
Fields map[string]any `json:"fields,omitempty"`
Body *string `json:"body,omitempty"`
Append string `json:"append,omitempty"`
AddRelations []Relation `json:"add_relations,omitempty"`
// contains filtered or unexported fields
}
A nil body preserves the existing body on update, and means empty on creation.
type Configuration ¶
type Configuration struct {
Embeddings EmbeddingConfig `json:"embeddings" yaml:"embeddings"`
Recall RecallPolicy `json:"recall" yaml:"recall"`
}
func LoadConfiguration ¶
func LoadConfiguration(path string, fallback ...EmbeddingConfig) (Configuration, error)
type DeleteBlocked ¶
type DeleteBlocked struct {
Records []Record `json:"records"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
DeleteBlocked retains the complete list so a UI can navigate to each source.
func (*DeleteBlocked) Error ¶
func (e *DeleteBlocked) Error() string
type Destination ¶
type Destination string
const ( Memories Destination = "memories" Entities Destination = "entities" Topics Destination = "topics" Stories Destination = "stories" )
type Diagnostic ¶
Diagnostic identifies a recoverable problem without hiding healthy records.
type Document ¶
type Document struct {
ID string `yaml:"-"`
Revision string `yaml:"-"`
Pending bool `yaml:"-"`
Unconfirmed bool `yaml:"-"`
Frontmatter yaml.Node
Body string
// contains filtered or unexported fields
}
Document keeps the complete YAML tree and Markdown body, including damaged fields. Diagnostics reports problems without making the record unavailable.
func Parse ¶
Parse always retains the content. Unreadable YAML is kept verbatim in an unparsed_frontmatter field; when boundaries are unknown, the full source is body.
func (*Document) Diagnostics ¶
func (*Document) EditConnection ¶
EditConnection edits the single relations list. Other metadata and prose remain intact.
func (*Document) Marshal ¶
Marshal preserves damaged metadata as data rather than rejecting the record.
func (*Document) Metadata ¶
Metadata reads independent fields; one broken value cannot hide the others.
func (*Document) MoveConnection ¶
MoveConnection changes narrative reading order without changing the connection.
func (*Document) OriginalSource ¶
OriginalSource returns the exact snapshot captured by Read, before parsing or edits. Its revision belongs to these same bytes, including malformed headers.
func (*Document) Record ¶
func (d *Document) Record(kind Destination) Record
Record returns the same tolerant metadata view used by search and timelines.
func (*Document) Set ¶
Set edits one field, leaving other fields and their original representations intact.
type Edge ¶
type Edge struct {
Source string `json:"source"`
SourceTitle string `json:"source_title,omitempty"`
TargetTitle string `json:"target_title,omitempty"`
Type string `json:"type"`
ReverseType string `json:"reverse_type"`
Target string `json:"target"`
Resolved bool `json:"resolved"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
DetailsTruncated bool `json:"details_truncated,omitempty"`
}
type EmbeddingConfig ¶
type EmbeddingConfig struct {
Model string `json:"model" yaml:"model"`
BaseURL string `json:"base_url" yaml:"base_url"`
APIKey string `json:"api_key,omitempty" yaml:"api_key"`
ChunkSize int `json:"chunk_size,omitempty" yaml:"chunk_size"`
}
EmbeddingConfig uses an OpenAI-compatible embedding endpoint. Defaults match Clara's BGE-M3 service; dimensions are learned from the returned vectors.
func LoadEmbeddingConfig ¶
func LoadEmbeddingConfig(path string) (EmbeddingConfig, error)
LoadEmbeddingConfig reads the same store configuration used by the MCP server. Readable fields are retained when a damaged field needs repair.
func (*EmbeddingConfig) UnmarshalYAML ¶
func (c *EmbeddingConfig) UnmarshalYAML(node *yaml.Node) error
Configuration fields decode independently; numeric strings are accepted.
type EmbeddingStatus ¶
type EpisodeTime ¶
type EpisodeTime struct {
Date *string `json:"date" yaml:"date"`
Earliest *string `json:"earliest" yaml:"earliest"`
Latest *string `json:"latest" yaml:"latest"`
}
EpisodeTime describes the event, independently of automatic record timestamps.
type GraphQuery ¶
type GraphResult ¶
type GraphResult struct {
Resolution *Resolution `json:"resolution,omitempty"`
Edges []Edge `json:"edges"`
Next int `json:"next,omitempty"`
Truncated bool `json:"truncated"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type ImportCandidate ¶
type ImportMapping ¶
type ImportMapping struct {
Source string `json:"source"`
Revision string `json:"-"`
Archive string `json:"archive"`
BatchKey string `json:"batch_key"`
Status string `json:"status"`
Parts []ImportedPart `json:"parts"`
CoverageComplete bool `json:"coverage_complete"`
Uncovered []Span `json:"uncovered,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type ImportPart ¶
type ImportPart struct {
Start int `json:"start"`
End int `json:"end"`
Kind Destination `json:"kind,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
}
type ImportPreview ¶
type ImportPreview struct {
Files []ImportCandidate `json:"files"`
Next int `json:"next,omitempty"`
Truncated bool `json:"truncated"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type ImportRequest ¶
type ImportRequest struct {
User string `json:"user,omitempty"`
Path string `json:"path"`
Revision string `json:"-"`
Parts []ImportPart `json:"parts,omitempty"`
}
type ImportedPart ¶
type Match ¶
type Match struct {
Type string `json:"type,omitempty"`
User string `json:"user,omitempty"`
ID string `json:"id,omitempty"`
Source string `json:"source"`
Kind Destination `json:"kind"`
Revision string `json:"-"`
Pending bool `json:"pending,omitempty"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
Title string `json:"title"`
Aliases []string `json:"aliases,omitempty"`
Excerpt string `json:"excerpt"`
Redirects []string `json:"redirects,omitempty"`
Score float64 `json:"score"`
Reasons []string `json:"reasons,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty"`
DetailsTruncated bool `json:"details_truncated,omitempty"`
}
type MemoryInput ¶
type MemoryInput struct {
Key string `json:"-"`
ID string `json:"id,omitempty"`
User string `json:"user,omitempty"`
Type *string `json:"type,omitempty"`
Title *string `json:"title,omitempty"`
Text *string `json:"text,omitempty"`
Append string `json:"append,omitempty"`
Time any `json:"time,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Relations []RelationInput `json:"relations,omitempty"`
}
Key belongs to the caller's request metadata, never the model's arguments.
type MergeRequest ¶
type NamedInput ¶
type NamedInput struct {
Key string `json:"-"`
Create bool `json:"create,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
User string `json:"user,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Description *string `json:"description,omitempty"`
Append string `json:"append,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Relations []RelationInput `json:"relations,omitempty"`
}
type Part ¶
type Part struct {
Kind Destination `json:"kind,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
Body string `json:"body"`
}
type Preparation ¶
type Preparation struct {
Key string `json:"key"`
Query string `json:"query"`
User string `json:"user,omitempty"`
Matches []Match `json:"matches"`
Ambiguities []Ambiguity `json:"ambiguities"`
PossibleDuplicates [][]string `json:"possible_duplicates"`
Next int `json:"next,omitempty"`
Truncated bool `json:"truncated"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type Query ¶
type Query struct {
Mode string `json:"mode,omitempty"`
User string `json:"user,omitempty"`
Text string `json:"text,omitempty"`
Kind Destination `json:"kind,omitempty"`
RelatedTo string `json:"related_to,omitempty"`
RelationType string `json:"relation_type,omitempty"`
IncludeRetired bool `json:"include_retired,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
type RecallPage ¶
type RecallPolicy ¶
type RecallPolicy struct {
DirectLimit int `json:"direct_limit" yaml:"direct_limit"`
MinScore float64 `json:"min_score" yaml:"min_score"`
SearchKinds []Destination `json:"search_kinds" yaml:"search_kinds"`
ReturnKinds []Destination `json:"return_kinds" yaml:"return_kinds"`
ConnectionDepth int `json:"connection_depth" yaml:"connection_depth"`
ConnectedLimit int `json:"connected_limit" yaml:"connected_limit"`
RelationTypes []string `json:"relation_types" yaml:"relation_types"`
}
RecallPolicy belongs to the store, never to a requesting application.
func DefaultRecallPolicy ¶
func DefaultRecallPolicy() RecallPolicy
func (*RecallPolicy) UnmarshalYAML ¶
func (p *RecallPolicy) UnmarshalYAML(n *yaml.Node) error
Decode fields independently so a damaged option does not erase healthy ones.
type RecallQuery ¶
type RecallQuery struct {
Text string `json:"text"`
User string `json:"user,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
RecallQuery selects connected accounts. Offset and Limit count narrative bytes.
type RecallRequest ¶
type RecallRequest struct {
Message string `json:"message,omitempty"`
Messages []string `json:"messages,omitempty"`
Owners []string `json:"owners"`
}
RecallRequest accepts either one message or a batch sharing an ownership scope. Policies are deliberately absent: the store owns them.
func (RecallRequest) Validate ¶
func (r RecallRequest) Validate() error
type RecallResponse ¶
type RecallResponse struct {
Results []SemanticRecallResult `json:"results"`
Policy RecallPolicy `json:"policy"`
}
type Receipt ¶
type Receipt struct {
Key string `json:"key"`
Status string `json:"status"`
Refs map[string]string `json:"refs,omitempty"`
Records []SavedRecord `json:"records,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type Recollection ¶
type Recollection struct {
ID string `json:"id"`
Kind Destination `json:"kind"`
User string `json:"user,omitempty"`
Title string `json:"title"`
Time EpisodeTime `json:"time"`
Content string `json:"content"`
Reason string `json:"reason"`
Score *float64 `json:"score,omitempty"`
OriginID string `json:"origin_id,omitempty"`
Depth int `json:"depth"`
Path []RecallHop `json:"path,omitempty"`
ContentTruncated bool `json:"content_truncated,omitempty"`
}
type Record ¶
type Record struct {
User string `json:"user,omitempty"`
ID string `json:"id"`
Source string `json:"source"`
Kind Destination `json:"kind"`
Revision string `json:"-"`
Pending bool `json:"pending,omitempty"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
Title string `json:"title"`
Name string `json:"name,omitempty"`
Aliases []string `json:"aliases,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
Types map[string]string `json:"types,omitempty"`
Relations []Relation `json:"relations,omitempty"`
Redirects []string `json:"redirects,omitempty"`
Time EpisodeTime `json:"time"`
Body string `json:"body"`
Context string `json:"context,omitempty"`
Diagnostics []string `json:"diagnostics,omitempty"`
}
Record is the derived search/graph view. Source Markdown is authoritative.
type RelationInput ¶
type RelationInput struct {
Type string `json:"type" yaml:"type"`
Target any `json:"target" yaml:"target"`
}
Targets are record IDs, entity names, or a named entity/topic to create or reuse. Persisted relations always contain the engine-assigned target ID.
type Resolution ¶
type SavedRecord ¶
type SearchResult ¶
type SemanticRecallResult ¶
type SemanticRecallResult struct {
Mode string `json:"mode"`
Status string `json:"status"`
Items []Recollection `json:"items"`
Incomplete bool `json:"incomplete"`
Truncated bool `json:"truncated"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type SplitRequest ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds no open files between calls. Diagnostics is safe across goroutines.
Example ¶
package main
import (
"fmt"
"os"
"github.com/aristath/songya"
)
func main() {
path, err := os.MkdirTemp("", "songya-example-")
if err != nil {
panic(err)
}
defer os.RemoveAll(path)
store, err := songya.Open(path)
if err != nil {
panic(err)
}
created, err := store.Create(songya.Memories, map[string]any{
"user": "ari",
"title": "Example",
"custom": map[string]any{"labels": []string{"one", "two"}},
}, "Markdown body.")
if err != nil {
panic(err)
}
read, err := store.Read(created.ID)
if err != nil {
panic(err)
}
fmt.Println(read.Body)
updated, err := store.Update(read.ID, read.Revision, map[string]any{"title": "Edited"}, "More detail.")
if err != nil {
panic(err)
}
fmt.Println(updated.Body)
}
Output: Markdown body. More detail.
func Open ¶
func Open(path string, configuration ...EmbeddingConfig) (*Store, error)
Open opens the root and lock. Problems in individual directories are reported through Diagnostics rather than disabling healthy parts of the store.
func OpenExisting ¶
func OpenExisting(path string, configuration ...EmbeddingConfig) (*Store, error)
OpenExisting opens without creating record directories or publishing recovery work. Query clients can report missing sources instead of silently replacing them with empty directories. Normal writers keep Open's automatic recovery.
func (*Store) AbandonBatch ¶
AbandonBatch explicitly withdraws an uncommitted batch. Its journal, original account, and proposals stay intact. Only bytes published by this exact batch are rolled back; later external edits or deletions are never replaced.
func (*Store) ApplyBatch ¶
Example ¶
package main
import (
"context"
"fmt"
"os"
"github.com/aristath/songya"
)
func main() {
path, err := os.MkdirTemp("", "songya-capture-")
if err != nil {
panic(err)
}
defer os.RemoveAll(path)
store, err := songya.Open(path)
if err != nil {
panic(err)
}
ctx := context.Background()
prepared, err := store.Prepare(ctx, "I met John for coffee.", "ari", 5)
if err != nil {
panic(err)
}
body := "I met John for coffee."
receipt, err := store.ApplyBatch(ctx, songya.BatchRequest{User: "ari", Key: prepared.Key, Account: body, Changes: []songya.Change{
{Ref: "john", Kind: songya.Entities, Fields: map[string]any{"name": "John"}},
{Ref: "episode", Fields: map[string]any{"relations": []songya.Relation{{Type: "with", Target: "$john"}}}, Body: &body},
}})
if err != nil {
panic(err)
}
doc, err := store.Read(receipt.Refs["episode"])
if err != nil {
panic(err)
}
fmt.Println(receipt.Status)
fmt.Println(doc.Body)
fmt.Println(doc.Metadata().Relations[0].Target == receipt.Refs["john"])
}
Output: committed I met John for coffee. true
func (*Store) BatchData ¶
BatchData exposes retained work without changing it. Both original and proposed record bytes remain available after commit or abandonment. Receipt data can be byte-paged by a client even when a batch contains thousands of records.
func (*Store) BatchStatus ¶
func (*Store) Compose ¶
Compose expands the story’s ordered relations. Prose is never another link store.
func (*Store) Configuration ¶
func (s *Store) Configuration() (Configuration, error)
Configuration is reloaded per operation.
func (*Store) ConfigurationSnapshot ¶
func (s *Store) ConfigurationSnapshot() (Configuration, []byte, error)
ConfigurationSnapshot couples the effective values to the exact source bytes used for optimistic settings saves, including incomplete readable settings.
func (*Store) Create ¶
func (s *Store) Create(destination Destination, fields map[string]any, body string) (*Document, error)
Create assigns the filename ID and UTC timestamps. Metadata problems are diagnostics, not reasons to discard the body. Pending=true means the complete record is durably staged and readable, while final publication will be retried.
func (*Store) Delete ¶
Delete permanently removes one unreferenced, unchanged record. Checks and removal hold the same cross-process lock used by all engine writers.
func (*Store) Diagnostics ¶
func (*Store) Directory ¶
Directory is the canonical root used by applications storing companion state.
func (*Store) Graph ¶
func (s *Store) Graph(ctx context.Context, q GraphQuery) (GraphResult, error)
func (*Store) Import ¶
func (s *Store) Import(ctx context.Context, sourceRoot string, request ImportRequest) (ImportMapping, error)
Import keeps a checksum-named verbatim original and uses one idempotent batch per source path. Repartitioning an already imported source requires explicit organization of its mapped records, rather than duplicate active imports.
func (*Store) ImportSource ¶
func (*Store) IndexEmbeddings ¶
func (s *Store) IndexEmbeddings(ctx context.Context) (EmbeddingStatus, error)
IndexEmbeddings refreshes missing or damaged derived vectors. Writes to memories never depend on the endpoint; changed text gets new cache keys.
func (*Store) Merge ¶
Merge preserves every source body under its retired ID. The default canonical body concatenates those originals; a reviewed replacement may be supplied.
func (*Store) Prepare ¶
Prepare performs deterministic local retrieval. The caller interprets the shortlist and submits one complete ApplyBatch request; no inference is hidden.
func (*Store) PreviewImports ¶
func (s *Store) PreviewImports(ctx context.Context, sourceRoot string, offset, limit int) (ImportPreview, error)
PreviewImports never interprets episode boundaries. The client reviews exact source byte ranges; omitted parts import the entire file verbatim.
func (*Store) ReadArchive ¶
ReadArchive returns the checksum-verified original retained by an import.
func (*Store) ReadSource ¶
ReadSource exposes only Markdown sources in the four record directories. This also keeps records with damaged filenames inspectable without inventing IDs.
func (*Store) Rebuild ¶
Rebuild ignores cached parsing and derives a fresh catalogue from source data.
func (*Store) Recall ¶
func (s *Store) Recall(ctx context.Context, q RecallQuery) (RecallPage, error)
Recall returns canonical prose with record labels and story context. It does not generate summaries, choose a primary story, or modify stored accounts.
func (*Store) Recover ¶
Recover resumes completed pending writes when the write lock is available. Open reports deferred recovery without blocking access to readable records.
func (*Store) Retrieve ¶
func (s *Store) Retrieve(ctx context.Context, request RecallRequest) (RecallResponse, error)
Retrieve is the authoritative policy, ranking and traversal implementation. A batch scans and embeds each record once. Missing vectors never gain lexical scores.
func (*Store) RetrieveWithConfiguration ¶
func (s *Store) RetrieveWithConfiguration(ctx context.Context, request RecallRequest, config Configuration, configIssue error) (RecallResponse, error)
RetrieveWithConfiguration captures a turn's effective configuration for durable recovery. HTTP callers cannot override it through request fields.
func (*Store) SaveMemory ¶
SaveMemory translates the caller's concepts into one durable related write. Entity lookup and creation run under that write's process-wide store lock.
func (*Store) SaveNamed ¶
func (s *Store) SaveNamed(ctx context.Context, kind Destination, input NamedInput) (Receipt, error)
func (*Store) SaveSource ¶
func (s *Store) SaveSource(ctx context.Context, key, id string, kind Destination, revision, source string) (Receipt, error)
SaveSource edits a complete document through the same durable receipts as MCP writes. A stable key makes retries safe; updates require the bytes' revision.
func (*Store) SaveTypeConfiguration ¶
func (*Store) Scan ¶
Scan refreshes byte revisions on every call. Cached parsing never masks direct edits, and a damaged cache is rebuilt from the readable source files.
func (*Store) Split ¶
Split makes the one-to-many redirect explicit. The original remains readable; neither incoming links nor stories are assigned to an arbitrary replacement.
func (*Store) Timeline ¶
Timeline returns a partial chronology, never a guessed total ordering. Global analysis visits explicit edges; date-only edges are derived for this page, avoiding a quadratic graph of every dated pair in the entire store.
func (*Store) TypeConfiguration ¶
func (*Store) Update ¶
Update applies metadata changes and replaces the body of a committed record. Pass the revision from Read or a committed Create result. Identity and creation time are preserved. An error with Pending=true retains this attempt in staging; Recover can retry it without replacing a conflicting committed version.
func (*Store) UseConfiguration ¶
UseConfiguration selects a configuration file at construction, before sharing the Store with goroutines. All later operations read its current contents.
type StoryInput ¶
type StoryInput struct {
Key string `json:"-"`
ID string `json:"id,omitempty"`
User string `json:"user,omitempty"`
Type *string `json:"type,omitempty"`
Title string `json:"title,omitempty"`
Text *string `json:"text,omitempty"`
Append string `json:"append,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
Relations []RelationInput `json:"relations,omitempty"`
}
type StoryPage ¶
type StoryPage struct {
User string `json:"user,omitempty"`
UserTruncated bool `json:"user_truncated,omitempty"`
ID string `json:"id"`
Revision string `json:"-"`
Text string `json:"text,omitempty"`
Base64 string `json:"base64,omitempty"`
Offset int `json:"offset"`
Next int `json:"next,omitempty"`
Truncated bool `json:"truncated"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type TemporalConstraint ¶
type TemporalRecord ¶
type TemporalRecord struct {
User string `json:"user,omitempty"`
ID string `json:"id"`
Title string `json:"title"`
Time EpisodeTime `json:"time"`
Relations []Relation `json:"relations,omitempty"`
Unordered bool `json:"unordered"`
Unconfirmed bool `json:"unconfirmed,omitempty"`
DetailsTruncated bool `json:"details_truncated,omitempty"`
}
type Timeline ¶
type Timeline struct {
Groups map[string][]string `json:"groups,omitempty"`
Records []TemporalRecord `json:"records"`
Constraints []TemporalConstraint `json:"constraints"`
Next int `json:"next,omitempty"`
Truncated bool `json:"truncated"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
type TypeConfiguration ¶
type TypeConfiguration struct {
User string `json:"user" yaml:"user"`
Kinds map[Destination][]TypeDefinition `json:"kinds" yaml:"kinds"`
Version string `json:"version,omitempty" yaml:"-"`
Diagnostics []string `json:"diagnostics,omitempty" yaml:"-"`
Usage map[Destination]map[string]int `json:"usage,omitempty" yaml:"-"`
}
func DefaultTypeConfiguration ¶
func DefaultTypeConfiguration(user string) TypeConfiguration
type TypeDefinition ¶
Source Files
¶
- batch.go
- batch_abandon.go
- batch_inspect.go
- capture.go
- catalog.go
- chronology.go
- configuration.go
- connections.go
- delete.go
- document.go
- embeddings.go
- episode_time.go
- graph.go
- id.go
- import.go
- organize.go
- pending.go
- recall.go
- record_changes.go
- relation_input.go
- relations.go
- retrieval.go
- source.go
- store.go
- story.go
- types.go
- update.go
- user.go
- value.go
- yaml.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
songya-mcp
command
|
|
|
songya-query
command
songya-query is the JSON query boundary for application recall and browsing.
|
songya-query is the JSON query boundary for application recall and browsing. |
|
songya-web
command
|
|
|
Package mcpserver exposes the standalone memory engine over MCP stdio.
|
Package mcpserver exposes the standalone memory engine over MCP stdio. |
|
Package web serves Songya's standalone editor; all persistence stays in the engine.
|
Package web serves Songya's standalone editor; all persistence stays in the engine. |