code wiki / _hdl_build / nx_recycler_extract.nx

nx_recycler_extract.nx source

↩ module page · 103 lines · 7181 B

1// nx_recycler_extract.nx -- Extracts and verifies critiques of competing systems, mapping them to Nishi verdicts and hardening actions. 2import "nx_gate_gn.nx" 3// nx_recycler_extract.nx -- R5 EXTRACT + critique-assess (fills the last pipeline GAP). Consumes the critique-class 4// pages fetched by nx_recycler_critique_fetch (the literal Amazon-Basics: mine what's wrong with COMPETING products), 5// CONFIRMS each critique is really documented in its fetched page (EXTRACT = grounded keyword detection, not 6// hallucination), and maps each to a Nishi verdict + recycle-action. HONEST BY CONSTRUCTION: it does NOT flatter us 7// -- 2 of the 5 critiques genuinely APPLY (undefined behavior: our LM-030/031 are silent miscompiles = real UB; 8// memory safety: we are a manual-memory language with raw pointers), and those become hardening work; the other 3 9// (dependency hell, GC pauses, bloat) are design immunities/differentiation. Self-gating. license_tier: ORIGINAL 10import "nx_syscalls.nx" 11 12func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 14func streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 } 15func lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c } 16// case-insensitive: is the lowercase `needle` present in buf[0..n)? 17func page_has(buf: *u8, n: i64, needle: *u8) -> i64 { 18 let nl: i64 = slen(needle); if nl==0 { return 1 } 19 var i: i64=0 20 while i+nl<=n { 21 var k: i64=0; var m: i64=1 22 while k<nl { if lc(buf[i+k] as i64)!=(needle[k] as i64) { m=0; k=nl } else { k=k+1 } } 23 if m==1 { return 1 } 24 i=i+1 25 } 26 return 0 27} 28// 1 if the critique signature is documented in its fetched page (EXTRACT grounding). 29func extracted(file: *u8, sig: *u8) -> i64 { 30 let lp: *i64 = sys_mmap(16) as *i64; lp[0]=0 31 let buf: *u8 = sys_read_file(file, lp) 32 if (buf as i64)==0 { return 0-1 } 33 return page_has(buf, lp[0], sig) 34} 35 36func main() -> i64 { 37 gp("=== nx_recycler_extract: mine critiques of OTHER systems -> Nishi differentiation/hardening (R5) ===\n" as *u8) 38 39 let ids: *i64 = sys_mmap(8*8) as *i64 40 let sig: *i64 = sys_mmap(8*8) as *i64 41 let file: *i64 = sys_mmap(8*8) as *i64 42 let verd: *i64 = sys_mmap(8*8) as *i64 43 let basis: *i64 = sys_mmap(8*8) as *i64 44 let act: *i64 = sys_mmap(8*8) as *i64 45 46 ids[0]="undefined-behavior" as *u8 as i64; sig[0]="undefined behavior" as *u8 as i64; file[0]="knowledge/fetched/recyc_crit_ub.raw" as *u8 as i64 47 verd[0]="APPLIES" as *u8 as i64 48 basis[0]="WE have UB: LM-030/LM-031 (const-index / cast-then-index) SILENTLY MISCOMPILE to garbage with NO error = undefined behavior" as *u8 as i64 49 act[0]="HARDEN: value-level gates for the miscompile classes (verified-index / checked primitive); cross-linked to LM-030/LM-031" as *u8 as i64 50 51 ids[1]="memory-safety" as *u8 as i64; sig[1]="memory safety" as *u8 as i64; file[1]="knowledge/fetched/recyc_crit_memsafety.raw" as *u8 as i64 52 verd[1]="APPLIES" as *u8 as i64 53 basis[1]="Nishi is a MANUAL-memory language (raw *u8 / sys_mmap, no borrow checker, no default bounds) -> memory safety IS our surface" as *u8 as i64 54 act[1]="HARDEN: the Heartbleed bounds primitive (nx_recycler_bounds) across all parsers + a null/use-after discipline" as *u8 as i64 55 56 ids[2]="dependency-hell" as *u8 as i64; sig[2]="dependency" as *u8 as i64; file[2]="knowledge/fetched/recyc_crit_dephell.raw" as *u8 as i64 57 verd[2]="IMMUNE" as *u8 as i64 58 basis[2]="SOVEREIGN: zero third-party deps, no package manager -- there is no dependency graph to break" as *u8 as i64 59 act[2]="DIFFERENTIATION, locked by nx_recycler_sov_gate (the left-pad recycle: 0 third-party imports)" as *u8 as i64 60 61 ids[3]="software-bloat" as *u8 as i64; sig[3]="bloat" as *u8 as i64; file[3]="knowledge/fetched/recyc_crit_bloat.raw" as *u8 as i64 62 verd[3]="DIFFERENTIATION" as *u8 as i64 63 basis[3]="minimal by design (own toolchain, no framework) -- BUT 'own everything' can itself accrete organs, so not free" as *u8 as i64 64 act[3]="DISCIPLINE: a size-budget + dead-organ census (honest -- a real risk, not a pure win)" as *u8 as i64 65 66 ids[4]="gc-pause" as *u8 as i64; sig[4]="garbage collection" as *u8 as i64; file[4]="knowledge/fetched/recyc_crit_gc.raw" as *u8 as i64 67 verd[4]="IMMUNE" as *u8 as i64 68 basis[4]="NO garbage collector -> no stop-the-world GC pause; deterministic manual memory (the real-time exceed)" as *u8 as i64 69 act[4]="DIFFERENTIATION + regression-lock: prove no organ links a GC/managed runtime" as *u8 as i64 70 let nrec: i64 = 5 71 72 var applies: i64=0; var immune: i64=0; var diff: i64=0; var grounded: i64=0 73 var i: i64=0 74 while i < nrec { 75 let v: *u8 = verd[i] as *u8 76 let ex: i64 = extracted(file[i] as *u8, sig[i] as *u8) 77 gp(" [" as *u8); gp(ids[i] as *u8); gp("] verdict=" as *u8); gp(v) 78 if ex==1 { gp(" (EXTRACTED: critique documented in the fetched page)\n" as *u8); grounded=grounded+1 } 79 if ex==0 { gp(" (!! signature NOT found in page)\n" as *u8) } 80 if ex<0 { gp(" (!! page not fetched)\n" as *u8) } 81 gp(" basis: " as *u8); gp(basis[i] as *u8); gp("\n recycle-> " as *u8); gp(act[i] as *u8); gp("\n" as *u8) 82 if streq(v, "APPLIES" as *u8)==1 { applies=applies+1 } 83 if streq(v, "IMMUNE" as *u8)==1 { immune=immune+1 } 84 if streq(v, "DIFFERENTIATION" as *u8)==1 { diff=diff+1 } 85 i=i+1 86 } 87 gp(" TALLY: applies-to-us=" as *u8); gn(applies); gp(" immune=" as *u8); gn(immune); gp(" differentiation=" as *u8); gn(diff) 88 gp(" grounded(extracted)=" as *u8); gn(grounded); gp("/" as *u8); gn(nrec); gp("\n" as *u8) 89 90 var pass: i64=0; var fail: i64=0 91 if grounded==nrec { pass=pass+1 } else { fail=fail+1; gp(" FAIL a critique not extracted from its page (ungrounded)\n" as *u8) } 92 // HONESTY: the recycler must find REAL applicable critiques, not only flattering immunities 93 if applies>=2 { pass=pass+1 } else { fail=fail+1; gp(" FAIL no-applicable-critiques (over-flattering)\n" as *u8) } 94 if immune>=2 { pass=pass+1 } else { fail=fail+1; gp(" FAIL immune-count\n" as *u8) } 95 // the applicable UB critique must cross-link to OUR OWN documented landmines (the intelligence) 96 if page_has(basis[0] as *u8, slen(basis[0] as *u8), "lm-030" as *u8)==1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL ub-not-linked-to-LM-030\n" as *u8) } 97 // neg-control: a critique-class we did NOT fetch is not assessable 98 if extracted("knowledge/fetched/recyc_crit_NOTREAL.raw" as *u8, "x" as *u8) < 0 { pass=pass+1 } else { fail=fail+1; gp(" FAIL neg-control\n" as *u8) } 99 100 gp("RECYCLER-EXTRACT pass=" as *u8); gn(pass); gp(" fail=" as *u8); gn(fail) 101 if fail==0 { gp(" verdict=GREEN (5 critique-classes extracted from real pages; 2 APPLY to us [UB->LM-030/031, memory-safety] + 3 immune/differentiation; honest, not over-flattering)\n" as *u8); sys_exit(0); return 0 } 102 gp(" verdict=RED\n" as *u8); sys_exit(1); return 1 103}