code wiki / _hdl_build / nx_hosting_research.nx

nx_hosting_research.nx source

↩ module page · 146 lines · 6533 B

1// nx_hosting_research.nx -- drive the SOVEREIGN NISHI RESEARCHER over the hosting gap research. 2// 3// module: nishi-core.research.hosting 4// capability: CORE_COMPUTE (turn delegated hosting research into a verified, reproducible gap-task backlog) 5// 6// Reads knowledge/registry/hosting_research.tsv (the delegated fetch+extract: claims + 3 adversarial 7// votes each, grounded in real best-in-class-host sources) and runs nx_researcher's DETERMINISTIC 8// verify (>=2 confirm => CONFIRMED) + synthesize (CONFIRMED+actionable => gap-task). Prints the verdict 9// census + the gap-task backlog + the REPRODUCIBILITY proof (same evidence -> same tasks, the exceed 10// over a one-shot LLM report). Refuted/contested claims generate ZERO tasks (no wasted build effort). 11// Sovereign: nx_syscalls + nx_researcher. license_tier: ORIGINAL 12 13import "nx_syscalls.nx" 14import "nx_researcher.nx" 15 16const HR_FILE: *u8 = "knowledge/registry/hosting_research.tsv" 17 18static HR_N: i64 19static HR_FID: i64 // *i64 of *u8 20static HR_CLAIM: i64 // *i64 of *u8 21static HR_CV: i64 // *i64 22static HR_RV: i64 // *i64 23static HR_ACT: i64 // *i64 24static HR_ORGAN: i64 // *i64 of *u8 25static HR_NOTE: i64 // *i64 of *u8 26 27func hr_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 } 28func hr_putn(v: i64) -> i64 { 29 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } 30 var m: i64 = v 31 if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } 32 let d: *u8 = sys_mmap(24); var k: i64 = 0 33 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 34 var j: i64 = k - 1 35 while j >= 0 { sys_write(1, ((d as i64)+j) as *u8, 1); j = j - 1 } 36 return 0 37} 38func hr_field(b: *u8, ls: i64, le: i64, f: i64) -> *u8 { 39 var cur: i64 = 0; var i: i64 = ls 40 while cur < f { if i >= le { let e: *u8 = sys_mmap(2); e[0] = 0 as u8; return e } if b[i] == 9 as u8 { cur = cur + 1 } i = i + 1 } 41 let out: *u8 = sys_mmap(512); var o: i64 = 0 42 while i < le { if b[i] == 9 as u8 { i = le } else { if o < 511 { out[o] = b[i]; o = o + 1 } i = i + 1 } } 43 out[o] = 0 as u8 44 return out 45} 46func hr_atoi(s: *u8) -> i64 { if s[0] >= 48 as u8 { if s[0] <= 57 as u8 { return (s[0] - 48 as u8) as i64 } } return 0 } 47 48func hr_parse() -> i64 { 49 let lenbox: *i64 = sys_mmap(16) as *i64; lenbox[0] = 0 50 let data: *u8 = sys_read_file(HR_FILE, lenbox) 51 if (data as i64) == 0 { return 0 - 1 } 52 let n: i64 = lenbox[0] 53 var rows: i64 = 0; var ls: i64 = 0; var i: i64 = 0 54 while i <= n { 55 var atend: i64 = 0 56 if i == n { atend = 1 } 57 if i < n { if data[i] == 10 as u8 { atend = 1 } } 58 if atend == 1 { if i > ls { if data[ls] != 35 as u8 { rows = rows + 1 } } ls = i + 1 } 59 i = i + 1 60 } 61 let fid: *i64 = sys_mmap(8 * (rows + 1)) as *i64 62 let claim: *i64 = sys_mmap(8 * (rows + 1)) as *i64 63 let cv: *i64 = sys_mmap(8 * (rows + 1)) as *i64 64 let rv: *i64 = sys_mmap(8 * (rows + 1)) as *i64 65 let act: *i64 = sys_mmap(8 * (rows + 1)) as *i64 66 let organ: *i64 = sys_mmap(8 * (rows + 1)) as *i64 67 let note: *i64 = sys_mmap(8 * (rows + 1)) as *i64 68 var r: i64 = 0; ls = 0; i = 0 69 while i <= n { 70 var atend: i64 = 0 71 if i == n { atend = 1 } 72 if i < n { if data[i] == 10 as u8 { atend = 1 } } 73 if atend == 1 { 74 if i > ls { if data[ls] != 35 as u8 { 75 fid[r] = hr_field(data, ls, i, 0) as i64 76 claim[r] = hr_field(data, ls, i, 1) as i64 77 cv[r] = hr_atoi(hr_field(data, ls, i, 2)) 78 rv[r] = hr_atoi(hr_field(data, ls, i, 3)) 79 act[r] = hr_atoi(hr_field(data, ls, i, 4)) 80 organ[r] = hr_field(data, ls, i, 5) as i64 81 note[r] = hr_field(data, ls, i, 6) as i64 82 r = r + 1 83 } } 84 ls = i + 1 85 } 86 i = i + 1 87 } 88 HR_N = r 89 HR_FID = fid as i64; HR_CLAIM = claim as i64; HR_CV = cv as i64; HR_RV = rv as i64 90 HR_ACT = act as i64; HR_ORGAN = organ as i64; HR_NOTE = note as i64 91 return 0 92} 93 94func main() -> i64 { 95 hr_puts("=== NISHI RESEARCHER: hosting vs best-in-class -- verified gap-task backlog ===\n") 96 if hr_parse() != 0 { hr_puts("FATAL: hosting_research.tsv unreadable\n"); sys_exit(1); return 1 } 97 let cv: *i64 = HR_CV as *i64 98 let rv: *i64 = HR_RV as *i64 99 let act: *i64 = HR_ACT as *i64 100 let fid: *i64 = HR_FID as *i64 101 let claim: *i64 = HR_CLAIM as *i64 102 let organ: *i64 = HR_ORGAN as *i64 103 let note: *i64 = HR_NOTE as *i64 104 105 // owning-organ id array (row index; res_synthesize echoes it). 106 let oid: *i64 = sys_mmap(8 * (HR_N + 4)) as *i64 107 var z: i64 = 0; while z < HR_N { oid[z] = z; z = z + 1 } 108 109 let confirmed: i64 = res_count_verdict(HR_N, cv, rv, RES_CONFIRMED) 110 let refuted: i64 = res_count_verdict(HR_N, cv, rv, RES_REFUTED) 111 let contested: i64 = res_count_verdict(HR_N, cv, rv, RES_CONTESTED) 112 let repro: i64 = res_is_reproducible(HR_N, cv, rv, act, oid) 113 114 let out_idx: *i64 = sys_mmap(8 * (HR_N + 4)) as *i64 115 let out_org: *i64 = sys_mmap(8 * (HR_N + 4)) as *i64 116 let tasks: i64 = res_synthesize(HR_N, cv, rv, act, oid, out_idx, out_org) 117 118 hr_puts(" findings="); hr_putn(HR_N) 119 hr_puts(" CONFIRMED="); hr_putn(confirmed) 120 hr_puts(" REFUTED="); hr_putn(refuted) 121 hr_puts(" CONTESTED="); hr_putn(contested) 122 hr_puts(" -> gap-tasks="); hr_putn(tasks) 123 hr_puts(" (refuted/contested -> 0 tasks, the no-wasted-work exceed)\n") 124 hr_puts(" reproducible(same evidence -> same tasks)="); hr_putn(repro); hr_puts(" (an LLM one-shot cannot guarantee this)\n\n") 125 126 hr_puts(" GAP-TASK BACKLOG (CONFIRMED + actionable, ranked by confidence):\n") 127 var t: i64 = 0 128 while t < tasks { 129 let i: i64 = out_idx[t] 130 hr_puts(" ["); hr_putn(res_confidence_permil(cv[i])); hr_puts("permil] ") 131 hr_puts(fid[i] as *u8); hr_puts(" -> "); hr_puts(organ[i] as *u8); hr_puts("\n") 132 hr_puts(" "); hr_puts(claim[i] as *u8); hr_puts("\n") 133 t = t + 1 134 } 135 hr_puts("\n KILLED (not built -- the researcher refused them):\n") 136 var j: i64 = 0 137 while j < HR_N { 138 let v: i64 = res_verify(cv[j], rv[j]) 139 if v != RES_CONFIRMED { 140 hr_puts(" ["); if v == RES_REFUTED { hr_puts("REFUTED ") } else { hr_puts("CONTESTED") } 141 hr_puts("] "); hr_puts(fid[j] as *u8); hr_puts(" -- "); hr_puts(note[j] as *u8); hr_puts("\n") 142 } 143 j = j + 1 144 } 145 sys_exit(0); return 0 146}