# Accessibility Audit

`DomainDigUITests` runs Apple's `performAccessibilityAudit()` across every
primary screen. The audit checks contrast, hit-region size, clipped text at
large Dynamic Type, element descriptions, trait correctness, and Dynamic Type
support — the same ground the accessibility pass tracked in
[issue #21](https://github.com/krz-labs/domain-dig/issues/21) covers.

## The colour palette

Semantic colours live in `Shared/Colors.xcassets`, which is inside the `Shared`
file-system-synchronized group and therefore reaches the app, the widget, and
the share extension automatically. `AccentColor` stays in
`DomainDig/Assets.xcassets` because it is the system-wide tint resolved via
`ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME`.

Use the generated asset symbols — `Color(.statusCritical)`, `Color(.appSurface)`
— never a literal. `ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS`
is on, so these are compile-time checked; a typo will not build.

Every value clears WCAG AA (4.5:1) as text on its page, on its card, **and on
its own 16% badge tint** — the way `AppStatusBadgeView` actually draws it. The
worst of those three is shown:

| Role | Light | Dark | Worst light | Worst dark |
| --- | --- | --- | --- | --- |
| `StatusInfo` / `AccentColor` | `#0000FF` | `#4DA3FF` | 6.76 | 6.47 |
| `StatusPositive` | `#008035` | `#30D158` | 4.54 | 7.62 |
| `StatusWarning` | `#AD5100` | `#FF9F0A` | 4.59 | 7.76 |
| `StatusCritical` | `#CC0700` | `#FF6961` | 4.68 | 6.12 |
| `StatusNeutral` | `#5A5A5F` | `#A1A1A6` | 5.84 | 6.76 |

Each status foreground has a matching `…Surface` colour for the fill behind it,
paired through `AppStatusTone`.

**That table is enforced, not just recorded.** `PaletteContrastTests` reads the
colorsets, computes WCAG relative luminance, and asserts every status
foreground clears 4.5:1 on the page, on a card, and on its own badge fill, in
light and dark — the three surfaces `AppStatusBadgeView` can draw it on. It
covers `AppTextSecondary` on all three surfaces too, and `AppOnAccent` on
`StatusInfo`, which is the selected Dashboard chip. Until it existed, the
harness called this palette "the actual guard against contrast regressions"
while nothing checked it.

One pairing is deliberately not asserted. `AppOnAccent` over `AccentFill`
measures **2.78:1** in dark — black on `#0040DD` — but nothing draws it:
`accentFill` goes to `.tint`, where iOS picks its own label colour, and the
accent themes override `.onAccent` to white against their own fill. The number
is noted in the test so anything that starts drawing that pair has it to hand.

### Contrast alone is not a palette

The first version of this palette maximised contrast and produced mud. Requiring
every foreground to clear 4.5:1 against *its own 16% tint* — the harshest
surface it ever sits on — pushed each colour ~20% darker than the common case
needed. `#7A5600` is not amber, it is olive; `#146C2E` is not green so much as
bottle-dark. Contrast passed and the UI was still hard to read, because hue
identity is what tells "warning" from "critical" at a glance.

Two fixes:

1. **Decouple the fill from the foreground.** `AppStatusTone` carries a
   `foreground` and a `surface` that are authored independently, so the
   foreground no longer has to survive a wash of itself. Every status foreground
   is now fully saturated (`S = 1.0`).
2. **Warning is orange, not yellow.** Yellow cannot stay yellow at a lightness
   low enough to clear 4.5:1 on white — it *becomes* olive. That is
   colorimetric, not a tuning problem. Orange holds its identity when darkened,
   so warning is `#AD5100` in light and `#FF9F0A` in dark.

When adding a colour, search for the most saturated value that passes, not the
darkest. The darkest is always easy and always wrong.
| `AppTextSecondary` | `#5A5A5F` | `#A1A1A6` | 6.15 | 7.50 |

`AppTextSecondary` replaces `.secondary` for body text. iOS's own `secondaryLabel`
is only **3.29:1** on a light card — below AA — which never showed while the app
was locked to dark, where the same colour reads 6.32:1. Unlocking light mode
exposed it across 191 sites.

High Contrast variants push further in the same direction. Surfaces
(`AppBackground`, `AppSurface`, `AppSurfaceElevated`, `AppSeparator`) carry no
meaning, so they get Any/Dark and, where useful, High Contrast — but no status
semantics.

Why custom values instead of the system palette: **every** system colour fails
in light mode. Measured on white — systemYellow 1.51:1, systemOrange 2.20:1,
systemGreen 2.22:1, systemCyan 2.54:1, systemRed 3.55:1. All of them pass in
dark mode, which is why the dark-locked app looked fine and why unlocking light
mode is impossible without this work.

### The accent has two roles, and they conflict

An accent used as **text on a dark background** must be light. The same accent
used as a **fill behind a white label** must be dark. One value cannot do both:
`#4DA3FF` reads at 8.00:1 as text on black, but only 2.63:1 behind white text.

So there are two colours:

- `StatusInfo` / `AccentColor` — the accent as *foreground*: text, icons,
  bordered-button labels, tab bar.
- `AccentFill` — the accent as a *filled background* behind a label, used by
  `.borderedProminent`. Stays dark in both schemes so a white label clears AA
  (8.59:1 light, 7.56:1 dark).

`AppOnAccent` is the label colour for a solid accent fill and flips by scheme —
white on the light accent, black on the dark one.

## Appearance

`AppAppearance` (System / Light / Dark) is stored in `@AppStorage` and applied in
**exactly one place** — the `WindowGroup` in `DomainDigApp`. Keep it that way. The
app previously carried 16 separate `.preferredColorScheme(.dark)` calls scattered
through view bodies, which is how light mode became unreachable without anyone
noticing; re-applying per view is what let the lock spread.

Users override it under Settings → Display.

### Known light-mode findings

| Finding | Cause | Action |
| --- | --- | --- |
| 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 |
| 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 |

Dark mode reports 18 findings and light mode 21; the three extra are the section
headers above. Everything the app actually controls passes in both schemes.

## Enforcement — the ratchet is engaged

With phases 1–5 landed, `AccessibilityAuditHarness.enforcedAuditTypes` enforces
**`.textClipped`, `.dynamicType`, `.hitRegion`, `.elementDetection`,
`.sufficientElementDescription`, `.trait`** on the empty-state test suite. A
named finding in any of these fails the test run — regressions in five phases of
work fail the audit run, not merely reported.

Three deliberate carve-outs, each with its evidence:

1. **`.contrast` stays report-only.** The two long-standing Settings findings
   are rows scrolled under the translucent tab bar; their attribution flips
   between a row name and nil run-to-run, so no suppression is narrow enough to
   keep CI stable. The centralised palette in `Shared/Colors.xcassets` is the
   actual guard against contrast regressions. The same tab bar degrades
   `dynamicType` on the rows immediately above it, which is a separate carve-out
   — see "`dynamicType` findings land on a position, not on a row".
2. **The seeded tests run `reportOnly`.** Bisecting the row/badge accessibility
   modifiers showed the audit degrades on `children: .ignore` content — the
   *correct* VoiceOver treatment for dense rows — emitting unattributed
   contrast/dynamicType failures on rows that measure 6–7:1 and render
   correctly. Their burndown still prints; it just doesn't gate.
3. **Characterised noise is suppressed narrowly and always logged** with a
   `[noise: reason]` marker — disabled controls (WCAG 1.4.3 exempt), "nearly
   passed" near-misses, system field placeholders (clipped at any length —
   proven by shortening them to no effect), and unattributed
   clipped/dynamic-type artifacts. Nothing disappears silently; see
   `noiseReason(for:)` for each rule's provenance.

