Repository navigation
fix: reclaim cloud workers after cleanup acceptance - #182138
Conversation
|
🦞👀 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 SummaryThis 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. |
|
Codex review: needs changes before merge. What this changesThis PR lets session reclaim finish after cleanup acceptance while retaining ownership until physical worker release is confirmed. Example: An AWS worker accepts deletion while physical release is still pending.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 3 items remain Keep this PR open: the cleanup handoff is useful and maintainer-directed, but three patch-caused test regressions need repair. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherSession placement sends Stop requests to the environment lifecycle owner, which shuts down session transports and asks the provider to release its lease. flowchart TD
A[Session Stop] --> B[Placement reconciliation]
B --> C[Environment lifecycle owner]
C --> D[Session shutdown]
D --> E[Crabbox cleanup]
E --> F[Reclaim completion]
E --> G[Physical release confirmation]
G --> C
Technical reviewBest possible solution: Keep the existing lifecycle handoff and repair the public test import, placement cleanup fixtures, and timeout assertions. Do we have a high-confidence way to reproduce the issue? Current main awaits physical destruction during reclaim, and the PR records a failing baseline regression; no target code was executed during this review. Is this the best way to solve the issue? The existing environment owner is the appropriate place to separate acceptance from confirmation, with provider opt-in preserving other providers' behavior. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9cf739b6c0da. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +121, Tests +309, Docs +6. Total +436 across 25 files. Added test files: 2. View PR surface stats
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 October 23, 2026, 11:16 PM ET / October 24, 2026, 03:16 UTC. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcbce620e5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| !acceptCleanup || | ||
| !(error instanceof WorkerTunnelOwnerDisconnectedError) || | ||
| r.nodeDeviceId === null || | ||
| r.sharedHost !== false |
There was a problem hiding this comment.
Fall back to blocking destruction when computer cleanup fails
For a dedicated Crabbox worker whose computer driver rejects cleanup or exceeds its 60-second cleanup deadline, reclaim now calls stopOwner without a teardown reason. createWorkerEnvironmentTransportLifecycle.closeComputers therefore propagates that ordinary error, but this fallback only accepts WorkerTunnelOwnerDisconnectedError. Stop consequently fails before calling the provider's destroy operation, leaving the machine billable until reconciliation retries. Previously, the provider-destroying path explicitly tolerated this failure for dedicated machines; the existing provider-node-teardown.test.ts cases for a driver that never settles protect that behavior, but do not exercise acceptance-enabled reclaim. Disable early acceptance and retain blocking physical destruction for this cleanup failure too, while preserving strict acknowledgement requirements for shared hosts.
Useful? React with 👍 / 👎.
|
Landing note for head |
Reclaim waited for full provider destruction (40-120 s live: Azure ~100-117 s, GCP ~66-77 s, AWS 4-58 s). The provider lifecycle now separates cleanup acceptance from release confirmation: providers that declare supportsCleanupAcceptance call the optional onCleanupAccepted after durable acceptance (Crabbox: stop --wait=false), reclaim completes once session shutdown (tunnel stop, credential revocation, stale-handle rejection) and acceptance are done, and the owner keeps the environment lock while a background waiting stop confirms physical release before marking it destroyed. Failures stay visible and retryable; providers without the capability, offline dedicated workers and shared hosts keep the blocking path; warm-image capture stays detached.
Follow-up to #168454 and #173825.
What Problem This Solves
Stopping a cloud worker waits for the provider's full physical release, keeping session reclaim on a 40–120 second cleanup path.
User Impact
Reclaim can finish after session shutdown and accepted cleanup. The environment remains
destroyinguntil physical release is confirmed; billing can continue during that interval. Failed confirmation remains visible and retryable. Providers without the capability, unsupported direct Crabbox backends, and already-disconnected dedicated workers retain blocking cleanup.Expected savings are the physical-release portion of the observed Azure 100–117s, GCP 66–77s, and AWS 4–58s waits, minus acceptance and session-cleanup overhead. These are estimates from the reported timings, not a new live benchmark; physical billing duration is unchanged.
Why This Change Was Made
The existing environment lifecycle owner now distinguishes cleanup acceptance from confirmation through an optional provider notification. Crabbox uses
stop --wait=falsefor acceptance and a waitingstopwithin the same cleanup budget for confirmation. Terminal inspection alone is never release proof.Warm-image capture still releases reclaim after capture admission, but its destroy promise now remains owned through confirmed stop and preserves late failures. The redundant post-reclaim tunnel wait and warning-only teardown observer are removed. No new environment states, configuration, or state stores are introduced. The provider contract and user documentation describe the handoff and continued billing window.
Against the merge base: non-test source +212/-86, tests and fixtures +388/-63, docs +7/-1. The remaining production growth is the optional acceptance contract, its existing-owner handoff, and Crabbox's bounded acceptance/confirmation sequence. The CI follow-up changes only ten test/fixture files (+37/-16); it adds no production logic.
The CI follow-up preserves the original lifecycle assertions. The dispatch fixture now shuts down its tunnel before returning reclaim acceptance, matching the existing production owner. The Move/Stop fixture holds recovery-source release after local publication instead of waiting at the removed post-completion tunnel stop. A real SSH-manager regression verifies that tunnel shutdown, credential revocation, and rejection of the old handle all precede provider cleanup acceptance. The existing tests still cover delayed destruction, visible confirmation failure/retry, and blocking providers.
Crabbox's classless lifecycle command sequence was already correct; its exact timeout assertion now uses a fixed monotonic clock. Test doubles retain the required reclaim contract, the acceptance fixture narrows to an attached lease, and extension tests use the public SDK test-fixtures entry point.
Evidence
CI follow-up validation on Node 24.22.1 with
OPENCLAW_VITEST_RUNTIME=node; runtime checks usepnpm test <file...> --maxWorkers=1:src/gateway/worker-environments/placement-dispatch-authority.test.tssrc/gateway/server-worker-placement-reclaim.preparation.test.tsextensions/crabbox/index.test.tstest/extension-test-boundary.test.tssrc/gateway/worker-environments/provider-reclaim-acceptance.test.tssrc/gateway/worker-environments/placement-dispatch-reclaim.test.tssrc/gateway/worker-environments/placement-reclaim-acceptance.test.tssrc/gateway/worker-environments/worker-turn-launcher-build-recovery.test.tssrc/gateway/worker-environments/worker-turn-shutdown.test.tsextensions/crabbox/src/crabbox-worker-stop.test.tswithextensions/crabbox/index.test.tspnpm run tsgo:core: passed, 3.50s. Core test type graphsgateway-otherandgateway-servervianode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.<graph>.json --incremental: passed, 248.36s and 5.66s.pnpm run tsgo:extensions:test: passed, 305.08s.node --import tsx scripts/check-extension-plugin-sdk-boundary.mts --all: all three modes passed, 11.72s.scripts/run-oxlint.mjsrunner: core passed, 218.48s; Crabbox passed, 253.84s. Touched-filepnpm exec oxfmt --check: passed, 0.12s;git diff --check: passed.afa45c965d0: authority 1 failed/16 passed; Move/Stop 5 failed/34 passed; Crabbox lifecycle 2 failed/6 passed; boundary 1 failed/11 passed. The core test-type baseline reproduced all four reported diagnostics. The fixes retain the behavioral assertions rather than accepting new expected outcomes.Earlier implementation evidence:
094bbd6b153b(also unchanged onorigin/mainat1fead915921e): the placement regression failed withexpected 'waited-for-release' to be 'reclaimed'. One test, 364.88s wall / 6.948s test execution under Node 24.22.1.OPENCLAW_VITEST_RUNTIME=node:pnpm test src/gateway/worker-environments/provider-reclaim-acceptance.test.ts src/gateway/worker-environments/placement-reclaim-acceptance.test.ts src/gateway/worker-environments/provider-crabbox-runtime-preflight.test.ts src/gateway/worker-environments/placement-dispatch-reclaim.test.ts src/gateway/worker-environments/provider-node-teardown.test.ts extensions/crabbox/src/crabbox-worker-stop.test.ts --maxWorkers=1: 82 tests passed, 795.88s wall. Covers accepted reclaim, delayed physical confirmation, visible failure/reconciliation retry, unchanged blocking providers, direct-backend fallback, and detached capture.pnpm test src/gateway/worker-environments/provider-node-teardown.test.ts src/gateway/worker-environments/provider-reclaim-acceptance.test.ts extensions/crabbox/src/crabbox-worker-provider.test.ts extensions/crabbox/src/crabbox-worker-warm-image.test.ts extensions/crabbox/src/crabbox-worker-warm-image-lifecycle.test.ts extensions/crabbox/src/crabbox-worker-stop-lifetime.test.ts --maxWorkers=1: 125 tests passed, 216.38s wall. This includes the capable-provider offline fallback, shared/unknown-host rejection, warm-image lifecycle, and late stop failure/timeout custody.pnpm run tsgo:core, touched-fileoxfmt --check, scoped core and Crabbox type-aware lint, andgit diff --checkpassed. Independent review through P2 found no actionable issues in the final production change.