Repository navigation
refactor(commands): consolidate command mutation and reporting paths - #167043
Conversation
Consolidate model, binding, installation, cleanup, Doctor, and status variants while preserving their CLI contracts and lifecycle boundaries. Retire replaced internal helpers and migrate their callers; tests retain behavior assertions and only change removed seams.
|
🦞👀 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: needs maintainer review before merge. Reviewed October 8, 2026, 4:07 AM ET / 08:07 UTC (Revision 2). ClawSweeper reviewWhat this changesThis PR consolidates repeated CLI mutation, plugin installation, service cleanup, Doctor repair reporting, and status formatting paths while preserving their existing contracts. Review scores
ProductKind: Refactor · Worth it: Yes Merge readiness✅ Ready for maintainer review This PR remains useful maintenance work, with no concrete introduced defect found. The supplied maintainer-author classification also prevents automated closure. Priority: P3 Before mergeNone. FindingsNone. Provenance
Tests
Agent review detailsHow this fits togetherOpenClaw commands translate CLI requests into configuration updates, Gateway operations, installation, and maintenance work. These paths also turn results into human-readable messages and JSON output. flowchart TD
A[CLI request] --> B[Command dispatch]
B --> C[Shared mutation and maintenance paths]
D[Configuration and saved state] --> C
C --> E[Existing Gateway and installation owners]
E --> F[Operation results]
F --> G[CLI messages and JSON]
Technical reviewBest possible solution: Keep one internal implementation for equivalent command work while retaining branch-specific output, consent, cancellation, and recovery contracts. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes behavior-preserving consolidation and reports no product defect requiring reproduction. Is this the best way to solve the issue? Yes: the consolidation reuses existing operation owners, removes superseded internal helpers, and preserves distinct caller contracts without adding public configuration or SDK surface. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against bf67191c52e0. Provenance checked
TestingProof path: shipped entry point. Added test files: 6. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -639, Tests -18, Other -4. Total -661 across 52 files. View PR surface stats
Stored data modelPersistent data-model change detected: LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
|
…penclaw#167043) * refactor(commands): share command mutation and reporting paths Consolidate model, binding, installation, cleanup, Doctor, and status variants while preserving their CLI contracts and lifecycle boundaries. Retire replaced internal helpers and migrate their callers; tests retain behavior assertions and only change removed seams. * fix(commands): preserve transcript typing and UI progress text * test(cli): preserve model handler exports in partial mocks * refactor(commands): remove unused title repair report alias * refactor(commands): preserve catalog entry cloning * test(commands): keep status fixture details internal
What Problem This Solves
Several command variants repeat installation, mutation, and reporting work that can be maintained in one implementation.
User Impact
No user-visible behavior changes. CLI flags and output, configuration and protocol shapes, persisted data, cancellation, and recovery ordering are preserved.
Why This Change Was Made
Share model fallback/account/auth-order mutation paths, plugin install progress and completion, binding updates, reset/uninstall service teardown, Doctor repair/reporting mechanics, and status projections. Retire the replaced internal helpers and update their callers together.
Measured production reduction: 639 lines, including required CLI caller changes; tests: 18 lines removed net. The commands production inventory is 100,586 lines across 465 files, excluding
src/commands/doctor/, tests, fixtures, support, generated code, and declarations. This is the campaign's authorized 500–999-line exception after more than two hours of implementation and a largest-first file pass; it does not meet the 3% target.Most retained length represents distinct filesystem identity, database admission, state recovery, cancellation, or public output contracts. A model-default projection experiment and restore-report extraction were implemented, measured, and discarded because they reduced clarity or grew code.
Evidence
Validation used the repository test/check owners on AWS with Node v24.19.0 and pnpm 12.5.1. The native source receiver verified the reviewed source tree before execution. The broad focused/full runtime suites and SDK comparison ran on
ed587434c75c29efb821e267191f662031e5c54a; final-head checks ran on7223003e0ea498070880131744c32d80d8ae5b4b. Later corrections restore the original catalog-cloning operation, remove the unused Doctor report-type alias, prepare CLI partial mocks during collection, and keep two status-fixture constants internal; affected checks are repeated on the final head.src/commandsdirectory: 662 files passed; 7,995 tests passed and four skipped under the existing test configuration.The lint-suppression test on the starting base fails on two untouched logging
typescript/unbound-methodsuppressions. The exact failure reproduces onb300e0edea5e3e1b0aee58a33e188711380d8e22; the same test passes all three cases on maind41d7ff8c8fc8137523232f60f8194d403cfaefa, where #166841 removed those suppressions. This is an inherited defect already fixed on main, not a current-main failure. This PR adds no suppressions and only removes obsolete baseline entries. The dead-export scan also finds the untouchedreadRecommendedModelsscript export inherited from the starting base; #165825 has already made it internal on main. The lane-owned unused report alias is removed here. Remaining native changed-check commands are executed separately after the inherited scan failure, with no guard disabled.A local focused run under severe shared-host contention had 986 passing and 12 failing cases: timeouts in legacy-auth repair, incident-scale transcript repair, session reset, and probe cleanup, plus subsequent registry/session assertions and four MiniMax login failures. Source investigation found unchanged mutation order and a possible timeout/teardown overlap affecting shared fixture state; causation was not established. All five owning files then passed in original in-file order on isolated AWS (87 tests), and the complete focused/full directory runs passed there. The passing replay does not claim to fix the original local failures.
The first partial-mock CLI check exposed worker-bundle preparation inside case timers (223.391 seconds on the contended host). Three narrow imports now initialize the hoisted partial mocks during collection, preserving real exports and the same command spies, assertions, and timeouts. Separate cold/lazy-loading tests retain their existing contracts.
Serialized CI-mode measurements use
CI=1 node scripts/run-vitest.mjs <file> --maxWorkers=1. These are standalone AWS wall seconds, including native worker preparation; they are not whole-job hosted-CI totals.src/cli/models-cli.test.tssrc/commands/doctor-auth-migration-receipts.test.tssrc/commands/models/accounts.test.tssrc/commands/models/auth-order.test.tssrc/commands/models/model-selection.runtime.test.tssrc/commands/status-overview-surface.test.tsPer-file production coverage log
Every listed production owner was read in the largest-first implementation pass. “Changed” identifies retained structural consolidations; “retained” means no clearer behavior-identical consolidation survived inspection. New helper and required caller files are described above and visible in the diff.
doctor-auth-flat-profiles.tsmodels/list.status-command.tsdoctor-state-integrity.tsdoctor-session-sqlite.tsagent-via-gateway.tsmodels/auth.tsonboarding-plugin-install.tsmodels/list.probe.tsconfigure.wizard.tsdoctor-gateway-services.tsdoctor-lint-runner.tsonboard-guided.tsbackup-verify.tsdoctor-skill-workshop-collection-backups.tsdoctor-session-sqlite-restore.tsdaemon-install-helpers.tsdoctor-maintenance.tsdoctor-heartbeat-scratch-migration.tsdoctor-memory-search.tsdoctor-config-flow.tstriage.tsdoctor-update-schema-guard.tscleanup-utils.tsonboard.tsdoctor-plugin-registry.tsbackup-shared.tsonboard-custom-config.tsdoctor-heartbeat-task-migration.tsdoctor-session-canonical-keys.tsaudit.tsdoctor-gateway-daemon-flow.tsagents.commands.add.tsdoctor-session-transcripts.tsdoctor-skill-workshop-relocation.tsdoctor-tools-md-migration.tsdoctor-auth.tsdoctor-session-state-providers.tsdoctor-sqlite-nocow.tsdoctor-session-sqlite-discovery.tsdoctor-sandbox.tsdoctor-gateway-health.tsbackup-verify-manifest.tsdoctor-update-rehearsal-inventory.tsmigrate.tsstatus-all/channels.tsdoctor-session-sqlite-retirement.tsstatus-all/diagnosis.tsdoctor-auth-migration-receipts.tsagent-exec.tsdoctor-session-sqlite-recovery-inventory.tsonboard-non-interactive/local/auth-choice.plugin-providers.tsdoctor-session-sqlite-retained.tssessions.tsagents.commands.delete.tsdoctor-skill-workshop-sqlite.tsonboard-non-interactive/local.tsstatus.scan.shared.tsdoctor-session-sqlite-import.tstriage-update.tsstatus.command-sections.tsdoctor-config-preflight-plugin-migrations.tsonboard-helpers.tsonboard-remote-gateway.tsbackup-resource-inventory.tsdoctor-security.tsdoctor-model-catalog-credentials.tshealth.tsmodels/accounts.tsstatus.scan-overview.tssandbox-explain.tsdoctor-device-pairing.tsdoctor-session-sqlite-recover-report.tspromos/claim.tsmodels/shared.tsmodels/auth-logout.tsdoctor-workspace.tsmodels/scan.tschannels/capabilities.tsdoctor-config-preflight.tsonboard-custom.tsdoctor-config-analysis.tssessions-lifecycle.tsdoctor-session-snapshots.tsdoctor-skill-workshop-sidecars.tshealth-format.tsdoctor-retired-phone-control.tsmessage-format.tsstatus-all/format.tsdoctor-workspace-status.tsagents.config.tsdoctor-maintenance-state.tschannels/add-wizard.tsdoctor-session-sqlite-failure.tsmigrate/selection.tsdoctor.tsdoctor-session-sqlite-verification.tssessions-tail.tsdoctor-session-incognito-key-repair.tsonboard-browser-handoff.tschannels/add.tsdoctor-telegram-general-topic-conversations.tssessions-cleanup.tsdoctor-session-transcript-headers.tsagents.providers.tsgateway-status/helpers.tsagents.commands.bind.tsconfigure.gateway.tschannels/list.tsconfig-preflight-snapshot.tsconfigure.gateway-auth.tsdoctor-maintenance-restoration.tsonboard-skills.tsagents.bindings.tsdoctor-skill-workshop-workspaces.tsdoctor-heartbeat-main-session-repair.tsonboard-agent-target.tscontrol-ui-handoff.tsgateway-status/output.tsdoctor-session-incognito-key-repair-state.tsdoctor-session-delivery-state.tsdoctor-migration-backup.tsonboard-non-interactive/local/auth-choice.tssetup.tsdoctor-session-transcript-labels.tsstatus.command.tsdoctor-claude-cli.tsbackup-remote.tsdoctor-platform-notes.tsmigrate/output.tsruntime-plugin-install.tsstatus-overview-rows.tsstatus-runtime-shared.tsonboard-remote.tsuninstall.tsbackup-git.tschannels/status.runtime.tschannels/remove.tsdoctor-auth-legacy-paths.tsdoctor-completion.tsonboard-non-interactive/local/output.tsdashboard.tsmodels/list.auth-overview.tsstatus.update.tsdoctor-session-sqlite-targets.tsstatus.scan.gateway.tsdoctor-config-preflight-plugin-verification.tsdoctor-session-sqlite-diagnostics.tsdoctor-gateway-installation.tsstartup-config-preflight.tsdoctor-auth-profile-config.tsdoctor-sqlite-reclamation.tsdoctor-agent-memory-schema.tsdoctor-agent-deletion-journal-quarantine.tsdoctor-session-sqlite-archive.tstriage-prompt.tsbackup-restore.tsdoctor-post-upgrade.tsagents.commands.identity.tssessions-cleanup.runtime.tsbackup-sqlite.tschannel-setup/trusted-catalog.tsdoctor-memory-recall.tstriage-failure.tsbackup-schedule.tsdoctor-ui.tsagents.commands.list.tsdoctor-session-canonical-candidates.tsdoctor-update-refusal.tsmodels/auth-api-key.tsstatus-all/report-data.tsonboard-inference.tsdoctor-update-run.tsdoctor-plugin-manifests.tsdoctor-usage-cost-cache.tsmigrate/skill-selection-prompt.tsdoctor-sqlite-maintenance-lock.tsmodels/auth-logout-selections.tsdoctor-heartbeat-cadence-migration.tsgateway-status/probe-run.tschannels/resolve.tsstatus-update-restart.tsonboard-agent.tsdoctor-plugin-host-links.tsauth-choice-prompt.tsmodels/auth-model-policy.tsonboard-non-interactive/local/gateway-config.tsagent-exec-input.tsdoctor-maintenance-inspection.tsdoctor-outbound-delivery.tsgateway-status.tsdoctor-session-title-repair.tsgateway-install-token.tsdoctor-lint-process.tsexport-trajectory.tsdoctor-skill-workshop-automations.tsmodels/fallbacks-shared.tsreset.tsdoctor-workspace-alias.tsheartbeat-task-legacy.tsauth-choice.model-check.tsdoctor-session-sqlite-transcript-readers.tsmodels/accounts-gateway.tsonboard-recommendations.tsmodels/auth-order.tsmessage.tsdoctor-config-preflight-legacy-config.tsdoctor-session-sqlite-types.tsgateway-readiness.tsdocs.tsdoctor-gateway-dueling.tsdoctor-lint-output.tsdaemon-install-plan.shared.tsdoctor-agent-deletion-journal.tsdoctor-plugin-generations.tsdoctor-sqlite-compact.tsonboard-non-interactive.tsdoctor-auth-legacy-oauth.tsstatus-all/gateway.tschannel-setup/discovery.tsonboard-non-interactive/api-keys.tsdoctor-plugin-model-catalog.tsstatus-all/channels-token-summary.tsauth-choice-options.tssessions-table.tsdoctor-bootstrap-size.tsdoctor-session-store-owner.tsdoctor-project-clone-shape.tsmodels/list.list-command.tssandbox.tsdoctor-web-fetch-proxy.tsconfigure.daemon.tsdoctor-skills.tsmigrate/apply.tsmodels/auth-list.tsdoctor-maintenance-stale-service.tsdoctor-update-snapshots.tsdoctor-original-capture.tstelemetry-exporter-summary.tsdoctor-node-hosting-preconditions.tsdoctor-rehearsal-databases.tsstatus.scan.bootstrap-shared.tsbackup-namespace.tschannels/shared.tsagent-exec-result.tsmigrate/memory-import.tsmodels/aliases.tsdoctor-whatsapp-responsiveness.tstriage-automatic-repair.tssystemd-linger.tsstatus.command-report-data.tsstorage.tschannel-setup/channel-plugin-resolution.tschannels/status-config-format.tsdoctor-maintenance-foreground.tssessions-compact.tsdoctor-session-sqlite-active.tsonboard-interactive-runner.tsstatus.format.tsonboard-guided-manual.tsdoctor-update.tschannels/logs.tsconfigure.channels.tsdoctor-heartbeat-session-target.tsbackup-health.tsdoctor-disk-space.tsonboard-config.tsdoctor-config-preflight-migrations.tsdoctor-format.tssystem-agent-with-inference.tsdoctor-migration-backup-artifacts.tsdoctor-process.tsdoctor-service-repair-policy.tsonboard-types.tsdoctor-command-owner.tsdoctor-gateway-auth-token.tschannel-setup/plugin-install.tssession-store-targets.tsdoctor-service-audit.tsonboard-guided-consent.tsstatus-json-runtime.tsstatus-usage.runtime.tsconfig-validation.tsmodels/model-reference-validation.tssessions-display-model.tsconfigure.gateway-health.tsdoctor-config-audit-scrub.tsmodels/auth-credential-import.tsdoctor-bun-cli-launcher.tsmodels/auth-relogin-identity.tsmodels/provider-aliases.tsbackup.tschannels/status.tsdoctor-main-session-recovery.tsnode-runtime-diagnostics.tsdoctor-session-sqlite-missing-index.tsstatus.agent-local.tsdoctor-install.tsonboard-non-interactive/remote.tssandbox-display.tsauth-choice.apply.tsdoctor-session-sqlite-compact.tsdoctor-session-exec-policy.tsmodels/list.probe.cleanup.tsmodels/list.table.tsdoctor-skill-workshop-sources.tsstatus-overview-values.tsstatus-all/report-lines.tschannels/dead-letters.tsmodels/auth-refresh.tsdoctor-host-desktop.tsdoctor-install-policy.tsonboard-quickstart-host.tsstatus.scan.fast-json.tsdoctor-prompter.tsgateway-status/discovery.tsstatus.service-summary.tsdoctor-plugin-source-captures.tsdoctor-database-preflight.tsdoctor-update-rehearsal-paths.tsnode-daemon-install-helpers.tsconfigure.shared.tsdoctor-foreign-launchd-jobs.tsmigrate/context.tsonboard-non-interactive/local/daemon-install.tsstatus-all.tsgateway-health-auth-diagnostic.tsstatus-overview-surface.tsdoctor-tailscale.tsstatus-all/report-tables.tsstartup-plugin-source-captures.tsdaemon-install-auth-profile-env.tsdoctor-agent-lease-refusal.tsdoctor-session-sqlite-migration-coalesce.tsdoctor-db-bloat.read.tsstatus.command-report.tsstatus.scan-result.tsdoctor-state-sqlite-compact.tstriage-doctor.tsgateway-auth-token.tsdoctor-gateway-legacy-services.tsdoctor-startup-migration-refusal.tsdoctor-update-rehearsal-workshop.tsdoctor-original-capture-admission.tsonboard-non-interactive/local/auth-choice-inference.tsmodels/list.probe.models.tsonboard-options.tsstatus.node-mode.tsdoctor-session-canonical-owner-evidence.tsdoctor-config-preflight.cron.tsdoctor-session-sqlite-warnings.tsmodels/list.manifest-catalog.tsstatus-json-payload.tstriage-handoff.tsonboard-interactive.tsdoctor-tools-md-migration-guidance.tsgateway-setup-runtime.tsonboard-first-agent.tsstatus.scan.tsdoctor-lint.worker.tsdoctor-secret-runtime-degradation.tsagents.commands.team.tsauth-choice-options.static.tsdoctor-unconfigured-agent-databases.tsmigrate/providers.tsmodels/auth-activate.tsmodels/list.format.tsdoctor-skills-core.tsdoctor-memory-search-local.tspromos/list.tsstatus-json-command.tsstatus.scan-execute.tsgateway-startup-timing.tsgateway-presence.tsonboard-inference-ambient.tsdoctor-stale-runtime-build.tsgateway-diagnostic-readiness.tsdoctor-browser.tsdoctor-maintenance-admission.tsdoctor-session-sqlite-restore-report.tsdoctor-gateway-runtime-plan.tsdoctor-session-worktree-workspace.tsmigrate/types.tsdoctor-db-bloat.tsdoctor-tools-md-migration-budget.tsmodels/model-selection.runtime.tsstatus.gateway-connection.tsagent-local-audit.tscleanup-plan.tsconfigure.commands.tsdoctor-hooks-model.tsdoctor-repair-mode.tsbackup-record.tsdoctor-config-preflight-plugin-index.tsstatus-all/channels-table.tsauth-choice-legacy.tsmodels/auth-manual-input.tsmodels/load-config.tsdoctor-agent-database-operation.tsstatus.daemon.tsauth-choice.apply.api-providers.tsdoctor-retained-runtime.tschannel-setup/registry.tsdoctor-skill-workshop-read.kernel.tsbackup-summary.tsdoctor-agent-database-paths.tsnon-interactive-prompter.tsdoctor.worker.tsstatus-all/text-report.tsstatus.scan-memory.tsdoctor-maintenance-exit.tsdaemon-runtime.tsdoctor-backup-scratch.tsgateway-service-setup.tsmigrate/item-selection.tssqlite-wal-health.tsmodels/refresh.tstriage-claude.tstext-format.tsagents.binding-format.tsdoctor-channel-ingress.tsmodels/list.types.tschannel-setup/config-compatibility.tschannels/plugin-config-persistence.tsmodels/set.tsonboard-non-interactive/local/skills-config.tschannel-setup/owner.tsdoctor-memory-scope.tsonboard-hooks.tsonboard-non-interactive/local/workspace.tsdaemon-install-runtime-warning.tsdoctor-post-upgrade.types.tsstatus.gateway-probe.tsauth-choice.apply.types.tsdoctor-lint.tsdoctor-tools-md-migration-content.tsonboard-non-interactive/config-write.tsdoctor-state.worker.tsmodels/set-image.tsdoctor.types.tsstatus.gateway-probe-budget.tsmodel-picker.runtime.tsstatus-json.tsdoctor-maintenance-types.tsonboard-non-interactive/local/auth-choice.plugin-providers.runtime.tsconfigure.prompts.tsdoctor-lint-options.tschannels/runtime-label.tsdoctor-config-preflight-measure.tsdoctor-workspace-suggestions.tsstatus.command.text-runtime.tsmodels/alias-name.tsstatus.scan.runtime.tschannels/account-selector.tsstatus.scan.deps.runtime.tschannels/channel-selector.tsdoctor-state-integrity-format.tsrandom-token.tschannels.tscodex-runtime-plugin-install.tsstatus.tsagent.tsagent/session.runtime.tsauth-token.tsdaemon-install-auth-profiles-source.runtime.tsdaemon-install-auth-profiles-store.runtime.ts