Skip to content

fix(backup): keep a configured agent's Git backup scope when it cannot be copied - #149265

Merged
steipete merged 3 commits into
mainfrom
upd/backup-all-retain-scope-128010
Sep 15, 2026
Merged

steipete merged 3 commits into
mainfrom
upd/backup-all-retain-scope-128010

Conversation

@steipete

@steipete steipete commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #128010

What Problem This Solves

openclaw backup git create --all deletes a configured agent's previous backup when its database is missing, or aborts every agent's backup when one database fails snapshot maintenance validation after an upgrade.

Reported by @yetval (#128010).

User Impact

With --all, eligible agents are refreshed, unavailable configured agents retain their previous scope, and only agents removed from configuration are pruned. Degraded agents appear in CLI warnings, JSON warnings, and the existing recorded backup outcome.

Explicit --agent selection still fails for an unavailable database. Runs with no copyable databases still fail. A retained scope remains its previous snapshot; this does not migrate or repair the source database.

Why This Change Was Made

Keep the complete configured roster through staging, handle per-agent snapshot failures there, and pass the retained scopes explicitly to pruning. Copy only successfully staged manifests into the repository. Reuse the existing outcome error field without changing the outcome store's schema or retention. Update the Git backup documentation and shrink the assertion baseline for the removed cast.

Evidence

The existing regression drives separate real command processes with synthetic config files and SQLite databases, then checks committed Git tree hashes, CLI/JSON diagnostics, and persisted outcomes.

Before the fix, the same regression had two expected failures and one pass:

missing: fatal: path 'agents/ops' does not exist in 'HEAD'
old-schema: uses schema version 19; run openclaw doctor --fix before compacting it
removed: passed
Tests 2 failed | 1 passed

After the fix, the required suite passed:

node scripts/run-vitest.mjs src/commands/backup-git.test.ts src/snapshot/git-backup.test.ts src/snapshot/git-backup-streaming.test.ts src/commands/backup-schedule.test.ts
[test] passed 3 Vitest shards (52 passed, 1 Windows-only skip)

This covers retained scopes, refreshed healthy agents, removed-agent pruning, explicit-selection and zero-copyable failures, and 256 MiB streaming backup/restore/verification. Changed-file checks passed, including core and test typechecks, lint, and storage/import guards. No live scheduled job or external backup remote was exercised; scheduler argv coverage and isolated local Git proof cover this change.

The lead's independent P1 review is scoped-clean at 62ab114da6b79cacbd34ddfee575a0af5bcacdff. The landing refresh rebased all three commits onto d363685cab9fd6c6202998216cf945c46a195904, which contains both required fixture repairs (7dc8a1e79659afb833df4bbfe363744c8d775e5c and 273b6c5e114). All three range-diff entries are unchanged, and the aggregate stable patch ID is identical. The GitHub merge ref contains both fixes. No code changed during this refresh.

Exact-head CI for b94044f0e533a4ebc3b28b217d1d73293853d039 passed: 101 checks passed, 44 skipped, and none failed or remained pending, including openclaw/ci-gate. The one-hour watcher expired during runner queueing; the prescribed fallback polling confirmed green on its twelfth read. A transient API rate-limit read recovered without rerunning CI.

ClawSweeper review

The completed ClawSweeper review at b94044f0e533a4ebc3b28b217d1d73293853d039 reports no actionable findings and acknowledges the accepted diagnostic follow-up. No fixups applied. The P2 combined-warning budget finding is deferred under the maintainer's explicit P1-reviewed, patch-identical landing scope: sufficiently long agent warnings can truncate the saved push diagnostic at the existing 1,200-unit limit. The independent pushFailed flag and full CLI/JSON diagnostics remain available. A follow-up should budget the combined persisted diagnostic and cover mixed degradation plus push failure. The rebase changes no code, so no re-review command is requested.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations labels Sep 15, 2026
@steipete
steipete marked this pull request as ready for review September 15, 2026 16:22
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 15, 2026, 2:47 PM ET / 18:47 UTC (Revision 5).

ClawSweeper review

What this changes

Preserve configured agents’ previous Git backup scopes when their databases cannot be copied, refresh healthy agents, and report degraded backups.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this fixes a remaining backup defect in current main and v2026.9.4. No new blocking finding was identified; the earlier diagnostic-budget concern has an explicit maintainer disposition accepting it as follow-up.

Priority: P1
Reviewed head: b94044f0e533a4ebc3b28b217d1d73293853d039

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful production-boundary evidence and an explicitly accepted diagnostic limitation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied before/after output maps to inspected child processes exercising the real backup command, SQLite snapshot owner, and Git repository, with assertions covering retained scopes, healthy refreshes, pruning, and persisted degradation; no live scheduler or external remote was exercised.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied before/after output maps to inspected child processes exercising the real backup command, SQLite snapshot owner, and Git repository, with assertions covering retained scopes, healthy refreshes, pruning, and persisted degradation; no live scheduler or external remote was exercised.
Evidence reviewed 8 items Introduced retention logic: The complete local introduced diff was inspected. Copy failures are tolerated only for agents under --all; pruning receives the complete selected roster, and only successfully staged manifests replace scopes. Global and explicit-selection failures still propagate.
Still necessary on main: Comparison with fetched main shows that main still skips missing agent databases before unconditional stale-scope removal and lacks per-agent snapshot-failure retention. The earlier configured-root repair does not implement this remaining behavior.
Released behavior checked: GitHub source reads for v2026.9.4 confirm missing-database skipping and unconditional removal of existing agent scopes. This release does not contain the proposed retention behavior.
Findings None None.
Security None None.

How this fits together

Git backups turn configured OpenClaw SQLite databases into versioned snapshots in an operator-owned repository. Both manual and scheduled backups use this path to refresh snapshots and remove retired agent scopes.

flowchart TD
  A[Manual or scheduled backup] --> B[Configured database roster]
  B --> C[Validated SQLite snapshots]
  C --> D{Agent copy succeeds?}
  D -->|Yes| E[Refresh backup scope]
  D -->|No| F[Retain prior scope and warn]
  B --> G[Prune removed agents]
  E --> H[Git commit and recorded outcome]
  F --> H
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - Accepted follow-up: sufficiently long agent warnings can consume the saved 1,200-unit diagnostic budget and omit the push failure cause; the independent pushFailed flag and CLI/JSON diagnostics remain available.
Agent review details

Security

None.

PR surface

Source +19, Tests +150, Docs +8, Other -1. Total +176 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 2 49 30 +19
Tests 4 292 142 +150
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 8 349 173 +176

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Honor the accepted diagnostic follow-up (recommended)
    Retain the documented maintainer disposition while preserving full CLI/JSON diagnostics and the independent persisted pushFailed flag.

Technical review

Best possible solution:

Keep the approved retention contract and canonical snapshot validation, with combined diagnostic budgeting handled at the producer in a follow-up.

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

Yes: source establishes the missing-database prune and old-schema abort paths, and the PR supplies a failing-before/passing-after command-process regression; this review did not execute it.

Is this the best way to solve the issue?

Yes: retaining the configured roster through existing staging and pruning is a focused repair that avoids migrating live databases or weakening snapshot validation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The default scheduled backup path can remove a configured agent’s current backup scope or abort healthy-agent backups when one database is unavailable.
  • merge-risk: 🚨 other: Combining degradation and push warnings can truncate persisted failure details, a concrete diagnostic limitation explicitly accepted for follow-up.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied before/after output maps to inspected child processes exercising the real backup command, SQLite snapshot owner, and Git repository, with assertions covering retained scopes, healthy refreshes, pruning, and persisted degradation; no live scheduler or external remote was exercised.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied before/after output maps to inspected child processes exercising the real backup command, SQLite snapshot owner, and Git repository, with assertions covering retained scopes, healthy refreshes, pruning, and persisted degradation; no live scheduler or external remote was exercised.

Evidence

What I checked:

  • Introduced retention logic: The complete local introduced diff was inspected. Copy failures are tolerated only for agents under --all; pruning receives the complete selected roster, and only successfully staged manifests replace scopes. Global and explicit-selection failures still propagate. (src/snapshot/git-backup.ts:302, b94044f0e533)
  • Still necessary on main: Comparison with fetched main shows that main still skips missing agent databases before unconditional stale-scope removal and lacks per-agent snapshot-failure retention. The earlier configured-root repair does not implement this remaining behavior. (src/commands/backup-git.ts:86, e7dde047904e)
  • Released behavior checked: GitHub source reads for v2026.9.4 confirm missing-database skipping and unconditional removal of existing agent scopes. This release does not contain the proposed retention behavior. (src/snapshot/git-backup.ts, 3a9d69db306c)
  • Maintainer-confirmed retention direction: The maintainer comment explicitly distinguishes the shipped roster repair from remaining unavailable-database behavior and selects retaining configured scopes with degradation reporting: backup: Git backup --all prunes agent scopes whose registry schema version lags the running build after an upgrade #128010 (comment) .
  • Production-boundary regression evidence: The inspected regression launches separate processes calling the real backup command with real SQLite databases and Git repositories. It checks initial creation, unchanged degraded-agent tree hashes, refreshed healthy-agent trees, removed-agent pruning, CLI/JSON warnings, persisted outcomes, and explicit-selection failure. The captured PR body reports two pre-fix failures and an after-fix suite result of 52 passed with one Windows-only skip; sourceRevision is ef58575a3a502ba2172b2147a1e35f2536e049a8fab7940c712663ffd47ce458. Tests were not rerun during this read-only review. (src/snapshot/git-backup.test.ts:258, b94044f0e533)
  • Prior finding disposition: Agent warnings precede the push warning in the combined persisted diagnostic, whose existing owner truncates at 1,200 UTF-16 units. The captured PR body explicitly defers that earlier P2 finding; pushFailed and separate CLI/JSON diagnostics remain available. The prior completed review has no outstanding findings. Direct comparison with its older head could not complete because that object was unavailable; no new claim of independently verified patch identity is made. (src/commands/backup-git.ts:142, b94044f0e533)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ben.Li: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (4 earlier review cycles)
  • reviewed 2026-09-15T16:33:45.826Z sha e55342a :: needs maintainer review before merge. :: none
  • reviewed 2026-09-15T17:01:10.909Z sha 62ab114 :: needs changes before merge. :: [P2] Budget combined warnings before recording the backup outcome
  • reviewed 2026-09-15T17:12:49.367Z sha 62ab114 :: needs changes before merge. :: [P2] Budget combined warnings before recording the backup outcome
  • reviewed 2026-09-15T18:16:08.778Z sha 6907889d5dbe39b37f7fe0dae5961a2b2d648c71 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 15, 2026
@steipete
steipete force-pushed the upd/backup-all-retain-scope-128010 branch from 62ab114 to 6907889 Compare September 15, 2026 18:09
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 15, 2026
Keep configured scopes during --all backups when an agent database is missing or fails snapshot validation. Record degraded agents while copying healthy scopes, and prune only removed agents. Explicit selections still fail loudly.
@steipete
steipete force-pushed the upd/backup-all-retain-scope-128010 branch from 6907889 to b94044f Compare September 15, 2026 18:31
@steipete
steipete merged commit a47c579 into main Sep 15, 2026
157 checks passed
@steipete
steipete deleted the upd/backup-all-retain-scope-128010 branch September 15, 2026 19:55
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
…t be copied (openclaw#149265)

Keep configured agents' previous Git backup scopes when their databases are missing or fail snapshot maintenance validation during an all-agent backup. Refresh healthy scopes, prune only removed agents, and report degradation through CLI/JSON warnings and the recorded backup outcome. Explicit agent selections and runs with no copyable databases still fail.

Real command-process regressions cover missing and old-schema agents, retained Git trees, healthy refreshes, removed-agent pruning, and recorded outcomes. The landing rebase preserves the reviewed patch exactly.

Fixes openclaw#128010
Reported by @yetval (openclaw#128010).

ClawSweeper's P2 combined-warning truncation finding is deferred under the approved P1 landing scope; the pushFailed flag and CLI/JSON diagnostics remain available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backup: Git backup --all prunes agent scopes whose registry schema version lags the running build after an upgrade

1 participant