Docs/ACCESSIBILITY.txt
662 lines · 35174 bytes
1# Accessibility Audit
2
3`DomainDigUITests` runs Apple's `performAccessibilityAudit()` across every
4primary screen. The audit checks contrast, hit-region size, clipped text at
5large Dynamic Type, element descriptions, trait correctness, and Dynamic Type
6support — the same ground the accessibility pass tracked in
7[issue #21](https://github.com/krazywarez/domain-dig/issues/21) covers.
8
9## The colour palette
10
11Semantic colours live in `Shared/Colors.xcassets`, which is inside the `Shared`
12file-system-synchronized group and therefore reaches the app, the widget, and
13the share extension automatically. `AccentColor` stays in
14`DomainDig/Assets.xcassets` because it is the system-wide tint resolved via
15`ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME`.
16
17Use the generated asset symbols — `Color(.statusCritical)`, `Color(.appSurface)`
18— never a literal. `ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS`
19is on, so these are compile-time checked; a typo will not build.
20
21Every value clears WCAG AA (4.5:1) as text on its page, on its card, **and on
22its own 16% badge tint** — the way `AppStatusBadgeView` actually draws it. The
23worst of those three is shown:
24
25| Role | Light | Dark | Worst light | Worst dark |
26| --- | --- | --- | --- | --- |
27| `StatusInfo` / `AccentColor` | `#0000FF` | `#4DA3FF` | 6.76 | 6.47 |
28| `StatusPositive` | `#008035` | `#30D158` | 4.54 | 7.62 |
29| `StatusWarning` | `#AD5100` | `#FF9F0A` | 4.59 | 7.76 |
30| `StatusCritical` | `#CC0700` | `#FF6961` | 4.68 | 6.12 |
31| `StatusNeutral` | `#5A5A5F` | `#A1A1A6` | 5.84 | 6.76 |
32
33Each status foreground has a matching `…Surface` colour for the fill behind it,
34paired through `AppStatusTone`.
35
36### Contrast alone is not a palette
37
38The first version of this palette maximised contrast and produced mud. Requiring
39every foreground to clear 4.5:1 against *its own 16% tint* — the harshest
40surface it ever sits on — pushed each colour ~20% darker than the common case
41needed. `#7A5600` is not amber, it is olive; `#146C2E` is not green so much as
42bottle-dark. Contrast passed and the UI was still hard to read, because hue
43identity is what tells "warning" from "critical" at a glance.
44
45Two fixes:
46
471. **Decouple the fill from the foreground.** `AppStatusTone` carries a
48 `foreground` and a `surface` that are authored independently, so the
49 foreground no longer has to survive a wash of itself. Every status foreground
50 is now fully saturated (`S = 1.0`).
512. **Warning is orange, not yellow.** Yellow cannot stay yellow at a lightness
52 low enough to clear 4.5:1 on white — it *becomes* olive. That is
53 colorimetric, not a tuning problem. Orange holds its identity when darkened,
54 so warning is `#AD5100` in light and `#FF9F0A` in dark.
55
56When adding a colour, search for the most saturated value that passes, not the
57darkest. The darkest is always easy and always wrong.
58| `AppTextSecondary` | `#5A5A5F` | `#A1A1A6` | 6.15 | 7.50 |
59
60`AppTextSecondary` replaces `.secondary` for body text. iOS's own `secondaryLabel`
61is only **3.29:1** on a light card — below AA — which never showed while the app
62was locked to dark, where the same colour reads 6.32:1. Unlocking light mode
63exposed it across 191 sites.
64
65High Contrast variants push further in the same direction. Surfaces
66(`AppBackground`, `AppSurface`, `AppSurfaceElevated`, `AppSeparator`) carry no
67meaning, so they get Any/Dark and, where useful, High Contrast — but no status
68semantics.
69
70Why custom values instead of the system palette: **every** system colour fails
71in light mode. Measured on white — systemYellow 1.51:1, systemOrange 2.20:1,
72systemGreen 2.22:1, systemCyan 2.54:1, systemRed 3.55:1. All of them pass in
73dark mode, which is why the dark-locked app looked fine and why unlocking light
74mode is impossible without this work.
75
76### The accent has two roles, and they conflict
77
78An accent used as **text on a dark background** must be light. The same accent
79used as a **fill behind a white label** must be dark. One value cannot do both:
80`#4DA3FF` reads at 8.00:1 as text on black, but only 2.63:1 behind white text.
81
82So there are two colours:
83
84- `StatusInfo` / `AccentColor` — the accent as *foreground*: text, icons,
85 bordered-button labels, tab bar.
86- `AccentFill` — the accent as a *filled background* behind a label, used by
87 `.borderedProminent`. Stays dark in both schemes so a white label clears AA
88 (8.59:1 light, 7.56:1 dark).
89
90`AppOnAccent` is the label colour for a solid accent fill and flips by scheme —
91white on the light accent, black on the dark one.
92
93## Appearance
94
95`AppAppearance` (System / Light / Dark) is stored in `@AppStorage` and applied in
96**exactly one place** — the `WindowGroup` in `DomainDigApp`. Keep it that way. The
97app previously carried 16 separate `.preferredColorScheme(.dark)` calls scattered
98through view bodies, which is how light mode became unreachable without anyone
99noticing; re-applying per view is what let the lock spread.
100
101Users override it under Settings → Display.
102
103### Known light-mode findings
104
105| Finding | Cause | Action |
106| --- | --- | --- |
107| 2× `contrast failed` on Settings | The last rows of a section sit under the translucent tab bar, so the audit measures text against a blended background. Present in dark mode too, since phase 0. | None — standard iOS scroll-under behaviour |
108| 3× `contrast nearly passed` on Settings | iOS-rendered `Section` headers (`TIER`, `PREFERENCES`, `SERVICES`) use the system's grey. | Not fixed. Overriding system header styling across every section to gain ~0.3:1 on decorative labels trades platform convention for very little |
109
110Dark mode reports 18 findings and light mode 21; the three extra are the section
111headers above. Everything the app actually controls passes in both schemes.
112
113## Enforcement — the ratchet is engaged
114
115With phases 1–5 landed, `AccessibilityAuditHarness.enforcedAuditTypes` enforces
116**`.textClipped`, `.dynamicType`, `.hitRegion`, `.elementDetection`,
117`.sufficientElementDescription`, `.trait`** on the empty-state test suite. A
118named finding in any of these fails the test run — regressions in five phases of
119work are still gated locally and at the pre-push hook, not merely reported.
120
121Three deliberate carve-outs, each with its evidence:
122
1231. **`.contrast` stays report-only.** The two long-standing Settings findings
124 are rows scrolled under the translucent tab bar; their attribution flips
125 between a row name and nil run-to-run, so no suppression is narrow enough to
126 keep CI stable. The centralised palette in `Shared/Colors.xcassets` is the
127 actual guard against contrast regressions. The same tab bar degrades
128 `dynamicType` on the rows immediately above it, which is a separate carve-out
129 — see "`dynamicType` findings land on a position, not on a row".
1302. **The seeded tests run `reportOnly`.** Bisecting the row/badge accessibility
131 modifiers showed the audit degrades on `children: .ignore` content — the
132 *correct* VoiceOver treatment for dense rows — emitting unattributed
133 contrast/dynamicType failures on rows that measure 6–7:1 and render
134 correctly. Their burndown still prints; it just doesn't gate.
1353. **Characterised noise is suppressed narrowly and always logged** with a
136 `[noise: reason]` marker — disabled controls (WCAG 1.4.3 exempt), "nearly
137 passed" near-misses, system field placeholders (clipped at any length —
138 proven by shortening them to no effect), and unattributed
139 clipped/dynamic-type artifacts. Nothing disappears silently; see
140 `noiseReason(for:)` for each rule's provenance.
141
142`enforcedAuditTypes` is what a fully cleared screen gets. A screen part-way
143through its burndown passes `enforcing:` to `audit` instead, naming only the
144categories it has cleared, so progress gates as it is made rather than waiting
145on the whole screen. Monitoring Settings and Display gate on `.textClipped`.
146
147Enforcement is a committed constant rather than a CI setting, for two reasons.
148Environment variables do not work: neither a plain `xcodebuild` env var nor a
149`TEST_RUNNER_`-prefixed build setting reaches the UI test process, so the toggle
150silently did nothing. And a committed value makes "when did clipping become
151enforced?" answerable with `git blame` instead of CI tribal knowledge.
152
153## Screens reached through Settings
154
155The suite audited the five root tabs and the watchlist only, so every screen
156behind a Settings row was unaudited — including the integration editor's whole
157form, which is the densest set of text fields and captions in the app, and the
158SMTP port caption added in !5, which had never been rendered at the largest
159Dynamic Type under audit (A-review C9).
160
161Integrations and the integration editor are now covered, **report-only**: they
162have never been through the ratchet, so gating them on first contact would fail
163the build on findings that predate the coverage. What they report on iOS 27.0:
164
165| Screen | Findings |
166| --- | --- |
167| Integrations | 1: `dynamicType` on "Process Queue Now" |
168| Integration editor | 7: `contrast` on "Cancel", "Save", "DNS Changed", "Routing Rules"; `dynamicType` on "Cancel" and "Save"; one characterised system-field-placeholder clip |
169
170That table is the iOS 27.0 reading from !42. The editor's clipped picker values
171were fixed later — see the picker section below — and its `contrast` and
172`dynamicType` attribution churns between runs, so treat the names as indicative
173rather than a checklist.
174
175"Cancel" and "Save" are the editor's toolbar buttons, plain `Button`s with no
176density-aware font, which is why they appear in both categories. Note that for
177`dynamicType` that is **not** the cause — see "Already-scalable fonts report
178too" below — so only the `contrast` half of their findings is a real question.
179`enforcedAuditTypes` widens to cover these screens once they are clear.
180
181The other ten destinations are covered by `testSettingsDestinations`, also
182report-only. One launch audits all of them: re-selecting the Settings tab pops
183it back to root, so each row is tapped from a known place, and the store reset
184makes the launch state the same for every one. That is 98s for ten screens
185rather than ten launches.
186
187All ten are reachable and all ten audit. 87 findings, of which 43 are real and
18844 are already-characterised noise. **No enforced failures**, which is why the
189test passes report-only rather than needing a carve-out:
190
191| Screen | Real | Noise |
192| --- | --- | --- |
193| Monitoring Settings | 12 | 1 |
194| History & Network | 7 | 5 |
195| Scheduled Reports | 5 | 1 |
196| Monitoring Log | 4 | 1 |
197| Import & Export | 4 | 5 |
198| Display | 3 | 1 |
199| Local API | 3 | 5 |
200| Data Management | 2 | 8 |
201| App Info | 2 | 15 |
202| iCloud Sync | 1 | 2 |
203
204By category the 43 are: `dynamicType` 21, `textClipped` 15, `contrast` 6,
205`elementDetection` 1. Read that breakdown with the reclassification below: the
206`dynamicType` column turned out not to be a list of defects, so "43 real"
207overstates what is actually left to fix.
208
209App Info is the inverse: 17 findings, 2 real, the rest system-field and
210unattributed artefacts already characterised in `noiseReason(for:)`.
211
212The counts above are the floor tier (iPhone 16, iOS 18.6). The current tier
213reports fewer on every screen — Monitoring Settings 13 against 8, App Info 17
214against 5 — which is the asymmetry the coverage table below already records,
215measured here across ten more screens.
216
217## Menu pickers clip their value at accessibility text sizes
218
219A `Picker` in a `Form` renders as a menu button: the label takes the width it
220needs and the value gets what is left, on one line. At `AccessibilityXXXL` on
221an iPhone 16 that leaves nothing. Measured on Monitoring Settings before the
222fix:
223
224| Row | Value | Rendered |
225| --- | --- | --- |
226| Base Interval | Every 12 Hours | `E…rs` |
227| Notify For | Critical + Warnings | `C…s` |
228| Domains | All Tracked | `A…d` |
229| Sensitivity | Medium | `Medium` |
230
231Three treatments were measured. Only the third works:
232
233- **`.fixedSize(horizontal: false, vertical: true)`** — no change. The menu
234 button ignores it.
235- **Stacking the label above the menu** in a `VStack` at accessibility sizes —
236 the label gets full width, but the value still truncates
237 (`Criti…nings`). The menu's value is one line whatever width it gets.
238- **`.pickerStyle(.navigationLink)`** — the row becomes label over value with a
239 chevron, both in full, and the options move to a pushed list. This is what
240 iOS Settings itself does at these sizes.
241
242`AdaptivePicker` (`DomainDigUI.swift`) applies the third only when
243`dynamicTypeSize.isAccessibilitySize`, and stays a menu below that, so the
244interaction is unchanged for anyone not using accessibility text. It replaces
245the eight `Picker`s on History & Network and Monitoring Settings, the two
246quiet-hours pickers among them — those render only while the toggle is on, so
247the audit has never seen them, but they are the same construct.
248
249Result on the floor tier: `textClipped` on Monitoring Settings goes from 5 to
2500, and on History & Network from 3 to 1. Both screens are clipping-free on the
251current tier. Monitoring Settings is therefore the first Settings destination
252to gate rather than report, on `.textClipped` alone — the `enforcing:` argument
253on `AccessibilityAuditHarness.audit` is the ratchet at screen granularity, and
254it passes on both tiers.
255
256The same clipping is still reported on Display ("Compact", "Default",
257"System") and iCloud Sync ("Merge"), which are the same construct on screens
258outside this pass.
259
260## `dynamicType` findings land on a position, not on a row
261
262The remaining `dynamicType` findings — eight on Monitoring Settings, five named
263on History & Network, three on the Settings root — report "font sizes are
264partially unsupported" against rows the app sets no font on. They are
265reproducible: identical on both runtimes and across repeat runs. The picker fix
266above does not touch them.
267
268**They follow the slot, not the row.** Reordering the Settings root's Services
269section moves the findings onto whichever rows take the vacated positions:
270
271| Slot | Before | | After | |
272| --- | --- | --- | --- | --- |
273| 1 | Monitoring Log | | Local API | |
274| 2 | Integrations | | iCloud Sync | |
275| 3 | Local API | FAIL | Monitoring Settings | FAIL |
276| 4 | iCloud Sync | FAIL | Monitoring Log | FAIL |
277| 5 | Monitoring Settings | FAIL | Integrations | FAIL |
278| 6 | Scheduled Reports | contrast | Scheduled Reports | contrast |
279
280Every one of those rows is an identical `NavigationLink("Title") { … }`. The
281only thing that changed is which title sits in slots 3–5.
282
283**The slots are the band above the tab bar.** Measured frames at default size
284in a 912pt window:
285
286| Row | y | Hittable |
287| --- | --- | --- |
288| Monitoring Log | 590–642 | yes |
289| Integrations | 642–694 | yes |
290| Local API | 694–746 | yes |
291| iCloud Sync | 746–798 | yes |
292| Monitoring Settings | 798–850 | yes |
293| Scheduled Reports | 850–902 | **no** |
294
295The translucent tab bar starts around y 829. The three reporting slots are the
296156pt directly above it; the row that sits fully behind it reports `contrast`
297instead. As the audit sweeps content size categories the rows march downward —
298at `XXXL`, Monitoring Settings is at y 885 and no longer hittable and
299Scheduled Reports is gone from the tree entirely — so the rows in that band are
300the ones whose measurement degrades part-way through the sweep. Hence
301"partially".
302
303This is the same root cause already carved out for `.contrast`: rows under the
304translucent tab bar. It simply surfaces in a second audit category.
305
306Two earlier observations fit this and no other explanation:
307
308- **The same constructs report nothing.** `Text`, `Text` with the density
309 caption font, `Toggle` and `LabeledContent` inserted as probe rows into the
310 Monitoring Settings `Form` all audit clean — they sat near the top.
311- **Inserting rows moved the findings.** With five probe rows above them,
312 "Adaptive Monitoring" began reporting and "Enable Background Monitoring"
313 stopped, and "Background Refresh" and "Notification Access" switched from
314 `dynamicType` to `contrast` — pushed from the band into the bar.
315- **The rows render correctly.** Captured at `XXL` and `AccessibilityXXXL`,
316 every named label scales, wraps and reads in full.
317
318### Confirmed across the rest of the burndown
319
320The Settings root is not a special case. Reordering two more screens moves the
321verdict off the labels that had it and onto the labels that take their place.
322
323**Monitoring Settings** — "Notify For", "Background Refresh" and "Notification
324Access" moved from the bottom of the section to the top. Eight findings before,
325eight after, and five of the names changed:
326
327| Row | Before | After |
328| --- | --- | --- |
329| Background Refresh | reports | **clean** (moved to slot 2) |
330| Notification Access | reports | **clean** (moved to slot 3) |
331| Enable Background Monitoring | clean | **reports** (pushed to slot 4) |
332| Adaptive Monitoring | clean | **reports** (pushed to slot 6) |
333| Base Interval, Sensitivity, Quiet Hours, Domains, Local Alerts, Notify For | reports | reports |
334
335**History & Network** — the History and Network sections swapped. "Allow
336third-party enrichment" stopped reporting when its section moved to the top;
337five findings became four, with no change to that toggle.
338
339Nothing about any of those labels changed — not the text, not the font, not the
340construct. Four of them flipped verdict in each direction purely by moving.
341
342### Already-scalable fonts report too
343
344`EmptyStateCardView` sets `appDensity.font(...)` on its title, message and
345suggestion — `Font.system(textStyle:)`, scalable by construction — and applies
346`.fixedSize(horizontal: false, vertical: true)` so each one wraps and grows.
347All three still report `dynamicType` on Scheduled Reports and Monitoring Log.
348
349That rules out the obvious reading of these findings, which is that the named
350text uses a non-scaling font. **Earlier notes in this file and in the issue
351suggested the integration editor's plain `Button("Cancel")` / `Button("Save")`
352report `dynamicType` because they lack a density-aware font, and that adding one
353is a two-line fix. That is not supported.** Text that already has a
354density-aware font reports just the same.
355
356### What this means for the #21 burndown
357
358The `dynamicType` column is not a list of defects, so the 43 "real" findings in
359the Settings table above overstate what is left:
360
361| Category | Count | Status |
362| --- | --- | --- |
363| `dynamicType` | 21 | Not actionable — position-dependent, per the above |
364| `textClipped` | 15 | 7 fixed by `AdaptivePicker`; 4 are long navigation titles; **4 remain** |
365| `contrast` | 6 | Report-only by standing policy |
366| `elementDetection` | 1 | Not investigated |
367
368The actionable remainder was four clipped picker values — "Compact", "Default"
369and "System" on Display, and "Merge" on Import & Export — the same construct
370`AdaptivePicker` already fixes. (An earlier note put "Merge" on iCloud Sync;
371that was read off a sorted list pooled across screens. iCloud Sync has no
372clipped findings at all.)
373
374All four are now fixed, by converting the three Display pickers and the Import
375Mode picker. `textClipped` on Display goes from 3 to 0, so it joins Monitoring
376Settings in gating on that category. Import & Export keeps one clipped finding —
377its own navigation title — so it stays report-only despite its picker being
378fixed.
379
380That leaves, across the ten Settings destinations:
381
382| Finding | Where | Why it stays |
383| --- | --- | --- |
384| 4 clipped navigation titles | History & Network, Scheduled Reports, Import & Export, Data Management | Only a shorter screen name fixes it |
385| 21 `dynamicType` | all | Position-dependent, per the above |
386| 6 `contrast` | all | Report-only by standing policy |
387| 1 `elementDetection` | Local API | Not investigated |
388
389`AdaptivePicker` also reached the integration editor's three pickers — Type,
390Minimum Severity and SMTP Security. Its clipped findings go from four to one:
391"Warning" and "Webhook" cleared, and "Minimum Severity" cleared too, though
392that one had already shown itself unstable — it reported on a single-test run
393of the editor and not on the full-suite run of the same build.
394
395The editor is **not** gated on `.textClipped` even so. "Add Integration" is a
39615-character navigation title, the same unfixable case as the four Settings
397destinations, and a screen with one finding that comes and goes between runs is
398not a screen to gate.
399
400### What was done about it
401
402The Settings root is the only *enforced* screen long enough to reach the band,
403so it was the only one failing — `testSettingsScreen`, on iOS 27.0, with three
404`[FAIL][dynamicType]` findings. Reproduced with the picker change stashed on
405`main` at `02a3463`, so it predated that work. The floor tier passes, the
406pre-push hook runs the floor tier only, and there is no CI, which is why
407nothing had been looking at it.
408
409`noiseReason` now classifies dynamicType findings on the Settings root's row
410titles (`settingsDestinationRows`), with the reorder table recorded inline as
411the evidence. It is scoped to that category and those titles, so a regression on
412anything else on that screen still fails.
413
414Not done, deliberately: nothing was changed in the UI. List content scrolling
415under a translucent tab bar is how iOS is supposed to look, and inset-ing the
416list to stop it would be changing correct layout to satisfy a measurement
417artifact.
418
419The equivalent findings on the report-only Settings destinations are the same
420artifact and stay reported — those screens do not gate, so there is nothing to
421unblock, and a suppression wide enough to cover arbitrary `Form` rows would
422hide real regressions.
423
424## Long navigation titles clip
425
426`textClipped` is reported against the navigation title of exactly the screens
427whose title is 15 characters or more: History & Network, Scheduled Reports,
428Import & Export, Data Management. The short ones — Display, Monitoring, Local
429API, iCloud Sync — are clean. The large title renders in full at default size;
430it is the growth at larger sizes that does not fit, and SwiftUI does not wrap a
431large title.
432
433The only remedy in app code is a shorter title, which for these four would mean
434naming the screen something other than what the Settings row that opens it
435says. Left as reported. It is the one `textClipped` finding still open on
436History & Network, and why that screen stays report-only.
437
438## Recent searches are never audited
439
440The empty-state suite launches a fresh install, so Inspect's recent-searches
441section — which only appears once a lookup has been run — is never in the tree
442when the audit walks it. Driving one real lookup and re-auditing surfaced four
443findings in it on iOS 27.0:
444
445- `dynamicType` on the "RECENT" header and on the "Clear" button
446- `hitRegion` too small on "Clear"
447- `sufficientElementDescription`, "label not human-readable", on a domain chip
448
449These are latent rather than new: nothing in the section changed when Inspect
450moved to a `List`. They need a seeded recent-searches fixture to be audited
451properly, which the seed harness does not have.
452
453## The empty-state screens are cleared before each launch
454
455The enforced suite audits several screens in their empty state, and nothing used
456to guarantee they were empty: `AccessibilityAuditHarness.launch` only added
457launch arguments, so whatever a previous run, a manual launch or another test
458target had left in the app's container was still there.
459
460That made the result depend on what ran before it. `testTrackedDomainsScreen`
461passed with one finding in isolation, and reported six — including an enforced
462`[FAIL][dynamicType]` on `EditButton`, which only renders when the watchlist has
463rows — during a full `xcodebuild test`, which is what the pre-push hook runs.
464
465**A correction to what this file said first.** The initial note blamed the
466seeded fixtures. That was wrong: `seedAuditFixturesIfRequested` writes only to
467the live view model and `auditFixturesActive` blocks persistence precisely so
468they cannot leak, and running the whole audit class against a cleared store
469reproduces neither the failure nor the extra findings. Ruled out as well: the
470unit target, which leaves `trackedDomains` as an empty array in the app's own
471defaults. The source of the rows was never isolated.
472
473What fixed it is making the question moot. `AuditFixtures.resetStoreIfRequested`
474clears the app's defaults domain and the history files when
475`DOMAIN_DIG_RESET_STORE` is passed, and the harness passes it on every launch.
476It runs as the view model's `defaults:` argument rather than inside `init()`,
477because a property's default value is evaluated before the initialiser body —
478a reset in the body would run after the first read.
479
480Measured: the same full `xcodebuild test` that reported one enforced failure
481reports none, `AccessibilityAuditTests` goes from 13 of 14 passing to 14, and
482`tracked-domains` is back to a single characterised-noise finding.
483
484## Why the floor runtime needs its own run
485
486**Audit coverage is not nested across OS versions.** Each runtime reports
487findings the others miss, in *both* directions. Measured on this project:
488
489| Screen | iOS 18.6 | iOS 27.0 |
490| --- | --- | --- |
491| Tracked Domains | 2 (text clipped) | **6** (+ contrast ×3, element detection) |
492| Settings | 2 contrast | **`dynamicType`** finding 18.6 missed |
493| Dashboard @ `AccessibilityXXXL` | **hit region** + 2 clipped | 1 clipped only |
494
495Neither runtime is a superset, so the oldest supported OS needs its own run.
496This also rules out committing per-screen baseline counts as a regression guard:
497no single number is correct on both.
498
499The audit therefore runs locally, across both ends, via
500`Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime
501installed. The pre-push hook in `.githooks/` runs both of them.
502
503There is no CI job. The GitHub Actions workflow that used to run this suite on
504the newest runtime has been removed, and with it the one check that no local run
505can reproduce: **a clean checkout of the merge result.** That mattered here
506because `DomainDig.xcodeproj` is hand-edited and uses file-system-synchronized
507groups, where a whole missing folder still builds fine locally and breaks only
508for someone else. A local hook runs against the working tree, so it cannot catch
509a file that was never committed. Nothing covers that now — verify a fresh clone
510by hand before a release.
511
512## Running it
513
514```sh
515./Scripts/audit-a11y.sh # floor + current (~20 min)
516./Scripts/audit-a11y.sh floor # oldest supported only (~8 min)
517./Scripts/audit-a11y.sh current # newest installed only (~10 min)
518```
519
520It exits non-zero when a tier fails — an enforced category reporting a named
521finding, or the suite not running at all — so it can be used as a gate. Findings
522in unenforced categories are printed and do not affect the exit code.
523
524The script reads the deployment target from the project rather than hard-coding
525it, and selects the oldest installed runtime **at or above** it — a runtime
526below the deployment target is useless, because the app cannot install there.
527If the nearest installed runtime is a major version above the target, it says
528so rather than implying floor coverage it does not have.
529
530### Pre-push hook
531
532```sh
533git config core.hooksPath .githooks
534```
535
536Runs the complexity ratchet, then the audit on **both** runtimes, before a push,
537and only when Swift, asset, or project files changed. Bypass with
538`git push --no-verify`.
539
540Both tiers rather than the floor alone because coverage is not nested across OS
541versions (below) and there is no CI, so a tier the hook does not run is not run
542at all. The cost is real: about twenty minutes, against roughly eight for the
543floor alone.
544
545Pre-push rather than pre-commit deliberately: at pre-commit that blocks every
546commit. A hook routinely bypassed with `--no-verify` is worse than no hook,
547because it trains you to ignore it — which is the standing argument against
548letting this get any slower.
549
550## Layout gotchas found the hard way
551
552- **`Label` clips its own title.** Every empty-state heading reported as clipped
553 text. `.fixedSize` applied to the `Label` does not reach the `Text` inside it,
554 so the fix is to split it into an `HStack { Image; Text }` and put the modifier
555 on the `Text`. Changing the font design did **not** help — that hypothesis was
556 tested and discarded.
557- **Splitting a `Label` exposes its icon to VoiceOver.** `Label` folds the image
558 into the title's accessibility element; an `HStack` does not, so the icon
559 starts announcing its raw SF Symbol name ("checklist.unchecked"). Decorative
560 icons split out of a `Label` need `.accessibilityHidden(true)`.
561- **Placeholder text is always reported as clipped.** Search prompts and
562 `TextField` placeholders are flagged regardless of length — shortening
563 "Search portfolio" to "Search" changed nothing. Treat `textClipped` findings on
564 a `searchField` or `textField` element as noise rather than shortening useful
565 prompts to chase them.
566- **`AppLayout.minimumTapTarget` is the floor for every control.** `@ScaledMetric`
567 scales *down* below the default text size as well as up, so a scaled dimension
568 needs `max(scaled, AppLayout.minimumTapTarget)` or it drops under 44pt for
569 users who prefer smaller text.
570
571## VoiceOver conventions
572
573- **Dense rows use combine-for-summary, custom-content-for-detail.**
574 `BatchResultRowView` and `WatchlistRowView` each hold 8–9 text elements.
575 Reading them inline makes a long sweep unnavigable, so each row is one element:
576 `.accessibilityElement(children: .ignore)` + domain label + status value, with
577 the rest on `.accessibilityCustomContent(...)`. `.high` importance is spoken
578 inline; everything else reaches the More Content rotor on a vertical swipe.
579 Rows with only 3–4 elements (the portfolio activity/attention/expiry rows) are
580 left to `NavigationLink`'s automatic combine — custom content is for the dense
581 case, per WWDC21-10121.
582- **The custom-content chain must live in a `ViewModifier`.** Inlined onto a row
583 body, six `.accessibilityCustomContent` calls plus the visual layout blow the
584 Swift type-checker's budget ("unable to type-check in reasonable time").
585 `BatchRowAccessibility` / `WatchlistRowAccessibility` exist for that reason.
586- **Splitting a `Label` exposes its icon; combining a header swallows its
587 trailing controls.** Two opposite traps. A decorative icon pulled out of a
588 `Label` needs `.accessibilityHidden(true)`. A header built as a `Button` must
589 *not* get `.accessibilityElement(children: .combine)` if its label contains
590 other controls (`CollapsibleSectionView`'s `trailing()` holds Track/Pin) —
591 combine would merge them into the header and make them unreachable.
592- **Label-in-name (WCAG 2.5.3).** Every `accessibilityLabel` added to a control
593 with visible text keeps that text, so Voice Control still works. Free-form
594 labels are used only where the control is genuinely icon-only.
595- **Technical strings** get `speechStyle: .technical` on `InfoRowViewData`, which
596 applies `.speechAlwaysIncludesPunctuation()` and
597 `.accessibilityTextContentType(.sourceCode)`. Set today on DNS record values
598 and cipher suites; extend it wherever the view model emits a fingerprint,
599 serial, or record string.
600
601## Color independence, motion, transparency
602
603- **Status is never colour-only.** In-app badges already pair a symbol with the
604 colour. The widget status dot is now an SF Symbol
605 (`checkmark.circle.fill` / `exclamationmark.triangle.fill` /
606 `exclamationmark.octagon.fill`) — the same vocabulary as the badges, so a
607 status reads consistently across surfaces and survives greyscale.
608- **`accessibilityDifferentiateWithoutColor`** adds redundant shape only when the
609 user asks for it, avoiding clutter otherwise: the Dashboard summary-card dot
610 becomes a per-filter symbol, the selected quick-filter chip gains a checkmark
611 and border (selection was fill-colour only), and `LabeledValueRow` prefixes a
612 warning/failure symbol.
613- **`accessibilityReduceMotion`** guards all five animation sites via
614 `withAnimation(reduceMotion ? nil : …)` / `.animation(reduceMotion ? nil : …)`:
615 `AppCopyButton`'s check cross-fade, `CollapsibleSectionView`'s expand/collapse,
616 `TimelineDiffView`'s scroll, and `WatchlistView`'s list reorder.
617- **`accessibilityReduceTransparency`** swaps the single `.thinMaterial` for an
618 opaque `AppSurfaceElevated` capsule.
619
620These cannot be verified by `simctl`, which toggles only Increase Contrast — the
621other three settings live in the simulator's Settings app. They are correct by
622construction and build-clean; their runtime behaviour is part of the Phase 6
623manual pass. `SweepActivityController` was dropped from the motion list: it is
624pure ActivityKit lifecycle with no animation to guard.
625
626### What the automated audit cannot check
627
628`performAccessibilityAudit()` validates descriptions, traits, contrast, hit
629regions, and clipping. It does **not** exercise VoiceOver speech, the More
630Content rotor, custom-content ordering, or announcements. Those are verified by
631construction and a manual VoiceOver pass (Phase 6), not by the suite. A green
632audit is necessary, not sufficient, for the row and speech work.
633
634Additionally, the dense rows (`BatchResultRowView`, `WatchlistRowView`) and the
635widget never render in the audit — the test simulator has no tracked domains or
636batch results. Their treatment is unverified by the suite for the same reason the
637Phase 3 `ViewThatFits` work was deferred: absence of findings is absence of data.
638
639## Notes
640
641- **Disabled controls are a false positive, and are suppressed.** WCAG 1.4.3
642 exempts inactive components from contrast requirements, but the audit flags
643 them anyway — Inspect's Run button is disabled until a domain is typed, and
644 auditing the empty state reported a contrast failure that was never a real
645 defect. The harness now drops contrast findings whose element reports
646 `isEnabled == false`. Suppressing on the rule beats driving the UI to enable
647 the control: typing raises the keyboard, which then follows the audit onto
648 later screens and flags the system emoji picker's category buttons.
649- **A dirty simulator inflates the burndown.** Keyboard state persists across
650 runs, so a simulator left with the emoji picker open reports ~9 phantom
651 hit-region findings per screen. If findings appear that name system UI
652 ("Flags category", "Frequently Used category"), erase the simulator
653 (`xcrun simctl erase <udid>`) and re-run before believing them.
654- Audits retry up to three times. Slower machines can miss the audit's internal
655 deadline (`Audit failed to complete in time`, code `-56`), which is a tooling
656 timeout, not an app defect. A screen that still cannot be audited is reported
657 as an `XCTSkip`, never a pass — skips are visually distinct in CI, so an
658 unaudited screen stays visible instead of being silently counted as clean.
659- The suite launches with `DOMAIN_DIG_FORCE_PRO_PLUS` so Pro-gated screens are
660 reachable. `PurchaseService` honours that argument in `DEBUG` builds only.
661- Everything used is available at the iOS 17.6 deployment floor;
662 `performAccessibilityAudit` is `ios(17.0)`.