Skip to content

feat(audit): run Apple's native accessibility checks on iOS - #4776

Merged
thymikee merged 7 commits into
mainfrom
feat/audit-platform-ios
Nov 20, 2026
Merged

thymikee merged 7 commits into
mainfrom
feat/audit-platform-ios

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

On an iOS 17+ target served by the XCTest runner, audit now also runs Apple's accessibility audit and prints its findings with the heuristic ones. There is no flag. Other targets, and iOS before 17, return the heuristic findings alone.

Only Apple's five read-only checks run (contrast, element detection, hit region, description, trait). Dynamic Type and clipped-text are left out: they resize the app's text while they run. A native hit region on the frame of a small-target finding is dropped. Native findings print in a stable order. Part of #4761.

Before / after

agent-device audit   # iOS Settings, simulator

Before: 4 warnings, 1 observation.
After: 8 warnings, 1 observation. Added lines:

native  contrast  Contrast failed for element  @e46~s773569 text "StandBy"  [29.7,756 106.7×29]
native  trait  The accessibilityLabel of this element duplicates information that is available in the traits.  [16,484.3 370×52]

With a system alert over the app, after:

Error (COMMAND_FAILED): A system alert covers the app, so the accessibility audit did not run: Allow “Maps” to use your location? Not dispatched. Next: Run agent-device alert accept or agent-device alert dismiss, then run agent-device audit again.

Runner build progress, before: Building Apple runner.... After: Building Apple runner (one-time per agent-device version)....

Validation

Head 4a92fbfbcf7da9e88f91e85065b9a7031e66a70e.

  • pnpm check:affected --run: all checks passed except unit. There, 2 of 21,401 tests timed out on a host at load 36; both pass alone and are unrelated. The last full pass was at a7c8277505.
  • Live on the audit-platform-ios simulator (iOS 26.2) with the branch-built CLI: evidence. Warm audit takes 1.0–1.8 s; the first one after a runner build took 29 s.
  • Three audit XCTest unit tests passed on that simulator at df8dbd23ae; the alert branch has no unit test and was verified live only.
  • CI must pass at this head, including Apple Smoke Tests and Runner Build.

Risks: physical devices and iOS before 17 were not run live.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.46 MB 6.47 MB +10.5 kB
Package (unpacked) 6.46 MB 6.47 MB +10.5 kB
Package (download) 1.97 MB 1.97 MB +3.1 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 23.7 ms 26.6 ms +2.8 ms
CLI --help 50.0 ms 56.2 ms +6.1 ms

@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 4 new findings on 802f5fc. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

802f5fc has no code defects, and all 20 checks pass. The committed evidence files were recorded at 1c77d4b, and the only production change since then is one dropped export, so they still apply. Physical iOS devices with the XCTest runner are documented as supported but were not verified live, and it is not yet shown whether the dynamicType pass in performAccessibilityAudit leaves transient UI state that the following heuristic capture sees. The branch now conflicts with main.

Before merge, the design question below needs an answer, and the open threads on the audit result name check and the raw rect numbers in the text output should be fixed. The two inline threads on snapshot ordering and unknown names still stand, along with the raw rect numbers in the text output. The memo reuse thread does not apply: the memo is bound per request, so findings are reused only across capture attempts inside one command, and you can resolve it.

Could one platform operation, accessibilityAudit(input) -> NativeAuditFinding[], on PlatformRuntimeOperations replace the current piggyback on snapshot capture? platform-apple would admit it through facts only for runner-served iOS targets, and auditSnapshotCommand would call it once after the heuristic capture when nativeAudit is set. A missing admission would return the typed UNSUPPORTED_OPERATION. This would delete CaptureSnapshotInput.nativeAudit, the annotation field, the per-request memo, the daemon predicate copy and the owner-missing check, and it would fix the audit-before-snapshot ordering. Size stays about the same, but the rule has one owner. Nothing has to change first, because the operation admission mechanism already exists.

Not blocking, take or leave: the runner-served iOS predicate and its refusal message are written in both snapshot-runtime-binding.ts and native-audit.ts, and one predicate exported from platform-apple would give the rule one owner. Native hitRegion findings repeat the heuristic small-target finding for the same rect (the Dictate button in native.txt counts twice in the warning total), so either document the overlap or omit the duplicate. The help text says to match a finding's rect against a fresh snapshot, but Apple often sends no rect (all three contrast findings in the evidence), so add one sentence saying a finding without a rect names no element and should be reported, not acted on. The value as cast after startsWith at native-audit.ts:79 does not narrow, so a type guard or the unknown-name mapping from the open thread would cover it.