`enforcedAuditTypes` is what a fully cleared screen gets. A screen part-way
through its burndown passes `enforcing:` to `audit` instead, naming only the
categories it has cleared, so progress gates as it is made rather than waiting
on the whole screen. Monitoring Settings and Display gate on `.textClipped`.

Enforcement is a committed constant rather than a CI setting, for two reasons.
Environment variables do not work: neither a plain `xcodebuild` env var nor a
`TEST_RUNNER_`-prefixed build setting reaches the UI test process, so the toggle
silently did nothing. And a committed value makes "when did clipping become
enforced?" answerable with `git blame` instead of CI tribal knowledge.

## Screens reached through Settings

The suite audited the five root tabs and the watchlist only, so every screen
behind a Settings row was unaudited — including the integration editor's whole
form, which is the densest set of text fields and captions in the app, and the
SMTP port caption added in !5, which had never been rendered at the largest
Dynamic Type under audit (A-review C9).

Integrations and the integration editor are now covered, **report-only**: they
have never been through the ratchet, so gating them on first contact would fail
the build on findings that predate the coverage. What they report on iOS 27.0:

| Screen | Findings |
| --- | --- |
| Integrations | 1: `dynamicType` on "Process Queue Now" |
| Integration editor | 7: `contrast` on "Cancel", "Save", "DNS Changed", "Routing Rules"; `dynamicType` on "Cancel" and "Save"; one characterised system-field-placeholder clip |

