Repository navigation
Conversation
|
🦞👀 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 changesThe PR classifies six Git backup argument errors as expected failures so JSON-mode stderr includes their existing remedies. Example: Run
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a confirmed CLI diagnostic defect still present on current main; the focused implementation has sufficient behavior proof and no actionable findings. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGit backup command handlers validate CLI scopes before invoking backup operations; the shared CLI renderer turns their errors into stderr diagnostics and JSON failure envelopes. flowchart TD
A[Backup CLI arguments] --> B[Git scope validation]
B --> C[Expected CLI error]
C --> D[Shared failure renderer]
D --> E[Actionable stderr]
D --> F[JSON stdout envelope]
B --> G[Valid backup operation]
Technical reviewBest possible solution: Retain the six in-place classifier conversions and the portable fixture correction, using the existing shared renderer. Do we have a high-confidence way to reproduce the issue? Current-main source traces these plain errors through the generic JSON-mode stderr renderer, and supplied real CLI comparisons demonstrate the failure; this read-only review ran no target code. Is this the best way to solve the issue? The patch fixes classification at the producing guards, preserving validation and output contracts without adding another rendering path; existing tests gain relevant assertions without new scaffolding. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b83aae1c4e84. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests 0. Total +3 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. 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 November 15, 2026, 7:53 PM ET / November 16, 2026, 00:53 UTC (Revision 2). |
|
Validated final head Repeated production-path proofTier: source, host through Each row was exercised twice on main and twice on candidate, in both JSON and text modes:
Main JSON stderr showed the generic failure and Doctor hint for every row: Candidate JSON stderr instead contained exactly the corresponding existing message above. For every repetition, text-mode stderr was byte-identical before/after; JSON and text stdout were byte-identical; every exit code stayed 1. No repository or restore target was created. Unknown-agent control
That is 28 real CLI invocations per side, including controls, with all stdout/stderr/exit comparisons passing. Banner suppression and no-color mode excluded unrelated presentation noise; CLI validation and normal failure rendering were not mocked. Selected identical stdout SHA-256 receipts (both repetitions, both sides):
Focused regression and fixture correctionThe initial baseline test run exposed an existing fixture portability failure: With the identical corrected fixture on both sides: candidate 19 passed; baseline 2 failed / 17 passed, exactly the missing expected-error classifications. The unknown-agent case stayed green on the baseline. The baseline test command took 42.11 seconds; the candidate test/typecheck/format sequence took 59.54 seconds. Matching typecheck leaf Merge danger: reversible error-classification/test-fixture change. Blast radius: JSON stderr presentation for the six local Git backup scope guards. Full package and final scope
Hosted gates on the final head
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in ef35477. Thanks @SunnyShu0925. |
|
@obviyus Thanks! |
…openclaw#199850) fix(cli): report backup git scope errors through the expected-error path `openclaw backup git create`, `verify` and `restore` with `--json` threw plain errors for their scope checks (a blank `--agent` or `--store`, `--all` combined with explicit scopes, no scope, or more than one scope), so `--json` stderr showed the generic failure plus the Doctor hint instead of the existing message. These checks run before the repository or any database is touched and now use the expected-error path with the same messages. An unknown agent ID stays a plain error. No new text. Evidence: host, isolated state, no Gateway. Source CLI, twice per side, with --json and in text mode (28 calls per side): `backup git create --repository <tmp>` with no scope, with `--all --global` and with `--agent ' '`; `backup git verify --repository <tmp> --store ' '`; `backup git verify --repository <tmp> --global --agent main`; and `backup git restore --repository <tmp> --target <tmp2>` with no scope. Base prints the generic failure and Doctor hint, this change prints the existing message; text-mode stderr is byte-identical, JSON stdout and exit codes match, an unknown --agent stays a plain error on both, and no repository or restore target is created. Vitest-source: two cases fail on base, 19 pass here; typecheck, full build and packed smoke pass. Receipts: openclaw#199850 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
openclaw backup git create --repository <repo> --jsonwithout a scope flag exits 1 with only[openclaw] The CLI command failed.and the doctor hint on stderr, so machine callers that read stderr never see theChoose at least one Git backup scope: --all, --global, or --agent <id>.remediation that the text lane already prints. The same gap affects all six scope/blank argument guards acrossbackup git create,backup git verify, andbackup git restore.src/commands/backup-git.ts(blank--agentelement,--allcombined with an explicit scope, missing create scope, blank--store, more than one single-identity scope, missing single-identity scope) throw a plainError. The text lane renders its message, but the JSON lane classifies it as an unexpected failure and replaces stderr with the generic failure banner, leaving the remediation only inside the stdout envelope.ExpectedCliErrorfrom the same guards via the canonicalthrowExpectedCliErrorhelper, so the JSON lane renders the same remediation the text lane prints while keeping the envelope untouched.src/commands/backup-git.tsroutes the six guards throughthrowExpectedCliError(one new import, sixthrowcall sites, identical message text).src/commands/backup-git.test.tsfolds class assertions into two existing rejection tests (a per-row error-name column in the invalid-agent table — the neighboring unknown-agent guard stays a plainError— andname: "ExpectedCliError"in the--allconflict case), net zero test lines.backupsubcommand.Why This Change Was Made
ExpectedCliErroris the shipped owner for argument-level CLI failures (src/cli/expected-cli-error.ts), so the fix reuses the existing failure classifier instead of adding a rendering path. This is the same per-site conversion already merged for the sibling backup guards: #199573 (backup record), #199763 (backup create --to), and #199781 (backup verify/restore --namespace).error.messagefor plainErrortoo. Rejected: that would leak stack-y unexpected failures into the expected lane and change every other command at once.User Impact
Operators and CI jobs that run
backup git create/verify/restorewith--jsonnow get the actionable remediation on stderr (for exampleChoose a Git backup scope: --global, --agent <id>, or --store <id>.), matching the text lane, instead of a generic failure banner. Scripts that parse the stdout envelope see no change.Compatibility
cmp-verified below).src/commands/backup-git.ts, but it changes which agent database a snapshot captures (import rename plus the post-guard database resolution and happy-path tests); it does not touch these six guard throws or the two rejection tests folded here. The changes are complementary — whichever merges first, the other needs only a mechanical rebase.Evidence
Both arms were built with the shipped CLI pipeline (
node --import ./scripts/tsx.mjs scripts/build-all.mts cliStartup) and exercised through the real launcher (node openclaw.mjs <cmd>) withenv -iand a fresh chmod-700 scratchHOME/XDG_RUNTIME_DIR/OPENCLAW_STATE_DIRper cell — no gateway, no credentials, no mocks.--versionself-reports both arm identities: baseOpenClaw 2026.11.3 (e693b33), this headOpenClaw 2026.11.3 (6eb8f16). The finalruntime-postbuildmetadata phase fails identically on both arms on a dangling plugin-dependency symlink in the build host's shared checkout (pre-existing environment issue); the launcher and every cell below run on the produceddist.backup git ..., all with--repository <repo>)create --agent " " --json--agent must not be blank; stdout envelope byte-identical (104 B)create --all --global --jsonUse --all by itself, or select --global and --agent scopes explicitly.; envelope byte-identical (149 B)create --json(no scope)Choose at least one Git backup scope: --all, --global, or --agent <id>.; envelope byte-identical (150 B)verify --store " " --json--store must not be blank; envelope byte-identical (104 B)verify --global --agent main --jsonChoose exactly one Git backup scope: --global, --agent <id>, or --store <id>.; envelope byte-identical (156 B)verify --json(no scope)Choose a Git backup scope: --global, --agent <id>, or --store <id>.; envelope byte-identical (146 B)--json)cmpreports no difference on all six)backup verify <missing-archive> --json(non-guard failure)cmp); generic pair retainedbackup verify <missing-archive> --namespace probe --json(sibling guard converted by #199781)--namespace requires --from <location>.cmp); remedy retained, no generic bannerPre-fix JSON lane (base build, representative cell):
Post-fix JSON lane (this head build, identical command):
The
log file append failedline is scratch-environment noise emitted identically by both arms in every cell; it is included in all byte counts andcmpcomparisons.Invariants across the two builds (104 automated checks, all passing):
Reachability was verified on the base arm with
OPENCLAW_DEBUG=1(the plainErrorprints a stack; the expected error does not). Frame excerpt, paths shortened to dist-relative:The
verifyno-scope cell shows the analogousresolveOneIdentityframe. Serialized shipped bundles of the changed owner prove the executed form on each arm:The folded regression assertions are red against the frozen pre-fix owner (detached base worktree, production untouched) and green on this head:
The unknown-agent row of the same table asserts
name: "Error"and passes on both arms, pinning that the neighboring guard (a different owner) is not over-converted.What was not tested: no Windows or macOS run;
backup git restoreshares theresolveOneIdentityowner withverifyand was not driven separately; commander-level missing-value rejections happen before the owner and are not exercised. Both arms' builds fail identically in the finalruntime-postbuildmetadata phase on the shared checkout's dangling plugin-dependency symlink (environment, pre-existing); thecheck-cli-bootstrap-importsguard passed on both arms.Open PR collision check: on the day of writing, the full open-PR list (3611 PRs) was scanned by changed-file list (GraphQL for the newest 1100, REST per-PR files for the remainder; four empty-diff PRs verified individually). Only #161230 touches
src/commands/backup-git.ts/backup-git.test.ts; its hunks (canonical agent-database selection for--agentsnapshots) do not intersect the six guard throws or the two folded rejection cases, so it is complementary, not a duplicate (see Compatibility). Same-family merges this week are per-site siblings (#199573, #199763, #199781); none covers thebackup gitscope guards.Maintainer validation
Validated
501efb5896f447a998a51963feb031a985c6d4db: twice-per-side real CLI scope guards, byte-identical text/JSON/exit controls, unchanged unknown-agent errors, regression, typecheck and packed-install receipts. The contributor production fix is unchanged. The added commit only makes an existing external-root fixture independent of the macOS/tmpalias; no case was removed and test growth remains zero.Merge danger: reversible error-classification/test-fixture change. Blast radius: JSON stderr presentation for six local Git backup scope guards.