Skip to content

fix(gateway): report pending worker teardown as stopping - #174768

Merged
steipete merged 3 commits into
mainfrom
steipete/cs-170144-1016
Oct 16, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/cs-170144-1016

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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 appear available while a destroy request is pending.

Fixes #170144.

User Impact

Top-level environment status reports stopping during pending teardown, while cleanup errors remain visible. worker.state retains the record's actual lifecycle state, including attached while 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 destroyRequestedAtMs marker. It preserves the raw worker lifecycle state: synthesizing destroying broke the paired-node removal and offline abandonment contracts in CI on 4dcd0b56b95b1.

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

  • Ran the requested command: 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.
  • All three Gateway files passed: 37 tests, including the original move-abandon failure, unchanged. That failure asserted raw worker.state, so it required no top-level status exception or test adjustment.
  • The wire fencing case passed. The role-removal scenario timed out at its existing 360 s deadline while still preparing capacity-test workers, before reaching the original role-removal assertion.
  • One bounded rerun selected only the failed wire case with -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.
  • Audited available / in-use expectations 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-file pnpm exec oxfmt --check and pnpm exec oxlint, and git diff --check: passed.
  • Independent review of the follow-up: no actionable P0–P2 findings.

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.
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T23:35:41.094289Z 85226b1 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: M labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@steipete steipete changed the title fix(crabbox): report stopping during warm-image teardown fix(gateway): report pending worker teardown as stopping Oct 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@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.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. label Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Report 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.

  • Before: The summary reports status=available and worker.state=ready.
  • After: The summary reports status=stopping and worker.state=ready.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is source-correct and supported by reported Gateway regressions; confidence in exercised behavior remains limited to harness evidence while CI continues.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied validation exercises the summary and registered RPC harness, with no claimed live pending-teardown demonstration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agents can interpret a worker awaiting destruction as available and intervene unnecessarily.
Reason: The maintainer-authored change fixes the remaining status projection narrowly and preserves the explicitly accepted provider teardown contract.

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
Reviewed head: 85226b167891c6525a2c3622b4fa072b4dcbf0aa

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped-entry-point pending-status trace or executed base-failure comparison is supplied, and the wire role-removal assertion remains unverified after the reported local timeouts.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Cleanup-error precedence keeps the original intent (5790b12: Expose pending-cleanup failures without leaking stale errors from healthy workers.)
  • Prepared worker RPC projection keeps the original intent (a272cf0: Consolidate equivalent test fixtures while retaining observable lifecycle contracts.)
  • Warm-image documentation keeps the original intent (814362e: Maintain one coherent explanation of automatic preparation, capture, and reuse.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +3, Tests +38, Docs +2. Total +43 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 2 39 1 +38
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 46 3 +43

Labels

Label changes:

  • add P2: Misleading availability during pending cloud-worker teardown is a bounded user-facing status defect.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Misleading availability during pending cloud-worker teardown is a bounded user-facing status defect.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-16T22:40:31.201Z sha 4dcd0b5 :: needs changes before merge. :: [P2] Continue inventory polling for workers projected as destroying

Reviewed October 16, 2026, 7:37 PM ET / 23:37 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Restored raw worker.state; only top-level status projects pending teardown. The original move-abandon failure now passes unchanged. The PR body records the focused regression, availability-expectation audit, and both local wire-test timeouts before role removal; CI still needs to confirm that wire scenario.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Landing note: the only failing check on head 85226b167891 is checks-node-changed-10, where test/e2e/qa-lab/runtime/node-worker-launch-wire.e2e.test.ts ("transfers and reconciles a gateway-push workspace through a device runner") timed out at 240 s. That is the pre-existing main failure tracked in #169095, which surfaces only when a PR's changed-test selection includes it. This PR changes only the top-level environment summary status during pending teardown; that test never reads environment summaries (it drives chat.send, supervisor status, and readyz). All other required checks are green, and Codex autoreview is clean. Landing via the inherited-failure admin exception.

@steipete
steipete merged commit 1956ba0 into main Oct 16, 2026
131 of 137 checks passed
@steipete
steipete deleted the steipete/cs-170144-1016 branch October 16, 2026 23:49
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: crabbox tool stop times out at 600 s while teardown warm-image capture runs; environment reports ready throughout teardown

1 participant