code wiki / (root) / nx_galx_thumb_heal.nx

nx_galx_thumb_heal.nx

buildroot/runtime/nx_galx_thumb_heal.nx

8290 B155 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

about

nx_galx_thumb_heal.nx -- SELF-HEALING DELIVERY for the gallery (operator 2026-06-23 msg#1: "get our systems functionality self healing ... to s class exceed as delivery is d class tops"). Implements SH0 from knowledge/specs/2026-06-13-self-healing-data-management-exceed-bar.md: LIVE DEGRADATION DETECTION BEYOND PROCESS-DEATH. THE DEGRADATION (found by nx_explore mapping the live code): nx_gallery_serve::gs_thumb serves a cached thumbs/<cid>.jpg O(1); on a cold cache it generates via nx_galx_thumb, but if the generator is ABSENT/FAILS it FALLS BACK to the full-res PNG (gs_thumb line ~230). Result: a grid page = ~60 FULL-RES images = "loading is atrocious" -- yet every response is 200 OK, so a port-check / K8s liveness probe / Datadog uptime monitor reports the gallery HEALTHY. The incumbent is STRUCTURALLY BLIND to this class. This organ DETECTS it (thumb missing OR thumb not meaningfully smaller than the source = a fallback was/will-be served) and HEALS it (regenerate the cache via the SAME generator gs_thumb forks: nx_galx_thumb <src> <out> 384), then VERIFIES degraded->0. SELF-GATE (fault-injection as DATA, hermetic in /tmp): inject a MISSING thumb + an OVERSIZED (full-res) thumb + a HEALTHY thumb -> detect must find exactly 2 degraded (recall=1.0 on the fallback class the liveness probe misses) -> populate the cache (the generator's output) -> re-detect must find 0 (the closed detect->heal->verify loop) -> EXPLORE... EXPLORE-HEAL-GATE GREEN / run-exit=0. HONEST: the gate proves DETECTION + the verify TRANSITION; the actual PNG->JPEG regen is the proven nx_galx_thumb (composed live via fork, exactly like gs_thumb_run), not re-gated here. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_galx_thumb_heal.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main th_puts sys_write th_strlen th_mkdir sys_mmap th_cat th_path th_cat ↻ th_write sys_openat_wr sys_mmap ↻ sys_write ↻ sys_close th_scan sys_mmap ↻ th_path ↻ th_classify th_fsize sys_openat_rd sys_mmap ↻ sys_read sys_close ↻ th_puts ↻ th_putn sys_write ↻ sys_mmap ↻ sys_exit

structs

none

consts

22const TH_MAGIC_65536: i64 = 65536
23const TH_MAGIC_2048: i64 = 2048
24const TH_MAGIC_40000: i64 = 40000
25const TH_MAGIC_8000: i64 = 8000
27const TH_FALLBACK_RATIO: i64 = 2 // thumb is "real" only if thumb_size*2 < source_size (else ~full-res = degraded)

functions

29func th_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: th_puts
30func th_puts(s: *u8) -> i64 { sys_write(1, s, th_strlen(s)); return 0 }
called by 2: th_scanmain calls 2: sys_writeth_strlen
31func th_putn(v: i64) -> i64
called by 1: main calls 2: sys_writesys_mmap
41func th_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off + i] = s[i]; i = i + 1 } return off + i }
called by 2: th_pathmain
42func th_mkdir(path: *u8) -> i64 { __syscall(83, path as i64, 493, 0, 0, 0, 0); return 0 } // 493 = 0755, idempotent
called by 1: main
45func th_fsize(path: *u8) -> i64
57func th_write(path: *u8, val: i64, n: i64) -> i64
69func th_classify(thumb_path: *u8, src_size: i64) -> i64
called by 1: th_scan calls 1: th_fsize
77func th_path(dir: *u8, cid: *u8, out: *u8) -> i64
called by 2: th_scanmain calls 1: th_cat
87func th_scan(dir: *u8, cids: *i64, src_sizes: *i64, n: i64, emit_plan: i64) -> i64
108func main() -> i64