Backward, tail and hydrate pages now take each header's sent size and current
submission size from the bounded header query, admit whole sequence groups by
those sizes, and only then load the admitted bodies and submissions. An
oversized lone group becomes placeholders without decoding its bodies. Forward
pages pick the longest event prefix whose touched rows fit by the same sizes
before the existing replay builder reads current rows. The roster finds each
unnamed subagent's earliest visible naming row through one indexed lookup per
id instead of scanning every naming row.
The sent-size column and the subagent-name relation are a new migration body
for the central migration list; item writers call the bounds write after each
upsert.
Replace the staging reducer conversion and its generic table/column export
with a one-way domain import. A reader restores the copied legacy source with
the existing pure interpretation, reading in short statements with no
transaction spanning the restore, and returns bounded typed pages (items,
tombstones, aliases, attempts, receipts, queue cards, provider activity).
The writer inserts each page through its named statement keyed by restored
identities, so an interrupted import resumes idempotently. The chat head is
written last and is the ready mark: a ready chat never reads its frozen
source again, and the source watermark compare and retry loop are gone.
Queue cards live in one row per chat/epoch/message, updated in place. A
content or state change advances the row revision; edit holds name that
revision instead of copying body, fingerprint, state or consumed attempt.
Moves read only ordering headers and update only positions, returning
placements. Queued admission provenance is a column on the attempt,
backfilled from the exact named former card version (missing => not
personal), so card versions and source-card columns are removed.
Queue insert, edit, hold, withdraw and move now select the addressed current
card rows, apply the existing queue policy and copy-replace card versions in
the caller's writer transaction, with one sequence and replay event per
producing command. Order is a typed position column with message-id ties;
replaced versions stay only while a submission attempt names them, and
withdraw/edit retire their edit leases in the same transaction.
Domain schema v2 adds the history metadata the reader selects on (hidden, root,
subagent row/group, named subagent IDs, turn marker), backfilled once from saved
v1 payloads; every message upsert writes it from the merged current item.
Tail/before/hydrate pick a bounded newest-first header window (the existing
2x limit reach, counted over every row so sparse-root chats stay bounded,
completing the boundary sequence group) before decoding bodies. Forward
catch-up selects an ordered event window, resets below the pruned cursor or
across a gap, and returns current rows and current submissions for the touched
identities. All reads share one reader snapshot.
Adds latestPrompt, restartProgress and outgrownChild named reads on both
journal backends. Each answers from one reader snapshot: the newest root
user prompt through the existing user-prompt index, the logical epoch with
sends accepted after a cursor, and child sign-out evidence (input rejection
or a root status at the child's execution fence) with the newest turn end
and the next send's message body. Callers are converted separately.
The provider-started settlement chose running root turns on the producer and
handed a stale selection to the lifecycle batch. A writer command now reads the
unsettled population at its write position, filters running root turns at the
child fence other than the live turn, and plans the interruption there, on both
the in-memory and SQL writers. The settlement id and undefined-live-turn no-op
are unchanged.
A result whose reading a Stop changes writes both readings as one
stop-decided resolution; the writer checks the saved Stop at its position,
keeps one and reports which. The result and plugin-input failure paths share
it, and the producer no longer reads persisted Stop state.
The reserved conversation's aliases, attempts, roster and goal are read once
under the attach lock before spawn, and the attempt sink follows them. An
epoch replacement holds reading from the tick it reaches the writer until the
new epoch's actual facts are adopted, so later events never classify against
stale saved evidence.
Agent rows record their producer, tool-call alias and attempt beside the
row, so an acquisition snapshot reads aliases, attempts and the roster
without decoding bodies. The projection version bump reconverts chats.