refactor(main): add runtime domain registry and fan-in guardrails

Introduce runtime domain barrel exports and registry composition support, and document/check main runtime fan-in workflow with related backlog planning artifacts.
This commit is contained in:
2026-02-20 20:15:14 -08:00
parent 23b88bf20e
commit 4fc34ec787
19 changed files with 395 additions and 1 deletions

View File

@@ -116,6 +116,7 @@ Run `make help` for a full list of targets. Key ones:
- To add or change a config option, update `src/config/definitions.ts` first. Defaults, runtime-option metadata, and generated `config.example.jsonc` are derived from this centralized source.
- Overlay window/visibility state is owned by `src/core/services/overlay-manager.ts`.
- Main process composition is now split across `src/main/` modules (`startup.ts`, `app-lifecycle.ts`, `startup-lifecycle.ts`, `state.ts`, `ipc-runtime.ts`, `cli-runtime.ts`, `overlay-runtime.ts`, `subsync-runtime.ts`).
- Runtime domain imports for `src/main.ts` should route through `src/main/runtime/domains/*`; shared domain access point is `src/main/runtime/registry.ts`.
- Linux packaged desktop launches pass `--background` using electron-builder `build.linux.executableArgs` in `package.json`.
- MPV service has been split into transport, protocol, state, and properties layers in `src/core/services/`.
- Prefer direct inline deps objects in `src/main/` modules for simple pass-through wiring.

View File

@@ -8,6 +8,11 @@
- heartbeat_minutes: 5
## Current Work (newest first)
- [2026-02-21T02:04:12Z] handoff: completed writing-plans request; created 3 backlog tickets (`TASK-93`, `TASK-94`, `TASK-95`) and saved end-to-end execution plan at `docs/plans/2026-02-20-task85-remaining-workstreams-plan.md`.
- [2026-02-20T12:06:40Z] intent: user requested writing-plans output only: create end-to-end plans + one ticket per remaining workstream (TASK-85 tracking sync, main.ts composition-root completion, oversized hotspot decomposition).
- [2026-02-20T12:05:35Z] handoff: completed plan + execution for main.ts fan-in reduction slice. Added runtime domain barrels (`src/main/runtime/domains/*`), composed registry (`src/main/runtime/registry.ts`), migrated `src/main.ts` runtime imports to domain paths, and added fan-in guard (`scripts/check-main-runtime-fanin.ts` + package scripts).
- [2026-02-20T12:05:35Z] test: `bun run build`, `bun run test:config:dist`, `bun run test:core:dist`, `bun run check:main-fanin`, `bun run check:file-budgets` pass; registry unit test now skips in environments lacking `node:sqlite`.
- [2026-02-20T11:57:58Z] intent: user requested end-to-end execution for main.ts fan-in reduction; using writing-plans then executing-plans flow to add domain barrels + registry composition and migrate `src/main.ts` runtime imports/wiring.
- [2026-02-20T11:48:28Z] progress: executed cleanup item #4 first: reconciled launcher generated-artifact policy by moving `build-launcher` output to `dist/launcher/subminer` and making install targets consume that path.
- [2026-02-20T11:48:28Z] progress: added `scripts/verify-generated-launcher.sh` and documented canonical workflow in `docs/development.md` + `docs/installation.md`.
- [2026-02-20T11:48:28Z] test: `make build-launcher && ls -la dist/launcher/subminer && bash scripts/verify-generated-launcher.sh` passes (warns if stale `./subminer` exists locally).
@@ -25,6 +30,24 @@
- `scripts/verify-generated-launcher.sh`
- `docs/development.md`
- `docs/installation.md`
- `docs/plans/2026-02-20-main-runtime-fanin-registry-plan.md`
- `src/main/runtime/domains/anilist.ts`
- `src/main/runtime/domains/jellyfin.ts`
- `src/main/runtime/domains/overlay.ts`
- `src/main/runtime/domains/startup.ts`
- `src/main/runtime/domains/mpv.ts`
- `src/main/runtime/domains/shortcuts.ts`
- `src/main/runtime/domains/ipc.ts`
- `src/main/runtime/domains/mining.ts`
- `src/main/runtime/domains/index.ts`
- `src/main/runtime/registry.ts`
- `src/main/runtime/registry.test.ts`
- `scripts/check-main-runtime-fanin.ts`
- `src/main.ts`
- `package.json`
- `docs/file-size-budgets.md`
- `backlog/tasks/task-71 - Split-main.ts-into-domain-runtime-modules-round-2.md`
- `backlog/tasks/task-85 - Refactor-large-files-for-maintainability-and-readability.md`
## Assumptions
- Review scope = recent TASK-85 refactor commits on `main` (mostly 2026-02-20 series touching `src/main.ts` and `src/main/runtime/*`).
@@ -33,4 +56,4 @@
- none
## Next Step
- Convert review findings into concrete child backlog tasks under TASK-85 (domain-by-domain extraction + import-fan-in reduction + AC/DoD closeout pass).
- Continue reducing `src/main.ts` runtime import line count (currently 105) by collapsing repeated domain import blocks into central registry destructuring and/or domain-specific runtime composer modules.

