refactor(daemon): relocate the settle, disclosure and capture tests by what they assert

Merged
TH
4h ago
+809-233

Summary

Part 2 of 3 of the find/settle batch of the daemon test redesign (no test exports of any kind). Stacked on #3693 (green and mergeable; this PR retargets to main when it merges). The five root tests under src/__tests__/daemon-composition/interaction/ for capture disclosure, the fill-scrubbing common cases, dispatch disclosure and settle wiring are placed by what they assert. Daemon halves (a) run against the package fakes; assertions about what the real src/commands/interaction/** code does (c) moved beside that code. Part 3 (target evidence) follows.

New package fixture, a new unexported file: support/touch-forwarding-surface-fake.ts (a touch surface that also observes a settle and carries the capture preference). Edits to existing fixtures: command-surface-override-fake.ts (additive: settle observation and capture preference pass-through, from #3693).

a / c split and test-count parity

Before = exact count at the old path (vitest JSON reporter, origin/main); after = run count per destination on this head. Package paths are under packages/daemon/src/execution/interaction/internal/; command paths under src/commands/interaction/runtime/.

Source (before)Daemon half (a)Command half (c)
interaction-capture-disclosure (4)interaction-capture-disclosure.test.ts (4)selector-target-resolution-post-gesture.test.ts (1: the full-tree retry inherits the unsettled post-gesture outcome)
interaction-common (5)interaction-common.test.ts (5; parameterized fill scrubbing runs on the touch finalizer)none
interaction-dispatch-disclosure (16)interaction-dispatch-disclosure.test.ts (15: driver check, 10 daemon rows, 4 verdict cases), interaction-android-escape-dispatch-disclosure.test.ts (2: driver check, post-action-guard row)none (17 in total: the second driver file needs its own driver check)
interaction-settle (10)interaction-settle.test.ts (10)settle-capture-deadline.test.ts (2: stalled capture gets its deadline signal and a "stalled" hint; fill on a @ref with --settle); settle diff, removals-only tail and broken-capture hint were already pinned in settle.test.ts
interaction-settle-private-ax-route (1)interaction-settle-private-ax-route.test.ts (1; installs the fake InteractorResolution)the pinning rule and runner request construction are pinned by settle.test.ts and packages/platform-apple

36 tests before; 41 after (the +5: one command test, the second driver check, two settle command tests, and the ref-frame authority case in interaction-common.test.ts). No assertion was dropped.

Gap, stated rather than hidden. The private-ax route no longer exercises the composed path from daemon to runner request; its rule is pinned in settle.test.ts and in platform-apple. If that must remain a root (b) test it needs a full startDaemonRuntime session flow, which this PR does not build.

Mutation checks

  • Replacing issueSettleRefs(...) in interaction-touch-response.ts with undefined fails three settle tests: "press --settle responds with the settled diff, refsGeneration, and activates a partial ref frame", "held touch settle publishes refs into the current record of its scoped lifetime" and "press --settle on a removals-only diff attaches the unchanged interactive tail at the diff generation" (expected 'expired' to be 'active'). Reverted.
  • The agent that wrote the batch also broke the isSessionRecording gate and preferredBackend forwarding and saw the suites fail.

vi.mock

No vi.mock in any destination file (rg 'vi\.mock\(' over the destinations returns nothing). The snapshot-interactor-capture mock these tests used is replaced by the installed InteractorResolution.

Selection

All destinations match packages/*/src/**/*.test.ts or src/**/*.test.ts, so unit-core selects them (pnpm test:unit, test:coverage); the sources were already in unit-core. check:affected --run runs the vitest related leg.

Subpath exports

PackageBeforeAfter
daemon8179

Deleted: interaction/internal/interaction-android-escape, interaction/internal/types. No other package changed; no new subpath, barrel or export *.

Notes

  • Registry repoints for moved tests: DISPATCH_DISCLOSURE_DRIVER_OWNERS ('daemon.' and 'post-action-guard.' lines) in packages/contracts/src/dispatch-disclosure.fixtures.ts, and one path in .device-evidence/CHECKLIST.md.
  • The command halves are new files, not appends to another worker's tests, and are named for modules beside them (R84).

Validation

check:quick, check:layering, check:fallow and check:gate-manifest pass on this head. check:affected --run ran 15,437 tests and failed three, all 5-second timeouts under heavy host contention (the run took 649 s): two in scripts/fuzz/harness.test.ts and one in scripts/__tests__/test-file-size-ratchet.test.ts, neither touching this change. Rerun alone, harness.test.ts passes (2/2) and the ratchet passes (3/3).

🤖 Generated with Claude Code