code wiki / _hdl_build / nx_cwdguard.nx

nx_cwdguard.nx

buildroot/runtime/_hdl_build/nx_cwdguard.nx

10924 B240 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_cwdguard.nx -- THE STANDING GUARD for the CWD-DEPENDENT-VERDICT class (debt 1785879363). WHAT BIT US (measured 2026-08-04, three separate organs in one session): * nx_swarm_endpoint_lib read knowledge/swarm_nodes.conf relative; the gen daemon runs with CWD=/volume1/ai/gen, so the SSOT silently missed and gen dispatched at a DEAD GPU address. * nx_writebench printed verdict=GREEN coverage=553 from buildroot and result=LIAR claimed-artifacts-missing=8 from nishihost -- the tools-daemon CWD, i.e. EVERY MCP call. * nx_law_warden returned RED "law plane unseeded" and nx_sota_status reported an EMPTY estate (no proven domains at all) purely because of the directory they were launched from. ★★★★★★A VERDICT THAT CHANGES WITH THE CALLER'S WORKING DIRECTORY IS NOT A MEASUREMENT. ★WHY THIS DETECTOR IS STATIC, NOT A DIFFER. The obvious guard -- run each tool from two directories and compare -- is WRONG HERE, and I proved it on myself: comparing output md5 flagged nx_barcheck (a TLS bench whose ms= timings vary per run) and nx_frontier_watch (which APPENDS a row per run, so its base row advances every time) as CWD-fragile when NEITHER IS. It also would EXECUTE mutating organs twice per sweep just to look at them. So this guard reads SOURCE: an organ is AT RISK when it opens an estate path RELATIVE and carries no anchor. That is cheap, deterministic, side-effect-free, and has no false positives from clocks or counters. ⚠HONEST ENVELOPE: at-risk is a RISK, not a proven defect -- an organ whose subject genuinely IS "whatever tree I was pointed at" is CORRECT to read relative. This names candidates for a human or a follow-up differ to adjudicate; it must never be read as a list of confirmed bugs. nx_cwdguard -- scan, print the at-risk roster + verdict nx_cwdguard selftest -- teeth, incl. the NEGATIVE control (an anchored organ is NOT flagged) license_tier: ORIGINAL expect_exit: 0 module: nishi-core.estate.cwdguard

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_estate_path.nx nx_cwdguard.nx

imports: nx_syscalls.nxnx_estate_path.nx

imported by: nobody (leaf or entry point)

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

main cg_selftest ep_anchor sys_openat_rd sys_close sys_chdir sys_mmap sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read sys_close ↻ cg_anchored cg_has cg_w sys_write cg_reads_relative cg_has ↻ cg_n sys_mmap ↻ sys_write ↻ cg_scan ep_anchor ↻ sys_mmap ↻ cg_slurp ep_open_rd sys_openat_rd ↻ sys_mmap ↻ ep_join sys_read ↻ sys_close ↻ cg_w ↻ cg_toolname cg_load_source sys_mmap ↻ cg_slurp ↻ cg_reads_relative ↻ cg_anchored ↻ sys_write ↻

structs

none

consts

30const CG_SCRATCH: i64 = 1048576
31const CG_MAXTOOLS: i64 = 2048
32const CG_NAMECAP: i64 = 64

functions

34func cg_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: cg_scancg_selftest calls 1: sys_write
35func cg_n(v: i64) -> i64
46func cg_slurp(path: *u8, buf: *u8, cap: i64) -> i64
61func cg_has(buf: *u8, n: i64, needle: *u8) -> i64
79func cg_reads_relative(buf: *u8, n: i64) -> i64
called by 2: cg_scancg_selftest calls 1: cg_has
87func cg_anchored(buf: *u8, n: i64) -> i64
called by 2: cg_scancg_selftest calls 1: cg_has
95func cg_toolname(buf: *u8, off: i64, end: i64, name: *u8) -> i64
called by 1: cg_scan
112func cg_load_source(name: *u8, nl: i64, buf: *u8) -> i64
called by 1: cg_scan calls 2: sys_mmapcg_slurp
132func cg_scan() -> i64
195func cg_selftest() -> i64
234func main(argc: i64, argv: *i64) -> i64