code wiki / (root) / nx_underridge_nevergate.nx

nx_underridge_nevergate.nx source

↩ module page · 85 lines · 6112 B

1// nx_underridge_nevergate.nx -- the NEVER-BREAK-THE-TOILET gate. Rule 26 ("never brick the 2// electronics") in PHYSICAL form: the porcelain GLAZE is the brand-critical hardware, and the 3// cleaner must be UNABLE to crack/scratch it -- proven MECHANICALLY here, never asserted as a 4// promise. Every check is computed from the part's real design parameters (mm; sigma in 5// MPa = N/mm^2, so bending force comes out directly in newtons). 6// 7// NB1 GLAZE-CONTACT = PAD ONLY : pad stands proud of the printed lip -> only the soft, 8// glaze-safe pad ever touches porcelain (no plastic, no metal). 9// NB2 NO SHARP EDGES : every glaze-facing edge is filleted >= min radius. 10// NB3 CANNOT WEDGE : head stack + clearance <= measured rim gap (won't jam/crack). 11// NB4 SACRIFICIAL NECK : the neck yields BELOW any rim-cracking pry force, yet ABOVE 12// real scrub force -> the TOOL breaks before the toilet does. 13// NB5 GLAZE-SAFE CHEMISTRY : non-scratch pad declared + never bleach+acid. 14// NB6 SECURE MOUNT : >=1 mount point so the head can't drop into the bowl. 15// 16// The gate is LIAR-KILLABLE: it runs the REAL params (must be all-GREEN) AND a TAMPERED set 17// (thin pad + over-thick neck) which it must correctly flag RED. Green only if it discriminates. 18// expect_exit: 0 license_tier: ORIGINAL 19import "nx_syscalls.nx" 20 21func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 22func gn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-\x00" as *u8,1);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } 23 24// returns 1 if EVERY never-break check passes for these params; prints each line if verbose. 25func nb_eval(head_thick: i64, pocket_depth: i64, pad_thick: i64, edge_fillet: i64, 26 rim_gap_min: i64, clearance: i64, neck_w: i64, neck_t: i64, neck_len: i64, 27 sigma_mpa: i64, scrub_min: i64, pry_max: i64, 28 pad_safe: i64, no_bleach_acid: i64, mount_holes: i64, verbose: i64) -> i64 { 29 var allok: i64 = 1 30 31 // NB1: pad proud of the lip (pad_thick - pocket_depth) >= 2mm margin 32 let proud: i64 = pad_thick - pocket_depth 33 var nb1: i64 = 0; if proud >= 2 { nb1 = 1 } 34 if nb1 == 0 { allok = 0 } 35 if verbose==1 { if nb1==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB1 glaze-contact=pad-only: pad proud of lip = \x00" as *u8); gn(proud); gw("mm (>=2)\n" as *u8) } 36 37 // NB2: filleted edges 38 var nb2: i64 = 0; if edge_fillet >= 1 { nb2 = 1 } 39 if nb2 == 0 { allok = 0 } 40 if verbose==1 { if nb2==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB2 no sharp edges: fillet = \x00" as *u8); gn(edge_fillet); gw("mm (>=1)\n" as *u8) } 41 42 // NB3: stack fits the rim gap. pad_top = (head_thick - pocket_depth) + pad_thick 43 let stack: i64 = (head_thick - pocket_depth) + pad_thick 44 var nb3: i64 = 0; if stack + clearance <= rim_gap_min { nb3 = 1 } 45 if nb3 == 0 { allok = 0 } 46 if verbose==1 { if nb3==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB3 cannot wedge: stack \x00" as *u8); gn(stack); gw("mm + clearance \x00" as *u8); gn(clearance); gw(" <= rim gap \x00" as *u8); gn(rim_gap_min); gw("mm\n" as *u8) } 47 48 // NB4: sacrificial neck. F_yield = sigma * b * h^2 / (6 L) (mm + MPa -> N) 49 let fyield: i64 = (sigma_mpa * neck_w * neck_t * neck_t) / (6 * neck_len) 50 var nb4: i64 = 0; if fyield >= scrub_min { if fyield <= pry_max { nb4 = 1 } } 51 if nb4 == 0 { allok = 0 } 52 if verbose==1 { if nb4==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB4 sacrificial neck: F_yield = \x00" as *u8); gn(fyield); gw("N (band \x00" as *u8); gn(scrub_min); gw("..\x00" as *u8); gn(pry_max); gw("N: survives scrub, yields before a rim-crack pry)\n" as *u8) } 53 54 // NB5: glaze-safe chemistry declared 55 var nb5: i64 = 0; if pad_safe == 1 { if no_bleach_acid == 1 { nb5 = 1 } } 56 if nb5 == 0 { allok = 0 } 57 if verbose==1 { if nb5==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB5 glaze-safe chemistry: pad_safe=\x00" as *u8); gn(pad_safe); gw(" no_bleach_acid=\x00" as *u8); gn(no_bleach_acid); gw("\n" as *u8) } 58 59 // NB6: secure mount 60 var nb6: i64 = 0; if mount_holes >= 1 { nb6 = 1 } 61 if nb6 == 0 { allok = 0 } 62 if verbose==1 { if nb6==1 { gw(" [ok] " as *u8) } else { gw(" [X] " as *u8) } gw("NB6 secure mount: mount points = \x00" as *u8); gn(mount_holes); gw(" (>=1, can't drop in bowl)\n" as *u8) } 63 64 return allok 65} 66 67func main() -> i64 { 68 gw("=== nx_underridge_nevergate: NEVER BREAK THE TOILET (Rule 26, physical) ===\n" as *u8) 69 var pass: i64 = 0; var total: i64 = 0 70 71 // --- REAL shipped parameters (must be all-GREEN) --- 72 gw(" REAL part parameters:\n" as *u8) 73 let real_ok: i64 = nb_eval(6, 3, 10, 2, 22, 3, 16, 6, 45, 25, 30, 120, 1, 1, 2, 1) 74 total=total+1; if real_ok==1 { pass=pass+1; gw(" [PASS] real params: ALL never-break checks GREEN\n" as *u8) } else { gw(" [FAIL] real params did NOT all pass\n" as *u8) } 75 76 // --- TAMPERED parameters (must be flagged RED): thin pad (lip would touch glaze) + 77 // over-thick neck (becomes a rim-cracking pry bar) --- 78 gw(" TAMPERED parameters (thin pad + over-thick neck):\n" as *u8) 79 let tamper_ok: i64 = nb_eval(6, 3, 2, 2, 22, 3, 16, 12, 45, 25, 30, 120, 1, 1, 2, 1) 80 total=total+1; if tamper_ok==0 { pass=pass+1; gw(" [PASS] tamper correctly flagged RED (gate is non-vacuous)\n" as *u8) } else { gw(" [FAIL] tamper slipped through -> gate is vacuous\n" as *u8) } 81 82 gw("\n=== nx_underridge_nevergate " as *u8); gn(pass); gw("/" as *u8); gn(total) 83 if pass == total { gw(" GREEN (never-break proven MECHANICALLY: real=safe, tamper=caught -- the tool cannot break the toilet)\n" as *u8); sys_exit(0); return 0 } 84 gw(" RED\n" as *u8); sys_exit(1); return 1 85}