refactor(daemon): relocate the server runtime tests by what they assert
Summary
Batch server of the daemon test redesign (no test exports of any kind). The 11 root tests under src/__tests__/daemon-composition/server/ and three tails (daemon-composition-assembly, daemon-composition-web-cleanup, daemon-entrypoint) are placed by what they assert, not moved wholesale. Their vi.mocks of root platform modules and of daemon internals are gone or become relative in-package mocks.
New package fixture daemon-runtime-deps-fixture.ts: a ComposeDaemonRuntimeDeps factory of inert ports, so a daemon-runtime test starts startDaemonRuntime without the root composition. Also forwardingCreateCommandSurface in the command-surface fake: its snapshot capture reaches the config backend and writes the session back through the config session store, the two seams the daemon's refusals land on.
a / b / c split
| Test | Kind | Where |
|---|---|---|
daemon-runtime-idle-reap (3) | a | packages/daemon/src/server/http/ (beside daemon-runtime.ts), deps fixture, relative lease-registry mock |
daemon-runtime-lease-expiry (2) | a | same; relative lease-registry and request-execution-scope mocks |
daemon-runtime-rpc-flow-failure (2) | a | same; relative request-router mock |
daemon-runtime-recording-reaper (1) | a | same; host-kit/process mock kept |
daemon-runtime-metadata-ownership (8) | a | same; owner lifecycle and gateway come from fixture overrides |
daemon-runtime-recording-teardown (2) | a | same; platformResourceCleanupFixture instead of the root cleanup |
daemon-runtime-snapshot-shutdown (2) | a | same; forwarding command-surface fake, the device-ready and cleanup root mocks are gone |
daemon-runtime-lifecycle-shutdown (8) | a | same; root sendRequest replaced by an /rpc fetch |
daemon-runtime-interactor-composition | split | a: daemon-runtime-composition.test.ts (installs what the composition supplied; provider shutdown on a lost lock). c: src/daemon-composition.test.ts (the composed resolution picks the provider that owns the device). b: src/daemon-composition-credentials.test.ts (real composition through startDaemonRuntime, an /rpc lease allocate) |
daemon-runtime-xctest-device-set | split | a: daemon-runtime-owner-lifecycle.test.ts (configure before readiness publication; owner diagnostics reach daemon.log; startup survives a refused restore). c: src/platform-runtime-daemon-lifecycle.test.ts (the real darwin restore) |
daemon-runtime-web-close-teardown (4) | split | a: extended close budget, close asked of the port, failure on stderr, non-web asked too. c: src/platform-runtime-resource-cleanup.test.ts (agent-browser close argv, refusal rejects, non-web never reaches it) |
daemon-composition-assembly | a | policy gate and session callbacks bound to the server's store move to daemon-runtime-composition.test.ts; the unreadable-policy case moves with them |
daemon-composition-web-cleanup | c | moves beside src/daemon-composition.ts; it never needed a daemon SessionStore, so the literal session names replace it |
daemon-entrypoint | b | moves beside src/daemon.ts, inlines the one-use startDaemonRuntimeFixture (deleted) and uses the public entry only; the trackDownloadableArtifact fetch is dropped, since http-server-artifacts.test.ts serves a tracked artifact over bearer auth |
Every test is named for the module it sits beside (daemon-runtime-<aspect>.test.ts in server/http/; daemon-composition-<aspect>.test.ts, daemon-entrypoint.test.ts, platform-runtime-*.test.ts in src/), so none lands in the colocation baseline.
Mocks
Every surviving mock targets the module the daemon imports relatively from inside the package, so each takes effect. Evidence: the assertions read what the mock recorded (leaseProbe.registries, ended, shutdownSteps, the failing createRequestHandler flow), and they pass.
Subpath exports
| Package | Before | After |
|---|---|---|
daemon | 103 | 97 |
Deleted ./testing/ entries with no consumer left: __tests__/session-teardown.fixtures, __tests__/support/device-claim-store, application-lifecycle-recovery, server/daemon-runtime, server/server-shutdown, session-teardown-budget. (#3638 also deletes server/server-lifecycle; the manifest edits will merge on rebase.) No other package grew a subpath.
Also
- Removes the spent
APPROVED_OVER_CEILINGrow forpackages/daemon/src/index.ts: main carries the entry now, so the gate requires it gone. - Seam design (for the next batches) is in the handoff:
snapshot-interactor-captureis the installedInteractorResolution, anddevice-readyisDaemonPlatformServices.ensureLocalDeviceReady; neither needs a production change.
Validation
check:quick, check:layering, check:fallow, check:gate-manifest, check:affected --run (all green except the stale approval row, fixed in the last commit; the eager-closure suite passes) on the pre-final head.
🤖 Generated with Claude Code