code wiki / _hdl_build / nx_envelope_audit.nx
nx_envelope_audit.nx
buildroot/runtime/_hdl_build/nx_envelope_audit.nx
about
nx_envelope_audit.nx -- F227 THE SCALE-ENVELOPE SWEEP (operator scale-law: "every tool DECLARES its
envelope IN ITS OUTPUT -- silent capping is forbidden BY CONSTRUCTION"; editcover row 3 silent-truncation).
A bounded read that never says it was bounded is how a seat (any model) silently believes a partial answer
is the whole answer -- the ark v1 lesson and the nx_debt 64KB blind spot were both this class. This organ
MEASURES the law across the fleet a seat can actually CALL (the registered tool_allowlist rows -- not all
~15k .nx, that is the honest scope: an unregistered organ cannot mislead an agent).
PER ROW: resolve the source from the elf basename -> probe buildroot/runtime/_hdl_build/<base>.nx then
buildroot/runtime/<base>.nx -> classify:
DECLARING = source carries an envelope-declaration marker (envelope | caps: | window_bytes)
SILENT-CAP-CAND = has bounded-read consts (_CAP / _MAX) but NO declaration <- the actionable set
UNBOUNDED-OR-NA = no bounded-read consts found (nothing to declare, or reads are unbounded)
NAME-PROBE-MISS = no <elfbase>.nx in either probe dir. NOT proof of missing source: a tool's elf and
source names can DIVERGE (verified 07-20: nx_fs_write.elf builds from nx_fsops_write.nx). Treat as
'not found BY NAME PROBE' and verify by content before ever claiming a source is lost.
LIAR-KILLED: this is a CANDIDATE detector over source text, never an absolute verdict -- the output says so,
and it reports counts + the candidate list so a human/referee adjudicates. Measurement first; a ratchet
floor comes only AFTER a measured baseline (never a gate on an unmeasured fleet).
2026-08-20 (lane K, failure-detector census) -- THE SILENT-CAP DETECTOR HAD A SILENT CAP.
A row-cap gate wrapped the whole per-row body and the row counter only incremented INSIDE it, so every
allowlist row past the cap was dropped with no counter, no flag and no marker -- and the dogfood line
then printed the cap as a HAND-TYPED literal, which read as a population. MEASURED: the served binary
reported rows=512 against a tool_allowlist.conf of 81243 bytes whose line 906 exists, i.e. it published
a distribution over the HEAD of a sorted file and called it the fleet.
***THE ENFORCER COMMITTED THE DEFECT IT ENFORCES, AND ITS OWN OUTPUT WAS THE ALIBI.***
FIXED HERE: (1) the row gate is REMOVED -- nothing was indexed by the row counter, so the cap bounded
only wall time and bought nothing; (2) every remaining bound is now DERIVED from its own const and
printed, never re-typed in prose (a hand-typed copy of a cap is a second copy of that cap's shape and
the two drift silently); (3) each capped LIST says it is a prefix of its own count; (4) the partition is
printed and reconciled; (5) an incomplete audit exits EA_EXIT_PARTIAL instead of publishing a confident
distribution -- the nx_undefscan rule that a zero from an incomplete scan must still exit non-zero.
DOGFOOD: declares its OWN envelope in its own output, every field derived from the constant it bounds.
nx_envelope_audit [allowlist] [outpath]
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_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
| 37 | const EA_ALLOW: *u8 = "tool_allowlist.conf" as *u8 |
| 38 | const EA_OUT: *u8 = "knowledge/status/envelope_audit.log" as *u8 |
| 39 | const EA_D1: *u8 = "buildroot/runtime/_hdl_build/" as *u8 |
| 40 | const EA_D2: *u8 = "buildroot/runtime/" as *u8 |
| 41 | const EA_ALLOWCAP: i64 = 262144 |
| 42 | const EA_SRCCAP: i64 = 262144 |
| 43 | const EA_REPCAP: i64 = 131072 |
| 44 | const EA_MAXLIST: i64 = 64 |
| 48 | const EA_TAILRESERVE: i64 = 1024 |
| 51 | const EA_EXIT_PARTIAL: i64 = 5 |
| 52 | const EA_NL: i64 = 10 |
| 53 | const EA_TAB: i64 = 9 |
| 54 | const EA_HASH: i64 = 35 |
| 55 | const EA_SLASH: i64 = 47 |
| 56 | const EA_DOT: i64 = 46 |
| 57 | const EA_MODE: i64 = 0x1a4 |
| 58 | const EA_STDOUT: i64 = 1 |
| 59 | const EA_STDERR: i64 = 2 |
| 60 | const EA_PATHCAP: i64 = 512 |
| 61 | const EA_NAMECAP: i64 = 256 |
functions
| 63 | func ea_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 64 | func ea_werr(s: *u8) -> i64 { sys_write(EA_STDERR, s, ea_slen(s)); return 0 } |
| 65 | func ea_puts(b: *u8, off: i64, s: *u8) -> i64 { var o: i64 = off; var j: i64 = 0; while s[j] != (0 as u8) { if o < EA_REPCAP - 8 { b[o] = s[j]; o = o + 1 } j = j + 1 } return o } called by 1: main |
| 66 | func ea_puti(b: *u8, off: i64, v: i64) -> i64 |
| 78 | func ea_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 87 | func ea_has(buf: *u8, n: i64, needle: *u8) -> i64 calls 1: ea_slen |
| 116 | func ea_has_code(buf: *u8, n: i64, needle: *u8) -> i64 |
| 139 | func main(argc: i64, argv: *i64) -> i64 |