The gateway's session, authority, delivery and hosted-room modules call the interface operations instead of SessionDB and their own connections. The cron owner fake builds its authority on an interface handle, and the legacy cron run-history cases read the owner's store through a SessionDB of their own. The legacy tests whose cases the backend copies carry (journal mode, profile purge and rekey, owner reset housekeeping) go; the remaining legacy tests of these callers follow the moved names.
Review fixes for session.transcript:
- A store without a pooled reader (not WAL, a read-only handle, a reader
that failed to open, the pool's ceiling) pinned nothing, and its
consistency check was always true: a row deleted between the page read
and the cursor-state read stayed in the client forever (reset: false).
transcript_read_snapshot now checks there that no write landed in the
database during the block (_write_generation: the writer connection, its
total_changes for this process's writes and PRAGMA data_version for
every other connection's commits), holding no lock across the block.
_poll reads once more when one did; when the retry also overlaps a
write, the reply is reset: true with the first page and a cursor state
no transcript has, so the next poll resets again. The pooled path is
unchanged. The yielded check gains .pinned.
- page_handoffs deduplicated a handoff only within the current window, so
two carriers holding the same uid-less handoff each showed it once the
window moved past the first (also limit 1, oldest order). A handoff is
now shown before the first row in the whole transcript that holds it: a
rotated lineage checks the rows before the window it already read; one
segment asks the new SessionDB.transcript_handoffs_shown_before for the
display rows before the window's first slot.
Tests: tests/gateway/test_session_transcript_handoff_owner.py (seeded
transcripts with identical uid-less handoffs on several carriers, re-wraps,
in-place compactions and rotations: every limit 1-5, both orders, equals
the full read; two identical uid-less carriers, limit 1 and 2, both
orders). tests/gateway/test_session_transcript_snapshot.py: append-then-
clear and delete-during-page, each pooled and without a pooled reader; a
read that never settles resets twice, then converges.
tests/hermes_state/test_transcript_read_snapshot.py: without a pooled
reader a write from this process or another connection makes the block
inconsistent.
Review fixes for session.transcript (all behind SessionDB methods now):
- One read generation per poll. The cursor check, the page and the state the
next cursor stores are read in one read transaction
(SessionDB.transcript_read_snapshot: _read_ctx hands the thread's pinned
pooled reader to every nested read). Before, a row appended after the poll
started could land on the page and be deleted (clear_messages moves neither
the inactive count nor transcript_revision) before the state was sampled;
the cursor then certified the post-deletion state while the reader held the
deleted row, and later polls answered reset: false forever. A store without
a pooled reader (not WAL, read-only, pool ceiling) is not pinned, so a write
from inside can never wait on its own lock.
- transcript_cursor_state's live count spans the whole displayed lineage: the
segment's own rows up to the cursor, plus every live row of its earlier
segments. Deleting an earlier segment's rows now resets a poller, as its
reactions already did.
- limit bounds the rows sent, compaction rows included. A row's handoffs and
the row can fall on two pages; the cursor then names the row and how many
of its group were sent (a third key part), so no handoff is dropped or
sent twice, both orders, several handoffs on one carrier included.
- Storage interface: every new store read is a narrowly named SessionDB method
in one module, hermes_state_stored_reads.py (was
hermes_state_transcript_cursor.py; hermes_state_display_set.py folds in as
_display_set / _with_removed_identities, the worker calls the latter as on
main): transcript_read_snapshot, transcript_segment_page (with the cursor
slot and durable-id lookups), transcript_tool_calls_before,
sessions_in_workspace, picker_session_facts, session_current_segments,
subagent_session_ids. get_messages and _fetch_conversation_rows gain their
port lines. The gateway and tool modules keep their function names.
Tests: tests/gateway/test_session_transcript_snapshot.py (append+delete during
a page read; an earlier segment's deletion and, separately, its reaction;
limit 1 and 2 across a carrier with two handoffs, oldest and latest) and
tests/hermes_state/test_transcript_read_snapshot.py (one generation inside a
snapshot; a DELETE-journal store is not pinned). One consistency test's first
page now ends at the handoff, which counts toward limit.
session.transcript becomes the one stored-transcript read; session.compactions
and subagent.transcript never ship.
- Forward polling: an oldest-order cursor is never null. It also holds the
segment it read and transcript_cursor_state of the rows it covered; while
both hold, the next read continues after it (reset: false, only appends).
An in-place compaction, a rotation, a rewind, or a rewrite or deletion of a
covered row answers reset: true from the first page. The stored state is
read between two snapshots around the page read, and a non-append change in
between reads the page again. A page is empty only when caught up (windows
that project to nothing are read past). Latest order keeps its relocating
cursor and ends with a null cursor.
- An oldest-order page continues at the next display slot instead of
filtering by durable id, which is not monotonic in display order (a
handoff's new row sits before the carried copies of older messages).
- Every row carries row_kind: "message" (the session.resume display row) or
"compaction" (a handoff at its position: role system, the readable summary
as text, compacted_messages, timestamp, row_id). Older handoffs on earlier
copies of a re-wrapped or unwrapped carrier still show, each once
(SessionDB.transcript_handoff_rows).
- subagent_id reads a delegated child of session_id with the ownership rule
from #140477 (running: the parent's live roster; finished: the _subagent_id
marker and a lineage of delegate-child or compression hops). The reply adds
subagent_id, available, running and child_session_id; a foreign or unknown
child is available: false with no rows, a null cursor and reset: true.
- runtime.describe advertises session-transcript-v1 and
session-list-picker-v1.
- Contracts, OpenRPC/TS and the serve handler ledger regenerated; docs
updated. Storage-interface port names on every new or changed SessionDB
method.
Tests: the stored-read suites move to the one method (resets where a
compaction lands between pages, handoffs as rows); new poll tests drive
appends, compaction, rotation, rewind and rewrites between polls, plus a
seeded random sequence checked against a fresh read after every poll. The
subagent ownership, lineage, multiplex-scope and live E2E tests are adapted
from #140477 to session.transcript with subagent_id.