Repository navigation
Preserve the handoff until a replacement lands, and label re-deliveries (#221) - #222
Merged
Merged
Conversation
) SessionStart read remember.md and truncated it unconditionally, so any session that never writes a handoff back — a scheduled task passing through, a `claude -p` one-shot, an abandoned session — silently ate the note meant for the next human session. Detection was rejected: there is no signal for "this session will write a handoff back" (REMEMBER_NESTED_SUMMARIZER covers only the plugin's own child), and a guess wrong in the unsafe direction destroys data silently, which is the bug. Nothing is discarded until /remember overwrites the slot. Delivery is recorded instead, in remember.delivered (fingerprint, first delivery, count), so a re-delivered note is labelled as already delivered and pending replacement rather than reading as fresh forever. Co-Authored-By: Max <noreply>
fdaviddpt
added a commit
that referenced
this pull request
Aug 27, 2026
…ng each other's remember.md (#366) * feat: per-session handoff files stop interactive sessions from clobbering each other's remember.md (#363) Two interactive sessions sharing one project store (by design, even across worktrees, #56) both wrote the same fixed remember.md with no namespacing or locking, so the second /remember silently overwrote the first's handoff. Distinct from #221/#222, which protect a pending handoff from a session that never writes one back. Add `handoff_mode` ("single", default, unchanged; "per_session", keyed by the SessionStart payload's own session_id) so each session gets its own remember.<session_id>.md. The delivery record is namespaced the same way to avoid two sessions racing one fingerprint file. A per_session request with no usable session_id withholds the === HANDOFF === hint rather than silently pointing the /remember skill at the shared file under a mode the user believes is isolating them. No pruning ships with this change -- a stale per-session handoff is the user's own writing with no copy anywhere else. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP * fix: never withhold the HANDOFF hint on degrade -- it stays accurate (#363 review) The Explore review of the first commit caught a real regression: when per_session mode degraded to the shared file (no usable session_id), the hint was withheld outright -- including in external storage mode, where that shared path is still the one true handoff location. Withholding it there reintroduced the exact bug the external-mode hint exists to prevent: the /remember skill falling back to its own hardcoded, project-relative default instead of the real external path. The hint now always fires whenever it would have before (external mode, or a resolved per-session path), and a degraded per_session request adds a second, visible line saying the fallback happened, instead of either silence or a misleading absence. Tests, README, config.example.json and the changelog fragment updated to match; the old "withholds the hint" test is replaced with tests asserting the corrected path plus the presence/absence of the notice line (positive control). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FLHVEH4aeVK93939UYnfFP --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
The bug
scripts/session-start-hook.shemittedremember.mdand then truncated it, unconditionally, on everySessionStart:Correct only if every session that starts eventually calls
/remember. Plenty do not — a scheduled task whose prompt is read-only and has no reason to know this plugin exists, aclaude -pone-shot, a session abandoned before the handoff is written. Each passes through, consumes the note, leaves 0 bytes, and says nothing.Which option, and why the others lose
The report offered two directions. They are not equivalent.
(1) Detect the non-interactive session and skip the consume-clear. Rejected. There is no signal to detect.
REMEMBER_NESTED_SUMMARIZER(#202/#205) is a positive markerpipeline/haiku.pysets on the one child process this plugin spawns itself — checked inresolve-paths.sh, and it already correctly stops that child. An arbitrary scheduled task sets nothing, and nothing distinguishes it from a human at the momentSessionStartfires. Any detector is therefore a guess about who is starting the session, and a guess wrong in the unsafe direction destroys data silently — which is the bug.(2) Do not truncate until a replacement lands. Chosen. It needs no detection at all, so it cannot be wrong about who started the session.
/rememberwrites to this same path; the new content is what retires the old.The three failure modes, weighed
/remembersynthesis and was never spoken aloud, so the durable pipeline never saw it.Chosen: (2), with re-delivery labelled. Its cost is noise — a stale note may be re-emitted. That is the loud failure, and it is the one we want: it is visible, self-describing, and one
/rememberclears it.How infinite re-delivery is prevented from lying
A delivery record,
remember.delivered, sits beside the slot: content fingerprint (cksum, with a size fallback), first-delivery timestamp, delivery count. On session start:[already delivered N times since ‹ts› — no new handoff has been written since, so this is pending replacement, not news. You may already have acted on it. Running /remember replaces it.]The
=== LAST HANDOFF ===header is unchanged, so the position-first-in-output behaviour that survives context-preview truncation still holds. An emptied slot deletes the record, so a future handoff cannot inherit a stale label. A corrupt count degrades to 0 rather than erroring inside a hook documented never to block session startup.The note is never bounded off — it keeps being delivered while it is genuinely pending, honestly labelled, until a replacement retires it.
What I re-derived from the report and found different
The core mechanism holds exactly as reported. Two things did not survive as stated:
REMEMBER_NESTED_SUMMARIZER), and it is already wired throughresolve-paths.shfor all three hooks. It covers the plugin's own Haiku child, not scheduled tasks, so it does not fix SessionStart's handoff consume-clear silently destroys a pending remember.md when a scheduled/non-interactive task shares the project #221 — but the report's framing would have you build a detector from nothing, when the honest finding is that the existing detector is correct and structurally cannot be extended to arbitrary sessions. That is what makes (2) the right call rather than merely the convenient one.Everything the issue proposed as a dependency, flag or command to run was ignored on principle; the fix adds no dependency and runs nothing new (
cksumis POSIX, already assumed present everywhere else this plugin runs).TDD
Red — new tests against the unfixed hook:
The two that passed are the characterization tests —
test_fresh_handoff_replaces_the_old_one_and_is_delivered_onceandtest_empty_handoff_slot_emits_nothing. They pinned the ordinary interactive path before the implementation existed and still pass after it: a session receives its handoff,/rememberreplaces it, the next session gets the new one and never the old, and nothing is re-read forever. They were never red, and are not presented as such.Green — full suite:
tests/test_path_resolution.py::TestEdgeCases::test_handoff_consumed_after_session_startasserted the old destructive contract (remaining.strip() == ""). It is rewritten, not deleted, to the new one: content preserved,deliveries=1on record.Docs
CHANGELOG.mdunder## [Unreleased] / ### Fixed;README.md's handoff section now states the slot is not emptied on read and what the staleness line means, plus aremember.deliveredrow in the data-file table.Closes #221