code wiki / _hdl_build / nx_page_verify.nx
nx_page_verify.nx
buildroot/runtime/_hdl_build/nx_page_verify.nx
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
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
| 31 | const PV_CAP: i64 = 8388608 // the EYE must out-read the pages it audits (the 2MiB-truncation lesson) |
| 32 | const PV_MAXREF: i64 = 256 // per-page ref ceiling; the compare gallery lane emits 15+ figures beside |
| 37 | const PV_CERTDATA_CAP: i64 = 4194304 // trust-store parse arena for mozilla_certdata.txt |
| 38 | const PV_URL_CAP: i64 = 4096 // one absolute URL (origin, and each resolved ref) |
| 39 | const PV_REF_MAX: i64 = 2048 // longest relative ref we will resolve |
| 42 | const PV_PROUT_SLOTS: i64 = 2 |
| 43 | const PV_WORD_BYTES: i64 = 8 |
| 44 | const PV_FULLURL_CAP: i64 = 8192 // origin + ref joined |
| 50 | const PV_ATTR_DQ: i64 = 34 // " |
| 51 | const PV_ATTR_SQ: i64 = 39 // ' |
| 52 | const PV_ATTR_GT: i64 = 62 // > |
| 53 | const PV_ATTR_SP: i64 = 32 // space |
| 54 | const PV_ATTR_TAB: i64 = 9 // tab |
| 55 | const PV_ATTR_LF: i64 = 10 // newline |
| 56 | const PV_ATTR_CR: i64 = 13 |
| 57 | const PV_ATTR_LT: i64 = 60 // < |
| 76 | const PV_TAG_LOOKBACK: i64 = 4096 |
| 109 | const PV_EXIT_GREEN: i64 = 0 |
| 110 | const PV_EXIT_RED: i64 = 1 |
| 111 | const PV_EXIT_USAGE: i64 = 2 |
| 112 | const PV_EXIT_UNOBSERVABLE: i64 = 3 |
| 113 | const PV_EXIT_UNMEASURED: i64 = 4 // our-domain host with a malformed registry endpoint |
| 116 | const PV_FF_BAD_URL: i64 = 1 |
| 117 | const PV_FF_CONNECT: i64 = 2 |
| 118 | const PV_FF_HANDSHAKE: i64 = 3 |
| 119 | const PV_FF_GET: i64 = 4 |
| 120 | const PV_VANTAGE_CAP: i64 = 320 // "dns:<host>" or "pinned:<a.b.c.d:port>" for the verdict line |
| 121 | const PV_NO_STATUS: i64 = 0 // out_status when no HTTP response was ever parsed |
| 211 | const PV_RAW_NONE: i64 = 0 |
| 212 | const PV_RAW_SCRIPT: i64 = 1 |
| 213 | const PV_RAW_STYLE: i64 = 2 |
| 267 | const PV_HEAD_CAP: i64 = 65536 |
| 268 | const PV_HTTP_PARTIAL: i64 = 206 // RFC 9110 Partial Content: the server honoured the Range |
| 269 | const PV_HTTP_OK: i64 = 200 // a server that ignored the Range and answered whole; the spine bounds the body |
| 405 | const PV_DOMCONF: *u8 = "knowledge/registry/our_domains.conf" |
| 406 | const PV_DOMCAP: i64 = 65536 |
| 407 | const PV_EP_CAP: i64 = 256 |
| 504 | const PV_CONTRACT_OK: i64 = 0 |
| 505 | const PV_CONTRACT_RED: i64 = 1 |
| 506 | const PV_CONTRACT_USAGE: i64 = 2 |
| 507 | const PV_CONTRACT_HEX_BYTES: i64 = 32 |
| 508 | const PV_CONTRACT_HEX_CHARS: i64 = 64 |
| 509 | const PV_CONTRACT_PATH_CAP: i64 = 4096 |
| 510 | const PV_CONTRACT_EVIDENCE_CAP: i64 = 262144 |
| 511 | const PV_CONTRACT_DEFAULT_MAX_AGE: i64 = 900 |
functions
| 77 | func pv_in_tag(page: *u8, at: i64) -> i64 |
| 125 | func pv_vcat(d: *u8, off: i64, s: *u8) -> i64 |
| 132 | func pv_stage_name(n: i64) -> *u8 |
| 143 | func pv_unobservable(n: i64, status: i64) -> i64 |
| 148 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 155 | func pv_normpath(p: *u8) -> i64 called by 1: pv_host |
| 186 | func 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 } |
| 187 | func pw(s: *u8, n: i64) -> i64 { sys_write(1, s, n); return 0 } calls 1: sys_write |
| 189 | func sw_starts(b: *u8, off: i64, lit: *u8) -> i64 |
| 214 | func pv_in_rawtext(page: *u8, at: i64) -> i64 calls 1: sw_starts |
| 229 | func pv_origin(url: *u8, out: *u8) -> i64 |
| 274 | func pv_nxa_magic(b: *u8, n: i64) -> i64 called by 1: pv_check_asset |
| 282 | func pv_check_asset(store: *TrustStore, aurl: *u8, body: *u8) -> i64 |
| 352 | func pv_has(b: *u8, n: i64, lit: *u8) -> i64 calls 1: sw_starts |
| 357 | func pv_count(b: *u8, n: i64, lit: *u8) -> i64 calls 1: sw_starts |
| 365 | func pv_hskip(b: *u8, n: i64) -> i64 |
| 386 | func pv_pfx(s: *u8, pfx: *u8) -> i64 |
| 410 | func pv_host(url: *u8, out: *u8, cap: i64) -> i64 |
| 435 | func pv_dom_lookup(host: *u8, ep: *u8, epcap: i64) -> i64 |
| 492 | func pv_atoi(a: *u8) -> i64 |
| 513 | func pv_contract_hex(c: i64) -> i64 |
| 519 | func pv_contract_copy(dst: *u8, cap: i64, src: *u8, off: i64) -> i64 |
| 529 | func pv_contract_hex_equal(text: *u8, digest: *u8) -> i64 |
| 546 | func pv_contract_has(buf: *u8, n: i64, lit: *u8) -> i64 |
| 560 | func 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 |
| 610 | func main(argc: i64, argv: *i64) -> i64 |