refactor(daemon): add the single package entry and resolve its metadata consumers

Merged
TH
9h ago
+177-156

Summary

Layer 2 of the daemon single-entrypoint stack (after #3616 and #3625): @agent-device/daemon gets its public API in one file, and the seven production subpaths collapse into it.

  • packages/daemon/src/index.ts is the package boundary: explicit named re-exports, no export *. The one value is startDaemonRuntime. The rest are types the composition and platform-runtime modules name (ComposeDaemonRuntimeDeps, DaemonRuntimeController, DaemonRuntimeDeps, DaemonRuntimeDepsInput, DaemonPlatformServices, PlatformOwnerLifecycle, PlatformResourceCleanup, DaemonRequest, DaemonInvokeFn).
  • exports drops ./server/daemon-runtime, ./platform-owner-lifecycle, ./platform-resource-cleanup, ./platform-services, ./daemon-request, ./daemon-command-registry and ./route-owner-files, and gains .. src/daemon.ts, src/daemon-composition.ts and src/platform-runtime-* import @agent-device/daemon.
  • Metadata consumers resolved at their owner:
    • route-owner-files was tooling metadata keyed by command-registry's own DaemonCommandRoute. It now sits beside the per-command claims in @agent-device/command-registry/owner-files (existing subpath). The scripts, the CLI command-explain test, command-surface-metadata, and owner-files-no-leak read it there, so none of them depend on the daemon.
    • daemon-command-registry stays daemon-owned: its queries take DaemonRequest, and ~50 daemon modules use them. Its outside consumers no longer need it. scripts/depgraph/affected-run.ts and command-descriptor-parity.test.ts read deriveDaemonCommandDescriptors(commandDescriptors). command-descriptor-ref-frame-effect.test.ts tests the daemon query, so it moved to packages/daemon/src/core/__tests__/ unchanged apart from its import.
    • The three daemon-client-abort*.test.ts files declare a local (req: DaemonWireRequest) => Promise<DaemonResponse> instead of importing DaemonInvokeFn.
  • R81 allows packages/daemon/src/index.ts as the one production file at the daemon root, with a test.
  • Eager closure: packages/daemon/src/index.ts is a new entry evaluating 372 modules, which is startDaemonRuntime's server graph. It carries an APPROVED_OVER_CEILING row (#3352). src/daemon.ts and every existing entry stay under the no-growth rule. The stale maestro row is removed, because #3623 is now in the merge-base and the gate requires it.
  • Docs: ADR 0033's export-surface section describes the single entry. ADR 0019 notes that DaemonPlatformServices is exported from it. ADR 0032 and AGENTS.md state no changed path.

Transitional testing subpaths

Two ./testing/* entries are added, each deleted with its consumers in the relocation layers:

  • ./testing/server/daemon-runtime: the four teardownDaemonSessionForShutdown tests under src/__tests__/daemon-composition/server.
  • ./testing/daemon-command-registry: test/integration/nightly/concurrency-torture/bindings.ts, which deliberately consumes the production lock decision.

Subpath exports

PackageBeforeAfter
daemon107 (7 production + 100 testing)103 (. + 100 testing + 2 transitional)
command-registry2121 (owner-files already existed)
daemon-contracts, host-kit, test-kit, kernelunchangedunchanged

Validation

On the pushed head: pnpm check:quick, pnpm check:layering, pnpm check:fallow, pnpm check:gate-manifest, pnpm check:production-exports, pnpm check:affected --run, pnpm format:check, and after pnpm build: check:bundle-owner-files, check:package, check:doc-prose. The wire-compat ledger is untouched.

Not in this PR: moving the ./testing/* consumers into the package (next layers). The handoff notes name two candidates that may need a decision there: the client abort tests, which run the real client against the real daemon transport, and the nightly concurrency-torture bindings.

šŸ¤– Generated with Claude Code