That table is the iOS 27.0 reading from !42. The editor's clipped picker values
were fixed later — see the picker section below — and its `contrast` and
`dynamicType` attribution churns between runs, so treat the names as indicative
rather than a checklist.

"Cancel" and "Save" are the editor's toolbar buttons, plain `Button`s with no
density-aware font, which is why they appear in both categories. Note that for
`dynamicType` that is **not** the cause — see "Already-scalable fonts report
too" below — so only the `contrast` half of their findings is a real question.
`enforcedAuditTypes` widens to cover these screens once they are clear.

The other ten destinations are covered by `testSettingsDestinations`, also
report-only. One launch audits all of them: re-selecting the Settings tab pops
it back to root, so each row is tapped from a known place, and the store reset
makes the launch state the same for every one. That is 98s for ten screens
rather than ten launches.

All ten are reachable and all ten audit. 87 findings, of which 43 are real and
44 are already-characterised noise. **No enforced failures**, which is why the
test passes report-only rather than needing a carve-out:

| Screen | Real | Noise |
| --- | --- | --- |
| Monitoring Settings | 12 | 1 |
| History & Network | 7 | 5 |
| Scheduled Reports | 5 | 1 |
| Monitoring Log | 4 | 1 |
| Import & Export | 4 | 5 |
| Display | 3 | 1 |
| Local API | 3 | 5 |
| Data Management | 2 | 8 |
| App Info | 2 | 15 |
| iCloud Sync | 1 | 2 |

By category the 43 are: `dynamicType` 21, `textClipped` 15, `contrast` 6,
`elementDetection` 1. Read that breakdown with the reclassification below: the
`dynamicType` column turned out not to be a list of defects, so "43 real"
overstates what is actually left to fix.

App Info is the inverse: 17 findings, 2 real, the rest system-field and
unattributed artefacts already characterised in `noiseReason(for:)`.

The counts above are the floor tier (iPhone 16, iOS 18.6). The current tier
reports fewer on every screen — Monitoring Settings 13 against 8, App Info 17
against 5 — which is the asymmetry the coverage table below already records,
measured here across ten more screens.

## Menu pickers clip their value at accessibility text sizes

A `Picker` in a `Form` renders as a menu button: the label takes the width it
needs and the value gets what is left, on one line. At `AccessibilityXXXL` on
an iPhone 16 that leaves nothing. Measured on Monitoring Settings before the
fix:

| Row | Value | Rendered |
| --- | --- | --- |
| Base Interval | Every 12 Hours | `E…rs` |
| Notify For | Critical + Warnings | `C…s` |
| Domains | All Tracked | `A…d` |
| Sensitivity | Medium | `Medium` |

Three treatments were measured. Only the third works:

- **`.fixedSize(horizontal: false, vertical: true)`** — no change. The menu
  button ignores it.
- **Stacking the label above the menu** in a `VStack` at accessibility sizes —
  the label gets full width, but the value still truncates
  (`Criti…nings`). The menu's value is one line whatever width it gets.
- **`.pickerStyle(.navigationLink)`** — the row becomes label over value with a
  chevron, both in full, and the options move to a pushed list. This is what
  iOS Settings itself does at these sizes.

`AdaptivePicker` (`DomainDigUI.swift`) applies the third only when
`dynamicTypeSize.isAccessibilitySize`, and stays a menu below that, so the
interaction is unchanged for anyone not using accessibility text. It replaces
the eight `Picker`s on History & Network and Monitoring Settings, the two
quiet-hours pickers among them — those render only while the toggle is on, so
the audit has never seen them, but they are the same construct.

Result on the floor tier: `textClipped` on Monitoring Settings goes from 5 to
0, and on History & Network from 3 to 1. Both screens are clipping-free on the
current tier. Monitoring Settings is therefore the first Settings destination
to gate rather than report, on `.textClipped` alone — the `enforcing:` argument
on `AccessibilityAuditHarness.audit` is the ratchet at screen granularity, and
it passes on both tiers.

The same clipping is still reported on Display ("Compact", "Default",
"System") and iCloud Sync ("Merge"), which are the same construct on screens
outside this pass.

## `dynamicType` findings land on a position, not on a row

The remaining `dynamicType` findings — eight on Monitoring Settings, five named
on History & Network, three on the Settings root — report "font sizes are
partially unsupported" against rows the app sets no font on. They are
reproducible: identical on both runtimes and across repeat runs. The picker fix
above does not touch them.

**They follow the slot, not the row.** Reordering the Settings root's Services
section moves the findings onto whichever rows take the vacated positions:

| Slot | Before | | After | |
| --- | --- | --- | --- | --- |
| 1 | Monitoring Log | | Local API | |
| 2 | Integrations | | iCloud Sync | |
| 3 | Local API | FAIL | Monitoring Settings | FAIL |
| 4 | iCloud Sync | FAIL | Monitoring Log | FAIL |
| 5 | Monitoring Settings | FAIL | Integrations | FAIL |
| 6 | Scheduled Reports | contrast | Scheduled Reports | contrast |

Every one of those rows is an identical `NavigationLink("Title") { … }`. The
only thing that changed is which title sits in slots 3–5.

**The slots are the band above the tab bar.** Measured frames at default size
in a 912pt window:

| Row | y | Hittable |
| --- | --- | --- |
| Monitoring Log | 590–642 | yes |
| Integrations | 642–694 | yes |
| Local API | 694–746 | yes |
| iCloud Sync | 746–798 | yes |
| Monitoring Settings | 798–850 | yes |
| Scheduled Reports | 850–902 | **no** |

The translucent tab bar starts around y 829. The three reporting slots are the
156pt directly above it; the row that sits fully behind it reports `contrast`
instead. As the audit sweeps content size categories the rows march downward —
at `XXXL`, Monitoring Settings is at y 885 and no longer hittable and
Scheduled Reports is gone from the tree entirely — so the rows in that band are
the ones whose measurement degrades part-way through the sweep. Hence
"partially".

This is the same root cause already carved out for `.contrast`: rows under the
translucent tab bar. It simply surfaces in a second audit category.

Two earlier observations fit this and no other explanation:

- **The same constructs report nothing.** `Text`, `Text` with the density
  caption font, `Toggle` and `LabeledContent` inserted as probe rows into the
  Monitoring Settings `Form` all audit clean — they sat near the top.
- **Inserting rows moved the findings.** With five probe rows above them,
  "Adaptive Monitoring" began reporting and "Enable Background Monitoring"
  stopped, and "Background Refresh" and "Notification Access" switched from
  `dynamicType` to `contrast` — pushed from the band into the bar.
- **The rows render correctly.** Captured at `XXL` and `AccessibilityXXXL`,
  every named label scales, wraps and reads in full.

### Confirmed across the rest of the burndown

The Settings root is not a special case. Reordering two more screens moves the
verdict off the labels that had it and onto the labels that take their place.

**Monitoring Settings** — "Notify For", "Background Refresh" and "Notification
Access" moved from the bottom of the section to the top. Eight findings before,
eight after, and five of the names changed:

| Row | Before | After |
| --- | --- | --- |
| Background Refresh | reports | **clean** (moved to slot 2) |
| Notification Access | reports | **clean** (moved to slot 3) |
| Enable Background Monitoring | clean | **reports** (pushed to slot 4) |
| Adaptive Monitoring | clean | **reports** (pushed to slot 6) |
| Base Interval, Sensitivity, Quiet Hours, Domains, Local Alerts, Notify For | reports | reports |

**History & Network** — the History and Network sections swapped. "Allow
third-party enrichment" stopped reporting when its section moved to the top;
five findings became four, with no change to that toggle.

Nothing about any of those labels changed — not the text, not the font, not the
construct. Four of them flipped verdict in each direction purely by moving.

### Already-scalable fonts report too

`EmptyStateCardView` sets `appDensity.font(...)` on its title, message and
suggestion — `Font.system(textStyle:)`, scalable by construction — and applies
`.fixedSize(horizontal: false, vertical: true)` so each one wraps and grows.
All three still report `dynamicType` on Scheduled Reports and Monitoring Log.

That rules out the obvious reading of these findings, which is that the named
text uses a non-scaling font. **Earlier notes in this file and in the issue
suggested the integration editor's plain `Button("Cancel")` / `Button("Save")`
report `dynamicType` because they lack a density-aware font, and that adding one
is a two-line fix. That is not supported.** Text that already has a
density-aware font reports just the same.

### What this means for the #21 burndown

The `dynamicType` column is not a list of defects, so the 43 "real" findings in
the Settings table above overstate what is left:

| Category | Count | Status |
| --- | --- | --- |
| `dynamicType` | 21 | Not actionable — position-dependent, per the above |
| `textClipped` | 15 | 7 fixed by `AdaptivePicker`; 4 are long navigation titles; **4 remain** |
| `contrast` | 6 | Report-only; the palette is tested instead |
| `elementDetection` | 1 | Unattributed — see below |

The actionable remainder was four clipped picker values — "Compact", "Default"
and "System" on Display, and "Merge" on Import & Export — the same construct
`AdaptivePicker` already fixes. (An earlier note put "Merge" on iCloud Sync;
that was read off a sorted list pooled across screens. iCloud Sync has no
clipped findings at all.)

All four are now fixed, by converting the three Display pickers and the Import
Mode picker. `textClipped` on Display goes from 3 to 0, so it joins Monitoring
Settings in gating on that category. Import & Export keeps one clipped finding —
its own navigation title — so it stays report-only despite its picker being
fixed.

That leaves, across the ten Settings destinations:

| Finding | Where | Why it stays |
| --- | --- | --- |
| 4 clipped navigation titles | History & Network, Scheduled Reports, Import & Export, Data Management | Only a shorter screen name fixes it |
| 21 `dynamicType` | all | Position-dependent, per the above |
| 6 `contrast` | all | Report-only; the palette is tested instead |
| 1 `elementDetection` | Local API | Unattributed — see below |

`AdaptivePicker` also reached the integration editor's three pickers — Type,
Minimum Severity and SMTP Security. Its clipped findings go from four to one:
"Warning" and "Webhook" cleared, and "Minimum Severity" cleared too, though
that one had already shown itself unstable — it reported on a single-test run
of the editor and not on the full-suite run of the same build.

The editor is **not** gated on `.textClipped` even so. "Add Integration" is a
15-character navigation title, the same floor-only case as the four Settings
destinations above, and a screen with one finding that comes and goes between
runs is not a screen to gate.

### What was done about it

The Settings root is the only *enforced* screen long enough to reach the band,
so it was the only one failing — `testSettingsScreen`, on iOS 27.0, with three
`[FAIL][dynamicType]` findings. Reproduced with the picker change stashed on
`main` at `02a3463`, so it predated that work. The floor tier passes, the
pre-push hook runs the floor tier only, and there is no CI, which is why
nothing had been looking at it.

`noiseReason` now classifies dynamicType findings on the Settings root's row
titles (`settingsDestinationRows`), with the reorder table recorded inline as
the evidence. It is scoped to that category and those titles, so a regression on
anything else on that screen still fails.

Not done, deliberately: nothing was changed in the UI. List content scrolling
under a translucent tab bar is how iOS is supposed to look, and inset-ing the
list to stop it would be changing correct layout to satisfy a measurement
artifact.

The equivalent findings on the report-only Settings destinations are the same
artifact and stay reported — those screens do not gate, so there is nothing to
unblock, and a suppression wide enough to cover arbitrary `Form` rows would
hide real regressions.

## `contrast` and `elementDetection`, the last two categories

Neither is a to-do list either, for different reasons.

**Every `elementDetection` finding is unattributed.** Across both runtimes they
report against "unknown element" — on `seeded-dashboard`,
`seeded-tracked-domains` and `monitoring-log`, and nowhere else. All three are
report-only screens, so none of them gates anything, and a finding that names no
element cannot be acted on. No carve-out was added: there is nothing to unblock,
and a rule wide enough to cover them would weaken an enforced category
everywhere else.

**The `contrast` attribution differs so much between runtimes that the names
cannot be worked through.** On `seeded-tracked-domains` the floor names 25
elements and the current runtime names 5, largely a different set; on
`seeded-dashboard` the floor reports 4 unattributed findings and the current
runtime names 17. Same build, same fixtures. That is the flip the `.contrast`
carve-out was written for, at a larger scale.

What was done instead is the thing the carve-out always pointed at: the palette
is tested, so a colour that stops clearing AA fails the unit suite in seconds
rather than appearing as one more unstable name in an audit list.

## Long navigation titles clip, on the narrower device only

`textClipped` is reported against the navigation title of exactly the screens
whose title runs to 15 characters or more:

| Title | Length | Screen |
| --- | --- | --- |
| History & Network | 17 | Settings → History & Network |
| Scheduled Reports | 17 | Settings → Scheduled Reports |
| Import & Export | 15 | Settings → Import & Export |
| Data Management | 15 | Settings → Data Management |
| Add Integration | 15 | the integration editor |

The short ones are clean: Display (7), App Info (8), Settings (8), Local API
(9), Monitoring (10), iCloud Sync (11).

**All five report on the floor tier only.** iPhone 16 is 393pt wide and iPhone
Air is 420pt, and the current tier reports none of them, so this is screen
width rather than OS version — the one entry in the coverage table below that
the newer runtime misses for a reason that is understood. The large title
renders in full at default size; it is the growth at larger sizes that does not
fit, and SwiftUI does not wrap a large title.

The only remedy in app code is a shorter title, which for these five would mean
naming the screen something other than the row that opens it. Left as reported.
It is the single `textClipped` finding still open on History & Network, Import
& Export, Data Management and the integration editor, and why those screens
stay report-only while Display and Monitoring Settings gate.

