Skip to content

feat(backup): recorded runs, scheduled backups, and git-backed versioned snapshots - #122485

Merged
steipete merged 25 commits into
mainfrom
steipete/backup-ops-git-provider
Aug 12, 2026
Merged

steipete merged 25 commits into
mainfrom
steipete/backup-ops-git-provider

Conversation

@steipete

@steipete steipete commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Backups existed only as a manual command: nothing ran them on a schedule, nothing recorded that they ran, and nothing noticed when they silently stopped. The backup_runs state table had zero production writers. Snapshots were full copies with no incremental or offsite path, and the docs explicitly declared scheduling, upload, retention, and incremental behavior out of scope.

Why This Change Was Made

Backups become an operated system plus an efficient versioned backend, per the operator discussion of backup strategies:

  • Recorded runs: every archive/sqlite/git backup attempt writes backup_runs (bounded to 200 rows, best-effort, never fails the backup).
  • Freshness surfacing: openclaw status gains a Backups overview row + JSON payload; openclaw doctor prints an informational hint when no successful backup exists or the newest is older than 14 days.
  • Scheduling: openclaw backup enable --repository <dir> [--every 24h] [--push] [--exclude-secrets] provisions one idempotent gateway cron job (kind: "command", isolated session target) running backup git create --all; backup disable removes it.
  • Versioned git snapshots: backup git init|create|log|verify|restore. Deterministic per-table JSONL dumps (PK-ordered, lossless int64/blob encoding), verbatim SQLite DDL preserved, one commit per backup run, push optional. Unchanged databases produce no commit, so quiet cycles are free.
  • Restore correctness: virtual tables (FTS5/vec0) and their shadow tables are never dumped; restore recreates FTS5 tables and rebuilds content-backed ones, skips vec0 (memory-core reprovisions and reindexes on first use), and omits session_transcript_index_state so gateway startup reconciliation rebuilds the transcript FTS projection. Restores verify by re-serialization against per-table manifest hashes plus PRAGMA integrity_check/foreign_key_check.
  • Secrets policy: --exclude-secrets redacts the credential-bearing tables (documented list); pushing without it warns that history carries credential material.

Supporting refactors: the worktrees git wrapper moved to src/infra/git-exec.ts and the hardened online-backup/sanitize/VACUUM/verify copy step into src/snapshot/openclaw-snapshot-copy.ts, shared by the local and git snapshot backends (behavior-identical, all importers updated). One owner-level fix: schema_meta.updated_at no longer bumps on every database open — it records when schema metadata actually changed, which unconditional bumps previously defeated any no-change detection.

User Impact

Operators get scheduled, history-keeping, offsite-capable backups with three commands (backup git init, backup enable, done), visible freshness in status, and a doctor nudge before the missing-backup regret moment. No new config keys or env vars; no schema changes (the backup_runs table already existed).

Evidence

Live-tested against copies of real production databases (24MB state DB, 55MB agent DB with FTS5, sqlite-vec, and 7.6MB of embedding blobs) in an isolated OPENCLAW_STATE_DIR:

  • backup git create --all: first run commits; second and third runs report no changes (idempotence held only after the schema_meta/backup_runs fixes — the live test caught both).
  • backup git verify: global 4.2s, agent 2.2s — every table digest byte-identical after full restore + FTS rebuild, including a 17MB trajectory table (which also exposed and fixed a 1MB exec buffer cap).
  • backup git restore --agent main: 3,497 transcript events byte-preserved, user_version 17, projection/vec tables correctly absent, integrity_check ok.
  • --exclude-secrets: zero secret-table files in the tree; manifest documents exactly the six redacted state tables.
  • status shows Backups │ last ok just now (git); doctor prints the no-backup hint on a fresh state dir.
  • backup enable/disable round trip against a session-owned dev gateway (port 19917): job created (every 6h), idempotently updated (12h), removed; cron list confirms each step.
  • Stale-registry robustness: --all skips agents whose registered DB no longer exists (real stale QA-suite path found in production state) instead of aborting the scheduled run.

Gates: focused vitest suites green (git codec, run records, schedule, snapshot repository 65, doctor contributions 107, status 19, worktrees); pnpm build green including SDK-export and dynamic-import boundary checks; env-var ratchet 502/502; autoreview (Codex gpt-5.6-sol, high) clean, zero accepted findings.

Main repair carried in this PR

