Skip to content

fix(crabbox): don't wait for optional teardown capture - #168454

Merged
steipete merged 4 commits into
mainfrom
steipete/reclaim-hang-20261010
Oct 10, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/reclaim-hang-20261010

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

After #168371, empty-workspace AWS sessions use Crabbox's teardown warm-image capture. Waiting for that optional capture made sessions.reclaim take a measured 880 seconds. Reclaim must stop waiting only when an optional capture is actually claimed; all other teardown failures must remain retryable by the Gateway.

User Impact

Only a claimed optional capture detaches. Capture stays at teardown and still precedes lease stop. Disabled capture, unenrolled allocations, up-to-date images, retained refusals, and other skipped captures retain synchronous stop and propagate its original error.

The provider's capture-failure and stop-failure warning strings directly name the lease and the next-step crabbox stop --provider <provider> <lease> command. Session-change warnings retain the existing redacted message/code formatting fix.

Why This Change Was Made

The existing capture owner signals after its guards and successful claim. Destroy waits for either that signal or completed teardown. A plain local boolean records whether capture started; there is no AsyncLocalStorage or logging context. The original project-preparation constant, provisioning methods, and inline timeout methods are restored. crabbox-worker-timeouts.ts has no change from the PR base, and no timeout values changed.

Accepted edge case: if the Gateway process exits while detached capture is running, OpenClaw does not stop the lease; Crabbox's idle timeout / TTL reaps it. There is no new durable state, restart recovery, or core lifecycle machinery.

Evidence

Final full-PR diff: 16 files, +244/-82. Production diff against the PR base:

File Added Removed
crabbox-worker-provider.ts 36 22
crabbox-worker-warm-image-capture.ts 2 0
session-change-event.ts 5 4
Total 43 26

The capture file retains only the two-line onCaptureStart hook. The timeout module is unchanged.

  • pnpm test <11 focused files> --maxWorkers=1: 284 tests passed in 188.05 s wall time. This includes all previously failing preflight, plugin lifecycle, allocation-authority, and recovery-event files, plus stop, provider, desktop, cancellation, stop-lifetime, warm-image, and warm-image-lifecycle coverage. The held-capture regression took 630 ms.
  • pnpm tsgo:extensions and pnpm tsgo:extensions:test passed. Formatting and git diff --check passed. Independent Codex review of the staged full candidate was scoped-clean at P0/P1.
  • Lint reported only the provider's 710 counted lines against its 700-line cap. The requested original methods are retained rather than adding an unrelated extraction or suppression. The existing repository policy makes numeric limits advisory in GitHub Actions; all other touched-file lint checks were clean.

Earlier CI failures were fixed by restoring behavior, not weakening assertions: preflight and classless lifecycle expectations are unchanged. The fork fixture waits for the seed's real capture/lease-release write before asserting a fork. The recovery-event test expects the intended formatted error string. The seed observer has an explicit generic store return type; its exact CI type configuration and allocation tests passed in the preceding correction.

Exact-head CI on b9f08b89664190acf2ac0be21bb761257de57daf: run 38081765268 is green. timeout 40m node scripts/watch-pr-ci.mjs 168454 <head> completed successfully in 393.79 s.

No live Gateway was changed or restarted. This PR remains open and unmerged.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: crabbox size: M labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR returns from destruction when optional Crabbox capture is claimed and preserves readable session-change error details.

Example: Reclaim an AWS cloud session whose optional image capture takes the reported 880 seconds.

  • Before: Reclaim waits for capture and confirmed lease stop.
  • After: Reclaim returns after capture is claimed while capture and lease stop continue.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful latency repair with successful exact-head CI, but confirmed-stop settlement remains incorrect and supplied media does not exercise the changed behavior; persisted formats are unchanged.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Reclaiming a cloud session can wait nearly fifteen minutes for optional image capture.
Reason: The supplied maintainer-authored direction addresses an observed workflow stall without adding configuration or a new capability.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: responsive reclaim is valuable, but claimed captures still acknowledge destruction before confirmed stop and can leave a paid lease outside Gateway cleanup retries.

Priority: P1
Reviewed head: b9f08b89664190acf2ac0be21bb761257de57daf

