// Build sealed real supports and matched controls; no new statistic runs here. const fs = require('node:fs'); const path = require('node:path'); const crypto = require('node:crypto'); const assert = require('node:assert/strict'); process.chdir(__dirname); const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const source = fs.readFileSync('phase-margin-728.js', 'utf8'); assert.equal(sha(source), 'd78760cccaa48205a11a8cd42f18f0959b25160115cabd47f3bc14285db72d8a'); const cut = source.indexOf('const tiny=directTile(5),'); assert(cut > 0); // Load the earlier pinned construction and exact two-prime kernel checker, // stopping before any earlier statistic or trial loop executes. const helper = new Function('require', 'process', source.slice(0, cut) + '\nreturn {base,bs,N,Random32,edges,kernelSpectrum,fromWord,hist,pairs,directTile};')(require, process); const { base, bs, N, Random32, edges, kernelSpectrum, fromWord, hist, pairs, directTile } = helper; const priorText = fs.readFileSync('phase-pairs-727.json', 'utf8'); assert.equal(sha(priorText), 'c72c7b29e9dd2aa10cd09df51ed396e066bf09d43b9b0f5ab87a4e7d9f0d2bf9'); const prior = JSON.parse(priorText); const pilot = process.argv.includes('--pilot'); const tiny = directTile(5); const words = [ { label: 'tiny-T5', width: tiny.width, slots: Array.from(tiny.slots), primes: [7, 11, 13], lengths: [41], retain_events: true }, { label: 'actual-T13', width: base.width, slots: Array.from(base.slots), primes: [17, 19, 23], lengths: [205, 241], retain_events: true } ]; const matched = [], rng = new Random32(72713), pivot = 9; const others = Array.from({ length: N }, (_, i) => i).filter(i => i !== pivot); for (let trial = 1; trial <= (pilot ? 1 : 32); trial++) { const tours = Array.from({ length: 3 }, () => [pivot, ...rng.shuffle(others)]); const orders = [tours.flat(), [tours[0], tours[2], tours[1]].flat()]; if (trial === 1) assert.deepEqual(orders, prior.orders); const edgeData = orders.map(edges), kernelData = orders.map(kernelSpectrum); const gapWords = orders.map(order => order.flatMap(i => bs[i])); assert.deepEqual(edgeData[0], edgeData[1]); assert.deepEqual(kernelData[0], kernelData[1]); assert.deepEqual(hist(gapWords[0]), hist(gapWords[1])); assert.deepEqual(pairs(gapWords[0]), pairs(gapWords[1])); const indices = []; for (let side = 0; side < 2; side++) { const tile = fromWord(gapWords[side], 3 * base.width, base.slots[0]); indices.push(words.length); words.push({ label: `pair-${trial}-${side}`, width: tile.width, slots: Array.from(tile.slots), primes: [17, 19, 23], lengths: [241], retain_events: trial === 1 }); } matched.push({ trial, orders, word_indices: indices, edge_sha256: sha(JSON.stringify(edgeData[0])), kernel_sha256: sha(JSON.stringify(kernelData[0])), gap_histogram_sha256: sha(JSON.stringify(hist(gapWords[0]))), gap_pairs_sha256: sha(JSON.stringify(pairs(gapWords[0]))), matched_edges_H_pairs_and_two_prime_kernel: true }); } const result = { job_id: 741, pilot, seed: 72713, anchor: base.slots[0], blocks: bs, matched_pairs: matched, words, construction_source_sha256: sha(source), prior_first_pair_sha256: sha(priorText), inherited_dependencies: ['onefold-state-717.js', 'phase-memory-727.json', 'separator-spectrum-721.json', 'separator-kernel-721-pairs.json'], all_construction_and_kernel_gates_passed: true }; process.stdout.write(JSON.stringify(result) + '\n');