Skip to content

fix(state): PostgreSQL updates to builds with Template bootstrap deferral are refused as schema drift - #197010

Closed
etzelm wants to merge 5 commits into
openclaw:mainfrom
etzelm:fix/postgres-bootstrap-deferred-v40
Closed

etzelm wants to merge 5 commits into
openclaw:mainfrom
etzelm:fix/postgres-bootstrap-deferred-v40

Conversation

@etzelm

@etzelm etzelm commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

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-preflight with "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_deferred as 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:

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, or NOT NULL) as drift. The change touches these places:

  • Migration step: may declare alsoFromSchemas, additional exact predecessor shapes. The runner and existing-version inspection select the stored shape through selectPostgresMigrationSource.
  • Port descriptor: may declare 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.
  • SQLite: adds the column if it is missing. The predecessor transforms keep v39 admission, backups, ports and the historical v13 rebuild on the exact pre-v40 shape.
  • Workspace writer: no longer calls ensureColumn. On PostgreSQL that call would have added an integer column against the generated bigint contract.

Maintainer decision

This PR makes bootstrap_deferred a 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:

  • First-use companion table: moves the flag into its own table. Stores already bootstrapped with the column would then drift.
  • First-use columns in PostgreSQL admission: a new admission and seal concept that loosens exact catalog checks.

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 with max_locks_per_transaction=512 and the unaccent, pg_trgm and vector extensions, as in CI.

Discriminating PostgreSQL regression: src/state/openclaw-state-workspace-bootstrap-migration.postgres.test.ts, run with node scripts/test-database-conformance.mjs --engine postgres --connection <disposable> -- <file>.

main 29c445e7: × upgrades a v39 store with the column absent … → PostgreSQL schema drift detected against generated DDL.
               × upgrades a v39 store with the column present … (main has no v40; the store stays at v39)
               ✓ still refuses … integer   ✓ … bigint DEFAULT 0   ✓ … bigint NOT NULL DEFAULT 0
this head:     5 passed (5)

SQLite, both v39 shapes: src/agents/workspace-state-store.test.ts.

  • Column absent: the column is added, user_version reaches 40, and setup rows are unchanged.
  • Column present with bootstrap_deferred = 1: the store opens at 40 and keeps the value. If the v40 step instead adds the column unconditionally, this case fails with duplicate column name: bootstrap_deferred.

Real CLI, PostgreSQL (run by the author on fdf476ea; this head changes only src/agents/workspace-state-store.test.ts and the test-lines allocation on top of 8da0de95): isolated git installs with all three families on PostgreSQL, onboarded and seeded with agents add probe. Each runs openclaw update --yes --no-restart --channel dev against a local mirror whose main is pinned to the target.

  • Column absent: installed 2026.11.2 (0a9d8c71).
    • Before, main 25bf99f6: refused at database-engine-preflight with "PostgreSQL schema drift detected against generated DDL"; exit 1.
    • After: ✅ OpenClaw updated to 2026.11.3 (fdf476ea) (from 2026.11.2 (0a9d8c71)), exit 0. Schema 40, column added, 2 retained rows. agents add probe2 writes a setup row (3 rows), and a doctor reopen shows version 40 and all three agents.
  • Column present: installed 2026.11.3 (041c3b71), which bootstrapped the store at v39 with the column. Before the update, one retained row was set to bootstrap_deferred = 1 with SQL; I found no offline product path that drives Template deferral.
    • Before, an earlier revision of this PR: refused at database-engine-preflight with the same drift error; exit 1, and the store stays at v39.
    • After: ✅ OpenClaw updated to 2026.11.3 (fdf476ea) (from 2026.11.3 (041c3b71)), exit 0. Schema 40. Values were 1,null before the update; after a new setup write they read 1,null,null, and after the reopen still 1,null,null at 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 own openclaw update --channel dev to the fix gives ✅ updated, exit 0. The store ends at user_version 40 with bootstrap_deferred present and its 2 rows kept, and agents and gateway.port are preserved.

Focused checks on this head:

  • PostgreSQL conformance, file by file:
    • openclaw-state-workspace-bootstrap-migration 5/5
    • doctor-migration 26/26
    • openclaw-state-db.postgres 13/13
    • database-prepare-state 3/3
    • schema-admission 15/15
    • readonly-admission 6/6
    • config-preflight 1/1
    • state-port 2/2
    • agent-port 9/9
    • port-command 5/5
    • port-provider 1/1
    • git-backup-secrets 4/4
    • update-cohort-restore 1/1
    • postgres-generation 2/2
    • startup-client-credentials 7/7
    • client-credential-migration 3/3
    • client-credential-startup.gateway 1/1
    • logbook-port 5/5, logbook and workboard transports 1/1 each
  • src/agents/workspace-state-store.test.ts and src/state/openclaw-state-db.test.ts: 73 passed.
  • pnpm tsgo:core:test: passes. oxlint and oxfmt --check on the changed test: clean.
  • Test-lines ratchet: Test lines OK: 6645167; ceiling: 6645186; slack: 19. The +119 net test lines are covered by config/test-lines-allocations/postgres-workspace-bootstrap-deferral.txt. Main's 19 lines of slack are unchanged.
  • PR wrapper inventory: scripts/pr-lib/wrapper-components.txt lists the new v40 module.

CI on 8da0de95 (run 42972390862): each remaining failure is unrelated to this change.