Before merge

  • Add real behavior proof - Authority-chain proof required: show reclaim returning during pending capture, replacement work succeeding, and retired-worker replay and queued effects rejected before transcript, tool, or provider I/O. The supplied tests mock commands, and inspected screenshots cover earlier snapshot-refusal guidance. Provide redacted terminal output or logs without API keys, IPs, phone numbers, or private endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Retain cleanup settlement after a capture is claimed (P1) - For an enrolled warm-image lease that claims capture, this race fulfills before capture and stop finish. The unchanged finishDestroy caller treats fulfillment as physical teardown, releases the dedicated worker's retained stop owner, and marks the environment destroyed. If stop subsequently fails, the catch only warns and reconciliation skips the terminal environment, so cleanup cannot retry through its normal owner. This previously reported finding remains after the latest simplification. Keep provider destruction pending through confirmed stop and preserve rejection; implement early reclaim admission through the environment lifecycle owner.
  • Resolve security concern: Establish retired-worker isolation before releasing termination custody - Dedicated-node teardown relies on provider destruction instead of a remote worker-stop acknowledgment; no authorization bypass is established, but the changed lifetime leaves already-queued effects after replacement unproven.
  • Resolve merge risk - Before merge, establish that releasing dedicated-worker termination custody during pending capture cannot let the retired scope complete queued effects after replacement.
  • Improve patch quality - Add final-effect proof that retired-worker replay and queued effects are rejected after reclaim and replacement, before transcript, tool, or provider I/O.

Findings

  • [P1] Retain cleanup settlement after a capture is claimed — extensions/crabbox/src/crabbox-worker-provider.ts:743
  • [medium] Establish retired-worker isolation before releasing termination custody — extensions/crabbox/src/crabbox-worker-provider.ts:743

Tests

  • Low-value test extensions/crabbox/src/crabbox-worker-provider.test-support.ts: destroyAndWait manufactures cleanup rejection from warning text; remove that alternate settlement contract and exercise cleanup success and failure through the real lifecycle owner.
  • Missing end-to-end proof: Missing production-path evidence covers responsive reclaim, successful and failed post-capture stop settlement, replacement work, and rejection of retired-worker effects before final I/O.
Agent review details

How this fits together

The Gateway environment lifecycle calls the Crabbox provider with a lease identity and interprets successful destruction as confirmed physical teardown.

flowchart TD
A[Session reclaim] --> B[Environment lifecycle]
B --> C[Revoke worker authority]
C --> D[Crabbox provider destroy]
D --> E[Optional image capture]
E --> F[Lease stop]
D --> G[Terminal cleanup settlement]
Loading

Technical review

Best possible solution:

Return reclaim admission promptly through the existing environment lifecycle owner while retaining destruction settlement through confirmed stop and retryable cleanup failure.

Do we have a high-confidence way to reproduce the issue?

Current main awaits capture before stop, matching the reported delay; the introduced race and unchanged lifecycle caller establish premature cleanup settlement without running target code.

Is this the best way to solve the issue?

Detaching only claimed capture preserves skipped-capture errors, but provider fulfillment still violates the confirmed-teardown contract.

Full review comments:

  • [P1] Retain cleanup settlement after a capture is claimed — extensions/crabbox/src/crabbox-worker-provider.ts:743
    For an enrolled warm-image lease that claims capture, this race fulfills before capture and stop finish. The unchanged finishDestroy caller treats fulfillment as physical teardown, releases the dedicated worker's retained stop owner, and marks the environment destroyed. If stop subsequently fails, the catch only warns and reconciliation skips the terminal environment, so cleanup cannot retry through its normal owner. This previously reported finding remains after the latest simplification. Keep provider destruction pending through confirmed stop and preserve rejection; implement early reclaim admission through the environment lifecycle owner.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e40606fdea96.

Merge-risk options

Maintainer options:

  1. Preserve confirmed cleanup settlement (recommended)
    Keep provider destruction pending through confirmed stop and let the environment lifecycle retain cleanup and termination custody while reclaim returns promptly.
  2. Hold detached teardown
    Retain synchronous provider destruction until cleanup custody and retired-worker isolation are established.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve WorkerProvider.destroy completion through confirmed lease stop, retain failed cleanup for reconciliation, and implement responsive reclaim admission through the existing environment lifecycle owner.

