Repository navigation
Conversation
…rral are refused as schema drift openclaw#196392 added `workspace_setup_state.bootstrap_deferred` as a first-use column. SQLite tolerates a missing first-use column, but PostgreSQL has no first-use columns: the generated DDL declares the column, so any existing PostgreSQL state store sealed without it was refused by update admission and Doctor preflight with "PostgreSQL schema drift detected against generated DDL". Make the column part of state schema 40, following the single-column v39 precedent: SQLite adds it if missing (stores that already gained it from the former first-use writer keep it), PostgreSQL adds it in a registered v39-to-v40 transition with a table-scoped backup, and the predecessor transforms keep v39 admission, backups, ports and the v13 rebuild on the exact pre-v40 shape. The first-use writer no longer calls ensureColumn, which on PostgreSQL would have added an `integer` column against the generated `bigint` contract. Closes openclaw#196966
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR versions workspace bootstrap deferral at shared-state schema 40 and migrates both valid schema-39 layouts while preserving stored values. Example: Update a PostgreSQL schema-39 installation whose workspace_setup_state table lacks bootstrap_deferred.
Review scores
ProductKind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete Regression provenanceRegression provenance — suspected predecessor, not a causality claim: source commit Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 1 item remains Keep open: this PR repairs a confirmed PostgreSQL update regression, and the earlier code findings are addressed; the schema-40 cutover still needs maintainer acceptance. Priority: P1 Decision needed
Before merge
FindingsNone. Agent review detailsHow this fits togetherThe shared-state database owner sits beneath update preflight, Doctor, workspace setup, and backup/restore; it accepts existing SQLite or PostgreSQL stores and publishes an admitted, versioned schema. flowchart TD
A[Update or Doctor] --> B[Database admission]
B --> C[Exact predecessor selection]
C --> D[Verified backup]
D --> E[Schema 40 migration]
E --> F[Catalog and version publication]
F --> G[Workspace setup writer]
Technical reviewBest possible solution: Accept the documented schema-40 transition and land the existing migration through the normal review and CI gates. Do we have a high-confidence way to reproduce the issue? The reporter’s pinned PostgreSQL update bisect matches current exact-catalog admission and the first-use column addition; this read-only review ran no reproduction or tests. Is this the best way to solve the issue? The patch repairs the schema owner rather than bypassing drift checks, and its migration-source and port variants are needed to preserve both observed predecessor layouts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 26a4a89b304f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +168, Tests +119, Docs +25, Config 0, Other +3. Total +315 across 37 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)
Reviewed November 11, 2026, 10:28 AM ET / 15:28 UTC (Revision 3). |
…er inventory and test-lines budget Historical Doctor fixtures that already have workspace_setup_state now record the v40 change line, the PR wrapper inventory includes the new v40 migration module, and the new PostgreSQL regression lines carry a justified test-lines allocation. Refs openclaw#196966
…eferred The shared-state PostgreSQL owner fixtures rebuild empty predecessor tables from the registered fromSchema before sealing an older version; workspace_setup_state now joins that list so a pre-v40 store really lacks the v40 column. database prepare-state reports the current state schema version instead of a literal 39. The test-lines allocation matches the measured +89. Refs openclaw#196966
…strap_deferred PostgreSQL stores bootstrapped from the first-use DDL that openclaw#196392 shipped already hold workspace_setup_state.bootstrap_deferred at schema 39. The v40 step now declares that exact shape as a second accepted source, the migration runner and existing-version inspection select the stored shape through the schema owner, and the step adds the column only if it is absent, so stored values are kept. Any other definition of the column is still refused as drift. Refs openclaw#196966
…rred - A v39 SQLite store whose first-use writer added the column opens at v40 with bootstrap_deferred = 1 kept. - Test-lines allocation moves from 99 to 119 for the 20 added lines.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…_deferred openclaw#196392 added workspace_setup_state.bootstrap_deferred to the eager schema-39 PostgreSQL DDL without a version step, so every store sealed before it is refused as drift, including update preflight (openclaw#196966). Declare the column as a same-version PostgreSQL additive column. A writable admission verifies the exact predecessor DDL, adds the generated bigint column and reseals in one transaction. Inspection accepts either exact shape without writing. Any other difference is still refused. The workspace worker no longer adds an INTEGER column on PostgreSQL. Credit to etzelm, who diagnosed the same failure in openclaw#197010 (openclaw#197010). That PR fixes it with a schema-40 step accepting both schema-39 shapes. This change keeps schema 39 instead. Stores it completes have the column-present shape that the schema-40 step accepts. Signed-off-by: Chris Eckert <[email protected]>
…al is refused as schema drift (#197425) * fix(state): admit PostgreSQL schema-39 stores sealed before bootstrap_deferred #196392 added workspace_setup_state.bootstrap_deferred to the eager schema-39 PostgreSQL DDL without a version step, so every store sealed before it is refused as drift, including update preflight (#196966). Declare the column as a same-version PostgreSQL additive column. A writable admission verifies the exact predecessor DDL, adds the generated bigint column and reseals in one transaction. Inspection accepts either exact shape without writing. Any other difference is still refused. The workspace worker no longer adds an INTEGER column on PostgreSQL. Credit to etzelm, who diagnosed the same failure in #197010 (#197010). That PR fixes it with a schema-40 step accepting both schema-39 shapes. This change keeps schema 39 instead. Stores it completes have the column-present shape that the schema-40 step accepts. Signed-off-by: Chris Eckert <[email protected]> * fix(state): complete retained PostgreSQL predecessor facts for writers An inspection admission retains a schema-39 predecessor's catalog as found. A writable admission that reused those shared facts skipped the bootstrap_deferred completion, so its first setup write failed with column "bootstrap_deferred" does not exist. A writer now completes the predecessor before using retained facts that lack a declared additive column. Read the additive column name through a type guard instead of an unchecked cast. Signed-off-by: Chris Eckert <[email protected]> * docs(state): separate PostgreSQL downgrade refusal from SQLite compatibility Older builds ignore bootstrap_deferred only on SQLite. On PostgreSQL a build that predates the column refuses a completed store as drift and needs the matching schema and anchor from before the upgrade. Signed-off-by: Chris Eckert <[email protected]> * test(state): rebuild workspace setup table for pre-v39 PostgreSQL fixtures --------- Signed-off-by: Chris Eckert <[email protected]> Co-authored-by: VACInc <[email protected]>
…al is refused as schema drift (openclaw#197425) * fix(state): admit PostgreSQL schema-39 stores sealed before bootstrap_deferred openclaw#196392 added workspace_setup_state.bootstrap_deferred to the eager schema-39 PostgreSQL DDL without a version step, so every store sealed before it is refused as drift, including update preflight (openclaw#196966). Declare the column as a same-version PostgreSQL additive column. A writable admission verifies the exact predecessor DDL, adds the generated bigint column and reseals in one transaction. Inspection accepts either exact shape without writing. Any other difference is still refused. The workspace worker no longer adds an INTEGER column on PostgreSQL. Credit to etzelm, who diagnosed the same failure in openclaw#197010 (openclaw#197010). That PR fixes it with a schema-40 step accepting both schema-39 shapes. This change keeps schema 39 instead. Stores it completes have the column-present shape that the schema-40 step accepts. Signed-off-by: Chris Eckert <[email protected]> * fix(state): complete retained PostgreSQL predecessor facts for writers An inspection admission retains a schema-39 predecessor's catalog as found. A writable admission that reused those shared facts skipped the bootstrap_deferred completion, so its first setup write failed with column "bootstrap_deferred" does not exist. A writer now completes the predecessor before using retained facts that lack a declared additive column. Read the additive column name through a type guard instead of an unchecked cast. Signed-off-by: Chris Eckert <[email protected]> * docs(state): separate PostgreSQL downgrade refusal from SQLite compatibility Older builds ignore bootstrap_deferred only on SQLite. On PostgreSQL a build that predates the column refuses a completed store as drift and needs the matching schema and anchor from before the upgrade. Signed-off-by: Chris Eckert <[email protected]> * test(state): rebuild workspace setup table for pre-v39 PostgreSQL fixtures --------- Signed-off-by: Chris Eckert <[email protected]> Co-authored-by: VACInc <[email protected]>
…al is refused as schema drift (#197425) * fix(state): admit PostgreSQL schema-39 stores sealed before bootstrap_deferred #196392 added workspace_setup_state.bootstrap_deferred to the eager schema-39 PostgreSQL DDL without a version step, so every store sealed before it is refused as drift, including update preflight (#196966). Declare the column as a same-version PostgreSQL additive column. A writable admission verifies the exact predecessor DDL, adds the generated bigint column and reseals in one transaction. Inspection accepts either exact shape without writing. Any other difference is still refused. The workspace worker no longer adds an INTEGER column on PostgreSQL. Credit to etzelm, who diagnosed the same failure in #197010 (#197010). That PR fixes it with a schema-40 step accepting both schema-39 shapes. This change keeps schema 39 instead. Stores it completes have the column-present shape that the schema-40 step accepts. Signed-off-by: Chris Eckert <[email protected]> * fix(state): complete retained PostgreSQL predecessor facts for writers An inspection admission retains a schema-39 predecessor's catalog as found. A writable admission that reused those shared facts skipped the bootstrap_deferred completion, so its first setup write failed with column "bootstrap_deferred" does not exist. A writer now completes the predecessor before using retained facts that lack a declared additive column. Read the additive column name through a type guard instead of an unchecked cast. Signed-off-by: Chris Eckert <[email protected]> * docs(state): separate PostgreSQL downgrade refusal from SQLite compatibility Older builds ignore bootstrap_deferred only on SQLite. On PostgreSQL a build that predates the column refuses a completed store as drift and needs the matching schema and anchor from before the upgrade. Signed-off-by: Chris Eckert <[email protected]> * test(state): rebuild workspace setup table for pre-v39 PostgreSQL fixtures --------- Signed-off-by: Chris Eckert <[email protected]> Co-authored-by: VACInc <[email protected]> (cherry picked from commit 17c5fb0) Companion review: no later PR-number references through pinned main. Baseline schema-40 migration already owns completion; add the missing bootstrap-deferred historical layouts and column to that owner. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit d7583be40016d304ddbafe20cc36dc238205e154)
Closes #196966
Related: #197008 (SQLite clean-close seals invalidated by the same column)
What Problem This Solves
Fixes: PostgreSQL-backed installs cannot update to any build from caa978c (#196392) onward. The update is refused at
database-engine-preflightwith "PostgreSQL schema drift detected against generated DDL".User Impact
User impact: PostgreSQL installs update past 2026.11.2 again, whichever valid schema-39 shape their store holds. The store moves to shared-state schema 40 with its workspace setup rows and stored values intact. SQLite installs migrate the same way.
Required action: none. As with every state schema bump, older builds refuse a schema-40 store, and downgrade means restoring the verified pre-upgrade backup with its matching binary.
Why This Change Was Made
#196392 added
workspace_setup_state.bootstrap_deferredas a first-use column. SQLite admission tolerates a missing first-use column, but PostgreSQL stores have no first-use columns. The generated PostgreSQL DDL declares the column, so every existing PostgreSQL store sealed without it no longer matched the candidate's contract.This PR makes the column part of state schema 40, following the single-column v39 precedent (
retention_json). Two valid v39 shapes exist in the field:bigint), and SQLite stores whose first-use writer added it (INTEGER).The v40 step accepts exactly those two shapes. It adds the column only if it is missing, so stored values are kept. On PostgreSQL it refuses any other definition (for example
integer, a default, orNOT NULL) as drift. The change touches these places:alsoFromSchemas, additional exact predecessor shapes. The runner and existing-version inspection select the stored shape throughselectPostgresMigrationSource.sourceVariants. Port admission (snapshot, backup, restore) selects the variant the source holds, comparing only the tables where the variants differ. The v39 descriptor carries the column-present variant.ensureColumn. On PostgreSQL that call would have added anintegercolumn against the generatedbigintcontract.Maintainer decision
This PR makes
bootstrap_deferreda schema-40 column on SQLite and PostgreSQL. It replaces the first-use install that #196392 chose. Both exact schema-39 shapes migrate with their stored values kept. Older binaries refuse a schema-40 store, as with every state schema bump. Downgrade means restoring the verified pre-upgrade backup with its matching binary.Why not keep first-use: PostgreSQL has no first-use columns. It adds columns to existing tables only through versioned transitions (v28, v35, v37 to v39). The other options also change the #196392 storage design:
A versioned column is the smallest change that reuses the existing schema, migration and backup owners and keeps admission exact.
Evidence
All local runs below are on tree
551c0c97e2a4(this head), PostgreSQL 17.11 withmax_locks_per_transaction=512and theunaccent,pg_trgmandvectorextensions, as in CI.Discriminating PostgreSQL regression:
src/state/openclaw-state-workspace-bootstrap-migration.postgres.test.ts, run withnode scripts/test-database-conformance.mjs --engine postgres --connection <disposable> -- <file>.SQLite, both v39 shapes:
src/agents/workspace-state-store.test.ts.user_versionreaches 40, and setup rows are unchanged.bootstrap_deferred = 1: the store opens at 40 and keeps the value. If the v40 step instead adds the column unconditionally, this case fails withduplicate column name: bootstrap_deferred.Real CLI, PostgreSQL (run by the author on
fdf476ea; this head changes onlysrc/agents/workspace-state-store.test.tsand the test-lines allocation on top of8da0de95): isolated git installs with all three families on PostgreSQL, onboarded and seeded withagents add probe. Each runsopenclaw update --yes --no-restart --channel devagainst a local mirror whosemainis pinned to the target.0a9d8c71).25bf99f6: refused atdatabase-engine-preflightwith "PostgreSQL schema drift detected against generated DDL"; exit 1.✅ OpenClaw updated to 2026.11.3 (fdf476ea) (from 2026.11.2 (0a9d8c71)), exit 0. Schema 40, column added, 2 retained rows.agents add probe2writes a setup row (3 rows), and adoctorreopen shows version 40 and all three agents.041c3b71), which bootstrapped the store at v39 with the column. Before the update, one retained row was set tobootstrap_deferred = 1with SQL; I found no offline product path that drives Template deferral.database-engine-preflightwith the same drift error; exit 1, and the store stays at v39.✅ OpenClaw updated to 2026.11.3 (fdf476ea) (from 2026.11.3 (041c3b71)), exit 0. Schema 40. Values were1,nullbefore the update; after a new setup write they read1,null,null, and after the reopen still1,null,nullat version 40. All three agents are listed.Latest stable → fix (SQLite, run by the author on
f5abb2d5, an earlier revision with the same SQLite path):npm install -g openclaw@latest(2026.11.3), onboarded and seeded. The stable binary's ownopenclaw update --channel devto the fix gives✅ updated, exit 0. The store ends atuser_version 40withbootstrap_deferredpresent and its 2 rows kept, and agents andgateway.portare preserved.Focused checks on this head:
openclaw-state-workspace-bootstrap-migration5/5doctor-migration26/26openclaw-state-db.postgres13/13database-prepare-state3/3schema-admission15/15readonly-admission6/6config-preflight1/1state-port2/2agent-port9/9port-command5/5port-provider1/1git-backup-secrets4/4update-cohort-restore1/1postgres-generation2/2startup-client-credentials7/7client-credential-migration3/3client-credential-startup.gateway1/1logbook-port5/5, logbook and workboard transports 1/1 eachsrc/agents/workspace-state-store.test.tsandsrc/state/openclaw-state-db.test.ts: 73 passed.pnpm tsgo:core:test: passes.oxlintandoxfmt --checkon the changed test: clean.Test lines OK: 6645167; ceiling: 6645186; slack: 19.The +119 net test lines are covered byconfig/test-lines-allocations/postgres-workspace-bootstrap-deferral.txt. Main's 19 lines of slack are unchanged.scripts/pr-lib/wrapper-components.txtlists the new v40 module.CI on
8da0de95(run 42972390862): each remaining failure is unrelated to this change.extensions/codex/src/app-server/run-attempt.native-hook-relay.test.ts("relays native tool results through Codex result middleware")29c445e7. Same failure on other PRs' CI: runs 43024779027, 43009841575, 43008868345, 42999561346test/e2e/qa-lab/runtime/telegram-message-tool-failure-settlement.e2e.test.tsPostgreSQL conformance (1/3)passed 9 Vitest shards in 1460.35s), and the PG16 Gateway smoke passed 8/8. The job reached its 30 minute limit while that step exited. The shard's file list is the same on main. Other PRs hit the same cancel: runs 42991997194 (1816 s) and 42982947108 (1808 s)openclaw/ci-gateGaps
database.*config, so the stable→fix run is SQLite-only.archive-restore,git-backupandport-command-refusalsneed a builtdist/and were not rerun on this head.pr-simplify: each hunk serves one of three things: the v40 column, its two exact predecessor shapes (migration source and port variant), or removing the first-use path. The two new optional fields are the smallest way I found to make one schema version accept two exact shapes in both the migration runner and the port layer, without loosening any exact-catalog check. The new PostgreSQL tests live in their own file because
doctor-migration.postgres.test.tsis at its 1000-line budget.