code wiki / _hdl_build / nx_attempt_loop_register.nx
nx_attempt_loop_register.nx source
↩ module page · 40 lines · 3447 B
1// nx_attempt_loop_register.nx -- records the Warden team-attempt loop
2// (X-Q-003 rung 1). Engineer gate = the 12-check 4-beat scratch proof
3// (_attempt_loop_gate_authored) re-run GREEN at register time (evidence law).
4// Registered via Librarian alloc + dual-write. license_tier: ORIGINAL
5import "nx_cap_register.nx"
6import "nx_capreg_librarian.nx"
7import "nx_syscalls.nx"
8
9func alr_run(path: *u8) -> i64 {
10 let pid: i64 = sys_fork()
11 if pid == 0 {
12 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
13 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
14 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0
15 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
16 sys_execve(path, argv, envp); sys_exit(127)
17 }
18 let st: *i64 = sys_mmap(16) as *i64
19 sys_wait4(pid, st, 0)
20 return st[0]
21}
22
23func main() -> i64 {
24 var allok: i64 = 1
25 if alr_run("/tmp/_attempt_loop_gate_authored.sov.elf" as *u8) != 0 { allok = 0 }
26 cr_w(1, "ENGINEER: attempt-loop 4-beat 12-check gate re-run all-pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8)
27 let eng: i64 = ig_engineer(1, 1, 1, allok)
28 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1)
29 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) }
30 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) }
31 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
32 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
33 let idx: i64 = cl_next_idx(lp, jp)
34 let ok: i64 = cl_register_dual(lp, jp, idx, 5,
35 2, "SELF ATTEMPT-LOOP (X-Q-003 rung1: the queue works ITSELF) -- nx_attempt_loop (policy nx_wd_core, composes an_pick/nx_guarded_run/nx_reconcile, NO duplicated priority/marker logic): one beat = route the Conductor's pick; ||EXEC=<organ> recipe rows are attempted hands-off (durable lane build+run under attempt_loop.conf exec_deadline_ms, SIGKILL-reaped) and judged ONLY by nx_reconcile's MARK-evidence DONE flip -- a recipe that exits 0 without turning its marker green is flipped RED (the fake-green class is structurally dead); failed attempts flip RED too (fail-loud, queue-health escalates, no livelock); uncovered picks are RAISED TODO->NOVEL (the tutor batch, never a silent stall) AND the best covered row is attempted in the SAME beat so a raise never wastes a beat; ASSIGNRESULT id/route/verdict/rc/epoch rows -> assign_next.log. Gate _attempt_loop_gate_authored 12/12: scratch queue through the REAL lane + REAL reconcile elf (no mocks), beats = raise+attempt-RED same beat / liar-RED / green-DONE-via-RECONCILE-FLIP / IDLE, conf KATs, STALE-seeded markers make re-runs deterministic. LIVE: first beat raised X-B0-003, pulse step wired (29-step pulse green incl it), rung_gates.tsv R8 row added, X-Q-003 itself closed BY nx_reconcile on the gate's ALGATE evidence (the loop closed its own birth assignment). Basename note: nx_work_dispatcher name was taken by the governor-era policy lib (untouched); Q3 ships as nx_attempt_loop. Rung2 filed: X-Q-006 emitter-SHAPE routing (warden classifier lanes); also filed X-Q-007 slow-beat gate re-prove, X-Q-008 an_load 1024-row silent cap vs ~1240 model" as *u8)
36 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) }
37 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED -- the queue now attempts its own work\n" as *u8)
38 sys_exit(0)
39 return 0
40}