Documentation
¶
Index ¶
- Constants
- func ClippedBodyHint(hits []Hit) string
- func CompactSnapshot(root, sessionID string) string
- func ConsolidateCap() int
- func CopyInto(srcPath, dstPath string) error
- func Cosine(left Vector, right []byte) float64
- func CountLiveMemories(root string) int
- func CurrentEmbedder() string
- func DefaultHorizon(kind string, pin bool) string
- func DisplayType(ep Episode) string
- func DistillBrief(root, sessionID string) (string, error)
- func EmptyHitHint(live, fts int, sealed bool) string
- func EmptyRecallHint(live, fts int, sealed bool) string
- func EnsureEmbedWorker()
- func EnsureModelDir() error
- func EstimateTokens(s string) int
- func FetchModels() error
- func FormatIndexLine(ep Episode) string
- func HasEpisodes(root string) bool
- func HelpForGet(eps []Episode) []string
- func HelpForSearch(hits []Hit) []string
- func IndexRow(idx IndexHit) map[string]any
- func IndexRowsFromEpisodes(eps []Episode) []map[string]any
- func IndexRowsFromHits(hits []Hit) []map[string]any
- func LiveDistillInstruction(pendingSession string) string
- func ModelDir() string
- func NormalizeHorizon(raw string) string
- func NormalizePath(p string) string
- func ParseIDs(args []string) ([]int64, error)
- func PendingDistillLine(root string) string
- func PromptRecallPack(root, cue string) string
- func Sanitize(s string) string
- func ServeEmbedWorker(addr string) error
- func SessionStartIndex(root string) string
- func SleepRoot(root string) error
- type ActivityBucket
- type CaptureInput
- type DistillResult
- type Economy
- type Episode
- type Hit
- type IndexHit
- type IngestResult
- type MemoryCounts
- type ObserveResult
- type Pack
- type RecallResult
- type SearchFilter
- type Status
- type Store
- func (s *Store) BuildNextPack(cue, currentSession string) (Pack, error)
- func (s *Store) BuildPack(cue, currentSession string) (Pack, error)
- func (s *Store) BuildPromptRecall(cue string) string
- func (s *Store) BuildSessionIndex() string
- func (s *Store) BumpDistillFail(sessionID string)
- func (s *Store) BumpSessionSeq() int
- func (s *Store) Capture(in CaptureInput) (Episode, error)
- func (s *Store) ClearDistillFail(sessionID string)
- func (s *Store) ClearPending(sessionID string) error
- func (s *Store) Close() error
- func (s *Store) ClusterTopics() error
- func (s *Store) Consolidate() error
- func (s *Store) Contradict(oldID int64, in CaptureInput) (Episode, error)
- func (s *Store) Curiosity(limit int) ([]Hit, error)
- func (s *Store) DeleteExpired(cutoff time.Time) (int, error)
- func (s *Store) DeleteUnprotectedForSessions(sessionIDs []string) (int, error)
- func (s *Store) DistillFailCount(sessionID string) int
- func (s *Store) DistillPaused() bool
- func (s *Store) DistilledSessions() []string
- func (s *Store) Events(limit int) ([]TimelineBucket, error)
- func (s *Store) ExpireHorizons() (int, error)
- func (s *Store) FTSDocCount() int
- func (s *Store) Fade(id int64) error
- func (s *Store) FileContext(path string, limit int) ([]Hit, error)
- func (s *Store) ForgetEpisode(id int64) error
- func (s *Store) Get(id int64) (Episode, error)
- func (s *Store) GetMany(ids []int64) ([]Episode, error)
- func (s *Store) HasDistilled(sessionID string) bool
- func (s *Store) HasKindPrompt(sessionID string) bool
- func (s *Store) HasSessionRollup(sessionID string) bool
- func (s *Store) IndexSealed() bool
- func (s *Store) LatestSessionKind(kind string) (Episode, error)
- func (s *Store) Layout(maxNodes int) (api.LayoutResult, error)
- func (s *Store) ListTopics() ([]Topic, error)
- func (s *Store) LiveKnowledge(limit int) ([]Episode, error)
- func (s *Store) LiveMemoryCount() int
- func (s *Store) MapJSON() (string, error)
- func (s *Store) MarkDistilled(sessionID string) error
- func (s *Store) MarkPending(sessionID string) error
- func (s *Store) Patterns(limit int) ([]string, error)
- func (s *Store) PendingDistill() []string
- func (s *Store) Pin(id int64) error
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) Preview(id int64) string
- func (s *Store) Profile() map[string]string
- func (s *Store) PromoteHorizon(id int64, horizon string) error
- func (s *Store) ReadEconomy() (Economy, error)
- func (s *Store) Recall(query string, budget int) (RecallResult, error)
- func (s *Store) RecallFilter(filter SearchFilter, budget int) (RecallResult, error)
- func (s *Store) RecallShape(cue string, limit int) ([]Hit, error)
- func (s *Store) Recent(limit int) ([]Episode, error)
- func (s *Store) RecordPack(tokensInjected, tokensSaved int) error
- func (s *Store) RecordSearch() error
- func (s *Store) Reinforce(id int64) error
- func (s *Store) Rescue(id int64) error
- func (s *Store) Search(filter SearchFilter) ([]Hit, error)
- func (s *Store) SessionSeq() int
- func (s *Store) SetDistillPaused(paused bool) error
- func (s *Store) SetProfile(key, value string) error
- func (s *Store) Sleep() error
- func (s *Store) Status() (Status, error)
- func (s *Store) TemporalRecall(query, asOf, changedSince string, budget int) (RecallResult, error)
- func (s *Store) Timeline(limit int) ([]TimelineBucket, error)
- func (s *Store) TimelineAround(id int64, before, after int) ([]Episode, error)
- func (s *Store) When(query string, limit int) ([]Hit, error)
- func (s *Store) WorkingSnapshot(sessionID string) string
- type TeachReport
- type TimelineBucket
- type Topic
- type Vector
- type WatchResult
Constants ¶
const ( HorizonWorking = "working" HorizonShort = "short" HorizonMedium = "medium" HorizonLong = "long" )
const ( KindPrompt = "prompt" KindTool = "tool" KindWorking = "working" KindSession = "session" KindPin = "pin" KindTeaching = "teaching" KindObservation = "observation" SourceSpan = "span" SourceAgent = "agent" SourceTeach = "teach" SourceHeadless = "headless" SourceObserver = "observer" // ObservationType* taxonomy values stored on topic. ObservationDecision = "decision" ObservationBugfix = "bugfix" ObservationFeature = "feature" ObservationRefactor = "refactor" ObservationDiscovery = "discovery" ObservationChange = "change" EdgeContradicts = "contradicts" EdgeSameSession = "same_session" EdgeRolledUpFrom = "rolled_up_from" EdgeTaughtFrom = "taught_from" EdgeNext = "next" )
const DefaultEmbedListen = "127.0.0.1:18765"
DefaultEmbedListen is the shared loopback the UI and CLI probe.
const EmbedderID = "so-prose-384-v1"
EmbedderID stamps hashed 384-d int8 vectors used when the loopback worker is unavailable. Neural workers use distinct ids so geometries are never mixed.
Variables ¶
This section is empty.
Functions ¶
func ClippedBodyHint ¶
ClippedBodyHint tells the agent recall bodies are windows, not the full episode.
func CompactSnapshot ¶
CompactSnapshot is the Cursor preCompact inject: this-session working set, fail-open, never a full JSONL dump.
func ConsolidateCap ¶
func ConsolidateCap() int
func CopyInto ¶
CopyInto copies memory tables from srcPath into dstPath. Graph publish replaces so.db with a staged graph; this keeps the project diary. No-op if src is missing or has no memory_episodes table.
func CountLiveMemories ¶
CountLiveMemories is fail-open for hooks.
func CurrentEmbedder ¶
func CurrentEmbedder() string
func DefaultHorizon ¶
func DisplayType ¶
func DistillBrief ¶
DistillBrief is the same prompt the one-shot CLI would see, for the live agent.
func EmptyHitHint ¶
EmptyHitHint distinguishes empty store vs no match vs sealed FTS (AXI hint:).
func EmptyRecallHint ¶
EmptyRecallHint is the empty-hit line for so memory recall (which prints bodies).
func EnsureEmbedWorker ¶
func EnsureEmbedWorker()
EnsureEmbedWorker points capture/recall at the shared loopback worker. Users do not set SO_EMBED_URL for the normal path; that env remains an override.
func EnsureModelDir ¶
func EnsureModelDir() error
func EstimateTokens ¶
func FetchModels ¶
func FetchModels() error
func FormatIndexLine ¶
func HasEpisodes ¶
HasEpisodes is true when this repository's store already has at least one memory moment or rollup. Used to keep cold-clone tool lists graph-only.
func HelpForGet ¶
func HelpForSearch ¶
func IndexRowsFromEpisodes ¶
func IndexRowsFromHits ¶
func LiveDistillInstruction ¶
func NormalizeHorizon ¶
func NormalizePath ¶
NormalizePath slash-normalizes episode file paths so FTS and --file filters match Windows and POSIX spellings of the same location.
func PendingDistillLine ¶
func PromptRecallPack ¶
PromptRecallPack is the UserPromptSubmit inject for a prior-work / personal cue: matching recalled bodies from this workspace store, framed as the user's own notes. Empty when recall has no hits (caller may fall back to the pointer-only index). Fail-open.
func Sanitize ¶
Sanitize strips <private> blocks and secrets. Empty after privacy tags means the moment must not be stored or sent to a distill prompt.
func ServeEmbedWorker ¶
func SessionStartIndex ¶
SessionStartIndex is the SessionStart inject: when live memories exist, say how many and give the Bash recall command. Fail-open, no bodies and no uncued #id list (there is no question yet). Prompt-submit uses PromptRecallPack for matching bodies. Empty store stays silent except a pending distill one-liner.
Types ¶
type ActivityBucket ¶
type CaptureInput ¶
type DistillResult ¶
type DistillResult struct {
SessionID string `json:"session_id"`
Provider string `json:"provider,omitempty"`
Pending bool `json:"pending,omitempty"`
Skipped string `json:"skipped,omitempty"`
EpisodeID int64 `json:"episode_id,omitempty"`
Written int `json:"written,omitempty"`
}
func ApplyJSON ¶
func ApplyJSON(root, sessionID string, raw []byte) DistillResult
ApplyJSON ingests live-agent distill JSON without spawning a headless CLI.
func Distill ¶
func Distill(root, sessionID string) DistillResult
Distill runs skip gates then at most one bounded call on the session's own CLI.
func DistillSession ¶
func DistillSession(root, sessionID string) (DistillResult, error)
func MaybeDistill ¶
func MaybeDistill(root, sessionID string, detach bool) DistillResult
MaybeDistill detaches `so memory distill` after finalize when the live vendor has a one-shot CLI. Cursor marks pending for SessionStart.
type Episode ¶
type Episode struct {
ID int64 `json:"id"`
UID string `json:"uid"`
SessionID string `json:"session_id,omitempty"`
SpanID string `json:"span_id,omitempty"`
Kind string `json:"kind"`
Source string `json:"source"`
Title string `json:"title"`
Text string `json:"text,omitempty"`
Files []string `json:"files,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Tokens int `json:"tokens"`
Pinned bool `json:"pinned"`
Faded bool `json:"faded"`
Fading bool `json:"fading,omitempty"`
EmbeddingPending bool `json:"embedding_pending,omitempty"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ValidFrom string `json:"valid_from,omitempty"`
ValidTo string `json:"valid_to,omitempty"`
CommunityID string `json:"community_id,omitempty"`
Centrality float64 `json:"centrality,omitempty"`
Tier string `json:"tier,omitempty"`
Horizon string `json:"horizon,omitempty"`
KeepUntilSession int `json:"keep_until_session,omitempty"`
NeverDecay bool `json:"never_decay,omitempty"`
Tags string `json:"tags,omitempty"`
Topic string `json:"topic,omitempty"`
Facts []string `json:"facts,omitempty"`
Narrative string `json:"narrative,omitempty"`
Concepts []string `json:"concepts,omitempty"`
ContentHash string `json:"content_hash,omitempty"`
Score float64 `json:"score,omitempty"`
}
func CaptureRoot ¶
func CaptureRoot(root string, in CaptureInput) (Episode, error)
type IndexHit ¶
type IndexHit struct {
ID int64 `json:"id"`
Kind string `json:"kind"`
Topic string `json:"topic,omitempty"`
Horizon string `json:"horizon,omitempty"`
Title string `json:"title"`
Tokens int `json:"tokens"`
Score float64 `json:"score,omitempty"`
SessionID string `json:"session_id,omitempty"`
Files []string `json:"files,omitempty"`
}
IndexHit is the cheap search/timeline row: IDs, type, title, tokens. Bodies stay behind so memory get (index-then-fetch pattern).
func IndexFromEpisode ¶
func IndexFromHit ¶
type IngestResult ¶
type IngestResult struct {
SessionID string `json:"session_id"`
Inserted int `json:"inserted"`
Existing int `json:"existing"`
Skipped int `json:"skipped"`
}
func IngestAll ¶
func IngestAll(root string) ([]IngestResult, error)
func IngestBackfill ¶
func IngestBackfill(root, currentSession string, limit int) []IngestResult
IngestBackfill ingests at most `limit` recent other sessions that have spans but no KindPrompt. Fail-open. Bound for SessionStart (5s hook).
func IngestSession ¶
func IngestSession(root, sessionID string) (IngestResult, error)
type MemoryCounts ¶
type MemoryCounts struct {
Episodic int `json:"episodic"`
Semantic int `json:"semantic"`
Procedural int `json:"procedural"`
Working int `json:"working"`
Short int `json:"short"`
Medium int `json:"medium"`
Long int `json:"long"`
Tombstoned int `json:"tombstoned"`
Edges int `json:"edges"`
Pins int `json:"pins"`
Fading int `json:"fading"`
}
type ObserveResult ¶
type ObserveResult struct {
SessionID string `json:"session_id"`
Inserted int `json:"inserted"`
Provider string `json:"provider,omitempty"`
Skipped string `json:"skipped,omitempty"`
}
func ObserveSession ¶
func ObserveSession(root, sessionID string) (ObserveResult, error)
ObserveSession is a no-op. Typed knowledge comes from live capture JSON or post-session distill — not regex on prompts.
type Pack ¶
type Pack struct {
Text string `json:"text"`
Tokens int `json:"tokens"`
PendingSession string `json:"pending_session,omitempty"`
AskDistill bool `json:"ask_distill,omitempty"`
}
func PackForRoot ¶
func PackNextForRoot ¶
type RecallResult ¶
type SearchFilter ¶
type Status ¶
type Status struct {
Episodes int `json:"episodes"`
Vectors int `json:"vectors"`
Edges int `json:"edges"`
Topics int `json:"topics"`
Teachings int `json:"teachings"`
Pins int `json:"pins"`
Faded int `json:"faded"`
Fading int `json:"fading"`
RolledUp int `json:"rolled_up"`
PendingDistill []string `json:"pending_distill"`
DistillPaused bool `json:"distill_paused"`
EmbedderID string `json:"embedder_id"`
EmbeddingPending int `json:"embedding_pending"`
RolledUpPct float64 `json:"rolled_up_pct"`
FadePct float64 `json:"fade_pct"`
EdgeDensity float64 `json:"edge_density"`
Coverage float64 `json:"coverage"`
Live int `json:"live"`
Lifecycle string `json:"lifecycle"`
KnowledgePct float64 `json:"knowledge_pct"`
Connected float64 `json:"connected"`
CleanedPct float64 `json:"cleaned_pct"`
Counts MemoryCounts `json:"counts"`
Activity []ActivityBucket `json:"activity,omitempty"`
ActivityPeak int `json:"activity_peak"`
Economy Economy `json:"economy"`
SchemaVersion string `json:"schema_version"`
TopicsDetail []Topic `json:"topics_detail,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) BuildNextPack ¶
func (*Store) BuildPromptRecall ¶
func (*Store) BuildSessionIndex ¶
func (*Store) BumpDistillFail ¶
func (*Store) BumpSessionSeq ¶
func (*Store) ClearDistillFail ¶
func (*Store) ClearPending ¶
func (*Store) ClusterTopics ¶
func (*Store) Consolidate ¶
func (*Store) Contradict ¶
func (s *Store) Contradict(oldID int64, in CaptureInput) (Episode, error)
func (*Store) DeleteExpired ¶
DeleteExpired hard-deletes unpinned moments older than cutoff. Teachings, pins, and never_decay rows are kept.
func (*Store) DeleteUnprotectedForSessions ¶
DeleteUnprotectedForSessions removes diary rows tied to deleted session ids. Teachings, pins, and never_decay rows stay.
func (*Store) DistillFailCount ¶
func (*Store) DistillPaused ¶
func (*Store) DistilledSessions ¶
func (*Store) ExpireHorizons ¶
func (*Store) FTSDocCount ¶
FTSDocCount is how many plaintext FTS rows exist (0 if missing).
func (*Store) ForgetEpisode ¶
func (*Store) HasDistilled ¶
func (*Store) HasKindPrompt ¶
func (*Store) HasSessionRollup ¶
func (*Store) IndexSealed ¶
IndexSealed reports a leftover ciphertext FTS (search cannot see bodies).
func (*Store) ListTopics ¶
func (*Store) LiveMemoryCount ¶
LiveMemoryCount is faded non-tool, non-prompt rows on knowledge horizons (KindSession diary captures included). KindPrompt is never knowledge (M3).
func (*Store) MarkDistilled ¶
func (*Store) MarkPending ¶
func (*Store) PendingDistill ¶
func (*Store) ReadEconomy ¶
func (*Store) RecallFilter ¶
func (s *Store) RecallFilter(filter SearchFilter, budget int) (RecallResult, error)
func (*Store) RecallShape ¶
RecallShape is a compatibility alias for Search. Shape/HD vectors are no longer written or scored; hybrid FTS+dense ranking replaced that path.
func (*Store) RecordPack ¶
func (*Store) RecordSearch ¶
func (*Store) SessionSeq ¶
func (*Store) SetDistillPaused ¶
func (*Store) SetProfile ¶
func (*Store) TemporalRecall ¶
func (s *Store) TemporalRecall(query, asOf, changedSince string, budget int) (RecallResult, error)
func (*Store) TimelineAround ¶
func (*Store) WorkingSnapshot ¶
type TeachReport ¶
type TeachReport struct {
Inserted int `json:"inserted"`
Reinforced int `json:"reinforced"`
Edges int `json:"edges"`
RecallTested int `json:"recall_tested"`
RecallVerified int `json:"recall_verified"`
VerifiedDelta int `json:"verified_delta"`
Episodes []Episode `json:"episodes,omitempty"`
}
func TeachPath ¶
func TeachPath(root, path, title string) (TeachReport, error)
type TimelineBucket ¶
type Vector ¶
type Vector [embedDimensions]int8
Vector is a unit-quantized 384-d int8 embedding.
func EmbedQuery ¶
EmbedQuery encodes a search query. The BGE worker gets input_type=query (instruction prefix). The hash fallback is unprefixed so it stays symmetric with stored document vectors on machines without the Python worker.
func EmbedSentence ¶
EmbedSentence hashes word and character n-grams into a 384-d int8 unit vector.
func EmbedText ¶
EmbedText encodes prose for memory ingest and recall. A healthy BGE worker is preferred. If one is configured but fails, a zero vector (embedding_pending) is returned so hash geometry is never mixed into a neural store. If no worker is configured at all, hashed embeddings are used and EnsureEmbedWorker prints a one-time stderr notice — that path is weaker semantic recall, not a silent success.
type WatchResult ¶
type WatchResult struct {
Taught TeachReport `json:"taught"`
Faded []int64 `json:"faded,omitempty"`
}
func WatchOnce ¶
func WatchOnce(root, dir string) (WatchResult, error)