Repository navigation
fix: release pressured background integrity readers - #204943
Merged
Merged
Conversation
- Acquire the private image through the existing online backup owner before verification. - Keep raw pages unnormalized until their integrity check, then preserve publication checks. - Prove live checkpoint progress and physical corruption refusal.
- Exercise publication mutation against the published file instead of staging internals. - Require raw acquired corruption and native diagnostics to survive until consumer verification.
- Count pinned SQLite pages rather than accumulated historical WAL frames. - Keep conservative recovery-family accounting for raw copies. - Remove the retired normalization-open test and preserve native corruption diagnostics.
- Keep native page probes in the existing SQLite primitive module. - Preserve logical-image admission without expanding SQL classifications. - Targeted capacity/error tests and the dialect ratchet pass.
- Publish byte pressure once at the checkpoint owner. - Cancel and join only the startup verifier child through its existing lifetime. - Preserve pressure and ownership controls in a real SQLite regression.
- Carry newly recorded checkpoint observations on the existing settled reply transport. - Qualify observations with captured actor identity and live request custody. - Keep explicit maintenance on its existing publication path and scope scan cancellation to its native reader. - Prove real scheduled worker tick delivery, owned-child cleanup, and stale-fact refusal.
- Keep the real held-SQLite child and native scheduled tick on the focused owning interface. - Cover warning-only and unrelated observations without a fabricated integrity verdict.
Contributor
|
🦞👀 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. |
- Preserve the already-settled preparation case in the bounded test helper. - The exact state-logging type leaf and real native checkpoint regression pass.
obviyus
added a commit
that referenced
this pull request
Nov 24, 2026
## What Problem This Solves Backup verification held a read transaction on the live SQLite store while scanning the whole database. Concurrent writes could therefore keep accumulating in the WAL even after the actual backup copy had finished. ## User Impact Backups release their live reader before integrity verification and compaction. Writers keep running, and corrupt source pages still prevent publication. The consistent-copy read transaction remains; this is not a hard WAL size cap. ## Why This Change Was Made Use the existing online-copy owner to acquire a raw private image, then verify that image before journal normalization, caller validation, transforms, or VACUUM. Delete the second live-source verification/copy path. Acquisition no longer normalizes pages before their corruption check, and a copied image does not certify a concurrently changing canonical source. Native capacity admission counts logical SQLite pages through the existing header owner; raw copies still reserve the full recovery family. ## Evidence - Test-first reproduction: a concurrent PASSIVE checkpoint copied **0 of 2 frames** during verification on the base. The regression now requires complete checkpoint progress and checks the backup's original rows against the source's later committed row. - **116 tests passed, 2 existing conditional skips on AWS/Linux**, across six owning snapshot/acquisition suites on `bd5521c7bc98`. The held-reader case, overwrite-WAL and WAL-only-growth sizing, physical corruption, publication mutation, and cleanup contracts passed. - Local owning checks passed, with 3 platform-conditional skips; targeted Oxlint found 0 warnings/errors. The full build with declarations and installed packed-CLI smoke passed on the initial copy-path revision. - Exact-head PR CI is green on `bd5521c7bc98`. The SQLite dialect ratchet decreased engine-maintenance constructs from 9 to 8, without a classification change. - The broader consumer run reached its 25-minute limit. Changed-check guards/formatting ran, but its test type graph reached the 15-minute local limit; canonical compiler/breadth proof remains with PR CI. Production delta: **+6 lines**; tests: **+181**; docs: **+3**. Background-verifier pressure handling is separate in #204943 and is not included here. Co-authored-by: Ayaan Zaidi <[email protected]>
- Keep only the intended actor-context override in the admission mock. - Retire its obsolete full-mock exception. - Registration and native checkpoint regressions, state-logging types, lint, and mock guard pass.
- Return the promised native-check result in the controlled Gateway startup fixture. - Gateway preparation and native checkpoint regressions pass (34 tests). - Gateway-server typecheck, lint, and mock-export guard pass.
Collaborator
Author
|
Landed. The background startup integrity verifier now gives up its own read when the checkpoint owner reports WAL pressure (blocked checkpoint and a WAL larger than twice the database or 64 MiB), so a long verification no longer keeps the WAL growing on a large store. The checkpoint fact now reaches the host from the normal 10 s worker ticks, not only from 30-minute passes. Proof: 36 verifier tests on AWS (run_39e14deb) and CI including PostgreSQL conformance and the Docker seed lane. Follows #204907. |
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 25, 2026
## What Problem This Solves Backup verification held a read transaction on the live SQLite store while scanning the whole database. Concurrent writes could therefore keep accumulating in the WAL even after the actual backup copy had finished. ## User Impact Backups release their live reader before integrity verification and compaction. Writers keep running, and corrupt source pages still prevent publication. The consistent-copy read transaction remains; this is not a hard WAL size cap. ## Why This Change Was Made Use the existing online-copy owner to acquire a raw private image, then verify that image before journal normalization, caller validation, transforms, or VACUUM. Delete the second live-source verification/copy path. Acquisition no longer normalizes pages before their corruption check, and a copied image does not certify a concurrently changing canonical source. Native capacity admission counts logical SQLite pages through the existing header owner; raw copies still reserve the full recovery family. ## Evidence - Test-first reproduction: a concurrent PASSIVE checkpoint copied **0 of 2 frames** during verification on the base. The regression now requires complete checkpoint progress and checks the backup's original rows against the source's later committed row. - **116 tests passed, 2 existing conditional skips on AWS/Linux**, across six owning snapshot/acquisition suites on `bd5521c7bc98`. The held-reader case, overwrite-WAL and WAL-only-growth sizing, physical corruption, publication mutation, and cleanup contracts passed. - Local owning checks passed, with 3 platform-conditional skips; targeted Oxlint found 0 warnings/errors. The full build with declarations and installed packed-CLI smoke passed on the initial copy-path revision. - Exact-head PR CI is green on `bd5521c7bc98`. The SQLite dialect ratchet decreased engine-maintenance constructs from 9 to 8, without a classification change. - The broader consumer run reached its 25-minute limit. Changed-check guards/formatting ran, but its test type graph reached the 15-minute local limit; canonical compiler/breadth proof remains with PR CI. Production delta: **+6 lines**; tests: **+181**; docs: **+3**. Background-verifier pressure handling is separate in #204943 and is not included here. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit a5bf129) Co-authored-by: RomneyDa <[email protected]>
obviyus
added a commit
that referenced
this pull request
Nov 25, 2026
…4868) Closes #204704 ## What Problem This Solves A release switch can replace or restore SQLite files while the previous Gateway or initiating CLI still holds them. On Windows this can prevent every new Gateway from starting with `EPERM` on `openclaw.sqlite-wal`. A restart can also keep waiting after its trial has already committed. ## User Impact Release switches wait for the old readers to close. An adopted package's committed trial ends `gateway restart` without requiring an operator-scoped health RPC. A connected CLI without `operator.read` gets a distinct diagnostic and a clear next step, not a false startup timeout. If an unmanaged foreground launcher dies before readiness, the old runtime exits with an error and prints `openclaw gateway` as the recovery command. It does not reopen a store that the launcher may have migrated. A live launcher remains the only recovery owner. ## Why This Change Was Made The existing shared-state close owner now joins native consumers and retires retained file-identity descriptors before custody transfers. The Gateway completes its boot record and closes shared state before releasing its lock; process cleanup and a final custody close precede a standalone launcher spawn. The retiring Gateway's readiness observer uses only HTTP and captured configuration; its sentinel reads/writes and in-process fallback after spawning a launcher are gone. Restart observers use file-lock identity, native process/listener information, HTTP and RPC instead of opening the store to inspect migration and owner leases. A live file owner retains bounded startup grace during a long migration. The update CLI releases custody at its existing pre-dispatch boundary, and the adopted-result waiter consumes the terminal phase at the sole trial path: update preparation already serializes active trials under the update lock. No schema, launcher protocol or public Plugin SDK API changes. The private QA startup collector retains its closed-fixture lease check on its existing connection. Service-definition repair publishes its planned command/environment and effective configuration after token preparation but before activation. Start and restart observers consume those facts instead of reopening SQLite to recapture repaired credentials or arguments. Windows captures its command once before `/Run`, retires preflight custody through the existing caller hook, and uses bounded file/process observations afterward. ## Evidence - On source baseline `33586124338a`, regressions fail for retained identity descriptors, an early-returning one-shot reader, RPC access after a committed trial, scope denial reported as a timeout, and a retiring successor observer reopening state. - The reported Linux external holders and Windows native ARM64 WAL/`EPERM` failures are retained base evidence; they were not repeated just to confirm them. - Earlier affected AWS gate on `c698a589b131` passed (`run_8c5f0a8b1085ed134733db543b577cc2`): seven Vitest shards in 189.73s, targeted types/lint and ratchets. This remains prior-head evidence, not final platform proof. - The first Windows head (`f798ffc61fd9`) was **red**: npm exited0, restart exited1 after728.479s and nothing served; signed Handle matched the initiating CLI to control/shared/quarantine SQLite. Final stable-path evidence is below; the separately reproduced repair-path gap is explicitly tracked. - Test growth after consolidation and the requested recovery regression is 848 net lines against the PR's base; the approved 448-line allocation covers the distinct contracts itemized below. No behavioral assertion is weakened. - Platform packages/proofs use source `21066b69471a1998505bac4ee4758e2138694d33`, rebuilt after the required main merge (including inherited WAL/state-upgrade changes). Later changes are the status-test warning correction and the narrowly guarded SQL-free stale-listener recovery fix, qualified by124 focused pinned-Bun consumer tests/typed lint. The platform recordings do not claim to exercise that legacy recovery branch or byte-equivalence with the later head. - **Linux crash/restore PASS** — [AWS run `run_ae3ce038d7ae16a26540b0d69c956015`](https://crabbox.openclaw.ai/portal/runs/run_ae3ce038d7ae16a26540b0d69c956015),201.82s:10 publication and6 restore snapshots, zero external native/identity holders and zero scan errors, all four families present. RestoredT served with its exact identity, read the persisted cron sentinel over RPC, and all live integrity checks passed. Actual update row finished/failed (expected injected crash); CLI settled exit1. No harness recovery. Receipt archive SHA256 `68973c89550142131208d65ca7de293b18bd9dcbfaa785a92f0e28831893766f`. - **Windows native ARM64 stable-path PASS** — npm0; restart0 on its own in107.673s; exact2106 RPC version/build with `connected_no_operator_scope`; store read passed; complete17-file scan found no EPERM. Stable archive SHA256 `260da7b92739a2444678d1bb61dbceb679f4aeae6f3400cc21a9032d52092906`. - Borrow qualification `run_ec051c902d31b5c93086dcbbfde87d1b` passed Node37 tests, process4 tests (including real watchdog SIGKILL and successor), and pinned Bun77 tests/1 skip. Test types and numeric guards passed. Its two static failures were a mistakenly removed required import and a stale inline suppression; both are corrected without changing borrower behavior. - Both Node and pinned Bun fail the unlinked-path regression on b8ee (`run_40c6e4e508e393b27716dc57072b0a88`). Registry-owner fix eeee passes Node cache/lock35 tests, pinned Bun cache10 tests, and original failing files/lock114 tests with21 skips (`run_2844130f72a5635dadfbce107f8cd587`). None of the six Bun failures needed a fixture expectation change. - Final head `da4ee212087163db858e1472f9052fd270d02f97` local review completed: patch correct, zero findings. The additional legacy-recovery guard/fixtures pass124 pinned-Bun consumer tests and targeted typed lint; migrating/healthy/unknown/foreign negative guards remain intact. - Inherited CI timing note: #204943's Bun checkpoint assertion failed in a prior CI shard. The one identical-test/identical-pinned-Bun comparison on current main094e225 and head3c43 both passed ([run `run_adc41ae48859bff924ccce98fb5a2119`](https://crabbox.openclaw.ai/portal/runs/run_adc41ae48859bff924ccce98fb5a2119)); no expectation/source change was made for it. Maintainer owns its once-only diagnostic rerun and owner routing; passing again is not claimed as a fix. - The approved narrow run-loop cap is1238 counted lines: inherited1235 plus the stop-budget custody join and restored required import. The cohesive persistence/custody-release block moved to run-loop-cleanup.ts; the old inline suppression and its inventory entry are removed. The original malformed-database report remains ground truth, but its physical corruption mechanism was not established. This change removes the proven unsafe custody handoff; it does not claim to identify a corrupt SQLite page. ## Known Edge Cases If a second update prepares in the short window after the first commits but before its CLI reads the trial, the first command can report the second outcome or wait until its deadline; both are visible, and `openclaw update status` shows the true runs. Windows coverage limit, explicitly accepted for this native-install cell: its actual tree is task supervisor → job anchor → cmd → Gateway, not a converted resident release launcher. No wrong process was killed and no launcher-manager recovery is claimed. The converted-install manager-cut cell belongs to the full matrix after#204866; it is not proven here. **Open reproduced repair gap: [#205035](#205035 TEMP-prefix service repair is not a pass: on source2106, npm0/346.427s, restart self-exit1/512.647s, target never ready, repeated EPERM publishing `control/services.sqlite`. Original archive SHA256 `29be88bba446d938eebe3dd4305f5b49c3248523b2096062c9a7cc09145fac5a`. A fresh diagnostic captured the restart CLI child node.exe PID1652/handle3E8 on that file104ms after the first error, while alive; live archive SHA256 `161ea7d9034b0a96294f37286f9473cf054c8599cd2ab14c9325b5ca73082f23`. Both source/target were non-readonly with FullControl ACLs. The post-native-install runtime-pin read (`service.ts:410–420`→`runtime-pin-store.ts:83–98`) and publication rename (`state-upgrade-tree.ts:627`) already exist on main; no repair fix or success is claimed here. Maintainer explicitly accepts landing this PR with that named gap, owned by the next repair-producer change. ### Backport `release/2026.11.15` (`f1debfde108a`) needs the custody correction: Gateway/resource retirement before lock transfer, file/HTTP-only restart observation, and CLI reader release. The serving Gateway must contain its part; a candidate cannot close an older process's handles. That release has no package-adoption waiter, so the terminal-trial waiter change is not part of the smallest backport. No backport PR was opened. ## Test Cost and Necessity Compared with PR base `1bec22471ad0`: **848 net test/support lines; 448 allocated above the 400-line allowance**. Shared full-lock/process fixtures removed39 lines, retained child diagnostics add9. The final +33 lines are the requested stale-owner regression (+28) and verified-owner caller migration (+5), explicitly approved. The orphan-FD case stays at the cache boundary: its native owner and admission record are already gone. The full-lock matrix instead retains a live borrower and must preserve Gateway exclusion. Combining those different states would obscure which owner failed. Repair producer, native dispatch, and caller-result tests likewise exercise different boundaries. All changed test/support files are listed; `+/-` counts include helper cost and deletions: | File | + / - | Contract or required migration | | --- | ---: | --- | | `src/cli/daemon-cli/diagnostic-readiness.test.ts` | 9 / 15 | Existing diagnostic consumers use file/HTTP snapshots. | | `src/cli/daemon-cli/lifecycle-core.test.ts` | 51 / 22 | Async drain ordering and refusal before native dispatch. | | `src/cli/daemon-cli/lifecycle-readiness.test.ts` | 92 / 2 | Captured facts and pre-activation readiness ownership. | | `src/cli/daemon-cli/lifecycle.test.ts` | 40 / 17 | Repaired facts reach callers without reopening stores. | | `src/cli/daemon-cli/restart-health-deadline.test.ts` | 3 / 3 | Existing deadline fixture cutover. | | `src/cli/daemon-cli/restart-health-probe.test.ts` | 80 / 2 | Scope denial settles distinctly without polling. | | `src/cli/daemon-cli/restart-health-progress.test.ts` | 77 / 1 | Long migration remains protected; verified stale stopped-listener recovery remains reachable without SQL. | | `src/cli/daemon-cli/restart-health-wait.test.ts` | 10 / 26 | Bounded waits replace DB migration polling. | | `src/cli/daemon-cli/restart-health.test-helpers.ts` | 0 / 3 | Remove obsolete DB observer mock. | | `src/cli/daemon-cli/restart-health.test.ts` | 25 / 19 | Existing restart fixtures consume file-only observations. | | `src/cli/daemon-cli/start-repair.test.ts` | 57 / 4 | Producer publishes prepared auth/command facts before activation. | | `src/cli/gateway-cli/run-loop-mocks.test-support.ts` | 6 / 30 | Remove sentinel/fallback mocks; retain launcher owner. | | `src/cli/gateway-cli/run-loop-natural-exit.test-support.ts` | 9 / 5 | Lifecycle cleanup ordering fixtures. | | `src/cli/gateway-cli/run-loop-restart-ownership.test-support.ts` | 1 / 1 | Existing restart owner fixture cutover. | | `src/cli/gateway-cli/run-loop-stop.test-support.ts` | 10 / 8 | Stop/flush ordering fixture cutover. | | `src/cli/gateway-cli/run-loop-update-respawn.test-support.ts` | 14 / 31 | Launcher failure replaces competing in-process recovery. | | `src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts` | 143 / 32 | Existing signal cases plus real stuck-borrow watchdog exit and successor. | | `src/cli/gateway-cli/run-loop.test-support.ts` | 6 / 25 | Remove retired successor sentinel behavior. | | `src/cli/gateway-cli/run-loop.test.ts` | 12 / 21 | Launcher death exits visibly without reopening state. | | `src/cli/gateway-cli/update-successor.test.ts` | 36 / 0 | Successor readiness never reopens shared state. | | `src/cli/update-cli/update-command-readiness.windows.test.ts` | 0 / 1 | Remove obsolete observer mock. | | `src/cli/update-cli/update-command-verification.test.ts` | 11 / 6 | Preserve switched-release recovery outcomes and negative guards with correct file-owner lifetimes. | | `src/commands/doctor-config-preflight.admission.process.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pending-read.test.ts` | 2 / 1 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.plugin-persistence.test.ts` | 3 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pristine.process.test.ts` | 2 / 5 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/health.test.ts` | 24 / 0 | CLI reports reached/scope denial, not timeout. | | `src/commands/startup-config-preflight.native-bootstrap.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/startup-config-preflight.recovery.test.ts` | 4 / 3 | Offline lease-inspector migration. | | `src/commands/status.scan.shared.test.ts` | 25 / 1 | Status preserves reached/no-scope capability and both warnings without another probe. | | `src/daemon/schtasks-runtime-definition.test.ts` | 54 / 5 | Captured command and exact file/PID/port observations avoid SQL. | | `src/daemon/schtasks.start.test.ts` | 24 / 0 | Existing effect hooks can refuse before Scheduled Task Run. | | `src/infra/gateway-lock.test.ts` | 127 / 1 | Shared/control/agent physical custody; immediate/borrowed handoff matrix. | | `src/infra/startup-migration-checkpoint.test-support.ts` | 35 / 0 | Offline-only inspector replaces removed production observer. | | `src/infra/startup-migration-checkpoint.test.ts` | 6 / 14 | Inspector moved without losing lease assertions. | | `src/state/openclaw-state-db-cache.cleanup.test.ts` | 38 / 1 | Unlinked, recordless identity FD closes physically. | | `src/state/openclaw-state-read-source.test.ts` | 50 / 2 | Successful one-shot CLI reads join native worker exit. | | `src/update/cli.test.ts` | 95 / 25 | File-only terminal trial/deadline and pre-dispatch custody refusal. | | `test/scripts/ci-workflow-guards.test.ts` | 5 / 4 | Required healthy/crash lane selection and artifacts. | | `test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts` | 2 / 2 | Remaining offline inspector caller migration. | Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 25, 2026
…4907) ## What Problem This Solves Backup verification held a read transaction on the live SQLite store while scanning the whole database. Concurrent writes could therefore keep accumulating in the WAL even after the actual backup copy had finished. ## User Impact Backups release their live reader before integrity verification and compaction. Writers keep running, and corrupt source pages still prevent publication. The consistent-copy read transaction remains; this is not a hard WAL size cap. ## Why This Change Was Made Use the existing online-copy owner to acquire a raw private image, then verify that image before journal normalization, caller validation, transforms, or VACUUM. Delete the second live-source verification/copy path. Acquisition no longer normalizes pages before their corruption check, and a copied image does not certify a concurrently changing canonical source. Native capacity admission counts logical SQLite pages through the existing header owner; raw copies still reserve the full recovery family. ## Evidence - Test-first reproduction: a concurrent PASSIVE checkpoint copied **0 of 2 frames** during verification on the base. The regression now requires complete checkpoint progress and checks the backup's original rows against the source's later committed row. - **116 tests passed, 2 existing conditional skips on AWS/Linux**, across six owning snapshot/acquisition suites on `bd5521c7bc98`. The held-reader case, overwrite-WAL and WAL-only-growth sizing, physical corruption, publication mutation, and cleanup contracts passed. - Local owning checks passed, with 3 platform-conditional skips; targeted Oxlint found 0 warnings/errors. The full build with declarations and installed packed-CLI smoke passed on the initial copy-path revision. - Exact-head PR CI is green on `bd5521c7bc98`. The SQLite dialect ratchet decreased engine-maintenance constructs from 9 to 8, without a classification change. - The broader consumer run reached its 25-minute limit. Changed-check guards/formatting ran, but its test type graph reached the 15-minute local limit; canonical compiler/breadth proof remains with PR CI. Production delta: **+6 lines**; tests: **+181**; docs: **+3**. Background-verifier pressure handling is separate in openclaw#204943 and is not included here. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 25, 2026
## What Problem This Solves A background integrity reader can retain an old SQLite snapshot while checkpoints are blocked. The native writer already observes checkpoint pressure, but ordinary worker replies did not carry that observation back to the Gateway that owns the background reader. Builds on merged openclaw#204907. This PR is retargeted to `main` and contains only the verifier/worker-observation slice. ## User Impact Background integrity checks release their own reader under excessive blocked-WAL pressure. User reads and writes continue unchanged. Interrupted verification stays inconclusive: no verification receipt, clean-close seal, or corruption refusal is invented. This is not a hard WAL size cap. ## Why This Change Was Made The existing checkpoint owner computes byte pressure once: blocked, with WAL bytes greater than both twice the database size and 64 MiB. Newly recorded observations travel on the existing settled worker reply, qualified by the original actor's physical identity and current custody. Optional fast-grant authority keeps its stronger incarnation check. The verifier subscribes only during its native integrity promise, aborts and joins its own child, and unregisters before verdict processing. Explicit maintenance retains its existing publication route. There is no new channel, registry, scheduler, retry loop, or writer-admission policy. Existing backend validation and reply contracts move to their existing loader/type owners to keep the implementation local and bounded. The lifecycle-file change is type imports only. ## Evidence - Real native scheduled tick → ordinary session command → host observation regression was **red** with the owned SQLite child still alive, then **green** with joined cancellation and subsequent checkpoint progress. It does not inject a host checkpoint fact or issue an explicit WAL-maintenance command for the positive case. - **54 local tests passed** across six targeted files, including healthy/corrupt verification, native loss, quarantine, ordinary replies, checkpoint handling, and cleanup. **36 tests passed on AWS/Linux** across the five transport/checkpoint suites in parallel with the backup proof. - Stale physical identity, birthtime, path, incarnation, custody, and owner observations cannot publish through the reply boundary. Warning-only and unrelated-store pressure do not cancel the scan. - Targeted Oxlint: 0 warnings/errors; changed-file formatting passed. The exact state-logging compiler leaf passes after the test-only optional-promise correction; its focused native regression passes too. Canonical compiler/breadth validation belongs to PR CI. - Local reviews of `8ff498ec` and `eafdcfb3` found no actionable correctness/security defects. The later merge from `main` introduces no additional verifier runtime changes. - Exact-head PR CI is **green on `7afef14b9c12`**, including PostgreSQL conformance and Docker seed E2E. The last repairs changed test fixtures only. Production delta: **+157 lines**; test/support/routing delta: **+460**; docs: **+8**. The additional transport is required by the real native-flow regression; the smaller main-thread-only implementation was not shipped. The regression allocation records the native process/worker harness above the normal test budget. Registration fixtures preserve real unrelated broker exports, and their retired full-mock exception is removed. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 25, 2026
…nclaw#204868) Closes openclaw#204704 ## What Problem This Solves A release switch can replace or restore SQLite files while the previous Gateway or initiating CLI still holds them. On Windows this can prevent every new Gateway from starting with `EPERM` on `openclaw.sqlite-wal`. A restart can also keep waiting after its trial has already committed. ## User Impact Release switches wait for the old readers to close. An adopted package's committed trial ends `gateway restart` without requiring an operator-scoped health RPC. A connected CLI without `operator.read` gets a distinct diagnostic and a clear next step, not a false startup timeout. If an unmanaged foreground launcher dies before readiness, the old runtime exits with an error and prints `openclaw gateway` as the recovery command. It does not reopen a store that the launcher may have migrated. A live launcher remains the only recovery owner. ## Why This Change Was Made The existing shared-state close owner now joins native consumers and retires retained file-identity descriptors before custody transfers. The Gateway completes its boot record and closes shared state before releasing its lock; process cleanup and a final custody close precede a standalone launcher spawn. The retiring Gateway's readiness observer uses only HTTP and captured configuration; its sentinel reads/writes and in-process fallback after spawning a launcher are gone. Restart observers use file-lock identity, native process/listener information, HTTP and RPC instead of opening the store to inspect migration and owner leases. A live file owner retains bounded startup grace during a long migration. The update CLI releases custody at its existing pre-dispatch boundary, and the adopted-result waiter consumes the terminal phase at the sole trial path: update preparation already serializes active trials under the update lock. No schema, launcher protocol or public Plugin SDK API changes. The private QA startup collector retains its closed-fixture lease check on its existing connection. Service-definition repair publishes its planned command/environment and effective configuration after token preparation but before activation. Start and restart observers consume those facts instead of reopening SQLite to recapture repaired credentials or arguments. Windows captures its command once before `/Run`, retires preflight custody through the existing caller hook, and uses bounded file/process observations afterward. ## Evidence - On source baseline `e147cdfe6e38`, regressions fail for retained identity descriptors, an early-returning one-shot reader, RPC access after a committed trial, scope denial reported as a timeout, and a retiring successor observer reopening state. - The reported Linux external holders and Windows native ARM64 WAL/`EPERM` failures are retained base evidence; they were not repeated just to confirm them. - Earlier affected AWS gate on `c698a589b131` passed (`run_8c5f0a8b1085ed134733db543b577cc2`): seven Vitest shards in 189.73s, targeted types/lint and ratchets. This remains prior-head evidence, not final platform proof. - The first Windows head (`f798ffc61fd9`) was **red**: npm exited0, restart exited1 after728.479s and nothing served; signed Handle matched the initiating CLI to control/shared/quarantine SQLite. Final stable-path evidence is below; the separately reproduced repair-path gap is explicitly tracked. - Test growth after consolidation and the requested recovery regression is 848 net lines against the PR's base; the approved 448-line allocation covers the distinct contracts itemized below. No behavioral assertion is weakened. - Platform packages/proofs use source `21066b69471a1998505bac4ee4758e2138694d33`, rebuilt after the required main merge (including inherited WAL/state-upgrade changes). Later changes are the status-test warning correction and the narrowly guarded SQL-free stale-listener recovery fix, qualified by124 focused pinned-Bun consumer tests/typed lint. The platform recordings do not claim to exercise that legacy recovery branch or byte-equivalence with the later head. - **Linux crash/restore PASS** — [AWS run `run_ae3ce038d7ae16a26540b0d69c956015`](https://crabbox.openclaw.ai/portal/runs/run_ae3ce038d7ae16a26540b0d69c956015),201.82s:10 publication and6 restore snapshots, zero external native/identity holders and zero scan errors, all four families present. RestoredT served with its exact identity, read the persisted cron sentinel over RPC, and all live integrity checks passed. Actual update row finished/failed (expected injected crash); CLI settled exit1. No harness recovery. Receipt archive SHA256 `68973c89550142131208d65ca7de293b18bd9dcbfaa785a92f0e28831893766f`. - **Windows native ARM64 stable-path PASS** — npm0; restart0 on its own in107.673s; exact2106 RPC version/build with `connected_no_operator_scope`; store read passed; complete17-file scan found no EPERM. Stable archive SHA256 `260da7b92739a2444678d1bb61dbceb679f4aeae6f3400cc21a9032d52092906`. - Borrow qualification `run_ec051c902d31b5c93086dcbbfde87d1b` passed Node37 tests, process4 tests (including real watchdog SIGKILL and successor), and pinned Bun77 tests/1 skip. Test types and numeric guards passed. Its two static failures were a mistakenly removed required import and a stale inline suppression; both are corrected without changing borrower behavior. - Both Node and pinned Bun fail the unlinked-path regression on b8ee (`run_40c6e4e508e393b27716dc57072b0a88`). Registry-owner fix eeee passes Node cache/lock35 tests, pinned Bun cache10 tests, and original failing files/lock114 tests with21 skips (`run_2844130f72a5635dadfbce107f8cd587`). None of the six Bun failures needed a fixture expectation change. - Final head `da4ee212087163db858e1472f9052fd270d02f97` local review completed: patch correct, zero findings. The additional legacy-recovery guard/fixtures pass124 pinned-Bun consumer tests and targeted typed lint; migrating/healthy/unknown/foreign negative guards remain intact. - Inherited CI timing note: openclaw#204943's Bun checkpoint assertion failed in a prior CI shard. The one identical-test/identical-pinned-Bun comparison on current main094e225 and head3c43 both passed ([run `run_adc41ae48859bff924ccce98fb5a2119`](https://crabbox.openclaw.ai/portal/runs/run_adc41ae48859bff924ccce98fb5a2119)); no expectation/source change was made for it. Maintainer owns its once-only diagnostic rerun and owner routing; passing again is not claimed as a fix. - The approved narrow run-loop cap is1238 counted lines: inherited1235 plus the stop-budget custody join and restored required import. The cohesive persistence/custody-release block moved to run-loop-cleanup.ts; the old inline suppression and its inventory entry are removed. The original malformed-database report remains ground truth, but its physical corruption mechanism was not established. This change removes the proven unsafe custody handoff; it does not claim to identify a corrupt SQLite page. ## Known Edge Cases If a second update prepares in the short window after the first commits but before its CLI reads the trial, the first command can report the second outcome or wait until its deadline; both are visible, and `openclaw update status` shows the true runs. Windows coverage limit, explicitly accepted for this native-install cell: its actual tree is task supervisor → job anchor → cmd → Gateway, not a converted resident release launcher. No wrong process was killed and no launcher-manager recovery is claimed. The converted-install manager-cut cell belongs to the full matrix after#204866; it is not proven here. **Open reproduced repair gap: [openclaw#205035](openclaw#205035 TEMP-prefix service repair is not a pass: on source2106, npm0/346.427s, restart self-exit1/512.647s, target never ready, repeated EPERM publishing `control/services.sqlite`. Original archive SHA256 `29be88bba446d938eebe3dd4305f5b49c3248523b2096062c9a7cc09145fac5a`. A fresh diagnostic captured the restart CLI child node.exe PID1652/handle3E8 on that file104ms after the first error, while alive; live archive SHA256 `161ea7d9034b0a96294f37286f9473cf054c8599cd2ab14c9325b5ca73082f23`. Both source/target were non-readonly with FullControl ACLs. The post-native-install runtime-pin read (`service.ts:410–420`→`runtime-pin-store.ts:83–98`) and publication rename (`state-upgrade-tree.ts:627`) already exist on main; no repair fix or success is claimed here. Maintainer explicitly accepts landing this PR with that named gap, owned by the next repair-producer change. ### Backport `release/2026.11.15` (`109e8ff908ae`) needs the custody correction: Gateway/resource retirement before lock transfer, file/HTTP-only restart observation, and CLI reader release. The serving Gateway must contain its part; a candidate cannot close an older process's handles. That release has no package-adoption waiter, so the terminal-trial waiter change is not part of the smallest backport. No backport PR was opened. ## Test Cost and Necessity Compared with PR base `285567057721`: **848 net test/support lines; 448 allocated above the 400-line allowance**. Shared full-lock/process fixtures removed39 lines, retained child diagnostics add9. The final +33 lines are the requested stale-owner regression (+28) and verified-owner caller migration (+5), explicitly approved. The orphan-FD case stays at the cache boundary: its native owner and admission record are already gone. The full-lock matrix instead retains a live borrower and must preserve Gateway exclusion. Combining those different states would obscure which owner failed. Repair producer, native dispatch, and caller-result tests likewise exercise different boundaries. All changed test/support files are listed; `+/-` counts include helper cost and deletions: | File | + / - | Contract or required migration | | --- | ---: | --- | | `src/cli/daemon-cli/diagnostic-readiness.test.ts` | 9 / 15 | Existing diagnostic consumers use file/HTTP snapshots. | | `src/cli/daemon-cli/lifecycle-core.test.ts` | 51 / 22 | Async drain ordering and refusal before native dispatch. | | `src/cli/daemon-cli/lifecycle-readiness.test.ts` | 92 / 2 | Captured facts and pre-activation readiness ownership. | | `src/cli/daemon-cli/lifecycle.test.ts` | 40 / 17 | Repaired facts reach callers without reopening stores. | | `src/cli/daemon-cli/restart-health-deadline.test.ts` | 3 / 3 | Existing deadline fixture cutover. | | `src/cli/daemon-cli/restart-health-probe.test.ts` | 80 / 2 | Scope denial settles distinctly without polling. | | `src/cli/daemon-cli/restart-health-progress.test.ts` | 77 / 1 | Long migration remains protected; verified stale stopped-listener recovery remains reachable without SQL. | | `src/cli/daemon-cli/restart-health-wait.test.ts` | 10 / 26 | Bounded waits replace DB migration polling. | | `src/cli/daemon-cli/restart-health.test-helpers.ts` | 0 / 3 | Remove obsolete DB observer mock. | | `src/cli/daemon-cli/restart-health.test.ts` | 25 / 19 | Existing restart fixtures consume file-only observations. | | `src/cli/daemon-cli/start-repair.test.ts` | 57 / 4 | Producer publishes prepared auth/command facts before activation. | | `src/cli/gateway-cli/run-loop-mocks.test-support.ts` | 6 / 30 | Remove sentinel/fallback mocks; retain launcher owner. | | `src/cli/gateway-cli/run-loop-natural-exit.test-support.ts` | 9 / 5 | Lifecycle cleanup ordering fixtures. | | `src/cli/gateway-cli/run-loop-restart-ownership.test-support.ts` | 1 / 1 | Existing restart owner fixture cutover. | | `src/cli/gateway-cli/run-loop-stop.test-support.ts` | 10 / 8 | Stop/flush ordering fixture cutover. | | `src/cli/gateway-cli/run-loop-update-respawn.test-support.ts` | 14 / 31 | Launcher failure replaces competing in-process recovery. | | `src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts` | 143 / 32 | Existing signal cases plus real stuck-borrow watchdog exit and successor. | | `src/cli/gateway-cli/run-loop.test-support.ts` | 6 / 25 | Remove retired successor sentinel behavior. | | `src/cli/gateway-cli/run-loop.test.ts` | 12 / 21 | Launcher death exits visibly without reopening state. | | `src/cli/gateway-cli/update-successor.test.ts` | 36 / 0 | Successor readiness never reopens shared state. | | `src/cli/update-cli/update-command-readiness.windows.test.ts` | 0 / 1 | Remove obsolete observer mock. | | `src/cli/update-cli/update-command-verification.test.ts` | 11 / 6 | Preserve switched-release recovery outcomes and negative guards with correct file-owner lifetimes. | | `src/commands/doctor-config-preflight.admission.process.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pending-read.test.ts` | 2 / 1 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.plugin-persistence.test.ts` | 3 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pristine.process.test.ts` | 2 / 5 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/health.test.ts` | 24 / 0 | CLI reports reached/scope denial, not timeout. | | `src/commands/startup-config-preflight.native-bootstrap.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/startup-config-preflight.recovery.test.ts` | 4 / 3 | Offline lease-inspector migration. | | `src/commands/status.scan.shared.test.ts` | 25 / 1 | Status preserves reached/no-scope capability and both warnings without another probe. | | `src/daemon/schtasks-runtime-definition.test.ts` | 54 / 5 | Captured command and exact file/PID/port observations avoid SQL. | | `src/daemon/schtasks.start.test.ts` | 24 / 0 | Existing effect hooks can refuse before Scheduled Task Run. | | `src/infra/gateway-lock.test.ts` | 127 / 1 | Shared/control/agent physical custody; immediate/borrowed handoff matrix. | | `src/infra/startup-migration-checkpoint.test-support.ts` | 35 / 0 | Offline-only inspector replaces removed production observer. | | `src/infra/startup-migration-checkpoint.test.ts` | 6 / 14 | Inspector moved without losing lease assertions. | | `src/state/openclaw-state-db-cache.cleanup.test.ts` | 38 / 1 | Unlinked, recordless identity FD closes physically. | | `src/state/openclaw-state-read-source.test.ts` | 50 / 2 | Successful one-shot CLI reads join native worker exit. | | `src/update/cli.test.ts` | 95 / 25 | File-only terminal trial/deadline and pre-dispatch custody refusal. | | `test/scripts/ci-workflow-guards.test.ts` | 5 / 4 | Required healthy/crash lane selection and artifacts. | | `test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts` | 2 / 2 | Remaining offline inspector caller migration. | Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot
added a commit
that referenced
this pull request
Nov 25, 2026
## What Problem This Solves Backup verification held a read transaction on the live SQLite store while scanning the whole database. Concurrent writes could therefore keep accumulating in the WAL even after the actual backup copy had finished. ## User Impact Backups release their live reader before integrity verification and compaction. Writers keep running, and corrupt source pages still prevent publication. The consistent-copy read transaction remains; this is not a hard WAL size cap. ## Why This Change Was Made Use the existing online-copy owner to acquire a raw private image, then verify that image before journal normalization, caller validation, transforms, or VACUUM. Delete the second live-source verification/copy path. Acquisition no longer normalizes pages before their corruption check, and a copied image does not certify a concurrently changing canonical source. Native capacity admission counts logical SQLite pages through the existing header owner; raw copies still reserve the full recovery family. ## Evidence - Test-first reproduction: a concurrent PASSIVE checkpoint copied **0 of 2 frames** during verification on the base. The regression now requires complete checkpoint progress and checks the backup's original rows against the source's later committed row. - **116 tests passed, 2 existing conditional skips on AWS/Linux**, across six owning snapshot/acquisition suites on `bd5521c7bc98`. The held-reader case, overwrite-WAL and WAL-only-growth sizing, physical corruption, publication mutation, and cleanup contracts passed. - Local owning checks passed, with 3 platform-conditional skips; targeted Oxlint found 0 warnings/errors. The full build with declarations and installed packed-CLI smoke passed on the initial copy-path revision. - Exact-head PR CI is green on `bd5521c7bc98`. The SQLite dialect ratchet decreased engine-maintenance constructs from 9 to 8, without a classification change. - The broader consumer run reached its 25-minute limit. Changed-check guards/formatting ran, but its test type graph reached the 15-minute local limit; canonical compiler/breadth proof remains with PR CI. Production delta: **+6 lines**; tests: **+181**; docs: **+3**. Background-verifier pressure handling is separate in #204943 and is not included here. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit a5bf129) Release adaptation for 2026.11.11: resolved import-only conflicts (kept pathEntryExists, dropped imports the fix retires) and kept the existing capacity allocation test beside the new logical-image budget test. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
obviyus
added a commit
that referenced
this pull request
Nov 25, 2026
Closes #204880 ## What Problem This Solves A build currently refuses every database written at a newer schema version, even when the change only adds storage that the older build can safely ignore. This prevents a previous Gateway from reopening compatible state after an update trial. ## User Impact The next stable can reopen future SQLite state, agent stores, and PostgreSQL schemas when their recorded reader floor permits it. Incompatible changes still stop startup with a clear schema refusal. Existing strict stores retain their current format and behavior; this PR does not change update backup policy. ## Why This Change Was Made The existing version owners publish or clear `min_reader` in the version transaction. An absent/null floor means the writer version, so strict steps need no new storage; the first tolerable step adds a nullable floor column. Pre-v43 agent history stays strict; from v43 the SQLite migration finisher derives tolerance from the migrated predecessor catalog. No schema number is bumped, and port publication is unchanged. Admission, boot preflight and catalog checks preserve the actual writer version while accepting unknown tables and NULL-safe nullable columns. Non-nullable columns, non-NULL defaults, CHECKs rejecting NULL, generated columns, keys and references stay non-additive. Known constraints, triggers and ownership checks remain enforced; PostgreSQL also requires the newer writer's unchanged catalog seal. Newer registry rows remain discovery candidates; the `raised` case in `openclaw-agent-db.checkonce.test.ts` proves that a store whose floor is above this code is still refused at open. Ayaan approved this schema contract change on 2026-11-24 (`state-model-decision.md`). This PR targets main only; the release manager owns any backport. Rollback also retains the valid restored config when automatic recovery finds a newer writer's backup. The existing destructive-action guard remains enforced for an actually loaded newer config; prepared, synchronous and asynchronous recovery share this rule. The independent config-recovery repair is being landed first as a prerequisite (it also affects existing copy-and-swap rollback). Once main contains it, this PR will inherit the same implementation rather than carry a second change. ## Evidence - AWS: 164 SQLite/boot/catalog tests and 44 PostgreSQL tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_44448ae157b99967d36d4de1029769af)). - Red on unmodified main: SQLite state, SQLite agent, and PostgreSQL writable/read-only admission refuse the same compatible-newer fixtures ([run](https://crabbox.openclaw.ai/portal/runs/run_06577478aecf849ce6463a01fab37b53)). - Two local ClawSweeper rounds completed; verified findings were fixed. The lead reviewed the final registry delta and the subsequent behavior-equivalent type/lint fixes against the exact head. - AWS `check:changed` passed on `956fc25da6`: core/core-test type graphs, lint, format, dead-export checks, SQLite worker/dialect guards, and the remaining selected guards ([run](https://crabbox.openclaw.ai/portal/runs/run_cf80edb44a2a04deba0c2cf62af5810f)). Narrow subsequent auth/guard changes require the checks below. - Linux T/T+1 packages built successfully ([run](https://crabbox.openclaw.ai/portal/runs/run_5eaf078abca514a139d8c599b2092035)). That run exposed the restored-config recovery blocker, which was fixed rather than bypassed. The recovery regression then failed against the old owner and all 56 main config tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_96332cda9f136830532e490fd55faacb)). **Proof status:** the completed main SQLite downgrade run is recorded below. The built PostgreSQL downgrade cell remains NOT RUN; it is not claimed green. Affected behavior and final-head type checks remain covered by required PR CI. ## Scope One version owner per store publishes the floor; strict steps retain the existing encoding. The change removes duplicate shared-version publication rather than adding a parallel migration mechanism. The focused column classifier now lives in `sqlite-additive-column.ts` to satisfy the existing owner's line cap; both consumers import it directly, without a facade or re-export. No broad historical fixture rewrites or unrelated documentation changes remain. Follow-up class: the admission rule currently spans about 15 independent version gates; consolidate them behind one admission owner so a future rule change is one edit. This PR only changes their existing decisions and required propagation. <details> <summary>LSP production reader inventory</summary> LSP references were collected before edits; its index is anchored to the primary checkout, so coordinates are not claimed for these frozen worktrees. New worktree-only consumers are named explicitly below. Paths without a prefix are under `src/state/`. - Shared version gate: `openclaw-state-db-schema-version.ts`, `openclaw-state-db-maintenance.ts`, `openclaw-state-db-fast-path.ts`, `openclaw-state-db-existing-schema.ts`, `openclaw-state-db-open.ts`, `openclaw-state-db-read-schema.ts`, `openclaw-state-db-existing-write.ts`, `openclaw-state-db-startup-checkpoint.ts`, `openclaw-state-db-schema-runtime.ts`, `openclaw-state-db-read-connection.ts`, `openclaw-state-db.ts`, `startup-metadata-live-read.worker.ts`, `src/plugins/update-cohort-recovery.ts`, `src/snapshot/openclaw-snapshot-copy.ts`, `src/snapshot/git-backup-codec.ts`, `src/agents/harness/native-hook-relay-client-read.ts`. New floor-read consumers: `openclaw-state-schema-preflight.ts`, `src/infra/sqlite-schema-header.ts`. - Agent version gate: `openclaw-agent-db-schema-read.ts`, `openclaw-agent-db-owner-read.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema.ts`, `openclaw-agent-db-maintenance.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/infra/database-engine/agent-port-descriptor.ts`, `src/infra/state-migrations.media-persistence.ts`, `src/snapshot/git-backup-codec.ts`, `src/snapshot/openclaw-snapshot-copy.ts`. Current-agent metadata gate: `openclaw-agent-db-engine.ts`, `openclaw-agent-db-schema-helpers.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`. - PostgreSQL physical admission: `src/infra/database-engine/open.ts`, `openclaw-state-db-engine.ts`. Schema verification: `src/infra/database-engine/physical-facts.ts`, `src/infra/database-engine/adapters.ts`. Engine-open callers: `openclaw-state-db-open.ts`, `openclaw-agent-db-engine.ts`, `openclaw-state-db-engine.ts`, `src/infra/database-engine/historical-index-ordering-port.ts`, `src/infra/database-engine/state-port-descriptor.ts`; Plugin SDK re-export unchanged. - Runtime inspection/preflight: `openclaw-agent-schema-inspection.worker.ts`, `openclaw-database-preflight.ts`, `openclaw-state-read-operation-registry.ts`. Preflight entry callers include Doctor database preflight, startup client credentials, preflight contexts, update-data-at-risk, auto-update compatibility, daemon status, Gateway bootstrap/startup maintenance, Doctor lease refusal and agent admission. Explicit updater-target policy remains strict. - Audit catalog admission: `openclaw-state-db-audit-migration.ts`, `openclaw-state-db-schema-repair.ts`. Canonical session-validation catalog admission: `openclaw-agent-canonical-validation-schema.ts`, `openclaw-agent-canonical-validation-receipt.ts`, `openclaw-agent-db-validation-cache.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema-admission.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/config/sessions/session-canonical-key.ts`. - Registry candidate filtering: `openclaw-agent-db-registry-listing.ts` (inspection, memo and snapshot paths), `src/infra/update-data-at-risk.ts`, `src/commands/doctor-db-bloat.read.ts`. Actual store admission remains the floor authority. - Config recovery's existing future-version guard is now consulted by the shared recovery plan builder. LSP callers: `io.observe-recovery.ts` prepared and immediate recovery entrypoints; synchronous/asynchronous startup loaders at `src/config/io.load.ts:210-212`; prepared snapshot recovery at `src/config/io.snapshot.ts:486`. Actual current-config admission in Gateway pre-bootstrap is unchanged. - Auth-profile reader admission: LSP production consumers `src/agents/auth-profiles/sqlite-json.ts:187,210` and `src/agents/auth-profiles/sqlite.ts:239,361` now use the canonical agent floor gate. Pooled same-version reuse remains query-free; a changed supplied version is checked once. </details> ## Test growth allocation The maintainer approved allocation **150** for measured net test growth550: the prior127, optional-floor reference metadata (5), persisted-floor/refusal proof (2), cold-worker zero-comparison-DDL coverage (6), and cap-required fixture extraction/imports/formatting (10). The obsolete strict43-reader refusal case is replaced by actual44-writer/floor43 admission and old-writer NULL insertion proof. Only a redundant step-presence assertion was removed; exact rollback, ownership, catalog and constraint assertions remain. | Test file (`src/` unless otherwise qualified) | + / - | Protected contract | | --- | ---: | --- | | `agents/auth-profiles.sqlite-read-pool.test.ts` | 42 / 0 | Retained/raised floors through projected/plain auth readers; query-free warm reuse. | | `config/sessions/startup-migration.acp.test.ts` | 4 / 1 | Legacy admission uses consistent header/ownership markers. | | `infra/database-engine/bridge-prestart.test.ts` | 1 / 0 | PostgreSQL admission facts carry the required floor. | | `infra/database-engine/physical-facts.test.ts` | 2 / 2 | Strict metadata keeps absent-floor compatibility. | | `infra/database-engine/schema-admission.postgres.test.ts` | 172 / 1 | Writable/read-only T+1 admission; malformed/raised floors; nullable versus constrained catalogs; seals and rollback. | | `infra/sqlite-schema-facts.test.ts` | 42 / 0 | Warm future-reader cache stays query-free and rejects floors raised after schema/version invalidation. | | `infra/sqlite-schema-header.test.ts` | 9 / 5 | Floor/ownership survive inspection; native lock/WAL fixtures carry historical agent metadata. | | `state/openclaw-agent-db-registry-listing.snapshot.test.ts` | 2 / 2 | Future stores remain discovery candidates, not implicitly admitted stores. | | `state/openclaw-agent-db.checkonce.test.ts` | 120 / 5 | SQLite agent admission, readonly open, metadata preservation and transactional floor publication/rollback. | | `state/openclaw-agent-db.committed-read.test.ts` | 4 / 1 | A legacy replacement is refused before invoking its reader. | | `state/openclaw-database-preflight.startup-prepared.test.ts` | 7 / 1 | Boot preflight retains the actual legacy migration refusal. | | `state/openclaw-schema-metadata.test.ts` | 15 / 0 | SQLite ownership metadata/floor contract. | | `state/openclaw-state-db-checkonce.test.ts` | 1 / 1 | Cold content/floor read still executes exactly once. | | `state/openclaw-state-db-cron-delivery-migration.test.ts` | 1 / 1 | Managed snapshot qualification retains its exact query sequence. | | `state/openclaw-state-db-schema-version.test.ts` | 83 / 1 | SQLite state T+1 admission, raised-floor refusal and atomic floor publication/rollback. | | `state/openclaw-state-read.owned-native-token.test.ts` | 7 / 4 | Snapshot files and stable SHM bytes remain exact; only documented read marks may vary. | | `state/openclaw-state-read.worker.test.ts` | 1 / 0 | PostgreSQL worker facts retain the floor. | | `state/openclaw-agent-active-event-facts-migration.postgres.test.ts` | 1 / 1 | Strict legacy reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-approval-profile-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-worker-provision-source-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader39. | | `extensions/workboard/src/postgres-store.test.ts` | 1 / 1 | A legacy strict workboard floor refuses the unsupported reader. | | `state/openclaw-agent-tool-usage-migration.postgres.test.ts` | 5 / 3 | Persists derived floor43 after strict42/43 plus additive44, and refuses reader41. | | `state/openclaw-agent-schema-inspection-worker.test.ts` | 16 / 0 | A future agent floor is read even when ownership projection is not requested. | | `state/openclaw-database-preflight.artifacts.test.ts` | 2 / 2 | Locked source fixture retains the real agent metadata shape; lock/readiness assertions unchanged. | | `commands/backup-verify.test.ts` | 4 / 4 | Wrong-role/path negatives carry otherwise complete agent metadata; rejection assertions unchanged. | | `commands/doctor-maintenance.schema-preflight.test.ts` | 2 / 2 | A raised agent floor refuses before incomplete registry repairs. | | `flows/doctor-health.dangling-workshop-index.test.ts` | 2 / 2 | Newer agent refusal preserves damaged shared-state bytes. | | `infra/database-engine/admitted-diagnostics.test.ts` | 1 / 1 | Read-free diagnostic agent fixture includes ownership columns. | | `infra/update-database-backup.agent-owners.test.ts` | 2 / 2 | Backup manifest owner discovery uses complete agent metadata. | | `infra/update-database-backup.test.ts` | 1 / 1 | External-agent backup fixture matches its existing version17 header. | | `state/openclaw-state-worker-loss-recovery.postgres.test.ts` | 4 / 1 | Newly merged v42 migration still refuses its v41 reader, asserting the floor diagnostic dynamically. | | `infra/sqlite-schema-contract.test.ts` | 25 / 16 | NULL-safe CHECK/default positives; six non-additive negatives, retaining strict known-object checks. | | `state/openclaw-agent-member-access-migration.test.ts` | 30 / 19 | Real step44 retains floor43 and old-reader/write compatibility; commit/rollback, sharing, witness and exact shipped PG SQL stay covered. | | `infra/database-engine/doctor-migration.postgres.test.ts` | 6 / 9 | Exact seven historical-agent upgrade/rollback catalogs; coherent fixture extraction keeps the owner within its line cap. | | `infra/database-engine/doctor-migration.postgres.test-support.ts` | 16 / 0 | Independent relocated full-catalog reader and optional-floor reference metadata fixture; no comparison filtering. | | `infra/sqlite-schema-contract.worker.test.ts` | 6 / 0 | NULL-safe CHECK drift remains compatible with strictly zero comparison DDL. | | `state/openclaw-state-ownership.test.ts` | 3 / 1 | A truly incompatible non-NULL default still blocks malformed-owner repair without changing its bytes. | The supported-header warm shortcut relies on atomically matching markers and `min_reader <= writer_version`; it does **not** short-circuit newer headers. The `raised` case in `openclaw-agent-db.checkonce.test.ts` asserts refusal at physical open, and the new `sqlite-schema-facts.test.ts` schema/version-invalidation cases require `SqliteSchemaVersionError` after a floor rises above this build. These new-head checks remain part of the explicitly outstanding proof, not a claim of final-head green. ## Completed SQLite downgrade proof [AWS run `run_9344a01fac267cad3cc0253546ab206b`](https://crabbox.openclaw.ai/portal/runs/run_9344a01fac267cad3cc0253546ab206b) completed the real packed main agent44→45 Gateway cases. T reached readiness with T+1's retained-floor shared/agent stores, including the first newly added nullable floor storage; agent-only retained snapshots also reached readiness. Raised shared and agent-only floors both refused with exit78. Metadata and seeded session rows were preserved. Main auth tests, SQLite floor/CI regressions and PostgreSQL floor regressions passed; Kysely passed. The run used frozen main `546bde6b` before later warm-path and fixture corrections, so it is not presented as a blanket final-head CI result. The five canonical `check-test-types-core-*` jobs passed on run `45517151870`; the ad-hoc proof typecheck configuration was discarded rather than loosening its libraries. **PostgreSQL built downgrade cell: NOT RUN.** The initial run stopped at T+1 Doctor's strict pre-repair predecessor catalog check; the repaired predecessor fixture is prepared but its bounded replay could not run. Both standard-profile AWS allocations (including the single retry after capacity was freed) were quota-rejected down to an undersized `t3.small`; both leases were released without launching builds. PostgreSQL floor unit regressions passed. No backup/catalog gate was bypassed and no PG downgrade boot is claimed. Per the maintainer's decision, this capacity gap does not block the SQLite-proven PR; required CI and review still apply. ## Codex timeout attribution [Controlled AWS comparison `run_f1242c2eb06315326ef5805841e000b1`](https://crabbox.openclaw.ai/portal/runs/run_f1242c2eb06315326ef5805841e000b1) ran the single Codex runtime test on the actual release merge candidate `adbb7d9d` (head `8b9199fd`) and its base `6b006bb1`, using the same pinned Bun and Node24.22.1. **Both reproduced the identical45000ms timeout.** Base/head wall time was114.352s/114.205s; Vitest110.85s/110.71s; max RSS5405548/5225840KiB. No head slowdown was observed in this isolated comparison. This is baseline reproduction, not a passing test or a “flake cleared” claim. The optional SQL trace covered diagnostics_channel only and does not establish absence of native SQLite calls. ## Round-two owner-selection regression One local `ocx test --no-memo src/state/openclaw-agent-schema-inspection-worker.test.ts` run on `6f3417a4c8` was **red**: only the new 45/min_reader44, ownership-disabled case failed because minReader44 was omitted (7 existing tests passed). One run on the fixed `acaf8043a6` head was **green: 8/8**. Proof tier: vitest-source, no build. Agent inspection always reads the agent metadata floor; only the ownership result is optional, and the state floor owner is unchanged. This is review round2/2; no additional full review was requested. Historical ownership check: the first agent-store commit `fc50f949` (#88349), shipped `v2026.5.30-beta.1`, and retained stable `v2026.7.35` all have required `role` and `schema_version` metadata. The `git log --follow -S 'schema_version INTEGER'` history contains no shipped removal. Four minimal two-column test fixtures were corrected in place, with no assertion/timing changes or net test growth; no legacy product fallback was added. Focused local fixture proof (vitest-source, no build): one `ocx test --no-memo src/state/openclaw-database-preflight.artifacts.test.ts src/infra/sqlite-schema-header.test.ts` invocation passed **19/19** (9 preflight, 10 header), including unchanged lock tolerance, hot-journal and WAL byte-preservation cases. Completed a full `CREATE TABLE schema_meta` / agent_id fixture inventory across `src` and `test`, including multiline/quoted forms. All remaining synthetic agent fixtures now carry role/schema_version; the deliberately malformed populated-v0 refusal fixture remains malformed by design. Shared/global, credential-source and generic engine-scope fixtures are not agent stores and remain unchanged. The sweep changes only SQL fixture lines (12 replacements/net0), not assertions or timeouts. One local `ocx test --no-memo` invocation of all six sweep files passed **87 tests, 1 Windows-only skip** on main (43 infra +44 commands); proof tier vitest-source/no build. Total main diff after the newly merged PostgreSQL refusal diagnostic correction: **77 files, +1331/-268 (net1063)** against merge-base `8aaf3820112a`; production/config +740/-216, tests +552/-45, versioning doc +39/-7. After merging main's new shared schema42, PostgreSQL conformance run45543740954/job138969182913 exposed its newly introduced worker-loss migration test's old `is newer` diagnostic expectation. The actual refusal correctly required floor42 versus reader41. Updated only that expectation to the dynamic minimum-reader diagnostic; a sweep of all `*.postgres.test.ts` under `src`/`test` found no other remaining `is newer` refusal expectation. Green PostgreSQL execution of this narrow correction is left to required CI, not claimed from a skipped local test. ## Real step44: classifier-derived compatibility `src/infra/sqlite-additive-column.ts` is the single column predicate. Its SELECT-only evaluator replaces the earlier candidate CREATE/INSERT probe: it parses nullable/default/CHECK clauses and evaluates scalar CHECK expressions over an explicit NULL value under deterministic-function authorization. It executes no comparison DDL and never touches source state. Non-nullable/unsafe default/key/reference/generated declarations stay incompatible; bare-type and warm admission paths retain their existing fast paths. `src/state/openclaw-agent-db-schema-helpers.ts:450` compares the migrated catalog with the actual predecessor before atomically stamping the version and derived floor. Pre-v43 history remains strict. PostgreSQL step44 computes its existing `minReader` property lazily through the same predicate (`openclaw-agent-member-access-schema.ts:10`, `openclaw-agent-db-engine.ts:431`), with no hand-declared floor43. Its generated migration SQL is asserted **byte-identical** to main's shipped SQL. Removed: the obsolete strict43-reader refusal test and the claimed43→44 pre-image requirement. There is no step44-specific production copy/pre-image branch to retain; generic backup restoration proof remains. Witness normalization treats `min_reader` like the existing version/app/time migration metadata; raw same-version schema/content hashes remain exact. This update adds **no persistent application column or table beyond the min_reader storage already present at870ef9ba31**, and the final classifier also performs **zero comparison DDL**. Proof: the two owning files on baseline870ef9ba31 with the new regression were **red: 4 intended failures, 35 passing**. Final main-only change **7f02f3b218** is **green: 39/39** via `ocx test --no-memo src/infra/sqlite-schema-contract.test.ts src/state/openclaw-agent-member-access-migration.test.ts` (vitest-source/no build). Logs: `ReaderFloor-null-safe-check/red-870ef9ba31.log`, `green-final.log`. Intermediate helper-regex and witness failures were corrected in their owners; no assertion/timeout masking. Latest measured scope against8aaf3820112a, superseding earlier historical counts: **82 files, +1485/-321, net1164**; production/config48 +836/-233 (net603), tests33 +607/-80 (net527), versioning doc +42/-8 (net34). Allocation127 covers the requested step44 contract and six negatives. Architecture CI's native-opener guard found one owned integration issue at7f02f3b218: the disposable classifier probe used the raw constructor. Fixed only its opener/import through `openNodeSqliteDatabase` (no exemption); owning39tests and `pnpm lint:kysely` both pass. Repair748ab989ac is +3/-3, no net scope growth or schema change. Logs: `ReaderFloor-null-safe-check/canonical-opener-tests.log`, `canonical-opener-guard.log`. ## Consolidated CI repair The SELECT-only helper's +83 production lines replace its DDL probe while preserving the cold-worker zero-comparison-DDL contract. The trusted PR wrapper legitimately imports this schema-rule owner through its already-inventoried schema contract; `scripts/pr-lib/wrapper-components.txt` now declares the extracted helper (one path), rather than relocating a schema rule into an unrelated native owner or weakening the closure test. PostgreSQL's seven reported historical-agent failures occurred before rollback: migrated engine metadata had its optional floor column, while the fresh reference intentionally omitted it. The independent reference fixture now includes that exact nullable BIGINT metadata representation; whole-catalog equality and all rollback/foreign-write assertions remain. Fresh production bootstrap remains unchanged. The tool-usage predecessor refusal now asserts the correct derived floor43, not44. The malformed-owner negative uses a non-NULL default because DEFAULT NULL is now intentionally additive. The unrelated startup timing case from #204943 is owned by the maintainer's override; this repair neither changes nor reruns it. Owning local schema/PostgreSQL lanes initially failed during dependency setup, before tests, when parallel ocx installs rematerialized a shared checkout; source-identical committed-head serial proof runs in an isolated checkout instead. CI on652ae1d9aa remains the full proof. Latest consolidated scope against8aaf3820112a: **87 files, +1604/-333, net1271**; production/config49 +920/-233 (net687), tests37 +642/-92 (net550), versioning doc +42/-8 (net34). Head652ae1d9aa differs from consolidated repair e57d895 only by its approved allocation record. Kysely guardrails passed; final local/CI outcomes are not claimed before completion. ## Merged native-observer compatibility Main was merged once to include #205022's migration observer. Its catalog capture happens before every observed statement, so the private NULL probe now permits only the observer's read-only catalog PRAGMAs/schema reads in addition to its scalar CHECK evaluation, and clears its authorizer before disposal. Writes, user-table reads and nondeterministic functions remain denied; neither the observer nor source guards changed. Merged-tree local proof: **45/45 passed** (migration-chain5, classifier/cold-worker/real-step44 tests40), log `ReaderFloor-consolidated-repairs/observer-merged.log`. Earlier owning schema proof was71/71; wrapper closure23/23 and provisioner17 cases passed, with only the independently observed plain-main macOS sparse-transition120s timeout remaining locally. PostgreSQL's hand-built pre-merge local proof had later credential-restore/transaction errors; it is not claimed green, and the maintainer designated CI's PostgreSQL conformance as authoritative. Current head **c946b3fc75**, measured against main merge-base **3f2e0ade38**: **87 files, +1614/-333, net1281**; production/config49 net697, tests37 net550, versioning doc net34. Allocation150 is unchanged. All task-owned local PostgreSQL/container and scratch resources have been released. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 26, 2026
) Closes openclaw#204880 ## What Problem This Solves A build currently refuses every database written at a newer schema version, even when the change only adds storage that the older build can safely ignore. This prevents a previous Gateway from reopening compatible state after an update trial. ## User Impact The next stable can reopen future SQLite state, agent stores, and PostgreSQL schemas when their recorded reader floor permits it. Incompatible changes still stop startup with a clear schema refusal. Existing strict stores retain their current format and behavior; this PR does not change update backup policy. ## Why This Change Was Made The existing version owners publish or clear `min_reader` in the version transaction. An absent/null floor means the writer version, so strict steps need no new storage; the first tolerable step adds a nullable floor column. Pre-v43 agent history stays strict; from v43 the SQLite migration finisher derives tolerance from the migrated predecessor catalog. No schema number is bumped, and port publication is unchanged. Admission, boot preflight and catalog checks preserve the actual writer version while accepting unknown tables and NULL-safe nullable columns. Non-nullable columns, non-NULL defaults, CHECKs rejecting NULL, generated columns, keys and references stay non-additive. Known constraints, triggers and ownership checks remain enforced; PostgreSQL also requires the newer writer's unchanged catalog seal. Newer registry rows remain discovery candidates; the `raised` case in `openclaw-agent-db.checkonce.test.ts` proves that a store whose floor is above this code is still refused at open. Ayaan approved this schema contract change on 2026-11-24 (`state-model-decision.md`). This PR targets main only; the release manager owns any backport. Rollback also retains the valid restored config when automatic recovery finds a newer writer's backup. The existing destructive-action guard remains enforced for an actually loaded newer config; prepared, synchronous and asynchronous recovery share this rule. The independent config-recovery repair is being landed first as a prerequisite (it also affects existing copy-and-swap rollback). Once main contains it, this PR will inherit the same implementation rather than carry a second change. ## Evidence - AWS: 164 SQLite/boot/catalog tests and 44 PostgreSQL tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_44448ae157b99967d36d4de1029769af)). - Red on unmodified main: SQLite state, SQLite agent, and PostgreSQL writable/read-only admission refuse the same compatible-newer fixtures ([run](https://crabbox.openclaw.ai/portal/runs/run_06577478aecf849ce6463a01fab37b53)). - Two local ClawSweeper rounds completed; verified findings were fixed. The lead reviewed the final registry delta and the subsequent behavior-equivalent type/lint fixes against the exact head. - AWS `check:changed` passed on `956fc25da6`: core/core-test type graphs, lint, format, dead-export checks, SQLite worker/dialect guards, and the remaining selected guards ([run](https://crabbox.openclaw.ai/portal/runs/run_cf80edb44a2a04deba0c2cf62af5810f)). Narrow subsequent auth/guard changes require the checks below. - Linux T/T+1 packages built successfully ([run](https://crabbox.openclaw.ai/portal/runs/run_5eaf078abca514a139d8c599b2092035)). That run exposed the restored-config recovery blocker, which was fixed rather than bypassed. The recovery regression then failed against the old owner and all 56 main config tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_96332cda9f136830532e490fd55faacb)). **Proof status:** the completed main SQLite downgrade run is recorded below. The built PostgreSQL downgrade cell remains NOT RUN; it is not claimed green. Affected behavior and final-head type checks remain covered by required PR CI. ## Scope One version owner per store publishes the floor; strict steps retain the existing encoding. The change removes duplicate shared-version publication rather than adding a parallel migration mechanism. The focused column classifier now lives in `sqlite-additive-column.ts` to satisfy the existing owner's line cap; both consumers import it directly, without a facade or re-export. No broad historical fixture rewrites or unrelated documentation changes remain. Follow-up class: the admission rule currently spans about 15 independent version gates; consolidate them behind one admission owner so a future rule change is one edit. This PR only changes their existing decisions and required propagation. <details> <summary>LSP production reader inventory</summary> LSP references were collected before edits; its index is anchored to the primary checkout, so coordinates are not claimed for these frozen worktrees. New worktree-only consumers are named explicitly below. Paths without a prefix are under `src/state/`. - Shared version gate: `openclaw-state-db-schema-version.ts`, `openclaw-state-db-maintenance.ts`, `openclaw-state-db-fast-path.ts`, `openclaw-state-db-existing-schema.ts`, `openclaw-state-db-open.ts`, `openclaw-state-db-read-schema.ts`, `openclaw-state-db-existing-write.ts`, `openclaw-state-db-startup-checkpoint.ts`, `openclaw-state-db-schema-runtime.ts`, `openclaw-state-db-read-connection.ts`, `openclaw-state-db.ts`, `startup-metadata-live-read.worker.ts`, `src/plugins/update-cohort-recovery.ts`, `src/snapshot/openclaw-snapshot-copy.ts`, `src/snapshot/git-backup-codec.ts`, `src/agents/harness/native-hook-relay-client-read.ts`. New floor-read consumers: `openclaw-state-schema-preflight.ts`, `src/infra/sqlite-schema-header.ts`. - Agent version gate: `openclaw-agent-db-schema-read.ts`, `openclaw-agent-db-owner-read.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema.ts`, `openclaw-agent-db-maintenance.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/infra/database-engine/agent-port-descriptor.ts`, `src/infra/state-migrations.media-persistence.ts`, `src/snapshot/git-backup-codec.ts`, `src/snapshot/openclaw-snapshot-copy.ts`. Current-agent metadata gate: `openclaw-agent-db-engine.ts`, `openclaw-agent-db-schema-helpers.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`. - PostgreSQL physical admission: `src/infra/database-engine/open.ts`, `openclaw-state-db-engine.ts`. Schema verification: `src/infra/database-engine/physical-facts.ts`, `src/infra/database-engine/adapters.ts`. Engine-open callers: `openclaw-state-db-open.ts`, `openclaw-agent-db-engine.ts`, `openclaw-state-db-engine.ts`, `src/infra/database-engine/historical-index-ordering-port.ts`, `src/infra/database-engine/state-port-descriptor.ts`; Plugin SDK re-export unchanged. - Runtime inspection/preflight: `openclaw-agent-schema-inspection.worker.ts`, `openclaw-database-preflight.ts`, `openclaw-state-read-operation-registry.ts`. Preflight entry callers include Doctor database preflight, startup client credentials, preflight contexts, update-data-at-risk, auto-update compatibility, daemon status, Gateway bootstrap/startup maintenance, Doctor lease refusal and agent admission. Explicit updater-target policy remains strict. - Audit catalog admission: `openclaw-state-db-audit-migration.ts`, `openclaw-state-db-schema-repair.ts`. Canonical session-validation catalog admission: `openclaw-agent-canonical-validation-schema.ts`, `openclaw-agent-canonical-validation-receipt.ts`, `openclaw-agent-db-validation-cache.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema-admission.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/config/sessions/session-canonical-key.ts`. - Registry candidate filtering: `openclaw-agent-db-registry-listing.ts` (inspection, memo and snapshot paths), `src/infra/update-data-at-risk.ts`, `src/commands/doctor-db-bloat.read.ts`. Actual store admission remains the floor authority. - Config recovery's existing future-version guard is now consulted by the shared recovery plan builder. LSP callers: `io.observe-recovery.ts` prepared and immediate recovery entrypoints; synchronous/asynchronous startup loaders at `src/config/io.load.ts:210-212`; prepared snapshot recovery at `src/config/io.snapshot.ts:486`. Actual current-config admission in Gateway pre-bootstrap is unchanged. - Auth-profile reader admission: LSP production consumers `src/agents/auth-profiles/sqlite-json.ts:187,210` and `src/agents/auth-profiles/sqlite.ts:239,361` now use the canonical agent floor gate. Pooled same-version reuse remains query-free; a changed supplied version is checked once. </details> ## Test growth allocation The maintainer approved allocation **150** for measured net test growth550: the prior127, optional-floor reference metadata (5), persisted-floor/refusal proof (2), cold-worker zero-comparison-DDL coverage (6), and cap-required fixture extraction/imports/formatting (10). The obsolete strict43-reader refusal case is replaced by actual44-writer/floor43 admission and old-writer NULL insertion proof. Only a redundant step-presence assertion was removed; exact rollback, ownership, catalog and constraint assertions remain. | Test file (`src/` unless otherwise qualified) | + / - | Protected contract | | --- | ---: | --- | | `agents/auth-profiles.sqlite-read-pool.test.ts` | 42 / 0 | Retained/raised floors through projected/plain auth readers; query-free warm reuse. | | `config/sessions/startup-migration.acp.test.ts` | 4 / 1 | Legacy admission uses consistent header/ownership markers. | | `infra/database-engine/bridge-prestart.test.ts` | 1 / 0 | PostgreSQL admission facts carry the required floor. | | `infra/database-engine/physical-facts.test.ts` | 2 / 2 | Strict metadata keeps absent-floor compatibility. | | `infra/database-engine/schema-admission.postgres.test.ts` | 172 / 1 | Writable/read-only T+1 admission; malformed/raised floors; nullable versus constrained catalogs; seals and rollback. | | `infra/sqlite-schema-facts.test.ts` | 42 / 0 | Warm future-reader cache stays query-free and rejects floors raised after schema/version invalidation. | | `infra/sqlite-schema-header.test.ts` | 9 / 5 | Floor/ownership survive inspection; native lock/WAL fixtures carry historical agent metadata. | | `state/openclaw-agent-db-registry-listing.snapshot.test.ts` | 2 / 2 | Future stores remain discovery candidates, not implicitly admitted stores. | | `state/openclaw-agent-db.checkonce.test.ts` | 120 / 5 | SQLite agent admission, readonly open, metadata preservation and transactional floor publication/rollback. | | `state/openclaw-agent-db.committed-read.test.ts` | 4 / 1 | A legacy replacement is refused before invoking its reader. | | `state/openclaw-database-preflight.startup-prepared.test.ts` | 7 / 1 | Boot preflight retains the actual legacy migration refusal. | | `state/openclaw-schema-metadata.test.ts` | 15 / 0 | SQLite ownership metadata/floor contract. | | `state/openclaw-state-db-checkonce.test.ts` | 1 / 1 | Cold content/floor read still executes exactly once. | | `state/openclaw-state-db-cron-delivery-migration.test.ts` | 1 / 1 | Managed snapshot qualification retains its exact query sequence. | | `state/openclaw-state-db-schema-version.test.ts` | 83 / 1 | SQLite state T+1 admission, raised-floor refusal and atomic floor publication/rollback. | | `state/openclaw-state-read.owned-native-token.test.ts` | 7 / 4 | Snapshot files and stable SHM bytes remain exact; only documented read marks may vary. | | `state/openclaw-state-read.worker.test.ts` | 1 / 0 | PostgreSQL worker facts retain the floor. | | `state/openclaw-agent-active-event-facts-migration.postgres.test.ts` | 1 / 1 | Strict legacy reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-approval-profile-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-worker-provision-source-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader39. | | `extensions/workboard/src/postgres-store.test.ts` | 1 / 1 | A legacy strict workboard floor refuses the unsupported reader. | | `state/openclaw-agent-tool-usage-migration.postgres.test.ts` | 5 / 3 | Persists derived floor43 after strict42/43 plus additive44, and refuses reader41. | | `state/openclaw-agent-schema-inspection-worker.test.ts` | 16 / 0 | A future agent floor is read even when ownership projection is not requested. | | `state/openclaw-database-preflight.artifacts.test.ts` | 2 / 2 | Locked source fixture retains the real agent metadata shape; lock/readiness assertions unchanged. | | `commands/backup-verify.test.ts` | 4 / 4 | Wrong-role/path negatives carry otherwise complete agent metadata; rejection assertions unchanged. | | `commands/doctor-maintenance.schema-preflight.test.ts` | 2 / 2 | A raised agent floor refuses before incomplete registry repairs. | | `flows/doctor-health.dangling-workshop-index.test.ts` | 2 / 2 | Newer agent refusal preserves damaged shared-state bytes. | | `infra/database-engine/admitted-diagnostics.test.ts` | 1 / 1 | Read-free diagnostic agent fixture includes ownership columns. | | `infra/update-database-backup.agent-owners.test.ts` | 2 / 2 | Backup manifest owner discovery uses complete agent metadata. | | `infra/update-database-backup.test.ts` | 1 / 1 | External-agent backup fixture matches its existing version17 header. | | `state/openclaw-state-worker-loss-recovery.postgres.test.ts` | 4 / 1 | Newly merged v42 migration still refuses its v41 reader, asserting the floor diagnostic dynamically. | | `infra/sqlite-schema-contract.test.ts` | 25 / 16 | NULL-safe CHECK/default positives; six non-additive negatives, retaining strict known-object checks. | | `state/openclaw-agent-member-access-migration.test.ts` | 30 / 19 | Real step44 retains floor43 and old-reader/write compatibility; commit/rollback, sharing, witness and exact shipped PG SQL stay covered. | | `infra/database-engine/doctor-migration.postgres.test.ts` | 6 / 9 | Exact seven historical-agent upgrade/rollback catalogs; coherent fixture extraction keeps the owner within its line cap. | | `infra/database-engine/doctor-migration.postgres.test-support.ts` | 16 / 0 | Independent relocated full-catalog reader and optional-floor reference metadata fixture; no comparison filtering. | | `infra/sqlite-schema-contract.worker.test.ts` | 6 / 0 | NULL-safe CHECK drift remains compatible with strictly zero comparison DDL. | | `state/openclaw-state-ownership.test.ts` | 3 / 1 | A truly incompatible non-NULL default still blocks malformed-owner repair without changing its bytes. | The supported-header warm shortcut relies on atomically matching markers and `min_reader <= writer_version`; it does **not** short-circuit newer headers. The `raised` case in `openclaw-agent-db.checkonce.test.ts` asserts refusal at physical open, and the new `sqlite-schema-facts.test.ts` schema/version-invalidation cases require `SqliteSchemaVersionError` after a floor rises above this build. These new-head checks remain part of the explicitly outstanding proof, not a claim of final-head green. ## Completed SQLite downgrade proof [AWS run `run_9344a01fac267cad3cc0253546ab206b`](https://crabbox.openclaw.ai/portal/runs/run_9344a01fac267cad3cc0253546ab206b) completed the real packed main agent44→45 Gateway cases. T reached readiness with T+1's retained-floor shared/agent stores, including the first newly added nullable floor storage; agent-only retained snapshots also reached readiness. Raised shared and agent-only floors both refused with exit78. Metadata and seeded session rows were preserved. Main auth tests, SQLite floor/CI regressions and PostgreSQL floor regressions passed; Kysely passed. The run used frozen main `546bde6b` before later warm-path and fixture corrections, so it is not presented as a blanket final-head CI result. The five canonical `check-test-types-core-*` jobs passed on run `45517151870`; the ad-hoc proof typecheck configuration was discarded rather than loosening its libraries. **PostgreSQL built downgrade cell: NOT RUN.** The initial run stopped at T+1 Doctor's strict pre-repair predecessor catalog check; the repaired predecessor fixture is prepared but its bounded replay could not run. Both standard-profile AWS allocations (including the single retry after capacity was freed) were quota-rejected down to an undersized `t3.small`; both leases were released without launching builds. PostgreSQL floor unit regressions passed. No backup/catalog gate was bypassed and no PG downgrade boot is claimed. Per the maintainer's decision, this capacity gap does not block the SQLite-proven PR; required CI and review still apply. ## Codex timeout attribution [Controlled AWS comparison `run_f1242c2eb06315326ef5805841e000b1`](https://crabbox.openclaw.ai/portal/runs/run_f1242c2eb06315326ef5805841e000b1) ran the single Codex runtime test on the actual release merge candidate `adbb7d9d` (head `8b9199fd`) and its base `6b006bb1`, using the same pinned Bun and Node24.22.1. **Both reproduced the identical45000ms timeout.** Base/head wall time was114.352s/114.205s; Vitest110.85s/110.71s; max RSS5405548/5225840KiB. No head slowdown was observed in this isolated comparison. This is baseline reproduction, not a passing test or a “flake cleared” claim. The optional SQL trace covered diagnostics_channel only and does not establish absence of native SQLite calls. ## Round-two owner-selection regression One local `ocx test --no-memo src/state/openclaw-agent-schema-inspection-worker.test.ts` run on `6f3417a4c8` was **red**: only the new 45/min_reader44, ownership-disabled case failed because minReader44 was omitted (7 existing tests passed). One run on the fixed `acaf8043a6` head was **green: 8/8**. Proof tier: vitest-source, no build. Agent inspection always reads the agent metadata floor; only the ownership result is optional, and the state floor owner is unchanged. This is review round2/2; no additional full review was requested. Historical ownership check: the first agent-store commit `227691b6` (openclaw#88349), shipped `v2026.5.30-beta.1`, and retained stable `v2026.7.35` all have required `role` and `schema_version` metadata. The `git log --follow -S 'schema_version INTEGER'` history contains no shipped removal. Four minimal two-column test fixtures were corrected in place, with no assertion/timing changes or net test growth; no legacy product fallback was added. Focused local fixture proof (vitest-source, no build): one `ocx test --no-memo src/state/openclaw-database-preflight.artifacts.test.ts src/infra/sqlite-schema-header.test.ts` invocation passed **19/19** (9 preflight, 10 header), including unchanged lock tolerance, hot-journal and WAL byte-preservation cases. Completed a full `CREATE TABLE schema_meta` / agent_id fixture inventory across `src` and `test`, including multiline/quoted forms. All remaining synthetic agent fixtures now carry role/schema_version; the deliberately malformed populated-v0 refusal fixture remains malformed by design. Shared/global, credential-source and generic engine-scope fixtures are not agent stores and remain unchanged. The sweep changes only SQL fixture lines (12 replacements/net0), not assertions or timeouts. One local `ocx test --no-memo` invocation of all six sweep files passed **87 tests, 1 Windows-only skip** on main (43 infra +44 commands); proof tier vitest-source/no build. Total main diff after the newly merged PostgreSQL refusal diagnostic correction: **77 files, +1331/-268 (net1063)** against merge-base `44d311177c0f`; production/config +740/-216, tests +552/-45, versioning doc +39/-7. After merging main's new shared schema42, PostgreSQL conformance run45543740954/job138969182913 exposed its newly introduced worker-loss migration test's old `is newer` diagnostic expectation. The actual refusal correctly required floor42 versus reader41. Updated only that expectation to the dynamic minimum-reader diagnostic; a sweep of all `*.postgres.test.ts` under `src`/`test` found no other remaining `is newer` refusal expectation. Green PostgreSQL execution of this narrow correction is left to required CI, not claimed from a skipped local test. ## Real step44: classifier-derived compatibility `src/infra/sqlite-additive-column.ts` is the single column predicate. Its SELECT-only evaluator replaces the earlier candidate CREATE/INSERT probe: it parses nullable/default/CHECK clauses and evaluates scalar CHECK expressions over an explicit NULL value under deterministic-function authorization. It executes no comparison DDL and never touches source state. Non-nullable/unsafe default/key/reference/generated declarations stay incompatible; bare-type and warm admission paths retain their existing fast paths. `src/state/openclaw-agent-db-schema-helpers.ts:450` compares the migrated catalog with the actual predecessor before atomically stamping the version and derived floor. Pre-v43 history remains strict. PostgreSQL step44 computes its existing `minReader` property lazily through the same predicate (`openclaw-agent-member-access-schema.ts:10`, `openclaw-agent-db-engine.ts:431`), with no hand-declared floor43. Its generated migration SQL is asserted **byte-identical** to main's shipped SQL. Removed: the obsolete strict43-reader refusal test and the claimed43→44 pre-image requirement. There is no step44-specific production copy/pre-image branch to retain; generic backup restoration proof remains. Witness normalization treats `min_reader` like the existing version/app/time migration metadata; raw same-version schema/content hashes remain exact. This update adds **no persistent application column or table beyond the min_reader storage already present at870ef9ba31**, and the final classifier also performs **zero comparison DDL**. Proof: the two owning files on baseline870ef9ba31 with the new regression were **red: 4 intended failures, 35 passing**. Final main-only change **7f02f3b218** is **green: 39/39** via `ocx test --no-memo src/infra/sqlite-schema-contract.test.ts src/state/openclaw-agent-member-access-migration.test.ts` (vitest-source/no build). Logs: `ReaderFloor-null-safe-check/red-870ef9ba31.log`, `green-final.log`. Intermediate helper-regex and witness failures were corrected in their owners; no assertion/timeout masking. Latest measured scope against8aaf3820112a, superseding earlier historical counts: **82 files, +1485/-321, net1164**; production/config48 +836/-233 (net603), tests33 +607/-80 (net527), versioning doc +42/-8 (net34). Allocation127 covers the requested step44 contract and six negatives. Architecture CI's native-opener guard found one owned integration issue at7f02f3b218: the disposable classifier probe used the raw constructor. Fixed only its opener/import through `openNodeSqliteDatabase` (no exemption); owning39tests and `pnpm lint:kysely` both pass. Repair748ab989ac is +3/-3, no net scope growth or schema change. Logs: `ReaderFloor-null-safe-check/canonical-opener-tests.log`, `canonical-opener-guard.log`. ## Consolidated CI repair The SELECT-only helper's +83 production lines replace its DDL probe while preserving the cold-worker zero-comparison-DDL contract. The trusted PR wrapper legitimately imports this schema-rule owner through its already-inventoried schema contract; `scripts/pr-lib/wrapper-components.txt` now declares the extracted helper (one path), rather than relocating a schema rule into an unrelated native owner or weakening the closure test. PostgreSQL's seven reported historical-agent failures occurred before rollback: migrated engine metadata had its optional floor column, while the fresh reference intentionally omitted it. The independent reference fixture now includes that exact nullable BIGINT metadata representation; whole-catalog equality and all rollback/foreign-write assertions remain. Fresh production bootstrap remains unchanged. The tool-usage predecessor refusal now asserts the correct derived floor43, not44. The malformed-owner negative uses a non-NULL default because DEFAULT NULL is now intentionally additive. The unrelated startup timing case from openclaw#204943 is owned by the maintainer's override; this repair neither changes nor reruns it. Owning local schema/PostgreSQL lanes initially failed during dependency setup, before tests, when parallel ocx installs rematerialized a shared checkout; source-identical committed-head serial proof runs in an isolated checkout instead. CI on652ae1d9aa remains the full proof. Latest consolidated scope against8aaf3820112a: **87 files, +1604/-333, net1271**; production/config49 +920/-233 (net687), tests37 +642/-92 (net550), versioning doc +42/-8 (net34). Head652ae1d9aa differs from consolidated repair e57d895 only by its approved allocation record. Kysely guardrails passed; final local/CI outcomes are not claimed before completion. ## Merged native-observer compatibility Main was merged once to include openclaw#205022's migration observer. Its catalog capture happens before every observed statement, so the private NULL probe now permits only the observer's read-only catalog PRAGMAs/schema reads in addition to its scalar CHECK evaluation, and clears its authorizer before disposal. Writes, user-table reads and nondeterministic functions remain denied; neither the observer nor source guards changed. Merged-tree local proof: **45/45 passed** (migration-chain5, classifier/cold-worker/real-step44 tests40), log `ReaderFloor-consolidated-repairs/observer-merged.log`. Earlier owning schema proof was71/71; wrapper closure23/23 and provisioner17 cases passed, with only the independently observed plain-main macOS sparse-transition120s timeout remaining locally. PostgreSQL's hand-built pre-merge local proof had later credential-restore/transaction errors; it is not claimed green, and the maintainer designated CI's PostgreSQL conformance as authoritative. Current head **c946b3fc75**, measured against main merge-base **5f9e215d2a**: **87 files, +1614/-333, net1281**; production/config49 net697, tests37 net550, versioning doc net34. Allocation150 is unchanged. All task-owned local PostgreSQL/container and scratch resources have been released. Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 26, 2026
…4868) Closes #204704 A release switch can replace or restore SQLite files while the previous Gateway or initiating CLI still holds them. On Windows this can prevent every new Gateway from starting with `EPERM` on `openclaw.sqlite-wal`. A restart can also keep waiting after its trial has already committed. Release switches wait for the old readers to close. An adopted package's committed trial ends `gateway restart` without requiring an operator-scoped health RPC. A connected CLI without `operator.read` gets a distinct diagnostic and a clear next step, not a false startup timeout. If an unmanaged foreground launcher dies before readiness, the old runtime exits with an error and prints `openclaw gateway` as the recovery command. It does not reopen a store that the launcher may have migrated. A live launcher remains the only recovery owner. The existing shared-state close owner now joins native consumers and retires retained file-identity descriptors before custody transfers. The Gateway completes its boot record and closes shared state before releasing its lock; process cleanup and a final custody close precede a standalone launcher spawn. The retiring Gateway's readiness observer uses only HTTP and captured configuration; its sentinel reads/writes and in-process fallback after spawning a launcher are gone. Restart observers use file-lock identity, native process/listener information, HTTP and RPC instead of opening the store to inspect migration and owner leases. A live file owner retains bounded startup grace during a long migration. The update CLI releases custody at its existing pre-dispatch boundary, and the adopted-result waiter consumes the terminal phase at the sole trial path: update preparation already serializes active trials under the update lock. No schema, launcher protocol or public Plugin SDK API changes. The private QA startup collector retains its closed-fixture lease check on its existing connection. Service-definition repair publishes its planned command/environment and effective configuration after token preparation but before activation. Start and restart observers consume those facts instead of reopening SQLite to recapture repaired credentials or arguments. Windows captures its command once before `/Run`, retires preflight custody through the existing caller hook, and uses bounded file/process observations afterward. - On source baseline `33586124338a`, regressions fail for retained identity descriptors, an early-returning one-shot reader, RPC access after a committed trial, scope denial reported as a timeout, and a retiring successor observer reopening state. - The reported Linux external holders and Windows native ARM64 WAL/`EPERM` failures are retained base evidence; they were not repeated just to confirm them. - Earlier affected AWS gate on `c698a589b131` passed (`run_8c5f0a8b1085ed134733db543b577cc2`): seven Vitest shards in 189.73s, targeted types/lint and ratchets. This remains prior-head evidence, not final platform proof. - The first Windows head (`f798ffc61fd9`) was **red**: npm exited0, restart exited1 after728.479s and nothing served; signed Handle matched the initiating CLI to control/shared/quarantine SQLite. Final stable-path evidence is below; the separately reproduced repair-path gap is explicitly tracked. - Test growth after consolidation and the requested recovery regression is 848 net lines against the PR's base; the approved 448-line allocation covers the distinct contracts itemized below. No behavioral assertion is weakened. - Platform packages/proofs use source `21066b69471a1998505bac4ee4758e2138694d33`, rebuilt after the required main merge (including inherited WAL/state-upgrade changes). Later changes are the status-test warning correction and the narrowly guarded SQL-free stale-listener recovery fix, qualified by124 focused pinned-Bun consumer tests/typed lint. The platform recordings do not claim to exercise that legacy recovery branch or byte-equivalence with the later head. - **Linux crash/restore PASS** — [AWS run `run_ae3ce038d7ae16a26540b0d69c956015`](https://crabbox.openclaw.ai/portal/runs/run_ae3ce038d7ae16a26540b0d69c956015),201.82s:10 publication and6 restore snapshots, zero external native/identity holders and zero scan errors, all four families present. RestoredT served with its exact identity, read the persisted cron sentinel over RPC, and all live integrity checks passed. Actual update row finished/failed (expected injected crash); CLI settled exit1. No harness recovery. Receipt archive SHA256 `68973c89550142131208d65ca7de293b18bd9dcbfaa785a92f0e28831893766f`. - **Windows native ARM64 stable-path PASS** — npm0; restart0 on its own in107.673s; exact2106 RPC version/build with `connected_no_operator_scope`; store read passed; complete17-file scan found no EPERM. Stable archive SHA256 `260da7b92739a2444678d1bb61dbceb679f4aeae6f3400cc21a9032d52092906`. - Borrow qualification `run_ec051c902d31b5c93086dcbbfde87d1b` passed Node37 tests, process4 tests (including real watchdog SIGKILL and successor), and pinned Bun77 tests/1 skip. Test types and numeric guards passed. Its two static failures were a mistakenly removed required import and a stale inline suppression; both are corrected without changing borrower behavior. - Both Node and pinned Bun fail the unlinked-path regression on b8ee (`run_40c6e4e508e393b27716dc57072b0a88`). Registry-owner fix eeee passes Node cache/lock35 tests, pinned Bun cache10 tests, and original failing files/lock114 tests with21 skips (`run_2844130f72a5635dadfbce107f8cd587`). None of the six Bun failures needed a fixture expectation change. - Final head `da4ee212087163db858e1472f9052fd270d02f97` local review completed: patch correct, zero findings. The additional legacy-recovery guard/fixtures pass124 pinned-Bun consumer tests and targeted typed lint; migrating/healthy/unknown/foreign negative guards remain intact. - Inherited CI timing note: #204943's Bun checkpoint assertion failed in a prior CI shard. The one identical-test/identical-pinned-Bun comparison on current main094e225 and head3c43 both passed ([run `run_adc41ae48859bff924ccce98fb5a2119`](https://crabbox.openclaw.ai/portal/runs/run_adc41ae48859bff924ccce98fb5a2119)); no expectation/source change was made for it. Maintainer owns its once-only diagnostic rerun and owner routing; passing again is not claimed as a fix. - The approved narrow run-loop cap is1238 counted lines: inherited1235 plus the stop-budget custody join and restored required import. The cohesive persistence/custody-release block moved to run-loop-cleanup.ts; the old inline suppression and its inventory entry are removed. The original malformed-database report remains ground truth, but its physical corruption mechanism was not established. This change removes the proven unsafe custody handoff; it does not claim to identify a corrupt SQLite page. If a second update prepares in the short window after the first commits but before its CLI reads the trial, the first command can report the second outcome or wait until its deadline; both are visible, and `openclaw update status` shows the true runs. Windows coverage limit, explicitly accepted for this native-install cell: its actual tree is task supervisor → job anchor → cmd → Gateway, not a converted resident release launcher. No wrong process was killed and no launcher-manager recovery is claimed. The converted-install manager-cut cell belongs to the full matrix after#204866; it is not proven here. **Open reproduced repair gap: [#205035](#205035 TEMP-prefix service repair is not a pass: on source2106, npm0/346.427s, restart self-exit1/512.647s, target never ready, repeated EPERM publishing `control/services.sqlite`. Original archive SHA256 `29be88bba446d938eebe3dd4305f5b49c3248523b2096062c9a7cc09145fac5a`. A fresh diagnostic captured the restart CLI child node.exe PID1652/handle3E8 on that file104ms after the first error, while alive; live archive SHA256 `161ea7d9034b0a96294f37286f9473cf054c8599cd2ab14c9325b5ca73082f23`. Both source/target were non-readonly with FullControl ACLs. The post-native-install runtime-pin read (`service.ts:410–420`→`runtime-pin-store.ts:83–98`) and publication rename (`state-upgrade-tree.ts:627`) already exist on main; no repair fix or success is claimed here. Maintainer explicitly accepts landing this PR with that named gap, owned by the next repair-producer change. `release/2026.11.15` (`f1debfde108a`) needs the custody correction: Gateway/resource retirement before lock transfer, file/HTTP-only restart observation, and CLI reader release. The serving Gateway must contain its part; a candidate cannot close an older process's handles. That release has no package-adoption waiter, so the terminal-trial waiter change is not part of the smallest backport. No backport PR was opened. Compared with PR base `1bec22471ad0`: **848 net test/support lines; 448 allocated above the 400-line allowance**. Shared full-lock/process fixtures removed39 lines, retained child diagnostics add9. The final +33 lines are the requested stale-owner regression (+28) and verified-owner caller migration (+5), explicitly approved. The orphan-FD case stays at the cache boundary: its native owner and admission record are already gone. The full-lock matrix instead retains a live borrower and must preserve Gateway exclusion. Combining those different states would obscure which owner failed. Repair producer, native dispatch, and caller-result tests likewise exercise different boundaries. All changed test/support files are listed; `+/-` counts include helper cost and deletions: | File | + / - | Contract or required migration | | --- | ---: | --- | | `src/cli/daemon-cli/diagnostic-readiness.test.ts` | 9 / 15 | Existing diagnostic consumers use file/HTTP snapshots. | | `src/cli/daemon-cli/lifecycle-core.test.ts` | 51 / 22 | Async drain ordering and refusal before native dispatch. | | `src/cli/daemon-cli/lifecycle-readiness.test.ts` | 92 / 2 | Captured facts and pre-activation readiness ownership. | | `src/cli/daemon-cli/lifecycle.test.ts` | 40 / 17 | Repaired facts reach callers without reopening stores. | | `src/cli/daemon-cli/restart-health-deadline.test.ts` | 3 / 3 | Existing deadline fixture cutover. | | `src/cli/daemon-cli/restart-health-probe.test.ts` | 80 / 2 | Scope denial settles distinctly without polling. | | `src/cli/daemon-cli/restart-health-progress.test.ts` | 77 / 1 | Long migration remains protected; verified stale stopped-listener recovery remains reachable without SQL. | | `src/cli/daemon-cli/restart-health-wait.test.ts` | 10 / 26 | Bounded waits replace DB migration polling. | | `src/cli/daemon-cli/restart-health.test-helpers.ts` | 0 / 3 | Remove obsolete DB observer mock. | | `src/cli/daemon-cli/restart-health.test.ts` | 25 / 19 | Existing restart fixtures consume file-only observations. | | `src/cli/daemon-cli/start-repair.test.ts` | 57 / 4 | Producer publishes prepared auth/command facts before activation. | | `src/cli/gateway-cli/run-loop-mocks.test-support.ts` | 6 / 30 | Remove sentinel/fallback mocks; retain launcher owner. | | `src/cli/gateway-cli/run-loop-natural-exit.test-support.ts` | 9 / 5 | Lifecycle cleanup ordering fixtures. | | `src/cli/gateway-cli/run-loop-restart-ownership.test-support.ts` | 1 / 1 | Existing restart owner fixture cutover. | | `src/cli/gateway-cli/run-loop-stop.test-support.ts` | 10 / 8 | Stop/flush ordering fixture cutover. | | `src/cli/gateway-cli/run-loop-update-respawn.test-support.ts` | 14 / 31 | Launcher failure replaces competing in-process recovery. | | `src/cli/gateway-cli/run-loop.direct-stop-active-work.process.test.ts` | 143 / 32 | Existing signal cases plus real stuck-borrow watchdog exit and successor. | | `src/cli/gateway-cli/run-loop.test-support.ts` | 6 / 25 | Remove retired successor sentinel behavior. | | `src/cli/gateway-cli/run-loop.test.ts` | 12 / 21 | Launcher death exits visibly without reopening state. | | `src/cli/gateway-cli/update-successor.test.ts` | 36 / 0 | Successor readiness never reopens shared state. | | `src/cli/update-cli/update-command-readiness.windows.test.ts` | 0 / 1 | Remove obsolete observer mock. | | `src/cli/update-cli/update-command-verification.test.ts` | 11 / 6 | Preserve switched-release recovery outcomes and negative guards with correct file-owner lifetimes. | | `src/commands/doctor-config-preflight.admission.process.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pending-read.test.ts` | 2 / 1 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.plugin-persistence.test.ts` | 3 / 2 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.pristine.process.test.ts` | 2 / 5 | Offline lease-inspector migration. | | `src/commands/doctor-config-preflight.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/health.test.ts` | 24 / 0 | CLI reports reached/scope denial, not timeout. | | `src/commands/startup-config-preflight.native-bootstrap.test.ts` | 2 / 2 | Offline lease-inspector migration. | | `src/commands/startup-config-preflight.recovery.test.ts` | 4 / 3 | Offline lease-inspector migration. | | `src/commands/status.scan.shared.test.ts` | 25 / 1 | Status preserves reached/no-scope capability and both warnings without another probe. | | `src/daemon/schtasks-runtime-definition.test.ts` | 54 / 5 | Captured command and exact file/PID/port observations avoid SQL. | | `src/daemon/schtasks.start.test.ts` | 24 / 0 | Existing effect hooks can refuse before Scheduled Task Run. | | `src/infra/gateway-lock.test.ts` | 127 / 1 | Shared/control/agent physical custody; immediate/borrowed handoff matrix. | | `src/infra/startup-migration-checkpoint.test-support.ts` | 35 / 0 | Offline-only inspector replaces removed production observer. | | `src/infra/startup-migration-checkpoint.test.ts` | 6 / 14 | Inspector moved without losing lease assertions. | | `src/state/openclaw-state-db-cache.cleanup.test.ts` | 38 / 1 | Unlinked, recordless identity FD closes physically. | | `src/state/openclaw-state-read-source.test.ts` | 50 / 2 | Successful one-shot CLI reads join native worker exit. | | `src/update/cli.test.ts` | 95 / 25 | File-only terminal trial/deadline and pre-dispatch custody refusal. | | `test/scripts/ci-workflow-guards.test.ts` | 5 / 4 | Required healthy/crash lane selection and artifacts. | | `test/scripts/doctor-config-preflight-plugin-index.built-cli.e2e.test.ts` | 2 / 2 | Remaining offline inspector caller migration. | Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e77d359) Release adaptation: conflicts in src/update/cli.test.ts resolved by applying the source change over release-only hunks; source hunks verified unchanged (whitespace-insensitive). Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 26, 2026
Closes #204880 A build currently refuses every database written at a newer schema version, even when the change only adds storage that the older build can safely ignore. This prevents a previous Gateway from reopening compatible state after an update trial. The next stable can reopen future SQLite state, agent stores, and PostgreSQL schemas when their recorded reader floor permits it. Incompatible changes still stop startup with a clear schema refusal. Existing strict stores retain their current format and behavior; this PR does not change update backup policy. The existing version owners publish or clear `min_reader` in the version transaction. An absent/null floor means the writer version, so strict steps need no new storage; the first tolerable step adds a nullable floor column. Pre-v43 agent history stays strict; from v43 the SQLite migration finisher derives tolerance from the migrated predecessor catalog. No schema number is bumped, and port publication is unchanged. Admission, boot preflight and catalog checks preserve the actual writer version while accepting unknown tables and NULL-safe nullable columns. Non-nullable columns, non-NULL defaults, CHECKs rejecting NULL, generated columns, keys and references stay non-additive. Known constraints, triggers and ownership checks remain enforced; PostgreSQL also requires the newer writer's unchanged catalog seal. Newer registry rows remain discovery candidates; the `raised` case in `openclaw-agent-db.checkonce.test.ts` proves that a store whose floor is above this code is still refused at open. Ayaan approved this schema contract change on 2026-11-24 (`state-model-decision.md`). This PR targets main only; the release manager owns any backport. Rollback also retains the valid restored config when automatic recovery finds a newer writer's backup. The existing destructive-action guard remains enforced for an actually loaded newer config; prepared, synchronous and asynchronous recovery share this rule. The independent config-recovery repair is being landed first as a prerequisite (it also affects existing copy-and-swap rollback). Once main contains it, this PR will inherit the same implementation rather than carry a second change. - AWS: 164 SQLite/boot/catalog tests and 44 PostgreSQL tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_44448ae157b99967d36d4de1029769af)). - Red on unmodified main: SQLite state, SQLite agent, and PostgreSQL writable/read-only admission refuse the same compatible-newer fixtures ([run](https://crabbox.openclaw.ai/portal/runs/run_06577478aecf849ce6463a01fab37b53)). - Two local ClawSweeper rounds completed; verified findings were fixed. The lead reviewed the final registry delta and the subsequent behavior-equivalent type/lint fixes against the exact head. - AWS `check:changed` passed on `956fc25da6`: core/core-test type graphs, lint, format, dead-export checks, SQLite worker/dialect guards, and the remaining selected guards ([run](https://crabbox.openclaw.ai/portal/runs/run_cf80edb44a2a04deba0c2cf62af5810f)). Narrow subsequent auth/guard changes require the checks below. - Linux T/T+1 packages built successfully ([run](https://crabbox.openclaw.ai/portal/runs/run_5eaf078abca514a139d8c599b2092035)). That run exposed the restored-config recovery blocker, which was fixed rather than bypassed. The recovery regression then failed against the old owner and all 56 main config tests passed ([run](https://crabbox.openclaw.ai/portal/runs/run_96332cda9f136830532e490fd55faacb)). **Proof status:** the completed main SQLite downgrade run is recorded below. The built PostgreSQL downgrade cell remains NOT RUN; it is not claimed green. Affected behavior and final-head type checks remain covered by required PR CI. One version owner per store publishes the floor; strict steps retain the existing encoding. The change removes duplicate shared-version publication rather than adding a parallel migration mechanism. The focused column classifier now lives in `sqlite-additive-column.ts` to satisfy the existing owner's line cap; both consumers import it directly, without a facade or re-export. No broad historical fixture rewrites or unrelated documentation changes remain. Follow-up class: the admission rule currently spans about 15 independent version gates; consolidate them behind one admission owner so a future rule change is one edit. This PR only changes their existing decisions and required propagation. <details> <summary>LSP production reader inventory</summary> LSP references were collected before edits; its index is anchored to the primary checkout, so coordinates are not claimed for these frozen worktrees. New worktree-only consumers are named explicitly below. Paths without a prefix are under `src/state/`. - Shared version gate: `openclaw-state-db-schema-version.ts`, `openclaw-state-db-maintenance.ts`, `openclaw-state-db-fast-path.ts`, `openclaw-state-db-existing-schema.ts`, `openclaw-state-db-open.ts`, `openclaw-state-db-read-schema.ts`, `openclaw-state-db-existing-write.ts`, `openclaw-state-db-startup-checkpoint.ts`, `openclaw-state-db-schema-runtime.ts`, `openclaw-state-db-read-connection.ts`, `openclaw-state-db.ts`, `startup-metadata-live-read.worker.ts`, `src/plugins/update-cohort-recovery.ts`, `src/snapshot/openclaw-snapshot-copy.ts`, `src/snapshot/git-backup-codec.ts`, `src/agents/harness/native-hook-relay-client-read.ts`. New floor-read consumers: `openclaw-state-schema-preflight.ts`, `src/infra/sqlite-schema-header.ts`. - Agent version gate: `openclaw-agent-db-schema-read.ts`, `openclaw-agent-db-owner-read.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema.ts`, `openclaw-agent-db-maintenance.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/infra/database-engine/agent-port-descriptor.ts`, `src/infra/state-migrations.media-persistence.ts`, `src/snapshot/git-backup-codec.ts`, `src/snapshot/openclaw-snapshot-copy.ts`. Current-agent metadata gate: `openclaw-agent-db-engine.ts`, `openclaw-agent-db-schema-helpers.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`. - PostgreSQL physical admission: `src/infra/database-engine/open.ts`, `openclaw-state-db-engine.ts`. Schema verification: `src/infra/database-engine/physical-facts.ts`, `src/infra/database-engine/adapters.ts`. Engine-open callers: `openclaw-state-db-open.ts`, `openclaw-agent-db-engine.ts`, `openclaw-state-db-engine.ts`, `src/infra/database-engine/historical-index-ordering-port.ts`, `src/infra/database-engine/state-port-descriptor.ts`; Plugin SDK re-export unchanged. - Runtime inspection/preflight: `openclaw-agent-schema-inspection.worker.ts`, `openclaw-database-preflight.ts`, `openclaw-state-read-operation-registry.ts`. Preflight entry callers include Doctor database preflight, startup client credentials, preflight contexts, update-data-at-risk, auto-update compatibility, daemon status, Gateway bootstrap/startup maintenance, Doctor lease refusal and agent admission. Explicit updater-target policy remains strict. - Audit catalog admission: `openclaw-state-db-audit-migration.ts`, `openclaw-state-db-schema-repair.ts`. Canonical session-validation catalog admission: `openclaw-agent-canonical-validation-schema.ts`, `openclaw-agent-canonical-validation-receipt.ts`, `openclaw-agent-db-validation-cache.ts`, `openclaw-agent-db-readonly-open.ts`, `openclaw-agent-db-schema-admission.ts`, `openclaw-agent-db.ts`, `openclaw-agent-db-schema-refresh.ts`, `src/config/sessions/session-canonical-key.ts`. - Registry candidate filtering: `openclaw-agent-db-registry-listing.ts` (inspection, memo and snapshot paths), `src/infra/update-data-at-risk.ts`, `src/commands/doctor-db-bloat.read.ts`. Actual store admission remains the floor authority. - Config recovery's existing future-version guard is now consulted by the shared recovery plan builder. LSP callers: `io.observe-recovery.ts` prepared and immediate recovery entrypoints; synchronous/asynchronous startup loaders at `src/config/io.load.ts:210-212`; prepared snapshot recovery at `src/config/io.snapshot.ts:486`. Actual current-config admission in Gateway pre-bootstrap is unchanged. - Auth-profile reader admission: LSP production consumers `src/agents/auth-profiles/sqlite-json.ts:187,210` and `src/agents/auth-profiles/sqlite.ts:239,361` now use the canonical agent floor gate. Pooled same-version reuse remains query-free; a changed supplied version is checked once. </details> The maintainer approved allocation **150** for measured net test growth550: the prior127, optional-floor reference metadata (5), persisted-floor/refusal proof (2), cold-worker zero-comparison-DDL coverage (6), and cap-required fixture extraction/imports/formatting (10). The obsolete strict43-reader refusal case is replaced by actual44-writer/floor43 admission and old-writer NULL insertion proof. Only a redundant step-presence assertion was removed; exact rollback, ownership, catalog and constraint assertions remain. | Test file (`src/` unless otherwise qualified) | + / - | Protected contract | | --- | ---: | --- | | `agents/auth-profiles.sqlite-read-pool.test.ts` | 42 / 0 | Retained/raised floors through projected/plain auth readers; query-free warm reuse. | | `config/sessions/startup-migration.acp.test.ts` | 4 / 1 | Legacy admission uses consistent header/ownership markers. | | `infra/database-engine/bridge-prestart.test.ts` | 1 / 0 | PostgreSQL admission facts carry the required floor. | | `infra/database-engine/physical-facts.test.ts` | 2 / 2 | Strict metadata keeps absent-floor compatibility. | | `infra/database-engine/schema-admission.postgres.test.ts` | 172 / 1 | Writable/read-only T+1 admission; malformed/raised floors; nullable versus constrained catalogs; seals and rollback. | | `infra/sqlite-schema-facts.test.ts` | 42 / 0 | Warm future-reader cache stays query-free and rejects floors raised after schema/version invalidation. | | `infra/sqlite-schema-header.test.ts` | 9 / 5 | Floor/ownership survive inspection; native lock/WAL fixtures carry historical agent metadata. | | `state/openclaw-agent-db-registry-listing.snapshot.test.ts` | 2 / 2 | Future stores remain discovery candidates, not implicitly admitted stores. | | `state/openclaw-agent-db.checkonce.test.ts` | 120 / 5 | SQLite agent admission, readonly open, metadata preservation and transactional floor publication/rollback. | | `state/openclaw-agent-db.committed-read.test.ts` | 4 / 1 | A legacy replacement is refused before invoking its reader. | | `state/openclaw-database-preflight.startup-prepared.test.ts` | 7 / 1 | Boot preflight retains the actual legacy migration refusal. | | `state/openclaw-schema-metadata.test.ts` | 15 / 0 | SQLite ownership metadata/floor contract. | | `state/openclaw-state-db-checkonce.test.ts` | 1 / 1 | Cold content/floor read still executes exactly once. | | `state/openclaw-state-db-cron-delivery-migration.test.ts` | 1 / 1 | Managed snapshot qualification retains its exact query sequence. | | `state/openclaw-state-db-schema-version.test.ts` | 83 / 1 | SQLite state T+1 admission, raised-floor refusal and atomic floor publication/rollback. | | `state/openclaw-state-read.owned-native-token.test.ts` | 7 / 4 | Snapshot files and stable SHM bytes remain exact; only documented read marks may vary. | | `state/openclaw-state-read.worker.test.ts` | 1 / 0 | PostgreSQL worker facts retain the floor. | | `state/openclaw-agent-active-event-facts-migration.postgres.test.ts` | 1 / 1 | Strict legacy reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-approval-profile-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader40. | | `state/openclaw-worker-provision-source-migration.postgres.test.ts` | 1 / 1 | Strict state reader-floor refusal reports floor41 versus reader39. | | `extensions/workboard/src/postgres-store.test.ts` | 1 / 1 | A legacy strict workboard floor refuses the unsupported reader. | | `state/openclaw-agent-tool-usage-migration.postgres.test.ts` | 5 / 3 | Persists derived floor43 after strict42/43 plus additive44, and refuses reader41. | | `state/openclaw-agent-schema-inspection-worker.test.ts` | 16 / 0 | A future agent floor is read even when ownership projection is not requested. | | `state/openclaw-database-preflight.artifacts.test.ts` | 2 / 2 | Locked source fixture retains the real agent metadata shape; lock/readiness assertions unchanged. | | `commands/backup-verify.test.ts` | 4 / 4 | Wrong-role/path negatives carry otherwise complete agent metadata; rejection assertions unchanged. | | `commands/doctor-maintenance.schema-preflight.test.ts` | 2 / 2 | A raised agent floor refuses before incomplete registry repairs. | | `flows/doctor-health.dangling-workshop-index.test.ts` | 2 / 2 | Newer agent refusal preserves damaged shared-state bytes. | | `infra/database-engine/admitted-diagnostics.test.ts` | 1 / 1 | Read-free diagnostic agent fixture includes ownership columns. | | `infra/update-database-backup.agent-owners.test.ts` | 2 / 2 | Backup manifest owner discovery uses complete agent metadata. | | `infra/update-database-backup.test.ts` | 1 / 1 | External-agent backup fixture matches its existing version17 header. | | `state/openclaw-state-worker-loss-recovery.postgres.test.ts` | 4 / 1 | Newly merged v42 migration still refuses its v41 reader, asserting the floor diagnostic dynamically. | | `infra/sqlite-schema-contract.test.ts` | 25 / 16 | NULL-safe CHECK/default positives; six non-additive negatives, retaining strict known-object checks. | | `state/openclaw-agent-member-access-migration.test.ts` | 30 / 19 | Real step44 retains floor43 and old-reader/write compatibility; commit/rollback, sharing, witness and exact shipped PG SQL stay covered. | | `infra/database-engine/doctor-migration.postgres.test.ts` | 6 / 9 | Exact seven historical-agent upgrade/rollback catalogs; coherent fixture extraction keeps the owner within its line cap. | | `infra/database-engine/doctor-migration.postgres.test-support.ts` | 16 / 0 | Independent relocated full-catalog reader and optional-floor reference metadata fixture; no comparison filtering. | | `infra/sqlite-schema-contract.worker.test.ts` | 6 / 0 | NULL-safe CHECK drift remains compatible with strictly zero comparison DDL. | | `state/openclaw-state-ownership.test.ts` | 3 / 1 | A truly incompatible non-NULL default still blocks malformed-owner repair without changing its bytes. | The supported-header warm shortcut relies on atomically matching markers and `min_reader <= writer_version`; it does **not** short-circuit newer headers. The `raised` case in `openclaw-agent-db.checkonce.test.ts` asserts refusal at physical open, and the new `sqlite-schema-facts.test.ts` schema/version-invalidation cases require `SqliteSchemaVersionError` after a floor rises above this build. These new-head checks remain part of the explicitly outstanding proof, not a claim of final-head green. [AWS run `run_9344a01fac267cad3cc0253546ab206b`](https://crabbox.openclaw.ai/portal/runs/run_9344a01fac267cad3cc0253546ab206b) completed the real packed main agent44→45 Gateway cases. T reached readiness with T+1's retained-floor shared/agent stores, including the first newly added nullable floor storage; agent-only retained snapshots also reached readiness. Raised shared and agent-only floors both refused with exit78. Metadata and seeded session rows were preserved. Main auth tests, SQLite floor/CI regressions and PostgreSQL floor regressions passed; Kysely passed. The run used frozen main `546bde6b` before later warm-path and fixture corrections, so it is not presented as a blanket final-head CI result. The five canonical `check-test-types-core-*` jobs passed on run `45517151870`; the ad-hoc proof typecheck configuration was discarded rather than loosening its libraries. **PostgreSQL built downgrade cell: NOT RUN.** The initial run stopped at T+1 Doctor's strict pre-repair predecessor catalog check; the repaired predecessor fixture is prepared but its bounded replay could not run. Both standard-profile AWS allocations (including the single retry after capacity was freed) were quota-rejected down to an undersized `t3.small`; both leases were released without launching builds. PostgreSQL floor unit regressions passed. No backup/catalog gate was bypassed and no PG downgrade boot is claimed. Per the maintainer's decision, this capacity gap does not block the SQLite-proven PR; required CI and review still apply. [Controlled AWS comparison `run_f1242c2eb06315326ef5805841e000b1`](https://crabbox.openclaw.ai/portal/runs/run_f1242c2eb06315326ef5805841e000b1) ran the single Codex runtime test on the actual release merge candidate `adbb7d9d` (head `8b9199fd`) and its base `6b006bb1`, using the same pinned Bun and Node24.22.1. **Both reproduced the identical45000ms timeout.** Base/head wall time was114.352s/114.205s; Vitest110.85s/110.71s; max RSS5405548/5225840KiB. No head slowdown was observed in this isolated comparison. This is baseline reproduction, not a passing test or a “flake cleared” claim. The optional SQL trace covered diagnostics_channel only and does not establish absence of native SQLite calls. One local `ocx test --no-memo src/state/openclaw-agent-schema-inspection-worker.test.ts` run on `6f3417a4c8` was **red**: only the new 45/min_reader44, ownership-disabled case failed because minReader44 was omitted (7 existing tests passed). One run on the fixed `acaf8043a6` head was **green: 8/8**. Proof tier: vitest-source, no build. Agent inspection always reads the agent metadata floor; only the ownership result is optional, and the state floor owner is unchanged. This is review round2/2; no additional full review was requested. Historical ownership check: the first agent-store commit `fc50f949` (#88349), shipped `v2026.5.30-beta.1`, and retained stable `v2026.7.35` all have required `role` and `schema_version` metadata. The `git log --follow -S 'schema_version INTEGER'` history contains no shipped removal. Four minimal two-column test fixtures were corrected in place, with no assertion/timing changes or net test growth; no legacy product fallback was added. Focused local fixture proof (vitest-source, no build): one `ocx test --no-memo src/state/openclaw-database-preflight.artifacts.test.ts src/infra/sqlite-schema-header.test.ts` invocation passed **19/19** (9 preflight, 10 header), including unchanged lock tolerance, hot-journal and WAL byte-preservation cases. Completed a full `CREATE TABLE schema_meta` / agent_id fixture inventory across `src` and `test`, including multiline/quoted forms. All remaining synthetic agent fixtures now carry role/schema_version; the deliberately malformed populated-v0 refusal fixture remains malformed by design. Shared/global, credential-source and generic engine-scope fixtures are not agent stores and remain unchanged. The sweep changes only SQL fixture lines (12 replacements/net0), not assertions or timeouts. One local `ocx test --no-memo` invocation of all six sweep files passed **87 tests, 1 Windows-only skip** on main (43 infra +44 commands); proof tier vitest-source/no build. Total main diff after the newly merged PostgreSQL refusal diagnostic correction: **77 files, +1331/-268 (net1063)** against merge-base `8aaf3820112a`; production/config +740/-216, tests +552/-45, versioning doc +39/-7. After merging main's new shared schema42, PostgreSQL conformance run45543740954/job138969182913 exposed its newly introduced worker-loss migration test's old `is newer` diagnostic expectation. The actual refusal correctly required floor42 versus reader41. Updated only that expectation to the dynamic minimum-reader diagnostic; a sweep of all `*.postgres.test.ts` under `src`/`test` found no other remaining `is newer` refusal expectation. Green PostgreSQL execution of this narrow correction is left to required CI, not claimed from a skipped local test. `src/infra/sqlite-additive-column.ts` is the single column predicate. Its SELECT-only evaluator replaces the earlier candidate CREATE/INSERT probe: it parses nullable/default/CHECK clauses and evaluates scalar CHECK expressions over an explicit NULL value under deterministic-function authorization. It executes no comparison DDL and never touches source state. Non-nullable/unsafe default/key/reference/generated declarations stay incompatible; bare-type and warm admission paths retain their existing fast paths. `src/state/openclaw-agent-db-schema-helpers.ts:450` compares the migrated catalog with the actual predecessor before atomically stamping the version and derived floor. Pre-v43 history remains strict. PostgreSQL step44 computes its existing `minReader` property lazily through the same predicate (`openclaw-agent-member-access-schema.ts:10`, `openclaw-agent-db-engine.ts:431`), with no hand-declared floor43. Its generated migration SQL is asserted **byte-identical** to main's shipped SQL. Removed: the obsolete strict43-reader refusal test and the claimed43→44 pre-image requirement. There is no step44-specific production copy/pre-image branch to retain; generic backup restoration proof remains. Witness normalization treats `min_reader` like the existing version/app/time migration metadata; raw same-version schema/content hashes remain exact. This update adds **no persistent application column or table beyond the min_reader storage already present at870ef9ba31**, and the final classifier also performs **zero comparison DDL**. Proof: the two owning files on baseline870ef9ba31 with the new regression were **red: 4 intended failures, 35 passing**. Final main-only change **7f02f3b218** is **green: 39/39** via `ocx test --no-memo src/infra/sqlite-schema-contract.test.ts src/state/openclaw-agent-member-access-migration.test.ts` (vitest-source/no build). Logs: `ReaderFloor-null-safe-check/red-870ef9ba31.log`, `green-final.log`. Intermediate helper-regex and witness failures were corrected in their owners; no assertion/timeout masking. Latest measured scope against8aaf3820112a, superseding earlier historical counts: **82 files, +1485/-321, net1164**; production/config48 +836/-233 (net603), tests33 +607/-80 (net527), versioning doc +42/-8 (net34). Allocation127 covers the requested step44 contract and six negatives. Architecture CI's native-opener guard found one owned integration issue at7f02f3b218: the disposable classifier probe used the raw constructor. Fixed only its opener/import through `openNodeSqliteDatabase` (no exemption); owning39tests and `pnpm lint:kysely` both pass. Repair748ab989ac is +3/-3, no net scope growth or schema change. Logs: `ReaderFloor-null-safe-check/canonical-opener-tests.log`, `canonical-opener-guard.log`. The SELECT-only helper's +83 production lines replace its DDL probe while preserving the cold-worker zero-comparison-DDL contract. The trusted PR wrapper legitimately imports this schema-rule owner through its already-inventoried schema contract; `scripts/pr-lib/wrapper-components.txt` now declares the extracted helper (one path), rather than relocating a schema rule into an unrelated native owner or weakening the closure test. PostgreSQL's seven reported historical-agent failures occurred before rollback: migrated engine metadata had its optional floor column, while the fresh reference intentionally omitted it. The independent reference fixture now includes that exact nullable BIGINT metadata representation; whole-catalog equality and all rollback/foreign-write assertions remain. Fresh production bootstrap remains unchanged. The tool-usage predecessor refusal now asserts the correct derived floor43, not44. The malformed-owner negative uses a non-NULL default because DEFAULT NULL is now intentionally additive. The unrelated startup timing case from #204943 is owned by the maintainer's override; this repair neither changes nor reruns it. Owning local schema/PostgreSQL lanes initially failed during dependency setup, before tests, when parallel ocx installs rematerialized a shared checkout; source-identical committed-head serial proof runs in an isolated checkout instead. CI on652ae1d9aa remains the full proof. Latest consolidated scope against8aaf3820112a: **87 files, +1604/-333, net1271**; production/config49 +920/-233 (net687), tests37 +642/-92 (net550), versioning doc +42/-8 (net34). Head652ae1d9aa differs from consolidated repair e57d895 only by its approved allocation record. Kysely guardrails passed; final local/CI outcomes are not claimed before completion. Main was merged once to include #205022's migration observer. Its catalog capture happens before every observed statement, so the private NULL probe now permits only the observer's read-only catalog PRAGMAs/schema reads in addition to its scalar CHECK evaluation, and clears its authorizer before disposal. Writes, user-table reads and nondeterministic functions remain denied; neither the observer nor source guards changed. Merged-tree local proof: **45/45 passed** (migration-chain5, classifier/cold-worker/real-step44 tests40), log `ReaderFloor-consolidated-repairs/observer-merged.log`. Earlier owning schema proof was71/71; wrapper closure23/23 and provisioner17 cases passed, with only the independently observed plain-main macOS sparse-transition120s timeout remaining locally. PostgreSQL's hand-built pre-merge local proof had later credential-restore/transaction errors; it is not claimed green, and the maintainer designated CI's PostgreSQL conformance as authoritative. Current head **c946b3fc75**, measured against main merge-base **3f2e0ade38**: **87 files, +1614/-333, net1281**; production/config49 net697, tests37 net550, versioning doc net34. Allocation150 is unchanged. All task-owned local PostgreSQL/container and scratch resources have been released. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit cf9a46d) Release adaptation: release lacks agent schema v44 (session member access) and state schema v42 (worker-loss recovery), so their migration files and member-access reader-floor hunks are omitted; openclaw-agent-db-engine.ts takes only the admission/minReader hunks. Postgres migration tests take the source reader-floor assertions. Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 28, 2026
## What Problem This Solves A background integrity reader can retain an old SQLite snapshot while checkpoints are blocked. The native writer already observes checkpoint pressure, but ordinary worker replies did not carry that observation back to the Gateway that owns the background reader. Builds on merged #204907. This PR is retargeted to `main` and contains only the verifier/worker-observation slice. ## User Impact Background integrity checks release their own reader under excessive blocked-WAL pressure. User reads and writes continue unchanged. Interrupted verification stays inconclusive: no verification receipt, clean-close seal, or corruption refusal is invented. This is not a hard WAL size cap. ## Why This Change Was Made The existing checkpoint owner computes byte pressure once: blocked, with WAL bytes greater than both twice the database size and 64 MiB. Newly recorded observations travel on the existing settled worker reply, qualified by the original actor's physical identity and current custody. Optional fast-grant authority keeps its stronger incarnation check. The verifier subscribes only during its native integrity promise, aborts and joins its own child, and unregisters before verdict processing. Explicit maintenance retains its existing publication route. There is no new channel, registry, scheduler, retry loop, or writer-admission policy. Existing backend validation and reply contracts move to their existing loader/type owners to keep the implementation local and bounded. The lifecycle-file change is type imports only. ## Evidence - Real native scheduled tick → ordinary session command → host observation regression was **red** with the owned SQLite child still alive, then **green** with joined cancellation and subsequent checkpoint progress. It does not inject a host checkpoint fact or issue an explicit WAL-maintenance command for the positive case. - **54 local tests passed** across six targeted files, including healthy/corrupt verification, native loss, quarantine, ordinary replies, checkpoint handling, and cleanup. **36 tests passed on AWS/Linux** across the five transport/checkpoint suites in parallel with the backup proof. - Stale physical identity, birthtime, path, incarnation, custody, and owner observations cannot publish through the reply boundary. Warning-only and unrelated-store pressure do not cancel the scan. - Targeted Oxlint: 0 warnings/errors; changed-file formatting passed. The exact state-logging compiler leaf passes after the test-only optional-promise correction; its focused native regression passes too. Canonical compiler/breadth validation belongs to PR CI. - Local reviews of `8ff498ec` and `eafdcfb3` found no actionable correctness/security defects. The later merge from `main` introduces no additional verifier runtime changes. - Exact-head PR CI is **green on `7afef14b9c12`**, including PostgreSQL conformance and Docker seed E2E. The last repairs changed test fixtures only. Production delta: **+157 lines**; test/support/routing delta: **+460**; docs: **+8**. The additional transport is required by the real native-flow regression; the smaller main-thread-only implementation was not shipped. The regression allocation records the native process/worker harness above the normal test budget. Registration fixtures preserve real unrelated broker exports, and their retired full-mock exception is removed. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit c635b05)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
A background integrity reader can retain an old SQLite snapshot while checkpoints are blocked. The native writer already observes checkpoint pressure, but ordinary worker replies did not carry that observation back to the Gateway that owns the background reader.
Builds on merged #204907. This PR is retargeted to
mainand contains only the verifier/worker-observation slice.User Impact
Background integrity checks release their own reader under excessive blocked-WAL pressure. User reads and writes continue unchanged. Interrupted verification stays inconclusive: no verification receipt, clean-close seal, or corruption refusal is invented. This is not a hard WAL size cap.
Why This Change Was Made
The existing checkpoint owner computes byte pressure once: blocked, with WAL bytes greater than both twice the database size and 64 MiB. Newly recorded observations travel on the existing settled worker reply, qualified by the original actor's physical identity and current custody. Optional fast-grant authority keeps its stronger incarnation check.
The verifier subscribes only during its native integrity promise, aborts and joins its own child, and unregisters before verdict processing. Explicit maintenance retains its existing publication route. There is no new channel, registry, scheduler, retry loop, or writer-admission policy.
Existing backend validation and reply contracts move to their existing loader/type owners to keep the implementation local and bounded. The lifecycle-file change is type imports only.
Evidence
8ff498ecandeafdcfb3found no actionable correctness/security defects. The later merge frommainintroduces no additional verifier runtime changes.7afef14b9c12, including PostgreSQL conformance and Docker seed E2E. The last repairs changed test fixtures only.Production delta: +157 lines; test/support/routing delta: +460; docs: +8. The additional transport is required by the real native-flow regression; the smaller main-thread-only implementation was not shipped. The regression allocation records the native process/worker harness above the normal test budget. Registration fixtures preserve real unrelated broker exports, and their retired full-mock exception is removed.