@kinti/a11y-toolkit 5.26.0 → 5.27.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/a11y_toolkit/a11y.py +27 -4
  3. package/a11y_toolkit/a11yact.py +9 -1
  4. package/a11y_toolkit/a11yannotate.py +185 -0
  5. package/a11y_toolkit/a11yaudit.py +853 -193
  6. package/a11y_toolkit/a11ybadge.py +24 -17
  7. package/a11y_toolkit/a11ybudget.py +145 -1
  8. package/a11y_toolkit/a11ycorpus.py +58 -24
  9. package/a11y_toolkit/a11ycrit.py +110 -53
  10. package/a11y_toolkit/a11ydiff.py +104 -34
  11. package/a11y_toolkit/a11ydisprove.py +15 -8
  12. package/a11y_toolkit/a11ydocx.py +8 -6
  13. package/a11y_toolkit/a11ydom.py +425 -95
  14. package/a11y_toolkit/a11yen301549.py +53 -1
  15. package/a11y_toolkit/a11yengines.py +157 -0
  16. package/a11y_toolkit/a11yevidence.py +81 -33
  17. package/a11y_toolkit/a11yfix.py +131 -52
  18. package/a11y_toolkit/a11yinit.py +30 -5
  19. package/a11y_toolkit/a11yjourney.py +110 -4
  20. package/a11y_toolkit/a11yledger.py +119 -12
  21. package/a11y_toolkit/a11ylocate.py +247 -0
  22. package/a11y_toolkit/a11yopenacr.py +10 -3
  23. package/a11y_toolkit/a11ypatches.py +154 -0
  24. package/a11y_toolkit/a11ypatterns.py +344 -0
  25. package/a11y_toolkit/a11ypdf.py +109 -53
  26. package/a11y_toolkit/a11yrgaa.py +60 -0
  27. package/a11y_toolkit/a11yroute.py +34 -12
  28. package/a11y_toolkit/a11ysarif.py +45 -18
  29. package/a11y_toolkit/a11yscope.py +67 -15
  30. package/a11y_toolkit/a11yscroll.py +7 -5
  31. package/a11y_toolkit/a11ystatement.py +30 -6
  32. package/a11y_toolkit/a11ytrace.py +293 -0
  33. package/a11y_toolkit/a11yvalidate.py +21 -15
  34. package/a11y_toolkit/a11yvpat.py +34 -7
  35. package/a11y_toolkit/a11yvtt.py +22 -6
  36. package/a11y_toolkit/a11ywiz.py +121 -0
  37. package/a11y_toolkit/contrast.py +62 -24
  38. package/a11y_toolkit/locales/en.json +177 -20
  39. package/a11y_toolkit/locales/es.json +178 -21
  40. package/a11y_toolkit/rgaa.json +2661 -0
  41. package/a11y_toolkit/server.py +149 -50
  42. package/package.json +2 -2
  43. package/a11y_toolkit/a11yplan.py +0 -214
  44. package/a11y_toolkit/a11ywcagem.py +0 -237
@@ -18,7 +18,10 @@ level the toolkit evaluates.
18
18
  The families beyond the WCAG mirror (5, 6, 7, 8, 12, 13) are real
19
19
  applicability territory — closed functionality, RTT, hardware, relay — that
20
20
  no HTML audit can answer. They appear here as honest rows for the scope
21
- engine (a11yscope), never as something this toolkit evaluates.
21
+ engine (a11yscope), never as something this toolkit evaluates. For software
22
+ targets the same honesty applies to the EN-only sub-clauses of clause 11
23
+ itself (11.5 interoperability with AT, 11.6 documented accessibility usage,
24
+ 11.7 user preferences): surfaced as human-review rows, never evaluated.
22
25
 
23
26
  No network, no third parties: this module is pure data.