Failing check Classification Evidence
extensions/codex/src/app-server/run-attempt.native-hook-relay.test.ts ("relays native tool results through Codex result middleware") Pre-existing Fails the same way locally on main 29c445e7. Same failure on other PRs' CI: runs 43024779027, 43009841575, 43008868345, 42999561346
test/e2e/qa-lab/runtime/telegram-message-tool-failure-settlement.e2e.test.ts Pre-existing Same assertion on another PR's CI: runs 42998401262, 42991776111. No frame touches state schema
PostgreSQL conformance (1/3) Job time limit Every conformance file passed (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-gate Aggregate Fails because of the rows above

Gaps

  • The native Swift shared-state ceiling and its test constant moved to 40. The Swift tests were not run here.
  • There is no stable PostgreSQL upgrade to prove: latest stable 2026.11.3 rejects database.* config, so the stable→fix run is SQLite-only.
  • archive-restore, git-backup and port-command-refusals need a built dist/ 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.ts is at its 1000-line budget.

…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
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: M labels Nov 11, 2026
@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 11, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This 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.

  • Before: Update admission refuses the candidate with “PostgreSQL schema drift detected against generated DDL.”
  • After: The store advances to schema 40, adds the nullable column, and retains its workspace setup rows.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Concrete product upgrade evidence and no remaining code findings support the repair; unresolved acceptance of the storage contract holds overall readiness at C.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Supplied terminal results exercise real openclaw update on PostgreSQL 17.11 for both schema-39 layouts, followed by retained-value inspection, a workspace setup write, and Doctor reopen; latest-stable SQLite upgrade also preserves rows and settings.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Valid PostgreSQL installations cannot activate newer dev-channel builds because update preflight rejects the missing bootstrap-deferral column.
Reason: The repair has clear user value, but intentionally replaces the existing first-use storage contract with a schema-version transition requiring owner acceptance.

Regression provenance

Regression provenance — suspected predecessor, not a causality claim: source commit 6c1e1667bd61 by Peter Steinberger; no PR verified.

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
Reviewed head: 3619148b9748dfe0d2311d31e08cfe4842507912
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should bootstrap_deferred become a schema-40 column on both engines, replacing SQLite first-use installation and requiring backup restoration for downgrade?
  • Recommendation: Accept schema 40: Approve the versioned column and documented downgrade contract, retaining both exact predecessor layouts and existing migration owners.
  • Why: The original implementation deliberately preserved schema 39, and repository policy requires acceptance of a schema-version bump; the contributor explains the tradeoff, but no maintainer has accepted it in the recorded discussion.

Before merge

  • Await maintainer action - A database-area maintainer must accept the schema-40 cutover and its documented downgrade contract.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Workspace bootstrap column installation changes intended behavior with a stated reason (caa978c: Install deferral through the workspace writer while preserving historical read-only opening, existing attestation semantics, and schema 39.)
  • Exact PostgreSQL migration admission keeps the original intent (e3b8a28: Keep forward migrations atomic and verify exact source and destination catalogs before sealing.)
  • Database port descriptor ownership keeps the original intent (d6f6f76: Use family-owned descriptors for exact schema, backup, restore, and optional-fragment handling.)
  • Historical v13 rebuild keeps the original intent (1ea2640: Consolidate workspace setup and other canonical state through the historical migration owner; excluding the later column leaves its installation to v40.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e3b8a28 adds src/infra/database-engine/postgres-schema.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e3b8a282764d; files: src/infra/database-engine/postgres-schema.ts)

PR surface

Source +168, Tests +119, Docs +25, Config 0, Other +3. Total +315 across 37 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 19 283 115 +168
Tests 12 128 9 +119
Docs 2 33 8 +25
Config 1 1 1 0
Generated 0 0 0 0
Other 3 4 1 +3
Total 37 449 134 +315

Preflight source

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

Review metrics

Metric Value Why it matters
Shared-state compatibility Schema 39 → 40; two accepted predecessor layouts The migration preserves either valid layout, while older binaries refuse the resulting schema.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: A controlled reporter bisect and matching source establish blocked PostgreSQL dev-channel updates, including an affected production installation.
  • merge-risk: 🚨 compatibility: The schema bump changes older-reader admission and downgrade recovery on both SQLite and PostgreSQL, requiring the recorded owner decision.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-11T04:01:21.086Z sha 8a066e4 :: blocked before merge. :: [P1] Accept the valid PostgreSQL predecessor that already has the column | [P1] Include the new migration in the extracted PR wrapper inventory | [P2] Update the historical Doctor migration-report expectations
  • reviewed 2026-11-11T15:10:22.704Z sha 3619148 :: ready, awaiting a maintainer decision. :: none

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
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Nov 11, 2026
…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
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 11, 2026
…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.
@etzelm

etzelm commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@etzelm

etzelm commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
ceckert added a commit to ceckert/openclaw that referenced this pull request Nov 11, 2026
…_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]>
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 12, 2026
@etzelm

etzelm commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #197425, which fixes #196966 without a schema version bump. Since this PR, main took state v40 for another change, so this branch would need a renumber to land. #197425 avoids that.

@etzelm etzelm closed this Nov 13, 2026
@etzelm
etzelm deleted the fix/postgres-bootstrap-deferred-v40 branch November 13, 2026 14:30
VACInc added a commit that referenced this pull request Nov 18, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…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]>
RomneyDa pushed a commit that referenced this pull request Nov 19, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawtributors PR from a clawtributor commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PostgreSQL git update to main ≥ caa978ca (#196392) refused at database-engine-preflight: "schema drift detected against generated DDL"

2 participants