Repository navigation
fix(agents): prevent concurrent workspace setup failures - #164377
Conversation
Serialize complete workspace preparation and bootstrap seeding per canonical directory while retaining each caller's options, authority, filesystem identity, and accepted-write settlement. Keep sandbox copying and scaffolding in one interval and retire the Git-only shared-promise path. Original-code controls reproduce the race, canceled-caller writes, root replacement, and sandbox ordering gap. Focused tests, the full changed-file gate, and the source-performance runtime build pass. The unchanged Darwin benchmark shutdown failure remains separate; all eight mock warmup turns verify.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 12:26 PM ET / 16:26 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR serializes workspace setup, bootstrap seeding, sandbox copying, and dev-template publication per directory while retaining each caller’s options and cancellation checks. Merge readiness✅ Ready for maintainer review The fix remains useful, and no introduced blocking defect was found. The revised head addresses the previous integration concern by preserving sandbox custody across queued preparation. Priority: P2 Review scores
Verification
How this fits togetherWorkspace preparation runs before agent execution and creates bootstrap files, initializes Git, and records setup state. Command, reply, cron, voice, and sandbox callers feed this preparation owner before continuing their runs. flowchart TD
A[Agent and sandbox requests] --> B[Capture options and authority]
B --> C[Canonical directory queue]
C --> D[Recheck authority and directory identity]
D --> E[Prepare bootstrap files and Git]
E --> F[Settle workspace state writes]
F --> G[Return caller result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +213, Tests +560, Docs +7, Other 0. Total +780 across 26 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep complete local preparation under one directory owner while preserving existing bootstrap contents, worker admission, and live caller authority. Do we have a high-confidence way to reproduce the issue? Yes, source provides a high-confidence path: concurrent callers can interleave complete preparation on main while filesystem evidence rejects their competing writes. The PR records negative controls; this read-only review did not execute them. Is this the best way to solve the issue? Yes, serializing the complete preparation interval through the existing queue owner addresses the race while preserving individual results and custody checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b6cde0d5f24c. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Integrate pinned main while keeping sandbox copying and scaffolding in one FIFO interval. Capture the existing custody guard before waiting and preserve the separation between host filesystem checks and worker admission.
|
|
Merged via squash.
|
…4377) Serialize complete workspace preparation and bootstrap seeding per canonical directory while retaining each caller's options, authority, filesystem identity, and accepted-write settlement. Keep sandbox copying and scaffolding in one interval and retire the Git-only shared-promise path. Original-code controls reproduce the race, canceled-caller writes, root replacement, and sandbox ordering gap. Focused tests, the full changed-file gate, and the source-performance runtime build pass. The unchanged Darwin benchmark shutdown failure remains separate; all eight mock warmup turns verify.
What Problem This Solves
Fixes workspace setup failing during concurrent first turns with “Workspace filesystem changed while preparing state” before any provider request, as observed in the Full Release Validation source-performance job.
User Impact
Concurrent runs can prepare the same workspace reliably while retaining each caller’s bootstrap options and result. Requests canceled or revoked while queued cannot publish workspace files when their turn arrives.
Why This Change Was Made
Complete local preparation and consented bootstrap seeding share one FIFO per canonical filesystem directory. Sandbox copying and scaffolding retain the same slot, and dev-template publication joins the same owner. Existing Gateway custody guards are captured before waiting and checked before filesystem effects; worker admission retains its separate host-only authority and recovery predicate. Different directories remain independent, accepted writes settle before the next caller enters, and the old Git-only shared-promise path is removed.
Evidence
AGENTS.mdbetween sandbox copying and scaffolding. The integrated custody regression also fails by publishingAGENTS.mdwhen the guard is borrowed instead of captured.--maxWorkers=1, including workspace, sandbox, and state/managed/browser custody cases. Earlier worker, atomic-publication, SQLite-safety, and caller compatibility proof is retained. Initial owner/caller regression cases took 11.3 seconds of serial local test time; the extended custody case took 0.70 seconds.maincommitfd8397a6bb6e10eb5346f7a1452ac2e970033127. Production/test typechecks, lint, ratchets, storage guards, and import-cycle checks passed.sourcePerformanceruntime build passed in 167.892 seconds. Fresh AutoReview of the complete candidate is clean through P2.e9b5a30416738beabb0d7b16756d2cc33f844c36. All 12 introduced or materially changed regression cases executed once and passed, totaling 5.777 seconds of rounded, reported case duration; measured costs are below.Before the main integration, the unchanged baseline and initial repaired candidate each completed and verified all eight mock warmup turns on macOS. Both benchmark invocations exited 1 during Gateway teardown before a measured run began. This is not a passing performance benchmark; the separately diagnosed Darwin filesystem-watcher cleanup limitation remains outside this repair. The original Full Release Validation performance job runs on Linux.
Measured CI regression costs
These are sums of Vitest's rounded per-case durations, not file wall time or incremental job cost. Each file ran once in the recorded CI plan. The successful run tested GitHub merge
72591dfcfb61c86e08e9eafd174cdb42759dee5a, combining base7ae1ec5a37b6bb807cfbc51e1e1be5542c25ac67with the published PR head; the four test files and their workspace registration helper are unchanged between that head and the tested merge.Focused integration test command
Run through the repository test wrapper (
pnpm testuses the same entry point):The current candidate integrates pinned
maincommitfd8397a6bb6e10eb5346f7a1452ac2e970033127and preserves its hosted sandbox custody contract. The review, test, and isolated build/check copies are bound to the same complete candidate tree and per-file hashes, modes, and deletion.