code wiki / _hdl_build / nx_pub_fin_handoff.nx

nx_pub_fin_handoff.nx source

↩ module page · 49 lines · 3514 B

1// nx_pub_fin_handoff.nx -- push the sovereign nishifamily.com/finance dashboard to the Nishi Publisher 2// (operator: "push to publisher, don't directly do"). The finance workstream REQUESTS; the publisher 3// SHIPS (serialize -> idempotent sha-skip -> stage -> VERIFY-sha -> ATOMIC-promote -> ledger) to a LOCAL, 4// ISOLATED finance liveroot. Mirrors nx_pub_reader_handoff exactly (DRY #15). The OUTWARD transport 5// liveroot -> nishifamily.com is OPERATOR-GATED (publisher R6 policy=outward + R8 transport). The LIVE 6// in-app serving of /finance is done by the OPAQUE route (olg_route) calling the SAME renderer; this 7// liveroot file is the publishable artifact + the sha-verified, ledgered audit trail. license_tier: ORIGINAL 8import "nx_publisher.nx" 9import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 10import "nx_syscalls.nx" 11 12func fh_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 } 13// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 14// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 15// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 16// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 17func fh_putn(v: i64) -> i64 { nxi_out(v); return 0 } 18func fh_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } 19 20func main() -> i64 { 21 fh_puts("=== NISHI PUBLISHER <- finance dashboard handoff: REQUEST (pub_submit) then the publisher SHIPS ===\n" as *u8) 22 let src: *u8 = "knowledge/staging/media/finance_dashboard.html\x00" as *u8 23 let q: *u8 = "knowledge/publish/finance-queue.tsv\x00" as *u8 24 let led: *u8 = "knowledge/publish/finance-ledger.tsv\x00" as *u8 25 let stageroot: *u8 = "knowledge/publish/finance-stage\x00" as *u8 26 let liveroot: *u8 = "knowledge/publish/finance-live\x00" as *u8 27 let live: *u8 = "knowledge/publish/finance-live/finance_dashboard.html\x00" as *u8 28 29 if fh_exists(src) == 0 { fh_puts(" FATAL: dashboard not emitted -- run nx_fin_dashboard first\n" as *u8); sys_exit(1); return 1 } 30 pub_init() 31 sys_mkdir(stageroot, 0x1ed) 32 sys_mkdir(liveroot, 0x1ed) 33 34 // 1. REQUEST -- the finance workstream submits a publish request (sha256 of content); decoupled, durable. 35 let s1: i64 = pub_submit_to(q, src, "finance_dashboard.html\x00" as *u8, "nishifamily\x00" as *u8, "nishi-finance\x00" as *u8, "internal\x00" as *u8) 36 fh_puts(" [finance] pub_submit dashboard -> "); fh_putn(s1); fh_puts("\n" as *u8) 37 38 // 2. SHIP -- the publisher owns this: serialize -> idempotent -> stage -> VERIFY-sha -> ATOMIC-promote -> ledger. 39 let pubd: i64 = pub_run_full(q, led, stageroot, liveroot, "publish:finance\x00" as *u8) 40 fh_puts(" [publisher] pub_run_full -> published_this_pass="); fh_putn(pubd); fh_puts("\n" as *u8) 41 42 if fh_exists(live) == 1 { 43 fh_puts(" SHIPPED by the Nishi Publisher -> knowledge/publish/finance-live/finance_dashboard.html (sha-verified, ledgered, isolated finance queue)\n" as *u8) 44 fh_puts(" COORDINATED: finance REQUESTED, publisher SHIPPED (NO direct push). OUTWARD liveroot -> nishifamily.com/finance = OPERATOR-GATED (R6 policy=outward + R8 transport).\n" as *u8) 45 sys_exit(0); return 0 46 } 47 fh_puts(" publisher did not promote (verify hold or error)\n" as *u8) 48 sys_exit(1); return 1 49}