code wiki / _hdl_build / nx_capability_census.nx

nx_capability_census.nx source

↩ module page · 75 lines · 3446 B

1// nx_capability_census.nx -- LIB: a GENERAL, reusable "study an external tool -> compare to OUR capability 2// census" engine for the Nishi researcher. Point it at ANY subject (a set of sovereign-fetched source files) 3// and ANY capability axis (a competitor-evidence TERM + our implementing-organ path + our exceed-gate path), 4// and per axis it grades, NEVER self-scored: 5// competitor-has = how many of the subject's banked sources attest the term (re_has over the .raw corpus; 6// >=2 = corroborated, >=1 = noted, 0 = unattested) 7// our-grade = EXCEEDS (our exceed-gate opens on disk) > PRESENT (our organ opens) > ABSENT [disk facts] 8// verdict = GAP (they have, we ABSENT) | PARITY (both have) | AHEAD (we EXCEEDS, or we PRESENT & they unattested) 9// Composes the proven nx_game_research_census grading pattern + re_has (nx_research_extract). Adding a new tool 10// or axis = DATA (more rows in the caller), NOT new code -> the researcher's comparison muscle keeps GROWING and 11// is SHARED across domains (EDA today, CAD/DCC/games/metahumans tomorrow -- same engine, different census). 12// Third-party tools are BENCHMARKS ONLY (yardsticks we exceed sovereignly), never dependencies. license_tier: ORIGINAL 13import "nx_syscalls.nx" 14import "nx_research_extract.nx" // re_has / re_find / re_count 15 16// our-side grade codes: 4 EXCEEDS, 3 PRESENT, 0 ABSENT. verdict codes: 0 BOTH-ABSENT, 1 GAP, 2 PARITY, 3 AHEAD. 17 18func cc_file_exists(path: *u8) -> i64 { 19 let fd: i64 = sys_openat_rd(path) 20 if fd < 0 { return 0 } 21 sys_close(fd) 22 return 1 23} 24 25// read up to cap bytes of a file into buf; returns bytes (0 if absent). One read -- adequate for term detection. 26func cc_read_file(path: *u8, buf: *u8, cap: i64) -> i64 { 27 let fd: i64 = sys_openat_rd(path) 28 if fd < 0 { return 0 } 29 let n: i64 = sys_read(fd, buf, cap) 30 sys_close(fd) 31 if n < 0 { return 0 } 32 return n 33} 34 35// competitor attestation: how many of the subject's source files (full paths in paths[]) contain `term`. 36func cc_comp_attest(paths: *i64, npaths: i64, term: *u8, buf: *u8, cap: i64) -> i64 { 37 var hits: i64 = 0 38 var i: i64 = 0 39 while i < npaths { 40 let n: i64 = cc_read_file(paths[i] as *u8, buf, cap) 41 if n > 0 { if re_has(buf, n, term) == 1 { hits = hits + 1 } } 42 i = i + 1 43 } 44 return hits 45} 46 47// our-grade from disk facts ONLY (never self-scored): exceed-gate beats organ beats nothing. 48func cc_our_grade(organ: *u8, exceed: *u8) -> i64 { 49 if cc_file_exists(exceed) == 1 { return 4 } 50 if cc_file_exists(organ) == 1 { return 3 } 51 return 0 52} 53 54// verdict given competitor attestation count + our grade. 55func cc_verdict(comp: i64, our: i64) -> i64 { 56 if comp >= 1 { 57 if our >= 4 { return 3 } // AHEAD: we have a MEASURED exceed-gate 58 if our >= 3 { return 2 } // PARITY: both have it 59 return 1 // GAP: they have it, we are ABSENT 60 } 61 if our >= 3 { return 3 } // AHEAD: we have it, competitor unattested in our corpus 62 return 0 // BOTH-ABSENT / unknown 63} 64 65func cc_grade_str(g: i64) -> *u8 { 66 if g == 4 { return "EXCEEDS" as *u8 } 67 if g == 3 { return "PRESENT" as *u8 } 68 return "ABSENT " 69} 70func cc_verdict_str(v: i64) -> *u8 { 71 if v == 3 { return "AHEAD " as *u8 } 72 if v == 2 { return "PARITY" as *u8 } 73 if v == 1 { return "GAP " as *u8 } 74 return "------" 75}