Skip to content

refactor(cli): collapse duplicated command plumbing - #165492

Merged
steipete merged 4 commits into
mainfrom
unify/cli-1004-batch2
Oct 5, 2026
Merged

steipete merged 4 commits into
mainfrom
unify/cli-1004-batch2

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

CLI commands repeat parsing, RPC option forwarding, formatting, and one-use wrappers that make equivalent command behavior harder to maintain.

User Impact

No user-visible change: flags, help text, output, JSON shapes, exit codes, and configuration semantics stay the same. Update/service behavior and plugin SDK contracts are preserved; no migration is required.

Why This Change Was Made

Reuse the existing parsing and formatting owners, keep command policy where it is consumed, and remove unused internal parameters and forwarding layers across configuration, models, status, onboarding, devices, nodes, cron, and capability commands. Preserve lazy imports, registration order, option-presence distinctions, and mutation ownership.

Evidence

  • Fully paginated GitHub production diff: +1,015 / -2,057 / net -1,042 across 95 production files. Measured from all 104 PR files on two API pages (gh api --paginate "repos/openclaw/openclaw/pulls/165492/files?per_page=100"); tests/support, fixtures, and generated baselines are excluded.
  • Crabbox/Hetzner focused coverage: 2,634 passed and one existing skip across 116 files. Initial selection: 639.82 s; remaining coverage: 157.29 s; corrected capability/status rerun: 131 passed in 54.05 s. The two added registration-order cases cost 0.004 s combined.
  • Full build passed in 539.00 s, including CLI bootstrap imports and public SDK declarations/exports.
  • Codex autoreview is clean through P2, including the final generated baseline updates.
  • Before publication, fixes restored the existing snapshot-call arity, preserved the precise local channel-status type, documented mock isolation, and used a Set for repeated flag membership. No assertion was weakened. Canonical ratchets only shrink.
  • After the single landing rebase, 253 focused tests passed in 39.44 s; both import-cycle checks passed in 50.09 s and 53.17 s. Rebased check:changed passed formatting, ratchets, boundaries, core/test types, and API guards in a 1,910.56 s run; its only failure was the inherited dead-export scan described below. Standalone lint of all 102 changed TypeScript files passed with zero warnings/errors in 16.72 s wall time. The verified remote source tree matches this PR head.

The inherited scan failures are GoogleMeetJoinResult in extensions/google-meet/src/transports/types.ts, resolveGatewayWorkboardWorkspaceAccess in extensions/workboard/src/gateway-helpers.ts, and MeetingRuntimeOwner in src/meeting-bot/runtime-facade-types.ts. All three reproduced on current main 10080eaf91bc314a6703c8edd629f499c0a0190b with node --import ./scripts/tsx.mjs scripts/check-deadcode-exports.mts (92.43 s). Those source files and both Knip configs are byte-identical between that main and this candidate; this PR changes none of them. No scan was skipped or baseline broadened.

Hosted CI run 37291916493 passed on exact head 04c662283a584454e6a7df7ee50398adac08b97b. Exact-head auto-merge landed this PR as fe493b83337aa4012b077fac68099bd2aba067d4.

@clawsweeper

clawsweeper Bot commented Oct 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 commands Command implementations docker Docker and sandbox tooling size: XL labels Oct 5, 2026
@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 Oct 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 6:01 AM ET / 10:01 UTC (Revision 2).

ClawSweeper review

What this changes

The PR consolidates CLI parsing, registration, formatting, and forwarding while preserving existing command behavior.

Merge readiness

⛔ Blocked before merge - 2 items remain

The refactor remains distinct from current main, and no blocking correctness defect was found. The earlier generic compatibility warning is unsupported by the introduced changes.

Priority: P3
Reviewed head: 04c662283a584454e6a7df7ee50398adac08b97b

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent simplification with substantial reported validation and no supported blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from the external-contributor runtime-proof gate. Source review found no material authority change or stored-data contract change; reported tests and builds remain supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from the external-contributor runtime-proof gate. Source review found no material authority change or stored-data contract change; reported tests and builds remain supplemental validation.
Evidence reviewed 9 items Introduced changes reviewed: Inspected the complete introduced file list and hunks in bounded groups, including original implementations. The changes consolidate existing behavior rather than adding configuration options, defaults, or storage formats.
Current-main necessity: Fetched main still contains the duplicated before/after plugin-registration wrapper that this branch consolidates. No merged replacement or canonical related item was supplied or established.
Compatibility concern reassessed: Model commands mutate a structured clone supplied by the existing source-config write owner. Replacing nested object spreads with assignments preserves the persisted representation and does not introduce a migration. Config merge and conditional-write checks retain their existing decisions.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI turns operator arguments into configuration changes, Gateway requests, and local service operations. These adapters also format command results and errors.

