postgres

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

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

func Open(ctx context.Context, dsn string, dims int) (*Store, error)

Open connects to Postgres, ensures the schema exists for the given embedding dimensionality, and returns a ready Store.

func (*Store) Close

func (s *Store) Close() error

Close releases the connection pool.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, namespace, id string) error

Delete removes a memory by ID.

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) DeleteNamespace added in v0.0.8

func (s *Store) DeleteNamespace(ctx context.Context, namespace string) (int64, error)

DeleteNamespace removes every memory in a namespace. Returns the number of memories deleted.

func (*Store) Get

func (s *Store) Get(ctx context.Context, namespace, id string) (*memory.Memory, error)

Get returns a memory by ID.

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 and expired rows are excluded so a dead duplicate never absorbs a fresh write.

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) 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) ListNamespaces

func (s *Store) ListNamespaces(ctx context.Context) ([]string, error)

ListNamespaces returns the distinct namespaces holding memories.

func (*Store) Ping

func (s *Store) Ping(ctx context.Context) error

Ping verifies the database is reachable.

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) 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.

func (*Store) SetMetrics

func (s *Store) SetMetrics(m store.Metrics)

SetMetrics installs an observability sink. Passing nil disables metrics.

func (*Store) SetSuperseded

func (s *Store) SetSuperseded(ctx context.Context, namespace, id, supersededBy string) error

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

func (s *Store) Upsert(ctx context.Context, m *memory.Memory) error

Upsert inserts or replaces a memory. Returns ErrConflict when the ID already exists under a different namespace.

func (*Store) VectorSearch

func (s *Store) VectorSearch(ctx context.Context, namespace string, vec []float32, f store.Filter, k int) ([]store.Scored, error)

VectorSearch returns the k nearest live memories to vec in the namespace.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL