Skip to content

refactor(commands): share command validation and diagnostic paths - #167783

Merged
steipete merged 1 commit into
mainfrom
deslop/d20-p2-20261007
Oct 9, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/d20-p2-20261007

Conversation

@steipete

@steipete steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Commands repeat model selection, authentication diagnostics, transcript inspection, and CLI dispatch logic across closely related operations.

User Impact

There is no user-visible change. CLI flags and output, configuration and protocol fields, persisted data, repair authority, and cleanup/error ordering remain unchanged. No migration or operator action is required.

Why This Change Was Made

Share model setters and probe configuration with explicit text/image and credential parameters; share unavailable-profile facts while retaining each command's output projection; share transcript scanning and snapshot comparison while leaving repair transactions with their existing owners. Smaller consolidations remove duplicate command dispatch, credential processing, platform warnings, and diagnostic projections.

This is the second commands pass after #167043. The initial inventory covered 460 production files and 97,801 lines; the additional platform module extracted on main was also inspected. Earlier rejected candidates were reconsidered, implemented, and measured. Experiments that added indirection or obscured lifecycle/output differences were removed. The per-file coverage log is attached in two comments.

The committed diff removes 610 net production lines, excluding tests, fixtures, support, generated files, and declarations. Tests/support add 44 lines; nine obsolete mock-baseline rows are removed and the assertion allowance shrinks from two to one. This uses the campaign's authorized 500–999-line coverage-log route after the completed deep pass and main integration.

Evidence

Source: e9ef52146778849b7904ee56b0cc861098b2468d, tree 456d05f3c93fe75f27587ccefac5751f2f27c39d, based on f02f2de695169db662dae961fc5c19951f0f4a28.

  • Full changed checks passed in 3,044.92 seconds: production types, all 27 test typecheck shards, all three Knip scans with zero findings, lint, ratchets, and boundary checks. Eleven size warnings concern untouched files; there are no lint errors or new suppressions.
  • Focused proof passed across 135 files: 2,262 tests and one existing Windows-only MAX_PATH skip. All ten shards passed, including 43 E2E cases. Wall time was 1,140.87 seconds, including the 412.7-second E2E runtime build.
  • Lint-suppression, eager-import, and PR-tooling closure guards passed: 23 tests across three files.
  • Independent review of the final source found no actionable P0–P2 findings. All changed TypeScript files passed formatting and targeted lint.
  • The directly imported tooling export, runDoctorStateSqliteCompact, retains its signature, defaults, body, and behavior. Landing tooling and its scripts helpers are unchanged.
  • Full src/commands directory passed: 640 files, 7,653 tests, and four existing platform/path-alias skips; 2,305.35 seconds wall time.
  • Runtime value cycles: zero. Static import cycles: zero, matching the clean pinned main baseline.
  • Strict Plugin SDK API comparison passed with no API changes and no acknowledgement supplied (551.84 seconds).
  • All 16 changed test files passed with --maxWorkers=1: 355 tests, no skips, 322.55 seconds wall time and 470.34 CPU seconds. This is measured remote test cost; hosted CI duration is separate.

Remote proof ran on Hetzner lease cbx_e6628f0492aa: https://crabbox.openclaw.ai/portal/runs/run_ed68743da0e4bddca1ee0b5854cfb790. Its verified source tree exactly matches the authored commit; the capsule transport commit is not presented as the PR head.

@clawsweeper

clawsweeper Bot commented Oct 9, 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.

@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Coverage log, part 1 of 2.

Per-file implementation and retention decisions

Commands P2 per-file coverage

Initial coverage inventory: 50d7eb1b7fbc65d5552ac3c82d65dcb512e15b42, 460 production files / 97,801 lines. Final reduction columns are measured against integrated main f02f2de695169db662dae961fc5c19951f0f4a28; the additional extracted platform owner was also read and is included below; the excluded src/commands/doctor/ subtree was not edited. Read reuse is explicit in the decisions and supported by matching P1/current blobs in the local audit. P1 reviewed head: 7223003e0ea498070880131744c32d80d8ae5b4b.

