refactor(move): move remaining daemon-only and shared core modules to their owners

Merged
TH
2mo ago
+34-14

Summary

PR 9 of the daemon-extraction plan. The daemon no longer imports src/core/ except through the composition root. Pure moves plus direct consumer rewires; no re-export shims, no behavior change. 26 files, ~55 changed lines.

  • core/dispatch-context.ts → src/daemon/dispatch-context.ts — sole importer is daemon/context.ts.
  • core/interaction-response-data-transform.ts → src/daemon/interaction/internal/ — sole importer is the daemon touch-response route.
  • core/doctor-output.ts → @agent-device/host-kit/doctor-lines — presentation shared by the CLI (dynamic) and the daemon doctor handlers (static); the lowest common owner is host-kit, beside the status-markers it formats. Keeps commands out of daemon/handlers (prevents a rank-3 → rank-4 inversion).
  • core/deploy-result-target.ts → @agent-device/contracts/deploy-result-target — pure precedence vocabulary shared by daemon deployment handlers and CLI/MCP serializers.
  • core/interaction-outcome.ts → @agent-device/host-kit/interaction-outcome — commands attach, daemon reads. The plan suggested contracts; R18's planted ban refuses mutable WeakMap lifecycle there, so it lands in host-kit, the shared mechanics seam below both. R18's message names the new owner.
  • core/status-markers.ts → @agent-device/host-kit/status-markers — host-kit is the lowest package both CLI and daemon import.

Remaining daemon → core edges: daemon/server/daemon-runtime.ts → core/interactors.ts (composition root, leaves in PR 6) plus test-tree reads of core/interactors*/core/platform-plugin-registry. Graph scan confirms zero static/type/dynamic edges from commands/** or cli/** into daemon/handlers/**.

Validation

Commit 586a714. pnpm install --frozen-lockfile && pnpm build, pnpm format, pnpm check:quick, pnpm check:layering (312 pass), pnpm check:fallow --base origin/main (clean), pnpm check:affected --run (all runnable checks passed), pnpm vitest run scripts/__tests__/test-file-size-ratchet.test.ts (pass), moved tests discovered and green at new paths.

Depgraph summary unchanged vs origin/main: 1,817 files / 9,721 edges / 44 zones; R4 0, R5 0, R6 11; daemon.ts eager closure 650, daemon-runtime.ts branch 647.

Touches packages/contracts/package.json as one self-contained ./deploy-result-target entry for a trivial rebase against #3394/#3395.