Skip to content

fix: update plugins after the new Gateway starts - #204127

Merged
obviyus merged 9 commits into
mainfrom
fix/204035-plugin-maintenance
Nov 23, 2026
Merged

obviyus merged 9 commits into
mainfrom
fix/204035-plugin-maintenance

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Prepared-release updates ran the candidate's plugin maintenance before restarting the serving Gateway. When the candidate needed a newer shared-state schema, that maintenance correctly refused to migrate under the old Gateway. Core activation could succeed while plugins missed their update.

Closes #204035.

User Impact

The new version reports success as soon as it is ready. Plugin downloads, installs and runtime reloads run afterward, without holding core readiness or disabling Update. Final plugin results reach the open update details; real failures add an attention warning without failing or rolling back the core update.

Stopping the Gateway during maintenance can leave no final plugin result. Work may be incomplete; this is not an atomic all-old/all-new plugin transaction. Published compatible versions load at the next Gateway start, and openclaw plugins update --all finishes the rest.

Removed install records do not hot-unload an already-running plugin. As in the existing metadata-only update path, removal takes effect at the next Gateway start. This repair reloads changed records that still exist.

Why This Change Was Made

  • Remove candidate maintenance from pre-restart preparation for equal/newer versions. Downgrades retain the previous pre-trial maintenance because older targets do not run this post-ready job and do not migrate the schema forward.
  • Use one existing Gateway-watcher job after success: ten-minute plugin maintenance, release its lease, reload successful changes through the existing runtime lifecycle, then run advisory Doctor inspections.
  • Record only final plugin steps. Preserve explicit capability consent in one optional field in the existing trial record; absence never approves widened capabilities.
  • The internal update plugins --json result optionally carries existing batch-reload targets, captured from the exact published records under the publishing lease. The parent passes their hashes unchanged; the existing batch check refuses a record changed again before reload.
  • Bind both commands to existing watcher cancellation and command-process cleanup, so stop/restart does not wait for their work budgets.

No new scheduler, timer, retry, in-progress marker, plugin staging mechanism, SQL, protocol or config change. Already-current updates keep their existing maintenance/restart behavior. An upgrade candidate that crashes before readiness does not start plugin maintenance.

Accepted edge case: a Git target with the same version string but an older revision gets no plugin maintenance if that revision lacks the post-ready job. Run openclaw plugins update --all in that case.

Ownership is unchanged: update plugins calls the maintenance owner directly, not the offline plugins update command. Its plugin lifecycle lease uses ordinary shared-state access. gateway-state-owner-record.ts:132–134 permits that access while a Gateway serves; schema mutation has a separate exclusive lease and still refuses a foreign owner. The earlier real three-plugin command completed with the managed Gateway up (run_f97b488afec5a305855aaaf6ba36ff64, 46.20 s, schema 41). That is same-schema ownership evidence, not the repaired schema-bump proof. Plugin-owned SQL migrations retain their existing refusals.

Evidence

  • Red on main: the preparation regression exercises real candidate plugin lifecycle/schema admission while the old Gateway owns older state and captures the reported schema-mutation refusal.
  • Head 37415ace28cf3b98055b6b707115f9dd9566986d: AWS focused preparation, trial settlement, late ledger receipt, and plugin-record publication suites passed on production-identical 9507eb380c (run_21799856ebb39d5a8f48461e3c9fb78e), with all 14 changed TypeScript files' lint, export collision guard, and TypeScript/docs format. The ledger-only assertion reduction then passed its suite, lint, format and ratchet on the final head (run_91d5a424ce7fc02ef11e44244d7da329). Earlier 15-suite/core-typecheck evidence is retained on 550010466eae (run_5f88592c54ec96289086157555acda72); it is not represented as final-head execution.
  • Test budget: removed 12 duplicate report-assertion lines; trial settlement remains the report behavior owner. Both downgrade decisions already share it.each. Net +465 test lines retain distinct schema-admission, consent, late-receipt, child-cancellation and exact-install reload contracts; the allocation is 65 above the 400-line allowance. The required local ratchet passed before push.
  • Design measurement, not fix proof: three real IRC/Matrix/MS Teams updates took 46.20 seconds in one untraced warm-cache run. The separate counted filesystem performance finding is Plugin maintenance performs millions of filesystem metadata calls after npm updates #204046, not part of this repair.
  • Passing Linux Control UI proof on this head: official IRC .6 → .7 run ea01e4df-6fb3-453b-9484-023036b557d6 (AWS run_d1d3df4f1e0e6e55fcc36bad4826e01f) and compiled test-registry plugin 1.0.0 → 1.0.1 run 44217221-4196-436f-bb74-3bfd7a09eb12 (AWS run_6a29d07f27be45d349bb62bc076f8324). Both core updates succeeded through the real schema 41→42 migration chain, without generic fallback; plugins completed and Doctor inspections followed. Run details and Settings → Updates screenshots.
  • Official plugins are converged by the new core's own startup: IRC was already current before post-ready maintenance. The separate honest compiled fixture (two real archives in the kit registry, plain JavaScript, no SQL migration) proves the third-party path: after core success, installed/runtime version changed 1.0.0 → 1.0.1 and Gateway generation changed 2 → 3 with unchanged service PID. All 31 sampled readiness probes during that post-success work were healthy; final plugin work took 7.348 seconds, then Doctor finished with informational findings.
  • Full T/next builds retained exact source/build/schema provenance. Canonical stampFixtureVersion relabeled their package versions to T=2026.11.6, next=2026.11.7, preserving distinct build IDs, commits and schemas. Both qualified clicks followed two minutes of serving T plus observed maintenance ticks. Earlier live-own-lock interruption is tracked separately in fix(update): keep a Gateway's own update running when it first reports ready #204215; QQbot package refusal was a published-package missing-compiled-output finding, not an update regression.
  • Sampled outages were 65.678 seconds (official IRC) and 44.306 seconds (compiled fixture). An earlier no-plugin sample was 42.706 seconds but hit fix(update): keep a Gateway's own update running when it first reports ready #204215; it is not a clean controlled latency comparison. Crash rollback was explicitly removed from this PR's proof scope. All AWS leases were released with --wait. Local review is owned by the lead; no further proof variants are pending.
  • Linux container, macOS and Windows proof is unproven; this PR does not qualify a stable release.

