nx_galx_thumb_heal.nx
buildroot/runtime/nx_galx_thumb_heal.nx
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
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
structs
| none |
consts
| 22 | const TH_MAGIC_65536: i64 = 65536 |
| 23 | const TH_MAGIC_2048: i64 = 2048 |
| 24 | const TH_MAGIC_40000: i64 = 40000 |
| 25 | const TH_MAGIC_8000: i64 = 8000 |
| 27 | const TH_FALLBACK_RATIO: i64 = 2 // thumb is "real" only if thumb_size*2 < source_size (else ~full-res = degraded) |
functions
| 29 | func 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 |
| 30 | func th_puts(s: *u8) -> i64 { sys_write(1, s, th_strlen(s)); return 0 } |
| 31 | func th_putn(v: i64) -> i64 |
| 41 | func 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 } |
| 42 | func th_mkdir(path: *u8) -> i64 { __syscall(83, path as i64, 493, 0, 0, 0, 0); return 0 } // 493 = 0755, idempotent called by 1: main |
| 45 | func th_fsize(path: *u8) -> i64 |
| 57 | func th_write(path: *u8, val: i64, n: i64) -> i64 |
| 69 | func th_classify(thumb_path: *u8, src_size: i64) -> i64 |
| 77 | func th_path(dir: *u8, cid: *u8, out: *u8) -> i64 |
| 87 | func th_scan(dir: *u8, cids: *i64, src_sizes: *i64, n: i64, emit_plan: i64) -> i64 |
| 108 | func main() -> i64 |