4.2 KiB
id, title, status, assignee, created_date, updated_date, labels, dependencies, references, priority
| id | title | status | assignee | created_date | updated_date | labels | dependencies | references | priority | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TASK-95 | Decompose remaining oversized core hotspots | Done |
|
2026-02-20 12:06 | 2026-02-21 03:29 |
|
|
|
high |
Description
Three core files remain materially oversized and unfinished: src/anki-integration.ts, src/config/service.ts, and src/core/services/immersion-tracker-service.ts. Complete decomposition into focused collaborators/modules with behavior preserved and regression coverage.
Action Steps
- Capture per-file baseline LOC and key responsibilities (constructor orchestration, phase lifecycle, persistence/sync/event flow).
- For
src/anki-integration.ts: extract facade collaborators by domain (config/field resolution/media/card creation/notifications) and reduce class surface to orchestration. - For
src/config/service.ts: split lifecycle phases into explicit modules (load,migrate,validate,warnings) and keep API stable. - For
src/core/services/immersion-tracker-service.ts: separate state/reducer, persistence adapter, and sync/reporting orchestration. - Add focused tests for extracted modules and preserve existing integration-level assertions.
- Run full build + config/core tests + file-budget checks; record before/after LOC metrics.
- Update
TASK-85AC/DoD linkage to mark completed sub-scope with evidence.
Acceptance Criteria
- #1
src/anki-integration.ts,src/config/service.ts, andsrc/core/services/immersion-tracker-service.tsare each reduced with clear collaborator boundaries. - #2 Public behavior remains unchanged (existing config/core tests pass).
- #3 New seam tests cover extracted collaborators/modules.
- #4 File-budget report reflects measurable LOC reduction on all three hotspots.
Implementation Plan
Execution plan of record: docs/plans/2026-02-21-task-95-hotspot-decomposition-plan.md
- Capture baseline LOC and file-budget status for the 3 hotspot files.
- Add characterization seam tests before extraction in each domain (Anki, Config, Immersion).
- Decompose each hotspot behind stable facades by extracting focused collaborators/modules.
- Use parallel subagents for independent hotspot workstreams; integrate safely on shared boundaries.
- Run required gates (
bun run build,bun run test:config:dist,bun run test:core:dist,bun run check:file-budgets). - Record before/after LOC plus ownership map; update TASK-95 AC/DoD and TASK-85 progress evidence.
Implementation Notes
Baseline LOC (before): src/anki-integration.ts 1722, src/config/service.ts 1591, src/core/services/immersion-tracker-service.ts 1470.
After LOC: src/anki-integration.ts 1315 (-407), src/config/service.ts 99 (-1492), src/core/services/immersion-tracker-service.ts 1109 (-361).
Module ownership map: Anki -> src/anki-integration/field-grouping-merge.ts; Config -> src/config/{load.ts,parse.ts,warnings.ts,resolve.ts}; Immersion -> src/core/services/immersion-tracker/{types.ts,reducer.ts,queue.ts,maintenance.ts,query.ts}.
Seam tests added: src/anki-integration.test.ts (field-grouping merge seams), src/config/config.test.ts (loader/strict reload/warning determinism seams), src/core/services/immersion-tracker-service.test.ts (queue/reducer/month-key seams).
Verification gates passed: bun run build, bun run test:config:dist (43 pass), bun run test:core:dist (204 pass, 10 skipped, 0 fail), bun run check:file-budgets (warning-mode report with all three hotspot LOC reduced).
Definition of Done
- #1 Refactor notes include before/after LOC and module ownership map for all three files.
- #2
bun run build,bun run test:config:dist,bun run test:core:distpass. - #3
TASK-85progress/AC reflects this completion slice with evidence links.