code wiki / _hdl_build / nx_atan_register.nx

nx_atan_register.nx source

↩ module page · 52 lines · 4189 B

1// nx_atan_register.nx -- registers the team-authored ATAN rung via the Librarian. 2// ENGINEER evidence = team invariant test + oracle self-anchor gate + live-oracle 3// ULP gate, ALL re-run here (no stale grades); on pass it appends the gate rows 4// to knowledge/status/math_engine.log (the scorecard's evidence source) and 5// dual-writes the capability via cl_next_idx (atomic idx allocation). 6// license_tier: ORIGINAL 7import "nx_cap_register.nx" 8import "nx_capreg_librarian.nx" 9import "nx_syscalls.nx" 10 11func atr_run(path: *u8) -> i64 { 12 let pid: i64 = sys_fork() 13 if pid == 0 { 14 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 15 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 16 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 17 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 18 sys_execve(path, argv, envp); sys_exit(127) 19 } 20 let st: *i64 = sys_mmap(16) as *i64 21 sys_wait4(pid, st, 0) 22 return st[0] 23} 24 25func main() -> i64 { 26 var allok: i64 = 1 27 if atr_run("/tmp/_pe_f64atan_test.sov.elf" as *u8) != 0 { allok = 0 } 28 if atr_run("/tmp/_bf_atan_gate_authored.sov.elf" as *u8) != 0 { allok = 0 } 29 if atr_run("/tmp/_f64_atan_gate_authored.sov.elf" as *u8) != 0 { allok = 0 } 30 cr_w(1, "ENGINEER: atan invariants + oracle self-anchor + live-oracle ULP gate pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8) 31 if allok == 1 { 32 let lg: i64 = sys_openat_append("knowledge/status/math_engine.log" as *u8, 0x1a4) 33 if lg >= 0 { 34 cr_w(lg, "ATANORACLE epoch=run-2026-06-10 module=_bf_atan_gate_authored machin-recombine=rel-2^-108 tan-roundtrip=206/206-rel-2^-100 specials=PASS verdict=GREEN oracle=nx_bigfloat120_atan(SOVEREIGN,anchored-vs-blessed-trig-organ) reduction=atan-inv-table-subtraction domain=TOTAL lane=nx_sov_build_run\n" as *u8) 35 cr_w(lg, "ATANGATE epoch=run-2026-06-10 module=_f64_atan_gate_authored vectors=322 exact=305 ulp1=17 worse=0 max-ulp=1 verdict=GREEN oracle=LIVE-bigfloat-atan(SOVEREIGN) authored-by=TEAM-MATH_KERNEL-ATAN spec=nx_mathspec_atan(no-python) scheme=accurate-table-j8-anchors-0..20-fold-41/16 domain=TOTAL tamper-test=RED-then-GREEN lane=nx_sov_build_run\n" as *u8) 36 sys_close(lg) 37 } 38 } 39 let eng: i64 = ig_engineer(1, 1, 1, allok) 40 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1) 41 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) } 42 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 43 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 44 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 45 let idx: i64 = cl_next_idx(lp, jp) 46 let ok: i64 = cl_register_dual(lp, jp, idx, 5, 47 2, "GEN F64-ATAN TEAM-AUTHORED, SOVEREIGN KERNEL LOOP RUNG 2 (ME1 rung 5; DLMF ch4 -> 555 permil) -- zero borrowed tools, TOTAL DOMAIN (first ME1 fn with no refusal band): nx_bigfloat120_atan (SOVEREIGN ORACLE: general atan from the blessed Machin organ alone -- addition-formula reduction subtracting atan(1/n) table angles, n=nearest(1/x) bumped, residual <1/8 in <=3 rounds + 30-term Taylor tail; self-anchor gate = Machin recombination through the GENERAL path rel<2^-108 + tan(atan(x))=x vs blessed bf_sin_r/bf_cos_r at 206 pts rel<2^-100 + specials) -> nx_mathspec_atan (SPEC EMITTER: 77 consts -- pi/2 hi/lo, 21 anchors j/8 with atan(j/8) hi/lo accurate-table, 8 odd-Taylor coeffs -- ALL from sovereign bigfloat) -> pe6_author_atan (MATH_KERNEL template 3: accurate-table, |t|<=1/16 Sterbenz-exact, fold at 41/16 where 2-binade gap damps folded error 4x) -> TEAM authored _pe_f64atan (nx_f64_atan) -> GATE vs LIVE bigfloat-atan oracle: 322 points exact=305 ulp1=17 worse=0 max-ulp=1, tamper-test RED(worse=5,max=1000)-then-GREEN, weak-tamper lesson logged (low-bit coeff flip stays sub-ulp; tamper the table). Scorecard overall 294->352 ON-LADDER. Composes CAPREG276/285/289/294" as *u8) 48 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 49 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED (team atan, total-domain sovereign loop)\n" as *u8) 50 sys_exit(0) 51 return 0 52}