code wiki / (root) / nx_citator_gate.nx

nx_citator_gate.nx source

↩ module page · 121 lines · 6970 B

1// nx_citator_gate.nx -- F995 INDEPENDENT GATE: citation treatment signals + the composed safety check. 2// Proves worst-wins (one overruling kills reliance no matter how many followings), the good-law bright 3// line, and the killer composition: a REAL quote from an OVERRULED case is UNSAFE to cite. 4// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 5 6import "nx_citator_lib.nx" 7// D001 MIGRATION 2026-08-16 -- see the sibling note in nx_clm_gate.nx. Three gates in this family each 8// carried a byte-for-byte copy of puts/num/pass-fail/verdict; ★TWO GUARDS FOR ONE INVARIANT IS THE 9// DUPLICATE-RULER DEFECT, and the remedy is to EXTEND THE INCUMBENT, never to keep a third twin alive. 10import "nx_gate_verdict.nx" 11 12func tg_ck(cnt: *i64, name: *u8, got: i64, want: i64) -> i64 { 13 // gv_check owns the counters and the PASS/FAIL word; the VALUES stay, because ★A GATE THAT REPORTS 14 // A BOOLEAN CANNOT SAY WHY. 15 var ok: i64 = 0 16 if got == want { ok = 1 } 17 let r: i64 = gv_check(name, ok, cnt) 18 gv_puts(" got=" as *u8); gv_num(got); gv_puts(" want=" as *u8); gv_num(want); gv_puts("\n" as *u8) 19 return r 20} 21func tg_id(tag: *u8, nonce: i64, out: *u8) -> i64 { 22 var o: i64 = mt_catcopy(out, 0, tag) 23 o = mt_catn(out, o, nonce) 24 out[o] = 0 as u8 25 return o 26} 27 28func main(argc: i64, argv: *i64) -> i64 { 29 // FIXTURE MOVED OUT OF THE SWEPT STORE (2026-08-07). knowledge/store/ is walked every 600s by 30 // the nx_segguard beat; this gate's fixture is one of TEN measured as actually folded by it. A 31 // fold landing mid-run rewrites the manifest under the code being measured, so a RED could not 32 // be attributed. Proven on the sibling defect: the SAME code went RED on a knowledge/store 33 // fixture and GREEN 24/24 on a /tmp one -- the RED tracked the FIXTURE, not the code. 34 // Created at SETUP, not teardown: a teardown does not run when a run crashes. 35 sys_mkdir("/tmp/citatorgate\x00" as *u8, 0x1ed) 36 let pfx: *u8 = "/tmp/citatorgate/citatorgate-" as *u8 37 let nonce: i64 = sys_now_us() 38 let cnt: *i64 = gv_ctr() 39 40 gv_head("NISHI-CITATOR-GATE (F995 treatment signals: is it still good law?)" as *u8) 41 42 // run-unique case ids 43 let good: *u8 = sys_mmap(64) 44 let dead: *u8 = sys_mmap(64) 45 let mixed: *u8 = sys_mmap(64) 46 let caution: *u8 = sys_mmap(64) 47 let unknown: *u8 = sys_mmap(64) 48 let c1: *u8 = sys_mmap(64) 49 let c2: *u8 = sys_mmap(64) 50 let c3: *u8 = sys_mmap(64) 51 tg_id("Good-v-State-" as *u8, nonce, good) 52 tg_id("Dead-v-State-" as *u8, nonce, dead) 53 tg_id("Mixed-v-State-" as *u8, nonce, mixed) 54 tg_id("Caution-v-State-" as *u8, nonce, caution) 55 tg_id("Unknown-v-State-" as *u8, nonce, unknown) 56 tg_id("Later-A-" as *u8, nonce, c1) 57 tg_id("Later-B-" as *u8, nonce, c2) 58 tg_id("Later-C-" as *u8, nonce, c3) 59 60 // build a treatment graph 61 cit_treat_put(pfx, good, c1, "followed" as *u8) 62 cit_treat_put(pfx, good, c2, "followed" as *u8) 63 cit_treat_put(pfx, dead, c1, "overruled" as *u8) 64 cit_treat_put(pfx, caution, c1, "questioned" as *u8) 65 cit_treat_put(pfx, caution, c2, "distinguished" as *u8) 66 // MIXED: followed twice AND overruled once -> worst-wins says OVERRULED 67 cit_treat_put(pfx, mixed, c1, "followed" as *u8) 68 cit_treat_put(pfx, mixed, c2, "followed" as *u8) 69 cit_treat_put(pfx, mixed, c3, "overruled" as *u8) 70 71 // ---- T1: a followed-only case is GOOD LAW ---- 72 tg_ck(cnt, "T1 followed-only case status = 0 (good)" as *u8, cit_status(pfx, good), 0) 73 tg_ck(cnt, "T1a good case IS good law" as *u8, cit_is_good_law(pfx, good), 1) 74 75 // ---- T2: an overruled case is BAD LAW ---- 76 tg_ck(cnt, "T2 overruled case status = 3 (bad)" as *u8, cit_status(pfx, dead), 3) 77 tg_ck(cnt, "T2a overruled case is NOT good law" as *u8, cit_is_good_law(pfx, dead), 0) 78 79 // ---- T3: WORST-WINS. followed x2 + overruled x1 -> OVERRULED dominates ---- 80 tg_ck(cnt, "T3 mixed (2 followed, 1 overruled) status = 3" as *u8, cit_status(pfx, mixed), 3) 81 tg_ck(cnt, "T3a one overruling kills reliance despite the followings" as *u8, cit_is_good_law(pfx, mixed), 0) 82 83 // ---- T4: caution (questioned + distinguished, no overruling) -> worst=2, still good law but flagged ---- 84 tg_ck(cnt, "T4 caution status = 2 (questioned dominates distinguished)" as *u8, cit_status(pfx, caution), 2) 85 tg_ck(cnt, "T4a caution is still good law (not overruled)" as *u8, cit_is_good_law(pfx, caution), 1) 86 tg_ck(cnt, "T4b but it carries a caution flag" as *u8, cit_is_caution(pfx, caution), 1) 87 tg_ck(cnt, "T4c good-law case carries NO caution flag" as *u8, cit_is_caution(pfx, good), 0) 88 89 // ---- T5: an unknown case (no treatment recorded) presumed good law, no caution ---- 90 tg_ck(cnt, "T5 untreated case status = 0" as *u8, cit_status(pfx, unknown), 0) 91 tg_ck(cnt, "T5a untreated case is good law" as *u8, cit_is_good_law(pfx, unknown), 1) 92 93 // ---- T6: THE COMPOSITION. store a real quote for BOTH the good and the dead case ---- 94 let realquote: *u8 = "the statute requires strict compliance" as *u8 95 cite_source_put(pfx, good, "We hold that the statute requires strict compliance in all cases." as *u8) 96 cite_source_put(pfx, dead, "We hold that the statute requires strict compliance in all cases." as *u8) 97 98 // the quote is REAL in both -- cite_ok passes for both 99 tg_ck(cnt, "T6 quote verifies against the good case" as *u8, cite_ok(pfx, good, realquote), 1) 100 tg_ck(cnt, "T6a SAME quote verifies against the dead case too" as *u8, cite_ok(pfx, dead, realquote), 1) 101 102 // ---- T7: THE KILLER. safe_to_cite passes for the good case, REFUSES the overruled one ---- 103 // a real quote from dead law is UNSAFE -- the trap a citator exists to prevent. 104 tg_ck(cnt, "T7 safe-to-cite the GOOD case (real quote + good law)" as *u8, 105 cit_safe_to_cite(pfx, good, realquote), 1) 106 // ★A CONTROL NOBODY CAN FIND IS A CONTROL NOBODY MAINTAINS. These two are the deny-side controls, and 107 // together with T7 they are the DISCRIMINATION proof: each varies ONE signal (good law / real quote) 108 // while holding the other, so an implementation that refuses everything and one that allows 109 // everything both fail. Two tests that each isolate one signal would not prove that. 110 tg_ck(cnt, "neg-control-T7a UNSAFE to cite the OVERRULED case despite the real quote" as *u8, 111 cit_safe_to_cite(pfx, dead, realquote), 0) 112 113 // ---- T8: safe_to_cite also refuses a FABRICATED quote even from a good-law case ---- 114 tg_ck(cnt, "neg-control-T8 fabricated quote from a good case is still UNSAFE" as *u8, 115 cit_safe_to_cite(pfx, good, "the statute is merely advisory" as *u8), 0) 116 117 // ★A GATE WHOSE EXIT CODE DOES NOT CARRY ITS VERDICT SILENTLY BLESSES EVERY FAILURE IT FINDS. 118 let rc: i64 = gv_verdict("citator_gate" as *u8, cnt, "F995 citation treatment signals over nx_citator_lib" as *u8) 119 sys_exit(rc) 120 return rc 121}