File Net removed Decision
src/commands/doctor-auth-flat-profiles.ts 7 After main integration, retain only the provider-hint conflict map; main owns alias readers, owner census, isMainStore and warning consolidation. Conflict null preserves first-owner/conflicting-hint behavior.
src/commands/models/list.status-command.ts 64 Share unavailable-profile facts, positive probe-option parsing, OAuth count, status labels and ordered model-use projection. The fresh Object.assign output keeps optional classification presence and property order without mutating shared facts; net -64.
src/commands/doctor-state-integrity.ts 11 Preserve main platform-module extraction and collector. Retain the common path property in the issue union and child-recovery snapshot filter, preserving all union alternatives and publication fields.
src/commands/doctor-session-sqlite.ts 0 Retain cross-target archiveLegacyArtifacts orchestration: retention propagates transitively through shared transcripts and sibling indexes before publication, and every referencing owner receives its receipt. Independent per-target archival would lose ownership coordination.
src/commands/agent-via-gateway.ts 0 Read complete fresh 1,200 lines. Remote roster and local persisted owner selection differ intentionally; abort retries need accepted identity and post-connect request fallback, unlike transient handshake retries. A shared callback would need to expose retry config mutation and acceptance provenance to both paths; no clearer common core remains without hiding those boundaries.
src/commands/models/auth.ts 10 Single-use mergeSetupProviders inlined into its owner; original normalized provider membership retains runtime order, replacement behavior and appended setup duplicates. Public signatures unchanged.
src/commands/onboarding-plugin-install.ts 13 Implemented channel-default switch and shared empty Git-marker rejection. Retain npm watchdog/archive exception/ClawHub navigation distinctions. Remaining candidate: share CWD/workspace list construction without dropping repeated realpath checks. Applied final shared CWD/workspace root-list constructor, measured another 3 lines removed; all filesystem freshness checks retained.
src/commands/models/list.probe.ts 25 Eligibility details table builds identical diagnostics. One createProbeConfig path shares cleared profile order while preserving direct credential binding/fact exclusion, provider lookup before copying, and models-before-auth property insertion.
src/commands/configure.wizard.ts 0 Retain the existing sectionActions table. Flag-driven sections commit once before daemon/health; interactive sections commit before the next prompt, so merging the two execution loops would obscure different publication timing.
src/commands/doctor-gateway-services.ts 0 Retain installation/definition/config repair discrimination, token preservation before service publication, and native writability rechecks. Two legacy-platform cleanup branches do not warrant another generic callback layer.
src/commands/doctor-lint-runner.ts 0 Read complete. Private snapshots, deferred disposal and output-before-cleanup retain different failure precedence; A generic output factory would need separate JSON findings/ok/warnings overrides and late cleanup projection for each variant; retained the existing explicit result owners.
src/commands/onboard-guided.ts 5 Implemented one lazy memory-import invocation at the existing chat/local call sites. Retain receipt ownership, pre-inference commit claims, workspace approval, and browser/TUI handoff ordering.
src/commands/backup-verify.ts 6 Share extraction-size accumulation with explicit SQLite mode while preserving file selection, zero-length rejection, overflow/error text and call order. The second main integration retains its UTF-8 validation before decoding. The inspected three-way result is main plus only the P2 extraction counter; net -6.
src/commands/doctor-maintenance.ts 0 Current full read includes newer-schema refusal guidance. Retain stopped-service custody, original-stop compensation, uncertain-child cleanup fences, and post-repair restoration as distinct lifetimes; they cannot be derived from one boolean.
src/commands/daemon-install-helpers.ts 0 Retain separate durable/config/auth-profile/exec/ambient env collection: reserved Gateway secrets, HOME exception, existing-managed-key ownership, and precedence differ. Shared service-env plan already owns final merging/render policy.
src/commands/doctor-config-flow.ts 1 Consume the warning-only Tailscale collector at the original phase; main positional fixHint and default warning emission remain intact.
src/commands/doctor-heartbeat-scratch-migration.ts 2 Derived source-retention decision from retained owner plus accepted import count; no claim, archive, CAS, rollback or warning behavior changes.
src/commands/triage.ts 0 P1 full-read decision reused after exact blob parity verification: interactive external launch, automatic bounded repair, and embedded loop own different consent, cancellation and cleanup receipts; merging them would conceal real differences.
src/commands/doctor-session-sqlite-restore.ts 0 Retain separate restore planning and publication. Planning resolves duplicate destinations using content and recorded consumption; publication rechecks selected bytes and durably records consumption before archive removal. These are distinct recovery responsibilities.
src/commands/doctor-update-schema-guard.ts 0 Retain released-driver phase checks, physical canonical-backup coverage, and disposable rehearsal cleanup identity. These are different proofs, not duplicate schema guards; no storage/recovery contract change proposed.
src/commands/doctor-memory-search.ts 0 Fresh Active Memory derivation inspected. Native-provider extraction rejected because Doctor must snapshot diagnostic fields before disposal. This file is byte-identical HEAD.
src/commands/doctor-skill-workshop-retire-proposals.ts 14 Keep main migrationResult factory and reuse the already-read proposal inventory/result facts. Preserve malformed-data outcomes, retirement transactions, retained artifact text and authority checks.
src/commands/cleanup-utils.ts 0 Fresh full inspection resolves the prior log wording that only said Read. Dry-run avoids locks and admission; real deletion holds exact physical state identity, preserves lock paths, revalidates linked paths and state admission, then releases and checks replacement operations. Workspace cleanup and session-history reset have separate custody and failure aggregation, so sharing their loops would conceal authority and settlement differences.
src/commands/onboard.ts 0 Retain ordered preflight and final reset dispatch. Remote/local flag exclusions, credential-ref consistency, interactive TTY admission, and reset credential validation fail before destructive reset with distinct user guidance.
src/commands/backup-shared.ts 4 Retain the ordered comparator fallback: internally constructed candidates exhaust the kind-priority table, preserving path length, kind priority and locale order. Existing-path canonicalization falls back lexically after a direct lookup failure; containment canonicalization resolves the nearest existing ancestor while preserving missing suffixes, so those helpers have different contracts.
src/commands/doctor-plugin-registry.ts 0 P1 shared stale-local reporting and registry finalization already remain. Retain npm package/lockfile removal, recovered-record baseline capture, lifecycle lease reinspection, and official provenance migration as separate responsibilities.
src/commands/onboard-custom-config.ts 15 Implemented common OpenAI probe assembly and image-confidence result. Retain Anthropic path/header/token differences, Azure stored URL normalization, collision naming, alias scope, and authored catalog-field preservation.
src/commands/doctor-heartbeat-task-migration.ts 2 Derived blocked planning from completed job-plan count rather than separately mutating a flag; collision detection and all atomic writes unchanged.
src/commands/doctor-session-canonical-keys.ts 0 P1 full-read decision reused after exact blob parity verification: Single/cross-store batch routes share final archive accumulation, counters and fresh group discovery; mutation order and bounded same-database batching retained. ranking and isolation authority are separate. Implemented shared single/cross-store batch settlement tail without changing either mutation route.
src/commands/audit.ts 4 Revisited complete owner/test plus CLI/audit doctrine. Implemented shared available/unavailable identity sections and lineage field formatting; actual formatted delta -4. All labels/state/section order unchanged. No src/audit edits.
src/commands/doctor-gateway-daemon-flow.ts 0 Current full read includes flattened declined-install/running-state branches. Retain macOS bootstrap versus install/start/restart paths, Windows Disabled start, headless restart refusal, and recent-restart preservation; their prompts and effects differ.
src/commands/agents.commands.add.ts 4 Read complete. Existing update commits auth before config and rolls back only on config/hook failure; fresh creation stages auth under the creation owner's commit. Cannot share these lifecycles. Portable copy and per-mode result projections retain separate fields.
src/commands/doctor-auth.ts 17 Fresh complete module and profile/shared-health tests read. Consumes shared unavailable-profile facts; retains Doctor-only inherited-provider recovery lookup and exact formatted notes/findings.
src/commands/doctor-session-state-providers.ts 5 Retain main normalization, flattened owner loops and repair predicate. Filter authoritative snapshots directly; the replacement owner still projects entry/sessionKey, so no additional data is persisted.
src/commands/doctor-sqlite-nocow.ts 0 Paired path/identity slots intentionally survive partially failed staging creation; unifying their optional state would lose retained-path diagnostics. Exchange and recovery unchanged.
src/commands/doctor-session-sqlite-discovery.ts 0 P1 full-read decision reused after exact blob parity verification: live sources, archived ownership, source identity revalidation and known-store coverage each supply different evidence.
src/commands/doctor-session-transcripts.ts 0 P1 full-read decision reused after exact blob parity verification: Maintenance callback returns actual reports instead of eight zero-valued placeholder states; preview legacy-entry refusal returns its report explicitly. Operation order, maintenance lock boundary, plugin step receipt and output order unchanged.
src/commands/doctor-sandbox.ts 0 Already shares image repair with explicit engine/kind. Namespace uncertainty and script/image errors differ and remain distinct.
src/commands/doctor-gateway-health.ts 0 Retain separate structured lint findings and interactive diagnostics: exec-secret admission, unauthenticated reachability, per-RPC diagnostic budgets, installed-state fallback, and memory shallow-skip classification serve different contracts.
src/commands/backup-verify-manifest.ts 0 P1 full-read decision reused after exact blob parity verification: JSON diagnostics and update recovery schemas differ deliberately. No schema modifications; exact validation ordering and legacy compatibility kept.
src/commands/status-all/channels.ts 13 Unified shared disabled/missing-file/plugin-issue/unknown-configuration state+detail precedence; retained distinct link-versus-token detail policy and unavailable-credential severity.
src/commands/doctor-tools-md-migration.ts 2 Derived inside-Tools state from captured headingEnd, removing a second state variable. Rejected shared markdown fence parser: it limits indentation to 3 spaces and closing whitespace to spaces/tabs; existing migration accepts broader whitespace.
src/commands/doctor-session-sqlite-retirement.ts 0 Retain selection-wide disposal: persist every owner intent, claim the whole selection, persist unlink intent and validate all claims before synchronous unlinks. A per-artifact loop would weaken sibling/index protection and interrupted-cleanup recovery.
src/commands/status-all/diagnosis.ts 0 P1 inspection reused after fresh-head comparison; Changed: common bounded-list emission; preserves source order, per-list caps, line styling, redaction, and trailers.
src/commands/doctor-update-rehearsal-inventory.ts 0 Current full read confirms Workshop inventory removed by the owning change. Retain explicit shipped isolation environment, plugin data-root precedence, strict data versus allowed code-link traversal, lease checks, and final revalidation.
src/commands/agent-exec.ts 0 Retained environment/snapshot restoration and cleanup dependency chain: runtime uncertainty must stop database/lock release while synchronous environment restoration still runs.
src/commands/onboard-non-interactive/local/auth-choice.plugin-providers.ts 0 Retain trusted manifest versus install-catalog selection, replacement-credential staging, cleanup settlement, utility projection, and runtime-plugin install order. Shared setup-credential helpers do not own this noninteractive staging transaction.
src/commands/sessions.ts 0 Read complete. ACP metadata, CLI context fallback, authored/runtime model and JSON projection are distinct contracts, with no equivalent duplicate path found.
src/commands/doctor-session-sqlite-recovery-inventory.ts 0 Retain inventory classification separately from retirement authority and its transitive dependency-protection pass. Shared source references, bidirectional index/transcript dependencies and grouped database backups require graph propagation rather than independent filtering.
src/commands/agents.commands.delete.ts 0 Read complete. Gateway, unreachable offline, and credentials-required fallback must retain their distinct cron custody. Actual live-authority assertions and rollback uncertainty are not redundant state.
src/commands/doctor-session-sqlite-retained.ts 0 Retain the receipt-retirement transaction and repeated current-state checks. Plugin completion is insufficient: originals must be absent, the receipt unchanged and canonical binding verified. Diagnostic metadata comparison remains separate from replay/retirement authority.
src/commands/migrate.ts 8 The approved interactive plan now constructs apply options once, preserving secret consent and preflight selection. Default-command planning and explicit apply still retain distinct validation timing; merging their public entry points would change when --no-backup and noninteractive errors occur.
src/commands/onboard-non-interactive/local.ts 0 Retain config proposal admission before credentials, first-agent creation/hash adoption, provisioning, commit, daemon install, and health phases. Explicitly skipped absent Gateway is informational only under its existing condition.
src/commands/status.scan.shared.ts 0 Native-provider sharing implemented and measured -8 across owners, then rejected on pre-close versus post-close health projection semantics. This file is back to byte-identical HEAD.
src/commands/triage-update.ts 0 P1 full-read decision reused after exact blob parity verification: prompt, artifact and inventory projections retain distinct shipped-reader compatibility, byte budgets and field precedence.
src/commands/doctor-auth-migration-receipts.ts 0 Fresh full P2 read-only review after freeze. Receipt ownership, digest verification, non-clobber archive recovery and source-change branches retained; no edit.
src/commands/status.command-sections.ts 0 P1 inspection reused after fresh-head comparison; Retained: each section has separate output/ordering/truncation contracts; shared health and memory formatting already owned elsewhere.
src/commands/doctor-session-sqlite-import.ts 3 Share the failure value and construct AggregateError only when manifest failure recording also fails. Preserve issue recording, timestamp, cause, message, and order. The second main integration retains caller-requested current-session admission through main's ||= update; net -3.
src/commands/onboard-helpers.ts 0 Retain reset/session/workspace ordering and lock-overlap protection. Lightweight reachability and configured-model probes have different evidence/error classifications; common runOnboardingGatewayProbe already owns transport parameters.
src/commands/onboard-remote-gateway.ts 0 Retain RPC-bound activation session cancellation and new-boot verification. Wizard answers, stable device chat authority, retryable restart waits, and in-process secret handoff are separate transport obligations.
src/commands/doctor-config-preflight-plugin-migrations.ts 2 Reuse remember() for the initial retained load. Preserve main's versioned stateless-plugin settlement, recoverable warning, explicit migration/unavailable obligations, conflict reset and locked persistence; net -2.
src/commands/backup-resource-inventory.ts 0 P1 full-read decision reused after exact blob parity verification: explicit protected roots, volatile rules and physical ownership are separate; no synthetic ownership by names.
src/commands/doctor-security.ts 6 Retain main scope/global predicate and share ordered security/ask rendering with explicit default labels; derive warning presence from collected host conflicts, preserving canonical-mode and output order.
src/commands/doctor-model-catalog-credentials.ts 7 Fresh full source and prior full boundary tests inspected. Paired catalog credential/invalid-profile facts replace parallel arrays. One staged iterator preserves shared config migration -> shared reload -> catalog migration and common counts/errors. Formatted net -7.
src/commands/health.ts 0 P1 inspection reused after fresh-head comparison; Retained: CLI health/auth/readiness and per-agent selected-account flow; debug and self-identity reporting intentionally differ.
src/commands/status.scan-overview.ts 0 P1 inspection reused after fresh-head comparison; Retained: common scan already shared; lazy imports, shared deadline, progress phases, local/gateway facts not interchangeable.
src/commands/sandbox-explain.ts 0 P1 full-read decision reused after exact blob parity verification: runtime paths, persisted spawn workspace overrides and per-gate diagnostics already share facts. Kept exact JSON shape and text.
src/commands/doctor-device-pairing.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/doctor-session-sqlite-recover-report.ts 0 P1 full-read decision reused after exact blob parity verification: corruption/index repair and original preservation share reporting but differ in authority to replace; kept.
src/commands/promos/claim.ts 0 Read complete. Pre-auth and post-consent offer reads fence a changing remote contract; revalidation cannot reuse the initial data.
src/commands/models/accounts.ts 0 P1 already shares use/clear-default mutation. P2 full read retained socket-owned polling, protected prompts, serial RPCs, cancellation acknowledgement and terminal outcomes as distinct lifecycle contracts; production/tests are blob-identical to the reviewed P1 head.
src/commands/models/shared.ts 0 Fresh full P2 read. Source/runtime config snapshots, authored env-ref restoration, provider preparation and canonical model-key migration remain distinct owner contracts. No further edit.
src/commands/models/auth-logout.ts 0 Fresh full P2 read. Config-before-credential removal, partial-survivor restoration, reconnect exclusion and confirmed conversation cleanup remain separately fenced phases. No further edit.
src/commands/doctor-config-preflight.ts 0 Retain snapshot refreshes after state relocation, plugin convergence, completion, and automatic config repair. Runtime and retained plugin config projections differ; merging refresh blocks must not erase each stage's admission facts.
src/commands/onboard-custom.ts 0 Retain immediate versus deferred verification and detection retry ordering. Generic error formatters differ on falsy/structured values and redaction; using them would change displayed verification errors.
src/commands/doctor-config-analysis.ts 6 Implemented ordered OpenCode override derivation and identical invalid-array exits. Retain custom diagnostic path rendering: the shared quoted-path formatter changes special-key/root text. Include preservation and update-time skip remain intact.
src/commands/models/scan.ts 0 Fresh full P2 read-only review after freeze. P1 parameterized scan capability and prompt/config sharing present; metadata-only safety and exact diagnostics retained.
src/commands/doctor-workspace.ts 0 P1 inspection reused after fresh-head comparison; Changed: common bounded root-memory reads and failure-note renderer; pre-rename and post-rename reads remain distinct.
src/commands/sessions-lifecycle.ts 16 Implemented direct parameterized public-internal command; removed archive/delete forwarding exports. Complete CLI caller and seam tests migrated; all behavior assertions retained. Measured -16 production lines plus -2 CLI lines after formatting.
src/commands/channels/capabilities.ts 0 P1 inspection reused after fresh-head comparison; Changed: one deadline/error runner with per-result adapters; same bounded probes, exact diagnostic shapes, and safe default tone.
src/commands/doctor-session-snapshots.ts 0 P1 full-read decision reused after exact blob parity verification: cross-platform cached paths and legacy JSON inspection are intentional; map deduplication preserves fixed-store reporting.
src/commands/health-format.ts 0 P1 inspection reused after fresh-head comparison; Retained: lifecycle/pre-probe/failed-probe/passive precedence and plugin secret redaction; no duplicated variant implementation.
src/commands/doctor-retired-phone-control.ts 0 Read complete; implemented then rejected ES2024 Set.difference derivation under ES2023 contract. Authored duplicates and journal precedence retained.
src/commands/message-format.ts 0 Read complete. Fresh main already shares read/pins rendering; safe reaction tables differ deliberately from ordinary tables.
src/commands/status-all/format.ts 0 P1 inspection reused after fresh-head comparison; Retained: shared overview owner and precise source/auth/service/update labels; wide option surface has active callers.
src/commands/doctor-workspace-status.ts 3 Keep main pluginTargetResolutionError helper and precompute registry-lag facts for existing repair rows; diagnostic distinctions, fields and text remain unchanged.
src/commands/agents.config.ts 0 Read complete. Roster collapse and expansion use canonical transition owners; deletion reference pruning differs by field. Explicit empty delegation lists must not restore inherited permission.
src/commands/doctor-maintenance-state.ts 0 Implemented and measured a shared drained-database callback at only 3 net lines, then restored original. Retain visible authority checks, NOCOW finally restoration, reclamation aggregate errors, and original write-capture settlement.
src/commands/channels/add-wizard.ts 0 Revisited initial selector versus trusted catalog: wizard exact id outranks aliases, trusted catalog matches in catalog order. They cannot share the current resolver without changing behavior.
src/commands/doctor-session-sqlite-failure.ts 0 P1 full-read decision reused after exact blob parity verification: publication claims bind exact sanitized content and durable attempt state; no changes.
src/commands/migrate/selection.ts 0 P1 full-read decision reused after exact blob parity verification: skill/plugin selection already parameterized; Enter, Space, all/invert retain distinct keyboard semantics and config ownership.
src/commands/doctor.ts 0 CLI mode dispatch already shares canonical operations. Receipt claim/reconcile/unknown-publication and browser fallback have distinct retry authority.
src/commands/sessions-tail.ts 0 Explicit-store/explicit-key/Gateway selection differ; bounded initial history and sequence-follow cleanup retained.
src/commands/doctor-session-incognito-key-repair.ts 0 P1 full-read decision reused after exact blob parity verification: already table-drives key columns and shared entry visitor; journal before multi-store rewrites and final journal cleanup retained.
src/commands/onboard-browser-handoff.ts 0 Retain credential-bound target preparation, document readiness, baseline presence, URL retargeting, and GUI/headless waits. Browser success and a newly connected Control UI client are different evidence; no common retry wrapper added.
src/commands/channels/add.ts 18 One option filter with explicit legacy/contract coercion mode, repeated effect context factory and unsupported-add message owner; callback read at each prior stage and invocation boundaries unchanged. Rejected replacing with installable-channel resolver because install/load order, setup-only preference and metadata scope differ.
src/commands/doctor-session-sqlite-verification.ts 0 Retain the recovery-destination verifier lifecycle: inspect ownership once, establish database/sidecar fingerprints after closing the reader, then use stat-only checks. Reopening SQLite on each check could itself alter WAL/SHM state.
src/commands/sessions-cleanup.ts 0 Read complete. Remote output must not canonicalize a foreign-host path. Dry-run is local/read-only; applied cleanup takes separate custody.
src/commands/doctor-session-transcript-headers.ts 37 Shared transcript scanning removes discovery/connection/error boilerplate. Header repair still validates canonical events, session binding, timestamp-inclusive snapshots, legacy header version, event identity and preserved row timestamps inside its replacement transaction; these differ materially from surgical label repair.
src/commands/doctor-state-storage-platform.ts 12 Port P2 cloud-root detection sharing into the new main-owned platform module. Preserve platform admission, OS-home/environment-root precedence, Windows case folding, existing-ancestor lookup and first-match ordering. Full extracted owner read; no storage semantics changed.
src/commands/agents.providers.ts 0 Retained first-canonical account precedence, wildcard expansion, hidden-provider visibility and missing-plugin diagnostics. Existing helpers own labels and identity.
src/commands/gateway-status/helpers.ts 6 Shared current/legacy issue projection and connected-probe rendering. Probe latency is host-produced number/null, so connected success/failure share formatting while limited/failed read labels remain distinct.
src/commands/configure.gateway.ts 0 Retain ordered bind/auth/Tailscale prompts and trusted-proxy loopback consent. Token plaintext/ref and password prompting have different validation/storage behavior; final auth-field removal already has one owner.
src/commands/channels/list.ts 0 P1 inspection reused after fresh-head comparison; Retained: JSON manifest-only path deliberately differs from text runtime credential snapshots and catalog visibility.
src/commands/doctor-telegram-general-topic-conversations.ts 5 Implemented -5: three separately typed Kysely update builders share the ordered executor loop inside the existing transaction. Static table/column checking, all target columns and delete ordering retained.
src/commands/config-preflight-snapshot.ts 0 Retained separate core/config-recovery/plugin snapshot admissions and post-lease revalidation; reads establish different generations and are not redundant.
src/commands/configure.gateway-auth.ts 8 Implemented removal of a one-use static-catalog wrapper. Retain agent-target projection, existing-primary preservation, provider preference changes, utility early return, scoped allowlist updates, and retry selection semantics.
src/commands/doctor-maintenance-restoration.ts 0 Retain own-stop reversal versus optional offline activation, installation rewrite admission, manager lock, and final service identity revalidation. Combining these branches would conflate recovery authority with fresh activation authority.
src/commands/onboard-skills.ts 0 Retain primary-recipe readiness cache, selected-ready/skipped partition, node-manager persistence before install, and per-result diagnostics. Alternative recipes cannot replace the chosen primary recipe merely to simplify readiness.
src/commands/agents.bindings.ts 0 Read complete. Implemented a shared binding builder and measured +5 production LOC after formatting; removed the experiment because the extra parameter/assembly seam was larger than the duplication. Add and remove matching differ in first-owner versus positional duplicate behavior.
src/commands/doctor-heartbeat-main-session-repair.ts 0 P1 inspection reused after fresh-head comparison; Retained: transcript chunk/record bounds and legacy/sqlite lifecycle paths reflect shipped storage contracts.
src/commands/onboard-agent-target.ts 12 Reimplemented P1's rejected candidate as explicit four-field pick/omit only. Original comparisons, short-circuits, object insertion order, legacy/default ownership, and sibling roster entries remain intact.
src/commands/control-ui-handoff.ts 0 Retained credential planning, verified loopback alias and HEAD/GET readiness lifetime. GET fallback cannot replace the observed HEAD result.
src/commands/gateway-status/output.ts 0 P1 inspection reused after fresh-head comparison; Retained: JSON and text projections deliberately differ; warnings retain individual ordering and diagnostic identity.
src/commands/doctor-session-incognito-key-repair-state.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/doctor-session-delivery-state.ts 0 P1 full-read decision reused after exact blob parity verification: already shares canonical/raw transformation owner; raw repair adds backup and identity admission.
src/commands/doctor-migration-backup.ts 0 Retained after P2 reconsideration: capture marker, source identity, snapshot verification, rollback grouping and maintenance checks are distinct safety contracts.
src/commands/onboard-non-interactive/local/auth-choice.ts 0 Retain flag/env/profile SecretRef serialization boundaries, deprecation checks, plugin dispatch, custom optional-key behavior, and inactive replacement-credential guidance; profile material must not become plaintext config.
src/commands/setup.ts 0 Fresh complete current source read. Authored/include provenance, fresh versus existing roster writes, inherited explicit-set paths and creation revision adoption are distinct contracts. Workspace publication and output projections already use existing owners; a generic leaf-write table would hide differences in persisted value sources.
src/commands/agents.commands.bind.ts 24 Shared binding mutation now exported with explicit bind/unbind operation; old forwarding handlers and duplicate option shape removed. Caller and seam tests cut over. Shared expected-error owner also replaces private throw helper.
src/commands/doctor-session-transcript-labels.ts 38 Shared scanning owns read connections and diagnostics. Frozen shipped-label rewrites, timestamp-envelope and active-memory handling stay local; per-row repair retains malformed-sibling refusal and seq/eventJson snapshot comparison without adding the header-only createdAt guard.
src/commands/backup-remote.ts 0 P1 full-read decision reused after exact blob parity verification: source capture and restore download already share their correct owners; scratch cleanup guarantees location close after errors.
src/commands/doctor-platform-notes.ts 6 Combine the three sequential macOS warning operations. Keep main noteMacGatewayWarning helper, collector order, platform checks and exact note text.
src/commands/runtime-plugin-install.ts 0 P1 shared descriptor installer retained; repair versus fresh install have distinct consent/record flow.
src/commands/status-overview-rows.ts 0 P1 inspection reused after fresh-head comparison; Retained: Human regular/all sections differ; shared degradation and surface rows already centralized.
src/commands/status-runtime-shared.ts 8 Common lazy import/deadline/RPC result core. Request construction occurs only after import+budget check, failures retain phase and exact formatting. Strict health/heartbeat signatures omit callOverrides as before.
src/commands/status.command.ts 0 P1 inspection reused after fresh-head comparison; Changed: shared optional-probe progress decorator; direct prepared scan surface.
src/commands/onboard-remote.ts 0 Retain discovery endpoint trust, manual URL override invalidation, existing-secret confirmation, no-secret confirmation, SecretRef flow, and origin-bound edge-auth preservation. They express user authorization, not repeated prompt boilerplate.
src/commands/migrate/output.ts 0 P1 full-read decision reused after exact blob parity verification: Dispatch reason precedence once across preview/result. Installation-specific migrated/skipped/warning messages and all exact text retained.
src/commands/backup-git.ts 0 P1 full-read decision reused after exact blob parity verification: Git identity selection and SQLite source selection have distinct blank handling/config resolution/contracts.
src/commands/channels/status.runtime.ts 0 P1 inspection reused after fresh-head comparison; Retained: runtime-specific lifecycle, event loop, probe/audit and credential output.
src/commands/channels/remove.ts 0 P1 inspection reused after fresh-head comparison; Retained: separate delete/disable confirmation and running-account stop boundary.
src/commands/doctor-auth-legacy-paths.ts 0 Fresh full P2 read-only review after freeze. Shared-main ordering, symlink/unavailable distinctions and retired sidecar references retained; no edit.
src/commands/onboard-non-interactive/local/output.ts 0 Retain command-specific runtime text: the daemon formatter changes pid=0 handling, trimming, duplicate-state suppression, parentheses and signal annotations. Failure classification precedence and caller Fix override remain explicit.
src/commands/doctor-claude-cli.ts 11 Implemented -11: scanner carries ordered directory variants; reporting derives labels/remedies from explicit workspace/project subjects and shares the problem prefix. Probe order and readonly-project no-repair policy unchanged.
src/commands/dashboard.ts 11 Implemented common SSH hint branch and derived undelivered handoff from clipboard/browser results; exact text and token/SecretRef behavior unchanged (-11).
src/commands/models/list.auth-overview.ts 0 Fresh full P2 read-only review after freeze. Provider-scoped cooldown labels, source-owner display, redaction and explicit synthetic projection retained. Reusing whole-store unavailability would add repeated scans.
src/commands/status.update.ts 0 P1 inspection reused after fresh-head comparison; Retained: Git/registry/immutable/host labels and stale ledger hints differ by public contract.
src/commands/doctor-completion.ts 10 Implemented -10: interactive repair consumes existing readiness finding; inline private one-use nonInteractive options type. Same flags, note bytes, prompt/generation/install truth table.
src/commands/doctor-session-sqlite-targets.ts 0 P1 full-read decision reused after exact blob parity verification: explicit stores, automatic candidates, historical agents and retained deletion discovery differ intentionally.
src/commands/status.scan.gateway.ts 0 P1 inspection reused after fresh-head comparison; Retained: Online operator.read projection deliberately avoids local discovery and reports noncollection.
src/commands/doctor-config-preflight-plugin-verification.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/startup-config-preflight.ts 0 Read complete. Readiness/recovery paths have distinct authoritative snapshots and lease lifetimes.
src/commands/doctor-auth-profile-config.ts 27 After main integration, retain inferred-provider metadata fact reuse and remove duplicate record/provider normalization. Main mode switch and prefix helper remain unchanged. Explicit dictionary annotations preserve the isRecord contract; runtime JavaScript is byte-identical.
src/commands/doctor-session-sqlite-diagnostics.ts 0 Retain report aggregation that deduplicates physical archive paths and shared database entry counts while summing target-specific outcomes and preserving mode-dependent fields. Generic summation would change reported values and shapes.
src/commands/doctor-gateway-installation.ts 0 Current full read confirms one-use installation callback inlined by the owning change. Retain native operation lock, command comparison, current maintenance assertions, Windows standalone restart, and operator systemd override refusal.
src/commands/doctor-sqlite-reclamation.ts 0 Retained read-only detection, disk-space admission and post-mutation verification. PRAGMA reader differs from compaction in fallback and nonnegative validation.
src/commands/doctor-agent-memory-schema.ts 0 Retained read-only no-op scan and rediscovery under maintenance lease; schema owner untouched.
src/commands/doctor-agent-deletion-journal-quarantine.ts 0 Retained archive-before-quarantine and raw source comparison; held-source paths and cleanup authority are separate responsibilities.
src/commands/triage-prompt.ts 0 P1 full-read decision reused after exact blob parity verification: frozen text and retained failure evidence versus advisory byte allocation are intentional.
src/commands/backup-restore.ts 0 P1 full-read decision reused after exact blob parity verification: verification before target creation, delayed symlink materialization, preserved targets and aggregate cleanup errors remain intact.
src/commands/doctor-post-upgrade.ts 24 Share record-scoped error emission with explicit code and preserve field omission/order. Retain ordered checkout-marker checks and package/source simplifications; preserve main report factory, explicit return type, declaration module and directory-parent reuse.
src/commands/doctor-session-sqlite-archive.ts 0 Retain the shared-index publication boundary: group owners, verify admitted index identity, derive recovery dependencies, record every owner before moving and distinguish failures before versus after a durable publication plan.
src/commands/agents.commands.identity.ts 2 Read complete. Workspace locator versus identity source and committed workspace have separate report meanings. Common field renderer already landed on main.
src/commands/sessions-cleanup.runtime.ts 0 Per-workspace harness scope and partial-result aggregation preserve authoritative cleanup owner; no concurrency or lease changes.
src/commands/backup-sqlite.ts 0 P1 full-read decision reused after exact blob parity verification: create/list/verify/restore commands keep distinct report keys, source resolution and role validation.
src/commands/channel-setup/trusted-catalog.ts 0 Retain trust-filtered lookup with bounded rejected-owner/origin fallback. Trusted installed entries and discoverable untrusted install candidates intentionally use different missing-fallback policy through the existing shared core.
src/commands/doctor-memory-recall.ts 10 Implemented ordered recall/dreaming audit-confirm-repair-report loop with distinct prompt strings and per-artifact typed repair branches; decline/unchanged cases still advance to dreaming.
src/commands/triage-failure.ts 0 P1 full-read decision reused after exact blob parity verification: foreground and supervisor handoffs have distinct ownership/receipt contracts.
src/commands/backup-schedule.ts 0 P1 full-read decision reused after exact blob parity verification: Git and offsite validation and secret defaults differ; no cron owner changes.
src/commands/agents.commands.list.ts 0 Read complete. Provenance and plugin details have deliberately different JSON/tree loading gates. Ordered fallback traversal keeps every node visible for corrupt lineage cycles.
src/commands/doctor-session-canonical-candidates.ts 0 P1 full-read decision reused after exact blob parity verification: actual inventory-driven owner/lineage evidence; already factored sibling owner resolver.
src/commands/uninstall.ts 0 P1 full-read decision reused after exact blob parity verification: Shared service cleanup; explicit Nix uninstall refusal, unloaded-service note, stop failure diagnostics, and uninstall-after-failed-stop retained.
src/commands/doctor-update-refusal.ts 0 Retain parent start-time and reflog-chain evidence for diagnostic recovery only. Checkout versus rebase sequence, tree equality, ancestry, and live parent/head rechecks cannot collapse to HEAD@{1} or a recorded path.
src/commands/models/auth-api-key.ts 0 Fresh full P2 read. Owner selection, shared-shadow checks, credential-before-config save and current binding validation retained. No further edit.
src/commands/status-all/report-data.ts 0 P1 inspection reused after fresh-head comparison; Changed: passes prepared overview plus gateway/service facts straight to row owner.
src/commands/onboard-inference.ts 0 Retain passive CLI discovery, desktop-app fallback, no-prompt credential reads, and Claude/Codex tie randomization. Credential presence differs from verified login, especially Gemini's legacy file and Codex's stored record.
src/commands/doctor-ui.ts 9 Implemented -9: narrow detector to the no-argument current-install path used by every production caller. Root/Git fixture injection moved from production options to spies on actual dependencies; all output and build/repair behavior preserved.
src/commands/doctor-update-run.ts 0 Retain artifact-preserving discovery, separate interrupted-run reconciliation, fresh postwrite reads, and warning persistence that does not advance updater heartbeat. These read/write phases are intentionally separate.
src/commands/doctor-plugin-manifests.ts 0 Retain canonical-path deduplication and legacy-to-contract key precedence. Replacing generic-record schema parsing with a plain record predicate could change special-key normalization, so no parser cutover made.
src/commands/doctor-usage-cost-cache.ts 5 Implemented -5: retained temporary-name variants are a fixed non-stateful regex table with one test operation; exact regex bytes, grace period and cleanup scope unchanged.
src/commands/migrate/skill-selection-prompt.ts 0 P1 full-read decision reused after exact blob parity verification: maintained selected-value cache required by upstream key/cursor ordering; do not derive from already-mutated prompt state.
src/commands/doctor-sqlite-maintenance-lock.ts 0 Lexical/physical ownership and post-reconciliation checks defend different boundaries. Repeated final stat is a fresh identity check.
src/commands/models/auth-logout-selections.ts 0 Fresh full P2 read. Physical owner capture, logical consumer selection and inherited/default fallback preservation retained. No further edit.
src/commands/doctor-heartbeat-cadence-migration.ts 3 Implemented common owned CronService/Scheduler lifetime, measured198→195lines (-3). Both read/create-monitor and apply-cadence flows stop cron then await scheduler cleanup; preview remains read-only.
src/commands/gateway-status/probe-run.ts 9 Derived sshTunnelStarted from owned tunnel handle, removed duplicated mutable success state; startSshPortForward implementation always returns a handle or throws. Same abort error, discovery order, budgets and cleanup.
src/commands/channels/resolve.ts 0 P1 inspection reused after fresh-head comparison; Retained: target kind inference, per-kind batching and request-order restoration.
src/commands/status-update-restart.ts 0 P1 inspection reused after fresh-head comparison; Retained: Target versus serving identity, rollback and abandoned-run evidence must remain separate.
src/commands/onboard-agent.ts 0 Retain authored-versus-injected roster detection, expected hash admission, team creation, candidate rebase, post-create hash check, and migration warning detection. Agent/team result variants carry genuinely different ownership facts.
src/commands/auth-choice-prompt.ts 0 Retain detected/featured/additional-group ordering, More/Back navigation, and keep-current option behavior. Precomputing detected status across awaited prompts would change the current read lifecycle; no cache added.
src/commands/models/auth-model-policy.ts 0 Fresh full P2 read. User consent, policy snapshot/currentness and application acknowledgement retained. No further edit.
src/commands/onboard-non-interactive/local/gateway-config.ts 0 Retain saved-setting-sensitive normalization and token precedence. Explicit overrides, persisted plaintext, existing refs, ambient env and generated/store secrets cannot share one truthiness-based assignment rule.
src/commands/agent-exec-input.ts 0 Read complete. Stream prompt and descriptor-based agent prompt have different '-' semantics, errors, and directory/stream behavior; generic file reader would alter contracts.
src/commands/doctor-maintenance-inspection.ts 0 Retain refusal precedence across nested errors and separate readiness versus native-service admission. Ownership mismatch isolation, pending migration refusal, and backup completion are different state proofs.
src/commands/doctor-outbound-delivery.ts 0 Retained after P2 reconsideration: distinct plugin runtime acquisition/retained cleanup failures must preserve maintenance exclusion.
src/commands/gateway-status.ts 0 P1 inspection reused after fresh-head comparison; Retained: signal cleanup and SSH route target selection; repeated signal hooks are bounded.
src/commands/gateway-install-token.ts 0 Captured write preparation and SecretRef/no-secret precedence retained; generated-token persistence warning-only behavior unchanged.
src/commands/doctor-lint-process.ts 0 Read complete. Readiness publication and disposal deadline state cannot derive from process exit; caller cancellation remains independently authoritative.
src/commands/doctor-plugin-host-links.ts 0 Current full read confirms shared read-error reporters, link report helper, and repaired-count loop already on main. Audit and repair still have different effects/result types; no second abstraction added.
src/commands/export-trajectory.ts 4 Removed private expected-error constructor in favor of canonical CLI owner; source/store/export error prefixes unchanged.
src/commands/doctor-session-title-repair.ts 0 P1 full-read decision reused after exact blob parity verification: first-user bounded prefix, current generation/lifecycle and active request predicates are meaningful. Removed the unreferenced return-type alias after transcript result inference retired its only caller (-2 lines).
src/commands/doctor-workspace-alias.ts 0 P1 inspection reused after fresh-head comparison; Retained: current-config and operator-consent revalidation intentionally separates inspection from repair.
src/commands/heartbeat-task-legacy.ts 0 Parser simultaneously owns task selection and exact preserved source bytes; comment/orphan state is required.
src/commands/auth-choice.model-check.ts 0 Retain route-specific ready/missing/indeterminate/incompatible states and pending wizard credentials. Catalog observations and auth availability are different evidence; warnings must not turn uncertainty into readiness.
src/commands/doctor-session-sqlite-transcript-readers.ts 0 P1 full-read decision reused after exact blob parity verification: lazy schema-specific statements and exact iterator cleanup preserve old-db reads and no live cursor across writes.
src/commands/models/accounts-gateway.ts 0 Fresh full P2 read. Socket-owned cancellation/readiness/user identity/cleanup boundaries retained. No further edit.
src/commands/onboard-recommendations.ts 0 Retain safe opaque IDs, canonical source/tier deduplication, legacy bare-ID retirement, compare-and-swap retry updates, and agent-scoped store selection. Read/acknowledge/refresh effects cannot share a generic mutation path.
src/commands/message.ts 0 Account resolution, scoped secrets, action validation and progress retain their original ordering; JSON/error surface unchanged.
src/commands/doctor-config-preflight-legacy-config.ts 0 Retain current legacy-byte repair before last-known-good recovery and future/read-only/update-parent gates. Config recovery alternatives have different diagnostics and must reread after successful publication.
src/commands/doctor-session-sqlite-types.ts 0 P1 full-read decision reused after exact blob parity verification: intentional public command report shapes and missing optional fields retained.
src/commands/gateway-readiness.ts 4 Shared initial nonrecoverable result branch, preserving separate native-service/start/install permission facts and exact hints (-4).
src/commands/docs.ts 0 Markdown vs rich output differs intentionally; bounded fatal UTF8/JSON decoding and transport abort lifecycle retained.
src/commands/doctor-gateway-dueling.ts 0 Retain active-and-enabled system-owner proof before user-unit removal, confirmation-time revalidation, and final remaining-owner report. Generic service cleanup cannot safely replace this ownership-specific path.
src/commands/doctor-lint-output.ts 0 Read complete. Public JSON fields and shipped updater failure envelope intentionally explicit.
src/commands/daemon-install-plan.shared.ts 0 Retain explicit/pinned runtime precedence, implicit Bun fallback, and path-directory discovery tied to the active package. Wrapper bypass and unsupported runtime discovery have distinct selection contracts.
src/commands/doctor-agent-deletion-journal.ts 0 Retained distinct missing/unreadable/quarantined/reconstructed outcomes and command guidance; no recovery semantics changes.
src/commands/doctor-plugin-generations.ts 0 Retain authoritative active-record matching before retiring stale trees, and mark only successful retained generations before invalidating cache. Shared display callback would add scaffolding for two short reports.
src/commands/models/list.list-command.ts 0 Fresh full P2 read-only review after freeze. Selected remote Gateway remains authoritative; offline fallback is only before owner selection. No edit.
src/commands/doctor-sqlite-compact.ts 0 Initial checkpoint busy, mutation failure, close failure and success-hook failure retain distinct public outcomes; import-finalize no-op differs from explicit compact.
src/commands/onboard-non-interactive.ts 0 Retain separate migration-import and ordinary setup leases. Duplicate config reads are fresh read versus commit-CAS boundaries; a new snapshot helper offers little reduction while obscuring those entry points.
src/commands/doctor-auth-legacy-oauth.ts 0 Fresh full P2 read-only review after freeze. Retired-profile removal and OAuth ID repair have different consent/state boundaries; no edit.
src/commands/status-all/gateway.ts 0 P1 inspection reused after fresh-head comparison; Retained: OAuth JSON block grouping and bounded tail rendering are separate responsibilities.
src/commands/onboard-non-interactive/api-keys.ts 0 Retain explicit flag/ref rules, provider env resolution, malformed-command rejection, ordered existing-profile fallback and requiredness. Ref mode cannot borrow an unidentifiable or plaintext source.
src/commands/doctor-plugin-model-catalog.ts 0 Retain sidecar migration versus persisted catalog repair, deduplicated warnings, and repair only after warning-free reread. Returned counters are also used in meaningful reports; dropping the return shape would not remove the work.
src/commands/status-all/channels-token-summary.ts 0 P1 inspection reused after fresh-head comparison; Retained: HTTP/socket credential pair variants already share core with explicit precedence.
src/commands/auth-choice-options.ts 0 Retain one accepted CLI-choice owner, trusted provider contributions, visibility filtering and group sort rules. Core generic choices and interactive grouped choices intentionally differ.
src/commands/models/auth-order.ts 0 P1 already shares set/clear mutation. P2 full read retained get-order canonical/alias resolution, config-fallback descriptions, set-only profile validation and refresh ordering; production/tests are blob-identical to the reviewed P1 head.
src/commands/sessions-table.ts 0 Read complete. Explicit field projection preserves the JSON shape; deriving by object spread would expose extra persisted fields.
src/commands/reset.ts 0 P1 full-read decision reused after exact blob parity verification: Use shared service cleanup; reset still skips Nix and stops only loaded services.
src/commands/doctor-bootstrap-size.ts 3 Implemented -3: derive per-file warning candidates once, then select fixed USER.md versus configurable tips. Total-budget path and unknown-cause output retained.
src/commands/doctor-session-store-owner.ts 0 P1 full-read decision reused after exact blob parity verification: config backup chronology, authored-include refusal, explicit consent and evidence recheck are contracts.
src/commands/doctor-command-owner.ts 0 Read complete. Resolver preserves plugin target kinds; no migration semantics changes.
src/commands/doctor-project-clone-shape.ts 0 Retained after P2 reconsideration: command ordering, redaction and manual-only repair preserve source trust.
src/commands/sandbox.ts 1 Failure count derives from the private selected result list minus successful removals. Browser/container selection and removal are already parameterized, while validation, consent, owner revalidation before every removal and exact per-item output remain explicit.
src/commands/channel-setup/discovery.ts 0 P1 installed/installable filter core remains. Retain distinct trusted versus discoverable sources, configured-channel exclusion only for installable entries, and metadata precedence across built-in/runtime/catalog sources.
src/commands/doctor-web-fetch-proxy.ts 4 Implemented -4: inline sole proxy-key selector at its rendering owner; proxy precedence, value redaction and loopback/direct probes unchanged.
src/commands/models/fallbacks-shared.ts 0 P1 already shares add/remove mutation. P2 full read retained source-position filtering against runtime-resolved refs, add-only canonical model upsert and remove-only not-found validation; production/tests are blob-identical to the reviewed P1 head.
src/commands/configure.daemon.ts 0 Retain restart/reinstall/skip choices, preparation before replacement, token warnings, and linger setup after success. Noninteractive and Doctor install flows use the same service owner but different prompts/failure outcomes.
src/commands/doctor-skills.ts 0 P1 inspection reused after fresh-head comparison; Retained: fleet-wide unavailable derivation and per-agent report keep healthy sibling skills enabled.
src/commands/migrate/apply.ts 0 P1 full-read decision reused after exact blob parity verification: backup, plan, apply and lifecycle custody have meaningful different settlement behavior.

