code wiki / _hdl_build / nx_lang_maturity.nx

nx_lang_maturity.nx source

↩ module page · 132 lines · 6314 B

1// nx_lang_maturity.nx -- the NISHI-LANG S-CLASS-EXCEED meter (operator: feedback on how 2// the LANGUAGE reaches S-class-exceed, tracked not asserted). Reads lang_panel.tsv 3// (dimension verdicts vs C/Rust/Elm/Java) + lang_lint landmine count, scores a maturity 4// permil, and NAMES the lowest dimensions = the ranked climb. Design-intelligence: the 5// EXCEED dims are the MOAT (keep them); the path is converting the closeable BELOW dims 6// to PARITY/EXCEED via SOVEREIGN-NATIVE answers, not copying incumbents. 7// verdict score: EXCEED=1000 PARITY=600 BELOW=300 GAP=100 8// maturity_permil = avg(dim scores); landmine_count from lang_lint (ergonomic debt) 9// S-CLASS-EXCEED-as-a-language = maturity>=850 WITH all EXCEED dims held + landmines=0 10// Durable: LANGMAT row + the lowest 3 dims -> knowledge/status/lang_maturity.log. 11// Exit 0 = measured. argv[1]=panel override. license_tier: ORIGINAL 12import "nx_syscalls.nx" 13const K_MAGIC_262144: i64 = 262144 14const K_MAGIC_262128: i64 = 262128 15const K_MAGIC_9999: i64 = 9999 16const K_MAGIC_65536: i64 = 65536 17const K_MAGIC_65520: i64 = 65520 18func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 19func _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 } 20func _fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } 21func lm_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 22func lm_read(path: *u8, buf: *u8, cap: i64) -> i64 { 23 let fd: i64 = sys_openat_rd(path) 24 if fd < 0 { return 0 } 25 var n: i64 = 0 26 var go: i64 = 1 27 while go == 1 { let base: i64 = buf as i64; let r: i64 = sys_read(fd, (base + n) as *u8, cap - n); if r <= 0 { go = 0 } else { n = n + r } if n >= cap { go = 0 } } 28 sys_close(fd) 29 return n 30} 31func lm_has(hay: *u8, a: i64, b: i64, pat: *u8) -> i64 { 32 let pl: i64 = lm_len(pat) 33 if pl == 0 { return 0 } 34 var i: i64 = a 35 while i + pl <= b { 36 var k: i64 = 0 37 var hit: i64 = 1 38 while k < pl { if hay[i+k] != pat[k] { hit = 0; k = pl } else { k = k + 1 } } 39 if hit == 1 { return 1 } 40 i = i + 1 41 } 42 return 0 43} 44// copy column 0 (dimension name) of a line into out 45func lm_dim(buf: *u8, a: i64, b: i64, out: *u8) -> i64 { 46 var o: i64 = 0 47 var i: i64 = a 48 while i < b { if buf[i] == (9 as u8) { i = b } else { out[o] = buf[i]; o = o + 1; i = i + 1 } } 49 out[o] = 0 as u8 50 return o 51} 52// [start,end) of column `col` (0-indexed, TAB-delimited) within [a,b); out[0],out[1] 53func lm_col(buf: *u8, a: i64, b: i64, col: i64, out: *i64) -> i64 { 54 // advance p past `col` tabs (clean counter, no loop-var reuse) 55 var p: i64 = a 56 var seen: i64 = 0 57 while seen < col { 58 if p >= b { out[0] = b; out[1] = b; return 0 } 59 if buf[p] == (9 as u8) { seen = seen + 1 } 60 p = p + 1 61 } 62 out[0] = p 63 var e: i64 = p 64 var done: i64 = 0 65 while done == 0 { 66 if e >= b { done = 1 } 67 else { if buf[e] == (9 as u8) { done = 1 } else { e = e + 1 } } 68 } 69 out[1] = e 70 return 0 71} 72func main(argc: i64, argv: *i64) -> i64 { 73 var pp: *u8 = "knowledge/registry/lang_panel.tsv" as *u8 74 if argc >= 2 { pp = argv[1] as *u8 } 75 _p("=== NISHI-LANG MATURITY: the S-class-exceed climb, scored + ranked ===\n" as *u8) 76 let b: *u8 = sys_mmap(K_MAGIC_262144) 77 let n: i64 = lm_read(pp, b, K_MAGIC_262128) 78 if n <= 0 { _p(" lang_panel MISSING -- fail loud\n" as *u8); sys_exit(1); return 1 } 79 let lfd: i64 = sys_openat_append("knowledge/status/lang_maturity.log" as *u8, 0x1a4) 80 if lfd < 0 { _p(" lang_maturity log open failed\n" as *u8); sys_exit(1); return 1 } 81 let dimn: *u8 = sys_mmap(128) 82 var ndim: i64 = 0 83 var sum: i64 = 0 84 var nexceed: i64 = 0 85 var lo1: i64 = K_MAGIC_9999 86 let lo1d: *u8 = sys_mmap(128) 87 var i: i64 = 0 88 while i < n { 89 var le: i64 = i 90 var s: i64 = 1 91 while s == 1 { if le >= n { s = 0 } else { if b[le] == (10 as u8) { s = 0 } else { le = le + 1 } } } 92 if b[i] != (35 as u8) { 93 // verdict is COLUMN 3 (dimension,nishi_status,vs_incumbents,VERDICT,evidence) 94 // -- scan that column ONLY, never the prose (the 1000-on-safety bug) 95 let vc: *i64 = sys_mmap(16) as *i64 96 lm_col(b, i, le, 3, vc) 97 var sc: i64 = 0 - 1 98 if lm_has(b, vc[0], vc[1], "EXCEED" as *u8) == 1 { sc = 1000; nexceed = nexceed + 1 } 99 else { if lm_has(b, vc[0], vc[1], "PARITY" as *u8) == 1 { sc = 600 } 100 else { if lm_has(b, vc[0], vc[1], "BELOW" as *u8) == 1 { sc = 300 } 101 else { if lm_has(b, vc[0], vc[1], "GAP" as *u8) == 1 { sc = 100 } } } } 102 if sc >= 0 { 103 ndim = ndim + 1 104 sum = sum + sc 105 if sc < lo1 { lo1 = sc; lm_dim(b, i, le, lo1d) } 106 lm_dim(b, i, le, dimn) 107 _fp(lfd, "LANGDIM dim=" as *u8); _fp(lfd, dimn); _fp(lfd, " score=" as *u8); _fn(lfd, sc); _fp(lfd, "\n" as *u8) 108 } 109 } 110 i = le + 1 111 } 112 var maturity: i64 = 0 113 if ndim > 0 { maturity = sum / ndim } 114 // landmine count from lang_lint (ergonomic debt drag) 115 let llb: *u8 = sys_mmap(K_MAGIC_65536) 116 let lln: i64 = lm_read("knowledge/status/lang_lint.log" as *u8, llb, K_MAGIC_65520) 117 // grade band 118 var grade: *u8 = "ON-LADDER" as *u8 119 if maturity >= 850 { if nexceed >= 4 { grade = "S-EXCEED-CANDIDATE" as *u8 } } 120 _fp(lfd, "LANGMAT epoch=" as *u8); _fn(lfd, sys_now_realtime_sec()) 121 _fp(lfd, " dims=" as *u8); _fn(lfd, ndim) 122 _fp(lfd, " exceed_dims=" as *u8); _fn(lfd, nexceed) 123 _fp(lfd, " maturity_permil=" as *u8); _fn(lfd, maturity) 124 _fp(lfd, " weakest=" as *u8); _fp(lfd, lo1d as *u8) 125 _fp(lfd, " grade=" as *u8); _fp(lfd, grade) 126 _fp(lfd, " verdict=MEASURED\n" as *u8) 127 sys_close(lfd) 128 _p(" maturity_permil=" as *u8); _fn(1, maturity); _p(" exceed_dims=" as *u8); _fn(1, nexceed) 129 _p(" weakest=" as *u8); _p(lo1d as *u8); _p(" (attack this first)\n" as *u8) 130 sys_exit(0) 131 return 0 132}