@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from 802f5fc to 6e39135 Compare November 19, 2026 22:14
@thymikee
thymikee marked this pull request as draft November 19, 2026 22:15
@thymikee

thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member Author

Rebased on main. Native audit is now one admitted accessibilityAudit operation for runner-served iOS. Heuristic capture and evaluation run first. Apple is called once afterward. Snapshot piggybacking, annotations, the memo, the duplicate predicate, and the capture-owner check are gone.

The four threads are fixed and resolved with SHA replies. Capture ordering is tested. Unknown names map to unknown:. Text rects round to one decimal. Unique frame matches include a pinned ref, role, and accessible name. Ambiguous matches stay unbound.

All recommendations were taken. One exported predicate owns admission. The hitRegion/small-target overlap is documented and retained. Help says findings without rects are report-only. A type guard replaces the cast.

Validation passed: 94 focused unit tests, four provider scenarios, and six XCTest tests. Provider scenarios cover audit before an explicit snapshot, ordering, repeated calls, unknown names, and native-only ref use. The final foreground gate passed all 42 runnable checks with exactCommit=true. Full unit results: 21,114 passed, 10 skipped. Receipt: .tmp/validation/run-HGhgYn/receipt.json.

Final-head live contrast evidence is blocked. The required T3 CLI 0.21.36 rejects --native and audit. Cleanup used close --shutdown. Old evidence keeps its original SHA. The evidence README records the gap. The PR is draft pending fresh live evidence.

Hosted Apple smoke is incomplete. Its aggregate failed with RESULT: cancelled from the cancelled child jobs. Other hosted checks and fresh review remain pending.

SHA: 6e39135.

@thymikee

Copy link
Copy Markdown
Member Author

Live evidence at the final head 6e39135, branch-built node bin/agent-device.mjs with its own daemon. Simulator audit-platform-ios (iPhone 17, iOS 26.2), Settings app.

  • audit --native ran as the first command after open, with no snapshot before it. It returned the heuristic and native findings together (exit 0), so the audit-before-snapshot ordering works.
  • Native contrast findings now carry the matched snapshot ref, role and name, with rounded rects: @e46~s755880 text "StandBy" [29.7,756 106.7×29].
  • The native hitRegion frame matches both "Dictate" buttons (same frame), so it prints no ref, by the unique-match rule. Its rect still prints rounded in text; JSON keeps the raw frame.
  • Plain audit on the same screen: 4 warnings, 1 observation. audit --native: 9 warnings, 1 observation (the 5 extra are native).
audit --native (text)
agent-device audit
9 warnings, 1 observation — current screen
@e48~s755880  covered-control  cell  Accessible action is unavailable to touch
@e56~s755880  small-target     button "Dictate"  17.3×22pt, below 44×44pt
@e56~s755880  ambiguous-name   button "Dictate"  Name shared by 2 controls of this role
@e58~s755880  small-target     button "Dictate"  17.3×22pt, below 44×44pt
@e58~s755880  ambiguous-name   button "Dictate"  Name shared by 2 controls of this role
native  hitRegion  The size of this element is too small for user to interact.  [335.7,811 17.3×22]
native  trait  The accessibilityLabel of this element duplicates information that is available in the traits.  [16,484.3 370×52]
native  contrast  Contrast is not high enough for element unless font size is larger.  @e10~s755880 text "Sign in to access your iCloud data, the App Store, Apple services, and more."  [100,209.7 236×33.7]
native  contrast  Contrast failed for element  @e46~s755880 text "StandBy"  [29.7,756 106.7×29]
native  contrast  Contrast failed for element  @e50~s755880 text "Screen Time"  [29.7,843 137.7×29]

covered-control: Move the control out from under the cover. If the cover can be dismissed, such as a sheet or dialog, dismiss it before you use the control.
small-target: Apple HIG recommends 44×44pt. Enlarge the touch area with padding, a minimum size, or hitSlop.
ambiguous-name: Give each control a unique label that names its target, for example "Save Lemon Herb Rice".

@thymikee
thymikee marked this pull request as ready for review November 19, 2026 22:20
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 3 new findings on 6e39135. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The code at 6e39135 is ready. The earlier review's concerns are fixed: the per-request memo and snapshot piggyback are gone, native audit now runs after heuristic capture as its own operation, rects print with one decimal, and unrecognised names map to unknown:<name>. The live run posted in #4776 (comment) covers the final head, and that comment is where the live output is quoted. Physical-device runs and the XCTest run are author-reported only.

The hosted Apple jobs (Smoke Tests ios and macos, Runner Build for tvOS, visionOS and watchOS) were cancelled, not run, so no job reported a test or build failure. This diff touches the runner command, RunnerSurfacePolicy and the Models tables that every Apple job builds, so please re-run them to green before merge.

Not blocking, take or leave: the evidence README at docs/evidence/ios-native-audit-2026-11-19/README.md line 9 still says live contrast evidence is blocked, and the PR body still says draft pending live evidence. Replacing both with the final-head run would make them match.

The open inline threads on a position tolerance constant and on a missing ref fallback still stand as low-priority notes. The thread on --native replay and MCP does not apply: audit is not a recorded command, and MCP options reach the native audit. The threads at #4776 (comment), #4776 (comment), #4776 (comment) and #4776 (comment) are fixed at this head and can be resolved.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 finding moved to a new line on dc09d59. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

Still ready at dc09d59. The change since 6e39135 only updates the evidence folder: the README and the raw heuristic and native outputs now cite the final-head live run. No code changed, and the label stays.

@thymikee

Copy link
Copy Markdown
Member Author

This now conflicts with main. Please rebase. The code verdict at dc09d59 stands, so a clean rebase gets the label back without a new review.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from dc09d59 to b3d3514 Compare November 20, 2026 07:48
@thymikee

Copy link
Copy Markdown
Member Author

Rebased onto main (115c83a) at b3d3514.

  • I squashed the branch to one commit before the rebase, because each commit conflicted in the same two files. The squashed tree equals dc09d59.
  • Conflicts: the runtime import now reads auditSnapshotState (merged feat(audit): evaluate role-less clickable views on Android #4780) and matchNativeAuditFindings; the audit description and cliDetail keep main's text plus this PR's three --native sentences.
  • One follow-up commit for R89 (chore(gates): ratchet untyped reason literals per file (R89) #4779, merged after dc09d59): native-audit-invalid-result was a call-site literal in three places. It is now published from a typed NATIVE_AUDIT_FAILURES table, and commands.md documents it. No behavior change.
  • check:affected --run passed with exactCommit=true. The Apple jobs need to run again on this head; they passed at 6e39135.

@thymikee

Copy link
Copy Markdown
Member Author

Ready again at b3d3514. The rebase onto main is clean. It follows main's auditSnapshotState rename, and the new commit publishes native-audit-invalid-result from a typed NATIVE_AUDIT_FAILURES table, so the R89 untyped-reason rule from #4779 passes. The rest of the patch matches dc09d59, and the earlier code verdict stands.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

This now conflicts with main. Please rebase. The earlier review at b3d3514 still stands for the code.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from b3d3514 to 5bd1013 Compare November 20, 2026 12:34
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 finding moved to a new line on 5bd1013. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The code in 5bd1013 is ready. The conflict from the earlier review (#4776 (comment)) is gone, and there are no conflicts now.

Not blocking, and you can take or leave it: heuristicFindings in snapshot-audit.ts defaults to [], so if the caller in snapshot.ts dropped its third argument, no unit test would fail and the dedupe would silently stop. Making the parameter required would force every caller to pass it, or one command-runtime test where a native hit region shares a small-target frame would cover the wiring.

The Runner Build (tvOS + visionOS + watchOS) check failed in "Restore and build visionOS XCTest runner" because the runner could not find action.yml for actions/cache. That is a runner fault before any build step, not the Swift change, and the job is rerunning. It should be green before merge, since this PR changes the Swift runner.

On the open threads: the one on audit-output.ts does not apply, because refsGeneration is attached whenever a finding carries a ref, so the daemon route cannot reach the dropped-ref state (#4776 (comment)). Please resolve it.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from 5bd1013 to 5d4f3f8 Compare November 20, 2026 13:40
@thymikee thymikee changed the title feat(audit): add native iOS accessibility checks feat(audit): run Apple's native accessibility checks on iOS Nov 20, 2026
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding and 2 moved to a new line on 5d4f3f8. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

The PR is ready at 5d4f3f8. The earlier review of 5bd1013 found no problems, and nothing has regressed since. The Swift alert catch branch has a live alert-blocked.txt run but no Swift unit test. iOS before 17 and physical xctest devices were not run live. The swallow path is covered by native-audit.test.ts with a production-shaped error.

Not blocking: the docs line says a pre-iOS 17 runner reports native_audit_unavailable, but native-audit.ts swallows that error and returns no findings, so callers never see it. Consider "Before iOS 17, audit returns the heuristic findings alone", or surface an audit limitation instead. Take it or leave it.

The open inline thread on audit-output.ts:98-102 does not apply, because snapshot-audit-runtime.ts attaches refsGeneration whenever a finding carries a ref, so the daemon route never sees an undefined generation. You can resolve it: #4776 (comment)

No conflicts. The 19 test and build checks pass, including the Apple runner build and smoke jobs.

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from bc4f28b to a7c8277 Compare November 20, 2026 14:50
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

The ordering fix from 6d08076 is in at a7c8277, and the native findings are now sorted before printing, with a test for both input orders. One tie in that sort still leaves the order unstable.

compareNativeAuditFindings treats two findings with the same audit type, x, y and description as equal, even when width or height differs. The sort is stable, so such a pair keeps the order the runner sent. An in-memory run of the collector, matcher and formatter with two contrast issues at (10,20) with the same description and frames 30×44 and 60×44 printed the rows reversed when the runner sent them in reverse. The same unchanged screen can then print in a different order in JSON and CLI text, which breaks the stable-list promise in commands.md. Please compare rect width and height after description, and extend the reversed-input test with a pair that shares check, origin and description but differs in size, asserting the ordered rects.

The open thread on dropped refs does not apply: the ref is left out without a refs generation because pinnedRefText refuses to print an unpinned ref, the same rule the heuristic lines follow, and the rect is still printed. The open thread on frame matching does not apply either: Apple and the snapshot report frames in the same points, and a ref attaches only on exactly one match, so the 0.5pt tolerance cannot attach a wrong ref. The thread on Apple's order is fixed by the sort above. Please resolve all three.

Not verified here: the runner error-code generator and the unit tests were not run locally. Generator parity was checked by comparing key order at head. The sort change is host-side only and was not validated live; the earlier live evidence predates it. Before iOS 17 and physical xctest devices were not run live, as you disclosed.

No conflicts, and CI is green at a7c8277. After the tie-break fix, the checks need to pass again on the new head before merge.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
…duplicate hit region

Apple's Dynamic Type and clipped-text checks resize the app's text while they
run and cost about 2 s of the 2.3 s native audit. The runner now requests the
five checks that leave the app as it is. A native hitRegion finding on the frame
of a heuristic small-target finding is left out.
…tem alert

Remove --native, which no release shipped. On an owner that advertises
accessibilityAudit, audit adds Apple's findings to its one answer; other owners
answer with the heuristic findings alone, and a runner before iOS 17
contributes none.

When Apple's audit fails under a system alert, the runner answers
NATIVE_AUDIT_BLOCKED_BY_ALERT with the alert title and a hint to accept or
dismiss it. The runner build progress message says the build is one-time.
matchNativeAuditFindings requires the heuristic findings, so a caller cannot
drop the hit-region dedupe.
Apple delivers audit issues in an order that changes between runs of one
unchanged screen. Order them by check, then by frame.
…er receives

The host reads NATIVE_AUDIT_UNAVAILABLE by its runner code and answers with the
heuristic findings alone, so the row declares no reason and the docs say what
audit returns before iOS 17.
Two findings with the same check, origin and description but different sizes
kept the runner's order. Compare width, then height, last.
@thymikee
thymikee force-pushed the feat/audit-platform-ios branch from a7c8277 to 4a92fbf Compare November 20, 2026 15:41
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 4a92fbf

Since the review of a7c8277: 0 new · 0 still open · 0 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (c9cce06b24a3).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 4a92fbf. The tie-break fix from the earlier review is in: native audit findings now sort with a total comparator that breaks ties on width and height, and the reversed-input test would fail on the old comparator, so output order no longer depends on Apple's result order. The review found nothing else to change.

All checks pass at 4a92fbf and there are no conflicts.

Not verified here: the unit tests were not run locally. The tie-break is host-side only, so it was not re-validated live; the earlier iOS evidence in docs/evidence/ios-native-audit-2026-11-19 still covers the route. Pre-iOS 17 and physical xctest devices were not run live, as the PR discloses.

Three earlier inline threads can be resolved. The unstable order thread is fixed at this commit (#4776 (comment)). The dropped ref thread does not apply, because an unpinned ref is refused the same way as heuristic lines and the rect still prints (#4776 (comment)). The frame tolerance thread does not apply, because Apple and snapshot frames share points and a ref attaches only on exactly one match (#4776 (comment)).

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@thymikee
thymikee merged commit 79f512e into main Nov 20, 2026
24 of 25 checks passed
@thymikee
thymikee deleted the feat/audit-platform-ios branch November 20, 2026 16:03
thymikee added a commit that referenced this pull request Nov 20, 2026
…nts-main

* origin/main:
  feat(platform-apple): admit screen recording on watchOS simulators (#4819)
  feat(audit): run Apple's native accessibility checks on iOS (#4776)
  fix(test-app): make the reorder handle a labelled native hold-then-drag (#4811)

# Conflicts:
#	packages/command-surface/src/recording/index.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant