nx_sovereignty_audit.nx
buildroot/runtime/nx_sovereignty_audit.nx
about
nx_sovereignty_audit.nx -- the team's SOVEREIGNTY-PURITY auditor.
module: nishi-core.audit.sovereignty_audit
depends: nishi-core.storage.seg_store, nishi-core.io.syscalls
capability: AUDIT
license_tier: ORIGINAL
MISSION: a sovereignty-obsessed operator needs a sovereignty tool that is
ITSELF perfectly sovereign. This organ recursively walks the WHOLE repo tree
(its OWN bounded getdents64 work-stack -- no find/grep/python/sqlite, no
shelling out, pure .nx), classifies EVERY file's sovereignty status with a
DATA-DRIVEN policy, PERSISTS every PRODUCT-CONTAMINANT (+ a summary) to the
sovereign seg_store so the debt is SEARCHABLE (ss_term later), and SELF-GATES
with a positive + negative control liar-kill before printing GREEN.
CLASSIFICATION (data-driven; the policy IS the tables below):
ext SOVEREIGN = .nx / .md / .nxgate
ext CANDIDATE-NONSOV = .py .sh .js .mjs .ts .tsv .conf .toml .json .css .html
zone FENCED-REFERENCE = path contains /bench/ /.alelane/ /node_modules/
/_scratch/ /.build/ /.git/ (Law-1 allowed reference)
zone PRODUCT = everything else
per-file verdict:
SOVEREIGN = .nx/.md/.nxgate anywhere
FENCED-REFERENCE = candidate-non-sov in a fenced zone (allowed)
PRODUCT-CONTAMINANT = candidate-non-sov in PRODUCT zone (the REAL debt)
product_purity_permil = (n_product_files - n_product_contaminant)*1000
/ n_product_files (files OUTSIDE fenced zones)
LANDMINES DODGED (from the ecosystem's own registry):
- DOUBLE-IMPORT of syscalls -> nxasm rc6. nx_dir.nx imports "syscalls.nx"
(+nx_fcntl+nx_dirent) while nx_seg_store imports "nx_syscalls.nx"; pulling
both double-defines sys_* and fails to build. So this organ imports the
PROVEN-SAFE pair (nx_seg_store + nx_syscalls, the exact set nx_workstream_
store.nx uses) and does its OWN raw getdents64 walk.
- The NxDirent STRUCT path crashes signal-11 under nx_cc_sovereign
(nx_nas_book_census.nx header). So we walk struct-free over raw dirent
bytes via dirent_reclen/dirent_type/dirent_name -- the proven shape.
- JPL bounded-loop discipline: explicit budgets on dirs + files + iters; a
cap HIT is reported LOUD (capped=1), never a silent truncation.
dependencies 2 imports · 0 importers
imports: nx_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
| 42 | const SAV_MAGIC_8192: i64 = 8192 |
| 44 | const SAV_PREFIX: *u8 = "knowledge/store/sovaudit-" |
| 45 | const SAV_LOG: *u8 = "knowledge/status/sovereignty_audit.log" |
| 48 | const SAV_MAX_DIRS: i64 = 60000 // pending-dir stack ceiling |
| 49 | const SAV_MAX_FILES: i64 = 400000 // classified-file ceiling |
| 50 | const SAV_ITER_CAP: i64 = 2000000 // hard dir-pop ceiling (symlink-loop guard) |
| 51 | const SAV_DIRBUF: i64 = 1048576 // getdents64 batch buffer (1 MiB) |
| 52 | const SAV_DIR_ARENA: i64 = 268435456 // 256 MiB of dir-path bytes |
| 53 | const SAV_TOPK: i64 = 15 // contaminant paths echoed to stdout |
| 101 | const SAV_NSOV: i64 = 3 |
| 109 | const SAV_NCAND: i64 = 11 |
| 125 | const SAV_NFENCE: i64 = 18 |
functions
| 56 | func sav_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 57 | func sav_wn(fd: i64, buf: *u8, n: i64) -> i64 { sys_write(fd, buf, n); return 0 } calls 1: sys_write |
| 58 | func sav_n(fd: i64, v: i64) -> i64 |
| 64 | func sav_p(s: *u8) -> i64 { sav_w(1, s); return 0 } |
| 65 | func sav_pn(v: i64) -> i64 { sav_n(1, v); return 0 } |
| 67 | func sav_w2(lfd: i64, s: *u8) -> i64 { sav_w(1, s); if lfd >= 0 { sav_w(lfd, s) } return 0 } |
| 68 | func sav_n2(lfd: i64, v: i64) -> i64 { sav_n(1, v); if lfd >= 0 { sav_n(lfd, v) } return 0 } |
| 70 | func sav_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 73 | func sav_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: sav_ext_of |
| 76 | func sav_streq(a: *u8, b: *u8) -> i64 |
| 84 | func sav_has(hay: *u8, needle: *u8) -> i64 |
| 102 | func sav_sov_ext(i: i64) -> *u8 called by 1: sav_is_sov_ext |
| 110 | func sav_cand_ext(i: i64) -> *u8 |
| 126 | func sav_fence(i: i64) -> *u8 called by 1: sav_is_fenced |
| 155 | func sav_ext_of(name: *u8, extbuf: *u8) -> i64 |
| 168 | func sav_is_sov_ext(extlc: *u8) -> i64 |
| 174 | func sav_is_cand_ext(extlc: *u8) -> i64 |
| 180 | func sav_cand_ext_idx(extlc: *u8) -> i64 |
| 189 | func sav_class_of(ei: i64) -> i64 called by 1: main |
| 205 | func sav_is_fenced(path: *u8) -> i64 |
| 215 | func sav_classify(path: *u8, name: *u8, extbuf: *u8) -> i64 |
| 226 | func sav_vname(v: i64) -> *u8 |
| 235 | func sav_catstr(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ dst[off+i]=s[i]; i=i+1 } return off+i } called by 1: main |
| 236 | func sav_catnum(dst: *u8, off: i64, v: i64) -> i64 |
| 246 | func main() -> i64 |