jeevesagent.memory.postgres_facts

Postgres + pgvector FactStore.

Schema (created by init_schema()):

  • facts(id, subject, predicate, object, confidence, valid_from, valid_until, recorded_at, sources, embedding vector(N)) with optional HNSW index on embedding (only when an embedder is configured at construction time — the dimension is fixed in the column type).

The vector(N) dimension is locked at table-creation time. Switching embedders later requires migrating the table.

Lazy asyncpg + pgvector.asyncpg imports inside connect() mirror the pattern in memory.postgres.

Classes

PostgresFactStore

Postgres-backed bi-temporal fact store.

Module Contents

class jeevesagent.memory.postgres_facts.PostgresFactStore(pool: Any, *, embedder: jeevesagent.core.protocols.Embedder | None = None)[source]

Postgres-backed bi-temporal fact store.

async aclose() None[source]
async all_facts() list[jeevesagent.core.types.Fact][source]
async append(fact: jeevesagent.core.types.Fact) str[source]
async append_many(facts: collections.abc.Iterable[jeevesagent.core.types.Fact]) list[str][source]
classmethod connect(dsn: str, *, embedder: jeevesagent.core.protocols.Embedder | None = None, min_size: int = 1, max_size: int = 10) PostgresFactStore[source]
Async:

async init_schema() None[source]
async query(*, subject: str | None = None, predicate: str | None = None, object_: str | None = None, valid_at: datetime.datetime | None = None, limit: int = 10, user_id: str | None = None) list[jeevesagent.core.types.Fact][source]
async recall_text(query: str, *, limit: int = 5, valid_at: datetime.datetime | None = None, user_id: str | None = None) list[jeevesagent.core.types.Fact][source]
schema_sql() list[str][source]

Return the DDL for this fact store’s schema.

Exposed so tests can assert on the SQL strings, and so migration scripts can apply the schema in their own transaction.

property embedder: jeevesagent.core.protocols.Embedder | None