@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Coverage log, part 2 of 2.

Per-file implementation and retention decisions

Commands P2 per-file coverage

Initial coverage inventory: 50d7eb1b7fbc65d5552ac3c82d65dcb512e15b42, 460 production files / 97,801 lines. Final reduction columns are measured against integrated main f02f2de695169db662dae961fc5c19951f0f4a28; the additional extracted platform owner was also read and is included below; the excluded src/commands/doctor/ subtree was not edited. Read reuse is explicit in the decisions and supported by matching P1/current blobs in the local audit. P1 reviewed head: 7223003e0ea498070880131744c32d80d8ae5b4b.

File Net removed Decision
src/commands/models/auth-list.ts 0 Fresh full P2 read. Historical cooldown timestamps differ from active-unavailability status, so the new active-only helper cannot replace this projection. Exact fields/order retained.
src/commands/doctor-maintenance-stale-service.ts 0 Retain positive legacy-lock or serving-build mismatch evidence, native service ownership proof, and post-stop runtime/port/lock checks. Version equality alone is not replacement authority.
src/commands/doctor-update-snapshots.ts 0 Retain bounded root/descendant scanning, no symlink following, partial-size reporting and manual-only cleanup guidance. Separate entry/depth/time budgets cannot be replaced by an unbounded recursive size helper.
src/commands/doctor-original-capture.ts 0 Retained after P2 reconsideration: original baseline admission and standalone capture have distinct authority and refusal behavior.
src/commands/telemetry-exporter-summary.ts 0 Full current source and direct tests read. Safe field projections exclude private data; latest-event selection preserves ties and stable grouping. The two recovery labels and transport-specific ownership text are explicit short contracts; a descriptor helper would add indirection without a reduction.
src/commands/doctor-node-hosting-preconditions.ts 6 Implemented -6: four independent warnings share their fixed checkId/severity through a typed local emitter; predicates, order and complete text preserved.
src/commands/doctor-rehearsal-databases.ts 0 Retained after P2 reconsideration: database/family sets, alias map and identity map carry distinct invariants.
src/commands/status.scan.bootstrap-shared.ts 0 P1 inspection reused after fresh-head comparison; Retained: Common bootstrap already shared; cold-start suppresses state/network work.
src/commands/backup-namespace.ts 0 P1 full-read decision reused after exact blob parity verification: claim/takeover/race readback and per-side-effect owner validation are real contracts.
src/commands/channels/shared.ts 0 P1 inspection reused after fresh-head comparison; Retained: existing shared account label/state/token owners already consolidate renderers.
src/commands/agent-exec-result.ts 0 Read complete. Redacted payload projection, final-text exclusion and metadata fallback independent; status precedence intentional.
src/commands/migrate/memory-import.ts 0 P1 full-read decision reused after exact blob parity verification: negative provider detection, exact memory item IDs, safe-copy restriction and context binding retained.
src/commands/models/aliases.ts 0 Fresh full P2 read. Alias source snapshot, collision semantics and built-in alias diagnostics retained. No further edit.
src/commands/doctor-whatsapp-responsiveness.ts 11 Implemented -11: one insertion-ordered Map owns first-seen PID deduplication; account enablement derives from one values array; same pressure/enablement predicate order.
src/commands/triage-automatic-repair.ts 0 P1 full-read decision reused after exact blob parity verification: inference deadline explicitly ends before maintenance phase; original owner cancellation remains.
src/commands/doctor-command-owner-recovery.ts 0 New since P1; read complete. Backup scan must stop across any owner identity change and can only recover a proven prior kind. Not generalized with ordinary migration.
src/commands/systemd-linger.ts 0 Interactive sudo retry and noninteractive command are intentionally different; current account-resolution owner shared.
src/commands/status.command-report-data.ts 0 P1 inspection reused after fresh-head comparison; Retained: Explicit rendering inputs protect optional section and column contracts.
src/commands/storage.ts 0 Init, byte-roundtrip probe and list inspection have distinct cleanup/report behavior; no generic output wrapper added.
src/commands/channel-setup/channel-plugin-resolution.ts 0 Retain registered-plugin fast path, one operation workspace owner, scoped setup registry, optional install and reload. Runtime plugins and setup-only plugins have intentionally different supports filtering.
src/commands/channels/status-config-format.ts 0 P1 inspection reused after fresh-head comparison; Retained: config-only path uses separate secret-unavailable fallback and absent-plugin contract.
src/commands/doctor-maintenance-foreground.ts 0 Retain foreground-owner identity continuity and a distinct ownerless shutdown reserve. Retrying any contention with a fresh deadline would change the admission contract.
src/commands/sessions-compact.ts 0 Read complete. Explicit ok check prevents malformed response from becoming a successful no-op; backend pending is separate from completed compaction.
src/commands/doctor-session-sqlite-active.ts 0 P1 full-read decision reused after exact blob parity verification: retained active original append/reverify contract differs from ordinary metadata import.
src/commands/onboard-interactive-runner.ts 0 Retain terminal restoration on cancellation and before/after hatch, plus separate browser/foreground/chat handoffs. Injected launch callback and production launch require different parameters for existing test seams.
src/commands/status.format.ts 0 P1 inspection reused after fresh-head comparison; Retained: Token and prompt-cache formulas share one statistics owner.
src/commands/onboard-guided-manual.ts 0 Retain explicit candidate/provider selection, missing-candidate retry, role lookup, activation and existing-model-kept guidance. Failure text comes from status-specific keys; no auto-selection or extra inference introduced.
src/commands/doctor-update.ts 0 Retain install-owner refusal, TTY/update/repair gates, git-root verification and updater-result handoff. A skipped readiness result can still be handled without claiming a verified Gateway.
src/commands/channels/logs.ts 0 P1 inspection reused after fresh-head comparison; Retained: manifest identities and exact path-root matching; limits and output shape remain independent.
src/commands/configure.channels.ts 0 Retain safe channel-key filtering, display-label sorting, confirmation before deletion and empty-parent cleanup. Channel tokens/settings are removed while credentials remain on disk; do not reuse credential cleanup helpers.
src/commands/doctor-heartbeat-session-target.ts 0 P1 inspection reused after fresh-head comparison; Retained: alias/global/subagent and explicit-delivery boundaries avoid false warnings.
src/commands/backup-health.ts 0 P1 full-read decision reused after exact blob parity verification: latest attempt/local successful backup/offsite schedule are separate health dimensions.
src/commands/onboard-config.ts 0 Retain authored roster/state-sensitive workspace conflict guard and explicit move permission. skipBootstrap clones before canonical path mutation; replacing it with shallow spreads would change aliasing.
src/commands/doctor-format.ts 8 Implemented -8: share optional file-log hint between early exits and inline private options shape without changing the exported structural signature.
src/commands/system-agent-with-inference.ts 0 Inference import failures and system-agent execution failures have different catch boundaries; preserving lazy import errors prevents one catch-all core.
src/commands/doctor-migration-backup-artifacts.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/doctor-process.ts 0 Read complete. Admitted migration cannot be interrupted by output failure; differs from disposable lint worker and must not share cancellation mechanics.
src/commands/doctor-service-repair-policy.ts 0 Retained after P2 reconsideration: supervisor/container ownership, updater deferral and service selection remain separate policy decisions.
src/commands/onboard-types.ts 0 Retain CLI option/choice definitions and dynamic plugin flag index. This file declares public flags; deleting apparent unused properties is not an authorized structural reduction.
src/commands/doctor-gateway-auth-token.ts 0 Retain exec SecretRef refusal, no ambient fallback for unresolved configured refs, duplicate-secret reuse and verified backup before a new secret-store entry. Recovery and runtime token resolution are separate operations.
src/commands/channel-setup/plugin-install.ts 0 Retain catalog-to-installer adapter and scoped registry snapshot loading. Returned status intentionally omits installer error detail; broad result forwarding would change caller-visible shape.
src/commands/session-store-targets.ts 0 Read complete. Explicit SQLite selector inspection distinguishes missing, non-file, unreadable and foreign schemas; source config errors keep the root CLI error envelope.
src/commands/doctor-service-audit.ts 2 Implemented -2: one issue prefix with optional parenthesized detail; ownership/policy predicates unchanged.
src/commands/onboard-guided-consent.ts 0 Retain security acknowledgement CAS-like preservation, telemetry consent timing and guarded/full access persistence. Quickstart suppresses only its documented prompt, not the acknowledgement owner.
src/commands/status-usage.runtime.ts 0 P1 inspection reused after fresh-head comparison; Retained: Optional credential scope and synthetic provider request are distinct and sequential.
src/commands/config-validation.ts 0 Full current source and human/JSON tests read. Snapshot/write options retain native ownership, JSON exits before human diagnostics, and plugin metadata stays lazy. Existing validator already shares the meaningful core; distinct reader operations must remain separate.
src/commands/models/model-reference-validation.ts 0 Fresh full P2 read-only review after freeze. Installed/uncatalogued/unknown provider distinctions and source alias normalization retained; no edit.
src/commands/status-json-runtime.ts 0 P1 inspection reused after fresh-head comparison; Changed: passes prepared scan plus services straight to JSON projection owner.
src/commands/doctor-config-preflight-migrations.ts 0 Retain plugin convergence before state selection, fresh config comparison, scoped refusal isolation and readiness diagnosis on failure. Existing noteStateMigrationResult already shares change/notice/warning rendering.
src/commands/sessions-display-model.ts 0 Read complete. Embedded-provider preference, configured-provider inference and default fallback are intentionally ordered.
src/commands/configure.gateway-health.ts 0 Retain local/remote auth resolution and fallback policy, successful-daemon startup grace, target-bound health RPC and ExitError no-double-report handling. Onboarding's informational absent-Gateway behavior is not equivalent.
src/commands/models/auth-credential-import.ts 0 Fresh full P2 read. Import plan identity, provider scope and before/after persistent-effect validation retained. No further edit.
src/commands/doctor-bun-cli-launcher.ts 0 Retained after P2 reconsideration: launcher preconditions, temporary Node alias rejection and conflict handling are feature contracts.
src/commands/models/auth-relogin-identity.ts 0 Fresh full P2 read. Unique identity match, matcher-throw behavior and current credential validation retained. No further edit.
src/commands/models/provider-aliases.ts 0 Fresh full P2 read-only review after freeze. Bundled source-peer fallback is an explicit development contract; cache and canonicalizer preserved.
src/commands/backup.ts 0 P1 full-read decision reused after exact blob parity verification: remote verify and local dry-run custody/outcome distinctions retained.
src/commands/channels/status.ts 0 P1 inspection reused after fresh-head comparison; Retained: typed protocol refusal versus config-only fallback and one readiness deadline.
src/commands/doctor-config-audit-scrub.ts 0 P1 preview/repair invocation core remains. Retain aborted-write handling and distinct preview versus completed scrub messages; audit retention and append-conflict behavior remain with the audit owner.
src/commands/doctor-main-session-recovery.ts 2 Implemented -2: return filtered detached SessionEntrySummary snapshots as replacements; storage owner normalizes the identical shape. Batching, await, current-entry transition and consumePendingReset preserved. Shared helper experiment rejected after measured growth.
src/commands/node-runtime-diagnostics.ts 0 CLI failure and service warning have different severity/install-owner and fallback contracts.
src/commands/doctor-session-sqlite-missing-index.ts 0 P1 full-read decision reused after exact blob parity verification: read-only proof requires matching canonical transcript bytes and surviving index dependencies.
src/commands/status.agent-local.ts 0 P1 inspection reused after fresh-head comparison; Retained: Agent admission and read-only session/workspace facts are distinct.
src/commands/doctor-disk-space.ts 0 Retained after P2 reconsideration: warning data constructed directly in collection owner; critical/warning boundaries, rounding, findings and notes unchanged.
src/commands/doctor-install.ts 4 Implemented -4: package.json and pnpm-workspace.yaml self-link checks share read/catch/report loop; JSON and YAML parsers and malformed-document rules remain explicit.
src/commands/onboard-non-interactive/remote.ts 9 Implemented ordered token/password projection. Retain endpoint-change clearing, same-endpoint route preservation, SecretRef provider selection, exact output auth priority and canonical wizard commit.
src/commands/sandbox-display.ts 0 P1 full-read decision reused after exact blob parity verification: shared usage rendering exists; runtime/browser details cannot merge without more parameter boilerplate than removed.
src/commands/auth-choice.apply.ts 0 Retain normalization, plugin preparation and persistence separation. Do not delete the oauth fallback merely from the first normalization branch: plugin/token-provider discovery can contribute dynamic choices before preparation.
src/commands/doctor-session-sqlite-compact.ts 0 P1 full-read decision reused after exact blob parity verification: import finalization's migration/lease differs from explicit compaction.
src/commands/doctor-session-exec-policy.ts 0 P1 full-read decision reused after exact blob parity verification: shared entry transformer already owns scan/rewrite; retained messages explain approval-policy preservation.
src/commands/models/list.probe.cleanup.ts 0 Fresh full P2 read-only review after freeze. Parent tracked work, deferred physical cleanup and database-before-directory settlement retained; no edit.
src/commands/status-overview-values.ts 0 P1 inspection reused after fresh-head comparison; Retained: Distinct display values, count thresholds and formatting contracts.
src/commands/status-all/report-lines.ts 0 P1 inspection reused after fresh-head comparison; Retained: Shared render helpers preserve style callback and section ordering.
src/commands/channels/dead-letters.ts 0 P1 inspection reused after fresh-head comparison; Retained: list and resubmit own distinct queue operations, errors and JSON shapes.
src/commands/models/auth-refresh.ts 0 Fresh full P2 read. Native/callback refresh outcomes, legacy fallback and local/remote transport warnings differ materially. No further edit.
src/commands/doctor-host-desktop.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/doctor-install-policy.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/onboard-quickstart-host.ts 0 Retain fresh plugin-cache scope, foreground Gateway lifetime, races against gateway stop, browser failure fallback and continued service wait. Browser handoff completion does not own the Gateway process.
src/commands/status.scan.fast-json.ts 0 P1 inspection reused after fresh-head comparison; Retained: Separate no-channel fast path, lazy all-only memory/plugin inspection.
src/commands/doctor-prompter.ts 0 Retained explicit cancellation and aggressive/runtime consent variations; common confirm owner already exists.
src/commands/gateway-status/discovery.ts 0 P1 inspection reused after fresh-head comparison; Retained: ssh-config resolution and discovery-derived targets differ in available identity facts.
src/commands/status.service-summary.ts 0 P1 inspection reused after fresh-head comparison; Retained: Native inspection failure and optional layout drift preserve partial evidence.
src/commands/models/list.table.ts 0 Fresh full P2 read-only review after freeze. P1 state formatting is already shared. Terminal width/sanitization and JSON field projection retained.
src/commands/doctor-plugin-source-captures.ts 0 Retain schema-maintenance custody and other-process census for legacy capture removal, versus native-capture liveness rules. Inspection warnings and partial size facts are kept separate from removal success.
src/commands/doctor-database-preflight.ts 0 Retained source-config capture, target inventory and incompatible/unreadable refusal precedence.
src/commands/doctor-update-rehearsal-paths.ts 0 Retain canonical in-copy traversal, physical identity, owner/mode/hardlink restrictions and the bounded code-link exception. A generic path-inside check is insufficient replacement evidence.
src/commands/node-daemon-install-helpers.ts 0 Retain node-host-specific launch flags, runtime selection reuse and file-backed credential env policies. Gateway install planning has different config/auth/service-path responsibilities; only existing shared runtime helpers fit.
src/commands/configure.shared.ts 12 Share only prompt parameter styling; ordinary arrow wrappers retain deferred Clack export access and direct calls. Exact imported Clack function types preserve the cancellation symbol. Replaced the rejected eager factory after the unchanged cold-help assertion caught it; current reduction is 12 lines against main.
src/commands/doctor-foreign-launchd-jobs.ts 0 Retained after P2 reconsideration: reporting and authorized removal remain split with exact repair and ownership gates.
src/commands/migrate/context.ts 0 P1 full-read decision reused after exact blob parity verification: config overrides, explicit owner resolution and stdout-to-stderr provider logger routing retained.
src/commands/onboard-non-interactive/local/daemon-install.ts 0 Retain systemd availability skip, durable-auth admission, runtime selection, canonical install and linger steps. Its false result and exit behavior differ from interactive configure outcomes.
src/commands/status-all.ts 0 P1 inspection reused after fresh-head comparison; Retained: All-report scan, services, diagnostics and usage preserve progress order.
src/commands/gateway-health-auth-diagnostic.ts 0 Credentials-required and rate-limited shapes differ; canonical connect classifier retained.
src/commands/doctor-tailscale.ts 13 Implemented -13: warning-only collector replaces obsolete mutation-shaped API; sole config-flow consumer migrated by onboarding owner. History b636a65 removed mutation long ago. Same runner, URL/ownership selection and all warning strings.
src/commands/status-all/report-tables.ts 0 P1 inspection reused after fresh-head comparison; Retained: Agent/table detail formatting differs by data ownership.
src/commands/startup-plugin-source-captures.ts 0 Full current source and direct tests read. Canonical and fallback capture discovery have different access/iteration operations; joining catches would suppress fallback discovery on ENOENT. Maintenance contention is intentionally quiet while other cleanup errors warn. Existing cleanup owner retained.
src/commands/daemon-install-auth-profile-env.ts 0 Retain cold source-check boundary before loading auth stores, credential-kind ref selection and host-env security filtering. Config refs add reserved-secret and durable-source policy absent from this owner.
src/commands/doctor-agent-lease-refusal.ts 0 Negative-only external lease preflight differs from held-owner admission; neither can grant the other authority.
src/commands/doctor-session-sqlite-migration-coalesce.ts 0 P1 full-read decision reused after exact blob parity verification: already parameterizes planned/completed arrays; acknowledged imports must not resurrect explicitly deleted sessions.
src/commands/doctor-db-bloat.read.ts 0 Retained after P2 reconsideration: state-first inspection must precede registry read; snapshot cleanup failures stay terminal.
src/commands/status.command-report.ts 0 P1 inspection reused after fresh-head comparison; Retained: Rendering sections already delegate spacing/table ownership.
src/commands/status.scan-result.ts 0 P1 inspection reused after fresh-head comparison; Retained: Explicit scan flattening excludes call overrides and private overview fields.
src/commands/doctor-state-sqlite-compact.ts 4 Implemented -4: inline sole private env options alias; no runtime body change. Existing scripts/lib callers still pass the identical env object.
src/commands/triage-doctor.ts 0 P1 full-read decision reused after exact blob parity verification: independent child oracle, bounded output and unavailable-oracle failure are meaningful.
src/commands/gateway-auth-token.ts 0 Configured vs resolved auth checks fence separate secret-resolution stages; no token output or authorization changes.
src/commands/doctor-gateway-legacy-services.ts 0 Retain recognized Linux legacy-name admission, platform/scope classification and cleanup result mapping. A detected label is not sufficient authority to remove arbitrary units.
src/commands/doctor-startup-migration-refusal.ts 0 Retained after P2 reconsideration: exit reporting and named refusal classification differ from ordinary operational failures.
src/commands/doctor-original-capture-admission.ts 0 Retained after P2 reconsideration: rehearsal namespace checks occur around awaited schema admission and guard original capture.
src/commands/onboard-non-interactive/local/auth-choice-inference.ts 0 Retain trusted manifest flags, ordered explicit matches and custom-provider aggregate flag label. Multiple matches remain evidence for entry-point rejection, not a first-match decision here.
src/commands/models/list.probe.models.ts 5 Candidate map retains only the first model per provider because its sole consumer only selects that element. ReadonlyMap<string,string> replaces unused candidate tails; fallback behavior unchanged.
src/commands/onboard-options.ts 0 Retain one JSON rejection/exit owner and existing table-driven choice validation. Port validation and enum-specific errors are distinct CLI text contracts; no validation ordering change.
src/commands/status.node-mode.ts 0 P1 inspection reused after fresh-head comparison; Retained: Node-only absence decision requires explicit installed=false and active remote service.
src/commands/doctor-session-canonical-owner-evidence.ts 0 P1 full-read decision reused after exact blob parity verification: memoization deliberately excludes cycles; broader rewrite would change repeated-root choice.
src/commands/doctor-config-preflight.cron.ts 0 Retain custom partition/store and webhook projection for partially valid legacy config. This delegates to excluded cron migration owners; no cron semantics or directory edits made.
src/commands/doctor-session-sqlite-warnings.ts 0 P1 full-read decision reused after exact blob parity verification: bounded presentation retains complete raw reports and latest completed per-target evidence.
src/commands/models/list.manifest-catalog.ts 0 Fresh full P2 read-only review after freeze. Static convention-first manifest ownership and explicit provider contribution fallback retained.
src/commands/status-json-payload.ts 0 P1 inspection reused after fresh-head comparison; Retained: Explicit outward JSON shape and optional fields are the serialization contract.
src/commands/triage-handoff.ts 0 P1 full-read decision reused after exact blob parity verification: CLI-specific syntax is user contract; generated handoffs intentionally differ from interactive launch.
src/commands/onboard-interactive.ts 0 Retain classic wizard lifecycle delegation versus conversational inference gate. The conversational path must verify before opening the system agent, so these are not interchangeable wrappers.
src/commands/cleanup-service.ts 0 P1 lifecycle core retained; reset/uninstall differences remain explicit.
src/commands/doctor-lint.worker.ts 0 Same measured worker experiment rejected. Readiness publication before bounded disposal remains distinct from ordinary Doctor exit.
src/commands/doctor-tools-md-migration-guidance.ts 0 P1 inspection reused after fresh-head comparison; Retained: language/template rewrites are exact historical byte contracts.
src/commands/gateway-setup-runtime.ts 0 Explicit selection, retained runtime and persisted pin have different precedence; no extra persistent pins.
src/commands/onboard-first-agent.ts 0 Retain roster skip, team preset/member validation and first-agent naming. Team and single-agent prompts intentionally differ; session migration warnings already use one small reporter.
src/commands/status.scan.ts 0 P1 inspection reused after fresh-head comparison; Retained: Text scan progress and fast/deep flags own one call path.
src/commands/doctor-secret-runtime-degradation.ts 0 Three-line append experiment rejected after declaration build inferred an incompatible hint literal. Restored the original main return branches; byte-identical to main, no P2 reduction claimed.
src/commands/agents.commands.team.ts 4 Uses the shared expected CLI error constructor/throw path, preserving message, human and machine fields exactly.
src/commands/auth-choice-options.static.ts 0 Retain core Custom Provider metadata, generic token/API-key choices and deterministic CLI help order. Replacing these declarations with inferred runtime choices would break pre-manifest help.
src/commands/doctor-unconfigured-agent-databases.ts 0 Retained: filter-then-map experiment implemented/formatted grew by 1 line; reverted entirely. Existing targeted projection/error behavior retained.
src/commands/migrate/providers.ts 0 P1 full-read decision reused after exact blob parity verification: selected plugin provider lifetime is intentionally retained across recursive public command calls.
src/commands/models/auth-activate.ts 0 Fresh full P2 read. Saved setup activation and applied-config acknowledgement are separate boundaries. No further edit.
src/commands/models/list.format.ts 0 Fresh full P2 read-only review after freeze. Visibility-width, sanitization and tag style contracts retained; no edit.
src/commands/doctor-skills-core.ts 0 P1 inspection reused after fresh-head comparison; Retained: semantic filters distinguish disabled, allowlist, agent and platform exclusions.
src/commands/doctor-memory-search-local.ts 0 P1 inspection reused after fresh-head comparison; Retained: four policy outcomes have distinct hints; dynamic table conversion would eagerly format unrelated commands.
src/commands/promos/list.ts 0 Unavailable service differs from empty active offers; notification recording remains before output.
src/commands/status-json-command.ts 0 P1 inspection reused after fresh-head comparison; Retained: JSON runner keeps update-run history and shared deadline order.
src/commands/status.scan-execute.ts 0 P1 inspection reused after fresh-head comparison; Retained: Keeps parallel memory/summary collection and selective scan output.
src/commands/gateway-startup-timing.ts 0 Setup and update share existing timing owner but floors/caps and derivation strings differ intentionally.
src/commands/gateway-presence.ts 0 Released text fallback and typed self-record ordering retained; no extra runtime fields projected.
src/commands/onboard-inference-ambient.ts 0 Retain ordered OpenAI/Anthropic env detection and fixed labels/default refs. A generic provider table would save little here and expand a two-provider static contract; no model IDs changed.
src/commands/doctor-stale-runtime-build.ts 0 Retained after P2 reconsideration: updater/owner/source-build/env-commit gates prevent distinct false positives.
src/commands/gateway-diagnostic-readiness.ts 0 Single monotonic budget and explicit starting outcome retained.
src/commands/doctor-browser.ts 0 Retained after P2 reconsideration: plugin facade preserves optional repair and diagnostic-unavailable behavior.
src/commands/doctor-maintenance-admission.ts 0 Retain live reader admission on every assertion/continuation read and original continuation identity for recording. Recorded step presence is not a substitute for current authority.
src/commands/doctor-session-sqlite-restore-report.ts 0 Fresh full inspection confirms target-report projection, trusted restore-target projection and empty-selection fallback have different output shapes. Restore conflicts attach only to the selected reporting target; the previously implemented shared attachment helper grew production code by six lines and remains rejected.
src/commands/doctor-gateway-runtime-plan.ts 0 Retain supported installed Node selection when no explicit/pinned/wrapper override exists; delegate final plan construction to daemon-install owner. Removing the probe could replace an operator runtime.
src/commands/doctor-session-worktree-workspace.ts 0 P1 full-read decision reused after exact blob parity verification: async close only for handles acquired in task; no pooling or authority changes.
src/commands/migrate/types.ts 0 Fresh full inspection fills the missing P1 log row despite byte parity. Common, apply and default option types express real command contracts; suppressPlanLog, configOverride, configPatchMode, itemIds and preflightPlan are documented internal handoff capabilities, not removable speculative options.
src/commands/doctor-db-bloat.ts 0 Retained after P2 reconsideration: worker-owned read and authority assertion; bloat and large DB thresholds remain distinct.
src/commands/doctor-tools-md-migration-budget.ts 0 P1 inspection reused after fresh-head comparison; Retained: per-agent bootstrap budget across shared workspace and canonical grouping.
src/commands/models/model-selection.runtime.ts 0 Fresh full P2 read-only review after freeze. P1 caller-owned selection policy and prepared generation scope present; no edit.
src/commands/status.gateway-connection.ts 0 P1 inspection reused after fresh-head comparison; Retained: Raw verbose output and remote missing-url guidance are distinct.
src/commands/agent-local-audit.ts 0 Writer owner starts once and retires sinks before flushing; no audit changes.
src/commands/cleanup-plan.ts 0 P1 full-read decision reused after exact blob parity verification: read-only dry run differs from strict destructive configuration admission.
src/commands/configure.commands.ts 0 Retain section parsing before TTY guard and distinction between omitted sections and an empty runner selection. Non-TTY hints reflect the existing public config subcommands.
src/commands/doctor-hooks-model.ts 0 Retained after P2 reconsideration: unresolved, disallowed and catalog-absent findings are independent.
src/commands/doctor-repair-mode.ts 0 Existing owner already centralizes prompt/autofix/update policy. No safe policy simplification needed.
src/commands/backup-record.ts 0 P1 full-read decision reused after exact blob parity verification: external source output and record validation retained.
src/commands/doctor-config-preflight-plugin-index.ts 0 Retain one completion flag scoped to preflight and fresh update-phase checks on every snapshot selection. Rehearsal copying must not run merely because a prior call once qualified.
src/commands/status-all/channels-table.ts 0 P1 inspection reused after fresh-head comparison; Retained: Canonical first-issue map and disabled-state precedence.
src/commands/auth-choice-legacy.ts 0 Retain shipped oauth spelling and manifest-provided claude-cli deprecation diagnostics. This is compatibility normalization with a named CLI contract, not removable alias clutter.
src/commands/models/auth-manual-input.ts 0 Fresh full P2 read-only review after freeze. Provider aliases, key/token distinction and exact input errors retained; no edit.
src/commands/models/load-config.ts 0 Fresh full P2 read-only review after freeze. Source config pinning remains separate from resolved credentials; no edit.
src/commands/doctor-agent-database-operation.ts 0 Sync and async consumers both exist; merging catch wrappers would change return timing or require promise-shape detection.
src/commands/status.daemon.ts 0 P1 inspection reused after fresh-head comparison; Retained: Gateway/node summary already parameterized; package-root check gateway-only.
src/commands/auth-choice.apply.api-providers.ts 0 Retain generic api-key/token kind selection and provider matching; plugin discovery owns the actual auth choice. Moving this into static flags would duplicate plugin policy.
src/commands/doctor-retained-runtime.ts 0 Retained after P2 reconsideration: cleanup closure captures prepared facts and revalidates authority at mutation.
src/commands/channel-setup/registry.ts 0 Retain imperative wizard adapters versus declarative adapters and WeakMap caching for the latter. Shape guards discriminate supported plugin contracts rather than speculative defensive states.
src/commands/backup-summary.ts 0 P1 full-read decision reused after exact blob parity verification: text contract only, no structural reduction without golfing.
src/commands/doctor-agent-database-paths.ts 0 Retained Windows-only alias repair under existing writer owner; update deferral remains inside its original transaction.
src/commands/non-interactive-prompter.ts 0 Prompt refusal owner already shared; per-method logging contracts remain explicit.
src/commands/doctor.worker.ts 0 Shared cleanup/completion experiment measured +1 across both workers and new helper; reverted. Native entry and error finalization preserved.
src/commands/status-all/text-report.ts 0 P1 inspection reused after fresh-head comparison; Retained: Existing shared section spacing/table rendering owner.
src/commands/status.scan-memory.ts 0 P1 inspection reused after fresh-head comparison; Retained: Lazy memory runtime boundary and default database path ownership.
src/commands/doctor-maintenance-exit.ts 0 Retain signal gate, cancellation controller and one-shot release state. The finished rejection communicates failed drainage only during an exit, so it cannot become an unconditional process exit.
src/commands/daemon-runtime.ts 0 Public runtime choices/hints and binary detection kept unchanged.
src/commands/doctor-backup-scratch.ts 0 Retained after P2 reconsideration: small adapter maps owner report categories to exact user-facing text.
src/commands/gateway-service-setup.ts 0 Prepared service definition stays bound to inspected runtime pin until install; retained.
src/commands/migrate/item-selection.ts 0 P1 full-read decision reused after exact blob parity verification: exact selection unknown-ID validation differs from friendly skill/plugin lookup.
src/commands/sqlite-wal-health.ts 0 Pure retained warning projection; no database freshness reads introduced.
src/commands/models/refresh.ts 0 Fresh full P2 read-only review after freeze. Remote refresh outcome projection is already narrow; no edit.
src/commands/triage-claude.ts 0 P1 full-read decision reused after exact blob parity verification: bounded help probe and unsupported versus unavailable result distinction retained.
src/commands/text-format.ts 0 Read complete. Code-point truncation differs from grapheme/visible-width cells; unifying would change output bytes.
src/commands/agents.binding-format.ts 0 Ordered conditional binding fields retained; no benefit from a descriptor layer.
src/commands/doctor-channel-ingress.ts 5 Implemented -5: inline sole private options alias; every runtime statement and structural call shape unchanged.
src/commands/models/list.types.ts 0 Fresh full P2 read-only review after freeze. Output projections retain exact keys and optionality; no edit.
src/commands/channel-setup/config-compatibility.ts 0 Retain host-owned migration lookup, unknown-migration refusal and deep clone before mutation. The clone prevents setup plugins from mutating a prior config snapshot through shared nested objects.
src/commands/status-overview-surface.ts 0 P1 inspection reused after fresh-head comparison; Changed: type-only contract; removed both redundant runtime field-copy adapters.
src/commands/channels/plugin-config-persistence.ts 0 P1 inspection reused after fresh-head comparison; Retained: canonical persistence plus plugin registry invalidation owner.
src/commands/models/set.ts -5 Shared text/image command implementation. Text runtime repair module loads at command entry before any config mutation; image does not import it. Config write/warnings/output preserved.
src/commands/onboard-non-interactive/local/skills-config.ts 0 Retain skipSkills returning the original config and node-manager precedence over existing/default values. No second install policy is introduced by this short config projection.
src/commands/channel-setup/owner.ts 0 Retain blank selector rejection, exact configured-ID validation and ambient owner selection before discovery. Normalizing a requested ID into another agent is not permitted.
src/commands/doctor-memory-scope.ts 0 P1 inspection reused after fresh-head comparison; Retained: shared fleet scope and label owner used by search and recall.
src/commands/onboard-hooks.ts 0 Retain explicit disabled/enabled session-memory policy and add the default only when unauthored. Reducing the condition to truthiness would overwrite explicit false.
src/commands/onboard-non-interactive/local/workspace.ts 0 Retain requested/configured/env/default precedence and non-default-state-root workspace derivation. Guided onboarding's proposed workspace is not the same persistence contract.
src/commands/daemon-install-runtime-warning.ts 0 Retain node-only runtime probing and title-specific warning delivery. This is the shared warning owner used by Gateway and node plans, not another forwarding layer to remove.
src/commands/doctor-post-upgrade.types.ts 0 The overlapping simplification landed on main independently; final source is byte-identical to main and no P2 reduction is claimed.
src/commands/status.gateway-probe.ts 0 P1 inspection reused after fresh-head comparison; Retained: Lazy secret resolution adapter binds local versus remote auth.
src/commands/auth-choice.apply.types.ts 0 Retain command-specific omission/narrowing of the plugin auth contract and prepared-profile persistence shape. Deleting aliases would duplicate the same parameter selections in callers without reducing runtime logic.
src/commands/doctor-lint.ts 0 Full current source and native-admission tests read. This small dispatcher preserves cold imports and released updater process isolation; flattening into the eager runner would load the graph before delegation.
src/commands/doctor-tools-md-migration-content.ts 0 P1 inspection reused after fresh-head comparison; Retained: historical untouched templates must remain exact.
src/commands/onboard-non-interactive/config-write.ts 0 Retain one canonical wizard commit with merge base/hash and reset-only size-drop permission. Direct config replacement would lose conflict handling and pending plugin-record ownership.
src/commands/models/set-image.ts 19 Deleted internal parallel handler; all callers migrated to explicit imageModel field.
src/commands/doctor.types.ts 0 Public CLI option shape retained unchanged.
src/commands/status.gateway-probe-budget.ts 0 P1 inspection reused after fresh-head comparison; Retained: Single monotonic deadline owner.
src/commands/doctor-migration-notes.ts 0 Existing migration result renderer is already shared; exact title/prefix defaults retained.
src/commands/model-picker.runtime.ts 0 Lazy provider runtime bundle retained as an intentional loading boundary.
src/commands/status-json.ts 0 P1 inspection reused after fresh-head comparison; Retained: Public command wrapper owns deadline initialization.
src/commands/doctor-maintenance-types.ts 0 Retain shared maintenance/config-writer contracts; these express actual cross-module ownership inputs and add no parallel runtime path.
src/commands/onboard-non-interactive/local/auth-choice.plugin-providers.runtime.ts 0 Retain lazy provider-discovery boundary and canonical runtime exports. Inlining imports into the noninteractive entry module would load provider runtime for skip-only setup.
src/commands/configure.prompts.ts 0 Retain runtime-bound cancellation conversion for each styled prompt and generic select result. A second generic cancellation decorator adds type scaffolding for this already short adapter.
src/commands/doctor-lint-options.ts 0 Strict worker input schema retained; no protocol changes.
src/commands/channels/runtime-label.ts 0 P1 inspection reused after fresh-head comparison; Retained: loaded/setup/bundled resolution precedence is shared by add/remove.
src/commands/doctor-config-preflight-measure.ts 0 Retain composition of bootstrap trace with optional Doctor measure hook and optional metrics. Removing it would duplicate naming and timing ownership across preflight imports/steps.
src/commands/doctor-state.worker.ts 0 Small worker registration table retained unchanged.
src/commands/doctor-workspace-suggestions.ts 0 P1 inspection reused after fresh-head comparison; Retained: generator preserves backup tip before asynchronous memory guidance.
src/commands/status.command.text-runtime.ts 0 P1 inspection reused after fresh-head comparison; Retained: Lazy text rendering barrel.
src/commands/models/alias-name.ts 0 Fresh full P2 read. Single narrow syntax validation owner retained.
src/commands/status.scan.runtime.ts 0 P1 inspection reused after fresh-head comparison; Retained: Lazy channel runtime barrel.
src/commands/channels/account-selector.ts 0 P1 inspection reused after fresh-head comparison; Retained: shared selector validation has callers outside lane.
src/commands/status.scan.deps.runtime.ts 0 P1 inspection reused after fresh-head comparison; Retained: Lazy optional memory/tailscale runtime boundary.
src/commands/channels/channel-selector.ts 0 P1 inspection reused after fresh-head comparison; Retained: shared selector validation has callers outside lane.
src/commands/doctor-state-integrity-format.ts 0 P1 full-read decision reused after exact blob parity verification: 8-line shared pluralization/type owner already minimal.
src/commands/random-token.ts 0 Single 192-bit token owner retained.
src/commands/channels.ts 0 Command facade retained; no structural duplication inside five export lines.
src/commands/codex-runtime-plugin-install.ts 0 Existing module facade retained for runtime loading/callers; no gratuitous import cutover.
src/commands/status.ts 0 P1 inspection reused after fresh-head comparison; Retained: Public command/status summary facade used outside lane.
src/commands/agent.ts 0 Embedded command public barrel retained.
src/commands/agent/session.runtime.ts 0 Intentional lazy session-store resolution entry retained.
src/commands/auth-token.ts 0 Provider setup-token facade retained.
src/commands/daemon-install-auth-profiles-source.runtime.ts 0 Retain the two-line source-presence facade so the cheap daemon cold path does not activate auth-store runtime imports.
src/commands/daemon-install-auth-profiles-store.runtime.ts 0 Retain the two-line lazy facade separating expensive auth-store loading from daemon plan imports; production imports it dynamically only after source presence is known.

