Skip to content

refactor(daemon): relocate the daemon client out of src/daemon #2342

Description

@thymikee

Part of #2335.

Purpose

src/daemon/client/ (9 files, 2,416 lines; zone daemon-client, rank 5) is the daemon's client, not the daemon. No daemon file imports it; its consumers are src/cli.ts, src/agent-device-client.ts, src/cli/commands/proxy.ts, src/commands/management/output.ts (via B) and src/cli/injected-daemon-dispatch.ts (type). Relocating it makes src/daemon server-only. This issue is a relocation; it does not promise a package.

Remaining server and root seams (inventory to carry into the PR)

  • src/daemon/config.ts (113, pure over host-kit/kernel), src/daemon/daemon-process.ts (122, host-kit), src/daemon/request-progress-protocol.ts (48, imports the request types C splits).
  • src/daemon/code-signature*.ts — moved by E.
  • src/daemon/session-store.ts → findUnrecoveredRepairCommitFailure from daemon-client-lifecycle.ts:17: a disk reader of session artifacts, to be extracted below both client and store.
  • src/core/lease-scope.ts (258, kernel-only) from the RPC layer.
  • src/remote/daemon-artifacts.ts (imports daemon types and recording/output-path.ts) and src/remote/remote-request-diagnostics.ts (imports session-store.ts).
  • src/command-catalog.ts, core/command-descriptor/registry.ts, timeout-policy.ts — A's package.
  • src/daemon/types.ts wire types — C's request module.
  • src/daemon/client/doctor-progress.ts — deleted by B.

Required behavior

  • Move the directory to src/daemon-client/ (zone name unchanged; targetDagZone in scripts/layering/model.ts updated from the src/daemon/client/ prefix). Rank stays 5.
  • The client's imports of src/daemon/* are reduced to the named shared kernel: config.ts, daemon-process.ts, request-progress-protocol.ts, the extracted session-artifact reader, and C's request module.
  • No behavior change in daemon launch, takeover, progress streaming or code-signature checks; test/integration/smoke-cli and the daemon lifecycle tests pass unchanged.

Completion conditions

  • src/daemon/client/ no longer exists; src/daemon contains only server code plus the shared kernel modules listed above.
  • The PR lists every remaining src/daemon and src/remote import from the relocated client, each with its seam named; the list is the input to any later packaging decision.
  • check:layering green (R5, R6 type-inversion ratchet, DAEMON_MODULARITY_BASELINE), eager-closure budgets green for src/cli.ts.

Dependencies

Blocked by A, B, C, E.

Activity

  1. thymikee commented on Sep 6, 2026

    @thymikee
    MemberAuthor

    Seam inventory re-derived from the tree — six corrections

    This issue was written against main at 27a97ee; five merges later its "Remaining server and root seams" section no longer matches the tree. Following the precedent set in #2335's second comment, every entry below was re-derived on main at bd08e6e, file by file, rather than carried over. Implemented in #2360.

    1. core/replay-divergence.ts is missing from the list

    daemon-client-lifecycle.ts:6 imports readReplayDivergenceResume from src/core/replay-divergence.ts (513 lines). The issue names core/lease-scope.ts from the RPC layer but not this one, so a reader working the list would conclude the client has a single src/core seam. It has two.

    2. src/commands/management/output.ts is not a consumer

    The Purpose section lists it "(via B)". B (#2349) deleted doctor-progress.ts outright, and nothing under src/commands/ imports the client on main. The four production consumers are src/cli.ts, src/agent-device-client.ts, src/cli/commands/proxy.ts and src/cli/injected-daemon-dispatch.ts (type-only).

    3. The size figure

    9 files / 2,466 lines, not 2,416: 8 production modules totalling 2,386 lines plus the colocated daemon-client-rpc.ts test (80). The __tests__/ directory adds a further 3,862 lines that move with them.

    4. The consumer list omits everything that is not production src/

    A relocation has to carry all of it, and it is the bulk of the diff: 9 files under src/__tests__/ (including test-utils/boundary-fault-matrix.ts, which stores client test paths as evidence strings), src/commands/batch/cli.test.ts, two test/integration/*-e2e live harnesses, four test/wire-compat/ gate files (surface.ts, closure-policy.ts, ledger.json, wire-mutations.test.ts), scripts/ios-snapshot-benchmark/cell-admission.ts, oxlint.config.ts, fallow-baselines/health.json, scripts/layering/model.ts, and ADR 0016.

    5. DAEMON_MODULARITY_BASELINE interacts with the move; the issue does not say so

    R10 counts external importers of the daemon request/session-state modules by the src/daemon/ path prefix. The client's five daemon-request.ts edges were invisible to it only because the client sat inside that prefix. Relocating makes them external — so the completion condition "check:layering green (… DAEMON_MODULARITY_BASELINE)" is not free. #2360 records the five files in the list rather than widening the prefix: the set can only shrink, so a new src/daemon-client/ module reaching session-state.ts still fails, which a prefix skip would not catch. Its size assertion now reads the recorded list instead of the literal 2.

    6. The eager-closure condition needs a second extraction

    "eager-closure budgets green for src/cli.ts" is a no-growth rule, and the required tombstone-reader extraction adds one module to that closure. Removing the client's session-store.ts edge does not offset it, because src/cli.ts:10 imports session-store.ts directly for one pure path helper, resolveRemoteRequestDiagnosticsPath — as does src/remote/remote-request-diagnostics.ts:29. #2360 therefore also moves the four session-artifact path helpers to src/daemon/session-artifact-paths.ts. src/cli.ts drops from 379 to 365 eagerly evaluated modules and no longer loads the daemon's session store at all.

    Confirmed as written

    config.ts 113, daemon-process.ts 122, request-progress-protocol.ts 48, core/lease-scope.ts 258 (kernel-only) — all four line counts and the lease-scope characterisation hold. src/daemon/types.ts, src/daemon/code-signature*.ts, src/command-catalog.ts, src/core/command-descriptor/ and client/doctor-progress.ts are all gone from src/daemon as the blockers promised. src/remote/daemon-artifacts.ts does import the daemon request types and recording/output-path.ts; src/remote/remote-request-diagnostics.ts does import session-store.ts. And the load-bearing premise holds: no file under src/daemon/ imports the client — the only two mentions are comments in replay tests.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions