postgres

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmbeddingConfig

type EmbeddingConfig struct {
	Dimensions int
	Model      string
}

EmbeddingConfig controls the vector schema created for Postgres-backed stores.

type PostgresStore

type PostgresStore struct {
	// contains filtered or unexported fields
}

PostgresStore implements storage.Store backed by PostgreSQL plus pgvector.

func Open

func Open(dsn string, cfg EmbeddingConfig) (*PostgresStore, error)

Open creates a new PostgresStore and ensures the schema exists.

func (*PostgresStore) AddAuditEntry

func (s *PostgresStore) AddAuditEntry(ctx context.Context, id string, entry schema.AuditEntry) error

func (*PostgresStore) AddRelation

func (s *PostgresStore) AddRelation(ctx context.Context, sourceID string, rel schema.Relation) error

func (*PostgresStore) Begin

func (*PostgresStore) ClaimUnextractedEpisodics

func (s *PostgresStore) ClaimUnextractedEpisodics(ctx context.Context, limit int) ([]string, error)

ClaimUnextractedEpisodics atomically claims up to limit episodic records for semantic extraction and returns their record IDs.

func (*PostgresStore) CleanStaleExtractionClaims

func (s *PostgresStore) CleanStaleExtractionClaims(ctx context.Context, olderThan time.Duration) error

CleanStaleExtractionClaims deletes in-flight claims older than olderThan.

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

Close closes the underlying database connection.

func (*PostgresStore) Create

func (s *PostgresStore) Create(ctx context.Context, rec *schema.MemoryRecord) error

func (*PostgresStore) Delete

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

func (*PostgresStore) FindSemanticExact

func (s *PostgresStore) FindSemanticExact(ctx context.Context, subject, predicate, object string) (*schema.MemoryRecord, error)

FindSemanticExact retrieves a semantic record by exact subject-predicate-object match.

func (*PostgresStore) Get

func (*PostgresStore) GetRelations

func (s *PostgresStore) GetRelations(ctx context.Context, id string) ([]schema.Relation, error)

func (*PostgresStore) GetTriggerEmbedding

func (s *PostgresStore) GetTriggerEmbedding(ctx context.Context, recordID string) ([]float32, error)

GetTriggerEmbedding retrieves the stored embedding for a record.

func (*PostgresStore) List

func (*PostgresStore) ListByType

func (s *PostgresStore) ListByType(ctx context.Context, memType schema.MemoryType) ([]*schema.MemoryRecord, error)

func (*PostgresStore) MarkEpisodicExtracted

func (s *PostgresStore) MarkEpisodicExtracted(ctx context.Context, recordID string, tripleCount int) error

MarkEpisodicExtracted marks a claimed episodic record as fully processed.

func (*PostgresStore) ReleaseEpisodicClaim

func (s *PostgresStore) ReleaseEpisodicClaim(ctx context.Context, recordID string) error

ReleaseEpisodicClaim clears an in-flight extraction claim so the episode can be retried.

func (*PostgresStore) Reset

func (s *PostgresStore) Reset(ctx context.Context) error

Reset deletes all stored records and embeddings. Intended for tests and local evaluation flows.

func (*PostgresStore) SearchByEmbedding

func (s *PostgresStore) SearchByEmbedding(ctx context.Context, query []float32, limit int) ([]string, error)

SearchByEmbedding returns record IDs ordered by cosine distance ascending.

func (*PostgresStore) StoreTriggerEmbedding

func (s *PostgresStore) StoreTriggerEmbedding(ctx context.Context, recordID string, embedding []float32, model string) error

StoreTriggerEmbedding stores or updates a trigger embedding for a record.

func (*PostgresStore) Update

func (s *PostgresStore) Update(ctx context.Context, rec *schema.MemoryRecord) error

func (*PostgresStore) UpdateSalience

func (s *PostgresStore) UpdateSalience(ctx context.Context, id string, salience float64) error

Jump to

Keyboard shortcuts

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