Repository navigation
feat(backup): preserve source artifacts for internal captures - #189638
Conversation
Co-authored-by: galiniliev <[email protected]>
Worked on by: - @galiniliev Co-authored-by: galiniliev <[email protected]> OpenClaw-Publication: 13c22d85-5d08-4693-a372-4f031d1e46e8
|
🦞👀 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 an internal backup mode that preserves source SQLite artifacts and row IDs while retaining existing row-level sanitizers. Example: Capture a database containing witness row ID 71 while an external SQLite writer holds a WAL or rollback journal.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR provides a useful internal capture mode with adequate behavior evidence and no remaining actionable findings; it is ready for normal landing. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe archive owner resolves backup resources, acquires verified SQLite images, sanitizes private copies, and publishes a restorable archive. flowchart TD
A[Internal capture caller] --> B[Backup archive owner]
B --> C[Artifact preserving planning scope]
C --> D[Existing SQLite acquisition owner]
D --> E[Private image and row sanitizers]
E --> F[Archive publication]
C --> G[Legacy audit refusal]
Technical reviewBest possible solution: Land the focused internal mode using the existing acquisition owners and retain ordinary backup compaction and sanitization defaults. Do we have a high-confidence way to reproduce the issue? This is an additive capability; supplied original-base controls fail at source-fingerprint and row-ID assertions, and the retained regressions exercise those contracts through the real archive owner. Is this the best way to solve the issue? The change is appropriately scoped: it reuses existing read scopes and private acquisition, preserves sanitizers, and refuses legacy reconciliation that would violate source preservation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e40ffa377444. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +46, Tests +142, Other +2. Total +190 across 6 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 HistoryReviewed October 31, 2026, 5:24 PM ET / 21:24 UTC (Revision 3). |
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
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
Internal filesystem captures need to read SQLite state without changing the source WAL index or recovering rollback journals in place.
User Impact
No new CLI flags or changes to ordinary backups. This adds the internal
createBackupArchive({ preserveSourceArtifacts: true, ... })mode for isolated migration/checkpoint capture processes. Default backup sanitization and compaction, archive format, and PostgreSQLonline: truecapture remain unchanged.The internal mode preserves row IDs by skipping compaction, so free-page bytes can remain in its archive. It still applies the existing row-level sanitizers and is not a secure-deletion export.
Why This Change Was Made
The backup owner applies the existing artifact-preserving read scope during planning as well as private SQLite acquisition. Legacy audit reconciliation is refused before it can take a source write lease. Acquisition uses verified private images and preserves row IDs. No companion profile, anchor inventory, CLI, or quiescence API is included.
The hosted review's P2 fixture finding is repaired at the shared backup scratch owner: drain fixture state, retire idle state readers and the retained native broker, then remove the case directory. Failed custody settlement retains the directory. The regression starts cold with a short fixture prefix so a long-socket-path fallback cannot mask the deleted-socket failure. Production behavior is unchanged by this repair.
Extracted and adapted from galiniliev's source commit, with contributor credit retained.
Evidence
Changed preserving mode through the production CLI consumer
This is additional evidence for the changed mode, distinct from the ordinary CLI compatibility run below. The existing stacked consumer in PR #189685 executed its built CLI while a disposable Gateway and PostgreSQL 17.11 were running:
The original native command and terminal receipt, successful build log, clean build stamps, capture output, witness implementation and retained archive were independently inspected—not inferred from PR6's rating. Runtime source was
399a3cfc1ab391ae5c17b85350aa2b7c1aabde6e; both build stamps and build-info identify it. The comparison to integrated consumer head9bbf226cf8db03c4ed0b96effc4143d296620c2achanges only three test/support/allocation files, so the tested production inputs remain identical.The call chain was personally checked: CLI option/action → unchanged
backupCreateCommandoption forwarding → archive owner selectingpreserveSourceArtifacts: true→ the preserving planning scope and private SQLite snapshot acquisition. The private-acquisition/row-ID block is byte-identical to this PR, as aresqlite-snapshot.ts,sqlite-readonly-location.ts,sqlite-snapshot-staging-owner.ts,artifact-preserving-state-reads.ts,commands/backup.ts, and the lockfile. The two archive modules as a whole are not claimed identical: PR6 adds profile/anchor inventory and its own destination policy.The retained 953,531-byte archive has SHA-256
7f149851302acccaeef09415c98c367b534135db960240dd81dcb7e3929f259c. Its unique manifest reportslocal-companion, one PostgreSQL anchor and zero export capsules; it contains both the shared-anchor and fixed-local credential SQLite images. A separate read-only audit extracted private copies and matched whole-row hashes/counts against the original capture-time witness: 2 device identities, 2 device tokens and 1 native exec socket credential, with the same anchor store/engine/namespace. No credential values are published. Retained final-effect receipts additionally show offline verify/restore, a successful allowed protected RPC after activation, and rejection before effect of a client revoked after capture.This qualifies actual production-consumer selection/acquisition and a usable archive. PR6's credential-retention policy is not attributed to PR4, which retains its existing sanitizers. The exact-base WAL/DELETE fingerprint, row-ID and sanitization oracles below remain the detailed preservation proof; this retained consumer run is not mislabeled as a new before/after WAL measurement. No new public API or service rerun was introduced for this evidence audit.
Original-base, invariant and compatibility proof
f1c93577085244aa96aa87b53a2df9b59d293bd7in a separate checkout, copying only the regression and corrected fixture helper. Both cases failed at the intended product assertions: WAL capture changed a source-family SHA-256; DELETE capture produced row ID 1 instead of 71. Setup failures are not counted as this evidence.connect ENOENTfor the previous case's removedscratch/oc-br-*/resource.sock. Native Bun and a short CI-style temporary root exposed it; the earlier long local path had relocated the socket outside case scratch and masked the lifetime mismatch. With the shared cleanup repair, both unchanged preservation assertions pass.scripts/ci-run-node-test-shard.mts,OPENCLAW_CI_TEST_RUNTIME_POLICY=bun-all, short CI-style TMPDIR, and the original seven changed-3 targets followed by all remaining shared-fixture consumers: 16/16 invocations, 241 tests passed, zero failed invocations. This covers config capture, archive streaming/publication, audit migration/restore and bounded retries, credentials, ownership, privacy, mixed engines, ordinary backup commands, atomic publication, restore/verification and SQLite hardlinks. No test timeout, assertion, skip, or baseline exception was weakened.pnpm openclaw --profile <isolated-profile> backup create --verify --no-include-workspace --json, thenbackup restore --json, with synthetic state, matching isolated service selectors and an owner-claimed port. The restored database independently retained the committed witness value, compacted its implicit row ID from 71 to 1 as ordinary backups should, and contained zero runtime leases. No live Gateway was changed and no publication guard was disabled. This proves ordinary CLI compatibility; the new preserving mode deliberately remains an internal archive-owner API.check:changedpassed, including all core test type graphs, guards, dead-export scans, core/script lint and formatting. Targeted type-aware lint on the two repaired TypeScript files passed all 293 rules with zero warnings/errors;git diff --checkand the test-line ratchet passed. Final full-PR local autoreview against the original base completed source verification with no actionable P0–P2 findings. Its earlier INDEX-only finding was resolved by staging the reviewed repair and verifying index/worktree equality before the final review. The reviewed repair isdc21e69acc5f63c281f3a531e4252a4cda68387e; publication head9bac5c28b3c3094ad653119ce06082e4173fe62ais tree-identical. Local ClawSweeper was unavailable; the documented local-autoreview/hosted-review fallback is used. Paginated current-head CI readback observed 139 terminal check runs: 63 success, 75 skipped, 1 neutral, no failure or pending; all three commit statuses, includingopenclaw/ci-gate, are successful. Skipped runs are not counted as executed proof.Worked on by