@kinti/a11y-toolkit 5.26.0 → 5.28.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 (45) hide show
  1. package/README.md +1 -1
  2. package/a11y_toolkit/a11y.py +30 -4
  3. package/a11y_toolkit/a11yact.py +9 -1
  4. package/a11y_toolkit/a11yannotate.py +185 -0
  5. package/a11y_toolkit/a11yaudit.py +924 -196
  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 +114 -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 +567 -97
  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/a11ygate.py +225 -0
  19. package/a11y_toolkit/a11yinit.py +73 -7
  20. package/a11y_toolkit/a11yjourney.py +110 -4
  21. package/a11y_toolkit/a11yledger.py +119 -12
  22. package/a11y_toolkit/a11ylocate.py +247 -0
  23. package/a11y_toolkit/a11yopenacr.py +10 -3
  24. package/a11y_toolkit/a11ypatches.py +154 -0
  25. package/a11y_toolkit/a11ypatterns.py +344 -0
  26. package/a11y_toolkit/a11ypdf.py +109 -53
  27. package/a11y_toolkit/a11yrgaa.py +60 -0
  28. package/a11y_toolkit/a11yroute.py +34 -12
  29. package/a11y_toolkit/a11ysarif.py +45 -18
  30. package/a11y_toolkit/a11yscope.py +67 -15
  31. package/a11y_toolkit/a11yscroll.py +7 -5
  32. package/a11y_toolkit/a11ystatement.py +30 -6
  33. package/a11y_toolkit/a11ytrace.py +293 -0
  34. package/a11y_toolkit/a11yvalidate.py +21 -15
  35. package/a11y_toolkit/a11yvpat.py +34 -7
  36. package/a11y_toolkit/a11yvtt.py +22 -6
  37. package/a11y_toolkit/a11ywiz.py +121 -0
  38. package/a11y_toolkit/contrast.py +62 -24
  39. package/a11y_toolkit/locales/en.json +185 -20
  40. package/a11y_toolkit/locales/es.json +186 -21
  41. package/a11y_toolkit/rgaa.json +2661 -0
  42. package/a11y_toolkit/server.py +157 -54
  43. package/package.json +2 -2
  44. package/a11y_toolkit/a11yplan.py +0 -214
  45. package/a11y_toolkit/a11ywcagem.py +0 -237
@@ -21,14 +21,16 @@ from . import a11yi18n
21
21
 
22
22
  _TEXTS = a11yi18n.pair('badge') # locales/<lang>.json — community-editable
23
23
 
24
- _COLORS = [(90, '#2da44e'), (75, '#8bdb5e'), (50, '#d29922'), (0, '#cf222e')]
24
+ # paleta por defecto: TODOS los fondos pasan 4.5:1 con el texto blanco del
25
+ # badge (verificado con el propio motor) — una herramienta de accesibilidad
26
+ # no puede exhibir texto de bajo contraste (revisión externa 2026-11)
27
+ _COLORS = [(90, '#1a7f37'), (75, '#4d6b0f'), (50, '#9a6700'), (0, '#cf222e')]
25
28
 
26
29
 
27
- def _color(score):
28
- for threshold, c in _COLORS:
29
- if score >= threshold:
30
- return c
31
- return _COLORS[-1][1]
30
+ def _esc(value):
31
+ """XML escape INCLUDING double quotes: the title lands in an attribute
32
+ (aria-label), where a raw quote breaks out of the SVG."""
33
+ return _xesc(value, {'"': '&quot;'})
32
34
 
33
35
 
34
36
  def badge(score, date=None, scope=None, lang='en', brand=None, palette=None, height=None):
@@ -41,7 +43,7 @@ def badge(score, date=None, scope=None, lang='en', brand=None, palette=None, hei
41
43
  score = max(0, min(100, int(round(score))))
42
44
  t = dict(_TEXTS.get(lang, _TEXTS['en']))
43
45
  if brand:
44
- t['name'] = brand[:24]
46
+ t['name'] = str(brand)[:24]
45
47
  colors = palette or _COLORS
46
48
 
47
49
  def _color(s):
@@ -50,17 +52,22 @@ def badge(score, date=None, scope=None, lang='en', brand=None, palette=None, hei
50
52
  return c
51
53
  return colors[-1][1]
52
54
 
53
- date = date or datetime.date.today().isoformat()
54
- scope = scope or t['scope']
55
- date = _xesc(date)[:30]
56
- scope = _xesc(scope)[:60]
57
- title = _xesc(t['title'].format(score=score, date=date, scope=scope))
55
+ # truncate FIRST, escape ONCE, per field: truncating escaped text can cut
56
+ # an entity in half (&amp; → &amp), and re-escaping pre-escaped values
57
+ # double-escapes (& → &amp;amp;). Metrics (width) use the raw truncated
58
+ # strings; the SVG gets the escaped ones.
59
+ raw_date = str(date or datetime.date.today().isoformat())[:30]
60
+ raw_scope = str(scope or t['scope'])[:60]
61
+ date_e = _esc(raw_date)
62
+ scope_e = _esc(raw_scope)
63
+ name_e = _esc(t['name']) # brand incluido: nada crudo entra al SVG
64
+ title = _esc(t['title']).format(score=score, date=date_e, scope=scope_e)
58
65
  color = _color(score)
59
66
  h = height or 20
60
67
  font = 11 if h == 20 else round(h * 0.58)
61
68
  y = h / 2 + font * 0.35
62
69
  left = len(t['name']) * (font * 0.60) + 14
63
- right = len(f'{score}/100 · {date}') * (font * 0.60) + 14
70
+ right = len(f'{score}/100 · {raw_date}') * (font * 0.60) + 14
64
71
  width = left + right
65
72
  return f'''<svg xmlns="http://www.w3.org/2000/svg" width="{width:.0f}" height="{h}" role="img" aria-label="{title}">
66
73
  <title>{title}</title>
@@ -72,10 +79,10 @@ def badge(score, date=None, scope=None, lang='en', brand=None, palette=None, hei
72
79
  <rect width="{width:.0f}" height="{h}" fill="url(#s)"/>
73
80
  </g>
74
81
  <g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" font-size="{font}">
75
- <text x="{left / 2:.0f}" y="{y + 1:.1f}" fill="#010409" fill-opacity=".3">{t['name']}</text>
76
- <text x="{left / 2:.0f}" y="{y:.1f}">{t['name']}</text>
77
- <text x="{left + right / 2:.0f}" y="{y + 1:.1f}" fill="#010409" fill-opacity=".3">{score}/100 · {date}</text>
78
- <text x="{left + right / 2:.0f}" y="{y:.1f}">{score}/100 · {date}</text>
82
+ <text x="{left / 2:.0f}" y="{y + 1:.1f}" fill="#010409" fill-opacity=".3">{name_e}</text>
83
+ <text x="{left / 2:.0f}" y="{y:.1f}">{name_e}</text>
84
+ <text x="{left + right / 2:.0f}" y="{y + 1:.1f}" fill="#010409" fill-opacity=".3">{score}/100 · {date_e}</text>
85
+ <text x="{left + right / 2:.0f}" y="{y:.1f}">{score}/100 · {date_e}</text>
79
86
  </g>
80
87
  </svg>'''
81
88
 
@@ -21,6 +21,21 @@ Compare with: a11ytoolkit budget --budget budget.json --audit audit.js
21
21
  Exit code: 0 ok / 2 blocked.
22
22
 
23
23
  Only stable keys ('signal') and severities are compared, never prose.
24
+
25
+ Structural budget (the same SRE doctrine applied to the RENDERED structure —
26
+ what a11y snapshot captures):
27
+
28
+ Baseline today: a11ytoolkit snapshot https://web --out s.json
29
+ a11ytoolkit budget --init-snapshot s.json > structural.json
30
+ Compare: a11ytoolkit budget --budget structural.json --snapshot s2.json
31
+ Exit code: 0 ok / 2 blocked.
32
+
33
+ The baseline ACCEPTS the interactives and focus order that exist today; only
34
+ what is NEW blocks (added elements count against max_new; a lost element
35
+ contradicts the approved baseline and blocks; a reordered focus chain blocks).
36
+ Renames surface as removed+added (elements without ids are matched by
37
+ tag+name+href). Noise doctrine from fingerprints: give controls stable ids
38
+ and the budget stops counting cosmetic churn as structure.
24
39
  """
25
40
 
26
41
  import argparse
@@ -30,6 +45,20 @@ import json
30
45
  from .a11yaudit import normalize_signal # noqa: E402 (compat 5.10)
31
46
  import sys
32
47
 
48
+ # mensajes CLI bilingües (patrón _labels): el stdin de --init espera el JSON
49
+ # del informe de auditoría — un input vacío/corrupto debe decir QUÉ espera,
50
+ # no tronar con un traceback
51
+ _CLI_MSG = {
52
+ 'es': {'stdin_json': ('stdin no contiene un JSON de informe válido — '
53
+ 'esperado: la salida de `a11ytoolkit audit` '
54
+ '(p. ej. {"url": …, "score": …, "findings": […]}) '
55
+ 'por tubería, o usa --audit fichero.json')},
56
+ 'en': {'stdin_json': ('stdin is not a valid audit-report JSON — expected: '
57
+ 'the output of `a11ytoolkit audit` (e.g. {"url": …, '
58
+ '"score": …, "findings": […]}), or pass '
59
+ '--audit report.json instead')},
60
+ }
61
+
33
62
 
34
63
  def init(audit):
35
64
  """Informe (o site) → fichero de presupuesto inicial."""
@@ -82,18 +111,120 @@ def compare(budget, audit, today=None):
82
111
  }
83
112
 
84
113
 
114
+ STRUCTURAL_FORMAT = 'a11y-budget-structural/1'
115
+
116
+
117
+ def init_structural(snapshot, days=90):
118
+ """Snapshot (a11y snapshot) → structural budget: the structure of TODAY is
119
+ accepted. Keys are the snapshot's stable signatures (tag+name+href, or
120
+ #id when the control has one)."""
121
+ if not isinstance(snapshot, dict) or not isinstance(snapshot.get('elements'), list):
122
+ return {'error': 'not a snapshot (use a11ytoolkit snapshot / a11y_snapshot)'}
123
+ return {
124
+ 'format': STRUCTURAL_FORMAT,
125
+ 'url': snapshot.get('url', ''),
126
+ 'elements': sorted({e['key'] for e in snapshot['elements']
127
+ if isinstance(e, dict) and e.get('key')}),
128
+ 'focus_order': list(snapshot.get('focus_order', [])),
129
+ 'max_new': 0,
130
+ 'removed_block': True,
131
+ 'review_date': (datetime.date.today() + datetime.timedelta(days=days)).isoformat(),
132
+ 'generated': datetime.datetime.now(datetime.timezone.utc).isoformat(),
133
+ }
134
+
135
+
136
+ def compare_structural(budget, snapshot, today=None):
137
+ """Structural budget vs today's snapshot → verdict. Only what is NEW
138
+ blocks: added elements (up to max_new), lost baseline elements (they
139
+ contradict the approved baseline), reordered focus chain, expired baseline."""
140
+ if not isinstance(budget, dict) or budget.get('format') != STRUCTURAL_FORMAT:
141
+ return {'error': f'not a structural budget (format {STRUCTURAL_FORMAT})'}
142
+ if not isinstance(snapshot, dict) or not isinstance(snapshot.get('elements'), list):
143
+ return {'error': 'not a snapshot (use a11ytoolkit snapshot / a11y_snapshot)'}
144
+
145
+ base = set(budget.get('elements', []))
146
+ current = {e['key'] for e in snapshot['elements'] if isinstance(e, dict) and e.get('key')}
147
+ added = sorted(current - base)
148
+ removed = sorted(base - current)
149
+ removed_block = bool(budget.get('removed_block', True))
150
+ max_new = int(budget.get('max_new', 0))
151
+
152
+ # focus chain: the RELATIVE order of the surviving common keys is the
153
+ # invariant (same doctrine as the diff) — an appended new element is
154
+ # governed by `added`/max_new, a reorder of the existing chain blocks
155
+ focus_pinned = 'focus_order' in budget and budget['focus_order'] is not None
156
+ focus_changed = False
157
+ if focus_pinned:
158
+ base_order = budget['focus_order']
159
+ cur_order = snapshot.get('focus_order', [])
160
+ base_set, cur_set = set(base_order), set(cur_order)
161
+ focus_changed = [k for k in cur_order if k in base_set] != \
162
+ [k for k in base_order if k in cur_set]
163
+
164
+ ok = (len(added) <= max_new
165
+ and (not removed_block or not removed)
166
+ and not focus_changed)
167
+ expired = False
168
+ date = budget.get('review_date')
169
+ if date:
170
+ expired = (today or datetime.date.today().isoformat()) > date
171
+
172
+ return {
173
+ 'ok': ok and not expired,
174
+ 'url': snapshot.get('url', budget.get('url', '')),
175
+ 'added': added,
176
+ 'removed': removed,
177
+ 'focus_order_changed': focus_changed,
178
+ 'focus_pinned': focus_pinned,
179
+ 'summary': {
180
+ 'baseline': len(base),
181
+ 'current': len(current),
182
+ 'added': len(added),
183
+ 'removed': len(removed),
184
+ },
185
+ 'baseline_expired': expired,
186
+ 'note': ('ok=false: structure changed against the accepted baseline '
187
+ '(new interactives beyond max_new, a baseline element '
188
+ 'disappeared, or the focus chain reordered — or the baseline '
189
+ 'expired). ok=true: the rendered structure is the approved one; '
190
+ 'to accept a deliberate change, re-run --init-snapshot.'),
191
+ }
192
+
193
+
85
194
  def main(argv):
86
195
  ap = argparse.ArgumentParser(description=__doc__)
87
196
  ap.add_argument('--init', action='store_true',
88
197
  help='genera el presupuesto desde un informe (stdin o --audit)')
198
+ ap.add_argument('--init-snapshot', dest='init_snapshot',
199
+ help='structural budget: baseline from a snapshot JSON (stdin if omitted)')
89
200
  ap.add_argument('--budget', default='budget.json', help='fichero de presupuesto')
90
201
  ap.add_argument('--audit', help='informe JSON del auditor')
202
+ ap.add_argument('--snapshot', help='structural compare: today\'s snapshot JSON')
91
203
  ap.add_argument('--url', help='auditar esta URL al vuelo')
92
204
  a = ap.parse_args(argv)
205
+ if a.init_snapshot:
206
+ if a.init_snapshot == '-':
207
+ snap = json.loads(sys.stdin.read())
208
+ else:
209
+ with open(a.init_snapshot, encoding='utf-8') as f:
210
+ snap = json.load(f)
211
+ b = init_structural(snap)
212
+ if 'error' in b:
213
+ print(json.dumps(b, ensure_ascii=False))
214
+ return 1
215
+ print(json.dumps(b, ensure_ascii=False, indent=1))
216
+ return 0
93
217
  if a.init:
94
218
  inform = None
95
219
  if not sys.stdin.isatty():
96
- inform = json.loads(sys.stdin.read())
220
+ try:
221
+ inform = json.loads(sys.stdin.read())
222
+ except json.JSONDecodeError:
223
+ # stdin vacío/corrupto (no-tty): decir qué se espera, no un
224
+ # traceback — el JSON del informe, con la forma de arriba
225
+ print(json.dumps({'error': _CLI_MSG['en']['stdin_json']},
226
+ ensure_ascii=False))
227
+ return 1
97
228
  elif a.audit:
98
229
  with open(a.audit, encoding='utf-8') as f:
99
230
  inform = json.load(f)
@@ -102,6 +233,19 @@ def main(argv):
102
233
  return 1
103
234
  print(json.dumps(init(inform), ensure_ascii=False, indent=1))
104
235
  return 0
236
+ if a.snapshot:
237
+ with open(a.budget, encoding='utf-8') as f:
238
+ budget = json.load(f)
239
+ with open(a.snapshot, encoding='utf-8') as f:
240
+ snap = json.load(f)
241
+ verdict = compare_structural(budget, snap)
242
+ if 'error' in verdict:
243
+ # presupuesto no-estructural / snapshot malformado: error de USO
244
+ # limpio (exit 1), no un KeyError 'ok' con traceback
245
+ print(json.dumps(verdict, ensure_ascii=False, indent=1))
246
+ return 1
247
+ print(json.dumps(verdict, ensure_ascii=False, indent=1))
248
+ return 0 if verdict['ok'] else 2
105
249
  if not (a.audit or a.url):
106
250
  print('need --audit report.json or --url https://…')
107
251
  return 1
@@ -24,7 +24,7 @@ placebos, per-criterion confusion. `corpus reference` re-runs this engine
24
24
  over the frozen pages and ships the baseline with it.
25
25
 
26
26
  CLI (this is infrastructure, not a tool — D17):
27
- a11ycorpus.py build [--version 2026.10.0] [--seed 7] [--n 18] [--out corpus]
27
+ a11ycorpus.py build [--version 2026.11.0] [--seed 7] [--n 18] [--out corpus]
28
28
  a11ycorpus.py verify [dir]
29
29
  a11ycorpus.py evaluate --submission sub.jsonl [dir]
30
30
  a11ycorpus.py reference [dir]
@@ -61,15 +61,16 @@ on that page (criterion codes, e.g. "1.4.4" — not tool-specific rule ids).
61
61
  Placebo entries accept the same shape; anything you flag on them counts as a
62
62
  false positive by construction (no violation was injected).
63
63
 
64
- Score it:
64
+ Score it (from inside this directory):
65
65
 
66
- a11ytoolkit corpus evaluate --submission my-submission.jsonl {rel}
66
+ a11ytoolkit corpus evaluate --submission my-submission.jsonl .
67
67
 
68
68
  ## Verify this corpus (no toolkit needed)
69
69
 
70
- Every file hash and the manifest seal are plain sha256:
70
+ Every file hash and the manifest seal are plain sha256 — from inside this
71
+ directory:
71
72
 
72
- cd {rel} && shasum -a 256 -c <(python3 -c \\
73
+ shasum -a 256 -c <(python3 -c \\
73
74
  "import json;m=json.load(open('MANIFEST.json'));[print(v+' '+k) for k,v in m['files'].items()]")
74
75
 
75
76
  The seal `MANIFEST.json.sha256` covers the canonical manifest without the
@@ -106,7 +107,7 @@ def _side_features(html_text):
106
107
  }
107
108
 
108
109
 
109
- def build(version='2026.10.0', seeds=(7,), n_per_seed=18, out='corpus',
110
+ def build(version='2026.11.0', seeds=(7,), n_per_seed=18, out='corpus',
110
111
  date=None, with_reference=True):
111
112
  """Congela un examen del banco de mutantes como corpus versionado.
112
113
  Determinista dadas (version, seeds, n, date) y la versión del motor (el
@@ -174,7 +175,17 @@ def build(version='2026.10.0', seeds=(7,), n_per_seed=18, out='corpus',
174
175
  encoding='utf-8') as f:
175
176
  f.write(ref_text)
176
177
  manifest['files']['results/reference.json'] = _sha(ref_text.encode('utf-8'))
177
- for rel in sorted(set(['cases.jsonl', 'CHANGELOG.md']
178
+ # el README es el CONTRATO de sumisión: se escribe ANTES del manifiesto y
179
+ # entra en la tabla sellada — un README fuera del sello es un contrato
180
+ # manipulable con verify() en verde (revisión 11-2026). El texto es
181
+ # INDEPENDIENTE de la ubicación (rutas relativas al propio corpus): el
182
+ # sello de un mismo insumo no puede depender de dónde se construyó
183
+ readme = _NOTE_README.format(version=version, n_total=len(entries),
184
+ n_mutants=n_mut, n_control=n_pla,
185
+ fmt=CORPUS_FORMAT)
186
+ with open(os.path.join(out, 'README.md'), 'w', encoding='utf-8') as f:
187
+ f.write(readme)
188
+ for rel in sorted(set(['cases.jsonl', 'CHANGELOG.md', 'README.md']
178
189
  + ['pages/%s.html' % c['case_id'] for c in entries])):
179
190
  with open(os.path.join(out, rel), 'rb') as f:
180
191
  manifest['files'][rel] = _sha(f.read())
@@ -182,11 +193,6 @@ def build(version='2026.10.0', seeds=(7,), n_per_seed=18, out='corpus',
182
193
  if k != 'sha256'}).encode('utf-8'))
183
194
  with open(os.path.join(out, 'MANIFEST.json'), 'w', encoding='utf-8') as f:
184
195
  json.dump(manifest, f, ensure_ascii=False, indent=1, sort_keys=True)
185
- readme = _NOTE_README.format(version=version, n_total=len(entries),
186
- n_mutants=n_mut, n_control=n_pla,
187
- fmt=CORPUS_FORMAT, rel=out.rstrip('/') or '.')
188
- with open(os.path.join(out, 'README.md'), 'w', encoding='utf-8') as f:
189
- f.write(readme)
190
196
  return manifest
191
197
 
192
198
 
@@ -218,6 +224,15 @@ def verify(directory='corpus'):
218
224
  with open(path, 'rb') as f:
219
225
  if _sha(f.read()) != expected:
220
226
  return False, 'hash mismatch: %s' % rel
227
+ # el contrato de sumisión (README.md) DEBE estar sellado: presente en
228
+ # disco pero ausente de la tabla = manifiesto legado cuyo sello no cubre
229
+ # el contrato — verify falla con la razón (reconstruir para sellarlo)
230
+ if 'README.md' not in table:
231
+ if os.path.exists(os.path.join(directory, 'README.md')):
232
+ return False, ('README.md present but NOT sealed in the manifest '
233
+ '(legacy manifest): the submission contract is '
234
+ 'unverified — rebuild the corpus version to seal it')
235
+ return True, '%d files + seal verified (legacy manifest: no README.md)' % len(table)
221
236
  return True, '%d files + seal verified' % len(table)
222
237
 
223
238
 
@@ -325,29 +340,43 @@ def reference(directory='corpus'):
325
340
 
326
341
 
327
342
  def _read_submission(path):
328
- """JSONL (un objeto por línea) o UN array JSON completo: el contrato es
329
- neutral y terceros mandan ambos; el lector acepta los dos."""
343
+ """JSONL (un objeto por línea) o UN array JSON completo → (entries,
344
+ invalid). El contrato es neutral y terceros mandan ambos formatos; una
345
+ línea corrupta NO tumba el grading (debe ser robusto a input hostil):
346
+ se cuenta en invalid ({count, example} de la primera) y se sigue con
347
+ las válidas."""
330
348
  with open(path, encoding='utf-8') as f:
331
349
  text = f.read().strip()
332
350
  if not text:
333
- return []
351
+ return [], None
334
352
  if text.startswith('['):
335
- return [e for e in json.loads(text) if isinstance(e, dict)]
336
- out = []
337
- for line in text.splitlines():
353
+ try:
354
+ return [e for e in json.loads(text) if isinstance(e, dict)], None
355
+ except json.JSONDecodeError as e:
356
+ return [], {'count': 1,
357
+ 'example': 'json array: %s' % str(e)[:120]}
358
+ out, invalid = [], None
359
+ for n, line in enumerate(text.splitlines(), 1):
338
360
  line = line.strip()
339
- if line:
361
+ if not line:
362
+ continue
363
+ try:
340
364
  obj = json.loads(line)
341
- if isinstance(obj, dict):
342
- out.append(obj)
343
- return out
365
+ except json.JSONDecodeError as e:
366
+ if invalid is None:
367
+ invalid = {'count': 0, 'example': 'line %d: %s' % (n, str(e)[:120])}
368
+ invalid['count'] += 1
369
+ continue
370
+ if isinstance(obj, dict):
371
+ out.append(obj)
372
+ return out, invalid
344
373
 
345
374
 
346
375
  def main(argv):
347
376
  ap = argparse.ArgumentParser(description='Versioned audit corpus (VK-LSVD translation)')
348
377
  sub = ap.add_subparsers(dest='action', required=True)
349
378
  b = sub.add_parser('build', help='freeze a corpus version from the mutant bank')
350
- b.add_argument('--version', default='2026.10.0')
379
+ b.add_argument('--version', default='2026.11.0')
351
380
  b.add_argument('--seed', type=int, action='append', default=None)
352
381
  b.add_argument('--n', type=int, default=18)
353
382
  b.add_argument('--out', default='corpus')
@@ -376,8 +405,13 @@ def main(argv):
376
405
  print(json.dumps({'ok': ok, 'detail': detail}, ensure_ascii=False))
377
406
  return 0 if ok else 1
378
407
  if a.action == 'evaluate':
379
- res = evaluate(_read_submission(a.submission), a.directory,
408
+ entries, invalid = _read_submission(a.submission)
409
+ res = evaluate(entries, a.directory,
380
410
  submission_name=os.path.basename(a.submission))
411
+ if invalid:
412
+ # el grading sigue con las líneas válidas, pero las corruptas se
413
+ # declaran — jamás un veredicto mudo sobre input roto
414
+ res['invalid_lines'] = invalid
381
415
  print(json.dumps(res, ensure_ascii=False, indent=1))
382
416
  return 0
383
417
  if a.action == 'reference':