Repository navigation
refactor(state): migrate in place and remove copy-and-swap - #205165
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: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
|
- Preserve canonical migration, deletion custody, and historical receipt readers. - Stage the approved in-place cut before integrating the existing manifest writer.
…covery - Reuse existing schema and custody owners; delete shadow trees, Doctor-on-copy, generic rebuilds and forward file swaps. - Reuse per-release restore receipts with independent build-named images only when the derived reader floor rises. - Preserve historical receipt recovery and existing pre-image retention; remove copied-state handoffs and post-commit image cleanup.
- Reuse Doctor’s existing environment-aware legacy owner and ordinary config rewrite, without a copied tree or subprocess. - Remove both schema-only early gates so legacy/config-only upgrades still run under custody. - Seed canonical predecessor ownership in the retained owner fixtures.
- Declare prospective stores in the single inventory and preserve null pre-images. - Retain the shipped applied-receipt shape solely for kind:add removals consumed by installed launchers. - Preserve existing generation retention for imaged files only.
- Settle only existing durable swap plans before config and SQL admission; never create new forward plans. - Preserve changing config originals through the existing recovery writer and frozen launcher. - Reuse verified boot images for credential custody and the existing heartbeat retirement owner. - Repair real host-broker fixture routing, native credential binding, and owned CI findings.
- Rebase onto the landed reader-floor contract and retain shipped-plan settlement. - Reuse captured-identity include repair with original-file recovery images. - Keep asynchronous migration owners outside synchronous engine admission scopes.
Related: #205165, #204915 ## What Problem This Solves A failed update still reconstructs its rollback from build-global receipts and a directory scan, rather than the files that candidate recorded. Returning to the same build can consume an older receipt, and a legacy import's prospective removal list can delete a store normal runtime created later. ## User Impact A new resident launcher restores exactly the selected release's recorded pre-images, removes its recorded additions first, and keeps later runtime-created stores. An invalid or incomplete manifest fails visibly with a triage next step instead of silently guessing or switching to the old release with unrestored state. No operator action, schema change, new flag or manifest field is introduced. ## Why This Change Was Made The existing state publisher owns the write set; the launcher only executes it. The v1 manifest remains `{v:1,runId,files:[{live,preimage}]}` in the target release directory. Rename replay is restart-safe. Before mutation the publisher still records the full prospective list; after successful import and native close, it durably republishes that same manifest with unused prospective file families removed. Families actually created during boot retain all sidecar removals. An interrupted import before completion conservatively retains the broad list (the explicitly accepted rare case); no persisted provenance field is added. Manifest-backed rollback never interprets global `.upgraded-<build>` receipts or scans `.pre` paths. Targets without `.restore` retain the shipped compatibility interpreter, including the early Git launcher; the modern fallback scopes legacy receipt consumption to the trial's existing freshness window. Retire compatibility only when the supported update/rollback floor passes the last published target without `.restore`. A still-running older resident judges the first hop until a native service start loads format 4; this PR does not pretend an on-disk rewrite upgrades that process. Simplification: modern recovery has one declared write-set owner; inference is isolated in the explicitly temporary compatibility module. Scoped tokei production code (six touched production files, excluding tests): **1,265 → 1,381 (+116)**. Test-line guard: **+198**, below the existing 400 allowance; no allocation/exemption. ## Evidence - Pinned base: `627f23654573975faa0492e44562f5755b2d4101`; head: `7f07553a09ec2443dbdddfdcde4c0000ec812115`. - AWS owner/consumer suites: 90 assertions across seven files pass across the initial wave and the single repaired generated-import consumer. Covers authoritative target-only restore, external paths, stale same-build/global receipts, malformed manifests, interrupted rename replay, legacy fallback, late SQLite/WAL preservation and immutable retry originals. The initial wave exposed a quoted old export in one existing test; both quoted uses were migrated, with assertions unchanged, and that consumer passed on the final head. - Production/state-test types, changed-file lint/format and test-line guard passed. Full build and package integrity passed on the final head: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_1f93f346dea32b949bb9fcc1a1412188). Carrier `07484900409ed1cf2a1671cac06d98d53751afcd` binds identical source; candidate SHA256 `321b3d2674d23ed6d56cecfe1e10476fec4c006b173dfcb908a3ae8ccd6ca012`. - Published **2026.11.10 → head passed** through its real npm updater and native service: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_9361f7427d0212093904834a993880ec), serving build `2026.11.10-07484900409e-2026-11-25T22-05-40.010Z`, ready/core/settled true. The first driver incorrectly expected that shipped in-place updater to produce a v2 trial; it timed out after the successful update. The corrected driver uses the real update result, then head's public release updater for conversion and the failing successor; no product bytes or package stamps changed. - Still running, not yet claimed: actual schema+1 successor rollback through resident format 4, including a store created through public session RPC after import completion. Trial/unit/journal, literal manifest, file identities and public-session receipts are captured. This requested product gate must pass before merge. - Exact-head local review: complete, patch correct, security cleared, no findings, confidence 0.76 (`~/.cache/clawsweeper-local-review/7f07553a09ec.md`). Its remaining proof gap is the running product gate. CI currently has no reds; no Windows or macOS product proof is claimed. Co-authored-by: Ayaan Zaidi <[email protected]>
…#205421) ## Problem On `main`, `packages/gateway-protocol/src/compiled/protocol.generated/predicates.js` is out of date with its generator. Every PR's `build-artifacts` job therefore fails at `validators:check`, for example openclaw#205165 in run 45636087623. ## Fix Ran the owner command `pnpm gateway:validators:gen` on `main` at `c4593f351d`. It changed only `predicates.js`, and reported every other output as unchanged. ## Impact Generated code only. Behavior is the same as the generator source. ## Evidence On a fresh checkout of `main`, the generator rewrote `predicates.js` and reported all other outputs as unchanged.
…#205421) ## Problem On `main`, `packages/gateway-protocol/src/compiled/protocol.generated/predicates.js` is out of date with its generator. Every PR's `build-artifacts` job therefore fails at `validators:check`, for example openclaw#205165 in run 45636087623. ## Fix Ran the owner command `pnpm gateway:validators:gen` on `main` at `c4593f351d`. It changed only `predicates.js`, and reported every other output as unchanged. ## Impact Generated code only. Behavior is the same as the generator source. ## Evidence On a fresh checkout of `main`, the generator rewrote `predicates.js` and reported all other outputs as unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
…205165) ## Problem Gateway boot copies a private state tree, runs Doctor there, and publishes database replacements. The generic rebuild fallback adds another migration owner. Update cost grows with unrelated state and retains competing copy/swap machinery. Based on main c6eb8cd, including openclaw#204956. Main only; no release-branch changes. ## Fix - Migrate canonical databases in place through existing state, agent and engine owners under exclusive custody. - Keep `discoverDatabases` as the inventory. Reuse openclaw#204915's per-release `.restore` v1 receipt; only a raised reader floor needs a database image. SQLite images are independent CoW clones or byte copies, never hard links. PostgreSQL copies a namespace only as its rollback image. - Keep the installed launcher's `.pre-<build-generation>` naming and existing `kind: add` receipt contract. No launcher reader or resident transition is added. - Reuse legacy-file imports, native credential custody, heartbeat/config repair and session imports on live paths. Include repair preserves authored directives and images every changed physical file. - Admit projected config and its source/hot-journal guard first; close that snapshot, migrate under the exclusive owner, then enforce database readiness. Config still invalid after projection refuses before writes. - Retain the session import/post-session handoff from Doctor (`doctor-health-contribution-runners.state.ts:62–84`; `doctor-session-transcripts.ts:227–355`). - Retain historical BLOB-backed TEXT repair from `de5a86ead888^:src/state/state-upgrade-tree.ts:719–753`, now in existing schema repair before typed readers and only for outdated databases. The original order normalized before `runChain` (`state-upgrade.ts:454–481`), not inside Doctor. Normalization now uses one existing transaction per database; conflicts roll back, name the table/key and take the existing exit-78 refusal path. - Preserve an already-lower reader floor during same-version Doctor repair. - Delete the shadow-tree writer, generic rebuild/value helpers, forward database swap wrappers, copied-target validation/readability, Doctor-on-copy process, copy-only CLI handoff and copied-state fixtures. Existing retention and historical receipt readers remain. - Settle only already-written `.upgrade-*/plan.json` before state reads. Stable 2026.11.10 shipped these plans; finishing one preserves committed WAL rows after an interrupted companion removal. No new plan is written. - Implement the engine gate's existing migrations permission at its one execution owner. Ordinary Gateway, closed/expired custody and config-only custody still refuse. No new table, column, stored-row shape, migration option or fallback. Clone reuse follows @fuller-stack-dev's openclaw#201716 via existing `copySqliteFile`. Related: openclaw#198389, openclaw#168750, openclaw#161888; retains openclaw#204752/openclaw#204227 inventory and clean-WAL work. ## User impact Starts and updates stop copying/replacing the state tree. Compatible schema steps, including compatible external stores, take no database image. Floor-raising rollback uses only the recorded image; unsupported paths refuse before the old Gateway stops with move/retry instructions. Accepted cost: without CoW, a floor-raising boot takes one byte copy of that database. No size refusal or 30-second probe. Required-image failure refuses before that step. Non-trial starts do not acquire copy-only prerequisites. Historical imports must retain sessions. The six published-release corpora remain required. One-time empty-source ownership maintenance is followed by a no-op boot; its regression preserves bytes on the second boot. Inherited frozen-reader edge: **A commits → downgrade T → return to the same A build → A fails before replacing its receipt** can consume stale build-keyed `kind: add` entries (`rollback-source.ts:39–55`). Existing debt; the paused per-release manifest reader removes it. Legacy-import plans may conservatively declare prospective stores. A future manifest reader could remove a store created later at such a path during rollback. This is accepted only on the one-time legacy-import path, not schema-only/additive updates; absent targets are now excluded unless existing source owners report legacy import sources. Accepted recovery edge: an invalid legacy `device.json` with no canonical identity is refused after the in-place schema upgrade; the existing full original backup preserves the pre-upgrade bytes. Canonical identity retains its shipped precedence over an invalid legacy file. No new credential reader or custody bypass is added. ## Evidence and current gate Remote head: **d449180993a4ee51aa180d9cb0a6b25ecdd27d52**. Current CI is the maintainer's final gate; earlier results remain scoped to their tested heads. The latest focused PostgreSQL proof is recorded below. - On the preceding 033d3de production tree, `ocx build --dist` passed, then selected **2026.7.1-blob E2E passed (20.94s)** with combined projection, additive-only and corrected historical non-STRICT normalization changes. The first version-only gate failed this corpus; the corrected gate passed. - Corrected Doctor/native-bootstrap/admission files **49/49 passed**; restored original fresh-profile pending-pin/offline-handoff contract **9/9 passed**; recovery tests passed, including localhost/0.0.0.0. - Final catalog-only migration observer **7/7 passed**. Inventory **27/27 passed**. Leasehold **4/4** and admission gate **7 passed/3 PostgreSQL skipped** passed on the initial catalog repair; the final historical gate was additionally qualified by the observer and BLOB corpus. - PostgreSQL tests had **6 skips** without a qualified local connection. Neither skips nor the inventory-only run qualify the live PostgreSQL behavior. - Local import-cycles, Madge (0 cycles) and Kysely guards passed on the repair batch. This is not behavioral proof. - On committed **bda681956e**, `ocx build --dts` completed the actual full build in 13m05s (not a cache hit), including native declarations and all 165 public SDK subpaths. Earlier infrastructure-only lock/admission failures were resolved without changing source or bypassing ownership. - Baseline regressions proved: [run_f5d15c230817a891fa97f1a7218498af](https://crabbox.openclaw.ai/portal/runs/run_f5d15c230817a891fa97f1a7218498af). Pinned `434459170f` loses the WAL witness at the selected assertion and refuses with `config original must precede manifest`; pinned `d31b2ca386` refuses the repairable include with `config-invalid: diagnostics.otel`. Only test fixtures were overlaid. Lease released with `--wait`. - **Older a5ef head:** [run_d4822472e48e3a5f847c9bde74317959](https://crabbox.openclaw.ai/portal/runs/run_d4822472e48e3a5f847c9bde74317959): full build, package and all six historical corpora **passed** (2026.7.1, 7.1-blob, 7.35, 8.35, 9.37, 10.10; seven tests including invalid-config preservation, zero skips). Admission/owner/live-PG/test-types/lint failed; subsequent fixes are not called green without verification. - **Older 78af head only:** published 2026.11.10 routed Gateway API upgrade passed: [run_605e7f763523ff2d8dd7d20b7428893f](https://crabbox.openclaw.ai/portal/runs/run_605e7f763523ff2d8dd7d20b7428893f), product row `e4d2cb81-841a-46a1-a6b7-50164052d3cd`, state40→42/agent42→44, clean WAL without SHM accepted, exact commit serving, no sampled/final `.upgrade-*` tree. Product downtime82.424s; sampled95.671s. This does not qualify the current head's modern selective-image contract. - **539 diagnostic only:** [run_cbb2a0713d7096f4e6a9588d3b0a4f9c](https://crabbox.openclaw.ai/portal/runs/run_cbb2a0713d7096f4e6a9588d3b0a4f9c), one cron case: Gateway ready, zero provider requests, pre-run persistence refused missing `public.unaccent`. The private AWS driver omitted extension provisioning present in canonical CI; the driver is corrected, with no speculative product change. This is setup-failure evidence, not a passing cron result. Lease released with `--wait`. - Obsolete 716 proof lanes were stopped by maintainer direction; every lease was released with `--wait`. Current-head native rollback, interrupted-plan startup and additive-boot qualification remain unproven. No AWS lease remains allocated. Remaining proof gaps: current-head CI, live PostgreSQL, and the native scenarios above. Inherited failures left unchanged: checkpoint timing at `agent-database-startup-verification.test.ts:340` (openclaw#205290); scheduled-turn budget failure matches [scheduled main run45634242694/job139276192521](https://github.com/openclaw/openclaw/actions/runs/45634242694/job/139276192521) exactly. For be51's merge-only stale-validator failure, owner regeneration left all52 outputs unchanged with identical SHA-256 manifests; no generated output was hand-edited. On 033d3de, `tokei` on all46 touched `src` production files, excluding `*.test.ts`, `*.test-support.ts` and `*.test-harness.ts`, against c6eb8cd: **15,307→13,481 (-1,826)** code lines. Whole PR including tests/docs: **+3,586/-6,364, net -2,778**. ### PostgreSQL startup admission follow-up Under PostgreSQL, retired heartbeat configuration is now repaired at startup instead of merely reported: startup is valid, the legacy heartbeat is durably removed, and PostgreSQL configuration is retained. The ordinary main-thread PostgreSQL refusal remains enforced. Only synchronous Doctor manifest selection uses the existing engine admission; no admission spans asynchronous preparation. The focused regression passed locally against the CI-pinned PostgreSQL 16 Docker image with `unaccent`, `pg_trgm` and `vector`: **1 passed, 5 unselected cases skipped**. Extended-stack reproduction identified the bundled-discovery policy read during Doctor manifest selection; the fixed test verifies the persisted repair. The owned container was removed after proof. This qualifies the selected regression, not the entire PostgreSQL suite. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: openclaw#205165, openclaw#204915 ## What Problem This Solves A failed update still reconstructs its rollback from build-global receipts and a directory scan, rather than the files that candidate recorded. Returning to the same build can consume an older receipt, and a legacy import's prospective removal list can delete a store normal runtime created later. ## User Impact A new resident launcher restores exactly the selected release's recorded pre-images, removes its recorded additions first, and keeps later runtime-created stores. An invalid or incomplete manifest fails visibly with a triage next step instead of silently guessing or switching to the old release with unrestored state. No operator action, schema change, new flag or manifest field is introduced. ## Why This Change Was Made The existing state publisher owns the write set; the launcher only executes it. The v1 manifest remains `{v:1,runId,files:[{live,preimage}]}` in the target release directory. Rename replay is restart-safe. Before mutation the publisher still records the full prospective list; after successful import and native close, it durably republishes that same manifest with unused prospective file families removed. Families actually created during boot retain all sidecar removals. An interrupted import before completion conservatively retains the broad list (the explicitly accepted rare case); no persisted provenance field is added. Manifest-backed rollback never interprets global `.upgraded-<build>` receipts or scans `.pre` paths. Targets without `.restore` retain the shipped compatibility interpreter, including the early Git launcher; the modern fallback scopes legacy receipt consumption to the trial's existing freshness window. Retire compatibility only when the supported update/rollback floor passes the last published target without `.restore`. A still-running older resident judges the first hop until a native service start loads format 4; this PR does not pretend an on-disk rewrite upgrades that process. Simplification: modern recovery has one declared write-set owner; inference is isolated in the explicitly temporary compatibility module. Scoped tokei production code (six touched production files, excluding tests): **1,265 → 1,381 (+116)**. Test-line guard: **+198**, below the existing 400 allowance; no allocation/exemption. ## Evidence - Pinned base: `e786de6c7fd2ecc8784d9c84e994a2ea942179d1`; head: `7f07553a09ec2443dbdddfdcde4c0000ec812115`. - AWS owner/consumer suites: 90 assertions across seven files pass across the initial wave and the single repaired generated-import consumer. Covers authoritative target-only restore, external paths, stale same-build/global receipts, malformed manifests, interrupted rename replay, legacy fallback, late SQLite/WAL preservation and immutable retry originals. The initial wave exposed a quoted old export in one existing test; both quoted uses were migrated, with assertions unchanged, and that consumer passed on the final head. - Production/state-test types, changed-file lint/format and test-line guard passed. Full build and package integrity passed on the final head: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_1f93f346dea32b949bb9fcc1a1412188). Carrier `07484900409ed1cf2a1671cac06d98d53751afcd` binds identical source; candidate SHA256 `321b3d2674d23ed6d56cecfe1e10476fec4c006b173dfcb908a3ae8ccd6ca012`. - Published **2026.11.10 → head passed** through its real npm updater and native service: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_9361f7427d0212093904834a993880ec), serving build `2026.11.10-07484900409e-2026-11-25T22-05-40.010Z`, ready/core/settled true. The first driver incorrectly expected that shipped in-place updater to produce a v2 trial; it timed out after the successful update. The corrected driver uses the real update result, then head's public release updater for conversion and the failing successor; no product bytes or package stamps changed. - Still running, not yet claimed: actual schema+1 successor rollback through resident format 4, including a store created through public session RPC after import completion. Trial/unit/journal, literal manifest, file identities and public-session receipts are captured. This requested product gate must pass before merge. - Exact-head local review: complete, patch correct, security cleared, no findings, confidence 0.76 (`~/.cache/clawsweeper-local-review/7f07553a09ec.md`). Its remaining proof gap is the running product gate. CI currently has no reds; no Windows or macOS product proof is claimed. Co-authored-by: Ayaan Zaidi <[email protected]>
Gateway boot copies a private state tree, runs Doctor there, and publishes database replacements. The generic rebuild fallback adds another migration owner. Update cost grows with unrelated state and retains competing copy/swap machinery. Based on main ba96ee5, including #204956. Main only; no release-branch changes. - Migrate canonical databases in place through existing state, agent and engine owners under exclusive custody. - Keep `discoverDatabases` as the inventory. Reuse #204915's per-release `.restore` v1 receipt; only a raised reader floor needs a database image. SQLite images are independent CoW clones or byte copies, never hard links. PostgreSQL copies a namespace only as its rollback image. - Keep the installed launcher's `.pre-<build-generation>` naming and existing `kind: add` receipt contract. No launcher reader or resident transition is added. - Reuse legacy-file imports, native credential custody, heartbeat/config repair and session imports on live paths. Include repair preserves authored directives and images every changed physical file. - Admit projected config and its source/hot-journal guard first; close that snapshot, migrate under the exclusive owner, then enforce database readiness. Config still invalid after projection refuses before writes. - Retain the session import/post-session handoff from Doctor (`doctor-health-contribution-runners.state.ts:62–84`; `doctor-session-transcripts.ts:227–355`). - Retain historical BLOB-backed TEXT repair from `de5a86ead888^:src/state/state-upgrade-tree.ts:719–753`, now in existing schema repair before typed readers and only for outdated databases. The original order normalized before `runChain` (`state-upgrade.ts:454–481`), not inside Doctor. Normalization now uses one existing transaction per database; conflicts roll back, name the table/key and take the existing exit-78 refusal path. - Preserve an already-lower reader floor during same-version Doctor repair. - Delete the shadow-tree writer, generic rebuild/value helpers, forward database swap wrappers, copied-target validation/readability, Doctor-on-copy process, copy-only CLI handoff and copied-state fixtures. Existing retention and historical receipt readers remain. - Settle only already-written `.upgrade-*/plan.json` before state reads. Stable 2026.11.10 shipped these plans; finishing one preserves committed WAL rows after an interrupted companion removal. No new plan is written. - Implement the engine gate's existing migrations permission at its one execution owner. Ordinary Gateway, closed/expired custody and config-only custody still refuse. No new table, column, stored-row shape, migration option or fallback. Clone reuse follows @fuller-stack-dev's #201716 via existing `copySqliteFile`. Related: #198389, #168750, #161888; retains #204752/#204227 inventory and clean-WAL work. Starts and updates stop copying/replacing the state tree. Compatible schema steps, including compatible external stores, take no database image. Floor-raising rollback uses only the recorded image; unsupported paths refuse before the old Gateway stops with move/retry instructions. Accepted cost: without CoW, a floor-raising boot takes one byte copy of that database. No size refusal or 30-second probe. Required-image failure refuses before that step. Non-trial starts do not acquire copy-only prerequisites. Historical imports must retain sessions. The six published-release corpora remain required. One-time empty-source ownership maintenance is followed by a no-op boot; its regression preserves bytes on the second boot. Inherited frozen-reader edge: **A commits → downgrade T → return to the same A build → A fails before replacing its receipt** can consume stale build-keyed `kind: add` entries (`rollback-source.ts:39–55`). Existing debt; the paused per-release manifest reader removes it. Legacy-import plans may conservatively declare prospective stores. A future manifest reader could remove a store created later at such a path during rollback. This is accepted only on the one-time legacy-import path, not schema-only/additive updates; absent targets are now excluded unless existing source owners report legacy import sources. Accepted recovery edge: an invalid legacy `device.json` with no canonical identity is refused after the in-place schema upgrade; the existing full original backup preserves the pre-upgrade bytes. Canonical identity retains its shipped precedence over an invalid legacy file. No new credential reader or custody bypass is added. Remote head: **d449180993a4ee51aa180d9cb0a6b25ecdd27d52**. Current CI is the maintainer's final gate; earlier results remain scoped to their tested heads. The latest focused PostgreSQL proof is recorded below. - On the preceding 033d3de production tree, `ocx build --dist` passed, then selected **2026.7.1-blob E2E passed (20.94s)** with combined projection, additive-only and corrected historical non-STRICT normalization changes. The first version-only gate failed this corpus; the corrected gate passed. - Corrected Doctor/native-bootstrap/admission files **49/49 passed**; restored original fresh-profile pending-pin/offline-handoff contract **9/9 passed**; recovery tests passed, including localhost/0.0.0.0. - Final catalog-only migration observer **7/7 passed**. Inventory **27/27 passed**. Leasehold **4/4** and admission gate **7 passed/3 PostgreSQL skipped** passed on the initial catalog repair; the final historical gate was additionally qualified by the observer and BLOB corpus. - PostgreSQL tests had **6 skips** without a qualified local connection. Neither skips nor the inventory-only run qualify the live PostgreSQL behavior. - Local import-cycles, Madge (0 cycles) and Kysely guards passed on the repair batch. This is not behavioral proof. - On committed **bda681956e**, `ocx build --dts` completed the actual full build in 13m05s (not a cache hit), including native declarations and all 165 public SDK subpaths. Earlier infrastructure-only lock/admission failures were resolved without changing source or bypassing ownership. - Baseline regressions proved: [run_f5d15c230817a891fa97f1a7218498af](https://crabbox.openclaw.ai/portal/runs/run_f5d15c230817a891fa97f1a7218498af). Pinned `434459170f` loses the WAL witness at the selected assertion and refuses with `config original must precede manifest`; pinned `d31b2ca386` refuses the repairable include with `config-invalid: diagnostics.otel`. Only test fixtures were overlaid. Lease released with `--wait`. - **Older a5ef head:** [run_d4822472e48e3a5f847c9bde74317959](https://crabbox.openclaw.ai/portal/runs/run_d4822472e48e3a5f847c9bde74317959): full build, package and all six historical corpora **passed** (2026.7.1, 7.1-blob, 7.35, 8.35, 9.37, 10.10; seven tests including invalid-config preservation, zero skips). Admission/owner/live-PG/test-types/lint failed; subsequent fixes are not called green without verification. - **Older 78af head only:** published 2026.11.10 routed Gateway API upgrade passed: [run_605e7f763523ff2d8dd7d20b7428893f](https://crabbox.openclaw.ai/portal/runs/run_605e7f763523ff2d8dd7d20b7428893f), product row `e4d2cb81-841a-46a1-a6b7-50164052d3cd`, state40→42/agent42→44, clean WAL without SHM accepted, exact commit serving, no sampled/final `.upgrade-*` tree. Product downtime82.424s; sampled95.671s. This does not qualify the current head's modern selective-image contract. - **539 diagnostic only:** [run_cbb2a0713d7096f4e6a9588d3b0a4f9c](https://crabbox.openclaw.ai/portal/runs/run_cbb2a0713d7096f4e6a9588d3b0a4f9c), one cron case: Gateway ready, zero provider requests, pre-run persistence refused missing `public.unaccent`. The private AWS driver omitted extension provisioning present in canonical CI; the driver is corrected, with no speculative product change. This is setup-failure evidence, not a passing cron result. Lease released with `--wait`. - Obsolete 716 proof lanes were stopped by maintainer direction; every lease was released with `--wait`. Current-head native rollback, interrupted-plan startup and additive-boot qualification remain unproven. No AWS lease remains allocated. Remaining proof gaps: current-head CI, live PostgreSQL, and the native scenarios above. Inherited failures left unchanged: checkpoint timing at `agent-database-startup-verification.test.ts:340` (#205290); scheduled-turn budget failure matches [scheduled main run45634242694/job139276192521](https://github.com/openclaw/openclaw/actions/runs/45634242694/job/139276192521) exactly. For be51's merge-only stale-validator failure, owner regeneration left all52 outputs unchanged with identical SHA-256 manifests; no generated output was hand-edited. On 033d3de, `tokei` on all46 touched `src` production files, excluding `*.test.ts`, `*.test-support.ts` and `*.test-harness.ts`, against ba96ee5: **15,307→13,481 (-1,826)** code lines. Whole PR including tests/docs: **+3,586/-6,364, net -2,778**. Under PostgreSQL, retired heartbeat configuration is now repaired at startup instead of merely reported: startup is valid, the legacy heartbeat is durably removed, and PostgreSQL configuration is retained. The ordinary main-thread PostgreSQL refusal remains enforced. Only synchronous Doctor manifest selection uses the existing engine admission; no admission spans asynchronous preparation. The focused regression passed locally against the CI-pinned PostgreSQL 16 Docker image with `unaccent`, `pg_trgm` and `vector`: **1 passed, 5 unselected cases skipped**. Extended-stack reproduction identified the bundled-discovery policy read during Doctor manifest selection; the fixed test verifies the persisted repair. The owned container was removed after proof. This qualifies the selected regression, not the entire PostgreSQL suite. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e43debf) Release adaptation: floorRaisingDatabases drops the agent v44 member-access additive exception because release has no v44 schema; release keeps the restore-path owner in state-upgrade-databases.ts as on main (release-only state-upgrade-paths.ts from the #204916 adaptation removed along with state-upgrade-tree.ts); modify/delete conflicts on files absent from release (upgrade-survivor-migration-chain test, historical declared-input fixtures) keep the release state; remaining conflicts resolved by applying the source change over release-only hunks. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Related: #205165, #204915 ## What Problem This Solves A failed update still reconstructs its rollback from build-global receipts and a directory scan, rather than the files that candidate recorded. Returning to the same build can consume an older receipt, and a legacy import's prospective removal list can delete a store normal runtime created later. ## User Impact A new resident launcher restores exactly the selected release's recorded pre-images, removes its recorded additions first, and keeps later runtime-created stores. An invalid or incomplete manifest fails visibly with a triage next step instead of silently guessing or switching to the old release with unrestored state. No operator action, schema change, new flag or manifest field is introduced. ## Why This Change Was Made The existing state publisher owns the write set; the launcher only executes it. The v1 manifest remains `{v:1,runId,files:[{live,preimage}]}` in the target release directory. Rename replay is restart-safe. Before mutation the publisher still records the full prospective list; after successful import and native close, it durably republishes that same manifest with unused prospective file families removed. Families actually created during boot retain all sidecar removals. An interrupted import before completion conservatively retains the broad list (the explicitly accepted rare case); no persisted provenance field is added. Manifest-backed rollback never interprets global `.upgraded-<build>` receipts or scans `.pre` paths. Targets without `.restore` retain the shipped compatibility interpreter, including the early Git launcher; the modern fallback scopes legacy receipt consumption to the trial's existing freshness window. Retire compatibility only when the supported update/rollback floor passes the last published target without `.restore`. A still-running older resident judges the first hop until a native service start loads format 4; this PR does not pretend an on-disk rewrite upgrades that process. Simplification: modern recovery has one declared write-set owner; inference is isolated in the explicitly temporary compatibility module. Scoped tokei production code (six touched production files, excluding tests): **1,265 → 1,381 (+116)**. Test-line guard: **+198**, below the existing 400 allowance; no allocation/exemption. ## Evidence - Pinned base: `627f23654573975faa0492e44562f5755b2d4101`; head: `7f07553a09ec2443dbdddfdcde4c0000ec812115`. - AWS owner/consumer suites: 90 assertions across seven files pass across the initial wave and the single repaired generated-import consumer. Covers authoritative target-only restore, external paths, stale same-build/global receipts, malformed manifests, interrupted rename replay, legacy fallback, late SQLite/WAL preservation and immutable retry originals. The initial wave exposed a quoted old export in one existing test; both quoted uses were migrated, with assertions unchanged, and that consumer passed on the final head. - Production/state-test types, changed-file lint/format and test-line guard passed. Full build and package integrity passed on the final head: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_1f93f346dea32b949bb9fcc1a1412188). Carrier `07484900409ed1cf2a1671cac06d98d53751afcd` binds identical source; candidate SHA256 `321b3d2674d23ed6d56cecfe1e10476fec4c006b173dfcb908a3ae8ccd6ca012`. - Published **2026.11.10 → head passed** through its real npm updater and native service: [AWS run](https://crabbox.openclaw.ai/portal/runs/run_9361f7427d0212093904834a993880ec), serving build `2026.11.10-07484900409e-2026-11-25T22-05-40.010Z`, ready/core/settled true. The first driver incorrectly expected that shipped in-place updater to produce a v2 trial; it timed out after the successful update. The corrected driver uses the real update result, then head's public release updater for conversion and the failing successor; no product bytes or package stamps changed. - Still running, not yet claimed: actual schema+1 successor rollback through resident format 4, including a store created through public session RPC after import completion. Trial/unit/journal, literal manifest, file identities and public-session receipts are captured. This requested product gate must pass before merge. - Exact-head local review: complete, patch correct, security cleared, no findings, confidence 0.76 (`~/.cache/clawsweeper-local-review/7f07553a09ec.md`). Its remaining proof gap is the running product gate. CI currently has no reds; no Windows or macOS product proof is claimed. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 9029709) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
) ## What Problem This Solves Schema-change CI can still report a previous-reader failure without failing the PR, and the test itself restores databases/config before checking that reader. That does not prove the rollback that an installed OpenClaw actually performs. Related coverage class: #203735, #203769, #204094, #204224, #204426, #204512, #204275. Follows #204883 and #205022 after #204956, #205165 and #205578. These are proof-debt coverage links, not claims to fix each runtime cause. ## User Impact Schema/migration changes must pass the existing Linux update lane's genuine previous-reader check. No shipped behavior, storage schema, launcher format or update contract changes. The nightly 10 GB case remains a separate PR. ## Why This Change Was Made The existing upgrade-survivor downgrade controller remains the sole check owner. T's public `update --tag file:<candidate> --no-restart` prepares the genuine candidate, and T's actual resident launcher retries and rolls back its trial. The harness records stopped-store inspection copies, trial/manifest/build evidence, then checks T's authenticated serving identity and exact seeded sessions, history and cron. Deletes the report-only/capability probe, the harness's store/config restoration writer, and the candidate's redundant global install. Raised-floor stores must return to T's committed schema/floor; unraised stores must retain T+1's schema/floor. Candidate-created null-preimage stores follow production restoration rather than a second test policy. The pre-listen barrier is target-root scoped so the real fallback is not parked. The resident and Gateway are separately detached processes; bounded cleanup and a shutdown allowance above the resident's real 15-second child deadline are necessary to observe stores only after shutdown. The fixture restarts the resident mid-trial to obtain quiescent post-migration facts without racing its retry. Line-count policy: direction over deletion quota; no production code added or changed (delta 0). On this PR's seven harness `.mjs` files, `tokei` code lines: **1,225 → 1,331 (+106)** against pinned main `b7bd237d00508e0999c7a3fc6e36bc32bf421098`. Growth replaces the synthetic restoration path with real updater/resident lifecycle coverage; no padded deletions. ## Evidence - Source/Fable 5.2 design challenge completed before implementation; accepted concrete corrections for real explicit-artifact preparation, launcher provenance, detached process ownership, release-scoped barrier and failure classification. - Final head **`d402754aeddc08073c5a768d0eb9ec5a757c090f`**: AWS [run_c853226a09bf6307cb2fb9c6883a6e3f](https://crabbox.openclaw.ai/portal/runs/run_c853226a09bf6307cb2fb9c6883a6e3f) passed canonical root-scripts types and **25/25** real NodeSQLite/barrier owner tests (8.90 seconds). Hosted [CI 45786731172](https://github.com/openclaw/openclaw/actions/runs/45786731172) is **green**, including lint, selected types, build, changed tests, docs, plan, guards and the existing [Docker seed lane](https://github.com/openclaw/openclaw/actions/runs/45786731172/job/139796419090) (**51m06s**, within its115-minute budget). - Nine-file AWS formatting passed in [run_7b781a5cac85a7c1da10d6c349c797db](https://crabbox.openclaw.ai/portal/runs/run_7b781a5cac85a7c1da10d6c349c797db). Final exact-head local review: patch correct, zero findings, security cleared (`d402754aeddc.md`). - **Genuine green:** AWS [run_61f0082ee849fbbdbe56541506e092d2](https://crabbox.openclaw.ai/portal/runs/run_61f0082ee849fbbdbe56541506e092d2), candidate full build **401.239 seconds**, real runtime **186 seconds**; T full build **398 seconds** in [run_f95430f16696a3a598cdbc58a7840fe2](https://crabbox.openclaw.ai/portal/runs/run_f95430f16696a3a598cdbc58a7840fe2). Genuine T source `9959708b7d1df23a2600c5f9b3e09d54270e391b` versus exact d402 candidate, both version2026.11.10 with distinct verified build IDs. Two real pre-listen crashes led to trial `rolled-back`, attempts2, actual format4 resident selecting T. T was ready/authenticated with matching build identity; exact histories for two agents and cron passed. Agent stores advanced44→45, retainedfloor44 and remained45 after rollback; shared42/floor42 was untouched. The actual manifest correctly contained no restore entries for this all-unraised pair. Raised-store restoration is not claimed as an integration result for this pair. Saved receipt/trial/manifest were independently read after root-owned artifact recovery; the driver itself exited0. - **Genuine red:** AWS [run_1b513d7779956f918a79f09cd66ada22](https://crabbox.openclaw.ai/portal/runs/run_1b513d7779956f918a79f09cd66ada22), throwaway commit **`4d9f9361eafb9d6f96866401973e8e5401efea29`** (never pushed/merged). Full build **403.664 seconds**, runtime **183 seconds**. A real floor-preserving migration changed canonical session labels and their projection. The actual required gate exited **1**, with **no structural/setup failures**, solely because T's old-label lookup returned0!==1. T was ready/authenticated with the correct serving build; the real resident had rolled back, and agent45/floor44 remained retained. Before this one full corrected run, [run_4ca76b2321c5e2fb29fc90a317dfe8c0](https://crabbox.openclaw.ai/portal/runs/run_4ca76b2321c5e2fb29fc90a317dfe8c0) (**64.925 seconds**) calibrated exact SQL against disposable retained copies and the unchanged genuine T oracle. The first projection-only specimen passed because RPC reads canonical JSON; it is not counted as red proof. Receipts, trials, manifests, store inspections and Gateway logtails were saved and independently read. - The genuine runtime pair is an explicitly historical qualification pair, **not this harness-only PR's fork point**. Automatic selected schema/migration CI still uses the genuine fork point → tested merge package; this PR changes no selector or fanout. The CI candidate package is reused; only selected schema/migration diffs incur the prior-release build and downgrade runtime. - AWS leases were released with `stop --wait` (including `cbx_5408b16cf245`). No provider fallback, assertion forcing, or host proof. **Runtime green/red requirements, exact-head local review and hosted CI are complete.** The10GB nightly remains deferred. - No host build/test/lint/format runs. Production restore is the only writer; no new production hooks or formats. Co-authored-by: Ayaan Zaidi <[email protected]>
…claw#205857) ## What Problem This Solves Schema-change CI can still report a previous-reader failure without failing the PR, and the test itself restores databases/config before checking that reader. That does not prove the rollback that an installed OpenClaw actually performs. Related coverage class: openclaw#203735, openclaw#203769, openclaw#204094, openclaw#204224, openclaw#204426, openclaw#204512, openclaw#204275. Follows openclaw#204883 and openclaw#205022 after openclaw#204956, openclaw#205165 and openclaw#205578. These are proof-debt coverage links, not claims to fix each runtime cause. ## User Impact Schema/migration changes must pass the existing Linux update lane's genuine previous-reader check. No shipped behavior, storage schema, launcher format or update contract changes. The nightly 10 GB case remains a separate PR. ## Why This Change Was Made The existing upgrade-survivor downgrade controller remains the sole check owner. T's public `update --tag file:<candidate> --no-restart` prepares the genuine candidate, and T's actual resident launcher retries and rolls back its trial. The harness records stopped-store inspection copies, trial/manifest/build evidence, then checks T's authenticated serving identity and exact seeded sessions, history and cron. Deletes the report-only/capability probe, the harness's store/config restoration writer, and the candidate's redundant global install. Raised-floor stores must return to T's committed schema/floor; unraised stores must retain T+1's schema/floor. Candidate-created null-preimage stores follow production restoration rather than a second test policy. The pre-listen barrier is target-root scoped so the real fallback is not parked. The resident and Gateway are separately detached processes; bounded cleanup and a shutdown allowance above the resident's real 15-second child deadline are necessary to observe stores only after shutdown. The fixture restarts the resident mid-trial to obtain quiescent post-migration facts without racing its retry. Line-count policy: direction over deletion quota; no production code added or changed (delta 0). On this PR's seven harness `.mjs` files, `tokei` code lines: **1,225 → 1,331 (+106)** against pinned main `dbf975ac7374fa6f95c5778cbe98abda8a8f5cc3`. Growth replaces the synthetic restoration path with real updater/resident lifecycle coverage; no padded deletions. ## Evidence - Source/Fable 5.2 design challenge completed before implementation; accepted concrete corrections for real explicit-artifact preparation, launcher provenance, detached process ownership, release-scoped barrier and failure classification. - Final head **`d402754aeddc08073c5a768d0eb9ec5a757c090f`**: AWS [run_c853226a09bf6307cb2fb9c6883a6e3f](https://crabbox.openclaw.ai/portal/runs/run_c853226a09bf6307cb2fb9c6883a6e3f) passed canonical root-scripts types and **25/25** real NodeSQLite/barrier owner tests (8.90 seconds). Hosted [CI 45786731172](https://github.com/openclaw/openclaw/actions/runs/45786731172) is **green**, including lint, selected types, build, changed tests, docs, plan, guards and the existing [Docker seed lane](https://github.com/openclaw/openclaw/actions/runs/45786731172/job/139796419090) (**51m06s**, within its115-minute budget). - Nine-file AWS formatting passed in [run_7b781a5cac85a7c1da10d6c349c797db](https://crabbox.openclaw.ai/portal/runs/run_7b781a5cac85a7c1da10d6c349c797db). Final exact-head local review: patch correct, zero findings, security cleared (`d402754aeddc.md`). - **Genuine green:** AWS [run_61f0082ee849fbbdbe56541506e092d2](https://crabbox.openclaw.ai/portal/runs/run_61f0082ee849fbbdbe56541506e092d2), candidate full build **401.239 seconds**, real runtime **186 seconds**; T full build **398 seconds** in [run_f95430f16696a3a598cdbc58a7840fe2](https://crabbox.openclaw.ai/portal/runs/run_f95430f16696a3a598cdbc58a7840fe2). Genuine T source `901b070361208f47a21206eba9c5ef9b5670f254` versus exact d402 candidate, both version2026.11.10 with distinct verified build IDs. Two real pre-listen crashes led to trial `rolled-back`, attempts2, actual format4 resident selecting T. T was ready/authenticated with matching build identity; exact histories for two agents and cron passed. Agent stores advanced44→45, retainedfloor44 and remained45 after rollback; shared42/floor42 was untouched. The actual manifest correctly contained no restore entries for this all-unraised pair. Raised-store restoration is not claimed as an integration result for this pair. Saved receipt/trial/manifest were independently read after root-owned artifact recovery; the driver itself exited0. - **Genuine red:** AWS [run_1b513d7779956f918a79f09cd66ada22](https://crabbox.openclaw.ai/portal/runs/run_1b513d7779956f918a79f09cd66ada22), throwaway commit **`4d9f9361eafb9d6f96866401973e8e5401efea29`** (never pushed/merged). Full build **403.664 seconds**, runtime **183 seconds**. A real floor-preserving migration changed canonical session labels and their projection. The actual required gate exited **1**, with **no structural/setup failures**, solely because T's old-label lookup returned0!==1. T was ready/authenticated with the correct serving build; the real resident had rolled back, and agent45/floor44 remained retained. Before this one full corrected run, [run_4ca76b2321c5e2fb29fc90a317dfe8c0](https://crabbox.openclaw.ai/portal/runs/run_4ca76b2321c5e2fb29fc90a317dfe8c0) (**64.925 seconds**) calibrated exact SQL against disposable retained copies and the unchanged genuine T oracle. The first projection-only specimen passed because RPC reads canonical JSON; it is not counted as red proof. Receipts, trials, manifests, store inspections and Gateway logtails were saved and independently read. - The genuine runtime pair is an explicitly historical qualification pair, **not this harness-only PR's fork point**. Automatic selected schema/migration CI still uses the genuine fork point → tested merge package; this PR changes no selector or fanout. The CI candidate package is reused; only selected schema/migration diffs incur the prior-release build and downgrade runtime. - AWS leases were released with `stop --wait` (including `cbx_5408b16cf245`). No provider fallback, assertion forcing, or host proof. **Runtime green/red requirements, exact-head local review and hosted CI are complete.** The10GB nightly remains deferred. - No host build/test/lint/format runs. Production restore is the only writer; no new production hooks or formats. Co-authored-by: Ayaan Zaidi <[email protected]>
The shipped swap retires WAL and SHM before renaming the staged main. After interruption, config selection could read metadata from the old main without the committed WAL, and a mode refusal could skip replay entirely. Settle existing durable intent under file-only Gateway custody before the first selected config snapshot or the raw startup guard. Source commit: e43debf Source PR: #205165 Release adaptation: Port only early replay; retain stable's copy-and-swap writer, existing applyPlan, plan format, and state 40 / agent 42. Share the lock-held replay loop with the ordinary upgrade owner, close both database handle families and recheck custody before swaps. Refuse and retain invalid plans; leave no-plan scratch alone and do not replay for dev reset. Do not port in-place migration, restore-image changes, or the applied-plan receipt. Co-authored-by: RomneyDa <[email protected]>
20 conflicts. Fork re-applies: SOUL identity section (now a manifest section, system-prompt-soul.ts), fire-and-forget moved into prepareSessionsSendReplyContext, memory-flush signal tokens via recordMemoryFlushSuccess extraFields, tts.stream row last. Redundant vs upstream: 22a277a (mostly, openclaw#206468/openclaw#207319), 963903f (openclaw#207212), sqlite copy-swap of f2fcce2 (openclaw#205165).
…chiving (#205026) * fix(sessions): keep inactive chats eligible for cold storage after archiving * test(sessions): align archive fixtures and identity baseline * test(sessions): create a private cold backup restore target (cherry picked from commit 81d69df) Follow-ups: 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048) [separately ordered lane row]; ece7a74 improve(workboard): apply the Control UI glossary and style to Workboard copy [not selected for this narrow backport]; b616036 refactor(subagents): simplify ACP spawn relay ownership (#207023) [not selected for this narrow backport]; 93ca762 improve: reduce allocations when preparing session rows (#207109) [not selected for this narrow backport]; 9993328 refactor(subagents): simplify kill claim and ownership handling (#207025) [not selected for this narrow backport]; 97815bd refactor(subagents): consolidate registry cleanup and publication guards (#207064) [not selected for this narrow backport]; e94f799 refactor(subagents): centralize requester turn matching (#206584) [not selected for this narrow backport]; ea77ca3 refactor: report update failures from recorded runs (#206700) [not selected for this narrow backport]; 4d7e00b fix: let started participant runs and requests finish after an access change (#206747) [not selected for this narrow backport]; f89ae43 refactor(subagents): use cleanup and terminal owners in sweeps (#206533) [not selected for this narrow backport]; a882e0f fix(agents): preserve task answers when sessions are reused (#126263) [not selected for this narrow backport]; 81fc833 refactor(subagents): own dormant child Stop decisions (#206479) [not selected for this narrow backport]; 91d4912 fix(update): stop using foreign recovery records as admission (#206295) [not selected for this narrow backport]; be3c73e fix(subagents): finish claimed stops after session rotation (#206405) [not selected for this narrow backport]; ed8b883 fix(update): settle after plugins and share one completion summary (#205987) [not selected for this narrow backport]; 1de306e fix: pause interrupted shell turns when their result is unknown (#205859) [separately ordered lane row]; 16a6aa4 fix(memory): keep a child's memory audience after its parent resets (#205887) [not selected for this narrow backport]; 50a7368 feat: let agents snooze a conversation after replying [not selected for this narrow backport]; 40f3903 fix(ci): remove unused role and workflow exports (#205720) [not selected for this narrow backport]; e43debf refactor(state): migrate in place and remove copy-and-swap (#205165) [not selected for this narrow backport]; 8027293 refactor(plugins): plugin tools take the turn's owner bit; delete the requester-owner continuation (OA2 PR 6j) (#205483) [not selected for this narrow backport]; 13e2ec3 feat: let participants publish through the session's shared GitHub account (#204914) [not selected for this narrow backport]; 5434992 fix: use the configured runtime when switching model providers (#203973) [not selected for this narrow backport]; 5271519 fix(feishu): honor the filename override on sent attachments (#205287) [not selected for this narrow backport]; ca087d4 refactor(admission): drop the replay automationAdmin bit and the R7 source re-check (#205268) [not selected for this narrow backport] Co-authored-by: RomneyDa <[email protected]>
Problem
Gateway boot copies a private state tree, runs Doctor there, and publishes database replacements. The generic rebuild fallback adds another migration owner. Update cost grows with unrelated state and retains competing copy/swap machinery.
Based on main ba96ee5, including #204956. Main only; no release-branch changes.
Fix
discoverDatabasesas the inventory. Reuse feat(state): publish candidate-owned restore manifests #204915's per-release.restorev1 receipt; only a raised reader floor needs a database image. SQLite images are independent CoW clones or byte copies, never hard links. PostgreSQL copies a namespace only as its rollback image..pre-<build-generation>naming and existingkind: addreceipt contract. No launcher reader or resident transition is added.doctor-health-contribution-runners.state.ts:62–84;doctor-session-transcripts.ts:227–355).de5a86ead888^:src/state/state-upgrade-tree.ts:719–753, now in existing schema repair before typed readers and only for outdated databases. The original order normalized beforerunChain(state-upgrade.ts:454–481), not inside Doctor. Normalization now uses one existing transaction per database; conflicts roll back, name the table/key and take the existing exit-78 refusal path..upgrade-*/plan.jsonbefore state reads. Stable 2026.11.10 shipped these plans; finishing one preserves committed WAL rows after an interrupted companion removal. No new plan is written.No new table, column, stored-row shape, migration option or fallback. Clone reuse follows @fuller-stack-dev's #201716 via existing
copySqliteFile. Related: #198389, #168750, #161888; retains #204752/#204227 inventory and clean-WAL work.User impact
Starts and updates stop copying/replacing the state tree. Compatible schema steps, including compatible external stores, take no database image. Floor-raising rollback uses only the recorded image; unsupported paths refuse before the old Gateway stops with move/retry instructions.
Accepted cost: without CoW, a floor-raising boot takes one byte copy of that database. No size refusal or 30-second probe. Required-image failure refuses before that step. Non-trial starts do not acquire copy-only prerequisites.
Historical imports must retain sessions. The six published-release corpora remain required. One-time empty-source ownership maintenance is followed by a no-op boot; its regression preserves bytes on the second boot.
Inherited frozen-reader edge: A commits → downgrade T → return to the same A build → A fails before replacing its receipt can consume stale build-keyed
kind: addentries (rollback-source.ts:39–55). Existing debt; the paused per-release manifest reader removes it.Legacy-import plans may conservatively declare prospective stores. A future manifest reader could remove a store created later at such a path during rollback. This is accepted only on the one-time legacy-import path, not schema-only/additive updates; absent targets are now excluded unless existing source owners report legacy import sources.
Accepted recovery edge: an invalid legacy
device.jsonwith no canonical identity is refused after the in-place schema upgrade; the existing full original backup preserves the pre-upgrade bytes. Canonical identity retains its shipped precedence over an invalid legacy file. No new credential reader or custody bypass is added.Evidence and current gate
Remote head: d449180. Current CI is the maintainer's final gate; earlier results remain scoped to their tested heads. The latest focused PostgreSQL proof is recorded below.
On the preceding 033d3de production tree,
ocx build --distpassed, then selected 2026.7.1-blob E2E passed (20.94s) with combined projection, additive-only and corrected historical non-STRICT normalization changes. The first version-only gate failed this corpus; the corrected gate passed.Corrected Doctor/native-bootstrap/admission files 49/49 passed; restored original fresh-profile pending-pin/offline-handoff contract 9/9 passed; recovery tests passed, including localhost/0.0.0.0.
Final catalog-only migration observer 7/7 passed. Inventory 27/27 passed. Leasehold 4/4 and admission gate 7 passed/3 PostgreSQL skipped passed on the initial catalog repair; the final historical gate was additionally qualified by the observer and BLOB corpus.
PostgreSQL tests had 6 skips without a qualified local connection. Neither skips nor the inventory-only run qualify the live PostgreSQL behavior.
Local import-cycles, Madge (0 cycles) and Kysely guards passed on the repair batch. This is not behavioral proof.
On committed bda6819,
ocx build --dtscompleted the actual full build in 13m05s (not a cache hit), including native declarations and all 165 public SDK subpaths. Earlier infrastructure-only lock/admission failures were resolved without changing source or bypassing ownership.Baseline regressions proved: run_f5d15c230817a891fa97f1a7218498af. Pinned
434459170floses the WAL witness at the selected assertion and refuses withconfig original must precede manifest; pinnedd31b2ca386refuses the repairable include withconfig-invalid: diagnostics.otel. Only test fixtures were overlaid. Lease released with--wait.Older a5ef head: run_d4822472e48e3a5f847c9bde74317959: full build, package and all six historical corpora passed (2026.7.1, 7.1-blob, 7.35, 8.35, 9.37, 10.10; seven tests including invalid-config preservation, zero skips). Admission/owner/live-PG/test-types/lint failed; subsequent fixes are not called green without verification.
Older 78af head only: published 2026.11.10 routed Gateway API upgrade passed: run_605e7f763523ff2d8dd7d20b7428893f, product row
e4d2cb81-841a-46a1-a6b7-50164052d3cd, state40→42/agent42→44, clean WAL without SHM accepted, exact commit serving, no sampled/final.upgrade-*tree. Product downtime82.424s; sampled95.671s. This does not qualify the current head's modern selective-image contract.539 diagnostic only: run_cbb2a0713d7096f4e6a9588d3b0a4f9c, one cron case: Gateway ready, zero provider requests, pre-run persistence refused missing
public.unaccent. The private AWS driver omitted extension provisioning present in canonical CI; the driver is corrected, with no speculative product change. This is setup-failure evidence, not a passing cron result. Lease released with--wait.Obsolete 716 proof lanes were stopped by maintainer direction; every lease was released with
--wait. Current-head native rollback, interrupted-plan startup and additive-boot qualification remain unproven. No AWS lease remains allocated.Remaining proof gaps: current-head CI, live PostgreSQL, and the native scenarios above. Inherited failures left unchanged: checkpoint timing at
agent-database-startup-verification.test.ts:340(#205290); scheduled-turn budget failure matches scheduled main run45634242694/job139276192521 exactly. For be51's merge-only stale-validator failure, owner regeneration left all52 outputs unchanged with identical SHA-256 manifests; no generated output was hand-edited.On 033d3de,
tokeion all46 touchedsrcproduction files, excluding*.test.ts,*.test-support.tsand*.test-harness.ts, against ba96ee5: 15,307→13,481 (-1,826) code lines. Whole PR including tests/docs: +3,586/-6,364, net -2,778.PostgreSQL startup admission follow-up
Under PostgreSQL, retired heartbeat configuration is now repaired at startup instead of merely reported: startup is valid, the legacy heartbeat is durably removed, and PostgreSQL configuration is retained. The ordinary main-thread PostgreSQL refusal remains enforced. Only synchronous Doctor manifest selection uses the existing engine admission; no admission spans asynchronous preparation.
The focused regression passed locally against the CI-pinned PostgreSQL 16 Docker image with
unaccent,pg_trgmandvector: 1 passed, 5 unselected cases skipped. Extended-stack reproduction identified the bundled-discovery policy read during Doctor manifest selection; the fixed test verifies the persisted repair. The owned container was removed after proof. This qualifies the selected regression, not the entire PostgreSQL suite.