Repository navigation
fix(gateway): report pending worker teardown as stopping - #174768
Conversation
Acknowledge session stop once the lifecycle records destroy intent, while retaining cleanup ownership through capture and confirmed lease stop. Project pending teardown as stopping and keep cleanup failures visible. Remove the detached teardown observer from provider fixtures.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
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. |
|
@clawsweeper re-review Narrowed to the pending-destroy status projection, focused regression, existing RPC expectations, and a two-sentence docs note. The provider and RPC lifecycle changes have been removed; #168454's timeout fix remains intact. The PR body contains the updated proof. |
|
🦞👀 Re-review progress:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4dcd0b56b9
ℹ️ 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".
| providerId: record.providerId, | ||
| ...(record.leaseId ? { leaseId: record.leaseId } : {}), | ||
| state: record.state, | ||
| state: cleanupPending ? "destroying" : record.state, |
There was a problem hiding this comment.
Keep polling workers projected as destroying
When a prepared worker has destroyRequestedAtMs set while teardown is still running, this projection changes its state from ready or idle to destroying. The Cloud Workers page only schedules another inventory read for requested, provisioning, bootstrapping, or ready workers (ui/src/pages/cloud-workers/cloud-worker-environments.tsx:228-242), so it stops polling after this response and can leave the row displayed as Destroying after cleanup completes. Include destroying in that polling lifecycle or otherwise trigger a refresh when cleanup settles.
AGENTS.md reference: AGENTS.md:L79-L85
Useful? React with 👍 / 👎.
|
Codex review: needs maintainer review before merge. What this changesReport pending worker teardown as stopping while preserving cleanup errors and the worker’s actual lifecycle state. Example: worker-1 is ready with lease-1, destroyRequestedAtMs=2, and no cleanup error.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful and has no actionable findings: the follow-up resolves the prior polling concern by preserving raw worker state, while current main still reports pending teardown as available. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway summary adapter converts lifecycle-owner records into environment RPC responses consumed by agents and the Control UI. flowchart LR
A[Destroy request] --> B[Worker lifecycle owner]
B --> C[Worker record]
C --> D[Environment summary]
D --> E[Environment RPC response]
E --> F[Agents and Control UI]
Technical reviewBest possible solution: Land the focused status projection with the existing lifecycle owner, raw worker state, and accepted capture behavior preserved. Do we have a high-confidence way to reproduce the issue? Source establishes the failure: destruction can retain a ready or attached lifecycle state while awaiting the provider, and current main consequently reports available; no target code was executed. Is this the best way to solve the issue? The existing summary owner is the appropriate boundary, and changing only top-level status avoids the lifecycle-consumer regressions caused by synthesizing worker.state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 418940c3e233. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +3, Tests +38, Docs +2. Total +43 across 4 files. Added test files: 1. 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 HistoryReview history (1 earlier review cycle)
Reviewed October 16, 2026, 7:37 PM ET / 23:37 UTC (Revision 2). |
|
@clawsweeper re-review Restored raw |
|
🦞👀 Re-review progress:
|
|
Landing note: the only failing check on head |
…law#174768) Environment status projected the record state while destroy was requested, so a worker read ready/available for the 40-120 s of lease stop. Status now reports stopping while cleanup is pending (worker.state stays the raw lifecycle state). The 600 s stop timeout in the issue was already fixed by openclaw#168454, which detaches an optional teardown capture. Fixes openclaw#170144
What Problem This Solves
#168454 (
1b07457339cea) already fixed the reported 600-second timeout by detaching a claimed optional teardown capture. The reporter used 2026.10.2, before that fix. This PR fixes the remaining stale status: a worker can still appearavailablewhile a destroy request is pending.Fixes #170144.
User Impact
Top-level environment status reports
stoppingduring pending teardown, while cleanup errors remain visible.worker.stateretains the record's actual lifecycle state, includingattachedwhile remote cleanup is still pending; consumers can continue branching on that state. Failed workers without a lease remain terminal.The docs clarify that warm-image capture may finish after the lease reports
destroyed, and Crabbox's idle timeout or TTL reaps the lease if the Gateway exits mid-capture.Why This Change Was Made
The summary now derives availability from the existing
destroyRequestedAtMsmarker. It preserves the raw worker lifecycle state: synthesizingdestroyingbroke the paired-node removal and offline abandonment contracts in CI on4dcd0b56b95b1.The focused regression covers pending teardown, raw lifecycle state, error precedence, and terminal records. The existing pool RPC expectation reflects stopping status while retaining its idle worker state. #168454's detached-capture behavior remains intact, with no provider/RPC lifecycle changes or new response fields, configuration, schema, or state store.
Final PR diff: four files, 46 insertions and 3 deletions. Latest follow-up: four files, 6 insertions and 5 deletions.
Evidence
pnpm test test/e2e/qa-lab/runtime/paired-node-worker-lifecycle-wire.e2e.test.ts src/gateway/worker-environments/placement-move-abandon.test.ts src/gateway/worker-environments/environment-summary.test.ts src/gateway/server-methods/environments.pool.test.ts --maxWorkers=1. Result: 38 passed, 1 failed; 1971.06 s wall, including a 14 min 22 s cold runtime build.worker.state, so it required no top-level status exception or test adjustment.-t 'keeps local control usable across bundle loss, disconnect, capacity, and role removal': the same 360 s timeout; 525.43 s wall. Its log shows the expected offline-failure turn consumed 124 s, followed by more runtime installation. The wire assertion remains unverified locally and needs CI confirmation; no deadline or wire-test expectation was changed.available/in-useexpectations against pending-destroy records. The pool fixture is covered by the passing run; other availability matches had a null destroy marker or described unrelated availability.pnpm run tsgo:core, changed-filepnpm exec oxfmt --checkandpnpm exec oxlint, andgit diff --check: passed.