Run candidate-owned plugin maintenance after core success under the Gateway update watcher, then apply changed plugins through the existing runtime reload owner before post-activation inspections.
Bind both commands to the existing watcher cancellation owner so Gateway shutdown stops the process tree without waiting for the work budget.
Keep plugin failures as late warning steps and preserve explicit capability consent in the existing trial record.
Closes #204035
@clawsweeper

clawsweeper Bot commented Nov 23, 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 size: L labels Nov 23, 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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Nov 23, 2026
@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Move plugin maintenance after successful Gateway activation, reload changed plugins, and append final results without changing core success.

Example: An update requires a newer shared-state schema and newer installed plugins.

  • Before: Candidate plugin maintenance runs while the old Gateway owns state and refuses the schema migration.
  • After: The new Gateway migrates state and reports ready before background plugin maintenance and reload begin.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful repair direction, but patch-caused CI defects remain and real update proof is pending; the optional acceptCapabilities field in releases/.trial also needs upgrade compatibility evidence.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A core update can succeed while plugin maintenance fails because the candidate attempts shared-state migration beneath the serving Gateway.
Reason: The failure is concrete, and the maintainer author explicitly chooses background maintenance with nonfatal failures and recoverable interruption.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-authored PR addresses a concrete update defect, but two patch-caused CI failures need repair.

Priority: P2
Reviewed head: e55fd96a4fdc502ca0f9d4e5fda2e02715a63874

Before merge

  • Wait for completion before closing the test work scope (P2) - Resolving command.promise and immediately calling work.drain() aborts the scope before the maintenance continuation records its result. The new production cancellation checks then correctly suppress that receipt. Exact-head CI fails both new plugin cases at line 480 and both existing inspection cases at line 347 for the same reason. Await ordinary work settlement before draining in completion tests, and preserve the separate watcher-stop cancellation case.
  • Use a distinct export for release-command orchestration (P2) - Exporting maintainPlugins here creates a second definition alongside src/update/plugins.ts. scripts/check-export-name-collisions.mts rejects this pair, and exact-head check-source-contracts reports that guard failing. Give the orchestration operation a distinct export and update its gateway-trial caller so the required source-contract check can pass.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P2] Wait for completion before closing the test work scope — src/update/gateway-trial.test.ts:472
  • [P2] Use a distinct export for release-command orchestration — src/update/run.ts:475

Tests

  • Missing end-to-end proof: Provide redacted real-update output showing schema-crossing activation, subsequent plugin update/reload, late receipts and rollback behavior, plus latest-stable upgrade compatibility; the body claims a red baseline but does not supply a passing head run.
Agent review details

How this fits together

The release updater prepares a candidate and persists a launcher trial; after activation, the Gateway watcher owns background maintenance and publishes results through the existing update ledger.

flowchart TD
  A[Update request] --> B[Prepare release]
  B --> C[Persist launcher trial]
  C --> D[New Gateway ready]
  D --> E[Record core success]
  E --> F[Watcher plugin maintenance]
  F --> G[Runtime reload and inspections]
  G --> H[Update ledger and details]
Loading

Technical review

Best possible solution:

Retain the existing watcher, maintenance and reload owners, repair the completion tests and export collision, and qualify the resulting update path.

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

Current-main ordering and migration-capable lease admission establish the reported conflict when a candidate needs a newer schema; the linked report supplies observed failures, but this review ran no reproduction.

Is this the best way to solve the issue?

Post-ready maintenance uses the appropriate existing owners and removes the conflicting pre-restart path; its interruption tradeoff is explicitly accepted by the maintainer author.

Full review comments:

  • [P2] Wait for completion before closing the test work scope — src/update/gateway-trial.test.ts:472
    Resolving command.promise and immediately calling work.drain() aborts the scope before the maintenance continuation records its result. The new production cancellation checks then correctly suppress that receipt. Exact-head CI fails both new plugin cases at line 480 and both existing inspection cases at line 347 for the same reason. Await ordinary work settlement before draining in completion tests, and preserve the separate watcher-stop cancellation case.
    Confidence: 0.99
  • [P2] Use a distinct export for release-command orchestration — src/update/run.ts:475
    Exporting maintainPlugins here creates a second definition alongside src/update/plugins.ts. scripts/check-export-name-collisions.mts rejects this pair, and exact-head check-source-contracts reports that guard failing. Give the orchestration operation a distinct export and update its gateway-trial caller so the required source-contract check can pass.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +123, Tests +389, Docs +18. Total +530 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 194 71 +123
