nx_codec_caps.nx
buildroot/runtime/nx_codec_caps.nx
about
nx_codec_caps.nx -- the SINGLE source of truth for what we may advertise.
THE DEFECT THIS EXISTS TO KILL. Thirteen call sites across the fetchers and
the browser each hand-wrote their own negotiation headers. Two of them lie:
nx_http_client sends `Accept: ...,image/avif,image/webp,...` and
nx_polite_browser sends `Accept-Encoding: gzip, deflate, br`. We have no
AVIF pixel codec and no Brotli decoder. A server that believes either one
answers with bytes we cannot read -- and the failure is not an error, it is
a blank image or a body of binary noise handed to an HTML parser.
The other nine sites have the opposite defect: they send
`Accept-Encoding: identity` while nx_gzip_inflate and nx_zlib_inflate are
both in-tree and complete. That is a real capability left on the floor on
every fetch.
A FIX THAT NEEDS MEMORY AT THIRTEEN SITES IS NOT A FIX. So the header is not
written anywhere -- it is DERIVED, here, from a registry of what actually
decodes. Adding a decoder means flipping one flag in one table and every
call site that composes this becomes honest in the same act. Drift is not
discouraged, it is unrepresentable.
WHAT IS DECLARED HAVE, AND WHY (verified 2026-07-31 by reading the tree,
not by recalling it):
image/gif -- nx_gif_decode.nx (gif_decode -> w*h grayscale, LZW, + gate)
WIRED into nx_img_bytes_to_rgb 2026-08-04; before that the
decoder existed but no image path called it.
WITHDRAWN 2026-08-04 -- image/webp, and WHY (measured, not recalled):
The row above claimed "VP8L lossless + VP8 keyframe". VP8L is real. VP8
KEYFRAME IS NOT: nx_vp8.nx is the boolean entropy decoder + frame-header
parser ONLY -- no macroblock modes, no coefficient decode, no dequant/IDCT,
no intra prediction, no reconstruction. And webp_decode() walks chunks to
the VP8L fourcc and returns 0 for anything else.
MEASURED (nx_webpprobe over a 101-file real-web corpus): 25 of 25 WebP were
VP8 LOSSY, and webp_decode returned 0 on every one. Zero VP8L in the wild.
CONSEQUENCE OF THE LIE: because we advertised image/webp, content-negotiating
origins served WebP for URLs ending .jpg (proven: a Wikimedia
250px-*.jpg came back RIFF/WEBP), so the advertisement CREATED the
undecodable corpus it claimed to be able to read.
Restore have=1 only when a VP8 keyframe decoder reconstructs real pixels.
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_codec_caps_gate.nxnx_http_client.nxnx_https_get_spoof.nxnx_polite_browser.nx
structs
| none |
consts
| 58 | const NX_MAGIC_1024: i64 = 1024 |
| 62 | const NX_CC_N_IMAGE: i64 = 8 |
| 94 | const NX_CC_N_ENCODING: i64 = 4 |
functions
| 64 | func cc_image_name(i: i64) -> *u8 |
| 76 | func cc_image_have(i: i64) -> i64 |
| 96 | func cc_encoding_name(i: i64) -> *u8 |
| 104 | func cc_encoding_have(i: i64) -> i64 |
| 114 | func nx_cc_len(s: *u8) -> i64 |
| 121 | func nx_cc_eq(a: *u8, b: *u8) -> i64 |
| 135 | func nx_cc_put(out: *u8, off: i64, s: *u8) -> i64 |
| 150 | func nx_cc_find(hay: *u8, needle: *u8) -> i64 |
| 174 | func nx_cc_count_tokens(s: *u8) -> i64 |
| 191 | func nx_codec_caps_have_image(name: *u8) -> i64 |
| 200 | func nx_codec_caps_have_encoding(name: *u8) -> i64 |
| 215 | func nx_codec_caps_accept_image(out: *u8) -> i64 |
| 233 | func nx_codec_caps_accept_encoding(out: *u8) -> i64 |
| 253 | func nx_codec_caps_accept_document(out: *u8) -> i64 |
| 266 | func nx_codec_caps_headers(out: *u8) -> i64 |