Skip to content

refactor(backup): unify required path resolution - #128132

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/backup-required-path
Aug 23, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/backup-required-path

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Backup commands independently normalized required repository, target, snapshot, and scratch paths. The duplicate policy could drift across Git backup, SQLite backup, whole-archive restore, and scheduled backup flows.

Why This Change Was Made

backup-shared.ts now owns required backup path validation and user-path resolution. All four command surfaces call that canonical helper in their existing order, preserving exact missing-value errors, whitespace trimming, effective-home expansion, relative-path resolution, and absolute paths.

This removes four local wrappers without changing CLI, configuration, storage, or backup behavior. Production delta: +37/-53 (net -16).

User Impact

No intended user-visible change. Backup path handling remains consistent while the duplicated policy is removed.

Evidence

  • node scripts/run-vitest.mjs src/commands/backup-shared.test.ts - 7 passed
  • node scripts/run-vitest.mjs src/commands/backup-git.test.ts - 8 passed
  • node scripts/run-vitest.mjs src/commands/backup-sqlite.test.ts - 10 passed
  • node scripts/run-vitest.mjs src/commands/backup-restore.test.ts - 7 passed
  • node scripts/run-vitest.mjs src/commands/backup-schedule.test.ts - 9 passed
  • Targeted oxfmt and git diff --check passed
  • Autoreview passed with no actionable findings
  • check-changed passed its source guards, formatting, dead-export scan, core typecheck, and lint. Its core-test typecheck stopped on missing shared-install UI dependencies (@panzoom/panzoom and pako typings), unrelated to these backup command files; repository policy forbids dependency installation inside this GWT.

@clawsweeper

clawsweeper Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 23, 2026
@vincentkoc
vincentkoc force-pushed the refactor/backup-required-path branch from 348d32b to 52eeac6 Compare August 23, 2026 06:25
@vincentkoc
vincentkoc force-pushed the refactor/backup-required-path branch from 52eeac6 to 594c549 Compare August 23, 2026 06:27
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Aug 23, 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 exact_review_queue).
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 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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 23, 2026
@clawsweeper

clawsweeper Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 2:45 AM ET / 06:45 UTC.

ClawSweeper review

What this changes

The PR replaces four duplicate backup-path validators with one shared resolver used by Git backup, SQLite snapshot, archive restore, and scheduled-backup commands.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings. This maintainer-authored, maintainer-labeled cleanup remains open for the normal merge decision once exact-head checks complete.

Priority: P3
Reviewed head: 594c54900ac3561bac43f7e53e302d5f486e84f4
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with direct source-equivalence evidence and no actionable finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored refactor is exempt from the external-contributor proof gate; its discussion additionally records focused Testbox and sanitized remote validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored refactor is exempt from the external-contributor proof gate; its discussion additionally records focused Testbox and sanitized remote validation.
Evidence reviewed 7 items Behavior-preserving shared resolver: The new helper retains the previous required-value error and delegates path resolution to the existing canonical user-path resolver.
Canonical path contract: resolveUserPath trims, expands an effective-home prefix, and returns path.resolve output, making the removed outer path.resolve calls redundant.
All affected command surfaces use the one helper: Git, SQLite, archive restore, and scheduled backups call the shared resolver at their existing path-consumption boundaries.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw backup git init --repository ' '

Result: PASS (completed)

pnpm openclaw backup git init --repository '   '
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128132-riOAf9/target$ pnpm openclaw backup git init --repository '   '
$ node scripts/run-node.mjs backup git init --repository '   '
pnpm openclaw backup git init --repository '   '
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 111.18 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.8s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 15.1s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4553ms (slowest: built plugin control-plane loads 3778ms)
│
◇

OpenClaw 2026.8.1 (594c549) — I can grep it, git blame it, and gently roast it—pick your coping mechanism.

Missing required --repository value.
[ELIFECYCLE] Command failed with exit code 1.
runner@runnervm76f27:/tmp/clawsweeper-live-proof-128132-riOAf9/target$ pnpm openclaw backup git init --repository '   '
$ node scripts/run-node.mjs backup git init --repository '   '


Assertions:

  • PASS expect_output: Missing required --repository value.

How this fits together

Backup CLI commands receive operator-supplied filesystem paths before handing them to Git, SQLite snapshot, archive-restore, or Gateway scheduling operations. The shared helper now owns the common required-value check, trimming, home expansion, and absolute-path resolution.

flowchart LR
  A[Backup CLI paths] --> B[Shared required-path resolver]
  B --> C[Git backup commands]
  B --> D[SQLite snapshot commands]
  B --> E[Archive restore]
  B --> F[Scheduled backup setup]