flowchart TD
  A[Operator arguments] --> B[CLI registration]
  B --> C[Parsing and validation]
  C --> D[Configuration owner]
  C --> E[Gateway requests]
  C --> F[Service operations]
  D --> G[Command output]
  E --> G
  F --> G
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/devices-cli.runtime.ts, migration/backfill/repair: src/cli/update-cli/status.ts, unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep shared parsing and formatting with their existing owners while preserving command-specific policy, lazy loading, and mutation boundaries.

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

Not applicable: this PR addresses duplicated internal plumbing rather than a reported behavioral failure.

Is this the best way to solve the issue?

Yes: the introduced changes reuse existing owners and remove forwarding layers without establishing a competing implementation or changed upgrade contract.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against a9f47795c00c.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is internal CLI cleanup with no established user-facing defect or intentional 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: The verified repository-admin author is exempt from the external-contributor runtime-proof gate. Source review found no material authority change or stored-data contract change; reported tests and builds remain supplemental validation.

Evidence

What I checked:

  • Introduced changes reviewed: Inspected the complete introduced file list and hunks in bounded groups, including original implementations. The changes consolidate existing behavior rather than adding configuration options, defaults, or storage formats. (04c662283a58)
  • Current-main necessity: Fetched main still contains the duplicated before/after plugin-registration wrapper that this branch consolidates. No merged replacement or canonical related item was supplied or established. (src/cli/program/register.subclis.ts:46, a9f47795c00c)
  • Compatibility concern reassessed: Model commands mutate a structured clone supplied by the existing source-config write owner. Replacing nested object spreads with assignments preserves the persisted representation and does not introduce a migration. Config merge and conditional-write checks retain their existing decisions. (src/commands/models/shared.ts:103, 04c662283a58)
  • Restart authority remains unchanged: The consolidated restart branch preserves current-target revalidation, owner-ID targeting, legacy Windows payloads, acknowledgement checks, and legacy signal fallback. It does not broaden who can request a final effect. (src/cli/daemon-cli/lifecycle-unmanaged.ts:140, 04c662283a58)
  • Verified merge-result ownership: Raw test-merge parents are the pinned base followed by the exact PR head. Comparing that merge result with its base preserves the reviewed config, model-alias, and restart refactors; endpoint drift was not attributed to this PR. (da30f9f6416f)
  • Trusted author verified: GitHub confirms steipete has repository admin permission. This resolves the conflicting association fields in the supplied context and establishes that the ordinary external-contributor proof gate does not apply.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • sxh: 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 (1 earlier review cycle)
  • reviewed 2026-10-05T09:48:14.261Z sha 04c6622 :: blocked before merge. :: none

@steipete
steipete enabled auto-merge (squash) October 5, 2026 09:58
@steipete
steipete merged commit fe493b8 into main Oct 5, 2026
168 of 170 checks passed
@steipete
steipete deleted the unify/cli-1004-batch2 branch October 5, 2026 10:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
Unify internal CLI parsing, RPC option forwarding, formatting, and one-use wrappers while preserving flags, help, output, JSON shapes, exit codes, configuration semantics, and lazy boundaries.

Production diff: +1,015/-2,057, net -1,042, measured from both GitHub file pages. Remote focused coverage, full build, rebased cycle checks, core/test types, lint, and Codex review completed. The only changed-check failure is an unrelated dead-export scan reproduced on main; see the PR evidence for exact symbols, source identity, and timings.
steipete added a commit that referenced this pull request Oct 15, 2026
* refactor: consolidate command and cron preparation paths

Keep one sub-CLI metadata/registration catalog, common cron payload updates,
canonical agent migration visitors, and shared account-state projection.
Trust typed internal adapters while retaining external validation, effect
authority, cancellation settlement, supported migrations and path containment.

Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files).
Branch-only handoff for the coordinator's bundle; no standalone PR.

