fix(state): fail loudly when state.db is replaced under a live process

Detect same-inode cp via a generation stamp, halt FTS repair, and divert
unwritten transcripts to sessions/<id>.jsonl plus the gateway pending spool.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
rainbowgits
2026-08-18 20:54:14 +03:00
committed by Teknium
parent 5a264f9a58
commit 71256dfd01
7 changed files with 548 additions and 2 deletions
+1 -1
View File
@@ -752,7 +752,7 @@ def finalize_turn(
"health (`hermes doctor`), then send your message again"
)
# Machine-readable cause for the gateway/desktop: exactly
# 'session_persistence_failed:<locked|compression|turn_lease|corrupt|disk|unknown>'.
# 'session_persistence_failed:<locked|compression|turn_lease|corrupt|replaced|disk|unknown>'.
# Never clobber a failure_reason another path already stamped.
if "failure_reason" not in result:
_cause = getattr(agent, "_last_persistence_error_cause", None)