code wiki / (root) / nx_readiness_census.nx

nx_readiness_census.nx source

↩ module page · 99 lines · 5184 B

1// nx_readiness_census.nx -- reads the ITERABLE roadmap (knowledge/readiness/ 2// roadmap.map) and applies the TRL/MRL engine to emit, for EVERY Nishi 3// capability, the hardware-rung-up roadmap: current rung, the next concrete 4// action to advance, rungs remaining to market, and the market-entry 5// verdict. Validates every rung (a malformed TRL/MRL level -> RED, exit 1), 6// so the roadmap cannot silently carry a bogus rung. Absolute map path so 7// it runs from any cwd. license_tier: ORIGINAL expect_exit: 0 8import "nx_syscalls.nx" 9import "nx_readiness.nx" 10const K_MAGIC_65536: i64 = 65536 11 12func w(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 } 13func wn(fd: i64, v: i64) -> i64 { 14 var m: i64 = v; if m < 0 { w(fd, "-" as *u8); m = 0 - m } 15 let t: *u8 = sys_mmap(24); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } 16 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 17 let o: *u8 = sys_mmap(24); var i: i64 = 0; while i < k { o[i] = t[k-1-i]; i = i + 1 } sys_write(fd, o, k); return 0 18} 19func c_read(path: *u8, buf: *u8, cap: i64) -> i64 { 20 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } 21 var tot: i64 = 0 22 while tot < cap { let r: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if r <= 0 { break } tot = tot + r } 23 sys_close(fd); return tot 24} 25func splitpipe(s: *u8, fld: *i64, maxf: i64) -> i64 { 26 var c: i64 = 1; fld[0] = s as i64; var i: i64 = 0 27 while s[i] != (0 as u8) { if s[i] == (124 as u8) { s[i] = 0 as u8; if c < maxf { fld[c] = (s as i64) + i + 1; c = c + 1 } } i = i + 1 } 28 return c 29} 30func atoi(s: *u8) -> i64 { 31 var v: i64 = 0; var i: i64 = 0 32 while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } 33 return v 34} 35func kind_of(s: *u8) -> i64 { 36 if s[0] == (72 as u8) { return RD_HARDWARE } // H 37 if s[0] == (89 as u8) { return RD_HYBRID } // Y 38 return RD_SOFTWARE // S 39} 40 41func main() -> i64 { 42 let cap: i64 = K_MAGIC_65536 43 let buf: *u8 = sys_mmap(cap) 44 let n: i64 = c_read("/mnt/c/Users/elder/nishi-core/nxc2/knowledge/readiness/roadmap.map" as *u8, buf, cap) 45 if n <= 0 { w(1, "READINESS: roadmap.map missing\n" as *u8); sys_exit(1); return 1 } 46 47 w(1, "=== NISHI PRODUCT-READINESS ROADMAP (hardware rung up, per capability) ===\n" as *u8) 48 let fld: *i64 = sys_mmap(64) as *i64 49 var total: i64 = 0 50 var ready: i64 = 0 51 var need_hw: i64 = 0 52 var bad: i64 = 0 53 54 var p: i64 = 0 55 while p < n { 56 var e: i64 = p 57 while e < n { if buf[e] == (10 as u8) { break } e = e + 1 } 58 buf[e] = 0 as u8 59 let line: *u8 = (buf as i64 + p) as *u8 60 p = e + 1 61 if line[0] == (0 as u8) { } else { if line[0] == (35 as u8) { } else { 62 let cnt: i64 = splitpipe(line, fld, 6) 63 if cnt >= 5 { 64 total = total + 1 65 let name: *u8 = fld[0] as *u8 66 let kind: i64 = kind_of(fld[1] as *u8) 67 let trl: i64 = atoi(fld[2] as *u8) 68 let mrl: i64 = atoi(fld[3] as *u8) 69 let note: *u8 = fld[4] as *u8 70 if rd_trl_valid(trl) == 0 { bad = bad + 1 } 71 if kind != RD_SOFTWARE { if rd_mrl_valid(mrl) == 0 { bad = bad + 1 } } 72 73 w(1, "\n* " as *u8); w(1, name); w(1, " [" as *u8) 74 if kind == RD_SOFTWARE { w(1, "software" as *u8) } 75 if kind == RD_HARDWARE { w(1, "hardware" as *u8) } 76 if kind == RD_HYBRID { w(1, "hybrid" as *u8) } 77 w(1, "]\n TRL " as *u8); wn(1, trl); w(1, ": " as *u8); w(1, rd_trl_name(trl)); w(1, "\n" as *u8) 78 if kind != RD_SOFTWARE { 79 w(1, " MRL " as *u8); wn(1, mrl); w(1, ": " as *u8); w(1, rd_mrl_name(mrl)); w(1, "\n" as *u8) 80 w(1, " next hardware rung: " as *u8); w(1, rd_next_hardware_rung(trl)); w(1, "\n" as *u8) 81 need_hw = need_hw + 1 82 } else { 83 w(1, " next: " as *u8); w(1, rd_trl_exit(rd_next_trl(trl))); w(1, "\n" as *u8) 84 } 85 w(1, " rungs to market: TRL+" as *u8); wn(1, rd_trl_to_market(trl)) 86 if kind != RD_SOFTWARE { w(1, " MRL+" as *u8); wn(1, rd_mrl_to_market(mrl)) } 87 w(1, " market-entry: " as *u8) 88 if rd_market_entry_ready(kind, trl, mrl) == 1 { w(1, "READY" as *u8) } else { w(1, "not yet" as *u8) } 89 w(1, "\n plan: " as *u8); w(1, note); w(1, "\n" as *u8) 90 if rd_market_entry_ready(kind, trl, mrl) == 1 { ready = ready + 1 } 91 } 92 } } 93 } 94 95 w(1, "\n=== SUMMARY: " as *u8); wn(1, total); w(1, " capabilities | market-entry ready: " as *u8); wn(1, ready) 96 w(1, " | need hardware rungs: " as *u8); wn(1, need_hw); w(1, " ===\n" as *u8) 97 if bad == 0 { w(1, "ROADMAP VALID (every rung a real TRL 1-9 / MRL 1-10) verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 98 w(1, "ROADMAP RED: " as *u8); wn(1, bad); w(1, " invalid rung(s)\n" as *u8); sys_exit(1); return 1 99}