Versions in this module Expand all Collapse all v0 v0.5.1 Nov 14, 2026 Changes in this version + const DefaultLinkMinSim + const DefaultSupersedeMinSim + const MinRerankDocBytes + func IsRerankDegradation(err error) bool + func LogRerankDegraded(site string, err error) + func RerankShrinking(ctx context.Context, rr embedding.Reranker, req embedding.RerankRequest) ([]embedding.RerankResult, error) type ExportData + Links []ExportedLink + type ExportedLink struct + Bidirectional bool + CreatedAt time.Time + ID int64 + Label string + LinkType string + Metadata json.RawMessage + Namespace string + SourceID int64 + TargetID int64 type FactExtractor + func (e *FactExtractor) SetSimilarityPolicy(pol SimilarityPolicy) *FactExtractor type ImportResult + Links int + LinksSkipped int + type SimilarityPolicy struct + Calibrated bool + LinkMinSim float64 + SupersedeMinSim float64 + func DefaultSimilarityPolicy(model string) SimilarityPolicy + func SimilarityPolicyFromEnv(prefix, model string) (SimilarityPolicy, error) v0.4.1 Nov 14, 2026 Changes in this version + const ChunkMinBytes + const ChunkOverlapBytes + const ChunkTargetTokens + const DefaultDetectReadScore + const DefaultRerankCandidates + const DefaultRerankDocBytes + const DefaultRerankThreshold + const DefaultRerankWeight + const EmbedEnvPrefix + const InlineRejectScore + const MaxContentLength + const RefTypeFact + const RefTypeHint + const RefTypeTurn + const RerankDroppedHeader + const RerankTopDroppedHeader + const ScopeAdmin + const ScopeIngest + const ScopeRead + const ScopeWrite + var ErrNotFound = errors.New("not found") + var ErrNotPermitted = errors.New("not permitted") + var ErrScreenRejected = errors.New("memstore: write rejected by injection screening") + func ChunkFact(model, content string, ceiling int) []embedding.Chunk + func ConfigPath() string + func DetectReadableSQL(prefix string, threshold int) string + func DetectRuleIDs(r detect.Result) []string + func EmbedConfigFromEnv() (embedding.Config, error) + func EmbedRecipe(model string) string + func FactEmbedText(model, subject, chunk string) string + func FactQueryText(model, query string) string + func FetchLimit(opts SearchOpts) int + func FuseScore(mode RerankMode, weight, rerank, firstStage float64) float64 + func LoadIngestToken() string + func LogEmbedModel(cfg embedding.Config) + func MatchFilePattern(pattern, filePath string) bool + func MetadataConflicts(a, b json.RawMessage) bool + func ProjectNameFromCWD(cwd string) string + func RedactDSN(dsn string) string + func RerankerFromEnv(prefix string) (embedding.Reranker, embedding.RerankConfig, error) + func ScreenNotRejectedSQL(prefix string) string + func ScreenReadableSQL(prefix string) string + func ScreenableText(content, metadata string) string + func ValidScopes() []string + func ValidateScopes(scopes []string) error + type AdminStore interface + type AppConfig struct + APIKey string + Addr string + DB string + GenModel string + GenURL string + InsecurePlaintext bool + LLMAPIKey string + Namespace string + Ollama string + PG string + Remote string + ScreenBatch int + ScreenConcurrency int + ScreenDetectRead string + ScreenDetectReadScore int + ScreenDetectScore int + ScreenDetectWrite string + ScreenIntervalSec int + ScreenMaxAttempts int + ScreenMode string + ScreenThreat int + TLSCAFile string + TLSCertFile string + TLSClientCAFile string + TLSClientCertFile string + TLSClientKeyFile string + TLSDisabled bool + TLSKeyFile string + VecDim int + func DefaultConfig() AppConfig + func LoadConfig() AppConfig + func (c AppConfig) String() string + type BlockedFact struct + Category string + Content string + CreatedAt time.Time + ID int64 + Reason string + Subject string + Threat int + type ContextFeedback struct + Reason string + RefID string + RefType string + Score int + SessionID string + type ContextHint struct + CWD string + CandidateScores map[string]float64 + ConsumedAt *time.Time + CreatedAt time.Time + Desirability float64 + HintText string + ID int64 + RankerVersion string + RefIDs []string + Relevance float64 + RetrievedIDs []string + SearchQuery string + SessionID string + TurnIndex int + type Curator interface + Curate func(ctx context.Context, task string, candidates []Fact, maxOutput int) (selected []Fact, rationale string, err error) + type Document struct + Basename string + ChunkStrategy string + ChunkerVersion int + Commit string + Dirty bool + FileSHA256 []byte + FrontMatter json.RawMessage + Generated bool + ID int64 + IngestedAt time.Time + IsTest bool + Lang string + Mtime *time.Time + Namespace string + Path string + RepoURL string + Title string + Trusted bool + UserID int64 + type DocumentChunk struct + ByteEnd int + ByteStart int + Content string + CreatedAt time.Time + DeclKind string + DocumentID int64 + Exported bool + HeadingLevel int + HeadingPath string + ID int64 + ImportPath string + ImportsUsed []string + Lang string + LineEnd int + LineStart int + Ordinal int + Package string + Receiver string + ScopePath string + Signature string + Symbol string + type DocumentInfo struct + Dirty bool + FileSHA256 []byte + ID int64 + Path string + type DocumentSearchOpts struct + Basename string + IncludeGenerated bool + Lang string + MaxResults int + PathPrefix string + RepoURL string + type DocumentSearchResult struct + Basename string + Chunk DocumentChunk + Commit string + Dirty bool + DocLang string + Fallback bool + Generated bool + IsTest bool + Path string + RepoURL string + Score float64 + Trusted bool + func (r DocumentSearchResult) Citation() string + type DocumentStore interface + DeleteDocuments func(ctx context.Context, repoURL string, paths []string) (int64, error) + GetDocument func(ctx context.Context, id int64) (*Document, error) + GetDocumentChunks func(ctx context.Context, documentID int64) ([]DocumentChunk, error) + ListDocuments func(ctx context.Context, repoURL string) ([]DocumentInfo, error) + SearchDocumentChunks func(ctx context.Context, query string, opts DocumentSearchOpts) ([]DocumentSearchResult, error) + UpsertDocument func(ctx context.Context, doc Document, chunks []DocumentChunk) (int64, error) + type EmbedStore interface + EmbedFacts func(ctx context.Context, batchSize int) (int, error) + FactChunks func(ctx context.Context, id int64) ([]FactChunk, error) + MarkEmbedFailed func(ctx context.Context, id int64, reason string) error + NeedingEmbedding func(ctx context.Context, limit int) ([]Fact, error) + SetEmbedding func(ctx context.Context, id int64, emb []float32) error + SetFactVectors func(ctx context.Context, id int64, v FactVectors) error + type ExportData struct + EmbedderModel string + EmbeddingDimensions int + ExportedAt time.Time + Facts []ExportedFact + Version int + func Export(ctx context.Context, db *sql.DB) (*ExportData, error) + type ExportedFact struct + Category string + ConfirmedCount int + Content string + CreatedAt time.Time + ID int64 + InjectCount int + Kind string + LastConfirmedAt *time.Time + LastInjectedAt *time.Time + LastUsedAt *time.Time + Metadata json.RawMessage + Namespace string + Subject string + Subsystem string + SupersededAt *time.Time + SupersededBy *int64 + UseCount int + User string + type ExtractHints struct + Categories []string + Focus []string + Persona string + type ExtractOpts struct + Hints ExtractHints + Metadata json.RawMessage + Namespace string + Subject string + type ExtractResult struct + Duplicates int + Errors []error + Inserted []Fact + Superseded int + type Fact struct + Category string + ConfirmedCount int + Content string + CreatedAt time.Time + Embedding []float32 + ID int64 + InjectCount int + Kind string + LastConfirmedAt *time.Time + LastInjectedAt *time.Time + LastUsedAt *time.Time + Metadata json.RawMessage + Namespace string + Subject string + Subsystem string + SupersededAt *time.Time + SupersededBy *int64 + UseCount int + UserID int64 + func ExtractFacts(ctx context.Context, gen Generator, text string, opts ExtractOpts) ([]Fact, error) + type FactBreakdown struct + Categories map[string]int + Kinds map[string]int + Subjects map[string]int + type FactChunk struct + ByteEnd int + ByteStart int + Ordinal int + Vector []float32 + type FactExtractor struct + func NewFactExtractor(store Store, embedder embedding.Embedder, generator Generator) *FactExtractor + func (e *FactExtractor) Extract(ctx context.Context, text string, opts ExtractOpts) (*ExtractResult, error) + func (e *FactExtractor) SetEmbedCeiling(n int) + func (e *FactExtractor) SetPromptFunc(fn PromptFunc) + type FactVectors struct + Chunks []FactChunk + Whole []float32 + func EmbedFact(ctx context.Context, e embedding.Embedder, model string, f Fact, ceiling int) (FactVectors, error) + type FactVectorsResult struct + Err error + Vectors FactVectors + func EmbedFactsBatch(ctx context.Context, e embedding.Embedder, model string, facts []Fact, ...) []FactVectorsResult + type FeedbackScorer interface + FeedbackScores func(ctx context.Context, refIDs []string, refType string) (map[string]FeedbackStat, error) + type FeedbackStat struct + Avg float64 + Count int + type FeedbackStore interface + RecordFeedback func(ctx context.Context, fb ContextFeedback) error + type Generator interface + Generate func(ctx context.Context, prompt string) (string, error) + Model func() string + type HistoryEntry struct + ChainLength int + Fact Fact + Position int + type ImportOpts struct + SkipDuplicates bool + type ImportResult struct + Imported int + Skipped int + func Import(ctx context.Context, db *sql.DB, data *ExportData, opts ImportOpts) (*ImportResult, error) + func StoreImport(ctx context.Context, store Store, data *ExportData, opts ImportOpts) (*ImportResult, error) + type InjectionRecorder interface + RecordInjection func(ctx context.Context, ids []int64) error + type JSONGenerator interface + GenerateJSON func(ctx context.Context, prompt string) (string, error) + type JSONSchemaGenerator interface + GenerateJSONSchema func(ctx context.Context, prompt, name string, schema any) (string, error) + type Link struct + Bidirectional bool + CreatedAt time.Time + ID int64 + Label string + LinkType string + Metadata json.RawMessage + SourceID int64 + TargetID int64 + type LinkDirection int + const LinkBoth + const LinkInbound + const LinkOutbound + type MetadataFilter struct + IncludeNull bool + Key string + Op string + Value any + type NopCurator struct + func (NopCurator) Curate(_ context.Context, _ string, candidates []Fact, maxOutput int) ([]Fact, string, error) + type OpenAICurator struct + func NewOpenAICurator(baseURL, apiKey, model string) *OpenAICurator + func (c *OpenAICurator) Curate(ctx context.Context, task string, candidates []Fact, maxOutput int) ([]Fact, string, error) + type OpenAIGenerator struct + func NewOpenAIGenerator(baseURL, apiKey, model string) *OpenAIGenerator + func (g *OpenAIGenerator) Generate(ctx context.Context, prompt string) (string, error) + func (g *OpenAIGenerator) GenerateBounded(ctx context.Context, prompt string, maxTokens int) (string, error) + func (g *OpenAIGenerator) GenerateJSON(ctx context.Context, prompt string) (string, error) + func (g *OpenAIGenerator) GenerateJSONSchema(ctx context.Context, prompt, name string, schema any) (string, error) + func (g *OpenAIGenerator) Model() string + type Principal struct + UserID int64 + Write bool + type PromptFunc func(text string, hints ExtractHints) string + type QueryOpts struct + Category string + CreatedAfter *time.Time + CreatedBefore *time.Time + IDs []int64 + Kind string + Limit int + MetadataFilters []MetadataFilter + Namespaces []string + OnlyActive bool + Subject string + Subsystem string + type ReadableStore interface + ActiveCount func(ctx context.Context) (int64, error) + Breakdown func(ctx context.Context) (FactBreakdown, error) + BySubject func(ctx context.Context, subject string, onlyActive bool) ([]Fact, error) + Exists func(ctx context.Context, content, subject string) (bool, error) + Get func(ctx context.Context, id int64) (*Fact, error) + GetLink func(ctx context.Context, linkID int64) (*Link, error) + GetLinks func(ctx context.Context, factID int64, direction LinkDirection, ...) ([]Link, error) + History func(ctx context.Context, id int64, subject string) ([]HistoryEntry, error) + List func(ctx context.Context, opts QueryOpts) ([]Fact, error) + ListSubsystems func(ctx context.Context, subject string) ([]string, error) + Search func(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + SearchBatch func(ctx context.Context, queries []string, opts SearchOpts) ([][]SearchResult, error) + SearchFTS func(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + Touch func(ctx context.Context, ids []int64) error + func ReadOnly(r ReadableStore) ReadableStore + type RerankMode string + const RerankBalanced + const RerankDominant + const RerankGate + const RerankOff + func ParseRerankMode(s string) (RerankMode, error) + func (m RerankMode) Enabled() bool + type RerankPolicy struct + Candidates int + DocBytes int + Mode RerankMode + RecallCandidates int + RecallDocBytes int + Threshold float64 + func RerankPolicyFromEnv(prefix string) (RerankPolicy, error) + type RerankStats struct + Dropped int + TopDropped float64 + type SQLiteStore struct + func NewSQLiteStore(db *sql.DB, embedder embedding.Embedder, namespace string) (*SQLiteStore, error) + func (s *SQLiteStore) Abandon(ctx context.Context, id int64, reason string) error + func (s *SQLiteStore) ActiveCount(ctx context.Context) (int64, error) + func (s *SQLiteStore) BackfillDetectScores(ctx context.Context, limit int) (int, error) + func (s *SQLiteStore) BlockedFacts(ctx context.Context, limit int) ([]BlockedFact, error) + func (s *SQLiteStore) Breakdown(ctx context.Context) (FactBreakdown, error) + func (s *SQLiteStore) BySubject(ctx context.Context, subject string, onlyActive bool) ([]Fact, error) + func (s *SQLiteStore) Close() error + func (s *SQLiteStore) Confirm(ctx context.Context, id int64) error + func (s *SQLiteStore) Defer(ctx context.Context, id int64, reason string) error + func (s *SQLiteStore) Delete(ctx context.Context, id int64) error + func (s *SQLiteStore) DeleteLink(ctx context.Context, linkID int64) error + func (s *SQLiteStore) DetectScore(ctx context.Context, id int64) (int, error) + func (s *SQLiteStore) DetectWithheldCount(ctx context.Context) (int, error) + func (s *SQLiteStore) EmbedFacts(ctx context.Context, batchSize int) (int, error) + func (s *SQLiteStore) Exists(ctx context.Context, content, subject string) (bool, error) + func (s *SQLiteStore) FactChunks(ctx context.Context, id int64) ([]FactChunk, error) + func (s *SQLiteStore) Get(ctx context.Context, id int64) (*Fact, error) + func (s *SQLiteStore) GetLink(ctx context.Context, linkID int64) (*Link, error) + func (s *SQLiteStore) GetLinks(ctx context.Context, factID int64, direction LinkDirection, ...) ([]Link, error) + func (s *SQLiteStore) History(ctx context.Context, id int64, subject string) ([]HistoryEntry, error) + func (s *SQLiteStore) Insert(ctx context.Context, f Fact) (int64, error) + func (s *SQLiteStore) InsertBatch(ctx context.Context, facts []Fact) error + func (s *SQLiteStore) LinkFacts(ctx context.Context, sourceID, targetID int64, linkType string, ...) (int64, error) + func (s *SQLiteStore) List(ctx context.Context, opts QueryOpts) ([]Fact, error) + func (s *SQLiteStore) ListSubsystems(ctx context.Context, subject string) ([]string, error) + func (s *SQLiteStore) MarkEmbedFailed(ctx context.Context, id int64, reason string) error + func (s *SQLiteStore) NeedingEmbedding(ctx context.Context, limit int) ([]Fact, error) + func (s *SQLiteStore) PendingFacts(ctx context.Context, limit int) ([]screening.PendingFact, error) + func (s *SQLiteStore) ReadableFor(Principal) (ReadableStore, error) + func (s *SQLiteStore) RecordInjection(ctx context.Context, ids []int64) error + func (s *SQLiteStore) ReleaseFact(ctx context.Context, id int64) error + func (s *SQLiteStore) Resolve(ctx context.Context, id int64, d screening.Decision) error + func (s *SQLiteStore) ScreenCounts(ctx context.Context) (map[ScreenState]int, error) + func (s *SQLiteStore) Search(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + func (s *SQLiteStore) SearchBatch(ctx context.Context, queries []string, opts SearchOpts) ([][]SearchResult, error) + func (s *SQLiteStore) SearchFTS(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + func (s *SQLiteStore) SetDetectModes(write, read ScreenDetectMode) + func (s *SQLiteStore) SetDetectReadScore(n int) + func (s *SQLiteStore) SetDetectScoreForTest(ctx context.Context, id int64, score int) error + func (s *SQLiteStore) SetEmbedCeiling(n int) + func (s *SQLiteStore) SetEmbedding(ctx context.Context, id int64, emb []float32) error + func (s *SQLiteStore) SetFactVectors(ctx context.Context, id int64, v FactVectors) error + func (s *SQLiteStore) SetInlineRejectScore(score int) + func (s *SQLiteStore) SetReranker(rr embedding.Reranker) + func (s *SQLiteStore) SetScreenMode(m ScreenMode) + func (s *SQLiteStore) Supersede(ctx context.Context, oldID, newID int64) error + func (s *SQLiteStore) TermDocCounts(ctx context.Context, terms []string) (map[string]int, int, error) + func (s *SQLiteStore) Touch(ctx context.Context, ids []int64) error + func (s *SQLiteStore) UpdateLink(ctx context.Context, linkID int64, label string, metadata map[string]any) error + func (s *SQLiteStore) UpdateMetadata(ctx context.Context, id int64, patch map[string]any) error + func (s *SQLiteStore) WritableFor(p Principal) (WritableStore, error) + type ScreenDetectMode string + const ScreenDetectAllow + const ScreenDetectBlock + const ScreenDetectWarn + func ParseScreenDetectMode(s string) (ScreenDetectMode, error) + type ScreenMode string + const ScreenModeGate + const ScreenModeObserve + const ScreenModeOff + func ParseScreenMode(s string) (ScreenMode, error) + type ScreenState string + const ScreenAbandoned + const ScreenBlocked + const ScreenClean + const ScreenGrandfathered + const ScreenPending + const ScreenRegexClean + const ScreenScreening + type SearchOpts struct + AllNamespaces bool + Category string + CategoryDecay map[string]time.Duration + CreatedAfter *time.Time + CreatedBefore *time.Time + DecayHalfLife time.Duration + FTSWeight float64 + Kind string + MaxResults int + MetadataFilters []MetadataFilter + Namespaces []string + OnlyActive bool + RerankCandidates int + RerankDocBytes int + RerankMode RerankMode + RerankStats *RerankStats + RerankThreshold *float64 + RerankWeight float64 + Subject string + Subsystem string + VecWeight float64 + type SearchResult struct + Combined float64 + FTSScore float64 + Fact Fact + RerankScore float64 + VecScore float64 + func ScoreResults(ctx context.Context, rr embedding.Reranker, query string, ...) ([]SearchResult, error) + type SessionStore interface + GetPendingHints func(ctx context.Context, sessionID, cwd string) ([]ContextHint, error) + MarkHintConsumed func(ctx context.Context, hintID int64) error + RecordFeedback func(ctx context.Context, fb ContextFeedback) error + RecordInjection func(ctx context.Context, sessionID, refID, refType string, rank int) error + SaveHook func(ctx context.Context, payload []byte) error + SaveTurns func(ctx context.Context, sessionID string, turns []SessionTurn) error + StoreHint func(ctx context.Context, hint ContextHint) (int64, error) + WasInjected func(ctx context.Context, sessionID, refID, refType string) (bool, error) + type SessionTurn struct + CWD string + Content string + CreatedAt time.Time + Role string + SessionID string + TurnIndex int + UUID string + type SessionUserScoper interface + ForUser func(userID int64) (SessionStore, error) + type Store interface + ActiveCount func(ctx context.Context) (int64, error) + Breakdown func(ctx context.Context) (FactBreakdown, error) + BySubject func(ctx context.Context, subject string, onlyActive bool) ([]Fact, error) + Close func() error + Confirm func(ctx context.Context, id int64) error + Delete func(ctx context.Context, id int64) error + DeleteLink func(ctx context.Context, linkID int64) error + EmbedFacts func(ctx context.Context, batchSize int) (int, error) + Exists func(ctx context.Context, content, subject string) (bool, error) + FactChunks func(ctx context.Context, id int64) ([]FactChunk, error) + Get func(ctx context.Context, id int64) (*Fact, error) + GetLink func(ctx context.Context, linkID int64) (*Link, error) + GetLinks func(ctx context.Context, factID int64, direction LinkDirection, ...) ([]Link, error) + History func(ctx context.Context, id int64, subject string) ([]HistoryEntry, error) + Insert func(ctx context.Context, f Fact) (int64, error) + InsertBatch func(ctx context.Context, facts []Fact) error + LinkFacts func(ctx context.Context, sourceID, targetID int64, linkType string, ...) (int64, error) + List func(ctx context.Context, opts QueryOpts) ([]Fact, error) + ListSubsystems func(ctx context.Context, subject string) ([]string, error) + MarkEmbedFailed func(ctx context.Context, id int64, reason string) error + NeedingEmbedding func(ctx context.Context, limit int) ([]Fact, error) + Search func(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + SearchBatch func(ctx context.Context, queries []string, opts SearchOpts) ([][]SearchResult, error) + SearchFTS func(ctx context.Context, query string, opts SearchOpts) ([]SearchResult, error) + SetEmbedding func(ctx context.Context, id int64, emb []float32) error + SetFactVectors func(ctx context.Context, id int64, v FactVectors) error + Supersede func(ctx context.Context, oldID, newID int64) error + Touch func(ctx context.Context, ids []int64) error + UpdateLink func(ctx context.Context, linkID int64, label string, metadata map[string]any) error + UpdateMetadata func(ctx context.Context, id int64, patch map[string]any) error + type StoreScoper interface + ReadableFor func(p Principal) (ReadableStore, error) + WritableFor func(p Principal) (WritableStore, error) + type TermCounter interface + TermDocCounts func(ctx context.Context, terms []string) (counts map[string]int, totalDocs int, err error) + type UserScoper interface + ForUser func(userID int64) (Store, error) + type WhoAmIResponse struct + Allows []string + Authenticated bool + Name string + Scopes []string + Source string + type WritableStore interface + Confirm func(ctx context.Context, id int64) error + Delete func(ctx context.Context, id int64) error + DeleteLink func(ctx context.Context, linkID int64) error + Insert func(ctx context.Context, f Fact) (int64, error) + InsertBatch func(ctx context.Context, facts []Fact) error + LinkFacts func(ctx context.Context, sourceID, targetID int64, linkType string, ...) (int64, error) + Supersede func(ctx context.Context, oldID, newID int64) error + UpdateLink func(ctx context.Context, linkID int64, label string, metadata map[string]any) error + UpdateMetadata func(ctx context.Context, id int64, patch map[string]any) error v0.2.0 Feb 18, 2026 v0.1.0 Feb 16, 2026