check-test-types is red on current main: commit 92f5f07 (#114506) added lookupFn stubs in extensions/browser/src/browser/cdp.helpers.test.ts that do not satisfy the LookupFn overloads, and the breakage slipped through cancelled main-push CI. This PR repairs it with the established typed-stub pattern (see src/infra/net/ssrf.pinning.test.ts) per the never-land-onto-red rule.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 12, 2026 06:21
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes commands Command implementations agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR scripts Repository scripts and removed gateway Gateway runtime labels Aug 12, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 12, 2026, 10:20 AM ET / 14:20 UTC.

ClawSweeper review

What this changes

This PR adds recorded backup runs, scheduled Gateway jobs, and Git-backed versioned SQLite backup, verification, restore, status, and Doctor flows.

Merge readiness

⛔ Blocked by patch quality or review findings - 8 items remain

Keep open: the current head has two P1 security-boundary defects in Git-backup ownership and redaction, so it is not ready to merge.

Priority: P1
Reviewed head: ce2d18a613ea0da88d8cdf558f0712d9c37f4ef7

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The feature has substantial implementation and claimed live validation, but the two P1 security defects block merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless reports real database and Gateway runs.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless reports real database and Gateway runs.
Evidence reviewed 6 items Scoped commit leaks pre-staged files: The command stages only global and agents paths, but the subsequent plain Git commit consumes the full existing index; an adopted repository with an operator-staged unrelated file can therefore include and push that file in an OpenClaw backup commit.
Git commit contract: Git documents --only as the path-limited commit mode; the current invocation has no pathspec or --only restriction.
Current-main pairing credential is unredacted: Current main serializes a pairing setup payload into device_pairing_join_codes, and that payload includes bootstrapToken; the PR’s added state-secret inventory does not list this table even though the codec excludes only listed tables.
Findings 2 actionable findings [P1] Commit only backup-owned paths
[P1] Redact current pairing join codes
Security Needs attention Scoped backups commit the full staged index: A plain Git commit after path-scoped staging includes pre-existing staged files, allowing unrelated data to enter backup history and a subsequent push.
Pairing bootstrap tokens bypass redaction: The state redaction inventory omits device_pairing_join_codes even though current main stores setup payloads containing bootstrapToken there.

How this fits together

Backup commands create verified copies of shared and agent SQLite state, then store deterministic snapshots in an operator-owned Git repository. Gateway cron can invoke the same command periodically, while backup records feed Status and Doctor freshness guidance.

flowchart LR
  A[State and agent databases] --> B[Backup command]
  B --> C[Verified snapshot]
  C --> D[Git backup repository]
  E[Gateway cron job] --> B
  B --> F[Backup run record]
  F --> G[Status and Doctor]
  D --> H[Restore and verify]
Loading

Before merge

  • Commit only backup-owned paths (P1) - git add -- global agents leaves unrelated entries already in the index intact, and this plain git commit records all of them. In an adopted repository, an operator-staged file can enter an openclaw backup commit and pass the later message-based push check. Use a path-limited commit or isolated index and add a staged-file regression.
  • Redact current pairing join codes (P1) - After this behind-main branch merges, --exclude-secrets still dumps device_pairing_join_codes: current main stores a setup payload containing bootstrapToken in its payload_json, but this new inventory omits the table and the regex test only recognizes token-named columns. Add the table and a payload-redaction regression after rebasing.
  • Resolve security concern: Scoped backups commit the full staged index - A plain Git commit after path-scoped staging includes pre-existing staged files, allowing unrelated data to enter backup history and a subsequent push.
  • Resolve security concern: Pairing bootstrap tokens bypass redaction - The state redaction inventory omits device_pairing_join_codes even though current main stores setup payloads containing bootstrapToken there.
  • Resolve merge risk (P1) - Until the index is isolated and the redaction inventory is rebased against current main, a backup push can contain unrelated staged data or an active device bootstrap credential.
  • Complete next step (P2) - A protected maintainer PR needs the two security repairs and an exact-head review before merge.
  • Improve patch quality - Use a path-limited commit and prove a pre-staged unrelated file remains outside the backup commit.
  • Improve patch quality - Rebase on current main, redact device_pairing_join_codes, and prove its JSONL and schema are absent from redacted output.

Findings

  • [P1] Commit only backup-owned paths — src/snapshot/git-backup.ts:187-189
  • [P1] Redact current pairing join codes — src/state/secret-state-tables.ts:2-23
  • [high] Scoped backups commit the full staged index — src/snapshot/git-backup.ts:187
  • [high] Pairing bootstrap tokens bypass redaction — src/state/secret-state-tables.ts:2
Agent review details

Security

Needs attention: The new remote-backup path can expose operator-staged data and a current-main device bootstrap credential.

PR surface

Source +2139, Tests +1182, Docs +202, Other +1. Total +3524 across 45 files.

View PR surface stats
Area Files Added Removed Net
Source 33 2285 146 +2139
Tests 9 1186 4 +1182
Docs 2 212 10 +202
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 45 3684 160 +3524

Review metrics

Metric Value Why it matters
Production versus test LOC production +2,278/-145; tests +1,193/-5 The large feature addition is justified by new backup capability, but its security-critical owner boundaries need the two P1 repairs before merge.

Stored data model

Persistent data-model change detected: database schema: src/snapshot/git-backup-codec.ts, database schema: src/state/openclaw-agent-db-schema.ts, database schema: src/state/openclaw-state-db.ts, database schema: src/state/secret-state-tables.test.ts, serialized state: src/state/backup-run-records.test.ts, serialized state: src/state/backup-run-records.ts, and 6 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Contain commits and complete merged-state redaction (recommended)
    Commit only the backup-owned paths, add device_pairing_join_codes to global redaction after rebasing, and cover both regression paths before merge.

Technical review

Best possible solution:

Make backup commits path-limited and make redaction inventory cover the merged current-state schema before any remote Git backup can be merged.

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

Yes: stage an unrelated file before running a Git backup and inspect the resulting commit; separately create a current-main pairing join code and run a redacted Git backup to observe its payload being dumped.

Is this the best way to solve the issue?

No: the feature path is plausible, but plain Git commit does not preserve its scoped-staging invariant and the inventory must be reconciled with current main’s credential-bearing table.

Full review comments:

  • [P1] Commit only backup-owned paths — src/snapshot/git-backup.ts:187-189
    git add -- global agents leaves unrelated entries already in the index intact, and this plain git commit records all of them. In an adopted repository, an operator-staged file can enter an openclaw backup commit and pass the later message-based push check. Use a path-limited commit or isolated index and add a staged-file regression.
    Confidence: 0.99
  • [P1] Redact current pairing join codes — src/state/secret-state-tables.ts:2-23
    After this behind-main branch merges, --exclude-secrets still dumps device_pairing_join_codes: current main stores a setup payload containing bootstrapToken in its payload_json, but this new inventory omits the table and the regex test only recognizes token-named columns. Add the table and a payload-redaction regression after rebasing.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c5ba4efbd700.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: The current head can publish unrelated staged data or a live bootstrap credential through the new backup path.
  • merge-risk: 🚨 security-boundary: Git backup commits and the redaction inventory can expose sensitive operator or device-bootstrap material after merge.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; its body nonetheless reports real database and Gateway runs.

Evidence

Security concerns:

  • [high] Scoped backups commit the full staged index — src/snapshot/git-backup.ts:187
    A plain Git commit after path-scoped staging includes pre-existing staged files, allowing unrelated data to enter backup history and a subsequent push.
    Confidence: 0.99
  • [high] Pairing bootstrap tokens bypass redaction — src/state/secret-state-tables.ts:2
    The state redaction inventory omits device_pairing_join_codes even though current main stores setup payloads containing bootstrapToken there.
    Confidence: 0.97

What I checked:

  • Scoped commit leaks pre-staged files: The command stages only global and agents paths, but the subsequent plain Git commit consumes the full existing index; an adopted repository with an operator-staged unrelated file can therefore include and push that file in an OpenClaw backup commit. (src/snapshot/git-backup.ts:187, ce2d18a613ea)
  • Git commit contract: Git documents --only as the path-limited commit mode; the current invocation has no pathspec or --only restriction.
  • Current-main pairing credential is unredacted: Current main serializes a pairing setup payload into device_pairing_join_codes, and that payload includes bootstrapToken; the PR’s added state-secret inventory does not list this table even though the codec excludes only listed tables. (src/infra/device-pairing-join-code.ts:45, c5ba4efbd700)
  • Redaction policy is incomplete after three-way merge: The PR adds the global secret-table list, but it omits device_pairing_join_codes; its token-name-based inventory test cannot detect credentials embedded in payload_json. (src/state/secret-state-tables.ts:2, ce2d18a613ea)
  • Existing test misses the staged-index case: The adopted-repository test asserts that an untracked unrelated file stays uncommitted, but does not stage that file before backup creation. (src/snapshot/git-backup.test.ts:264, ce2d18a613ea)
  • Snapshot ownership provenance: Current-main blame attributes the existing verified SQLite snapshot publication path to Peter Steinberger, making steipete a relevant adjacent owner for this backup integration. (src/snapshot/local-repository.ts:254, 92ed766673d5)

Likely related people:

  • steipete: Current-main blame attributes the adjacent snapshot creation path to Peter Steinberger, and this PR’s backup implementation commits are authored by steipete. (role: recent snapshot contributor; confidence: high; commits: 92ed766673d5, ce2d18a613ea; files: src/snapshot/local-repository.ts, src/snapshot/git-backup.ts, src/state/secret-state-tables.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-12T08:09:27.929Z sha 7ba212ac7c7a9c17b8653bb2a633ab17a92dfc56 :: found issues before merge. :: [P1] Protect adopted backup namespaces before replacing them | [P1] Redact the existing origin before throwing | [P2] Publish the full redaction contract
  • reviewed 2026-08-12T08:15:01.412Z sha 7ba212ac7c7a9c17b8653bb2a633ab17a92dfc56 :: found issues before merge. :: [P1] Protect adopted backup namespaces before replacing them
  • reviewed 2026-08-12T09:14:14.903Z sha 7ba212ac7c7a9c17b8653bb2a633ab17a92dfc56 :: found issues before merge. :: [P1] Protect adopted backup namespaces before replacing them | [P1] Redact existing origins before reporting conflicts | [P1] Require a private Git backup root | [P2] Publish the actual staging and redaction contract
  • reviewed 2026-08-12T10:00:48.568Z sha ab908e071fd737ef7d8722b1c572720e44ecef6a :: needs changes before merge. :: [P2] Avoid bootstrapping state to log failed backups | [P2] Establish the remote before advertising pushed scheduling
  • reviewed 2026-08-12T11:57:21.674Z sha 82e1ed7 :: found issues before merge. :: [P1] Default pushed schedules to redacted backups
  • reviewed 2026-08-12T12:17:16.590Z sha 737d356 :: needs changes before merge. :: [P1] Redact audit and OAuth bearer state | [P1] Handle v6 databases without backup-run records
  • reviewed 2026-08-12T13:10:07.301Z sha 45e77a4 :: found issues before merge. :: [P1] Resolve scheduled repository paths on the Gateway | [P1] Select backup schedules by declaration key | [P1] Redact channel pairing requests from pushed backups | [P1] Validate restored databases against the requested owner | [P1] Publish Git restores through private staged storage | [P2] Keep the documented redaction inventory complete
  • reviewed 2026-08-12T13:19:48.687Z sha 45e77a4 :: found issues before merge. :: [P1] Resolve scheduled repositories on the Gateway | [P1] Validate restored database ownership after reconstruction | [P1] Publish Git restores through private staged storage | [P1] Isolate backup commits before pushing an adopted repository | [P2] Document every redacted state table

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed all seven findings on head 3891ae9:

  1. Credential redaction now covers every requested state table plus web push subscription key material, paired-device bearer tokens, channel ingress claim tokens, and agent suggestion dispatch claims. A schema ratchet scans both SQL schemas and requires each credential-suggestive table to be redacted or explicitly reviewed-safe.
  2. Repository initialization canonicalizes paths through existing ancestors and rejects overlap in either direction, including symlink aliases.
  3. Backup creation stages and checks status only under global and agents; unrelated adopted-repository files remain untouched and uncommitted.
  4. Push diagnostics redact URL userinfo and are capped at 500 characters before they can be returned, printed, or recorded.
  5. Successful local backups with failed requested pushes persist pushFailed: true; status shows (git, push failing) and Doctor points operators to the configured remote while retaining local status ok.
  6. Enable now performs one declaration-keyed cron.add; core owns the atomic create/update convergence. Disable still lists by name and removes by id.
  7. backup enable --push emits the same credential-material warning as backup git create before provisioning unless secrets are excluded.

Focused gate: 193 tests passed with 2 intentional skips; exact status-json.test.ts assertions pass unchanged. Env ratchet is 502/502, hosted pnpm build passed, and autoreview is clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

Copy link
Copy Markdown
Contributor Author

Follow-up to the seven-finding repair summary above: CI exposed that explicitly passing process.env still preserved cross-test ambient state. Final head 7ba212ac7c7a now carries the scan-owned environment into both JSON and text backup freshness reads; the unchanged status-json.test.ts assertions pass in the repaired path, the focused gate is green, the env ratchet remains 502/502, hosted build 31575627753 passed, and autoreview is clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 12, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 12, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 12, 2026
@steipete
steipete force-pushed the steipete/backup-ops-git-provider branch from ce2d18a to 5157769 Compare August 12, 2026 14:45
@steipete

Copy link
Copy Markdown
Contributor Author

Resolved both exact-head P1 findings on rebased head 5157769:

  1. Commit only backup-owned paths: backup commit creation now derives the staged non-empty backup roots and invokes git commit -m <message> -- <backup scopes>. Operator-pre-staged entries outside global/ and agents/ remain staged but never enter an OpenClaw backup commit. The regression stages unrelated.txt before backup creation, verifies git show --name-only contains only backup paths, and confirms the unrelated file remains staged and uncommitted. Deriving the non-empty scopes preserves first global-only and agent-only backups because Git rejects a never-tracked empty root pathspec.
  2. Redact current pairing join codes: after rebasing onto current main, device_pairing_join_codes is in STATE_SECRET_TABLE_NAMES. The ratchet classifies its opaque payload_json as credential-bearing because it embeds the pairing setup bootstrapToken; the Git dump fixture proves its schema and JSONL payload are absent from redacted history. The public CLI inventory remains exactly aligned with the source-of-truth list.

Commit: 5157769ab02c

Proof: focused gate green (22 unit tests, 8 command tests); env ratchet 502/502; Kysely guardrails green; format and git diff --check green; full build green; autoreview clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 37b4fc8 into main Aug 12, 2026
188 of 190 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the steipete/backup-ops-git-provider branch August 12, 2026 15:11
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
…ned snapshots (openclaw#122485)

* refactor(infra): extract shared git exec and verified snapshot-copy helpers

Moves the worktrees git wrapper to src/infra/git-exec.ts (with optional
maxOutputBytes for large buffered reads) and the online-backup/sanitize/
VACUUM/verify snapshot step into src/snapshot/openclaw-snapshot-copy.ts so
snapshot backends share one hardened copy path. Behavior-identical moves;
all importers updated.

* feat(snapshot): git-backed versioned SQLite snapshot engine

Deterministic per-table JSONL dumps (PK-ordered, lossless bigint/blob
encoding), verbatim DDL preservation, virtual/shadow-table skipping with
FTS rebuild on restore, secret-table redaction policy, manifest with
per-table row counts and content hashes, and restore verification by
re-serialization. Unchanged data produces no commit.

* feat(backup): recorded runs, freshness surfacing, and scheduled git backups

Every backup attempt is recorded in the previously writer-less backup_runs
table (bounded to 200 rows). openclaw status gains a Backups overview row
and JSON payload; doctor prints an informational hint when no successful
backup is recorded or the newest is stale. New commands: backup git
init/create/log/verify/restore and backup enable/disable, which provision
one idempotent gateway cron job running scheduled git backups.

* fix(state): stop bumping schema_meta.updated_at on unchanged opens

updated_at now records when schema metadata actually changed instead of
when the database was last opened; unconditional bumps dirtied the row on
every open and defeated no-change backup detection.

* docs: document versioned git backups, scheduling, and backup freshness

* fix(backup): satisfy CI ownership checks

* fix(backup): complete CI contract coverage

* fix(backup): complete credential table redaction

* fix(backup): isolate git repository ownership

* fix(backup): persist push degradation

* fix(backup): atomically converge schedules

* fix(status): isolate backup freshness environment

* fix(status): carry scan environment to freshness reads

* fix(backup): harden Git repository ownership

* docs(backup): document Git repository safety

* fix(backup): non-creating outcome log and origin preflight for pushed schedules

Recording a backup outcome never bootstraps an absent state database (a
failed backup on a fresh host would otherwise create a blank DB that a
retry treats as real input), and backup enable --push now requires the
repository to have an origin remote, pointing at backup git init --remote
instead of scheduling permanently degraded pushes.

* refactor(worktrees): use shared git exec helpers

* refactor(worktrees): remove unused git buffer wrapper

* refactor(worktrees): consume buffered git helper

* feat(backup): redact pushed schedules by default

Unattended recurring pushes retain credential-bearing tables durably in
remote Git history, so backup enable --push now defaults to
--exclude-secrets; --include-secrets is the explicit full-fidelity
override (still warned). Local non-push schedules keep full fidelity for
complete restores.

* fix(backup): redact audit HMAC and OAuth pending state; tolerate absent backup_runs

Adds audit_identity_keys (audit HMAC key) and mcp_oauth_pending_authorizations
(live OAuth callback state) to the redaction inventory, and makes read-only
backup freshness treat a same-version database without the additive
backup_runs table as no recorded backups instead of failing before a
writable open converges the schema.

* fix(backup): restrict schedules to local gateways

* fix(snapshot): harden Git restore and redaction

* fix(backup): block pushes of adopted history

* fix(backup): contain commits and pairing secrets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant