code wiki / _hdl_build / nx_pub_vroom_handoff.nx
nx_pub_vroom_handoff.nx source
↩ module page · 53 lines · 3664 B
1// nx_pub_vroom_handoff.nx -- wire the SOVEREIGN VIDEO ROOM through the Nishi Publisher (operator
2// 2026-06-22: "where are we on getting our video room wired up as s class exceed with the nishi
3// publisher"). The room workstream REQUESTS; the publisher SHIPS -- replacing the old direct-SSH push
4// (nx_vroom_html) with the sovereign publish pipeline, exactly like nx_pub_reader_handoff.
5// Pipeline: pub_submit (sha256 of the room client) -> pub_run_full (serialize -> idempotent sha-skip ->
6// stage -> VERIFY-sha -> ATOMIC-promote -> ledger) -> LOCAL vroom liveroot. The OUTWARD transport
7// liveroot -> nishifamily.com/video is OPERATOR-GATED (publisher R6 policy=outward + R8 transport) and
8// also needs the live relay daemon on the host (a separate operator-gated SSH step). license_tier: ORIGINAL
9import "nx_publisher.nx"
10import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
11import "nx_syscalls.nx"
12
13func vh_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 }
14// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
15// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
16// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
17// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
18func vh_putn(v: i64) -> i64 { nxi_out(v); return 0 }
19func vh_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
20
21func main() -> i64 {
22 vh_puts("=== NISHI PUBLISHER <- video-room handoff: REQUEST (pub_submit) then the publisher SHIPS ===\n")
23 let client: *u8 = "web_assets/vroom_client.html\x00" as *u8
24 let q: *u8 = "knowledge/publish/vroom-queue.tsv\x00" as *u8
25 let led: *u8 = "knowledge/publish/vroom-ledger.tsv\x00" as *u8
26 let stageroot: *u8 = "knowledge/publish/vroom-stage\x00" as *u8
27 let liveroot: *u8 = "knowledge/publish/vroom-live\x00" as *u8
28 let live_client: *u8 = "knowledge/publish/vroom-live/vroom_client.html\x00" as *u8
29
30 if vh_exists(client) == 0 { vh_puts(" FATAL: vroom_client.html not present in web_assets/\n"); sys_exit(1); return 1 }
31 pub_init()
32 sys_mkdir(stageroot, 0x1ed)
33 sys_mkdir(liveroot, 0x1ed)
34
35 // 1. REQUEST -- the room workstream submits a publish request (sha256 of the client); decoupled, durable.
36 let s1: i64 = pub_submit_to(q, client, "vroom_client.html\x00" as *u8, "nishifamily\x00" as *u8, "nishi-vroom\x00" as *u8, "internal\x00" as *u8)
37 vh_puts(" [vroom] pub_submit client -> "); vh_putn(s1); vh_puts("\n")
38
39 // 2. SHIP -- the publisher owns this: serialize -> idempotent -> stage -> VERIFY-sha -> ATOMIC-promote -> ledger.
40 let pubd: i64 = pub_run_full(q, led, stageroot, liveroot, "publish:vroom\x00" as *u8)
41 vh_puts(" [publisher] pub_run_full -> published_this_pass="); vh_putn(pubd); vh_puts("\n")
42
43 var ok: i64 = 0
44 if vh_exists(live_client) == 1 { ok = 1 }
45 vh_puts(" landed_in_liveroot="); vh_putn(ok); vh_puts(" / 1 (vroom_client.html)\n")
46 if ok == 1 {
47 vh_puts(" SHIPPED by the Nishi Publisher -> knowledge/publish/vroom-live/ (sha-verified, ledgered, isolated vroom queue)\n")
48 vh_puts(" COORDINATED: room REQUESTED, publisher SHIPPED (NO direct SSH push). OUTWARD live-root -> nishifamily.com/video = OPERATOR-GATED (R6 outward + R8 transport) + needs the live relay daemon on the host.\n")
49 sys_exit(0); return 0
50 }
51 vh_puts(" publisher did not promote (idempotent if already live at the same sha, or a verify hold)\n")
52 sys_exit(1); return 1
53}