Problem
src/daemon.ts is currently ~593 LOC and exceeds the intended thin-router boundary documented in AGENTS. The file handles broad orchestration concerns beyond minimal routing.
Goal
Restore src/daemon.ts to thin-router responsibilities by extracting orchestration helpers into dedicated modules.
Proposed split
src/daemon/server-lifecycle.ts
- startup/shutdown + state/lock coordination helpers
src/daemon/request-router.ts
- request dispatch orchestration across handlers
src/daemon/transport.ts
- transport-specific helper logic (if not already encapsulated)
- Keep
src/daemon.ts as minimal entrypoint + wiring.
Acceptance criteria
- No behavior change in daemon startup, routing, or shutdown semantics.
- Handler ownership boundaries remain intact (session/interaction/snapshot/find/record-trace).
- New modules target <=300 LOC where practical.
src/daemon.ts is substantially reduced and easier to audit.
Validation
pnpm typecheck
pnpm test:unit
pnpm test:smoke
Problem
src/daemon.tsis currently ~593 LOC and exceeds the intended thin-router boundary documented in AGENTS. The file handles broad orchestration concerns beyond minimal routing.Goal
Restore
src/daemon.tsto thin-router responsibilities by extracting orchestration helpers into dedicated modules.Proposed split
src/daemon/server-lifecycle.tssrc/daemon/request-router.tssrc/daemon/transport.tssrc/daemon.tsas minimal entrypoint + wiring.Acceptance criteria
src/daemon.tsis substantially reduced and easier to audit.Validation
pnpm typecheckpnpm test:unitpnpm test:smoke