code wiki / _hdl_build / nx_page_verify.nx

nx_page_verify.nx

buildroot/runtime/_hdl_build/nx_page_verify.nx

59259 B1006 linesdepth 21pulls 151 transitivereach 0 importersview sourcekind orphan librarytopic page
docsdependenciesstructsconstsfunctions

about

nx_page_verify.nx -- BROWSER-GRADE LIVE PAGE VERIFIER (the "my verify was shit" cure, operator 2026-07-16). Status-200-on-the-page is NOT verification: a page can 200 while every image on it is broken (the /render3d incident: the edge 301-strips trailing slashes, so RELATIVE img srcs resolve to the site root -> 404/fallback -> broken images that a direct asset fetch never catches). This organ verifies a page THE WAY A BROWSER EXPERIENCES IT: 1. fetch the page (sovereign TLS, redirects followed) -- must be 200 2. extract every asset ref (img/script src=, link href=) 3. LAW CHECK: a RELATIVE asset ref = RED by construction on our slash-stripping edge (use absolute /path) 4. fetch every same-origin asset -- 200 required 5. DEEP-DECODE: PNG assets run through the full sovereign decoder (nx_png_decode: signature, IHDR, zlib inflate, unfilter incl Paeth) -- "200 + magic bytes" is not proof; DECODED WxH is 6. an asset that answers with HTML (the 404-fallback class) = RED even though its status is 200 Composes nx_https_fetch_follow (the games_url_check fetch spine) + nx_png_decode. Exit = broken count. usage: nx_page_verify <https-url> [connect-host:port] (run from repo root: needs data/mozilla_certdata.txt) [connect-host:port] = OPTIONAL connect-override (curl --connect-to): page + every asset fetch opens TCP+TLS to THIS endpoint while SNI/Host/cert-name stay the URL host -- use 127.0.0.1:8443 to verify our OWN vhosts deterministically from the sovereign edge (kills the DSM-nginx :443 coin-flip false-RED). license_tier: ORIGINAL

dependencies 9 imports · 0 importers

nx_syscalls.nx nx_x509_trust_store.nx nx_trust_store_load_from_certdata. nx_https_url_connect.nx nx_https_fetch_follow.nx nx_png_decoder.nx nx_imgattr_lib.nx nx_pageref_lib.nx nx_sha256.nx nx_page_verify.nx

imports: nx_syscalls.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_https_url_connect.nxnx_https_fetch_follow.nxnx_png_decoder.nxnx_imgattr_lib.nxnx_pageref_lib.nxnx_sha256.nx

imported by: nobody (leaf or entry point)

structs

none

consts

31const PV_CAP: i64 = 8388608 // the EYE must out-read the pages it audits (the 2MiB-truncation lesson)
32const PV_MAXREF: i64 = 256 // per-page ref ceiling; the compare gallery lane emits 15+ figures beside
37const PV_CERTDATA_CAP: i64 = 4194304 // trust-store parse arena for mozilla_certdata.txt
38const PV_URL_CAP: i64 = 4096 // one absolute URL (origin, and each resolved ref)
39const PV_REF_MAX: i64 = 2048 // longest relative ref we will resolve
42const PV_PROUT_SLOTS: i64 = 2
43const PV_WORD_BYTES: i64 = 8
44const PV_FULLURL_CAP: i64 = 8192 // origin + ref joined
50const PV_ATTR_DQ: i64 = 34 // "
51const PV_ATTR_SQ: i64 = 39 // '
52const PV_ATTR_GT: i64 = 62 // >
53const PV_ATTR_SP: i64 = 32 // space
54const PV_ATTR_TAB: i64 = 9 // tab
55const PV_ATTR_LF: i64 = 10 // newline
56const PV_ATTR_CR: i64 = 13
57const PV_ATTR_LT: i64 = 60 // <
76const PV_TAG_LOOKBACK: i64 = 4096
109const PV_EXIT_GREEN: i64 = 0
110const PV_EXIT_RED: i64 = 1
111const PV_EXIT_USAGE: i64 = 2
112const PV_EXIT_UNOBSERVABLE: i64 = 3
113const PV_EXIT_UNMEASURED: i64 = 4 // our-domain host with a malformed registry endpoint
116const PV_FF_BAD_URL: i64 = 1
117const PV_FF_CONNECT: i64 = 2
118const PV_FF_HANDSHAKE: i64 = 3
119const PV_FF_GET: i64 = 4
120const PV_VANTAGE_CAP: i64 = 320 // "dns:<host>" or "pinned:<a.b.c.d:port>" for the verdict line
121const PV_NO_STATUS: i64 = 0 // out_status when no HTTP response was ever parsed
211const PV_RAW_NONE: i64 = 0
212const PV_RAW_SCRIPT: i64 = 1
213const PV_RAW_STYLE: i64 = 2
267const PV_HEAD_CAP: i64 = 65536
268const PV_HTTP_PARTIAL: i64 = 206 // RFC 9110 Partial Content: the server honoured the Range
269const PV_HTTP_OK: i64 = 200 // a server that ignored the Range and answered whole; the spine bounds the body
405const PV_DOMCONF: *u8 = "knowledge/registry/our_domains.conf"
406const PV_DOMCAP: i64 = 65536
407const PV_EP_CAP: i64 = 256
504const PV_CONTRACT_OK: i64 = 0
505const PV_CONTRACT_RED: i64 = 1
506const PV_CONTRACT_USAGE: i64 = 2
507const PV_CONTRACT_HEX_BYTES: i64 = 32
508const PV_CONTRACT_HEX_CHARS: i64 = 64
509const PV_CONTRACT_PATH_CAP: i64 = 4096
510const PV_CONTRACT_EVIDENCE_CAP: i64 = 262144
511const PV_CONTRACT_DEFAULT_MAX_AGE: i64 = 900

functions

77func pv_in_tag(page: *u8, at: i64) -> i64
125func pv_vcat(d: *u8, off: i64, s: *u8) -> i64
132func pv_stage_name(n: i64) -> *u8
143func pv_unobservable(n: i64, status: i64) -> i64
148func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: pv_check_assetpv_host calls 1: sys_write
155func pv_normpath(p: *u8) -> i64
called by 1: pv_host
186func pn(v: i64) -> i64 { let t: *u8=sys_mmap(24); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(24); var j: i64=0; while j<k{b[j]=t[k-1-j];j=j+1} sys_write(1,b,k); return 0 }
187func pw(s: *u8, n: i64) -> i64 { sys_write(1, s, n); return 0 }
calls 1: sys_write
189func sw_starts(b: *u8, off: i64, lit: *u8) -> i64
214func pv_in_rawtext(page: *u8, at: i64) -> i64
calls 1: sw_starts
229func pv_origin(url: *u8, out: *u8) -> i64
274func pv_nxa_magic(b: *u8, n: i64) -> i64
called by 1: pv_check_asset
282func pv_check_asset(store: *TrustStore, aurl: *u8, body: *u8) -> i64
352func pv_has(b: *u8, n: i64, lit: *u8) -> i64
calls 1: sw_starts
357func pv_count(b: *u8, n: i64, lit: *u8) -> i64
calls 1: sw_starts
365func pv_hskip(b: *u8, n: i64) -> i64
386func pv_pfx(s: *u8, pfx: *u8) -> i64
410func pv_host(url: *u8, out: *u8, cap: i64) -> i64
435func pv_dom_lookup(host: *u8, ep: *u8, epcap: i64) -> i64
492func pv_atoi(a: *u8) -> i64
513func pv_contract_hex(c: i64) -> i64
519func pv_contract_copy(dst: *u8, cap: i64, src: *u8, off: i64) -> i64
529func pv_contract_hex_equal(text: *u8, digest: *u8) -> i64
546func pv_contract_has(buf: *u8, n: i64, lit: *u8) -> i64
560func pv_contract_verify(url: *u8, page: *u8, page_n: i64, artifact: *u8, evidence_path: *u8, evidence_sha: *u8, interaction: *u8, runtime: *u8, observed: *u8, max_age: i64) -> i64
610func main(argc: i64, argv: *i64) -> i64