code wiki / _hdl_build / nx_hr_console_render.nx

nx_hr_console_render.nx source

↩ module page · 32 lines · 2075 B

1// nx_hr_console_render.nx -- renders the /hr admin console to a STATIC file from the staged roster, so the operator 2// can open it in a browser and SEE the family logins right now (before any deploy). The live interactive console 3// (invite/suspend actions) comes with the daemon wiring; this is the read-only view of the current staged roster. 4import "nx_hr_admin_page.nx" 5import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 6import "nx_hr_audit.nx" 7import "nx_syscalls.nx" 8const K_MAGIC_262144: i64 = 262144 9 10func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 11// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 12// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 13// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 14// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 15func g_num(v: i64) -> i64 { nxi_out(v); return 0 } 16 17func main() -> i64 { 18 let store: *u8 = "knowledge/publish/staging/nishi_hr.log" as *u8 19 let outp: *u8 = "knowledge/publish/staging/hr_console.html" as *u8 20 let buf: *u8 = sys_mmap(K_MAGIC_262144) 21 let n: i64 = hap_emit(store, 1, buf, K_MAGIC_262144) // super=1: render the full roster view 22 let fd: i64 = sys_openat_wr(outp, 0x1a4) 23 if fd < 0 { g_puts("render FAIL (cannot open output)\n" as *u8); sys_exit(1); return 1 } 24 sys_write(fd, buf, n); sys_close(fd) 25 g_puts("rendered knowledge/publish/staging/hr_console.html bytes=" as *u8); g_num(n); g_puts("\n" as *u8) 26 // also render the audit trail of the staged roster 27 let abuf: *u8 = sys_mmap(K_MAGIC_262144) 28 let an: i64 = hau_emit(store, 1, abuf, K_MAGIC_262144) 29 let afd: i64 = sys_openat_wr("knowledge/publish/staging/hr_audit.html" as *u8, 0x1a4) 30 if afd >= 0 { sys_write(afd, abuf, an); sys_close(afd); g_puts("rendered knowledge/publish/staging/hr_audit.html bytes=" as *u8); g_num(an); g_puts("\n" as *u8) } 31 sys_exit(0); return 0 32}