Current section
Files
Jump to
Current section
Files
priv/harness/ci-assert.mjs
// CI fuse assertion. Reads harness/results.json and enforces the FROZEN
// classification: green machines must be green on all engines; red fixtures must be
// red. Exits non-zero on any violation. Amber/unknown are reported, never gating.
// Usage: node ci-assert.mjs [path-to-results.json]
import { readFileSync } from 'node:fs';
const path = process.argv[2] || 'results.json';
const r = JSON.parse(readFileSync(path));
const engines = Object.keys(r.engines);
const NONDESTRUCTIVE = ['siblingPatch', 'contentPatch', 'attributePatch', 'reorderNearby', 'streamNearby', 'pushPatch', 'reconnect'];
const survived = (m, after) => {
if (!after) return false;
switch (m) {
case 'pop': return after.open === true;
case 'dlg': case 'det': return after.open === true;
case 'sel': return after.value === 'b';
case 'inp': return after.value === 'typed-value' && after.focused === true;
case 'scr': return after.scrollTop === 500;
}
};
// FROZEN expectations (see DELEGATION_LEDGER.md / RED_FIXTURES.md).
const GREEN = ['pop', 'sel', 'inp', 'scr']; // must survive all non-destructive patches, all engines
const RED = ['dlg', 'det']; // must fail all non-destructive patches (expected failure)
const violations = [];
const note = [];
for (const m of GREEN) {
for (const e of engines) {
const patches = r.engines[e].runs[0][m].patches;
for (const p of NONDESTRUCTIVE) {
if (!survived(m, patches[p].after)) violations.push(`GREEN REGRESSION: ${m}.${p} on ${e} — delegated state did not survive`);
}
}
}
for (const m of RED) {
for (const e of engines) {
const patches = r.engines[e].runs[0][m].patches;
const anySurvived = NONDESTRUCTIVE.some((p) => survived(m, patches[p].after));
if (anySurvived) violations.push(`RED FIXTURE TURNED GREEN: ${m} on ${e} — expected failure no longer fails; reconcile ledger & kernel`);
}
}
// determinism: both runs identical per engine
for (const e of engines) {
if (JSON.stringify(r.engines[e].runs[0]) !== JSON.stringify(r.engines[e].runs[1])) violations.push(`NON-DETERMINISTIC: ${e} run1 != run2`);
}
note.push(`versions: ${JSON.stringify(r.versions)}`);
note.push(`engines: ${engines.map((e) => e + ' ' + r.engines[e].version).join(', ')}`);
note.push(`amber/unknown (reported, non-gating): select-popup, IME`);
console.log(note.join('\n'));
if (violations.length) {
console.error('\nFUSE TRIPPED:\n' + violations.map((v) => ' ✗ ' + v).join('\n'));
process.exit(1);
}
console.log('\n✓ conformance fuse OK — green machines green, red fixtures red, deterministic');