View File

@@ -0,0 +1,35 @@
# Agent: `codex-task95-anki-20260221T031836Z-6f3e`
- alias: `codex-task95-anki`
- mission: `Implement TASK-95 anki-integration extraction for field-grouping merge collaborator`
- status: `done`
- branch: `main`
- started_at: `2026-02-21T03:18:36Z`
- heartbeat_minutes: `5`
## Current Work (newest first)
- [2026-02-21T03:18:36Z] intent: extract field-grouping/merge collaborator from `src/anki-integration.ts`; add seam tests; run build + node tests; no commit.
- [2026-02-21T03:26:55Z] completed: extracted collaborator to `src/anki-integration/field-grouping-merge.ts`; rewired `AnkiIntegration`; added seam tests; verified `bun run build && node --test dist/anki-integration.test.js`.
## Files Touched
- `docs/subagents/agents/codex-task95-anki-20260221T031836Z-6f3e.md`
- `docs/subagents/INDEX.md`
- `docs/subagents/collaboration.md`
- `src/anki-integration.ts`
- `src/anki-integration/field-grouping-merge.ts`
- `src/anki-integration.test.ts`
## Assumptions
- TASK-95 scope in this session limited to Anki portion requested by user.
- Keep `AnkiIntegration` external behavior unchanged; internal extraction only.
## Open Questions / Blockers
- None.
## Next Step
- Handoff ready: no blockers; no commit performed.

View File

@@ -0,0 +1,44 @@
# Agent: `codex-task95-hotspots-20260221T031420Z-x7k2`
- alias: `codex-task95-hotspots`
- mission: `Execute TASK-95 decompose oversized core hotspots end-to-end`
- status: `done`
- branch: `main`
- started_at: `2026-02-21T03:14:29Z`
- heartbeat_minutes: `5`
## Current Work (newest first)
- [2026-02-21T03:29:23Z] handoff: TASK-95 executed end-to-end; plan saved, parallel subagents completed hotspot refactors, full gates passed, backlog TASK-95 marked Done with evidence and TASK-85 updated.
- [2026-02-21T03:24:00Z] test: ran `bun run build && bun run test:config:dist && bun run test:core:dist && bun run check:file-budgets`; all tests passed, budgets warning-mode with measurable hotspot LOC reduction.
- [2026-02-21T03:18:00Z] progress: dispatched parallel subagents for Anki/Config/Immersion decomposition and integrated outputs.
- [2026-02-21T03:14:29Z] intent: load backlog task context, write execution plan via writing-plans skill, execute via executing-plans skill (no commit).
## Files Touched
- `docs/subagents/agents/codex-task95-hotspots-20260221T031420Z-x7k2.md`
- `docs/subagents/INDEX.md`
- `docs/subagents/collaboration.md`
- `docs/plans/2026-02-21-task-95-hotspot-decomposition-plan.md`
- `src/anki-integration.ts`
- `src/anki-integration/field-grouping-merge.ts`
- `src/config/service.ts`
- `src/config/load.ts`
- `src/config/parse.ts`
- `src/config/warnings.ts`
- `src/config/resolve.ts`
- `src/core/services/immersion-tracker-service.ts`
- `src/core/services/immersion-tracker/*`
## Assumptions
- TASK-95 exists in Backlog.md MCP and is the active scope for this request.
- No commit/push requested; changes remain local unless user asks.
## Open Questions / Blockers
- None yet.
## Next Step
- Await user review or follow-up changes.

View File

@@ -0,0 +1,43 @@
# Agent Log: opencode-task95-config-20260221T031843Z-m4k9
- alias: `opencode-task95-config`
- mission: `Implement TASK-95 config extraction for src/config/service.ts with unchanged public API/behavior`
- status: `done`
- last_update_utc: `2026-02-21T03:26:57Z`
## Intent
- Extract collaborators from `src/config/service.ts` under `src/config/` (load/parse/warnings/resolve as fits).
- Keep `ConfigService` API and behavior unchanged.
- Add/update seam tests in `src/config/config.test.ts` for loader precedence, strict parse non-mutation, warning determinism.
- Run `bun run build && bun run test:config:dist`.
## Planned Files
- `src/config/service.ts`
- `src/config/config.test.ts`
- `src/config/*` (new collaborator modules)
## Assumptions
- TASK-95 exists and this is the config-only slice.
- No backlog markdown edits allowed in this run.
## Activity
- 2026-02-21T03:18:43Z: started; loaded backlog workflow overview + TASK-95 context; initialized subagent coordination files.
- 2026-02-21T03:26:57Z: extracted collaborators `src/config/load.ts`, `src/config/parse.ts`, `src/config/warnings.ts`, `src/config/resolve.ts`; rewired `src/config/service.ts` as facade; added seam tests for loader precedence, strict parse non-mutation, warning determinism; ran `bun run build && bun run test:config:dist` (pass).
## Touched Files
- `src/config/service.ts`
- `src/config/load.ts`
- `src/config/parse.ts`
- `src/config/warnings.ts`
- `src/config/resolve.ts`
- `src/config/config.test.ts`
## Handoff
- ConfigService API unchanged (`constructor`, `get*`, `reload*`, `saveRawConfig`, `patchRawConfig`).
- Behavior preserved by moving logic (no semantic changes intended) and passing full config dist suite.

View File

@@ -0,0 +1,35 @@
# Agent Session: opencode-task95-immersion-tracker-20260221T031846Z-p4k9
- alias: `opencode-task95-immersion-tracker`
- mission: `Implement TASK-95 immersion-tracker extraction into focused collaborators and seam tests`
- status: `handoff`
- started_utc: `2026-02-21T03:18:46Z`
- backlog_ticket: `TASK-95`
## Intent
- reduce `src/core/services/immersion-tracker-service.ts` LOC; preserve public behavior.
- extract focused modules under `src/core/services/immersion-tracker/` (types/reducer/query/maintenance/queue helpers).
- add/update seam tests in `src/core/services/immersion-tracker-service.test.ts`.
## Planned Files
- `src/core/services/immersion-tracker-service.ts`
- `src/core/services/immersion-tracker/*`
- `src/core/services/immersion-tracker-service.test.ts`
## Assumptions
- existing TASK-95 plan allows independent immersion-tracker slice.
- no backlog file edits requested.
## Phase Log
- `2026-02-21T03:18:46Z` start; context loaded; beginning code/test extraction.
- `2026-02-21T03:26:51Z` refactor complete; extracted `types/reducer/query/maintenance/queue` modules; added seam tests; ran `bun run build && node --test dist/core/services/immersion-tracker-service.test.js`.
## Handoff
- touched: `src/core/services/immersion-tracker-service.ts`, `src/core/services/immersion-tracker-service.test.ts`, `src/core/services/immersion-tracker/*`.
- behavior guardrails: kept `ImmersionTrackerService` public API and DB schema/event constants stable.
- note: sqlite-backed tests skip in this environment; seam unit tests run and pass.