code wiki / (root) / nx_source_health.nx

nx_source_health.nx

buildroot/runtime/nx_source_health.nx

9153 B186 linesdepth 2pulls 2 transitivereach 3 importersview sourcekind librarytopic source
docsdependenciesstructsconstsfunctions

about

nx_source_health.nx -- SOURCE HEALTH, THE DECISION + THE PERSISTED VERDICT (/compare/mediaingest R1; contract symbol sh_preflight). LIB: pure classification + a tiny per-host verdict table. The heavy I/O probe (fetch + bot-wall classify) lives in the thin program nx_source_health_probe so THIS lib's import closure stays small (nx_syscalls only) and the gate can prove every branch with planted numbers -- the same lib/program split that keeps a gate honest and dodges the nx_cc module-limit that a fetch+antibot closure would hit here. WHY: Harvestr fast-fails a null-routed CDN (its April-2026 Coomer route-around) before queueing work against it; ours had nx_site_liveness for OUR sites only. This is the general per-host pre-flight: probe once, PERSIST the verdict, and let every capture read it so a dead host is skipped WITHOUT re-probing on every asset. FIVE STATES (a host that cannot be classified must not read as UP -- abstain, never flatter): SH_UP the host answered (any 2xx/3xx, or a 4xx/5xx where the HOST is alive but the path is bad) SH_SLOW it answered but slower than the slow bar -- usable, flagged SH_DEAD connect failed / timed out -- null-routed or down; skip and say so SH_WALLED it answered with a bot-wall (nx_antibot verdict) -- classified, never solved SH_UNKNOWN never probed / stale -- the third state, so "no evidence" is not "healthy" license_tier: ORIGINAL

dependencies 1 imports · 3 importers

nx_syscalls.nx nx_source_health.nx nx_cam_chaturbate_probe.nx nx_source_health_gate.nx nx_source_health_probe.nx

imports: nx_syscalls.nx

imported by: nx_cam_chaturbate_probe.nxnx_source_health_gate.nxnx_source_health_probe.nx

structs

none

consts

20const SH_UP: i64 = 0
21const SH_SLOW: i64 = 1
22const SH_DEAD: i64 = 2
23const SH_WALLED: i64 = 3
24const SH_UNKNOWN: i64 = 4
27const SH_DEFAULT_SLOW_MS: i64 = 8000
29const SH_DEFAULT_TTL_MS: i64 = 1800000
30const SH_SLOW_CONF: *u8 = "knowledge/status/source_health_slow_ms.conf"
31const SH_TABLE: *u8 = "knowledge/status/source_health.tbl"
34const SH_ABT_CLEAN: i64 = 0
84const SH_SLOTS: i64 = 4096
85const SH_REC: i64 = 32
86const SH_TBL_BYTES: i64 = 131072 // SH_SLOTS * SH_REC
87const SH_OFF_HASH: i64 = 0
88const SH_OFF_VERDICT: i64 = 8
89const SH_OFF_CHECKED: i64 = 16
90const SH_MAGIC_5381: i64 = 5381

functions

39func sh_decide(connect_ok: i64, status: i64, elapsed_ms: i64, wall_code: i64, slow_ms: i64) -> i64
called by 2: sh_preflightmain
47func sh_verdict_str(v: i64) -> *u8
57func sh_should_skip(v: i64) -> i64
64func sh_atoi(s: *u8, n: i64) -> i64
called by 1: sh_slow_ms
70func sh_slow_ms() -> i64
92func sh_hash(h: *u8, n: i64) -> i64
called by 2: sh_recordsh_lookup
98func sh_ld(tbl: *u8, off: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v = v | ((tbl[off+i] as i64) << (i*8)); i=i+1 } return v }
called by 2: sh_slotsh_lookup
99func sh_st(tbl: *u8, off: i64, val: i64) -> i64 { var i: i64=0; while i<8 { tbl[off+i] = ((val >> (i*8)) & 0xff) as u8; i=i+1 } return 0 }
called by 1: sh_record
101func sh_load_tbl_into(dst: *u8) -> i64
called by 1: sh_load_tbl calls 2: sys_mmapsys_read_file
111func sh_load_tbl() -> *u8 { let d: *u8 = sys_mmap(SH_TBL_BYTES); sh_load_tbl_into(d); return d }
112func sh_save_tbl(tbl: *u8) -> i64
121func sh_slot(tbl: *u8, hh: i64) -> i64
called by 1: sh_record calls 1: sh_ld
142func sh_record(host: *u8, host_len: i64, verdict: i64, now_ms: i64) -> i64
161func sh_preflight(host: *u8, host_len: i64, connect_ok: i64, status: i64, elapsed_ms: i64, wall_code: i64, now_ms: i64) -> i64
168func sh_lookup(host: *u8, host_len: i64, now_ms: i64) -> i64