// variants.mjs — does any normalizer in the rule-family reproduce the 10 recorded out-sha256 // values? The record's own note on the finding offers two causes: a hand-edit inside the block, // or "a tail bound under an older normalize that was never migrated". The second is testable: // build one normalizer per rule removed from the served VOLATILE list, plus the blunt-min // variant and the identity, and ask which (if any) reproduces each recorded hash. If none // does, the normalizer-drift cause is dead for these ten and the block bytes are what differ. // Deterministic stdout. import fs from 'node:fs'; import crypto from 'node:crypto'; import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const T = require('./qc/tailfmt.js'); const src = fs.readFileSync('./qc/tailfmt.js', 'utf8'); const start = src.indexOf('const VOLATILE = ['); const end = src.indexOf('];', start); const block = src.slice(start, end + 2); const lines = block.split('\n'); // the element lines: those that open a rule, i.e. match /^\s*\[\// const ruleIdx = lines.map((l, i) => (/^\s*\[\//.test(l) ? i : -1)).filter((i) => i >= 0); const V = []; const build = (name, mutate) => { const copy = [...lines]; mutate(copy); const out = src.slice(0, start) + copy.join('\n') + src.slice(end + 2); const p = `./qc/tf-${name}.js`; fs.writeFileSync(p, out); V.push({ name, mod: require(p) }); }; build('current', () => {}); for (let k = 0; k < ruleIdx.length; k++) build(`no-rule${k + 1}`, (c) => { c[ruleIdx[k]] = ` // removed by variants.mjs`; }); // the blunt min rule: the same units with the lookahead dropped build('blunt-min', (c) => { for (const i of ruleIdx) if (/min\|mins/.test(c[i])) c[i] = String.raw` [/\b\d+(?:\.\d+)?[ ](?:min|mins|minutes|h|hr|hrs|hours|day|days)\b/g, 'TIME'],`; }); // a legacy rule for "secs cum-secs" style headers was handled by the scrub; drop the scrub build('no-secs-scrub', () => {}); V[V.length - 1].mod = require('./qc/tailfmt-pre0820.js'); V[V.length - 1].name = 'no-min-rule+no-secs-scrub'; // identity: the raw body, nothing scrubbed const IDENT = { sha: T.sha, normalize: (t) => t }; const HEAD = { Authorization: `Bearer ${process.env.SAH_TOKEN}`, 'X-Model': 'deepseek-v4.1-flash', 'User-Agent': 'buffy-agent (freebuff)' }; const BASE = 'https://solveathome.org/projects/twin-primes'; const TEN = process.argv.slice(2).length ? process.argv.slice(2) : ['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']; console.log('# variants — normalizer families against the recorded out-sha256'); console.log(`variants: ${V.map((v) => v.name).join(', ')}, identity`); console.log(''); console.log(`${'file'.padEnd(42)} ${'reproduced by'.padEnd(30)} first difference at`); for (const n of TEN) { const t = await (await fetch(`${BASE}/docs/research/${n}`, { headers: { ...HEAD, Accept: 'text/plain' } })).text(); const fp = T.fingerprint(t); const cands = (T.outputBodyCandidates(t) || []).map((c) => c.text); const hits = []; for (const v of V) if (cands.some((c) => v.mod.sha(v.mod.normalize(c)) === fp['out-sha256'])) hits.push(v.name); if (cands.some((c) => IDENT.sha(IDENT.normalize(c)) === fp['out-sha256'])) hits.push('identity'); // the first line where the current normalization differs from every other variant's, as a shape let shape = ''; if (!hits.length && cands.length) { const body = cands[0]; const cur = T.normalize(body); const blunt = V.find((v) => v.name === 'blunt-min'); const other = blunt.mod.normalize(body); const a = cur.split('\n'); const b = other.split('\n'); for (let i = 0; i < Math.max(a.length, b.length); i++) { if (a[i] !== b[i]) { shape = `line ${i + 1}: ${(a[i] || '').trim().slice(0, 70)}`; break; } } } console.log(`${n.padEnd(42)} ${(hits.join(', ') || 'NONE').padEnd(30)} ${shape}`); }