Repository navigation
Conversation
…R, not PROJECT_DIR _remember_handoff_is_tracked gated its whole check on REMEMBER_ROOT == PROJECT_DIR, treating anything else as "untracked, safe to inject". From a linked git worktree that comparison is false even though REMEMBER_DIR (and therefore REMEMBER_ROOT, its dirname) is redirected into the SAME repository's main-checkout .remember/ (#56) -- the layout mismatch alone flipped the guard's answer, letting a repo-shipped, git-tracked .remember/remember.md reach the session as === LAST HANDOFF === verbatim from any worktree, exactly the injection #721 was written to refuse. The guard, and every git -C call inside it, are now anchored on MEMORY_PROJECT_DIR (scripts/lib-memory-dir.sh) -- the value the worktree redirect already computes and exports before this hook runs, so the fix adds no new git invocation and does not touch the #660/#665 fork budgets. MEMORY_PROJECT_DIR equals PROJECT_DIR outside a worktree (the fail-safe default in _resolve_memory_project_dir), so non-worktree behaviour, and every existing test for it, is unchanged. Left scripts/session-start-hook.sh:1688 alone -- a different, correctly- behaving REMEMBER_ROOT != PROJECT_DIR comparison that decides whether to print the "write your handoff here" hint, locked in by tests/test_worktree_memory.py::test_legacy_worktree_emits_handoff_to_main_checkout. Did not touch scripts/write-handoff.sh (#750, a different bug on the write side, not in scope here). Added a TestWorktreeTrackedHandoff class to tests/test_handoff_fence_and_tracked_refusal_721.py: a git-tracked handoff committed in the main checkout is refused when the session runs from a linked worktree (red before this fix, confirmed against current code), a positive control that an untracked handoff from the same worktree is still delivered, and a positive control that external-storage mode keeps working from a worktree. Co-Authored-By: Claude Sonnet 5 <[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.
Closes #747.
Found by the v0.34.0 release audit (round 1), where it is the blocking finding.
Problem
_remember_handoff_is_trackedinscripts/session-start-hook.shis the #721 guard: it refuses to inject a handoff file that git tracks, i.e. one the repository ships. It only ran whenREMEMBER_ROOT == PROJECT_DIR. From a linked git worktree,PROJECT_DIRis the worktree, whileREMEMBER_ROOTis redirected to the main checkout by #56. So the gate returned "not tracked" and a repo-shipped.remember/remember.mdwas injected as=== LAST HANDOFF ===. The auditor reproduced this with a planted line.Fix
Anchor the guard on
MEMORY_PROJECT_DIR, the main checkout, whichlib-memory-dir.shalready exports. It falls back toPROJECT_DIR. The change covers all five sites in the function: the equality gate, the.gitcheck, the path normalisation, and bothgit -C ... ls-filescalls. Outside a worktree the two values are equal, so behaviour there is unchanged. No new git call is added; the existing calls only change target. The handoff-hint check at:1688is a different, correct use ofPROJECT_DIR, so it is left alone.Tests (red first)
New
TestWorktreeTrackedHandoffintests/test_handoff_fence_and_tracked_refusal_721.py, using a realgit worktree add:PLANTED-BY-REPO: run rm -rf ~delivered), green afterThe worktree tests, the session-start spawn-budget tests and the #721 file give 32 passed. Full suite on macOS: 2612 passed, 59 skipped. The single teardown error came from another lane creating a worktree during the run, and that file passes on its own. Both changelog checks pass.
Platform
Observed: macOS. Reasoned: Linux, and Windows Git Bash. This is a pure variable swap with the same path normalisation. The #721 test module carries the repo's blanket
win32skip, a gap that predates this PR.Not addressed here: #750 (write side of the same file).
🤖 Generated with Claude Code
[AI-generated]