Repository navigation
perf(sandbox): run registry reservation and removal transactions in the executor - #165558
Conversation
…he executor Keep reservation selection and removal intent in the existing shared-state writer. Retain live synchronous generation checks for released sandbox callbacks. Join accepted removal across scheduler cancellation, direct database close, and database reopen while the Gateway remains live.
|
🦞👀 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 5, 2026, 10:59 AM ET / 14:59 UTC (Revision 8). ClawSweeper reviewWhat this changesMoves sandbox reservation and removal transactions into the existing SQLite worker and makes Gateway shutdown wait for accepted removal cleanup. Merge readiness✅ Ready for maintainer review Keep open: the change remains useful because inspected main and the latest release still execute these transactions on the caller thread. No actionable introduced defect was found, and GitHub confirms successful CI for the pinned head. Priority: P2 Review scores
Verification
How this fits togetherThe sandbox registry records runtime allocations used by provisioning, recreation, and pruning. Its worker commits reservation and removal decisions, while backend managers perform provider operations and Gateway lifecycle code joins their cleanup. flowchart TD
A[Provision or prune request] --> B[Live host authority]
B --> C[Shared SQLite worker]
C --> D[Authoritative registry decision]
D --> E[Sandbox backend operation]
E --> F[Exact generation cleanup]
G[Gateway shutdown] --> F
F --> C
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +244, Tests +250, Docs +16, Other +1. Total +511 across 17 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one shared-state transaction owner, bind cleanup to its original database and generation, and preserve released synchronous sandbox callbacks. Do we have a high-confidence way to reproduce the issue? Not applicable as a reported product bug; caller-thread transaction placement is directly visible on inspected main, and the PR supplies before/after execution counts. Is this the best way to solve the issue? Yes: extending the existing executor removes the host transactions while keeping reservation policy, public callbacks, and terminal cleanup under their established owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bb3a8a9ac304. 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 (7 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…he executor (openclaw#165558) Keep reservation selection and removal intent in the existing shared-state writer. Retain live synchronous generation checks for released sandbox callbacks. Join accepted removal across scheduler cancellation, direct database close, and database reopen while the Gateway remains live.
What Problem This Solves
Sandbox reservation and removal-intent transactions still executed shared-state SQLite on the Gateway thread during provisioning, recreate, and pruning.
Why This Change Was Made
Run both transactions through the existing shared-state executor. The worker selects the authoritative reservation and evaluates typed prune criteria against current rows. Remove the superseded host transactions and now-private kernel exports.
Accepted removal retains its original physical database and generation through provider work. Terminal deletion uses the existing cleanup worker with current host grants and an exact-generation predicate. Gateway shutdown seals new removals before scheduler cancellation and joins accepted settlement; this association survives direct database close/reopen while the Gateway remains live.
User Impact
No schema, configuration, or stored-format changes. Released sandbox callback signatures stay unchanged. Synchronous generation checks remain intentionally retained: these callbacks span provider waits and deferred process launch and must observe foreign removals. Async companions remain next-SDK-major work; there is no authority cache or prepared-row substitute.
Production: +405 / -161 / net +244; 566 changed lines. No new
OPENCLAW_*names.T1 same-rules ratchet: 882 → 879 globally; 4 → 1 in this lane. The original five-site audit also included the insertion helper, now worker-only; the ratchet applies that classification to both revisions rather than crediting metadata alone. The common live-generation row reader remains T1.
Overlap: #131941 touches sandbox activity/pruning; #162433 is the separate umbrella ownership design. This change keeps its scope to registry transactions and their settlement.
Retained follow-up debt: the pre-existing browser/retirement caller guard at
src/agents/sandbox/registry.ts:56can recheck other owners synchronously, including the session/worktree assertions insrc/gateway/worker-environments/local-workspace-projection.ts:282. Those checks remain live in grants; the zero-caller-SQL boundary applies to the moved reservation/removal operations, not these retained other-owner guards.Evidence
Instrumented, warmed real-entry MAIN SQL counts:
resolveSandboxContextremoveSandboxContainerThese are executed-statement counts, excluding prepare calls, from the same synthetic fixture; they are not a latency claim. The final native-boundary regression proves zero caller-thread SQL for reservation, removal, and readback.
--maxWorkers=1: zero caller SQL, stale-prune refusal, direct database-close settlement, and Gateway shutdown after database reopen. Command wall time: 578.02s, including 289.681s worker preparation.--maxWorkers=1. Includesruntime-process-build-graph, shared-state worker imports, and reply import closure. Existing host-owned project routing covers the changed callers; no new worker pins or serial configuration.38618131. The report follows declaration modules throughSandboxRegistryEntrytype imports, so it includes the internal facade's async reservation signature and new kernel declarations. Public callback/entry shapes are unchanged. SDK surface budget passes: 151 public entrypoints, 3,652 exports, 2,113 callable exports; no budget increase.ff398b3a90a4, with the commit and all changed runtime hashes verified before packaging. Durable/incognito before-and-after probes passed; final phasefinished, readiness HTTP 200, running candidate version verified. Package build/integrity: 740.13s; complete cell: 518.50s (actual updater 422.07s). Testbox admission timed out and AWS quota fallback provided insufficient memory; both leases were stopped. The successful Hetzner run used the existing Docker bootstrap after standard hydration omitted Docker. No budget caps were raised.check-changedencountered inherited dead-export findings forGoogleMeetJoinResult(extensions/google-meet/src/transports/types.ts),resolveGatewayWorkboardWorkspaceAccess(extensions/workboard/src/gateway-helpers.ts), andMeetingRuntimeOwner(src/meeting-bot/runtime-facade-types.ts). Their declarations and reference sets are unchanged from baseb658e685c314d154946358293b190e1fd3ad7c4d; the final export scan reports no sandbox findings. Remaining constituent checks run explicitly, without suppressing the failed gate. Final CI run wall time was 10m24s for the entire selected workflow; this is not an incremental test-cost measurement.Landing verification at
a8ec3471820e7: the original focused sandbox change remains 17 files with no additional sandbox production changes. Merge commitsd3dae1553b8d,59b2568238ac, anda8ec3471820e7incorporated three available main fixes; none needed conflict resolution or a rebase. Fresh Codex P2 review is clean. After the final integration,pnpm tsgo:core, all 27pnpm tsgo:core:testshards, and the separatetest/tsconfig/tsconfig.test.root.other.jsontype graph pass; Madge reports zero cycles.Released
v2026.9.8SDK subpaths andapi.runtime.sandboxdo not expose the changed internal reservation/removal functions or removed kernel exports. Public synchronous callbacks remain unchanged. The refreshed SDK report (f1930848efe6→d3dae1553b8d, digest28ac6e6d) reports 0 entrypoints added/removed, 0 direct export changes, and 128 reachable declaration changes. Subsequent integrations change none of the sandbox, sandbox SDK, or plugin-runtime type inputs, so this report remains applicable to the unchanged PR delta. Existing database-worker and forked host-owned projects cover all affected direct and indirect callers; no routing additions are needed.CI failure attribution:
ff398b3a90a4: the sole root was a 17-file Madge cycle introduced on main by1b7d11db6a98. It reproduced identically on clean main91dc92261fda; all component and scanner inputs matched the CI baseline and tested merge. Main fixed it in21901766c534, incorporated by the first merge. Scheduled main had skipped Madge, explaining its otherwise green guard result.d3dae1553b8d: two tooling shards failed because main's cycle fix omitteddeferred-plugin-migrations.contract.tsfrom the wrapper extraction inventory. Import closure reproduced 5/5 on both PR and main. Whole macOS provisioning files failed only with that missing module. Isolated Linux repeated all three failing provisioning cases 5/5 on each immutable head (d3dae1553b8dandf1930848efe6), including the Linux-only case; every repetition reported the identical missing contract. Main fixed the inventory in044859704eba, incorporated by the second merge. Testbox was stopped after 15 minutes without admission; the authorized AWS comparison completed, and both leases were stopped/released.59b2568238ac: the sole root wastest/gateway-rpc-exporters.test.ts:110TS2322, where main3e7f2d88803eassigned descriptors with optionalprofileAccessto the normalized array requiring it. The exact root-other type graph reproduced the sole error 5/5 on main and 5/5 on the PR, with identical relevant source and compiler inputs. Main fixed the fixture inb9f2ea649750, incorporated by the third merge; the formerly failing type graph now passes locally.The earlier PR-context check was corrected by using the required template headings; its replacement passed. No CI rerun was used merely to obtain green, and no admin exception has been used. Final-head CI run 37325029113 passed: 61 successful jobs, 24 conditionally skipped, no failed or cancelled jobs. ClawSweeper completed review of
a8ec3471820e752a72bd30824ebc847df7ba3c59at 2026-10-05 14:36 UTC with no actionable findings.