nx_printer_exceed_gate.nx source
↩ module page · 92 lines · 6393 B
1// nx_printer_exceed_gate.nx -- gate for the measured-exceed bakeoffs (nx_printer_exceed).
2//
3// Proves, with unique exit codes per invariant:
4// AXIS A (anti-silent-failure): our parser independently recovers ALL 8 reasons across the corpus (full
5// fault coverage) and beats the documented vendor headline-only count (4) -> beats=1. NEG controls: a
6// SILENT stack (1 headline per response = 4) does NOT beat; a stack tying the baseline does NOT beat.
7// AXIS B (security robustness): ZERO unsafe outcomes over the 5-case adversarial corpus -> beats the
8// documented CVE-2024-47176 RCE class. NEG controls: a NAIVE trusting parser is unsafe on all 5 -> does
9// NOT beat; a reference with no documented vuln cannot be "beaten".
10// INTEGRATION: feeding the computed (has_measure, beats) into nx_census_grade yields MEASURED-EXCEEDS for
11// both axes -- and ONLY because beats was earned (the grader's liar-kill is intact).
12//
13// expect_exit: 0 ; license_tier: ORIGINAL ; genealogy_id: project-printer-management-ipp-sclass-2026-06-20
14
15import "nx_syscalls.nx"
16import "nx_printer_exceed.nx"
17import "nx_printer_census.nx"
18
19func 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 }
20
21func main() -> i64 {
22 // ===== AXIS A: anti-silent-failure (fault coverage) =====
23 let ours: i64 = nx_obs_ours_total()
24 let ground: i64 = nx_obs_ground_total()
25 let base: i64 = nx_obs_baseline_total()
26 if ours != ground { return 1 } // must recover 100% of reasons (8/8) by real parse
27 if ours <= base { return 2 } // must beat headline-only (8 > 4)
28 if nx_obs_beats(ours, ground, base) != 1 { return 3 }
29 // NEG: a silent stack surfacing 1 headline per response (=4) must NOT earn exceed
30 if nx_obs_beats(nx_obs_cases(), ground, base) != 0 { return 4 }
31 // NEG: full count but only tying the baseline must NOT earn exceed
32 if nx_obs_beats(base, base, base) != 0 { return 5 }
33
34 // ===== AXIS B: security robustness (defensive parser) =====
35 let unsafe: i64 = nx_sec_ours_unsafe()
36 let advc: i64 = nx_sec_adv_count()
37 let bun: i64 = nx_sec_baseline_unsafe()
38 if unsafe != 0 { return 10 } // 0 unsafe outcomes over the adversarial corpus
39 if nx_sec_beats(unsafe, bun) != 1 { return 11 }
40 // NEG: a naive trusting parser is unsafe on EVERY adversarial input -> no exceed
41 if nx_sec_naive_unsafe() != advc { return 12 } // naive accepts all 5 -> 5 unsafe
42 if nx_sec_beats(nx_sec_naive_unsafe(), bun) != 0 { return 13 }
43 // NEG: a reference with no documented vulnerability cannot be "beaten"
44 if nx_sec_beats(0, 0) != 0 { return 14 }
45
46 // ===== AXIS C: waste / paper (REALIZED two-sided submission) =====
47 if nx_waste_req_carries_duplex() != 1 { return 30 } // our Print-Job actually carries two-sided
48 if nx_waste_default_carries_duplex() != 0 { return 31 } // NEG: the default build does not
49 let wo: i64 = nx_waste_ours_sheets()
50 let wv: i64 = nx_waste_vendor_sheets()
51 if wo >= wv { return 32 } // must save paper (19 < 36 sheets)
52 if nx_waste_beats(1, wo, wv) != 1 { return 33 }
53 if nx_waste_beats(0, wo, wv) != 0 { return 34 } // NEG: advisory-only (not realized) -> no exceed
54 if nx_waste_beats(1, wv, wv) != 0 { return 35 } // NEG: realized but no saving -> no exceed
55
56 // ===== AXIS D: any-printer (vendor-neutral, ONE codebase) =====
57 let vh: i64 = nx_vnd_ours_handled()
58 let vl: i64 = nx_vnd_locked_handled()
59 let vt: i64 = nx_vnd_total()
60 if vh != vt { return 40 } // our ONE codebase handles ALL 4 vendor profiles
61 if vl != 1 { return 41 } // the vendor-locked stack handles only Brother
62 if nx_vnd_beats(vh, vl, vt) != 1 { return 42 }
63 if nx_vnd_beats(vl, vl, vt) != 0 { return 43 } // NEG: vendor-locked (1/4) does NOT earn neutrality
64 if nx_vnd_beats(vt, vt, vt) != 0 { return 44 } // NEG: handles all but ties locked=total -> no
65
66 // ===== AXIS E: conformance observability (gaps surfaced vs the vendor UI's zero) =====
67 let cs: i64 = nx_conf_ours_surfaced()
68 let cb: i64 = nx_conf_baseline_surfaced()
69 if cs != 3 { return 50 } // real-Brother-class profile -> 3 actionable gaps
70 if nx_conf_beats(cs, cb) != 1 { return 51 }
71 if nx_conf_beats(0, cb) != 0 { return 52 } // NEG: vendor-equivalent (surfaces 0) -> no exceed
72 if nx_conf_beats(cb, cb) != 0 { return 53 } // NEG: tie with baseline -> no exceed
73
74 // ===== INTEGRATION: the grader flips each axis to EXCEEDS only because beats was EARNED =====
75 if nx_census_grade(1, 1, 1, 1, 1, nx_obs_beats(ours, ground, base)) != NX_CEN_EXCEEDS { return 20 }
76 if nx_census_grade(1, 1, 1, 1, 1, nx_sec_beats(unsafe, bun)) != NX_CEN_EXCEEDS { return 21 }
77 if nx_census_grade(1, 1, 1, 1, 1, nx_waste_beats(1, wo, wv)) != NX_CEN_EXCEEDS { return 23 }
78 if nx_census_grade(1, 1, 1, 1, 1, nx_vnd_beats(vh, vl, vt)) != NX_CEN_EXCEEDS { return 24 }
79 if nx_census_grade(1, 1, 1, 1, 1, nx_conf_beats(cs, cb)) != NX_CEN_EXCEEDS { return 25 }
80 // liar-kill still holds: same chain but beats=0 caps at LIVE
81 if nx_census_grade(1, 1, 1, 1, 1, 0) != NX_CEN_LIVE { return 22 }
82
83 t_puts("nx_printer_exceed: PASS\n")
84 t_puts(" AXIS-A anti-silent-failure: ours recovered 8/8 reasons across corpus vs vendor headline 4 -> BEATS\n")
85 t_puts(" AXIS-B security: unsafe 0/5 on adversarial corpus vs documented CVE-2024-47176 RCE class -> BEATS\n")
86 t_puts(" AXIS-C waste: Print-Job carries sides=two-sided-long-edge -> 19 vs 36 sheets (47% less paper) -> BEATS\n")
87 t_puts(" AXIS-D any-printer: ONE codebase handled 4/4 vendor profiles (Brother+HP+Canon+Epson) vs vendor-locked 1/4 -> BEATS\n")
88 t_puts(" AXIS-E conformance: 3 actionable gaps surfaced vs vendor UI 0 (no conformance auditing) -> BEATS\n")
89 t_puts(" NEG controls (silent, tie, naive, no-vuln-ref, advisory-only, no-saving, vendor-locked, vendor-equiv) all REFUSED\n")
90 t_puts(" INTEGRATION: nx_census_grade -> MEASURED-EXCEEDS for both, and LIVE when beats=0 (liar-kill intact)\n")
91 return 0
92}