Skip to content

fix(cli): preserve command dispatch and structured errors - #139067

Merged
steipete merged 2 commits into
mainfrom
codex/deslop-cli-parent-options
Sep 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/deslop-cli-parent-options

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #139053

Additional instructions

MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.

What Problem This Solves

Fixes an issue where config reads and skill verification lost their usual structured errors when a parent option or -- preceded the child command. For example, openclaw config -- get and openclaw skills -- verify returned human-only missing-argument errors even though those commands normally own machine-readable output.

The same disagreement about argument roles also sent openclaw -- config get gateway.mode into the TUI and treated a value spelled --card in skills verify --version --card or --tag --card as a request for card output.

Why This Change Was Made

Command discovery, startup selection, and output ownership now reuse the existing root/parent parser. Leading literal boundaries survive downstream parsing and lazy command dispatch, and the existing Commander token-role helper serves both models and skills output detection. This removes duplicate config, skills, root-index, Gateway-path, and models-output scanning paths.

Canonical command paths still pass through the catalog's longest-prefix policy lookup. Membership-only rows for seven existing model child roots preserve their default startup behavior, while nested skills commands retain their proxy bypass. Gateway foreground/respawn selection uses the same command-path owner; literal --force and --reset stay operands. Conservative execution routing still falls through to Commander when needed.

User Impact

Parent option values remain values, commands still dispatch after --, and structured errors remain available where they are already the command's default. Actual --card retains human output, config set keeps parse-only --json, and literal --help stays an operand after a terminator. No flags, configuration fields, defaults, dependencies, schemas, or persistence contracts are added. Current main's SkillWorkshop storage ownership changes are preserved.

Evidence

Full build and official CLI proof are complete. CI and the separate full-head source review are green at the current head.

Committed candidate: 3d752f9da95c90ead28774745659af521a406826, based on current main 31903060a5d4a98ccd367aa6f15e66339a3ddcba. The committed diff matches the final reviewed and checked tree.

Before production edits, real Commander comparisons and the actual OpenClawCommand error boundary reproduced the failures. The original built CLI also confirmed the leading-terminator TUI dispatch and card-shaped option-value failures. New root/tail, help, Gateway, lazy reparse, and respawn tests were captured failing before their repairs.

The current-main focused suite passed 529 tests across 12 files. After the typecheck caught two test-declaration issues, both corrected files passed their 69-case boundary suite without changing assertions or production behavior. Coverage includes root/parent/leaf terminators, literal help operands, required values spelled --, real card flags versus option values, Gateway destructive-option fencing, conservative route fallback, channels-add consumers, and complete model/startup policy dimensions.

Production: 105 added / 161 removed, net -56 lines. Tests: 297 added / 8 removed, net +289. Documentation: +4. No test-only production hooks were introduced.

Commander 15.0.0 was personally inspected in this checkout: lib/command.js child dispatch at line 1562, terminator handling at line 1789, and required-value consumption at line 1808. The launcher validates profile arguments before version handling: --profile --version returns a missing-value error, while --profile work --version succeeds. This preserves the existing validation owner.

Pinned oxfmt 0.65.0 and whitespace checks pass. Final P2 review and the independent source challenge are clean; the final full changed gate passes, including core/test types, changed-file lint, dead-export scans, storage/loader/security guards, and runtime import-cycle checks. A second review also caught a help-classification regression when a command-owned value resembled a root option before --help. Four real-Commander cases reproduced it before the early help policy was restored to its existing conservative owner. The corrected help/profile/container/entry/Gateway sweep passes 373 tests across nine files.

The full pnpm build passed in 3m 14s, including runtime bundles, declarations, plugin artifacts, Control UI budgets, and CLI bootstrap checks. dist/build-info.json records 4a7ad309e387ebbc553965991aca71f15bc13a00. All 21 files in that built candidate are byte-for-byte identical at the current head; the successor only updates the existing startup-context test. Dependencies were installed into this checkout with the frozen lockfile; no shared install was reconciled.

54/54 official dist CLI cases passed through node openclaw.mjs, using temporary synthetic home/state/config. Stdout, stderr, and exit codes were captured and completely inspected. There was no source loader or output-suppression override. Machine-output commands produced only their raw value or JSON; requested help retained its ordinary help text.

Actual command families Observed result
Config get/file, six plain/parent/root-terminator/profile forms each Exit 0, exact raw port/config path, empty stderr
Missing config path and skill reference, including root/parent terminators Exit 1, JSON cli_error plus normal diagnostic on stderr
Skills verify with --version --card / --tag --card, with/without parent agent Exit 1, default JSON missing-reference error; real --card keeps human output
Literal --help at root, parent, and leaf boundaries Intended unknown-command, excess-argument, or unknown-config-path error; no TUI or help takeover
Gateway run with literal --force --reset, root/parent/leaf forms Exit 1 parse error, no config rewrite, no listener
Skills Workshop list, with/without parent agent Exit 0, empty proposals-manifest JSON despite unusable proxy CA
Models refresh and scan Expected unreadable proxy CA failure, preserving their default proxy policy
Skills tag/version, models provider, and agent message values spelling --log-level before --help Exit 0 help with empty stderr despite unusable proxy CA
Root profile/container validation and profiled version Existing validation errors preserved; valid version identifies the candidate head

All 54 cases left their synthetic config unchanged and no Gateway listener behind; the fixture was removed. Config reads also used the unusable proxy CA to prove their existing bypass. These runtime captures are attributed to 4a7ad309e387ebbc553965991aca71f15bc13a00 and remain applicable because all original candidate file blobs are unchanged. Exact-head CI passed for 3d752f9da95c.

CI run 33975607691 caught an obsolete test assertion that expected Gateway token values to be misidentified as commands. The committed test-only correction updates the existing case to use valid acp --token client input and verifies that the authoritative ACP action path preserves protocol stdout. It no longer pins approximate parser output; negative-token and actual-client cases remain. The original 21 files and all production bytes are unchanged, preserving the completed build and 54-case runtime evidence. The corrected test was independently reviewed through P2; its 239-case focused suite and scoped changed-file gate pass. Fresh exact-head CI is green.

The separate final 22-file source review is clean at 3d752f9da95c90ead28774745659af521a406826, with verified inheritance from the unchanged production candidate and fresh inspection of the test correction. CI preflight actually tested merge 170a152fac87923c4b8a9ea68bedd268b0f32e8b, whose ordered parents are main 707edba619a6244fb6a465f9c4b01a856994a29c and this exact PR head.

The latest completed ClawSweeper review at exact 3d752f9d (16:49 UTC) accepts the 54-case runtime proof and has no patch/security finding. Its remaining environment limitation obtaining Commander 15.0.0 is addressed by actual pinned-source inspection by the owner, independent peers, and separate direct reviewer. No production behavior changed in the test-only successor, and no duplicate re-review request was posted.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 cli CLI command changes size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 12:49 PM ET / 16:49 UTC.

ClawSweeper review

What this changes

Unifies CLI argument discovery and output detection so parent options and option terminators preserve command dispatch and machine-readable errors.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful fix for a defect still present on current main. No introduced correctness defect was found, and the latest test-only commit preserves the supplied production proof.

Priority: P2
Reviewed head: 3d752f9da95c90ead28774745659af521a406826

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent owner-level repair with substantial packaged-CLI evidence and no actionable correctness findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied 54 packaged-CLI runs exercise discovery, registered parsing, structured errors, and startup policy with isolated state, observing correct output and no unintended config changes or listeners; the subsequent commit changes only a test.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied 54 packaged-CLI runs exercise discovery, registered parsing, structured errors, and startup policy with isolated state, observing correct output and no unintended config changes or listeners; the subsequent commit changes only a test.
Evidence reviewed 11 items Introduced scope and review continuity: The pinned merge-base comparison contains the CLI repair. Comparing the previously reviewed production candidate with HEAD shows only the resolved-action-path test correction; no production behavior changed. The stale test merge was not used to infer removal of current-main behavior.
Canonical argument owner: Root discovery retains leading literal command words, command-path parsing consumes required values, and delegated argument tails retain the terminator. Config and skills reuse the existing parent parser alongside agent, models, channels, and update.
Output ownership and error boundary: Skills registration passes the active Commander command into output detection. The shared option-role helper distinguishes a real card flag from a required option value; OpenClawCommand.error and JSON-mode metadata retain ownership of structured parse failures. Models reuse the same helper, while config set retains its parse-only JSON contract.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI examines arguments before loading commands to select startup behavior and output handling. Commander then parses the registered command tree and dispatches actions or reports errors.

flowchart TD
  A[CLI arguments] --> B[Shared argument discovery]
  B --> C[Startup and proxy policy]
  B --> D[Command registration]
  D --> E[Commander parsing]
  E --> F[Command action]
  E --> G[Structured or human error]
  C --> F
Loading

Before merge

  • Resolve merge risk (P1) - Independent Commander 15.0.0 source verification remains unavailable in this reviewer environment; dependency semantics are supported here by the supplied real-CLI results and parser comparisons.
Agent review details

Security

None.

PR surface

Source -56, Tests +289, Docs +4. Total +237 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 12 105 161 -56
Tests 9 297 8 +289
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 406 169 +237

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net -56 lines; tests net +289; docs +4 The repair removes duplicate parsing paths while adding boundary coverage, with no test-only production hooks.
Startup policy preservation 7 existing model child roots explicitly cataloged; 0 new public options Explicit membership preserves child defaults when canonical paths pass through longest-prefix lookup.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139053
Summary: This PR is the explicit candidate fix for the open structured-error issue; neither item is proven resolved by a merge.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep argument interpretation in the shared discovery and Commander option-role owners, preserving command-specific output and startup policies without adding configuration.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep argument interpretation in the shared discovery and Commander option-role owners, preserving command-specific output and startup policies without adding configuration.

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

Yes, from current-main source: config -- get and skills -- verify lose output classification at the terminator. The contributor supplies failing-before and packaged after-fix observations; this review did not execute them.

Is this the best way to solve the issue?

Yes for the inspected OpenClaw boundary: reusing existing argument and option-role owners removes the disagreement more cleanly than adding separate output guards.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This repairs bounded CLI dispatch and structured-error failures affecting scripts and operator commands.
  • 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 54 packaged-CLI runs exercise discovery, registered parsing, structured errors, and startup policy with isolated state, observing correct output and no unintended config changes or listeners; the subsequent commit changes only a test.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied 54 packaged-CLI runs exercise discovery, registered parsing, structured errors, and startup policy with isolated state, observing correct output and no unintended config changes or listeners; the subsequent commit changes only a test.

Evidence

What I checked:

  • Introduced scope and review continuity: The pinned merge-base comparison contains the CLI repair. Comparing the previously reviewed production candidate with HEAD shows only the resolved-action-path test correction; no production behavior changed. The stale test merge was not used to infer removal of current-main behavior. (src/cli/command-execution-startup.test.ts:140, 3d752f9da95c)
  • Canonical argument owner: Root discovery retains leading literal command words, command-path parsing consumes required values, and delegated argument tails retain the terminator. Config and skills reuse the existing parent parser alongside agent, models, channels, and update. (src/infra/cli-root-options.ts:46, 3d752f9da95c)
  • Output ownership and error boundary: Skills registration passes the active Commander command into output detection. The shared option-role helper distinguishes a real card flag from a required option value; OpenClawCommand.error and JSON-mode metadata retain ownership of structured parse failures. Models reuse the same helper, while config set retains its parse-only JSON contract. (src/cli/skills-cli.ts:579, 3d752f9da95c)
  • Startup, routing, and sibling coverage: Seven model child catalog entries preserve their existing default policy during longest-prefix lookup. Gateway parsing preserves literal destructive flags as operands. Route-first parsers still reject terminator-containing invocations and defer to Commander; regression coverage exercises these boundaries and nested skills proxy selection. (src/cli/command-catalog.ts:344, 3d752f9da95c)
  • Still necessary on current main: The fetched main revision retains the config scanner that returns null at a terminator; its skills scanner has the same stopping behavior and spelling-only card detection. The supplied linked issue describes those exact failures. No merged replacement is established. (src/cli/config-output-mode.ts:23, 426ca0d50f30)
  • Documented output contract: The CLI reference defines nonzero JSON failures on stdout, and docs/cli/skills.md documents verification JSON by default with explicit card output. The added terminator example matches the supplied packaged-CLI observations. Public docs: docs/cli/index.md. (docs/cli/index.md:73, 3d752f9da95c)

Likely related people:

  • Peter Steinberger: 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 (3 earlier review cycles)
  • reviewed 2026-09-05T12:14:18.787Z sha d4f35c3 :: blocked before merge. :: none
  • reviewed 2026-09-05T12:24:36.611Z sha d4f35c3 :: blocked before merge. :: none
  • reviewed 2026-09-05T15:50:58.188Z sha 4a7ad30 :: blocked before merge. :: none

@steipete
steipete marked this pull request as ready for review September 5, 2026 12:18
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Further source and real-distribution checks found two existing defects in the same command/token-role invariant. Holding this PR for their repair before landing.

openclaw -- config get gateway.mode entered the TUI and failed for lack of a TTY, while the equivalent invocation without the root terminator returned the configured value. The installed Commander 15.0.0 correctly dispatches the complete invocation; early root discovery loses it.

skills verify --version --card and skills verify --tag --card omitted the normal JSON missing-argument error. Commander correctly consumes --card as the required option value and leaves the card flag false, but the output detector matches its spelling. A genuine card flag must continue to select human output.

Both were reproduced through the built CLI in isolated synthetic state with stdout, stderr, and exit status captured. The repair will keep root command discovery and registered option-role facts as their existing owners, with failing-before regression coverage and refreshed focused, build, review, and exact-head CI proof. The earlier 230 tests and 20 distribution checks remain valid for their tested cases; they did not cover these two paths.

@steipete
steipete force-pushed the codex/deslop-cli-parent-options branch from d4f35c3 to 4a7ad30 Compare September 5, 2026 15:42
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L and removed size: S labels Sep 5, 2026
@steipete steipete changed the title fix(cli): preserve structured output around parent options fix(cli): preserve command dispatch and structured errors Sep 5, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Updated this PR to 4a7ad309e387ebbc553965991aca71f15bc13a00, integrating the complete repair with current main. The canonical command-path parser now preserves leading literal boundaries and required option values; config, skills, models and Gateway startup use the appropriate shared owners. A review-caught help-classification regression was reproduced with actual Commander calls and repaired before this push.

Final local proof is green: complete changed-file checks, P2 review, independent source challenge, official build (3m14s), and 54 isolated invocations through node openclaw.mjs. Output, exit status, unchanged fixture config and absence of leftover listeners were verified. The full change removes 56 production lines. Fresh hosted CI and the separate exact-head review are pending; prior-head CI is not claimed for this revision.

The automatic fresh ClawSweeper review of this exact head is already in progress. The rewritten PR body includes the root cause, preserved parser/proxy contracts, failing-before cases and final packaged-CLI proof; no duplicate review request is needed.

@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Final head 3d752f9da95c90ead28774745659af521a406826 is ready to land. Exact-head CI 33977508865 and the separate complete-head source review pass. The test-only successor preserves all 21 original file blobs and modes, retaining the completed official build and 54 packaged-CLI cases at 4a7ad309e387ebbc553965991aca71f15bc13a00. The startup test correction additionally passes 239 focused cases and its classified gate.

I read the latest completed ClawSweeper review, now covering this exact head at 16:49 UTC. It accepts the real CLI proof and reports no correctness or security finding. Its sole Before merge item is unavailable Commander source in that reviewer environment. This is resolved: I personally inspected the installed Commander 15.0.0 dispatch, terminator and required-value implementation, alongside the independent peers and separate reviewer. The actual dependency paths are lib/command.js:1562, :1789, and :1808; observed CLI behavior corroborates those contracts. There are no additional rank-up moves.

The canonical parser and registered option-role owners preserve command-specific output/startup policy while removing 56 production lines. All 54 synthetic runs retained config bytes and left no listener. Main has no overlap with this PR's 22 files or its dependency pins since the tested main parent. Proceeding through native prepare/merge; the body records the original bugs, repaired help regression, obsolete CI test correction and proof boundaries.

@steipete
steipete merged commit bdd75d4 into main Sep 5, 2026
179 checks passed
@steipete
steipete deleted the codex/deslop-cli-parent-options branch September 5, 2026 17:01
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to aniruddhaadak80/openclaw that referenced this pull request Sep 5, 2026
* commit '3e4becea5e2ce38ede69e8ecf5302805ecbfc09c':
  refactor: simplify outbound message execution context (openclaw#139107)
  fix(models): keep ordinary chat selections session-scoped (openclaw#139232)
  docs: slim root agent instructions and clarify testing scope (openclaw#139236)
  test(agents): give the sibling-drain completion wait a tolerance on slow runners (openclaw#139176)
  refactor(workboard): use canonical queries for card-tree writes (openclaw#139106)
  fix(canvas): recognize versioned macOS nodes (openclaw#138958)
  fix: load GitHub connections without a default agent (openclaw#139222)
  fix(memory): explain unsafe legacy host-event path recovery (openclaw#139195)
  refactor(talk): centralize typed voice session queries (openclaw#139103)
  fix(cli): preserve command dispatch and structured errors (openclaw#139067)
  refactor(agents): consolidate reply failure summaries (openclaw#139175)
  fix(auth): keep an unset default model unchanged during login (openclaw#139218)
  perf(media): reuse validated attachment read handles (openclaw#139168)
  refactor(channels): simplify account configuration updates (openclaw#139096)
  refactor(android): remove unused updater export root (openclaw#139198)
  fix(gateway): stop admitting post-ready producers during close (openclaw#139092)
  fix(gateway): expose agent hook completion outcomes (openclaw#139155)
  fix(config): return the saved configuration after plugin install commits (openclaw#139203)
  fix(android): reduce repeated retries to unreachable gateways (openclaw#138732)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…39067)

* fix(cli): preserve parent command argument roles

* test(cli): preserve resolved action path coverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

Bug: config and skills lose structured errors after the option terminator

1 participant