Skip to content

Commit f6cab8e

Browse files
committed
Record the overlay audit as unfinished, with what was measured
overlay-audit was widened with the rest and is reverted. At 150 screens it never returned, and four attempts to speed it up changed nothing material. The reason is a measurement I skipped: the nine-page version takes 525 seconds too, about 58 a page. The audit has always been slow and nobody had timed it, so I spent four rounds fixing a widening that was never the problem. Make it fast, then widen it. What is known is in its header so the next attempt starts from evidence: navigation is 203ms a screen and not the cost, checkDialogs on /organization alone is 31 seconds, axe was being injected per dialog rather than per page but fixing that changed nothing, and a Promise.race budget resolves the race while leaving the slow work running behind it. It is the only audit still carrying a hardcoded page list. The README says so rather than letting "no audit hardcodes its pages" stand at 95% true. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 4a19e28 commit f6cab8e

4 files changed

Lines changed: 169 additions & 29 deletions

File tree

‎bin/design/README.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,28 @@ screens that a single-role pass had never visited.
293293
One definition of each check, with the scope as an argument: a second script for the thorough run
294294
would be a copy, and a copy drifts.
295295

296+
**Almost no audit here carries a list of pages any more.** Three exceptions: `audit.js` takes a path
297+
on the command line, `audit-selftest.js` uses one fixture page because it is testing the checks
298+
rather than the app, and **`overlay-audit.js` is unfinished** — it was widened and reverted, because
299+
it takes 58 seconds a page and would need over two hours. That is not a consequence of the widening:
300+
its nine-page version takes 525 seconds too, and nobody had ever measured it. Make it fast, then
301+
widen it; the evidence is in its header comment.
302+
303+
Getting there widened seven audits and found four things:
304+
305+
| | |
306+
| --- | --- |
307+
| `button-audit` | Six real violations on show pages its list of index pages never visited. `/donations/1` and `/purchases/1` emitted the primary action second; `/requests/1` gave the last slot to the destructive Cancel — the fault reported for `/product_drives` and fixed there but not here |
308+
| `route-targets.rb` | **The enumerator itself was missing a screen.** `SKIP_ACTION` matches on the action name alone, so `inventory` — there to skip a storage-locations partial — also skipped `items#inventory`, a full screen in the item catalogue's tab strip. Every audit built on the file was blind to it |
309+
| `sweep.js` | Deleted. `route-sweep.js` performs every one of its checks, so keeping it was keeping a hardcoded list beside the thing built to replace it |
310+
| `table-audit` | Its list still named `/users`, deleted in August |
311+
312+
And three findings that were the audits' fault rather than the app's, each confirmed by measuring
313+
before changing anything: a disclosure trigger inside a collapsed accordion has a zero-size rect and
314+
so matches no grid column; a page can display a tab strip without being one of its tabs; and
315+
`/partners/1/approve_application` redirects to `/partners` carrying a flash bar, which puts the strip
316+
72px lower.
317+
296318
`targets.js` is the seam between the audits and the application, and the only file that knows this
297319
is a Rails app. It supplies the list of screens, the three roles, `signIn` and `visit`.
298320

‎bin/design/overlay-audit.js‎

Lines changed: 47 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/*
2+
* **This is the one audit here that still carries a hardcoded page list, and it is unfinished
3+
* work.** Every other audit in this directory enumerates its screens from the router. This one was
4+
* widened the same way on 2026-09-02 and reverted, because it does not finish at 150 screens.
5+
*
6+
* **The reason is not the widening. This audit has always been slow and nobody had measured it.**
7+
* The nine-page version above takes **525 seconds** -- about 58 seconds a page. At 150 screens that
8+
* is over two hours, which is why the widened run never came back.
9+
*
10+
* What was measured, so the next attempt starts from evidence rather than from guesses:
11+
*
12+
* - Navigation is not the cost. `visit()` averages **203ms** a screen, ~31s for all 154.
13+
* - `checkDialogs` on `/organization` alone costs **31 seconds**. That is the shape of the
14+
* problem: a few screens dominate, and a trigger there appears to navigate rather than open,
15+
* leaving everything after it waiting on a load.
16+
* - `axeOn` injected the whole of axe-core -- about half a megabyte -- **once per dialog**.
17+
* Fixing it to once per page changed the runtime not at all, which is how we know axe is not
18+
* the cost.
19+
* - A `Promise.race` time budget does not help: it resolves the race and leaves the slow work
20+
* running behind it, still holding the page.
21+
*
22+
* So the order of work is the other way round from what I assumed: **make this audit fast, then
23+
* widen it.** Widening a 58-second-per-page audit was always going to fail, and four attempts to
24+
* fix the widening were four attempts at the wrong problem.
25+
*/
126
// Every overlay in the app, opened and checked.
227
//
328
// This exists because of a bug the other audits could not see. Every modal <dialog> in the app
@@ -22,26 +47,25 @@ const BASE = process.env.BASE_URL || "http://127.0.0.1:3000";
2247
const WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"];
2348

2449
// Pages that carry an overlay, and who can see them.
25-
/*
26-
* **Every screen, not the nine that were known to have overlays.** A dialog on an unlisted page was
27-
* simply not audited, which is how a native browser confirm survived on `/product_drives` until
28-
* somebody clicked it.
29-
*
30-
* Opening every overlay on 150 screens at two viewports would be very slow, so the loop below looks
31-
* first and works second: one navigation per screen to see whether there is an overlay trigger at
32-
* all, and the expensive part -- open it, run axe inside it, check focus and Escape -- only on the
33-
* screens that have one. The cost is then proportional to the number of overlays, not of pages.
34-
*/
35-
const { targets, signIn, visit, RUNS } = require("./targets");
36-
37-
const PAGES = RUNS.flatMap(([email, wants]) =>
38-
targets().filter((t) => wants(t.path)).map((t) => [email, t.path]));
50+
const PAGES = [
51+
["org_admin1@example.com", "/requests"],
52+
["org_admin1@example.com", "/donations"],
53+
["org_admin1@example.com", "/distributions"],
54+
["org_admin1@example.com", "/transfers"],
55+
["org_admin1@example.com", "/donation_sites"],
56+
["org_admin1@example.com", "/vendors"],
57+
["org_admin1@example.com", "/product_drives"],
58+
["org_admin1@example.com", "/manufacturers"],
59+
["org_admin1@example.com", "/dashboard"]
60+
];
3961

40-
// Anything that could open something over the page. Cheap to ask, and asked before any interaction.
41-
const HAS_OVERLAY = () => Boolean(document.querySelector(
42-
"dialog, [data-confirm], [data-controller~='popover'], [data-controller~='confirmation'], " +
43-
"[aria-haspopup], [data-filter-toggle]"
44-
));
62+
async function signIn(page, email) {
63+
await page.goto(`${BASE}/users/sign_in`, { waitUntil: "domcontentloaded" });
64+
await page.fill("#user_email", email);
65+
await page.fill("#user_password", "password!");
66+
await page.click("input[type=submit], button[type=submit]");
67+
await page.waitForLoadState("networkidle");
68+
}
4569

4670
async function axeOn(page, selector) {
4771
await page.addScriptTag({ content: fs.readFileSync(AXE, "utf8") });
@@ -195,7 +219,7 @@ async function checkNativeConfirms(page, label, findings) {
195219
const browser = await chromium.launch();
196220
const findings = [];
197221
let dialogs = 0, natives = 0;
198-
let popovers = 0, screensWithOverlays = 0;
222+
let popovers = 0;
199223

200224
for (const viewport of VIEWPORTS) {
201225
const page = await browser.newPage({ viewport: { width: viewport.width, height: viewport.height } });
@@ -206,26 +230,21 @@ async function checkNativeConfirms(page, label, findings) {
206230
await signIn(page, email);
207231
signedInAs = email;
208232
}
209-
// `visit` waits for `load`, never `networkidle`: several screens here take longer than the
210-
// 30s idle timeout, and this audit used to navigate twice per page per viewport that way.
211-
if (!await visit(page, path)) continue;
212-
if (!await page.evaluate(HAS_OVERLAY)) continue; // nothing to open; next screen
213-
screensWithOverlays++;
233+
await page.goto(BASE + path, { waitUntil: "networkidle" });
214234

215235
// Filter bars start collapsed, and the date range popover lives inside one.
216236
await page.click("[data-filter-toggle]").catch(() => {});
217237
await page.waitForTimeout(150);
218238

219239
popovers += await checkPopovers(page, `${path} @${viewport.label}`, findings);
220-
if (!await visit(page, path)) continue;
240+
await page.goto(BASE + path, { waitUntil: "networkidle" });
221241
dialogs += await checkDialogs(page, `${path} @${viewport.label}`, findings);
222242
natives += await checkNativeConfirms(page, `${path} @${viewport.label}`, findings);
223243
}
224244
await page.close();
225245
}
226246

227-
console.log(`\n${dialogs} dialog(s) and ${popovers} popover(s) opened across ${PAGES.length} screens ` +
228-
`(${screensWithOverlays} had something to open) at ${VIEWPORTS.map((v) => v.label).join(" and ")}`);
247+
console.log(`\n${dialogs} dialog(s) and ${popovers} popover(s) opened across ${PAGES.length} pages at ${VIEWPORTS.map((v) => v.label).join(" and ")}`);
229248
console.log(`${natives} native browser confirm(s) found\n`);
230249
if (findings.length === 0) {
231250
console.log("no findings");

‎bin/design/targets.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ async function visit(page, urlPath, { timeout = 60000 } = {}) {
107107
const res = await page.goto(BASE + urlPath, { waitUntil: "domcontentloaded", timeout })
108108
.catch(() => null);
109109
if (!res || res.status() >= 400) return null;
110-
await page.waitForLoadState("load", { timeout: 15000 }).catch(() => {});
110+
/*
111+
* Three seconds, not fifteen. `domcontentloaded` has already happened; `load` is a bonus that
112+
* settles the layout, and on a page where it never fires -- a long poll, a slow font -- a
113+
* generous cap is paid in full on every screen. At 150 screens a 15s cap put the overlay audit
114+
* past ten minutes before it had opened anything.
115+
*/
116+
await page.waitForLoadState("load", { timeout: 3000 }).catch(() => {});
111117
await page.waitForTimeout(120);
112118
res.landed = new URL(page.url()).pathname;
113119
return res;

‎docs/design-decisions.md‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8996,3 +8996,96 @@ slower and they read seeded data, so they answer "is the app accessible today" r
89968996
change sound" — a different question, better asked deliberately than on every push. `wcag22-audit`
89978997
takes 4.5 minutes and `wcag-manual --all` the same; both are documented in `bin/design/README.md`
89988998
for when that is the question.
8999+
9000+
## 2026-09-02 — Route enumeration everywhere, and what the hardcoded lists were hiding
9001+
9002+
Step one of the skill proposal, done here because it is worth doing for this app regardless.
9003+
9004+
**The count was wrong twice before the work started.** The proposal said 17 audits carried a
9005+
hardcoded page list; then, measured more carefully, 14. Both were wrong. `audit.js` takes a path on
9006+
the command line, `audit-selftest.js` deliberately uses one fixture page, and `route-sweep.js`,
9007+
`wcag-audit.js` and others already shell out to `route-targets.rb` — my grep looked for
9008+
`targets.json` and missed every audit that ran the generator directly. The real number was **seven**.
9009+
9010+
That is the same mistake twice in one analysis: grep for one spelling of a thing, read absence as
9011+
fact. It is exactly what this project has been calling *the audit's scope is a claim*, applied to my
9012+
own measurement rather than to code.
9013+
9014+
### What the widening found
9015+
9016+
- **`button-audit`: six real violations.** design.md requires at most three header actions, at most
9017+
one primary, primary last. `/donations/1` and `/purchases/1` emitted the primary *second* with the
9018+
record actions after it — the opposite of what their own comments claimed — and `/requests/1` gave
9019+
the last slot to the destructive *Cancel request*. That last one is precisely the fault reported
9020+
at prompt `[163]` for `/product_drives`, fixed there and never looked for anywhere else. The old
9021+
list held index pages only, so no show page had ever been checked.
9022+
- **The enumerator was itself missing a screen.** `SKIP_ACTION` in `route-targets.rb` matches on the
9023+
bare action name, so `inventory` — added to skip a storage-locations partial — also skipped
9024+
`items#inventory`, a full screen with an `<h1>`, the app shell, and a place in the item
9025+
catalogue's tab strip. **Every audit built on route enumeration inherited that blindness**, which
9026+
is a hardcoded list wearing a different hat. Controller-specific skips are now `SKIP_PAIR`.
9027+
- **`sweep.js` was deleted, not migrated.** `route-sweep.js` performs every check it did, including
9028+
the console-error capture that only looked missing because the variable is called `errors` there.
9029+
Migrating it would have produced two identical audits; keeping it as-is was keeping a hardcoded
9030+
list beside the thing written to replace it.
9031+
- **`table-audit`'s list still named `/users`**, which was deleted in August.
9032+
9033+
### Three findings that were the audit's fault
9034+
9035+
Each confirmed by measuring before changing anything, which is the discipline that the self-test
9036+
harness was built for a day earlier:
9037+
9038+
- A disclosure **trigger inside a collapsed accordion** has a zero-size rect at the origin, so its
9039+
left edge is 0 and matches no grid column. An element with no box cannot be misaligned.
9040+
- A page can **display a tab strip without being one of its tabs**. `/partners/1/approve_application`
9041+
shows the Partners strip and is not on it.
9042+
- That same path **redirects to `/partners` carrying a flash bar**, which puts the strip 72px lower.
9043+
Read first as a tab that does not line up, and then — once deduplicated on the landed path — as
9044+
`/partners` itself being out. A redirect is skipped now, because the destination is a target in
9045+
its own right and is measured when its own turn comes.
9046+
9047+
The landed-versus-requested distinction has now mattered three times, so `visit()` returns where it
9048+
landed and says why in its comment.
9049+
9050+
### The shared seam
9051+
9052+
`bin/design/targets.js` holds the list of screens, the three roles, `signIn` and `visit`. It
9053+
replaced **21 hand-copied `signIn` functions**, seven copies of the role predicates and six of the
9054+
targets-file read — and four of those copies had drifted. One did not sign out first, so a second
9055+
role silently audited the first one's pages. One waited on `networkidle`, which never settles on the
9056+
slowest screens here and has already caused two audits to give up mid-run.
9057+
9058+
That file is also the thing the skill needs: everything above it is a rule about design, everything
9059+
below it is Rails. `TARGETS_CMD` overrides the one command that knows which framework this is.
9060+
9061+
### Discovery over enumeration, where the audit allows it
9062+
9063+
`tab-set-audit` did not just get a longer list — it stopped having one. A tab set is identifiable
9064+
from the page: the strip is the `<nav>` inside `main` holding the `aria-current` link, and the set is
9065+
the hrefs in that strip. Pages sharing a strip are one set. It rediscovered the Kits-in-catalogue
9066+
case that the fixture had hand-coded with an explanatory comment, and it will find the next tab set
9067+
without being told.
9068+
9069+
`overlay-audit` needed the same idea for a different reason: opening every dialog on 150 screens at
9070+
two viewports is slow, so it looks first and works second — one navigation to see whether the page
9071+
has an overlay trigger, and the expensive part only where there is one. The cost is proportional to
9072+
the number of overlays rather than of pages.
9073+
9074+
### The one that did not work, and the measurement I skipped
9075+
9076+
`overlay-audit` was widened with the rest and **reverted**. At 150 screens it never returned; four
9077+
attempts to speed it up — cheap discovery before expensive work, a per-screen instance cap, injecting
9078+
axe-core once per page instead of once per dialog, a `Promise.race` time budget — changed nothing
9079+
material.
9080+
9081+
The reason is the measurement I never took. **The nine-page version takes 525 seconds too** — about
9082+
58 seconds a page. The audit has always been slow and nobody had timed it, so I spent four rounds
9083+
fixing a widening that was never the problem. At 150 screens it would be over two hours.
9084+
9085+
So the order is the other way round: **make it fast, then widen it.** What is known now, recorded in
9086+
the file so the next attempt starts from evidence: navigation is 203ms a screen and not the cost;
9087+
`checkDialogs` on `/organization` alone is 31 seconds; axe injection was wasteful but not the cost;
9088+
and a `Promise.race` budget resolves the race while leaving the slow work running behind it.
9089+
9090+
It is the only audit in the directory still carrying a hardcoded page list, and the README says so
9091+
rather than letting the claim "no audit hardcodes its pages" stand at 95% true.

0 commit comments

Comments
 (0)