Skip to content

refactor(cli): deslop CLI and command flows - #164159

Merged
steipete merged 6 commits into
mainfrom
deslop/l341-simplify-cli-commands-20261002
Oct 3, 2026
Merged

steipete merged 6 commits into
mainfrom
deslop/l341-simplify-cli-commands-20261002

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

CLI and command flows accumulated forwarding layers, test-only branches, and duplicate classification/reporting logic that make their behavior harder to follow.

User Impact

The refactor preserves command flags, successful output, configuration, persisted data, July 2026 and newer migration contracts, authority checks, and lazy runtime boundaries. The small bug fix described below makes unexpected security-remediation failures visible and nonzero.

Why This Change Was Made

This batch removes 1,031 net production lines and 190 test/support lines without moving code to another subsystem.

  • TTS authentication hydrates the selected provider directly while preserving root/channel, alias, and explicit-key precedence.
  • Routed commands and plugin registration use native lazy imports without additional promise caches; setup, message preload, help, and daemon output lose single-use forwarding objects and functions. Plugin registration now has one validated entry point and one session-close owner; tests consume that entry point and the existing descriptor leaf directly.
  • Startup policy drops two unused modes; cron drops redundant descriptors/types, and image metadata shares its existing flag vocabulary.
  • Config patch reading and validation use their concrete flow, reuse SecretRef coercion, and avoid deep-cloning read-only schema output.
  • Doctor uses one SQLite report aggregator, one model-compatibility classification, the existing compaction-consumer scanner, and direct auth/context-health projections. Locked OAuth repair and plugin repair eligibility retain their existing owners.
  • Dashboard readiness is specialized to its sole production caller. Passive inference discovery and private QA loading lose injection knobs that only tests supplied; QA tests load real temporary artifacts.
  • Smaller binding, MCP, exec-policy, snapshot, transcript, memory-health, and log-tail simplifications remove redundant adapters and checks.

Fixes found along the way

security audit --fix --json caught an unexpected fixer rejection, omitted the fix result, and returned a successful audit-only response. The command now propagates that rejection to the existing root CLI failure handler, which emits the standard redacted failure envelope and exit status 1. Successful output remains unchanged; the failure behavior is documented. Its Commander regression failed on the old code and passed after the fix.

Evidence

Independent autoreview completed with no remaining actionable P0–P2 findings. Runtime build passed all 11 stages (31m53s); core types, all 27 test-type shards, scoped lint, and production/full-tree/script export scans passed. Ratchets and dependency, plugin, schema, storage, media, webhook, and pairing guards passed. The affected type graphs were checked again after consolidating plugin registration.

Completed test selections passed 1,686 tests, including 1,132 plugin-contract tests across 48 files. The security regression in src/cli/security-cli.test.ts failed before the fix and passed afterward; the security/failure-output/cron selection passed all 47 tests. The private QA test passed with one worker (18.31s wall time on the loaded development host); hosted CI timing is pending.

One Gateway memory fixture timed out during setup while invoking memory index --agent main --force, before its semantic-recall assertion. The coordinator classified this as host-load noise and directed publication without the remaining local shards; no timeout or assertion was weakened. Hosted CI on the published head is the remaining gate.

Before publication, check-madge-import-cycles.ts reported 0 cycles and check-import-cycles.ts reported 0 runtime value cycles. The reviewed batch was then rebased onto fresh origin/main as directed.

The initial hosted run passed 92 checks but exposed two inherited startup-admission failures, also present in earlier main CI. Main repaired the owner in b978fc0e0e7: startup does not rewrite config for webhook completion, and completion markers live in SQLite. This branch includes that fix without changing its owners or weakening the admission assertions.

The follow-up rebase also preserves main's newer invalid-config lifecycle and log-recovery fixes. Conflicts were limited to command catalog grouping and the inlined log-fetch flow; independent review of the rebased batch found no actionable P0–P2 issues. Before the replacement push, both cycle checks again reported 0. The selected tests passed all 1,249 cases across 57 files: 104 CLI cases, all 13 startup-admission cases (including both earlier failures), and 1,132 plugin-contract cases. No assertions or timeouts changed. The three Vitest selections took 1,150.35s on the loaded development host.

