code wiki / _hdl_build / nx_research_ingest_test.nx

nx_research_ingest_test.nx source

↩ module page · 76 lines · 4083 B

1// nx_research_ingest_test.nx -- the Researcher basis GROWS under governance. A 2// candidate research-grounded repair (from the seed basis, the tutor, or -- when 3// networked -- the sovereign SEARCH ENGINE) may enter the basis ONLY if it passes 4// the crew's epistemic checks: 5// ENGINEER the fix RE-VERIFIES sound 1:1 (not just claimed) 6// GENEALOGIST it is NOVEL (not already in the basis) 7// ARCHIVIST it is CITED (a real source -- Cardinal #4: verified facts, never 8// hallucinated/uncited "research") 9// -> Conductor admits; otherwise refused with the governing reason. 10// So the loop's knowledge can only GROW with research it has both VERIFIED and 11// SOURCED. This is the trust gate the live search engine plugs into (a hit -> a 12// candidate -> must clear this council before the loop believes it). 13// 14// Reuses the proven crew council (nx_crew_council): an ingestion maps to a 15// CrewAction {verifies=re-verifies, novel=novel, recorded=cited}. Known answer: 16// 4 candidates -> 1 ADMITTED + 3 REFUSED (uncited / unverified / duplicate). exit 0. 17 18import "nx_crew_council.nx" 19 20const RI_N: i64 = 4 21 22func ri_putn(v: i64) -> i64 { 23 let b: *u8 = sys_mmap(24); var n: i64 = v; if n < 0 { n = 0 - n } 24 let t: *u8 = sys_mmap(24); var k: i64 = 0 25 if n == 0 { t[0] = 48; k = 1 } 26 while n > 0 { t[k] = 48 + (n % 10); n = n / 10; k = k + 1 } 27 var i: i64 = 0; while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 28 sys_write(1, b, k); return 0 29} 30 31func main() -> i64 { 32 // candidate research-repairs: name + {re-verifies, novel, cited} 33 let nm: *i64 = sys_mmap(8 * RI_N) as *i64 34 let rv: *i64 = sys_mmap(8 * RI_N) as *i64 35 let nv: *i64 = sys_mmap(8 * RI_N) as *i64 36 let ci: *i64 = sys_mmap(8 * RI_N) as *i64 37 38 nm[0]=("div-by-const: Granlund-Montgomery magic (PLDI 1994), re-verified" as *u8) as i64; rv[0]=1; nv[0]=1; ci[0]=1 39 nm[1]=("blog claim: 'this trick always works' (no source)" as *u8) as i64; rv[1]=1; nv[1]=1; ci[1]=0 40 nm[2]=("claimed fix that does NOT re-verify sound" as *u8) as i64; rv[2]=0; nv[2]=1; ci[2]=1 41 nm[3]=("k<W guard -- already in the basis (duplicate)" as *u8) as i64; rv[3]=1; nv[3]=0; ci[3]=1 42 43 cc_puts("================================================================\n" as *u8) 44 cc_puts(" RESEARCH INGESTION -- the basis grows ONLY with research that is\n" as *u8) 45 cc_puts(" VERIFIED + NOVEL + CITED (epistemic checks & balances, Cardinal #4)\n" as *u8) 46 cc_puts("================================================================\n" as *u8) 47 48 let a: *CrewAction = sys_mmap(64) as *CrewAction 49 let why: *i64 = sys_mmap(8) as *i64 50 var admitted: i64 = 0 51 var refused: i64 = 0 52 let basis0: i64 = 8 // the seeded basis size (nx_research_basis: 5 numerics/compiler + 3 power/codegen) 53 54 var i: i64 = 0 55 while i < RI_N { 56 // ingestion -> CrewAction: verifies=re-verifies, novel=novel, recorded=cited. 57 cc_set(a, nm[i] as *u8, rv[i], nv[i], 1, 1, ci[i]) 58 let vd: i64 = cc_council(a, why) 59 cc_puts(" [" as *u8); cc_puts(cc_verdict_name(vd)); cc_puts("] " as *u8); cc_puts(a.name as *u8) 60 cc_puts("\n -> " as *u8); cc_puts(why[0] as *u8); cc_puts("\n" as *u8) 61 if vd == CC_ACT { admitted = admitted + 1 } else { refused = refused + 1 } 62 i = i + 1 63 } 64 65 cc_puts("----------------------------------------------------------------\n" as *u8) 66 cc_puts(" basis " as *u8); ri_putn(basis0); cc_puts(" -> " as *u8); ri_putn(basis0 + admitted) 67 cc_puts(" (ADMITTED " as *u8); ri_putn(admitted); cc_puts(", REFUSED " as *u8); ri_putn(refused) 68 cc_puts(")\n the basis grows only with VERIFIED + CITED research; uncited claims,\n" as *u8) 69 cc_puts(" unverified fixes, and duplicates are kept out. live search feeds HERE.\n" as *u8) 70 cc_puts("----------------------------------------------------------------\n" as *u8) 71 72 if admitted != 1 { sys_exit(1); return 1 } 73 if refused != 3 { sys_exit(2); return 2 } 74 sys_exit(0) 75 return 0 76}