Repository navigation
Hold Claude Code's lock when engine edits a harness's trust file - #316
Merged
Merged
Conversation
Claude Code saves ~/.claude.json under the proper-lockfile lock ~/.claude.json.lock, applying each change to a fresh read. Engine wrote the file without that lock, so a session saving between its own read and write put back a copy without engine's new trust entry, and the spawn stopped at the workspace trust dialog (#298). session.EditFile now holds <file>.lock for every trust edit, which also serializes engine's own concurrent spawns (Codex's joined config.toml too). Claude's trust also records the worktree's clone, the canonical git root whose key Claude Code checks first, so once a clone is trusted a later spawn has nothing a concurrent write could lose. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Releasing a session whose Codex home was never made used to be a no-op; taking the lock there failed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/harnesses.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Objective
Spawned Claude Code sessions no longer lose their workspace trust entry to a concurrent write, so they stop stalling at the trust dialog. Closes #298.
~/.claude.jsonunder the proper-lockfile directory lock~/.claude.json.lockand applies each save to a fresh read. Engine wrote the file without that lock. A session saving between its own read and write put back a copy without engine's new entry. On a Mac with live sessions, the lock was seen dozens of times in a few seconds.session.EditFile, used only for harness trust edits, now holds<file>.lock. It waits up to 30s for a live holder and takes over a lock left stale for 10s. This also orders engine's own concurrent spawns, including Codex's joinedconfig.toml. The stamp check stays, for writers that skip the lock.Trustalso records the worktree's clone. For any worktree, Claude Code checksprojects[<canonical git root>]first, so a later worktree key lost to a write leaves the session trusted. This holds even if a future Claude Code changes its locking.Gates
./dev test(every required lane)./dev teston 3af2d0d, which differs from head only in comments and one test's fake clock:TestDaemonInstanceIdentifiesOnlyItsOwnProcess,TestDashboardScripts).go test -race(cli, session, hostops, control, controlrun, harness/..., ui).-race -count=3../dev testis the gate for this PR. Merge only on green CI.internal/session/filelock_test.go:ErrLockHeldand leaves the file alone;internal/harness/claude/trust_test.go:TrustFoldercalls keep every folder.docs/harnesses.md, both kept) and trimmed that doc to its 580-word budget. No code changed since round 4.Rulings
engine start --checkprobe with two concurrent spawns is not built. Concurrency is proven in unit tests, deterministically, rather than with two real model sessions per check.Review
.lock. Declined: Claude Code passes an explicitlockfilePathbuilt from the unresolved config path, which proper-lockfile uses as given. Engine's<path>.locktaken before resolving is the same lock.EditFile's doc now says so.hosts-and-sessions.mdstep 2: the harnesses.md row owns per-harness trust, and step 2 stays accurate.editruns twice when the folder is missing: both callers' edits are pure.config.toml.lock: as stated above, the lock only orders engine's writers there.internal/session/filelock.go: stale takeover and wait bounds.internal/session/editfile.go: lock scope and the missing-folder shortcut.internal/harness/claude/claude.go:Trustnow records the clone.Deviations
./dev testis the gate, given the host's load.🤖 Generated with Claude Code