Review follow-ups on the sessions list:
- min_message_count was applied to the compression ROOT before the walk to
its tip, so a root that rotated before its first flush (0 messages) hid its
populated tip. The floor now admits a compression-ended row when any
continuation in its lineage meets it (same continuation edge as the list
CTE; the recursive EXISTS runs only for compression rows under the floor).
The reference backend's filter follows the same lineage rule.
- The tip-title inheritance lookup bound every ancestor id in one IN (...);
six 180-deep chains exceed a 999-variable SQLite build. It now goes
through _id_chunks.
- `--all` dropped every exclusion except `tool`; it now lists every source.
- Gateway `/sessions` leaves cron runs out of its recents/search page, as
#140273 proposed; pinned listings are unchanged.
Co-authored-by: hbtjm9000 <260822553+hbtjm9000@users.noreply.github.com>
Bare `hermes sessions` printed argparse help. On a terminal it now opens the
existing `browse` picker (arrows + Enter resumes via `hermes --resume <id>`);
off a terminal it prints the list.
`hermes sessions list` ranked root rows by started_at and cut the page before
projecting compression tips. A cron tick writes a `local-<sha>` row every run
(most stay empty, untitled: "—"), so the newest-started rows were all cron and
every compacted human thread, whose root started days ago, fell off the page.
List and browse now use the Desktop recents shape: rank lineages by their
tip's last message (order_by_last_active), drop zero-message rows, and leave
out automated sources (cron, webhook, push, kanban, tool, oneshot). `--all`
or an explicit `--source` brings them back. Subagent children stay out.
A projected tip with no title of its own fell back only to the root's title;
it now takes the nearest titled segment of its lineage (a thread titled after
its first rotation carries the title on a middle segment).
FooteredReply was one of six str subclasses whose __new__ needs more
than the text. Python's default copy/pickle rebuild calls
cls.__new__(cls, text), so copy.deepcopy of any payload holding one
raised TypeError. The gateway deep-copies every published event
payload, which is how a footered reply lost its message.complete
(#156709, #156824) and how an active-session refusal lost it before
(a5d3c25664, which fixed only that one class).
Give each remaining class a __getnewargs_ex__ returning its real
constructor arguments (TimelineNotification, _ConsentRefusal, _Miss,
_ProbeFailure, BacktrackResend), and replace the per-class test with
one AST invariant over the whole tree, so a new subclass of this
shape fails CI instead of a live turn.
The owner stamps each turn with the label its connection announced
(`surface_v1.client`). That label names the connection, not the request: an
app updated between a send and its retry announces another version, and a
reconnect may not have said hello yet. Including it in the digest turned such
a retry into `admission_conflict`.
`retry_input` (beside `admission_fingerprint`) drops the stamp, and an empty
`surface_v1` with it, from the input the admission digest covers. It is used
wherever the store computes that digest: admit, the retired-target retry, and
the two re-keying writes (rehome, automation retarget), plus the in-memory
reference backend, so every backend keeps one definition. The stored payload
keeps the stamp, so the first row's label is the one kept. A payload without
a stamp is digested exactly as before, so existing rows keep their digests.
Any other difference (text, a HUD surface) is still a conflict.
Nine Python gates each re-declared `^[a-z0-9][a-z0-9_-]{0,63}$` instead of using
`hermes_constants.PROFILE_ID_RE`: the `-p` pre-parse, the gateway's session-key
parser, lock-owner and home labels, the SSH spawn argument, saved SSH
`remoteProfile`, service/launchd profile names, the session store's own-profile
derivation and the profile segment of the public `<profile>:<platform>` status
key. Five Desktop files did the same instead of the exported
`profile-id-guard.ts::PROFILE_ID_ARG_RE` (`DESKTOP_PROFILE_NAME_RE` is now
derived from it). A change to the owner would have left each copy accepting the
old set.
Each gate now reads the owner at call time. Accepted and refused names, the
`default`/`main`/`main~` aliases and the platform-segment grammar are unchanged:
a 23-input corpus over all nine Python gates and a real `hermes -p` run give the
same output on base and head. Same-shaped grammars for other identifiers
(peer names, case-insensitive remote handles, webhook names, s6 service names,
kanban slugs, plugin names) are deliberately left alone.
New guards swap the owner for a different grammar and assert every gate
follows it (Python: tests/hermes_cli/test_profile_id_grammar_owner.py; Electron:
apps/desktop/electron/profile-id-guard.test.ts); both fail on the base code.
Refs #155595 (state-24).
A WAL snapshot failed at once with "database is locked" when it met
another connection rebuilding the WAL index: sqlite3's backup loop
retries only plain SQLITE_BUSY/LOCKED, so the extended
SQLITE_BUSY_RECOVERY (261) ended the copy as an error, and the progress
callback compared the unmasked status, so the 10 s busy deadline never
applied. Mask the status and restart the one-step backup on a busy
error until that same deadline, in both hermes_cli/backup_sqlite.py and
persistence/sqlite/admin/_backup.py. Still fails closed past the
deadline; never copies the main file alone.
referenced_archive_refs read at most 20,001 rows and answered "unknown"
past 20,000, and the sweep then kept every file in cache/pruned and
cache/spillover. Every prune stub row counts toward that number, so a
busy home passed it and was never swept again.
Rows are now read one at a time with no cap; memory is bounded by the
reference set. Any database error still answers "unknown", so the sweep
still fails closed. Below the old cap the cost is unchanged (the filter
has no index, so the whole table was already scanned). Past it the read
used to stop at the 20,001st match and now runs to the end, so on a
large home it stays open longer. The docs sentence about the cap is
removed.
(cherry picked from commit a5bed1d2d9fb436f6129388b237330a509abb6aa)
The checked reader ran its full-text index probes before the declared-schema probe, so a store that lags the schema and also has a broken full-text index failed on the index first. A gateway-owned store then got the generic "schema unavailable" 503 instead of the missing column and the gateway restart command, as on main. The reader now runs the drift probe first on the same connection, the order main's separate admin check had; a store at the current schema with a broken index is unchanged.
Co-authored-by: Bear Huddleston <bear@bearhuddleston.dev>
Every Desktop and dashboard session read opened state.db twice: an admin handle ran the declared-schema probe on a fresh connection, then the reader the read uses opened another. The read-only SessionDB browse the storage interface replaced ran that probe on its one reader connection, so each open and page read became about a third slower at the median.
open_persistence_reader gains check_drift, passed through the backend to the read-only holder the way patience_s is. With it, the holder's open runs the probe on its own connection and raises the core DeclarativeDrift with the reason StoreAdmin.schema_drift_reason gives; both now share one helper, declared_schema_drift. The browse open binds its reader with the check, and on drift runs the existing one-time catch-up and opens again, so a store that lags the declared schema is still caught up or refused by name exactly as before. A browse open's failures are reported in its 503 only and no longer reach the process's last session-store init error; main's browse wrote it only when its reader failed after the separate probe had passed.
Main's persistence interface makes the agent's store a storage handle with no
queue_token_counts; the warmer's keep-alive accounting called it on
agent._session_db directly and silently lost every refresh's usage. It now goes
through turn_usage.queue_usage, which takes the handle's usage repository (and
the worker store otherwise) with the session id and surface the keep-alive
captured when it was scheduled.
session's model_config, but the managed-worker sidecar allowlist only knew the
runway key. Every worker turn's runway clear (both keys) was refused as
invalid_params, which poisoned the worker store and failed the turn
(tests/gateway/test_surface_admission.py managed-worker case, CI 1/3).
Add the key to SIDECAR_KEYS; the worker-context test now restores and clears
both keys through the worker store.
Salvage of #136488 (kshitijk4poor), review findings from 100yenadmin and kvnloo.
- No information loss: before the proactive prune shortens a tool result, its
full original is written byte-verified to
$HERMES_HOME/cache/pruned/<session>_<UTC>_<tool>_<id>.<json|txt> and the stub
ends with " — full result: <path>", so read_file returns the exact output.
A result whose write fails stays whole and the reclaim gate is re-checked on
what is left (no commit -> the written files are removed).
- This also closes kvnloo's unflushed-original case without deferring the
prune: the original no longer depends on the store having seen the row.
- The running turn is never shortened: the post-tool site passes the turn's
user-row index (turn_start), and every row from it on is kept whole. Before,
the count-only tail let a long tool loop stub its own earlier calls.
- One sweeper: the spillover reference/retention machinery now covers
cache/pruned too (archive_refs_in_text / referenced_archive_refs; session
delete retires both). Pruned files follow sessions.retention_days and are
never deleted while state.db references them. cache/pruned is mounted for
sandboxed backends like cache/spillover, and the stub names the path the
backend sees.
- Cold-cache reading isolated in turn_proactive_prune.prompt_cache_is_cold so
the shared cache clock can replace it in one line.
- Two skill-safety fixtures pin the old 4096 reclaim gate (the shipped 64K
default made their ~7K-token transcripts no-ops).
From the final-head gate wave on b12ce8e275:
- Two openers that both saw the retired marker before rebuild admission each
ran the full rebuild in turn (about 130 s on a 1.35M-row store), because
the admitted callback did not re-check whether a peer had already
aligned. align_locked now re-reads the layout and the marker under
BEGIN IMMEDIATE and skips when there is nothing left to do. New test: the
opener admitted second runs no rebuild; red on b12ce8e275
(['second', 'first']).
- messages._display_set uses the shared sql_common._in_one_read instead of
its own copy of the same BEGIN/ROLLBACK wrapper.
- Docstrings corrected where they no longer matched the code: the probe's
IOERR may be persistent; _attribute_ranked_corruption raises it for a
replay; _fts_match_read publishes the unattributed error after the retry
budget; a writable write as well as a search detaches a damaged index;
the skip decision is re-read under the lock.
Second-model review of e468bba3ce: an exception's __context__ is not proof
that it came from the rank probe. A plain ranked-read IOERR raised while the
caller was handling an unrelated DatabaseError was treated as an exhausted
probe and latched that ambient error. The probe now raises _RankProbeIoerr,
an OperationalError (still retried by _read_retrying_ioerr) that carries the
corruption it was diagnosing, and only that type is restored after the
budget is spent.
Test: a plain ranked-read IOERR inside a handler for an unrelated corruption
error answers [] and latches nothing. Red on e468bba3ce.
The delta review of 6410cd3ca1 showed the probe re-raised every
OperationalError. "database is locked", "interrupted" or "no such function"
then replaced the bare SQLITE_CORRUPT, and the primary search route turned
it into an empty answer with nothing latched, where 5046fe2946 failed
closed. The probe now re-raises only disk I/O errors and keeps the original
error otherwise. An IOERR that outlasts the read retry budget restores the
unattributed corruption the probe was diagnosing (latched and raised)
instead of surfacing as the IOERR the search maps to [].
Test: a locked probe and a probe whose IOERR persists both leave
SQLITE_CORRUPT raised and latched, and only the IOERR case replays the read.
Both cases are red on 6410cd3ca1. The transient-IOERR test now asserts
exactly one failed probe.
Second-model review of 5046fe2946: the attribution probe caught every
DatabaseError, including a transient "disk I/O error" OperationalError, and
then returned the original bare SQLITE_CORRUPT. _read_retrying_ioerr retries
only IOERR, so it published the unattributed error to the storage-health
latch: the bug this PR fixes, reachable when index damage and the WAL
transition window coincide. The probe now re-raises OperationalError so the
holder replays the whole read.
Also from the gate wave:
- _in_one_read moves unchanged from stored_reads to sql_common, so search no
longer imports a private helper from the transcript module.
- The interrupted-realign test raises only after the FTS DDL, not after any
script the executor runs.
New test: a disk I/O error on the first probe replays the read, answers from
canonical rows and leaves storage ok. Red with the re-raise removed.
From the gate wave on 529797fa7c and BearHuddleston's re-review:
- The rank-only MATCH pins its snapshot through the existing
stored_reads._in_one_read instead of a local copy of the same
BEGIN/ROLLBACK wrapper.
- _migrate_misaligned_fts_source: one locked helper owns the population
recheck and the realign; the admitted callback is named instead of a
lambda returning an ignored value.
- New test: a realign interrupted after its DDL leaves the old index hit and
the retired marker in place, and the next open realigns. Red with the
BEGIN IMMEDIATE removed.
- Reopens in the realign tests assert FTS stays enabled instead of skipping.
- _search_messages_stale docstring narrowed to the Latin retries (Bear's
suggestion: a triggering CJK trigram failure still takes _search_cjk's
any-term fallback, as on main). The empty-store test no longer names a
savepoint.
From the gate wave and second-model review of 83d9fa65b3:
- A store whose FTS is detached now answers through one helper on the
triggering request and every later one: LIKE on the exact terms, then on
any term after a miss (CJK skipped, as the FTS OR-relaxed retry does). Before,
the triggering OR-relaxed request found a row the next identical request
did not. The primary-route detach returns that answer directly, which
removes the detached_before_retries flag.
- _mark_fts_detached owns the three in-memory flag writes shared by
writable fail-open, deferred admission, the cross-process stale refresh and
the read-only detach.
- Read-only detach: the warning and docstring no longer promise that the next
writable open repairs the index (nothing is persisted); they name the real
paths, a writable search or `hermes sessions optimize-storage`. The test
checks state_meta through a raw read-only connection instead of after a
writer open.
- Realign: the marker check is inlined with its rationale, the rebuild timer
starts inside do_align, and the warning states what is known (the marker
only pre-v3 releases write) instead of asserting the history.
- The injected-error latch test is named for what it injects.
From BearHuddleston's review of 8678b050ac (three inline patches):
- Realign: the unlocked message check only routes populated stores to
rebuild admission; the skip-rebuild decision, the DDL, any rebuild and the
marker removal now commit together under BEGIN IMMEDIATE. A peer insert
between the empty check and the old savepoint was indexed and then lost;
an interrupted rebuild now rolls back to the old index.
- Ranked MATCH: pin a read transaction for the rank-only route so the
diagnostic bm25 probe sees the same index generation as the failed read
(a peer rebuild in between otherwise let code 11 escape and latch a
healthy store). An existing transaction is left alone; the read-only
transaction is ended by ROLLBACK.
- Test: delete one cut tool row while the pre-v3 trigger is installed, so a
repair that only swaps triggers and keeps the old postings fails.
[Salvage: ported onto 83d9fa65b3 by kshitijk4poor; the _schema.py hunk was
re-applied by hand around the post-rebuild realign warning.]
Read-only handles (dashboard and TUI cross-profile browsing) cannot write
the stale breadcrumb, so _enter_fts_fail_open refused and the newly
index-scoped error propagated instead of answering from canonical rows.
Search now detaches FTS for that handle's own lifetime and serves LIKE,
leaving the persistent detach and the rebuild to the next writable open.
The pre-v3-marker realign now logs after the rebuild has run, with its
duration (130 s on a 1.35M-row / 8.9 GB store clone), instead of claiming a
rebuild before admission decides. A deferred open logs only the existing
deferral line.
The gate wave on 764c751 found that the `rescope` keyword threaded through
StoreHolder._read_all/_read_retrying_ioerr put FTS policy on the shared read
boundary, and that the diagnostic probe ran on a second pooled reader, after
the failing read had released its snapshot.
Search now owns one MATCH read (_fts_match_read) that runs inside
_read_retrying_ioerr's callback. It attributes a bare SQLITE_CORRUPT on the
rank-only route on the SAME connection before the error reaches the
storage-health latch. _holder.py is back to main, and both ranked call sites
share the read.
The genuine-corruption test now drives search_messages instead of the private
closure.
- Empty realigned store: the marker realign of a store with no messages runs
inside SAVEPOINT fts_align_empty; run its DDL through
_execute_ddl_script_transactional so executescript's implicit COMMIT no
longer ends the savepoint ("no such savepoint: fts_align_empty" on open).
- Trigram / OR-relaxed retry that detaches the indexes now answers the
triggering request from canonical rows (exact terms, then any term)
instead of returning an empty miss.
- _read_all passes rescope only when set, keeping the one-argument
_read_retrying_ioerr call shape other callers and test spies rely on.
- Rank detection compares against the rank-only ORDER BY constant instead
of a substring test on the SQL fragment.
Tests: empty-store reopen with the retired marker; trigram and OR-relaxed
retries return the stored row on the first request.
A dashboard search could take a whole profile's session storage down until restart
although state.db was intact (PRAGMA quick_check: ok).
FTS5 evaluates `ORDER BY rank` in a nested sorter statement and SQLite masks that
statement's error to the primary code, so index damage bm25 reports as
SQLITE_CORRUPT_VTAB (e.g. a posting whose _docsize row is gone) reached the read path as
bare SQLITE_CORRUPT. _read_retrying_ioerr published it before the search's existing
fail-open could run, it classified as structural, and the process-wide latch refused
every session.create/resume with storage_unavailable.
- StoreHolder._read_all/_read_retrying_ioerr take an optional `rescope` applied before
the storage-health latch. The ranked MATCH reads pass one that, only for bare
SQLITE_CORRUPT on a rank-ordered statement, re-asks the index alone (unsorted bm25
keeps the extended code). An index-scoped answer replaces the error, so the existing
fail-open answers from canonical rows and the error, if raised, maps to
SearchIndexCorrupt; anything else keeps the original and still fails closed.
- The zero-hit trigram retry now fails open like the other ranked routes.
- _migrate_misaligned_fts_source also realigns a store whose retired
fts_tool_full_content_high_water marker is back. A release before FTS storage v3
reopening a realigned store re-stamps it at MAX(id) and reinstalls id-gated triggers
whose 'delete' sends full content for tool rows the v3 rebuild indexed as the bounded
prefix; each such delete leaves the token cut at the boundary behind with no _docsize
row, which is the damage above.
Wire error codes are unchanged.
Main's backend holds the writer mutex helpers in one module beside the store; at this level that module is persistence/sqlite/_state/write.py, where _holder.py already imports them from.
F22 (sqlite-backend) added `from hermes_state_write import write_site, writer_mutex_until` to persistence/sqlite/authority/coordination.py while hermes_state_write.py still existed. The replayed removal commit deletes hermes_state_write.py and did not move that import, so at this level every import of the authority package raised ModuleNotFoundError: 25 of the 34 stand-in cases failed with it.
The import now names persistence.sqlite._state.write, the same objects _holder.py uses.
Proof: tests/test_hermes_state_standin.py at 1b486ca4e2: 25 cases fail on ModuleNotFoundError: No module named 'hermes_state_write'; with this change none does (the 6 left are F20's TypeError, fixed next). tests/scripts/test_check_backend_imports.py 30 passed both ways. Import-only check of the module passes; ruff clean.
The removal gave the backend's dbfile module its own copy of hermes_cli.backup.is_zeroed_sqlite_file, because the backend does not import hermes_cli.backup, and the test that kept the copy equal to backup's went with the old store's parity tests. So the detector existed twice, plus the header probe is_zeroed_state_db falls back on, and a fix to the live-connection guard or the header test had to land in both copies. The function now lives once in sqlite_support, the neutral SQLite helper module both sides already import, moved from hermes_cli/backup.py unchanged; backup.py and the backend import it from there, and the backend's copy goes. is_zeroed_state_db keeps main's fallback probe for the case where the detector raises.
The new case checks that the backend, the backup and sqlite_support name the same function; it fails before this commit. Greptile raised the duplicate in review.
hermes_state.py becomes the stand-in plugins import, the rest of the legacy store and its test folder go, and the per-process modules the backend imported from main move under persistence/sqlite/_state/. The backend checks PID namespaces and lease holders through process_identity and its WAL setup through sqlite_support, and its error module takes the shared predicates and classification from storage_errors, so neither helper set has a second copy. The backend, sqlite_support.py and the tests that pin those modules reach their final imports, and the backend-import guard allows no file outside persistence/. The modules no caller imports any more go with it: the agent's onboarding rules (now in session_rules) and gateway/session_admission.py.
The stand-in's SessionDB releases its store on close() and, used again afterwards, opens it again with a warning, as the old class reopened its connection, unless the file at its path was replaced or the store is latched corrupt; a read-only one raises. A close during a call releases the store when the call returns. A named source wins over a source list in its session listing and count.
An agent given a writable stand-in SessionDB as session_db= and no persistence= takes the store handle that SessionDB forwards to as its persistence, so its turn flush, token counts, compression and session row writes go through the storage interface, as an agent given the old SessionDB wrote through it.
The backend-import guard also holds the backend's remaining reads of the process or task home, each with its reason, and refuses any other and any import of the stand-in inside persistence/sqlite/.
Plugin context engines get the agent's store as persistence= beside the deprecated session_db=, in each hook whose signature accepts that keyword, including the rebind after /new, /resume and /branch, and the context engine guide and the plugin guide's replacement table name it. A test fails once the running release reaches the stand-in's removal release, listing what goes with the stand-in.
release_unheld_media and collect_unheld_api_images take a store only: their SessionDB branches, which no caller reaches, go with the gateway's own copies of the admission and transcript queries.
The policy snapshot again carries the thread's user message that a retained non-pass turn.settled names as its source, and never one from another thread, as main's checkpoint does. The SQLite backend and the reference backend read the source in the merge, the protocol docstring states it, and two contract cases pin it on every backend.
The bounded-settlement upgrade cases seed through the store fixture and the checkpoint on the interface.
The spillover reader behind session auto-prune opens a read-only StoreHolder. It already waits in connect_tracked while close_all_under closes the home's header probes, but the holder's identity record then read the application id through _pread_db_range, which opened and cached a new probe fd for the path the sweep had just released. That probe outlived the reader and stayed until the next sweep or exit.
A read-only holder never runs the write-path replacement checks that compare against the recorded id, so it now takes the id from its own connection (PRAGMA application_id) and leaves the probe cache alone. Writer holders keep the lock-safe raw header read.
Two SQLite handles serve one store while they share one holder: the registry hands every handle on a profile the same holder for the file's current generation, and a handle opened after state.db was replaced takes a new one while the older handle keeps the generation it held, as main's registry identity check compares its objects. SQLiteStore.serves_same_store compares holders, and the assembly's Persistence forwards it between the stores the two handles are bound to. A handle opened after the file was replaced reads the replacement and does not serve the same store as the owner; red without the method (the case raises AttributeError), green with it.
Reported-by: Greptile
Reported-by: BearHuddleston
_ledger_setup took the process-wide setup lock and the holder's writer lock with bare with blocks, and its deadline covered only the retry loop: a long write elsewhere held the setup, and every ledger verb behind it, with no bound. Both locks are now taken against that deadline, the writer lock through writer_mutex_until as every write takes it, so a held lock refuses the setup with StoreContention, which the existing retry loop and callers already handle. A case holds the writer lock from another thread and asserts the setup refuses within the wait and runs nothing; it hung before the fix.
Reported-by: Greptile
Reported-by: unsupportedpastels
The four turn-lease verbs called self._store.holder() inside their write transaction to find the conversation key. After a profile sweep (close_all_under) cleared the holder's registry ownership, that call reacquired from the registry, which waits on the sweep's teardown, which waits on the write lock the transaction holds: a deadlock. Main's lease writes resolve nothing inside the transaction. Each verb now resolves the holder once before the write and the closure uses that object, so a sweep during the write completes after it. A case starts a profile sweep from inside the write of try_acquire, refresh and release, and asserts both finish; it hung before the fix (stopped by its recorded pid after 150 s) and passes after. The only other in-closure holder calls in the backend are the topic reads' lambdas in gateway/routing.py, which run outside any transaction.
Reported-by: Greptile
Reported-by: unsupportedpastels
Main's update_session_model writes gateway_runtime={**route, "model": model or None} (2fee28289b), so a resumed session pairs the switched provider with its model even after a fallback serving the first call rewrote the model column. The SQLite backend wrote the route without the model; it now writes main's patch, with main's comment, and the update_model contract case (model stamped, stale endpoint cleared) passes on SQLite.
Reported-by: alt-glitch
Reported-by: kshitijk4poor
Reported-by: teknium1
The interface's append and append_batch dropped compression_lock_holder, which fenced nothing: a live compression lock never blocks an ordinary append, on main as here. The SQLite backend's two verbs drop it too and stop passing it to the store-level append; the store helpers keep their own parameter for the compression writes that do check the lock. The contract case refusing the keyword now passes on SQLite.
Reported-by: kshitijk4poor
The interface's gate may now be a callable over owner memory, answered at the gate's fixed point inside the write, so a drain that began while the write waited on the writer still refuses it, as main's in-transaction guard does. The SQLite backend's three gate points (admit after the queue cap, claim after the epoch fence, bind_api after the epoch fence) now call raise_gate inside the write closure that _execute_write retries, so the callable is answered again on every busy retry. A decided GateRefusal or None behave as before.
Reported-by: kshitijk4poor
The SQLite ledger matches the contract: every in-flight filter on `async_delegations` (prune counts and deletes, the orphan sweep and its reads, the finished read, the in-flight read) and the worker delivery claim test `state='running'` or `state!='running'`, since no writer stores `finalizing`. The abandoned-delegation recovery parity case now expects the one running row recovered.
The compress mutation's rotation publishes a new live segment; the conversation's name now follows it onto that segment (_title_follows_head), as an automatic rotation's does, so the listing and the CLI keep showing it after a manual /compress.
The SQLite mutation's title write goes to the live tip of the addressed row's compression chain and reads the receipt's title there. A committed write adds every row of the lineage, and the row the uniqueness rule freed the name from, to the affected set, so each segment's revision advances. A clear empties every row of the lineage through the same title rules, so the hidden canonical Bot Chat's name refuses.
The plain-message branch of the listing preview SQL now left-trims the content before the 63-character head cut, as main's listing does, so leading whitespace no longer eats into the cut and every cut preview carries the ... marker.
The holder's state.db hardening now raises OSError(ELOOP) on a symlinked state.db, -wal or -shm instead of skipping it, so sqlite3.connect() never follows a planted link; a state.db link the operator made to a store of their own still opens. Modes are tightened through _chmod_pinned_inode, which never re-resolves the path to a swapped-in link. The registry judges the link with refuse_planted_state_db_link before resolve() hides it.
Main's fail-closed cases run against the holder, the registry and the backend's open.
The backend's begin_runtime_epoch now runs main's owner guard before the bump: while another process holds the profile's gateway.lock, the bump raises AuthorityRefusal('ownership_conflict', field='runtime_epoch') and the owner's epoch stays where it was. A reservation this process holds grants the bump, the flock decides rather than the lock record, and a store with no directory of its own never refuses.
Main's ownership cases run against the backend's runtime.begin_epoch.
The worker receipt's usage.main accepts prompt_cache_clock. The owner stamps its durable context generation (the archived-row count at commit) into a clock that decodes to a JSON object and re-encodes it compactly, inside the receipt transaction; any other text is stored as sent. The stamp is main's stamp_cache_generation, held beside the other receipt context operations.
The holder keys prompt_cache_clock like a route field, so queued deltas carrying different cache events apply in order and are never merged. The usage delta passes its clock to the token update, which writes the column only when a clock is given, with main's statement. The usage repository gains prompt_cache_clock (one statement: the stored clock, the resume fallback only for sessions whose cache counters are non-zero, and the archived-row generation, after draining the queue) and prompt_cache_generation, and the session record carries the column.
The sessions table gains the nullable prompt_cache_clock TEXT column after transcript_revision, as main's DDL has it, and the schema history records it as entry 33 with main's text. Existing stores gain the column through the declarative reconcile, and offline recovery now copies the same columns as main's.
The SQLite backend's copies take main's bodies: the session row counts, the runtime-ledger rows probe, the doctor's session count, the write-health snapshot source, the integrity check, the journal-mode read and the journal-mode switch open through hermes_cli.sqlite_safe_read.connect_tracked with tracking_path, so has_live_connection() and offline_file_access() see them before any raw byte probe. The readiness probe opens read_only_db_uri(path) through connect_tracked, so a profile path containing a reserved URI character opens the tracked file.
The offline opens main keeps raw (the restore staging copy, the preflight staged copy, the write-health temp snapshot and the downgrade-guard snapshot probe) carry main's HX015 waivers.
The store open's _home_bound and the on_session_delete dispatch in session_retention bound the store's profile home through the legacy set_hermes_home_override, which under a bound scope moves the whole scope (secrets and terminal policy with it) or refuses in a hosted one. Both now push the home alone with hermes_scope.push_state(home=...), keeping the bind condition and resetting the token afterwards, so the caller's scope stays its own.
The SQLite backend's backup copies take main's bodies: the read-only integrity query, the restore-epoch read and the restore destination open through hermes_cli.sqlite_safe_read.connect_tracked, so has_live_connection() sees them before any raw byte probe, and the header read uses the module-level import.
The SQLite backend's peer-recovery queries now exclude rows carrying _delegate_from unless the row is the chat's /new continuation (_reset_from) or a delegate the user resumed the chat onto (_chat_adopted), as main's store does. The session insert strips a delegate marker from a keyed /new continuation and from a config upserted onto a reset row, and a compression rotation carries _chat_adopted onto the new tip.
A chat's /new continuation (session_key and _reset_from set) that picked up _delegate_from is hidden from every session list while the gateway keeps routing into it. The SQLite backend's schema open now strips the stray marker, as main's store does, and indexes the healed rows' messages into the trigram index under the same rebuild-window rule as the triggers.
hermes_state_dbfile caches one O_RDONLY fd per state.db so the on-write header probe never closes a descriptor SQLite has locked, and nothing evicted those entries: a multiplexed gateway kept one fd for every profile it had unserved. close_all_under in persistence/sqlite/_registry.py now releases the probe fds under the swept home, never while another descriptor in the process holds the probe's inode: one descriptor scan per sweep under the paths' lifecycle locks, then an inode rescan inside offline_file_access before each close, so a tracked open through another pathname (a hard link) after the first scan keeps the probe. _path_is_under is hermes_state_common.path_is_under.
Tests: test_header_probe_release.py ports the SessionDB registry cases against the holder registry.
When every pooled read permit is out, StoreHolder._get_read_conn hands the read to the writer connection under the write lock, where it waits behind every in-flight write. The holder now reports it through hermes_state_readpool.note_read_pool_exhausted: one WARNING per database per window, counting the reads that degraded since the previous one, never SQL or parameters.
Tests: test_read_pool_exhaustion_warning.py ports the SessionDB cases against the holder.