Best-effort tradeoffs accepted:
- Cron mid-setup reload recovery (#146582): synthetic retirement, no human
  incident. Setup may fail; the next invocation refreshes the cache.
- Recursive shared preparation retry (#102494/#138337): synthetic concurrent
  callers; production serializes same-job work. Duplicate direct callers may
  share cancellation. Failed-owner eviction preserves the next sequential run.
- Progress publication generation (#143621): synthetic held update/reset.
  Presentation dedupe may briefly be stale until a subsequent render/reset.
- Doctor adapter schema mirror (#69919): malformed synthetic hooks. Invalid
  executable adapters fail visibly; missing-hook fallbacks and config checks stay.
- Setup adapter schema mirror (#165492): typed internal union. Invalid internal
  adapters fail when used; both supported wizard forms remain.
- Injected process schema mirror (#84381): malformed injection was not human
  SIGTERM report #71710. Invalid adapters fail registration; cancellation stays.
- Loaded registry row revalidation/copy (#114942/#158830/#114476): rows already
  admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays.
- Custom compatibility duplicate check (#14223): all callers parse/type it.
  Hand-crafted invalid JS uses the default branch; external flags still reject it.
- Log probe identity matching (#88159, superseded by #168587): abort now joins
  the sole probe, so replacement cannot race its result. Recovery/settlement stay.
- Whole-config deep copy (#71218): no detached-copy incident. Structural copy
  updates agents/defaults; unrelated future mutation must respect config ownership.
- Repeated plugin-root probes (#70012): no disappearing-root incident. Resolve
  roots once; root replacement can fail discovery. Symlink containment stays.
- Second payload getter read (#135319): synthetic review/corpus, not a human
  report. Ordinary decoded records are read once; stateful accessors may differ.

Proof: fresh independent review clean; core types, targeted lint/format, runtime
and static cycles, assertion/line-cap ratchets, and suppression suite passed.
Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup
and cold-import checks passed. Cron and commands cohorts were interrupted after
partial results; complete owner tests, payload merging, test-graph types, broad
check-changed and build/smoke remain unproved at commit preparation.

Unattributed local 120-second timeouts retained: two root-command-descriptions
catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout,
retry, skip or kept-behavior expectation changes. Env-name budget mismatch
(455 vs 454) also exists at original HEAD and pinned main 7dccff5.
All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched.

* refactor: consolidate cron payload and lazy CLI paths

Share daemon and cron method forwarding through the existing lazy binder,
remove the cron CLI reexport shim, and consolidate normalization and merge
handling without changing public fields, explicit clears, or effect authority.
Remove the obsolete bundled discovery reentry mechanism and impossible Doctor
issue helper. The full lane now removes 475 net production lines.

Best-effort tradeoffs accepted:
- Unknown Doctor issue variants supplied by hand-crafted JavaScript return the
  invalid value rather than a custom error. Typed local producers and exhaustive
  switches remain; reporting feature #95979 cites no human unknown-kind incident.
- Synchronous bundled-module self-discovery may fail through the existing loader
  diagnostic instead of returning empty inventory. Commit 65f18d6 only pins
  injected Jiti reentry, not a human incident; ordinary caches remain.
- Cron defaults trust staggerMs normalized earlier in the same synchronous call.
  No await or mutation boundary intervenes; externally supplied invalid values
  remain rejected by the normalizer.

* fix(channels): retain replacement preview deduplication

Withdraw the progress compositor generation removal after the Mattermost
retiring-publication case failed CI and bounded serial head/base replays
remained inconclusive under load. Restore that file exactly to the branch
base and keep all Mattermost tests unchanged, following the campaign fallback.

Prune the single obsolete mock-export allowance left by the removed bundled
discovery reentry fixture. The local mock ratchet passes with 9586 factories.
The remaining lane reduction is 471 net production lines across 25 paths.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…#173036)

* refactor: consolidate command and cron preparation paths

Keep one sub-CLI metadata/registration catalog, common cron payload updates,
canonical agent migration visitors, and shared account-state projection.
Trust typed internal adapters while retaining external validation, effect
authority, cancellation settlement, supported migrations and path containment.

Wave-5 y10: BELOW-500, 353 net production lines removed (+440/-793 in 19 files).
Branch-only handoff for the coordinator's bundle; no standalone PR.

Best-effort tradeoffs accepted:
- Cron mid-setup reload recovery (openclaw#146582): synthetic retirement, no human
  incident. Setup may fail; the next invocation refreshes the cache.
- Recursive shared preparation retry (openclaw#102494/openclaw#138337): synthetic concurrent
  callers; production serializes same-job work. Duplicate direct callers may
  share cancellation. Failed-owner eviction preserves the next sequential run.
- Progress publication generation (openclaw#143621): synthetic held update/reset.
  Presentation dedupe may briefly be stale until a subsequent render/reset.
- Doctor adapter schema mirror (openclaw#69919): malformed synthetic hooks. Invalid
  executable adapters fail visibly; missing-hook fallbacks and config checks stay.
- Setup adapter schema mirror (openclaw#165492): typed internal union. Invalid internal
  adapters fail when used; both supported wizard forms remain.
- Injected process schema mirror (openclaw#84381): malformed injection was not human
  SIGTERM report openclaw#71710. Invalid adapters fail registration; cancellation stays.
- Loaded registry row revalidation/copy (openclaw#114942/openclaw#158830/openclaw#114476): rows already
  admitted/normalized. Corrupt trusted rows can fail; first-wins authority stays.
- Custom compatibility duplicate check (openclaw#14223): all callers parse/type it.
  Hand-crafted invalid JS uses the default branch; external flags still reject it.
- Log probe identity matching (openclaw#88159, superseded by openclaw#168587): abort now joins
  the sole probe, so replacement cannot race its result. Recovery/settlement stay.
- Whole-config deep copy (openclaw#71218): no detached-copy incident. Structural copy
  updates agents/defaults; unrelated future mutation must respect config ownership.
- Repeated plugin-root probes (openclaw#70012): no disappearing-root incident. Resolve
  roots once; root replacement can fail discovery. Symlink containment stays.
- Second payload getter read (openclaw#135319): synthetic review/corpus, not a human
  report. Ordinary decoded records are read once; stateful accessors may differ.

Proof: fresh independent review clean; core types, targeted lint/format, runtime
and static cycles, assertion/line-cap ratchets, and suppression suite passed.
Focused CLI cohort: 8 files / 41 tests passed. Earlier unchanged account/setup
and cold-import checks passed. Cron and commands cohorts were interrupted after
partial results; complete owner tests, payload merging, test-graph types, broad
check-changed and build/smoke remain unproved at commit preparation.

Unattributed local 120-second timeouts retained: two root-command-descriptions
catalog cases and agent-via-gateway's Gateway attempt-budget case. No timeout,
retry, skip or kept-behavior expectation changes. Env-name budget mismatch
(455 vs 454) also exists at original HEAD and pinned main 89f8219.
All runtime proof used isolated HOME/OpenClaw/XDG state; Phase E untouched.

* refactor: consolidate cron payload and lazy CLI paths

Share daemon and cron method forwarding through the existing lazy binder,
remove the cron CLI reexport shim, and consolidate normalization and merge
handling without changing public fields, explicit clears, or effect authority.
Remove the obsolete bundled discovery reentry mechanism and impossible Doctor
issue helper. The full lane now removes 475 net production lines.

Best-effort tradeoffs accepted:
- Unknown Doctor issue variants supplied by hand-crafted JavaScript return the
  invalid value rather than a custom error. Typed local producers and exhaustive
  switches remain; reporting feature openclaw#95979 cites no human unknown-kind incident.
- Synchronous bundled-module self-discovery may fail through the existing loader
  diagnostic instead of returning empty inventory. Commit ca10460 only pins
  injected Jiti reentry, not a human incident; ordinary caches remain.
- Cron defaults trust staggerMs normalized earlier in the same synchronous call.
  No await or mutation boundary intervenes; externally supplied invalid values
  remain rejected by the normalizer.

* fix(channels): retain replacement preview deduplication

Withdraw the progress compositor generation removal after the Mattermost
retiring-publication case failed CI and bounded serial head/base replays
remained inconclusive under load. Restore that file exactly to the branch
base and keep all Mattermost tests unchanged, following the campaign fallback.

Prune the single obsolete mock-export allowance left by the removed bundled
discovery reentry fixture. The local mock ratchet passes with 9586 factories.
The remaining lane reduction is 471 net production lines across 25 paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docker Docker and sandbox tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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