Create the turns table, the summary-lock table and their indexes. Call once at startup.
Recent turns, oldest → newest, capped at n (defaults to all retained).
Optionaln: numberClaim the right to summarise this session, fleet-wide.
One statement, so the check and the claim cannot interleave between processes: the
upsert only overwrites a row whose window has already elapsed, and RETURNING is empty
for the losers.
Postgres-backed hot session store (L1).
Pairs with PgVectorL2Store so both memory tiers live in a Postgres you already run, instead of adding Redis and a vector database. Takes an injected
pg-compatible client, so this package keeps no hardpgdependency.Redis gives TTL and list trimming for free; Postgres does not, so this store implements both explicitly:
expires_atcolumn. Reads filter on it and writes opportunistically delete the session's expired rows, so an abandoned session cannot accumulate forever with no background job scheduled.maxTurnsrows for that session, mirroring RedisLTRIM.Ordering uses a
bigserialrather than the timestamp, because two turns appended in the same clock tick would otherwise have no defined order, and prompt assembly depends on recent turns coming back oldest-first. Expiry is computed by the server (now() + make_interval(...)), never from the application clock, so retention does not depend on two machines agreeing on the time.Mirrors the Python
actrone_memory.l1.postgres_store.PostgresStoreand passes the same published conformance suite (actrone-memory/testing).