Repository navigation
test(update): preserve unverified restart outcomes after package swaps - #142102
Conversation
…he install swap A managed package update stages the new version, swaps it over the live install root, and only then restarts and verifies the gateway. That restart runs inside the updater process, which is still executing the build that was just replaced. The bundled dist is split into content-hashed chunks, so any `import()` reached for the first time after the swap resolves to a chunk name that only the old tree contained: Gateway: restart failed: Error: ENOENT: no such file or directory, open '.../node_modules/openclaw/dist/shared-DFJEouXv.js' `maybeRestartService` caught that as a restart failure, which became `recovery.serviceRestartSafe: false`, which made the update helper exit with the unsafe code and log "keep the gateway stopped until the installation is repaired". The installation was fine -- npm install, the swap, and doctor had all exited 0 -- but the gateway stayed down until someone restarted it by hand. Observed on a 2026.9.1 -> 2026.9.2 npm update: a 3h outage from a successful upgrade. Two changes: - Warm the restart path's lazy modules in `beforeActivate`, the last point where this process can still read its own install tree. The probe gained a loader for `gateway/call.js`, which was a bare dynamic import and so could not be warmed. - Recognize a missing module inside our own install root and stop treating it as a verdict on the new install. Restarting the service is strictly better than parking it: the old process is gone either way, and a genuinely broken install still surfaces through the service's own supervision. A missing *data* file in the install root is still a real failure. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01WKVaMWLzdHNJCa82nnTfWg
|
🦞👀 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 maintainer review before merge. Reviewed September 20, 2026, 12:02 AM ET / 04:02 UTC (Revision 13). ClawSweeper reviewWhat this changesAdds package-swap restart regressions, synchronizes asynchronous test fixtures, and caps GitHub-hosted storage/state test partitions at 64 files. Merge readiness✅ Ready for maintainer review Keep open: the branch retains useful regression coverage and a measured CI repair absent from current main. The prior maintenance-owner finding is resolved, live GitHub reports the reconciled head mergeable, and no actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw's update finalizer verifies the restarted Gateway before retiring the previous package. These tests protect that decision, while the CI planner divides the test inventory into bounded jobs. flowchart TD
A[Package swap fixtures] --> B[Production update finalizer]
B --> C{Restart verified?}
C -->|No| D[Retain recovery material]
C -->|Yes| E[Retire previous package]
F[Test inventory] --> G[CI partition planner]
G --> H[Bounded test jobs]
H --> A
Before mergeNone. Agent review detailsSecurityNone. PR surfaceTests +845, Docs +2, Other +23. Total +870 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain one production restart and recovery owner, protect its outcomes through regression coverage, and bound hosted CI work without weakening assertions or deadlines. Do we have a high-confidence way to reproduce the issue? Not applicable as a new product-bug reproduction: the final branch preserves main's runtime behavior. Historical missing-module and hosted-timeout failures have recorded evidence; this read-only review executed no tests. Is this the best way to solve the issue? Yes. The branch tests existing update owners and extends the existing CI splitter; fixture corrections synchronize on committed work while retaining the original assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a545a850420c. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (12 earlier review cycles; latest 8 shown)
|
|
Merged via squash.
|
openclaw#142102) * fix(update): keep a managed update from stranding the gateway after the install swap A managed package update stages the new version, swaps it over the live install root, and only then restarts and verifies the gateway. That restart runs inside the updater process, which is still executing the build that was just replaced. The bundled dist is split into content-hashed chunks, so any `import()` reached for the first time after the swap resolves to a chunk name that only the old tree contained: Gateway: restart failed: Error: ENOENT: no such file or directory, open '.../node_modules/openclaw/dist/shared-DFJEouXv.js' `maybeRestartService` caught that as a restart failure, which became `recovery.serviceRestartSafe: false`, which made the update helper exit with the unsafe code and log "keep the gateway stopped until the installation is repaired". The installation was fine -- npm install, the swap, and doctor had all exited 0 -- but the gateway stayed down until someone restarted it by hand. Observed on a 2026.9.1 -> 2026.9.2 npm update: a 3h outage from a successful upgrade. Two changes: - Warm the restart path's lazy modules in `beforeActivate`, the last point where this process can still read its own install tree. The probe gained a loader for `gateway/call.js`, which was a bare dynamic import and so could not be warmed. - Recognize a missing module inside our own install root and stop treating it as a verdict on the new install. Restarting the service is strictly better than parking it: the old process is gone either way, and a genuinely broken install still surfaces through the service's own supervision. A missing *data* file in the install root is still a real failure. Claude-Session: https://claude.ai/code/session_01WKVaMWLzdHNJCa82nnTfWg * test(update): use canonical normalization in restart regression * test(update): register package-swap regression in its CI owner * test(gateway): join task events before reset fixture cleanup * test(gateway): join task events before in-test settlement * test(gateway): prepare auth command runtime before handshake * fix(ci): bound serial storage-state test stripes * fix(ci): scope storage file ceiling to hosted jobs * test(transcripts): wait for routed provider startup * test: honor delivery and session fixture ownership * test(transcripts): join configured provider startup --------- Co-authored-by: baovo15 <[email protected]> Co-authored-by: Jason (Json) <[email protected]>
What Problem This Solves
A missing runtime module after an install swap must not be reported as a verified Gateway restart or authorize deletion of the previous package.
User Impact
Regression coverage and a required-CI partitioning repair: no product behavior or configuration change against incorporated main.
Why This Change Was Made
Preserves @baovo15's original outage report and contributor ancestry while retaining main's installed-runtime restart, executor, readiness, and recovery owners. The original error-to-success fallback and preload registry are superseded by that implementation.
The delta includes three update regression files, seven focused fixture corrections discovered by required CI, and a core storage/state CI partitioning repair with its regression and capacity documentation. They exercise thrown module failures, real filesystem swaps, unverified backup retention, pending readiness, and verified retirement through complete production source modules. The unit-fast entry pins source and dependency inputs to its checkout.
Evidence
Current Verification
Current source: 664bb4f, incorporating main 97c7b35.
The repeated hosted handshake failure came from cold shared-state command-runtime loading inside the one-second handshake deadline. Fixture setup now awaits a real empty-token read before the client starts; the real client still performs its fresh read during the handshake. Both capability cases pass with all original deadlines and wire assertions unchanged. Resulting-head required CI and native landing checks must pass.
The original typed script lint reproduced all 12 diagnostics before correction and passed after it. The regression entry also passed with hostile inherited proof-path settings.
Required CI Capacity Correction
Run 35477045216 passed the three previously failing shards but its 203-file serial storage/state job reached GitHub's one-hour execution limit while still passing tests. Its 196-file sibling took 2,867 test seconds. This was diagnosed from the actual job logs, not treated as a flaky assertion or blindly retried.
The existing compact split owner now caps GitHub-hosted storage/state stripes at 64 files, independently of stale timing costs. Blacksmith and hybrid retain their existing measured partitioning. Prerequisite ownership and distinct-family packing keep the pieces separate. The real-inventory regression fails on the original 203-file hosted job, then passes for hosted, Blacksmith, and hybrid profiles with exact file coverage and the unchanged 80-row cap. All 549 focused timing/planner/routing/runner tests, typed lint, and formatting pass. The hosted PR plan remains 80 rows; existing timeouts, serial file execution, fork isolation, and worker limits are unchanged. Independent API review is P0–P2 clean. Measured resulting-head timing is recorded below; the final repaired head still requires green hosted CI.
The first partitioning head exposed four existing hybrid runtime-placement fixture assertions in job 105997407029. All four reproduced locally. Scoping the new ceiling to the profile with the observed timeout makes all four original assertions pass without changing tests or weakening coverage. The complete 549-test suite and independent API-only review pass. Measured storage-job timing is recorded below. Resulting-head hosted completion remains required; no CI failure is waived.
Measured Hosted Storage Completion and Readiness Repair
Run 35481614496 tested the prior published head against main
87fdeff3…. All nine storage stripes completed, selecting the full 411-file inventory with at most 64 files per stripe. Measured stripe elapsed times were 73, 571, 1543, 812, 227, 799, 1075, 1211, and 123 seconds. The longest stripe took 25m43s; the longest containing job took 31m36s, below the unchanged one-hour limit. These are actual executed-group logs, not inferred job numbering or forecast estimates.Eight storage stripes passed. Job 106000534947 failed two transcript-routing fixture assertions: the default one-second poll expired before real state initialization reached the provider callback. The CI fixture matched local source byte-for-byte, and both failures reproduced locally on the unchanged source.
The small correction joins the existing provider-callback deferred instead, retaining explicit call-count, routing, ownership, status, summary, and cleanup assertions. Both cases pass with actual elapsed times above one second; the full 19-test file, typed core lint, and formatting pass. Independent API-only review is P0–P2 clean with unchanged-source verification. No product code, mock expansion, deadline increase, or blind CI rerun is involved. The new signed head still requires exact-head CI and native landing gates; the failed run is not waived.
Required-CI Ownership Fixture Corrections
Run 35483375540 exposed three additional fixture failure groups in the GitHub merge composition
2bf3d1e5…(publisheddee3bce6…plus main576ba7e6…).ENOTEMPTY. The fixture now uses the existingremoveSessionTestDirectoriesowner, as its sibling suite already does, to drain work, deselect the store, and close the fixture databases before removal. Both connected/disconnected scenarios pass with all exactly-once event/history assertions unchanged. The original also passed locally; the CI log remains the failure evidence, not a claimed local red reproduction. No retry or timeout was added.The corrected files were qualified on the exact CI merge, then transferred back to the original PR head with byte-for-byte hash verification. Only the two test files are carried; no synthetic merge or production change is published. Typed core lint and formatting pass. Independent API-only review of the two ownership fixtures is P0–P2 clean. Resulting-head CI remains required; no failing run is waived.
Sibling Transcript Startup Readiness
The same completed run's job 106005217455 exposed seven startup-readiness assertions in the selection and provider-reload fixtures. All seven reproduced locally on source identical to the CI composition (the two complete files initially had 7 failures and 16 passes). Their one-second readiness poll began before real cold state initialization reached the fake provider callback.
The correction joins the existing deferred callback signal after the provider fixture has completed its startup work, then retains the original active-state assertions and polling deadlines. The selection fixture resolves after its real utterance write; provider reload also joins the second successful admission on the next date. Same-date conflict detection, the 65-second no-retry check, explicit start/write counts, source-privacy checks, summaries, and cleanup assertions are unchanged. The shared fixture harness and product code are not modified.
Both complete fixtures pass 23/23. Typed core lint and formatting pass. Independent API-only review is P0–P2 clean, with final source verification. Exact-head hosted CI and native landing remain required; no failed check is waived.
Current-main CI fixture ownership
Run 35485394439 exposed three further fixture boundaries, diagnosed from the actual failed logs:
All original assertions, transport mock coverage, both held writer boundaries, privacy/root checks, and timeouts remain. Typed core lint, formatting, and independent API-only P0–P2 review pass. A broader local shared-selector probe passed the readonly target but ended in a native SIGSEGV during completion; it is not claimed as a full-suite pass.
The tested CI main parent
afa9d8de67b60c5bf7d09c1adf2a947a26fa6765is incorporated with the original PR as first parent, preserving contributor ancestry and the upstream committed-enqueue helper. The genuine reconciliation's tree is verified identical to the qualified CI composition plus these three fixture corrections. The synthetic CI merge is not published. Resulting-head hosted CI and native landing remain required; no failed check is waived.Subsequent current-main conflict reconciliation
Native review captured main
3a2ce26706457fed70a84b865ee0dc6bca475bf3. It independently contains the transcript routing callback fix and a complete-start-promise join for the transcript selection fixture. The one selection conflict is resolved to the exact canonical upstream version; both overlapping files now match main, removing their duplicate changes from this PR.The adopted selection fixture passes 21/21, and the updater regression entry passes 1/1 on the reconciled tree. Typed core lint and formatting pass. Final independent API-only review of the complete remaining PR diff against that main is P0–P2 clean. The three additional CI correction files remain byte-identical to their qualified 7/7, 16/16, and 9/9 source. The earlier run's last pending substantive job completed successfully; its three actual failures are all covered by the recorded repairs. Resulting-head required CI is still required, and the recorded installed-package acceptance remains source-bound rather than being replayed or relabeled.
Retained Installed-Package Qualification
The original head reproduced false success and backup deletion for real ENOENT and ERR_MODULE_NOT_FOUND cases. The source-bound installed-package qualification at signed head 3ddc135 passed: healthy activation verified the candidate and retired its backup; removing an actual Gateway CLI module after the next activation produced exit1, a truthful error, and verified automatic rollback. Product functions/outcomes were not mocked in that native lane.
That proof is retained for its recorded artifact. Current main has advanced; no byte-identical runtime or all-platform qualification is claimed.
Redacted isolated managed-upgrade transcript and artifact bindings
Environment: Docker/Linux, canonical systemctl supervisor fixture, real Gateway processes and token-authenticated RPC. This is not host-systemd, Windows/macOS service, or live-model-inference proof. No live operator Gateway was updated or restarted.
The successor tarball is produced by the repository’s canonical first-hop fixture transformer. The injected module’s bytes were verified against both bound packages. The final harness remained unchanged during execution. An earlier setup/path refusal and an earlier harness follow-up failure were corrected; neither is counted as a full passing run.
This artifact proof is bound to the recorded head. Advanced-main caller/launcher changes still require the resulting-head CI and native merge-relevance checks before landing.