Loading

Decision needed

Question Recommendation
Should this maintainer-authored backup-path consolidation merge once its exact-head required checks are green? Merge after exact-head checks: Accept the canonical resolver because it preserves the existing path contract across every caller while removing duplicate policy.

Why: The protected maintainer label requires explicit maintainer handling even though source review found no correctness blocker.

Before merge

  • Complete next step (P2) - No repair is needed; explicit maintainer merge handling remains because the PR carries the protected maintainer label.
Agent review details

Security

None.

PR surface

Source -16, Tests +37. Total +21 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 5 37 53 -16
Tests 1 37 0 +37
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 74 53 +21

Review metrics

Metric Value Why it matters
Production versus test delta production -16 net (37 added, 53 removed); tests +37 The refactor removes four duplicate implementations while adding focused shared-contract coverage.

Technical review

Best possible solution:

Land the single canonical resolver after exact-head CI confirms the already-reviewed behavior-preserving refactor.

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

Not applicable: this refactor has no reported defect; equivalence is directly established from the former wrappers and the canonical path-resolver contract.

Is this the best way to solve the issue?

Yes. A single helper at the shared backup boundary removes four copies while preserving the prior validation and resolution behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a small behavior-preserving cleanup of backup command internals.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored refactor is exempt from the external-contributor proof gate; its discussion additionally records focused Testbox and sanitized remote validation.

Evidence

What I checked:

  • Behavior-preserving shared resolver: The new helper retains the previous required-value error and delegates path resolution to the existing canonical user-path resolver. (src/commands/backup-shared.ts:18, 594c54900ac3)
  • Canonical path contract: resolveUserPath trims, expands an effective-home prefix, and returns path.resolve output, making the removed outer path.resolve calls redundant. (src/infra/home-dir.ts:146, 594c54900ac3)
  • All affected command surfaces use the one helper: Git, SQLite, archive restore, and scheduled backups call the shared resolver at their existing path-consumption boundaries. (src/commands/backup-git.ts:146, 594c54900ac3)
  • Existing behavior and new boundary coverage: SQLite command tests retain required repository, snapshot, and target assertions; the new helper test covers blank input, relative paths, effective-home expansion, and absolute paths. (src/commands/backup-shared.test.ts:9, 594c54900ac3)
  • Current-main comparison: The current-main snapshot differs only by this six-file refactor; the PR's base-to-current-main comparison reports no intervening changes to the production files. (src/commands/backup-shared.ts:18, 33abd6273131)
  • Feature-history provenance: Blame attributes the duplicated required-path implementations across all four current-main command files to the same historical commit, supporting consolidation at the shared backup boundary. (src/commands/backup-git.ts:41, a9e3b69750e0)

Likely related people:

  • Vincent Koc: Prior merged backup work includes SQLite snapshot ownership validation and verified snapshot support; the author also recorded the exact merge-tree validation. (role: recent backup contributor and likely merge decision owner; confidence: high; commits: f5b3f2a89da2, 2f25e9cba384; files: src/commands/backup-sqlite.ts, src/commands/backup-shared.ts)
  • Vyctor H. Brzezowski: Current-main blame assigns the duplicated required-path implementations in Git, SQLite, restore, and schedule commands to the same commit. (role: introduced current duplicated resolver behavior; confidence: high; commits: a9e3b69750e0; files: src/commands/backup-git.ts, src/commands/backup-sqlite.ts, src/commands/backup-restore.ts)
  • Peter Steinberger: History includes whole-archive restore and backup-path test work on the shared backup surface. (role: historical backup and restore contributor; confidence: medium; commits: e69a973bfb74, 86679ba84e7c; files: src/commands/backup-restore.ts, src/commands/backup-shared.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 (1 earlier review cycle)
  • reviewed 2026-08-23T06:31:20.181Z sha 594c549 :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

Maintainer decision: mark ready and keep the reviewed head unchanged.

ClawSweeper rank-up move handled: I am not rebasing solely for unrelated main movement because that would rewrite the exact head after full proof. The unchanged touched blobs plus clean current-main merge tree provide the requested merge-head refresh without invalidating exact-head evidence.

@vincentkoc
vincentkoc marked this pull request as ready for review August 23, 2026 06:41
@vincentkoc
vincentkoc merged commit 68b4aab into main Aug 23, 2026
297 checks passed
@vincentkoc
vincentkoc deleted the refactor/backup-required-path branch August 23, 2026 07:02
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant