code wiki / _hdl_build / nx_cwdguard.nx
nx_cwdguard.nx
buildroot/runtime/_hdl_build/nx_cwdguard.nx
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
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
structs
| none |
consts
| 30 | const CG_SCRATCH: i64 = 1048576 |
| 31 | const CG_MAXTOOLS: i64 = 2048 |
| 32 | const CG_NAMECAP: i64 = 64 |
functions
| 34 | func 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 } |
| 35 | func cg_n(v: i64) -> i64 |
| 46 | func cg_slurp(path: *u8, buf: *u8, cap: i64) -> i64 |
| 61 | func cg_has(buf: *u8, n: i64, needle: *u8) -> i64 |
| 79 | func cg_reads_relative(buf: *u8, n: i64) -> i64 |
| 87 | func cg_anchored(buf: *u8, n: i64) -> i64 |
| 95 | func cg_toolname(buf: *u8, off: i64, end: i64, name: *u8) -> i64 called by 1: cg_scan |
| 112 | func cg_load_source(name: *u8, nl: i64, buf: *u8) -> i64 |
| 132 | func cg_scan() -> i64 |
| 195 | func cg_selftest() -> i64 |
| 234 | func main(argc: i64, argv: *i64) -> i64 |