Skip to content

fix(backup): restore every PostgreSQL store from archives and Git - #174744

Merged
steipete merged 12 commits into
mainfrom
pgprep/pg-backup-stores
Oct 17, 2026
Merged

steipete merged 12 commits into
mainfrom
pgprep/pg-backup-stores

Conversation

@steipete

@steipete steipete commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Full archive restore extracted PostgreSQL exports without recreating their namespaces. Git --all could collide discovered stores, and Git verification allocated a namespace it did not remove. The proposed archive import path also needed provenance: a valid export copied into a workspace must not be mistaken for a generated capsule and consumed.

User Impact

New archives record every generated PostgreSQL capsule by archive-relative path and the SHA-256 of its exact manifest. That manifest binds the store UUID, namespace, and artifact hashes. Verification and restore use this capture-time list. Unlisted capsule-shaped files remain opaque user data: they are neither imported nor consumed.

Declared PostgreSQL stores restore through their existing providers into fresh namespaces: state, agents, Workboard, Logbook, Team Reports, and retained Matrix roots. Every store verifies before matching anchors publish. Recovery configuration and its captured includes are validated under offline custody; the existing family-selection owner prepares engines from that recovered configuration. The recovered configuration publishes last. Failures clean prepared namespaces and the incomplete target. SQLite stores remain SQLite.

Declared capsules reject SQLite WAL, SHM, and journal sidecars before verification or import, including sidecars beside their outer anchors. The shared matched-export verifier enforces the same self-contained artifact rule for direct import. Captured root config aliases read the archived canonical payload while preserving the original path context for relative includes.

The outer archive's capsule inventory and canonical config-source path are additive; the PostgreSQL capsule format is unchanged. Older archives without the field import only global/agent capsules named by their existing database inventory. Other exports remain byte-identical files. Verification and restore warn operators to re-run backup with this version on the source installation before recovering plugin PostgreSQL stores automatically. A PostgreSQL anchor without an owned matched capsule is refused before application-database checks.

Git backup records distinct registry/plugin resource identities and exposes --store <id> alongside --global and --agent. PostgreSQL Git verification checks matched artifacts locally without allocating a namespace. Source bindings reject swapped current captures; historical captures remain readable. Removed-store pruning preserves operator files and history, and degraded agents retain their previous scopes while healthy stores refresh.

Why This Change Was Made

Addresses source audit #174642 and the copied-export finding in #174786 (comment). Rebased after #174698 and #174387 merged, dropping the squashed security commits while retaining PR2's family-aware selection and resource discovery.

The producer owns capsule provenance; archive orchestration owns sequencing; existing providers own store restoration and verification. Broad capsule-shape discovery is removed. Manifest encoding and portable archive-path checks use their existing owners. Net production delta: +609 (+945/−336). The additional production code preserves the existing config reader and provider boundaries; it adds no capsule version or database schema.

Evidence

  • A real provider-generated export copied into a workspace reproduced the pre-fix failure at the archive verification boundary. The repaired mixed-mode round trip checks all four user files byte-for-byte and proves no extra namespace is imported.
  • Five PostgreSQL families plus two Matrix roots: backup → wipe → restore into a separate database → real Gateway startup. The restored mixed PostgreSQL/SQLite installation then creates and verifies another full backup without collisions, including the retained capsule directories.
  • Legacy archive: only the declared global store imports; the unlisted plugin export and operator file remain byte-identical, a re-backup warning is reported, and no plugin namespace is created.
  • Later unavailable provider and missing-capsule failures leave no scratch namespaces; mismatched capture hashes and damaged inner/outer artifacts are rejected.
  • Retained Git regressions cover distinct scopes, namespace-free verification, swapped/corrupt capsules, historical captures, pruning, degraded agents, and SQLite/PostgreSQL secret-exclusion parity.
  • Committed unmanifested WALs beside the exported database, inner anchor, and outer anchor reproduced acceptance before the fix; direct matched-export verification also reproduced six sidecar failures.
  • Captured config aliases preserve relative include context and select only archived canonical payloads; the mixed PostgreSQL/SQLite round trip includes an absolute root config symlink.
  • SQLite archive verification/restore suites, scoped types/lint/format, and independent P0–P2 review.

