code wiki / (root) / nx_printer_exceed.nx

nx_printer_exceed.nx source

↩ module page · 405 lines · 20898 B

1// nx_printer_exceed.nx -- MEASURED head-to-head bakeoffs that FEED the S-class census (nx_printer_census). 2// 3// Per [[feedback-no-wave-measured-exceed]]: "MEASURED-EXCEEDS" must be a real number that beats a defensible 4// baseline -- NEVER self-scored. nx_census_report previously HAND-ASSERTED the (has_measure, beats_baseline) 5// flags for each axis; that is the integrity gap this organ closes. Here the flags are COMPUTED from real 6// measurements over real IPP byte corpora, and a negative control proves a silent/naive stack is REFUSED. 7// 8// AXIS A anti-silent-failure (fault coverage): 9// Build realistic Get-Printer-Attributes responses (the live-Brother single-reason case + multi-fault 10// cases the vendor UI still collapses to ONE headline). Our stack must independently RECOVER (parse) the 11// number of printer-state-reasons present -- it is not told the answer -- and beat the vendor headline 12// (which surfaces exactly 1 condition per response, documented + live-observed: the panel said 13// "Replace Toner" while the IPP carried toner-low-warning + idle + accepting). 14// 15// AXIS B security robustness (defensive parser): 16// Run an ADVERSARIAL corpus (truncated header, value-length overrun, name-length overrun, mid-attribute 17// truncation, oversized 1setOf value) through the real parser and COUNT unsafe outcomes. Unsafe = the 18// parser returned a confident status on malformed bytes (silent-accept), i.e. NOT the sealed UNKNOWN. 19// Ours = 0 by construction (bounds-checked, bounded loops, no shell-out path). Baseline = the DOCUMENTED 20// CVE-2024-47176 cups-browsed unauth RCE class (CVSS 9.9) -- a CITED reference yardstick, NOT run here 21// (running a 9.9 RCE would be reckless), exactly as git was a stated yardstick for the WMS exceed. 22// 23// PURE measurement: builds byte buffers + runs the existing parser/health organs; only syscall is sys_mmap 24// for scratch. never-brick by construction. Sovereign: nx_cc -> nxasm, no gcc. 25// genealogy_id: project-printer-management-ipp-sclass-2026-06-20 ; [[feedback-author-by-organ-not-claude]] 26// license_tier: ORIGINAL 27 28import "nx_syscalls.nx" 29import "nx_ipp_codec.nx" 30import "nx_printer_health.nx" 31import "nx_ipp_submit.nx" 32import "nx_printer_conform.nx" 33const K_MAGIC_2048: i64 = 2048 34const K_MAGIC_2024: i64 = 2024 35const K_MAGIC_47176: i64 = 47176 36 37// ======================= AXIS A: anti-silent-failure (fault coverage) ======================= 38 39// header + printer group + printer-state(enum) + printer-is-accepting-jobs(bool). Caller appends reasons + end. 40func nx_obs_head(buf: *u8, pstate: i64, accepting: i64) -> i64 { 41 let n_pst: *u8 = "printer-state" 42 let n_acc: *u8 = "printer-is-accepting-jobs" 43 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 44 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 45 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), pstate) 46 p = nx_ipp_attr_bool(buf, p, n_acc, nx_ipp_strlen(n_acc), accepting) 47 return p 48} 49 50// CASE 1 -- live-Brother-faithful: idle, accepting, [toner-low-warning] => 1 reason 51func nx_obs_case1(buf: *u8) -> i64 { 52 let n_psr: *u8 = "printer-state-reasons" 53 var p: i64 = nx_obs_head(buf, NX_IPP_PSTATE_IDLE, 1) 54 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "toner-low-warning", 17) 55 return nx_ipp_end(buf, p) 56} 57 58// CASE 2 -- stopped, [media-jam(bare), marker-supply-low-warning, cover-open-warning] => 3 reasons 59func nx_obs_case2(buf: *u8) -> i64 { 60 let n_psr: *u8 = "printer-state-reasons" 61 var p: i64 = nx_obs_head(buf, NX_IPP_PSTATE_STOPPED, 1) 62 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "media-jam", 9) 63 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "marker-supply-low-warning", 25) 64 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "cover-open-warning", 18) 65 return nx_ipp_end(buf, p) 66} 67 68// CASE 3 -- stopped, [media-empty(bare), toner-empty-error] => 2 reasons 69func nx_obs_case3(buf: *u8) -> i64 { 70 let n_psr: *u8 = "printer-state-reasons" 71 var p: i64 = nx_obs_head(buf, NX_IPP_PSTATE_STOPPED, 1) 72 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "media-empty", 11) 73 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "toner-empty-error", 17) 74 return nx_ipp_end(buf, p) 75} 76 77// CASE 4 -- idle, [marker-supply-low-warning, toner-low-report] => 2 reasons 78func nx_obs_case4(buf: *u8) -> i64 { 79 let n_psr: *u8 = "printer-state-reasons" 80 var p: i64 = nx_obs_head(buf, NX_IPP_PSTATE_IDLE, 1) 81 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "marker-supply-low-warning", 25) 82 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "toner-low-report", 16) 83 return nx_ipp_end(buf, p) 84} 85 86func nx_obs_cases() -> i64 { return 4 } // # responses in the corpus 87func nx_obs_ground_total() -> i64 { return 8 } // reasons ENCODED into the corpus (1+3+2+2) -- the oracle 88func nx_obs_baseline_total() -> i64 { return 4 } // documented vendor: exactly ONE headline per response 89 90// MEASUREMENT: our stack independently parses each response and reports its reason count; sum across corpus. 91func nx_obs_ours_total() -> i64 { 92 let sc: *i64 = sys_mmap(64) as *i64 93 let os: *i64 = sys_mmap(16) as *i64 94 let ov: *i64 = sys_mmap(16) as *i64 95 let oc: *i64 = sys_mmap(16) as *i64 96 let oa: *i64 = sys_mmap(16) as *i64 97 let buf: *u8 = sys_mmap(K_MAGIC_2048) 98 var total: i64 = 0 99 var ln: i64 = nx_obs_case1(buf) 100 nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa); total = total + oc[0] 101 ln = nx_obs_case2(buf) 102 nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa); total = total + oc[0] 103 ln = nx_obs_case3(buf) 104 nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa); total = total + oc[0] 105 ln = nx_obs_case4(buf) 106 nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa); total = total + oc[0] 107 return total 108} 109 110// beats iff ours recovers 100% of the reasons present (full fault coverage) AND surfaces strictly more than 111// the headline-only vendor baseline. Either failure -> 0 (no self-scored exceed). 112func nx_obs_beats(ours_total: i64, ground_total: i64, base_total: i64) -> i64 { 113 if ours_total != ground_total { return 0 } 114 if ours_total <= base_total { return 0 } 115 return 1 116} 117 118// ======================= AXIS B: security robustness (defensive parser) ======================= 119 120// ADV 1 -- truncated header (n < 8): cannot even be a message 121func nx_sec_adv1(buf: *u8) -> i64 { 122 buf[0] = 1 as u8; buf[1] = 1 as u8; buf[2] = 0 as u8; buf[3] = 0 as u8; buf[4] = 0 as u8 123 return 5 124} 125 126// ADV 2 -- valid prefix (printer-state) then a printer-state-reasons with a LYING value-length (0x7fff) 127func nx_sec_adv2(buf: *u8) -> i64 { 128 let n_pst: *u8 = "printer-state" 129 let n_psr: *u8 = "printer-state-reasons" 130 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 131 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 132 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_IDLE) 133 buf[p] = NX_IPP_VT_KEYWORD as u8; p = p + 1 134 p = nx_ipp_put_u16(buf, p, 21) 135 p = nx_ipp_memcpy(buf, p, n_psr, 21) 136 p = nx_ipp_put_u16(buf, p, 0x7fff) // lying value-length, no value bytes follow 137 return p 138} 139 140// ADV 3 -- name-length overrun (declares a 0x7fff-byte name with only 1 byte present) 141func nx_sec_adv3(buf: *u8) -> i64 { 142 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 143 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 144 buf[p] = NX_IPP_VT_ENUM as u8; p = p + 1 145 p = nx_ipp_put_u16(buf, p, 0x7fff) // lying name-length 146 buf[p] = 112 as u8; p = p + 1 // a single name byte 147 return p 148} 149 150// ADV 4 -- value-tag present but the attribute is truncated (< 3 bytes remain for name-length) 151func nx_sec_adv4(buf: *u8) -> i64 { 152 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 153 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 154 buf[p] = NX_IPP_VT_ENUM as u8; p = p + 1 155 return p 156} 157 158// ADV 5 -- valid prefix then a 1setOf value whose declared length (100) runs past the buffer 159func nx_sec_adv5(buf: *u8) -> i64 { 160 let n_pst: *u8 = "printer-state" 161 let n_psr: *u8 = "printer-state-reasons" 162 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 163 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 164 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_IDLE) 165 buf[p] = NX_IPP_VT_KEYWORD as u8; p = p + 1 166 p = nx_ipp_put_u16(buf, p, 21) 167 p = nx_ipp_memcpy(buf, p, n_psr, 21) 168 p = nx_ipp_put_u16(buf, p, 100) // claims 100 value bytes ... 169 buf[p] = 120 as u8; p = p + 1 // ... but only 1 is present 170 return p 171} 172 173func nx_sec_adv_count() -> i64 { return 5 } 174func nx_sec_baseline_unsafe() -> i64 { return 1 } // documented CVE-K_MAGIC_2024-K_MAGIC_47176 RCE class (cited reference) 175 176// unsafe = the parser returned a confident verdict on malformed bytes; the safe sealed outcome is UNKNOWN. 177func nx_sec_is_unsafe(verdict: i64) -> i64 { 178 if verdict == NX_PR_UNKNOWN { return 0 } 179 return 1 180} 181 182// MEASUREMENT: run the REAL defensive parser over the adversarial corpus; count unsafe outcomes. 183func nx_sec_ours_unsafe() -> i64 { 184 let sc: *i64 = sys_mmap(64) as *i64 185 let os: *i64 = sys_mmap(16) as *i64 186 let ov: *i64 = sys_mmap(16) as *i64 187 let oc: *i64 = sys_mmap(16) as *i64 188 let oa: *i64 = sys_mmap(16) as *i64 189 let buf: *u8 = sys_mmap(K_MAGIC_2048) 190 var unsafe: i64 = 0 191 var ln: i64 = nx_sec_adv1(buf) 192 unsafe = unsafe + nx_sec_is_unsafe(nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa)) 193 ln = nx_sec_adv2(buf) 194 unsafe = unsafe + nx_sec_is_unsafe(nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa)) 195 ln = nx_sec_adv3(buf) 196 unsafe = unsafe + nx_sec_is_unsafe(nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa)) 197 ln = nx_sec_adv4(buf) 198 unsafe = unsafe + nx_sec_is_unsafe(nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa)) 199 ln = nx_sec_adv5(buf) 200 unsafe = unsafe + nx_sec_is_unsafe(nx_printer_diagnose(buf, ln, sc, os, ov, oc, oa)) 201 return unsafe 202} 203 204// beats iff we produced ZERO unsafe outcomes AND the reference has the documented vulnerability. 205func nx_sec_beats(ours_unsafe: i64, base_unsafe: i64) -> i64 { 206 if ours_unsafe != 0 { return 0 } 207 if base_unsafe < 1 { return 0 } 208 return 1 209} 210 211// NEGATIVE CONTROL: a non-defensive stub that trusts the bytes and always reports "ready" (the silent-accept 212// bug class). Over the same adversarial corpus it is unsafe on EVERY input -> the bakeoff must refuse exceed. 213func nx_sec_naive_verdict(buf: *u8, n: i64) -> i64 { 214 return NX_PR_CAN_PRINT 215} 216 217func nx_sec_naive_unsafe() -> i64 { 218 let buf: *u8 = sys_mmap(K_MAGIC_2048) 219 var unsafe: i64 = 0 220 var ln: i64 = nx_sec_adv1(buf) 221 unsafe = unsafe + nx_sec_is_unsafe(nx_sec_naive_verdict(buf, ln)) 222 ln = nx_sec_adv2(buf) 223 unsafe = unsafe + nx_sec_is_unsafe(nx_sec_naive_verdict(buf, ln)) 224 ln = nx_sec_adv3(buf) 225 unsafe = unsafe + nx_sec_is_unsafe(nx_sec_naive_verdict(buf, ln)) 226 ln = nx_sec_adv4(buf) 227 unsafe = unsafe + nx_sec_is_unsafe(nx_sec_naive_verdict(buf, ln)) 228 ln = nx_sec_adv5(buf) 229 unsafe = unsafe + nx_sec_is_unsafe(nx_sec_naive_verdict(buf, ln)) 230 return unsafe 231} 232 233// ======================= AXIS C: waste / paper (REALIZED two-sided submission) ======================= 234// 235// NOT advisory: our Print-Job ACTUALLY carries sides=two-sided-long-edge (we parse it back from the request 236// bytes below). On a duplex-capable printer (the Brother -- live-confirmed) two-sided HALVES sheets vs the 237// vendor one-sided default. The "realized" guard is the honesty fix: advice-without-submission earns NOTHING. 238 239// realization: build a real Print-Job and confirm it carries sides=two-sided-long-edge. 240func nx_waste_req_carries_duplex() -> i64 { 241 let req: *u8 = sys_mmap(K_MAGIC_2048) 242 let n: i64 = nx_ipp_build_print_job_sides(req, 192, 168, 8, 127, "/ipp/print", "nishi", "duplex", "image/urf", "two-sided-long-edge", 19) 243 return nx_ipp_set_contains(req, n, "sides", "two-sided-long-edge") 244} 245 246// NEG control: the default Print-Job (no sides attr) must NOT carry two-sided. 247func nx_waste_default_carries_duplex() -> i64 { 248 let req: *u8 = sys_mmap(K_MAGIC_2048) 249 let n: i64 = nx_ipp_build_print_job(req, 192, 168, 8, 127, "/ipp/print", "nishi", "plain", "image/urf") 250 return nx_ipp_set_contains(req, n, "sides", "two-sided-long-edge") 251} 252 253// sheets needed for a page count: two-sided = ceil(pages/2); one-sided = pages. 254func nx_sheets_two_sided(pages: i64) -> i64 { return (pages + 1) / 2 } 255func nx_sheets_one_sided(pages: i64) -> i64 { return pages } 256 257func nx_waste_jobs() -> i64 { return 5 } // realistic job-size corpus: 1, 2, 3, 10, 20 pages 258func nx_waste_ours_sheets() -> i64 { 259 return nx_sheets_two_sided(1) + nx_sheets_two_sided(2) + nx_sheets_two_sided(3) + nx_sheets_two_sided(10) + nx_sheets_two_sided(20) 260} 261func nx_waste_vendor_sheets() -> i64 { 262 return nx_sheets_one_sided(1) + nx_sheets_one_sided(2) + nx_sheets_one_sided(3) + nx_sheets_one_sided(10) + nx_sheets_one_sided(20) 263} 264 265// beats iff we ACTUALLY submit two-sided (realized=1) AND use strictly fewer sheets than the vendor default. 266func nx_waste_beats(realized: i64, ours_sheets: i64, vendor_sheets: i64) -> i64 { 267 if realized != 1 { return 0 } 268 if ours_sheets >= vendor_sheets { return 0 } 269 return 1 270} 271 272// ======================= AXIS D: any-printer (vendor-neutral, ONE codebase) ======================= 273// 274// The operator's core goal: a standard that works with ANY printer. The incumbent model needs a SEPARATE 275// per-vendor driver (and Microsoft is removing 3rd-party drivers 2026-27). We prove ONE sovereign codebase 276// correctly diagnoses MULTIPLE vendors' IPP responses. Brother is LIVE hardware (jobs 49-54); HP/Canon/Epson 277// are fixtures built from DOCUMENTED attribute differences (ipp-versions-supported, document-format-supported, 278// printer-state). HONEST: this measures vendor-NEUTRALITY (breadth), with only Brother on real hardware. 279 280func nx_vnd_total() -> i64 { return 4 } 281 282// Build vendor idx's Get-Printer-Attributes response into buf; out_expect[0] = the verdict diagnose MUST return. 283func nx_vnd_build(buf: *u8, idx: i64, out_expect: *i64) -> i64 { 284 let n_pst: *u8 = "printer-state" 285 let n_acc: *u8 = "printer-is-accepting-jobs" 286 let n_psr: *u8 = "printer-state-reasons" 287 let n_df: *u8 = "document-format-supported" 288 let n_iv: *u8 = "ipp-versions-supported" 289 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 290 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 291 if idx == 0 { 292 // Brother DCP-L2540DW (LIVE): idle, toner-low-warning, NO pdf, ipp 1.0 -> DEGRADED 293 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_IDLE) 294 p = nx_ipp_attr_bool(buf, p, n_acc, nx_ipp_strlen(n_acc), 1) 295 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "toner-low-warning", 17) 296 p = nx_ipp_attr(buf, p, NX_IPP_VT_MIMETYPE, n_df, nx_ipp_strlen(n_df), "image/urf", 9) 297 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_iv, nx_ipp_strlen(n_iv), "1.0", 3) 298 out_expect[0] = NX_PR_DEGRADED 299 } 300 if idx == 1 { 301 // HP-style: idle, no reasons, supports application/pdf, ipp 2.0 -> CAN_PRINT 302 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_IDLE) 303 p = nx_ipp_attr_bool(buf, p, n_acc, nx_ipp_strlen(n_acc), 1) 304 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "none", 4) 305 p = nx_ipp_attr(buf, p, NX_IPP_VT_MIMETYPE, n_df, nx_ipp_strlen(n_df), "application/pdf", 15) 306 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_iv, nx_ipp_strlen(n_iv), "2.0", 3) 307 out_expect[0] = NX_PR_CAN_PRINT 308 } 309 if idx == 2 { 310 // Canon-style: stopped, media-jam, supports pdf, ipp 1.1 -> BLOCKED 311 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_STOPPED) 312 p = nx_ipp_attr_bool(buf, p, n_acc, nx_ipp_strlen(n_acc), 1) 313 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "media-jam", 9) 314 p = nx_ipp_attr(buf, p, NX_IPP_VT_MIMETYPE, n_df, nx_ipp_strlen(n_df), "application/pdf", 15) 315 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_iv, nx_ipp_strlen(n_iv), "1.1", 3) 316 out_expect[0] = NX_PR_BLOCKED 317 } 318 if idx == 3 { 319 // Epson-style: idle, marker-supply-low-warning, supports pdf, ipp 2.0 -> DEGRADED 320 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, n_pst, nx_ipp_strlen(n_pst), NX_IPP_PSTATE_IDLE) 321 p = nx_ipp_attr_bool(buf, p, n_acc, nx_ipp_strlen(n_acc), 1) 322 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_psr, nx_ipp_strlen(n_psr), "marker-supply-low-warning", 25) 323 p = nx_ipp_attr(buf, p, NX_IPP_VT_MIMETYPE, n_df, nx_ipp_strlen(n_df), "application/pdf", 15) 324 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, n_iv, nx_ipp_strlen(n_iv), "2.0", 3) 325 out_expect[0] = NX_PR_DEGRADED 326 } 327 return nx_ipp_end(buf, p) 328} 329 330// MEASUREMENT: our ONE codebase -- count vendor profiles whose verdict diagnose() returns CORRECTLY. 331func nx_vnd_ours_handled() -> i64 { 332 let sc: *i64 = sys_mmap(64) as *i64 333 let os: *i64 = sys_mmap(16) as *i64 334 let ov: *i64 = sys_mmap(16) as *i64 335 let oc: *i64 = sys_mmap(16) as *i64 336 let oa: *i64 = sys_mmap(16) as *i64 337 let buf: *u8 = sys_mmap(K_MAGIC_2048) 338 let exp: *i64 = sys_mmap(16) as *i64 339 var handled: i64 = 0 340 var i: i64 = 0 341 while i < 4 { 342 let n: i64 = nx_vnd_build(buf, i, exp) 343 if nx_printer_diagnose(buf, n, sc, os, ov, oc, oa) == exp[0] { handled = handled + 1 } 344 i = i + 1 345 } 346 return handled 347} 348 349// NEG control: a vendor-LOCKED stack that assumes the Brother quirk (ipp-versions contains "1.0") and only 350// accepts responses matching it -> handles just the Brother profile, failing vendor-neutrality. 351func nx_vnd_locked_handled() -> i64 { 352 let buf: *u8 = sys_mmap(K_MAGIC_2048) 353 let exp: *i64 = sys_mmap(16) as *i64 354 var handled: i64 = 0 355 var i: i64 = 0 356 while i < 4 { 357 let n: i64 = nx_vnd_build(buf, i, exp) 358 if nx_ipp_set_contains(buf, n, "ipp-versions-supported", "1.0") == 1 { handled = handled + 1 } 359 i = i + 1 360 } 361 return handled 362} 363 364// beats iff our ONE codebase handles ALL vendor profiles AND beats the vendor-locked stack (the incumbent 365// model = one driver per vendor; Microsoft is removing 3rd-party drivers 2026-27). 366func nx_vnd_beats(ours_handled: i64, locked_handled: i64, total: i64) -> i64 { 367 if ours_handled != total { return 0 } 368 if ours_handled <= locked_handled { return 0 } 369 return 1 370} 371 372// ======================= AXIS E: conformance observability ======================= 373// 374// We surface ACTIONABLE IPP conformance gaps (no-PDF, duplex-default-waste, mono, old-IPP) from the printer's 375// OWN attributes; the vendor UI surfaces NONE of them (it shows status + supplies, not conformance auditing). 376// LIVE-corroborated: a real read of the Brother (nx_printer_conform_live, http 200, 6204B) surfaced 3 gaps -- 377// no-PDF + duplex-default-waste + mono (NOT old-IPP: the live unit DOES advertise 2.0, correcting an old note). 378 379func nx_conf_baseline_surfaced() -> i64 { return 0 } // documented: the vendor UI does NO conformance auditing 380 381// our profiler on the real-Brother-class profile (advertises 2.0 like the live unit; no pdf; duplex but 382// sides-default one-sided; mono) -> 3 actionable gaps, recovered by an INDEPENDENT parse (not asserted). 383func nx_conf_ours_surfaced() -> i64 { 384 let buf: *u8 = sys_mmap(K_MAGIC_2048) 385 let sc3: *i64 = sys_mmap(64) as *i64 386 var p: i64 = nx_ipp_begin(buf, 1, 1, NX_IPP_STATUS_OK, 1) 387 p = nx_ipp_group(buf, p, NX_IPP_GRP_PRINTER) 388 p = nx_ipp_attr_int(buf, p, NX_IPP_VT_ENUM, "printer-state" as *u8, 13, NX_IPP_PSTATE_IDLE) 389 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, "ipp-versions-supported" as *u8, 22, "1.1" as *u8, 3) 390 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "2.0" as *u8, 3) 391 p = nx_ipp_attr(buf, p, NX_IPP_VT_MIMETYPE, "document-format-supported" as *u8, 25, "image/urf" as *u8, 9) 392 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, "sides-supported" as *u8, 15, "one-sided" as *u8, 9) 393 p = nx_ipp_attr_add(buf, p, NX_IPP_VT_KEYWORD, "two-sided-long-edge" as *u8, 19) 394 p = nx_ipp_attr(buf, p, NX_IPP_VT_KEYWORD, "sides-default" as *u8, 13, "one-sided" as *u8, 9) 395 p = nx_ipp_attr_bool(buf, p, "color-supported" as *u8, 15, 0) 396 let n: i64 = nx_ipp_end(buf, p) 397 return nx_conf_gap_count(nx_conf_gaps(buf, n, sc3)) 398} 399 400// beats iff we surface at least one actionable gap AND strictly more than the vendor UI (which surfaces zero). 401func nx_conf_beats(ours_surfaced: i64, baseline_surfaced: i64) -> i64 { 402 if ours_surfaced <= 0 { return 0 } 403 if ours_surfaced <= baseline_surfaced { return 0 } 404 return 1 405}