#!/usr/bin/env python3 """Build outputs/job4472/attack0830_level23.js from the served producer. Job #4472 (explore, lane dir-558, Q-varE-identification-0830). The served producer `research/history/staging/attack-0830-varE-identification.js` computes the exact branch-type x modulus-band table of X at x = 7, 11, 13, 17, 19 and the balance split (PART G) of the dominant mix2a cell at the same levels. Every one of the note's declared-not-run falsifiers for the identification step is "the shares at a new level", and x = 23 is not in the served table. This script applies a minimal, auditable patch to the fetched copy: * appends the x = 23 level to LV, with the corpus delta*X = 0.364320 (varE-theta2-step.md sec.4) and the 2026-09-05 rider's corrected delta*X2 = 0.000236 / delta*Xmix = -0.013876 as the cross-checks; * merges PART C's top two bands at x = 23 (2L < n <= 8L | n > 8L), as that producer already does at x = 19, so the descent stops at 8L; * guards the three corpus asserts that have no x = 23 column. Only the three assert lines and the two band-edge lines differ. No number in the computation is changed. """ import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) SRC = os.path.join(HERE, "served", "doc_research_history_staging_attack-0830-varE-identification.js") DST = os.path.join(HERE, "attack0830_level23.js") PATCHES = [ # 1. the x = 23 level (""" {x:19,L:9699690, X:81.289135, dX1:0.363348, dX2:0.011379, dXm:-0.038804}, ];""", """ {x:19,L:9699690, X:81.289135, dX1:0.363348, dX2:0.011379, dXm:-0.038804}, // x = 23 ADDED (job #4472). Corpus delta*X = 0.364320 (varE-theta2-step.md sec.4); // rider 2026-09-05 corrected values delta*X2 = 0.000236, delta*Xmix = -0.013876. // The X2 *column* and X1 are not carried at x = 23, so those asserts are guarded. {x:23,L:223092870, X:null, dX1:null, dX2:null, dXm:null, dX:0.364320, dX2r:0.000236, dXmr:-0.013876}, ];"""), # 2. bands: merge the top two at x >= 19 so the descent stops at 8L (""" const edges=(x===19)?[2*L,8*L]:[2*L,8*L,L*lny*lny];""", """ const edges=(x>=19)?[2*L,8*L]:[2*L,8*L,L*lny*lny];"""), (""" const bnames=['n<=2L','2L8L']:['8LL ln^2 y']);""", """ const bnames=['n<=2L','2L=19?['n>8L']:['8LL ln^2 y']);"""), # 3. guarded asserts (""" assert(Math.abs(totR-lv.X)/lv.X<2e-6,'total REM reproduces the corpus X at x='+x);""", """ if(lv.X!=null){assert(Math.abs(totR-lv.X)/lv.X<2e-6,'total REM reproduces the corpus X at x='+x);} else{assert(Math.abs(delta*totR-lv.dX)/lv.dX<2e-6,'total REM reproduces the corpus delta*X at x='+x);}"""), (""" assert(Math.abs(delta*X1-lv.dX1)<2e-6&&Math.abs(delta*(totR-X1)-(2*lv.dX2+lv.dXm))<3e-6,'X1 and X - X1 reproduce varE-theta2-step at x='+x);""", """ if(lv.dX1!=null){assert(Math.abs(delta*X1-lv.dX1)<2e-6&&Math.abs(delta*(totR-X1)-(2*lv.dX2+lv.dXm))<3e-6,'X1 and X - X1 reproduce varE-theta2-step at x='+x);} else{assert(Math.abs(delta*X2-lv.dX2r)<3e-6&&Math.abs(delta*Xm-lv.dXmr)<3e-6,'delta*X2 and delta*Xmix reproduce the 2026-09-05 rider at x='+x);}"""), (""" assert(Math.abs(delta*X2c-lv.dX2)<2e-6,'the corpus X2 column is reproduced by the asymmetric formula at x='+x);""", """ if(lv.dX2!=null) assert(Math.abs(delta*X2c-lv.dX2)<2e-6,'the corpus X2 column is reproduced by the asymmetric formula at x='+x);"""), ] def main(): src = open(SRC, encoding="utf-8").read() out = src for old, new in PATCHES: n = out.count(old) if n != 1: raise SystemExit("patch anchor not unique (%d): %r" % (n, old[:60])) out = out.replace(old, new) # the two console.log lines that would print NaN for x = 23 fixes = [ ("""' (corpus '+lv.dX1+') delta*(X - X1) = '+f6(delta*(totR-X1))+' (corpus 2*dX2 + dXmix = '+f6(2*lv.dX2+lv.dXm)+')');""", """' (corpus '+(lv.dX1==null?'n/a':lv.dX1)+') delta*(X - X1) = '+f6(delta*(totR-X1))+' (corpus 2*dX2 + dXmix = '+(lv.dX2==null?'n/a':f6(2*lv.dX2+lv.dXm))+')');"""), ("""' (corpus column '+lv.dX2+') delta*Xmix = '+f6(delta*Xm)+' (corpus column '+lv.dXm+') [see PART F]');""", """' (corpus column '+(lv.dX2==null?'n/a':lv.dX2)+') delta*Xmix = '+f6(delta*Xm)+' (corpus/rider '+(lv.dXm==null?'n/a':lv.dXm)+') [see PART F]');"""), ] for old, new in fixes: if out.count(old) != 1: raise SystemExit("log anchor not unique: %r" % old[:60]) out = out.replace(old, new) with open(DST, "w", encoding="utf-8", newline="\n") as fh: fh.write(out) print("wrote %s (%d bytes)" % (DST, len(out))) return 0 if __name__ == "__main__": sys.exit(main())