Repository navigation
fix: preserve worker environments during Doctor checks - #156160
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: needs real behavior proof before merge. Reviewed September 23, 2026, 12:12 AM ET / 04:12 UTC. ClawSweeper reviewWhat this changesPreserves live worker environments during Doctor readiness checks, joins resource retirement after actual repairs, and prevents queued reconciliation failures from leaking an unhandled rejection. Merge readiness⛔ Blocked before merge - 3 items remain The fix remains necessary: current main still retires worker inventory after a successful no-op schema check. Source review found no blocking introduced defect. Priority: P1 Review scores
Verification
How this fits togetherDoctor prepares the shared SQLite database before maintenance proceeds. Worker environments use database-bound inventory resources, so retiring those resources affects subsequent Gateway reads and worker reconciliation. flowchart TD
A[Doctor or startup check] --> B[Shared database preparation]
B --> C{Repair admitted?}
C -->|No| D[Keep live worker inventory]
C -->|Yes| E[Run synchronous repair]
E --> F[Drain and retire database resources]
D --> G[Gateway worker reconciliation]
F --> H[Continue maintenance]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -3, Tests +199, Docs +5. Total +201 across 20 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep healthy inventory generations usable during readiness checks while making admitted repairs own complete retirement and preserving reconciliation's existing failure handling. Do we have a high-confidence way to reproduce the issue? Yes, from source: create live worker inventory, run a current-schema preparation step, then read the inventory; current main unconditionally retires it. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes. Centralizing preparation and conditional retirement preserves existing repair and ownership checks, and the callback fix leaves reconciliation reporting and drainage with their current owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de32d6b7a12e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
@clawsweeper re-review The PR body now links the completed exact-head CI and published |
|
🦞👀 Re-review progress:
|
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix: preserve worker environments during Doctor checks This is item 1/1 in the current shard. Shard 0/1. This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
|
Merged via squash.
|
#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
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
#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]>
What Problem This Solves
Fixes a Gateway crash after a diagnostic Doctor check closes its live worker-environment inventory, even though the shared database already has the current schema.
User Impact
Routine checks keep existing worker environments usable. Actual repairs still retire the old database generation, including when cleanup fails after repair; ownership refusals preserve the live generation. There are no schema, configuration, or permission changes.
Why This Change Was Made
The migration wrapper always closed shared-state resources after checking readiness. Move preparation and retirement into one asynchronous owner that records actual repair admission, preserving synchronous database transactions and the existing synchronous SDK repair API. Both migration callers use that owner.
Also keep a session-change callback from returning an already-tracked reconciliation promise into an ignored promise chain. The existing reconciliation owner continues to log failures and drain work at shutdown.
Evidence
Worker environment inventory has closedbefore the repair.The production failure was observed during an update; isolated source and SQLite tests exercise its owning boundaries. No production state or schema version was changed for these proofs. 204 focused tests passed (199 across 16 files in 118.37s;5 selected large-suite cases in 8.80s). The queued-event case costs
150 ms and real inventory lifecycle cases1 s each. Independent P0–P2 review is clean. Production changes are net −3 lines. Local changed checks passed formatting, ratchets and initial core guards, then correctly refused the borrowed dependency tree at the TypeScript physical-containment gate; the full exact-head CI run subsequently passed, including production/test types, lint, build artifacts, docs and Windows checks.The required published-driver × exact-candidate Package Acceptance run passed:
[email protected]→a93d22b0a1816471b25912d8b192f1feae568451, trusted tooling35fd3b1617e0afc48e4e08afd9e767c0585dda95, syntheticbasescenario. The receipt records updater installation,updateOutcome: success,updateRecovery: null, Doctor and survival assertions, Gateway startup (51 s),/healthzand/readyz(1 s each), and RPC status (2 s). Package integrity and npm 12 installer acceptance also passed.The separate first-hop post-core snapshot is unavailable because its redacted update output was truncated; this proves the completed survivor flow, not that missing intermediate observation. Stored-data compatibility is preserved: no DDL, schema version, persisted representation, permission or configuration change; the existing synchronous SDK repair API remains unchanged.