Provenance checked

  • Crabbox destruction settlement changes intended behavior with a stated reason (d48d7c2: Optional capture errors should warn after confirmed cleanup; failed source stop must still reject.)
  • Warm-image capture ordering keeps the original intent (a82042f: Capture a scrubbed reusable image before stopping its source lease.)
  • Session-change diagnostics keeps the original intent (6e70aff: Report asynchronous preparation and publication failures while preserving event ordering and lifetime ownership.)

Testing

Proof path: in-process harness.

Security

Needs attention: Credential revocation remains, but early destruction acknowledgment releases physical-stop custody before retired-worker isolation is established.

Evidence

Security concerns:

  • [medium] Establish retired-worker isolation before releasing termination custody — extensions/crabbox/src/crabbox-worker-provider.ts:743
    Dedicated-node teardown relies on provider destruction instead of a remote worker-stop acknowledgment; no authorization bypass is established, but the changed lifetime leaves already-queued effects after replacement unproven.
    Confidence: 0.9

What I checked:

PR surface

Source +17, Tests +145. Total +162 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 43 26 +17
Tests 13 201 56 +145
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 244 82 +162

Review metrics

Metric Value Why it matters
Production versus test growth Production +43/-26; tests and fixtures +201/-56 The production change is focused, but the added warning-driven settlement fixture gives tests a cleanup contract unavailable to production callers.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Reclaim stalls an active cloud-session workflow, and premature cleanup settlement can leave a paid lease outside normal retries.
  • merge-risk: 🚨 compatibility: Claimed captures change the existing provider completion contract while core callers still interpret fulfillment as proven destruction.
  • merge-risk: 🚨 security-boundary: Early completion releases retained physical-stop custody while retired-worker effects remain unproven.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-10T14:04:11.625Z sha 2064b3b :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T15:52:41.325Z sha de43745 :: needs real behavior proof before merge. :: [P2] Keep requestDestroy observable as a spy in the shared fixture | [P2] Update dispatch expectations for admission-owned tunnel stopping | [P2] Migrate staged-result regressions to the new teardown contract
  • reviewed 2026-10-10T16:44:38.355Z sha 5545fc7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T17:19:55.957Z sha 810b3bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T17:53:01.885Z sha 810b3bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-10T18:31:45.614Z sha c5029fa :: needs real behavior proof before merge. :: [P1] [P1] Preserve confirmed-stop settlement for provider destruction | [P2] [P2] Update the recovery-event assertion for formatted errors
  • reviewed 2026-10-10T19:21:42.059Z sha 9715294 :: needs real behavior proof before merge. :: [P1] Retain cleanup settlement after a capture is claimed
  • reviewed 2026-10-10T19:41:07.421Z sha 120bd84 :: needs real behavior proof before merge. :: [P1] Retain cleanup settlement after a capture is claimed

Reviewed October 10, 2026, 4:16 PM ET / 20:16 UTC (Revision 11).

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete steipete changed the title fix(crabbox): keep image capture out of session reclaim fix(workers): return reclaim before provider teardown settles Oct 10, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: XL and removed size: M labels Oct 10, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 10, 2026
@steipete
steipete force-pushed the steipete/reclaim-hang-20261010 branch from 810b3bd to c5029fa Compare October 10, 2026 18:23
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation app: web-ui App: web-ui labels Oct 10, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M and removed scripts Repository scripts size: XL labels Oct 10, 2026
@steipete steipete changed the title fix(workers): return reclaim before provider teardown settles fix(crabbox): don't wait for optional teardown capture Oct 10, 2026
@steipete
steipete merged commit 1b07457 into main Oct 10, 2026
132 checks passed
@steipete
steipete deleted the steipete/reclaim-hang-20261010 branch October 10, 2026 20:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
* fix(crabbox): detach optional teardown capture from reclaim

* fix(crabbox): await teardown when capture is skipped

* test(crabbox): preserve the observer store generic

* refactor(crabbox): simplify optional teardown handling
steipete added a commit that referenced this pull request Oct 16, 2026
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 #168454, which detaches an optional teardown capture.

Fixes #170144
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

extensions: crabbox gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant