Skip to content

refactor(cli): consolidate repeated command registration - #119434

Merged
steipete merged 1 commit into
mainfrom
codex/loc-0804-cli-luem8u
Aug 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/loc-0804-cli-luem8u

Conversation

@steipete

@steipete steipete commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Model fallback, node lifecycle, system heartbeat, and TTS commands repeated structurally identical Commander registration and dispatch. This is part of a maintainer-requested project-wide production LOC reduction campaign.

Why This Change Was Made

Use focused owner-local command registration tables while preserving command order, help text, flags, defaults, lazy loading, and errors.

User Impact

All documented CLI commands and output remain unchanged; removes 105 production lines.

Evidence

Exact-head Commander registration and dispatch proof

The four exact committed production modules were checked against their Git blob IDs, TypeScript-transpiled in memory, and executed with the real installed Commander 15 parser. Runtime, gateway, and native service operations were safely replaced only at their external dispatch boundaries; no operator gateway, service, account, or network was touched.

$ git rev-parse HEAD
06f4227cbd7edc76e15dc6a28832a5aa972fb262
$ openclaw infer tts convert --text hello --provider xiaomi --json
[mock dispatch] {"handler":"runTtsConvert","text":"hello","provider":"xiaomi","transport":"local"}
[stdout] {"ok":true,"capability":"tts.convert","transport":"local","provider":"xiaomi","outputs":[]}
$ openclaw infer tts set-persona --off --json
[mock dispatch] {"handler":"runTtsStateMutation","capability":"tts.set-persona","persona":null,"transport":"gateway"}
$ openclaw models fallbacks --help
Commands:
  list [options]  List fallback models
  add <model>     Add a fallback model
  remove <model>  Remove a fallback model
  clear           Clear all fallback models
$ openclaw models fallbacks add openai/gpt-5.6-luna
[mock dispatch] {"handler":"modelsFallbacksAddCommand","model":"openai/gpt-5.6-luna"}
$ openclaw models image-fallbacks list --json
[mock dispatch] {"handler":"modelsImageFallbacksListCommand","json":true,"plain":false}
$ openclaw node restart --json
[mock dispatch] {"handler":"runNodeDaemonRestart","json":true}
$ openclaw system heartbeat enable --json
[mock dispatch] {"handler":"callGatewayFromCli","method":"set-heartbeats","enabled":true,"json":true,"expectFinal":false}
[stdout] {"ok":true,"enabled":true}
$ openclaw system heartbeat disable --json
[mock dispatch] {"handler":"callGatewayFromCli","method":"set-heartbeats","enabled":false,"json":true,"expectFinal":false}
[stdout] {"ok":true,"enabled":false}
PASS: exact-head production Commander registration, help, flags, defaults, and 10 safely mocked dispatch scenarios

All ten actual production registration/dispatch assertions passed at the unchanged exact reviewed head, fulfilling the requested TTS, model fallback, node, and heartbeat evidence.

Base-refresh disposition: The exact reviewed CLI head already passed 182 focused tests, the full remote changed gate, exact-head hosted required CI, and the production Commander dispatch transcript above. Rebasing solely because unrelated mainline commits advanced is intentionally skipped: no conflict exists, a rebase would invalidate the reviewed exact SHA and its proof, and the canonical maintainer merge workflow revalidates current-main drift and all required checks immediately before landing.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L maintainer Maintainer-authored PR labels Aug 5, 2026
@steipete
steipete marked this pull request as ready for review August 5, 2026 02:50
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 11:23 PM ET / August 5, 2026, 03:23 UTC.

ClawSweeper review

What this changes

This PR replaces repeated Commander CLI registrations for TTS, model fallbacks, node lifecycle actions, and heartbeat controls with local command tables while preserving their public commands and output.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for maintainer merge judgment. The exact-head refactor preserves the inspected CLI registration and dispatch contracts, and the updated terminal proof addresses the prior proof request; no actionable patch defect was found.

Priority: P3
Reviewed head: 06f4227cbd7edc76e15dc6a28832a5aa972fb262
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused source comparison, existing contract tests, exact-head terminal proof, and green supplied checks support a normal mergeable-quality cleanup.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.
Evidence reviewed 6 items Exact PR surface: The reviewed commit changes exactly four CLI registration modules and is a net reduction of 105 production lines, with no test, dependency, workflow, config, or migration change.
TTS owner and dispatch contract: The shared helper retains local defaults for conversion/providers/personas and gateway defaults for state mutations; existing runtime owners still receive the same transport and capability values.
Sibling command contracts: The fallback table retains command names, help text, arguments, list flags, lazy loaders, and parent JSON inheritance; node and heartbeat loops retain their handler order and gateway payloads. Existing system tests directly assert both heartbeat payloads.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI lazily registers operator commands, parses options with Commander, and sends normalized requests to local runtime, gateway, or node-service handlers. This change affects the registration layer before those existing dispatch owners run.

flowchart LR
  Operator[CLI operator] --> Registry[CLI command registration]
  Registry --> Parser[Commander parser]
  Parser --> Options[Parsed options]
  Options --> Dispatch[Runtime gateway or node dispatch]
  Dispatch --> Result[CLI output]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled CLI LOC-reduction refactor be landed after its current-main refresh? Refresh and merge: Refresh the branch against current main, verify the exact resulting head, and merge the focused refactor.

Why: The patch is behavior-preserving by the inspected source and proof, but the protected maintainer label requires an explicit human merge decision and the branch is behind current main.

Before merge

None.

Agent review details

Security

None.

PR surface

Source -105. Total -105 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 4 202 307 -105
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 202 307 -105

Review metrics

Metric Value Why it matters
Production versus test delta production -105, tests +0 The four-file cleanup reduces duplicated production registration code without expanding the test surface or public configuration.

Stored data model

Persistent data-model change detected: serialized state: src/cli/capability-cli/tts.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

  • GitHub reports the branch behind current main; the four paths have no intervening main-branch change, but landing should use an exact-current-head refresh and required checks.

Maintainer options:

  1. Decide the mitigation before merge
    Keep one owner-local registration table per repeated command family and merge it only after an exact-current-main validation refresh confirms the preserved CLI contract.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one owner-local registration table per repeated command family and merge it only after an exact-current-main validation refresh confirms the preserved CLI contract.

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

Not applicable: this is a behavior-preserving refactor, and the exact-head terminal transcript plus focused existing tests exercise the retained registration-to-dispatch paths.

Is this the best way to solve the issue?

Yes. Local tables remove structurally repeated registration while keeping command-specific transport, validation, formatting, lazy loading, and dispatch ownership in their existing modules.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 0ef191119290.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This is a focused, behavior-preserving CLI cleanup with no reported user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.
  • proof: sufficient: Contributor real behavior proof is sufficient. The updated PR body provides an exact-head terminal transcript that directly exercises real Commander parsing and the changed registration-to-dispatch boundary; external service calls are safely mocked beyond that boundary.

Evidence

What I checked:

  • Exact PR surface: The reviewed commit changes exactly four CLI registration modules and is a net reduction of 105 production lines, with no test, dependency, workflow, config, or migration change. (src/cli/capability-cli/tts.ts:21, 06f4227cbd7e)
  • TTS owner and dispatch contract: The shared helper retains local defaults for conversion/providers/personas and gateway defaults for state mutations; existing runtime owners still receive the same transport and capability values. (src/cli/capability-cli/tts.ts:48, 06f4227cbd7e)
  • Sibling command contracts: The fallback table retains command names, help text, arguments, list flags, lazy loaders, and parent JSON inheritance; node and heartbeat loops retain their handler order and gateway payloads. Existing system tests directly assert both heartbeat payloads. (src/cli/system-cli.test.ts:126, 11027a3712b9)
  • Current-main and release status: The PR head is not contained in current main or any local release tag; current main has no intervening change in these four paths relative to the PR parent, so the refactor remains a distinct open contribution. (src/cli/models-cli.ts:194, 0ef191119290)
  • History routing: Visible current-source attribution for all four parent modules traces to the same recent source-introduction commit; partial-clone history could not establish an older feature lineage. (src/cli/node-cli/register.ts:125, 11027a3712b9)
  • After-fix behavior proof: The PR body contains an exact-head terminal transcript using the committed modules and real Commander 15 parsing, covering TTS conversion/persona, both fallback groups, node restart, and both heartbeat payloads while mocking only external dispatch boundaries. (06f4227cbd7e)

Likely related people:

  • Vincent Koc: The available blame and short history attribute the current parent implementations across all four affected modules to the same source-introduction commit; deeper lineage is unavailable in this partial clone. (role: visible current-source contributor; confidence: medium; commits: 11027a3712b9; files: src/cli/capability-cli/tts.ts, src/cli/models-cli.ts, src/cli/node-cli/register.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh against current main and rerun the required checks on the resulting exact head before landing.

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-05T03:04:33.234Z sha 06f4227 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete
steipete merged commit 752dd2b into main Aug 5, 2026
206 of 222 checks passed
@steipete
steipete deleted the codex/loc-0804-cli-luem8u branch August 5, 2026 03:51
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. 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.

1 participant