code wiki / (root) / nx_commons_defect_gate.nx

nx_commons_defect_gate.nx source

↩ module page · 85 lines · 4962 B

1// nx_commons_defect_gate.nx -- proves, against the REAL shipped organs, that the estate's pairwise 2// reciprocity audit SILENTLY STOPS DETECTING EXTRACTION once the flows get large. 3// 4// WHY THIS CALLS THE REAL FUNCTIONS AND NEVER A COPY: a hand-copied differential probe is evidence 5// only if proven character-identical, and this estate has already paid for that lesson -- a copied 6// probe silently FIXED the bug it was meant to expose and exonerated an innocent compiler for four 7// rounds. So this gate imports nx_mycorrhiza.nx and calls nx_my_audit_kind on a real NxMycorrhiza 8// built by the real constructor. If the audit is fixed, this gate goes green without being touched. 9// 10// THE DEFECT (read from source, then made to fire here): 11// nx_my_audit_kind computes (native_gives_q * NX_MAGIC_1024) / foreign_gives_q. 12// native_gives_q * 1024 overflows i64 above ~9.0e15 units. On overflow the product goes NEGATIVE, 13// every `> tolerance` test is false, both net-giver/net-taker tests are false, and the function 14// falls through to OK_BALANCED. 15// IT FAILS TOWARD "NO EXTRACTION DETECTED", AND IT DOES SO ON THE LARGEST FLOWS FIRST. 16// 9.0e15 is 9 PB of DISK_BYTES, or 285 CPU-years of CPU_MICROSECONDS -- reachable by a fleet, and 17// reachable soonest by exactly the actor moving the most volume. 18// 19// T1/T3 are the NEGATIVE CONTROLS: the same extraction at ordinary scale MUST still be caught. If 20// T1/T3 ever fail the fix broke the detector rather than extending it. 21// license_tier: ORIGINAL expect_exit: 0 22import "nx_gate_verdict.nx" 23import "nx_mycorrhiza.nx" 24 25const DG_TOL_Q10: i64 = 2048 // 2.0x slack, the mycorrhiza-style admit window 26const DG_SMALL: i64 = 10000 // ordinary scale 27const DG_HUGE: i64 = 10000000000000000 // 1e16 units -- past the 9.0e15 overflow cliff 28const DG_CAP: i64 = 8 29 30// Build a partnership carrying exactly one give and one take of the named magnitudes, then audit it. 31func dg_audit(native_gives: i64, foreign_gives: i64) -> i64 { 32 let m: *NxMycorrhiza = nx_my_new(1, 7, 9, DG_CAP, DG_TOL_Q10, 0) 33 if (m as i64) == 0 { return 0 - 1 } 34 nx_my_record_flow(m, NX_MY_KIND_DISK_BYTES, NX_MY_DIR_NATIVE_TO_FOREIGN, native_gives, 0, 0, 0) 35 nx_my_record_flow(m, NX_MY_KIND_DISK_BYTES, NX_MY_DIR_FOREIGN_TO_NATIVE, foreign_gives, 0, 0, 0) 36 return nx_my_audit_kind(m, NX_MY_KIND_DISK_BYTES) 37} 38 39func main() -> i64 { 40 let ctr: *i64 = gv_ctr() 41 gv_head("nx_commons_defect_gate -- does the pairwise extraction audit survive large flows?" as *u8) 42 43 // foreign extracts: we give hugely, they give ~nothing -> EXTRACTION_BY_FOREIGN 44 let small_foreign: i64 = dg_audit(DG_SMALL, 1) 45 let huge_foreign: i64 = dg_audit(DG_HUGE, 1) 46 // we extract: they give hugely, we give ~nothing -> EXTRACTION_BY_NATIVE (the ethical refusal) 47 let small_native: i64 = dg_audit(1, DG_SMALL) 48 let huge_native: i64 = dg_audit(1, DG_HUGE) 49 50 gv_puts(" audit(native=1e4, foreign=1) = " as *u8); gv_num(small_foreign) 51 gv_puts(" (want " as *u8); gv_num(NX_MY_V_EXTRACTION_BY_FOREIGN); gv_puts(" EXTRACTION_BY_FOREIGN)\n" as *u8) 52 gv_puts(" audit(native=1e16, foreign=1) = " as *u8); gv_num(huge_foreign) 53 gv_puts(" (want " as *u8); gv_num(NX_MY_V_EXTRACTION_BY_FOREIGN); gv_puts(" -- " as *u8) 54 gv_num(NX_MY_V_OK_BALANCED); gv_puts(" would mean the overflow swallowed it)\n" as *u8) 55 gv_puts(" audit(native=1, foreign=1e4) = " as *u8); gv_num(small_native) 56 gv_puts(" (want " as *u8); gv_num(NX_MY_V_EXTRACTION_BY_NATIVE); gv_puts(" EXTRACTION_BY_NATIVE)\n" as *u8) 57 gv_puts(" audit(native=1, foreign=1e16) = " as *u8); gv_num(huge_native) 58 gv_puts(" (want " as *u8); gv_num(NX_MY_V_EXTRACTION_BY_NATIVE); gv_puts(")\n\n" as *u8) 59 60 var t1: i64 = 0 61 if small_foreign == NX_MY_V_EXTRACTION_BY_FOREIGN { t1 = 1 } 62 gv_check("T1 NEG-CONTROL ordinary scale: foreign extraction IS detected" as *u8, t1, ctr) 63 64 var t2: i64 = 0 65 if huge_foreign == NX_MY_V_EXTRACTION_BY_FOREIGN { t2 = 1 } 66 gv_check("T2 LARGE scale (1e16): foreign extraction still detected (overflow-safe)" as *u8, t2, ctr) 67 68 var t3: i64 = 0 69 if small_native == NX_MY_V_EXTRACTION_BY_NATIVE { t3 = 1 } 70 gv_check("T3 NEG-CONTROL ordinary scale: OUR OWN extraction is refused" as *u8, t3, ctr) 71 72 var t4: i64 = 0 73 if huge_native == NX_MY_V_EXTRACTION_BY_NATIVE { t4 = 1 } 74 gv_check("T4 LARGE scale (1e16): our own extraction still refused (overflow-safe)" as *u8, t4, ctr) 75 76 // A detector that only works below a threshold is not a detector, it is a threshold. 77 var scale_free: i64 = 0 78 if t1 == 1 { if t2 == 1 { if t3 == 1 { if t4 == 1 { scale_free = 1 } } } } 79 gv_check("T5 the audit is SCALE-FREE (same verdict shape at 1e4 and 1e16)" as *u8, scale_free, ctr) 80 81 let rc: i64 = gv_verdict("COMMONS-DEFECT" as *u8, ctr, 82 "pairwise extraction audit holds at fleet-scale magnitudes" as *u8) 83 sys_exit(rc) 84 return rc 85}