code wiki / _hdl_build / nx_gatedry_gate.nx

nx_gatedry_gate.nx source

↩ module page · 58 lines · 3437 B

1// nx_gatedry_gate.nx -- proves the gate-DRY classifier, and DOGFOODS BOTH BASE CLASSES IT ADVOCATES: 2// it emits its verdict through nx_gate_verdict (so this gate is itself an L009 ADOPTER, not a breach), 3// and every tooth is a gv_bite cell (fires on the crafted-bad input, SILENT on the crafted-good one), 4// because a gate that only ever sees one polarity proves nothing. Measured 2026-07-31: gv_bite appears 5// in only 8 of 2167 gate files = 3.7 permil, so most gates cannot tell "it passed" from "it never fired". 6// 7// HERMETIC BY CONSTRUCTION: drives the pure classifier on SYNTHETIC BUFFERS. It writes nothing and reads 8// no shared tree, so it can never disturb the corpus it judges (the fsops-gate lesson). 9// license_tier: ORIGINAL No hw writes (Rule 26). 10import "nx_gatedry_lib.nx" 11import "nx_gate_verdict.nx" 12 13func gdg_cls(s: *u8) -> i64 { return gd_classify(s, gd_len(s)) } 14 15func main() -> i64 { 16 let ctr: *i64 = gv_ctr() 17 gv_head("nx_gatedry -- single-file gate-DRY classifier (ADOPTER / CUSTOM-VERDICT / NO-VERDICT)" as *u8) 18 19 let adopter: *u8 = "func main() -> i64 { let ctr: *i64 = gv_ctr() return gv_verdict(\"X-GATE\" as *u8, ctr, \"note\" as *u8) }" as *u8 20 let handrolled: *u8 = "func main() -> i64 { p(\" verdict=GREEN\") return 0 }" as *u8 21 let anchorless: *u8 = "func main() -> i64 { p(\"AA-GATE GREEN\") return 0 }" as *u8 22 23 var t1bad: i64 = 0 24 if gdg_cls(handrolled) == GD_CUSTOM { t1bad = 1 } 25 var t1good: i64 = 0 26 if gdg_cls(adopter) == GD_CUSTOM { t1good = 1 } 27 gv_bite("T1 a hand-rolled verdict is CUSTOM; a base-class adopter is NOT" as *u8, t1bad, t1good, ctr) 28 29 var t2bad: i64 = 0 30 if gdg_cls(anchorless) == GD_NOVERDICT { t2bad = 1 } 31 var t2good: i64 = 0 32 if gdg_cls(handrolled) == GD_NOVERDICT { t2good = 1 } 33 gv_bite("T2 an anchor-less gate is NO-VERDICT (seq585); one that emits the anchor is NOT" as *u8, t2bad, t2good, ctr) 34 35 // u2605T3 IS THE ORDER TOOTH. A base-class adopter ALSO contains the anchor `verdict=` because gv_verdict 36 // emits it, so a classifier that tested the anchor FIRST would misfile EVERY adopter as the breach -- 37 // it would report the migration TARGET as the defect. This fires the moment that order is reversed. 38 let adopter_with_anchor: *u8 = "gv_verdict(ctr) and also the literal verdict=GREEN appears here" as *u8 39 var t3bad: i64 = 0 40 if gdg_cls(adopter_with_anchor) == GD_ADOPTER { t3bad = 1 } 41 var t3good: i64 = 0 42 if gdg_cls(handrolled) == GD_ADOPTER { t3good = 1 } 43 gv_bite("T3 ORDER: an adopter that ALSO contains verdict= still reads ADOPTER; a hand-rolled one never does" as *u8, t3bad, t3good, ctr) 44 45 var t4: i64 = 0 46 if GD_ADOPTER != GD_CUSTOM { if GD_CUSTOM != GD_NOVERDICT { if GD_NOVERDICT != GD_UNREADABLE { t4 = 1 } } } 47 gv_check("T4 the four verdicts carry DISTINCT exit codes (a caller can branch on them)" as *u8, t4, ctr) 48 49 var t5: i64 = 0 50 if gd_has("hello NEEDLE world" as *u8, 18, "NEEDLE" as *u8) == 1 { t5 = 1 } 51 var t5g: i64 = 0 52 if gd_has("hello world" as *u8, 11, "NEEDLE" as *u8) == 1 { t5g = 1 } 53 gv_bite("T5 the substring primitive finds a present needle and refuses an absent one" as *u8, t5, t5g, ctr) 54 55 let rc: i64 = gv_verdict("NX-GATEDRY-GATE" as *u8, ctr, "single-file gate-DRY classification proven both polarities; order-of-test pinned so an adopter can never be misfiled as the breach" as *u8) 56 sys_exit(rc) 57 return rc 58}