Repository navigation
feat(backup): add PostgreSQL local companion checkpoints - #189685
Conversation
Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 13c22d85-5d08-4693-a372-4f031d1e46e8
Capture local files and fixed-local credentials with validated PostgreSQL anchors, then verify and restore offline without exporting, importing, or rolling back PostgreSQL rows. Reuse the source-preserving backup owner and rebind credentials to the same store identities. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: b1627006-23a2-496a-8b7b-df1b1dcc5a04
|
🦞👀 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 changesThis PR adds PostgreSQL companion checkpoints that restore local files and credentials while reconnecting to existing database rows. Example: A device label changes to current-after-capture after a companion checkpoint is created.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR adds a distinct checkpoint capability absent from main; the previous fixture finding is fixed, and no new actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe backup CLI passes filesystem resources and database identities through existing capture, archive verification, and staging restore owners, producing restored local state bound to the original PostgreSQL stores. flowchart TD
A[Backup CLI] --> B[Resource inventory]
B --> C[Local snapshots and PostgreSQL anchors]
C --> D[Companion archive]
D --> E[Offline verification]
E --> F[Staging restore and credential rebinding]
F --> G[Existing PostgreSQL stores]
Technical reviewBest possible solution: Land the explicit companion profile through the existing backup and credential owners after the stacked dependency and required checks clear. Do we have a high-confidence way to reproduce the issue? This is a feature addition; source inspection confirms main's ordinary recovery uses exports, while the supplied production CLI trace exercises companion capture, offline restore, and activation. Is this the best way to solve the issue? The smallest coherent implementation adds profile and anchor metadata to existing owners, preserves ordinary recovery, and reuses credential matching rather than introducing a parallel recovery manager. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ed22dfb04081. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +277, Tests +330, Docs +27, Other +1. Total +635 across 19 files. Added test files: 1. View PR surface stats
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 (1 earlier review cycle)
Reviewed October 31, 2026, 4:54 PM ET / 20:54 UTC (Revision 2). |
Keep fixture fields concretely typed, reuse the SQLite inspection pragma owner, and replace the moved errno assertion with its existing guard. Prune the retired assertion allowance through the ratchet generator. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 3ce080ef-b111-4629-91b6-3cb40fedc152
Keep per-case native socket custody until state readers and the broker join. Start preservation proof cold under short roots so the socket-path fallback cannot hide the removed-socket regression. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 8d66e0e9-1742-4a32-b7ef-5349abb5dece
Merge verified PR4 head 9bac5c2. Only inherited test/support files and their allocation change; production inputs remain identical to the real Gateway/PostgreSQL proof at 399a3cf. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: e3e68a2c-75f4-4114-83c2-8f240cd55c0c
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merge pinned main f33e48e after PR4 landed by squash. Resolve only duplicate preservation-option hunks while retaining the reviewed companion flow and main weak-owner map reuse. The main-targeted diff contains only the 19 PR6 files; no PR4-only delta. Retain Diamond review and live PostgreSQL proof at 9bbf226/399a3cfc as their original source-bound evidence; current-head CI remains required. Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: d663c56a-c58f-4e07-8718-6d7aa9283a28
What Problem This Solves
PostgreSQL installations need local restart checkpoints without exporting and later rolling back their live database rows.
User Impact
openclaw backup create --local-companion --verifycaptures local files, fixed-local credentials, and PostgreSQL anchors. Verification and staging restore work while PostgreSQL is offline; activation reconnects to the same stores/namespaces and current rows.restore --local-companionalso works through--fromand refuses ordinary archives before extraction.This is not disaster recovery. All portable families must select PostgreSQL. Local files roll back; PostgreSQL rows do not. Stop the Gateway before activation, keep the matching database available, and do not run original/restored installations concurrently with the same credentials. Legacy-audit migration inputs and saved PostgreSQL export directories are refused. Source-preserving capture keeps row IDs and may retain free-page bytes; it is not a secure-deletion export. Ordinary backups retain exports, online capture, sanitization, and fresh-namespace recovery.
Why This Change Was Made
The manifest profile/anchor inventory lets the existing verifier reject store/namespace mismatches, sidecars, and undeclared exports offline. Existing credential owners preserve fixed-local credentials and rebind them to the matching anchor. Generic acquisition remains owned by #189638, now landed on main as
f33e48e6720fe0b7b8ba2801096f532275cd08a5. This PR targets main and contains only PR6 changes; the squashed dependency is not duplicated in its diff.Adapted from Galin's source commit, with contributor credit retained. No externally-quiesced capture API, PostgreSQL import/rollback path, new production manager, or competing state owner is added.
Evidence
Main integration after PR4 landing
Merged pinned main
f33e48e6720fe0b7b8ba2801096f532275cd08a5into the existing publication lineage after the stacked PR automatically retargeted to main. Resolved only six duplicate preservation-option hunks in two files, retaining the reviewed companion behavior. The main-targeted diff is exactly the 19 PR6 files, with no PR4-only test/support/allocation delta.backup-create.tsis byte-identical to the Diamond-reviewed version; snapshot planning retains main’s existing weak-owner-map allocation helper instead of the equivalent local helper.Inspected relevant main authority changes: pairing wait-observation labels, worker-identity detection (not the operator client path), and an early refusal to issue a token for a missing paired device. Token verification/revocation and the companion credential-restore owner are unchanged. The original actual Gateway/PostgreSQL and stable-upgrade evidence remains bound to its recorded source, not relabeled as a new-head execution.
Affected gates: 66 tests passed in 7 files / 2 shards (capture and ordinary controls, archive completeness, credential promotion, source aliases, pairing worker, weak-map contract); wrapper 133.64s, native preparation 71.00s. Core and infra test typechecks passed; targeted type-aware lint had zero warnings/errors; formatting and diff checks passed. Fresh independent P0–P2 autoreview of committed
f0d71193a94d178b486623b929b9b2a63ae3f7f4against pinned main completed source verification with the full PR6 delta and 18 frozen owner contracts: scoped-clean, no actionable findings. It did not independently rerun tests or live PostgreSQL. New exact-head PR CI is required. No product scope or test-budget expansion was added for this integration.Integrated production CLI / Gateway / PostgreSQL
Built through the supported owner at exact source
399a3cfc1ab391ae5c17b85350aa2b7c1aabde6e; all build stamps/build-info matched. The subsequent merge6818508e3090855e6478358b3897f62f323ac4e4changes exactly two inherited test/support files and their allocation. At Diamond-reviewed head9bbf226cf8db03c4ed0b96effc4143d296620c2a, all production inputs were byte-identical to that tested runtime. The later main integration is qualified separately above; no fresh live PostgreSQL run on the new head is claimed. PostgreSQL 17.11 ran only in a disposable task-owned container/database; no live user state or Gateway was touched. No model inference is claimed for this authentication/RPC boundary.backup create --local-companion --verifywhile the Gateway ran: one matching PostgreSQL anchor, zero export capsules.device.token.revokeon the second client and changed a real PostgreSQL-backed label tocurrent-after-capture.restore --local-companionreturnedok:true. Promoted only the task-owned restored tree, with both services stopped. Read-only whole-row hashes/counts matched for two native identities, two tokens, and one native exec socket credential; the PostgreSQL anchor matched exactly.AUTH_DEVICE_TOKEN_MISMATCHduring connection authentication, before its attempted protected rename. An independently admitted read proved the forbidden label was never written. The post-capture label survived activation; the store anchor and every non-system namespace matched. No PostgreSQL import, new namespace, or rollback occurred during companion restore.Sanitized terminal results; successful proof commands exited 0:
Latest-stable existing-data compatibility
Installed actual latest stable
v2026.10.9with the maintained installer in a separate task prefix, isolating released dependencies from this checkout. Its real Gateway/public SDK produced a paired identity/token, protected rename, and nondefault timezone. On the same state without resetting/reseeding, current Doctor migrated shared schema 20 → 36 and the native credential store; original identity/token whole-row hashes matched. The original token authenticated to the exact candidate Gateway, read the retained setting, and completed a protected rename. After the supported SQLite → PostgreSQL port, that same released credential authenticated against PostgreSQL and read the retained setting.Stable had no PostgreSQL/native-client-store selection: this proves actual stable SQLite/native-credential upgrade, followed by a supported port before capture, not stable PostgreSQL migration. First Doctor invocation hit its outer command budget after migration; state was reconciled before idempotent resumption, which completed. No product watchdog was weakened.
Automated proof and finding disposition
hasErrnoCode; duplicated PRAGMA site replaced with existing read-only helper, preserving both guards. Generated assertion baseline pruned through its owner (one obsolete allowance removed); dialect sites decrease 3 → 1. Both ratchets pass. Test-line CI already passed: 328 governed lines plus two inventory lines explains the review's +330 surface. Unique allocation remains 328.resource.sockfailure is fixed by feat(backup): preserve source artifacts for internal captures #189638 and integrated without duplicating the patch. Personally inspected exact test-only diff and owner evidence: 241 passing tests / 16 consumer groups, original-base red controls, real CLI round trip, clean independent review.Remaining observations and accepted limits
Prior head
494226b9CI's compact-small-18 failure is the now-integrated missing broker socket repair. Its separate copied-harness E2E failed with retryableModel runtime changed before this turn started; that fixture does not exercise backup/restore. No fix or baseline attribution is claimed for that observation; current-head CI must be inspected. An earlier broad Node ordinary-WAL timeout at 120s and cleanup cascades remain recorded; later Bun success is not claimed as its fix. The earlier pre-integration two-anchor PostgreSQL exercise is supplementary only.Initial final-flow setup gave two clients identical silent-pairing metadata, so the owner correctly pruned the superseded client before revocation. Distinct client display names repaired the fixture, then a new archive was captured only after both explicit tokens authenticated. No authorization guard/scope was relaxed; original stable-token compatibility had already passed independently.
Combined-stack follow-up: the separately prepared SQLite-only migration PR must reject
postgresAnchorsas well as PostgreSQL exports; that guard is absent from the pinned main base. Parent coordinates that integration and serialized landing. Current-head CI remains required. The original hosted Diamond 5/6 assessment is retained at9bbf226c; no new hosted assessment is claimed or requested solely for this mechanical main integration.Worked on by