feat(interaction): add the moving-target gate the tap path consults (#3471)
Summary
Part of #3471 (layer 1 of 3) — the judgement half of the moving-target gate; #3471 closes at the top layer.
A press resolves a point from one capture, and nothing between that capture and the dispatch ever looked at the surface twice — so a press issued right after an action that animated the UI can resolve a point the control has already vacated and report success: true on the vacancy. #3539 carries the base/head device numbers.
This layer is the decision and the seam, not the history it reads:
@agent-device/contracts/moving-target-gate—movingTargetGateDecision(is this position owed a second observation, from the session's mutation clock) and the rest question (movingTargetRectsStable), pure over values the caller already holds. Window 500 ms anchored on the mutation's end, sample spacing 50 ms. The rect band is not this module's fact to hold: #3548 hoists it toareCapturedRectsAtSamePositionin@agent-device/kernel/rect-center, which is the one place that decides whether two capture rects count as one position (the post-gesture no-effect comparison already ran that comparison against its own copy of the band). Landing here first and hoisting in the next layer is what #3538's review asked for; the stack merges together.@agent-device/ad-scriptnodeRectByIdentity— the same-node lookup the screening needs, placed with the owner of local-identity matching rather than beside its only caller; fails closed when an identity is absent, shared, or unmeasurable.src/commands/interaction/runtime/moving-target-gate.ts— the seam intapCommandbetween resolution andruntime.backend.tap: waits out the window, re-observes twice, taps where the target came to rest, refuses withtarget_still_moving/dispatched: 'no'.
12 files, 958 gross. No behavior change here: nothing writes movingTargetBaseline yet, so every press answers idle and pays one session-record read — grep -rn --include='*.ts' movingTargetBaseline src packages/*/src scripts (excluding tests) returns only the type's declaration and this gate's own read. Each layer consumes what it adds. MovingTargetBaseline.tree is documented as the pre-action tree only; #3539 widens that doc when the writer proves the converged-settle case, because the doc cannot be written truthfully from this layer.
Validation
Tested at 3e6c29f44.
pnpm check:affected --run --base origin/main— result recorded in a comment on this PR. Selection is fail-open (the layer adds apackages/contracts/package.jsonexport, which rewires package resolution and can alter any gate), so this is the full check set, taken under the machine-wide gate lock.typecheck,lint,format:check,check:layering,check:production-exports,eager-closure-budgets— clean. The reason literal stays in@agent-device/selectors, the leaf every interaction adapter already reads, so the gate module keeps importing nothing new at module scope.vitest run packages/ad-script packages/contracts src/commands/interaction— pass; each new gate test fails when its guard is reverted.- Device evidence is on #3539, where the refusal becomes reachable. Residual risk: this seam is unreachable in production until the top layer lands, so #3539 must land with this PR or immediately after it.
Guarantees
The ADR 0011 targetStability cells — the runtime enforcement on runtime-selector and runtime-ref, and the intentional waivers on the paths that hand off before the seam (direct-ios, native-ref, coordinate, the two Maestro routes, target-drag) — are declared in #3539, the layer that makes the guard reachable. A cell has to name a guarantee the shipped paths actually provide, and until the top layer writes movingTargetBaseline no press is screened.