docs(worktree): scratch space is not isolated between workers - #351
Merged
Conversation
The harness scratchpad path's isolating token is the PLANNER SESSION's id, so every worker fanned out from one dispatch is handed the same string. It is one flat directory. Measured 2026-08-09: four concurrent workers all built before/after trees in it — base/after, out-base/out-new, zh-base/zh-new, out/base-<campaign>/out/new-<campaign> — and one worker's base/ was replaced mid-run by another's repo checkout. Its own setup line was 'rm -rf $SP/base', so with the arrival order reversed it would have deleted the other tree. Not bad luck: a before/after byte comparison is the evidence this project demands of everyone touching emission, and 'base' is the word all of them reach for. The loud failure is the safe one — that worker got ENOENT and noticed. The quiet one is a byte-identity proof that hashed somebody else's tree. Another worker was writing outputs of the SAME campaign under out-base/out-new; had the names collided, a worker could have compared that worker's before against that worker's after and reported its own change byte-identical. A green that binds to nothing, invisible to review because it looks exactly like a pass. Asymmetry against the worktree-collision precedent this mirrors: a code leak fails CI; a corrupted evidence tree fails nothing. Convention adopted: each worker gets its own scratch subdirectory, named in the dispatch prompt, same token as its worktree. The stronger fix is named but not built here — a baseline manifest that records the git SHA and delvec version it came from, and a comparison that asserts them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AjQ5p1Kv5MrkGPumi7yXWL
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 harness hands every worker a scratchpad path it calls "session-specific, isolated". The isolating token is the planner session's id — so every worker fanned out from one dispatch gets the same string. One flat directory, no per-agent segment.
Measured, 2026-08-09. Four concurrent workers, four independent before/after trees, one namespace:
base/·after/out-base/·out-new/(bothnobodys-cave-island)zh-base/·zh-new/out/base-<campaign>·out/new-<campaign>Worker 1's
base/was replaced mid-run by worker 2's repo checkout — verified:$SP/base/campaignsnow resolves intowt-state. Worker 1's own setup line wasrm -rf $SP/base && mkdir -p $SP/base, so with the arrival order reversed it would have deleted worker 2's tree. Same shape as thegit add -Anear-miss the constitution already records, one layer over.This was not bad luck. A before/after byte comparison is the evidence this project demands of everyone who touches emission, and
baseis the first word all of them reach for.Why it is worse than a lost directory
The loud failure is the safe one — worker 1 got
ENOENTand noticed. The quiet one is the danger. A byte-identity proof isfind base/ | shasumagainst the same overafter/. Had the foreign tree landed before the hash instead of after, the run would have hashed someone else's repo. Worse: worker 2 was writing build outputs of the same campaign. Had those names collided, a worker could have compared worker 2's before-tree against worker 2's after-tree and reported its own change byte-identical — hundreds of files, all matching, a number nobody can re-derive from the PR.That is a green gate that binds to nothing, and review cannot see it, because the output is indistinguishable from a pass.
The asymmetry against the worktree-collision precedent this mirrors: a code leak fails CI; a corrupted evidence tree fails nothing. It emits a sentence in a PR description.
What this PR does, and what it does not
Adopts the convention — each worker gets its own scratch subdirectory, named in the dispatch prompt, same token as its worktree — and records the measurement so the next session does not rediscover it.
It does not build the real fix, which is named in the file: a baseline hash manifest that records the git SHA and
delvec --versionit was produced from, with the comparison asserting them. That turns a swapped tree into a loud failure and covers every piece of before/after evidence, not just the ones in a shared directory. Filed separately.What CI proves
Doc-only.
check-doc-dupesandcheck-reference-versionsgreen.