Skip to content

refactor(daemon): move interaction and find routes behind the interaction facade #2178

Description

@thymikee

Parent: #2132

Blocked by: #2177.

Outcome

Move interaction, touch, gesture, and find route implementations behind the accepted interaction facade so the remaining handler files perform routing only.

Exact production scope

Move these remaining files into src/daemon/interaction/internal/ (the prerequisite owns the other eight shared files):

  • src/daemon/handlers/find.ts

  • src/daemon/handlers/find-match-ranking.ts

  • src/daemon/handlers/find-match-resolution.ts

  • src/daemon/handlers/find-target-capture.ts

  • src/daemon/handlers/interaction.ts

  • src/daemon/handlers/interaction-android-escape.ts

  • src/daemon/handlers/interaction-gesture.ts

  • src/daemon/handlers/interaction-gesture-response.ts

  • src/daemon/handlers/interaction-ios-tap-outcome.ts

  • src/daemon/handlers/interaction-targeting.ts

  • src/daemon/handlers/interaction-touch.ts

  • src/daemon/handlers/interaction-touch-android-freshness.ts

  • src/daemon/handlers/interaction-touch-android-readiness.ts

  • src/daemon/handlers/interaction-touch-direct-ios-eligibility.ts

  • src/daemon/handlers/interaction-touch-direct-ios.ts

  • src/daemon/handlers/interaction-touch-fill.ts

  • src/daemon/handlers/interaction-touch-payload.ts

  • src/daemon/handlers/interaction-touch-policy.ts

  • src/daemon/handlers/interaction-touch-prepare.ts

  • src/daemon/handlers/interaction-touch-press-admission.ts

  • src/daemon/handlers/interaction-touch-press.ts

  • src/daemon/handlers/interaction-touch-reference-frame.ts

  • src/daemon/handlers/interaction-touch-response.ts

  • src/daemon/handlers/interaction-touch-runtime.ts

  • src/daemon/handlers/interaction-touch-targets.ts

  • Extend src/daemon/interaction/index.ts with only handleInteractionCommands, handleFindCommands, and their named narrow inputs.

  • Update src/daemon/request-handler-chain.ts to lazy-load the public interaction facade for both interaction and find routes. Preserve the lazy closure and route-owner metadata.

  • Delete the old production paths, old broad handler parameter types, and superseded fixtures; no compatibility re-exports.

  • Update scripts/layering/architecture-ownership.ts, route-owner declarations, and structural tests so only the facade is externally importable.

Commands covered: tap, longpress, hover, fill, gesture, swipe, type, get, is, and find.

Authority contract

Use the prerequisite's named interaction operations. Current leaf reads include device, surface, appBundleId, trace, snapshot, lease, and screenRecording; do not widen them. Ref-frame expiration, snapshot publication/freshness, deferred outcomes, action recording, script publication, Android readiness, runtime binding, and platform cleanup stay with existing owners/capabilities.

Exact external capabilities remain InspectDeviceRuntimeFacts, BindDeviceRuntime, AndroidObservationAdapter, and optional PlatformResourceCleanup, plus the existing request context function. Do not introduce an interactor-shaped capability bag.

Behavior and structural proof

Move the matching src/daemon/handlers/__tests__/interaction-*.test.ts, find-*.test.ts, find.test.ts, and their named fixture modules one-to-one with source. Move interaction.test.ts only after splitting its remaining aggregation into owner tests. Preserve and run route-level characterization for direct iOS eligibility, Android freshness/readiness, ref authorization, press/touch/fill payloads, gesture/swipe, type, get/is, find ranking/single-bind, settled observations, deferred outcomes, response construction, and target evidence.

Plant both forbidden deep-import directions, old-path regrowth, and an eager-load regression in the request-handler closure. The planted failures must name the invariant.

Shrink and validation

Minimal request handlers should be route selection and argument projection only. Report gross and move-adjusted production LOC; the child must shrink after discounting moves and remove superseded tests/baseline slack. Run focused route suites, ADR 0011 guarantee/coverage tests, R7/session-state tests, pnpm check:layering, fallow audit, and pnpm check:affected --run after staging.

No replay engine move, no silent script rewriting, no behavior/error/wire change, and no generic package extraction.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions