Repository navigation
fix: keep sandbox tools from starving behind checkpoints - #200643
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper review Please review head |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR orders workspace admission within a Gateway, limits acquisition waits to 60 seconds, and diagnoses recursive acquisition. Example: A sandbox tool waits for own-worktree while three later checkpoints request custody.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: main still permits workspace-lease starvation, and the pinned diff has no actionable correctness or security findings. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSandbox commands, preparation, and checkpoints enter the workspace store, which acquires custody before reading or changing workspace projections; SQLite leases retain cross-process exclusion and cleanup ownership. flowchart TD
A[Sandbox tool or checkpoint] --> B[Workspace store]
B --> C[Keyed FIFO admission]
C --> D[Persisted SQLite lease]
D --> E[Workspace operation]
E --> F[Settlement and cleanup]
F --> C
Technical reviewBest possible solution: Retain FIFO admission at the existing workspace lease boundary, with persisted leases continuing to own exclusion, renewal, and settlement. Do we have a high-confidence way to reproduce the issue? Main's polling acquisition permits later callers to overtake a waiting tool, and the body records repeated parent failures against the committed regression; this read-only review did not execute tests. Is this the best way to solve the issue? The change repairs ordering at the shared workspace owner, preserves persisted exclusion, and removes the superseded acquisition path without adding a competing queue implementation or durable state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 46982ac40764. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +81, Tests +203, Docs +6. Total +290 across 7 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 17, 2026, 10:03 AM ET / 15:03 UTC. |
|
Merged via squash.
|
Backport FIFO workspace admission, bounded acquisition and immediate self-wait rejection while retaining persisted lease custody through settlement. Adapt target store context; source-only preparation test helper is absent on this target. Preserve prepared sandbox boundary regressions. (cherry picked from commit 20248a9) Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 20248a9) Companion disposition: state admission still belongs to the existing worker; keyed local lease replaces blocking checkpoint contention and forwards cancellation. Release adaptation: none. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit 440c78ccf4d5d55a93aa59051d334dcdb3962547)
What Problem This Solves
A sandbox tool call can keep losing its workspace lease to later checkpoints. Polling did not preserve arrival order, so repeated checkpoint traffic could leave the tool waiting for minutes. A callback that requested a checkpoint while holding the same workspace lease also waited on itself.
User Impact
Waiting sandbox operations now get their turn before later checkpoints in the same Gateway. Workspace admission ends after 60 seconds with a visible error explaining which workspace is busy and when to retry. Recursive acquisition reports the custody conflict immediately.
Why This Change Was Made
Order admission at the existing workspace lease owner using the shared keyed FIFO primitive. Keep the persisted lease responsible for cross-process exclusion, expiry, renewal and cleanup, and propagate cancellation through worker admission. Queue release follows persisted lease settlement. This does not change acceptance, journal, conflict or recovery semantics, add a schema/config option, or claim FIFO across processes.
The deadline covers waiting, not execution. Existing callers keep their cancellation error contract. Normal tool finalization already releases execution custody before checkpointing; the new diagnostic catches a nested request instead of allowing a self-wait.
The change adds 81 net production lines for queue ordering, bounded cancellation and the self-dependency diagnostic. It removes the unbounded-at-worker-admission polling-only workspace path and reuses existing queue/lease owners rather than introducing a cache or durable queue.
Evidence
Two A/A controls on exact parent
d565e17c2563632a64c94185d05042cf62483ae3both fail the new real sandbox/backend regression: three later checkpoints run before the waiting tool. The candidate runs the tool first. Tests also cover same-worktree recursion, the 60-second deadline, caller cancellation and queue-slot cleanup. Additional parent controls fail the recursion diagnostic assertion and time out at the runner’s 120-second limit for the new 60-second deadline; the candidate passes both. The parent deadline control was stopped during its stuck teardown after recording that failure.Real SQLite proof queues four workspace writes with renewal: each write commits and renewal succeeds without BUSY or reacquisition. A separate connection holding a write transaction produces actual SQLITE_BUSY on automatic renewal; the existing 25 ms retry succeeds after release while exclusion and owner identity remain intact. No renewal algorithm change was needed.
Final focused state/sandbox tests: 37 passed. Affected projection cancellation/admission cases: 4 passed. Earlier broader projection/store run: 107 passed, with the four subsequently repaired cases and two platform skips; existing lease timer cases: 6 passed. This is synthetic macOS proof with real SQLite and sandbox backend boundaries; live Podman behavior and production writer attribution are not claimed.
pnpm check:changed --base d565e17c2563632a64c94185d05042cf62483ae3 --timedpasses changed-code checks but reports five inherited unused exports. The same Knip scans reproduce all five on the exact main parent:validateArtifactMetadata: export introduced by fix(release): avoid repeated payload downloads during receipt recovery #196501 (09723cdcad18).qualificationAdmissionContract: final external production consumer removed by fix(release): reject unadmitted historical release evidence #200019 (5fb231527f4f).resolveMcpOAuthLinkRedirectUrl: export introduced by fix: connect OAuth MCP servers from chat without stopping the Gateway #200538 (bdd7cd53a397).markRunningToolCalls: export introduced by refactor: let background chat forks reuse the chat's prompt cache #200545 (2a7ca163a57d).resolveBrowserAuthOrigin: final external production consumer removed by fix: connect OAuth MCP servers from chat without stopping the Gateway #200538 (bdd7cd53a397).These are main regressions requiring their owners' follow-up. They are outside this change.