code wiki / _hdl_build / nx_symdrop.nx

nx_symdrop.nx

buildroot/runtime/_hdl_build/nx_symdrop.nx

37029 B776 linesdepth 3pulls 3 transitivereach 2 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_symdrop.nx -- catch SILENT SYMBOL LOSS in shared sources (seq1407 root fix). THE DEFECT CLASS, witnessed three times: a session lands a source change, verifies it LIVE, and a sibling later writes back a stale WHOLE-FILE copy that erases it. The running binary keeps serving the fix, so every health check stays green -- and the revert only detonates at the NEXT rebuild, silently restoring the old behaviour with NO failing test. My own seq1318 supervisor fix was erased this way 25 minutes after I proved it live (diff against my pre-edit original: ZERO lines = a pure stale-copy write-back, not a competing edit). WHY THIS SHAPE: a fix that must be REMEMBERED at N write sites is not a fix -- and the writes arrive through many doors (nx_fs_write, ssh redirects, treepack unpack, cron rewrites). So bind the check to the one property they all share: after any of them, the FILE'S SYMBOL SET either kept everything it had, or something was removed. Removal is the signal. Additions are normal and ignored. FAIL-CLOSED, and deliberately NOT auto-healing: an unreadable/vanished watched file is itself the defect, so it is reported RED rather than skipped; and nothing here ever rewrites a source. A real removal is legitimised by an explicit `bless`, which makes an intentional deletion a deliberate, recorded act instead of an indistinguishable accident. nx_symdrop check [watchconf] [snapfile] -- compare live symbols vs the snapshot; exit 1 on ANY drop nx_symdrop bless [watchconf] [snapfile] -- accept current symbols as the new baseline nx_symdrop list [watchconf] -- show what is watched and each file's symbol count license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_itoa_lib.nx nx_symdrop.nx nx_symdrop_gate.nx nx_treepack.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nx_symdrop_gate.nxnx_treepack.nx

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

main sd_werr sys_write sd_slen sys_exit sys_mmap sd_read sys_openat_rd sys_read sys_close sd_eqs sd_puts sys_write ↻ sd_slen ↻ sd_symbols sd_starts sd_slen ↻ sd_identch sd_bodies sd_declkw sd_starts ↻ sd_bhash sd_emit_pair sys_mmap ↻ sd_identch ↻ sd_putn nxi_out nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap sd_fnv1a sd_hist_probe sd_slen ↻ sd_hist_line_b sys_mmap ↻ sd_hist_write sys_openat_append sys_write ↻

structs

none

consts

27const SD_SRCCAP: i64 = 2097152 // largest guarded source (nx_hostctl.nx measured ~281KB) with headroom
28const SD_SYMCAP: i64 = 1048576 // symbol csv per file
29const SD_SNAPCAP: i64 = 8388608 // whole snapshot file
30const SD_CONFCAP: i64 = 65536
31const SD_PATHCAP: i64 = 1024
32const SD_NAMECAP: i64 = 256
33const SD_NL: i64 = 10
34const SD_TAB: i64 = 9
35const SD_COMMA: i64 = 44
36const SD_HASH: i64 = 35
37const SD_SPACE: i64 = 32
38const SD_STDOUT: i64 = 1
39const SD_STDERR: i64 = 2
40const SD_MODE: i64 = 420
41const SD_EXIT_DROP: i64 = 1
42const SD_EXIT_USAGE: i64 = 2
43const SD_EXIT_REFUSED: i64 = 3
44const SD_EXIT_IO: i64 = 4
45const SD_DEF_CONF: *u8 = "knowledge/symdrop_watch.conf" as *u8
46const SD_DEF_SNAP: *u8 = "knowledge/symdrop_snapshot.tsv" as *u8
47const SD_DEF_HIST: *u8 = "knowledge/symdrop_history.tsv" as *u8
48const SD_FNV_OFF: i64 = 1469598103934665603
49const SD_FNV_PRIME: i64 = 1099511628211
296const SD_BODYCAP: i64 = 1048576
297const SD_EQ: i64 = 61
298const SD_MAXGEN: i64 = 256 // generations compared per declaration; bounded, and a longer history simply compares its most recent 256

functions

68func sd_fnv1a(b: *u8, n: i64) -> i64
called by 2: mainmain
79func sd_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
80func sd_puts(s: *u8) -> i64 { sys_write(SD_STDOUT, s, sd_slen(s)); return 0 }
called by 1: main calls 2: sys_writesd_slen
81func sd_werr(s: *u8) -> i64 { sys_write(SD_STDERR, s, sd_slen(s)); return 0 }
called by 1: main calls 2: sys_writesd_slen
86func sd_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
87func sd_eqs(a: *u8, b: *u8) -> i64
called by 1: main
93func sd_read(path: *u8, b: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
106func sd_write(path: *u8, b: *u8, n: i64) -> i64
115func sd_starts(buf: *u8, at: i64, n: i64, lit: *u8) -> i64
called by 2: sd_symbolssd_declkw calls 1: sd_slen
123func sd_identch(c: i64) -> i64
called by 2: sd_symbolssd_bodies
136func sd_symbols(src: *u8, n: i64, out: *u8, cap: i64) -> i64
183func sd_has(csv: *u8, cn: i64, name: *u8, nl: i64) -> i64
called by 3: mainmaintp_unpack
205func sd_hist_probe(hist: *u8, hn: i64, path: *u8, h: i64, out3: *i64) -> i64
called by 2: mainmain calls 1: sd_slen
247func sd_hist_line(dst: *u8, off: i64, path: *u8, h: i64) -> i64 { return sd_hist_line_b(dst, off, path, h, 0 as *u8, 0) }
called by 1: sd_hist_append calls 1: sd_hist_line_b
248func sd_hist_line_b(dst: *u8, off: i64, path: *u8, h: i64, bodies: *u8, bn: i64) -> i64
called by 2: sd_hist_linemain calls 1: sys_mmap
266func sd_hist_write(histp: *u8, buf: *u8, n: i64) -> i64
275func sd_hist_append(histp: *u8, path: *u8, h: i64) -> i64
301func sd_bhash(src: *u8, s: i64, e: i64) -> i64
called by 1: sd_bodies
308func sd_declkw(src: *u8, ls: i64, n: i64) -> i64
called by 1: sd_bodies calls 1: sd_starts
318func sd_bodies(src: *u8, n: i64, out: *u8, cap: i64) -> i64
361func sd_emit_pair(out: *u8, off: i64, cap: i64, src: *u8, ns: i64, ne: i64, h: i64) -> i64
called by 1: sd_bodies calls 1: sys_mmap
381func sd_body_of(csv: *u8, cn: i64, name: *u8, nl: i64) -> i64
called by 1: sd_bodies_reverted
415func sd_hist_field3(hist: *u8, ls: i64, le: i64, out2: *i64) -> i64
called by 1: sd_bodies_reverted
433func sd_bodies_reverted(hist: *u8, hn: i64, path: *u8, cur: *u8, cn: i64, firstnm: *u8) -> i64
504func sd_snap_find(snap: *u8, sn: i64, path: *u8, out2: *i64) -> i64
called by 1: main calls 1: sd_slen
532func main(argc: i64, argv: *i64) -> i64