Repository navigation
fix: keep database preflight responsive during gateway startup - #138986
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: blocked before merge. Reviewed September 5, 2026, 7:02 AM ET / 11:02 UTC. ClawSweeper reviewWhat this changesMakes database compatibility checks asynchronous and ties startup snapshot workers to Gateway cancellation and cleanup, while preserving Update and Doctor sequencing. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 3 items remain Still useful: current main retains blocking schema snapshots. No concrete introduced correctness defect found; the declared final Linux lifecycle verification remains outstanding. Priority: P2 Review scores
Verification
How this fits togetherBefore Gateway startup, updates, and Doctor maintenance, OpenClaw inspects existing SQLite databases for compatibility. Private snapshot workers feed those checks; the Gateway host now owns their cancellation and cleanup during startup. flowchart TD
A[Gateway startup or maintenance] --> B[Database preflight]
C[Existing SQLite stores] --> D[Private snapshot worker]
B --> D
D --> E[Version and shape checks]
E --> F[Continue or report refusal]
G[Gateway stop request] --> H[Cancel worker and join cleanup]
H --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +186, Tests +466. Total +652 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the existing isolated snapshot strategy under one host-owned cancellation and cleanup boundary, with compiled startup and shutdown behavior verified. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main synchronously waits for snapshot workers during schema inspection, and the existing live-WAL fixture supplies a focused event-loop regression path. This review did not execute it. Is this the best way to solve the issue? Yes, architecturally: reusing the snapshot owner and AsyncWorkScope addresses both blocking and worker lifetime; changing transport alone would leave the recorded orphan-worker failure unresolved. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1a13b42b6b75. 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
HistoryReview history (1 earlier review cycle)
|
5fcb700 to
a6cb4a1
Compare
|
Final verification is complete for On matched Linux / Node 26.7 compiled builds, baseline schema preflight serviced zero callbacks over 185.4 ms; the candidate serviced 33 over 169.4 ms, with a 5.41 ms largest adjacent in-phase gap. Both reached an owned readiness endpoint. This establishes preflight scheduling progress; it does not establish an overall startup-speed improvement. Both real Gateway startup stop paths passed. During schema copying, the worker closed from SIGTERM in 7.15 ms and the parent closed with code 0 in 28.84 ms, with no later network bootstrap. During ownership inspection, the parent remained alive after accepted STOP while the exact child was deliberately paused; after the timing control was released, actual child SIGTERM close and staging cleanup preceded parent exit 0. No fallback signals, orphan workers, live group, or staging residue were needed to make either result pass. All 32 changed checks and 772 focused tests passed; one Windows-only case was skipped on Linux. Live-WAL POSIX-lock and uncommitted-writer-version assertions passed explicitly. The independent baseline used its own checkout and frozen dependency install. Source/build/harness inventories matched, including all 38,048 candidate and 38,027 baseline source entries against immutable Git blobs. Exact-head CI passed. The data-model warning refers to private child-process replies relocated into The delegated Blacksmith Testbox command exited 0 and all acquired runtimes settled before capture. The 24,862,800-byte archive was downloaded and verified before lease closure (SHA-256 |
|
Merged via the native squash workflow as d46c7ee046a9, from tested head 1ce6848dbbe3. The accepted merge was reconciled after a post-dispatch GitHub policy-service timeout; no second merge request was sent. Final Linux, lifecycle, compatibility and CI evidence is complete. |
Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins.
Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins.
Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins.
Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins.
…law#138986) * fix: keep database preflight responsive during gateway startup * fix: join early database ownership checks during startup stop
Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins.
* refactor(update): stage and retain package and Git transactions Stage supported package-manager layouts and prebuilt Git runtimes before activation. Expose candidate validation and activation boundaries, retain the previous package and launcher until finalization, and preserve the original failure when source exposure is cancelled. Verify the requested package version before admitting a staged no-op. Replace live Git install/build and rollback rebuild work with prepared runtime promotion. (cherry picked from commit 0a1e09cb5350e1e1268d07753c11551d24549aa1) * feat(update): validate online and verify activation or rollback Keep the gateway serving during candidate staging, lint, config/plugin checks, and an isolated SQLite-snapshot canary. Same-version and same-SHA no-ops never stop the service. Limit activation downtime to swap, owned migrations, and start. Record settle, version/build, plugin, channel, readiness, advisory inference, and downtime in the existing run ledger. Restore retained package transactions only across unchanged state schemas, using prior verification to authorize the previous gateway restart. Hand migrated-state finalization to candidate code. Park managed helpers only at activation. Give the spawn fallback runner sole ownership of helper stdin so activation acknowledgements reach its child. Protect active backups from cleanup and CLI-owned runs from premature notices. Refs #137580, #136997, #124396. (cherry picked from commit 5523f4f419652d7e6666fa53dc19c650528aba0d) * docs(update): explain staged activation and schema-neutral recovery Document no-op behavior, candidate validation, bounded activation, verified package rollback, migration refusal, downtime, and managed-helper ownership. (cherry picked from commit d1dc73c804e02626e89d677970744bf1b235269b) * fix(update): preserve run ownership and explain skipped rollback Record an explicit no-retained-package fact when post-core verification fails without a rollback transaction, keeping the original failing oracle and service policy. Verify the durable report with an isolated real ledger. Keep staging and repair under CLI completion ownership too, so sentinel expiry after an unrelated gateway boot cannot prematurely finish an active update run. The existing phase regression fails for both phases before this fix. (cherry picked from commit c212030ce05a41018c0d2f335d49e65ec999c92c) * fix(update): restore a running previous generation after rollback Restore package bytes and shims, the config writer version, the owned service definition, and the previous Node runtime across unchanged config and schemas. Scope the existing older-binary recovery allowance to service invocations. Carry complete restoration proof into the managed helper, keep its ledger run open through CLI unwind, and recover instead of unconditionally parking on exit 79. Refresh observed service facts and retain restoration receipts when bounded diagnostics are evicted. Successful recovery remains a failed update but records rolled-back, the previous version, and verified downtime. Wait on actual ownership validation readiness and isolate all helper test coordinators while preserving real cross-process arbitration within fixtures. Document the recovery boundary and the helper's observed verification limits. Follow-up: review zero-wait coordinator admission under concurrent independent updates; the existing lease reader maps SQLite contention to unavailable identity. This change does not alter production store concurrency policy. Validation: full CLI/ledger/report scope 948 passed (1 skipped); handoff/package scope 176 passed (2 skipped); two concurrent lifecycle copies passed 154/154 each during a separate checkout build; closing cross-process/CLI scope 114 passed (1 skipped). pnpm build, the complete changed-files gate, and P1 autoreview pass. (cherry picked from commit fe3fa2e7dd29ca98e9e5e8c375f9e7431d4733dc) * fix(update): preserve sibling packages during late native rollback Recheck the native global project before stopping a reachable candidate and again before restoring any project or launcher bytes. Compare the finalized staging fingerprint, excluding OpenClaw payloads, using the existing helper with per-entry digests and direct sibling entries. Refuse changed-project rollback with rollback-project-changed, preserve the candidate and backups, record names-only details, and report recovery guidance. Keep the run failed without automatically repairing the shared project. npm package-root swaps retain their existing behavior. Validation: 85 focused tests passed; three final fixture cases passed after adding required service inspection fields. The new filesystem regression failed on the parent for pnpm 10, pnpm 11, and Bun. Full changed-file checks and fresh Codex P0/P1 autoreview passed. Production +112 lines, tests +179 lines, docs +2 lines; no new fingerprint implementation, configuration, or schema. (cherry picked from commit 0abb72b514226cc0b4cd4d0f99207e93aedad99b) * fix(update): preserve verification and cancellation ownership Verify metadata-refresh restarts through the same readiness and inference path, preserve rollback recovery ownership, and reject cancelled activation after asynchronous checks. Keep schema/protocol verification fields aligned and share update step and state-snapshot types. Carry the cancellation-only hardening from campaign commit d37a9418d94 without its automatic repair integration. Regression proofs cover refresh readiness, Windows autostart compensation, and systemd/launchd cancellation boundaries. * fix(update): require safe recovery before restoring autostart Narrow the recovery verdict before consuming service health. Align native Windows fixtures with their actual enabled state, verify compensation after an enable commits and fails, and preserve the precise interrupted verification diagnostic. Keep npm staging and cleanup assertions on the current namespace. * refactor(update): keep verified service recovery in its owner Move failed-update restart into the existing recovery module, retain the service facade, and await Doctor lifecycle cleanup. Align Doctor tests with HTTP readiness and advisory inference, including a healthy service with unready HTTP and preserved probe-port coverage. Complete synthetic helper teardown before removing its files. * fix(update): preserve staging and plugin maintenance boundaries Use effective pnpm configuration arguments and verify staged root/bin destinations before installing. Preserve relative external dependency links during Git promotion through the same relocation owner as native package staging. Centralize post-plugin completion in the parent updater after the fresh child finishes package work. Park the owned service only for required Doctor maintenance, retain Windows compensation through verification, and measure the full second outage. Keep downgrade writes in the target runtime and validate unchanged-plugin configuration with that runtime's schema. Remove the recovery-to-command import cycle. Cover native destination refusal, promoted imports, fresh child/parent lease boundaries, target-owned downgrade stamps, and migration/restart timing. Isolated real pnpm and Doctor coordinator flows verify the dependency and maintenance contracts. * fix(update): finalize unmanaged runs after gateway restart Use the recorded CLI trigger or managed handoff identity to preserve verification ownership. An unmanaged RPC also reaches restarting, so its phase cannot imply an updater exists to finish it. Keep notice expiry bounded while preserving managed verification. Reproduce four unmanaged completion failures before the fix; cover successful and expired unmanaged runs, managed API/chat/control-plane/campaign handoffs, and all CLI phases. Gateway owner, sentinel, and update method tests: 150 passed. Codex P1 local review clean. * fix(update): retain complete candidate dependency stores Retain configured Git virtual stores inside the exact preflight cleanup boundary, including sibling and symlinked stores. Rebase external store metadata and launchers, preserve rollback, and refuse source or destination checkout overlap through aliases. Share native and Git relocation of links, manifests, and launchers. Keep pnpm candidate project stores private through the supported invocation environment so staging cannot prune the serving generation. Preserve operator configuration and ordinary subsequent package-manager operations. Proof: five pre-fix Git regressions; 40 Git/native transaction and 27 post-update tests passed, followed by eight focused overlap/native tests. Real pnpm proof covers seven Git layouts and four native manager/store modes, imports, launchers, metadata, rollback, promotion, and subsequent global install. Codex P1 review clean. * test(update): preserve online inspection through package executor * test(update): align transaction fixtures and prune unused exports * fix(update): retain Git runtime backups after failed restoration * test(update): consolidate post-update fixtures for lint * fix(update): preserve recovery ownership and CI prerequisites Remove the history-based cleanup lock. A killed updater leaves a running ledger row, but history is not retirement authority: migration cleanup already verifies its own archives under exclusive maintenance ownership. Package, shim, and Git runtime backups belong to separate transactions. This also avoids opening the ledger before external state ownership checks. Register the real candidate canary and migrated-update process fixtures with their runtime build owner. Partition whole-config consumers before striping, keeping one runtime build and removing the sibling-sharing exception without changing CI caps or worker budgets. Align installed-CLI validation, managed handoff, and native stop fixtures with the transaction and service-owner contracts. * test(ci): derive runtime exclusions from the consumer catalog * fix(update): preserve report ownership across candidate migration Suspend every old CLI progress reader at activation and resume only after schema compatibility is established. Let migrated candidates own final reporting, and keep the permanent finished-notice key available while CLI verification remains pending. Preserve the merged update-surface contracts, truthful acknowledgement wording, and canonical restart successor ownership. Regression coverage includes real candidate migration in text and JSON modes plus sentinel expiry followed by verified completion. * fix(update): preserve live SQLite artifacts during inspection Use the canonical private snapshot owner for candidate copies and schema inspection. Discover registered databases from the same private generation instead of reopening the live registry, and preserve original locators in rollback receipts. Keep the existing bounded inspection deadline and fail-closed rollback behavior. Regression coverage reproduces source WAL sidecar creation, checks closed WAL and rollback stores, and verifies committed schema visibility while a live writer retains its transaction. * test(update): sort artifact entries without mutation * fix(update): preserve active runtime ownership during staged updates Keep candidate pnpm stores private across installs, nested lifecycle commands, workspace configuration, native staging, and Git promotion so preparation cannot prune the serving generation or leave activated dependencies behind. Record the active package root at each activation and restoration boundary. Launch post-activation schema inspection from that package and selected Node; retain unknown identity after partial moves until recovery verifies the original. Accumulate verified outage intervals independently of mutable ledger health, excluding online plugin work. Register built schema-worker test prerequisites. Refs #136997, #137580, #124396. * test(ci): type build admission argument rows explicitly * fix(update): await the async schema preflight before activation Follow #138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins. * fix(update): restart the unchanged gateway after native swap refusal Record live mutation in the swap owner after its native project recheck, immediately before the first move. A sibling change during shutdown now preserves safe recovery of the original package without restoring over the sibling. Extend the native refusal matrix with the original recovery version and exercise its safe restart outcome through finalization. Keep late rollback-project-changed behavior unchanged. * fix(update): preserve finalization for older downgrade targets Keep the shipped explicit downgrade contract when a candidate predates the migration-continuation worker. Record runtime validation as unavailable before invoking new-only canary commands, then use the established finalization owner. Present workers must still report their schema contract, and database preflights remain mandatory when target schema metadata is available. Do not attempt the new schema-worker or rollback contract for targets that do not provide it. * fix(update): make Windows Bun refusal actionable Preserve the pre-stop refusal for Bun's Windows launchers. Carry the inspected install spec into staging so the failed step names the exact manual Bun install, Gateway restart, and update-status commands. Bun is an opt-in runtime; keep one supported staging flow instead of adding an in-place fallback. Match the updating guide to the emitted recovery instructions. * perf(update): avoid snapshot imports during schema inspection Load the verified-snapshot dependency only when snapshot rehearsal runs. Schema-version workers do not need the snapshot module's memory and plugin import graph. Keep the same private-copy inspection and 30-second worker deadline. This changes dependency loading without changing SQLite schemas, data, or recovery policy. * fix(update): keep the owned managed-update environment when given process.env The absent-service rollback regression exposed an aliased input: clearing process.env also cleared the environment supplied to the phase. Reuse the existing snapshot for that input and preserve restoration after failure. The environment-only regression fails before the repair; copied-input and rollback sibling paths pass. * fix(triage): accept the unavailable canary advisory Preserve failure diagnostics after a confirmed downgrade to a target without migration continuation. The diagnostic boundary accepts both advisory variants while retaining only actual failed steps; the new advisory row failed schema validation before this repair. * test(ci): route real-worker update CLI tests to the process lane Keep rollback, post-update recovery and service integration tests that launch built schema workers in the existing isolated serial process owner. Move their runtime prerequisites with them and preserve CI partition, concurrency and budget assertions. All three routing regressions failed before the owner correction. * test(update): align downgrade and recovery fixtures with checks Supply the required invariant diagnostic and construct recovery table rows without map-spread. Preserve all cases and assertions. * test(ci): align CLI build admission with process ownership The shared CLI config has no runtime consumers after moving the real-worker update tests. Test it in the no-build table and retain process-lane build, failure, exclusion and SIGTERM coverage. Fixes the stale build.pid expectation from CI run 33991347672 without changing deadlines or production behavior. * test(update): verify candidate snapshots through the worker Snapshot backup and VACUUM run in a dedicated production process so cancellation can join before cleanup. Direct Vitest DELETE and symlink cases hit their 120-second deadline, while the equivalent worker copies preserved source bytes in about seven seconds. Exercise the existing worker entrypoint, retain every registry and artifact assertion, and bound the child to 30 seconds. * test(update): include helper logs in terminal outcome failures A loaded-host run restored the Gateway but left the ledger running. The six-case and full 154-case reruns passed without a production change. Preserve helper diagnostics in the assertion so a recurrence exposes the terminal-writer failure; no behavioral fix or timeout relaxation is claimed. * test(update): preserve launchd recovery identity proof after restack Carry the real stripped helper environment and emulated recovery cleanup from #139393 into the extracted transaction boundary fixture. * fix(update): retain runtime evidence across partial backup cleanup A cross-device backup move can publish its backup, remove the source dist inventory, then reject after deleting a runtime file. Directory order varies by filesystem. Older packages may legitimately lack that inventory, so a fresh verification using only surviving metadata could accept a gutted tree. Retain the expected dist files before mutation and compare the surviving runtime against them before accepting recovery without a completed rollback. A partially removed package must never be reported as the active root. Preserve recovery of an unchanged package after a refused backup move. Make the existing cleanup regression exercise inventory-first deletion; it fails before this fix with the same active-root assertion as CI. Recovery and native transaction suites pass all 57 cases. Extend CLI finalization coverage to ensure failed swaps with unsafe recovery never restart the package. * fix(update): verify recovery inventory at the previous package root * fix(update): retain backups until activation or restoration is verified * test(update): isolate handoff workers and child result publication
…w#138839) * refactor(update): stage and retain package and Git transactions Stage supported package-manager layouts and prebuilt Git runtimes before activation. Expose candidate validation and activation boundaries, retain the previous package and launcher until finalization, and preserve the original failure when source exposure is cancelled. Verify the requested package version before admitting a staged no-op. Replace live Git install/build and rollback rebuild work with prepared runtime promotion. (cherry picked from commit 0a1e09cb5350e1e1268d07753c11551d24549aa1) * feat(update): validate online and verify activation or rollback Keep the gateway serving during candidate staging, lint, config/plugin checks, and an isolated SQLite-snapshot canary. Same-version and same-SHA no-ops never stop the service. Limit activation downtime to swap, owned migrations, and start. Record settle, version/build, plugin, channel, readiness, advisory inference, and downtime in the existing run ledger. Restore retained package transactions only across unchanged state schemas, using prior verification to authorize the previous gateway restart. Hand migrated-state finalization to candidate code. Park managed helpers only at activation. Give the spawn fallback runner sole ownership of helper stdin so activation acknowledgements reach its child. Protect active backups from cleanup and CLI-owned runs from premature notices. Refs openclaw#137580, openclaw#136997, openclaw#124396. (cherry picked from commit 5523f4f419652d7e6666fa53dc19c650528aba0d) * docs(update): explain staged activation and schema-neutral recovery Document no-op behavior, candidate validation, bounded activation, verified package rollback, migration refusal, downtime, and managed-helper ownership. (cherry picked from commit d1dc73c804e02626e89d677970744bf1b235269b) * fix(update): preserve run ownership and explain skipped rollback Record an explicit no-retained-package fact when post-core verification fails without a rollback transaction, keeping the original failing oracle and service policy. Verify the durable report with an isolated real ledger. Keep staging and repair under CLI completion ownership too, so sentinel expiry after an unrelated gateway boot cannot prematurely finish an active update run. The existing phase regression fails for both phases before this fix. (cherry picked from commit c212030ce05a41018c0d2f335d49e65ec999c92c) * fix(update): restore a running previous generation after rollback Restore package bytes and shims, the config writer version, the owned service definition, and the previous Node runtime across unchanged config and schemas. Scope the existing older-binary recovery allowance to service invocations. Carry complete restoration proof into the managed helper, keep its ledger run open through CLI unwind, and recover instead of unconditionally parking on exit 79. Refresh observed service facts and retain restoration receipts when bounded diagnostics are evicted. Successful recovery remains a failed update but records rolled-back, the previous version, and verified downtime. Wait on actual ownership validation readiness and isolate all helper test coordinators while preserving real cross-process arbitration within fixtures. Document the recovery boundary and the helper's observed verification limits. Follow-up: review zero-wait coordinator admission under concurrent independent updates; the existing lease reader maps SQLite contention to unavailable identity. This change does not alter production store concurrency policy. Validation: full CLI/ledger/report scope 948 passed (1 skipped); handoff/package scope 176 passed (2 skipped); two concurrent lifecycle copies passed 154/154 each during a separate checkout build; closing cross-process/CLI scope 114 passed (1 skipped). pnpm build, the complete changed-files gate, and P1 autoreview pass. (cherry picked from commit fe3fa2e7dd29ca98e9e5e8c375f9e7431d4733dc) * fix(update): preserve sibling packages during late native rollback Recheck the native global project before stopping a reachable candidate and again before restoring any project or launcher bytes. Compare the finalized staging fingerprint, excluding OpenClaw payloads, using the existing helper with per-entry digests and direct sibling entries. Refuse changed-project rollback with rollback-project-changed, preserve the candidate and backups, record names-only details, and report recovery guidance. Keep the run failed without automatically repairing the shared project. npm package-root swaps retain their existing behavior. Validation: 85 focused tests passed; three final fixture cases passed after adding required service inspection fields. The new filesystem regression failed on the parent for pnpm 10, pnpm 11, and Bun. Full changed-file checks and fresh Codex P0/P1 autoreview passed. Production +112 lines, tests +179 lines, docs +2 lines; no new fingerprint implementation, configuration, or schema. (cherry picked from commit 0abb72b514226cc0b4cd4d0f99207e93aedad99b) * fix(update): preserve verification and cancellation ownership Verify metadata-refresh restarts through the same readiness and inference path, preserve rollback recovery ownership, and reject cancelled activation after asynchronous checks. Keep schema/protocol verification fields aligned and share update step and state-snapshot types. Carry the cancellation-only hardening from campaign commit d37a9418d94 without its automatic repair integration. Regression proofs cover refresh readiness, Windows autostart compensation, and systemd/launchd cancellation boundaries. * fix(update): require safe recovery before restoring autostart Narrow the recovery verdict before consuming service health. Align native Windows fixtures with their actual enabled state, verify compensation after an enable commits and fails, and preserve the precise interrupted verification diagnostic. Keep npm staging and cleanup assertions on the current namespace. * refactor(update): keep verified service recovery in its owner Move failed-update restart into the existing recovery module, retain the service facade, and await Doctor lifecycle cleanup. Align Doctor tests with HTTP readiness and advisory inference, including a healthy service with unready HTTP and preserved probe-port coverage. Complete synthetic helper teardown before removing its files. * fix(update): preserve staging and plugin maintenance boundaries Use effective pnpm configuration arguments and verify staged root/bin destinations before installing. Preserve relative external dependency links during Git promotion through the same relocation owner as native package staging. Centralize post-plugin completion in the parent updater after the fresh child finishes package work. Park the owned service only for required Doctor maintenance, retain Windows compensation through verification, and measure the full second outage. Keep downgrade writes in the target runtime and validate unchanged-plugin configuration with that runtime's schema. Remove the recovery-to-command import cycle. Cover native destination refusal, promoted imports, fresh child/parent lease boundaries, target-owned downgrade stamps, and migration/restart timing. Isolated real pnpm and Doctor coordinator flows verify the dependency and maintenance contracts. * fix(update): finalize unmanaged runs after gateway restart Use the recorded CLI trigger or managed handoff identity to preserve verification ownership. An unmanaged RPC also reaches restarting, so its phase cannot imply an updater exists to finish it. Keep notice expiry bounded while preserving managed verification. Reproduce four unmanaged completion failures before the fix; cover successful and expired unmanaged runs, managed API/chat/control-plane/campaign handoffs, and all CLI phases. Gateway owner, sentinel, and update method tests: 150 passed. Codex P1 local review clean. * fix(update): retain complete candidate dependency stores Retain configured Git virtual stores inside the exact preflight cleanup boundary, including sibling and symlinked stores. Rebase external store metadata and launchers, preserve rollback, and refuse source or destination checkout overlap through aliases. Share native and Git relocation of links, manifests, and launchers. Keep pnpm candidate project stores private through the supported invocation environment so staging cannot prune the serving generation. Preserve operator configuration and ordinary subsequent package-manager operations. Proof: five pre-fix Git regressions; 40 Git/native transaction and 27 post-update tests passed, followed by eight focused overlap/native tests. Real pnpm proof covers seven Git layouts and four native manager/store modes, imports, launchers, metadata, rollback, promotion, and subsequent global install. Codex P1 review clean. * test(update): preserve online inspection through package executor * test(update): align transaction fixtures and prune unused exports * fix(update): retain Git runtime backups after failed restoration * test(update): consolidate post-update fixtures for lint * fix(update): preserve recovery ownership and CI prerequisites Remove the history-based cleanup lock. A killed updater leaves a running ledger row, but history is not retirement authority: migration cleanup already verifies its own archives under exclusive maintenance ownership. Package, shim, and Git runtime backups belong to separate transactions. This also avoids opening the ledger before external state ownership checks. Register the real candidate canary and migrated-update process fixtures with their runtime build owner. Partition whole-config consumers before striping, keeping one runtime build and removing the sibling-sharing exception without changing CI caps or worker budgets. Align installed-CLI validation, managed handoff, and native stop fixtures with the transaction and service-owner contracts. * test(ci): derive runtime exclusions from the consumer catalog * fix(update): preserve report ownership across candidate migration Suspend every old CLI progress reader at activation and resume only after schema compatibility is established. Let migrated candidates own final reporting, and keep the permanent finished-notice key available while CLI verification remains pending. Preserve the merged update-surface contracts, truthful acknowledgement wording, and canonical restart successor ownership. Regression coverage includes real candidate migration in text and JSON modes plus sentinel expiry followed by verified completion. * fix(update): preserve live SQLite artifacts during inspection Use the canonical private snapshot owner for candidate copies and schema inspection. Discover registered databases from the same private generation instead of reopening the live registry, and preserve original locators in rollback receipts. Keep the existing bounded inspection deadline and fail-closed rollback behavior. Regression coverage reproduces source WAL sidecar creation, checks closed WAL and rollback stores, and verifies committed schema visibility while a live writer retains its transaction. * test(update): sort artifact entries without mutation * fix(update): preserve active runtime ownership during staged updates Keep candidate pnpm stores private across installs, nested lifecycle commands, workspace configuration, native staging, and Git promotion so preparation cannot prune the serving generation or leave activated dependencies behind. Record the active package root at each activation and restoration boundary. Launch post-activation schema inspection from that package and selected Node; retain unknown identity after partial moves until recovery verifies the original. Accumulate verified outage intervals independently of mutable ledger health, excluding online plugin work. Register built schema-worker test prerequisites. Refs openclaw#136997, openclaw#137580, openclaw#124396. * test(ci): type build admission argument rows explicitly * fix(update): await the async schema preflight before activation Follow openclaw#138986's asynchronous database preflight contract before checking its result. Passing the promise to hasSchemaRefusal otherwise throws on package activation. Keep Git's mutation fence after its post-stop schema check so interruption can restore the unchanged Windows task. Reject retained recovery handles as soon as settlement begins. * fix(update): restart the unchanged gateway after native swap refusal Record live mutation in the swap owner after its native project recheck, immediately before the first move. A sibling change during shutdown now preserves safe recovery of the original package without restoring over the sibling. Extend the native refusal matrix with the original recovery version and exercise its safe restart outcome through finalization. Keep late rollback-project-changed behavior unchanged. * fix(update): preserve finalization for older downgrade targets Keep the shipped explicit downgrade contract when a candidate predates the migration-continuation worker. Record runtime validation as unavailable before invoking new-only canary commands, then use the established finalization owner. Present workers must still report their schema contract, and database preflights remain mandatory when target schema metadata is available. Do not attempt the new schema-worker or rollback contract for targets that do not provide it. * fix(update): make Windows Bun refusal actionable Preserve the pre-stop refusal for Bun's Windows launchers. Carry the inspected install spec into staging so the failed step names the exact manual Bun install, Gateway restart, and update-status commands. Bun is an opt-in runtime; keep one supported staging flow instead of adding an in-place fallback. Match the updating guide to the emitted recovery instructions. * perf(update): avoid snapshot imports during schema inspection Load the verified-snapshot dependency only when snapshot rehearsal runs. Schema-version workers do not need the snapshot module's memory and plugin import graph. Keep the same private-copy inspection and 30-second worker deadline. This changes dependency loading without changing SQLite schemas, data, or recovery policy. * fix(update): keep the owned managed-update environment when given process.env The absent-service rollback regression exposed an aliased input: clearing process.env also cleared the environment supplied to the phase. Reuse the existing snapshot for that input and preserve restoration after failure. The environment-only regression fails before the repair; copied-input and rollback sibling paths pass. * fix(triage): accept the unavailable canary advisory Preserve failure diagnostics after a confirmed downgrade to a target without migration continuation. The diagnostic boundary accepts both advisory variants while retaining only actual failed steps; the new advisory row failed schema validation before this repair. * test(ci): route real-worker update CLI tests to the process lane Keep rollback, post-update recovery and service integration tests that launch built schema workers in the existing isolated serial process owner. Move their runtime prerequisites with them and preserve CI partition, concurrency and budget assertions. All three routing regressions failed before the owner correction. * test(update): align downgrade and recovery fixtures with checks Supply the required invariant diagnostic and construct recovery table rows without map-spread. Preserve all cases and assertions. * test(ci): align CLI build admission with process ownership The shared CLI config has no runtime consumers after moving the real-worker update tests. Test it in the no-build table and retain process-lane build, failure, exclusion and SIGTERM coverage. Fixes the stale build.pid expectation from CI run 33991347672 without changing deadlines or production behavior. * test(update): verify candidate snapshots through the worker Snapshot backup and VACUUM run in a dedicated production process so cancellation can join before cleanup. Direct Vitest DELETE and symlink cases hit their 120-second deadline, while the equivalent worker copies preserved source bytes in about seven seconds. Exercise the existing worker entrypoint, retain every registry and artifact assertion, and bound the child to 30 seconds. * test(update): include helper logs in terminal outcome failures A loaded-host run restored the Gateway but left the ledger running. The six-case and full 154-case reruns passed without a production change. Preserve helper diagnostics in the assertion so a recurrence exposes the terminal-writer failure; no behavioral fix or timeout relaxation is claimed. * test(update): preserve launchd recovery identity proof after restack Carry the real stripped helper environment and emulated recovery cleanup from openclaw#139393 into the extracted transaction boundary fixture. * fix(update): retain runtime evidence across partial backup cleanup A cross-device backup move can publish its backup, remove the source dist inventory, then reject after deleting a runtime file. Directory order varies by filesystem. Older packages may legitimately lack that inventory, so a fresh verification using only surviving metadata could accept a gutted tree. Retain the expected dist files before mutation and compare the surviving runtime against them before accepting recovery without a completed rollback. A partially removed package must never be reported as the active root. Preserve recovery of an unchanged package after a refused backup move. Make the existing cleanup regression exercise inventory-first deletion; it fails before this fix with the same active-root assertion as CI. Recovery and native transaction suites pass all 57 cases. Extend CLI finalization coverage to ensure failed swaps with unsafe recovery never restart the package. * fix(update): verify recovery inventory at the previous package root * fix(update): retain backups until activation or restoration is verified * test(update): isolate handoff workers and child result publication
What Problem This Solves
Fixes an issue where Gateway startup and database maintenance become unresponsive while inspecting large existing SQLite stores.
Why This Change Was Made
Schema preflight now awaits the existing isolated, byte-preserving snapshot strategy. It keeps version/shape checks, per-database ordering, source-file protection, and cleanup at their existing owners.
The Gateway run loop owns the resource-bearing ownership and schema checks through one per-start work scope. Accepted stops cancel and join the child and its private staging before exit; queued startup restarts retain their existing behavior. Snapshot errors settle after child close, and cleanup failures remain failures. The sync and async worker transports share argument construction, result validation, and process completion handling; snapshot strategy, staging, and cleanup remain in their existing owner. The Windows update owner also rejects mutation after interruption or completed recovery, including signals received during the newly awaited schema check.
Database schemas, migration decisions, shutdown deadlines, configuration, and dependencies remain unchanged.
User Impact
The event loop can service work while snapshot preparation runs, and Gateway stop joins its database workers and staging cleanup before reporting a clean exit. Overall startup duration still depends on copying and validation.
Direct in-process container onboarding still has its existing noncancellable startup-before-handle limitation. This change does not claim clean child teardown after forced process exit in that path.
Evidence
a6cb4a10c351) confirmed the earlier ownership gap: after parent-only SIGTERM, the Gateway exited/closed with code 0 in 30 ms while its deliberately paused snapshot worker remained alive under PID 1. Source/dist/harness seals were stable; recovery and fixture cleanup were recorded separately. This controlled pause proves lifetime ownership, not natural latency or production frequency.Final verification on public head
1ce6848dbbe3fbb83f91dadded8704ee517a5162is complete:/readyz200. These single instrumented runs establish scheduling progress; they do not establish overall startup acceleration or a latency distribution.Remote proof used Crabbox 0.49.1 with the configured Blacksmith Testbox backend, lease
tbx_01m1rk2v2zfwjsydpj9f4xxyce. The delegated command exited 0; the 24,862,800-byte evidence archive was downloaded and SHA-256 verified before lease closure (514242a6ac34fada8580155492683a75276094dbebd4f73012880898185a820f). The persistent Testbox workflow shows cancelled after normal lease cleanup; its command result and retained receipts are successful.Validation history is retained: an initial pre-lease base-ref guard refused a raw SHA, the next Linux gate rejected a widening assertion, and earlier CI found test syntax/file-length issues. The final revision passes those guards without suppressions or longer timeouts.
The data-model review heuristic refers to private child-process JSON replies moved between modules. Their
{ ok, location }/{ ok, message }shapes are unchanged; no persisted tables, schema definitions, migrations, or SQLite transaction policy change. The extra worker argument names only caller-owned temporary staging. Existing schema compatibility/refusal and source-artifact tests remain in the completed proof.Production LOC: +335/-149 (net +186, including the worker transport move). Tests: +592/-126. The production growth supplies the startup operation lifetime and parent-owned temporary staging required to cancel and join safely; changing only the blocking transport reproduced the orphan-worker failure above.