code wiki / _hdl_build / nx_refcorpus_gate.nx

nx_refcorpus_gate.nx source

↩ module page · 67 lines · 4398 B

1// nx_refcorpus_gate.nx -- PROVE THE PUBLISHED PROMISES ARE WALLS, NOT PROSE. 2// 3// /code/research_reciprocal_corpus_program tells the public two things: we retain ZERO asset 4// bytes from any reference corpus, and we publish only AGGREGATE statistics that cannot describe 5// one creator's work. This gate exists so neither sentence has to be believed. 6// 7// ★A GUARANTEE THAT ONLY PASSES IS NOT A GUARANTEE. Every tooth here has BOTH polarities in-run: 8// a legitimate measurement must be ADMITTED and a payload-shaped value must be REFUSED, with the 9// SPECIFIC reason code asserted. A contract that accepted everything would pass a "does a real 10// fact get in?" test perfectly while protecting nothing -- so each admission tooth is paired with 11// the refusal that gives it meaning. 12// license_tier: ORIGINAL No hw writes (Rule 26). 13import "nx_syscalls.nx" 14import "nx_gate_verdict.nx" 15import "nx_refcorpus.nx" 16 17func rg_mkstr(n: i64, ch: i64) -> *u8 { 18 let s: *u8 = sys_mmap(n + 8) 19 var i: i64 = 0 20 while i < n { s[i] = ch as u8; i = i + 1 } 21 s[n] = 0 as u8 22 return s 23} 24 25func main(argc: i64, argv: *i64) -> i64 { 26 let ctr: *i64 = gv_ctr() 27 gv_head("nx_refcorpus_gate -- the zero-asset-bytes and aggregate-only promises, as mechanical walls" as *u8) 28 29 // T1 a real measurement is admitted. Without this the contract could be a brick wall that 30 // protects everything by permitting nothing, which is a different failure, not a success. 31 let ok1: i64 = rc_admit("14164" as *u8, 50) 32 gv_check("T1 A LEGITIMATE MEASUREMENT PASSES: a plain short numeric fact with an adequate sample size is admitted -- the contract is a filter, not a brick wall" as *u8, (ok1 == 0) as i64, ctr) 33 34 // T2 the length wall: payload is long, a measurement is not. 35 let big: *u8 = rg_mkstr(400, 65) 36 let r2: i64 = rc_admit(big, 50) 37 gv_check("T2 PAYLOAD-LENGTH WALL FIRES: a 400-character value is refused with the length reason -- a texture, a mesh, or any fragment of one cannot enter the corpus store" as *u8, (r2 == 0 - 1) as i64, ctr) 38 39 // T3 the alphabet wall: base64 and binary carry bytes a measurement never needs. '=' (padding) 40 // and '+' are outside the plain alphabet, so an encoded blob is refused on CONTENT even at a 41 // length that would otherwise pass -- the two walls are independent, not one wall twice. 42 let r3: i64 = rc_admit("iVBORw0KGgoAAAANSUhEUg==" as *u8, 50) 43 gv_check("T3 ENCODED-PAYLOAD WALL FIRES INDEPENDENTLY: a short base64 blob is refused on its ALPHABET, so shortening a payload does not smuggle it past the length wall" as *u8, (r3 == 0 - 2) as i64, ctr) 44 45 // T4 the k-anonymity floor: the aggregate-only promise. 46 let r4: i64 = rc_admit("172.5" as *u8, 3) 47 gv_check("T4 K-ANONYMITY FLOOR FIRES: a perfectly plain statistic drawn from too few sources is refused -- this is the promise that a published distribution can never describe one creator's asset" as *u8, (r4 == 0 - 3) as i64, ctr) 48 49 // T5 the floor is a BOUNDARY, not a mood: one sample below refuses, exactly at the floor admits. 50 let below: i64 = rc_admit("172.5" as *u8, 7) 51 let at: i64 = rc_admit("172.5" as *u8, 8) 52 var t5: i64 = 0 53 if below == 0 - 3 { if at == 0 { t5 = 1 } } 54 gv_check("T5 THE FLOOR IS AN EXACT BOUNDARY: n=7 refused and n=8 admitted, so the k-anonymity rule is a measured threshold rather than an approximate discouragement" as *u8, t5, ctr) 55 56 // T6 empty is refused too -- an unset value silently stored as blank is a fact nobody measured. 57 let r6: i64 = rc_admit("" as *u8, 50) 58 gv_check("T6 AN EMPTY VALUE IS REFUSED: a blank fact is an unmeasured fact, and storing one would put a claim in the corpus that no measurement supports" as *u8, (r6 == 0 - 4) as i64, ctr) 59 60 // T7 the reasons are DISTINCT. If two walls returned one code, a caller could not tell which 61 // guarantee fired, and the gate above would be asserting a coincidence rather than a contract. 62 var t7: i64 = 0 63 if r2 != r3 { if r3 != r4 { if r4 != r6 { if r2 != r4 { t7 = 1 } } } } 64 gv_check("T7 EACH WALL REPORTS A DISTINCT REASON: length, alphabet, sample-size and empty are separately identifiable, so a refusal names WHICH promise it enforced" as *u8, t7, ctr) 65 66 return gv_verdict("REFCORPUS-GATE" as *u8, ctr, "zero-asset-bytes and aggregate-only are enforced walls with both polarities proven in-run" as *u8) 67}