Skip to content

doctor is one 1,159-line file: model, registry, runner, thirteen checks and renderer with no seam between them #467

Description

@MongLong0214

src/commands/doctor.ts is one file carrying the model, the registry, the runner, thirteen checks and the renderer — 1,159 lines with the in-flight #458 check. Adding a check means editing the file every other check lives in, and nothing but convention stops one check from reaching into another. ADR-0032's context section names this file size as part of what forced the ADR.

Why this exists

  • PRD §9.4 fixes the layout, and the ADR's consequences section states the outcome: "src/commands/doctor.ts splits into a registry, a runner, per-check modules, and a renderer; the PRD fixes the layout. The command's observable text output for existing checks does not change."
  • The contributor story depends on it: one registry entry plus one test against an injected context, in a file of its own.

Scope

Move-only. No logic change, no behaviour change.

Acceptance criteria

  • Layout exactly as PRD §9.4 plus the shim; src/commands/init.ts untouched; every existing test passes unedited.
  • Text output and --json byte-identical (the pinned snapshots stay green with zero updates).
  • No file under checks/ imports another file under checks/ — the seam is real: a check depends on the model and src/core/, never on a sibling. Enforced by a test that walks the import graph, not by review.
  • npm run build still produces dist/commitlore.mjs, and the CI fresh-clone step ("A fresh clone runs, and the plugin entry points resolve", .github/workflows/ci.yml) passes.
  • git log --follow/rename detection recognises the moves (move-only diffs, reviewable as such).

Tests that must exist

case what it catches
no check module imports a sibling check module (import-graph walk over src/commands/doctor/checks/) dependency-by-import creeping back — the coupling the registry's declared edges exist to replace. This is the fails-if-wrong case: the split that leaves checks entangled has not produced the seam PRD §9.4 is for
text and JSON snapshots unchanged any behaviour smuggled into the move
the existing full suite, unedited a broken re-export — init and the doctor tests are the consumers PRD §9.4 promises stability to

Open question — flagged, not decided here

PRD §9.4 names four module files plus checks/, but does not name a home for the model and factory (DoctorCheck, check(...), the unions). A model.ts beside them is the obvious reading; report.ts is arguable. Implementer's choice, stated in the PR, not silently mixed into runner.ts.

Depends on

Out of scope

  • Any behaviour, ordering, rendering, or export-name change; any new file beyond the layout; fixing anything found during the move (file it instead).

Traceability: PRD §9.4; ADR-0032 consequences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions