@radicaltools/mcp 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,710 @@
1
+ {
2
+ "hub": {
3
+ "id": "concern-mobile-performance",
4
+ "category": "concern",
5
+ "name": "Mobile and perceived performance",
6
+ "description": "How fast a web front end feels and whether it works on a phone: the Core Web Vitals budget in the lab on every change and in the field from real users, for phones and desktops each on its own, Reflow at 320 CSS px, touch target size, and screenshots on phone viewports.",
7
+ "tags": [
8
+ "ux",
9
+ "mobile",
10
+ "performance",
11
+ "core web vitals",
12
+ "lighthouse",
13
+ "reflow",
14
+ "touch targets",
15
+ "visual regression"
16
+ ],
17
+ "requiredMetamodel": "c4-ddd-governance-builtin",
18
+ "concern": {
19
+ "id": "mobile-performance",
20
+ "trigger": "LIST NODES WHERE type = \"webapp\" AND external != true",
21
+ "why": "these are web front ends that people open on phones and computers, so how fast they must feel, how that is measured, and how they must work on a small screen has to be decided.",
22
+ "group": "ux"
23
+ },
24
+ "sources": [
25
+ {
26
+ "title": "web.dev: Web Vitals (LCP, INP, CLS, measured at the 75th percentile)",
27
+ "url": "https://web.dev/articles/vitals"
28
+ },
29
+ {
30
+ "title": "web.dev: How the Core Web Vitals metrics thresholds were defined",
31
+ "url": "https://web.dev/articles/defining-core-web-vitals-thresholds"
32
+ },
33
+ {
34
+ "title": "web.dev: Why lab and field data can be different",
35
+ "url": "https://web.dev/articles/lab-and-field-data-differences"
36
+ },
37
+ {
38
+ "title": "GoogleChrome/web-vitals: the library that measures the vitals in the page",
39
+ "url": "https://github.com/GoogleChrome/web-vitals"
40
+ },
41
+ {
42
+ "title": "Lighthouse CI: configuration (collect, settings, preset)",
43
+ "url": "https://github.com/GoogleChrome/lighthouse-ci/blob/main/docs/configuration.md"
44
+ },
45
+ {
46
+ "title": "Lighthouse: network and CPU throttling",
47
+ "url": "https://github.com/GoogleChrome/lighthouse/blob/main/docs/throttling.md"
48
+ },
49
+ {
50
+ "title": "Lighthouse: score variability",
51
+ "url": "https://github.com/GoogleChrome/lighthouse/blob/main/docs/variability.md"
52
+ },
53
+ {
54
+ "title": "W3C: Understanding WCAG 2.2, Success Criterion 1.4.10 Reflow",
55
+ "url": "https://www.w3.org/WAI/WCAG22/Understanding/reflow.html"
56
+ },
57
+ {
58
+ "title": "W3C: Understanding WCAG 2.2, Success Criterion 2.5.8 Target Size (Minimum)",
59
+ "url": "https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html"
60
+ },
61
+ {
62
+ "title": "W3C: Understanding WCAG 2.2, Success Criterion 2.5.5 Target Size (Enhanced)",
63
+ "url": "https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html"
64
+ },
65
+ {
66
+ "title": "Apple Human Interface Guidelines: Accessibility (hit targets of at least 44 × 44 pt)",
67
+ "url": "https://developer.apple.com/design/human-interface-guidelines/accessibility"
68
+ },
69
+ {
70
+ "title": "Playwright: Emulation (devices, viewport, isMobile, hasTouch)",
71
+ "url": "https://playwright.dev/docs/emulation"
72
+ },
73
+ {
74
+ "title": "Playwright: Visual comparisons (toHaveScreenshot)",
75
+ "url": "https://playwright.dev/docs/test-snapshots"
76
+ }
77
+ ],
78
+ "templateParams": [
79
+ {
80
+ "key": "DEVICES",
81
+ "title": "Devices",
82
+ "label": "On which devices is the budget measured?",
83
+ "hint": "Phones and desktops differ several times over in CPU and network, so Google judges the vitals for each on its own. Measuring a device class nobody uses costs CI time; leaving out the one most users have hides where the budget breaks.",
84
+ "defaultValue": "mobile",
85
+ "options": [
86
+ {
87
+ "value": "mobile",
88
+ "label": "phones (mobile first)",
89
+ "description": "The lab runs Lighthouse's mobile default and the field data is judged for phones. Pick it for public sites and apps where most visits come from phones, which is most of them; desktops then pass by a wide margin."
90
+ },
91
+ {
92
+ "value": "both",
93
+ "label": "phones and desktops, each against the budget",
94
+ "description": "Both lab presets run on every pull request and both device classes are judged in the field. Pick it when a large share of the work happens on desktops (business tools, dashboards) and phones matter too."
95
+ },
96
+ {
97
+ "value": "desktop",
98
+ "label": "desktops only",
99
+ "description": "Only Lighthouse's desktop preset runs. Pick it for an internal tool used on managed desktops, where analytics show almost no phones. Reflow at 320 CSS px and target size still hold: people zoom on desktops too."
100
+ }
101
+ ]
102
+ },
103
+ {
104
+ "key": "LAB",
105
+ "title": "Lab budget",
106
+ "label": "How does the lab hold each pull request?",
107
+ "hint": "Fixed limits say what good is; a front end that is already slower than that would fail every pull request until it is rewritten. Comparing with the main branch keeps it from getting worse while it is brought within the budget.",
108
+ "defaultValue": "budget",
109
+ "options": [
110
+ {
111
+ "value": "budget",
112
+ "label": "fixed limits from the budget",
113
+ "description": "Each main page must stay within the LCP, CLS and Total Blocking Time limits on every pull request. Pick it for a new front end, or one that is already within the budget."
114
+ },
115
+ {
116
+ "value": "baseline",
117
+ "label": "no regression against the main branch",
118
+ "description": "Each value may be only a set percentage worse than the median of the main branch's latest runs. Pick it for an existing front end above the budget, until it is within it; then switch to fixed limits."
119
+ }
120
+ ]
121
+ },
122
+ {
123
+ "key": "FIELD",
124
+ "title": "Field data",
125
+ "label": "Where do the field vitals come from?",
126
+ "hint": "The lab simulates one phone on one network; what users get is only known from their own browsers. Field data needs a page that reports it, an endpoint that stores it and a job that summarises it.",
127
+ "defaultValue": "rum",
128
+ "options": [
129
+ {
130
+ "value": "rum",
131
+ "label": "our own real-user monitoring (the web-vitals library sending to our endpoint)",
132
+ "description": "The page reports LCP, INP and CLS with the web-vitals library to an endpoint of ours; a nightly job writes the 75th percentiles as measurements. Pick it when the front end is live, or about to be, and you can store a few events per visit."
133
+ },
134
+ {
135
+ "value": "none",
136
+ "label": "none yet: the lab stands in until there is real-user data",
137
+ "description": "Only the lab budget is checked. Pick it before launch, or when no endpoint can be added yet; plan the field data, as only it shows INP and real networks."
138
+ }
139
+ ]
140
+ },
141
+ {
142
+ "key": "TOUCH",
143
+ "title": "Target size",
144
+ "label": "How large must a touch or click target be?",
145
+ "hint": "Small targets are missed by thumbs, tremors and people on the move. WCAG 2.2 AA asks for 24 × 24 CSS px (or enough space around a smaller one); platform guides ask for more.",
146
+ "defaultValue": "24",
147
+ "options": [
148
+ {
149
+ "value": "24",
150
+ "label": "24 × 24 CSS px (WCAG 2.2 Target Size Minimum, level AA)",
151
+ "description": "What WCAG 2.2 AA, EN 301 549 and the European Accessibility Act require, with its exceptions (a link in a sentence, a smaller target with enough space around it). Pick it for dense business screens used mostly with a mouse."
152
+ },
153
+ {
154
+ "value": "44",
155
+ "label": "44 × 44 CSS px (Apple's guideline, WCAG 2.5.5 level AAA)",
156
+ "description": "What Apple's guidelines and WCAG 2.5.5 (AAA) ask, close to Material Design's 48 × 48 dp. Pick it for front ends used mostly on phones, by the public, or by people on the move."
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "key": "VISUAL",
162
+ "title": "Screenshots",
163
+ "label": "Are pages compared with approved screenshots on phones?",
164
+ "hint": "A layout that breaks on a phone is seldom seen by a team working on desktops. Screenshot comparison catches it, at the cost of approving every intended change.",
165
+ "defaultValue": "yes",
166
+ "options": [
167
+ {
168
+ "value": "yes",
169
+ "label": "screenshots on phone viewports compared on every pull request",
170
+ "description": "Playwright takes each main page on iPhone 15 and Pixel 7 viewports and compares it with the approved screenshot. Pick it when the front end is used on phones and the layout changes often. Not for a desktop-only tool."
171
+ },
172
+ {
173
+ "value": "no",
174
+ "label": "no screenshot comparison",
175
+ "description": "The layout test (Reflow, target size) is the only check of the layout on phones. Pick it for a desktop-only tool, or while screens change too often for approved screenshots to last."
176
+ }
177
+ ]
178
+ },
179
+ {
180
+ "key": "LCP_MS",
181
+ "label": "Largest Contentful Paint at most (ms)?",
182
+ "defaultValue": "2500",
183
+ "type": "number"
184
+ },
185
+ {
186
+ "key": "INP_MS",
187
+ "label": "Interaction to Next Paint at the 75th percentile of real visits at most (ms)?",
188
+ "defaultValue": "200",
189
+ "type": "number"
190
+ },
191
+ {
192
+ "key": "CLS",
193
+ "label": "Cumulative Layout Shift at most?",
194
+ "defaultValue": "0.1",
195
+ "type": "number"
196
+ },
197
+ {
198
+ "key": "TBT_MS",
199
+ "label": "Total Blocking Time in the lab at most, on the reference machine (ms)?",
200
+ "defaultValue": "200",
201
+ "type": "number"
202
+ },
203
+ {
204
+ "key": "LAB_MARGIN",
205
+ "label": "With no regression: how much worse than the main branch may a lab value be (%)?",
206
+ "defaultValue": "10",
207
+ "type": "number"
208
+ }
209
+ ]
210
+ },
211
+ "nodes": [
212
+ {
213
+ "id": "need",
214
+ "type": "need",
215
+ "label": "Fast and usable on the devices people have",
216
+ "x": 0,
217
+ "y": 0,
218
+ "kind": "brief",
219
+ "source": "Hub concern pack: Mobile and perceived performance",
220
+ "description": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
221
+ },
222
+ {
223
+ "id": "req-lab-budget",
224
+ "type": "requirement",
225
+ "label": "Lab budget holds",
226
+ "x": 260,
227
+ "y": 0,
228
+ "ears_type": "event-driven",
229
+ "trigger": "a pull request changes the front end",
230
+ "action": "keep every main page, in the median of three Lighthouse runs for {{DEVICES}}, within a Largest Contentful Paint of {{LCP_MS}} ms, a Cumulative Layout Shift of {{CLS}} and a Total Blocking Time of {{TBT_MS}} ms on the reference machine",
231
+ "rationale": "Field data arrives after release; the lab catches a regression in the pull request that causes it. Total Blocking Time is the lab's stand-in for INP, which needs real interactions (web.dev, Why lab and field data can be different; Lighthouse CI).",
232
+ "hubWhen": {
233
+ "LAB": [
234
+ "budget"
235
+ ]
236
+ }
237
+ },
238
+ {
239
+ "id": "req-lab-trend",
240
+ "type": "requirement",
241
+ "label": "No lab regression",
242
+ "x": 260,
243
+ "y": 130,
244
+ "ears_type": "event-driven",
245
+ "trigger": "a pull request changes the front end",
246
+ "action": "keep the Largest Contentful Paint, Cumulative Layout Shift and Total Blocking Time of every main page, in the median of three Lighthouse runs for {{DEVICES}}, within {{LAB_MARGIN}}% of the median of the main branch's latest seven runs",
247
+ "rationale": "A front end above the budget cannot meet fixed limits at once; holding the line against the main branch stops it getting worse while it is brought within them (Lighthouse, score variability: compare like with like, on one class of machine).",
248
+ "hubWhen": {
249
+ "LAB": [
250
+ "baseline"
251
+ ]
252
+ }
253
+ },
254
+ {
255
+ "id": "req-field-vitals",
256
+ "type": "requirement",
257
+ "label": "Field vitals within budget",
258
+ "x": 260,
259
+ "y": 260,
260
+ "ears_type": "ubiquitous",
261
+ "action": "meet, at the 75th percentile of real page loads over 28 days, for each page group and for {{DEVICES}}, a Largest Contentful Paint within {{LCP_MS}} ms, an Interaction to Next Paint within {{INP_MS}} ms and a Cumulative Layout Shift of at most {{CLS}}",
262
+ "rationale": "These are the thresholds of a \"good\" experience, judged at the 75th percentile of field data per device class (web.dev, Web Vitals: LCP 2.5 s, INP 200 ms, CLS 0.1; How the thresholds were defined).",
263
+ "hubWhen": {
264
+ "FIELD": [
265
+ "rum"
266
+ ]
267
+ }
268
+ },
269
+ {
270
+ "id": "req-reflow",
271
+ "type": "requirement",
272
+ "label": "Reflows at 320 CSS px",
273
+ "x": 260,
274
+ "y": 390,
275
+ "ears_type": "ubiquitous",
276
+ "action": "present every page in a window 320 CSS px wide, as at 400% zoom of a 1280 px window, and on phone viewports, with 0 px of horizontal scrolling and nothing cut off, except parts that need two dimensions to be read (maps, diagrams, wide data tables), which scroll inside their own container",
277
+ "rationale": "People who zoom to read, and people on small phones, lose content that sits beside the viewport; WCAG 2.2 AA requires reflow at 320 CSS px (W3C, Understanding SC 1.4.10 Reflow)."
278
+ },
279
+ {
280
+ "id": "req-targets",
281
+ "type": "requirement",
282
+ "label": "Targets large enough",
283
+ "x": 260,
284
+ "y": 520,
285
+ "ears_type": "ubiquitous",
286
+ "action": "make every pointer target at least {{TOUCH}}, except a link inside a sentence, a control whose label of that size activates it, and a smaller target spaced so that a circle of that diameter on its centre touches no other target",
287
+ "rationale": "Small, crowded targets are missed by thumbs, tremors and people on the move (W3C, Understanding SC 2.5.8 Target Size (Minimum) and 2.5.5 Target Size (Enhanced); Apple Human Interface Guidelines)."
288
+ },
289
+ {
290
+ "id": "req-phone-screens",
291
+ "type": "requirement",
292
+ "label": "Phone screenshots approved",
293
+ "x": 260,
294
+ "y": 650,
295
+ "ears_type": "event-driven",
296
+ "trigger": "a pull request changes the front end",
297
+ "action": "compare each main page on iPhone 15 and Pixel 7 viewports with its approved screenshot, and refuse a difference until a person approves the new screenshot in the same pull request",
298
+ "rationale": "A layout that breaks on a phone is seldom seen by a team that works on desktops; emulated viewports make the comparison repeatable (Playwright, Emulation and Visual comparisons).",
299
+ "hubWhen": {
300
+ "VISUAL": [
301
+ "yes"
302
+ ]
303
+ }
304
+ },
305
+ {
306
+ "id": "sc-lab-budget",
307
+ "type": "scenario",
308
+ "label": "Heavier page refused",
309
+ "x": 520,
310
+ "y": 0,
311
+ "given": "a pull request that makes the largest image of a main page three times heavier",
312
+ "when": "Lighthouse CI collects and radical check judges the measurements",
313
+ "then": "the LCP condition fails for each device class measured, naming the page's value against {{LCP_MS}} ms",
314
+ "hubWhen": {
315
+ "LAB": [
316
+ "budget"
317
+ ]
318
+ }
319
+ },
320
+ {
321
+ "id": "sc-lab-trend",
322
+ "type": "scenario",
323
+ "label": "Regression refused",
324
+ "x": 520,
325
+ "y": 130,
326
+ "given": "a main page whose LCP on main is a steady 3800 ms",
327
+ "when": "a pull request makes it 25% slower",
328
+ "then": "the LCP condition fails against the main branch's median plus {{LAB_MARGIN}}%",
329
+ "hubWhen": {
330
+ "LAB": [
331
+ "baseline"
332
+ ]
333
+ }
334
+ },
335
+ {
336
+ "id": "sc-field-vitals",
337
+ "type": "scenario",
338
+ "label": "Field vitals within budget",
339
+ "x": 520,
340
+ "y": 260,
341
+ "given": "28 days of real-user measurements per page group and device class",
342
+ "when": "the nightly job writes their 75th percentiles and radical check judges them",
343
+ "then": "LCP is within {{LCP_MS}} ms, INP within {{INP_MS}} ms and CLS at most {{CLS}} for the worst page group of each device class",
344
+ "hubWhen": {
345
+ "FIELD": [
346
+ "rum"
347
+ ]
348
+ }
349
+ },
350
+ {
351
+ "id": "sc-reflow",
352
+ "type": "scenario",
353
+ "label": "No sideways scrolling",
354
+ "x": 520,
355
+ "y": 390,
356
+ "given": "each main page in a 320 CSS px window and on the phone viewports",
357
+ "when": "the layout test measures how far the page scrolls sideways",
358
+ "then": "it scrolls 0 px sideways in each"
359
+ },
360
+ {
361
+ "id": "sc-targets",
362
+ "type": "scenario",
363
+ "label": "Small icon button caught",
364
+ "x": 520,
365
+ "y": 520,
366
+ "given": "a main page with a 16 × 16 CSS px icon button beside another button",
367
+ "when": "the layout test measures the targets",
368
+ "then": "it counts the icon button as a small target and the condition on ux.mobile.small_targets fails"
369
+ },
370
+ {
371
+ "id": "sc-phone-screens",
372
+ "type": "scenario",
373
+ "label": "Broken phone layout caught",
374
+ "x": 520,
375
+ "y": 650,
376
+ "given": "approved screenshots of the main pages on iPhone 15 and Pixel 7",
377
+ "when": "a pull request widens a fixed element past the phone's width",
378
+ "then": "the screenshot comparison fails on both phones until the change is fixed or the new screenshots are approved",
379
+ "hubWhen": {
380
+ "VISUAL": [
381
+ "yes"
382
+ ]
383
+ }
384
+ },
385
+ {
386
+ "id": "adr-perf-budget",
387
+ "type": "adr",
388
+ "label": "Pages held to the Core Web Vitals",
389
+ "x": 780,
390
+ "y": 0,
391
+ "concern": "mobile-performance",
392
+ "status": "accepted",
393
+ "date": "",
394
+ "context": "This element is a web front end that people open on their own phones and computers, over networks they do not choose. The forces: most visits come from mid-range phones on mobile networks, where every image and script costs seconds that a developer's laptop never shows; what users feel is how soon the main content appears (LCP), how soon a tap answers (INP) and whether the page jumps while it loads (CLS), and Google measures exactly these at the 75th percentile of real visits; lab runs on every change are repeatable but simulate one phone on one network, field data is the truth but arrives days later and only once the page is live; lab timings depend on the CPU of the machine that runs them; people zoom, use small screens and hit targets with a thumb, so a layout that scrolls sideways at 320 CSS px or a 16 px icon button fails some of them (WCAG 2.2: Reflow, Target Size); and a layout that breaks on a phone is seldom seen by a team that works on desktops.",
395
+ "decision": "Pages are held to the Core Web Vitals at web.dev's \"good\" thresholds, for {{DEVICES}}, each device class judged on its own: Largest Contentful Paint within {{LCP_MS}} ms, Interaction to Next Paint within {{INP_MS}} ms and Cumulative Layout Shift at most {{CLS}}, at the 75th percentile of real page loads over 28 days. In the lab, on every pull request: Lighthouse CI collects three runs of each main page (Lighthouse's mobile default for phones, its desktop preset for desktops) and only collects; radical sense lighthouse reads the reports, and the fitness functions' conditions judge the medians, so the limits live in the model and not in lighthouserc. The lab is held with {{LAB}}. The lab has no INP: Total Blocking Time within {{TBT_MS}} ms stands in for it, its limit scaled to the speed of the runner, because TBT is CPU time; LCP is not scaled, and the runners are kept of one class. Field data: {{FIELD}}. With our own real-user monitoring, the page reports with the web-vitals library to our endpoint, and a nightly job writes the 75th percentiles per page group and device class as radical-metrics/1 for radical check. The Chrome UX Report is not read by any check: it covers only origins with enough Chrome traffic, trails by 28 days and cannot be tied to a release; PageSpeed Insights shows it to anyone who looks. The JavaScript budget per route is decided in the Frontend stack pack; accessibility as a whole in the Accessibility pack.",
396
+ "consequences": "• A regression fails the pull request that causes it, with the page, the device class and the value.\n• The numbers live in the model: changing the budget is a change of the decision's details, not of a CI file.\n• Lab runs add minutes to every pull request (three runs a page, per device class); keep the list of main pages short.\n• The lab simulates one phone and one network; only the field data, when there is any, says what users get, and it arrives days after a release.\n• A runner of another class shifts lab timings: TBT's limit follows it, LCP's does not.",
397
+ "alternatives": "1. Assertions in lighthouserc: the limits then live in a CI file, apart from the decision, and the model cannot show them.\n2. Lighthouse's performance score as the gate: one number that mixes metrics and changes its weights between versions.\n3. Field data only (CrUX or RUM): the truth, but only after release, and no check of the pull request that caused a regression.\n4. A commercial RUM service (SpeedCurve, Datadog, New Relic): the same data without our own endpoint, at a price per page view; its export then writes the measurements."
398
+ },
399
+ {
400
+ "id": "adr-mobile-layout",
401
+ "type": "adr",
402
+ "label": "Pages reflow and can be touched",
403
+ "x": 780,
404
+ "y": 130,
405
+ "concern": "mobile-performance",
406
+ "status": "accepted",
407
+ "date": "",
408
+ "context": "This element is a web front end that people open on their own phones and computers, over networks they do not choose. The forces: most visits come from mid-range phones on mobile networks, where every image and script costs seconds that a developer's laptop never shows; what users feel is how soon the main content appears (LCP), how soon a tap answers (INP) and whether the page jumps while it loads (CLS), and Google measures exactly these at the 75th percentile of real visits; lab runs on every change are repeatable but simulate one phone on one network, field data is the truth but arrives days later and only once the page is live; lab timings depend on the CPU of the machine that runs them; people zoom, use small screens and hit targets with a thumb, so a layout that scrolls sideways at 320 CSS px or a 16 px icon button fails some of them (WCAG 2.2: Reflow, Target Size); and a layout that breaks on a phone is seldom seen by a team that works on desktops.",
409
+ "decision": "Every page works in a window 320 CSS px wide (a 1280 px window at 400% zoom) and on phone viewports without scrolling sideways, as WCAG 2.2 SC 1.4.10 requires; parts that need two dimensions (maps, diagrams, wide tables) scroll inside their own container. Every pointer target is at least {{TOUCH}}, with the exceptions WCAG 2.2 SC 2.5.8 allows. A Playwright test measures both on every pull request in four viewports (320 CSS px; iPhone 15 and Pixel 7 as Playwright emulates them; a 1280 px desktop) and writes what it found as radical-metrics/1, which the model's conditions judge. Screenshots on phones: {{VISUAL}}; when compared, they are taken in the Playwright Docker image of the version in use, locally and in CI alike, as fonts and rendering differ between systems. The rest of WCAG 2.2 AA (automated rules, the keyboard, the manual audit) is decided in the Accessibility pack; the framework and browser support in the Frontend stack pack.",
410
+ "consequences": "• A layout that scrolls sideways or a target too small to hit fails the pull request, with the page, viewport and element in the test report.\n• Emulated phones are not real ones: CPU, memory and the browser chrome of a real device are not tested here.\n• With screenshots, every intended visual change needs its new screenshots approved in the pull request.\n• Larger targets take room: dense tables and toolbars need a design that spaces them.",
411
+ "alternatives": "1. Manual checks on a device bench before release: catches what emulation misses, but late and by hand.\n2. axe-core's target-size rule alone: checks 2.5.8 but not Reflow, and gives no count to judge.\n3. A cloud device farm (BrowserStack, Sauce Labs) for every pull request: real devices, at a price per minute and with slower runs."
412
+ },
413
+ {
414
+ "id": "ff-lab-mobile",
415
+ "type": "fitness-fn",
416
+ "label": "Lab budget on phones",
417
+ "x": 1040,
418
+ "y": 0,
419
+ "characteristic": "performance-efficiency",
420
+ "scope": "atomic",
421
+ "cadence": "triggered",
422
+ "trigger": "pull-request",
423
+ "invocation": "automated",
424
+ "measure": "lighthouse\nmachine",
425
+ "metrics": "web.lab.lcp.max{device=mobile} <= {{LCP_MS}} ms\nweb.lab.cls.max{device=mobile} <= {{CLS}}\nweb.lab.tbt.max{device=mobile} <= {{TBT_MS}} ms scaled",
426
+ "description": "On every pull request Lighthouse CI starts the preview build and runs Lighthouse's mobile default (a mid-range phone on a slow 4G connection, simulated) three times on each main page, writing the reports to .lighthouseci; lighthouserc.cjs holds no assertions, because the limits are this fitness function's conditions and radical check judges them. radical sense lighthouse reads the reports: the median per page and device class, and the worst page as web.lab.*.max{device=mobile}. Total Blocking Time stands in for INP, which needs real interactions (a navigation report has none). TBT is main-thread CPU time, so its limit is scaled: multiplied by the speed ratio the machine sensor measures when the runner is slower than the reference machine, never below ×1. LCP is not scaled. Under Lighthouse's simulated throttling it is computed from the observed load, with the network modelled and the CPU work multiplied, so a slow runner does lengthen it; but on most pages the modelled network dominates, and stretching the whole limit by the CPU ratio would let a heavier page pass on a slow runner. Keep the runners of one class instead (or calibrate throttling.cpuSlowdownMultiplier from the benchmarkIndex in the reports, as Lighthouse's throttling documentation describes); a page that renders in the browser, whose LCP waits on JavaScript, may add \"scaled\" to its LCP line. Pages behind sign-in need a puppeteerScript that signs in first.\n\nThreshold: For the slowest main page, median of three runs with Lighthouse's mobile default (a mid-range phone on a slow 4G connection, simulated): LCP within {{LCP_MS}} ms, CLS at most {{CLS}}, and Total Blocking Time within {{TBT_MS}} ms on the reference machine, that limit scaled to the speed of the runner\n\nTool: Lighthouse CI (@lhci/cli) with radical sense lighthouse\n\n```js\n// lighthouserc.cjs: Lighthouse CI only collects; the model's conditions judge the numbers\nmodule.exports = {\n ci: {\n collect: {\n startServerCommand: 'npm run preview',\n url: ['http://localhost:4173/', 'http://localhost:4173/search', 'http://localhost:4173/checkout'],\n numberOfRuns: 3,\n // puppeteerScript: './lighthouse-login.cjs', // signs in first, for pages behind sign-in\n },\n },\n}\n// The pull-request job (no assert, no upload: radical check fails the job):\n// npx @lhci/cli@0.15.1 collect # phones: Lighthouse's mobile default\n// npx @lhci/cli@0.15.1 collect --additive --settings.preset=desktop # desktops; without --additive when only desktops count\n// npx radical sense run --trigger pull-request --out reports/metrics # lighthouse reads .lighthouseci, machine times the runner\n// npx radical check --metrics reports/metrics\n```",
427
+ "hubWhen": {
428
+ "DEVICES": [
429
+ "mobile",
430
+ "both"
431
+ ],
432
+ "LAB": [
433
+ "budget"
434
+ ]
435
+ }
436
+ },
437
+ {
438
+ "id": "ff-lab-desktop",
439
+ "type": "fitness-fn",
440
+ "label": "Lab budget on desktops",
441
+ "x": 1040,
442
+ "y": 130,
443
+ "characteristic": "performance-efficiency",
444
+ "scope": "atomic",
445
+ "cadence": "triggered",
446
+ "trigger": "pull-request",
447
+ "invocation": "automated",
448
+ "measure": "lighthouse\nmachine",
449
+ "metrics": "web.lab.lcp.max{device=desktop} <= {{LCP_MS}} ms\nweb.lab.cls.max{device=desktop} <= {{CLS}}\nweb.lab.tbt.max{device=desktop} <= {{TBT_MS}} ms scaled",
450
+ "description": "On every pull request Lighthouse CI starts the preview build and runs Lighthouse's desktop preset three times on each main page, writing the reports to .lighthouseci; lighthouserc.cjs holds no assertions, because the limits are this fitness function's conditions and radical check judges them. radical sense lighthouse reads the reports: the median per page and device class, and the worst page as web.lab.*.max{device=desktop}. Total Blocking Time stands in for INP, which needs real interactions (a navigation report has none). TBT is main-thread CPU time, so its limit is scaled: multiplied by the speed ratio the machine sensor measures when the runner is slower than the reference machine, never below ×1. LCP is not scaled. Under Lighthouse's simulated throttling it is computed from the observed load, with the network modelled and the CPU work multiplied, so a slow runner does lengthen it; but on most pages the modelled network dominates, and stretching the whole limit by the CPU ratio would let a heavier page pass on a slow runner. Keep the runners of one class instead (or calibrate throttling.cpuSlowdownMultiplier from the benchmarkIndex in the reports, as Lighthouse's throttling documentation describes); a page that renders in the browser, whose LCP waits on JavaScript, may add \"scaled\" to its LCP line. Pages behind sign-in need a puppeteerScript that signs in first.\n\nThreshold: For the slowest main page, median of three runs with Lighthouse's desktop preset: LCP within {{LCP_MS}} ms, CLS at most {{CLS}}, and Total Blocking Time within {{TBT_MS}} ms on the reference machine, that limit scaled to the speed of the runner\n\nTool: Lighthouse CI (@lhci/cli) with radical sense lighthouse\n\n```js\n// lighthouserc.cjs: Lighthouse CI only collects; the model's conditions judge the numbers\nmodule.exports = {\n ci: {\n collect: {\n startServerCommand: 'npm run preview',\n url: ['http://localhost:4173/', 'http://localhost:4173/search', 'http://localhost:4173/checkout'],\n numberOfRuns: 3,\n // puppeteerScript: './lighthouse-login.cjs', // signs in first, for pages behind sign-in\n },\n },\n}\n// The pull-request job (no assert, no upload: radical check fails the job):\n// npx @lhci/cli@0.15.1 collect # phones: Lighthouse's mobile default\n// npx @lhci/cli@0.15.1 collect --additive --settings.preset=desktop # desktops; without --additive when only desktops count\n// npx radical sense run --trigger pull-request --out reports/metrics # lighthouse reads .lighthouseci, machine times the runner\n// npx radical check --metrics reports/metrics\n```",
451
+ "hubWhen": {
452
+ "DEVICES": [
453
+ "both",
454
+ "desktop"
455
+ ],
456
+ "LAB": [
457
+ "budget"
458
+ ]
459
+ }
460
+ },
461
+ {
462
+ "id": "ff-lab-mobile-trend",
463
+ "type": "fitness-fn",
464
+ "label": "No lab regression on phones",
465
+ "x": 1040,
466
+ "y": 260,
467
+ "characteristic": "performance-efficiency",
468
+ "scope": "atomic",
469
+ "cadence": "triggered",
470
+ "trigger": "pull-request",
471
+ "invocation": "automated",
472
+ "measure": "lighthouse",
473
+ "metrics": "web.lab.lcp.max{device=mobile} <= baseline + {{LAB_MARGIN}}%\nweb.lab.cls.max{device=mobile} <= baseline + {{LAB_MARGIN}}%\nweb.lab.tbt.max{device=mobile} <= baseline + {{LAB_MARGIN}}%",
474
+ "description": "For a front end that starts above the budget: every pull request runs Lighthouse's mobile default (a mid-range phone on a slow 4G connection, simulated) three times on each main page and radical sense lighthouse reads the medians; each value may be at most {{LAB_MARGIN}}% worse than the main branch's. The job on main keeps its reports/metrics file as an artifact, and the pull request's job passes the latest seven to radical check with --baseline, which compares with their median. Both run on runners of one class, so the speed of the machine cancels out. lighthouserc.cjs holds no assertions: the conditions are the model's. When the pages are within the budget ({{LCP_MS}} ms LCP, {{CLS}} CLS, {{TBT_MS}} ms TBT), answer the lab question again with fixed limits.\n\nThreshold: For the slowest main page, median of three runs with Lighthouse's mobile default (a mid-range phone on a slow 4G connection, simulated): LCP, CLS and Total Blocking Time each at most {{LAB_MARGIN}}% above the median of the main branch's latest seven runs\n\nTool: Lighthouse CI (@lhci/cli) with radical sense lighthouse\n\n```js\n// lighthouserc.cjs: Lighthouse CI only collects; the model's conditions judge the numbers\nmodule.exports = {\n ci: {\n collect: {\n startServerCommand: 'npm run preview',\n url: ['http://localhost:4173/', 'http://localhost:4173/search', 'http://localhost:4173/checkout'],\n numberOfRuns: 3,\n // puppeteerScript: './lighthouse-login.cjs', // signs in first, for pages behind sign-in\n },\n },\n}\n// The pull-request job (no assert, no upload: radical check fails the job):\n// npx @lhci/cli@0.15.1 collect # phones: Lighthouse's mobile default\n// npx @lhci/cli@0.15.1 collect --additive --settings.preset=desktop # desktops; without --additive when only desktops count\n// npx radical sense run --trigger pull-request --out reports/metrics # lighthouse reads .lighthouseci, machine times the runner\n// npx radical check --metrics reports/metrics\n```",
475
+ "hubWhen": {
476
+ "DEVICES": [
477
+ "mobile",
478
+ "both"
479
+ ],
480
+ "LAB": [
481
+ "baseline"
482
+ ]
483
+ }
484
+ },
485
+ {
486
+ "id": "ff-lab-desktop-trend",
487
+ "type": "fitness-fn",
488
+ "label": "No lab regression on desktops",
489
+ "x": 1040,
490
+ "y": 390,
491
+ "characteristic": "performance-efficiency",
492
+ "scope": "atomic",
493
+ "cadence": "triggered",
494
+ "trigger": "pull-request",
495
+ "invocation": "automated",
496
+ "measure": "lighthouse",
497
+ "metrics": "web.lab.lcp.max{device=desktop} <= baseline + {{LAB_MARGIN}}%\nweb.lab.cls.max{device=desktop} <= baseline + {{LAB_MARGIN}}%\nweb.lab.tbt.max{device=desktop} <= baseline + {{LAB_MARGIN}}%",
498
+ "description": "For a front end that starts above the budget: every pull request runs Lighthouse's desktop preset three times on each main page and radical sense lighthouse reads the medians; each value may be at most {{LAB_MARGIN}}% worse than the main branch's. The job on main keeps its reports/metrics file as an artifact, and the pull request's job passes the latest seven to radical check with --baseline, which compares with their median. Both run on runners of one class, so the speed of the machine cancels out. lighthouserc.cjs holds no assertions: the conditions are the model's. When the pages are within the budget ({{LCP_MS}} ms LCP, {{CLS}} CLS, {{TBT_MS}} ms TBT), answer the lab question again with fixed limits.\n\nThreshold: For the slowest main page, median of three runs with Lighthouse's desktop preset: LCP, CLS and Total Blocking Time each at most {{LAB_MARGIN}}% above the median of the main branch's latest seven runs\n\nTool: Lighthouse CI (@lhci/cli) with radical sense lighthouse\n\n```js\n// lighthouserc.cjs: Lighthouse CI only collects; the model's conditions judge the numbers\nmodule.exports = {\n ci: {\n collect: {\n startServerCommand: 'npm run preview',\n url: ['http://localhost:4173/', 'http://localhost:4173/search', 'http://localhost:4173/checkout'],\n numberOfRuns: 3,\n // puppeteerScript: './lighthouse-login.cjs', // signs in first, for pages behind sign-in\n },\n },\n}\n// The pull-request job (no assert, no upload: radical check fails the job):\n// npx @lhci/cli@0.15.1 collect # phones: Lighthouse's mobile default\n// npx @lhci/cli@0.15.1 collect --additive --settings.preset=desktop # desktops; without --additive when only desktops count\n// npx radical sense run --trigger pull-request --out reports/metrics # lighthouse reads .lighthouseci, machine times the runner\n// npx radical check --metrics reports/metrics\n```",
499
+ "hubWhen": {
500
+ "DEVICES": [
501
+ "both",
502
+ "desktop"
503
+ ],
504
+ "LAB": [
505
+ "baseline"
506
+ ]
507
+ }
508
+ },
509
+ {
510
+ "id": "ff-field-vitals",
511
+ "type": "fitness-fn",
512
+ "label": "Field vitals within budget",
513
+ "x": 1040,
514
+ "y": 520,
515
+ "characteristic": "performance-efficiency",
516
+ "scope": "holistic",
517
+ "cadence": "triggered",
518
+ "trigger": "nightly",
519
+ "invocation": "automated",
520
+ "description": "The page reports LCP, INP and CLS from real visits with the web-vitals library, sending each with navigator.sendBeacon to /rum, which stores the name, the value, the device class (mobile when the user agent contains \"Mobi\", as MDN advises, else desktop) and the page group in rum_events. A nightly job runs the script below: the 75th percentile per metric, device class and page group over the last 28 days (page groups with fewer than 100 loads left out), and the worst page group per device class as web.field.*.p75.max, written as a radical-metrics/1 file that radical check reads with --metrics. No sensor of radical sense reads it, so this fitness function states no measure; nothing reads the Chrome UX Report either (see the decision).\n\nThreshold: 75th percentile over 28 days, for the worst page group of each device class measured: LCP within {{LCP_MS}} ms, INP within {{INP_MS}} ms, CLS at most {{CLS}}. Once the nightly job writes its file, these conditions go into this fitness function's metrics (a pack names only the built-in sensors): web.field.lcp.p75.max{device=mobile} <= {{LCP_MS}} ms, web.field.inp.p75.max{device=mobile} <= {{INP_MS}} ms, web.field.cls.p75.max{device=mobile} <= {{CLS}}, and the same with device=desktop for each device class measured\n\nTool: web-vitals 6.x in the page; a nightly Node.js script over the RUM table (PostgreSQL, pg 8.x); radical check --metrics\n\n```ts\n// src/rum.ts, loaded by every page: what real visits get\nimport { onCLS, onINP, onLCP, type Metric } from 'web-vitals'\n\nconst device = /Mobi/i.test(navigator.userAgent) ? 'mobile' : 'desktop'\nconst pageGroup = document.body.dataset.pageGroup ?? location.pathname\nfunction send({ name, value }: Metric): void {\n navigator.sendBeacon('/rum', JSON.stringify({ name, value, device, page_group: pageGroup }))\n}\nonLCP(send)\nonINP(send)\nonCLS(send)\n\n// scripts/rum-metrics.mts, nightly:\n// node scripts/rum-metrics.mts > reports/metrics/rum.json && npx radical check --metrics reports/metrics\nimport pg from 'pg'\n\nconst METRIC: Record<string, string> = { LCP: 'web.field.lcp.p75', INP: 'web.field.inp.p75', CLS: 'web.field.cls.p75' }\nconst UNIT: Record<string, string | undefined> = { LCP: 'ms', INP: 'ms' }\nconst db = new pg.Client() // PGHOST, PGDATABASE, PGUSER, PGPASSWORD\nawait db.connect()\nconst { rows } = await db.query(`\n SELECT name, device, page_group, percentile_cont(0.75) WITHIN GROUP (ORDER BY value) AS p75\n FROM rum_events\n WHERE received_at > now() - interval '28 days'\n GROUP BY name, device, page_group\n HAVING count(*) >= 100`)\nawait db.end()\ntype Measurement = { metric: string; value: number; unit?: string; labels: Record<string, string> }\nconst measurements: Measurement[] = []\nconst worst = new Map<string, Measurement>() // the worst page group per metric and device class\nfor (const r of rows) {\n const m = { metric: METRIC[r.name], value: r.p75, unit: UNIT[r.name], labels: { device: r.device, page: r.page_group } }\n measurements.push(m)\n const key = r.name + ' ' + r.device\n if ((worst.get(key)?.value ?? -1) < m.value) worst.set(key, { ...m, metric: m.metric + '.max', labels: { device: r.device } })\n}\nmeasurements.push(...worst.values())\nprocess.stdout.write(JSON.stringify({ format: 'radical-metrics', version: 1, source: 'rum', at: new Date().toISOString(), measurements }))\n```",
521
+ "hubWhen": {
522
+ "FIELD": [
523
+ "rum"
524
+ ]
525
+ }
526
+ },
527
+ {
528
+ "id": "ff-layout-24",
529
+ "type": "fitness-fn",
530
+ "label": "Pages reflow, targets large enough",
531
+ "x": 1040,
532
+ "y": 650,
533
+ "characteristic": "interaction-capability",
534
+ "scope": "atomic",
535
+ "cadence": "triggered",
536
+ "trigger": "pull-request",
537
+ "invocation": "automated",
538
+ "description": "A Playwright test opens each main page in four viewports (320 CSS px wide, the width of a 1280 px window at 400% zoom; iPhone 15 and Pixel 7 as Playwright emulates them, with touch; Desktop Chrome) and measures how far the page scrolls sideways and which pointer targets are smaller than 24 × 24 CSS px, applying the exceptions of WCAG 2.5.8: a link inside a sentence, an input with a label of the size (its equivalent), and the spacing rule. It judges nothing: it lists what it found in the test report and, when radical sense playwright runs it, writes ux.mobile.overflow_px.max (px, the worst page and viewport) and ux.mobile.small_targets (a count over every page and viewport) as radical-metrics/1 into RADICAL_METRICS_DIR, so the model's conditions decide. Run it in a Chromium project (Firefox does not emulate isMobile). Content hidden with overflow-x: hidden does not scroll and is not seen here; a two-dimensional part (a map, a wide table) belongs in its own scroll container, which the page's width does not count.\n\nThreshold: On every main page, in a 320 CSS px window, on iPhone 15, on Pixel 7 and on a 1280 px desktop: 0 px of horizontal scrolling, and 0 pointer targets under 24 × 24 CSS px that are not inside a sentence, labelled by a large enough label, or spaced so that a 24 px circle around them touches no other target. Once the measure line \"playwright tests/mobile-layout.spec.ts --project chromium\" is added to this fitness function (a pack cannot know the project's tests), its conditions are: ux.mobile.overflow_px.max <= 0 px, and ux.mobile.small_targets <= 0\n\nTool: Playwright (@playwright/test 1.5x or later)\n\n```ts\n// tests/mobile-layout.spec.ts: measures; the model's conditions judge\nimport { writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { devices, test, type BrowserContextOptions } from '@playwright/test'\n\nconst PAGES = ['/', '/search', '/checkout'] // the main pages\nconst MIN = 24 // the target size decided, in CSS px\nconst VIEWPORTS: Record<string, BrowserContextOptions> = {\n '320 px (400% zoom)': { viewport: { width: 320, height: 640 } },\n 'iPhone 15': devices['iPhone 15'],\n 'Pixel 7': devices['Pixel 7'],\n 'desktop': devices['Desktop Chrome'],\n}\nconst TARGETS = 'a[href], button, input:not([type=hidden]), select, textarea, summary, [role=button], [role=link], [role=checkbox], [role=radio], [role=switch], [role=tab], [role=menuitem], [tabindex]:not([tabindex=\"-1\"])'\n\ntest('main pages reflow and their targets are large enough', async ({ browser }, testInfo) => {\n let overflow = 0\n let small = 0\n for (const [name, options] of Object.entries(VIEWPORTS)) {\n const context = await browser.newContext({ ...options, baseURL: testInfo.project.use.baseURL })\n const page = await context.newPage()\n for (const path of PAGES) {\n await page.goto(path)\n await page.evaluate(() => document.fonts.ready)\n const width = page.viewportSize()!.width\n const found = await page.evaluate(({ min, width, selector }) => {\n const sideways = Math.max(0, document.documentElement.scrollWidth - width)\n const targets = [...document.querySelectorAll<HTMLElement>(selector)].filter((el) => el.checkVisibility() && !el.closest('[inert]'))\n const boxes = targets.map((el) => el.getBoundingClientRect())\n const under = (r: DOMRect) => r.width < min || r.height < min\n const centre = (r: DOMRect) => [r.x + r.width / 2, r.y + r.height / 2]\n // WCAG 2.5.8 exceptions: inline in a sentence; an input whose label is large enough\n const exempt = (el: HTMLElement) =>\n (getComputedStyle(el).display === 'inline' && (el.parentElement?.textContent ?? '').trim().length > (el.textContent ?? '').trim().length)\n || [...((el as HTMLInputElement).labels ?? [])].some((l) => !under(l.getBoundingClientRect()))\n const fails = targets.flatMap((el, i) => {\n const r = boxes[i]\n if (!under(r) || exempt(el)) return []\n // spacing: a circle of diameter MIN on its centre touches no other target and no other small target's circle\n const [x, y] = centre(r)\n const crowded = boxes.some((o, j) => j !== i && !targets[j].contains(el) && !el.contains(targets[j])\n && (Math.hypot(Math.max(o.left - x, 0, x - o.right), Math.max(o.top - y, 0, y - o.bottom)) < min / 2\n || (under(o) && Math.hypot(centre(o)[0] - x, centre(o)[1] - y) < min)))\n const name = (el.getAttribute('aria-label') ?? el.textContent ?? '').trim().slice(0, 40)\n return crowded ? [el.tagName.toLowerCase() + ' \"' + name + '\" ' + Math.round(r.width) + '×' + Math.round(r.height)] : []\n })\n return { sideways, fails }\n }, { min: MIN, width, selector: TARGETS })\n overflow = Math.max(overflow, found.sideways)\n small += found.fails.length\n if (found.sideways) testInfo.annotations.push({ type: 'scrolls sideways', description: name + ' ' + path + ': ' + found.sideways + ' px' })\n for (const f of found.fails) testInfo.annotations.push({ type: 'small target', description: name + ' ' + path + ': ' + f })\n }\n await context.close()\n }\n const dir = process.env.RADICAL_METRICS_DIR // set by radical sense playwright\n if (dir) writeFileSync(join(dir, 'mobile-layout.json'), JSON.stringify({\n format: 'radical-metrics', version: 1, source: 'mobile-layout.spec.ts', at: new Date().toISOString(),\n measurements: [\n { metric: 'ux.mobile.overflow_px.max', value: overflow, unit: 'px' },\n { metric: 'ux.mobile.small_targets', value: small },\n ],\n }))\n})\n```",
539
+ "hubWhen": {
540
+ "TOUCH": [
541
+ "24"
542
+ ]
543
+ }
544
+ },
545
+ {
546
+ "id": "ff-layout-44",
547
+ "type": "fitness-fn",
548
+ "label": "Pages reflow, targets large enough",
549
+ "x": 1040,
550
+ "y": 780,
551
+ "characteristic": "interaction-capability",
552
+ "scope": "atomic",
553
+ "cadence": "triggered",
554
+ "trigger": "pull-request",
555
+ "invocation": "automated",
556
+ "description": "A Playwright test opens each main page in four viewports (320 CSS px wide, the width of a 1280 px window at 400% zoom; iPhone 15 and Pixel 7 as Playwright emulates them, with touch; Desktop Chrome) and measures how far the page scrolls sideways and which pointer targets are smaller than 44 × 44 CSS px, applying the exceptions of WCAG 2.5.8: a link inside a sentence, an input with a label of the size (its equivalent), and the spacing rule. It judges nothing: it lists what it found in the test report and, when radical sense playwright runs it, writes ux.mobile.overflow_px.max (px, the worst page and viewport) and ux.mobile.small_targets (a count over every page and viewport) as radical-metrics/1 into RADICAL_METRICS_DIR, so the model's conditions decide. Run it in a Chromium project (Firefox does not emulate isMobile). Content hidden with overflow-x: hidden does not scroll and is not seen here; a two-dimensional part (a map, a wide table) belongs in its own scroll container, which the page's width does not count.\n\nThreshold: On every main page, in a 320 CSS px window, on iPhone 15, on Pixel 7 and on a 1280 px desktop: 0 px of horizontal scrolling, and 0 pointer targets under 44 × 44 CSS px that are not inside a sentence, labelled by a large enough label, or spaced so that a 44 px circle around them touches no other target. Once the measure line \"playwright tests/mobile-layout.spec.ts --project chromium\" is added to this fitness function (a pack cannot know the project's tests), its conditions are: ux.mobile.overflow_px.max <= 0 px, and ux.mobile.small_targets <= 0\n\nTool: Playwright (@playwright/test 1.5x or later)\n\n```ts\n// tests/mobile-layout.spec.ts: measures; the model's conditions judge\nimport { writeFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport { devices, test, type BrowserContextOptions } from '@playwright/test'\n\nconst PAGES = ['/', '/search', '/checkout'] // the main pages\nconst MIN = 44 // the target size decided, in CSS px\nconst VIEWPORTS: Record<string, BrowserContextOptions> = {\n '320 px (400% zoom)': { viewport: { width: 320, height: 640 } },\n 'iPhone 15': devices['iPhone 15'],\n 'Pixel 7': devices['Pixel 7'],\n 'desktop': devices['Desktop Chrome'],\n}\nconst TARGETS = 'a[href], button, input:not([type=hidden]), select, textarea, summary, [role=button], [role=link], [role=checkbox], [role=radio], [role=switch], [role=tab], [role=menuitem], [tabindex]:not([tabindex=\"-1\"])'\n\ntest('main pages reflow and their targets are large enough', async ({ browser }, testInfo) => {\n let overflow = 0\n let small = 0\n for (const [name, options] of Object.entries(VIEWPORTS)) {\n const context = await browser.newContext({ ...options, baseURL: testInfo.project.use.baseURL })\n const page = await context.newPage()\n for (const path of PAGES) {\n await page.goto(path)\n await page.evaluate(() => document.fonts.ready)\n const width = page.viewportSize()!.width\n const found = await page.evaluate(({ min, width, selector }) => {\n const sideways = Math.max(0, document.documentElement.scrollWidth - width)\n const targets = [...document.querySelectorAll<HTMLElement>(selector)].filter((el) => el.checkVisibility() && !el.closest('[inert]'))\n const boxes = targets.map((el) => el.getBoundingClientRect())\n const under = (r: DOMRect) => r.width < min || r.height < min\n const centre = (r: DOMRect) => [r.x + r.width / 2, r.y + r.height / 2]\n // WCAG 2.5.8 exceptions: inline in a sentence; an input whose label is large enough\n const exempt = (el: HTMLElement) =>\n (getComputedStyle(el).display === 'inline' && (el.parentElement?.textContent ?? '').trim().length > (el.textContent ?? '').trim().length)\n || [...((el as HTMLInputElement).labels ?? [])].some((l) => !under(l.getBoundingClientRect()))\n const fails = targets.flatMap((el, i) => {\n const r = boxes[i]\n if (!under(r) || exempt(el)) return []\n // spacing: a circle of diameter MIN on its centre touches no other target and no other small target's circle\n const [x, y] = centre(r)\n const crowded = boxes.some((o, j) => j !== i && !targets[j].contains(el) && !el.contains(targets[j])\n && (Math.hypot(Math.max(o.left - x, 0, x - o.right), Math.max(o.top - y, 0, y - o.bottom)) < min / 2\n || (under(o) && Math.hypot(centre(o)[0] - x, centre(o)[1] - y) < min)))\n const name = (el.getAttribute('aria-label') ?? el.textContent ?? '').trim().slice(0, 40)\n return crowded ? [el.tagName.toLowerCase() + ' \"' + name + '\" ' + Math.round(r.width) + '×' + Math.round(r.height)] : []\n })\n return { sideways, fails }\n }, { min: MIN, width, selector: TARGETS })\n overflow = Math.max(overflow, found.sideways)\n small += found.fails.length\n if (found.sideways) testInfo.annotations.push({ type: 'scrolls sideways', description: name + ' ' + path + ': ' + found.sideways + ' px' })\n for (const f of found.fails) testInfo.annotations.push({ type: 'small target', description: name + ' ' + path + ': ' + f })\n }\n await context.close()\n }\n const dir = process.env.RADICAL_METRICS_DIR // set by radical sense playwright\n if (dir) writeFileSync(join(dir, 'mobile-layout.json'), JSON.stringify({\n format: 'radical-metrics', version: 1, source: 'mobile-layout.spec.ts', at: new Date().toISOString(),\n measurements: [\n { metric: 'ux.mobile.overflow_px.max', value: overflow, unit: 'px' },\n { metric: 'ux.mobile.small_targets', value: small },\n ],\n }))\n})\n```",
557
+ "hubWhen": {
558
+ "TOUCH": [
559
+ "44"
560
+ ]
561
+ }
562
+ },
563
+ {
564
+ "id": "ff-phone-screens",
565
+ "type": "fitness-fn",
566
+ "label": "Phone screenshots unchanged",
567
+ "x": 1040,
568
+ "y": 910,
569
+ "characteristic": "interaction-capability",
570
+ "scope": "atomic",
571
+ "cadence": "triggered",
572
+ "trigger": "pull-request",
573
+ "invocation": "automated",
574
+ "description": "Two Playwright projects emulate iPhone 15 (WebKit) and Pixel 7 (Chromium) as Playwright's device list describes them; a test takes each main page whole, after its fonts load, and compares it with the approved screenshot kept beside the test (one per page, project and platform). Parts that change by themselves (dates, avatars) are masked. Screenshots are taken in the Playwright Docker image of the @playwright/test version in use (mcr.microsoft.com/playwright:v<version>-noble), in CI and when approving with --update-snapshots, so fonts and rendering match.\n\nThreshold: 0 main pages on the iPhone 15 and Pixel 7 projects whose full-page screenshot differs from the approved one\n\nTool: Playwright (@playwright/test 1.5x or later, toHaveScreenshot)\n\n```ts\n// playwright.config.ts (the part that matters)\nimport { defineConfig, devices } from '@playwright/test'\n\nexport default defineConfig({\n use: { baseURL: 'http://localhost:4173' },\n webServer: { command: 'npm run preview', url: 'http://localhost:4173', reuseExistingServer: !process.env.CI },\n projects: [\n { name: 'iphone', use: { ...devices['iPhone 15'] } },\n { name: 'pixel', use: { ...devices['Pixel 7'] } },\n ],\n})\n\n// tests/phone-screens.spec.ts\nimport { expect, test } from '@playwright/test'\n\nfor (const path of ['/', '/search', '/checkout']) {\n test('page ' + path + ' looks as approved', async ({ page }) => {\n await page.goto(path)\n await page.evaluate(() => document.fonts.ready)\n await expect(page).toHaveScreenshot({ fullPage: true, mask: [page.locator('[data-volatile]')] })\n })\n}\n```",
575
+ "hubWhen": {
576
+ "VISUAL": [
577
+ "yes"
578
+ ]
579
+ }
580
+ }
581
+ ],
582
+ "relations": [
583
+ {
584
+ "id": "req-lab-budget--derives--need",
585
+ "sourceId": "req-lab-budget",
586
+ "targetId": "need",
587
+ "relationType": "derives",
588
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
589
+ },
590
+ {
591
+ "id": "req-lab-trend--derives--need",
592
+ "sourceId": "req-lab-trend",
593
+ "targetId": "need",
594
+ "relationType": "derives",
595
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
596
+ },
597
+ {
598
+ "id": "req-field-vitals--derives--need",
599
+ "sourceId": "req-field-vitals",
600
+ "targetId": "need",
601
+ "relationType": "derives",
602
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
603
+ },
604
+ {
605
+ "id": "req-reflow--derives--need",
606
+ "sourceId": "req-reflow",
607
+ "targetId": "need",
608
+ "relationType": "derives",
609
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
610
+ },
611
+ {
612
+ "id": "req-targets--derives--need",
613
+ "sourceId": "req-targets",
614
+ "targetId": "need",
615
+ "relationType": "derives",
616
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
617
+ },
618
+ {
619
+ "id": "req-phone-screens--derives--need",
620
+ "sourceId": "req-phone-screens",
621
+ "targetId": "need",
622
+ "relationType": "derives",
623
+ "quote": "People open this front end on their own phones and computers, over networks they do not choose, some zoomed in, most with a thumb. A page that paints late, jumps while it loads, answers a tap slowly, scrolls sideways or has targets too small to hit loses them, however it looks on a developer's laptop. The budget it is held to and the rules for small screens must be written down, measured on every change and, once it is live, from real visits, and judged in one place. The checks assume the main pages are listed in the tests (/, /search and /checkout in the snippets), a preview server on http://localhost:4173 (npm run preview), and, with real-user monitoring, a table rum_events(name, value, device, page_group, received_at) that the page's beacons fill."
624
+ },
625
+ {
626
+ "id": "sc-lab-budget--verifies--req-lab-budget",
627
+ "sourceId": "sc-lab-budget",
628
+ "targetId": "req-lab-budget",
629
+ "relationType": "verifies"
630
+ },
631
+ {
632
+ "id": "sc-lab-trend--verifies--req-lab-trend",
633
+ "sourceId": "sc-lab-trend",
634
+ "targetId": "req-lab-trend",
635
+ "relationType": "verifies"
636
+ },
637
+ {
638
+ "id": "sc-field-vitals--verifies--req-field-vitals",
639
+ "sourceId": "sc-field-vitals",
640
+ "targetId": "req-field-vitals",
641
+ "relationType": "verifies"
642
+ },
643
+ {
644
+ "id": "sc-reflow--verifies--req-reflow",
645
+ "sourceId": "sc-reflow",
646
+ "targetId": "req-reflow",
647
+ "relationType": "verifies"
648
+ },
649
+ {
650
+ "id": "sc-targets--verifies--req-targets",
651
+ "sourceId": "sc-targets",
652
+ "targetId": "req-targets",
653
+ "relationType": "verifies"
654
+ },
655
+ {
656
+ "id": "sc-phone-screens--verifies--req-phone-screens",
657
+ "sourceId": "sc-phone-screens",
658
+ "targetId": "req-phone-screens",
659
+ "relationType": "verifies"
660
+ },
661
+ {
662
+ "id": "ff-lab-mobile--implements--adr-perf-budget",
663
+ "sourceId": "ff-lab-mobile",
664
+ "targetId": "adr-perf-budget",
665
+ "relationType": "implements"
666
+ },
667
+ {
668
+ "id": "ff-lab-desktop--implements--adr-perf-budget",
669
+ "sourceId": "ff-lab-desktop",
670
+ "targetId": "adr-perf-budget",
671
+ "relationType": "implements"
672
+ },
673
+ {
674
+ "id": "ff-lab-mobile-trend--implements--adr-perf-budget",
675
+ "sourceId": "ff-lab-mobile-trend",
676
+ "targetId": "adr-perf-budget",
677
+ "relationType": "implements"
678
+ },
679
+ {
680
+ "id": "ff-lab-desktop-trend--implements--adr-perf-budget",
681
+ "sourceId": "ff-lab-desktop-trend",
682
+ "targetId": "adr-perf-budget",
683
+ "relationType": "implements"
684
+ },
685
+ {
686
+ "id": "ff-field-vitals--implements--adr-perf-budget",
687
+ "sourceId": "ff-field-vitals",
688
+ "targetId": "adr-perf-budget",
689
+ "relationType": "implements"
690
+ },
691
+ {
692
+ "id": "ff-layout-24--implements--adr-mobile-layout",
693
+ "sourceId": "ff-layout-24",
694
+ "targetId": "adr-mobile-layout",
695
+ "relationType": "implements"
696
+ },
697
+ {
698
+ "id": "ff-layout-44--implements--adr-mobile-layout",
699
+ "sourceId": "ff-layout-44",
700
+ "targetId": "adr-mobile-layout",
701
+ "relationType": "implements"
702
+ },
703
+ {
704
+ "id": "ff-phone-screens--implements--adr-mobile-layout",
705
+ "sourceId": "ff-phone-screens",
706
+ "targetId": "adr-mobile-layout",
707
+ "relationType": "implements"
708
+ }
709
+ ]
710
+ }