code wiki / _hdl_build / nx_gzip_kat.nx
nx_gzip_kat.nx
buildroot/runtime/_hdl_build/nx_gzip_kat.nx
about
nx_gzip_kat.nx -- THE SOVEREIGN DEFLATE ROUND-TRIP KAT: the rostered tooth for /compare/performance
PF3 (dynamic Huffman) and the lazy-matching rung, 2026-09-01. Until today the proof that gz_compress
emits streams every inflater accepts lived in ONE session record (nx_gunzip by hand, zlib-strict on
a laptop, GNU gzip on another machine). A proof nobody re-runs is a claim. This gate re-runs it on
every roster beat against the SHIPPED artifacts -- the wasm module every world page carries and a
served world page -- plus an adversarial synthetic set, through the estate's own inflater with its
CRC32 and ISIZE checks armed.
WHY THE TEETH ARE SHAPED THIS WAY:
- round-trip = inflate returns EXACTLY n bytes AND every byte matches. A stub that copies input
through fails the gzip-magic tooth; a stub that emits nothing fails round-trip; a stream one
Kraft unit over-subscribed (the 2026-08-29 defect) fails inflate.
- the MODULE must come back BTYPE=10 (dynamic) and under GK_MODULE_PERMIL_BAR. The bar is DERIVED
from the board's own measurements on this module class: lazy+fixed measured 499 permil, zlib -9
429, lazy+dynamic 430. 460 sits between the encoder this rung replaced and the encoder it
shipped, with 39 permil of margin to each -- so the fixed-Huffman encoder CANNOT pass this tooth
and the shipped one passes it with room for input drift. Not a taste.
- a TINY input must come back BTYPE=01 (fixed): the block choice is an arithmetic comparison per
input, never a mode flag, and this is the input where fixed wins.
- neg-control-corrupt-stream: one flipped byte in the compressed body must be REFUSED or must not
reproduce the input. A round-trip oracle that cannot fail is decoration.
- adversarial-kraft-limiter: gz_dh_lens over 40 exponentially skewed symbols (raw depth 39) must
return a COMPLETE 15-bit code (Kraft sum exactly 2^15) with no length over 15 and no used
symbol at 0. This is the arithmetic that came out one unit over on 2026-08-29.
PRECONDITIONS are declared with gv_need (SKIP, never RED): the module and the page are estate
artifacts that may be absent on a foreign tree.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_gzip_lib.nxnx_inflate.nxnx_gate_verdict.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
| 33 | const GK_MODULE: *u8 = "buildroot/_build/nx_wasm_craft_emit.wasm" |
| 34 | const GK_PAGE: *u8 = "sites/nishifamily/world/beach.html" |
| 35 | const GK_SYN_N: i64 = 65536 |
| 36 | const GK_MODULE_PERMIL_BAR: i64 = 460 |
| 37 | const GK_SLACK: i64 = 4096 |
| 38 | const GK_NAMECAP: i64 = 512 |
| 39 | const GK_LCG_A: i64 = 1103515245 |
| 40 | const GK_LCG_C: i64 = 12345 |
| 41 | const GK_LCG_MASK: i64 = 2147483647 |
| 42 | const GK_LCG_SEED: i64 = 20260901 |
| 43 | const GK_SKEW_SYMS: i64 = 40 |
| 44 | const GK_SKEW_VALS: i64 = 16 |
| 45 | const GK_SKEW_TOP: i64 = 32768 |
| 46 | const GK_MAXBITS: i64 = 15 |
| 47 | const GK_LITLEN_N: i64 = 286 |
| 48 | const GK_GZ_HDR: i64 = 10 |
| 49 | const GK_FLIP: i64 = 85 |
| 50 | const GK_ASCII_A: i64 = 65 |
| 51 | const GK_ASCII_a: i64 = 97 |
functions
| 54 | func gk_btype(ob: *u8) -> i64 { return ((ob[GK_GZ_HDR] as i64) >> 1) & 3 } |
| 58 | func gk_roundtrip(name: *u8, src: *u8, n: i64, ctr: *i64, obout: *i64) -> i64 |
| 87 | func main() -> i64 |