Skip to content

test(cli): keep parser coverage without formatter self-comparison - #133771

Merged
steipete merged 1 commit into
mainfrom
codex/test-audit-cli-parser-contract
Aug 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/test-audit-cli-parser-contract

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

The registered-command test replaced real actions with synthetic failures, injected its own JSON formatter, then compared that formatter with itself. It could verify parser acceptance but could not independently detect broken JSON failure output.

Why This Change Was Made

Keep real command registration and declared output-flag parsing, and assert that each parser reaches the original synthetic failure. Remove the injected formatter/runtime and name the test for the parser contract it actually checks. Simplify the adjacent required-argument fixture's identical variadic and nonvariadic branches.

User Impact

No CLI behavior or JSON schema changes. The preceding inventory still checks route-first JSON support. Independent literal formatter/redaction assertions, asynchronous exit-finalization tests, and real entrypoint process tests for routed and Commander failures remain.

Evidence

Direct Commander source confirms that replacing action handlers bypasses the original commands, and the retained throw preserves hook ordering. The real CLI entrypoints own JSON error output; their callbacks and existing process assertions were inspected. No test execution is removed.

All 58 focused tests passed before and after across command registration/parsing, literal failure formatting, and one-shot exit behavior. Codex autoreview found no accepted actionable findings. The changed-file gate passed, including dead-export scans, core-test typechecking, formatting, lint, and repository guards. Tests +5/-22 lines (net -17); production and test support unchanged.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS maintainer Maintainer-authored PR labels Aug 31, 2026
@steipete
steipete marked this pull request as ready for review August 31, 2026 03:59
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 12:06 AM ET / 04:06 UTC.

ClawSweeper review

What this changes

This PR replaces a CLI inventory test’s synthetic JSON formatter self-comparison with a check that every command declaring its own --json option accepts it and dispatches to the injected action.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. No blocking finding: the change correctly limits this inventory test to Commander parser acceptance, while OpenClaw’s real entrypoints and dedicated tests retain JSON failure-envelope coverage; current main still has the self-comparison this PR removes.

Priority: P3
Reviewed head: 083e94a08c186102f58067c0826486bd1d15b6bb

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-neutral test cleanup with a sound owner-boundary split and no blocking correctness or security concern.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, test-only change does not alter user-visible runtime behavior; its relevant evidence is the parser and failure-output test boundary rather than a live setup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, test-only change does not alter user-visible runtime behavior; its relevant evidence is the parser and failure-output test boundary rather than a live setup.
Evidence reviewed 6 items Introduced test boundary: The pinned PR delta changes only the parser-inventory test: it filters to commands with an own --json option and asserts that parsing reaches the injected failure, rather than wrapping that parse in a second formatter.
Current-main need: Fetched current main still contains the former test, which injects a formatter through runCliWithExitFinalization and compares its output to another invocation of that same formatter; the PR is therefore not superseded.
Production owner separation: The real CLI entrypoint calls program.parseAsync, while src/index.ts owns final error formatting and exit finalization. The removed wrapper in this registration test was not exercising that production boundary.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI registers Commander command trees, then its top-level entrypoint parses a selected command and formats failures for terminal or JSON output. This test enumerates the registered tree to guard the declared parser options without becoming the failure-output owner.

flowchart LR
  Registry[Command registry] --> Tree[Registered command tree]
  Tree --> Parser[Commander parser]
  Parser --> Action[Injected test action]
  Entry[CLI entrypoint] --> Formatter[JSON failure formatter]
  Formatter --> Output[Terminal or JSON output]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: this active maintainer-owned PR has no actionable review defect.
Agent review details

Security

None.

PR surface

Tests -17. Total -17 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 5 22 -17
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 5 22 -17

Review metrics

Metric Value Why it matters
Production versus test delta production 0; tests +5/-22 (net -17) The PR removes an isolated test-only wrapper and adds no runtime, configuration, or dependency surface.

Technical review

Best possible solution:

Land the focused test refactor while retaining the dedicated formatter, parse-error, and real-entrypoint failure tests as the canonical JSON-output coverage.

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

Not applicable: this is a test-only PR. Source inspection establishes the intended parser and formatter boundaries; no reported end-user failure needs reproduction.

Is this the best way to solve the issue?

Yes. The parser inventory now proves the contract it can independently observe, while the real CLI entrypoint and dedicated failure-output tests continue to own JSON failure behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a small test-quality cleanup with no user-facing runtime behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, test-only change does not alter user-visible runtime behavior; its relevant evidence is the parser and failure-output test boundary rather than a live setup.

Label justifications:

  • P3: This is a small test-quality cleanup with no user-facing runtime behavior change.
  • 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 maintainer-authored, test-only change does not alter user-visible runtime behavior; its relevant evidence is the parser and failure-output test boundary rather than a live setup.

Evidence

What I checked:

  • Introduced test boundary: The pinned PR delta changes only the parser-inventory test: it filters to commands with an own --json option and asserts that parsing reaches the injected failure, rather than wrapping that parse in a second formatter. (src/cli/program/root-command-descriptions.test.ts:428, 083e94a08c18)
  • Current-main need: Fetched current main still contains the former test, which injects a formatter through runCliWithExitFinalization and compares its output to another invocation of that same formatter; the PR is therefore not superseded. (src/cli/program/root-command-descriptions.test.ts:430, 607821e11d1d)
  • Production owner separation: The real CLI entrypoint calls program.parseAsync, while src/index.ts owns final error formatting and exit finalization. The removed wrapper in this registration test was not exercising that production boundary. (src/cli/run-main.ts:1741, 083e94a08c18)
  • Independent formatter coverage: Dedicated tests directly assert the typed JSON envelope, redaction, debug behavior, and parse-error formatting, so removing the inventory test’s formatter self-comparison does not remove the formatter contract. (src/cli/failure-output.test.ts:14, 083e94a08c18)
  • Commander contract: OpenClaw pins Commander 15.0.0. Its locally cached package source shows action(fn) replaces _actionHandler, and parseAsync(args, { from: 'user' }) parses only supplied user arguments, so the retained assertion proves both option acceptance and dispatch to the injected failure. (package.json:2072, 083e94a08c18)
  • Relevant history: The previous test was added with current-main commit 3efa9e8; this PR’s sole commit revises that same surface. The older commit’s parent object is unavailable locally, so this is routing context rather than a verified source-line introduction claim. (src/cli/program/root-command-descriptions.test.ts:428, 3efa9e83063f)

Likely related people:

  • steipete: 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.

@steipete
steipete merged commit 072aabb into main Aug 31, 2026
183 checks passed
@steipete
steipete deleted the codex/test-audit-cli-parser-contract branch August 31, 2026 04:43
@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 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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: XS 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