@kinti/a11y-toolkit 5.22.2 → 5.22.3

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jesús Quintana Fernández
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.
@@ -46,6 +46,7 @@ from . import a11ybudget
46
46
  from . import a11ycrit
47
47
  from . import a11ydiff
48
48
  from . import a11ysarif
49
+ from . import a11ywcagem
49
50
  from . import contrast
50
51
  from . import a11ystatement
51
52
  from . import a11yjourney
@@ -68,6 +69,7 @@ SUBCOMMANDS = {
68
69
  'diff': (a11ydiff, 'diff'),
69
70
  'criterion': (a11ycrit, None),
70
71
  'sarif': (a11ysarif, None),
72
+ 'wcagem': (a11ywcagem, None),
71
73
  'fix': (a11yfix, None),
72
74
  'kbd': (a11ydom, 'kbd_main'),
73
75
  'scroll': (a11yscroll, None),
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env python3
2
+ """WCAG-EM 2.0 evaluation mode — the sampling/aggregation layer.
3
+
4
+ WCAG-EM (W3C Group Note, 2026-07-23) is HOW a full evaluation is scoped,
5
+ sampled and reported. This module does the machine half honestly:
6
+
7
+ plan JSON → what is being evaluated (Step 1), the sample set (Step 3)
8
+ packs[] → the sealed evidence per sample (Step 4, a11y_evidence output)
9
+ report → per-criterion rollup ACROSS the sample (Step 5), sealed with
10
+ a root hash over the pack seals
11
+
12
+ What it deliberately does NOT do: claim conformance. The report carries
13
+ evidence-status per criterion (the worst across the sample wins), the
14
+ priced human work that remains, and the standard's step trace. Random
15
+ sample selection stays with the evaluator (their methodology, their name);
16
+ structured samples and complete processes (journeys) are first-class.
17
+
18
+ CLI:
19
+ a11ywcagem.py --plan plan.json --packs p1.json p2.json -o report.json
20
+ """
21
+
22
+ import argparse
23
+ import hashlib
24
+ import json
25
+ import sys
26
+
27
+ # El worst peor gana al agregar samples; never-flagged en TODAS no es pass
28
+ # (es "ninguna señal saltó en esta sample"), exactamente como el pack.
29
+ _RANK = {'automated-fail': 0, 'not-run': 1, 'automated-review': 2,
30
+ 'manual-only': 3, 'not-flagged': 4, 'agent-verified': 5}
31
+
32
+ _TYPES = ('structured', 'random', 'process', 'common-view')
33
+
34
+ _STEPS = [
35
+ {'step': '1', 'what': 'Define the evaluation scope',
36
+ 'where': 'plan.product (enclosure: all views, states, functionality)'},
37
+ {'step': '1.2', 'what': 'Conformance target', 'where': 'plan.conformance_target'},
38
+ {'step': '1.3', 'what': 'Accessibility support baseline', 'where': 'plan.support_baseline'},
39
+ {'step': '2', 'what': 'Explore the target product', 'where': 'plan.sample[].why'},
40
+ {'step': '3', 'what': 'Select a representative sample set',
41
+ 'where': 'plan.sample[] (structured / random / process) + packs per sample'},
42
+ {'step': '4', 'what': 'Evaluate the selected sample set',
43
+ 'where': 'the evidence packs (a11y-evidence-pack/2)'},
44
+ {'step': '5', 'what': 'Report the evaluation findings', 'where': 'this report'},
45
+ ]
46
+
47
+
48
+ def _canon(obj):
49
+ return json.dumps(obj, ensure_ascii=False, sort_keys=True,
50
+ separators=(',', ':'))
51
+
52
+
53
+ def validate_plan(plan):
54
+ """Plan (dict) → (ok, error). Solo estructura; el muestreo es del auditor."""
55
+ if not isinstance(plan, dict):
56
+ return False, 'el plan debe ser un objeto'
57
+ for field in ('product', 'conformance_target', 'sample'):
58
+ if field not in plan:
59
+ return False, f'falta {field} (WCAG-EM paso 1/3)'
60
+ if not isinstance(plan['product'], dict) or not plan['product'].get('name'):
61
+ return False, 'product.name es obligatorio (¿qué se evalúa?)'
62
+ if not isinstance(plan['conformance_target'], str):
63
+ return False, 'conformance_target debe ser texto (p. ej. "WCAG 2.2 AA")'
64
+ sample = plan['sample']
65
+ if not isinstance(sample, list) or not sample:
66
+ return False, 'sample debe ser una lista no vacía de samples'
67
+ for i, m in enumerate(sample):
68
+ if not isinstance(m, dict):
69
+ return False, f'sample #{i + 1} debe ser objeto'
70
+ for field in ('id', 'type'):
71
+ if not m.get(field):
72
+ return False, f'sample #{i + 1} sin {field}'
73
+ if m['type'] not in _TYPES:
74
+ return False, (f"sample {m['id']}: type debe ser "
75
+ f"{'/'.join(_TYPES)} (WCAG-EM 3.1-3.3)")
76
+ if not m.get('url') and not m.get('file'):
77
+ return False, f"sample {m['id']}: url o file requeridos"
78
+ return True, ''
79
+
80
+
81
+ def aggregate(plan, packs):
82
+ """Plan válido + packs sellados → report agregado con sello raíz.
83
+
84
+ Regla de agregado por criterio: el PEOR worst de todas las samples
85
+ (un fallo en cualquier página muestreada es un fallo del report).
86
+ agent-verified no borra un fail (misma honestidad que el pack).
87
+ """
88
+ ok, err = validate_plan(plan)
89
+ if not ok:
90
+ raise ValueError(err)
91
+ if len(packs) != len(plan['sample']):
92
+ raise ValueError(f'{len(plan["sample"])} samples, {len(packs)} packs: deben emparejar')
93
+
94
+ codes, names, effort = set(), {}, {'MIN': 0, 'MED': 0, 'MAX': 0}
95
+ worst = {} # code → peor worst
96
+ fail_counts = {} # code → cuántas samples fallaron
97
+ for pack in packs:
98
+ for c in pack.get('criteria', []):
99
+ code = c['criterion'].split(' ')[0]
100
+ codes.add(code)
101
+ names[code] = c['criterion']
102
+ st = c['status']
103
+ if code not in worst or _RANK[st] < _RANK[worst[code]]:
104
+ worst[code] = st
105
+ if st == 'automated-fail':
106
+ fail_counts[code] = fail_counts.get(code, 0) + 1
107
+ ef = c.get('effort', {}).get('class')
108
+ if ef in effort and st != 'agent-verified':
109
+ effort[ef] += 1
110
+
111
+ criteria = []
112
+ for code in sorted(codes, key=lambda x: tuple(int(n) for n in x.split('.'))):
113
+ row = {'criterion': names[code], 'status': worst[code],
114
+ 'samples_failing': fail_counts.get(code, 0),
115
+ 'total_samples': len(packs)}
116
+ if worst[code] == 'not-flagged':
117
+ row['note'] = ('no signal fired on ANY sampled page — explicitly '
118
+ 'NOT pass; the human still owns this criterion')
119
+ criteria.append(row)
120
+
121
+ report = {
122
+ 'format': 'a11y-wcagem-report/1',
123
+ 'method': 'WCAG-EM 2.0 (W3C Group Note, 2026-07-23)',
124
+ 'product': plan['product'],
125
+ 'conformance_target': plan['conformance_target'],
126
+ 'support_baseline': plan.get('support_baseline', []),
127
+ 'sample': plan['sample'],
128
+ 'wcag_em': {'steps': _STEPS,
129
+ 'note': ('random selection (3.2) stays with the evaluator: '
130
+ 'this tool aggregates, never chooses')},
131
+ 'criteria': criteria,
132
+ 'summary': {s: sum(1 for c in criteria if c['status'] == s)
133
+ for s in _RANK},
134
+ 'effort_pending': effort,
135
+ 'packs': [{'sample': m['id'], 'type': m['type'],
136
+ 'sha256': p['sha256'], 'format': p.get('format')}
137
+ for m, p in zip(plan['sample'], packs)],
138
+ # sin claim de conformidad: el report ES evidencia para el humano
139
+ }
140
+ report['sha256'] = hashlib.sha256(
141
+ _canon({k: v for k, v in report.items() if k != 'sha256'}).encode('utf-8')
142
+ ).hexdigest()
143
+ return report
144
+
145
+
146
+ def verify_report(report):
147
+ """(ok, detalle): el sello raíz del report (menos sha256)."""
148
+ expected = hashlib.sha256(
149
+ _canon({k: v for k, v in report.items() if k != 'sha256'}).encode('utf-8')
150
+ ).hexdigest()
151
+ return expected == report.get('sha256'), 'root sha256'
152
+
153
+
154
+ def main(argv):
155
+ ap = argparse.ArgumentParser(description='WCAG-EM 2.0 aggregated evaluation report')
156
+ ap.add_argument('--plan', required=True, help='evaluation plan JSON (scope + sample set)')
157
+ ap.add_argument('--packs', nargs='+', required=True,
158
+ help='evidence pack JSON per sample, in plan.sample order')
159
+ ap.add_argument('-o', '--out', default='wcagem-report.json')
160
+ a = ap.parse_args(argv)
161
+ plan = json.load(open(a.plan, encoding='utf-8'))
162
+ packs = [json.load(open(p, encoding='utf-8')) for p in a.packs]
163
+ try:
164
+ report = aggregate(plan, packs)
165
+ except ValueError as e:
166
+ print(json.dumps({'error': str(e)}))
167
+ return 2
168
+ with open(a.out, 'w', encoding='utf-8') as f:
169
+ json.dump(report, f, ensure_ascii=False, indent=1)
170
+ print(json.dumps({'report': a.out, 'sha256': report['sha256'],
171
+ 'criteria': len(report['criteria']),
172
+ 'summary': report['summary']}, ensure_ascii=False))
173
+ return 0
174
+
175
+
176
+ if __name__ == '__main__':
177
+ sys.exit(main(sys.argv[1:]))
@@ -87,7 +87,7 @@ try:
87
87
  except ImportError:
88
88
  ARIALIVE_JS = None # repo checkout: read the file
89
89
 
90
- VERSION = '5.22.2'
90
+ VERSION = '5.22.3'
91
91
 
92
92
  # Params renombrados a inglés en 5.11.0; se aceptan los nombres previos.
93
93
  PARAM_ALIASES = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kinti/a11y-toolkit",
3
- "version": "5.22.2",
4
- "description": "Zero-dependency WCAG 2.2 accessibility engine (34 MCP tools + CLI): audits, contrast fixing, SHA-256-sealed evidence packs, SARIF, EARL/ACT, CI ratchet. Node launcher; the engine itself is Python via uv.",
3
+ "version": "5.22.3",
4
+ "description": "Zero-dependency WCAG 2.2 accessibility engine (34 MCP tools + CLI): audits, contrast fixing, SHA-256-sealed evidence packs, SARIF, EARL/ACT, CI ratchet. Self-contained: the pure-stdlib Python engine ships inside and runs via python3 \u2014 no downloads, no installs.",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -17,6 +17,7 @@
17
17
  "bin/",
18
18
  "lib/",
19
19
  "a11y_toolkit/",
20
+ "LICENSE",
20
21
  "README.md"
21
22
  ],
22
23
  "keywords": [
@@ -33,5 +34,8 @@
33
34
  ],
34
35
  "engines": {
35
36
  "node": ">=16"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/kinti/a11y-toolkit/issues"
36
40
  }
37
41
  }