d5d7cab2b6
When /compress rotates the session, the handler repointed the live session entry onto the new (empty) continuation session_id and _save()d that BEFORE writing the compressed transcript — and rewrite_transcript swallowed DB write failures at DEBUG. A transient write failure (SQLite lock under concurrent writes, ENOSPC, disk/IO error) left the session pointing at an empty id while the handler still reported a cheerful 'Compressed: N → M' success. The active conversation vanished from view. - gateway/session.py: rewrite_transcript now returns bool (True on write success or no-DB, False on canonical write failure). /retry, /undo, and yuanbao recall ignore the result, so their behavior is unchanged. - gateway/slash_commands.py: _handle_compress_command persists the compressed transcript FIRST and treats a write failure as fatal (raises into the outer handler's 'compress failed' banner). Only repoints + _save()s the session on a successful write. Widened beyond the original rotation case to also cover in-place compaction (#38763): a failed in-place write would otherwise leave the DB untouched while still reporting success. - tests: regression tests for both the rotation and in-place write-failure paths — assert a failure banner, unchanged session_id, and no _save(). Co-authored-by: Hermes Agent <agent@nousresearch.com>