Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

CheckpointPerISC: a project ISA's old `started` turns off the mtime filter, so a claim commit stages every concurrent session's dirty files

Open rain77-work opened this issue 1 month ago • 2 comments

Written by my AI assistant and reviewed by me before posting.

What happens. On 7.40.4, with several Claude Code sessions open in one tree, the checkpoint commit made when one session closes a claim also stages files that other sessions wrote and had not committed. The commit subject describes one session's claim, while the diff holds another session's work.

Three paths, all in hooks/CheckpointPerISC.hook.ts (v1.1.2):

  1. Project ISAs. runTouchedPaths() (lines 150-155) keeps dirty paths whose mtime is at or after the ISA's started (line 264). Since #1807, project ISAs (<project>/ISA.md) checkpoint too, and a project ISA's started is the day the project began, often weeks earlier. Every dirty file then passes the filter, so the commit is in effect the whole-tree stage that the comment at lines 143-145 rules out.
  2. Task ISAs. The residual named at lines 146-148: a file that another session dirties after the task started still has a fresh mtime. Today one claim commit here took 33 files that a concurrent session was writing.
  3. Staged files. git commit runs with no pathspec (line 203), so anything another session has staged is committed too, whatever its age.

Measured on one install, last 7 days. Attributing writes from each session's transcript (Write/Edit/MultiEdit file_path), at least 22 of 112 claim commits whose closing session could be identified contained files that a different session wrote. In one example, a project-ISA claim commit contained a second session's new hook and its test file, and a third session's code file.

Prior work. PR #1826 (@justinkatz94-glitch) proposed foreignClaimedPaths(): read sibling transcripts and exclude only the paths another session provably wrote, leaving unattributed paths on mtime, because staging only a session's own transcript paths drops shell-written work (it recovered 14 of 33 paths in their test). The author withdrew it on 2026-08-12 and has not resubmitted it. It covers path 2. Path 1 also needs a start time scoped to the session rather than the ISA's started.

What we run locally until your fix. For path 1, a small patch takes "the run started" as the later of the ISA's started and the session's own start (the first timestamp in its transcript; a subagent's transcript maps to its parent session's; ctime also counts then, so a renamed file stays in), and keeps your original behaviour when the transcript cannot be read. For path 3, the commit names the paths it staged. Both apply your comment's rule; we have not patched path 2.

Questions. Is a session-scoped start the fix you would choose for path 1? For path 2, would you accept a fix along the lines of #1826?

rain77-work avatar Oct 15 '26 14:10 rain77-work

Follow-up on the residual named in the hook's comment (lines 146-148), with data and a working approach. Measured: on one day with concurrent sessions, 6 of 46 claim commits held files that another session changed after the run began (28 files, one of them another session's source file). Our local stopgap leaves a path out when only other sessions' records name it since the run start: their transcripts' Write/Edit/MultiEdit/NotebookEdit calls (skipping calls whose own result is an error), and a per-session list of files each Bash command changed (from tool_response.bashEditDiff plus a git change-time scan, recorded by a PostToolUse Bash hook). Order per path: own edit keeps; other edit drops; own shell record keeps; other shell record drops; no record keeps, as now. The triggering ISA always stays, and if only another session edited it, the hook makes no commit. Any error, an unknown session or a 2 s scan budget falls back to the current list. Replay of that day's 69 commits: 27 of the 28 foreign files stay out, no file the committing session edited is dropped, and one scan of about 22 hours of transcripts takes about 0.5 s. Limits: deletions, and files that other sessions' hooks write, still go in. Does this direction fit how you plan to handle the residual?

rain77-work avatar Oct 16 '26 15:10 rain77-work

Thanks for the careful measurements. The checkpoint hook now stages only the paths the closing session wrote, read from that session's own transcript, and it commits through a private git index, so another session's staged files can't ride along. That covers all three paths you listed.

You'll see it in the release that's about to land, so we're closing this one. Thanks again for sending it in.

danielmiessler avatar Oct 17 '26 03:10 danielmiessler