/* * make-a309-rev2.mjs — the served research/a3-09-histogram-operator.md plus BOTH sections this * session proposes: the fold-29 localization (return #251's revision) and the fold-37 / local-test * section. Built from a309-revised.md, which already carries the first, so the file is a strict * superset of either revision alone and applying it loses nothing if #251 is accepted first. * The footer is the anchor; refuse unless it appears exactly once. */ import { readFileSync, writeFileSync } from "node:fs"; const SRC = "a309.md"; // the served file as just re-fetched const PREV = "a309-revised.md"; // the served file + the fold-29 section (return #251) const OUT = "a309-revised2.md"; const FOOTER = "*This document states current understanding. Superseded claims, retired numbers and the reasons they changed are in [history/CHANGELOG.md](history/CHANGELOG.md), indexed by document.*"; const served = readFileSync(SRC, "utf8"); const prev = readFileSync(PREV, "utf8"); if (served.split(FOOTER).length !== 2) throw new Error("the served file's footer anchor is not unique"); if (prev.split(FOOTER).length !== 2) throw new Error("a309-revised.md's footer anchor is not unique"); if (!prev.startsWith(served.split(FOOTER)[0])) throw new Error("a309-revised.md is not the served file plus a tail: re-fetch and rebuild"); const PRODUCER = process.argv[2]; const VALIDATE = process.argv[3]; const BIG = process.argv[4]; const section = `## The fold above the table: the certificate at 37, and the local test *Audit, 2026-09-13, second revision from the same session. The ladder above stops at T31.* **1. The local test.** A fold's certificate is exact exactly when its own argmax is realizable, and that is one comparison in the pass that already computes \`M\`: a window is realizable iff its interior partial-sum residues mod q lie in a 2-set \`{a-2, a}\` -- equivalently, iff no two consecutive *nonzero* interior steps have the same sign. A drifting run (steps +2, +2) reaches three distinct residues and no \`a\` serves, which is where the slack lives (the fold-29 section above). Applied at every fold the corpus can reach: fold certificate M record argmax windows realizable verdict 11 -> 13 66 66 6 6 exact 13 -> 17 108 108 8 8 exact 17 -> 19 150 150 8 8 exact 19 -> 23 204 204 4 4 exact 23 -> 29 270 270 2 0 loose (the two phantoms) 29 -> 31 348 348 4 4 exact 31 -> 37 528 528 2 2 exact Every gate reproduces the record's certificate column exactly. **2. The top term, without storing the word.** The fold 31 -> 37 is reachable with this instrument even though \`T_31\` has 6,226,553,025 gaps -- 6.2 GB as bytes and 12.5 GB as 16-bit, past the 8 GB offered. The fold emits \`T_31\`'s gaps in sorted order (\`x = k*W_29 + s\`, ordered by \`(k, s)\`, and the surviving lifts are 29 of 31 because \`x = 0, -2 mod 31\` are excluded), a ring of the last \`CAP+1 = 129\` gaps evaluates every window as it arrives, and one replay of the first 129 gaps -- the ring then holding the word's tail, so negative indices resolve cyclically -- covers the wrap. Memory is O(CAP) beyond the previous tile's slot array. Wall clock **241 s**. Gates on the way: \`T_29\` \`D = 214,708,725\`, max gap 258; \`T_31\` \`D = 6,226,553,025\`, max gap 348. The certificate at the fold 31 -> 37 is **528**, attained by two windows, \`168+222+72+66\` and its reverse \`66+72+222+168\`, both realizable (\`nu_q = 1\`), interiors \`[20,20,18]\` and \`[29,27,27]\`, each inside a 2-set. So the instrument is exact at this fold and reports so by its own test. **3. Cross-reference, not a new number.** \`G2(T_37) = 528\` is already on the record: \`research/oeis-G2-submission.md\` line 46 lists the ladder through \`... 204, 258, 348, 528\`, and line 174 records that term as a "mod-30 lattice walk over 7.42e12 positions (~54 min; slot count matched A059861 = 217929355875 exactly; max gap at r = 544899485411)". This is therefore an independent route to the same value, and a cheaper one by about 13x (241 s against ~54 min), not a new term. What is new is that the *certificate* reaches the top of the record's ladder and stays exact there, which the ladder's own table did not have. Reproduction: \`node --max-old-space-size=7000 streamfold.mjs validate\` (10 s, six gates) and \`node --max-old-space-size=7000 streamfold.mjs big\` (241 s, the top term). Producer \`${PRODUCER}\`, validate stdout \`${VALIDATE}\`, big stdout \`${BIG}\`. `; writeFileSync(OUT, prev.split(FOOTER)[0] + section + "---\n\n" + FOOTER + prev.split(FOOTER)[1], "utf8"); console.log(`wrote ${OUT}: ${prev.split("\n").length} -> ${(prev.split(FOOTER)[0] + section + "---\n\n" + FOOTER).split("\n").length} lines`); console.log(`served file unchanged: ${served.split(FOOTER)[0].length === prev.split(FOOTER)[0].length - 0 ? "same body prefix, revision #251 present" : "check"}`);