pg: Gateway conversations on Postgres #105

Closed
opened 2026-10-27 13:34:58 +00:00 by sam · 0 comments
Owner

Move internal/gateway session store (sessions, messages, turns; conversationDBPath) to the Postgres server in a schema the Gateway owns, keeping the rule that the daemon and Gateway never own the State Store's tables.

Notes

2ic ruling (approved): Preserve current turn-recovery semantics and support a single serving Gateway only. Hold a PostgreSQL advisory serve-ownership lock for the full Gateway serving lifetime; fail startup if another Gateway holds it. Do not let RecoverTurns mark another live process owner failed. Multi-Gateway lease/adoption semantics are out of scope and need a separate design.
2ic clarification: retain nanosecond timestamp behavior in the existing cursor contract for this migration by refusing import on any source/target ordered-ID mismatch; no event-id renumbering or schema widening without collision evidence and a separate decision.
From 7r0x.9: when the Gateway opens its Postgres pool in production, claim serve ownership with postgres.AcquireOwnership(ctx, pool, 'gateway') held for the process life and released at orderly shutdown (2ic ruling on 7r0x.9). The State Store wiring in internal/app/archied/state_store_pool.go is the pattern.

Close reason

Closed


Imported from beads archie-core-7r0x.5 · GitHub #1016 · type task · priority P1 · created 2026-09-23 · closed 2026-09-28

Move internal/gateway session store (sessions, messages, turns; conversationDBPath) to the Postgres server in a schema the Gateway owns, keeping the rule that the daemon and Gateway never own the State Store's tables. ### Notes 2ic ruling (approved): Preserve current turn-recovery semantics and support a single serving Gateway only. Hold a PostgreSQL advisory serve-ownership lock for the full Gateway serving lifetime; fail startup if another Gateway holds it. Do not let RecoverTurns mark another live process owner failed. Multi-Gateway lease/adoption semantics are out of scope and need a separate design. 2ic clarification: retain nanosecond timestamp behavior in the existing cursor contract for this migration by refusing import on any source/target ordered-ID mismatch; no event-id renumbering or schema widening without collision evidence and a separate decision. From 7r0x.9: when the Gateway opens its Postgres pool in production, claim serve ownership with postgres.AcquireOwnership(ctx, pool, 'gateway') held for the process life and released at orderly shutdown (2ic ruling on 7r0x.9). The State Store wiring in internal/app/archied/state_store_pool.go is the pattern. ### Close reason Closed --- _Imported from beads `archie-core-7r0x.5` · GitHub #1016 · type task · priority P1 · created 2026-09-23 · closed 2026-09-28_
sam added the hightask labels 2026-10-27 13:34:58 +00:00
sam self-assigned this 2026-10-27 13:34:58 +00:00
sam closed this issue 2026-10-27 13:34:58 +00:00
sam added a new dependency 2026-10-27 13:41:43 +00:00
sam added a new dependency 2026-10-27 13:41:43 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#105