code wiki / _hdl_build / nx_staghyg.nx

nx_staghyg.nx

buildroot/runtime/_hdl_build/nx_staghyg.nx

33655 B642 linesdepth 6pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_staghyg.nx -- STAGING-AREA HYGIENE: census, verdict, and expiry for the deploy queue. THE MEASURED PROBLEM (debt 1785531571, sev-9): the staging area has no expiry, so a .new file that PREDATES the live binary it would replace sits there looking deployable forever. Promoting it is a ROLLBACK WEARING AN UPGRADE FILENAME. Nothing in the tree measured this per-artifact, and nothing refused it at the moment of promote. FOUR VERBS, DELIBERATELY SEPARATED (Rule 9 -- each does ONE thing): census [root] report size+mtime for BOTH sides and DECIDE NOTHING. This is the rung-0 instrument, modelled verbatim on nx_tree_diff, whose banked lesson is that a tool which picks a direction is the clobber bug with a friendlier face. scan [root] the classified verdict: every staged artifact bucketed, counts that SUM. check <livepath> one target. exit 0 = promotable, exit 3 = refused. The gate/promote surface. expire [root] apply disarm artifacts past the expiry window. *EXPIRY RENAMES, IT NEVER DELETES. An expired artifact becomes <name>.new.expired-<epoch>, which md_promote_staged can no longer see (it opens exactly <name>.new) -- so the queue is disarmed while every byte is kept and the act is reversible with a single rename back (Rule 13 additive-only, Rule 26 fail-safe by construction). Without `apply` it only reports. *THE CENSUS COUNTS THE HEALTHY ROWS TOO. An instrument blind to the common case only ever sees crises -- the banked crawler lesson. FORWARD and ORPHAN are reported beside every refusal, and the class counts are printed so a reader can check they SUM to the number scanned (a partition is a claim). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_staging_guard.nx nx_staghyg.nx

imports: nx_syscalls.nxnx_staging_guard.nx

imported by: nobody (leaf or entry point)

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

main 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 ↻ sg_conf_load sys_mmap ↻ sg_slurp sys_openat_rd sys_read sys_close sys_munmap sg_conf_get sg_strlen sg_eq_at sg_parse_int_at sg_slurp ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sg_contains sg_strlen ↻ sh_puts sys_write ↻ sys_exit ↻ sh_append_str sg_classify sg_file_evidence sys_mmap_try

structs

none

consts

29const SH_STDOUT: i64 = 1
30const SH_DIRBUF: i64 = 262144
31const SH_PATHCAP: i64 = 1024
32const SH_DIR_TYPE: i64 = 4
33const SH_ALLOWCAP: i64 = 1048576

functions

35func sh_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(SH_STDOUT, s, n); return 0 }
called by 2: sh_rowmain calls 1: sys_write
36func sh_num(v: i64) -> i64
52func sh_ends_new(nm: *u8) -> i64
called by 1: main calls 1: sg_strlen
63func sh_join(dir: *u8, nm: *u8, out: *u8, strip: i64) -> i64
called by 1: main calls 1: sg_strlen
81func sh_live_path(dir: *u8, nm: *u8, out: *u8) -> i64
called by 1: main calls 2: sg_strlensg_eq_at
106func sh_ends(s: *u8, suf: *u8) -> i64
called by 2: sh_abs_livemain calls 1: sg_strlen
120func sh_field(buf: *u8, ls: i64, le: i64, idx: i64, out: *u8, cap: i64) -> i64
called by 1: main
140func sh_abs_live(p: *u8, out: *u8) -> i64
called by 1: main calls 3: sg_strlensh_endssg_eq_at
161func sh_append_num(out: *u8, pos: i64, v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_munmap
175func sh_append_str(out: *u8, pos: i64, s: *u8) -> i64
called by 1: main
183func sh_row(nm: *u8, cls: i64, out: *i64) -> i64
called by 1: main calls 3: sh_putssg_class_namesh_num
201func main(argc: i64, argv: *i64) -> i64