Files
SubMiner/backlog/tasks/task-94 - Reduce-main.ts-to-thin-composition-root.md

3.0 KiB

id, title, status, assignee, created_date, updated_date, labels, dependencies, priority
id title status assignee created_date updated_date labels dependencies priority
TASK-94 Reduce main.ts to thin composition root In Progress
2026-02-20 12:06 2026-02-21 03:40
architecture
refactor
maintainability
TASK-71
TASK-85
high

Description

src/main.ts still contains heavy deps-builder orchestration and high import concentration. Complete the composition-root refactor so main.ts owns boot wiring only and domain assembly moves behind registry/domain composer modules.

Action Steps

  1. Baseline current main.ts fan-in (check:main-fanin, check:file-budgets, wc -l src/main.ts).
  2. Introduce domain composer modules for repeated build-handler clusters (startup, overlay, jellyfin, anilist, ipc/shortcuts).
  3. Move createBuild*MainDepsHandler call clusters out of main.ts into domain composer modules with narrow typed inputs.
  4. Replace inline assembly in main.ts with single-call composer invocations per domain.
  5. Add/adjust unit tests for new composer modules to lock shape and wiring.
  6. Tighten check:main-fanin thresholds after refactor to prevent regression.
  7. Re-run full config/core test gates and update TASK-71 progress.

Progress Notes

  • 2026-02-21 baseline: src/main.ts = 3129 LOC; check:main-fanin = 105 import lines / 9 unique runtime paths.
  • 2026-02-21 extraction slice: added composer modules src/main/runtime/composers/jellyfin-remote-composer.ts and src/main/runtime/composers/anilist-setup-composer.ts; moved corresponding createBuild*MainDepsHandler orchestration out of main.ts.
  • 2026-02-21 tests: added focused composer shape tests at src/main/runtime/composers/jellyfin-remote-composer.test.ts and src/main/runtime/composers/anilist-setup-composer.test.ts.
  • 2026-02-21 guardrail tighten: scripts/check-main-runtime-fanin.ts defaults tightened to import lines <= 110 and unique runtime paths <= 11.
  • 2026-02-21 post-slice metrics: src/main.ts = 3042 LOC; check:main-fanin --strict = 103 import lines / 11 unique runtime paths.
  • Remaining gap: startup/overlay/ipc/shortcuts composer extraction still required to fully meet thin composition-root target.

Acceptance Criteria

  • #1 src/main.ts is composition-focused (boot/runtime wiring only; no broad deps-builder clusters).
  • #2 Runtime import paths in src/main.ts stay domain-registry oriented (no relapse to per-leaf runtime imports).
  • #3 check:main-fanin passes under updated threshold.
  • #4 bun run test:core:dist passes with no CLI/IPC behavior regressions.

Definition of Done

  • #1 src/main.ts LOC and fan-in metrics improve from pre-task baseline and are recorded in task notes.
  • #2 New composer modules are covered by focused tests.
  • #3 TASK-71 and TASK-85 progress notes reflect completed slice and remaining gap.