code wiki / _hdl_build / nx_hr_census.nx
nx_hr_census.nx source
↩ module page · 41 lines · 2259 B
1// nx_hr_census.nx -- NISHI HR, rung A: the MATURITY CENSUS that ORGAN-GRADES each HR capability, never self-scored
2// (charter ladder: ABSENT < PRESENT < PARITY < EXCEEDS). The grade is COMPUTED FROM EVIDENCE on disk:
3// - a capability is PRESENT only if its GATE log contains "verdict=GREEN" (proven, not asserted);
4// - PARITY/EXCEEDS require a MEASURED head-to-head record (h2h=parity / h2h=exceeds) vs a named incumbent
5// (HRIS/IAM for the team+user side; a WAF/Cloudflare for the visitor side). LIAR-KILL: gate-green WITHOUT an
6// h2h record caps at PRESENT -- the census cannot promote itself to EXCEEDS by assertion. A missing/RED gate
7// log => ABSENT. So today's honest reading is PRESENT for the built modules, EXCEEDS=0 (no h2h measured yet).
8// license_tier: ORIGINAL
9import "nx_hr.nx" // hr_read (reused)
10import "nx_syscalls.nx"
11const HC_MAGIC_262144: i64 = 262144
12
13const HC_ABSENT: i64 = 0
14const HC_PRESENT: i64 = 1
15const HC_PARITY: i64 = 2
16const HC_EXCEEDS: i64 = 3
17
18// does the file at `path` contain the NUL-terminated `needle`?
19func hc_file_contains(path: *u8, needle: *u8) -> i64 {
20 let buf: *u8 = sys_mmap(HC_MAGIC_262144); let n: i64 = hr_read(path, buf, HC_MAGIC_262144)
21 if n <= 0 { return 0 }
22 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1}
23 if nl <= 0 { return 0 }
24 var i: i64=0
25 while i + nl <= n { var j: i64=0; var m: i64=1; while j<nl { if buf[i+j]!=needle[j] {m=0;j=nl} else {j=j+1} } if m==1 { return 1 } i=i+1 }
26 return 0
27}
28// THE GRADE (organ-computed, liar-kill): ABSENT unless the gate log is GREEN; then PRESENT, lifted to PARITY/
29// EXCEEDS ONLY by a real measured-h2h record. No h2h => capped at PRESENT (cannot self-promote).
30func hc_grade(gate_log: *u8, h2h_path: *u8) -> i64 {
31 if hc_file_contains(gate_log, "verdict=GREEN" as *u8) == 0 { return HC_ABSENT }
32 if hc_file_contains(h2h_path, "h2h=exceeds" as *u8) == 1 { return HC_EXCEEDS }
33 if hc_file_contains(h2h_path, "h2h=parity" as *u8) == 1 { return HC_PARITY }
34 return HC_PRESENT
35}
36func hc_grade_name(g: i64) -> *u8 {
37 if g == HC_EXCEEDS { return "EXCEEDS" as *u8 }
38 if g == HC_PARITY { return "PARITY" as *u8 }
39 if g == HC_PRESENT { return "PRESENT" as *u8 }
40 return "ABSENT" as *u8
41}