nx_cachewatch_gate.nx
buildroot/runtime/nx_cachewatch_gate.nx
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
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
structs
| none |
consts
| 40 | const CWG_S_A: *u8 = "buildroot/_build/nx_cachewatch.sov.elf" as *u8 |
| 41 | const CWG_S_B: *u8 = "_build/nx_cachewatch.sov.elf" as *u8 |
| 42 | const CWG_S_C: *u8 = "_offc/nx_cachewatch.elf" as *u8 |
| 43 | const CWG_S_D: *u8 = "nx_cachewatch.elf" as *u8 |
| 45 | const CWG_ROOT: *u8 = "/tmp/cachewatch" as *u8 |
| 46 | const CWG_PROC: *u8 = "/tmp/cachewatch/proc" as *u8 |
| 47 | const CWG_FCD: *u8 = "/tmp/cachewatch/proc/flashcache" as *u8 |
| 48 | const CWG_INST: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1" as *u8 |
| 49 | const CWG_CI: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/cache_info" as *u8 |
| 50 | const CWG_PG: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/flashcache_progress" as *u8 |
| 51 | const CWG_ST: *u8 = "/tmp/cachewatch/proc/flashcache/vgtest_cache_1+volume_1/flashcache_stats" as *u8 |
| 52 | const CWG_MD: *u8 = "/tmp/cachewatch/proc/mdstat" as *u8 |
| 53 | const CWG_ABSENT: *u8 = "/tmp/cachewatch_absent/proc" as *u8 |
| 55 | const CWG_CAP: i64 = 16384 |
| 56 | const CWG_MODE: i64 = 420 |
| 57 | const CWG_DIRMODE: i64 = 0x1ff |
| 59 | const CWG_GREEN: i64 = 0 |
| 60 | const CWG_RED: i64 = 1 |
| 61 | const CWG_AMBER: i64 = 2 |
| 62 | const CWG_UNOBS: i64 = 3 |
| 65 | const 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" |
| 66 | const CWG_PG_OFF: *u8 = "status=uncacheable_flush_done initial_num_of_dirty=0 remaining_num_of_dirty=0\n" |
| 67 | const CWG_PG_ON: *u8 = "status=none initial_num_of_dirty=0 remaining_num_of_dirty=0\n" |
| 68 | const 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" |
| 69 | const 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" |
| 70 | const CWG_STATS: *u8 = "reads=1 writes=2 dirty_writeback_kb=31543788 dirty_write_hits=43493286 write_hits=44269137\n" |
functions
| 72 | func cwg_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 73 | func cwg_write(path: *u8, s: *u8) -> i64 |
| 88 | func cwg_rm(path: *u8) -> i64 { return __syscall(263, 0 - 100, path, 0, 0, 0, 0) } called by 1: main |
| 89 | func cwg_exists(p: *u8) -> i64 |
| 95 | func cwg_resolve() -> *u8 |
| 102 | func cwg_find(buf: *u8, n: i64, needle: *u8) -> i64 |
| 118 | func cwg_run(subj: *u8, verb: *u8, root: *u8, out: *u8, ol: *i64) -> i64 |
| 127 | func main(argc: i64, argv: *i64) -> i64 |