Remote attempt: Blacksmith Testbox tbx_01m40jyr34wn0h7ec2gswtycyy stayed queued for ten minutes and failed hydration before the payload ran; the lease is stopped. The authorized fallback ran the focused node scripts/run-vitest.mjs selection plus check-madge-import-cycles.ts and check-import-cycles.ts serially with nice -n 15. A newer main caller of the warning-merge helper required retaining that shared helper for service start and unmanaged stop recovery. Existing stop-output tests caught the integration error; the corrective change preserves main's warning order and empty-warning omission.

Final repair proof passed on Blacksmith Testbox tbx_01m40nm3serw3g7fbzs3mafn1a (run): frozen install, pnpm tsgo:core, all 88 tests in the three lifecycle-core suites, and both import-cycle checks (0). The payload took 165.88s and the Vitest selection took 17.71s. The tested source tree 623f8fdf2c035da205704468450c1c48e41a72f0 exactly matches the committed tree. Independent review of this repair was clean through P2; the lease is stopped. Hosted CI run 37117777343 passed on exact head bc00f18f4ebf757997fdeb0b28201734aa298482; both required CI-gate statuses succeeded. GitHub squash-merged this PR as 3e710dbfe96da54b751abd6d5fb0bd2ddd3c9171, verified as an ancestor of freshly fetched origin/main. No admin exception was used.

@clawsweeper

clawsweeper Bot commented Oct 3, 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 docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes security Security documentation commands Command implementations size: XL labels Oct 3, 2026
@steipete
steipete enabled auto-merge (squash) October 3, 2026 08:03
@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 Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 6:57 AM ET / 10:57 UTC (Revision 4).

ClawSweeper review

What this changes

The branch simplifies CLI routing, plugin registration, configuration handling, and Doctor reporting, and makes unexpected security-remediation failures return an error.

Merge readiness

⛔ Blocked before merge - 1 item remains

The previous warning-merge blocker is resolved, and no remaining actionable regression was found. The security-failure fix remains absent from current main and the latest release, so the PR still has useful work.

Likely related people: steipete (high-confidence routing from prior CLI and plugin work).

Priority: P2
Reviewed head: bc00f18f4ebf757997fdeb0b28201734aa298482

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The prior blocker is repaired and the inspected patch is coherent, with substantial reported validation and no remaining concrete correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The author’s verified repository admin role exempts this PR from external-contributor runtime proof. Lifecycle tests and the security rejection regression are supplemental validation, not independently observed live behavior; no material stored-data contract change was identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author’s verified repository admin role exempts this PR from external-contributor runtime proof. Lifecycle tests and the security rejection regression are supplemental validation, not independently observed live behavior; no material stored-data contract change was identified.
Evidence reviewed 11 items Previous finding resolved: The exact previous-head comparison restores mergeWarnings. The current implementation combines captured and reported warnings in order, omits an empty result, and retains the unmanaged-stop caller at line 409.
Useful fix remains: The branch awaits security remediation without swallowing unexpected rejection. The added Commander regression checks rejection and absence of successful JSON output; the documentation describes the failure outcome.
Current-main necessity check: At the fetched main revision, unexpected fixer rejection is still caught and converted to null, allowing audit-only success output.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI turns operator commands and configuration into local operations or Gateway requests. These changes simplify command preparation and reporting while retaining the existing runtime and state owners.

flowchart TD
  A[Operator command] --> B[CLI routing]
  B --> C[Configuration preparation]
  C --> D[Plugin registration]
  C --> E[Local command or Doctor]
  D --> E
  E --> F[Gateway or local state]
  E --> G[Success or failure output]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -1031, Tests -190, Docs +2, Other -1. Total -1220 across 74 files.

View PR surface stats
Area Files Added Removed Net
Source 54 820 1851 -1031
Tests 18 202 392 -190
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 4 -1
Total 74 1027 2247 -1220

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-auth.ts, migration/backfill/repair: src/commands/doctor-config-preflight-worker-scope.ts, migration/backfill/repair: src/commands/doctor-config-preflight.ts, migration/backfill/repair: src/commands/doctor-memory-search.ts, migration/backfill/repair: src/commands/doctor-session-snapshots.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-diagnostics.ts, and 26 more. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep command preparation and reporting with their existing owners, preserving successful output and supported migrations while surfacing unexpected remediation failures.

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

Yes, source establishes the security-failure mechanism: a fixer rejection becomes null on current main and permits audit-only success. The branch adds a focused rejection regression; this review did not execute it.

Is this the best way to solve the issue?

Yes. The inspected simplifications retain existing owners, and propagating unexpected fixer failure to the shared CLI failure handler is a narrow repair.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • 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: The author’s verified repository admin role exempts this PR from external-contributor runtime proof. Lifecycle tests and the security rejection regression are supplemental validation, not independently observed live behavior; no material stored-data contract change was identified.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is normal-priority CLI maintenance with a focused correction to misleading security-remediation success output.
  • 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 author’s verified repository admin role exempts this PR from external-contributor runtime proof. Lifecycle tests and the security rejection regression are supplemental validation, not independently observed live behavior; no material stored-data contract change was identified.

Evidence

What I checked:

  • Previous finding resolved: The exact previous-head comparison restores mergeWarnings. The current implementation combines captured and reported warnings in order, omits an empty result, and retains the unmanaged-stop caller at line 409. (src/cli/daemon-cli/lifecycle-core.ts:91, bc00f18f4ebf)
  • Useful fix remains: The branch awaits security remediation without swallowing unexpected rejection. The added Commander regression checks rejection and absence of successful JSON output; the documentation describes the failure outcome. (src/cli/security-cli.ts:120, bc00f18f4ebf)
  • Current-main necessity check: At the fetched main revision, unexpected fixer rejection is still caught and converted to null, allowing audit-only success output. (src/cli/security-cli.ts:120, 9c1e4ce25273)
  • Latest-release check: The same rejection-swallowing implementation remains in v2026.9.8; the branch’s security-failure behavior is not already supplied by that release. (src/cli/security-cli.ts:120, fc23bc864e45)
  • Plugin registration boundary: Registration is consolidated into the existing validated-config entry point with one session-close owner. Reference searches found no remaining executable caller of the removed entry point and no exported Plugin SDK contract using it. (src/plugins/cli.ts:29, bc00f18f4ebf)
  • Migration and authority review: Catalog cleanup retains the unique matching transport-route predicate; OAuth cleanup retains identity comparison and rechecking within the existing locked updater. The inspected changes do not introduce a stored format, migration policy, or expanded authorization scope. (src/commands/doctor/shared/stale-oauth-profile-shadows.ts:207, bc00f18f4ebf)

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.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-03T08:06:49.469Z sha 94d822c :: blocked before merge. :: none
  • reviewed 2026-10-03T08:22:48.230Z sha 94d822c :: blocked before merge. :: none
  • reviewed 2026-10-03T10:38:38.474Z sha 2524667 :: blocked before merge. :: [P1] Preserve warning merging for the remaining stop caller

Route unexpected fixer errors through the standard CLI failure owner. Preserve the validated cron stream mode union after removing its duplicated result type.
@steipete
steipete disabled auto-merge October 3, 2026 09:54
@steipete
steipete force-pushed the deslop/l341-simplify-cli-commands-20261002 branch from 94d822c to 2524667 Compare October 3, 2026 10:32
@steipete
steipete enabled auto-merge (squash) October 3, 2026 10:33
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 3, 2026
@steipete
steipete disabled auto-merge October 3, 2026 10:39
@steipete
steipete enabled auto-merge (squash) October 3, 2026 10:52
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 3, 2026
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Oct 3, 2026
@steipete
steipete merged commit 3e710db into main Oct 3, 2026
154 checks passed
@steipete
steipete deleted the deslop/l341-simplify-cli-commands-20261002 branch October 3, 2026 11:04
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
## What Problem This Solves

CLI and command flows accumulated forwarding layers, test-only branches, and duplicate classification/reporting logic that make their behavior harder to follow.

## User Impact

The refactor preserves command flags, successful output, configuration, persisted data, July 2026 and newer migration contracts, authority checks, and lazy runtime boundaries. The small bug fix described below makes unexpected security-remediation failures visible and nonzero.

## Why This Change Was Made

This batch removes 1,031 net production lines and 190 test/support lines without moving code to another subsystem.

- TTS authentication hydrates the selected provider directly while preserving root/channel, alias, and explicit-key precedence.
- Routed commands and plugin registration use native lazy imports without additional promise caches; setup, message preload, help, and daemon output lose single-use forwarding objects and functions. Plugin registration now has one validated entry point and one session-close owner; tests consume that entry point and the existing descriptor leaf directly.
- Startup policy drops two unused modes; cron drops redundant descriptors/types, and image metadata shares its existing flag vocabulary.
- Config patch reading and validation use their concrete flow, reuse SecretRef coercion, and avoid deep-cloning read-only schema output.
- Doctor uses one SQLite report aggregator, one model-compatibility classification, the existing compaction-consumer scanner, and direct auth/context-health projections. Locked OAuth repair and plugin repair eligibility retain their existing owners.
- Dashboard readiness is specialized to its sole production caller. Passive inference discovery and private QA loading lose injection knobs that only tests supplied; QA tests load real temporary artifacts.
- Smaller binding, MCP, exec-policy, snapshot, transcript, memory-health, and log-tail simplifications remove redundant adapters and checks.

## Fixes found along the way

`security audit --fix --json` caught an unexpected fixer rejection, omitted the fix result, and returned a successful audit-only response. The command now propagates that rejection to the existing root CLI failure handler, which emits the standard redacted failure envelope and exit status 1. Successful output remains unchanged; the failure behavior is documented. Its Commander regression failed on the old code and passed after the fix.

## Evidence

Independent autoreview completed with no remaining actionable P0–P2 findings. Runtime build passed all 11 stages (31m53s); core types, all 27 test-type shards, scoped lint, and production/full-tree/script export scans passed. Ratchets and dependency, plugin, schema, storage, media, webhook, and pairing guards passed. The affected type graphs were checked again after consolidating plugin registration.

Completed test selections passed 1,686 tests, including 1,132 plugin-contract tests across 48 files. The security regression in `src/cli/security-cli.test.ts` failed before the fix and passed afterward; the security/failure-output/cron selection passed all 47 tests. The private QA test passed with one worker (18.31s wall time on the loaded development host); hosted CI timing is pending.

One Gateway memory fixture timed out during setup while invoking `memory index --agent main --force`, before its semantic-recall assertion. The coordinator classified this as host-load noise and directed publication without the remaining local shards; no timeout or assertion was weakened. Hosted CI on the published head is the remaining gate.

Before publication, `check-madge-import-cycles.ts` reported 0 cycles and `check-import-cycles.ts` reported 0 runtime value cycles. The reviewed batch was then rebased onto fresh `origin/main` as directed.

The initial hosted run passed 92 checks but exposed two inherited startup-admission failures, also present in [earlier main CI](https://github.com/openclaw/openclaw/actions/runs/37107076035/job/111157672568). Main repaired the owner in `2d6d9a7c97c`: startup does not rewrite config for webhook completion, and completion markers live in SQLite. This branch includes that fix without changing its owners or weakening the admission assertions.

The follow-up rebase also preserves main's newer invalid-config lifecycle and log-recovery fixes. Conflicts were limited to command catalog grouping and the inlined log-fetch flow; independent review of the rebased batch found no actionable P0–P2 issues. Before the replacement push, both cycle checks again reported 0. The selected tests passed all 1,249 cases across 57 files: 104 CLI cases, all 13 startup-admission cases (including both earlier failures), and 1,132 plugin-contract cases. No assertions or timeouts changed. The three Vitest selections took 1,150.35s on the loaded development host.

Remote attempt: Blacksmith Testbox `tbx_01m40jyr34wn0h7ec2gswtycyy` stayed queued for ten minutes and failed hydration before the payload ran; the lease is stopped. The authorized fallback ran the focused `node scripts/run-vitest.mjs` selection plus `check-madge-import-cycles.ts` and `check-import-cycles.ts` serially with `nice -n 15`. A newer main caller of the warning-merge helper required retaining that shared helper for service start and unmanaged stop recovery. Existing stop-output tests caught the integration error; the corrective change preserves main's warning order and empty-warning omission.

Final repair proof passed on Blacksmith Testbox `tbx_01m40nm3serw3g7fbzs3mafn1a` ([run](https://github.com/openclaw/openclaw/actions/runs/37117204982)): frozen install, `pnpm tsgo:core`, all 88 tests in the three lifecycle-core suites, and both import-cycle checks (0). The payload took 165.88s and the Vitest selection took 17.71s. The tested source tree `623f8fdf2c035da205704468450c1c48e41a72f0` exactly matches the committed tree. Independent review of this repair was clean through P2; the lease is stopped. Hosted CI is the final gate for `bc00f18f4ebf757997fdeb0b28201734aa298482`.
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 docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security Security documentation 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