code wiki / _hdl_build / nx_stackaudit_targets.nx

nx_stackaudit_targets.nx source

↩ module page · 33 lines · 1988 B

1// nx_stackaudit_targets.nx -- THE LOOP-CLOSER: the stack audit's RED/below-floor rungs become ranked 2// work in the autonomous loop's assignment_queue.tsv. Mirrors nx_ecomat_target_emit exactly (shared 3// sax_emit_targets_core, rt_lock-protected, IDEMPOTENT: a rung already queued as STACK-<name> is not 4// re-emitted; a healthy rung writes a STACK-DONE marker that nx_reconcile flips the row on). So the 5// audit stops being a report and starts DRIVING the build -- measured, never asserted. 6// license_tier: ORIGINAL expect_exit: 0 7import "nx_stackaudit_lib.nx" 8import "nx_registry_lock.nx" 9 10func main(argc: i64, argv: *i64) -> i64 { 11 var queue: *u8 = "knowledge/registry/assignment_queue.tsv" 12 var lock: *u8 = "knowledge/registry/assignment_queue.tsv.lock" 13 var tlog: *u8 = "knowledge/status/stack_targets.log" 14 if argc >= 2 { queue = argv[1] as *u8 } 15 if argc >= 3 { lock = argv[2] as *u8 } 16 if argc >= 4 { tlog = argv[3] as *u8 } 17 _p("=== nx_stackaudit_targets -- unhealthy rungs -> ranked TODOs in the loop queue (idempotent, lock-protected) ===\n" as *u8) 18 let szp: *i64 = sys_mmap(16) as *i64 19 let qb: *u8 = ss_readall(queue, szp) 20 var qn: i64 = szp[0] 21 if qn < 0 { qn = 0 } 22 let lk: i64 = rt_lock(lock) 23 let qf: i64 = sys_openat_append(queue, 0x1a4) 24 let lf: i64 = sys_openat_append(tlog, 0x1a4) 25 let out: *i64 = sys_mmap(32) as *i64 26 sax_emit_targets_core(qb, qn, qf, lf, out) 27 if lf >= 0 { _fp(lf, "STACK-EMIT-RUN emitted=" as *u8); _fn(lf, out[0]); _fp(lf, " done_marks=" as *u8); _fn(lf, out[1]); _fp(lf, " epoch=" as *u8); _fn(lf, sys_now_realtime_sec()); _fp(lf, " src=knowledge/status verdict=GREEN\n" as *u8); sys_close(lf) } 28 if qf >= 0 { sys_close(qf) } 29 rt_unlock(lock, lk) 30 _p("STACK-EMIT emitted=" as *u8); _fn(1, out[0]); _p(" targets done_marks=" as *u8); _fn(1, out[1]); _p(" (re-run = 0 emitted; the loop's an_pick consumes these by weight) verdict=GREEN\n" as *u8) 31 sys_exit(0) 32 return 0 33}