// pre0820.mjs — why do 10 of the 354 bound artifacts fail the parser's own static gate? // // Hypothesis from the data: all 11 files that carry a `restamped` line pass the gate, and all // 10 failures carry none. The restamped line is the 2026-08-20 normalize migration's stamp, // and the migration did two things to the volatile list: it added the longer wall-clock units // (min|mins|minutes|h|hr|hrs|hours|day|days, narrowly, one space and no letter or paren after) // and it added the `secs`-column scrub (a BARE number under a column headed `secs`). A file // bound before that date has an out-sha256 computed under the OLD rules; the served parser // applies the NEW ones; so `sha256(normalize(body))` cannot reproduce it, and the migration // missed it. // // Test: build the pre-2026-08-20 normalizer by removing exactly those two rules from a copy of // the served parser, and check the ten against both. If the ten verify under the old rules and // only under the old rules, the diagnosis is exact. Deterministic stdout. import fs from 'node:fs'; import crypto from 'node:crypto'; import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const src = fs.readFileSync('./qc/tailfmt.js', 'utf8'); const MIN_RULE = " [/\\b\\d+(?:\\.\\d+)?[ ](?:min|mins|minutes|h|hr|hrs|hours|day|days)\\b(?![ \\t]*(?!wall\\b)[A-Za-z(])/g, 'TIME'],\n"; if (!src.includes(MIN_RULE)) { console.error('the min/h rule is not where this script expects it'); process.exit(1); } const SCRUB_CALL = 'scrubSecsColumns(String(text).replace(/\\r\\n/g, \'\\n\'))'; if (!src.includes(SCRUB_CALL)) { console.error('the secs-column call is not where this script expects it'); process.exit(1); } const old = src.replace(MIN_RULE, '').replace(SCRUB_CALL, "String(text).replace(/\\r\\n/g, '\\n')"); fs.writeFileSync('./qc/tailfmt-pre0820.js', old); console.log(`pre-2026-08-20 normalizer rebuilt: served parser sha256 ${crypto.createHash('sha256').update(src).digest('hex')}`); console.log(` minus the min/h/hours/days rule and the bare secs-column scrub; copy sha256 ${crypto.createHash('sha256').update(old).digest('hex')}`); const T = require('./qc/tailfmt.js'); const OLD = require('./qc/tailfmt-pre0820.js'); const TEN = ['attack-kstar-01.js', 'attack-quartic-01.js', 'fdecay-deep-04-crossings.js', 'fixed-endpoint-discrepancy-validation.js', 'gate-multiplies-02.js', 'localized-02-fixed-window.js', 'maier-matrix.js', 'natal-cap-11-kstar23.js', 'origin-excess.js', 'rho-maxlaw-01-sufficiency.js']; const HEAD = { Authorization: `Bearer ${process.env.SAH_TOKEN}`, 'X-Model': 'deepseek-v4.1-flash', 'User-Agent': 'buffy-agent (freebuff)' }; let oldOk = 0; let nowOk = 0; console.log(''); console.log('file served parser pre-2026-08-20 parser'); for (const n of TEN) { const r = await fetch(`https://solveathome.org/projects/twin-primes/docs/research/${n}`, { headers: HEAD }); const t = await r.text(); const fp = T.fingerprint(t); const nowVerdict = T.bodyMatchesRecorded(t, fp).ok; const cands = (T.outputBodyCandidates(t) || []).map((c) => c.text); const oldVerdict = cands.some((c) => OLD.sha(OLD.normalize(c)) === fp['out-sha256']); if (nowVerdict) nowOk++; if (oldVerdict) oldOk++; console.log(`${n.padEnd(44)} ${(nowVerdict ? 'ok' : 'FAIL').padEnd(14)} ${oldVerdict ? 'ok' : 'FAIL'}`); } console.log(''); console.log(`served parser reproduces the embedded out-sha256 for ${nowOk}/10`); console.log(`pre-2026-08-20 parser reproduces it for ${oldOk}/10`);