Skip to content

The #373 delivery-record sweep can delete a live session's record, because a session's transcript does not exist yet when the hook runs #393

Closed

Description

@fdaviddpt

Found by the round-one release audit of v0.22.0..HEAD before tagging 0.23.0.

Symptom

With handoff_mode: "per_session", one session starting can delete another, still-live session's remember.delivered.<session_id> record. The live session's delivery counter then resets, and a handoff it has already been shown reads as a first delivery.

Location

scripts/session-start-hook.sh:1057-1067 -- the sweep added by #373. Its coupling is stated in its own comment at scripts/session-start-hook.sh:1030-1040: transcript absent under $SESSIONS_DIR implies the session is gone.

The same file states the opposite at scripts/session-start-hook.sh:100-108, load-bearing for #270:

at source=startup Claude Code creates that transcript AFTER this hook has run

Mechanism

Between a session writing its delivery record (scripts/session-start-hook.sh:1012) and Claude Code creating that session's transcript, a live session is indistinguishable from a dead one by the only signal the sweep consults. Any other session starting inside that window deletes the live session's record. The self-skip at scripts/session-start-hook.sh:1063 protects only the current invocation, not a concurrent one.

test_record_for_a_session_with_no_transcript_is_pruned proves the deletion fires on exactly this shape -- the test is correct, the coupling is what is too coarse.

The cost is bounded and is not data loss: the record is bookkeeping, and remember.<session_id>.md survives by design (#221). What is lost is the counter's accuracy, which is the whole point of #341's work in the same delta.

What would settle it

Whether the record's own mtime can arbitrate: a record younger than the startup window is not evidence of a dead session, whatever the transcript says. If that holds, the sweep gains a third state it currently lacks -- pruned, kept because the transcript exists, and kept because the record is too young to judge.

A test needs two sessions: one whose record is fresh and whose transcript does not exist yet (must not be pruned) paired against one whose record is old and whose transcript is gone (must be pruned).

Activity

  1. added
    priority:medium
    on Aug 28, 2026
  2. self-assigned this
    on Aug 28, 2026
  3. added 2 commits that reference this issue 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:medium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions