refactor(11a-2): package-local fakes at the daemon ports; root-own command-surface composition tests

Merged
TH
2mo ago
+1426-1159

Summary

Second half of the daemon test-boundary prep (after #3498). This PR cuts its own clusters — command surface, platform-resource-cleanup, provider admission/credentials — from src/daemon/ test imports. It does not empty the daemon tree: the createRequestHandler test defaults (real root cleanup and claim recovery behind ~33 router suites) and the runtime-gateway/lifecycle, runtime-hints, host-diagnostics, claim-recovery, and perf-capture clusters are deferred to #3544 (stacked on #3517). The zero-edge target for src/daemon/ holds only at the top of the 11a stack (#3517 → #3544), not at this PR alone; the remaining residue below #3544 is the 11a-3 data-fixture cluster.

  • Command-surface split (evidence-driven): a canned CreateDaemonCommandSurface fake was installed and all 124 fixture users run against it. 42 files failed (266 tests): their assertions traverse real root command code, so they relocate to src/__tests__/daemon-composition/ (subtrees preserved) with the real factory, which itself moved there (command-surface-fixture.ts wraps root createCommandSurfaceAgentDevice). The 82 survivors get support/command-surface-fake.ts. Real-surface runners and the invokeFindHandler surface parameter keep the relocated suites meaningful. Owner review applied the same rule to find-read-only / find-ambiguous-match (selector find/wait route → root-owned) and re-swept all 388 src/daemon suites: none reaches selectors.*.
  • Cleanup port: one fixture per port — teardown/close suites inject platformResourceCleanupFixture() and assert the stopSnapshotHelper / closeManagedBrowser port members (rejecting override for the cleanup-failure channel). The composed adapter's platform filtering (Android stop, web-device close, non-web no-dispatch) is pinned root-owned under daemon-composition/, with the non-web case armed via the fake agent-browser and stderr.
  • Provider ports: daemon suites inject support/provider-credentials-fixture.ts (opaque deterministic fingerprint key, no copied digest format) and support/provider-device-admission-fixture.ts; the credential-digest family of lease.test.ts (real fingerprint + manifest behavior) split to daemon-composition/handlers/lease-provider-credentials.test.ts.

Validation

Head 8e599d3: check:affected --run, check:quick, check:layering, check:di-seams, check:gate-manifest, check:fallow, plus the eager-closure-budgets and test-file-size-ratchet pins, all pass. Full unit-core lane through the host lock: 13,469 tests / 0 failures. Name-parity vs the main baseline (5680da519, 13,422 names): every baseline assertion survives exactly once; the diffs are parameterized names carrying run-dependent ports/timestamps (matched 1:1) and names added/renamed by main's own rebased commits (#3500/#3504/#3505/#3493/#3473). Fresh-context self-review ran on the rebased diff: two dead-code findings fixed (the close fixture's snapshot-helper mock seam the port assertions superseded; the admission fixture's unused reset()); the enforcement-table commit-hygiene finding was rejected — folding it would rewrite commits the reviewer verified unchanged under a three-PR stack.