New shared cores: src/commands/models/auth-unavailability.ts (28 lines) and src/commands/doctor-session-transcript-scan.ts (61 lines), included in the net production delta.

Measured and rejected experiments: shared binding builder (+5 LOC), shared Doctor worker lifecycle (+1), backup output callback (-12 but generic plumbing), and common memory-provider projection (-8 but changed pre-close field capture). ES2024 Set/grouping candidates were rejected under the repository ES2023 target.

@steipete
steipete marked this pull request as ready for review October 9, 2026 11:06
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations docker Docker and sandbox tooling size: XL labels Oct 9, 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 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR consolidates repeated command validation, model selection, and Doctor diagnostics while preserving existing CLI output and repair behavior.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful consolidation with preserved contracts, reported shipped-CLI coverage, and no actionable finding.
Proof confidence 🐚 platinum hermit (4/6) The author has verified repository admin authority, so the external-contributor proof gate does not apply. Reported exact-source validation includes real CLI Doctor coverage; its remote artifact was inaccessible to this reviewer. Source comparison verifies unchanged stored formats, repair predicates, transaction ownership, and persisted values, requiring no new migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
Reason: Repeated command mechanics create maintenance cost across existing operations. Prior area ownership and the substantial production reduction support this cleanup without requiring a new product direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this is useful internal maintenance with no concrete correctness defect found. Current main retains the paths being consolidated, and the earlier merged cleanup does not supersede this work.

