Two gaps, both test-side. No production behaviour changes here: the
branches were already correct, they were simply unpinned, so a later edit
could have broken them silently.
1. Crash-time states the hook header's TTL discussion anticipates and no
test exercised: a partially written marker (valid prefix, no close - what
an interrupted printf leaves), a marker with no runId, a marker whose
runId is empty or not a string, and malformed ledger lines. All must
ALLOW, because a marker we cannot read cannot say which run we are in,
and a half-written ledger line is not a spent turn. One test pins the
other direction too: skipping bad lines must not mean skipping the run's
tombstone.
2. The marker snippet is now RUN, not asserted about. Every existing pin on
the marker lifecycle (tests/lib/doc-consistency.test.mjs) is a substring
assertion on prose, so a snippet emitting invalid JSON or writing to a
path the hook never reads would keep the whole suite green while the hook
allowed everything - the failure S82 had to find by hand with a
scratchpad probe. Three tests now extract the real ```bash blocks from
commands/trekresearch.md and execute them with CLAUDE_PLUGIN_DATA
stripped and HOME sandboxed:
- the write snippet lands parseable JSON at the exact path the hook
looks up, with runId and a Date.parse-able startedAt;
- an empty CLAUDE_CODE_SESSION_ID produces NO `.json` marker and says
the cap stays inert;
- write snippet -> real hook denies -> removal snippet -> real hook
allows, which is the writer/reader agreement end to end.
On the non-string runId: it clears the falsy guard and then matches no
ledger record, so the run reads as 0 turns and is allowed. Allow is correct
either way and no writer emits one, so that stays a pin on the outcome
rather than an argument for a type guard on an unreachable state.
Review finding 823d8c28d7c993717606433fd6711d5a67877967 (MINOR).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LuGhWAbWyRFBFeemfhxoVv