Skip to content

fix(gateway): resume worker reconciliation after state DB seals - #175185

Merged
steipete merged 1 commit into
mainfrom
steipete/cs-160521-1017
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cs-160521-1017

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #160521

What Problem This Solves

Fixes cloud-worker reconciliation remaining disabled after a temporary state-database read-admission seal, with "Worker environment inventory has closed" warnings on every sweep until the Gateway restarts.

User Impact

After the same database reopens, the next reconciliation sweep reloads the inventory and resumes worker maintenance. Explicit store closure and Gateway shutdown remain permanent. No configuration or schema changes are required.

Why This Change Was Made

Per-database drainage used the permanent store-close path, and ready() could only reject the retired inventory. The store now releases the retired generation and obtains fresh canonical admission on the next awaited access, retaining its original scope and physical database identity. Recovery uses the existing worker reader and admitted database facts, with no freshness probes or main-thread SQL. Shared credential-revocation subscriptions survive projection replacement.

The earlier unhandled rejection was already addressed by #156160. This fixes the remaining running-Gateway recovery failure while preserving shutdown retirement from #168862. The simplification keeps one store owner and separates temporary retirement from final closure; production delta is +92/-21 lines, with a 75-line boundary regression and one test-routing entry.

Evidence

  • Red: the new regression against original production code at 66ffabc522acce880e6fc28f18964608049593f1 fails at the next reconciliation after reopen with WorkerEnvironmentInventoryClosedError: 32.07s wall.
  • Green: pnpm test src/gateway/worker-environments/service-inventory-recovery.test.ts --maxWorkers=1: 1 passed, 29.63s wall, 1.510s test execution. Covers held admission seal, successful next full sweep after reopen, revoked old admission, shared revocation notifications, and permanent shutdown retirement.
  • Selected store-worker.test.ts and service-lifetime.test.ts cases: 6 passed, 33.78s wall. Covers database aliases, refused admission, durable quarantine, reconciliation retirement, and draining accepted shutdown operations.
  • CI type-aware core lint through node --import ./scripts/tsx.mjs scripts/run-oxlint-shards.mts --only=core --files-json <three changed TypeScript files>: 0 warnings/errors, 11.95s wall. Test-routing lint through scripts/run-oxlint.mjs --tsconfig test/tsconfig/tsconfig.test.root.json: 0 warnings/errors, 0.66s wall.
  • pnpm exec oxfmt --check on all five changed files: passed, 0.08s wall. git diff --check: passed.
  • pnpm run tsgo:core: passed, 53.77s wall. Independent code review: no actionable P0–P2 findings.

Focused tests and lint completed on Linux/Node 24.19.0 using Blacksmith Testbox tbx_01m5454e4fctcsa0bhvhm3kgys (carrier workflow); the final command exited 0 against source tree c3675304ccf83e78f32645265208553f8fa9655e. Lease cleanup may mark the carrier workflow cancelled. Local test startup was interrupted before assertions on the heavily loaded host; those attempts are not test verdicts. Broad suites and PR CI timing remain for PR CI.

@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-17T05:49:06.588903Z cb71bdb PR opened
ℹ️ 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 size: S labels Oct 17, 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 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing note: the only failing checks on head cb71bdbb9504 are three node-worker e2e shards — checks-node-changed-10 (node-worker-launch-wire.e2e.test.ts), checks-node-changed-14 (skill-library-worker-wire.e2e.test.ts) and checks-node-changed-1 (cloud-worker-midturn-loss). Each fails because the worker's exec tool throws Cannot find module '<node-host>/bundles/config/sessions/session-transcript.worker.mjs' (the downstream approval_required / "Bundled helper returned no JSON result" assertions are that same broken exec). That is a pre-existing regression on main since #169622, unrelated to the worker-environment inventory store this PR changes, and it is fixed separately in #175196. All other required checks are green and Codex autoreview is clean. Landing via the inherited-failure admin exception.

@steipete
steipete merged commit 6653b26 into main Oct 17, 2026
143 of 150 checks passed
@steipete
steipete deleted the steipete/cs-160521-1017 branch October 17, 2026 05:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
openclaw#175185)

Per-database drainage (a state DB read-admission seal/reopen under event-loop stalls) closed the worker-environment store permanently, so every reconcile sweep failed with 'Worker environment inventory has closed' until a Gateway restart. Drainage now retires only the current database generation; the next ready() re-captures the same database file (identity-checked), reinstalls the inventory and keeps revocation subscriptions and a monotonic inventory version. Gateway shutdown still closes permanently. The earlier unhandled-rejection crash was already fixed by openclaw#156160.

Fixes openclaw#160521
tideclaw-bot pushed a commit that referenced this pull request Nov 6, 2026
#175185)

Per-database drainage (a state DB read-admission seal/reopen under event-loop stalls) closed the worker-environment store permanently, so every reconcile sweep failed with 'Worker environment inventory has closed' until a Gateway restart. Drainage now retires only the current database generation; the next ready() re-captures the same database file (identity-checked), reinstalls the inventory and keeps revocation subscriptions and a monotonic inventory version. Gateway shutdown still closes permanently. The earlier unhandled-rejection crash was already fixed by #156160.

Fixes #160521

(cherry picked from commit 6653b26)

Co-authored-by: RomneyDa <[email protected]>
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-environment 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: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway crash: state DB read-admission seal -> "Worker environment inventory has closed" -> unhandled rejection in reconcileActive

1 participant