code wiki / _hdl_build / nx_vecfetch.nx
nx_vecfetch.nx
buildroot/runtime/_hdl_build/nx_vecfetch.nx
about
nx_vecfetch.nx -- ACQUIRE EXTERNAL ANSWERS WITH THE AGENT OUT OF THE BYTE PATH.
THE HOLE THIS CLOSES (measured 2026-07-31): every clause in the evidence apparatus verifies the
COMPARISON and none verifies the PROVENANCE OF THE ANSWERS. An agent can write a gate against
"RFC 8032 test vectors" by typing them from its own recall -- it compiles, runs GREEN, and yields a row
with a real ref=, a real refdig= and a real execution. refdig= commits to the bytes we compared against;
it CANNOT prove those bytes came from the IETF rather than from the model that wrote the file.
============================ v2, 2026-07-31: TWO DEFECTS FOUND AND FIXED ============================
⚠DEFECT 1 -- I HASHED THE ENVELOPE, NOT THE DOCUMENT. v1 hashed whatever nx_https_get returned. By
contract that is the ENTIRE HTTP RESPONSE: status line, headers, and chunked-transfer framing. So all 14
pinned "authority documents" were HTTP WIRE TRANSCRIPTS -- rfc2202.txt carried 707 bytes of Cloudflare
headers and a `2ea6` chunk-size line before the RFC even began. nx_extvec_authentic_gate now reports
14/14 CONTAMINATED against the v1 corpus. Verified against a stack sharing no code (.NET WebClient):
chunk size 0x2ea6 = 11942 = the true document length exactly.
★★★★★ THE LAW v1 GOT WRONG, CORRECTED:
v1 said "hash the bytes before anything touches them". That is too crude -- it hashes the ENVELOPE.
THE RULE IS: HASH THE OBJECT YOU ARE MAKING A CLAIM ABOUT, AT THE EARLIEST POINT IT EXISTS.
The document does not exist until the transport framing is removed. Hashing before that point is not
"hashing earlier and therefore safer" -- it is hashing A DIFFERENT OBJECT.
The anti-tamper property v1 was protecting is PRESERVED: the decode below is a pure, deterministic,
in-process transform. No agent, no second tool, and no disk sits between the socket and the digest.
⚠DEFECT 2 -- THE DECODER ALREADY EXISTED AND I DID NOT ADOPT IT. nx_fetch_unit.nx has had fu_body_off /
fu_status / fu_find_ci / fu_dechunk, and a fully staged nx_fetch_staged, the whole time. v1 called the
RAW primitive underneath them. ★THE ADOPTION GAP, NOT A MISSING PRIMITIVE -- the same class already in
memory. The fix is to ADOPT the proven decoder, not to write a ninth private copy of one. (`nx_body_off`
is currently duplicated across at least 9 files -- that Rule-15 extraction is filed separately; this
organ deliberately adds no new copy.)
============================ CORROBORATION: THE JULY-2026 BAR ============================
A digest pin proves INTEGRITY-SINCE-FETCH. It cannot prove AUTHENTICITY-AT-SOURCE, because a corrupted
or re-framed fetch pins exactly as cleanly as a good one -- the pin is self-consistent by construction.
The state of the art does not solve this with a better hash; it solves it with ANOTHER PARTY:
- CA/Browser Forum MPIC (mandatory for TLS/S-MIME issuance): validate from MULTIPLE INDEPENDENT
NETWORK PERSPECTIVES, and if the perspectives DISAGREE, THE PROCESS HALTS. It does not pick one.
- Sigstore/Rekor: a transparency log exists so verification need not trust a single party.
So this organ takes an OPTIONAL third argument: a digest obtained by an INDEPENDENT STACK. If supplied
dependencies 8 imports · 0 importers
imports: nx_syscalls.nxnx_csprng.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_get.nxnx_fetch_unit.nxnx_sha256_wasm.nxnx_inflate.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
| 64 | const INF_RC_NOT_GZIP: i64 = 0 - 7 // inf_gunzip's rc for a body that is not a gzip container (identity) |
functions
| 66 | func vf_put(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 67 | func vf_wb(b: *u8, n: i64) -> i64 { sys_write(1, b, n); return 0 } |
| 69 | func vf_num(v: i64) -> i64 |
| 83 | func vf_hexnib(v: i64) -> i64 { if v < 10 { return 48 + v } return 87 + v } called by 1: main |
| 84 | func vf_lc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: main |
| 86 | func main(argc: i64, argv: *i64) -> i64 |