code wiki / _hdl_build / nx_gate_fixture_ratchet_gate.nx

nx_gate_fixture_ratchet_gate.nx

buildroot/runtime/_hdl_build/nx_gate_fixture_ratchet_gate.nx

15397 B357 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/prooftopic gate
docsdependenciesstructsconstsfunctions

about

nx_gate_fixture_ratchet_gate.nx -- A GATE MUST NOT SHARE ITS FIXTURE WITH A PRODUCTION BEAT. 2026-08-07, ws=segstore. SIBLING OF nx_gate_dry_ratchet_gate, deliberately built to the same shape: same corpus, same baseline-file convention, same first-run honesty, same gv_bite non-vacuity cell. Only the TOOTH differs. Matching the known good was the point -- a second ratchet that behaved differently would be a second thing to remember, and the whole value of a ratchet is that nobody has to remember it. WHAT IT RATCHETS. A gate that keeps its scratch planes under knowledge/store/ is sharing a directory with the nx_segguard beat, which sweeps every 600s and folds any plane at or above its threshold. MEASURED 2026-08-07T10:01:56: segguard folded `segracegate-real 23 -> 1` WHILE nx_segrace_gate was mid-run, and the gate then reported "COMPACTION STILL ERASES COMMITTED SEGMENTS -- lost 1". A controlled comparison settled it: the SAME code on a /tmp fixture went GREEN 24/24, the pre-change baseline on the knowledge/store fixture went RED. The RED tracked the FIXTURE, not the code. ★★★★★★A GATE THAT SHARES ITS FIXTURE WITH A PRODUCTION BEAT IS MEASURING THE BEAT. ★A RED THAT A THIRD PARTY CAN CAUSE IS NOT A MEASUREMENT OF THE CODE UNDER TEST. WHY A RATCHET AND NOT A LINT-AND-FIX PASS: fixing the 9 gates that carry this today is O(LEAVES) and does nothing about the tenth someone writes tomorrow. The sibling gate says it best -- "a rule nothing must remember beats a list". This fails if they forget. SCOPE -- CORRECTED 2026-08-07, AND THE CORRECTION IS THE POINT. This header first claimed the defect was LATENT: "segguard has folded ZERO of them". That was measured over NINE planes I happened to have to hand, and all nine came back clean. Re-measured over the FULL population of thirty, the sweeper has touched TEN of them -- 57 logged COMPACT/FAIL/DEFER events, `ledgergate` alone 17 and `citatorgate` 9. So the defect is ACTIVE for a third of the population, not latent. ★★★★★★A SAMPLE THAT RETURNS ZERO IS THE EASIEST KIND TO BELIEVE AND THE MOST LIKELY TO BE UNREPRESENTATIVE -- 0/9 read as "no problem", the true rate was 33%. ★★★★★A LATENT DEFECT AND AN ACTIVE ONE ARE DIFFERENT FACTS -- AND YOU DO NOT KNOW WHICH YOU HAVE UNTIL YOU HAVE ASKED THE WHOLE POPULATION. THE TOOTH: count *_gate.nx sources that name a TEST-FIXTURE plane under knowledge/store/. current > baseline -> RED. Someone added a gate whose fixture the sweeper can rewrite. current < baseline -> GREEN, baseline TIGHTENS. The ratchet only ever closes. current == baseline -> GREEN, no change. DETECTOR, and why it is narrow ON PURPOSE: it fires only when the plane NAME following knowledge/store/ contains gate|test|probe|scratch|fixture. A gate that READS a real production plane is legitimate and must not be flagged; a raw "does the source mention knowledge/store/" check counts 124 gate files, of which only 9 are fixtures. The narrow form is the difference

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_gate_fixture_ratchet_gate.n

imports: nx_syscalls.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ fx_enter_buildroot fx_exists sys_openat_rd sys_close sys_chdir sys_mmap ↻ gv_puts ↻ gv_check gv_puts ↻ gv_verdict gv_note_bare_rate gv_bare_rate gv_at gv_obj_has_n gv_at ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap

structs

none

consts

50const FX_DIRBUF: i64 = 262144
51const FX_PATH: i64 = 512
52const FX_SRC: i64 = 262144
53const FX_NAME: i64 = 128
54const FX_RECLEN_OFF: i64 = 16
55const FX_NAME_OFF: i64 = 19
56const FX_MODE: i64 = 420
57const FX_NUM: i64 = 32
58const FX_ZERO: i64 = 48
59const FX_B10: i64 = 10
60const FX_LC_A: i64 = 97
61const FX_LC_Z: i64 = 122
62const FX_D0: i64 = 48
63const FX_D9: i64 = 57
64const FX_DASH: i64 = 45
65const FX_USCORE: i64 = 95
66const FX_BASELINE: *u8 = "knowledge/status/gate_fixture_ratchet.conf"

functions

68func fx_exists(path: *u8) -> i64
75func fx_enter_buildroot() -> i64
called by 1: main calls 2: fx_existssys_chdir
83func fx_cat(dst: *u8, o: i64, s: *u8) -> i64
called by 2: fx_count_dirmain
91func fx_slurp(path: *u8, buf: *u8, cap: i64) -> i64
107func fx_has(hay: *u8, hn: i64, needle: *u8) -> i64
called by 1: fx_marks_fixture
126func fx_marks_fixture(nm: *u8, n: i64) -> i64
called by 1: fx_fixture_in_store calls 1: fx_has
136func fx_fixture_in_store(buf: *u8, n: i64, nm: *u8) -> i64
called by 2: fx_count_dirmain calls 1: fx_marks_fixture
173func fx_is_gate_src(nm: *u8, n: i64) -> i64
called by 1: fx_count_dir
187func fx_count_dir(dir: *u8) -> i64
240func fx_atoi(s: *u8, n: i64) -> i64
255func fx_write_baseline(v: i64) -> i64
272func main(argc: i64, argv: *i64) -> i64