@kinti/a11y-toolkit 5.22.2 → 5.23.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.
- package/LICENSE +21 -0
- package/a11y_toolkit/a11y.py +4 -0
- package/a11y_toolkit/a11yplan.py +214 -0
- package/a11y_toolkit/a11ywcagem.py +177 -0
- package/a11y_toolkit/server.py +1 -1
- package/package.json +6 -2
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.
|
package/a11y_toolkit/a11y.py
CHANGED
|
@@ -46,6 +46,8 @@ from . import a11ybudget
|
|
|
46
46
|
from . import a11ycrit
|
|
47
47
|
from . import a11ydiff
|
|
48
48
|
from . import a11ysarif
|
|
49
|
+
from . import a11ywcagem
|
|
50
|
+
from . import a11yplan
|
|
49
51
|
from . import contrast
|
|
50
52
|
from . import a11ystatement
|
|
51
53
|
from . import a11yjourney
|
|
@@ -68,6 +70,8 @@ SUBCOMMANDS = {
|
|
|
68
70
|
'diff': (a11ydiff, 'diff'),
|
|
69
71
|
'criterion': (a11ycrit, None),
|
|
70
72
|
'sarif': (a11ysarif, None),
|
|
73
|
+
'wcagem': (a11ywcagem, None),
|
|
74
|
+
'plan': (a11yplan, None),
|
|
71
75
|
'fix': (a11yfix, None),
|
|
72
76
|
'kbd': (a11ydom, 'kbd_main'),
|
|
73
77
|
'scroll': (a11yscroll, None),
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Remediation plan — turn a findings list into an ordered ROUTE.
|
|
3
|
+
|
|
4
|
+
An inventory of 40 findings overwhelms; nobody answers "in what order?".
|
|
5
|
+
Planning matters because fixes change the cost of other fixes: semantic
|
|
6
|
+
infrastructure (headings, landmarks, labels) makes later work cheaper, one
|
|
7
|
+
design-token decision kills many contrast findings at once, and instances
|
|
8
|
+
on a page headed for redesign are wasted minutes. Cross-industry origin:
|
|
9
|
+
planning over evolving state (candidate-generation MDPs, arXiv 2607.02115)
|
|
10
|
+
— translated here into a deterministic, auditable heuristic. No ML, no
|
|
11
|
+
network: batches, declared phases, declared minute assumptions, a root
|
|
12
|
+
seal. The human reorders; the plan is evidence, not an oracle.
|
|
13
|
+
|
|
14
|
+
Phases (in order):
|
|
15
|
+
infrastructure — structural semantics first (they reprice everything else)
|
|
16
|
+
design-system — shared-cause decisions (contrast as a system fix)
|
|
17
|
+
instances — per-instance work, severity high → medium → low
|
|
18
|
+
redesign-zone — one page accumulating many distinct signals: flagged,
|
|
19
|
+
moved last, with an explicit note
|
|
20
|
+
|
|
21
|
+
CLI:
|
|
22
|
+
a11ytoolkit plan --report audit.json [-o plan.json]
|
|
23
|
+
a11ytoolkit plan --report audit.json --from-pack pack.json # pack effort
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import argparse
|
|
27
|
+
import hashlib
|
|
28
|
+
import json
|
|
29
|
+
import sys
|
|
30
|
+
|
|
31
|
+
# Phase assignment by signal class (declared, not learned).
|
|
32
|
+
INFRA_SIGNALS = {'no_h1', 'heading_order', 'landmark', 'bypass_missing',
|
|
33
|
+
'region_missing', 'field_label', 'button_name', 'link_name',
|
|
34
|
+
'img_no_alt', 'iframe_title', 'html_lang_missing',
|
|
35
|
+
'title_missing', 'viewport_zoom_blocked'}
|
|
36
|
+
DESIGN_SIGNALS = {'contrast_low', 'contrast_image_fail', 'color_alone',
|
|
37
|
+
'focus_visibility', 'text_spacing'}
|
|
38
|
+
MINUTES_BY_SEVERITY = {'high': [12, 20], 'medium': [5, 10], 'low': [2, 4]}
|
|
39
|
+
REDESIGN_SIGNAL_THRESHOLD = 4 # distinct signals on one URL → zone flag
|
|
40
|
+
|
|
41
|
+
# What each assumption means, printed with the plan (honesty by default).
|
|
42
|
+
ASSUMPTIONS_HEURISTIC = {
|
|
43
|
+
'source': 'severity heuristic',
|
|
44
|
+
'minutes': MINUTES_BY_SEVERITY,
|
|
45
|
+
'note': ('per-finding heuristic ranges, NOT measured effort; the pack '
|
|
46
|
+
'effort pricing (a11y_evidence) is the better source when '
|
|
47
|
+
'available'),
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _canon(obj):
|
|
52
|
+
return json.dumps(obj, ensure_ascii=False, sort_keys=True,
|
|
53
|
+
separators=(',', ':'))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _minutes_for(findings, effort_by_criterion=None):
|
|
57
|
+
"""Sum of per-finding minute ranges. With pack effort pricing, the
|
|
58
|
+
criterion's MIN/MED/MAX range replaces the severity heuristic."""
|
|
59
|
+
lo = hi = 0
|
|
60
|
+
for f in findings:
|
|
61
|
+
eff = effort_by_criterion.get((f.get('criterion') or '').split(' ')[0])
|
|
62
|
+
if eff and eff.get('minutes'):
|
|
63
|
+
lo += eff['minutes'][0]
|
|
64
|
+
hi += eff['minutes'][1]
|
|
65
|
+
else:
|
|
66
|
+
r = MINUTES_BY_SEVERITY.get(f.get('severity', 'low'), MINUTES_BY_SEVERITY['low'])
|
|
67
|
+
lo += r[0]
|
|
68
|
+
hi += r[1]
|
|
69
|
+
return [lo, hi]
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def build_plan(report, pack=None):
|
|
73
|
+
"""Report (dict with findings[]) → sealed fix-plan dict. Deterministic:
|
|
74
|
+
same report, same plan. Malformed findings are skipped, never fatal."""
|
|
75
|
+
findings = [f for f in (report.get('findings') or []) if isinstance(f, dict)
|
|
76
|
+
and f.get('signal')]
|
|
77
|
+
effort_by_criterion = {}
|
|
78
|
+
if pack:
|
|
79
|
+
for c in pack.get('criteria', []):
|
|
80
|
+
if c.get('effort', {}).get('minutes'):
|
|
81
|
+
effort_by_criterion[c['criterion'].split(' ')[0]] = c['effort']
|
|
82
|
+
assumptions = dict(ASSUMPTIONS_HEURISTIC)
|
|
83
|
+
if pack:
|
|
84
|
+
assumptions = {'source': 'pack effort',
|
|
85
|
+
'note': 'minutes from the evidence pack effort pricing'}
|
|
86
|
+
|
|
87
|
+
# redesign zones: one URL accumulating many distinct signals
|
|
88
|
+
by_url = {}
|
|
89
|
+
for f in findings:
|
|
90
|
+
u = f.get('url') or report.get('url') or ''
|
|
91
|
+
by_url.setdefault(u, set()).add(f['signal'])
|
|
92
|
+
zones = {u for u, sigs in by_url.items() if len(sigs) >= REDESIGN_SIGNAL_THRESHOLD}
|
|
93
|
+
|
|
94
|
+
# batch by signal inside each phase (one signal = one kind of fix)
|
|
95
|
+
by_signal = {}
|
|
96
|
+
for f in findings:
|
|
97
|
+
by_signal.setdefault(f['signal'], []).append(f)
|
|
98
|
+
|
|
99
|
+
def phase_of(signal):
|
|
100
|
+
if signal in INFRA_SIGNALS:
|
|
101
|
+
return 'infrastructure'
|
|
102
|
+
if signal in DESIGN_SIGNALS:
|
|
103
|
+
return 'design-system'
|
|
104
|
+
return 'instances'
|
|
105
|
+
|
|
106
|
+
sev_rank = {'high': 0, 'medium': 1, 'low': 2}
|
|
107
|
+
batches = []
|
|
108
|
+
infra_signals = sorted(s for s in by_signal if phase_of(s) == 'infrastructure')
|
|
109
|
+
for signal in sorted(by_signal):
|
|
110
|
+
if signal in infra_signals and signal != (infra_signals or [signal])[0]:
|
|
111
|
+
continue # infrastructure is ONE combined batch (one work session)
|
|
112
|
+
fs = by_signal[signal]
|
|
113
|
+
if signal == (infra_signals or [None])[0] and infra_signals:
|
|
114
|
+
fs = [f for sg in infra_signals for f in by_signal[sg]]
|
|
115
|
+
signal = 'document_structure'
|
|
116
|
+
phase = 'infrastructure' if signal == 'document_structure' else phase_of(signal)
|
|
117
|
+
zone = bool(zones & {f.get('url') or '' for f in fs})
|
|
118
|
+
if phase == 'instances' and zone and len({f.get('url') for f in fs}) == 1 \
|
|
119
|
+
and len(by_url[list(zones & {f.get('url') for f in fs})[0]]) >= REDESIGN_SIGNAL_THRESHOLD:
|
|
120
|
+
phase = 'redesign-zone'
|
|
121
|
+
sev = min((sev_rank.get(f.get('severity', 'low'), 2) for f in fs))
|
|
122
|
+
batch = {
|
|
123
|
+
'title': (f"Fix document structure semantics ({len(fs)} findings)"
|
|
124
|
+
if signal == 'document_structure' else
|
|
125
|
+
f"Fix {signal.replace('_', ' ')} ({len(fs)} finding"
|
|
126
|
+
f"{'s' if len(fs) != 1 else ''})"),
|
|
127
|
+
'phase': phase, 'signal': signal,
|
|
128
|
+
'finding_count': len(fs), 'severity': ('high', 'medium', 'low')[sev],
|
|
129
|
+
'signals': infra_signals if signal == 'document_structure' else [signal],
|
|
130
|
+
'urls': sorted({f.get('url') or '' for f in fs})[:8],
|
|
131
|
+
'criteria': sorted({(f.get('criterion') or '').split(' ')[0] for f in fs}),
|
|
132
|
+
'minutes': _minutes_for(fs, effort_by_criterion),
|
|
133
|
+
'note': ('same kind of fix repeated — fix the pattern once and '
|
|
134
|
+
're-apply; itemized minutes are the upper bound'
|
|
135
|
+
if len(fs) > 1 else ''),
|
|
136
|
+
}
|
|
137
|
+
if phase == 'redesign-zone':
|
|
138
|
+
batch['note'] = ('this URL accumulates %d distinct signals — '
|
|
139
|
+
'consider fixing it in a redesign pass, not '
|
|
140
|
+
'piecemeal' % len(by_url[list(zones & {f.get('url') for f in fs})[0]]))
|
|
141
|
+
batches.append(batch)
|
|
142
|
+
|
|
143
|
+
order = {'infrastructure': 0, 'design-system': 1, 'instances': 2, 'redesign-zone': 3}
|
|
144
|
+
batches.sort(key=lambda b: (order[b['phase']], sev_rank[b['severity']],
|
|
145
|
+
b['signal']))
|
|
146
|
+
|
|
147
|
+
# design-system note when contrast concentrates: one decision, many fixes
|
|
148
|
+
design = [b for b in batches if b['phase'] == 'design-system']
|
|
149
|
+
if design and sum(b['finding_count'] for b in design) >= 3:
|
|
150
|
+
design[0]['note'] = (design[0]['note'] or '') + (
|
|
151
|
+
' — consider a design-token/theme decision: one change here '
|
|
152
|
+
'typically resolves every finding in this batch').strip(' —')
|
|
153
|
+
|
|
154
|
+
cumulative = [0, 0]
|
|
155
|
+
for b in batches:
|
|
156
|
+
cumulative[0] += b['minutes'][0]
|
|
157
|
+
cumulative[1] += b['minutes'][1]
|
|
158
|
+
b['cumulative_minutes'] = list(cumulative)
|
|
159
|
+
|
|
160
|
+
itemized = [cumulative[0], cumulative[1]]
|
|
161
|
+
savings = [max(0, itemized[0] // 6), max(0, itemized[1] // 5)] # declared: 15-20% pattern reuse
|
|
162
|
+
|
|
163
|
+
plan = {
|
|
164
|
+
'format': 'a11y-fix-plan/1',
|
|
165
|
+
'source_report': {'url': report.get('url'), 'score': report.get('score'),
|
|
166
|
+
'mode': report.get('mode'),
|
|
167
|
+
'findings_total': len(findings)},
|
|
168
|
+
'assumptions': assumptions,
|
|
169
|
+
'batches': batches,
|
|
170
|
+
'total_minutes': list(cumulative),
|
|
171
|
+
'grouping_savings_minutes': savings,
|
|
172
|
+
'grouping_note': ('declared estimate of pattern-reuse savings from '
|
|
173
|
+
'fixing by batch instead of item by item — an '
|
|
174
|
+
'optimistic bound, not a promise'),
|
|
175
|
+
'redesign_zones': sorted(zones),
|
|
176
|
+
'note': ('the order is a declared heuristic: infrastructure first '
|
|
177
|
+
'(it reprices everything else), then design decisions, '
|
|
178
|
+
'then instances; the human reorders — re-run the seal '
|
|
179
|
+
'after reordering')
|
|
180
|
+
+ ('' if findings else ' NO FINDINGS in the source report '
|
|
181
|
+
'— nothing to plan (run the audit first).'),
|
|
182
|
+
}
|
|
183
|
+
plan['sha256'] = hashlib.sha256(
|
|
184
|
+
_canon({k: v for k, v in plan.items() if k != 'sha256'}).encode('utf-8')
|
|
185
|
+
).hexdigest()
|
|
186
|
+
return plan
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def verify_plan(plan):
|
|
190
|
+
expected = hashlib.sha256(
|
|
191
|
+
_canon({k: v for k, v in plan.items() if k != 'sha256'}).encode('utf-8')
|
|
192
|
+
).hexdigest()
|
|
193
|
+
return expected == plan.get('sha256'), 'root sha256'
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def main(argv):
|
|
197
|
+
ap = argparse.ArgumentParser(description='Remediation plan: findings → ordered fix route')
|
|
198
|
+
ap.add_argument('--report', required=True, help='audit report JSON (findings[])')
|
|
199
|
+
ap.add_argument('--from-pack', help='evidence pack JSON: use its effort pricing for minutes')
|
|
200
|
+
ap.add_argument('-o', '--out', default='fix-plan.json')
|
|
201
|
+
a = ap.parse_args(argv)
|
|
202
|
+
report = json.load(open(a.report, encoding='utf-8'))
|
|
203
|
+
pack = json.load(open(a.from_pack, encoding='utf-8')) if a.from_pack else None
|
|
204
|
+
plan = build_plan(report, pack=pack)
|
|
205
|
+
with open(a.out, 'w', encoding='utf-8') as f:
|
|
206
|
+
json.dump(plan, f, ensure_ascii=False, indent=1)
|
|
207
|
+
print(json.dumps({'plan': a.out, 'sha256': plan['sha256'],
|
|
208
|
+
'batches': len(plan['batches']),
|
|
209
|
+
'total_minutes': plan['total_minutes']}, ensure_ascii=False))
|
|
210
|
+
return 0
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
if __name__ == '__main__':
|
|
214
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -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:]))
|
package/a11y_toolkit/server.py
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kinti/a11y-toolkit",
|
|
3
|
-
"version": "5.
|
|
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.
|
|
3
|
+
"version": "5.23.0",
|
|
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
|
}
|