NEXO 7.8.1 — v7.8 emergency-diary SID targeting closed
Published 2026-04-22. Patch release over v7.8.0.
v7.8.0 shipped the main compaction-continuity work: PostCompact as a real registered hook, exact SID via CLAUDE_SESSION_ID, per-conversation sidecar under $NEXO_HOME, fail-closed on mismatch, per-session event queue. Francisco audited the diff and flagged one residual hole: the Layer-2 emergency auto-diary and Layer-3 compaction_memory.record_auto_flush inside pre-compact.sh were still querying SELECT sid FROM sessions ORDER BY last_update_epoch DESC LIMIT 1 — the same "latest active session" anti-pattern that v7.8 had just eliminated from the main restore path. In multi-conversation Desktop that routinely wrote the emergency diary against the wrong conversation even when the main restore was already correct.
What v7.8.1 changes
- Both layers now use
TARGET_SIDalready resolved fromCLAUDE_SESSION_IDat the top of the hook. Same SID the checkpoint + sidecar + event emit use. - If
TARGET_SIDis missing or does not exist insessions, the Layer-2 block skips cleanly. Fail-closed: writing nothing is better than writing the diary against a different conversation. last_diary_tsis scoped bysession_idtoo — otherwise another conversation's recent diary would truncate this conv's mechanical summary window.
Behavioural tests, not just contract tests
v7.8.0 shipped source-contract tests (greps that pin strings). Francisco asked explicitly for multi-conv behavioural coverage. v7.8.1 adds two tests that drive the real shell script:
test_rail_pre_compact_emergency_diary_uses_target_sid_not_latestbuilds a fixture DB with two sessions, where the "latest active" belongs to a different conversation than the target. It then runsbash src/hooks/pre-compact.shwith a matchingCLAUDE_SESSION_IDand asserts the diary row carries the TARGET SID — not the latest.test_rail_pre_compact_emergency_diary_fail_closed_without_target_siddrives the same script withoutCLAUDE_SESSION_IDand asserts no diary row is written (fail-closed instead of falling back to latest).
The latent bash-escape bug we would have never caught otherwise
Adding the behavioural tests surfaced a subtle production bug: a Python comment inside the python3 -c "..." shell heredoc contained a phrase in double quotes (# not "latest active" which ...). Inside a bash double-quoted string, the inner " silently closed the argument early — so the entire Layer-2 Python block had been no-oping on the first hook run in production even though the source looked correct. The comment was reworded to remove any bash-meta characters inside the Python payload. The behavioural tests would fail noisily if this ever regresses.
No Desktop bump
Entirely Brain-side. Desktop v0.27.0 continues to ship.
Tests
Pytest: 2092 passing (+2 new behavioural). Ten unrelated pre-existing failures remain (darwin-only TTY / client-sync / doctor / evolution).
Related: full v7.8.1 changelog · v7.8.0 release notes · source on GitHub