code wiki / _hdl_build / nx_pub_vroom_emit_handoff.nx
nx_pub_vroom_emit_handoff.nx source
↩ module page · 71 lines · 4960 B
1// nx_pub_vroom_emit_handoff.nx -- the EMITTED /video/ client deployed BY THE NISHI PUBLISHER (operator
2// 2026-06-23: "we have a nishi team with publisher, make sure it's working with that and the publisher
3// deploys"). The flow is now end-to-end sovereign + team-owned: nx_vroom_emit OWNS+emits the client (with
4// the camera-mirror fix) -> THIS organ pub_submits the emitted index.html + app.js to the publisher ->
5// the PUBLISHER ships them (serialize -> idempotent sha-skip -> stage -> VERIFY-sha -> ATOMIC-promote ->
6// ledger). No direct push; the publisher is the deploy authority. We then VERIFY the camera-fix marker
7// survived into the PUBLISHED bytes (strong verify, not a shared string). The liveroot -> live /video/
8// web root transport (R8) + nx_live_verify on the served bytes is the final gate. license_tier: ORIGINAL
9import "nx_publisher.nx"
10import "nx_syscalls.nx"
11
12func hp(s: *u8) -> i64 { var n: i64=0; while s[n]!=0 as u8 { n=n+1 } sys_write(1,s,n); return 0 }
13func hn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let d: *u8=sys_mmap(24); var k: i64=0; while m>0 { d[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var i: i64=k-1; while i>=0 { let o: *u8=sys_mmap(1); o[0]=d[i]; sys_write(1,o,1); i=i-1 } return 0 }
14func hx(p: *u8) -> i64 { let fd: i64=sys_openat_rd(p); if fd<0 { return 0 } sys_close(fd); return 1 }
15func slen2(s: *u8) -> i64 { var n: i64=0; while s[n]!=0 as u8 { n=n+1 } return n }
16func find_sub(hay: *u8, n: i64, needle: *u8) -> i64 {
17 let m: i64=slen2(needle); if m==0 { return 0 }
18 var i: i64=0
19 while i+m<=n { var j: i64=0; var ok: i64=1; while j<m { if hay[i+j]!=needle[j] { ok=0; j=m } else { j=j+1 } } if ok==1 { return i } i=i+1 }
20 return 0-1
21}
22
23func main() -> i64 {
24 hp("=== NISHI PUBLISHER <- emitted /video/ client (organ-emitted SSOT, camera-fix integrated) ===\n")
25 let idx: *u8 = "knowledge/staging/video/index.html\x00" as *u8
26 let app: *u8 = "knowledge/staging/video/app.js\x00" as *u8
27 let q: *u8 = "knowledge/publish/video-queue.tsv\x00" as *u8
28 let led: *u8 = "knowledge/publish/video-ledger.tsv\x00" as *u8
29 let stageroot: *u8 = "knowledge/publish/video-stage\x00" as *u8
30 let liveroot: *u8 = "knowledge/publish/video-live\x00" as *u8
31 let live_idx: *u8 = "knowledge/publish/video-live/video/index.html\x00" as *u8
32 let live_app: *u8 = "knowledge/publish/video-live/video/app.js\x00" as *u8
33
34 if hx(idx)==0 { hp(" FATAL: emitted index.html missing -- run nx_vroom_emit first\n"); sys_exit(1); return 1 }
35 if hx(app)==0 { hp(" FATAL: emitted app.js missing -- run nx_vroom_emit first\n"); sys_exit(1); return 1 }
36 pub_init()
37 sys_mkdir(stageroot, 0x1ed)
38 sys_mkdir(liveroot, 0x1ed)
39
40 // 1. REQUEST -- submit both emitted artifacts (subdir dests; publisher pub_mkdirp creates them)
41 let s1: i64 = pub_submit_to(q, idx, "video/index.html\x00" as *u8, "nishifamily\x00" as *u8, "nishi-vroom\x00" as *u8, "internal\x00" as *u8)
42 hp(" [emit] pub_submit index.html -> "); hn(s1); hp("\n")
43 let s2: i64 = pub_submit_to(q, app, "video/app.js\x00" as *u8, "nishifamily\x00" as *u8, "nishi-vroom\x00" as *u8, "internal\x00" as *u8)
44 hp(" [emit] pub_submit app.js -> "); hn(s2); hp("\n")
45
46 // 2. SHIP -- the publisher owns it: serialize -> sha-verify -> atomic-promote -> ledger
47 let pubd: i64 = pub_run_full(q, led, stageroot, liveroot, "publish:vroom-video\x00" as *u8)
48 hp(" [publisher] pub_run_full -> published_this_pass="); hn(pubd); hp("\n")
49
50 // 3. STRONG VERIFY -- both landed AND the camera-fix marker survived into the PUBLISHED bytes
51 var landed: i64 = 0
52 if hx(live_idx)==1 { landed=landed+1 }
53 if hx(live_app)==1 { landed=landed+1 }
54 let lb: *i64 = sys_mmap(8) as *i64
55 var css_pub: i64 = 0 - 1; var self_pub: i64 = 0 - 1
56 if hx(live_idx)==1 { let b: *u8=sys_read_file(live_idx, lb); if (b as i64)!=0 { css_pub=find_sub(b, lb[0], "scaleX(-1)" as *u8) } }
57 if hx(live_app)==1 { let b2: *u8=sys_read_file(live_app, lb); if (b2 as i64)!=0 { self_pub=find_sub(b2, lb[0], "tile self" as *u8) } }
58 hp(" landed_in_liveroot="); hn(landed); hp("/2 ; published index.html has scaleX(-1) @"); hn(css_pub); hp(" ; published app.js has 'tile self' @"); hn(self_pub); hp("\n")
59
60 var ok: i64 = 1
61 if landed != 2 { ok=0 }
62 if css_pub < 0 { ok=0 }
63 if self_pub < 0 { ok=0 }
64 if ok==1 {
65 hp(" PUBLISHER DEPLOYED the organ-emitted client (camera-fix VERIFIED in the published bytes, sha-verified + ledgered).\n")
66 hp(" REMAINING (final gate): R8 transport liveroot -> live /video/ web root, then nx_live_verify must find scaleX(-1) in the SERVED bytes. No 'done' before that.\n")
67 sys_exit(0); return 0
68 }
69 hp(" HELD: not both landed, or the camera-fix marker did NOT survive into the published bytes (would be a silent regression -- caught).\n")
70 sys_exit(1); return 1
71}