code wiki / _hdl_build / nx_search_reach_pulse.nx

nx_search_reach_pulse.nx source

↩ module page · 92 lines · 5163 B

1// nx_search_reach_pulse.nx -- SREACH R4: the DURABLE REACH LOOP step. 2// 3// Conductor-owned pulse step: re-proves the search arc's two regression gates 4// EVERY beat -- nx_facet_gate (R2: bits-up facets agree with gold at the 5// permil bar) and nx_diora_leaderboard (R0/R2: Nishi exceeds EVERY incumbent 6// on research delivery AND reach, with classifier facets + the content- 7// accessibility axis live) -- then appends ONE machine-readable verdict row 8// to knowledge/status/search_reach.log (NTFS-durable, reboot-safe) for the 9// Examiner's per-arc grading (examiner_arcs.conf row SREACH). So reach is 10// re-proven per-BEAT, not per-session: a regression anywhere in the ranking / 11// facet / scoring stack turns the arc RED on the next pulse, evidence-first. 12// 13// Deliberately NOT in this step: the LIVE-network crawls (R1 guarded reach / 14// live SERP) -- a beat must be deterministic and offline-green; live reach 15// re-proves per-arc via nx_diora_live_reach_guarded, never on the clock. 16// 17// Child-run pattern = nx_team_pulse's tp_run (self-healing): exec the /tmp 18// sovereign binary; if /tmp was wiped (reboot / concurrent cleanup), fall 19// back to the durable _offc/nx_sov_build_run.elf which rebuilds from settled 20// source -- identical judgment, no exec-127 false reds. license_tier: ORIGINAL 21import "nx_syscalls.nx" 22import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 23func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 24// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 25// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 26// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 27// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 28func _pn(v: i64) -> i64 { nxi_out(v); return 0 } 29func _fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 30// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 31// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 32// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 33// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 34func _fn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } 35func srp_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } 36// run /tmp/<name>.sov.elf muted; heal via durable nx_sov_build_run if absent. 37func srp_run(name: *u8) -> i64 { 38 let path: *u8 = sys_mmap(256) 39 var o: i64 = 0 40 o = srp_cat(path, o, "/tmp/" as *u8); o = srp_cat(path, o, name); o = srp_cat(path, o, ".sov.elf" as *u8); path[o] = 0 as u8 41 var heal: i64 = 0 42 let probe: i64 = sys_openat_rd(path) 43 if probe >= 0 { sys_close(probe) } else { heal = 1 } 44 let pid: i64 = sys_fork() 45 if pid == 0 { 46 let argv: *i64 = sys_mmap(32) as *i64 47 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 48 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4); if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 49 if heal == 1 { 50 let sbr: *u8 = "_offc/nx_sov_build_run.elf" as *u8 51 argv[0] = sbr as i64; argv[1] = name as i64; argv[2] = 0 52 sys_execve(sbr, argv, envp) 53 } 54 argv[0] = path as i64; argv[1] = 0 55 sys_execve(path, argv, envp) 56 sys_exit(127) 57 } 58 let st: *i64 = sys_mmap(16) as *i64 59 sys_wait4(pid, st, 0) 60 if (st[0] % 128) != 0 { return 0 - 1 } 61 return (st[0] >> 8) & 0xff 62} 63func main() -> i64 { 64 _p("=== SEARCH REACH PULSE (SREACH R4): re-prove facet gate + reach gate, one beat unit ===\n" as *u8) 65 let facet_rc: i64 = srp_run("nx_facet_gate" as *u8) 66 _p(" nx_facet_gate rc=" as *u8); _pn(facet_rc); _p("\n" as *u8) 67 let lead_rc: i64 = srp_run("nx_diora_leaderboard" as *u8) 68 _p(" nx_diora_leaderboard rc=" as *u8); _pn(lead_rc); _p("\n" as *u8) 69 // CONTENT-NEUTRALITY CHARTER (operator 2026-06-10): agnostic retrieval -- 70 // order, never exclude; a suppression filter must turn this beat RED 71 let neut_rc: i64 = srp_run("nx_search_neutrality_gate" as *u8) 72 _p(" nx_search_neutrality_gate rc=" as *u8); _pn(neut_rc); _p("\n" as *u8) 73 var all0: i64 = 0 74 if facet_rc == 0 { if lead_rc == 0 { if neut_rc == 0 { all0 = 1 } } } 75 let lfd: i64 = sys_openat_append("knowledge/status/search_reach.log" as *u8, 0x1a4) 76 if lfd >= 0 { 77 _fp(lfd, "SREACH-PULSE epoch=" as *u8); _fn(lfd, sys_now_realtime_sec()) 78 _fp(lfd, " facet_rc=" as *u8); _fn(lfd, facet_rc) 79 _fp(lfd, " leaderboard_rc=" as *u8); _fn(lfd, lead_rc) 80 _fp(lfd, " neutrality_rc=" as *u8); _fn(lfd, neut_rc) 81 if all0 == 1 { _fp(lfd, " verdict=GREEN\n" as *u8) } else { _fp(lfd, " verdict=RED\n" as *u8) } 82 sys_close(lfd) 83 } 84 if all0 == 1 { 85 _p(" SREACH-PULSE: GREEN\n" as *u8) 86 sys_exit(0) 87 return 0 88 } 89 _p(" SREACH-PULSE: RED\n" as *u8) 90 sys_exit(1) 91 return 1 92}