code wiki / _hdl_build / _freshness_gate.nx

_freshness_gate.nx

buildroot/runtime/_hdl_build/_freshness_gate.nx

4996 B98 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

_freshness_gate.nx -- LOCK for the LM-027 reactive freshness detector (DISCIPLINE -> AUTO upgrade). Proves the new mtime CHANNEL (sys_fstatat/262 + sys_utimensat/280, the x86_64-direct stat family) and oi_src_stale: a source-vs-artifact staleness detector that works with NO /tmp twin -- so a gate that compiles-then-runs an external artifact can REACTIVELY detect "artifact older than source" and refuse to run yesterday's binary (the trap that printed 650 for a 125-line program), instead of only the proactive oi_fresh remove-before-compile discipline. DETERMINISTIC: sets explicit mtimes via sys_utimensat (no sleeps / no FS-resolution races), on /tmp fixtures (no _offc pollution). Self-cleaning via oi_fresh (unlinkat). T1 stale : artifact mtime < source mtime -> oi_src_stale == 1 T2 fresh : artifact mtime > source mtime -> oi_src_stale == 0 (no false-positive) T3 art-absent : artifact missing, source present -> oi_src_stale == 1 (never built) T4 src-absent : source missing -> oi_src_stale == 0 (nothing to be stale vs) T5 round-trip : utimensat sets mtime=S; oi_mtime_ns reads S back -> the stat is REAL (not a constant) GREEN only if T1..T5 hold. Evidence -> knowledge/status/offc_install.log. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_offc_install.nx nx_syscalls.nx _freshness_gate.nx

imports: nx_offc_install.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main oi_fresh sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close fr_write sys_openat_wr sys_write fr_len sys_close ↻ fr_set_mtime sys_mmap ↻ sys_utimensat oi_src_stale oi_mtime_ns sys_mmap ↻ sys_fstatat oi_mtime_ns ↻ fr_p sys_write ↻ fr_len ↻ fr_row fr_p ↻ sys_openat_append fr_fp sys_write ↻ fr_len ↻ oi_wn sys_mmap ↻ sys_write ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_close ↻ sys_exit

structs

none

consts

19const FR_LOG: *u8 = "knowledge/status/offc_install.log"
20const FR_SRC: *u8 = "/tmp/_frsrc"
21const FR_ART: *u8 = "/tmp/_frart"
22const FR_MISSING: *u8 = "/tmp/_frmissing_zzq"

functions

24func fr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 3: fr_pfr_fpfr_write
25func fr_p(s: *u8) -> i64 { sys_write(1, s, fr_len(s)); return 0 }
called by 2: fr_rowmain calls 2: sys_writefr_len
26func fr_fp(fd: i64, s: *u8) -> i64 { sys_write(fd, s, fr_len(s)); return 0 }
called by 1: main calls 2: sys_writefr_len
27func fr_write(path: *u8, content: *u8) -> i64
34func fr_set_mtime(path: *u8, sec: i64) -> i64
called by 1: main calls 2: sys_mmapsys_utimensat
39func fr_row(name: *u8, pass: i64) -> i64 { fr_p(" " as *u8); fr_p(name); if pass == 1 { fr_p(" PASS\n" as *u8) } else { fr_p(" FAIL\n" as *u8) } return 0 }
called by 1: main calls 1: fr_p
41func main() -> i64