From 32c7fd51cd6bb0fabb7f531dc5982f217318127d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 11:54:51 +0100 Subject: [PATCH 1/4] refactor(ios-runner): drop the XCTest coordinate gesture fallback A synthesized tap, long press, drag, sequence step, nav-bar back tap, coordinate fill tap, or one-contact gesture whose private XCTest event record is refused now answers the refusal (SYNTHESIZED_GESTURE_NOT_DISPATCHED when nothing was sent, UNSUPPORTED_OPERATION otherwise) with the synthesis hint, instead of replaying the gesture through XCUICoordinate. Removes the fallback policy, its deferred-window proof and policy log marker, the gestureFallback* response fields and their TS diagnostic, and amends ADR 0011. Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+Alert.swift | 2 +- .../RunnerTests+CommandExecution.swift | 37 +--- .../RunnerTests+GestureExecution.swift | 30 +-- .../RunnerTests+Interaction.swift | 14 +- .../RunnerTests+Lifecycle.swift | 1 - .../RunnerTests+Models.swift | 3 - .../RunnerTests+Navigation.swift | 13 +- .../RunnerTests+ScrollDragExecution.swift | 38 ++-- .../RunnerTests+SequenceExecution.swift | 20 +- ...RunnerTests+SynthesizedGesturePolicy.swift | 143 +++----------- .../RunnerTests+SynthesizedInteraction.swift | 41 +--- .../RunnerTests+TypeExecution.swift | 2 - .../RunnerTests.swift | 8 +- .../RunnerTests+CommandExecutionTests.swift | 1 - .../RunnerTests+GestureExecutionTests.swift | 30 +-- .../RunnerTests+LifecycleTests.swift | 4 +- ...RunnerTests+ScrollDragExecutionTests.swift | 76 ++------ ...ts+SnapshotCapturePlanOccupancyTests.swift | 2 +- ...rTests+SynthesizedGesturePolicyTests.swift | 177 +++--------------- ...nerTests+SynthesizedInteractionTests.swift | 26 +-- ...nnerTests+SynthesizedTapContextTests.swift | 89 --------- apple/runner/RUNNER_PROTOCOL.md | 4 +- .../0011-interaction-guarantee-contract.md | 31 ++- .../__tests__/runner-session-response.test.ts | 27 --- packages/apple-runner/src/runner-exchange.ts | 19 +- 25 files changed, 156 insertions(+), 682 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift index 06c34b984b4..7d0a8393641 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift @@ -232,7 +232,7 @@ extension RunnerTests { context: hostContext, deadline: deadline ) - } catch let refusal as RunnerGestureRefusedWithoutFallback { + } catch let refusal as RunnerGestureNotSent { outcome = .unsupported(message: refusal.message, hint: refusal.hint) return } catch { diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift index 1c7678b5458..5d1d6b188d7 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift @@ -116,8 +116,7 @@ extension RunnerTests { y: touchPoint.y ) func selectorTapResponse( - timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double), - fallback: GestureFallback? = nil + timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double) ) throws -> Response { if isTextEntry { try waitForTextEntryReadinessAfterTap(app: activeApp, element: element) @@ -127,20 +126,16 @@ extension RunnerTests { message: match.usedNonHittableFallback ? "tapped via non-hittable coordinate fallback" : "tapped", timing: timing, frame: .touch(touchFrame), - fallback: fallback, maestroNonHittableCoordinateFallbackUsed: command.allowNonHittableCoordinateFallback == true ? match.usedNonHittableFallback : nil ) } - var fallback: GestureFallback? if command.synthesized == true { switch try performSynthesizedTapGesture(app: activeApp, x: touchPoint.x, y: touchPoint.y) { case .performed(let timing): return try selectorTapResponse(timing: timing) - case .xctestFallback(let message, let hint): - fallback = .coordinateTap(message, hint: hint) case .refused(_, let refusal): return refusedTapResponse(refusal) } @@ -159,7 +154,7 @@ extension RunnerTests { clearRememberedTextEntryTap() return response } - return try selectorTapResponse(timing: timing, fallback: fallback) + return try selectorTapResponse(timing: timing) } clearRememberedTextEntryTap() return Response(ok: false, error: ErrorPayload(code: RunnerWireErrorCode.elementNotFound, message: "element not found")) @@ -187,15 +182,12 @@ extension RunnerTests { xCTestChannelPenalized ? "penalized-xctest-channel" : "evidence" ) } - var fallback: GestureFallback? if command.synthesized == true { let context = deferredWindowTapContext(app: activeApp) switch try performSynthesizedTapGesture(app: activeApp, x: x, y: y, context: context) { case .performed(let timing): rememberTextEntryTap(textInput) return gestureResponse(message: "tapped", timing: timing) - case .xctestFallback(let message, let hint): - fallback = .coordinateTap(message, hint: hint) case .refused(_, let refusal): return refusedTapResponse(refusal) } @@ -207,12 +199,7 @@ extension RunnerTests { return response } rememberTextEntryTap(textInput) - return gestureResponse( - message: "tapped", - timing: timing, - frame: .touch(touchFrame), - fallback: fallback - ) + return gestureResponse(message: "tapped", timing: timing, frame: .touch(touchFrame)) } clearRememberedTextEntryTap() return Response(ok: false, error: ErrorPayload(message: "tap requires a selector or x/y")) @@ -244,24 +231,18 @@ extension RunnerTests { return Response(ok: false, error: ErrorPayload(message: "longPress requires x and y")) } let durationMs = command.durationMs ?? 800 - let fallback: GestureFallback? #if os(iOS) - let policyKind = SynthesizedGesturePolicyKind.coordinateLongPress let context = try synthesizedCoordinateContext(app: activeApp) - switch try performSynthesizedGesture(activeApp, kind: policyKind, context: context, synthesize: { + switch try performSynthesizedGesture({ try synthesizedLongPressAt(app: activeApp, x: x, y: y, durationMs: durationMs, context: context) }) { case .performed(let timing): let touchFrame = context.map { touchVisualizationFrame(point: SurfacePoint(CGPoint(x: x, y: y)), context: $0) } return gestureResponse(message: "long pressed", timing: timing, frame: .touch(touchFrame)) - case .xctestFallback(let message, let hint): - fallback = GestureFallback(strategy: "xctest-coordinate-long-press", message: message, hint: hint) case .refused(_, let refusal): return refusalResponse(refusal) } #else - fallback = nil -#endif let touchFrame = try resolvedTouchVisualizationFrame(app: activeApp, x: x, y: y) let (timing, outcome) = try performGesture(activeApp) { try longPressAt(app: activeApp, x: x, y: y, duration: durationMs / 1000.0) @@ -269,12 +250,8 @@ extension RunnerTests { if let response = unsupportedResponse(for: outcome) { return response } - return gestureResponse( - message: "long pressed", - timing: timing, - frame: .touch(touchFrame), - fallback: fallback - ) + return gestureResponse(message: "long pressed", timing: timing, frame: .touch(touchFrame)) +#endif case .drag: guard let x = command.x, let y = command.y, let x2 = command.x2, let y2 = command.y2 else { return Response(ok: false, error: ErrorPayload(message: "drag requires x, y, x2, and y2")) @@ -684,7 +661,7 @@ extension RunnerTests { y2: last.y, durationMs: plan.durationMs, message: plan.intent, - synthesized: (profile: .fastSwipe, policyKind: .synthesizedDrag) + synthesizedProfile: .fastSwipe ) ) case .sampled: diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift index 226032e1c92..427ddef2c91 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift @@ -56,17 +56,6 @@ extension RunnerTests { case drag(DragVisualizationFrame) } - struct GestureFallback { - let strategy: String - let message: String - let hint: String? - - static func coordinateTap(_ message: String, hint: String?) -> Self { - Self(strategy: "xctest-coordinate-tap", message: message, hint: hint) - } - } - - /// Runs a gesture action with uniform timing capture. Touch gestures pass `idleTimeout: true` /// (the default) to run inside the scroll idle-timeout + quiescence-skip wrapper; synthesis /// pointer-plan gestures pass `false` because RunnerSynthesizedGesture governs their @@ -99,7 +88,6 @@ extension RunnerTests { message: String, timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double), frame: GestureFrame = .none, - fallback: GestureFallback? = nil, maestroNonHittableCoordinateFallbackUsed: Bool? = nil ) -> Response { let data: DataPayload @@ -109,9 +97,6 @@ extension RunnerTests { message: message, gestureStartUptimeMs: timing.gestureStartUptimeMs, gestureEndUptimeMs: timing.gestureEndUptimeMs, - gestureFallback: fallback?.strategy, - gestureFallbackMessage: fallback?.message, - gestureFallbackHint: fallback?.hint, maestroNonHittableCoordinateFallbackUsed: maestroNonHittableCoordinateFallbackUsed ) case .touch(let f): @@ -123,9 +108,6 @@ extension RunnerTests { y: f?.y, referenceWidth: f?.referenceWidth, referenceHeight: f?.referenceHeight, - gestureFallback: fallback?.strategy, - gestureFallbackMessage: fallback?.message, - gestureFallbackHint: fallback?.hint, maestroNonHittableCoordinateFallbackUsed: maestroNonHittableCoordinateFallbackUsed ) case .drag(let f): @@ -138,17 +120,14 @@ extension RunnerTests { x2: f.x2, y2: f.y2, referenceWidth: f.referenceWidth, - referenceHeight: f.referenceHeight, - gestureFallback: fallback?.strategy, - gestureFallbackMessage: fallback?.message, - gestureFallbackHint: fallback?.hint + referenceHeight: f.referenceHeight ) } return Response(ok: true, data: data) } /// Gesture plans already return canonical centroid endpoints from the portable runtime. - /// Keep runner timing/fallback diagnostics, but do not leak the coordinate-drag adapter's + /// Keep runner timing, but do not leak the coordinate-drag adapter's /// visualization frame into only the fast-fling response shape. func canonicalPlannedGestureResponse(_ response: Response) -> Response { guard response.ok, let data = response.data else { return response } @@ -157,10 +136,7 @@ extension RunnerTests { data: DataPayload( message: data.message, gestureStartUptimeMs: data.gestureStartUptimeMs, - gestureEndUptimeMs: data.gestureEndUptimeMs, - gestureFallback: data.gestureFallback, - gestureFallbackMessage: data.gestureFallbackMessage, - gestureFallbackHint: data.gestureFallbackHint + gestureEndUptimeMs: data.gestureEndUptimeMs ) ) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift index 385ef4326a0..8945ec61fd5 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift @@ -12,18 +12,16 @@ struct RunnerCoordinateRefusal: Error { let hint: String? } -/// A synthesized gesture that failed after its events reached XCTest, so it may have run. Thrown -/// rather than returned so that no XCTest fallback repeats it: a fallback would press a second time. -/// `executeOnMainPrepared` answers it as `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN`. +/// A synthesized gesture that failed after its events reached XCTest, so it may have run and nothing +/// may repeat it. `executeOnMainPrepared` answers it as `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN`. struct RunnerGestureOutcomeUnknown: Error { let message: String let hint: String? } -/// A synthesized gesture that sent nothing and that no XCTest gesture may replace: on a simulator a -/// tap whose touchscreen HID contact cannot be sent. Thrown rather than returned so that no fallback -/// policy answers it; `performSynthesizedGesture` turns it into an `UNSUPPORTED_OPERATION` refusal. -struct RunnerGestureRefusedWithoutFallback: Error { +/// A synthesized gesture that sent nothing: on a simulator a tap whose touchscreen HID contact cannot +/// be sent. `performSynthesizedGesture` turns it into an `UNSUPPORTED_OPERATION` refusal. +struct RunnerGestureNotSent: Error { let message: String let hint: String? } @@ -705,8 +703,6 @@ extension RunnerTests { switch try performSynthesizedTapGesture(app: app, x: x, y: y, context: context) { case .performed: return .performed - case .xctestFallback(let message, let hint): - throw RunnerCoordinateRefusal(message: message, hint: hint) case .refused(_, let refusal): let text = refusal.refusalText throw RunnerCoordinateRefusal(message: text?.message ?? "synthesized tap refused", hint: text?.hint) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift index 29042f9ec23..ebdf99654c0 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift @@ -215,7 +215,6 @@ extension RunnerTests { clearRememberedTextEntryTap() snapshotXCTestPenaltyWarmupExemption.isPending = false lastLoggedFastAppGuardLine = nil - lastLoggedGesturePolicyLines.removeAll() } @MainActor diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift index 7154379dd10..589fd35efa8 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift @@ -562,9 +562,6 @@ struct DataPayload: Codable { /// readable. Absent when the key carries none, or there is no key to read. var keyboardReturnKeyLabel: String? var orientation: String? - var gestureFallback: String? - var gestureFallbackMessage: String? - var gestureFallbackHint: String? // Scroll keyboard avoidance evidence (#2500): the swipe was clipped to the band above an // on-screen keyboard, and where that band ended. `referenceHeight` already names the clipped axis. var keyboardAvoided: Bool? diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift index 6411d4425ba..e120acfff4a 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift @@ -244,16 +244,9 @@ extension RunnerTests { } trace.found = "yes" // The synthesized tap returns once the touch is delivered; an XCTest tap would also wait out the - // pop animation, which the bar check below reads sooner. On iOS a readable tree's XCTest tap - // either runs or throws, so its fallback needs no outcome check. - switch try performSynthesizedTapGesture(app: app, x: frame.midX, y: frame.midY, context: context) { - case .performed: - break - case .xctestFallback: - _ = try performGesture(app) { try tapAt(app: app, x: frame.midX, y: frame.midY, context: context) } - case .refused: - return nil - } + // pop animation, which the bar check below reads sooner. + guard case .performed = try performSynthesizedTapGesture(app: app, x: frame.midX, y: frame.midY, context: context) + else { return nil } trace.pressed = true let tapped = currentUptimeMs() let confirmation = navigationBarBackConfirmation( diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift index 0fbb37bc957..0f1223ab428 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift @@ -49,7 +49,7 @@ extension RunnerTests { durationMs: durationMs, message: message, synthesizedContext: context, - synthesized: (profile: scrollDragProfile(releaseBehavior: releaseBehavior), policyKind: .scroll) + synthesizedProfile: scrollDragProfile(releaseBehavior: releaseBehavior) ) #else return try executeDragGesture( @@ -64,8 +64,9 @@ extension RunnerTests { #endif } - /// Shared coordinate drag execution. Callers that pass `synthesized` take the iOS synthesized - /// lane with that profile and fallback policy; the rest perform an XCTest coordinate drag. + /// Shared coordinate drag execution. On iOS, callers that pass `synthesizedProfile` take the + /// synthesized lane with that profile, and a failed synthesis refuses; the rest perform an XCTest + /// coordinate drag. @MainActor func executeDragGesture( activeApp: XCUIApplication, @@ -76,7 +77,7 @@ extension RunnerTests { durationMs: Double?, message: String, synthesizedContext: SynthesizedCoordinateContext? = nil, - synthesized: (profile: SynthesizedDragProfile, policyKind: SynthesizedGesturePolicyKind)? = nil + synthesizedProfile: SynthesizedDragProfile? = nil ) throws -> Response { let durationMs = durationMs ?? runnerDefaultDragDurationMs let commandName = dragCommandName(message: message) @@ -86,7 +87,7 @@ extension RunnerTests { error: ErrorPayload(code: RunnerWireErrorCode.invalidArgs, message: "\(commandName) requires finite coordinates") ) } - if let synthesized, let synthesizedResponse = try executeSynthesizedDragGesture( + if let synthesizedProfile, let synthesizedResponse = try executeSynthesizedDragGesture( activeApp: activeApp, x: x, y: y, @@ -95,8 +96,7 @@ extension RunnerTests { durationMs: durationMs, message: message, context: synthesizedContext, - policyKind: synthesized.policyKind, - profile: synthesized.profile + profile: synthesizedProfile ) { return synthesizedResponse } @@ -106,14 +106,14 @@ extension RunnerTests { y: y, x2: x2, y2: y2, - holdDuration: synthesized == nil + holdDuration: synthesizedProfile == nil ? coordinateDragHoldDuration() : synthesizedSwipeFallbackHoldDuration(durationMs: durationMs), message: message ) } - /// Callers own the hold duration; only synthesized fallback attaches `fallback` evidence. + /// Callers own the hold duration. @MainActor private func executeCoordinateDrag( activeApp: XCUIApplication, @@ -122,8 +122,7 @@ extension RunnerTests { x2: Double, y2: Double, holdDuration: TimeInterval, - message: String, - fallback: GestureFallback? = nil + message: String ) throws -> Response { let dragPoints = try keyboardAvoidingDragPoints(app: activeApp, x: x, y: y, x2: x2, y2: y2) let dragFrame = try resolvedDragVisualizationFrame( @@ -146,7 +145,7 @@ extension RunnerTests { if let response = unsupportedResponse(for: outcome) { return response } - return gestureResponse(message: message, timing: timing, frame: .drag(dragFrame), fallback: fallback) + return gestureResponse(message: message, timing: timing, frame: .drag(dragFrame)) } @MainActor @@ -159,7 +158,6 @@ extension RunnerTests { durationMs: Double, message: String, context: SynthesizedCoordinateContext?, - policyKind: SynthesizedGesturePolicyKind, profile: SynthesizedDragProfile ) throws -> Response? { #if os(iOS) @@ -173,7 +171,6 @@ extension RunnerTests { context: context ) else { - logSynthesizedGesturePolicyDecision(kind: policyKind, context: context, fallbackAttempted: false) return Response( ok: false, error: ErrorPayload( @@ -191,7 +188,7 @@ extension RunnerTests { referenceWidth: Double(plan.context.geometry.windowOnScreen.rect.width), referenceHeight: Double(plan.context.geometry.windowOnScreen.rect.height) ) - switch try performSynthesizedGesture(activeApp, kind: policyKind, context: plan.context, synthesize: { + switch try performSynthesizedGesture({ try synthesizedDragAt( app: activeApp, x: plan.points.x, @@ -205,17 +202,6 @@ extension RunnerTests { }) { case .performed(let timing): return gestureResponse(message: message, timing: timing, frame: .drag(dragFrame)) - case .xctestFallback(let fallbackMessage, let hint): - return try executeCoordinateDrag( - activeApp: activeApp, - x: plan.points.x, - y: plan.points.y, - x2: plan.points.x2, - y2: plan.points.y2, - holdDuration: synthesizedSwipeFallbackHoldDuration(durationMs: durationMs), - message: message, - fallback: GestureFallback(strategy: "xctest-coordinate-drag", message: fallbackMessage, hint: hint) - ) case .refused(_, let refusal): return refusalResponse(refusal) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift index 259fe9b775b..2ac8131b2be 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift @@ -55,7 +55,7 @@ extension RunnerTests { do { firstFrame = try resolvedTouchVisualizationFrame(app: activeApp, x: x, y: y) } catch let refusal as RunnerCoordinateRefusal { - if synthesizedPolicyKind(forSequenceStep: firstStep) == nil { + if synthesizedKind(forSequenceStep: firstStep) == nil { firstStepRefusal = refusal } } @@ -187,22 +187,22 @@ extension RunnerTests { let x = step.x ?? 0 let y = step.y ?? 0 let longPressDurationMs = min(max(step.durationMs ?? 800, 16), 10000) - if let policyKind = synthesizedPolicyKind(forSequenceStep: step) { + if let synthesizedStepKind = synthesizedKind(forSequenceStep: step) { let attempt: SynthesizedGestureAttempt let attemptStartUptimeMs = currentUptimeMs() do { - attempt = try performSynthesizedGesture(activeApp, kind: policyKind, context: synthesizedContext, synthesize: { + attempt = try performSynthesizedGesture { try synthesizedSequenceStep( - policyKind, + synthesizedStepKind, app: activeApp, x: x, y: y, longPressDurationMs: longPressDurationMs, context: synthesizedContext ) - }) + } } catch let unknown as RunnerGestureOutcomeUnknown { - // The step may have run, so the sequence stops on it instead of falling back and repeating it. + // The step may have run, so the sequence stops on it instead of repeating it. // Its window runs from before dispatch to the failure, covering whatever part of it ran. var failed = finishedSequenceStep( step, @@ -223,8 +223,6 @@ extension RunnerTests { refused.errorCode = RunnerWireErrorCode.synthesizedGestureNotDispatched } return refused - case .xctestFallback: - break } } let (timing, outcome) = try performGesture(activeApp) { @@ -249,16 +247,16 @@ extension RunnerTests { @MainActor private func synthesizedSequenceStep( - _ policyKind: SynthesizedGesturePolicyKind, + _ kind: SynthesizedSequenceStepKind, app: XCUIApplication, x: Double, y: Double, longPressDurationMs: Double, context: SynthesizedCoordinateContext? ) throws -> RunnerInteractionOutcome? { - switch policyKind { + switch kind { #if os(iOS) - case .coordinateLongPress: + case .longPress: return try synthesizedLongPressAt( app: app, x: x, diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift index 0e77ce99a0b..cbdc0435094 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift @@ -1,11 +1,12 @@ import XCTest import AgentDeviceSnapshotPresentation -// Runner-local policy for AX-free/private synthesized iOS gestures. +// Runner-local context for AX-free/private synthesized iOS gestures. // -// This policy is intentionally separate from the TS interaction guarantee matrix: +// This module is intentionally separate from the TS interaction guarantee matrix: // ADR 0011 models element-targeting guarantees, while this module models command // paths that must keep scroll/drag/sequence usable when XCTest AX is unhealthy. +// A synthesized gesture that fails refuses; no XCTest coordinate gesture replaces it. enum RunnerAccessibilityHealth: String, Equatable { case unknown @@ -13,35 +14,6 @@ enum RunnerAccessibilityHealth: String, Equatable { case unavailable } -enum SynthesizedGesturePolicyKind: String, Equatable, Hashable { - case coordinateTap - case coordinateLongPress - case scroll - case synthesizedDrag - - /// Whether the call site's XCTest coordinate gesture may run after private synthesis fails. - /// Scroll's swipe is viewport-center-symmetric, so an unverified dispatch cannot be told apart - /// from one that never reached the view, and it keeps the refusal. A coordinate long press - /// resolves the app frame through the tree, so on a tree XCTest cannot serialize that read fails - /// after its retries and raises an exception that ends the runner test; its fallback needs a tree - /// that answers. A coordinate tap resolves its anchor through the same read, but its refusal - /// needs the proof of the call's own windows query (`treeUnreadable`), not the health the last - /// snapshot left behind: a tree that answers now still takes the XCTest tap. - func allowsXCTestCoordinateFallback( - accessibilityHealth: RunnerAccessibilityHealth, - treeUnreadable: Bool = false - ) -> Bool { - switch self { - case .coordinateTap: - return !treeUnreadable - case .coordinateLongPress, .synthesizedDrag: - return accessibilityHealth != .unavailable - case .scroll: - return false - } - } -} - /// Where a synthesized gesture's window frame came from, which decides both where its records /// route and what the frame proves about the app's tree. enum SynthesizedWindowSource { @@ -53,8 +25,7 @@ enum SynthesizedWindowSource { /// XCTest cannot anchor a coordinate on the app's tree. case soleScreen /// The call skipped the windows query because a sole-screen iPhone's screen is its window, so - /// nothing yet proves whether the tree answers. A fallback decision runs the query first - /// (`provingDeferredWindowQuery`). + /// nothing proves whether the tree answers. case deferred } @@ -109,28 +80,32 @@ func shouldProbeCoordinateTapTextInput( return false } -/// A synthesized `tap` step in a `sequence` is a standalone coordinate tap and follows its policy. On -/// iOS a `longPress` step is a standalone long press, which is always synthesized. -func synthesizedPolicyKind(forSequenceStep step: SequenceStep) -> SynthesizedGesturePolicyKind? { +/// The synthesized gesture a `sequence` step runs. A synthesized `tap` step is a standalone +/// coordinate tap. On iOS a `longPress` step is a standalone long press, which is always synthesized. +enum SynthesizedSequenceStepKind: Equatable { + case tap + case longPress +} + +func synthesizedKind(forSequenceStep step: SequenceStep) -> SynthesizedSequenceStepKind? { switch step.kind { case "tap": - return step.synthesized == true ? .coordinateTap : nil + return step.synthesized == true ? .tap : nil #if os(iOS) case "longPress": - return .coordinateLongPress + return .longPress #endif default: return nil } } -/// A synthesized gesture's result for its call site, which owns the XCTest coordinate gesture. +/// A synthesized gesture's result for its call site. enum SynthesizedGestureAttempt { case performed(timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double)) - /// Synthesis failed and the policy allows the call site's XCTest coordinate gesture. - case xctestFallback(message: String, hint: String?) - /// Synthesis failed and the policy refuses an XCTest coordinate gesture. `refusal` is the - /// producer's `.unsupported` or `.notDispatched` outcome, never `.performed`. + /// Synthesis failed. `refusal` is the producer's `.unsupported` or `.notDispatched` outcome, + /// never `.performed`. No XCTest coordinate gesture replaces it: both routes run through the same + /// testmanagerd event synthesis, and the XCTest route ends the runner test on a tree it cannot read. case refused( timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double), refusal: RunnerInteractionOutcome @@ -143,7 +118,7 @@ extension RunnerTests { steps: [SequenceStep], app: XCUIApplication ) throws -> SynthesizedCoordinateContext? { - guard steps.lazy.contains(where: { synthesizedPolicyKind(forSequenceStep: $0) != nil }) else { + guard steps.lazy.contains(where: { synthesizedKind(forSequenceStep: $0) != nil }) else { return nil } return try synthesizedCoordinateContext(app: app) @@ -157,104 +132,34 @@ extension RunnerTests { context: SynthesizedCoordinateContext? = nil ) throws -> SynthesizedGestureAttempt { let context = try context ?? synthesizedCoordinateContext(app: app) - return try performSynthesizedGesture(app, kind: .coordinateTap, context: context) { + return try performSynthesizedGesture { try synthesizedTapAt(app: app, x: x, y: y, context: context) } } - /// `context` is nil when no window frame resolved; `kind`'s fallback decision then reads the - /// runner's current accessibility health. @MainActor func performSynthesizedGesture( - _ app: XCUIApplication, - kind: SynthesizedGesturePolicyKind, - context: SynthesizedCoordinateContext?, - synthesize: () throws -> RunnerInteractionOutcome? + _ synthesize: () throws -> RunnerInteractionOutcome? ) throws -> SynthesizedGestureAttempt { var outcome: RunnerInteractionOutcome? let timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double) let gestureStartUptimeMs = currentUptimeMs() do { timing = try measureGesture { outcome = try synthesize() } - } catch let unknown as RunnerGestureOutcomeUnknown { - // A gesture that may have run is never repeated through a fallback. - logSynthesizedGesturePolicyDecision(kind: kind, context: context, fallbackAttempted: false) - throw unknown - } catch let refusal as RunnerGestureRefusedWithoutFallback { - logSynthesizedGesturePolicyDecision(kind: kind, context: context, fallbackAttempted: false) + } catch let refusal as RunnerGestureNotSent { return .refused( timing: (gestureStartUptimeMs, currentUptimeMs()), refusal: .unsupported(message: refusal.message, hint: refusal.hint) ) } guard let outcome else { - logSynthesizedGesturePolicyDecision(kind: kind, context: context, fallbackAttempted: false) return .refused( timing: timing, refusal: .unsupported(message: "synthesized gesture deadline expired before dispatch", hint: nil) ) } - guard case let (message, hint)? = outcome.refusalText else { - logSynthesizedGesturePolicyDecision(kind: kind, context: context, fallbackAttempted: false) - return .performed(timing: timing) - } - let context = context.map { provingDeferredWindowQuery($0, app: app) } - let fallbackAllowed = kind.allowsXCTestCoordinateFallback( - accessibilityHealth: context?.accessibilityHealth ?? mainOwned.accessibilityHealth, - treeUnreadable: context?.treeUnreadable ?? false - ) - logSynthesizedGesturePolicyDecision( - kind: kind, - context: context, - fallbackAttempted: fallbackAllowed - ) - return fallbackAllowed - ? .xctestFallback(message: message, hint: hint) - : .refused(timing: timing, refusal: outcome) - } - - @MainActor - func logSynthesizedGesturePolicyDecision( - kind: SynthesizedGesturePolicyKind, - context: SynthesizedCoordinateContext?, - fallbackAttempted: Bool - ) { -#if os(iOS) - let line = Self.synthesizedGesturePolicyLine( - kind: kind, - context: context, - fallbackAttempted: fallbackAttempted - ) - // The same decision for the same gesture kind on every command is one line; a changed policy - // (AX health or the fallback decision) is a new one. - if lastLoggedGesturePolicyLines[kind] != line { - lastLoggedGesturePolicyLines[kind] = line - runnerMarkerWriter(line) - } -#endif - } - - static func synthesizedGesturePolicyLine( - kind: SynthesizedGesturePolicyKind, - context: SynthesizedCoordinateContext?, - fallbackAttempted: Bool - ) -> String { - guard let context else { - return "AGENT_DEVICE_RUNNER_SYNTHESIZED_GESTURE_POLICY kind=\(kind.rawValue)" - + " context=unavailable fallbackAttempted=\(fallbackAttempted)" - } - let fallbackAllowed: String - switch context.windowSource { - case .deferred: - // The windows query has not run, so the fallback decision is not known yet. - fallbackAllowed = "unproven" - case .resolved, .soleScreen: - fallbackAllowed = "\(kind.allowsXCTestCoordinateFallback(accessibilityHealth: context.accessibilityHealth, treeUnreadable: context.treeUnreadable))" - } - return "AGENT_DEVICE_RUNNER_SYNTHESIZED_GESTURE_POLICY kind=\(kind.rawValue)" - + " axHealth=\(context.accessibilityHealth.rawValue)" - + " fallbackAllowed=\(fallbackAllowed)" - + " fallbackAttempted=\(fallbackAttempted)" + if case .performed = outcome { return .performed(timing: timing) } + return .refused(timing: timing, refusal: outcome) } } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index d3bb88424e6..6241f80f679 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -124,7 +124,7 @@ extension RunnerTests { case .failed: return .unsupported( message: message as String? ?? "private XCTest event synthesis failed", - hint: "Falling back to XCTest coordinate tap may be slower and can still need a healthy accessibility tree." + hint: "This tap uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists." ) @unknown default: return .unsupported( @@ -462,8 +462,8 @@ extension RunnerTests { ) guard let soleScreen else { return nil } geometry = soleScreen - // The windows query just failed on this tree, so this gesture's keyboard probes and XCTest - // fallbacks would fail on it too, after XCTest's own retries. + // The windows query just failed on this tree, so this gesture's keyboard probes would fail on + // it too, after XCTest's own retries. health = .unavailable windowSource = .soleScreen } @@ -480,8 +480,7 @@ extension RunnerTests { /// A coordinate tap's context that needs no windows query, or nil when the tap must resolve its /// window. On an iPhone with one screen the app fills that screen, so the screen in the app's /// orientation is the window frame and the record routes to the screen, so the windows query (three - /// XCTest round trips on every tap) would only repeat it. Only an XCTest fallback needs what the - /// query proves, so a failed synthesis runs it then (`provingDeferredWindowQuery`). + /// XCTest round trips on every tap) would only repeat it. @MainActor func deferredWindowTapContext(app: XCUIApplication) -> SynthesizedCoordinateContext? { #if os(iOS) @@ -496,28 +495,6 @@ extension RunnerTests { #endif } - /// `context` with its deferred windows query run: a tree that answers no window is unreadable - /// for the fallback decision, as when the query ran up front. - @MainActor - func provingDeferredWindowQuery( - _ context: SynthesizedCoordinateContext, - app: XCUIApplication - ) -> SynthesizedCoordinateContext { - guard case .deferred = context.windowSource else { return context } - guard let resolved = resolveRunnerWindowElement(app: app) else { - return SynthesizedCoordinateContext( - geometry: context.geometry, - windowSource: .soleScreen, - accessibilityHealth: .unavailable - ) - } - return SynthesizedCoordinateContext( - geometry: context.geometry, - windowSource: .resolved(resolved.window, fillsSoleScreen: resolved.frame == context.geometry.windowOnScreen.rect), - accessibilityHealth: context.accessibilityHealth - ) - } - #if os(iOS) /// Sole-screen geometry with a single app orientation sample: when /// the app provably fills the device's only screen, its window is that screen. A deep app tree @@ -607,7 +584,7 @@ extension RunnerTests { /// Taps `point` (native portrait points) with one touchscreen HID contact from inside the /// simulator, its only tap route. XCTest event synthesis spends about 280 ms per tap waiting on its /// own round trip; this contact returns once the finger lifts. A contact that cannot be prepared, - /// or that never went down, sent nothing: it throws `RunnerGestureRefusedWithoutFallback`, because + /// or that never went down, sent nothing: it throws `RunnerGestureNotSent`, because /// that is a broken simulator runtime, which no XCTest gesture may hide. A contact that went down /// and then failed may have reached the app, so it throws `RunnerGestureOutcomeUnknown` and nothing /// repeats it. Nil: the deadline passed before the contact. @@ -650,8 +627,8 @@ extension RunnerTests { static let simulatorHIDRefusalHint = "Restart the simulator. If the failure persists, rebuild the runner." - static func simulatorHIDTapRefusal(reason: String) -> RunnerGestureRefusedWithoutFallback { - RunnerGestureRefusedWithoutFallback( + static func simulatorHIDTapRefusal(reason: String) -> RunnerGestureNotSent { + RunnerGestureNotSent( message: "simulator tap could not send a touchscreen HID contact: \(reason)", hint: simulatorHIDRefusalHint ) @@ -973,8 +950,8 @@ extension RunnerTests { #endif /// A synthesized gesture's result. A failure before its events reached XCTest sent nothing, so it - /// is a `.notDispatched` refusal, which a policy may still answer with an XCTest fallback. A failure - /// after may have run, so it throws `RunnerGestureOutcomeUnknown`, which no fallback repeats. + /// is a `.notDispatched` refusal. A failure after may have run, so it throws + /// `RunnerGestureOutcomeUnknown`, and nothing repeats it. static func synthesizedGestureOutcome( failure: String?, dispatched: Bool, diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift index d147b64a35d..b8b822f17a8 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift @@ -95,8 +95,6 @@ extension RunnerTests { inputAtRefreshPoint: reached.input, postFocusRead: reached.read ) - case .xctestFallback: - break case .refused(_, let refusal): return refusalResponse(refusal) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift index 4b2beba5541..24dba1e4f56 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift @@ -89,12 +89,10 @@ final class RunnerTests: XCTestCase { // screenshot round trip, not the frame interval: a capture slower than the interval lowers the // frame rate, and only a capture this slow counts as main-thread occupancy. let recordingFrameCaptureTimeout: TimeInterval = 1 - // Per-command markers that restate a fact of the bound target (the fast app guard, the - // synthesized gesture policy per gesture kind) write only when that fact changes; otherwise a - // long session fills runner.log with one identical line per command. Cleared with the rest of the - // target-bound state so a rebind states the fact once more. + // A per-command marker that restates a fact of the bound target (the fast app guard) writes only + // when that fact changes; otherwise a long session fills runner.log with one identical line per + // command. Cleared with the rest of the target-bound state so a rebind states the fact once more. var lastLoggedFastAppGuardLine: String? - var lastLoggedGesturePolicyLines: [SynthesizedGesturePolicyKind: String] = [:] var runnerMarkerWriter: @MainActor (String) -> Void = { NSLog("%@", $0) } /// When the first interaction after an activation may run. The guarantee is a minimum gap /// *since the activation*, not a pause at the interaction: a caller that already spent that gap diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+CommandExecutionTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+CommandExecutionTests.swift index 4eee27bdff5..c4aa2c93a99 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+CommandExecutionTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+CommandExecutionTests.swift @@ -73,7 +73,6 @@ extension RunnerTests { XCTAssertEqual(response.error?.code, "UNSUPPORTED_OPERATION") XCTAssertEqual(response.error?.message, refusal.message) XCTAssertEqual(response.error?.hint, refusal.hint) - XCTAssertNil(response.data?.gestureFallback) XCTAssertEqual(taps.observer.count, 0) } #endif diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+GestureExecutionTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+GestureExecutionTests.swift index d5c517cf45b..a2bcd23738a 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+GestureExecutionTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+GestureExecutionTests.swift @@ -3,26 +3,6 @@ import AgentDeviceSnapshotPresentation #if AGENT_DEVICE_RUNNER_UNIT_TESTS extension RunnerTests { - func testGestureResponseIncludesSynthesizedTapFallbackDiagnostics() { - let response = gestureResponse( - message: "tapped", - timing: (gestureStartUptimeMs: 1, gestureEndUptimeMs: 2), - fallback: GestureFallback( - strategy: "xctest-coordinate-tap", - message: "Runner synthesized coordinate tap is unavailable", - hint: "Using XCTest coordinate tap fallback." - ) - ) - - XCTAssertEqual(response.ok, true) - XCTAssertEqual(response.data?.gestureFallback, "xctest-coordinate-tap") - XCTAssertEqual( - response.data?.gestureFallbackMessage, - "Runner synthesized coordinate tap is unavailable" - ) - XCTAssertEqual(response.data?.gestureFallbackHint, "Using XCTest coordinate tap fallback.") - } - func testGestureResponseIncludesMaestroNonHittableFallbackUsage() { let response = gestureResponse( message: "tapped via non-hittable coordinate fallback", @@ -34,7 +14,7 @@ extension RunnerTests { XCTAssertEqual(response.data?.maestroNonHittableCoordinateFallbackUsed, true) } - func testCanonicalPlannedGestureResponseOmitsDragFrameAndPreservesDiagnostics() { + func testCanonicalPlannedGestureResponseOmitsDragFrameAndPreservesTiming() { let response = gestureResponse( message: "fling", timing: (gestureStartUptimeMs: 1, gestureEndUptimeMs: 2), @@ -47,11 +27,6 @@ extension RunnerTests { referenceWidth: 200, referenceHeight: 300 ) - ), - fallback: GestureFallback( - strategy: "xctest-coordinate-drag", - message: "Private synthesis unavailable", - hint: "Using XCTest coordinate fallback." ) ) @@ -59,9 +34,6 @@ extension RunnerTests { XCTAssertEqual(canonical.data?.gestureStartUptimeMs, 1) XCTAssertEqual(canonical.data?.gestureEndUptimeMs, 2) - XCTAssertEqual(canonical.data?.gestureFallback, "xctest-coordinate-drag") - XCTAssertEqual(canonical.data?.gestureFallbackMessage, "Private synthesis unavailable") - XCTAssertEqual(canonical.data?.gestureFallbackHint, "Using XCTest coordinate fallback.") XCTAssertNil(canonical.data?.x) XCTAssertNil(canonical.data?.y) XCTAssertNil(canonical.data?.x2) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+LifecycleTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+LifecycleTests.swift index 5d076bb49a2..e88b29c946f 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+LifecycleTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+LifecycleTests.swift @@ -197,13 +197,11 @@ extension RunnerTests { #if AGENT_DEVICE_RUNNER_UNIT_TESTS extension RunnerTests { @MainActor - func testResettingTargetBoundStateForgetsTheLastWrittenMarkers() { + func testResettingTargetBoundStateForgetsTheLastWrittenMarker() { defer { invalidateCachedTarget(reason: "unit_test_cleanup") } lastLoggedFastAppGuardLine = "AGENT_DEVICE_RUNNER_FAST_APP_GUARD bundle=app state=4" - lastLoggedGesturePolicyLines[.scroll] = "AGENT_DEVICE_RUNNER_SYNTHESIZED_GESTURE_POLICY kind=scroll" resetTargetBoundState() XCTAssertNil(lastLoggedFastAppGuardLine, "a rebind must state the guard once more") - XCTAssertTrue(lastLoggedGesturePolicyLines.isEmpty, "a rebind must state the policy once more") } @MainActor diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+ScrollDragExecutionTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+ScrollDragExecutionTests.swift index a4039a3d4ea..28537e4e0f4 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+ScrollDragExecutionTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+ScrollDragExecutionTests.swift @@ -25,7 +25,7 @@ private final class RunnerSynthesizedSwipeFailureStub: NSObject { extension RunnerTests { #if os(iOS) @MainActor - func testCoordinateDragPreservesFrameWithoutFallbackDiagnostics() throws { + func testCoordinateDragPreservesFrame() throws { app.launch() defer { invalidateCachedTarget(reason: "unit_test_cleanup") @@ -49,84 +49,37 @@ extension RunnerTests { XCTAssertEqual(response.data?.y2, 150) XCTAssertEqual(response.data?.referenceWidth, Double(referenceFrame.width)) XCTAssertEqual(response.data?.referenceHeight, Double(referenceFrame.height)) - XCTAssertNil(response.data?.gestureFallback) - XCTAssertNil(response.data?.gestureFallbackMessage) - XCTAssertNil(response.data?.gestureFallbackHint) } + /// A fast-swipe planned gesture refused before its record reached XCTest sent nothing: on a healthy + /// tree too, it reports the typed not-dispatched code with the synthesis hint, and no XCTest drag + /// replaces it. @MainActor - func testSinglePointerFlingFallsBackToXCTestCoordinateDragWhenPrivateSynthesisFails() throws { - RunnerSynthesizedSwipeFailureStub.dispatchedBeforeFailing = false - let selector = NSSelectorFromString( - "synthesizeDragWithApplication:resolvedWindow:interfaceOrientation:drag:dispatched:" - ) - guard - let synthesizedSwipeMethod = class_getClassMethod(RunnerSynthesizedGesture.self, selector), - let failureStubMethod = class_getClassMethod(RunnerSynthesizedSwipeFailureStub.self, selector) - else { - XCTFail("unable to install synthesized swipe failure stub") - return - } - let originalImplementation = method_getImplementation(synthesizedSwipeMethod) - method_setImplementation( - synthesizedSwipeMethod, - method_getImplementation(failureStubMethod) - ) - app.launch() - mainOwned.accessibilityHealth = .healthy - defer { - method_setImplementation(synthesizedSwipeMethod, originalImplementation) - invalidateCachedTarget(reason: "unit_test_cleanup") - app.terminate() - } - let command = try runnerCommandFixture( - """ - {"command":"gesture","commandId":"gesture-fling-fallback","gesturePlan":{"topology":"single","intent":"fling","executionProfile":"endpoint-hold","durationMs":100,"viewport":{"x":0,"y":0,"width":200,"height":300},"pointers":[{"pointerId":0,"samples":[{"offsetMs":0,"point":{"x":160,"y":150}},{"offsetMs":100,"point":{"x":40,"y":150}}]}]}} - """ - ) - - let response = try executeOnMainPrepared(command: command, activeApp: app) + func testFastSwipePlannedGestureRefusedBeforeDispatchIsNotDispatched() throws { + let response = try flingWithFailingSynthesis(dispatchedBeforeFailing: false) - XCTAssertTrue(response.ok) - XCTAssertEqual(response.data?.message, "fling") - XCTAssertEqual(response.data?.gestureFallback, "xctest-coordinate-drag") - XCTAssertEqual(response.data?.gestureFallbackMessage, "forced private synthesis failure") + XCTAssertEqual(response.error?.code, RunnerWireErrorCode.synthesizedGestureNotDispatched) + XCTAssertEqual(response.error?.message, "forced private synthesis failure") XCTAssertEqual( - response.data?.gestureFallbackHint, + response.error?.hint, "Private XCTest event synthesis is required for AX-free coordinate drag on iOS; update Xcode if this persists." ) - XCTAssertNil(response.data?.x) - XCTAssertNil(response.data?.y) - XCTAssertNil(response.data?.x2) - XCTAssertNil(response.data?.y2) } - /// A fast-swipe planned gesture refused before its record reached XCTest sent nothing: with no - /// XCTest fallback allowed it reports the typed not-dispatched code. + /// One that failed after its record reached XCTest may have run: it reports the unknown outcome. @MainActor - func testFastSwipePlannedGestureRefusedBeforeDispatchIsNotDispatched() throws { - let response = try flingWithFailingSynthesis(dispatchedBeforeFailing: false, health: .unavailable) - - XCTAssertEqual(response.error?.code, RunnerWireErrorCode.synthesizedGestureNotDispatched) - } - - /// One that failed after its record reached XCTest may have run: it reports the unknown outcome - /// and no XCTest drag repeats it. - @MainActor - func testFastSwipePlannedGestureFailingAfterDispatchIsUnknownAndNeverFallsBack() throws { - let response = try flingWithFailingSynthesis(dispatchedBeforeFailing: true, health: .healthy) + func testFastSwipePlannedGestureFailingAfterDispatchIsUnknown() throws { + let response = try flingWithFailingSynthesis(dispatchedBeforeFailing: true) XCTAssertEqual(response.error?.code, RunnerWireErrorCode.synthesizedGestureOutcomeUnknown) - XCTAssertNil(response.data?.gestureFallback, "no XCTest drag repeats a fling that may have run") } /// A scroll whose synthesized drag was refused before hand-off (RunnerCreateEventRecord) sent - /// nothing: scroll never falls back to an XCTest drag, so it answers the not-dispatched code. + /// nothing, so it answers the not-dispatched code. @MainActor func testScrollDragRefusedBeforeHandOffIsNotDispatched() throws { let response = try flingWithFailingSynthesis( dispatchedBeforeFailing: false, - health: .healthy, command: #"{"command":"scroll","commandId":"scroll-refused-synthesis","direction":"down"}"# ) @@ -136,7 +89,6 @@ extension RunnerTests { @MainActor private func flingWithFailingSynthesis( dispatchedBeforeFailing: Bool, - health: RunnerAccessibilityHealth, command json: String? = nil ) throws -> Response { RunnerSynthesizedSwipeFailureStub.dispatchedBeforeFailing = dispatchedBeforeFailing @@ -148,7 +100,7 @@ extension RunnerTests { let original = method_setImplementation(target, method_getImplementation(stub)) app.launch() mainOwned.app = app - mainOwned.accessibilityHealth = health + mainOwned.accessibilityHealth = .healthy defer { method_setImplementation(target, original) invalidateCachedTarget(reason: "unit_test_cleanup") diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SnapshotCapturePlanOccupancyTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SnapshotCapturePlanOccupancyTests.swift index 9b5b7d95086..a7007216962 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SnapshotCapturePlanOccupancyTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SnapshotCapturePlanOccupancyTests.swift @@ -563,7 +563,7 @@ extension RunnerTests { ) XCTAssertEqual(quality.backend, SnapshotBackendKind.recursiveTree.rawValue) // The rejected verdict also declares the channel unavailable, which gates the - // synthesized-gesture probe and the XCTest coordinate fallback (#3885 follow-up). + // synthesized gesture's keyboard probe (#3885 follow-up). XCTAssertEqual(mainOwned.accessibilityHealth, .unavailable) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGesturePolicyTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGesturePolicyTests.swift index 15f2ad44166..b14574032c3 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGesturePolicyTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGesturePolicyTests.swift @@ -1,77 +1,8 @@ import AgentDeviceSnapshotPresentation import XCTest -#if AGENT_DEVICE_RUNNER_UNIT_TESTS && os(iOS) -extension RunnerTests { - @MainActor - func testSynthesizedGesturePolicyMarkerWritesOncePerKindUntilTheDecisionChanges() { - var written: [String] = [] - runnerMarkerWriter = { written.append($0) } - defer { - runnerMarkerWriter = { NSLog("%@", $0) } - invalidateCachedTarget(reason: "unit_test_cleanup") - } - logSynthesizedGesturePolicyDecision(kind: .coordinateTap, context: nil, fallbackAttempted: false) - logSynthesizedGesturePolicyDecision(kind: .coordinateTap, context: nil, fallbackAttempted: false) - XCTAssertEqual(written.count, 1, "a repeated decision writes no second line") - logSynthesizedGesturePolicyDecision(kind: .scroll, context: nil, fallbackAttempted: false) - XCTAssertEqual(written.count, 2, "each gesture kind states its own decision") - logSynthesizedGesturePolicyDecision(kind: .coordinateTap, context: nil, fallbackAttempted: true) - XCTAssertEqual(written.count, 3, "a changed decision writes a new line") - resetTargetBoundState() - logSynthesizedGesturePolicyDecision(kind: .coordinateTap, context: nil, fallbackAttempted: true) - XCTAssertEqual(written.count, 4, "a rebind states the same decision once more") - } -} -#endif - #if AGENT_DEVICE_RUNNER_UNIT_TESTS extension RunnerTests { - /// The whole fallback decision: which gesture kind may take the call site's XCTest coordinate - /// gesture, at each accessibility health. - func testSynthesizedCoordinateFallbackFollowsItsKindAndAccessibilityHealth() { - let cases: [(kind: SynthesizedGesturePolicyKind, health: RunnerAccessibilityHealth, allowed: Bool)] = [ - (.coordinateTap, .unknown, true), - (.coordinateTap, .healthy, true), - (.coordinateTap, .unavailable, true), - (.coordinateLongPress, .unknown, true), - (.coordinateLongPress, .healthy, true), - (.coordinateLongPress, .unavailable, false), - (.scroll, .unknown, false), - (.scroll, .healthy, false), - (.scroll, .unavailable, false), - (.synthesizedDrag, .unknown, true), - (.synthesizedDrag, .healthy, true), - (.synthesizedDrag, .unavailable, false), - ] - for testCase in cases { - XCTAssertEqual( - testCase.kind.allowsXCTestCoordinateFallback(accessibilityHealth: testCase.health), - testCase.allowed, - "kind=\(testCase.kind.rawValue) axHealth=\(testCase.health.rawValue)" - ) - } - } - - /// A coordinate tap refuses the XCTest fallback only on the proof of its own windows query, - /// whatever health the last snapshot left behind. - func testCoordinateTapFallbackIsRefusedOnlyForATreeThisCallFoundUnreadable() { - for health: RunnerAccessibilityHealth in [.unknown, .healthy, .unavailable] { - XCTAssertTrue( - SynthesizedGesturePolicyKind.coordinateTap.allowsXCTestCoordinateFallback( - accessibilityHealth: health, treeUnreadable: false - ), - "axHealth=\(health.rawValue)" - ) - XCTAssertFalse( - SynthesizedGesturePolicyKind.coordinateTap.allowsXCTestCoordinateFallback( - accessibilityHealth: health, treeUnreadable: true - ), - "axHealth=\(health.rawValue)" - ) - } - } - func testKeyboardProbeIsAllowedAtEveryAccessibilityHealthExceptUnavailable() { let cases: [(health: RunnerAccessibilityHealth, allowsProbe: Bool)] = [ (.unknown, true), @@ -89,110 +20,50 @@ extension RunnerTests { XCTAssertFalse(shouldProbeCoordinateTapTextInput(xCTestChannelPenalized: true, evidence: nil, point: nil, targetBundleId: nil)) } - func testOnlySynthesizedSequenceTapStepsTakeTheCoordinateTapPolicy() { - XCTAssertEqual(synthesizedPolicyKind(forSequenceStep: sequenceStep("tap", synthesized: true)), .coordinateTap) - XCTAssertNil(synthesizedPolicyKind(forSequenceStep: sequenceStep("tap", synthesized: nil))) - XCTAssertNil(synthesizedPolicyKind(forSequenceStep: sequenceStep("doubleTap", synthesized: true))) + func testOnlySynthesizedSequenceTapStepsAreSynthesizedTaps() { + XCTAssertEqual(synthesizedKind(forSequenceStep: sequenceStep("tap", synthesized: true)), .tap) + XCTAssertNil(synthesizedKind(forSequenceStep: sequenceStep("tap", synthesized: nil))) + XCTAssertNil(synthesizedKind(forSequenceStep: sequenceStep("doubleTap", synthesized: true))) } - func testSequenceLongPressStepsTakeTheLongPressPolicyWithoutARequestFlag() { + func testSequenceLongPressStepsAreSynthesizedWithoutARequestFlag() { for synthesized in [nil, true] as [Bool?] { #if os(iOS) - XCTAssertEqual( - synthesizedPolicyKind(forSequenceStep: sequenceStep("longPress", synthesized: synthesized)), - .coordinateLongPress - ) + XCTAssertEqual(synthesizedKind(forSequenceStep: sequenceStep("longPress", synthesized: synthesized)), .longPress) #else - XCTAssertNil(synthesizedPolicyKind(forSequenceStep: sequenceStep("longPress", synthesized: synthesized))) + XCTAssertNil(synthesizedKind(forSequenceStep: sequenceStep("longPress", synthesized: synthesized))) #endif } } + /// Every failed synthesis is the call's refusal: a deadline that expired before dispatch, a + /// producer refusal, and a thrown not-sent refusal. No XCTest coordinate gesture replaces any of them. @MainActor - func testCoordinateTapThatWasNotDispatchedDoesNotFallBackToXCTest() throws { - for health: RunnerAccessibilityHealth in [.unknown, .healthy, .unavailable] { - mainOwned.accessibilityHealth = health - for context in [nil, synthesizedGestureTestContext(accessibilityHealth: health)] { - let attempt = try performSynthesizedGesture(app, kind: .coordinateTap, context: context) { nil } - XCTAssertEqual(synthesizedGestureRoute(attempt), "refused", "axHealth=\(health.rawValue)") - } - } - } - - @MainActor - func testFailedCoordinateTapSynthesisFallsBackToXCTestUnlessThisCallFoundTheTreeUnreadable() throws { - for health: RunnerAccessibilityHealth in [.unknown, .healthy, .unavailable] { - mainOwned.accessibilityHealth = health - for context in [nil, synthesizedGestureTestContext(accessibilityHealth: health)] { - let label = "axHealth=\(health.rawValue) context=\(context == nil ? "unresolved" : "resolved")" - let attempt = try performSynthesizedGesture( - app, - kind: .coordinateTap, - context: context, - synthesize: failedSynthesis - ) - XCTAssertEqual(synthesizedGestureRoute(attempt), "xctestFallback", label) - } - let unreadable = try performSynthesizedGesture( - app, - kind: .coordinateTap, - context: synthesizedGestureTestContext(accessibilityHealth: health, treeUnreadable: true), - synthesize: failedSynthesis - ) - XCTAssertEqual(synthesizedGestureRoute(unreadable), "refused", "axHealth=\(health.rawValue) unreadable") - } - } - - @MainActor - func testSynthesizedGestureFallbackFollowsItsKindAndTheResolvedAccessibilityHealth() throws { - mainOwned.accessibilityHealth = .healthy - let unavailable = synthesizedGestureTestContext(accessibilityHealth: .unavailable) - let unknown = synthesizedGestureTestContext(accessibilityHealth: .unknown) - let cases: [(SynthesizedGesturePolicyKind, SynthesizedCoordinateContext?, String)] = [ - (.scroll, synthesizedGestureTestContext(accessibilityHealth: .healthy), "refused"), - (.synthesizedDrag, unavailable, "refused"), - (.synthesizedDrag, unknown, "xctestFallback"), - (.coordinateTap, unavailable, "xctestFallback"), - (.coordinateLongPress, unavailable, "refused"), - (.coordinateLongPress, unknown, "xctestFallback"), + func testFailedSynthesisIsTheCallsRefusal() throws { + let refusals: [(name: String, synthesize: () throws -> RunnerInteractionOutcome?, expected: RunnerInteractionOutcome)] = [ + ("deadline", { nil }, .unsupported(message: "synthesized gesture deadline expired before dispatch", hint: nil)), + ("unsupported", { .unsupported(message: "forced", hint: "forced hint") }, .unsupported(message: "forced", hint: "forced hint")), + ("notDispatched", { .notDispatched(message: "forced", hint: "forced hint") }, .notDispatched(message: "forced", hint: "forced hint")), + ("notSent", { throw RunnerGestureNotSent(message: "forced", hint: "forced hint") }, .unsupported(message: "forced", hint: "forced hint")), ] - for (kind, context, expected) in cases { - let attempt = try performSynthesizedGesture(app, kind: kind, context: context, synthesize: failedSynthesis) - XCTAssertEqual(synthesizedGestureRoute(attempt), expected, "kind=\(kind.rawValue)") - switch attempt { - case .xctestFallback(let message, let hint): - XCTAssertEqual(message, "forced private synthesis failure") - XCTAssertEqual(hint, "forced hint") - case .refused(_, let refusal): - XCTAssertEqual(refusal.refusalText?.message, "forced private synthesis failure") - XCTAssertEqual(refusal.refusalText?.hint, "forced hint") - case .performed: - break + for refusal in refusals { + guard case .refused(_, let outcome) = try performSynthesizedGesture(refusal.synthesize) else { + XCTFail("refused: \(refusal.name)") + continue } - let performed = try performSynthesizedGesture(app, kind: kind, context: context) { .performed } - XCTAssertEqual(synthesizedGestureRoute(performed), "performed", "kind=\(kind.rawValue)") + XCTAssertEqual(String(describing: outcome), String(describing: refusal.expected), refusal.name) } - } - - private func failedSynthesis() -> RunnerInteractionOutcome { - .unsupported(message: "forced private synthesis failure", hint: "forced hint") - } - - private func synthesizedGestureRoute(_ attempt: SynthesizedGestureAttempt) -> String { - switch attempt { - case .performed: return "performed" - case .xctestFallback: return "xctestFallback" - case .refused: return "refused" + guard case .performed = try performSynthesizedGesture({ .performed }) else { + return XCTFail("a performed synthesis is performed") } } private func synthesizedGestureTestContext( - accessibilityHealth: RunnerAccessibilityHealth, - treeUnreadable: Bool = false + accessibilityHealth: RunnerAccessibilityHealth ) -> SynthesizedCoordinateContext { SynthesizedCoordinateContext( geometry: SurfaceGeometry(windowOnScreen: SurfaceRect(CGRect(x: 0, y: 0, width: 390, height: 844)), panelNativeSize: nil, orientation: 1), - windowSource: treeUnreadable ? .soleScreen : .resolved(app.windows.firstMatch, fillsSoleScreen: false), + windowSource: .resolved(app.windows.firstMatch, fillsSoleScreen: false), accessibilityHealth: accessibilityHealth ) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift index 9cb50297ca6..b0a77f77c10 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift @@ -254,17 +254,17 @@ extension RunnerTests { } /// A long press whose synthesis failed after its events reached XCTest may have run, so it reports - /// an unknown outcome and no XCTest fallback presses a second time. + /// an unknown outcome and no XCTest press repeats it. @MainActor - func testLongPressSynthesisFailingAfterDispatchIsUnknownAndNeverFallsBack() throws { + func testLongPressSynthesisFailingAfterDispatchIsUnknownAndNeverRepeated() throws { let (response, presses) = try longPressWithFailingSynthesis(dispatchedBeforeFailing: true, health: .healthy) XCTAssertEqual(response.error?.code, RunnerWireErrorCode.synthesizedGestureOutcomeUnknown) - XCTAssertEqual(presses, 0, "no XCTest fallback repeats a gesture that may have run") + XCTAssertEqual(presses, 0, "no XCTest press repeats a gesture that may have run") } /// A sequence step whose synthesis failed after hand-off reports the same unknown code as the - /// standalone command, keeps its gesture window, and stops the sequence: no XCTest fallback press, + /// standalone command, keeps its gesture window, and stops the sequence: no XCTest press, /// and the next step never runs. @MainActor func testSequenceLongPressFailingAfterDispatchReportsTheUnknownCodeAndStops() throws { @@ -289,8 +289,9 @@ extension RunnerTests { } /// A sequence long-press step refused before its events reached XCTest reports the same - /// not-dispatched code as the standalone command, whether or not an earlier step ran. The host - /// reads the sequence as sent nothing only when no earlier step ran. + /// not-dispatched code as the standalone command, whether or not an earlier step ran, and on a + /// healthy tree no XCTest press replaces it. The host reads the sequence as sent nothing only when + /// no earlier step ran. @MainActor func testSequenceLongPressRefusedBeforeDispatchIsNotDispatched() throws { for (steps, failedIndex) in [ @@ -299,7 +300,7 @@ extension RunnerTests { ] { let (response, presses) = try longPressWithFailingSynthesis( dispatchedBeforeFailing: false, - health: .unavailable, + health: .healthy, command: #"{"command":"sequence","commandId":"refused-synthesis-sequence-\#(failedIndex)","steps":\#(steps)}"# ) @@ -311,12 +312,14 @@ extension RunnerTests { } } - /// One refused before its events reached XCTest sent nothing, and says so. + /// One refused before its events reached XCTest sent nothing, and says so with the synthesis + /// hint: on a healthy tree too, no XCTest press replaces it. @MainActor func testLongPressSynthesisRefusedBeforeDispatchIsNotDispatched() throws { - let (response, presses) = try longPressWithFailingSynthesis(dispatchedBeforeFailing: false, health: .unavailable) + let (response, presses) = try longPressWithFailingSynthesis(dispatchedBeforeFailing: false, health: .healthy) XCTAssertEqual(response.error?.code, RunnerWireErrorCode.synthesizedGestureNotDispatched) + XCTAssertNotNil(response.error?.hint) XCTAssertEqual(presses, 0) } @@ -444,7 +447,7 @@ extension RunnerTests { return XCTFail("no failure is performed") } guard case .notDispatched = try Self.synthesizedGestureOutcome(failure: "x", dispatched: false, refusalHint: "") else { - return XCTFail("a failure before dispatch is a refusal a fallback may answer") + return XCTFail("a failure before dispatch is a not-dispatched refusal") } XCTAssertThrowsError(try Self.synthesizedGestureOutcome(failure: "x", dispatched: true, refusalHint: "")) { XCTAssertTrue($0 is RunnerGestureOutcomeUnknown) @@ -519,7 +522,6 @@ extension RunnerTests { XCTAssertEqual(longPressResponse.data?.message, "long pressed") XCTAssertTrue(pressSeriesResponse.ok, String(describing: pressSeriesResponse.error)) XCTAssertEqual(longPressCoordinatePresses, 0) - XCTAssertNil(longPressResponse.data?.gestureFallback) XCTAssertEqual(pressSeriesResponse.data?.completedSteps, 2) XCTAssertEqual(RunnerCoordinatePressCounter.presses, 0) XCTAssertEqual(RunnerUnserializableTreeStub.frameReads, 0) @@ -1025,7 +1027,7 @@ extension RunnerTests { ) { XCTAssertThrowsError(try tap(), file: file, line: line) { error in XCTAssertEqual( - (error as? RunnerGestureRefusedWithoutFallback)?.message, + (error as? RunnerGestureNotSent)?.message, Self.simulatorHIDTapRefusal(reason: "the display size could not be read").message, file: file, line: line diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedTapContextTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedTapContextTests.swift index 42ed0bd75e4..e730d51b937 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedTapContextTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedTapContextTests.swift @@ -58,77 +58,6 @@ extension RunnerTests { XCTAssertEqual(tapContext.geometry.orientation, windowContext.geometry.orientation) } - /// A tap synthesis that fails runs the deferred windows query before the fallback decision: a tree - /// that answers a window still takes the XCTest coordinate tap, one that answers none refuses it, - /// exactly as when the query ran before the tap. - @MainActor - func testFailedTapSynthesisProvesTheTreeBeforeChoosingTheXCTestFallback() throws { - guard tapDefersTheWindowQuery else { return } - app.launch() - mainOwned.app = app - defer { - invalidateCachedTarget(reason: "unit_test_cleanup") - app.terminate() - } - let failing: () throws -> RunnerInteractionOutcome? = { - .unsupported(message: "injected synthesis failure", hint: nil) - } - - let readable = try XCTUnwrap(deferredWindowTapContext(app: app)) - let (readableAttempt, readableQueries) = try countingElementQueries { - try performSynthesizedGesture(app, kind: .coordinateTap, context: readable, synthesize: failing) - } - guard case .xctestFallback = readableAttempt else { - return XCTFail("a readable tree keeps the XCTest fallback: \(readableAttempt)") - } - XCTAssertGreaterThan(readableQueries, 0, "the fallback decision ran the deferred windows query") - - let restoreXCTest = try simulateUnserializableAppTree() - defer { restoreXCTest() } - let unreadable = try XCTUnwrap(deferredWindowTapContext(app: app)) - guard case .deferred = unreadable.windowSource else { return XCTFail("the tap defers its windows query") } - guard case .refused = try performSynthesizedGesture( - app, kind: .coordinateTap, context: unreadable, synthesize: failing - ) else { - return XCTFail("a tree that answers no window refuses the XCTest fallback") - } - - XCTAssertTrue( - Self.synthesizedGesturePolicyLine(kind: .coordinateTap, context: unreadable, fallbackAttempted: false) - .contains(" fallbackAllowed=unproven "), - "a deferred context logs no fallback decision it has not proven" - ) - let proven = provingDeferredWindowQuery(unreadable, app: app) - guard case .soleScreen = proven.windowSource else { return XCTFail("a tree with no window is unreadable") } - XCTAssertEqual(proven.accessibilityHealth, .unavailable) - XCTAssertTrue( - Self.synthesizedGesturePolicyLine(kind: .coordinateTap, context: proven, fallbackAttempted: false) - .contains(" fallbackAllowed=false ") - ) - } - - /// A refusal that no XCTest gesture may replace stays the answer on a healthy tree, where any - /// other tap refusal takes the XCTest fallback, and no windows query runs to decide it. - @MainActor - func testRefusalWithoutFallbackSkipsTheXCTestFallbackOnAHealthyTree() throws { - let health = mainOwned.accessibilityHealth - defer { mainOwned.accessibilityHealth = health } - mainOwned.accessibilityHealth = .healthy - - let (attempt, queries) = try countingElementQueries { - try performSynthesizedGesture(app, kind: .coordinateTap, context: nil) { - throw RunnerGestureRefusedWithoutFallback(message: "injected refusal", hint: "injected hint") - } - } - - XCTAssertEqual(queries, 0) - guard case .refused(_, .unsupported(let message, let hint)) = attempt else { - return XCTFail("the refusal must not take the XCTest fallback: \(attempt)") - } - XCTAssertEqual(message, "injected refusal") - XCTAssertEqual(hint, "injected hint") - } - /// A resolved window that fills an iPhone's only screen routes its records to that screen, so /// dispatch does not re-read the window; the window stays on the context for its other reads. @MainActor @@ -179,23 +108,5 @@ extension RunnerTests { XCTAssertEqual(queries, 0) XCTAssertEqual(app.staticTexts["agent-device-tap-witness-presses"].label, "presses=1") } - - /// A tap that synthesizes never needs the deferred query's answer, so it never runs it. - @MainActor - func testSynthesizedTapThatSucceedsRunsNoWindowsQuery() throws { - guard tapDefersTheWindowQuery else { return } - app.launch() - mainOwned.app = app - defer { - invalidateCachedTarget(reason: "unit_test_cleanup") - app.terminate() - } - let context = try XCTUnwrap(deferredWindowTapContext(app: app)) - let (attempt, queries) = try countingElementQueries { - try performSynthesizedGesture(app, kind: .coordinateTap, context: context) { .performed } - } - guard case .performed = attempt else { return XCTFail("the tap was performed: \(attempt)") } - XCTAssertEqual(queries, 0) - } } #endif diff --git a/apple/runner/RUNNER_PROTOCOL.md b/apple/runner/RUNNER_PROTOCOL.md index 29469636571..7fe2ee1d221 100644 --- a/apple/runner/RUNNER_PROTOCOL.md +++ b/apple/runner/RUNNER_PROTOCOL.md @@ -354,8 +354,8 @@ handed to XCTest, so the command sent nothing. It also covers a planned gesture its window or display is resolved (the window cannot be named, or the sole display cannot be measured), before any synthesis. Any other refusal keeps `UNSUPPORTED_OPERATION`. `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN` means it failed after its event record was handed to XCTest. That is not confirmed delivery: the record can still fail before its -events run. The gesture may have run, so the runner does not fall back to an XCTest gesture that -would repeat it. A sequence long-press step reports the same two codes as the step's `errorCode`. The runner does not +events run. The gesture may have run, so the runner does not repeat it. A synthesized gesture that +fails refuses: the runner never replaces it with an XCTest coordinate gesture. A sequence long-press step reports the same two codes as the step's `errorCode`. The runner does not report a dispatch for the whole sequence: the daemon derives it from the step code when `completedSteps` is 0, and reports `dispatched: unknown` once an earlier step completed. diff --git a/docs/adr/0011-interaction-guarantee-contract.md b/docs/adr/0011-interaction-guarantee-contract.md index d6072edba3f..5b11bde6a8c 100644 --- a/docs/adr/0011-interaction-guarantee-contract.md +++ b/docs/adr/0011-interaction-guarantee-contract.md @@ -398,15 +398,14 @@ The element dispatch-path matrix above intentionally does not include synthesize - Synthesized `sequence` tap/drag steps. They do not resolve selectors or refs, so a claim of the element-targeting guarantees would be misleading. -Their AX-health, keyboard-probe, frame-source, activation-preflight, and XCTest-coordinate fallback rules stay runner-local in `RunnerTests+SynthesizedGesturePolicy.swift`. -That Swift policy is the source of truth, because the current table has only three behaviors: +Their AX-health, keyboard-probe, frame-source, and activation-preflight rules stay runner-local in `RunnerTests+SynthesizedGesturePolicy.swift`. +That Swift policy is the source of truth, because the current table has only two behaviors: -- A coordinate synthesized tap never probes keyboards and may use the coordinate fallback. +- A coordinate synthesized tap never probes keyboards. This applies to a standalone tap and a `sequence` step. - Default iOS scroll probes keyboards whenever AX is not stamped unavailable, including while health is still unknown (#2500). - It must not fall back to `XCUICoordinate`. -- Synthesized one-contact `gesture` plans may still use the coordinate fallback before AX health is known. - After a snapshot stamps AX unavailable, they stop using it. + +No synthesized gesture falls back to `XCUICoordinate` (see the amendment below). Gated XCTest policy tests cover the non-obvious parts, instead of a cross-language mirror. A future sibling registry should be introduced only once one of these conditions is true: @@ -429,12 +428,12 @@ The reason: those sources can diverge from full-screen screenshot coordinates on On an iOS Simulator, the runner dispatches a synthesized tap as one touchscreen HID contact from inside the simulator. The contact goes down at the resolved native point, holds 50 ms, and lifts, as the XCTest tap record does. It uses the touchscreen sender of the app's display, the same sender the screen-edge touch uses. -A synthesized simulator tap has no XCTest event record and no XCUICoordinate fallback. +A synthesized simulator tap has no XCTest event record. If the HID contact cannot be prepared, or does not go down, the tap answers `UNSUPPORTED_OPERATION` with the HID reason and a hint, and sends nothing. These cases include missing IOKit symbols, a missing, ambiguous, or unrecognized touchscreen service, an unreadable display size, and HID client or event creation failures before touch-down. They are a broken simulator runtime, so the refusal surfaces them, as the screen-edge touch does. -A contact that went down and then failed answers `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN`, and no fallback repeats it. -Physical devices keep the XCTest event record and may use its XCUICoordinate fallback when the accessibility tree is readable, because only a simulator accepts this HID dispatch. +A contact that went down and then failed answers `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN`, and nothing repeats it. +Physical devices keep the XCTest event record, because only a simulator accepts this HID dispatch. The reason: XCTest event synthesis spends about 280 ms of its own round trip on every tap, and the HID contact returns when the finger lifts. The runner process is inside the simulator, so provider simulators get the same route as local ones. @@ -445,6 +444,20 @@ Settle keeps its quiet-window rule; a delayed result needs `wait` on the expecte Rejected: host-side HID through the simulator host. It works only on a local Mac and not on provider simulators. Rejected: accessibility activation (`AXElement press`). It reports success on a React Native `Pressable` without running its press handler. +#### No XCUICoordinate fallback (amendment, 2026-12) + +This amendment withdraws a permission: a synthesized tap, long press, drag, `sequence` step, or one-contact `gesture` plan may no longer fall back to an `XCUICoordinate` gesture when its XCTest event record is refused. +A synthesis that fails answers its refusal with the synthesis hint. +The code is `SYNTHESIZED_GESTURE_NOT_DISPATCHED` when nothing was sent, and `UNSUPPORTED_OPERATION` otherwise. +Responses no longer carry the `gestureFallback` wire fields. + +The reason: both routes go through testmanagerd event synthesis, and they differ only when a private XCTest selector is missing. +Scroll uses the same event record with no fallback, so it shows a missing selector first. +The `XCUICoordinate` route also needs the application snapshot, and it ended the runner test when XCTest rejected the AX root (#4274). +No report showed the fallback running. +Consequence: an event-record failure that only a physical device shows now refuses instead of running the slower XCTest gesture. +Rejected: keep the fallback on physical devices only. It keeps a second dispatch route that no test exercises. + Target-authored `gesture drag` is classified as the `target-drag` path above, because it resolves two elements. Therefore, it inherits the element guarantees and the ADR 0012 identity requirements for both elements. Coordinate-authored drag remains outside this matrix. diff --git a/packages/apple-runner/src/__tests__/runner-session-response.test.ts b/packages/apple-runner/src/__tests__/runner-session-response.test.ts index 516fa2a96d7..72207d3a07c 100644 --- a/packages/apple-runner/src/__tests__/runner-session-response.test.ts +++ b/packages/apple-runner/src/__tests__/runner-session-response.test.ts @@ -3,9 +3,7 @@ import { onTestFinished, test } from 'vitest'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import path from 'node:path'; -import type { DiagnosticEventInput } from '@agent-device/host-kit/diagnostics'; import { mkdtempForTestSync } from './tmp-dir.ts'; -import { appleRunnerTestHost } from '../test-host.ts'; import { isRetryableRunnerError } from '../runner-error-classification.ts'; import type { RunnerLogAttempt } from '../runner-failure-diagnostics.ts'; import { parseRunnerResponse } from '../runner-exchange.ts'; @@ -296,31 +294,6 @@ test('parseRunnerResponse hints when XCTest main-thread execution times out', as ); }); -test('parseRunnerResponse emits diagnostics for runner gesture fallbacks', async () => { - const response = new Response( - JSON.stringify({ - ok: true, - data: { - message: 'dragged', - gestureFallback: 'xctest-coordinate-drag', - gestureFallbackMessage: 'Runner synthesized drag is unavailable', - gestureFallbackHint: 'Using XCTest coordinate drag fallback.', - }, - }), - ); - const session = { state: 'starting' } as const; - const diagnosticEvents: DiagnosticEventInput[] = []; - appleRunnerTestHost.update({ emitDiagnostic: (event) => diagnosticEvents.push(event) }); - - const data = await parseRunnerResponse(response, session, runnerLogAttempt('/tmp/runner.log')); - assert.equal(data.gestureFallback, 'xctest-coordinate-drag'); - - assert.equal(session.state, 'ready'); - const diagnostics = JSON.stringify(diagnosticEvents); - assert.match(diagnostics, /ios_runner_gesture_fallback/); - assert.match(diagnostics, /xctest-coordinate-drag/); -}); - /** * A log attempt over a log this test just created. Offset 0 is the honest boundary there: the file * holds nothing but this command's bytes, so everything in it may be read as this attempt's evidence. diff --git a/packages/apple-runner/src/runner-exchange.ts b/packages/apple-runner/src/runner-exchange.ts index 9fbfea3155b..b596b7c5755 100644 --- a/packages/apple-runner/src/runner-exchange.ts +++ b/packages/apple-runner/src/runner-exchange.ts @@ -532,24 +532,7 @@ export async function parseRunnerResponse( }); } advanceRunnerSessionState(session, 'ready'); - const data = readRunnerResponseData(payload); - emitRunnerResponseDiagnostics(data); - return data; -} - -function emitRunnerResponseDiagnostics(data: Record): void { - const fallback = data.gestureFallback; - if (typeof fallback !== 'string' || fallback.length === 0) return; - emitDiagnostic({ - level: 'debug', - phase: 'ios_runner_gesture_fallback', - data: { - fallback, - message: - typeof data.gestureFallbackMessage === 'string' ? data.gestureFallbackMessage : undefined, - hint: typeof data.gestureFallbackHint === 'string' ? data.gestureFallbackHint : undefined, - }, - }); + return readRunnerResponseData(payload); } function resolveRunnerFatalReason(data: Record): string | undefined { From 7923ac148318c06ae67d99cb29b6bf9f0a086e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 12:17:43 +0100 Subject: [PATCH 2/4] fix(ios-runner): answer a device tap that failed after hand-off as an unknown outcome The physical-device tap reported every event-record failure as UNSUPPORTED_OPERATION, so `back` read a record that failed after XCTest was handed it as unsent and sent the edge swipe too. The tap now reports its dispatch stage like the drag and long press: a refusal before hand-off answers SYNTHESIZED_GESTURE_NOT_DISPATCHED, and a failure after it throws the unknown outcome, so no second gesture follows. ADR 0011's amendment maps both stages. Co-Authored-By: Claude Opus 5.5 --- .../RunnerSynthesizedGesture.h | 1 + .../RunnerSynthesizedGesture.m | 9 +++- .../RunnerTests+Navigation.swift | 3 +- ...RunnerTests+SynthesizedGesturePolicy.swift | 8 ++-- .../RunnerTests+SynthesizedInteraction.swift | 24 ++++------- .../RunnerTests+NavigationTests.swift | 38 +++++++++++++++++ .../RunnerTests+SynthesizedGestureTests.swift | 42 ++++++++++++++++++- apple/runner/RUNNER_PROTOCOL.md | 2 +- .../0011-interaction-guarantee-contract.md | 7 +++- packages/apple-runner/src/runner-contract.ts | 2 +- 10 files changed, 109 insertions(+), 27 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h index 70aeaabd98c..8ef00f4ba43 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h @@ -37,6 +37,7 @@ typedef struct { interfaceOrientation:(NSInteger)interfaceOrientation point:(CGPoint)point deadline:(NSDate * _Nullable)deadline + dispatched:(BOOL * _Nullable)dispatched errorMessage:(NSString * _Nullable * _Nullable)errorMessage; // Each pointer is an ordered array of { x, y, offsetMs } samples. The first sample diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m index 5ab02205fc5..10bf347120a 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m @@ -74,6 +74,7 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( NSInteger interfaceOrientation, CGPoint point, NSDate * _Nullable deadline, + BOOL * _Nullable dispatched, NSString * _Nullable * _Nullable errorMessage ); // XCTest's proven swipe profile reaches the endpoint in 100 ms, then holds for the planned @@ -111,10 +112,14 @@ + (RunnerTapSynthesisStatus)synthesizeTapWithApplication:(id)application interfaceOrientation:(NSInteger)interfaceOrientation point:(CGPoint)point deadline:(NSDate * _Nullable)deadline + dispatched:(BOOL * _Nullable)dispatched errorMessage:(NSString * _Nullable * _Nullable)errorMessage { + if (dispatched != NULL) *dispatched = NO; if (errorMessage != NULL) *errorMessage = nil; @try { - return RunnerTrySynthesizeTap(application, resolvedWindow, interfaceOrientation, point, deadline, errorMessage); + return RunnerTrySynthesizeTap( + application, resolvedWindow, interfaceOrientation, point, deadline, dispatched, errorMessage + ); } @catch (NSException *exception) { if (errorMessage != NULL) { *errorMessage = RunnerFormatXCTestException(exception, @"private XCTest event synthesis failed"); @@ -221,6 +226,7 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( NSInteger interfaceOrientation, CGPoint point, NSDate * _Nullable deadline, + BOOL * _Nullable dispatched, NSString * _Nullable * _Nullable errorMessage ) { RunnerGestureEventBridge bridge; @@ -247,6 +253,7 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( if (deadline != nil && deadline.timeIntervalSinceNow <= 0) { return RunnerTapSynthesisStatusDeadlineExceeded; } + if (dispatched != NULL) *dispatched = YES; error = RunnerSynthesizeEventRecord(&bridge, record); if (errorMessage != NULL) *errorMessage = error; return error == nil ? RunnerTapSynthesisStatusSucceeded : RunnerTapSynthesisStatusFailed; diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift index e120acfff4a..e777decfa28 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift @@ -244,7 +244,8 @@ extension RunnerTests { } trace.found = "yes" // The synthesized tap returns once the touch is delivered; an XCTest tap would also wait out the - // pop animation, which the bar check below reads sooner. + // pop animation, which the bar check below reads sooner. A refused tap sent nothing, so the swipe + // may still run; a tap that failed after it was handed off throws its unknown outcome instead. guard case .performed = try performSynthesizedTapGesture(app: app, x: frame.midX, y: frame.midY, context: context) else { return nil } trace.pressed = true diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift index cbdc0435094..6ae6112143c 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift @@ -103,9 +103,11 @@ func synthesizedKind(forSequenceStep step: SequenceStep) -> SynthesizedSequenceS /// A synthesized gesture's result for its call site. enum SynthesizedGestureAttempt { case performed(timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double)) - /// Synthesis failed. `refusal` is the producer's `.unsupported` or `.notDispatched` outcome, - /// never `.performed`. No XCTest coordinate gesture replaces it: both routes run through the same - /// testmanagerd event synthesis, and the XCTest route ends the runner test on a tree it cannot read. + /// Synthesis refused before anything was sent. `refusal` is the producer's `.unsupported` or + /// `.notDispatched` outcome, never `.performed`. A failure after the events or HID contact were + /// handed off throws `RunnerGestureOutcomeUnknown` instead. No XCTest coordinate gesture replaces + /// a refusal: both routes run through the same testmanagerd event synthesis, and the XCTest route + /// ends the runner test on a tree it cannot read. case refused( timing: (gestureStartUptimeMs: Double, gestureEndUptimeMs: Double), refusal: RunnerInteractionOutcome diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index 6241f80f679..c854d454e60 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -107,6 +107,7 @@ extension RunnerTests { #if targetEnvironment(simulator) return try simulatorHIDTap(app: app, point: point, resolvedWindow: resolvedWindow, deadline: deadline) #else + var dispatched: ObjCBool = false var message: NSString? let status = RunnerSynthesizedGesture.synthesizeTap( withApplication: app, @@ -114,24 +115,15 @@ extension RunnerTests { interfaceOrientation: orientation, point: point, deadline: deadline, + dispatched: &dispatched, errorMessage: &message ) - switch status { - case .succeeded: - return .performed - case .deadlineExceeded: - return nil - case .failed: - return .unsupported( - message: message as String? ?? "private XCTest event synthesis failed", - hint: "This tap uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists." - ) - @unknown default: - return .unsupported( - message: "private XCTest event synthesis returned an unknown status", - hint: "Inspect the current app before deciding whether to act again." - ) - } + if status == .deadlineExceeded { return nil } + return try Self.synthesizedGestureOutcome( + failure: status == .succeeded ? nil : (message as String? ?? "private XCTest event synthesis failed"), + dispatched: dispatched.boolValue, + refusalHint: "This tap uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists." + ) #endif #elseif os(tvOS) return .unsupported( diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift index cde362becfa..348b8edbf43 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+NavigationTests.swift @@ -4,6 +4,27 @@ import XCTest import ObjectiveC.runtime #endif +#if AGENT_DEVICE_RUNNER_UNIT_TESTS && os(iOS) && targetEnvironment(simulator) +/// Stands in for a prepared `RunnerSimulatorTouch` whose tap contact goes down and then fails. It +/// counts the edge swipes sent through it. +private final class InterruptedTapSimulatorTouch: NSObject { + var swipes = 0 + + @objc(dispatchTapAtPoint:screenSize:touchDown:) + func dispatchTap(at point: CGPoint, screenSize: CGSize, touchDown: UnsafeMutablePointer) -> NSString? { + touchDown.pointee = true + return "contact interrupted by the test" + } + + @objc(dispatchSamples:screenSize:touchDown:) + func dispatch(samples: NSArray, screenSize: CGSize, touchDown: UnsafeMutablePointer) -> NSString? { + swipes += 1 + touchDown.pointee = true + return nil + } +} +#endif + #if AGENT_DEVICE_RUNNER_UNIT_TESTS extension RunnerTests { #if os(iOS) @@ -545,6 +566,23 @@ extension RunnerTests { XCTAssertEqual(status.label, "Back performed", "the swipe itself still ran") } + /// A back button tap whose contact went down and then failed may have popped, so back answers its + /// unknown outcome and never follows it with the edge swipe. + @MainActor + func testInAppBackAfterAnInterruptedBackButtonTapSendsNoSwipe() throws { + _ = try launchBackNavigationFixture(["--agent-device-back-navigation-bar"]) + defer { endBackFixture() } + let touch = InterruptedTapSimulatorTouch() + let restore = try replaceSimulatorTouchPreparation { _, _, _, _ in touch } + defer { restore() } + + XCTAssertThrowsError(try performInAppBack(app: app)) { error in + XCTAssertTrue(error is RunnerGestureOutcomeUnknown, "got \(error)") + } + XCTAssertEqual(lastNavigationBarBackTraceForTesting?.found, "yes", "the tap went to the bar's back button") + XCTAssertEqual(touch.swipes, 0) + } + /// Delays every `XCUIScreen.screenshot` by `seconds`, calling `onCapture` for each. private func slowScreenshots(by seconds: TimeInterval, onCapture: @escaping () -> Void) throws -> () -> Void { let selector = #selector(XCUIScreen.screenshot) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift index 49c6c14f244..287f02803ba 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift @@ -26,9 +26,15 @@ private final class TapRecordSpy: NSObject { static var syntheses = 0 static var recordOrientations: [Int] = [] static var recordReadError: String? + /// Set, the record fails after XCTest was handed it, as a rejected synthesis does. + static var failure: NSError? @objc(synthesizeWithError:) func synthesize(error: AutoreleasingUnsafeMutablePointer?) -> Bool { Self.syntheses += 1 + if let failure = Self.failure { + error?.pointee = failure + return false + } Self.recordReadError = RunnerObjCExceptionCatcher.catchException { if let orientation = self.value(forKey: "interfaceOrientation") as? NSNumber { Self.recordOrientations.append(orientation.intValue) @@ -49,6 +55,7 @@ extension RunnerTests { while Date() < deadline { Thread.sleep(forTimeInterval: 0.001) } prepared = true } + var dispatched: ObjCBool = true var message: NSString? let expired = RunnerSynthesizedGesture.synthesizeTap( withApplication: TapApplicationFixture(), @@ -56,12 +63,14 @@ extension RunnerTests { interfaceOrientation: 1, point: CGPoint(x: 50, y: 50), deadline: deadline, + dispatched: &dispatched, errorMessage: &message ) XCTAssertTrue(preparationBeganBeforeDeadline) XCTAssertTrue(prepared) XCTAssertEqual(expired, .deadlineExceeded) + XCTAssertFalse(dispatched.boolValue, "an expired deadline hands XCTest nothing") XCTAssertNil(message) XCTAssertEqual(TapRecordSpy.syntheses, 0) @@ -71,9 +80,11 @@ extension RunnerTests { interfaceOrientation: 1, point: CGPoint(x: 50, y: 50), deadline: .distantFuture, + dispatched: &dispatched, errorMessage: &message ) XCTAssertEqual(control, .succeeded, message as String? ?? "") + XCTAssertTrue(dispatched.boolValue) XCTAssertEqual(TapRecordSpy.syntheses, 1) } } @@ -87,6 +98,7 @@ extension RunnerTests { interfaceOrientation: 4, point: CGPoint(x: 50, y: 50), deadline: .distantFuture, + dispatched: nil, errorMessage: &message ) XCTAssertEqual(result, .succeeded, message as String? ?? "") @@ -95,6 +107,29 @@ extension RunnerTests { } } + /// A record that fails after XCTest was handed it may have run, so the tap reports it dispatched: + /// the caller answers an unknown outcome and sends no second gesture, such as `back`'s edge swipe. + func testTapRecordThatFailsAfterHandOffReportsItDispatched() throws { + try withTapRecordSpy { + TapRecordSpy.failure = NSError(domain: "RunnerTests", code: 1) + var dispatched: ObjCBool = false + var message: NSString? + let failed = RunnerSynthesizedGesture.synthesizeTap( + withApplication: TapApplicationFixture(), + resolvedWindow: TapWindowFixture {}, + interfaceOrientation: 1, + point: CGPoint(x: 50, y: 50), + deadline: .distantFuture, + dispatched: &dispatched, + errorMessage: &message + ) + XCTAssertEqual(failed, .failed) + XCTAssertTrue(dispatched.boolValue) + XCTAssertNotNil(message) + XCTAssertEqual(TapRecordSpy.syntheses, 1) + } + } + private func withTapRecordSpy(_ body: () throws -> Void) throws { let recordClass = try XCTUnwrap(NSClassFromString("XCSynthesizedEventRecord")) let selector = NSSelectorFromString("synthesizeWithError:") @@ -102,9 +137,12 @@ extension RunnerTests { let spy = try XCTUnwrap(class_getInstanceMethod(TapRecordSpy.self, selector)) let original = method_getImplementation(method) method_setImplementation(method, method_getImplementation(spy)) - defer { method_setImplementation(method, original) } + defer { + method_setImplementation(method, original) + TapRecordSpy.failure = nil + } TapRecordSpy.syntheses = 0 - + TapRecordSpy.failure = nil TapRecordSpy.recordOrientations = [] TapRecordSpy.recordReadError = nil try body() diff --git a/apple/runner/RUNNER_PROTOCOL.md b/apple/runner/RUNNER_PROTOCOL.md index 7fe2ee1d221..92b1ec37d84 100644 --- a/apple/runner/RUNNER_PROTOCOL.md +++ b/apple/runner/RUNNER_PROTOCOL.md @@ -347,7 +347,7 @@ Its shape is `{kind: "reported" | "derived", rect: {x, y, width, height}}` or `derived` and `missing` establish no screen origin. A root box used to validate presented nodes does not upgrade this evidence. -A synthesized long press, scroll, or planned gesture reports how far it got; on iOS the CLI `swipe` is +A synthesized tap, long press, scroll, or planned gesture reports how far it got; on iOS the CLI `swipe` is a planned fling `gesture` that runs as a synthesized drag, so it reports the same way. `SYNTHESIZED_GESTURE_NOT_DISPATCHED` means the iOS event synthesis refused before its event record was handed to XCTest, so the command sent nothing. It also covers a planned gesture refused on iOS while diff --git a/docs/adr/0011-interaction-guarantee-contract.md b/docs/adr/0011-interaction-guarantee-contract.md index 5b11bde6a8c..95a46f5cc7c 100644 --- a/docs/adr/0011-interaction-guarantee-contract.md +++ b/docs/adr/0011-interaction-guarantee-contract.md @@ -447,8 +447,11 @@ Rejected: accessibility activation (`AXElement press`). It reports success on a #### No XCUICoordinate fallback (amendment, 2026-12) This amendment withdraws a permission: a synthesized tap, long press, drag, `sequence` step, or one-contact `gesture` plan may no longer fall back to an `XCUICoordinate` gesture when its XCTest event record is refused. -A synthesis that fails answers its refusal with the synthesis hint. -The code is `SYNTHESIZED_GESTURE_NOT_DISPATCHED` when nothing was sent, and `UNSUPPORTED_OPERATION` otherwise. +A synthesis that fails answers by how far it got, with the synthesis hint, and nothing falls back in either case: +- Nothing sent: the event synthesis refused before it handed XCTest its record, and answers `SYNTHESIZED_GESTURE_NOT_DISPATCHED`. + A check that refuses before the synthesis, such as invalid input or the simulator tap's HID refusal above, keeps `UNSUPPORTED_OPERATION`. +- Sent, then failed: the record or HID contact failed after hand-off, and answers `SYNTHESIZED_GESTURE_OUTCOME_UNKNOWN`. + The gesture may have run, so nothing repeats it, and `back` sends no edge swipe after such a tap. Responses no longer carry the `gestureFallback` wire fields. The reason: both routes go through testmanagerd event synthesis, and they differ only when a private XCTest selector is missing. diff --git a/packages/apple-runner/src/runner-contract.ts b/packages/apple-runner/src/runner-contract.ts index 21735ced1b3..62bc40f39bf 100644 --- a/packages/apple-runner/src/runner-contract.ts +++ b/packages/apple-runner/src/runner-contract.ts @@ -114,7 +114,7 @@ export const SCROLL_KEYBOARD_OCCLUDES_SURFACE_RUNNER_CODE: RunnerTableErrorCode 'SCROLL_KEYBOARD_OCCLUDES_SURFACE'; /** - * The runner codes for a synthesized long press, scroll, or planned gesture on iOS; the CLI `swipe` is + * The runner codes for a synthesized tap, long press, scroll, or planned gesture on iOS; the CLI `swipe` is * a planned fling gesture. Both are rows of {@link RUNNER_ERROR_CODES}. * NOT_DISPATCHED: the event synthesis refused before any of its events reached XCTest, so the * command sent nothing. OUTCOME_UNKNOWN: failed after its events reached XCTest, so it may have run; From 071b487dbd270e146097b4f7096f2290e5a43010 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 12:20:46 +0100 Subject: [PATCH 3/4] refactor(ios-runner): report a tap that failed after hand-off as its own status The tap synthesis status now carries the dispatch stage, so the dispatched out-parameter leaves the tap API, and the unit tests share one tap helper. This clears the native-dupes clones. Co-Authored-By: Claude Sonnet 5.5 --- .../RunnerSynthesizedGesture.h | 4 +- .../RunnerSynthesizedGesture.m | 15 ++--- .../RunnerTests+SynthesizedInteraction.swift | 4 +- .../RunnerTests+SynthesizedGestureTests.swift | 67 +++++++------------ 4 files changed, 34 insertions(+), 56 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h index 8ef00f4ba43..14a58f59e46 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h @@ -8,7 +8,10 @@ FOUNDATION_EXPORT double RunnerControlledScrollProgress(double t); typedef NS_ENUM(NSInteger, RunnerTapSynthesisStatus) { RunnerTapSynthesisStatusSucceeded, RunnerTapSynthesisStatusDeadlineExceeded, + // The record failed before XCTest was handed it, so nothing ran. RunnerTapSynthesisStatusFailed, + // The record failed after XCTest was handed it, so the tap may have run. + RunnerTapSynthesisStatusFailedAfterHandOff, }; typedef struct { @@ -37,7 +40,6 @@ typedef struct { interfaceOrientation:(NSInteger)interfaceOrientation point:(CGPoint)point deadline:(NSDate * _Nullable)deadline - dispatched:(BOOL * _Nullable)dispatched errorMessage:(NSString * _Nullable * _Nullable)errorMessage; // Each pointer is an ordered array of { x, y, offsetMs } samples. The first sample diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m index 10bf347120a..1135cf09895 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m @@ -74,7 +74,6 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( NSInteger interfaceOrientation, CGPoint point, NSDate * _Nullable deadline, - BOOL * _Nullable dispatched, NSString * _Nullable * _Nullable errorMessage ); // XCTest's proven swipe profile reaches the endpoint in 100 ms, then holds for the planned @@ -112,13 +111,11 @@ + (RunnerTapSynthesisStatus)synthesizeTapWithApplication:(id)application interfaceOrientation:(NSInteger)interfaceOrientation point:(CGPoint)point deadline:(NSDate * _Nullable)deadline - dispatched:(BOOL * _Nullable)dispatched errorMessage:(NSString * _Nullable * _Nullable)errorMessage { - if (dispatched != NULL) *dispatched = NO; if (errorMessage != NULL) *errorMessage = nil; @try { return RunnerTrySynthesizeTap( - application, resolvedWindow, interfaceOrientation, point, deadline, dispatched, errorMessage + application, resolvedWindow, interfaceOrientation, point, deadline, errorMessage ); } @catch (NSException *exception) { if (errorMessage != NULL) { @@ -226,7 +223,6 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( NSInteger interfaceOrientation, CGPoint point, NSDate * _Nullable deadline, - BOOL * _Nullable dispatched, NSString * _Nullable * _Nullable errorMessage ) { RunnerGestureEventBridge bridge; @@ -253,10 +249,13 @@ static RunnerTapSynthesisStatus RunnerTrySynthesizeTap( if (deadline != nil && deadline.timeIntervalSinceNow <= 0) { return RunnerTapSynthesisStatusDeadlineExceeded; } - if (dispatched != NULL) *dispatched = YES; - error = RunnerSynthesizeEventRecord(&bridge, record); + @try { + error = RunnerSynthesizeEventRecord(&bridge, record); + } @catch (NSException *exception) { + error = RunnerFormatXCTestException(exception, @"private XCTest event synthesis failed"); + } if (errorMessage != NULL) *errorMessage = error; - return error == nil ? RunnerTapSynthesisStatusSucceeded : RunnerTapSynthesisStatusFailed; + return error == nil ? RunnerTapSynthesisStatusSucceeded : RunnerTapSynthesisStatusFailedAfterHandOff; } static NSString * _Nullable RunnerResolveGestureEventBridge( diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift index c854d454e60..6db43e5bbf1 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift @@ -107,7 +107,6 @@ extension RunnerTests { #if targetEnvironment(simulator) return try simulatorHIDTap(app: app, point: point, resolvedWindow: resolvedWindow, deadline: deadline) #else - var dispatched: ObjCBool = false var message: NSString? let status = RunnerSynthesizedGesture.synthesizeTap( withApplication: app, @@ -115,13 +114,12 @@ extension RunnerTests { interfaceOrientation: orientation, point: point, deadline: deadline, - dispatched: &dispatched, errorMessage: &message ) if status == .deadlineExceeded { return nil } return try Self.synthesizedGestureOutcome( failure: status == .succeeded ? nil : (message as String? ?? "private XCTest event synthesis failed"), - dispatched: dispatched.boolValue, + dispatched: status == .failedAfterHandOff, refusalHint: "This tap uses private XCTest event-synthesis APIs; rebuild the runner with a supported Xcode if this persists." ) #endif diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift index 287f02803ba..ee8f31c76d3 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedGestureTests.swift @@ -55,36 +55,17 @@ extension RunnerTests { while Date() < deadline { Thread.sleep(forTimeInterval: 0.001) } prepared = true } - var dispatched: ObjCBool = true var message: NSString? - let expired = RunnerSynthesizedGesture.synthesizeTap( - withApplication: TapApplicationFixture(), - resolvedWindow: window, - interfaceOrientation: 1, - point: CGPoint(x: 50, y: 50), - deadline: deadline, - dispatched: &dispatched, - errorMessage: &message - ) + let expired = synthesizeTap(window: window, deadline: deadline, message: &message) XCTAssertTrue(preparationBeganBeforeDeadline) XCTAssertTrue(prepared) XCTAssertEqual(expired, .deadlineExceeded) - XCTAssertFalse(dispatched.boolValue, "an expired deadline hands XCTest nothing") XCTAssertNil(message) XCTAssertEqual(TapRecordSpy.syntheses, 0) - let control = RunnerSynthesizedGesture.synthesizeTap( - withApplication: TapApplicationFixture(), - resolvedWindow: TapWindowFixture {}, - interfaceOrientation: 1, - point: CGPoint(x: 50, y: 50), - deadline: .distantFuture, - dispatched: &dispatched, - errorMessage: &message - ) + let control = synthesizeTap(message: &message) XCTAssertEqual(control, .succeeded, message as String? ?? "") - XCTAssertTrue(dispatched.boolValue) XCTAssertEqual(TapRecordSpy.syntheses, 1) } } @@ -92,44 +73,42 @@ extension RunnerTests { func testSynthesizedRecordKeepsTheConvertedPointsOrientation() throws { try withTapRecordSpy { var message: NSString? - let result = RunnerSynthesizedGesture.synthesizeTap( - withApplication: TapApplicationFixture(), - resolvedWindow: TapWindowFixture {}, - interfaceOrientation: 4, - point: CGPoint(x: 50, y: 50), - deadline: .distantFuture, - dispatched: nil, - errorMessage: &message - ) + let result = synthesizeTap(interfaceOrientation: 4, message: &message) XCTAssertEqual(result, .succeeded, message as String? ?? "") XCTAssertNil(TapRecordSpy.recordReadError) XCTAssertEqual(TapRecordSpy.recordOrientations, [4]) } } - /// A record that fails after XCTest was handed it may have run, so the tap reports it dispatched: + /// A record that fails after XCTest was handed it may have run, so the tap reports that stage: /// the caller answers an unknown outcome and sends no second gesture, such as `back`'s edge swipe. - func testTapRecordThatFailsAfterHandOffReportsItDispatched() throws { + func testTapRecordThatFailsAfterHandOffReportsTheHandOffStage() throws { try withTapRecordSpy { TapRecordSpy.failure = NSError(domain: "RunnerTests", code: 1) - var dispatched: ObjCBool = false var message: NSString? - let failed = RunnerSynthesizedGesture.synthesizeTap( - withApplication: TapApplicationFixture(), - resolvedWindow: TapWindowFixture {}, - interfaceOrientation: 1, - point: CGPoint(x: 50, y: 50), - deadline: .distantFuture, - dispatched: &dispatched, - errorMessage: &message - ) - XCTAssertEqual(failed, .failed) - XCTAssertTrue(dispatched.boolValue) + let failed = synthesizeTap(message: &message) + XCTAssertEqual(failed, .failedAfterHandOff) XCTAssertNotNil(message) XCTAssertEqual(TapRecordSpy.syntheses, 1) } } + private func synthesizeTap( + window: AnyObject = TapWindowFixture {}, + interfaceOrientation: Int = 1, + deadline: Date = .distantFuture, + message: inout NSString? + ) -> RunnerTapSynthesisStatus { + RunnerSynthesizedGesture.synthesizeTap( + withApplication: TapApplicationFixture(), + resolvedWindow: window, + interfaceOrientation: interfaceOrientation, + point: CGPoint(x: 50, y: 50), + deadline: deadline, + errorMessage: &message + ) + } + private func withTapRecordSpy(_ body: () throws -> Void) throws { let recordClass = try XCTUnwrap(NSClassFromString("XCSynthesizedEventRecord")) let selector = NSSelectorFromString("synthesizeWithError:") From 75aa7128f9fe7bd5d1afe268e8e00eb532e47b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 3 Dec 2026 12:34:13 +0100 Subject: [PATCH 4/4] refactor(ios-runner): name the profiled coordinate drag hold and fix stale policy docs Off iOS no synthesized lane exists, so a caller that passes a drag profile still performs the XCTest coordinate drag; the branch stays and its hold helper no longer implies a removed fallback. ADR 0011 now names only the rules the Swift policy file still owns. Co-Authored-By: Claude Sonnet 5.5 --- .../RunnerTests+GestureExecution.swift | 4 +++- .../RunnerTests+ScrollDragExecution.swift | 5 +++-- docs/adr/0011-interaction-guarantee-contract.md | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift index 427ddef2c91..11795adbbbc 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+GestureExecution.swift @@ -12,7 +12,9 @@ extension RunnerTests { return (gestureStartUptimeMs, currentUptimeMs()) } - func synthesizedSwipeFallbackHoldDuration(durationMs: Double) -> TimeInterval { + /// The hold of an XCTest coordinate drag a caller asked to run as a synthesized swipe, which only + /// platforms without the synthesized lane perform. + func profiledCoordinateDragHoldDuration(durationMs: Double) -> TimeInterval { min(max((durationMs / 5.0) / 1000.0, 0.016), 0.120) } diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift index 0f1223ab428..9e83700a367 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift @@ -66,7 +66,8 @@ extension RunnerTests { /// Shared coordinate drag execution. On iOS, callers that pass `synthesizedProfile` take the /// synthesized lane with that profile, and a failed synthesis refuses; the rest perform an XCTest - /// coordinate drag. + /// coordinate drag. Off iOS no synthesized lane exists, so every caller performs the XCTest + /// coordinate drag, with the profile only choosing its hold. @MainActor func executeDragGesture( activeApp: XCUIApplication, @@ -108,7 +109,7 @@ extension RunnerTests { y2: y2, holdDuration: synthesizedProfile == nil ? coordinateDragHoldDuration() - : synthesizedSwipeFallbackHoldDuration(durationMs: durationMs), + : profiledCoordinateDragHoldDuration(durationMs: durationMs), message: message ) } diff --git a/docs/adr/0011-interaction-guarantee-contract.md b/docs/adr/0011-interaction-guarantee-contract.md index 95a46f5cc7c..b06a19fa566 100644 --- a/docs/adr/0011-interaction-guarantee-contract.md +++ b/docs/adr/0011-interaction-guarantee-contract.md @@ -398,8 +398,8 @@ The element dispatch-path matrix above intentionally does not include synthesize - Synthesized `sequence` tap/drag steps. They do not resolve selectors or refs, so a claim of the element-targeting guarantees would be misleading. -Their AX-health, keyboard-probe, frame-source, and activation-preflight rules stay runner-local in `RunnerTests+SynthesizedGesturePolicy.swift`. -That Swift policy is the source of truth, because the current table has only two behaviors: +Their AX-health, window-source, and keyboard-probe rules stay runner-local in `RunnerTests+SynthesizedGesturePolicy.swift`. +That Swift file is the source of truth for keyboard probing, because the current table has only two behaviors: - A coordinate synthesized tap never probes keyboards. This applies to a standalone tap and a `sequence` step.