Repository navigation
iPhone tests: deterministic audits and timers, no re-run fallbacks - #447
Merged
Merged
Conversation
auditScrolling reached each page with swipeUp, a fling that travels as far as the touch events' timing makes it, so a slow CI runner audited each page at a slightly different scroll position. The two audits that still failed intermittently both sat on that edge: testConsent's "Text clipped" on a row whose y moved 181.7–184 between failures, by the bar's scroll-edge band, and testSettings' "Dynamic Type unsupported" on the rows beside the tab bar at the foot of the last page (7 of ~74 completed check.yml runs, Nov 25–27, 4 of them merge-queue ejections). Pages are now reached by a slow drag that holds still before lifting (`drag`), so every run audits the same screens; scrollTo uses the same drag. Removed the fallbacks that re-ran something hoping for a different answer: the second tap on testConsent's switch, the re-run of an audit pass XCTest timed out on, and the second audit whose findings had to repeat. A ScalingCheck failure now says what it measured: the text's height at the default size and at the largest, or that it never came fully into view there, since the log line is all a CI failure leaves most readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
Two iPhone unit tests timed out at random after #439, each waiting its whole 30 s `until` for a state that had already passed or never came: - acceptedPress: FakeListeningSource held a press's start for 200 ms of wall time to make `.connecting` visible, while the test polled for it on the main actor. On a loaded runner the main actor was busy past 200 ms, `.connecting` gave way to `.recording` unseen, and the test failed at ~40 s (run 45935799021, ios-build). The fake now holds start() until the test calls releaseStart(), so the phase lasts until it has been checked. - windowMinutesChanged: the test advanced the clock as soon as the record showed the shorter window, but the expiry timer is a task that parks on the clock when it next runs. Advanced first, it parked a minute past the step and never fired (same run, ios-sanitizers address). WindowRig.step(_:once:) advances only once a timer due within the given range has parked, bounded as `until` is; beat() is that for one heartbeat. Every heartbeat and resume-poll step in the window tests uses them, the unbounded waitUntilSleeping included, since these suites carry no .timeLimit to end a sleeper that never arrives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
The window and the coordinator still read the device's time beside the
clock they are given, and the fakes still modelled slow steps with real
sleeps:
1. ListeningWindow takes `now`, as DictationCoordinator does, and stamps
its records and measures its expiry from it rather than Date(). The app
passes { Date() }; WindowRig passes the rig's build time moved on only
by its TestClock, so a one-minute expiry sleeps a minute on the clock
(to a Date's rounding) and windowMinutesChanged waits for a timer due
59–60 s out, not 50–60. The window tests read the lease against rig.now.
2. FakeListeningSource's closeDelay and FakeIdle's closingDelay become
holds the test releases (Hold, which the start hold now uses too).
pressWhileClosing polled for `.closing` across a 400 ms real sleep, the
same race acceptedPress had; reopenDuringClose and
hopWaitsForTheIdleMode now also check the window waits while held,
which a delay could only let pass unproven.
3. The coordinator's recordingSince, spoken duration and phase stamp use
its injected `now`, and the meter's 80 ms throttle times itself on its
injected clock (still ContinuousClock in the app) rather than Date(),
which can jump back and freeze the meter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
The keyboard fuzz's recovery test ("from any state, an appearance is a
clean keyboard that can dictate") ran on the wall clock so its dying app's
record could age by Date(). On a stalled runner (24 s for the test, run
45717226112) the 1.2 s press deadline passed between a tap and its started
ack: the ack landed on an expired press, and the second tap went out as a
new press with no dictation, the two failures that run recorded. It now
keeps the rig's held time, and KeyboardRig.record/listening age the record
against it (`now:`), so the lease still lapses and nothing else can.
Every remaining TestClock.waitUntilSleeping in the iPhone tests becomes
`parked(on:for:)`, the same wait bounded as `until` is: these suites carry
no .timeLimit, so a timer that never parked hung the run instead of failing
its test.
From the concurrency review of the previous commit: Hold documents that a
held step must be released on every path, and reopenDuringClose drops an
assertion that held whether or not the close was held.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
…g fixes #445 excused "text clipped" on the consent sheet's four disclosure rows, from the audit's own screenshot showing the row whole. With #447's fixed drag, run 46010398262 (ios-audits a) put the row mid-screen at y 316.7 and the audit still raised it: it was never about the bar's edge, the fling only sometimes parked the row under the bar, where it was excused anyway. The exception is the fix; its comment now says the finding is consistent. #445 also fixed acceptedPress (the start delay on the rig's TestClock) and windowMinutesChanged (waiting for an expiry parked 30–60 s out). This branch's versions replace both — the start held until the test releases it, the expiry exactly a minute on the window's injected clock — so the four conflicted test files keep this branch's side; main's diff to them was only those two fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
ios-static's build (run 46012952910) refused `Self.stopwatch(on: clock)` in the level loop: "type 'any Clock<Duration>' cannot conform to 'Clock'" — Xcode's compiler would not open the stored existential there, though it opened the init's `clock` parameter in the same call. The generic is now called only in init, as `stopwatches(on:)`, and returns a maker the loop calls for each new stopwatch. swiftlint analyze: DictationCoordinator+Publish.swift no longer needs Foundation now that it stamps the phase with `now()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
ios-sanitizers (address), run 46014211769: "cannot find type 'Date' in scope" at WindowRig's `var now: Date`. The rig named no Foundation type before this PR, and MemberImportVisibility wants each file to import what it names itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
ios-static's periphery (run 46015518999) found TestClock's waitUntilSleeping unused: this PR moved every iPhone test onto the bounded parked(on:for:), and the iPhone scan indexes this shared stub with only the iPhone tests. The engine's tests still call it (22 times), under suites with a .timeLimit; marked with the repo's cross-scan periphery:ignore, above the doc comment as the repo places it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
3 tasks done
3 tasks done
alexkroman
pushed a commit
that referenced
this pull request
Nov 27, 2026
…hange
The audit timeouts ("Audit failed to complete in time", -56) hit the first
test of a shard: testSetupWithKey in #451's queue run (46055375031), and
testConsent and testSetupWithKey in the runs that added the re-run #447
removed. That test pays for the runner installing the app afresh (~20 s
in #451's recording) and the cold first launch after it, and the audit
read the hierarchy while the app was still coming up.
The class's setUp now launches the app once and waits for its screen to
hold still before any test (`warmFirstLaunch`), so no test's screen is the
cold launch; and audit() snapshots until the screen holds still before it
reads it, as auditScrolling already did for every page but the first.
Both are bounded waits for a state, not a re-run: a screen that never
settles still gets audited, and a pass that times out still fails.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
This fixes several sources of random red on the iPhone jobs. Each one is fixed at its cause, never by re-running or retrying.
1. Accessibility audits (
ios-audits, shard a)Across the last 100
check.ymlruns (Nov 25–27), 7 of the ~74 that finished failed on two audit findings. 4 of those were merge-queue runs, where a failure ejects the PR:testSettings, 4 runs: "Dynamic Type unsupported" on Settings page 3's last rows.testConsent, 3 runs: "Text clipped" on "The text just before your cursor".auditScrollingpaged withswipeUp(), a fling, so a slow runner audited each page at a slightly different scroll position.Changes
drag).scrollTouses it too. The page limit goes from 16 to 24.ScalingCheckfailure gives the measured heights, or says the text was never fully in view.testConsent, the re-run after an audit timeout, and the second audit pass whose findings had to repeat.What the fixed paging showed: this PR's first run put the consent row mid-screen (y 316.7), and the audit still flagged it. So that finding was never about the bar's edge: it had only passed when the fling left the row under the bar, where it was excused. #445, merged into this branch, already excuses the four consent rows by their exact text, based on the audit's own screenshot showing the row whole. Its comment now says the finding is consistent, not intermittent.
2. Unit-test timing races (
ios-build,ios-sanitizers)acceptedPress.connectinglasted a 200 ms real sleep, and the test's poll missed itstart()until the test callsreleaseStart()windowMinutesChangedWindowRig.step)pressWhileClosingacceptedPress.closingthat lasted a 400 ms real sleeprecovers(keyboard random-sequence test).pressinstead of.release, and a missing dictation id (run 45717226112, 24 s)#445 also fixed
acceptedPressandwindowMinutesChanged, a different way. This PR's versions replace both.Shared changes
Holdtype replaces every real sleep in the fakes: start, close and the idle mode's close.WindowRig.step/beat(). Every iPhoneTestClock.waitUntilSleepingbecomesparked(on:for:), the same wait capped likeuntil. The engine's tests keepwaitUntilSleeping, since their suites have a.timeLimit; it's marked with the cross-scanperiphery:ignore.3. App code: no wall-clock reads beside the injected clock
ListeningWindowtakesnow, asDictationCoordinatordoes, and no longer readsDate()for its records or its expiry. The app passes{ Date() }.now. The 80 ms meter throttle times itself on the injected clock, which is stillContinuousClockin the app.The app's behavior is unchanged. A Swift 6 concurrency review found no issues.
Caveat: the coordinator tests now run on two time bases. The coordinator's
nowis frozen, while the window's moves with the test clock. No current test depends on this. A future test that feeds coordinator snapshots into aKeyboardModelwould see identicalatstamps, which the model uses as a notice's identity.What to watch:
DictationCoordinator.swiftis at 396 of its 400-line limit, so a parallel PR that grows it could fail the size check.How it was tested
Written in a Linux sandbox, which can't build or run the iPhone app or tests. CI on
e8051d5is green across every job: the iPhone audits, unit tests and both sanitizers,ios-static,live-tests, and the Mac jobs. Locally: swift-format,swiftlint lint --strict, the size, lint-lite and test-clock checks, andscripts/check.sh --portableall pass.scripts/check.shpasses (or CI will, if I'm not on a Mac)🤖 Generated with Claude Code
https://claude.ai/code/session_01DS5B1Thm9A5RTqE6KU3jvP