Skip to content

Refactor daemon entrypoint back to thin-router responsibilities #160

@thymikee

Description

@thymikee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions