Skip to content

fix(#738): per_session /remember no longer writes into the last-started session's handoff - #739

Merged
fdaviddpt merged 3 commits into
mainfrom
fix/738
Sep 24, 2026
Merged

fdaviddpt merged 3 commits into
mainfrom
fix/738

Conversation

@fdaviddpt

@fdaviddpt fdaviddpt commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #738.

Problem

In handoff_mode: "per_session", session-start-hook.sh resolved a per-session target (remember.<session_id>.md) but published it through one project-wide file, .remember/tmp/handoff-path, rewritten on every SessionStart. write-handoff.sh had no session identity, so the last-started session owned the pointer and every other session's /remember wrote into its file. Regression from #731.

Fix

Tests (written first)

tests/test_handoff_per_session_pointer_738.py, 5 tests. Against main's scripts: 3 failed (session A's note landed in remember.sess-bbb.md). With the fix: all 5 pass, together with the #363 / #720 suites (18/18). Positive controls: the last-started session still writes to its own file; single mode still shares remember.md; a hint whose transcript exists survives pruning.

First CI round failed collection on every leg: str | None in a signature on Python 3.9. Fixed with from __future__ import annotations (8acf98c); 3.9 grammar checked with ast.parse(feature_version=(3, 9)), no local 3.9 interpreter to run it.

Platform

Observed on macOS: CLAUDE_CODE_SESSION_ID is exported to the Bash tool, and the suite is green. Reasoned, not observed: the same holds on Linux and Windows Git Bash. The new module carries the repo's standard blanket win32 skip, so CI's Windows legs do not cover it.

🤖 Generated with Claude Code

[AI-generated]

fdaviddpt and others added 3 commits September 24, 2026 21:03
…a project-wide last-writer-wins pointer

`handoff_mode: "per_session"` published the resolved handoff target to one
shared file, `tmp/handoff-path`, overwritten on every SessionStart. The last
session to start owned that pointer, so an earlier session's later
/remember could silently write into a more-recently-started session's
remember.<id>.md. write-handoff.sh never received a session id, so it had
no way to tell.

session-start-hook.sh now also publishes a copy keyed by that session's own
id, tmp/handoff-path.<session_id>; write-handoff.sh identifies its own
session via CLAUDE_CODE_SESSION_ID (a live env var Claude Code sets for the
Bash tool, never a value the model supplies) and prefers that copy over the
shared pointer whenever it exists, falling back exactly as before when no
session id reaches it. The new per-session hint files are pruned the same
way #373 already prunes remember.delivered.<session_id> records.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
`str | None` in a signature is evaluated at definition time on 3.9 and
failed collection on every CI leg. Postpone annotation evaluation.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The top-level LC_ALL save/restore around the allowlist `case` was not a
guard test_locale_ranges_695 recognises, and restored an unset LC_ALL as
set-but-empty. `case` patterns are measured not to collate (#698), so use
the same plain `case` as session-start-hook.sh:294 and list the site in
the same ALLOWLIST under _CASE.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@fdaviddpt
fdaviddpt merged commit 24beff9 into main Sep 24, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/738 branch September 24, 2026 19:48
fdaviddpt added a commit that referenced this pull request Sep 25, 2026
trap.d's queue (18 pre-existing plus 3 stray uncommitted, from the primary clone's
own working tree) plus two new fragments logged for this pass (#739, #746) --
21 total, all decided, none deferred.

New fragments added and curated in this same pass:
- 746: two PRs (#734 then #746) each stranded a sanctioned-divergence pair in
  test_case_divergence_298.py by stacking a new pair on a site an earlier PR had
  already pinned, going red on origin/main invisibly to either PR's own CI.
- 739: a targeted local pytest run missed a Python 3.9 str|None annotation and
  a new shell bracket-range pattern, both caught only by the full CI matrix.

Promoted (12 new rules, all firing-proven both directions via pre-path-hook.sh /
pre-tool-hook.sh, plus a known-good control):
- paths/00-manual: bash-locale-pin-byte-and-case-ops, dollar-paren-lt-file-is-a-
  special-case, hand-kept-completeness-list-goes-stale, kill-a-subshell-not-its-
  forked-child, per-session-value-shared-channel, security-check-three-states-
  not-two, simulating-tool-absence-on-macos, spawn-counter-splits-on-embedded-
  newlines, case-divergence-pin-fold-dont-stack
- tools/00-manual: supertool-cwd-verify-tree, raw-append-write-unguarded
  (interim, filed claude-supertool#2699), targeted-pytest-misses-py39-and-scanners

Merged into existing rules:
- 630, 695.outward-walk-assumes-lexical-scope -> folded into
  bash-locale-pin-byte-and-case-ops.md as supporting evidence
- 705.edit-toml-literal-double-escape -> appended to supertool-literal-
  backslashes.md

Declined, each recorded in the owning layer's 00-README.md:
- 695.emit-read-max-is-an-unvalidated-knob (still true, filed #758)
- 719.silent-exclude-mkdir-failure (still true, filed #759)
- 721.git-dir-symlink-bypasses-tracked-check (still true, filed #761,
  low-priority: attacker already needs a stronger primitive)
- 660.promo-installed-key-array-plugins-shape (still true, filed #762)
- 722.edit-tool-cannot-write-raw-unicode-literal (not a code claim; narrow,
  workaround already obvious)
- 725.recon-reads-dirty-sibling-clone-not-origin-main (not this repo's code;
  filed claude-oss#1745 against oss:recon itself)

721.git-command-failure-reads-as-untracked and 721.case-fold-helper-not-pinned-
to-c-locale were promoted rather than declined: both describe a generalizable
class (git-gated security checks folding failure into the permissive branch;
missing LC_ALL=C pinning) worth teaching beyond the one call site, so each
became -- or was folded into -- a promoted rule above, alongside filing the
underlying code issue.

Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

handoff_mode per_session: /remember writes into another session's handoff file, because tmp/handoff-path is one per project

1 participant