code wiki / (root) / nx_printer_census_test.nx

nx_printer_census_test.nx source

↩ module page · 37 lines · 1818 B

1// nx_printer_census_test.nx -- gate for the S-class census grader. Proves the LIAR-KILL: a grade is 2// unreachable without every evidence level beneath it, and EXCEEDS needs a measurement that beats baseline. 3// Unique exit codes per invariant. expect_exit: 0 ; license_tier: ORIGINAL 4 5import "nx_syscalls.nx" 6import "nx_printer_census.nx" 7 8func t_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 9 10func main() -> i64 { 11 // full chain -> EXCEEDS 12 if nx_census_grade(1,1,1,1,1,1) != NX_CEN_EXCEEDS { return 1 } 13 // measured but does NOT beat baseline -> capped LIVE (liar-kill) 14 if nx_census_grade(1,1,1,1,1,0) != NX_CEN_LIVE { return 2 } 15 // live, no measurement -> LIVE (cannot self-score EXCEEDS) 16 if nx_census_grade(1,1,1,1,0,0) != NX_CEN_LIVE { return 3 } 17 // claims measure+beats but NOT live -> capped GATED (liar-kill: no exceed without live) 18 if nx_census_grade(1,1,1,0,1,1) != NX_CEN_GATED { return 4 } 19 // claims everything but NO gate -> capped BUILT 20 if nx_census_grade(1,1,0,1,1,1) != NX_CEN_BUILT { return 5 } 21 // claims live but NO built -> capped SPEC 22 if nx_census_grade(1,0,1,1,1,1) != NX_CEN_SPEC { return 6 } 23 // nothing -> ABSENT 24 if nx_census_grade(0,0,0,0,0,0) != NX_CEN_ABSENT { return 7 } 25 // spec only 26 if nx_census_grade(1,0,0,0,0,0) != NX_CEN_SPEC { return 8 } 27 // gated chain 28 if nx_census_grade(1,1,1,0,0,0) != NX_CEN_GATED { return 9 } 29 30 // sealed-enum sanity 31 if nx_census_is_valid(NX_CEN_EXCEEDS) != 1 { return 20 } 32 if nx_census_is_valid(NX_CEN_N) != 0 { return 21 } 33 if nx_census_is_valid(0 - 1) != 0 { return 22 } 34 35 t_puts("nx_printer_census: PASS (liar-kill: no EXCEEDS without measure+beats; no grade without the full evidence chain)\n") 36 return 0 37}