Tests 3 393 4 +389
Docs 1 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 605 75 +530

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Schema-crossing updates can leave plugin maintenance incomplete while core activation succeeds; the report establishes no resulting channel outage.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Schema-crossing updates can leave plugin maintenance incomplete while core activation succeeds; the report establishes no resulting channel outage.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 execution lanes are retired.

Reviewed November 23, 2026, 11:12 AM ET / 16:12 UTC.

Capture optional internal batch reload targets from the records just published under the existing plugin lifecycle lease and preserve the batch install-hash precondition.
Pass the required channel-read argument, remove the exported helper name collision, and join successful background work before test teardown.
Keep receipt projection and diagnostic formatting in their existing owners without increasing the publication module line cap.
Test allocation: 415 net lines; the 15-line record covers owning-boundary schema, completion, cancellation and exact-install receipt proof.
Keep the existing Bun preflight cases in their own owning suite instead of growing the preparation suite beyond its line cap.
Use one watcher import, restore test spies through teardown, and simplify narrowed boolean assertions without changing tested behavior.
Test allocation is 423 net lines; the record covers the 23-line excess.

@THE-NAVVV THE-NAVVV left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

​

@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Nov 23, 2026
- Keep report behavior at trial settlement and retain ledger admission coverage.
- Allocate 65 lines above the base allowance for distinct schema, downgrade, consent, cancellation and exact-install reload owner boundaries.
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Exact-head Linux proof completed on 37415ace28cf3b98055b6b707115f9dd9566986d (AWS).

Case Durable update run AWS run Result
Published IRC 2026.11.6 → 2026.11.7 ea01e4df-6fb3-453b-9484-023036b557d6 run_d1d3df4f1e0e6e55fcc36bad4826e01f Core succeeded, schema 41→42 through the migration chain, plugins completed, then Doctor inspections completed. No false “Failed: plugins”.
Compiled test-registry plugin 1.0.0 → 1.0.1 44217221-4196-436f-bb74-3bfd7a09eb12 run_6a29d07f27be45d349bb62bc076f8324 Core succeeded first; post-ready maintenance updated the plugin and live batch reload changed Gateway generation 2→3 with unchanged service PID. plugins completed, then Doctor inspections completed.

Both updates used a real Settings → Updates click. The second plugin is an honest fixture: two distinct published archives in the kit registry, plain dist/index.js, a version log in register(api), and no SQL migration. It is not represented as a public third-party package. The serving Gateway reported the old and new versions active. All 31 readiness samples between core success and the final plugin receipt were healthy in the reload case (nominal 250 ms sampling); plugin work took 7.348 seconds after core success. Doctor returned informational findings, not an update failure.

The official-plugin run exposed an important boundary: the new core converges official plugins during its own startup, so IRC was already current before post-ready maintenance. That run proves clean official-plugin completion, not hot reload. The separate compiled fixture proves the post-ready path used by third-party plugins.

Fixture provenance: full T and next package builds came from this pushed head and a disposable child commit adding the real schema-42 table/catalog inputs. Canonical stampFixtureVersion relabeled the archives T=2026.11.6, next=2026.11.7, preserving their distinct build IDs, source commits and schemas. This lets genuine official IRC .7 resolve for next. Registry/channel and plugin-version routes were checked before each click. Both runs logged migration chain, with no generic-copy fallback.

T served for two minutes before each qualified click, with maintenance tick events captured. This avoids the independent live-own-lock interruption bug now tracked by #204215; the earlier failed row and live lock evidence were retained. QQbot was not used: its published 1.5.4/1.6.1 archives declare a TypeScript entry but omit compiled runtime output, and installation correctly refused them.

Sampled restart outages: 65.678 s (official IRC) and 44.306 s (compiled fixture). An earlier no-plugin sample was 42.706 s, but its row hit #204215; it is not a clean controlled comparison or a latency guarantee. The direct post-success samples above establish that maintenance/reload did not interrupt readiness in the passing fixture run.

AWS release receipts (stop --wait): final reload lease cbx_001a55c2d1ba released; official-plugin lease cbx_50b96b19630b released; build lease cbx_c18cf32195c0 released. Every earlier setup/failure lease was also released. Crash rollback was removed from scope; no rollback proof is claimed. No merge performed.

Settings Updates: successful official IRC update

Settings Updates: successful post-ready test-plugin reload

