nx_fetchclean.nx
buildroot/runtime/nx_fetchclean.nx
about
nx_fetchclean.nx -- REMOVE OUR OWN FETCH LANE'S DIAGNOSTIC PREAMBLE FROM A DOWNLOADED ASSET.
WHY (measured 2026-08-07, caught by nx_assetprobe on its first real binary): nx_https_get prints
transport diagnostics (nishi-tcc / nishi-cert / nishi-xfer) on the captured stream, AHEAD of the
entity body. A genuine PNG fetched through our lane therefore read:
bytes=13933 magic=UNKNOWN ext_claim=PNG verdict=UNIDENTIFIED
because a 38-byte preamble displaced the magic from offset 0. Two real BVH files landed at
exactly +38 bytes over their upstream size for the same reason; they survived only because BVH
is text and gets a bounded scan. EVERY binary asset -- PMX, VMD, PNG, ZIP, GLB -- is broken by
this, and each would have failed later, inside a loader, as an unexplained corruption.
*THE FIX BELONGS IN THE PIPE, NOT IN THE RULER. Widening the magic check to "somewhere in the
first N bytes" would have hidden this and destroyed the guarantee that makes a magic a magic.
CLOSED PREFIX SET, LEADING RUN ONLY. We strip a line only if it begins with one of the four
KNOWN diagnostic prefixes, and we stop at the first line that does not. A generic "starts with
nishi-" rule would eat a legitimate body, and a whole-file rule would eat a payload that merely
mentions the string. Never silent: the stripped byte and line counts are always printed.
usage: nx_fetchclean <in> <out>
nx_fetchclean --kat selftest: 5 teeth, 3 of them anti-vacuity
exit 0 ok | 2 unreadable | 3 usage | 9 write-failed | 1 KAT RED
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
| 26 | const FC_KATBUF: i64 = 4096 |
| 27 | const FC_MODE: i64 = 420 |
| 28 | const FC_NPFX: i64 = 4 |
functions
| 30 | func fc_slen(s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { i = i + 1 } return i } |
| 31 | func fc_puts(s: *u8) -> i64 { sys_write(1, s, fc_slen(s)); return 0 } |
| 32 | func fc_num(v: i64) -> i64 |
| 47 | func fc_at(b: *u8, len: i64, off: i64, pat: *u8) -> i64 |
| 56 | func fc_is_diag(b: *u8, len: i64, off: i64) -> i64 |
| 65 | func fc_body_off(b: *u8, len: i64, lines: *i64) -> i64 |
| 89 | func fc_write(path: *u8, b: *u8, off: i64, len: i64) -> i64 |
| 99 | func fc_put(b: *u8, o: i64, s: *u8) -> i64 |
| 106 | func fc_kat() -> i64 |
| 174 | func main(argc: i64, argv: *i64) -> i64 |