code wiki / _hdl_build / nx_sov_guard2.nx
nx_sov_guard2.nx
buildroot/runtime/_hdl_build/nx_sov_guard2.nx
about
nx_sov_guard2.nx -- the NO-NEW-TSV law with a WORKING TOOTH (eats seq279 at the root).
WHY A REWRITE, NOT A PATCH (rule 3): v1 scanned exactly ONE directory and defaulted to `knowledge/status`,
so `knowledge/registry` -- which holds ~150 .tsv including the 3 this session created -- was NEVER SCANNED.
The law existed, the organ existed, the allowlist existed, and none of it could fire on the directory that
mattered. A guard that cannot see the violation is not a guard.
TWO STRUCTURAL FIXES:
1. MULTI-DIR, DATA-DRIVEN scan-set. Dirs come from the native plane knowledge/store/sovguard- (`dir<TAB>path`
rows) -- rule 11, and pointedly NOT from a .tsv (the anti-tsv guard configuring itself with a tsv would be
the joke that writes itself). If the plane is absent the organ still guards using a compiled-in default set
and DECLARES `config:default-set` -- fail-SAFE, because a guard that silently stops guarding is worse than
one that guards loudly with defaults.
2. RATCHET, not a cliff. ~150 legacy files exist; a plain count>0 rule would be RED forever and get ignored
(an alarm nobody can silence is an alarm nobody hears). Instead we compare against a recorded BASELINE and
fail ONLY when the count RISES -- which is exactly what "no NEW tsv" means. Legacy shrinks lane by lane;
a new file trips it the same day. Same snapshot/check idiom as nx_tooldiff / nx_route_diff.
nx_sov_guard2 check -> GREEN if count <= baseline; RED (exit 1) naming the NEW files if it rose
nx_sov_guard2 snapshot -> deliberately re-record the baseline (after a migration lands)
Emits knowledge/status/sov_guard.log with a VERDICT line for the reliability plane.
license_tier: ORIGINAL expect_exit: 0
dependencies 4 imports · 0 importers
imports: nx_store_seed_lib.nxnx_itoa_lib.nxnx_seg_store.nxnx_syscalls.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
| 27 | const SG2_MAGIC_65536: i64 = 65536 |
| 28 | const SG2_MAGIC_4096: i64 = 4096 |
| 29 | const SG2_MAGIC_1024: i64 = 1024 |
| 30 | const SG2_MAGIC_262144: i64 = 262144 |
| 32 | const SG2_PLANE: *u8 = "knowledge/store/sovguard-" |
| 33 | const SG2_ALLOW: *u8 = "knowledge/registry/tsv_allow.list" |
| 34 | const SG2_LOG: *u8 = "knowledge/status/sov_guard.log" |
| 35 | const SG2_CAP: i64 = 1048576 |
functions
| 37 | func sg_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 42 | func sg_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 43 | func sg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 44 | func sg_cat(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a } |
| 45 | func sg_catn(o: *u8, at: i64, v: i64) -> i64 |
| 55 | func sg_ends(name: *u8, suf: *u8) -> i64 |
| 62 | func sg_readfile(path: *u8, buf: *u8, cap: i64) -> i64 |
| 71 | func sg_line_in(buf: *u8, n: i64, name: *u8) -> i64 |
| 91 | func sg_scan_dir(dir: *u8, allow: *u8, an: i64, names: *u8, no: *i64, shown: *i64) -> i64 |
| 128 | func main(argc: i64, argv: *i64) -> i64 |