code wiki / (root) / nx_servedrift.nx

nx_servedrift.nx

buildroot/runtime/nx_servedrift.nx

11292 B230 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_artifactdrift.nx -- IS THE BINARY WE ARE SERVING THE ONE THE LAST BUILD PRODUCED? ⚠THIS ORGAN WAS NAMED WRONG TWICE, AND BOTH GUARDS WERE RIGHT. It shipped as `nx_promotestale` and nx_job_run's launch guard refused it: that guard splits the name on '_' and denies any SEGMENT STARTING WITH a control-plane stem, so "promotestale" reads as promote. Renamed to `nx_servedrift`, /api/promote then refused it as a DAEMON and nx_job_run refused it again -- "servedrift" starts with "serve", and that guard's header states it chose stem-prefix DELIBERATELY so `nx_server` could never escape, calling an escaped server "the brick". -- BOTH REFUSALS WERE CORRECT. A launch guard must be wrong in the direction of REFUSING, and a name that starts with `serve` genuinely looks like a server. The tempting fix -- patch an allow-path into a never-brick guard so it consults organ_kind.conf -- would trade a real safety property for a bad name. -- SO THE NAME MOVED, NOT THE GUARD: this measures DRIFT BETWEEN THE BUILT AND SERVED ARTIFACT, which `artifactdrift` says exactly and claims to be no kind of server. ★★AN ORGAN'S NAME IS PART OF ITS INTERFACE, BECAUSE THE ESTATE'S OWN SAFETY RULES READ IT -- and when a guard and a name disagree, the guard is the thing with a proof behind it. WHY IT EXISTS, MEASURED 2026-08-14: two organs were found SERVING STALE CODE purely because a human happened to notice nx_catalog's BUILT and PROMOTED columns disagree -- nx_vizsla_digest (47,402 served vs 47,596 built) and nx_vizsla_plan (176,882 served vs 217,561 built: ~40 KB, a FIFTH of the organ, missing from the running binary). Both were invisible to every health check the estate runs. -- A RUNNING BINARY THAT IS NOT WHAT ITS SOURCE BUILT IS A SILENT CORRECTNESS AND SECURITY DEFECT: every fix, every audit and every gate verdict then describes code that is not the code being executed. -- SPOTTING IT BY EYE DOES NOT SCALE. nx_catalog answers this one NAME at a time; this sweeps. nx_servedrift [registry] [buildroot] THE UNIT IS THE BINARY, NOT THE REGISTRY ROW. Several names legitimately share one elf (nx_status and nx_torstat both point at nx_hostctl; nx_services/nx_health/nx_mgmt all at nx_mgmt_call.elf), so counting rows would INFLATE the population and report one stale binary as three. CLASSES -- a PARTITION whose parts are printed and MUST sum: IDENTICAL served bytes == built bytes -> what we run is what we built STALE both exist and DIFFER -> THE WORKLIST; the served code is not the build NO-BUILD no build artifact to compare against -> CANNOT JUDGE, never folded into IDENTICAL NO-SERVED the registry points at a missing elf -> a dangling row, a different defect entirely -- "I COULD NOT LOOK" GETS ITS OWN BUCKET. Folding NO-BUILD into IDENTICAL would report the fleet healthy in exactly the state this organ exists to catch -- the defect nx_offc_install already made once when it read "no twin to judge" as "not stale". CHEAP BY CONSTRUCTION: size comes from sys_fstatat (a stat, NOT a read), so the common case costs two

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_servedrift.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 ps_puts sys_write ps_len sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sys_exit ↻ ps_streq ps_size sys_mmap ↻ sys_fstatat ps_same sys_mmap ↻ sys_read_file ↻ ps_pn ps_puts ↻ sys_mmap ↻ sys_write ↻

structs

none

consts

47const PS_MAXROW: i64 = 4096
48const PS_NAMEMAX: i64 = 256
49const PS_STAT_SIZE_OFF: i64 = 48
50const PS_DEFAULT_REG: *u8 = "tool_allowlist.conf"
51const PS_DEFAULT_BROOT: *u8 = "buildroot/_build/"
52const PS_TAB: i64 = 9
53const PS_NL: i64 = 10

functions

55func ps_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: ps_puts
56func ps_puts(s: *u8) -> i64 { sys_write(1, s, ps_len(s)); return 0 }
called by 2: ps_pnmain calls 2: sys_writeps_len
57func ps_pn(v: i64) -> i64
called by 1: main calls 3: ps_putssys_mmapsys_write
71func ps_size(path: *u8) -> i64
called by 1: main calls 2: sys_mmapsys_fstatat
77func ps_streq(a: *u8, b: *u8) -> i64
called by 1: main
89func ps_same(a: *u8, b: *u8) -> i64
called by 1: main calls 2: sys_mmapsys_read_file
108func main(argc: i64, argv: *i64) -> i64