nx_research_ka.nx
buildroot/runtime/nx_research_ka.nx
about
nx_research_ka.nx -- R4 FULL: per-host connection POOL + keep-alive fetch, with a PROVEN-path fallback.
Operator 2026-07-01 chose R4. nx_https_get_complete has 30 callers (untouchable) so this is a SELF-CONTAINED module:
* caches ONE (host, fd, session) across calls (module static globals) -> a researcher hitting ONE host repeatedly
pays the ~300ms cert-verify (certloop) ONCE, then reuses the TLS session for every subsequent GET.
* SAFE by construction: only the clean case (fresh/reused -> HTTP 200, Content-Length body) uses the fast path;
ANYTHING else (redirect/non-200/stale/parse-miss) closes the pooled conn and FALLS BACK to the proven
nx_https_fetch_follow (fresh connect, full redirect+chunk handling). Worst case == today's behavior.
Proven mechanism: nx_https_ka_probe (2 GETs / 1 handshake, GREEN). license_tier: ORIGINAL expect_exit: 0
dependencies 14 imports · 2 importers
diagram shows first 10 each side; +4 more imports, +0 more importers in the complete lists below.
imports: nx_syscalls.nxnx_tls13.nxnx_tls13_record.nxnx_tls13_read_record_from_fd.nxnx_tls13_client_session.nxnx_x509_trust_store.nxnx_trust_store_load_from_certdata.nxnx_tls13_client_validate_certificate.nxnx_tls13_client_session_run.nxnx_url.nxnx_https_url_for_fetch.nxnx_https_url_connect.nxnx_http_response_parse.nxnx_https_fetch_follow.nx
imported by: nx_ka_engine_test.nxnx_research_engine.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 23 | const K_MAGIC_4096: i64 = 4096 |
| 24 | const K_MAGIC_16645: i64 = 16645 |
| 25 | const K_MAGIC_2048: i64 = 2048 |
| 26 | const K_MAGIC_4194304: i64 = 4194304 |
functions
| 36 | func rka_handshakes() -> i64 { return G_KA_HANDSHAKES } |
| 37 | func rka_reuses() -> i64 { return G_KA_REUSES } |
| 39 | func rp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 40 | func rn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0} let t: *u8=sys_mmap(28); 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} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } |
| 41 | func rka_write_n(fd: i64, buf: *u8, n: i64) -> i64 { var off: i64=0; while off<n { let w: i64=sys_write(fd,(buf as i64+off) as *u8,n-off); if w<=0 {return 0-1} off=off+w } return 0 } |
| 42 | func rka_cat(out: *u8, o: i64, s: *u8) -> i64 { var j: i64=0; while s[j]!=(0 as u8) { out[o]=s[j]; o=o+1; j=j+1 } return o } called by 1: rka_build_req |
| 44 | func rka_build_req(path: *u8, path_len: i64, host: *u8, host_len: i64, out: *u8) -> i64 |
| 53 | func rka_hdr_end(buf: *u8, n: i64) -> i64 { var i: i64=0; while i+4<=n { if buf[i]==(13 as u8){if buf[i+1]==(10 as u8){if buf[i+2]==(13 as u8){if buf[i+3]==(10 as u8){return i}}}} i=i+1 } return 0-1 } called by 1: rka_get |
| 54 | func rka_lc(c: i64) -> i64 { if c>=65 { if c<=90 { return c+32 } } return c } called by 1: rka_clen |
| 55 | func rka_clen(buf: *u8, hdr_end: i64) -> i64 |
| 79 | func rka_get(s: *Tls13ClientSession, fd: i64, path: *u8, path_len: i64, host: *u8, host_len: i64, out_buf: *u8, out_cap: i64) -> i64 |
| 120 | func rka_path(urlbuf: *u8, target: *NxHttpsTarget, path_out: *u8) -> i64 called by 1: rf_fetch_ka |
| 132 | func rka_host_match(host: *u8, hlen: i64) -> i64 called by 1: rf_fetch_ka |
| 141 | func rka_host_cache(host: *u8, hlen: i64) -> i64 |
| 151 | func rf_fetch_ka(url0: *u8, store: *TrustStore, out: *u8, out_cap: i64, out_status: *i64) -> i64 |
| 192 | func main() -> i64 |