Repository navigation
refactor(cli): deslop CLI and command flows - #164159
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed October 3, 2026, 6:57 AM ET / 10:57 UTC (Revision 4). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherOpenClaw’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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -1031, Tests -190, Docs +2, Other -1. Total -1220 across 74 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Route unexpected fixer errors through the standard CLI failure owner. Preserve the validated cron stream mode union after removing its duplicated result type.
94d822c to
2524667
Compare
## 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`.
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.
Fixes found along the way
security audit --fix --jsoncaught 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.tsfailed 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.tsreported 0 cycles andcheck-import-cycles.tsreported 0 runtime value cycles. The reviewed batch was then rebased onto freshorigin/mainas 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_01m40jyr34wn0h7ec2gswtycyystayed queued for ten minutes and failed hydration before the payload ran; the lease is stopped. The authorized fallback ran the focusednode scripts/run-vitest.mjsselection pluscheck-madge-import-cycles.tsandcheck-import-cycles.tsserially withnice -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 tree623f8fdf2c035da205704468450c1c48e41a72f0exactly matches the committed tree. Independent review of this repair was clean through P2; the lease is stopped. Hosted CI run 37117777343 passed on exact headbc00f18f4ebf757997fdeb0b28201734aa298482; both required CI-gate statuses succeeded. GitHub squash-merged this PR as3e710dbfe96da54b751abd6d5fb0bd2ddd3c9171, verified as an ancestor of freshly fetchedorigin/main. No admin exception was used.