Skip to content

doctor.sh's SessionEnd arm FAILs on a healthy install that has prior Claude Code history, and displaces the fresh-install remediation #392

Closed

Description

@fdaviddpt

Found by the round-one release audit of v0.22.0..HEAD before tagging 0.23.0, measured against v0.22.0 on identical fixtures. Two defects in the same arm; one lane fixes both.

Symptom

1. A healthy install reads as problem. The SessionEnd FAIL condition -- one transcript quiet for more than 900s and no session-end-*.log -- is satisfied by a plugin installed today into a project that already had Claude Code history. Nothing in the check establishes that the plugin was installed when those transcripts ran, so SessionEnd could not have fired for them.

Measured both directions (probe reused tests/test_doctor_session_end_370.py's own _project/_run/_backdate helpers, three transcripts backdated 3 days):

fixture v0.22.0 HEAD
fresh install, prior CC history, nothing captured VERDICT: problem -- PostToolUse has never fired; restart Claude Code (see REMEDIATION above) VERDICT: problem -- SessionEnd has never fired despite prior sessions ending in this project
healthy capture, no session ended yet VERDICT: capture is working -- last save 2026-08-28 11:42:42 VERDICT: problem -- SessionEnd has never fired ...

Row 1 is the arm displacing the correct, actionable remediation for a fresh install. Row 2 is a demonstrably healthy install reading as problem for a guaranteed window: every upgrading user with prior project history sees it until their first post-install session ends.

2. An unreadable mtime is counted but never measured. _file_age_seconds returns empty on an unreadable mtime (its own contract, scripts/doctor.sh:249). The SessionEnd loop increments _SE_TRANSCRIPT_COUNT for such a file and then continues past the staleness question, so the WARN asserts $_SE_TRANSCRIPT_COUNT transcript(s) ... none quiet long enough to call finished -- a claim about files whose quietness nobody established.

Location

scripts/doctor.sh:341-372 (the loop and the FAIL condition), composed with the verdict ladder at scripts/doctor.sh:679-712. The unreadable-mtime path is scripts/doctor.sh:346-356.

The same file already renders the third state correctly 60 lines above, at scripts/doctor.sh:285:

WARN PostToolUse marker present but its age could not be read

so the convention exists in this file and this block did not adopt it.

Mechanism

Only quietness is measured. The sentence "despite prior sessions ending" is a claim about session lifecycle that the check never establishes -- a quiet transcript predating the install is indistinguishable from one whose session ended while the hook was installed and failed to fire.

This is the composition of two commits that could not see each other: 206e151 (#370) argued this arm's position against a ladder 49c1647 (#359) was concurrently reordering, and row 2 above is specifically the new arm outranking capture is working.

It also contradicts the acceptance criterion written in the delta's own test docstring, tests/test_doctor_session_end_370.py:29-33:

the "just installed" and "mid-first-session" shapes -> the third state ... A check that answered FAIL here would flag every fresh install as broken before it had ever had the chance to prove itself.

The fixtures operationalise "just installed" as 0-or-1 transcript, which covers only a project with no prior Claude Code history. test_one_stale_transcript_alone_is_enough_to_fail pins the mechanism; nothing distinguishes a transcript that predates the install.

What would settle it

Whether an install-time baseline exists that the check can compare a transcript's mtime against. If none does, the FAIL needs a precondition it can actually observe -- and if no such precondition exists, the honest answer may be that this arm can only ever WARN, which is a legitimate outcome to argue for.

Both fixtures in the table above belong in the suite, each paired with its "must fire" control: the genuine never-fired case must still FAIL, or the fix has removed the check rather than corrected it.

Activity

  1. added
    priority:high
    on Aug 28, 2026
  2. self-assigned this
    on Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions