Files
Codex 7c285d25b7 test: golden acceptance keeps environment witnesses (#355)
Declaring the whole matrix in --expect-change could accept a completely
foreign capture (different font stack, different machine): no undeclared
passed scenes would remain, and undeclared passed scenes are exactly what
proves the capture environment equals the accepted baseline's. The
realistic failure is fatigue, not malice — a mass framing change where the
author lists "everything that went red", accidentally sweeping in scenes
that diverged because of the environment.

Acceptance now requires a witness floor: after subtracting
--expect-change/--expect-new, at least min(10, 10% of baseline scenes)
undeclared scenes must match their accepted baselines BYTE-FOR-BYTE (a
sub-threshold 'passed' proves nothing about the environment — #351). A
truly total repaint passes only with an explicit
--no-witnesses --reason="…", and the reason is written into the baseline
manifest — a trace in the artifact and its git history, not just in the
shell history. A first-ever capture with no baselines requires no
witnesses: every frame there is declared in --expect-new anyway.

Issue: #355
User-Visible: no
2026-08-28 18:18:24 +03:00

39 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Проходной вызов `demo/golden/accept.mjs` (#334, #350, #351).
*
* node scripts/golden-accept.mjs --reviewed --expect-change=<id,id>
* node scripts/golden-accept.mjs --reviewed --expect-new=<id,id>
* node scripts/golden-accept.mjs --reviewed --expect-change=… --no-witnesses --reason="…"
*
* Floor свидетелей (#355): после вычета объявленных сцен должно остаться
* достаточно необъявленных, совпавших с эталоном байт-в-байт, — они доказывают,
* что среда съёмки та же, что у принятого эталона. Тотальная перерисовка
* обходится только явным `--no-witnesses --reason="…"`; причина уезжает в
* манифест эталонов.
*
* Обёртка появилась потому, что до #344 любой `.mjs` из `demo/golden` входил в
* корпус отпечатка, и правка инструмента приёмки объявляла устаревшими бандл и
* оба манифеста. После #344 это ограничение снято, правило живёт в самом
* `accept.mjs`, а этот файл остался ради документированной команды и передаёт
* аргументы как есть.
*
* Два флага утверждают разное: `--expect-change` — «я знаю, почему старый кадр
* изменился», `--expect-new` — «я посмотрел на новый кадр». Необъявленная сцена
* не переписывается вовсе: её эталон и хеш остаются прежними (#351).
*/
import { spawnSync } from 'node:child_process';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const argv = process.argv.slice(2);
if (!argv.includes('--reviewed')) {
console.error('приёмка требует явного --reviewed');
process.exit(2);
}
const accept = spawnSync(process.execPath, [
resolve(ROOT, 'demo/golden/accept.mjs'), ...argv,
], { cwd: ROOT, stdio: 'inherit' });
process.exit(accept.status ?? 1);