Documentation
¶
Index ¶
- type Store
- func (s *Store) Close() error
- func (s *Store) Delete(ctx context.Context, namespace, id string) error
- func (s *Store) DeleteIfExpiredBefore(ctx context.Context, namespace, id string, cutoff time.Time) error
- func (s *Store) DeleteLink(ctx context.Context, src, dst string) (bool, error)
- func (s *Store) DeleteNamespace(ctx context.Context, namespace string) (int64, error)
- func (s *Store) EmbedModel(ctx context.Context) (string, error)
- func (s *Store) Get(ctx context.Context, namespace, id string) (*memory.Memory, error)
- func (s *Store) GetByFingerprint(ctx context.Context, namespace string, tier memory.Tier, fingerprint string, ...) (*memory.Memory, error)
- func (s *Store) KeywordSearch(ctx context.Context, namespace, query string, f store.Filter, k int) ([]store.Scored, error)
- func (s *Store) List(ctx context.Context, namespace string, f store.Filter, limit int) ([]*memory.Memory, error)
- func (s *Store) ListAllLinks(ctx context.Context) ([]store.NamespaceLink, error)
- func (s *Store) ListExpired(ctx context.Context, now time.Time, limit int) ([]*memory.Memory, error)
- func (s *Store) ListLinks(ctx context.Context, src string) ([]store.NamespaceLink, error)
- func (s *Store) ListNamespaces(ctx context.Context) ([]string, error)
- func (s *Store) MarkContradicted(ctx context.Context, namespace, id, contradictedBy string, confidence float64, ...) error
- func (s *Store) NamespaceActivity(ctx context.Context, now time.Time) ([]store.NamespaceActivity, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PredecessorIDs(ctx context.Context, namespace, id string) ([]string, error)
- func (s *Store) PutLink(ctx context.Context, l store.NamespaceLink) error
- func (s *Store) Reassign(ctx context.Context, fromNS string, ids []string, toNS string) (int64, error)
- func (s *Store) Reinforce(ctx context.Context, namespace string, ids []string, accessedAt time.Time, ...) error
- func (s *Store) RenameLinkEndpoints(ctx context.Context, from, to string) error
- func (s *Store) Restore(ctx context.Context, namespace, id string) error
- func (s *Store) Retier(ctx context.Context, namespace, id string, tier memory.Tier, ...) error
- func (s *Store) SetConfidence(ctx context.Context, namespace, id string, confidence float64, now time.Time) error
- func (s *Store) SetEmbedModel(ctx context.Context, model string) error
- func (s *Store) SetMetrics(m store.Metrics)
- func (s *Store) SetSuperseded(ctx context.Context, namespace, id, supersededBy string) error
- func (s *Store) Upsert(ctx context.Context, m *memory.Memory) error
- func (s *Store) VectorSearch(ctx context.Context, namespace string, vec []float32, f store.Filter, k int) ([]store.Scored, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a Postgres/VectorChord backed store.Store.
func Open ¶
Open connects to Postgres, ensures the schema exists for the given embedding dimensionality, and returns a ready Store.
func (*Store) DeleteIfExpiredBefore ¶
func (s *Store) DeleteIfExpiredBefore(ctx context.Context, namespace, id string, cutoff time.Time) error
DeleteIfExpiredBefore removes a memory only if its expiry is still at or before cutoff. Returns ErrNotFound when the memory is absent or its TTL was slid past cutoff by Reinforce since the last ListExpired call.
func (*Store) DeleteLink ¶ added in v0.6.6
DeleteLink removes the link from src to dst. The bool reports whether a link existed to delete.
func (*Store) DeleteNamespace ¶ added in v0.0.8
DeleteNamespace removes every memory in a namespace, plus any namespace_links row that references the namespace on either side (gap G5: a deleted namespace must not leave a dangling link). Returns the number of memories deleted.
func (*Store) EmbedModel ¶ added in v0.3.9
EmbedModel returns the recorded embedding model name, or "" if none was set.
func (*Store) GetByFingerprint ¶ added in v0.2.9
func (s *Store) GetByFingerprint( ctx context.Context, namespace string, tier memory.Tier, fingerprint string, now time.Time, ) (*memory.Memory, error)
GetByFingerprint returns the most recent live memory in namespace+tier whose content fingerprint matches. Superseded, expired, and validity-closed (contradicted) rows are excluded so a dead duplicate never absorbs a fresh write — re-asserting a contradicted fact must store a live row, not corroborate the invalidated one.
func (*Store) KeywordSearch ¶
func (s *Store) KeywordSearch(ctx context.Context, namespace, query string, f store.Filter, k int) ([]store.Scored, error)
KeywordSearch returns the k best full-text matches in the namespace.
func (*Store) List ¶
func (s *Store) List(ctx context.Context, namespace string, f store.Filter, limit int) ([]*memory.Memory, error)
List returns memories in a namespace matching f (without embeddings).
func (*Store) ListAllLinks ¶ added in v0.6.6
ListAllLinks returns every link in the store, ordered by Src then Dst.
func (*Store) ListExpired ¶
func (s *Store) ListExpired(ctx context.Context, now time.Time, limit int) ([]*memory.Memory, error)
ListExpired returns up to limit memories whose TTL has passed.
func (*Store) ListLinks ¶ added in v0.6.6
ListLinks returns the links whose Src is src, ordered by Dst.
func (*Store) ListNamespaces ¶
ListNamespaces returns the distinct namespaces holding memories.
func (*Store) MarkContradicted ¶ added in v0.5.6
func (s *Store) MarkContradicted(ctx context.Context, namespace, id, contradictedBy string, confidence float64, now time.Time) error
MarkContradicted invalidates a durable fact a newer write contradicts. The SET expressions read the pre-update confidence column (Postgres evaluates the right-hand side against the old row), snapshotting it into metadata for audit and reversal before overwriting it.
func (*Store) NamespaceActivity ¶ added in v0.6.6
func (s *Store) NamespaceActivity(ctx context.Context, now time.Time) ([]store.NamespaceActivity, error)
NamespaceActivity implements store.ActivityStore: one aggregate query for per-namespace live count and most recent created_at. Liveness reuses filterClause with an empty Filter so it stays byte-identical to what a default List applies (not expired at now, not superseded, validity window not closed).
func (*Store) PredecessorIDs ¶ added in v0.4.19
PredecessorIDs returns the IDs of memories in the namespace superseded by id.
func (*Store) PutLink ¶ added in v0.6.6
PutLink inserts or replaces the link keyed by (l.Src, l.Dst).
Unlike memory Put (created_at is immutable after insert), an upsert here overwrites created_at. This is intentional, not an oversight: links carry no recency semantics that a stable created_at would protect, and import restore relies on the overwrite being conditional on l.CreatedAt being non-zero (below) so it can replay a link's original creation time instead of stamping "now".
func (*Store) Reassign ¶ added in v0.0.11
func (s *Store) Reassign(ctx context.Context, fromNS string, ids []string, toNS string) (int64, error)
Reassign moves memories from fromNS to toNS. The fts column is generated and the vector index lives on the same row, so a single namespace UPDATE suffices. IDs absent from fromNS are not matched; IDs are globally unique so a move never collides in toNS.
func (*Store) Reinforce ¶
func (s *Store) Reinforce(ctx context.Context, namespace string, ids []string, accessedAt time.Time, newExpiry *time.Time) error
Reinforce bumps access_count/last_accessed_at and optionally slides the TTL.
func (*Store) RenameLinkEndpoints ¶ added in v0.6.6
RenameLinkEndpoints rewrites every link whose src_ns or dst_ns equals from to to instead. When a rewritten link collides with a pre-existing row at its new key, the pre-existing row is kept and the renamed link dropped (ON CONFLICT DO NOTHING): the target namespace's own explicit grant wins over an inherited one, so a rename can never silently widen or narrow tier access the target had already configured. The SELECT is ordered by (src_ns, dst_ns) so which renamed link survives a multi-way collision (e.g. the reciprocal pair link(from,to)+link(to,from) collapsing onto (to,to)) is deterministic: the first row in key order wins. A no-op when from == to.
func (*Store) Restore ¶ added in v0.4.12
Restore clears superseded_by/valid_to so a tombstoned memory is live again.
func (*Store) Retier ¶ added in v0.0.11
func (s *Store) Retier(ctx context.Context, namespace, id string, tier memory.Tier, expiresAt *time.Time) error
Retier changes a memory's tier and expiry in place. Tier and expiry live only in the memories row (fts is generated from content, the vector index is on the same row), so no reindex is required.
func (*Store) SetConfidence ¶ added in v0.0.11
func (s *Store) SetConfidence(ctx context.Context, namespace, id string, confidence float64, now time.Time) error
SetConfidence updates a memory's confidence and bumps updated_at to now. Confidence lives only in the memories row, so no reindex is needed. Validity-closed rows are skipped (ErrNotFound): corroboration must never regrow an invalidated fact, even when MarkContradicted lands between the caller's read and this write.
func (*Store) SetEmbedModel ¶ added in v0.3.9
SetEmbedModel records the embedding model the stored vectors were produced with.
func (*Store) SetMetrics ¶
SetMetrics installs an observability sink. Passing nil disables metrics.
func (*Store) SetSuperseded ¶
SetSuperseded records that a memory was replaced by supersededBy, stamping valid_to at the moment of supersession (unless already set) so a time-filtered recall can still surface the fact for the window it held.
func (*Store) Upsert ¶
Upsert inserts or replaces a memory. When m.Embedding is empty the row is stored with a NULL embedding (keyword index still written) — the write path used when embedding generation is unavailable; any other length must equal the store's dims. Returns ErrConflict when the ID already exists under a different namespace.