Skip to content

refactor(cli): deslop CLI and commands - #165900

Merged
steipete merged 8 commits into
mainfrom
deslop/l401-types-guards-cli-commands-20261005
Oct 6, 2026
Merged

steipete merged 8 commits into
mainfrom
deslop/l401-types-guards-cli-commands-20261005

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

CLI and command code repeats owner types and producer guarantees, making the same contracts harder to keep consistent.

User Impact

Normal CLI text, flags, exit codes, JSON shapes, and lazy command loading stay unchanged. This also fixes four edge cases found during the sweep: blocking named-pipe file input, asynchronous plugin logs escaping to stdout, stale-link cleanup deleting a replacement, and inherited object keys corrupting custom Mistral model costs.

Why This Change Was Made

This removes 1,001 net production lines (+680/−1,681 across 137 production files), excluding tests and test support. It is one CLI/commands cleanup batch, confined to src/cli and src/commands, plus regression tests, the secret-input documentation, and two shrink-only assertion-baseline removals.

  • Derive option bags and projections from their schema, exported owner, or function parameters across CLI parsers, approvals, Fleet, onboarding, and model authentication. The owner now defines each shape once.
  • Infer concrete factory/report results in Doctor, update, backup, status, and agent execution. Retain partial diagnostic and public contracts where callers actually require them.
  • Remove checks already guaranteed by typed producers, including parsed ports, Commander exit codes, concrete gateway options, and formatted status values. Keep checks on config, stored data, external responses, and lifecycle authority.
  • Reuse existing fixture helpers where inferred results expose incomplete test fixtures; preserve assertions and supported failure states.

Fixes found along the way

  • Secret file readers open POSIX files nonblocking before checking the descriptor, so an unwritten FIFO is rejected instead of hanging. Streaming input still uses stdin.
  • Plugin activation keeps stderr routing until asynchronous work settles. The existing output owner tracks overlapping temporary scopes and preserves JSON-mode refinement and retained routing.
  • Doctor pins a stale plugin-runtime alias and its parent before awaited inspection, then uses the existing guarded-removal owner to recheck identity and target absence immediately before unlinking.
  • Mistral's known-price lookup uses a Map, preserving custom model IDs such as constructor and __proto__ rather than treating inherited object properties as prices.

Evidence

Independent Codex review has no unresolved actionable findings. All validation ran on isolated Linux with Node 24.21.0 and a frozen-lockfile install.

  • Verified all 52,659 source files initially, then verified the complete final patch against commit eb75f70.
  • Broader selection: 157 files, 2,771 passing tests and four existing skips across eight shards (384.20s). All eight changed test files also pass individually with one worker.
  • Original-code controls reproduced all four defects: two FIFO timeouts, lost async/overlapping stderr routing, three replaced/restored-link removals, and both inherited-key costs. The fixed regression suites pass. The revised FIFO fixture was rechecked against the original code.
  • Production types and the config/CLI, commands, Doctor, and update test type graphs pass. Native declaration generation and touched-file lint pass with zero warnings/errors.
  • Production, full-tree, and script export scans pass; unused-file/dependency scanning, line limits, and suppression checks pass.
  • Rebased onto the auth-worker change in perf(auth): move auth saves to workers and publish incrementally #165644, preserving its scoped environment and worker cleanup. Revalidated the auth-probe suites, symlink regressions, all five type graphs, declarations/lint, export scans, and cycles on the rebased source.
  • CI correction: use typed array locals instead of two assertions, retain the original revoke-result schema explanation, and remove two obsolete assertion allowances. The four affected suites pass (63 tests, 67.47s), as do production types, native declarations, scoped lint, all eight baseline/inventory checks, and both cycle checks.
  • Runtime import cycles: 0. Static import cycles: 0, with byte-identical output on a clean recent main baseline.

Hosted CI qualification

Exact head eb75f70be05eee0f125b92be2e2f148cc54fb0a9 was tested in CI run 37404759348. The complete census contains 91 jobs: four succeeded, 62 were cancelled, two failed, and 23 were skipped. The only independent failure is security-fast: the production-dependency audit reports HIGH source-map-js, advisory GHSA-68fv-2mgg-jv7q (npm ID 1241209).

The current-main audit fails identically. The lockfile and both audit implementations are byte-identical between this head and current main; no changed file is an audit input. The successful fail-fast monitor recorded cancellation at 02:38:01.935 UTC. All 62 cancelled jobs ended afterward, with zero failed steps; openclaw/ci-gate names the audit job as its originating failure. Cancelled jobs are incomplete coverage, including hosted baseline ratchets. All ratchets passed separately on the source-verified remote patch. Security-sensitive review and dependency review statuses passed.

The earlier PR attempt also found three branch-caused assertion-ratchet issues. Those are corrected and independently reviewed; two obsolete allowances were removed. No branch-caused failure is being excused by the inherited audit.

Changed-test cost: single-worker wall seconds

Measured with node scripts/run-vitest.mjs <file> --maxWorkers=1 (the pnpm test entrypoint). Measured before the import-only rebase conflict resolution; affected proof was rerun on the rebased source. These isolated-file times include worker preparation; existing CI shards share that preparation. No new CI matrix or repeated-run lane is added. Hosted CI was cancelled after the inherited audit failure, so no completed hosted duration is claimed for these suites.

Test file Wall seconds
src/cli/json-output-mode.test.ts 2.60
src/cli/plugin-registry-loader.test.ts 2.61
src/cli/secrets-store-input.test.ts 20.83
src/cli/update-cli/update-command-doctor-authority-callers.test.ts 36.41
src/cli/update-cli/update-command-lifecycle.test.ts 35.03
src/commands/doctor-update-schema-guard.test.ts 130.79
src/commands/doctor/shared/legacy-mistral-model-cost.test.ts 21.05
src/commands/doctor/shared/plugin-runtime-symlinks.test.ts 2.75

No UI, manifest, public SDK, config-schema, persisted-format, or wire-format change. No dependency or generated-asset change.

@clawsweeper

clawsweeper Bot commented Oct 6, 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 cli CLI command changes commands Command implementations fleet size: XL labels Oct 6, 2026
Derive private parser, report, factory, and option types from their owners. Remove redundant checks on producer-established facts while preserving external input validation, CLI output, and lazy command loading. Keep partial diagnostic and public SDK contracts explicit.
Reject nonregular secret files without blocking on FIFO writers. Keep asynchronous plugin activation routed to stderr until overlapping loads settle. Preserve plugin-runtime links replaced or restored during Doctor inspection, and retain configured prices for custom Mistral model IDs that match inherited object keys.
Keep partial diagnostic and selection projections explicit where callers legitimately omit fields. Preserve the archive publication callback adapter with a direct undefined-returning expression.
@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 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 5, 2026, 10:48 PM ET / October 6, 2026, 02:48 UTC (Revision 3).

ClawSweeper review

What this changes

The branch consolidates CLI and command types under existing owners and fixes secret-file hangs, asynchronous diagnostic routing, stale-link cleanup races, and custom Mistral model costs.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: current main still needs the four edge-case fixes, and the cleanup has clear maintainer value. No actionable patch defect was found; the prior generic config/default compatibility warning is unsupported by the introduced diff.

Priority: P2
Reviewed head: eb75f70be05eee0f125b92be2e2f148cc54fb0a9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent cleanup with focused regressions and no actionable correctness finding; reported validation was not rerun here.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from ordinary external-contributor proof. Supplied validation is supplemental; source and regressions cover FIFO rejection, asynchronous routing, replacement preservation, and custom-price preservation. No material stored-data model change requires migration.
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 ordinary external-contributor proof. Supplied validation is supplemental; source and regressions cover FIFO rejection, asynchronous routing, replacement preservation, and custom-price preservation. No material stored-data model change requires migration.
Evidence reviewed 10 items Pinned introduction and clean checkout: Reviewed the merge-base-to-head introduced hunks, rather than endpoint drift. The final checkout remains clean, and the introduced diff passes whitespace checking.
Current-main necessity: GitHub contents reads pinned to fetched main confirm blocking file opens, immediate restoration around asynchronous plugin loading, unguarded stale-link unlinking, and object-property Mistral price lookup remain. The branch’s central repairs are therefore still necessary.
Secret-input compatibility: Nonblocking POSIX opening lets the existing descriptor-based regular-file check reject FIFOs. Regular files, size limits, descriptor cleanup, and streamed stdin retain their existing contracts; the documentation explains the supported input paths.
Findings None None.
Security None None.

How this fits together

OpenClaw’s CLI turns command-line arguments and configuration into setup, diagnostics, maintenance, and Gateway operations. These changes affect input handling, command output, and Doctor repairs.

flowchart TD
  A[Arguments and configuration] --> B[CLI command parsing]
  B --> C[Existing command owners]
  C --> D[Secret input validation]
  C --> E[Plugin activation and diagnostics]
  C --> F[Doctor repair checks]
  D --> G[Command results]
  E --> G
  F --> G
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface 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/commands/doctor/shared/legacy-config-migrations.runtime.models.refs.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.models.vllm.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.retired-memory-qmd.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-mistral-model-cost.ts, migration/backfill/repair: src/commands/doctor/shared/missing-configured-plugin-install.candidates.ts, migration/backfill/repair: src/commands/doctor/shared/missing-configured-plugin-install.install.ts, and 7 more. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep CLI contracts derived from their existing owners and retain the focused boundary repairs without adding configuration or migration surface.

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

Yes, source establishes focused triggers: an unwritten FIFO, asynchronous overlapping plugin loads, replacement during stale-link inspection, and custom Mistral IDs matching inherited keys. Execution was not repeated during this read-only review.

Is this the best way to solve the issue?

Yes. The patch reuses existing input, output-routing, and guarded-removal owners while removing duplicate type declarations; no concrete upgrade-breaking default or format change was found.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The branch addresses bounded CLI and Doctor edge cases alongside internal contract cleanup.
  • 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 ordinary external-contributor proof. Supplied validation is supplemental; source and regressions cover FIFO rejection, asynchronous routing, replacement preservation, and custom-price preservation. No material stored-data model change requires migration.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the merge-base-to-head introduced hunks, rather than endpoint drift. The final checkout remains clean, and the introduced diff passes whitespace checking. (eb75f70be05e)
  • Current-main necessity: GitHub contents reads pinned to fetched main confirm blocking file opens, immediate restoration around asynchronous plugin loading, unguarded stale-link unlinking, and object-property Mistral price lookup remain. The branch’s central repairs are therefore still necessary. (src/cli/secrets-store-input.ts:28, c439876feddf)
  • Secret-input compatibility: Nonblocking POSIX opening lets the existing descriptor-based regular-file check reject FIFOs. Regular files, size limits, descriptor cleanup, and streamed stdin retain their existing contracts; the documentation explains the supported input paths. (src/cli/secrets-store-input.ts:28, eb75f70be05e)
  • Asynchronous output ownership: Plugin loading now awaits settlement inside the existing stderr-routing owner. Temporary scopes remain active until the last load settles, while JSON refinement and retained routing use the same owner; regressions cover both settlement orders and rejection. (src/cli/json-output-mode.ts:94, eb75f70be05e)
  • Cleanup final-effect safeguards: Doctor captures the original parent and link before awaited inspection, then delegates removal to the existing guarded filesystem owner. The mutation callback rechecks identity and target absence before unlinking; filesystem regressions preserve replacement links, replacement files, and restored targets. (src/commands/doctor/shared/plugin-runtime-symlinks.ts:117, eb75f70be05e)
  • Existing-state compatibility: The Mistral lookup keeps the same known model IDs and prices while avoiding inherited object keys. The normalizer regression preserves configured custom-model costs and emits no repair notes. Other migration, update, and schema hunks derive types without changing stored formats or migration operations. (src/commands/doctor/shared/legacy-mistral-model-cost.test.ts:6, eb75f70be05e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu0925: 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 (2 earlier review cycles)
  • reviewed 2026-10-06T01:45:57.563Z sha c4eb6a14c89c48cd34cf4c66225ff60576d4fb51 :: blocked before merge. :: none
  • reviewed 2026-10-06T02:11:19.119Z sha fdb3129 :: blocked before merge. :: none

@steipete
steipete force-pushed the deslop/l401-types-guards-cli-commands-20261005 branch from c4eb6a1 to fdb3129 Compare October 6, 2026 02:03
@steipete

steipete commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Landing qualification for exact head eb75f70be05eee0f125b92be2e2f148cc54fb0a9 under the maintainer-authorized inherited-failure exception.

The complete CI run census contains 91 jobs, and all 148 exact-head checks were inspected. The only independent failure is security-fast: HIGH source-map-js, npm advisory 1241209 / GHSA-68fv-2mgg-jv7q. The current-main audit on b1f85addba465 fails identically. The lockfile and audit implementations match, and none of this PR's files is an audit input.

The aggregate gate explicitly names that audit as its originating failure. The successful fail-fast monitor cancelled 62 CI jobs; all ended afterward with zero failed steps. Those jobs remain incomplete hosted coverage, including baseline ratchets. A superseded PR-context check was cancelled by its per-PR concurrency policy; its later same-head replacement succeeded. Security-sensitive review and dependency review statuses passed.

The earlier branch-caused assertion-ratchet findings are fixed. The complete corrected patch was verified by hash on isolated Linux: all baseline/inventory checks passed, the four affected suites passed 63 tests, production types and scoped lint passed, and both runtime/static cycle checks reported zero. The broader retained proof passed 2,771 tests with four existing skips; four discovered defects have original/fixed regression controls. Independent review has no unresolved actionable findings, and native preparation is bound to this exact head. No cancelled job is represented as passing.

@steipete
steipete merged commit 10481d6 into main Oct 6, 2026
94 of 160 checks passed
@steipete
steipete deleted the deslop/l401-types-guards-cli-commands-20261005 branch October 6, 2026 02:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 6, 2026
* refactor(cli): deslop CLI and command contracts

Derive private parser, report, factory, and option types from their owners. Remove redundant checks on producer-established facts while preserving external input validation, CLI output, and lazy command loading. Keep partial diagnostic and public SDK contracts explicit.

* fix(cli): preserve input and plugin lifecycle boundaries

Reject nonregular secret files without blocking on FIFO writers. Keep asynchronous plugin activation routed to stderr until overlapping loads settle. Preserve plugin-runtime links replaced or restored during Doctor inspection, and retain configured prices for custom Mistral model IDs that match inherited object keys.

* refactor(cli): retain optional owner contracts

Keep partial diagnostic and selection projections explicit where callers legitimately omit fields. Preserve the archive publication callback adapter with a direct undefined-returning expression.

* refactor(cli): remove unused aliases and keep lazy type references

* refactor(cli): preserve lifecycle contracts in lint-clean forms

* test(cli): derive the resolved secret reader fixture type

* refactor(cli): preserve assertion safety in inferred reports

* chore(cli): shrink removed assertion baselines
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 fleet P2 Normal backlog priority with limited blast radius. 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