refactor(daemon): relocate the server runtime tests by what they assert

Merged
TH
14h ago
+1335-981

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

TestKindWhere
daemon-runtime-idle-reap (3)apackages/daemon/src/server/http/ (beside daemon-runtime.ts), deps fixture, relative lease-registry mock
daemon-runtime-lease-expiry (2)asame; relative lease-registry and request-execution-scope mocks
daemon-runtime-rpc-flow-failure (2)asame; relative request-router mock
daemon-runtime-recording-reaper (1)asame; host-kit/process mock kept
daemon-runtime-metadata-ownership (8)asame; owner lifecycle and gateway come from fixture overrides
daemon-runtime-recording-teardown (2)asame; platformResourceCleanupFixture instead of the root cleanup
daemon-runtime-snapshot-shutdown (2)asame; forwarding command-surface fake, the device-ready and cleanup root mocks are gone
daemon-runtime-lifecycle-shutdown (8)asame; root sendRequest replaced by an /rpc fetch
daemon-runtime-interactor-compositionsplita: 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-setsplita: 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)splita: 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-assemblyapolicy 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-cleanupcmoves beside src/daemon-composition.ts; it never needed a daemon SessionStore, so the literal session names replace it
daemon-entrypointbmoves 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

PackageBeforeAfter
daemon10397

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_CEILING row for packages/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-capture is the installed InteractorResolution, and device-ready is DaemonPlatformServices.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