code wiki / _hdl_build / nx_ng_publish.nx
nx_ng_publish.nx source
↩ module page · 94 lines · 6770 B
1// nx_ng_publish.nx -- hand the NEURAL-GRAPHICS visible artifacts to the Nishi Publisher (operator 2026-06-22:
2// "stop doing these local file show-and-tell, it needs to be nishifamily.com hosted"). The neural-graphics
3// workstream REQUESTS; the publisher SHIPS (NO direct push -- the sites.elf-outage law). Mirrors
4// nx_pub_reader_handoff: import the real publisher, pub_submit each artifact to an ISOLATED ng queue, then run
5// the publisher's full pipeline (serialize -> idempotent sha-skip -> stage -> VERIFY-sha -> ATOMIC-promote ->
6// ledger, pub_mkdirp makes the nested dests) into the CANONICAL served liveroot knowledge/publish/live (served
7// by nx_pub_serve). Dests under sites/nishifamily/ = the nishifamily.com serving structure.
8//
9// HONEST: this lands the artifacts in the publisher's canonical liveroot (served sovereignly by nx_pub_serve).
10// The final OUTWARD transport liveroot -> the public nishifamily.com host (.240 NAS, :443) is the OPERATOR-GATED
11// hub-side leg (the publisher emits/stages; hosting applies; the spoke's NAS verify-mount is empty). license_tier: ORIGINAL
12import "nx_publisher.nx"
13import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc)
14import "nx_syscalls.nx"
15
16func ph_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != 0 as u8 { n = n + 1 } sys_write(1, s, n); return 0 }
17// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer
18// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the
19// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls).
20// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign.
21func ph_putn(v: i64) -> i64 { nxi_out(v); return 0 }
22func ph_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 }
23
24func main() -> i64 {
25 ph_puts("=== NISHI PUBLISHER <- neural-graphics handoff: REQUEST (pub_submit) then the publisher SHIPS ===\n" as *u8)
26 let gsview: *u8 = "web_assets/ng_gsplat_view.html\x00" as *u8
27 let geneal: *u8 = "web_assets/genealogy_tree.html\x00" as *u8
28 let q: *u8 = "knowledge/publish/ng-queue.tsv\x00" as *u8
29 let led: *u8 = "knowledge/publish/ng-ledger.tsv\x00" as *u8
30 let stageroot: *u8 = "knowledge/publish/ng-stage\x00" as *u8
31 let liveroot: *u8 = "knowledge/publish/live\x00" as *u8
32 let live_gsview: *u8 = "knowledge/publish/live/sites/nishifamily/ng/ng_gsplat_view.html\x00" as *u8
33 let live_geneal: *u8 = "knowledge/publish/live/sites/nishifamily/genealogy/genealogy_tree.html\x00" as *u8
34 let world: *u8 = "web_assets/ng_world_view.html\x00" as *u8
35 let live_world: *u8 = "knowledge/publish/live/sites/nishifamily/ng/ng_world_view.html\x00" as *u8
36 let bowl: *u8 = "web_assets/ng_singing_bowl_binaural.wav\x00" as *u8
37 let live_bowl: *u8 = "knowledge/publish/live/sites/nishifamily/ng/ng_singing_bowl_binaural.wav\x00" as *u8
38 let mediapg: *u8 = "web_assets/media_audio.html\x00" as *u8
39 let live_mediapg: *u8 = "knowledge/publish/live/sites/nishifamily/media/audio.html\x00" as *u8
40
41 if ph_exists(gsview) == 0 { ph_puts(" FATAL: gsplat viewer not emitted -- run nx_ng_gsview first\n" as *u8); sys_exit(1); return 1 }
42 pub_init()
43 sys_mkdir(stageroot, 0x1ed)
44 sys_mkdir(liveroot, 0x1ed)
45
46 // 1. REQUEST -- submit publish requests (sha256 of content); decoupled, durable, isolated ng queue.
47 let s1: i64 = pub_submit_to(q, gsview, "sites/nishifamily/ng/ng_gsplat_view.html\x00" as *u8, "nishifamily\x00" as *u8, "neuralgfx\x00" as *u8, "internal\x00" as *u8)
48 ph_puts(" [neuralgfx] pub_submit gsplat-viewer -> " as *u8); ph_putn(s1); ph_puts("\n" as *u8)
49 var have_world: i64 = 0
50 if ph_exists(world) == 1 {
51 have_world = 1
52 let sw: i64 = pub_submit_to(q, world, "sites/nishifamily/ng/ng_world_view.html\x00" as *u8, "nishifamily\x00" as *u8, "neuralgfx\x00" as *u8, "internal\x00" as *u8)
53 ph_puts(" [neuralgfx] pub_submit world-view -> " as *u8); ph_putn(sw); ph_puts("\n" as *u8)
54 }
55 var have_bowl: i64 = 0
56 if ph_exists(bowl) == 1 {
57 have_bowl = 1
58 let sb: i64 = pub_submit_to(q, bowl, "sites/nishifamily/ng/ng_singing_bowl_binaural.wav\x00" as *u8, "nishifamily\x00" as *u8, "neuralgfx\x00" as *u8, "internal\x00" as *u8)
59 ph_puts(" [neuralgfx] pub_submit singing-bowl.wav -> " as *u8); ph_putn(sb); ph_puts("\n" as *u8)
60 }
61 var have_media: i64 = 0
62 if ph_exists(mediapg) == 1 {
63 have_media = 1
64 let sm: i64 = pub_submit_to(q, mediapg, "sites/nishifamily/media/audio.html\x00" as *u8, "nishifamily\x00" as *u8, "neuralgfx\x00" as *u8, "internal\x00" as *u8)
65 ph_puts(" [neuralgfx] pub_submit media/audio.html (the AUDIO TAB) -> " as *u8); ph_putn(sm); ph_puts("\n" as *u8)
66 }
67 var have_geneal: i64 = 0
68 if ph_exists(geneal) == 1 {
69 have_geneal = 1
70 let s2: i64 = pub_submit_to(q, geneal, "sites/nishifamily/genealogy/genealogy_tree.html\x00" as *u8, "nishifamily\x00" as *u8, "neuralgfx\x00" as *u8, "internal\x00" as *u8)
71 ph_puts(" [neuralgfx] pub_submit genealogy-tree -> " as *u8); ph_putn(s2); ph_puts("\n" as *u8)
72 }
73
74 // 2. SHIP -- the publisher owns this: serialize -> idempotent -> stage -> VERIFY-sha -> ATOMIC-promote -> ledger.
75 let pubd: i64 = pub_run_full(q, led, stageroot, liveroot, "publish:neuralgfx\x00" as *u8)
76 ph_puts(" [publisher] pub_run_full -> published_this_pass=" as *u8); ph_putn(pubd); ph_puts("\n" as *u8)
77
78 var ok: i64 = 0
79 if ph_exists(live_gsview) == 1 { ok = ok + 1 }
80 var want: i64 = 1
81 if have_world == 1 { want = want + 1; if ph_exists(live_world) == 1 { ok = ok + 1 } }
82 if have_bowl == 1 { want = want + 1; if ph_exists(live_bowl) == 1 { ok = ok + 1 } }
83 if have_media == 1 { want = want + 1; if ph_exists(live_mediapg) == 1 { ok = ok + 1 } }
84 if have_geneal == 1 { want = want + 1; if ph_exists(live_geneal) == 1 { ok = ok + 1 } }
85 ph_puts(" landed_in_canonical_liveroot=" as *u8); ph_putn(ok); ph_puts(" / " as *u8); ph_putn(want); ph_puts(" (knowledge/publish/live/sites/nishifamily/...)\n" as *u8)
86
87 if ok == want {
88 ph_puts(" SHIPPED by the Nishi Publisher -> knowledge/publish/live/sites/nishifamily/ (sha-verified, ledgered, isolated ng queue); served by nx_pub_serve.\n" as *u8)
89 ph_puts(" COORDINATED: neural-graphics REQUESTED, publisher SHIPPED (NO direct push). OUTWARD liveroot -> public nishifamily.com (.240 NAS) = OPERATOR-GATED hub-side transport (publisher stages; hosting applies).\n" as *u8)
90 sys_exit(0); return 0
91 }
92 ph_puts(" publisher did not promote all (idempotent if already live, or a verify hold) -- check ng-ledger\n" as *u8)
93 sys_exit(1); return 1
94}