Homebrew PostgreSQL 17 with vector, pg_trgm, and unaccent: the final archive and Git suites passed all five cases in one process (63.705s full-family Gateway recovery, 27.336s mixed-mode alias recovery plus recapture, 18.753s legacy/cleanup, 32.386s discovery/pruning, and 7.046s namespace-free verification/legacy restore). File time was 230.68s including cold compilation; wrapper time was 238.89s. The second-backup collision check moved to the smaller mixed-mode fixture after the prior CI head hit the all-family case deadline; the all-family Gateway proof remains intact. The original 240-second archive and 120-second Git deadlines are unchanged.

Final-head PostgreSQL CI passed all 395 tests, including all five archive/Git cases, four secret-parity cases, and Matrix account-root persistence. The archive cases took 138.905s, 59.216s, and 38.281s in CI; the Git cases took 79.847s and 12.840s, within their original deadlines.

Commands verification/restore suites passed 71 tests with one platform skip; config capture passed 16; the raw-config relative-include regression passed; the matched-envelope suite passed 17. Commands/config/infra types, scoped lint, formatting, and independent isolated P0–P2 review passed. The alias baseline attempt was invalidated during worker compilation before tests, so it is not counted as red proof. These real-server tests exceed the unit-test budget because they cover provider materialization, separate recovery databases, and actual Gateway admission.

Head: 376cbc58ec06441bcb240d868b5421c207e17c17. Final-head CI:

Check Result Evidence
PostgreSQL conformance Passed: 395 tests in 71 files (20m22s job) Exact-head job
Changed Node suites, types, lint, docs, and guards Passed CI
CodeQL / Critical Quality / OpenGrep Passed CodeQL, Critical Quality, OpenGrep
UI E2E 4 shards passed, 5 failed CI

The exact-head CI UI failures are admitted under Peter's inherited/causal-path exception. Latest completed scheduled main baseline: run 38999305057, head c05055d29fa2cbb5c21392f70975f03544021b75. All five failing test files are unchanged in the tested merge and import no PR-changed module. These cases use mocked Gateway data, not archive restore or config recovery.

UI shard / test file Cases Classification and evidence
1 — chat-plugin-steering.e2e.test.ts 4 desktop/mobile theme cases Disjoint rendering path: missing details.chat-notice-inline / Advisor guidance. The main shard passed; no matching-main failure is claimed. Projection, chat-divider, and notice CSS are unchanged; no backup/config recovery path executes.
4 — chat-pr-publication-state.e2e.test.ts 1 receipt recovery case Same case and locator-click timeout on main job 117298816884.
5 — plugin-skills.e2e.test.ts 1 bundle/settings case Disjoint CSS assertion: webkitLineClamp is empty instead of 2. The main shard passed; no matching-main failure is claimed. Plugin view/CSS and mock-Gateway setup are unchanged.
6 — chat-retry-failure.e2e.test.ts 1 restart/reload notice case Same case and notice wait timeout on main job 117298816841.
8 — chat-pull-requests.e2e.test.ts 5 label/action cases Same cases and signatures on main job 117298816957: short PR label mismatch plus four Details click timeouts.

No UI fixes or CI retries were made. All other CI jobs passed or were intentionally skipped; no fail-fast jobs were cancelled.

The preceding PostgreSQL run exceeded the all-family case deadline and subsequent config/custody checks failed while unfinished test work continued. This head redistributes the second-backup proof to the smaller mixed fixture while retaining all-family Gateway admission and the existing deadlines. ClawSweeper's exact-head review reports no actionable findings. Its release-archive compatibility request is now covered by an actual published [email protected] (latest) installation in a throwaway prefix: non-interactive SQLite onboarding, a local mock-provider turn, full backup with release-side verification, and restoration by this exact PR head's pnpm openclaw CLI after a qaRuntime build.

The released archive's 33 regular files were all retained. Its synthetic assistant reply remained queryable, and all three copied user-export files were byte-identical before and after activation. The existing release-to-current agent-schema migration required openclaw doctor --fix --non-interactive (v24 to v28); after migration the Gateway passed HTTP health and shut down cleanly. The counted proof used an allowlisted environment, isolated HOME/state/ports, and no configured channels or paid provider calls. An initial fixture inherited channel settings from the shell; it was stopped and excluded, and the complete proof was repeated cleanly. Throwaway package and data paths are removed after proof. No Docker was used.

The published stable release is SQLite-only, so released PostgreSQL artifacts remain unavailable; all-family PostgreSQL and legacy capsule behavior is covered by the exact-head 395-test conformance run and the fixture-based legacy tests above.

Landing uses the explicitly authorized inherited/causal-path CI exception above. No fix push or rebase was required.