Priority: P3
Reviewed head: e9ef52146778849b7904ee56b0cc861098b2468d

Before merge

None.

Findings

None.

Agent review details

How this fits together

OpenClaw commands translate operator requests into configuration updates, Gateway requests, and diagnostic reports. Doctor inspects existing configuration and stored sessions, then delegates approved repairs to their existing storage owners.

flowchart TD
  A[Operator CLI request] --> B[Command dispatch]
  B --> C[Shared validation and model selection]
  B --> D[Doctor diagnostic collectors]
  C --> E[Existing configuration and Gateway owners]
  D --> F[Read-only transcript inspection]
  F --> G[Existing guarded repair transactions]
  E --> H[CLI results and diagnostics]
  G --> H
Loading

Technical review

Best possible solution:

Keep shared mechanics in the existing command owners while preserving command-specific output, consent, and repair transactions.

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

Not applicable: this PR proposes behavior-preserving consolidation rather than a reported product defect.

Is this the best way to solve the issue?

Yes: the diff removes parallel internal handlers and shares existing mechanics without introducing competing state owners or public configuration.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced changes reviewed: Reviewed the complete merge-base-to-head diff, including files omitted from the supplied introduction list. Retired command-handler references were searched across source, plugins, and scripts; production callers use the consolidated handlers. (e9ef52146778)
  • Model setter contracts preserved: The consolidated setter retains explicit text/image fields, shared configuration validation, existing warnings, and distinct output labels. Runtime-plugin repair remains text-only and its module loads before configuration mutation. (src/commands/models/set.ts:6, e9ef52146778)
  • Transcript repair invariants preserved: Shared scanning retains read-only connection ownership. Header repair still compares timestamps and exact rows, revalidates the session binding inside the writer transaction, and verifies preserved event identities; label repair retains its narrower row comparison and surgical updates. (src/commands/doctor-session-transcript-headers.ts:220, e9ef52146778)
  • Status failure boundaries preserved: The shared Gateway query preserves lazy import failures, checks the remaining budget before constructing requests, and retains each caller's throwing, error-object, or null outcome. (src/commands/status-runtime-shared.ts:48, e9ef52146778)
  • Validation and shipped CLI coverage: The PR body reports passing exact-source changed checks, the full commands suite, and focused E2E coverage. Inspected Doctor consumer coverage invokes openclaw.mjs in child processes and checks retained account selections, configuration, stored credentials, session state, and repeat-run behavior. The linked remote run page was inaccessible to this reviewer; reported execution results were not independently replayed. (src/commands/doctor.auth-profile-consumers.e2e.test.ts:32, e9ef52146778)
  • Verified author authority: GitHub's collaborator-permission endpoint confirms steipete has repository admin and maintain permissions, resolving the conflicting author-association values in the supplied context and live PR response.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Labels

Label changes:

  • add P3: This is internal maintenance with no intended change to user-facing behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P3: This is internal maintenance with no intended change to user-facing behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 7:13 AM ET / 11:13 UTC.

@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head CI attribution for e9ef52146778849b7904ee56b0cc861098b2468d.

The build-artifacts job 113791537319 passed the full dist/UI build and then failed Check bundled plugin generated assets. The sole mismatch is extensions/workboard/openclaw.plugin.json.

I reproduced the same failure with pnpm plugins:assets:check (exit 1) after a frozen install in a clean, detached checkout of current main 10b767dc090cf5057c2cd13b0d8d51f519f6feb5. The check changed only Workboard's generated Control UI asset digest, from 4235c61ea4c036f6b4ad03a24d0b430dc440008a056580331e14985cc01907d2 to e7967afe91c40091c62fcd6a83a8cf61dba45936ac9057e5739fea51e56c0197.

CI tested merge beaade3f90e8cbd2f41ca4c32dcf58cd63089d69; its parents are exactly the reproduced main and this PR head. Workboard, the asset-generation scripts, the browser build helpers, the SDK alias helper, and dependency manifests are byte-identical between that main and CI's merge. This PR changes none of the Workboard or asset-build paths. This is an inherited generated-asset failure, left outside this commands refactor for the coordinator to repair.

Four initial zero-step auto-response cancellations were rerun individually and passed all eight steps: runs 37921721538, 37921722211, 37921722210, and 37921728199. No cancellation is treated as passing evidence.

The second failed check is openclaw/ci-gate job 113795239398. Its only failing selected dependency is build-artifacts; the job log reports build-artifacts: failure (selected=true). The matching openclaw/ci-gate commit status projects that same CI failure. Neither is an independent source or test defect.

Final paginated check-run census: 222 completed checks: 97 success, 122 conditional skips, one neutral, two failures attributed above; zero pending or cancelled checks. CI run 37921695912, attempt 1, is complete on the exact head. Dependency review and security-sensitive review both succeeded. Hosted review of this head reported no findings and no before-merge action; the independent pre-commit review was also clean.

The exact-source local/remote proof recorded in the PR passed, including all 7,653 commands tests (four existing platform skips), focused/E2E tests, changed checks, zero runtime/static cycles, and an unchanged Plugin SDK API. Under the coordinator's standing inherited-main-failure rule, this PR is ready for a squash merge pinned to the reviewed head. No test, ignore, timeout, budget, or suppression was weakened, and no inherited main fix is included.

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