## Recent searches

Inspect's recent-searches section appears only once a lookup has been run, so
the empty-state suite never had it in the tree. Four findings in it were found
by accident, by driving one real lookup; `testSeededRecentSearches` now covers
it on purpose.

**It needs its own launch argument.** `DOMAIN_DIG_SEED_FIXTURES` cannot be used:
Inspect renders either a result or the recent list, never both, so seeding the
batch results takes the branch and the section never appears. The first attempt
did exactly that and audited the batch screen instead — 35 findings, all of them
already covered by `testSeededBatchResults`. `DOMAIN_DIG_SEED_RECENT` seeds
`recentSearches` alone. Assigning that property does not persist (only
`addRecentSearch` and `clearRecentSearches` write to defaults), so it leaks no
more than the other fixtures.

The test asserts "RECENT" is on screen before auditing. Without that it passes
while measuring the wrong thing, which is how the first attempt looked green
until the finding list was read.

Under audit, the section reported eight findings. Two kinds were real:

- **`hitRegion` on "Clear".** A `Button("Clear")` with a `.caption2` font and no
  padding is about 16pt tall, well under the WCAG 2.5.8 floor. Given
  `minWidth`/`minHeight` of `AppLayout.minimumTapTarget` and a
  `contentShape(Rectangle())`.
- **`sufficientElementDescription` on each domain chip.** The button's label was
  the bare domain, which reads as neither a word nor an action. Given
  `accessibilityLabel("Look up <domain>")`; "Clear" likewise got "Clear recent
  searches".

Eight findings became three: two characterised noise entries, and `dynamicType`
on the "RECENT" header. `dynamicType` on "Clear" cleared as a side effect of the
44pt frame, which is consistent with those findings tracking geometry rather
than the element.

So the section gates on everything the project enforces except `.dynamicType` —
`enforcedAuditTypes.subtracting(.dynamicType)`. It is the only seeded screen
that gates at all.

## The empty-state screens are cleared before each launch

The enforced suite audits several screens in their empty state, and nothing used
to guarantee they were empty: `AccessibilityAuditHarness.launch` only added
launch arguments, so whatever a previous run, a manual launch or another test
target had left in the app's container was still there.

That made the result depend on what ran before it. `testTrackedDomainsScreen`
passed with one finding in isolation, and reported six — including an enforced
`[FAIL][dynamicType]` on `EditButton`, which only renders when the watchlist has
rows — during a full `xcodebuild test`, which is what `Scripts/audit-a11y.sh` runs.

**A correction to what this file said first.** The initial note blamed the
seeded fixtures. That was wrong: `seedAuditFixturesIfRequested` writes only to
the live view model and `auditFixturesActive` blocks persistence precisely so
they cannot leak, and running the whole audit class against a cleared store
reproduces neither the failure nor the extra findings. Ruled out as well: the
unit target, which leaves `trackedDomains` as an empty array in the app's own
defaults.

**The source of the rows was never isolated, and the search is closed.** The
remaining plan was to instrument a full-suite run, dump `trackedDomains` at each
launch and bisect which test precedes contamination. That is not being done: the
reset below makes the question unobservable from the suite's results, so the
answer would change nothing. Reopen it only if a finding shows up that the reset
does not explain.

What fixed it is making the question moot. `AuditFixtures.resetStoreIfRequested`
clears the app's defaults domain and the history files when
`DOMAIN_DIG_RESET_STORE` is passed, and the harness passes it on every launch.
It runs as the view model's `defaults:` argument rather than inside `init()`,
because a property's default value is evaluated before the initialiser body —
a reset in the body would run after the first read.

Measured: the same full `xcodebuild test` that reported one enforced failure
reports none, `AccessibilityAuditTests` goes from 13 of 14 passing to 14, and
`tracked-domains` is back to a single characterised-noise finding.

## Why the floor runtime needs its own run

**Audit coverage is not nested across OS versions.** Each runtime reports
findings the others miss, in *both* directions. Measured on this project:

| Screen | iOS 18.6 | iOS 27.0 |
| --- | --- | --- |
| Tracked Domains | 2 (text clipped) | **6** (+ contrast ×3, element detection) |
| Settings | 2 contrast | **`dynamicType`** finding 18.6 missed |
| Dashboard @ `AccessibilityXXXL` | **hit region** + 2 clipped | 1 clipped only |

Neither runtime is a superset, so the oldest supported OS needs its own run.
This also rules out committing per-screen baseline counts as a regression guard:
no single number is correct on both.

The audit therefore runs locally, across both ends, via
`Scripts/audit-a11y.sh` — on a machine that actually has an 18.x runtime
installed. The audit is optional: the pre-push hook in `.githooks/` warns when
a push has no recorded pass of both, and does not block it.

There is no CI job. The GitHub Actions workflow that used to run this suite on
the newest runtime has been removed, and with it the one check that no local run
can reproduce: **a clean checkout of the merge result.** That mattered here
because `DomainDig.xcodeproj` is hand-edited and uses file-system-synchronized
groups, where a whole missing folder still builds fine locally and breaks only
for someone else. A local hook runs against the working tree, so it cannot catch
a file that was never committed. Nothing covers that now — verify a fresh clone
by hand before a release.

## Running it

```sh
./Scripts/audit-a11y.sh            # floor + current (~20 min)
./Scripts/audit-a11y.sh floor      # oldest supported only (~8 min)
./Scripts/audit-a11y.sh current    # newest installed only (~10 min)
```

It exits non-zero when a tier fails — an enforced category reporting a named
finding, or the suite not running at all — so it can be used as a gate. Findings
in unenforced categories are printed and do not affect the exit code.

The script reads the deployment target from the project rather than hard-coding
it, and selects the oldest installed runtime **at or above** it — a runtime
below the deployment target is useless, because the app cannot install there.
If the nearest installed runtime is a major version above the target, it says
so rather than implying floor coverage it does not have.

### Pre-push hook

```sh
git config core.hooksPath .githooks
```

Runs the complexity ratchet, then warns when Swift, asset, or project files
changed and the tree being pushed has no recorded audit pass. The warning does
not block the push.

To check a tree, run the audit before pushing. `./Scripts/audit-a11y.sh` with no argument, on a
tree with no tracked changes and no untracked Swift, asset or project files,
appends `HEAD^{tree}` to `a11y-audit-passed` in the common git dir when both
tiers pass. A squash or rebase that keeps the tree keeps the pass.

The hook does not run the suite itself because git opens the connection before
pre-push runs, and gitbay kills a push that moves no data for a minute or has
not reached pre-receive fifteen minutes after taking its slot. The suite takes
about twenty minutes, so every push it gated failed.

Both tiers rather than the floor alone because coverage is not nested across OS
versions (below) and there is no CI, so a tier that is not run is not run at
all. The cost is real: about twenty minutes, against roughly eight for the floor
alone.

## Layout gotchas found the hard way

- **`Label` clips its own title.** Every empty-state heading reported as clipped
  text. `.fixedSize` applied to the `Label` does not reach the `Text` inside it,
  so the fix is to split it into an `HStack { Image; Text }` and put the modifier
  on the `Text`. Changing the font design did **not** help — that hypothesis was
  tested and discarded.
- **Splitting a `Label` exposes its icon to VoiceOver.** `Label` folds the image
  into the title's accessibility element; an `HStack` does not, so the icon
  starts announcing its raw SF Symbol name ("checklist.unchecked"). Decorative
  icons split out of a `Label` need `.accessibilityHidden(true)`.
- **Placeholder text is always reported as clipped.** Search prompts and
  `TextField` placeholders are flagged regardless of length — shortening
  "Search portfolio" to "Search" changed nothing. Treat `textClipped` findings on
  a `searchField` or `textField` element as noise rather than shortening useful
  prompts to chase them.
- **`AppLayout.minimumTapTarget` is the floor for every control.** `@ScaledMetric`
  scales *down* below the default text size as well as up, so a scaled dimension
  needs `max(scaled, AppLayout.minimumTapTarget)` or it drops under 44pt for
  users who prefer smaller text.

## VoiceOver conventions

- **Dense rows use combine-for-summary, custom-content-for-detail.**
  `BatchResultRowView` and `WatchlistRowView` each hold 8–9 text elements.
  Reading them inline makes a long sweep unnavigable, so each row is one element:
  `.accessibilityElement(children: .ignore)` + domain label + status value, with
  the rest on `.accessibilityCustomContent(...)`. `.high` importance is spoken
  inline; everything else reaches the More Content rotor on a vertical swipe.
  Rows with only 3–4 elements (the portfolio activity/attention/expiry rows) are
  left to `NavigationLink`'s automatic combine — custom content is for the dense
  case, per WWDC21-10121.
- **The custom-content chain must live in a `ViewModifier`.** Inlined onto a row
  body, six `.accessibilityCustomContent` calls plus the visual layout blow the
  Swift type-checker's budget ("unable to type-check in reasonable time").
  `BatchRowAccessibility` / `WatchlistRowAccessibility` exist for that reason.
- **Splitting a `Label` exposes its icon; combining a header swallows its
  trailing controls.** Two opposite traps. A decorative icon pulled out of a
  `Label` needs `.accessibilityHidden(true)`. A header built as a `Button` must
  *not* get `.accessibilityElement(children: .combine)` if its label contains
  other controls (`CollapsibleSectionView`'s `trailing()` holds Track/Pin) —
  combine would merge them into the header and make them unreachable.
- **Label-in-name (WCAG 2.5.3).** Every `accessibilityLabel` added to a control
  with visible text keeps that text, so Voice Control still works. Free-form
  labels are used only where the control is genuinely icon-only.
- **Technical strings** get `speechStyle: .technical` on `InfoRowViewData`, which
  applies `.speechAlwaysIncludesPunctuation()` and
  `.accessibilityTextContentType(.sourceCode)`. Set today on DNS record values
  and cipher suites; extend it wherever the view model emits a fingerprint,
  serial, or record string.

## Color independence, motion, transparency

- **Status is never colour-only.** In-app badges already pair a symbol with the
  colour. The widget status dot is now an SF Symbol
  (`checkmark.circle.fill` / `exclamationmark.triangle.fill` /
  `exclamationmark.octagon.fill`) — the same vocabulary as the badges, so a
  status reads consistently across surfaces and survives greyscale.
- **`accessibilityDifferentiateWithoutColor`** adds redundant shape only when the
  user asks for it, avoiding clutter otherwise: the Dashboard summary-card dot
  becomes a per-filter symbol, the selected quick-filter chip gains a checkmark
  and border (selection was fill-colour only), and `LabeledValueRow` prefixes a
  warning/failure symbol.
- **`accessibilityReduceMotion`** guards all five animation sites via
  `withAnimation(reduceMotion ? nil : …)` / `.animation(reduceMotion ? nil : …)`:
  `AppCopyButton`'s check cross-fade, `CollapsibleSectionView`'s expand/collapse,
  `TimelineDiffView`'s scroll, and `WatchlistView`'s list reorder.
- **`accessibilityReduceTransparency`** swaps the single `.thinMaterial` for an
  opaque `AppSurfaceElevated` capsule.

These cannot be verified by `simctl`, which toggles only Increase Contrast — the
other three settings live in the simulator's Settings app. They are correct by
construction and build-clean; their runtime behaviour is part of the Phase 6
manual pass. `SweepActivityController` was dropped from the motion list: it is
pure ActivityKit lifecycle with no animation to guard.

### What the automated audit cannot check

`performAccessibilityAudit()` validates descriptions, traits, contrast, hit
regions, and clipping. It does **not** exercise VoiceOver speech, the More
Content rotor, custom-content ordering, or announcements. Those are verified by
construction and a manual VoiceOver pass (Phase 6), not by the suite. A green
audit is necessary, not sufficient, for the row and speech work.

Additionally, the dense rows (`BatchResultRowView`, `WatchlistRowView`) and the
widget never render in the audit — the test simulator has no tracked domains or
batch results. Their treatment is unverified by the suite for the same reason the
Phase 3 `ViewThatFits` work was deferred: absence of findings is absence of data.

## Notes

- **Disabled controls are a false positive, and are suppressed.** WCAG 1.4.3
  exempts inactive components from contrast requirements, but the audit flags
  them anyway — Inspect's Run button is disabled until a domain is typed, and
  auditing the empty state reported a contrast failure that was never a real
  defect. The harness now drops contrast findings whose element reports
  `isEnabled == false`. Suppressing on the rule beats driving the UI to enable
  the control: typing raises the keyboard, which then follows the audit onto
  later screens and flags the system emoji picker's category buttons.
- **A dirty simulator inflates the burndown.** Keyboard state persists across
  runs, so a simulator left with the emoji picker open reports ~9 phantom
  hit-region findings per screen. If findings appear that name system UI
  ("Flags category", "Frequently Used category"), erase the simulator
  (`xcrun simctl erase <udid>`) and re-run before believing them.
- Audits retry up to three times. Slower machines can miss the audit's internal
  deadline (`Audit failed to complete in time`, code `-56`), which is a tooling
  timeout, not an app defect. A screen that still cannot be audited is reported
  as an `XCTSkip`, never a pass — skips are visually distinct in CI, so an
  unaudited screen stays visible instead of being silently counted as clean.
- The suite launches with `DOMAIN_DIG_FORCE_PRO_PLUS` so Pro-gated screens are
  reachable. `PurchaseService` honours that argument in `DEBUG` builds only.
- Everything used is available at the iOS 17.6 deployment floor;
  `performAccessibilityAudit` is `ios(17.0)`.