@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T04:05:09.838398Z 376cbc5 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations size: XL labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8230d12818

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapshot/database-backup.ts Outdated
Comment on lines +58 to +62
const { createConfigIO } = await import("../config/config.js");
const { config } = await createConfigIO({
observe: false,
pluginValidation: "core-only",
}).readConfigFileSnapshot();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Load the recovery config under offline custody

readConfigFileSnapshot() can return { valid: false }, but this code ignores that flag and passes the rejected configuration to PostgreSQL backup/restore workers; it also captures the config before runWithLocalStateOwner acquires custody, so an edit during admission can make the operation create or discard schemas on a stale destination. Previously the callback consumed scope.config, whose lazy loadConfig() runs under the owner assertion and rejects invalid configuration; retain that owner-scoped behavior while avoiding state-dependent plugin validation.

AGENTS.md reference: AGENTS.md:L65-L70

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Restore declared PostgreSQL archive stores through existing providers, give Git stores distinct identities, and verify Git exports without creating namespaces.

Example: Recover an archive containing shared state and Workboard into a separate PostgreSQL database.

  • Before: Restore extracts historical anchors and exports without recreating their PostgreSQL namespaces.
  • After: Restore prepares fresh namespaces, verifies both stores, and publishes matching anchors before the recovered configuration.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A coherent recovery repair with no confirmed introduced defect and substantial real-server harness coverage; persisted-artifact compatibility remains unproven against the latest stable producer.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises real PostgreSQL through production recovery owners and Gateway startup in an integration harness. Compatibility evidence covers synthetic legacy captures, but does not show recovery of latest-stable-produced artifacts with settings and data intact.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: PostgreSQL backup artifacts can look recoverable while full restore leaves their server data absent, and additional Git stores can overwrite the same backup scope.
Reason: This is maintainer-directed recovery work for source-confirmed defects, with provider reuse and explicit preservation of unrelated user artifacts.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this PR repairs documented PostgreSQL recovery gaps, and the previous code findings are addressed. No new introduced defect was confirmed; honor the maintainer’s request to leave it unmerged.

Priority: P1
Reviewed head: 376cbc58ec06441bcb240d868b5421c207e17c17

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Provide a recovery run using archive and Git artifacts produced by v2026.10.4, showing configuration and retained data survive with the candidate; redact credentials and non-public endpoints.
Agent review details

How this fits together

The backup CLI connects archive and Git artifact readers to database-family providers; captured configuration and matched exports enter, and verified recovery namespaces plus local anchors leave.

flowchart TD
  A[Backup CLI] --> B[Archive or Git inventory]
  B --> C[Matched artifact verification]
  C --> D[Offline recovery owner]
  D --> E[Database family providers]
  E --> F[Fresh PostgreSQL namespaces]
  F --> G[Matching anchors and recovered config]
Loading

Technical review

Best possible solution:

Keep capsule provenance with the producer and restore every declared store through its existing provider before publishing recovered anchors and configuration.

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

Current-main source confirms extraction without PostgreSQL rehydration, colliding additional-store identities, and verification through restore; supplied real-server integration results exercise the repaired paths, but no target code was executed during this review.

Is this the best way to solve the issue?

The implementation addresses the owning boundaries coherently: producer-recorded capsule provenance, existing family providers, offline configuration validation, staged publication, and local artifact verification.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • PostgreSQL capture and restore providers keeps the original intent (d0ea7ea: Preserve matched PostgreSQL exports and anchors and restore into fresh namespaces without dropping the original namespace.)
  • Mixed-engine backup selection keeps the original intent (8a2935f: Capture physical store engines and preserve family-specific selections.)
  • Git artifact ownership and pruning keeps the original intent (151cf8d: Manage declared backup artifacts while preserving operator files, staging, historical refs, and recorded supported schemas.)
  • Portable archive collision checks keeps the original intent (350bac4: Reject ambiguous portable archive paths; the PR moves the existing helper without changing its behavior.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current main still has the recovery gaps: Fetched main performs archive extraction without PostgreSQL rehydration and assigns additional Git-discovered PostgreSQL stores the same workboard identity. (src/commands/backup-restore.ts:165, 83fab6f21417)
  • Prior sidecar findings are addressed: Declared capsules reject sidecars beside portable images and inner and outer anchors; direct matched-export verification also checks sidecars before opening artifacts. (src/commands/backup-verify-manifest.ts:640, 376cbc58ec06)
  • Captured configuration retains its authored include context: Recovery selects the archived canonical payload and reads its bytes with the original config pathname as context; validation and engine selection occur under offline custody. (src/commands/backup-recovery-config.ts:10, 376cbc58ec06)
  • Real-server integration coverage: The supplied PostgreSQL tests exercise archive recovery into a separate database, retained Matrix roots, mixed engines, copied-export preservation, cleanup, Gateway startup, Git pruning, historical captures, and namespace-free verification; the maintainer reports all five cases passed. (src/infra/database-engine/archive-restore.postgres.test.ts:42, 376cbc58ec06)
  • Compatibility coverage is synthetic legacy coverage: Legacy PostgreSQL scenarios remove the new inventory or source-binding field from current captures; they do not exercise artifacts produced by v2026.10.4 through an upgrade. (src/infra/database-engine/archive-restore.postgres.test.ts:579, 376cbc58ec06)
  • Exact-head CI remains unsettled: The reviewed head has five failed UI E2E shards and PostgreSQL conformance still running. One inspected failure is a plugin-skills UI assertion; its cause has not been attributed to this diff or independently established on the base. (376cbc58ec06)

Likely related people:

  • Peter Steinberger: Raw commit d0ea7ea adds src/snapshot/database-backup.ts:53 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d0ea7eae7ead; files: src/snapshot/database-backup.ts)
  • Richard O’Shaughnessy: Raw commit 151cf8d adds src/snapshot/git-backup-artifacts.ts:161 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 151cf8db96f9; files: src/snapshot/git-backup-artifacts.ts)
  • Vincent Koc: Raw commit 350bac4 adds src/commands/backup-verify.ts:813 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 350bac4e0e2b; files: src/commands/backup-verify.ts)

PR surface

Source +609, Tests +1622, Docs +71, Other -1. Total +2301 across 39 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 22 945 336 +609
Tests 11 1627 5 +1622
Docs 4 117 46 +71
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 2 -1
Total 39 2690 389 +2301

Review metrics

Metric Value Why it matters
CLI surface One new selector: --store <id> Makes recorded plugin and additional-root Git scopes directly verifiable and restorable.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The central defects prevent complete PostgreSQL disaster recovery and allow discovered Git stores to collide.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Demonstrate recovery of latest-stable-produced archive and Git artifacts with captured settings and retained rows intact.

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 (3 earlier review cycles)
  • reviewed 2026-10-16T22:24:46.263Z sha 8230d12 :: blocked before merge. :: [P2] Validate recovery config after acquiring offline custody | [P2] Update typed Doctor fixtures for the expanded discovery reply
  • reviewed 2026-10-17T03:40:08.999Z sha f24d7b4 :: blocked before merge. :: [P1] Reject SQLite sidecars for declared PostgreSQL capsule images | [P2] Resolve captured config aliases to their archived canonical payload | [P3] Document that unlisted PostgreSQL exports remain opaque
  • reviewed 2026-10-17T04:09:29.834Z sha 376cbc5 :: blocked before merge. :: none

Reviewed October 17, 2026, 12:16 AM ET / 04:16 UTC (Revision 4).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e356c8c01a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +619 to +621
const entry = byPath.get(required);
if (!entry || !isRegularArchiveFile(entry.type)) {
throw new Error(`PostgreSQL backup is missing a regular matched artifact: ${required}`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify PostgreSQL artifacts before reporting backup success

When a PostgreSQL capsule contains all four regular files, this loop accepts it without validating the export manifest, artifact hashes, or anchor binding. The later SQLite pass only inspects portable images associated with global/agent owners, so plugin stores are not content-checked at all, and a valid-SQLite tamper or mismatched anchor can also pass for core stores. Consequently backup verify and backup create --verify can report success for a backup that preparePostgresRestore later rejects during disaster recovery; run matched-envelope verification for every declared capsule here.

Useful? React with 👍 / 👎.

Comment on lines +316 to +321
const id = primary
? family
: `${family}${resourceId ? `__${resourceId}` : ""}__${createHash("sha256")
.update(resourcePath)
.digest("hex")}`;
databases.push({ path: file, identity: { role: "generic", id } });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prune PostgreSQL scopes removed from an all-store backup

When a discovered store disappears between two git create --all runs, no new manifest is produced for its stores/<id> scope, but the cleanup path still calls only prepareStaleAgentUpdates and never reconciles generic scopes. The old store therefore remains in HEAD and continues to be selectable by --store, making the newest supposedly complete backup expose stale data as current; reconcile the existing stores/ scopes against the full discovered scope set.

Useful? React with 👍 / 👎.

Comment thread src/commands/backup-verify-manifest.ts Outdated
Comment on lines +604 to +605
const directoryPath = path.posix.dirname(entry.normalized);
const envelope = parsePostgresEnvelope(value, path.posix.basename(directoryPath));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid rejecting legacy archives for PostgreSQL lookalikes

For legacy archives, an ordinary file named *.postgres/manifest.json is ignored only when JSON parsing fails or source.engine differs; once it contains { "source": { "engine": "postgres" } }, parsePostgresEnvelope runs outside the catch and any missing field rejects the entire archive. Thus an unrelated plugin/user manifest with that minimal shape prevents verification and restore of an otherwise valid older backup, despite the adjacent compatibility comment; only claim the directory after the complete envelope shape has been recognized without turning malformed lookalikes into archive failures.

Useful? React with 👍 / 👎.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The final follow-ups at 7ae1b4e12416c46bead773ab7c8ce146944f0c02 address both findings: the recovery config is read and validated inside offline custody with ownership assertions around the await, and the typed Doctor discovery fixture includes the required inventory fields. Invalid config/read failures use the existing error owner. A regression reproduced dispatch of work from invalid config on the previous code and now passes; a real PostgreSQL capture/verify case remains green. Core types, scoped lint, the mock-export guard, and isolated review passed.

The full local archive → wipe → recovery-database restore → real Gateway-start proof passed, including five families, two Matrix roots, legacy capsules, and failed-restore namespace cleanup. The existing format-2 export and matching-provider requirement are unchanged; the optional archive inventory preserves legacy archive reads. The PR includes existing-format and opaque SQLite preservation proof, and does not claim a new cross-schema upgrade contract. The body records the local timing/deadline evidence. Final-head CI is running.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7ae1b4e124

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +615 to +617
...["manifest.json", "anchor.sqlite", "database.sqlite"].map((name) =>
path.posix.join(directoryPath, name),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject SQLite sidecars beside PostgreSQL artifacts

When a restored archive contains an undeclared database.sqlite-wal beside this required portable image, verification accepts it and extraction preserves it. restorePostgresBackup then opens database.sqlite normally in read-only mode, so SQLite can consume committed rows from that WAL; the envelope hashes only the main file, and user-backup restore does not compare the resulting table verification. Thus a tampered archive can pass verification yet silently import unmanifested data into PostgreSQL. This remains possible even after adding the matched-envelope verification requested in the earlier review because that verifier also ignores sidecars.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

await dumpGitBackupDatabase({

P2 Badge Handle PostgreSQL capture failures as degraded agents

When --all processes a configured PostgreSQL agent whose anchor is readable but whose server/provider export fails, dumpGitBackupDatabase() rejects outside the degradation try block. This aborts the entire backup instead of preserving that agent's previous scope, warning, and continuing with the other databases as the documented --all behavior promises; include PostgreSQL capture in the same per-agent failure boundary.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dab0f53f30

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapshot/git-backup.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bdbf473841

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/commands/backup-verify-manifest.ts Resolved
Base automatically changed from pgprep/pg-git-secrets to main October 17, 2026 00:50
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete
steipete merged commit b7bb85a into main Oct 17, 2026
187 of 194 checks passed
@steipete
steipete deleted the pgprep/pg-backup-stores branch October 17, 2026 04:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

roboclaw-bot added a commit that referenced this pull request Oct 17, 2026
#174744 and #174859 landed together; the consolidated lstatIfExists helper is always bigint and takes one argument, so tsgo failed on main.

Co-authored-by: steipete <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
…enclaw#174744)

* fix(backup): restore every PostgreSQL store from archives and Git

Rehydrate captured state, agents, plugin families and retained Matrix roots through their providers before publishing matched anchors. Preserve distinct Git resource identities, expose store selectors, and verify matched exports without allocating server namespaces.

* fix(backup): establish PostgreSQL selection in cold CLI workers

* test(backup): align discovery and CLI fixtures with restore contracts

* fix(backup): validate recovery config under offline custody

* fix(backup): verify PostgreSQL capsules and prune stale stores

* fix(backup): retain degraded PostgreSQL agent scopes

* fix(backup): bind PostgreSQL Git capsules to their scope

* fix(backup): reject undeclared PostgreSQL archive stores

* fix(backup): restore archived family selection under custody

* test(backup): separate archive restore proof scenarios

* fix(backup): bind archive imports to generated capsules

* fix(backup): reject capsule sidecars and restore config aliases
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant