Skip to content

feat(database): keep PostgreSQL rollback captures in PostgreSQL - #196236

Merged
vincentkoc merged 16 commits into
openclaw:mainfrom
etzelm:feat/postgres-native-captures
Nov 13, 2026
Merged

vincentkoc merged 16 commits into
openclaw:mainfrom
etzelm:feat/postgres-native-captures

Conversation

@etzelm

@etzelm etzelm commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #196155, #196154, #196156, #196157

What Problem This Solves

Each PostgreSQL rollback capture taken by openclaw update and Doctor exports the whole store to a local database.sqlite, which costs minutes of downtime and local disk on the order of the store size per capture (285 MB for a 243 MB table, section 3).

Owner Decision Recorded

Maintainer acceptance recorded on 2026-11-13: after the recommended design and its durability and retention limits were presented, continuation was authorized. Proceed with the opt-in database.postgres.recoveryCaptures design and cleanup lifecycle below. This records acceptance required by docs/reference/database-schemas/storage-changes.md; normal authentication, required review and validation remain enforced.

Accepted scope:

  • Default stays "portable". Installs that do nothing keep today's captures.
  • With "server", the update rollback capture and Doctor's pre-migration capture of a non-state PostgreSQL store live in a restore_<uuid> schema on the same server. Losing the server loses those captures. openclaw backup create stays portable.
  • Cleanup: a verified update drops its capture schemas; Doctor drops a store's orphaned capture schemas before its next pre-migration capture of that store.
  • Exceptions that stay portable: the shared state family capture, the candidate state copy, and original state captures (see User Impact).

Original state captures remain a separate follow-up. This PR leaves them portable, because their retention belongs to update capture cleanup, and a server carrier there would need schema drops in that cleanup too. That would be a follow-up.

User Impact

Nothing changes unless the operator opts in. database.postgres.recoveryCaptures accepts "portable" (default, today's SQLite export) or "server".

With "server", the update rollback capture and Doctor's pre-migration capture of a PostgreSQL store copy the store into a frozen restore_<uuid> schema in the same database. That capture directory holds only anchor.sqlite and manifest.json (plus the existing .pending marker while the capture is being written).

  • Rollback restores from that schema into a fresh namespace. The rows never leave the server, and the capture schema stays for a repeated or manual recovery.
  • After a verified update, retirement drops the capture schemas before it removes the snapshot directory. If the drop fails, the directory stays and the update reports that cleanup is pending.
  • Doctor keeps its captures like today's .bak files. Before each new pre-migration capture of a store, Doctor drops that store's capture schemas whose .bak directory was removed. This runs whatever the setting is, so switching back to "portable" still cleans up.
  • A server capture uses space on the database server and does not survive loss of the server. openclaw backup create still writes portable images for off-server copies.
  • Existing portable captures stay readable and restorable under either value. Older releases reject the new key, so remove it before downgrading.
  • SQLite stores are unchanged.

Some captures still write the SQLite export with "server", on purpose:

  • the candidate state copy (the update rehearsal reads it) and the shared state family in the update rollback capture (client credential rollback reads it);
  • original state captures, the existing copy taken before an update or a standalone doctor --fix writes state. This PR does not change them. So an update with "server" writes one local export of each PostgreSQL store instead of two (measured below: 1 x 208,896 bytes instead of 2 x 208,896 bytes for a small Workboard store). The docs now say so.

Why This Change Was Made

Why opt-in: a server capture changes rollback durability. Keeping the portable export as the default leaves every existing contract unchanged for installs that do nothing.

Config surface: one core path, so docs/.generated/config-baseline.counts.json is main's count plus one (generated with pnpm config:docs:gen). It is an enum rather than a boolean, so a future carrier does not need a second key.

Restore already rebuilt a new namespace and repointed the anchor; the SQLite image was only the carrier between two PostgreSQL states. The port copy now has a same-server path. It creates the schema from the build's generated DDL and runs INSERT ... SELECT for each table inside one REPEATABLE READ transaction. It sets sequences from the captured allocations, then runs the existing catalog, identity and hash verification. The manifest hashes come from a separate read of the source rows in the same snapshot and must match the hashes of the copy. The manifest keeps today's fields and adds carrier: "postgres-schema" and the schema name.

Restore copies the frozen schema into a fresh namespace and checks it against the manifest hashes. The capture stays unchanged, so a failed or repeated rollback can start again from it.

Several installs can share one database, and restored live stores also use restore_ names. So Doctor never drops a restore_ schema by name alone. It drops a schema only if all of these hold:

  • the runtime role holds the schema owner's privileges (pg_has_role(nspowner, 'USAGE')); schemas of other roles are skipped before any of their tables are read;
  • it carries a capture comment naming its directory;
  • the directory is under this store's .pre-startup-migration- prefix and is gone;
  • the schema's store id matches the store.

inspectRestorableDatabaseFiles and readPostgresPortCapabilities move unchanged into their own modules so the two touched files stay under the max-lines cap.

Evidence

New since the last review: section 2, an upgrade from the latest stable release ([email protected] from npm) to this PR (9edd6cbabc1), with existing settings, data and portable captures, and the same runs on a base-main package for comparison. Section 1 ran on packages built from 680518deb7d; the PR's own changes are the same at the head (see section 1).

All runs: macOS arm64, Node 24, PostgreSQL 17.11 with pgvector, max_locks_per_transaction=512 and the three extensions from the CI conformance action. Each OpenClaw install is isolated (own HOME, npm prefix and TMPDIR). Output is redacted: <e2e> is the scratch root, <dsn> the connection string.

1. Real update failure and rollback, server captures (680518deb7d, PR source unchanged since)

Two packages built from 680518deb7d, the first merge of main (277e32c668a). Since then the branch gained a test-line allocation number, two docs paragraphs and four more merges of main (f7008994ce8, 577da8a944e, c324818cbf8, 88a0f3baca8). Those merges bring 1155 changed files under src extensions packages ui scripts, all from main. The capture, restore and update path is src/snapshot, src/infra/database-engine, src/infra/update-database-backup*.ts, src/infra/update-database-restore*.ts, src/infra/package-update-swap*.ts, src/infra/update-recovery-baseline-capture*.ts, src/cli/update-cli, src/commands/doctor-postgres-migration*.ts, src/flows/doctor-health*.ts and src/config/types.database.ts (779 files). git diff --shortstat 680518deb7d 9edd6cbabc1 limited to it is empty, so sections 1 and 2 ran on that path as it is at 9edd6cbabc1. The merge of c324818cbf8 changes 7 files there, all from main's #196873: a target disk-space check in src/cli/update-cli/update-command-target*.ts and update-command-git.ts, and update-snapshot-space-cleanup.ts, which offers openclaw update cleanup when space is short. That cleanup covers <state>.update-captures and session recovery copies, not the rollback snapshot that holds a server capture, and none of the 7 files is in this PR's diff. The merge of 88a0f3baca8 changes 4 files there, all from main's #197277 (the parent hands its engine classification to the backup worker). It conflicted with this PR in src/infra/update-database-backup.ts: this PR moves inspectRestorableDatabaseFiles unchanged to src/infra/update-database-backup-files.ts for the max-lines cap, and #197277 edited that function (a missing sidecar file goes through ignoreMissingPath). The merge keeps the move and carries the edit, so the moved function is byte-identical to main's. Apart from that carried edit, the PR's own source diff against main is unchanged: git diff 277e32c668a 680518deb7d over those five directories is 23 files, +859/-117, and git diff 88a0f3baca8 HEAD is 23 files, +857/-114; they differ only in those two files, by #197277's new text of the moved function.

  • 2026.11.8: the head as committed. It is the installed updater, so it takes the capture and runs the rollback.
  • 2026.11.9: the head plus one proof-only change, used only as the update candidate. At the start of its update Doctor it throws injected candidate update Doctor failure before migrations when a marker file exists in the real state dir. The test script creates the marker right before openclaw update, so the candidate rehearsal on its canary copy passes and the post-swap Doctor fails.

Setup on 2026.11.8: three Workboard cards, Workboard ported to PostgreSQL with openclaw database port, recoveryCaptures set to server, then one card moved to ready.

$ openclaw --version
OpenClaw 2026.11.8 (680518d)
$ openclaw config get database.postgres.recoveryCaptures
server
$ anchor (store id -> live namespace) before
e7d71760-ebd3-4b8a-addf-2409d11aa9fc -> openclaw_workboard_e7d71760ebd34b8a
$ openclaw update --tag ./openclaw-2026.11.9.tgz --yes --no-restart --json
UPDATE_RC=1
$ update result (--json)
status: error | reason: doctor-failed | rollbackOutcome: {"status":"succeeded","reason":"Previous package and configuration restored"}
- database snapshot exit 0 | Databases snapshotted at <e2e>/prefix/lib/node_modules/.openclaw.package-backup-29016-1794367417657.databases. ...
- package-swap exit 0
- openclaw doctor exit 1 | injected candidate update Doctor failure before migrations
- database rollback exit 0 | Restored pre-migration databases from <e2e>/prefix/lib/node_modules/.openclaw.package-backup-29016-1794367417657.databases. / Migrated database file retained for manual recovery: PostgreSQL namespace openclaw_workboard_e7d71760ebd34b8a / ...
- package-rollback exit 0
- gateway recovery verification exit 1
$ openclaw --version
OpenClaw 2026.11.8 (680518d)
$ files of the Workboard rollback capture seen while the update ran
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/.pending
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/anchor.sqlite
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/manifest.json
$ PostgreSQL statement log during the update (workboard_cards shown; 18 tables each way)
19:23:54.205 INSERT INTO "restore_ec1ea530c82a4d58b367e6131158c21d"."workboard_cards" (...) SELECT ... FROM "openclaw_workboard_e7d71760ebd34b8a"."workboard_cards"
19:25:14.627 INSERT INTO "restore_9d2eb53ddb914c6c85464da3c5c55813"."workboard_cards" (...) SELECT ... FROM "restore_ec1ea530c82a4d58b367e6131158c21d"."workboard_cards"
$ anchor (store id -> live namespace) after
e7d71760-ebd3-4b8a-addf-2409d11aa9fc -> restore_9d2eb53ddb914c6c85464da3c5c55813
$ psql: capture-related schemas after
openclaw_workboard_e7d71760ebd34b8a | (no marker)
restore_9d2eb53ddb914c6c85464da3c5c55813 | (no marker)
restore_ec1ea530c82a4d58b367e6131158c21d | {"openclawCapture":"<e2e>/prefix/lib/node_modules/.openclaw.package-backup-29016-1794367417657.databases/payl
$ psql: cards in restore_9d2eb53ddb914c6c85464da3c5c55813 (anchor-selected live store)
Card A | ready | high
Card B | todo | normal
Card C | todo | low
$ diff <before> <after>      # per-table row digests of every Workboard table
(identical: 18 Workboard tables)
$ diff <before> <retained capture restore_ec1ea530c82a4d58b367e6131158c21d>
(identical)
$ rollback capture manifest (retained)
{"carrier":"postgres-schema","schemaVersion":2,"snapshotId":"workboard.sqlite.postgres","createdAt":"2026-11-11T03:23:54.241Z","profile":"exact","exportSchemaVersion":4,"schema":"restore_ec1ea530c82a4d58b367e6131158c21d"}
$ retained rollback capture files (Workboard)
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/anchor.sqlite
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/manifest.json
$ openclaw workboard create "Card D"   # write after rollback
732fd44a  todo      normal  default  Card D

What this shows: the installed updater captured the store into restore_ec1e... on the server, the candidate failed, and the rollback copied that capture into a fresh namespace, repointed the anchor (same store id) and restored the previous package. The live rows match the rows before the update, the capture schema and its directory are retained unchanged, and the migrated namespace is kept for manual recovery as the existing rollback contract says. The fault fires before the candidate's migrations, so the live namespace was never changed and identical rows alone cannot tell a restore from a no-op. The evidence that the restore ran is the anchor repoint to restore_9d2e... and the 18 INSERT ... SELECT statements out of restore_ec1e... in the statement log. "gateway recovery verification exit 1" is expected with --no-restart and no managed service.

Allocations: the Workboard store has no sequences or identity columns (pg_sequences count 0, identity or serial columns 0), and its manifest records verification.allocations: {}. So this run does not exercise sequence restoration; the conformance tests in section 4 do.

Same failed update with recoveryCaptures unset (portable), for comparison: same steps and outcome (database rollback exit 0, rollbackOutcome succeeded, 18 tables identical), the rollback capture holds anchor.sqlite, database.sqlite and manifest.json, and its manifest has no carrier.

Retained local SQLite exports of the Workboard store after each failed update (under home and the npm prefix; the candidate state copy also writes a transient 208,896-byte copy into TMPDIR in both modes, see User Impact):

recoveryCaptures Rollback capture Original state capture Total retained local export bytes
unset (portable) 208,896 208,896 417,792
server none 208,896 208,896

A standalone openclaw doctor --fix afterwards (server mode, exit 0) added one more original state capture with a 208,896-byte export and left the update capture schema in place.

2. Upgrade from the latest stable release, 2026.11.3 (9edd6cbabc1, PR source unchanged since)

Three packages: this PR at 9edd6cbabc1 as 2026.11.8 and again as 2026.11.9 (unmodified), and base main 577da8a944e (its main parent) as 2026.11.8 for comparison. Each run starts from npm install -g [email protected], the current latest on npm, in a fresh install and database. On 2026.11.3: agents.defaults.timeoutSeconds set to 321, Workboard enabled, a second agent helper, three Workboard cards (one moved to ready), a verified portable backup (openclaw backup create --verify) and a standalone openclaw doctor --fix original state capture. For PostgreSQL, 2026.11.3 has only database.engine, set to postgres before the Workboard store exists. Row digests use 2026.11.3's column lists. Files for every run: r2-2026-11-11/upgrade-2026.11.3/ in the evidence upload (its README.md has the full table). Evidence: r2-2026-11-11/upgrade-2026.11.3/README.md.

PostgreSQL Workboard, upgraded with npm install -g and openclaw doctor --fix, then a real update with server captures:

$ openclaw --version
OpenClaw 2026.11.3 (847611d)
$ anchor (store id -> live namespace)
3076b856-294b-47c1-8645-c9ff783dcad0 -> openclaw_workboard_3076b856294b47c1
$ npm install -g ./openclaw-2026.11.8.tgz          # this PR at 9edd6cbabc1
rc=0
$ openclaw doctor --fix --non-interactive
DOCTOR_RC=0
[config] Preserving the 2026.11.1 Workboard-only PostgreSQL setting: Workboard remains on PostgreSQL; shared state and other families remain on SQLite. The next config write records this explicitly.
$ openclaw config get agents.defaults.timeoutSeconds
321
$ openclaw agents list --json (ids)
main, helper
$ anchor (store id -> live namespace)
3076b856-294b-47c1-8645-c9ff783dcad0 -> openclaw_workboard_3076b856294b47c1
$ diff <2026.11.3 rows> <rows after upgrade>       # per table
(identical: 18 Workboard tables)
$ openclaw workboard create "Card D"               # write after upgrade
35ca3799  todo      normal  default  Card D
$ openclaw doctor --non-interactive
DOCTOR_RC=0
$ 2026.11.3 original state capture files: sha256 before vs after upgrade
(stable files: 4, unchanged: 4)
$ openclaw backup verify <2026.11.3 archive>
rc=0
$ openclaw config set database.postgres.recoveryCaptures server
Updated database.postgres.recoveryCaptures. Restart the gateway to apply.
$ openclaw update --tag ./openclaw-2026.11.9.tgz --yes --no-restart --json
UPDATE_RC=0
status: ok | before: 2026.11.8 | after: 2026.11.9
$ files of the Workboard rollback capture seen while the update ran
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/.pending
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/anchor.sqlite
<rollback snapshot>/.../plugins/workboard/workboard.sqlite.postgres/manifest.json
$ PostgreSQL log during the update   # from server-ddl.txt (raw server log; lines cut at 170 characters)
08:19:03.117 CREATE SCHEMA "restore_080a68989e094a4e8ac0a575d50c8fc7"
08:19:03.129 INSERT INTO "restore_080a68989e094a4e8ac0a575d50c8fc7"."workboard_cards" (...)   # one per table, 18 in total
08:19:03.175 COMMENT ON SCHEMA "restore_080a68989e094a4e8ac0a575d50c8fc7" IS '{"openclawCapture":...
08:20:58.847 DROP SCHEMA IF EXISTS "restore_080a68989e094a4e8ac0a575d50c8fc7" CASCADE
$ diff <rows before> <rows after the update>
(identical: 18 Workboard tables)

The same npm install -g upgrade with the base-main package gives the same results (doctor 0, settings and agents kept, 18 tables identical, write ok, 4 of 4 capture files unchanged). Only base rejects recoveryCaptures, as expected.

openclaw backup verify of the 2026.11.3 archive also reports, on this PR and on base alike: "This legacy archive has no PostgreSQL capsule ownership inventory. Unlisted exports are preserved as files, not imported." Restoring it extracts the archive but does not rehydrate the PostgreSQL Workboard store. That is main's documented legacy-archive behavior (docs/cli/backup.md), not changed here. A backup taken after the upgrade is the supported recovery point.

Upgrades through the installed 2026.11.3 updater (openclaw update) fail on base main 577da8a944e exactly as on this PR at 9edd6cbabc1, so this PR does not cause them. Reported as #197320. These runs were not repeated at the later merges, which add main's #196873 and #197277 on the update path (section 1):

2026.11.3 Workboard This PR at 9edd6cbabc1 Base main 577da8a944e
PostgreSQL via database.engine candidate-snapshot-failed: "Existing SQLite state data cannot switch engines"; nothing changed identical
SQLite, then 2026.11.3 database port --to postgres identical to the row above identical
SQLite second Doctor: "Agent database migration did not finish: .../workboard.sqlite; expected schema 41, found 0"; rollback refused (state-migrated-no-rollback). Install left on 2026.11.8 with settings, agents and 18 Workboard tables intact, writes work, doctor exits 0, 8 of 8 capture files unchanged identical

The first row is the Workboard-only database.engine: "postgres" shape that main's config reads keep (src/config/legacy-workboard-database.ts, #194648, the warning above). The update's candidate state snapshot refuses it anyway. Both happen on base main too; this PR does not change the updater's snapshot or Doctor paths (section 1 lists the empty path-limited diff).

Earlier real updates and Doctor runs (previous head c6d3352, before merging main)

These ran on packages from 16fe8f9931e, whose production source equals c6d335261ed, before main was merged in. They were not re-run later; section 1 re-ran the capture and rollback path at 680518deb7d, and the conformance tests in section 4 ran at 5d86e0b0dc4.

Real updates from stable 2026.11.2 to the PR, then portable and server:

$ openclaw update --tag ./openclaw-2026.11.6.tgz --yes --no-restart     # from 2026.11.2
UPDATE_RC=0
$ openclaw workboard list
a8fdbc0f  todo      high    default  Card A
59e8adc9  todo      normal  default  Card B

# Update 2: recoveryCaptures unset (portable)
$ openclaw update --tag ./openclaw-2026.11.7.tgz --yes --no-restart
UPDATE_RC=0
<snapshot>/.../workboard.sqlite.postgres/anchor.sqlite
<snapshot>/.../workboard.sqlite.postgres/database.sqlite
<snapshot>/.../workboard.sqlite.postgres/manifest.json
$ PostgreSQL server log: DDL on restore_ schemas during the update
(none)

# Update 3: recoveryCaptures "server"
$ openclaw update --tag ./openclaw-2026.11.8.tgz --yes --no-restart
UPDATE_RC=0
<snapshot>/.../workboard.sqlite.postgres/anchor.sqlite
<snapshot>/.../workboard.sqlite.postgres/manifest.json
$ PostgreSQL server log: DDL on restore_ schemas during the update
18:41:36.253 CREATE SCHEMA "restore_d789490cb918479ab626fb6f72b03ba6"
18:44:08.568 DROP SCHEMA IF EXISTS "restore_d789490cb918479ab626fb6f72b03ba6" CASCADE
$ psql: capture-related schemas after
openclaw_workboard_16fc0d7f9bda4cb3 | (no marker)

Doctor (one synthetic step per pass: the live state store is rebuilt at v38 with v38's registered DDL, so Doctor has a real migration to run):

== D1: recoveryCaptures unset
...pre-startup-migration-5c188ce6...: anchor.sqlite database.sqlite manifest.json
== D2: recoveryCaptures "server"
...pre-startup-migration-b7c26493...: anchor.sqlite manifest.json
restore_9bea9f50... | {"openclawCapture":"<e2e>/home/.openclaw/state/openclaw.sqlite.pre-startup-migration-b7c26493...
== D3: server, after rm -r of the two D2 directories
restore_9bea9f50...: dropped
restore_49b32efe...: dropped
== D4: switched back to "portable", after rm -r of the two D3 directories
restore_711093f9...: dropped
restore_3f251d7f...: dropped

Data-model compatibility with stable 2026.11.2: stable data (config settings, agents, state database, backup archives) loads after a real openclaw update to the PR, Doctor exits 0, and both stable archives pass openclaw backup verify. A PostgreSQL Workboard store written by 2026.11.2 opens and takes writes on the PR build. This PR adds no schema migration; its only stored-format addition is the optional server capture manifest field, written only with "server".

Two update paths from stable 2026.11.2 fail on base main dfc053fd4c6 too, the same way on the base-main package and on this PR's package (stable with database.engine: postgres refuses at the candidate state snapshot; stable with a SQLite Workboard store fails in the in-update Doctor). They happen on base main too; this PR does not change them.

Regression test for the last review finding, red with database-backup-core.worker.ts from 150df84 and green at the fix:

 ×  ... > leaves another role's capture alone under the same directory prefix 30ms
   → permission denied for schema restore_1084bd9622f1493d9067491d637964c0
 ✓  ... > leaves another role's capture alone under the same directory prefix 29ms

3. Capture time and local disk

Measured earlier with the same carrier code: one synthetic store of 200,000 Workboard cards (a 243 MB table), client and server on one host, two runs each.

Carrier Capture time Local bytes written Files
Portable export 5.5 to 5.9 s 285,691,316 anchor.sqlite, database.sqlite, manifest.json
Server capture 4.3 to 4.5 s 11,650 anchor.sqlite, manifest.json

These numbers are for the rollback capture alone and come from one host. They say nothing about a remote database server or real store shapes, and the original state capture of an update still writes its own portable export (section 1).

4. Tests and checks

Current maintainer correction candidate: 4357834c4924656b716fbcaf7a6672a91944846f (signed descendant of 072dc4ff98d74a518039c1703692abea125c632d). Capture cleanup metadata now commits atomically with the schema copy. PostgreSQL schema comments carry only an opaque trusted-prefix identity and generated capture UUID; they disclose no local custody path. Doctor reconstructs cleanup paths under its trusted local prefix while preserving role, store identity, foreign-prefix and retained-directory checks. Generic update captures retain manifest-owned retirement.

Focused real PostgreSQL 17.11 proof: all eight backup-schema-capture.test.ts cases pass, including before/after-COMMIT process termination, cross-role comment visibility, Doctor pruning/retention, portable defaults and mixed state/agent capture callbacks. The unchanged prior implementation fails the added privacy assertion because another unprivileged role can read the local capture path. The earlier post-COMMIT negative control failed on the missing cleanup marker. Runtime fsync and synchronous_commit were enabled; these are client-crash observations, not server-loss durability proof. Targeted lint, formatting and diff checks pass; independent full-feature plus correction review and autoreview report no remaining actionable findings. Exact final test allocation is 703 net lines (469 original +177 atomicity/crash proof +57 privacy proof), with no spare allowance. Correction production delta is +23 net lines versus the original incoming head, justified by transactional cleanup ownership and the cross-role privacy boundary. The signed candidate is published at that exact head; required hosted CI/security/reviews remain pending. No deployment or live operator-state claim.

The preceding contributor package/upgrade observations and the older runs below remain historical evidence at their named revisions.

At the head 5d86e0b0dc4 (merge of main 88a0f3baca8; conflict in src/infra/update-database-backup.ts resolved as described in section 1; no generated file changed): pnpm config:docs:check OK; pnpm check:baseline-ratchets --base 88a0f3baca8 --no-merge-base all 9 ok (Test lines OK: 6664606; ceiling: 6664614; slack: 8.); update-database-backup.test.ts (with #197277's new test), -engine, -space and .sqlite-source: 4 files, 74 passed; config.test.ts and update-command-database-retention.test.ts: 29 passed; PostgreSQL conformance, the same three batches: 94 passed, 2 skipped; pnpm check:changed --base 88a0f3baca8 (local): exit 0, including typecheck core and core tests, lint core and scripts, format changed files, config docs baseline, core tsgo graph boundary, and the dead export scan (0 entries).

At 68441c1c157 (merge of main c324818cbf8; it regenerated only docs/.generated/config-baseline.counts.json and .sha256, core 2645 -> 2646): pnpm config:docs:check OK, and pnpm check:test-lines-ratchet --base c324818cbf8 --no-merge-base: Test lines OK: 6664332; ceiling: 6664338; slack: 6. The PR's own diff against main, excluding docs/.generated, has the same git patch-id as at 9edd6cbabc1 (27 files, +911/-119; 29 files, +914/-122 with the two regenerated baselines).

At 9edd6cbabc1 (merge of main 577da8a944e; it only regenerated docs/.generated/config-baseline.sha256): pnpm config:docs:check OK, and pnpm check:test-lines-ratchet --base 577da8a944e --no-merge-base: Test lines OK: 6652683; ceiling: 6652693; slack: 10.

At 2278b2ed4b2 (merge of main f7008994ce8; the PR's own diff is the same as at the head):

  • PostgreSQL conformance, 11 files in three batches, 94 passed and 2 skipped:
    • batch a (backup-schema-capture, client-credential-update, backup, update-cohort-restore, archive-restore, port-provider): 6 files, 36 passed, 2 skipped
    • batch b (doctor-migration.postgres): 1 file, 26 passed
    • batch c (agent-port.postgres, port-command.postgres, update-preflight.conformance, openclaw-state-db.postgres): 4 files, 32 passed
  • Unit: config.test.ts and update-command-database-retention.test.ts, 29 passed.
  • pnpm config:docs:check: OK. pnpm config:schema:check: ok.
  • pnpm check:baseline-ratchets --base f7008994ce8 --no-merge-base: all ok, including test-lines (Test lines OK: 6650121; ceiling: 6650131; slack: 10.). The allocation config/test-lines-allocations/196155-postgres-schema-captures.txt stays 469.
  • Why the allocation: the PR adds 469 net test lines and no test-support or helper files. backup-schema-capture.test.ts +436: six PostgreSQL tests (update capture in a frozen schema that rollback copies and retirement drops; schema dropped when a capture fails after creating it; Doctor drops only its own capture schemas whose directory was removed; Doctor captures stay portable unless "server"; another role's capture is left alone; an agent store captured in a schema while state stays on SQLite). update-command-database-retention.test.ts +20 net: capture schemas are dropped only where snapshots retire, and a failed drop keeps the manifests and reports the pending cleanup. config.test.ts +13: rollback captures stay portable unless "server" is chosen. port-command.postgres.test.ts 0 net (one line changed). The record covers exactly that delta, with no headroom; the shared scalar is unchanged.
  • Wall times at 9edd6cbabc1, one file per run on the macOS arm64 host above (cold transform cache, so most of each run is transform; CI seconds not available yet):
    • pnpm test <file> --maxWorkers=1: backup-schema-capture.test.ts 38.8 s (6 skipped: no connection), update-command-database-retention.test.ts 14.0 s (15 passed), config.test.ts 7.3 s (14 passed), port-command.postgres.test.ts 6.6 s (4 passed, 1 skipped).
    • Through the PostgreSQL conformance runner (node scripts/test-database-conformance.mjs --engine postgres --connection <dsn> -- <file>): backup-schema-capture.test.ts 45.2 s (6 passed; the six tests take 0.04 to 2.2 s each, 6.7 s together), port-command.postgres.test.ts 37.9 s (5 passed).
  • CI at 9edd6cbabc1: checks-ui-e2e (1/2) failed in activity-denial-refresh.real-gateway.e2e.test.ts:33, which this PR does not touch. Main hit the same failure (run 42965770035, job 130343116189, at main parent 0d0ab362b22) and retired that test in fix: retire obsolete Activity privacy-denial test #197058 (d04c6ab44ad). The head 68441c1c157 merges main c324818cbf8, which contains fix: retire obsolete Activity privacy-denial test #197058, so the file is gone.
  • pnpm check:changed --base f7008994ce8 (local): 37 gates ok, including typecheck core, typecheck core tests, lint core, lint scripts, format changed files, config docs baseline and core tsgo graph boundary. The dead export scan fails on 18 files this PR does not touch; pnpm deadcode:exports on plain f7008994ce8 lists the same 18 files.
  • At b7842b029bc (before this merge, same docs and allocation): pnpm docs:check-mdx, pnpm docs:check-links, oxfmt --check on the changed docs, clean. git diff --check f7008994ce8...HEAD at the head: clean.

Follow-ups, not in this PR:

  • Original state captures stay portable with "server" (see the owner decision above).
  • Doctor drops orphaned captures only when it takes a new pre-migration capture of the same store. An orphan whose store never migrates again stays until then.
  • If someone deletes a retained update capture directory by hand, its schema stays on the server.
  • The capture comment is written right after the copy commits. A process crash between the two leaves an unmarked restore_ schema that pruning will not find. Errors in that window are handled: the capture's catch drops the schema.
  • Pruning reads openclaw_schema_meta from each marked schema the role owns. A marked schema without that table would fail the prune and stop Doctor. Capture writes the mark only after the copy has created that table, so only hand-edited schemas would hit this.

Not run: the full sharded PostgreSQL conformance suite, PostgreSQL 16 and 18, Linux and Windows, an update with a managed Gateway service running, and a rollback of a store that has sequences through openclaw update (covered by the conformance tests).

- Exact update rollback and Doctor pre-migration captures copy the store into a frozen restore_<uuid> schema on the same server
- The copy runs in one REPEATABLE READ transaction: generated DDL, INSERT ... SELECT per table, sequences from captured allocations
- Manifest hashes come from a separate source read in the same snapshot and are checked against the copy
- The manifest keeps today's fields and adds carrier "postgres-schema" plus the schema name; only anchor.sqlite and manifest.json are written locally
- Restore copies the frozen schema into a fresh namespace and checks the manifest hashes, so the capture survives a failed or repeated rollback
- Verified update retirement drops capture schemas through the restore namespace guard before removing the snapshot directory
- Capture schemas carry a comment naming their directory; before each pre-migration capture, Doctor drops this store's captures whose directory was removed
- The portable SQLite export stays the default for archives, ports, repairs and the candidate state copy; the shared state family keeps it for client credential rollback
- inspectRestorableDatabaseFiles and readPostgresPortCapabilities move unchanged to their own modules to stay under the line cap
@clawsweeper

clawsweeper Bot commented Nov 9, 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 cli CLI command changes commands Command implementations size: L labels Nov 9, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Adds opt-in PostgreSQL schema copies for recovery captures, with verified restore and lifecycle cleanup.

Example: Update a PostgreSQL Workboard store with database.postgres.recoveryCaptures set to server.

  • Before: The rollback capture writes anchor.sqlite, database.sqlite, and manifest.json locally.
  • After: The rollback capture keeps rows in a restore_<uuid> schema and writes only anchor.sqlite and manifest.json locally.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong behavior and upgrade evidence support a clean patch; overall scope remains an accepted partial implementation of the broader linked request.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Packaged CLI traces exercise server capture, injected update failure, fresh-namespace rollback, successful retirement, and stable upgrade on isolated PostgreSQL 17.11; focused real-client crash and cross-role evidence covers the subsequent correction, whose production and test blobs are unchanged at this head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Partial
User problem: PostgreSQL updates and migrations write large local SQLite recovery images and spend downtime exporting them.
Reason: A maintainer confirmed the opt-in design and its durability and retention limits; Related wording correctly leaves the broader capture request open.

Merge readiness

✅ Ready for maintainer review

This PR implements an accepted, useful improvement with no remaining actionable findings. The previous conflict is resolved; required checks for the exact head are still running.

Priority: P2
Reviewed head: 3708ddac55bc4d87d8fd67b0a7bff8c9373a6c59

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update and Doctor call the existing backup worker and database materializer to capture selected PostgreSQL stores, restore verified rows into fresh namespaces, and retire captures through their owning lifecycle.

flowchart TD
  A[Update or Doctor] --> B[Backup worker]
  B --> C[Database materializer]
  C --> D[PostgreSQL capture schema]
  B --> E[Local anchor and manifest]
  D --> F[Verified restore namespace]
  E --> F
  A --> G[Capture retirement]
Loading

Technical review

Best possible solution:

Land the accepted opt-in carrier through the existing materializer and cleanup owners while retaining the documented portable exceptions.

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

Current-main export code materializes PostgreSQL recovery rows into database.sqlite, matching the reported local-storage cost; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The change reuses the existing materializer, descriptor verification, restore owner, and retirement lifecycles; the added carrier and cleanup state are necessary for the accepted scope.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Portable PostgreSQL recovery captures keeps the original intent (d0ea7ea: Preserve PostgreSQL rows and matching anchors during backups and update rollback.)
  • Database materialization and verification keeps the original intent (cd32ddc: Provide verified offline copies preserving canonical cells, identities, and allocation facts.)
  • Exact PostgreSQL migration rollback keeps the original intent (407c309: Restore captured schema versions and exact rows while preserving custody and independent-write refusal.)
  • Verified update capture retirement keeps the original intent (b9c8a1d: Remove obsolete snapshots after verified activation while retaining recovery evidence after refusal or failure.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Exact-head integration: Among the introduced files, comparison with the previous reviewed head changes only the two generated config baselines; capture production and test blobs are unchanged. Public docs: docs/.generated/config-baseline.counts.json. (docs/.generated/config-baseline.counts.json:2, 3708ddac55bc)
  • Accepted product direction: vincentkoc confirms acceptance of opt-in server captures, portable defaults, and explicit same-server durability and retention limits: feat(database): keep PostgreSQL rollback captures in PostgreSQL #196236 (comment). (3708ddac55bc)
  • Capture integrity and privacy: Capture metadata is added through the existing post-data renderer inside the copy transaction; globally readable schema comments contain a prefix hash and generated UUID rather than a local path. (src/snapshot/database-backup-core.worker.ts:166, 3708ddac55bc)
  • Shared verification owner: Same-server copying uses the existing materializer, independently hashes source rows, restores allocations, and compares destination verification before commit. (src/infra/database-engine/port.worker.ts:654, 3708ddac55bc)
  • Real rollback and retirement evidence: The full PR body supplies isolated packaged CLI traces on macOS arm64, Node 24, and PostgreSQL 17.11: an injected candidate Doctor failure restores into a fresh namespace with matching Workboard rows; a successful update drops its capture schema. (3708ddac55bc)
  • Stable upgrade compatibility: The linked upgrade artifact records installation from 2026.11.3 followed by Doctor, preserved timeout 321, both agents, matching rows across 18 Workboard tables, successful writes, and unchanged historical capture files; installed-updater failures are reproduced on base as well. (9edd6cbabc1a)

Likely related people:

  • Peter Steinberger: Raw commit d6f6f76 adds src/snapshot/database-backup-core.worker.ts:60 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d6f6f76abbe0; files: src/snapshot/database-backup-core.worker.ts)
  • Mitchell Etzel: Raw commit f7b61f0 adds src/snapshot/database-backup-core.worker.ts:65 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f7b61f049a5c; files: src/snapshot/database-backup-core.worker.ts)

PR surface

Source +297, Tests +703, Docs +48, Generated 0, Other +2. Total +1050 across 30 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 19 408 111 +297
Tests 5 707 4 +703
Docs 3 50 2 +48
Config 0 0 0 0
Generated 2 3 3 0
Other 1 2 0 +2
Total 30 1170 120 +1050

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
New configuration surface 1 optional enum database.postgres.recoveryCaptures accepts portable or server; omission preserves portable captures, and older releases reject the new key.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Reduces local recovery-capture storage and export work for PostgreSQL operators without changing existing defaults.
  • merge-risk: 🚨 compatibility: Adds an opt-in persisted capture carrier and configuration key with different downgrade and server-loss behavior; the maintainer explicitly accepted these limits, and upgrade evidence preserves existing state.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • 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 (7 earlier review cycles)
  • reviewed 2026-11-09T20:43:34.077Z sha 6323aee :: needs real behavior proof before merge. :: [P2] Give the pruning worker implementation a distinct exported name | [P2] Document the server-dependent recovery capture format
  • reviewed 2026-11-10T00:32:32.385Z sha 150df84 :: needs real behavior proof before merge. :: [P2] Exclude other roles' schemas before reading capture metadata
  • reviewed 2026-11-10T04:40:21.287Z sha c6d3352 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-11T06:01:50.937Z sha 9edd6cb :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-11T17:08:41.091Z sha 68441c1 :: blocked before merge. :: none
  • reviewed 2026-11-11T21:04:49.995Z sha 390dce5 :: blocked before merge. :: none
  • reviewed 2026-11-13T08:26:14.423Z sha 4357834 :: needs changes before merge. :: none

Reviewed November 13, 2026, 4:06 AM ET / 09:06 UTC (Revision 8).

- Doctor's PostgreSQL capture no longer writes database.sqlite; the client credential Doctor test reads the captured token from the capture schema and drops it on cleanup
- Rename the worker-side prune to pruneOrphanedPostgresCaptures so prunePostgresSchemaCaptures has one exported spelling (export-name-collisions)
- Set the test-lines allocation to the CI-counted net delta (384)
- Add database.postgres.recoveryCaptures ("portable" default, "server")
- Update and Doctor captures use restore_<uuid> schemas only when "server"
- Doctor still prunes orphaned capture schemas regardless of the setting
- Shared state family and candidate state copy stay portable
- Document the server carrier trade-offs in database-engines.md
- Raise core config baseline 2638 -> 2639 for the new setting
- Raise test-lines allocation 384 -> 421 for the opt-in tests
@etzelm

etzelm commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 10, 2026
- Restrict Doctor capture pruning to schemas the runtime role can use (pg_has_role USAGE)
- Another role's marked restore_ schema under the same path no longer fails Doctor
- Test two isolated roles with one directory prefix; fails without the fix
- Raise test-lines allocation 421 -> 466 for the new test
@etzelm

etzelm commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Nov 10, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Nov 10, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Nov 10, 2026
- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2641 -> 2642).
@vincentkoc vincentkoc self-assigned this Nov 12, 2026
Write the cleanup marker through the existing post-data renderer so it commits with the copied schema. Preserve owner-specific DDL and keep ordinary restores unmarked.

Release note: keep PostgreSQL recovery captures discoverable after a client interruption at COMMIT.

Validation: the unchanged parent loses its marker after a real client SIGKILL; the fixed PostgreSQL 17.11 capture module passes all eight cases. Targeted lint, formatting, and independent P0-P2 correction review pass. Missing public.unaccent was reproduced on the parent and corrected through documented test-server initialization.
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please review exact signed head 4357834c4924656b716fbcaf7a6672a91944846f. The existing decision section records acceptance of opt-in server recovery captures with portable defaults and explicit same-server durability/retention limits. The correction publishes cleanup identity in the copy transaction and keeps local custody paths out of globally readable schema comments. The Evidence section records client-crash and unprivileged-role red/green proof, all eight focused PostgreSQL cases passing, and the unchanged limits.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 13, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

Please review exact head 3708ddac55bc4d87d8fd67b0a7bff8c9373a6c59. Native baseline integration resolves the generated-file conflict; the final canonical generator/check passed. All previously reviewed capture production and test blobs are unchanged. Independent final integration review is clean. Required exact-head CI remains enforced before landing.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 13, 2026
@vincentkoc
vincentkoc merged commit 2ff4256 into openclaw:main Nov 13, 2026
127 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

@etzelm
etzelm deleted the feat/postgres-native-captures branch November 13, 2026 14:47
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…claw#196236)

* feat(database): keep PostgreSQL rollback captures in PostgreSQL

- Exact update rollback and Doctor pre-migration captures copy the store into a frozen restore_<uuid> schema on the same server
- The copy runs in one REPEATABLE READ transaction: generated DDL, INSERT ... SELECT per table, sequences from captured allocations
- Manifest hashes come from a separate source read in the same snapshot and are checked against the copy
- The manifest keeps today's fields and adds carrier "postgres-schema" plus the schema name; only anchor.sqlite and manifest.json are written locally
- Restore copies the frozen schema into a fresh namespace and checks the manifest hashes, so the capture survives a failed or repeated rollback
- Verified update retirement drops capture schemas through the restore namespace guard before removing the snapshot directory
- Capture schemas carry a comment naming their directory; before each pre-migration capture, Doctor drops this store's captures whose directory was removed
- The portable SQLite export stays the default for archives, ports, repairs and the candidate state copy; the shared state family keeps it for client credential rollback
- inspectRestorableDatabaseFiles and readPostgresPortCapabilities move unchanged to their own modules to stay under the line cap

* fix(database): resolve CI failures for PostgreSQL schema captures

- Doctor's PostgreSQL capture no longer writes database.sqlite; the client credential Doctor test reads the captured token from the capture schema and drops it on cleanup
- Rename the worker-side prune to pruneOrphanedPostgresCaptures so prunePostgresSchemaCaptures has one exported spelling (export-name-collisions)
- Set the test-lines allocation to the CI-counted net delta (384)

* feat(database): make PostgreSQL server recovery captures opt-in

- Add database.postgres.recoveryCaptures ("portable" default, "server")
- Update and Doctor captures use restore_<uuid> schemas only when "server"
- Doctor still prunes orphaned capture schemas regardless of the setting
- Shared state family and candidate state copy stay portable
- Document the server carrier trade-offs in database-engines.md
- Raise core config baseline 2638 -> 2639 for the new setting
- Raise test-lines allocation 384 -> 421 for the opt-in tests

* fix(database): prune only capture schemas this role can drop

- Restrict Doctor capture pruning to schemas the runtime role can use (pg_has_role USAGE)
- Another role's marked restore_ schema under the same path no longer fails Doctor
- Test two isolated roles with one directory prefix; fails without the fix
- Raise test-lines allocation 421 -> 466 for the new test

* Merge origin/main into feat/postgres-native-captures

- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2641 -> 2642).

* test(database): raise schema capture test-line allocation to 469

- Net test lines of this change against current main are +469 (was 466 against the old base).

* docs(database): note original state captures stay portable

- Server recovery captures cover update rollback and Doctor pre-migration captures only.

- Original state captures before an update or standalone doctor --fix still write SQLite images of PostgreSQL stores.

* Merge origin/main into feat/postgres-native-captures

- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2645 -> 2646).

* Merge origin/main into feat/postgres-native-captures

- Resolve docs/.generated/config-baseline.sha256 by regenerating with pnpm config:docs:gen (counts unchanged, core 2646).

* Merge origin/main into feat/postgres-native-captures

- Bring in openclaw#197058, which retires the ui-e2e scenario failing on main.
- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2645 -> 2646).

* Merge origin/main into feat/postgres-native-captures

- Resolve src/infra/update-database-backup.ts: keep inspectRestorableDatabaseFiles in update-database-backup-files.ts (moved by this PR for the max-lines cap) and carry main openclaw#197277 sidecar lstat change into it; keep main engine-reuse changes.

* Merge origin/main into feat/postgres-native-captures

- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2647 -> 2648).

* fix(database): commit recovery capture metadata atomically

Write the cleanup marker through the existing post-data renderer so it commits with the copied schema. Preserve owner-specific DDL and keep ordinary restores unmarked.

Release note: keep PostgreSQL recovery captures discoverable after a client interruption at COMMIT.

Validation: the unchanged parent loses its marker after a real client SIGKILL; the fixed PostgreSQL 17.11 capture module passes all eight cases. Targeted lint, formatting, and independent P0-P2 correction review pass. Missing public.unaccent was reproduced on the parent and corrected through documented test-server initialization.

* fix(snapshot): keep capture custody paths private

* fix: refresh the reviewed correction baseline

Baseline-Refresh: 5211f64faa02cea25424c18dc6bcc3512926c76f

* fix(config): regenerate capture recovery baseline

Co-authored-by: Mitchell Etzel <[email protected]>
Co-authored-by: Mitchell Etzel <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…law#194384)

* docs: clarify PostgreSQL conformance coverage

* fix(cron): keep one-shot finalization working on PostgreSQL 16

* test(database): reuse cron conformance for JSON conversion regression

* test(postgres): accept fractional explain row counts

(cherry picked from commit 7ab0143)

Release adaptation: Only engine-owned jsonValue and retained cron enabled JSON replacement; preserve native boolean type with PG16 explicit ::json and SQLite json(). Omit unrelated PG docs/EXPLAIN test edits; retained one-shot enabled-transition caller present on baseline.

Follow-up dispositions: e029e18 docs: document isolated PostgreSQL restore drills (openclaw#202704); 49f0740 fix(database): report disabled memory after a port (openclaw#202630); a80b564 fix: keep database workers healthy after silent connection loss (openclaw#201856); 3d91af2 fix(config): reject reserved PostgreSQL schema prefixes (openclaw#202097); 835d722 fix: catch incompatible ownership before porting to SQLite (openclaw#202101); 67796a6 fix: keep scheduled Git backups current on PostgreSQL (openclaw#201870); cc849dd fix: recover lease heartbeats after a PostgreSQL connection loss (openclaw#201858); 6594caf fix: prepare macOS runtime pins without the PostgreSQL secret (openclaw#202102); 6ca56cd docs: clarify PostgreSQL storage and backup coverage (openclaw#202086); a079190 fix(postgres): chat history slows under concurrent reads (openclaw#190129); 2ff4256 feat(database): keep PostgreSQL rollback captures in PostgreSQL (openclaw#196236); 96c685b feat(backup): restore PostgreSQL stores into a staging database for restore drills (openclaw#194808); fb83d65 fix: reduce transcript allocation when preparing native context seeds; 71ec4d2 fix(config): keep Workboard PostgreSQL upgrades readable (openclaw#194648); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682)

Validation: Baseline cron generated json(bound text) on PostgreSQL where json(text) is unavailable; helper and focused boolean regression retained. Exact PostgreSQL16 server proof unavailable; focused SQLite/helper tests queued. diff check passed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 38fdd9b52704d588d9ca24ef8e391d644961c985)
(cherry picked from commit fb935e6912388314851b05cb698ef038b83bbd07)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants