code wiki / _hdl_build / _freshness_gate.nx
_freshness_gate.nx
buildroot/runtime/_hdl_build/_freshness_gate.nx
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
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
structs
| none |
consts
| 19 | const FR_LOG: *u8 = "knowledge/status/offc_install.log" |
| 20 | const FR_SRC: *u8 = "/tmp/_frsrc" |
| 21 | const FR_ART: *u8 = "/tmp/_frart" |
| 22 | const FR_MISSING: *u8 = "/tmp/_frmissing_zzq" |
functions
| 24 | func fr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 25 | func fr_p(s: *u8) -> i64 { sys_write(1, s, fr_len(s)); return 0 } |
| 26 | func fr_fp(fd: i64, s: *u8) -> i64 { sys_write(fd, s, fr_len(s)); return 0 } |
| 27 | func fr_write(path: *u8, content: *u8) -> i64 |
| 34 | func fr_set_mtime(path: *u8, sec: i64) -> i64 |
| 39 | func 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 } |
| 41 | func main() -> i64 |