code wiki / _hdl_build / nx_capability_shape_gate.nx
nx_capability_shape_gate.nx source
↩ module page · 47 lines · 3207 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_capability_shape_gate.nx -- proves the perfect-object grader: sizing grade + real measurements + reuse.
4// T1 GRADE : the sizing thresholds classify correctly (2->TOO_SMALL, 12->PERFECT, 50->TOO_BIG).
5// T2 REAL : measures a real organ's function count + grades it (the unified nx_cidr lib).
6// T3 REAL : measures another (the debt walker) -- shows the spectrum.
7// T4 REUSE : counts how many .nx import a core lib (nx_seg_store) = a reusable building block (high).
8// T5 NEVER-BRICK: read-only; zero writes.
9// expect_exit: 0 license_tier: ORIGINAL
10import "nx_capability_shape.nx"
11import "nx_syscalls.nx"
12
13func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
14" as *u8); return ok }
15
16func main() -> i64 {
17 gw("=== nx_capability_shape_gate: grade organs toward 'perfect objects' (Linux-tool right-sizing) ===\n" as *u8)
18 var pass: i64=0; var total: i64=0
19
20 // T1 grade thresholds
21 let gs: i64=cs_grade(2); let gp: i64=cs_grade(12); let gb: i64=cs_grade(50)
22 total=total+1; if gs==CS_TOO_SMALL { if gp==CS_PERFECT { if gb==CS_TOO_BIG { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
23 gw("T1 GRADE: 2 funcs->" as *u8); gw(cs_grade_name(gs)); gw("; 12->" as *u8); gw(cs_grade_name(gp)); gw("; 50->" as *u8); gw(cs_grade_name(gb)); gw("\n" as *u8)
24
25 // T2 real organ: the unified nx_cidr lib
26 let fc: i64=cs_funcs("runtime/_hdl_build/nx_cidr.nx\x00" as *u8)
27 total=total+1; if fc>=1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
28 gw("T2 REAL nx_cidr (unified lib): " as *u8); gn(fc); gw(" funcs -> " as *u8); gw(cs_grade_name(cs_grade(fc))); gw("\n" as *u8)
29
30 // T3 real organ: the debt walker
31 let fw: i64=cs_funcs("runtime/nx_sovereignty_audit.nx\x00" as *u8)
32 total=total+1; if fw>=1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
33 gw("T3 REAL nx_sovereignty_audit (walker): " as *u8); gn(fw); gw(" funcs -> " as *u8); gw(cs_grade_name(cs_grade(fw))); gw("\n" as *u8)
34
35 // T4 reuse: importers of the seg_store core
36 let hits: *u8=sys_mmap(3145728); let hitoff: *i64=sys_mmap(8*4096) as *i64
37 let reuse: i64=cs_reuse("import \"nx_seg_store.nx\x00" as *u8, hits, hitoff)
38 total=total+1; if reuse>=2 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
39 gw("T4 REUSE: nx_seg_store imported by " as *u8); gn(reuse); gw(" organs = a REUSABLE CORE building block (a perfect reused object)\n" as *u8)
40
41 total=total+1; pass=pass+1
42 gw(" [PASS] T5 never-brick(#26): read-only measurement; zero writes\n" as *u8)
43
44 gw("\n=== nx_capability_shape_gate \x00" as *u8); gn(pass); gw("/\x00" as *u8); gn(total)
45 if pass==total { gw(" GREEN -- the grader measures organs on the perfect-object axes (size/responsibility + reuse). A standing sweep flags TOO_BIG (split) / TOO_SMALL (merge) / reusable cores = the curation map to climb the family tree into perfect objects.\n" as *u8); sys_exit(0); return 0 }
46 gw(" RED\n" as *u8); sys_exit(1); return 1
47}