code wiki / (root) / nx_cachewatch_gate.nx

nx_cachewatch_gate.nx

buildroot/runtime/nx_cachewatch_gate.nx

12037 B229 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_cachewatch_gate.nx -- THE GATE FOR THE WRITE-CACHE AXIS, 2026-09-03. SUBJECT: the BUILT nx_cachewatch elf, forked against fixture /proc trees this gate writes at runtime. It never reads the real /proc, so it is deterministic on any host and cannot pass or fail because of the box it happens to run on -- which matters especially here, since the real host is currently in the RED state and a gate that read it would be indistinguishable from one hardcoded to say RED. T2 IS THE TOOTH THAT CARRIES THE FILE. Fixtures 1 and 2 have BYTE-IDENTICAL cache_info -- both say `mode=WRITE_BACK` -- and differ ONLY in flashcache_progress. If the organ keyed its verdict on `mode` (the obvious field, and the one a reader reaches for first) both would return the same answer and the detector would have read GREEN through the entire outage that motivated it. T2 requires them to DIFFER, so it can only pass on an organ that discriminates on the right field. T3 IS THE POSITIVE CONTROL. T1/T2/T4/T5 all assert a non-GREEN verdict, and a detector hardwired to alarm passes every one. T3 demands a fully healthy tree return GREEN at exit 0. T6 IS THE COUNTER TRAP, AND IT IS THE DEFECT THAT MOTIVATED THE ORGAN. The fixture plants `dirty_writeback_kb=31543788` -- the real live value -- beside `dirty_blocks=0`. A reader that treats the counter as a level reports tens of GB of stranded dirty data on a degraded unmirrored device: an alarming, actionable, WRONG conclusion that this estate's memory recorded once and this organ's author nearly published again. T6 requires the reported level to stay 0 and the counters to be NAMED as refused. Teeth, in order: T1 the live-host condition (cache flushed+disabled, mirror degraded) -> RED, exit 1. T2 DISCRIMINATOR: identical cache_info, progress differs -> AMBER not RED (mode is not the field). T3 POSITIVE CONTROL: a healthy tree -> GREEN, exit 0. T4 an absent flashcache -> UNOBSERVABLE (3), and specifically NOT GREEN. T5 an unreadable progress file -> UNOBSERVABLE, not a cheerful GREEN. T6 COUNTER TRAP: a huge lifetime counter beside dirty_blocks=0 must not become a level. T7 the degraded count reads [2/1] as degraded and leaves [2/2] and [8/8] alone. T8 ANTI-VACUITY: the four verdicts are four DISTINCT exit codes. MEASURED 8/8 GREEN 2026-09-03, bite-proven killed=1 (source 13321 B and deployed subject 23297 B both restored byte-identical). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_tool_run.nx nx_cachewatch_gate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_tool_run.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 ↻ cwg_resolve cwg_exists sys_openat_rd sys_close gv_need 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 gv_puts ↻ gv_num ↻ gv_journal

structs

none

consts

40const CWG_S_A: *u8 = "buildroot/_build/nx_cachewatch.sov.elf" as *u8
41const CWG_S_B: *u8 = "_build/nx_cachewatch.sov.elf" as *u8
42const CWG_S_C: *u8 = "_offc/nx_cachewatch.elf" as *u8
43const CWG_S_D: *u8 = "nx_cachewatch.elf" as *u8
45const CWG_ROOT: *u8 = "/tmp/cachewatch" as *u8
46const CWG_PROC: *u8 = "/tmp/cachewatch/proc" as *u8
47const CWG_FCD: *u8 = "/tmp/cachewatch/proc/flashcache" as *u8
48const CWG_INST: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1" as *u8
49const CWG_CI: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/cache_info" as *u8
50const CWG_PG: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/flashcache_progress" as *u8
51const CWG_ST: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/flashcache_stats" as *u8
52const CWG_MD: *u8 = "/tmp/cachewatch/proc/mdstat" as *u8
53const CWG_ABSENT: *u8 = "/tmp/cachewatch_absent/proc" as *u8
55const CWG_CAP: i64 = 16384
56const CWG_MODE: i64 = 420
57const CWG_DIRMODE: i64 = 0x1ff
59const CWG_GREEN: i64 = 0
60const CWG_RED: i64 = 1
61const CWG_AMBER: i64 = 2
62const CWG_UNOBS: i64 = 3
65const CWG_CI_TXT: *u8 = "ssd_dev=/dev/x disk_dev=/dev/y mode=WRITE_BACK total_blocks=15249408 cached_blocks=14501872 dirty_blocks=0 synced_blocks=0 occupied_blocks=670386 \n"
66const CWG_PG_OFF: *u8 = "status=uncacheable_flush_done initial_num_of_dirty=0 remaining_num_of_dirty=0\n"
67const CWG_PG_ON: *u8 = "status=none initial_num_of_dirty=0 remaining_num_of_dirty=0\n"
68const CWG_MD_DEG: *u8 = "md3 : active raid1 nvme1n1p1[1]\n 976757952 blocks super 1.2 [2/1] [_U]\nmd2 : active raid5 a b\n 1 blocks [8/8] [UUUUUUUU]\n"
69const CWG_MD_OK: *u8 = "md3 : active raid1 nvme0n1p1[0] nvme1n1p1[1]\n 976757952 blocks super 1.2 [2/2] [UU]\nmd2 : active raid5 a b\n 1 blocks [8/8] [UUUUUUUU]\n"
70const CWG_STATS: *u8 = "reads=1 writes=2 dirty_writeback_kb=31543788 dirty_write_hits=43493286 write_hits=44269137\n"

functions

72func cwg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: cwg_writecwg_find
73func cwg_write(path: *u8, s: *u8) -> i64
88func cwg_rm(path: *u8) -> i64 { return __syscall(263, 0 - 100, path, 0, 0, 0, 0) }
called by 1: main
89func cwg_exists(p: *u8) -> i64
called by 1: cwg_resolve calls 2: sys_openat_rdsys_close
95func cwg_resolve() -> *u8
called by 1: main calls 1: cwg_exists
102func cwg_find(buf: *u8, n: i64, needle: *u8) -> i64
called by 1: main calls 1: cwg_slen
118func cwg_run(subj: *u8, verb: *u8, root: *u8, out: *u8, ol: *i64) -> i64
called by 1: main calls 2: sys_mmaptr_run_capture
127func main(argc: i64, argv: *i64) -> i64