Repository navigation
Conversation
PostToolUse's alive-marker check answers "how old is the marker", which only makes sense because that hook fires many times inside a live session. SessionEnd fires at most once per session, so that reading does not transfer -- and until now doctor.sh said nothing about SessionEnd at all, so a user whose SessionEnd hook is unregistered or dying before it forks saw the same "capture is working" verdict as one whose last-chance flush actually runs. No new marker is introduced. session-end-hook.sh already leaves usable evidence of its own accord -- a logs/autonomous/session-end-*.log file, written unconditionally by its own background flush once it gets past its SAVE_SCRIPT-missing check -- and doctor.sh now reads that instead of inventing a second signal. Three states: fired (OK, at least one such log exists); never fired despite evidence a prior session has ended, i.e. 2+ transcripts in this project's Claude Code session directory (FAIL, and it now outranks the generic "capture is working" verdict -- a healthy PostToolUse must not mask a broken SessionEnd); and no session has had the chance to end yet (WARN, renders as neither of the other two). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…liveness (#370) Self-review turned up a false-positive in the first cut: counting *.jsonl files in the project's Claude Code session directory as "a prior session ended" breaks the moment two Claude Code windows are open on the same project at once -- an ordinary workflow, not a broken install, and it was producing a hard FAIL/VERDICT: problem for it. Replaced the count with a staleness check: a transcript other than the one currently growing has to have gone quiet for over 15 minutes before it counts as evidence a session ended. A currently-open window keeps touching its own transcript far more often than that, so two live windows no longer false-positive, while a genuinely finished session still does after the grace period. False negatives here only delay a real FAIL; false positives were the actual failure mode. Also: added coverage for the transcript-count boundary at exactly one file (fresh and stale), and folded the new check into doctor.sh's own top-of-file capture-health description, which the first commit left unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Aug 28, 2026
fdaviddpt
added a commit
that referenced
this pull request
Aug 28, 2026
…ss check (#390) (#391) PR #387 (closing #370) gave scripts/doctor.sh a second liveness check, for SessionEnd, alongside the existing PostToolUse one. README.md's Diagnostics section still described only the PostToolUse check, drafted before #387 landed and blocked at the time because #382 held README.md. Both PRs have since merged; verified the wording against the merged doctor.sh (three states, and "has ever fired" correctly describes the log-presence check rather than a transcript count) before applying it unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #370.
What
/remember:doctor(scripts/doctor.sh) had a detailed alive-marker check forPostToolUsebut said nothing aboutSessionEndat all, so a user whoseSessionEndhook is unregistered, dying before it forks, or simply never invoked by Claude Code on an undocumented exit path (crash, killed terminal) saw the exact same "capture is working" verdict as a user whose last-chance flush actually runs.PostToolUse's freshness-window reading (how old is the marker) doesn't transfer toSessionEnd, which fires at most once per session. No new marker is introduced anywhere:session-end-hook.sh(untouched by this PR) already leaves usable evidence of its own accord -- alogs/autonomous/session-end-<HHMMSS>.logfile, written unconditionally by its own existing background flush once it gets past itsSAVE_SCRIPT-missing check.doctor.shnow reads that.Three states, not two:
PostToolUsemust not mask a brokenSessionEnd.The staleness threshold (not a raw transcript count) is deliberate: an earlier cut of this fix counted
*.jsonlfiles and treated two-or-more as proof a session had ended, which two ordinary, simultaneously open Claude Code windows on the same project also produce with nothing broken. Self-review (anExploreagent against the committed diff) caught this as a real false-positive with a reproduction; it's fixed in a second commit, along with two smaller findings (a stale file-header description, and a missing test for the exact-one-transcript boundary).Tests
tests/test_doctor_session_end_370.py, 7 tests, one per state plus positive controls for each FAIL/WARN pairing and a VERDICT-ladder-ordering test. Full suite (pytest) run green twice (before and after the self-review fix): 1673 passed, 43 skipped, 0 failed.Docs
README.md's "## Diagnostics" section (docs_targets) also describes what/remember:doctorprints and should gain a mention of the new SessionEnd check. That file is held by open PR #382 (fix/369) and was not touched here -- exact replacement text is in this PR's companion agent report (blocked), for whoever lands it.Below-bar finding from review
The auditor separately flagged that
scripts/doctor.sh's DESCRIPTION header undersold what the tool checks even before this PR (only ever mentioned PostToolUse) -- fixed here as part of the same header update, so nothing is left below-bar from this diff.Co-Authored-By: Claude Opus 5 (1M context) [email protected]