24
27
  """
@@ -46,6 +49,45 @@ FAMILIES = (
46
49
  {'family': '13', 'key': 'relay_emergency'},
47
50
  )
48
51
 
52
+ # EN-only sub-clauses of clause 11 (software) beyond the WCAG mirror
53
+ # (11.1-11.4 mirror the SC by principle): 11.5-11.7. Titles are the
54
+ # standard's own clause titles (verified against the V4.1.1 table of
55
+ # contents). These are applicability rows only — the toolkit does NOT
56
+ # evaluate them and never proposes on them (unlike families 6/7/8 for web,
57
+ # the product's shape does not decide: a human answers).
58
+ SOFTWARE_CLAUSES = ('11.5', '11.6', '11.7')
59
+
60
+ # Module-level bilingual texts (the families live in locales; these clauses
61
+ # postdate them — same pattern as a11yaudit's _labels dicts)
62
+ _SOFTWARE_CLAUSE_TEXTS = {
63
+ 'en': {
64
+ '11.5': ('Interoperability with assistive technology',
65
+ 'Name, role, value and states exposed through the platform '
66
+ 'accessibility services can only be verified with the software '
67
+ 'running alongside a real assistive technology — human review.'),
68
+ '11.6': ('Documented accessibility usage',
69
+ 'The software must document its accessibility features; a '
70
+ 'documentation question no markup audit answers — human review.'),
71
+ '11.7': ('User preferences',
72
+ 'Respecting the platform user-preference settings requires the '
73
+ 'software running on each platform — human review.'),
74
+ },
75
+ 'es': {
76
+ '11.5': ('Interoperabilidad con productos de apoyo',
77
+ 'Exponer nombre, rol, valor y estados vía los servicios de '
78
+ 'accesibilidad de la plataforma solo puede verificarse con el '
79
+ 'software corriendo junto a un producto de apoyo real — '
80
+ 'revisión humana.'),
81
+ '11.6': ('Uso documentado de la accesibilidad',
82
+ 'El software debe documentar sus funciones de accesibilidad; '
83
+ 'una pregunta de documentación que ninguna auditoría de '
84
+ 'marcado responde — revisión humana.'),
85
+ '11.7': ('Preferencias del usuario',
86
+ 'Respetar las preferencias del usuario de la plataforma exige '
87
+ 'el software corriendo en cada plataforma — revisión humana.'),
88
+ },
89
+ }
90
+
49
91
 
50
92
  def clause_for(code, target='web'):
51
93
  """'1.4.3' + target → '9.1.4.3'. None si el código no es un SC válido.
@@ -83,6 +125,16 @@ def family_rows(lang='en'):
83
125
  return rows
84
126
 
85
127
 
128
+ def software_clause_rows(lang='en'):
129
+ """Filas de las cláusulas EN-only de software (11.5-11.7): número, título
130
+ bilingüe y nota honesta. Igual que family_rows: aquí solo vive el texto
131
+ — el estado (revisión humana, no evaluado por este motor) lo pone el
132
+ llamador (a11yscope, target software)."""
133
+ texts = _SOFTWARE_CLAUSE_TEXTS.get(lang) or _SOFTWARE_CLAUSE_TEXTS['en']
134
+ return [{'clause': cl, 'title': texts[cl][0], 'note': texts[cl][1]}
135
+ for cl in SOFTWARE_CLAUSES]
136
+
137
+
86
138
  def standard_block(target='web', lang='en'):
87
139
  """Bloque 'standard' para informes audit --standard en301549."""
88
140
  from .a11yi18n import pack
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env python3
2
+ """a11y_engines — cross-engine behavioral matrix (the same page, several engines).
3
+
4
+ Cross-industry translation of the cross-browser accessibility lab: teams run
5
+ static scans but cannot verify that an accessible task BEHAVES the same in
6
+ real engine configurations. This module captures the a11y snapshot
7
+ (interactives, real tab order, computed accessibility tree) of ONE URL in
8
+ SEVERAL browser engines and diffs every pair. What diverges between engines
9
+ is exactly what a single-engine audit can never see: elements that only exist
10
+ in one engine's DOM, tab order that forks, names that engines compute
11
+ differently.
12
+
13
+ Honesty (what this is and is not):
14
+ - Elements and focus order come from the DOM (spec-stable across engines):
15
+ divergence there is a REAL behavioral finding and blocks (ok=false).
16
+ - The accessibility tree is engine-computed: divergence is reported as
17
+ `tree_changed` per pair but does NOT block — different engines legitimately
18
+ compute some roles/names differently. It is the pointer for what a screen
19
+ reader on that platform would announce; judge it, don't gate on it.
20
+ - Engines must be installed locally (playwright install firefox webkit);
21
+ an engine that fails to launch is reported in engines_failed, never silently.
22
+
23
+ CLI (infrastructure, not a tool — D17, same tier as corpus/mutants):
24
+ a11yengines.py https://web # the 3 default engines
25
+ a11yengines.py https://web --engines chromium,firefox # your matrix
26
+ a11yengines.py https://web --auth-state session.json -o m.json
27
+ Exit: 0 no divergences / 2 behavioral divergences / 1 config error
28
+ (playwright missing or fewer than 2 engines launched).
29
+ """
30
+
31
+ import argparse
32
+ import itertools
33
+ import json
34
+ import sys
35
+ from datetime import datetime, timezone
36
+
37
+ from . import a11ydiff
38
+
39
+ ENGINES = ('chromium', 'firefox', 'webkit', 'chrome', 'msedge')
40
+ DEFAULT_ENGINES = ('chromium', 'firefox', 'webkit')
41
+
42
+
43
+ def _capture(url, engine, auth_state=None):
44
+ """One engine's snapshot; raises on engine failure (caller records it)."""
45
+ return a11ydiff.snapshot(url, engine=engine, auth_state=auth_state)
46
+
47
+
48
+ def _pair_entry(name_a, name_b, sa, sb):
49
+ d = a11ydiff.diff(sa, sb)
50
+ # behavioral verdict: DOM-level facts only — the tree is informational
51
+ # across engines (engines compute some roles/names differently by design)
52
+ focus = d['focus']
53
+ ok = not (d['added'] or d['removed'] or d['renamed']
54
+ or focus['removed'] or focus['reordered'])
55
+ return {
56
+ 'engines': [name_a, name_b],
57
+ 'ok': ok,
58
+ 'added': d['added'],
59
+ 'removed': d['removed'],
60
+ 'renamed': d['renamed'],
61
+ 'focus': {'removed': focus['removed'], 'added': focus['added'],
62
+ 'reordered': focus['reordered'],
63
+ 'first_divergence': focus['first_divergence']},
64
+ 'tree_changed': bool(d['tree']['changed']),
65
+ 'tree_first_differences': (d['tree']['first_differences'] or [])[:3],
66
+ }
67
+
68
+
69
+ def matrix(url, engines=None, auth_state=None, capture=None):
70
+ """One URL → per-engine snapshots → pairwise divergence report."""
71
+ engines = tuple(engines or DEFAULT_ENGINES)
72
+ capture = capture or _capture
73
+
74
+ ok, failed, snaps = [], [], {}
75
+ for name in engines:
76
+ if name not in ENGINES:
77
+ failed.append({'engine': name, 'error': f'unknown engine (known: {", ".join(ENGINES)})'})
78
+ continue
79
+ try:
80
+ snaps[name] = capture(url, name, auth_state)
81
+ s = snaps[name]
82
+ ok.append({'engine': name, 'elements': len(s.get('elements', [])),
83
+ 'focus_steps': len(s.get('focus_order', [])),
84
+ 'tree': 'accessibility_tree' in s or 'arbol_accesible' in s})
85
+ except ImportError:
86
+ # playwright ausente NO es «un motor muerto»: es un error de
87
+ # instalación que mata TODA la matriz — relanzar para que main
88
+ # aconseje `pip install playwright` (no `playwright install …`,
89
+ # el consejo equivocado cuando falta el paquete pip) y salga 1
90
+ raise
91
+ except Exception as e: # noqa: BLE001 — one dead engine must not kill the matrix
92
+ msg = str(e).splitlines()[0][:200] if str(e) else e.__class__.__name__
93
+ failed.append({'engine': name, 'error': msg})
94
+
95
+ pairs = [_pair_entry(a, b, snaps[a], snaps[b])
96
+ for a, b in itertools.combinations(sorted(snaps), 2)]
97
+ divergences = [p for p in pairs if not p['ok']]
98
+
99
+ enough = len(snaps) >= 2
100
+ report = {
101
+ 'mode': 'engines',
102
+ 'url': url,
103
+ 'ts': datetime.now(timezone.utc).isoformat(),
104
+ 'engines_ok': ok,
105
+ 'engines_failed': failed,
106
+ 'pairs': pairs,
107
+ 'divergences': divergences,
108
+ 'ok': bool(enough and not divergences),
109
+ 'insufficient_engines': not enough,
110
+ 'limits': ('elements and focus order are DOM facts: divergence blocks. '
111
+ 'The computed accessibility tree is engine-specific: '
112
+ 'tree_changed is informational, not a gate. A pass is '
113
+ 'engine-pair evidence for THIS url at THIS time — not a '
114
+ 'conformance claim.'),
115
+ }
116
+ if not enough:
117
+ report['note'] = ('fewer than 2 engines launched: install them with '
118
+ '`playwright install firefox webkit` — a matrix of one '
119
+ 'engine cannot see cross-engine behavior')
120
+ return report
121
+
122
+
123
+ def main(argv):
124
+ ap = argparse.ArgumentParser(description=__doc__)
125
+ ap.add_argument('url')
126
+ ap.add_argument('--engines', default=','.join(DEFAULT_ENGINES),
127
+ help=f'comma-separated engines (default: {",".join(DEFAULT_ENGINES)})')
128
+ ap.add_argument('--auth-state', help='Playwright storage_state JSON (session)')
129
+ ap.add_argument('-o', '--out', help='write the report here (default: stdout)')
130
+ a = ap.parse_args(argv)
131
+
132
+ engines = [e.strip() for e in a.engines.split(',') if e.strip()]
133
+ capture = _capture
134
+ try:
135
+ report = matrix(a.url, engines=engines, auth_state=a.auth_state,
136
+ capture=capture)
137
+ except ImportError:
138
+ print(json.dumps({'error': 'Playwright not installed: '
139
+ 'pip install playwright && playwright install chromium'}))
140
+ return 1
141
+ out = json.dumps(report, ensure_ascii=False, indent=1)
142
+ if a.out:
143
+ with open(a.out, 'w', encoding='utf-8') as f:
144
+ f.write(out + '\n')
145
+ report = dict(report)
146
+ report['pairs'] = [{'engines': p['engines'], 'ok': p['ok']} for p in report['pairs']]
147
+ print(json.dumps({'url': a.url, 'engines_ok': [e['engine'] for e in report['engines_ok']],
148
+ 'pairs': report['pairs'], 'out': a.out}, ensure_ascii=False))
149
+ else:
150
+ print(out)
151
+ if report.get('insufficient_engines'):
152
+ return 1
153
+ return 0 if report.get('ok') else 2
154
+
155
+
156
+ if __name__ == '__main__':
157
+ sys.exit(main(sys.argv[1:]))
@@ -29,6 +29,7 @@ import hashlib
29
29
  import json
30
30
 
31
31
  from .a11yaudit import normalize_report # noqa: E402 (compat 5.10)
32
+ from .a11ycrit import _EFFORT_MINUTES # single source: a11ycrit prices the classes
32
33
  import sys
33
34
  from datetime import datetime, timezone
34
35
 
@@ -81,6 +82,15 @@ def apply_scope(pack, scope, lang='en'):
81
82
  criteria.append(row)
82
83
  out['criteria'] = criteria
83
84
  out['summary'] = {e: sum(1 for m in criteria if m.get('status') == e) for e in _STATES}
85
+ # the scope changes what REMAINS to do: effort_pending and manual_pending
86
+ # must describe the resulting matrix (excluded = zero pending human
87
+ # effort), not the pre-scope pack — otherwise the human is overcharged
88
+ # and criteria already not-applicable keep being named as pending
89
+ out['effort_pending'] = _pending_effort(
90
+ criteria, tx.get('manual_remaining')
91
+ or a11yi18n.pack('en')['evidence']['manual_remaining'])
92
+ out['manual_pending'] = [m['criterion'] for m in criteria
93
+ if m.get('status') == 'manual-only']
84
94
  return out
85
95
 
86
96
 
@@ -88,8 +98,35 @@ def _sha256(obj):
88
98
  return hashlib.sha256(_canon(obj).encode('utf-8')).hexdigest()
89
99
 
90
100
 
101
+ def _pending_effort(matrix, note):
102
+ """Remaining human review, in minutes: MIN/MED/MAX per class summed over
103
+ every row a human still has to touch (agent-verified excluded; rows out
104
+ of applicability scope carry no effort). Shared by build_pack AND
105
+ apply_scope — the priced scope must always describe the CURRENT matrix,
106
+ never the pre-scope one."""
107
+ pend = {}
108
+ for m in matrix:
109
+ if m.get('status') == 'agent-verified':
110
+ continue
111
+ ef = m.get('effort')
112
+ if ef:
113
+ lo, hi = _EFFORT_MINUTES[ef['class']]
114
+ pend.setdefault(ef['class'], [0, 0])
115
+ pend[ef['class']][0] += lo
116
+ pend[ef['class']][1] += hi
117
+ return {
118
+ 'by_class': {k: {'criteria': sum(1 for m in matrix
119
+ if m.get('status') != 'agent-verified'
120
+ and m.get('effort', {}).get('class') == k),
121
+ 'minutes': v}
122
+ for k, v in sorted(pend.items())},
123
+ 'total_minutes': [sum(v[0] for v in pend.values()), sum(v[1] for v in pend.values())],
124
+ 'note': note,
125
+ }
126
+
127
+
91
128
  def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
92
- sr_transcript=None, lang='en', scope=None):
129
+ sr_transcript=None, lang='en', scope=None, build=None):
93
130
  """Informes (lista de dicts JSON) → paquete de evidencia verificable.
94
131
 
95
132
  verificados: lista de códigos de criterio ("1.4.1", "3.3.1"…) que un
@@ -109,12 +146,31 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
109
146
  tx = tx or a11yi18n.pack('en')['evidence']
110
147
  reports = [normalize_report(i) for i in reports] # compat 5.10: señales previas al rename
111
148
 
149
+ # site crawls (audit_site) nest the per-page reports under 'reports': a
150
+ # pack built from a crawl must flatten them BEFORE deriving (the same
151
+ # shape a11ysarif reads), or the whole crawl counts as automated-fail: 0
152
+ # while pages carry real failures. Artifacts stay one-per-INPUT report —
153
+ # the seal seals what came in, not the flattened view.
154
+ pages = []
155
+ for inf in reports:
156
+ subs = inf.get('reports')
157
+ # PREFERENCIA: si el informe tiene findings TOP-LEVEL son las COPIAS
158
+ # RE-VERIFICADAS (la salida del disprover sobre un site report las
159
+ # escribe arriba, no dentro de reports[]) — aplanarlas encima usaría
160
+ # los ejemplares MUERTOS y los hallazgos desmentidos resucitarían
161
+ if isinstance(inf.get('findings'), list) and inf['findings']:
162
+ pages.append(inf)
163
+ elif isinstance(subs, list) and subs:
164
+ pages.extend(normalize_report(s) for s in subs if isinstance(s, dict))
165
+ else:
166
+ pages.append(inf)
167
+
112
168
  # matriz de criterios: los que tocamos (estado según hallazgos) + manuales
113
169
  from .a11ycrit import _C as _CAT, effort
114
170
  codes_aa = sorted(k for k, v in _CAT.items() if v[0] in ('A', 'AA'))
115
- modes_included = {inf.get('mode', 'static') for inf in reports}
171
+ modes_included = {inf.get('mode', 'static') for inf in pages}
116
172
  touched = {}
117
- for inf in reports:
173
+ for inf in pages:
118
174
  for h in inf.get('findings', []):
119
175
  if (h.get('status') == 'rejected'
120
176
  or h.get('disprover_status') in ('rejected', 'not-rechecked')):
@@ -126,7 +182,11 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
126
182
  continue
127
183
  code = crit.split(' ')[0]
128
184
  severity = h.get('severity')
129
- state = 'automated-review' if severity == 'low' else 'automated-fail'
185
+ # severity ausente/None/abajo de high-medium: la máquina no puede
186
+ # afirmar un FALLO — el hallazgo queda como review (evidencia, no
187
+ # veredicto). Solo un fail del motor es un automated-fail.
188
+ state = ('automated-fail' if severity in ('high', 'medium')
189
+ else 'automated-review')
130
190
  # el peor estado gana: fail > review
131
191
  if touched.get(code) != 'automated-fail':
132
192
  touched[code] = state
@@ -152,14 +212,15 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
152
212
  excluded[crit.split(' ')[0]] = reason if isinstance(reason, str) else ''
153
213
  # extraer valores medidos clave de los hallazgos (ratio, ejemplos)
154
214
  values = {}
155
- for inf in reports:
215
+ for inf in pages:
156
216
  for h in inf.get('findings', []):
157
- code = (h.get('criterion') or '').split(' ')[0]
217
+ code = str(h.get('criterion') or '').split(' ')[0]
158
218
  if code not in values:
159
219
  val = {}
160
- if 'ratio' in h.get('issue', '').lower() or ':' in h.get('issue', ''):
220
+ issue_txt = h.get('issue') or '' # issue null explícito: sin crash
221
+ if 'ratio' in issue_txt.lower() or ':' in issue_txt:
161
222
  import re as _re
162
- m = _re.search(r'([\d.]+):1', h.get('issue', ''))
223
+ m = _re.search(r'([\d.]+):1', issue_txt)
163
224
  if m:
164
225
  val['measured'] = f'{m.group(1)}:1'
165
226
  _ex_list = h.get('examples', [])
@@ -173,8 +234,6 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
173
234
  # modo que la produce no se incluyó)
174
235
  from .a11ycrit import RENDERED_ONLY as _RENDERED_ONLY # canónico (a11ycrit)
175
236
 
176
- verified_set = {v.split(' ')[0] for v in (verified or [])}
177
-
178
237
  matrix = []
179
238
  _manual_codes = {m.split(' ')[0] for m in MANUAL_AA}
180
239
  for code in codes_aa:
@@ -198,7 +257,7 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
198
257
 
199
258
  # verificados: promueve not-flagged/not-run/manual-only → agent-verified
200
259
  # (pero automated-fail permanece: un fallo no se borra verificando)
201
- if code in verified_set and state != 'automated-fail':
260
+ if code in verified and state != 'automated-fail':
202
261
  state = 'agent-verified'
203
262
 
204
263
  note = None
@@ -258,27 +317,8 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
258
317
  # remaining human review, in minutes: MIN/MED/MAX per class summed over
259
318
  # every row a human still has to touch (everything except agent-verified).
260
319
  # This is the scope input for human review: agent output in,
261
- # priced human scope out.
262
- _MIN = {'MIN': (1, 3), 'MED': (5, 10), 'MAX': (15, 30)}
263
- pend = {}
264
- for m in matrix:
265
- if m['status'] == 'agent-verified':
266
- continue
267
- ef = m.get('effort')
268
- if ef:
269
- lo, hi = _MIN[ef['class']]
270
- pend.setdefault(ef['class'], [0, 0])
271
- pend[ef['class']][0] += lo
272
- pend[ef['class']][1] += hi
273
- pending_effort = {
274
- 'by_class': {k: {'criteria': sum(1 for m in matrix
275
- if m['status'] != 'agent-verified'
276
- and m.get('effort', {}).get('class') == k),
277
- 'minutes': v}
278
- for k, v in sorted(pend.items())},
279
- 'total_minutes': [sum(v[0] for v in pend.values()), sum(v[1] for v in pend.values())],
280
- 'note': tx['manual_remaining'],
281
- }
320
+ # priced human scope out. The class prices live in a11ycrit (single source).
321
+ pending_effort = _pending_effort(matrix, tx['manual_remaining'])
282
322
 
283
323
  artifacts = []
284
324
  for i, inf in enumerate(reports):
@@ -336,6 +376,7 @@ def build_pack(reports, snapshot=None, reviewer=None, notes=None, verified=None,
336
376
  'note': tx['reviewer_note'],
337
377
  },
338
378
  'notes': notes,
379
+ 'build': build, # claim→artifact chain: the build reference is SEALED into the sha
339
380
  'notice': tx['notice'],
340
381
  }
341
382
  # the seal excludes sha256 AND the clock ('generated'): re-emitting the
@@ -352,13 +393,20 @@ def main(argv):
352
393
  ap.add_argument('--scope', help='a11y_scope output JSON: confirmed exclusions '
353
394
  'become not-applicable rows (proposals never exclude)')
354
395
  ap.add_argument('--reviewer', help='JSON: {"name":…, "credential":…, "review_date":…}')
396
+ ap.add_argument('--build', help='build reference, e.g. "git:716d870" or JSON '
397
+ '{"commit":…, "ci_url":…} — sealed into the pack sha (claim→artifact chain)')
355
398
  ap.add_argument('-o', '--out', default='evidence-pack.json')
356
399
  a = ap.parse_args(argv)
357
400
  reports = [json.load(open(f, encoding='utf-8')) for f in a.reports]
358
401
  snapshot = json.load(open(a.snapshot, encoding='utf-8')) if a.snapshot else None
359
402
  scope = json.load(open(a.scope, encoding='utf-8')) if a.scope else None
360
403
  reviewer = json.loads(a.reviewer) if a.reviewer else None
361
- pack = build_pack(reports, snapshot=snapshot, reviewer=reviewer, scope=scope)
404
+ try:
405
+ build = json.loads(a.build) if a.build else None
406
+ except json.JSONDecodeError:
407
+ build = {'ref': a.build} if a.build else None
408
+ pack = build_pack(reports, snapshot=snapshot, reviewer=reviewer, scope=scope,
409
+ build=build)
362
410
  with open(a.out, 'w', encoding='utf-8') as f:
363
411
  json.dump(pack, f, ensure_ascii=False, indent=1)
364
412
  print(json.dumps({'pack': a.out, 'sha256': pack['sha256'],