Repository navigation
feat(database): keep PostgreSQL rollback captures in PostgreSQL - #196236
Conversation
- 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
|
🦞👀 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: needs maintainer review before merge. What this changesAdds 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.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Partial 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherUpdate 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +297, Tests +703, Docs +48, Generated 0, Other +2. Total +1050 across 30 files. Added test files: 2. 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:
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 (7 earlier review cycles)
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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
- 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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
- Resolve docs/.generated/config-baseline.{counts.json,sha256} by regenerating with pnpm config:docs:gen (core 2641 -> 2642).
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.
|
@clawsweeper re-review Please review exact signed head |
|
🦞👀 Re-review progress:
|
Baseline-Refresh: 5211f64faa02cea25424c18dc6bcc3512926c76f
|
@clawsweeper re-review Please review exact head |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…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]>
…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)
Related: #196155, #196154, #196156, #196157
What Problem This Solves
Each PostgreSQL rollback capture taken by
openclaw updateand Doctor exports the whole store to a localdatabase.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.recoveryCapturesdesign and cleanup lifecycle below. This records acceptance required bydocs/reference/database-schemas/storage-changes.md; normal authentication, required review and validation remain enforced.Accepted scope:
"portable". Installs that do nothing keep today's captures."server", the update rollback capture and Doctor's pre-migration capture of a non-state PostgreSQL store live in arestore_<uuid>schema on the same server. Losing the server loses those captures.openclaw backup createstays portable.statefamily 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.recoveryCapturesaccepts"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 frozenrestore_<uuid>schema in the same database. That capture directory holds onlyanchor.sqliteandmanifest.json(plus the existing.pendingmarker while the capture is being written)..bakfiles. Before each new pre-migration capture of a store, Doctor drops that store's capture schemas whose.bakdirectory was removed. This runs whatever the setting is, so switching back to"portable"still cleans up.openclaw backup createstill writes portable images for off-server copies.Some captures still write the SQLite export with
"server", on purpose:statefamily in the update rollback capture (client credential rollback reads it);doctor --fixwrites 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.jsonis main's count plus one (generated withpnpm 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 ... SELECTfor each table inside oneREPEATABLE READtransaction. 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 addscarrier: "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 arestore_schema by name alone. It drops a schema only if all of these hold:pg_has_role(nspowner, 'USAGE')); schemas of other roles are skipped before any of their tables are read;.pre-startup-migration-prefix and is gone;inspectRestorableDatabaseFilesandreadPostgresPortCapabilitiesmove 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 from680518deb7d; 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=512and 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 undersrc extensions packages ui scripts, all from main. The capture, restore and update path issrc/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*.tsandsrc/config/types.database.ts(779 files).git diff --shortstat 680518deb7d 9edd6cbabc1limited to it is empty, so sections 1 and 2 ran on that path as it is at9edd6cbabc1. The merge ofc324818cbf8changes 7 files there, all from main's #196873: a target disk-space check insrc/cli/update-cli/update-command-target*.tsandupdate-command-git.ts, andupdate-snapshot-space-cleanup.ts, which offersopenclaw update cleanupwhen space is short. That cleanup covers<state>.update-capturesand 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 of88a0f3baca8changes 4 files there, all from main's #197277 (the parent hands its engine classification to the backup worker). It conflicted with this PR insrc/infra/update-database-backup.ts: this PR movesinspectRestorableDatabaseFilesunchanged tosrc/infra/update-database-backup-files.tsfor the max-lines cap, and #197277 edited that function (a missing sidecar file goes throughignoreMissingPath). 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 680518deb7dover those five directories is 23 files, +859/-117, andgit diff 88a0f3baca8 HEADis 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 throwsinjected candidate update Doctor failure before migrationswhen a marker file exists in the real state dir. The test script creates the marker right beforeopenclaw 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,recoveryCapturesset toserver, then one card moved toready.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 torestore_9d2e...and the 18INSERT ... SELECTstatements out ofrestore_ec1e...in the statement log. "gateway recovery verification exit 1" is expected with--no-restartand no managed service.Allocations: the Workboard store has no sequences or identity columns (
pg_sequencescount 0, identity or serial columns 0), and its manifest recordsverification.allocations: {}. So this run does not exercise sequence restoration; the conformance tests in section 4 do.Same failed update with
recoveryCapturesunset (portable), for comparison: same steps and outcome (database rollback exit 0,rollbackOutcomesucceeded, 18 tables identical), the rollback capture holdsanchor.sqlite,database.sqliteandmanifest.json, and its manifest has nocarrier.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):
recoveryCapturesserverA standalone
openclaw doctor --fixafterwards (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
9edd6cbabc1as2026.11.8and again as2026.11.9(unmodified), and base main577da8a944e(its main parent) as2026.11.8for comparison. Each run starts fromnpm install -g [email protected], the currentlateston npm, in a fresh install and database. On 2026.11.3:agents.defaults.timeoutSecondsset to 321, Workboard enabled, a second agenthelper, three Workboard cards (one moved to ready), a verified portable backup (openclaw backup create --verify) and a standaloneopenclaw doctor --fixoriginal state capture. For PostgreSQL, 2026.11.3 has onlydatabase.engine, set topostgresbefore 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 -gandopenclaw doctor --fix, then a real update with server captures:The same
npm install -gupgrade 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 rejectsrecoveryCaptures, as expected.openclaw backup verifyof 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 main577da8a944eexactly as on this PR at9edd6cbabc1, 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):9edd6cbabc1577da8a944edatabase.enginecandidate-snapshot-failed: "Existing SQLite state data cannot switch engines"; nothing changeddatabase port --to postgresstate-migrated-no-rollback). Install left on 2026.11.8 with settings, agents and 18 Workboard tables intact, writes work,doctorexits 0, 8 of 8 capture files unchangedThe 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 equalsc6d335261ed, before main was merged in. They were not re-run later; section 1 re-ran the capture and rollback path at680518deb7d, and the conformance tests in section 4 ran at5d86e0b0dc4.Real updates from stable 2026.11.2 to the PR, then portable and server:
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):
Data-model compatibility with stable 2026.11.2: stable data (config settings, agents, state database, backup archives) loads after a real
openclaw updateto the PR, Doctor exits 0, and both stable archives passopenclaw 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
dfc053fd4c6too, the same way on the base-main package and on this PR's package (stable withdatabase.engine: postgresrefuses 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.tsfrom 150df84 and green at the fix: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.
anchor.sqlite,database.sqlite,manifest.jsonanchor.sqlite,manifest.jsonThese 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 of072dc4ff98d74a518039c1703692abea125c632d). 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.tscases 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. Runtimefsyncandsynchronous_commitwere 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 main88a0f3baca8; conflict insrc/infra/update-database-backup.tsresolved as described in section 1; no generated file changed):pnpm config:docs:checkOK;pnpm check:baseline-ratchets --base 88a0f3baca8 --no-merge-baseall 9 ok (Test lines OK: 6664606; ceiling: 6664614; slack: 8.);update-database-backup.test.ts(with #197277's new test),-engine,-spaceand.sqlite-source: 4 files, 74 passed;config.test.tsandupdate-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 mainc324818cbf8; it regenerated onlydocs/.generated/config-baseline.counts.jsonand.sha256, core 2645 -> 2646):pnpm config:docs:checkOK, andpnpm check:test-lines-ratchet --base c324818cbf8 --no-merge-base:Test lines OK: 6664332; ceiling: 6664338; slack: 6.The PR's own diff against main, excludingdocs/.generated, has the samegit patch-idas at9edd6cbabc1(27 files, +911/-119; 29 files, +914/-122 with the two regenerated baselines).At
9edd6cbabc1(merge of main577da8a944e; it only regenerateddocs/.generated/config-baseline.sha256):pnpm config:docs:checkOK, andpnpm check:test-lines-ratchet --base 577da8a944e --no-merge-base:Test lines OK: 6652683; ceiling: 6652693; slack: 10.At
2278b2ed4b2(merge of mainf7008994ce8; the PR's own diff is the same as at the head):config.test.tsandupdate-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 allocationconfig/test-lines-allocations/196155-postgres-schema-captures.txtstays 469.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.ts0 net (one line changed). The record covers exactly that delta, with no headroom; the shared scalar is unchanged.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.ts38.8 s (6 skipped: no connection),update-command-database-retention.test.ts14.0 s (15 passed),config.test.ts7.3 s (14 passed),port-command.postgres.test.ts6.6 s (4 passed, 1 skipped).node scripts/test-database-conformance.mjs --engine postgres --connection <dsn> -- <file>):backup-schema-capture.test.ts45.2 s (6 passed; the six tests take 0.04 to 2.2 s each, 6.7 s together),port-command.postgres.test.ts37.9 s (5 passed).9edd6cbabc1:checks-ui-e2e (1/2)failed inactivity-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 parent0d0ab362b22) and retired that test in fix: retire obsolete Activity privacy-denial test #197058 (d04c6ab44ad). The head68441c1c157merges mainc324818cbf8, 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:exportson plainf7008994ce8lists the same 18 files.b7842b029bc(before this merge, same docs and allocation):pnpm docs:check-mdx,pnpm docs:check-links,oxfmt --checkon the changed docs, clean.git diff --check f7008994ce8...HEADat the head: clean.Follow-ups, not in this PR:
"server"(see the owner decision above).restore_schema that pruning will not find. Errors in that window are handled: the capture'scatchdrops the schema.openclaw_schema_metafrom 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).