@obviyus
obviyus merged commit 3b64ff6 into main Nov 23, 2026
144 checks passed
@obviyus
obviyus deleted the fix/204035-plugin-maintenance branch November 23, 2026 20:51
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 3b64ff6.

  • Problem: release-path updates ran plugin maintenance from the new version before the restart, while the old Gateway still owned the state, so it was refused whenever the new version needed a newer schema: every such update showed "Failed: plugins" and third-party plugins stayed on their old versions.
  • Fix: after the update is recorded as succeeded, the serving Gateway updates plugins in the background (with the user's capability consent carried in the trial), reloads the changed ones through the hash-checked batch reload, then runs the Doctor checks. A downgrade keeps the old pre-restart path. Plugin failures stay warnings with a retry command that runs.
  • Proof: real Linux Control UI updates on this head: an official plugin (run ea01e4df) completed cleanly, and a third-party test plugin moved 1.0.0 → 1.0.1 live without a restart (run 44217221), with healthy readiness throughout.

obviyus added a commit that referenced this pull request Nov 23, 2026
…s ready (#204215)

Related: #203925

## What Problem This Solves

A Gateway that starts a release update takes the preparation lock under its own PID. On its first maintenance tick after it starts, `announceReady` treats any lock with its own PID as a leftover from an earlier Gateway that reused the PID, so it marks the running update `failed` with reason `interrupted` and releases the lock. The update itself continues and succeeds, but the recorded result says it failed.

Observed on Linux: run `90faf5a6-b3a4-4946-bebb-8f9ff903d6b6` was clicked shortly after a fresh Gateway start. The row was finished as `interrupted` at 20:02:00 while the old Gateway (PID 10561) was still preparing; the new Gateway started at 20:03 and served the target through the migration chain.

## User Impact

Clicking Update soon after a Gateway start no longer reports a working update as failed. A lock left by a dead process, or by an earlier Gateway whose PID a restarted container reused, is still settled as `interrupted`.

## Why This Change Was Made

The lock already records `startedAt`. A lock with this Gateway's PID counts as a leftover only when it was taken before this process started. No new state or check.

## Evidence

- `src/update/gateway-trial.test.ts`: the new `own-live` case (this Gateway's own lock, taken during its lifetime) fails on main (the run is marked `interrupted`) and passes here; the `same-pid` case now uses a lock from before the process started; `dead` and `live` are unchanged. All 10 trial tests pass.
- Real Linux proof on this head: a Control UI click 2.2 s after readiness (run `6567a5d6-184d-4c6c-849f-3d42fbd37fb5`); the own-PID lock survived two maintenance ticks during preparation and the run ended `succeeded` with the target serving. [Evidence](#204215 (comment)). The plugin warning in that run comes from this branch predating #204127.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
Closes #204085

Every release-path update that changes the state schema fails on Windows today: the startup swap renames over the live SQLite files while retained handles are still open. This also affects a successful migration chain, not only its generic-copy fallback (`state-upgrade.ts:566–584,660–663`). The launcher restores the previous release, but the update cannot complete. Shipped first hops use their existing in-place update route and are not affected by this release-path defect.

The candidate releases its closed databases' retained file descriptors before the startup swap. The Windows task supervisor now skips Gateway state and config bootstrap entirely, so it holds no database connection while its child runs. The child still loads its own dotenv files and selects its database and environment. Migration and rollback keep their existing owners and preserved files. There is no schema change or new user action.

An interrupted Windows swap that already created `.pre-*` hard links can still retain admission custody and roll back; this existing, visible recovery edge is unchanged.

Closing SQLite leaves the admission owner's identity descriptor open. A native Windows control reproduces the failure with both SQLite connections closed, then permits the same rename immediately after the existing admission-retirement operation runs. The durable swap now performs that retirement for both database paths before it preserves or replaces either file.

The next open must admit the replacement's physical identity again. The launcher, trial budget, attempts, rollback policy, and SQLite file-sharing mode are unchanged. This requires the candidate fix, not a new installed launcher.

The real Windows replay exposed a second holder: the waiting task supervisor had opened the shared database during Gateway pre-bootstrap. Its only job is to launch and wait for the real Gateway. Supervisor dispatch now happens before SQLite runtime, dotenv, database-engine selection, and Gateway environment selection. The late dispatch is removed.

- Original real Control UI failure: run `4adf1716-1734-4ed5-9eee-38083120fdfc`, two starts, schema 41→42 attempt, both blocked at the canonical WAL; the previous release served after rollback.
- Native Windows reproduction on Azure: a candidate with isolated state holds its own live and prepared file descriptors when replacement fails. No supervisor targets that isolated state.
- Product-API causal control on that lease:
  ```json
  {"file":"live.sqlite","nativeClosed":true}
  {"file":"next.sqlite","nativeClosed":true}
  {"beforeRetirement":"refused","code":"EPERM","syscall":"rename"}
  {"afterRetirement":"renamed"}
  ```
- One swap-owner regression checks descriptor release, new database contents, and the preserved old contents.
- AWS Linux run [`run_604041d54425b8c7e03ba43362072ac2`](https://crabbox.openclaw.ai/portal/runs/run_604041d54425b8c7e03ba43362072ac2): all 46 focused tests passed; the new regression fails on the base because the two descriptors remain retained (not a setup failure).
- Final-head T, next and crash full distribution builds, repository packing, and archive identity/SHA-256 checks passed in AWS run [`run_60ba70a2d1888c2d832aef9a1c6c3665`](https://crabbox.openclaw.ai/portal/runs/run_60ba70a2d1888c2d832aef9a1c6c3665). The corrected fixture declares its predecessor/runtime catalog inputs before generation.
- AWS run [`run_1af4700e569a25502494c17898d4839d`](https://crabbox.openclaw.ai/portal/runs/run_1af4700e569a25502494c17898d4839d): all 37 run-main tests passed; both new supervisor cases fail on clean main base `38f4f8fe018c` because the supervisor enters SQLite startup. Final parser consumer replay [`run_e6e98aa9e306b3332caadeefe5a8615c`](https://crabbox.openclaw.ai/portal/runs/run_e6e98aa9e306b3332caadeefe5a8615c) passes `cli-root-options` and `run-main`. Final-head local review and CI are owned by the lead.
- Fixed candidate-only Windows click on `3c150b5bfa`, run `36fec6f8-d822-409f-9f00-dfb6633e0d70`, still rolled back after two canonical-WAL `EPERM` failures. Native samples every two seconds show the old task supervisor retaining that WAL across candidate starts. Final head `69f58bc4e8` includes the early, database-free supervisor dispatch, its owner regression, and the preserved ordinary parser result.
- **Windows migrating UI update passed:** run `47295f8d-1098-407b-ac2d-160cdca32158`, committed on its first start, T+1 build `0322afdd098e` serving, shared schema 42 and the new STRICT table present. The startup log explicitly reports `by migration chain`. Across 491 native `openclaw.sqlite` handle samples, task-supervisor PID 404 has zero matching lines; other processes have 12,165 matching lines, confirming the sampler was active.
- **Linux chain-mode UI update passed:** run `137ae66a-ab63-4c64-af4b-9c90ee345278`, committed on its first start, T+1 serving schema 42 with the STRICT table. The startup journal explicitly reports `by migration chain`, not generic copy.
- The retained Doctor log explains the old fixture's generic-copy fallback: its schema-41 predecessor catalog was undeclared. Earlier Linux and macOS proof used that fallback. Those runs are not counted as chain-mode proof; the corrected final-head passes above are.

Crash rollback plus healthy recovery, and reboot-before-candidate recovery, cover paths this PR does not change; they run as follow-up proof after merge. Optional plugin maintenance refused old-Gateway-owned schema mutation in the passing runs; those advisory/plugin/channel checks are not claimed as passed.

The swap repair reuses admission retirement. The supervisor repair removes its unnecessary Gateway bootstrap. There is no new user-facing API, flag, configuration, retry, timer, or stored state.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit e2973f9)
Release adaptation: Place the custody regression before the baseline-only legacy registry fixture and integrate the startup contract in the baseline update docs. Retain the in-place update flow. Fold in only the supervisor dead-export cleanup and its test consumers from #204246.
Release companions: #204246 supervisor-only cleanup included; #204224 IPC release launcher and #204127 prepared-release plugin maintenance not applicable (src/update absent). #204275 early-main Git release check and #204253 reporting-only changes are independent, not required. #204230 and #204299 SHA mentions unrelated.
Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…tate database (#203578)

* fix(update): refuse migrating updates while a node service keeps the state open

Refs #203457

* docs(update): explain the node-service migration refusal

Refs #203457

* fix(update): match the node service's own state directory by filesystem identity

A default node service omits the state selector and must not inherit the updater's; path aliases name one directory. Refs #203457

* fix(update): refuse every activation while a node service keeps the state open

Update Doctor takes native exclusion of openclaw.sqlite on every activation, including patch updates without a schema change (#203457 reported 2026.11.5 -> 2026.11.6, both schema 36). Refuse whenever a running, kind-marked node service resolves to the same state directory, not only for pending migrations. Refs #203457

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit 19fcba1)

Release adaptation: retain stable captureUpdateActivationSchemas destructuring and check node ownership only before first mutation, so Git revalidation after mutation does not report a pre-mutation refusal. Keep stable preparatory staging and check before any Gateway stop or installed activation.

Release adaptation: keep only the node-service docs and regression in the conflict regions; the separate Gateway migration admission (#203170) is not a prerequisite and remains outside the lane.

Companion audit: no later PR or SHA mentions through 665c286. #203497 (future package preparation) is not needed; the existing stable package/Git activation hooks already share the pre-stop boundary. #203981 is selected elsewhere and already present at lane base (f6ad5b5). Later #204275, #204253, #204224, #204127, #204094, #204095, #204151, #204054, #203994, #203990, #203917, #203959, #203926, #203925, #203915, #203914, #202934 and #203735 are not applicable as companions: independent Git, rollback, Doctor/recovery, plugin, output, docs and host changes do not supply or consume node-service admission.

Validation: two same-state activation cases red on f6ad5b5 (wrongly reached mutation), three controls passed; all 73 tests in update-command-execution.test.ts passed with the fix.

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
## What Problem This Solves

Prepared-release updates ran the candidate's plugin maintenance before restarting the serving Gateway. When the candidate needed a newer shared-state schema, that maintenance correctly refused to migrate under the old Gateway. Core activation could succeed while plugins missed their update.

Closes openclaw#204035.

## User Impact

The new version reports success as soon as it is ready. Plugin downloads, installs and runtime reloads run afterward, without holding core readiness or disabling Update. Final plugin results reach the open update details; real failures add an attention warning without failing or rolling back the core update.

Stopping the Gateway during maintenance can leave no final plugin result. Work may be incomplete; this is not an atomic all-old/all-new plugin transaction. Published compatible versions load at the next Gateway start, and `openclaw plugins update --all` finishes the rest.

Removed install records do not hot-unload an already-running plugin. As in the existing metadata-only update path, removal takes effect at the next Gateway start. This repair reloads changed records that still exist.

## Why This Change Was Made

- Remove candidate maintenance from pre-restart preparation for equal/newer versions. Downgrades retain the previous pre-trial maintenance because older targets do not run this post-ready job and do not migrate the schema forward.
- Use one existing Gateway-watcher job after success: ten-minute plugin maintenance, release its lease, reload successful changes through the existing runtime lifecycle, then run advisory Doctor inspections.
- Record only final plugin steps. Preserve explicit capability consent in one optional field in the existing trial record; absence never approves widened capabilities.
- The internal `update plugins --json` result optionally carries existing batch-reload targets, captured from the exact published records under the publishing lease. The parent passes their hashes unchanged; the existing batch check refuses a record changed again before reload.
- Bind both commands to existing watcher cancellation and command-process cleanup, so stop/restart does not wait for their work budgets.

No new scheduler, timer, retry, in-progress marker, plugin staging mechanism, SQL, protocol or config change. Already-current updates keep their existing maintenance/restart behavior. An upgrade candidate that crashes before readiness does not start plugin maintenance.

Accepted edge case: a Git target with the same version string but an older revision gets no plugin maintenance if that revision lacks the post-ready job. Run `openclaw plugins update --all` in that case.

Ownership is unchanged: `update plugins` calls the maintenance owner directly, not the offline `plugins update` command. Its plugin lifecycle lease uses ordinary shared-state access. `gateway-state-owner-record.ts:132–134` permits that access while a Gateway serves; schema mutation has a separate exclusive lease and still refuses a foreign owner. The earlier real three-plugin command completed with the managed Gateway up (`run_f97b488afec5a305855aaaf6ba36ff64`, 46.20 s, schema 41). That is same-schema ownership evidence, not the repaired schema-bump proof. Plugin-owned SQL migrations retain their existing refusals.

## Evidence

- Red on main: the preparation regression exercises real candidate plugin lifecycle/schema admission while the old Gateway owns older state and captures the reported schema-mutation refusal.
- Head `37415ace28cf3b98055b6b707115f9dd9566986d`: AWS focused preparation, trial settlement, late ledger receipt, and plugin-record publication suites passed on production-identical `9507eb380c` (`run_21799856ebb39d5a8f48461e3c9fb78e`), with all 14 changed TypeScript files' lint, export collision guard, and TypeScript/docs format. The ledger-only assertion reduction then passed its suite, lint, format and ratchet on the final head (`run_91d5a424ce7fc02ef11e44244d7da329`). Earlier 15-suite/core-typecheck evidence is retained on `550010466eae` (`run_5f88592c54ec96289086157555acda72`); it is not represented as final-head execution.
- Test budget: removed 12 duplicate report-assertion lines; trial settlement remains the report behavior owner. Both downgrade decisions already share `it.each`. Net +465 test lines retain distinct schema-admission, consent, late-receipt, child-cancellation and exact-install reload contracts; the allocation is 65 above the 400-line allowance. The required local ratchet passed before push.
- Design measurement, not fix proof: three real IRC/Matrix/MS Teams updates took 46.20 seconds in one untraced warm-cache run. The separate counted filesystem performance finding is openclaw#204046, not part of this repair.
- **Passing Linux Control UI proof on this head:** official IRC `.6 → .7` run `ea01e4df-6fb3-453b-9484-023036b557d6` (AWS `run_d1d3df4f1e0e6e55fcc36bad4826e01f`) and compiled test-registry plugin `1.0.0 → 1.0.1` run `44217221-4196-436f-bb74-3bfd7a09eb12` (AWS `run_6a29d07f27be45d349bb62bc076f8324`). Both core updates succeeded through the real schema 41→42 migration chain, without generic fallback; `plugins` completed and Doctor inspections followed. [Run details and Settings → Updates screenshots](openclaw#204127 (comment)).
- Official plugins are converged by the new core's own startup: IRC was already current before post-ready maintenance. The separate honest compiled fixture (two real archives in the kit registry, plain JavaScript, no SQL migration) proves the third-party path: after core success, installed/runtime version changed `1.0.0 → 1.0.1` and Gateway generation changed `2 → 3` with unchanged service PID. All 31 sampled readiness probes during that post-success work were healthy; final plugin work took 7.348 seconds, then Doctor finished with informational findings.
- Full T/next builds retained exact source/build/schema provenance. Canonical `stampFixtureVersion` relabeled their package versions to T=`2026.11.6`, next=`2026.11.7`, preserving distinct build IDs, commits and schemas. Both qualified clicks followed two minutes of serving T plus observed maintenance ticks. Earlier live-own-lock interruption is tracked separately in openclaw#204215; QQbot package refusal was a published-package missing-compiled-output finding, not an update regression.
- Sampled outages were 65.678 seconds (official IRC) and 44.306 seconds (compiled fixture). An earlier no-plugin sample was 42.706 seconds but hit openclaw#204215; it is not a clean controlled latency comparison. Crash rollback was explicitly removed from this PR's proof scope. All AWS leases were released with `--wait`. Local review is owned by the lead; no further proof variants are pending.
- Linux container, macOS and Windows proof is unproven; this PR does not qualify a stable release.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…s ready (openclaw#204215)

Related: openclaw#203925

## What Problem This Solves

A Gateway that starts a release update takes the preparation lock under its own PID. On its first maintenance tick after it starts, `announceReady` treats any lock with its own PID as a leftover from an earlier Gateway that reused the PID, so it marks the running update `failed` with reason `interrupted` and releases the lock. The update itself continues and succeeds, but the recorded result says it failed.

Observed on Linux: run `90faf5a6-b3a4-4946-bebb-8f9ff903d6b6` was clicked shortly after a fresh Gateway start. The row was finished as `interrupted` at 20:02:00 while the old Gateway (PID 10561) was still preparing; the new Gateway started at 20:03 and served the target through the migration chain.

## User Impact

Clicking Update soon after a Gateway start no longer reports a working update as failed. A lock left by a dead process, or by an earlier Gateway whose PID a restarted container reused, is still settled as `interrupted`.

## Why This Change Was Made

The lock already records `startedAt`. A lock with this Gateway's PID counts as a leftover only when it was taken before this process started. No new state or check.

## Evidence

- `src/update/gateway-trial.test.ts`: the new `own-live` case (this Gateway's own lock, taken during its lifetime) fails on main (the run is marked `interrupted`) and passes here; the `same-pid` case now uses a lock from before the process started; `dead` and `live` are unchanged. All 10 trial tests pass.
- Real Linux proof on this head: a Control UI click 2.2 s after readiness (run `6567a5d6-184d-4c6c-849f-3d42fbd37fb5`); the own-PID lock survived two maintenance ticks during preparation and the run ended `succeeded` with the target serving. [Evidence](openclaw#204215 (comment)). The plugin warning in that run comes from this branch predating openclaw#204127.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…01978)

* fix(update): copy original state only at the first state change

* docs(update): say when the original-state capture is taken

* fix(update): copy before a Gateway handoff, legacy config repair, or a fresh post-core process

* test(update): expect the copy before a fresh post-core process

* test(update): prove real Git and release updates copy at their mutation hook

* fix(update): copy after the last pre-stop refusal and before writing a changed channel

* test(update): a refused update copies nothing; sort run ids with a comparator

* fix(update): copy before plugin records publish, outside the update deadline, and only once a handoff is certain

* fix(update): copy before the combined plugin index write, every channel write and a fresh post-core launch, outside every update clock

* fix(update): let the lazy capture follow this run's prepared package publication

* test(update): drive the Git no-op capture case through the release runner

* style(test): sort merged imports

Release adaptation: Keep stable’s in-place Git runner and its existing service and rollback paths. Route the Git no-op fixture through updateGitCheckout and retain the before-mutation capture assertions. Omit the prepared Git release branch and its release-link-only tests. Merge the Doctor and fresh-handoff timing checks alongside the stable-only handoff coverage. Stable arms the executor clock before already-current package maintenance; keep both its timer and its synchronous fence/SQLite deadline checks paused during separately bounded capture. Exercise a live fence assertion after the original activation deadline elapses inside excluded work.

Companion audit: #203578 is present-equivalent at e396e3f; its stable state-ownership guard is preserved. #203194, #203497 and #203926 apply to main’s newer release staging/activation flow and are not applicable here. #204127 changes when plugins are installed after activation, #203917 concerns retained-runtime cleanup, #202934 adds a separate macOS Git prereq, and #204151 is independent handoff repair guidance. None is required for lazy original-state capture.

(cherry picked from commit a577911)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 1a2e6a7bec75074a150a684848990710c3fddc48)
obviyus added a commit that referenced this pull request Nov 24, 2026
## What Problem This Solves

Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`.

Closes #204394. Closes #204227.
Related: #204775, #204502, #204095, #204127.

## User Impact

User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback.

**No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size.

Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update.

## Why This Change Was Made

`discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed.

This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate.

## Evidence

- Pinned base `d4c6c46e32ae`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac).

## Real-route proof on merged head5f8ce752

Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection.

- **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s.
- **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.”

Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification.

Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness.

## Review repair: ordinary PostgreSQL startup

Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability.

The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial.

## Main integration

Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy.

AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 25, 2026
Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`.

Closes #204394. Closes #204227.
Related: #204775, #204502, #204095, #204127.

User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback.

**No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size.

Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update.

`discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed.

This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate.

- Pinned base `d4c6c46e32ae`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac).

Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection.

- **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s.
- **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.”

Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification.

Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness.

Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability.

The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial.

Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy.

AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 270aae3)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 25, 2026
…aw#204752)

## What Problem This Solves

Release validation and state migration walked different database inventories. Registered external stores could escape rollback coverage, while a healthy closed WAL database without SHM could fail `check-release`.

Closes openclaw#204394. Closes openclaw#204227.
Related: openclaw#204775, openclaw#204502, openclaw#204095, openclaw#204127.

## User Impact

User impact: release preparation checks the databases the migration owner actually knows about, before stopping the serving Gateway. Unsupported recovery paths are refused with the affected database and a next step. Healthy closed WAL databases use the existing artifact-preserving inspection fallback.

**No update is refused by database size.** The SQLite/PostgreSQL budget refusal, its rate constant and its size-admission tests/docs have been removed per the approved state-model decision. Ordinary non-trial starts remain unrestricted by size.

Newly refused users are those with a pending schema migration and a registered/configured database outside the state directory, deeper than the frozen launcher's four-directory limit, symlinked/separately mounted, or below its skipped git-install/npm/node_modules/tmp/logs directories. Their old Gateway stays serving. The reason names the database and says to move it to a real covered directory (for agents: agents/<agent-id>/agent/openclaw-agent.sqlite), update its registration/configuration, and retry. This recovery-layout refusal remains until the separately sequenced restore-manifest cutover; it does not apply when no schema migration is pending. Missing unconfigured retained registrations do not block an unrelated update.

## Why This Change Was Made

`discoverDatabases` owns the inventory, metadata projection and copy eligibility. `check-release` no longer has a second scanner or direct `readonly_shm` opener. The copier consumes the authoritative target paths and retains its copy-coverage assertion. The obsolete success-notice recorder and the in-place PostgreSQL trial notice path are removed.

This PR intentionally does not add a manifest writer, CoW/in-place migration model, reader-floor logic or Doctor-chain rewrite. The manifest writer follows as its own small PR; the larger state-model cutover is separate.

## Evidence

- Pinned base `ad98b9e7f734`: initial owner/release-check regressions produced12 intended failures and4 passes. [AWS base proof](https://crabbox.openclaw.ai/portal/runs/run_9a0a8afeaa9a1af9caa2385e34602eac).

## Real-route proof on merged head5f8ce752

Both legs were rerun after the `run.ts` conflict resolution, on separate AWS leases using product-installed native services and the qualification kit's TLS/registry fixture preserving the exact public latest URL. No package-spec override or app-state injection.

- **Genuine published stable2026.11.7 → merged head:** [run](https://crabbox.openclaw.ai/portal/runs/run_846f96823734c8f716089e1b2ce03148), exit0, product `520d08a2-52a0-4999-a9ae-d3fda7d098f6`, `api/succeeded`. Exact-head serving build verified (fixture package2026.11.9-first-hop.0). State36→41 and dormant agent38→43; the cleanly closed WAL-mode agent had no SHM before candidate inspection and was accepted. Wall227.986s, sampled outage94.229s.
- **Merged head → same-head schema42 successor:** [run](https://crabbox.openclaw.ai/portal/runs/run_47605dc74641c05448ec970d6e8fdf12), exit0. External agent store refused before stop: product `80cdfd2d-1350-44ed-a0f2-245ca1ac490d`, `release-check-failed`. PID25851/schema41 unchanged; all278 readiness samples healthy (250ms interval). Validation took1.620s after staging. The actual Settings→Updates page and `update status --json` showed the affected path, move/update-registration/retry instructions, and “The current version is still running.”

Private receipts: `StateBoundary-proof/{mergedwal-result.json,mergedwal-receipt.tgz,merged-proof.tgz,merged-complete.tgz,merged-settings.txt,merged-settings.webp}`. These boundary legs are not a one-minute-outage or crash-rollback qualification.

Production `tokei` on the PR's six production TypeScript files after merging main336e9314: **2,540 → 2,557 (+17)**, excluding tests/support/harness.

## Review repair: ordinary PostgreSQL startup

Review-repair head: `cbe972b00e5e32cd0585713b032c53d773be7acb`. A local-review finding caught protected-copy CREATE admission accidentally applying outside a release trial. PostgreSQL protected-copy targets and prerequisites now apply only to pending/trial starts; manual package upgrades retain the existing in-place migration owner, original namespace and ordinary startup availability.

The existing owner table covers restricted-role ordinary startup versus protected-trial preflight refusal before mutation. [Merged-head AWS owner/build check](https://crabbox.openclaw.ai/portal/runs/run_93771e93ed0d283deb95854a692042ea) passed **118 tests** including large-postgres, gateway-trial and prepare-failure; three live-PG cases were skipped without a conformance connection. Full build and pack passed. The restricted-role case models the copy prerequisite at the upgrade boundary; it is not new live-PG serving proof. Existing protected-copy live-PG fixtures explicitly declare a pending trial.

## Main integration

Current head: `5f8ce7521eec58f2c98bf39f250922ecef3f967f`, merging main336e9314. Conflicts were only `docs/install/updating.md` and `src/update/run.ts`. The update owner retained main's under-lock trial admission and single failure settlement, and C's obsolete success-reason recorder stays deleted. Documentation retains both main's early-recovery contract and C's shared inventory/no-size policy.

AWS PostgreSQL schema regeneration completed with a zero-byte diff. Its first wrapper failed only downloading an obsolete artifact path; the generator completed successfully and the correct empty patch/log were collected with the passing owner/build run. Both affected real-route legs passed on this merged head, as recorded above.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prepared-release plugin maintenance refuses a schema bump while the serving Gateway owns state

2 participants