Publish benchmark task data
Browse files- LICENSE +21 -0
- README.md +112 -0
- croissant.json +216 -0
- data/PROVENANCE.md +13 -0
- data/tasks.jsonl +0 -0
- scripts/gen-tasks.mjs +581 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 Pooria Arab
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: "mit"
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pretty_name: "Accessibility Fix"
|
| 6 |
+
tags:
|
| 7 |
+
- benchmark
|
| 8 |
+
- llm-evaluation
|
| 9 |
+
- ai-benchmark
|
| 10 |
+
- model-evaluation
|
| 11 |
+
- evals
|
| 12 |
+
- grading
|
| 13 |
+
- accessibility
|
| 14 |
+
- a11y
|
| 15 |
+
- wcag
|
| 16 |
+
- openrouter
|
| 17 |
+
- openai
|
| 18 |
+
- mcp
|
| 19 |
+
- typescript
|
| 20 |
+
- agent-benchmark
|
| 21 |
+
task_categories:
|
| 22 |
+
- text-generation
|
| 23 |
+
size_categories:
|
| 24 |
+
- n<1K
|
| 25 |
+
configs:
|
| 26 |
+
- config_name: default
|
| 27 |
+
data_files:
|
| 28 |
+
- split: test
|
| 29 |
+
path: data/tasks.jsonl
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
# Accessibility Fix
|
| 33 |
+
|
| 34 |
+
Fix a broken page so keyboard, screen-reader and contrast checks pass.
|
| 35 |
+
|
| 36 |
+
## What it measures
|
| 37 |
+
|
| 38 |
+
Whether a fixed HTML page really repairs injected keyboard, screen-reader, and contrast defects without deleting or hiding content.
|
| 39 |
+
|
| 40 |
+
Category: `coding`. Status: `alpha`.
|
| 41 |
+
|
| 42 |
+
## How to run
|
| 43 |
+
|
| 44 |
+
```console
|
| 45 |
+
$ npx benchmark-accessibility-fix list
|
| 46 |
+
$ npx benchmark-accessibility-fix run --model <model-id> --provider openrouter
|
| 47 |
+
$ npx benchmark-accessibility-fix score results.json
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
`--provider mock` runs the whole benchmark offline with no keys. Real models run
|
| 51 |
+
through OpenRouter (`OPENROUTER_API_KEY`) or any OpenAI-compatible base URL
|
| 52 |
+
(`OPENAI_BASE_URL`, `OPENAI_API_KEY`).
|
| 53 |
+
|
| 54 |
+
## Data fields
|
| 55 |
+
|
| 56 |
+
`data/tasks.jsonl` holds 40 tasks, one JSON object per line
|
| 57 |
+
(kinds: 40 single).
|
| 58 |
+
|
| 59 |
+
| field | type |
|
| 60 |
+
|---|---|
|
| 61 |
+
| `id` | string |
|
| 62 |
+
| `kind` | string |
|
| 63 |
+
| `prompt` | string |
|
| 64 |
+
| `expected` | string |
|
| 65 |
+
| `metadata` | object |
|
| 66 |
+
|
| 67 |
+
## Provenance
|
| 68 |
+
|
| 69 |
+
# Accessibility Fix provenance
|
| 70 |
+
|
| 71 |
+
This file is generated from the benchmark definition.
|
| 72 |
+
|
| 73 |
+
## Synthetic accessibility fixtures
|
| 74 |
+
|
| 75 |
+
- Kind: `synthetic`
|
| 76 |
+
- URL: https://github.com/pooriaarab/benchmark-accessibility-fix/blob/main/scripts/gen-tasks.mjs
|
| 77 |
+
- Licence: `MIT`
|
| 78 |
+
- Retrieved: 2026-10-16T00:00:00.000Z
|
| 79 |
+
- How to get it: Run `npm run generate:tasks` (or `node scripts/gen-tasks.mjs --seed 20261015` after `npm run build`) from the repository root. The generator grades every reference page with the built package and re-draws until it scores 1. A hidden split uses another seed: `node scripts/gen-tasks.mjs --seed <n> --split hidden --out <path>`; hidden files use a11yh- ids and stay out of git and npm.
|
| 80 |
+
- Contamination notes: Public tasks use seed 20261015. Treat them as possibly in training data; use a separately seeded hidden split for final comparisons.
|
| 81 |
+
- Refresh: Change the seed, run the generator, and review the JSONL diff.
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
## Grader
|
| 85 |
+
|
| 86 |
+
Deterministic static analysis of the fixed HTML: ten WCAG-cited checks score defects fixed, minus regressions, content loss, element removal, and hiding abuse. Model judging is off.
|
| 87 |
+
|
| 88 |
+
## Limitations
|
| 89 |
+
|
| 90 |
+
This dataset contains only the public task split (40 tasks).
|
| 91 |
+
Hidden evaluation splits use a private seed and are deliberately not part of
|
| 92 |
+
this dataset. Source kinds: synthetic. These are evaluation prompts
|
| 93 |
+
for the `benchmark-accessibility-fix` benchmark, not training data; scoring requires the package's
|
| 94 |
+
deterministic grader. See PROVENANCE.md for contamination notes.
|
| 95 |
+
|
| 96 |
+
## Citation
|
| 97 |
+
|
| 98 |
+
```bibtex
|
| 99 |
+
@misc{benchmark_accessibility_fix,
|
| 100 |
+
author = {Pooria Arab},
|
| 101 |
+
title = {Accessibility Fix task data},
|
| 102 |
+
year = {2026},
|
| 103 |
+
url = {https://github.com/pooriaarab/benchmark-accessibility-fix}
|
| 104 |
+
}
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## Links
|
| 108 |
+
|
| 109 |
+
- npm: https://www.npmjs.com/package/benchmark-accessibility-fix
|
| 110 |
+
- GitHub: https://github.com/pooriaarab/benchmark-accessibility-fix
|
| 111 |
+
- Leaderboard: https://aibenchmarkindex.com/benchmarks/benchmark-accessibility-fix
|
| 112 |
+
- Dataset: https://huggingface.co/datasets/pooria/benchmark-accessibility-fix
|
croissant.json
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"@context": {
|
| 3 |
+
"@language": "en",
|
| 4 |
+
"@vocab": "https://schema.org/",
|
| 5 |
+
"citeAs": "cr:citeAs",
|
| 6 |
+
"column": "cr:column",
|
| 7 |
+
"conformsTo": "dct:conformsTo",
|
| 8 |
+
"cr": "http://mlcommons.org/croissant/",
|
| 9 |
+
"data": {
|
| 10 |
+
"@id": "cr:data",
|
| 11 |
+
"@type": "@json"
|
| 12 |
+
},
|
| 13 |
+
"dataBiases": "cr:dataBiases",
|
| 14 |
+
"dataCollection": "cr:dataCollection",
|
| 15 |
+
"dataType": {
|
| 16 |
+
"@id": "cr:dataType",
|
| 17 |
+
"@type": "@vocab"
|
| 18 |
+
},
|
| 19 |
+
"dct": "http://purl.org/dc/terms/",
|
| 20 |
+
"equivalentProperty": "cr:equivalentProperty",
|
| 21 |
+
"examples": {
|
| 22 |
+
"@id": "cr:examples",
|
| 23 |
+
"@type": "@json"
|
| 24 |
+
},
|
| 25 |
+
"extract": "cr:extract",
|
| 26 |
+
"field": "cr:field",
|
| 27 |
+
"fileProperty": "cr:fileProperty",
|
| 28 |
+
"fileObject": "cr:fileObject",
|
| 29 |
+
"fileSet": "cr:fileSet",
|
| 30 |
+
"format": "cr:format",
|
| 31 |
+
"includes": "cr:includes",
|
| 32 |
+
"isLiveDataset": "cr:isLiveDataset",
|
| 33 |
+
"jsonPath": "cr:jsonPath",
|
| 34 |
+
"key": "cr:key",
|
| 35 |
+
"md5": "cr:md5",
|
| 36 |
+
"parentField": "cr:parentField",
|
| 37 |
+
"path": "cr:path",
|
| 38 |
+
"personalSensitiveInformation": "cr:personalSensitiveInformation",
|
| 39 |
+
"prov": "http://www.w3.org/ns/prov#",
|
| 40 |
+
"rai": "http://mlcommons.org/croissant/RAI/",
|
| 41 |
+
"recordSet": "cr:recordSet",
|
| 42 |
+
"references": "cr:references",
|
| 43 |
+
"regex": "cr:regex",
|
| 44 |
+
"repeated": "cr:repeated",
|
| 45 |
+
"replace": "cr:replace",
|
| 46 |
+
"samplingRate": "cr:samplingRate",
|
| 47 |
+
"sc": "https://schema.org/",
|
| 48 |
+
"separator": "cr:separator",
|
| 49 |
+
"source": "cr:source",
|
| 50 |
+
"subField": "cr:subField",
|
| 51 |
+
"transform": "cr:transform"
|
| 52 |
+
},
|
| 53 |
+
"@type": "sc:Dataset",
|
| 54 |
+
"conformsTo": [
|
| 55 |
+
"http://mlcommons.org/croissant/1.0",
|
| 56 |
+
"http://mlcommons.org/croissant/RAI/1.0"
|
| 57 |
+
],
|
| 58 |
+
"name": "Accessibility Fix",
|
| 59 |
+
"description": "Fix a broken page so keyboard, screen-reader and contrast checks pass.",
|
| 60 |
+
"url": "https://huggingface.co/datasets/pooria/benchmark-accessibility-fix",
|
| 61 |
+
"sameAs": [
|
| 62 |
+
"https://github.com/pooriaarab/benchmark-accessibility-fix",
|
| 63 |
+
"https://aibenchmarkindex.com/benchmarks/benchmark-accessibility-fix"
|
| 64 |
+
],
|
| 65 |
+
"license": "https://choosealicense.com/licenses/mit/",
|
| 66 |
+
"creator": {
|
| 67 |
+
"@type": "Person",
|
| 68 |
+
"name": "Pooria Arab",
|
| 69 |
+
"url": "https://github.com/pooriaarab"
|
| 70 |
+
},
|
| 71 |
+
"datePublished": "2026-10-16",
|
| 72 |
+
"dateModified": "2026-10-16",
|
| 73 |
+
"version": "0.1.0",
|
| 74 |
+
"inLanguage": "en",
|
| 75 |
+
"keywords": [
|
| 76 |
+
"benchmark-accessibility-fix",
|
| 77 |
+
"llm-evaluation",
|
| 78 |
+
"benchmark"
|
| 79 |
+
],
|
| 80 |
+
"isAccessibleForFree": true,
|
| 81 |
+
"citeAs": "@misc{benchmark-accessibility-fix, author={Pooria Arab}, title={Accessibility Fix}, year={2026}, url={https://github.com/pooriaarab/benchmark-accessibility-fix}}",
|
| 82 |
+
"distribution": [
|
| 83 |
+
{
|
| 84 |
+
"@type": "cr:FileObject",
|
| 85 |
+
"@id": "data/PROVENANCE.md",
|
| 86 |
+
"name": "data/PROVENANCE.md",
|
| 87 |
+
"contentUrl": "https://huggingface.co/datasets/pooria/benchmark-accessibility-fix/resolve/main/data/PROVENANCE.md",
|
| 88 |
+
"encodingFormat": "text/markdown",
|
| 89 |
+
"sha256": "6f952aa73169afa78d3ac72269bcec7e2136b77b27d6f8b0caa5b42da13df958"
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"@type": "cr:FileObject",
|
| 93 |
+
"@id": "data/tasks.jsonl",
|
| 94 |
+
"name": "data/tasks.jsonl",
|
| 95 |
+
"contentUrl": "https://huggingface.co/datasets/pooria/benchmark-accessibility-fix/resolve/main/data/tasks.jsonl",
|
| 96 |
+
"encodingFormat": "application/jsonlines",
|
| 97 |
+
"sha256": "20d9f94a23dfa0d137e1235d84e3981b358ec54b0dd9d48ad4bba052cd207cc8"
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"@type": "cr:FileObject",
|
| 101 |
+
"@id": "scripts/gen-tasks.mjs",
|
| 102 |
+
"name": "scripts/gen-tasks.mjs",
|
| 103 |
+
"contentUrl": "https://huggingface.co/datasets/pooria/benchmark-accessibility-fix/resolve/main/scripts/gen-tasks.mjs",
|
| 104 |
+
"encodingFormat": "text/javascript",
|
| 105 |
+
"sha256": "fb61fec6a1ca75c7bc92e9a6908c0352d3b1617c728ecf762446302f0b10e45e"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"@type": "cr:FileObject",
|
| 109 |
+
"@id": "LICENSE",
|
| 110 |
+
"name": "LICENSE",
|
| 111 |
+
"contentUrl": "https://huggingface.co/datasets/pooria/benchmark-accessibility-fix/resolve/main/LICENSE",
|
| 112 |
+
"encodingFormat": "text/plain",
|
| 113 |
+
"sha256": "db83f2db2a2b6a3b5587ce4750a3a6cff3dd1219650fa1ea3b3354ee04891d96"
|
| 114 |
+
}
|
| 115 |
+
],
|
| 116 |
+
"recordSet": [
|
| 117 |
+
{
|
| 118 |
+
"@type": "cr:RecordSet",
|
| 119 |
+
"name": "tasks",
|
| 120 |
+
"description": "40 benchmark tasks, one JSON object per line.",
|
| 121 |
+
"field": [
|
| 122 |
+
{
|
| 123 |
+
"@type": "cr:Field",
|
| 124 |
+
"name": "id",
|
| 125 |
+
"dataType": "sc:Text",
|
| 126 |
+
"source": {
|
| 127 |
+
"fileObject": {
|
| 128 |
+
"@id": "data/tasks.jsonl"
|
| 129 |
+
},
|
| 130 |
+
"extract": {
|
| 131 |
+
"jsonPath": "$.id"
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
{
|
| 136 |
+
"@type": "cr:Field",
|
| 137 |
+
"name": "kind",
|
| 138 |
+
"dataType": "sc:Text",
|
| 139 |
+
"source": {
|
| 140 |
+
"fileObject": {
|
| 141 |
+
"@id": "data/tasks.jsonl"
|
| 142 |
+
},
|
| 143 |
+
"extract": {
|
| 144 |
+
"jsonPath": "$.kind"
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"@type": "cr:Field",
|
| 150 |
+
"name": "prompt",
|
| 151 |
+
"dataType": "sc:Text",
|
| 152 |
+
"source": {
|
| 153 |
+
"fileObject": {
|
| 154 |
+
"@id": "data/tasks.jsonl"
|
| 155 |
+
},
|
| 156 |
+
"extract": {
|
| 157 |
+
"jsonPath": "$.prompt"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
},
|
| 161 |
+
{
|
| 162 |
+
"@type": "cr:Field",
|
| 163 |
+
"name": "expected",
|
| 164 |
+
"dataType": "sc:Text",
|
| 165 |
+
"source": {
|
| 166 |
+
"fileObject": {
|
| 167 |
+
"@id": "data/tasks.jsonl"
|
| 168 |
+
},
|
| 169 |
+
"extract": {
|
| 170 |
+
"jsonPath": "$.expected"
|
| 171 |
+
}
|
| 172 |
+
}
|
| 173 |
+
},
|
| 174 |
+
{
|
| 175 |
+
"@type": "cr:Field",
|
| 176 |
+
"name": "metadata",
|
| 177 |
+
"dataType": "sc:Text",
|
| 178 |
+
"source": {
|
| 179 |
+
"fileObject": {
|
| 180 |
+
"@id": "data/tasks.jsonl"
|
| 181 |
+
},
|
| 182 |
+
"extract": {
|
| 183 |
+
"jsonPath": "$.metadata"
|
| 184 |
+
}
|
| 185 |
+
}
|
| 186 |
+
}
|
| 187 |
+
]
|
| 188 |
+
}
|
| 189 |
+
],
|
| 190 |
+
"rai:dataCollection": "Public task split cloned from the benchmark repository; tasks are produced by scripts/gen-tasks.mjs with a fixed public seed.",
|
| 191 |
+
"rai:dataCollectionType": "Benchmark task prompts for LLM evaluation.",
|
| 192 |
+
"rai:dataCollectionRawData": "https://github.com/pooriaarab/benchmark-accessibility-fix/tree/main/data",
|
| 193 |
+
"rai:dataReleaseMaintenancePlan": "Refreshed when the benchmark's public seed changes; hidden splits are generated with a private seed and never published.",
|
| 194 |
+
"rai:dataLimitations": "Public split only (40 tasks); hidden evaluation splits are held out. Evaluation prompts, not training data.",
|
| 195 |
+
"rai:dataBiases": "Synthetic task families oversample the shapes the generator enumerates; coverage of real-world variation is limited by the generator templates.",
|
| 196 |
+
"rai:personalSensitiveInformation": "None. Tasks contain no personal data; names, orders and scenarios are generated fixtures.",
|
| 197 |
+
"rai:dataUseCases": [
|
| 198 |
+
"Testing and comparing LLM/agent behaviour on the measured construct",
|
| 199 |
+
"Regression testing of model releases"
|
| 200 |
+
],
|
| 201 |
+
"rai:dataSocialImpact": "Low risk: synthetic eval data. Improves transparency of model capability claims when used responsibly.",
|
| 202 |
+
"rai:hasSyntheticData": true,
|
| 203 |
+
"prov:wasDerivedFrom": [
|
| 204 |
+
"https://github.com/pooriaarab/benchmark-accessibility-fix/blob/main/scripts/gen-tasks.mjs"
|
| 205 |
+
],
|
| 206 |
+
"prov:wasGeneratedBy": [
|
| 207 |
+
{
|
| 208 |
+
"@type": "prov:Activity",
|
| 209 |
+
"name": "Synthetic accessibility fixtures",
|
| 210 |
+
"description": "synthetic source: https://github.com/pooriaarab/benchmark-accessibility-fix/blob/main/scripts/gen-tasks.mjs"
|
| 211 |
+
}
|
| 212 |
+
],
|
| 213 |
+
"alternateName": [
|
| 214 |
+
"pooria/benchmark-accessibility-fix"
|
| 215 |
+
]
|
| 216 |
+
}
|
data/PROVENANCE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Accessibility Fix provenance
|
| 2 |
+
|
| 3 |
+
This file is generated from the benchmark definition.
|
| 4 |
+
|
| 5 |
+
## Synthetic accessibility fixtures
|
| 6 |
+
|
| 7 |
+
- Kind: `synthetic`
|
| 8 |
+
- URL: https://github.com/pooriaarab/benchmark-accessibility-fix/blob/main/scripts/gen-tasks.mjs
|
| 9 |
+
- Licence: `MIT`
|
| 10 |
+
- Retrieved: 2026-10-16T00:00:00.000Z
|
| 11 |
+
- How to get it: Run `npm run generate:tasks` (or `node scripts/gen-tasks.mjs --seed 20261015` after `npm run build`) from the repository root. The generator grades every reference page with the built package and re-draws until it scores 1. A hidden split uses another seed: `node scripts/gen-tasks.mjs --seed <n> --split hidden --out <path>`; hidden files use a11yh- ids and stay out of git and npm.
|
| 12 |
+
- Contamination notes: Public tasks use seed 20261015. Treat them as possibly in training data; use a separately seeded hidden split for final comparisons.
|
| 13 |
+
- Refresh: Change the seed, run the generator, and review the JSONL diff.
|
data/tasks.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
scripts/gen-tasks.mjs
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Generates synthetic accessibility-fix fixtures (MIT).
|
| 2 |
+
// Usage: node scripts/gen-tasks.mjs [--seed N] [--split public|hidden] [--out path] [--count N]
|
| 3 |
+
// Public split defaults to data/tasks.jsonl with seed 20261015.
|
| 4 |
+
// Hidden split defaults to artifacts/tasks.hidden.jsonl (gitignored, never published)
|
| 5 |
+
// and uses its own a11yh- id prefix so hidden ids never collide with public ones.
|
| 6 |
+
import { mkdir, writeFile } from "node:fs/promises";
|
| 7 |
+
import { dirname } from "node:path";
|
| 8 |
+
import { createHash } from "node:crypto";
|
| 9 |
+
|
| 10 |
+
const args = process.argv.slice(2);
|
| 11 |
+
const get = (name, fallback) => {
|
| 12 |
+
const index = args.indexOf(name);
|
| 13 |
+
return index === -1 ? fallback : args[index + 1];
|
| 14 |
+
};
|
| 15 |
+
if (args.includes("--help")) {
|
| 16 |
+
console.log("Usage: node scripts/gen-tasks.mjs [--seed N] [--split public|hidden] [--out path] [--count N]");
|
| 17 |
+
process.exit(0);
|
| 18 |
+
}
|
| 19 |
+
const seed = Number(get("--seed", "20261015"));
|
| 20 |
+
const split = get("--split", "public");
|
| 21 |
+
const count = Number(get("--count", "40"));
|
| 22 |
+
const out = get("--out", split === "hidden" ? "artifacts/tasks.hidden.jsonl" : "data/tasks.jsonl");
|
| 23 |
+
if (!Number.isInteger(seed) || !Number.isInteger(count) || count < 1) throw new Error("seed and count must be positive integers");
|
| 24 |
+
if (split !== "public" && split !== "hidden") throw new Error("--split must be public or hidden");
|
| 25 |
+
|
| 26 |
+
function mulberry32(start) {
|
| 27 |
+
let state = start >>> 0;
|
| 28 |
+
return () => {
|
| 29 |
+
state += 1831565813;
|
| 30 |
+
let value = state;
|
| 31 |
+
value = Math.imul(value ^ (value >>> 15), value | 1);
|
| 32 |
+
value ^= value + Math.imul(value ^ (value >>> 7), value | 61);
|
| 33 |
+
return ((value ^ (value >>> 14)) >>> 0) / 4294967296;
|
| 34 |
+
};
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
const pick = (rng, list) => list[Math.floor(rng() * list.length)];
|
| 38 |
+
const pickN = (rng, list, n) => {
|
| 39 |
+
const copy = [...list];
|
| 40 |
+
const out = [];
|
| 41 |
+
while (out.length < Math.min(n, copy.length)) out.push(copy.splice(Math.floor(rng() * copy.length), 1)[0]);
|
| 42 |
+
return out;
|
| 43 |
+
};
|
| 44 |
+
const shuffle = (rng, list) => {
|
| 45 |
+
const a = [...list];
|
| 46 |
+
for (let i = a.length - 1; i > 0; i--) {
|
| 47 |
+
const j = Math.floor(rng() * (i + 1));
|
| 48 |
+
[a[i], a[j]] = [a[j], a[i]];
|
| 49 |
+
}
|
| 50 |
+
return a;
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
// WCAG relative luminance for #rrggbb.
|
| 54 |
+
function luminance(hex) {
|
| 55 |
+
const h = hex.replace("#", "");
|
| 56 |
+
const [r, g, b] = [0, 2, 4].map((i) => {
|
| 57 |
+
const c = parseInt(h.slice(i, i + 2), 16) / 255;
|
| 58 |
+
return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
| 59 |
+
});
|
| 60 |
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
| 61 |
+
}
|
| 62 |
+
const ratio = (a, b) => {
|
| 63 |
+
const [x, y] = [luminance(a), luminance(b)].sort((m, n) => n - m);
|
| 64 |
+
return (x + 0.05) / (y + 0.05);
|
| 65 |
+
};
|
| 66 |
+
const hex = (rng, lo, hi) => "#" + [0, 1, 2].map(() => (lo + Math.floor(rng() * (hi - lo + 1))).toString(16).padStart(2, "0")).join("");
|
| 67 |
+
|
| 68 |
+
// A passing foreground/background pair at >= minRatio. The default
|
| 69 |
+
// carries margin over the 4.5:1 rule so equivalent color spellings
|
| 70 |
+
// (hsl() with rounded channels, 8-digit hex) cannot dip a reference
|
| 71 |
+
// page under the threshold.
|
| 72 |
+
function goodPair(rng, minRatio = 4.75) {
|
| 73 |
+
for (let tries = 0; tries < 200; tries++) {
|
| 74 |
+
const bg = hex(rng, 200, 255);
|
| 75 |
+
const fg = hex(rng, 0, 120);
|
| 76 |
+
if (ratio(fg, bg) >= minRatio) return { fg, bg };
|
| 77 |
+
}
|
| 78 |
+
throw new Error("no good pair found");
|
| 79 |
+
}
|
| 80 |
+
// A failing pair against a fixed background (text lands in the 3.5-4.4 band
|
| 81 |
+
// so the defect is visible but not blatant).
|
| 82 |
+
function badFg(rng, bg) {
|
| 83 |
+
for (let tries = 0; tries < 400; tries++) {
|
| 84 |
+
const fg = hex(rng, 120, 190);
|
| 85 |
+
const r = ratio(fg, bg);
|
| 86 |
+
if (r < 4.5 && r > 2.5) return fg;
|
| 87 |
+
}
|
| 88 |
+
return "#8a8a8a";
|
| 89 |
+
}
|
| 90 |
+
// A passing foreground on a FIXED background: the inline span inherits
|
| 91 |
+
// the body background, so it must be drawn against it, not against a
|
| 92 |
+
// throwaway pair bg.
|
| 93 |
+
function goodFg(rng, bg, minRatio = 4.75) {
|
| 94 |
+
for (let tries = 0; tries < 400; tries++) {
|
| 95 |
+
const fg = hex(rng, 0, 130);
|
| 96 |
+
if (ratio(fg, bg) >= minRatio) return fg;
|
| 97 |
+
}
|
| 98 |
+
throw new Error("no good foreground found");
|
| 99 |
+
}
|
| 100 |
+
// A large-text pair in the passing 3:1-4.5 band (valid fix, tests the
|
| 101 |
+
// large-text threshold). The 3.3 floor leaves room for color-format
|
| 102 |
+
// rounding noise, same margin idea as goodPair.
|
| 103 |
+
function largePair(rng) {
|
| 104 |
+
for (let tries = 0; tries < 300; tries++) {
|
| 105 |
+
const bg = hex(rng, 200, 255);
|
| 106 |
+
const fg = hex(rng, 60, 160);
|
| 107 |
+
const r = ratio(fg, bg);
|
| 108 |
+
if (r >= 3.3 && r < 4.5) return { fg, bg };
|
| 109 |
+
}
|
| 110 |
+
throw new Error("no large pair found");
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
const CHECKS = [
|
| 114 |
+
["missing-alt", "1.1.1"], ["unlabeled-input", "3.3.2"], ["low-contrast", "1.4.3"],
|
| 115 |
+
["heading-order", "1.3.1"], ["tabindex-positive", "2.4.3"], ["div-button", "4.1.2"],
|
| 116 |
+
["missing-lang", "3.1.1"], ["no-focus-style", "2.4.7"], ["empty-link", "2.4.4"],
|
| 117 |
+
["table-headers", "1.3.1"],
|
| 118 |
+
];
|
| 119 |
+
const WCAG = Object.fromEntries(CHECKS);
|
| 120 |
+
|
| 121 |
+
const ADJ = ["Harbor", "Kestrel", "Northern", "River", "Garden", "Amber", "Cedar", "Juniper", "Misty", "Copper", "Silver", "Quiet", "Bright", "Willow", "Frost", "Ember", "Sage", "Coral", "Atlas", "Meadow"];
|
| 122 |
+
const NOUN = ["Lights", "Ridge", "Valley", "Crossing", "Mills", "Works", "Foundry", "Collective", "Cooperative", "Observatory", "Pantry", "Workshop", "Ledger", "Orchard", "Depot", "Exchange", "Studio", "Clinic", "Archive", "Guild"];
|
| 123 |
+
const KIND = ["newsletter", "field guide", "status report", "release notes", "handbook", "bulletin", "weekly digest", "product sheet", "setup guide", "survey results", "booking page", "service page"];
|
| 124 |
+
const TOPICS = [
|
| 125 |
+
["ferry sailings", "harbor notes", "crossing times"],
|
| 126 |
+
["grind settings", "care notes", "brew ratios"],
|
| 127 |
+
["sleeper bookings", "reading list", "departure board"],
|
| 128 |
+
["volunteer shifts", "meeting point", "supply list"],
|
| 129 |
+
["api keys", "rate limits", "endpoint status"],
|
| 130 |
+
["survey findings", "next steps", "member quotes"],
|
| 131 |
+
["trail conditions", "permit windows", "ranger notes"],
|
| 132 |
+
["menu changes", "supplier list", "order cutoffs"],
|
| 133 |
+
["rehearsal dates", "set list", "venue notes"],
|
| 134 |
+
["seed inventory", "planting calendar", "pest watch"],
|
| 135 |
+
["loan rates", "branch hours", "member news"],
|
| 136 |
+
["build artifacts", "test matrix", "deploy log"],
|
| 137 |
+
];
|
| 138 |
+
const NOTES = [
|
| 139 |
+
"New routes post every Sunday evening.", "Burrs carry a five year warranty.",
|
| 140 |
+
"Berths sell out around holidays.", "Gloves and bags are provided.",
|
| 141 |
+
"Keys rotate every ninety days.", "Two hundred members answered.",
|
| 142 |
+
"Permits open on the first Monday.", "Orders close at noon on Fridays.",
|
| 143 |
+
"Rehearsals move indoors in winter.", "Seed counts refresh monthly.",
|
| 144 |
+
"Rates lock for sixty days.", "Artifacts prune after thirty days.",
|
| 145 |
+
];
|
| 146 |
+
const SPANS = [
|
| 147 |
+
"Ferries run hourly on holidays.", "Free returns within thirty days.",
|
| 148 |
+
"Bring a lock for the cabin door.", "All ages welcome with an adult.",
|
| 149 |
+
"Sandbox data refreshes hourly.", "Evening hours were the top ask.",
|
| 150 |
+
"Boots are required past the gate.", "Late orders ship the next day.",
|
| 151 |
+
"Guests may watch the last set.", "Cover beds before a frost.",
|
| 152 |
+
"Statements arrive by post.", "Flaky tests quarantine on retry.",
|
| 153 |
+
];
|
| 154 |
+
const ALTS = [
|
| 155 |
+
"Ferry crossing the harbor at dusk", "Steel burr coffee grinder on a counter",
|
| 156 |
+
"Sleeper train under northern lights", "Volunteers clearing a riverbank",
|
| 157 |
+
"Soil sensor beside tomato plants", "Reading room with tall shelves",
|
| 158 |
+
"Trail marker above the treeline", "Stacked crates at the loading dock",
|
| 159 |
+
"String section tuning on stage", "Seed packets on a potting bench",
|
| 160 |
+
"Teller counter at the main branch", "Build monitor showing green jobs",
|
| 161 |
+
];
|
| 162 |
+
const CTA = ["Subscribe", "Add to basket", "Save article", "Join us", "Get a key", "Download PDF", "Book now", "Reserve a spot", "Notify me", "Start trial"];
|
| 163 |
+
const NAV2 = ["About", "FAQ", "Pricing", "News", "Docs", "Team", "Contact", "Archive"];
|
| 164 |
+
const FIELD_POOL = [
|
| 165 |
+
["name", "Full name", "text"], ["email", "Email address", "email"],
|
| 166 |
+
["phone", "Phone number", "tel"], ["org", "Organization", "text"],
|
| 167 |
+
["city", "City", "text"], ["note", "Delivery note", "text"],
|
| 168 |
+
];
|
| 169 |
+
const CLASS_A = ["note", "hint", "aside", "fine", "meta", "muted"];
|
| 170 |
+
const CLASS_B = ["cta", "btn-primary", "action", "primary-btn", "main-action", "go"];
|
| 171 |
+
const CAPTIONS = ["Crossing times", "Grind guide", "Departure board", "Cleanup shifts", "Endpoint limits", "Survey results", "Permit windows", "Order ledger", "Rehearsal slots", "Seed counts", "Rate sheet", "Build history"];
|
| 172 |
+
const COLHEADS = [["Option", "Detail", "Status"], ["Name", "Owner", "State"], ["Step", "Input", "Output"], ["Item", "Count", "Flag"]];
|
| 173 |
+
const CELLS = [["Standard", "Weekly", "Open"], ["Plus", "Daily", "Open"], ["Rush", "Hourly", "Full"], ["Basic", "Monthly", "Closed"], ["Trial", "Once", "Open"], ["Custom", "On call", "Open"]];
|
| 174 |
+
|
| 175 |
+
// One randomized but fully accessible page. Returns the HTML plus a hooks
|
| 176 |
+
// object with the exact strings defect breakers can target.
|
| 177 |
+
function buildFixed(rng) {
|
| 178 |
+
const title = `${pick(rng, ADJ)} ${pick(rng, NOUN)} ${pick(rng, KIND)}`;
|
| 179 |
+
const topics = pick(rng, TOPICS);
|
| 180 |
+
const [h2a, h2b, caption] = [topics[0], topics[1], pick(rng, CAPTIONS)];
|
| 181 |
+
const noteClass = pick(rng, CLASS_A);
|
| 182 |
+
const ctaClass = pick(rng, CLASS_B);
|
| 183 |
+
const noteText = pick(rng, NOTES);
|
| 184 |
+
const spanText = pick(rng, SPANS);
|
| 185 |
+
const heroAlt = pick(rng, ALTS);
|
| 186 |
+
const img = `https://example.com/${title.toLowerCase().replace(/[^a-z]+/g, "-")}.jpg`;
|
| 187 |
+
const ctaText = pick(rng, CTA);
|
| 188 |
+
const nav2 = pick(rng, NAV2);
|
| 189 |
+
const fields = pickN(rng, FIELD_POOL, 2 + Math.floor(rng() * 2));
|
| 190 |
+
const colheads = pick(rng, COLHEADS);
|
| 191 |
+
const rows = pickN(rng, CELLS, 2 + Math.floor(rng() * 2));
|
| 192 |
+
// Colors: every pair is generated to pass.
|
| 193 |
+
const body = goodPair(rng);
|
| 194 |
+
const note = goodPair(rng);
|
| 195 |
+
const spanFg = goodFg(rng, body.bg);
|
| 196 |
+
const cta = goodPair(rng);
|
| 197 |
+
const focusColor = goodPair(rng).fg;
|
| 198 |
+
// A large-text heading pair in the legal 3:1-4.5 band keeps the
|
| 199 |
+
// large-text path exercised without tripping the defect check.
|
| 200 |
+
const large = rng() < 0.5 ? largePair(rng) : null;
|
| 201 |
+
const largeRule = large ? `\n.big-head{color:${large.fg};background-color:${large.bg};font-size:26px;font-weight:700}` : "";
|
| 202 |
+
const bigHead = large ? `<h2 class="big-head">${h2a}</h2>` : `<h2>${h2a}</h2>`;
|
| 203 |
+
const styleBlock = `<style>
|
| 204 |
+
body{color:${body.fg};background-color:${body.bg};font-family:system-ui,sans-serif;line-height:1.5}
|
| 205 |
+
.${noteClass}{color:${note.fg};background-color:${note.bg}}
|
| 206 |
+
.${ctaClass}{color:${cta.fg};background-color:${cta.bg};padding:.6rem 1rem;border:0;border-radius:.4rem}
|
| 207 |
+
a:focus-visible,.${ctaClass}:focus-visible{outline:3px solid ${focusColor};outline-offset:2px}${largeRule}
|
| 208 |
+
</style>`;
|
| 209 |
+
|
| 210 |
+
const skip = `<a href="#main">Skip to content</a>`;
|
| 211 |
+
const formFields = fields.map(([id, label, type]) =>
|
| 212 |
+
`<label for="${id}">${label}</label>\n<input id="${id}" name="${id}" type="${type}" autocomplete="${id}">`).join("\n");
|
| 213 |
+
const tableRows = rows.map((r) => `<tr>${r.map((c) => `<td>${c}</td>`).join("")}</tr>`).join("\n");
|
| 214 |
+
const table = `<table>\n<caption>${caption}</caption>\n<tr>${colheads.map((c) => `<th scope="col">${c}</th>`).join("")}</tr>\n${tableRows}\n</table>`;
|
| 215 |
+
const sections = shuffle(rng, [
|
| 216 |
+
`<img src="${img}" alt="${heroAlt}">`,
|
| 217 |
+
`<p class="${noteClass}">${noteText}</p>`,
|
| 218 |
+
`<p><span style="color:${spanFg}">${spanText}</span></p>`,
|
| 219 |
+
table,
|
| 220 |
+
]);
|
| 221 |
+
const html = `<!DOCTYPE html>
|
| 222 |
+
<html lang="en">
|
| 223 |
+
<head>
|
| 224 |
+
<meta charset="utf-8">
|
| 225 |
+
<title>${title}</title>
|
| 226 |
+
${styleBlock}
|
| 227 |
+
</head>
|
| 228 |
+
<body>
|
| 229 |
+
<header>
|
| 230 |
+
<nav>${skip} <a href="/${nav2.toLowerCase()}">${nav2}</a></nav>
|
| 231 |
+
<h1>${title}</h1>
|
| 232 |
+
</header>
|
| 233 |
+
<main id="main">
|
| 234 |
+
${bigHead}
|
| 235 |
+
${sections[0]}
|
| 236 |
+
${sections[1]}
|
| 237 |
+
<h3>${h2b}</h3>
|
| 238 |
+
<form action="/signup" method="post">
|
| 239 |
+
${formFields}
|
| 240 |
+
<button type="submit">Sign up</button>
|
| 241 |
+
</form>
|
| 242 |
+
${sections[2]}
|
| 243 |
+
<p><button class="${ctaClass}" type="button">${ctaText}</button></p>
|
| 244 |
+
${sections[3]}
|
| 245 |
+
</main>
|
| 246 |
+
<footer>
|
| 247 |
+
<p><a href="/archive">Archive</a> <a href="/contact">Contact</a></p>
|
| 248 |
+
</footer>
|
| 249 |
+
</body>
|
| 250 |
+
</html>`;
|
| 251 |
+
return {
|
| 252 |
+
html,
|
| 253 |
+
hooks: {
|
| 254 |
+
heroAlt: ` alt="${heroAlt}"`,
|
| 255 |
+
label: fields[1] ? `<label for="${fields[1][0]}">${fields[1][1]}</label>\n` : `<label for="${fields[0][0]}">${fields[0][1]}</label>\n`,
|
| 256 |
+
noteRule: `.${noteClass}{color:${note.fg};`,
|
| 257 |
+
noteBad: `.${noteClass}{color:${badFg(rng, note.bg)};`,
|
| 258 |
+
spanRule: `<span style="color:${spanFg}">`,
|
| 259 |
+
spanBad: `<span style="color:${badFg(rng, body.bg)}">`,
|
| 260 |
+
ctaButton: `<button class="${ctaClass}" type="button">${ctaText}</button>`,
|
| 261 |
+
ctaText,
|
| 262 |
+
focusRule: `\na:focus-visible,.${ctaClass}:focus-visible{outline:3px solid ${focusColor};outline-offset:2px}`,
|
| 263 |
+
skip,
|
| 264 |
+
archive: `<a href="/archive">Archive</a>`,
|
| 265 |
+
},
|
| 266 |
+
};
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
const TABS = ["Overview", "History", "Members", "Billing", "Usage", "Alerts", "Archive", "Notes"];
|
| 270 |
+
|
| 271 |
+
// Hard tier: a different page skeleton, not the easy page with extra
|
| 272 |
+
// defects. Grouped fields carry names through an aria-labelledby chain,
|
| 273 |
+
// a tab widget holds role/tabindex/handler parts, and the table spans
|
| 274 |
+
// headers across columns and rows - so a fixer tuned to the easy template
|
| 275 |
+
// leaves real barriers behind.
|
| 276 |
+
function buildHard(rng) {
|
| 277 |
+
const title = `${pick(rng, ADJ)} ${pick(rng, NOUN)} ${pick(rng, KIND)}`;
|
| 278 |
+
const topics = pick(rng, TOPICS);
|
| 279 |
+
const [h2a, h2b, h3c] = topics;
|
| 280 |
+
const caption = pick(rng, CAPTIONS);
|
| 281 |
+
const noteClass = pick(rng, CLASS_A);
|
| 282 |
+
const ctaClass = pick(rng, CLASS_B);
|
| 283 |
+
const noteText = pick(rng, NOTES);
|
| 284 |
+
const spanText = pick(rng, SPANS);
|
| 285 |
+
const heroAlt = pick(rng, ALTS);
|
| 286 |
+
const img = `https://example.com/${title.toLowerCase().replace(/[^a-z]+/g, "-")}.jpg`;
|
| 287 |
+
const ctaText = pick(rng, CTA);
|
| 288 |
+
const nav2 = pick(rng, NAV2);
|
| 289 |
+
const cardText = pick(rng, CTA.filter((c) => c !== ctaText));
|
| 290 |
+
const tabs = pickN(rng, TABS, 2);
|
| 291 |
+
const [f0, f1, f2] = pickN(rng, FIELD_POOL, 3);
|
| 292 |
+
const colheads = pick(rng, COLHEADS);
|
| 293 |
+
const cells = pickN(rng, CELLS, 4);
|
| 294 |
+
const body = goodPair(rng);
|
| 295 |
+
const note = goodPair(rng);
|
| 296 |
+
const spanFg = goodFg(rng, body.bg);
|
| 297 |
+
const cta = goodPair(rng);
|
| 298 |
+
const tabPair = goodPair(rng);
|
| 299 |
+
const focusColor = goodPair(rng).fg;
|
| 300 |
+
const large = rng() < 0.5 ? largePair(rng) : null;
|
| 301 |
+
const largeRule = large ? `\n.big-head{color:${large.fg};background-color:${large.bg};font-size:26px;font-weight:700}` : "";
|
| 302 |
+
const bigHead = large ? `<h2 class="big-head" id="deck">${h2a}</h2>` : `<h2 id="deck">${h2a}</h2>`;
|
| 303 |
+
const styleBlock = `<style>
|
| 304 |
+
body{color:${body.fg};background-color:${body.bg};font-family:system-ui,sans-serif;line-height:1.5}
|
| 305 |
+
.${noteClass}{color:${note.fg};background-color:${note.bg}}
|
| 306 |
+
.tab{color:${tabPair.fg};background-color:${tabPair.bg};padding:.4rem .8rem;display:inline-block}
|
| 307 |
+
.${ctaClass}{color:${cta.fg};background-color:${cta.bg};padding:.6rem 1rem;border:0;border-radius:.4rem}
|
| 308 |
+
a:focus-visible,.${ctaClass}:focus-visible,[role=tab]:focus-visible{outline:3px solid ${focusColor};outline-offset:2px}${largeRule}
|
| 309 |
+
</style>`;
|
| 310 |
+
|
| 311 |
+
const skip = `<a href="#main">Skip to content</a>`;
|
| 312 |
+
const labelParts = f0[1].split(" ");
|
| 313 |
+
const labSpanA = `<span id="l-a">${labelParts[0]}</span>`;
|
| 314 |
+
const labSpanB = `<span id="l-b">${labelParts.slice(1).join(" ") || pick(rng, topics)}</span>`;
|
| 315 |
+
const tabA = `<div role="tab" tabindex="0" onkeydown="pickTab('a')" aria-selected="true">${tabs[0]}</div>`;
|
| 316 |
+
const tabB = `<div role="tab" tabindex="0" onkeydown="pickTab('b')" aria-selected="false">${tabs[1]}</div>`;
|
| 317 |
+
const tabsOpen = `<div class="tabs" role="tablist" aria-labelledby="tabs-title">`;
|
| 318 |
+
const label = `<label for="hf2">${f1[1]}</label>`;
|
| 319 |
+
const cardHref = `/${cardText.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
|
| 320 |
+
const cardLink = `<a href="${cardHref}">${cardText}</a>`;
|
| 321 |
+
const table = `<table>
|
| 322 |
+
<caption>${caption}</caption>
|
| 323 |
+
<tr><th scope="col">${colheads[0]}</th><th colspan="2" scope="colgroup">${colheads[1]}</th></tr>
|
| 324 |
+
<tr><th scope="row">${cells[0][0]}</th><td>${cells[0][1]}</td><td>${cells[0][2]}</td></tr>
|
| 325 |
+
<tr><th scope="row">${cells[1][0]}</th><td>${cells[1][1]}</td><td>${cells[1][2]}</td></tr>
|
| 326 |
+
<tr><th scope="row">${cells[2][0]}</th><td>${cells[2][1]}</td><td>${cells[2][2]}</td></tr>
|
| 327 |
+
</table>`;
|
| 328 |
+
const sections = shuffle(rng, [
|
| 329 |
+
`<img src="${img}" alt="${heroAlt}">`,
|
| 330 |
+
`<p class="${noteClass}">${noteText}</p>`,
|
| 331 |
+
`<p><span style="color:${spanFg}">${spanText}</span></p>`,
|
| 332 |
+
table,
|
| 333 |
+
]);
|
| 334 |
+
const html = `<!DOCTYPE html>
|
| 335 |
+
<html lang="en">
|
| 336 |
+
<head>
|
| 337 |
+
<meta charset="utf-8">
|
| 338 |
+
<title>${title}</title>
|
| 339 |
+
${styleBlock}
|
| 340 |
+
</head>
|
| 341 |
+
<body>
|
| 342 |
+
<header>
|
| 343 |
+
<nav>${skip} <a href="/${nav2.toLowerCase()}">${nav2}</a></nav>
|
| 344 |
+
<h1>${title}</h1>
|
| 345 |
+
</header>
|
| 346 |
+
<main id="main">
|
| 347 |
+
${bigHead}
|
| 348 |
+
<section aria-labelledby="deck">
|
| 349 |
+
${sections[0]}
|
| 350 |
+
${sections[1]}
|
| 351 |
+
</section>
|
| 352 |
+
<h3 id="tabs-title">${h2b}</h3>
|
| 353 |
+
${tabsOpen}
|
| 354 |
+
${tabA}
|
| 355 |
+
${tabB}
|
| 356 |
+
</div>
|
| 357 |
+
<h4>${h3c}</h4>
|
| 358 |
+
<fieldset>
|
| 359 |
+
<legend>${h3c}</legend>
|
| 360 |
+
${labSpanA} ${labSpanB}
|
| 361 |
+
<input id="hf1" name="hf1" type="${f0[2]}" autocomplete="off" aria-labelledby="l-a l-b">
|
| 362 |
+
${label}
|
| 363 |
+
<input id="hf2" name="hf2" type="${f1[2]}" autocomplete="${f1[0]}">
|
| 364 |
+
<input id="hf3" name="hf3" type="${f2[2]}" autocomplete="${f2[0]}" aria-label="${f2[1]}">
|
| 365 |
+
</fieldset>
|
| 366 |
+
${sections[2]}
|
| 367 |
+
<p>${cardLink} <button class="${ctaClass}" type="button">${ctaText}</button></p>
|
| 368 |
+
${sections[3]}
|
| 369 |
+
</main>
|
| 370 |
+
<footer>
|
| 371 |
+
<p><a href="/archive">Archive</a> <a href="/contact">Contact</a></p>
|
| 372 |
+
</footer>
|
| 373 |
+
</body>
|
| 374 |
+
</html>`;
|
| 375 |
+
return {
|
| 376 |
+
html,
|
| 377 |
+
hooks: {
|
| 378 |
+
heroAlt: ` alt="${heroAlt}"`,
|
| 379 |
+
label: `${label}\n`,
|
| 380 |
+
labSpanA,
|
| 381 |
+
labSpanB,
|
| 382 |
+
labelledby: `aria-labelledby="l-a l-b"`,
|
| 383 |
+
noteRule: `.${noteClass}{color:${note.fg};`,
|
| 384 |
+
noteBad: `.${noteClass}{color:${badFg(rng, note.bg)};`,
|
| 385 |
+
spanRule: `<span style="color:${spanFg}">`,
|
| 386 |
+
spanBad: `<span style="color:${badFg(rng, body.bg)}">`,
|
| 387 |
+
tabA,
|
| 388 |
+
tabsOpen,
|
| 389 |
+
ctaButton: `<button class="${ctaClass}" type="button">${ctaText}</button>`,
|
| 390 |
+
ctaText,
|
| 391 |
+
focusRule: `\na:focus-visible,.${ctaClass}:focus-visible,[role=tab]:focus-visible{outline:3px solid ${focusColor};outline-offset:2px}`,
|
| 392 |
+
skip,
|
| 393 |
+
archive: `<a href="/archive">Archive</a>`,
|
| 394 |
+
cardLink,
|
| 395 |
+
cardHref,
|
| 396 |
+
cardText,
|
| 397 |
+
heading3: `<h3 id="tabs-title">${h2b}</h3>`,
|
| 398 |
+
},
|
| 399 |
+
};
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
// Each breaker rewrites one hook in the fixed page. Variants make the same
|
| 403 |
+
// defect appear in different disguises (role-button lookalikes, multi-step
|
| 404 |
+
// tab order, empty-label silences) so a template-aware regex fixer misses.
|
| 405 |
+
const BREAKERS = {
|
| 406 |
+
"missing-alt": (h) => [(p) => p.replace(h.hooks.heroAlt, ""), "alt removed"],
|
| 407 |
+
"unlabeled-input": (h, rng) => {
|
| 408 |
+
const variant = rng();
|
| 409 |
+
if (variant < 0.5) return [(p) => p.replace(h.hooks.label, ""), "label removed"];
|
| 410 |
+
if (variant < 0.8) return [(p) => p.replace(/<label for="(\w+)">/, '<label for="missing-$1">'), "label for broken"];
|
| 411 |
+
return [(p) => p.replace(h.hooks.label.trimEnd(), h.hooks.label.trimEnd().replace(/>([^<]+)</, "><")), "label emptied"];
|
| 412 |
+
},
|
| 413 |
+
"low-contrast": (h) => [(p) => p.replace(h.hooks.noteRule, h.hooks.noteBad).replace(h.hooks.spanRule, h.hooks.spanBad), "colors dimmed"],
|
| 414 |
+
"heading-order": (h, rng) => [(p) => (rng() < 0.5
|
| 415 |
+
? p.replace("<h3>", "<h5>").replace("</h3>", "</h5>")
|
| 416 |
+
: p.replace("<h1>", "<h2>").replace("</h1>", "</h2>")), "headings shuffled"],
|
| 417 |
+
"tabindex-positive": (h, rng) => [(p) => {
|
| 418 |
+
// Multi-step order: sprinkle 1-3 positive tabindices across the page.
|
| 419 |
+
let out = p.replace('<a href="#main">', '<a tabindex="3" href="#main">');
|
| 420 |
+
if (rng() < 0.6) out = out.replace('<a href="/archive">', '<a tabindex="1" href="/archive">');
|
| 421 |
+
if (rng() < 0.4) out = out.replace('type="submit"', 'tabindex="7" type="submit"');
|
| 422 |
+
return out;
|
| 423 |
+
}, "tabindex added"],
|
| 424 |
+
"div-button": (h, rng) => {
|
| 425 |
+
const v = rng();
|
| 426 |
+
const repl = v < 0.4
|
| 427 |
+
? `<div class="cta-div" onclick="go()">${h.hooks.ctaText}</div>`
|
| 428 |
+
: v < 0.7
|
| 429 |
+
? `<div role="button">${h.hooks.ctaText}</div>`
|
| 430 |
+
: `<span class="cta-div" onclick="go()">${h.hooks.ctaText}</span>`;
|
| 431 |
+
return [(p) => p.replace(h.hooks.ctaButton, repl), "button divved"];
|
| 432 |
+
},
|
| 433 |
+
"missing-lang": () => [(p) => p.replace('<html lang="en">', "<html>"), "lang removed"],
|
| 434 |
+
"no-focus-style": (h) => [(p) => p.replace(h.hooks.focusRule, ""), "focus rule removed"],
|
| 435 |
+
"empty-link": (h, rng) => {
|
| 436 |
+
const v = rng();
|
| 437 |
+
if (v < 0.5) return [(p) => p.replace(h.hooks.archive, '<a href="/archive"></a>'), "link emptied"];
|
| 438 |
+
if (v < 0.8) return [(p) => p.replace(h.hooks.archive, '<a href="/archive" aria-label=""></a>'), "link label emptied"];
|
| 439 |
+
return [(p) => p.replace(h.hooks.archive, '<a href="/archive"><span class="icon"></span></a>'), "link icon unlabeled"];
|
| 440 |
+
},
|
| 441 |
+
"table-headers": () => [(p) => p.replaceAll("<th scope=\"col\">", "<td>").replaceAll("</th>", "</td>"), "headers demoted"],
|
| 442 |
+
};
|
| 443 |
+
|
| 444 |
+
// Hard-tier breakers hit the widget skeleton: dangling name chains, a Tab
|
| 445 |
+
// trap, a control nested in a link, a widget hidden from AT, and spanning
|
| 446 |
+
// headers demoted. Each leaves the page looking close to fixed, so a
|
| 447 |
+
// template-aware repair still fails the check.
|
| 448 |
+
const HARD_BREAKERS = {
|
| 449 |
+
"missing-alt": (h) => [(p) => p.replace(h.hooks.heroAlt, ""), "alt removed"],
|
| 450 |
+
"unlabeled-input": (h, rng) => {
|
| 451 |
+
const v = rng();
|
| 452 |
+
if (v < 0.35) return [(p) => p.replace(h.hooks.labSpanB, h.hooks.labSpanB.replace('id="l-b"', 'id="l-gone"')), "labelledby link cut"];
|
| 453 |
+
if (v < 0.6) return [(p) => p.replace(h.hooks.labSpanA, h.hooks.labSpanA.replace(/>([^<]+)</, "><")).replace(h.hooks.labSpanB, h.hooks.labSpanB.replace(/>([^<]+)</, "><")), "labelledby emptied"];
|
| 454 |
+
if (v < 0.8) return [(p) => p.replace(h.hooks.labelledby, 'aria-labelledby="l-a l-missing"'), "labelledby dangled"];
|
| 455 |
+
return [(p) => p.replace(h.hooks.label, ""), "label removed"];
|
| 456 |
+
},
|
| 457 |
+
"low-contrast": (h) => [(p) => p.replace(h.hooks.noteRule, h.hooks.noteBad).replace(h.hooks.spanRule, h.hooks.spanBad), "colors dimmed"],
|
| 458 |
+
"heading-order": (h, rng) => [(p) => (rng() < 0.5
|
| 459 |
+
? p.replace("<h3", "<h5").replace("</h3>", "</h5>")
|
| 460 |
+
: p.replace("<h1>", "<h2>").replace("</h1>", "</h2>")), "headings shuffled"],
|
| 461 |
+
"tabindex-positive": (h, rng) => [(p) => {
|
| 462 |
+
// Two disguises: a focus trap on the first tab (Tab swallowed), and
|
| 463 |
+
// a bent multi-step order across nav and footer.
|
| 464 |
+
let out = p;
|
| 465 |
+
if (rng() < 0.6) out = out.replace('onkeydown="pickTab(\'a\')"', "onkeydown=\"if(event.key==='Tab')event.preventDefault()\"");
|
| 466 |
+
out = out.replace('<a href="#main">', '<a tabindex="2" href="#main">');
|
| 467 |
+
if (rng() < 0.5) out = out.replace('<a href="/archive">', '<a tabindex="1" href="/archive">');
|
| 468 |
+
return out;
|
| 469 |
+
}, "tab order bent"],
|
| 470 |
+
"div-button": (h, rng) => {
|
| 471 |
+
const v = rng();
|
| 472 |
+
if (v < 0.4) return [(p) => p.replace(`<p>${h.hooks.cardLink} ${h.hooks.ctaButton}</p>`, `<p><a href="${h.hooks.cardHref}">${h.hooks.cardText}<div class="cta-div" onclick="go()">${h.hooks.ctaText}</div></a></p>`), "control nested in link"];
|
| 473 |
+
if (v < 0.7) return [(p) => p.replace(h.hooks.tabA, h.hooks.tabA.replace(' tabindex="0" onkeydown="pickTab(\'a\')"', "")), "tab lost keyboard support"];
|
| 474 |
+
return [(p) => p.replace(h.hooks.tabsOpen, h.hooks.tabsOpen.replace(/>$/, ' aria-hidden="true">')), "widget hidden from AT"];
|
| 475 |
+
},
|
| 476 |
+
"missing-lang": () => [(p) => p.replace('<html lang="en">', "<html>"), "lang removed"],
|
| 477 |
+
"no-focus-style": (h) => [(p) => p.replace(h.hooks.focusRule, ""), "focus rule removed"],
|
| 478 |
+
"empty-link": (h, rng) => {
|
| 479 |
+
const v = rng();
|
| 480 |
+
// The div-button breaker can consume the card link first; the footer
|
| 481 |
+
// archive link is always there as a fallback target.
|
| 482 |
+
return [(p) => {
|
| 483 |
+
const target = p.includes(h.hooks.cardLink) ? h.hooks.cardLink : h.hooks.archive;
|
| 484 |
+
if (v < 0.4 && target === h.hooks.cardLink) return p.replace(target, target.replace(">", ' aria-labelledby="ghost">'));
|
| 485 |
+
if (v < 0.7) return p.replace(target, target.replace(/>([^<]+)</, "><"));
|
| 486 |
+
return p.replace(target, target.replace(/>([^<]+)</, '><span class="icon"></span><'));
|
| 487 |
+
}, "link name removed"];
|
| 488 |
+
},
|
| 489 |
+
"table-headers": () => [(p) => p.replaceAll("<th ", "<td ").replaceAll("</th>", "</td>"), "headers demoted"],
|
| 490 |
+
};
|
| 491 |
+
|
| 492 |
+
function pickDefects(rng, taskIndex, tier) {
|
| 493 |
+
const ids = CHECKS.map(([id]) => id);
|
| 494 |
+
const defects = new Set([ids[taskIndex % ids.length]]);
|
| 495 |
+
const target = tier === "hard" ? 4 + Math.floor(rng() * 2) : 2 + Math.floor(rng() * 2);
|
| 496 |
+
while (defects.size < target) defects.add(ids[Math.floor(rng() * ids.length)]);
|
| 497 |
+
return [...defects];
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
const PROMPT_HEAD = `Fix the broken HTML page below so keyboard, screen-reader, and contrast checks pass.
|
| 501 |
+
|
| 502 |
+
Repair every defect you find: image text alternatives, input labels, text contrast (4.5:1 or better, or 3:1 for large text), heading order, tab order, native buttons, page language, visible focus styles, link names, and table headers. Keep all visible text and elements; do not delete or hide content to silence a check.
|
| 503 |
+
|
| 504 |
+
Return the complete fixed HTML document.`;
|
| 505 |
+
|
| 506 |
+
// Verification imports the real grader from the built package: an
|
| 507 |
+
// expected page is only a valid reference when it scores exactly 1.
|
| 508 |
+
const { benchmark } = await import(new URL("../dist/index.js", import.meta.url).href).catch(() => {
|
| 509 |
+
throw new Error("dist/index.js not found - run `npm run build` before generating tasks");
|
| 510 |
+
});
|
| 511 |
+
|
| 512 |
+
// Tokens that mean a template leak: a breaker or builder read a field
|
| 513 |
+
// that does not exist and strung the result into the page.
|
| 514 |
+
const JUNK = /\bundefined\b|\bNaN\b|\[object Object\]|\bnull\b/;
|
| 515 |
+
const assertNoJunk = (where, text) => {
|
| 516 |
+
if (JUNK.test(text)) throw new Error(`generated ${where} contains a template-leak token`);
|
| 517 |
+
};
|
| 518 |
+
|
| 519 |
+
// Grade the fixed page as if every check were an injected defect: the
|
| 520 |
+
// score is exactly 1 iff all ten checks pass with real targets. A page
|
| 521 |
+
// that fails any check gets re-drawn; a reference that caps its own
|
| 522 |
+
// task below 1 must never ship.
|
| 523 |
+
const ALL_DEFECTS = CHECKS.map(([id]) => id);
|
| 524 |
+
async function expectedScoresOne(html) {
|
| 525 |
+
const probe = { id: "a11y-probe", kind: "single", prompt: `\`\`\`html\n${html}\n\`\`\``, expected: html, metadata: { defects: ALL_DEFECTS } };
|
| 526 |
+
const result = await benchmark.score(probe, { answer: html });
|
| 527 |
+
return result.score === 1;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
const rng = mulberry32(seed);
|
| 531 |
+
const tasks = [];
|
| 532 |
+
const fingerprints = new Set();
|
| 533 |
+
for (let i = 0; i < count; i++) {
|
| 534 |
+
const tier = i % 3 === 2 ? "hard" : "easy";
|
| 535 |
+
const build = tier === "hard" ? buildHard : buildFixed;
|
| 536 |
+
const breakers = tier === "hard" ? HARD_BREAKERS : BREAKERS;
|
| 537 |
+
let built;
|
| 538 |
+
for (let attempt = 0; ; attempt += 1) {
|
| 539 |
+
built = build(rng);
|
| 540 |
+
assertNoJunk(`page ${i + 1}`, built.html);
|
| 541 |
+
if (await expectedScoresOne(built.html)) break;
|
| 542 |
+
if (attempt >= 199) throw new Error(`task ${i + 1}: no clean reference page after 200 draws`);
|
| 543 |
+
}
|
| 544 |
+
const defects = pickDefects(rng, i, tier).sort();
|
| 545 |
+
let broken = built.html;
|
| 546 |
+
for (const id of defects) {
|
| 547 |
+
const [breakPage] = breakers[id](built, rng);
|
| 548 |
+
const next = breakPage(broken);
|
| 549 |
+
if (next === broken) throw new Error(`breaker ${id} changed nothing on task ${i + 1}`);
|
| 550 |
+
broken = next;
|
| 551 |
+
}
|
| 552 |
+
if (broken === built.html) throw new Error(`task ${i + 1} has no visible break`);
|
| 553 |
+
assertNoJunk(`task ${i + 1}`, broken);
|
| 554 |
+
fingerprints.add(createHash("sha1").update(built.html.replace(/>\s*</g, "><").replace(/[\w.-]+(?=\.jpg|"[a-z-]+")/g, "#")).digest("hex").slice(0, 12));
|
| 555 |
+
const idNum = String(i + 1).padStart(2, "0");
|
| 556 |
+
tasks.push({
|
| 557 |
+
id: `${split === "hidden" ? "a11yh" : "a11y"}-${idNum}`,
|
| 558 |
+
kind: "single",
|
| 559 |
+
prompt: `${PROMPT_HEAD}\n\n\`\`\`html\n${broken}\n\`\`\``,
|
| 560 |
+
expected: built.html,
|
| 561 |
+
metadata: {
|
| 562 |
+
defects, wcag: defects.map((d) => WCAG[d]), tier, seed, split, taskSeed: seed + i,
|
| 563 |
+
},
|
| 564 |
+
});
|
| 565 |
+
assertNoJunk(`task ${i + 1} prompt`, tasks[tasks.length - 1].prompt);
|
| 566 |
+
}
|
| 567 |
+
const coverage = new Map(CHECKS.map(([id]) => [id, 0]));
|
| 568 |
+
for (const task of tasks) for (const id of task.metadata.defects) coverage.set(id, coverage.get(id) + 1);
|
| 569 |
+
for (const [id, n] of coverage) {
|
| 570 |
+
if (n < Math.floor(count / CHECKS.length)) throw new Error(`check ${id} appears in only ${n} tasks`);
|
| 571 |
+
}
|
| 572 |
+
// Distinct pages, not six fixed themes: the hidden split cannot reuse a
|
| 573 |
+
// public reference page. Require well above the old six-theme ceiling.
|
| 574 |
+
if (fingerprints.size < Math.min(30, count)) {
|
| 575 |
+
throw new Error(`only ${fingerprints.size} distinct page fingerprints (need >= ${Math.min(30, count)})`);
|
| 576 |
+
}
|
| 577 |
+
await mkdir(dirname(out), { recursive: true });
|
| 578 |
+
await writeFile(out, `${tasks.map((task) => JSON.stringify(task)).join("\n")}\n`);
|
| 579 |
+
console.log(`generated ${tasks.length} ${split} tasks (seed ${seed}) -> ${out}`);
|
| 580 |
+
console.log(`fingerprints: ${fingerprints.size} distinct pages`);
|
| 581 |
+
console.log(`coverage: ${[...coverage].map(([id, n]) => `${id}=${n}`).join(" ")}`);
|