code wiki / _hdl_build / nx_printer_ctl_register.nx

nx_printer_ctl_register.nx source

↩ module page · 53 lines · 2860 B

1// nx_printer_ctl_register.nx -- GOVERNED registration of the sovereign-printer control substrate 2// (nx_motion_plan + nx_heater_pid, gated together by nx_printer_ctl_test). Engineer verdict from a 3// REAL re-run of the gate ELF. license_tier: ORIGINAL 4import "nx_cap_register.nx" 5import "nx_syscalls.nx" 6 7const PR_LAYER: i64 = 2 // GEN -- control synthesis (motion profiles + PID loop) 8const PR_STATUS: i64 = 2 9const PR_IDX: i64 = 213 10const PR_NLAYERS: i64 = 6 11 12func pr_run_status(path: *u8) -> i64 { 13 let pid: i64 = sys_fork() 14 if pid == 0 { 15 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 16 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 17 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 18 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 19 sys_execve(path, argv, envp); sys_exit(127) 20 } 21 let st: *i64 = sys_mmap(16) as *i64 22 sys_wait4(pid, st, 0) 23 return st[0] 24} 25 26func main() -> i64 { 27 let elf: *u8 = "/tmp/nx_printer_ctl_test.sov.elf" as *u8 28 let probe: i64 = sys_openat_rd(elf) 29 var present: i64 = 0 30 if probe >= 0 { present = 1; sys_close(probe) } 31 let raw: i64 = pr_run_status(elf) 32 var ran_no_signal: i64 = 0 33 if (raw % 128) == 0 { ran_no_signal = 1 } 34 var exit_ok: i64 = 0 35 if raw == 0 { exit_ok = 1 } 36 let eng: i64 = ig_engineer(present, present, ran_no_signal, exit_ok) 37 cr_w(1, "ENGINEER: printer-ctl gate re-run raw=" as *u8); cr_wn(1, raw); cr_w(1, " (0=8/8)\n" as *u8) 38 39 let cat: i64 = sys_openat_rd("knowledge/CAPABILITY_CATALOG.md" as *u8) 40 var documented: i64 = 0 41 if cat >= 0 { documented = ig_documented(1, 1); sys_close(cat) } 42 let council: i64 = ig_council(eng, 1, 1, 2) 43 let decision: i64 = ig_decision(eng, council, documented) 44 cr_w(1, "GOVERNED decision=" as *u8); cr_wn(1, decision); cr_w(1, " (1=INGEST)\n" as *u8) 45 if decision != IG_INGEST { sys_exit(1) } 46 if cr_can_register(PR_LAYER, PR_STATUS, PR_NLAYERS, decision) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 47 let fd: i64 = sys_openat_append("/tmp/nishi_cap_registry.log" as *u8, 0x1a4) 48 cr_write_entry(fd, PR_IDX, PR_LAYER, "GEN PRINTER-CTL substrate (sovereign printer arc, QIDI replacement) -- nx_motion_plan: trapezoid/triangle velocity profiles integer-exact (um/ms), steps+cruise-interval; nx_heater_pid: integer PID w/ INTEGRAL SEPARATION (+/-10C) + anti-windup clamp + first-order plant sim oracle, gains DERIVED from plant equations (kp from P-droop<separation, ki from equilibrium PWM 219); 8/8 gates incl bounded overshoot + windup-disabled safety; next rung: step-pulse ISR table + cortex_m/esp32 bare-metal port + real thermistor/MOSFET" as *u8, PR_STATUS) 49 sys_close(fd) 50 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, PR_IDX); cr_w(1, " REGISTERED\n" as *u8) 51 sys_exit(0) 52 return 0 53}