code wiki / _hdl_build / nx_pub_game_e2e_gate.nx
nx_pub_game_e2e_gate.nx source
↩ module page · 64 lines · 5091 B
1// nx_pub_game_e2e_gate.nx -- R8: the GAME is the publisher's FIRST REAL CUSTOMER, end-to-end. The real built
2// artifacts (knowledge/arcade.html + knowledge/sovereign-games.html) are pub_submit'd, then pub_run_full carries
3// them through the WHOLE pipeline (queue → serialize → idempotent → stage → VERIFY → atomic-promote → ledger)
4// into a local site-root model. Asserts: both published; the LIVE bytes are byte-identical to what we built
5// (sha match -> the live game IS our game); a re-run publishes 0 (no double-ship). The only remaining step to go
6// truly live is the sovereign transport push of liveroot -> nishifamily.com (operator-gated). Sovereign, per-wsid.
7// license_tier: ORIGINAL expect_exit: 0
8import "nx_syscalls.nx"
9import "nx_publisher.nx"
10import "nx_runpath.nx"
11
12func g_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
13func g_n(v: i64) -> i64 { var m: i64=v; if m<0{g_w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 }
14func g_row(id: *u8, ok: i64, pass: *i64) -> i64 { g_w(" " as *u8); g_w(id); g_w(": " as *u8); if ok==1 { g_w("OK\n" as *u8); pass[0]=pass[0]+1 } else { g_w("FAIL\n" as *u8) } return 0 }
15func e_reset(path: *u8) -> i64 { let fd: i64 = sys_openat_wr(path, 0x1a4); if fd >= 0 { sys_close(fd) } return 0 }
16func e_count(path: *u8) -> i64 {
17 let lenp: *i64 = sys_mmap(8) as *i64; let data: *u8 = sys_read_file(path, lenp)
18 if (data as i64) == 0 { return 0 }
19 let n: i64 = lenp[0]; var i: i64 = 0; var c: i64 = 0
20 while i < n { if data[i]==(10 as u8){ c=c+1 } i=i+1 }
21 return c
22}
23
24func main() -> i64 {
25 let pass: *i64 = sys_mmap(8) as *i64; pass[0]=0
26 g_w("=== NX-PUBLISHER GAME E2E (the game flows through the WHOLE publisher to a live site-root) ===\n" as *u8)
27 let wsid: *u8 = sys_mmap(64); rp_wsid(wsid); rp_ensure(wsid)
28 let queue: *u8 = sys_mmap(512); rp_path(wsid, "e2e_queue" as *u8, queue)
29 let ledger: *u8 = sys_mmap(512); rp_path(wsid, "e2e_ledger" as *u8, ledger)
30 let stageroot: *u8 = sys_mmap(512); rp_path(wsid, "e2e_stageroot" as *u8, stageroot); __syscall(83, stageroot as i64, 493, 0, 0, 0, 0)
31 let liveroot: *u8 = sys_mmap(512); rp_path(wsid, "e2e_liveroot" as *u8, liveroot); __syscall(83, liveroot as i64, 493, 0, 0, 0, 0)
32 let lockres: *u8 = sys_mmap(128); var lo: i64=0; var li: i64=0
33 let lpfx: *u8 = "e2e_"; while lpfx[li]!=(0 as u8){ lockres[lo]=lpfx[li]; lo=lo+1; li=li+1 }
34 li=0; while wsid[li]!=(0 as u8){ lockres[lo]=wsid[li]; lo=lo+1; li=li+1 } lockres[lo]=0 as u8
35
36 e_reset(queue); e_reset(ledger)
37 // the GAME workstream REQUESTS publication (it does NOT push directly -- the no-bypass law)
38 let s1: i64 = pub_submit_to(queue, "knowledge/arcade.html" as *u8, "arcade.html" as *u8, "nishifamily" as *u8, "game-ecosystem" as *u8, "outward" as *u8)
39 let s2: i64 = pub_submit_to(queue, "knowledge/sovereign-games.html" as *u8, "sovereign-games.html" as *u8, "nishifamily" as *u8, "game-ecosystem" as *u8, "outward" as *u8)
40
41 let published: i64 = pub_run_full(queue, ledger, stageroot, liveroot, lockres)
42
43 let live_arcade: *u8 = sys_mmap(700); pub_join(liveroot, "arcade.html" as *u8, live_arcade)
44 let live_gallery: *u8 = sys_mmap(700); pub_join(liveroot, "sovereign-games.html" as *u8, live_gallery)
45 let sha_arcade: *u8 = sys_mmap(72); pub_sha_file("knowledge/arcade.html" as *u8, sha_arcade)
46 let sha_gallery: *u8 = sys_mmap(72); pub_sha_file("knowledge/sovereign-games.html" as *u8, sha_gallery)
47 let arcade_ok: i64 = ((pub_exists(live_arcade)==1) as i64) & ((pub_sha_match(live_arcade, sha_arcade)==1) as i64)
48 let gallery_ok: i64 = ((pub_exists(live_gallery)==1) as i64) & ((pub_sha_match(live_gallery, sha_gallery)==1) as i64)
49 let led1: i64 = e_count(ledger)
50 let published2: i64 = pub_run_full(queue, ledger, stageroot, liveroot, lockres) // re-run
51 let led2: i64 = e_count(ledger)
52
53 g_w(" submit rc: arcade="); g_n(s1); g_w(" gallery="); g_n(s2); g_w(" published="); g_n(published); g_w(" ledger="); g_n(led1); g_w("\n")
54 g_w(" live integrity: arcade=="); g_n(arcade_ok); g_w(" gallery=="); g_n(gallery_ok); g_w(" re-run published="); g_n(published2); g_w(" ledger="); g_n(led2); g_w("\n")
55
56 g_row("PUBLISHED THROUGH THE PUBLISHER: both game artifacts went submit->queue->deploy->live" as *u8, (published==2) as i64, pass)
57 g_row("GAME INTEGRITY: live arcade.html is byte-identical to what we built (sha match)" as *u8, arcade_ok, pass)
58 g_row("GAME INTEGRITY: live sovereign-games.html is byte-identical to the source" as *u8, gallery_ok, pass)
59 g_row("IDEMPOTENT: a second pass publishes 0 (publisher will not double-ship the game)" as *u8, ((published2==0) as i64) & ((led2==2) as i64), pass)
60
61 g_w("PUB-GAME-E2E rows=4 pass="); g_n(pass[0])
62 if pass[0]==4 { g_w(" verdict=GREEN\n"); sys_exit(0); return 0 }
63 g_w(" verdict=RED\n"); sys_exit(1); return 1
64}