code wiki / (root) / nx_fin_dashboard.nx

nx_fin_dashboard.nx source

↩ module page · 28 lines · 1612 B

1// nx_fin_dashboard.nx -- emit the static nishifamily.com/finance dashboard to the staging media dir, so 2// the Nishi Publisher can ship it to liveroot (operator: "push to publisher, don't directly do"). Reuses 3// the single renderer fw_render (DRY #15). The SAME bytes are what the live OPAQUE /finance route serves. 4// license_tier: ORIGINAL 5import "nx_syscalls.nx" 6import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 7import "nx_finance_web.nx" 8 9func d_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 10// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 11// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 12// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 13// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 14func d_putn(v: i64) -> i64 { nxi_out(v); return 0 } 15 16func main() -> i64 { 17 __syscall(258, 0 - 100, "knowledge/staging/media\x00" as *u8, 0x1ed, 0, 0, 0) // mkdirat (idempotent) 18 let buf: *u8 = sys_mmap(65536) 19 let n: i64 = fw_render(buf, "operator\x00" as *u8) 20 let out: *u8 = "knowledge/staging/media/finance_dashboard.html\x00" as *u8 21 let fd: i64 = sys_openat_wr(out, 0x1a4) 22 if fd < 0 { d_puts("nx_fin_dashboard: FAIL open out\n" as *u8); sys_exit(1); return 1 } 23 sys_write(fd, buf, n) 24 sys_close(fd) 25 d_puts("nx_fin_dashboard: wrote knowledge/staging/media/finance_dashboard.html bytes=" as *u8) 26 d_putn(n); d_puts("\n" as *u8) 27 return 0 28}