code wiki / _hdl_build / nx_gzip_kat.nx

nx_gzip_kat.nx

buildroot/runtime/_hdl_build/nx_gzip_kat.nx

11127 B201 linesdepth 4pulls 6 transitivereach 0 importersview sourcekind tooltopic gzip
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gzip_lib.nx nx_inflate.nx nx_gate_verdict.nx nx_gzip_kat.nx

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

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close gv_need gv_puts ↻ gk_roundtrip sys_mmap ↻ gz_compress sys_mmap ↻ gz_deflate gz_putbits gz_flushbits sys_mmap ↻ gz_fill_len gz_fill_dist

structs

none

consts

33const GK_MODULE: *u8 = "buildroot/_build/nx_wasm_craft_emit.wasm"
34const GK_PAGE: *u8 = "sites/nishifamily/world/beach.html"
35const GK_SYN_N: i64 = 65536
36const GK_MODULE_PERMIL_BAR: i64 = 460
37const GK_SLACK: i64 = 4096
38const GK_NAMECAP: i64 = 512
39const GK_LCG_A: i64 = 1103515245
40const GK_LCG_C: i64 = 12345
41const GK_LCG_MASK: i64 = 2147483647
42const GK_LCG_SEED: i64 = 20260901
43const GK_SKEW_SYMS: i64 = 40
44const GK_SKEW_VALS: i64 = 16
45const GK_SKEW_TOP: i64 = 32768
46const GK_MAXBITS: i64 = 15
47const GK_LITLEN_N: i64 = 286
48const GK_GZ_HDR: i64 = 10
49const GK_FLIP: i64 = 85
50const GK_ASCII_A: i64 = 65
51const GK_ASCII_a: i64 = 97

functions

54func gk_btype(ob: *u8) -> i64 { return ((ob[GK_GZ_HDR] as i64) >> 1) & 3 }
called by 2: gk_roundtripmain
58func gk_roundtrip(name: *u8, src: *u8, n: i64, ctr: *i64, obout: *i64) -> i64
87func main() -> i64