code wiki / _hdl_build / nx_hub_deploy_bundle.nx
nx_hub_deploy_bundle.nx source
↩ module page · 50 lines · 3918 B
1// nx_hub_deploy_bundle.nx -- queue the DATA-DRIVEN hub to the publisher (outward, operator-approval-gated)
2// since we are NOT local to the NAS: the rebuilt nx_hub_gw (reads cards/roles/maturity from the sovereign
3// native store, no tsv) PLUS the nx_native_config store files it reads. All via pub_submit -> approval queue.
4// nx_hub_gw.elf -> /volume1/ai/hub/nx_hub_gw.elf.new
5// knowledge/store/hub-cards-* -> /volume1/ai/hub/knowledge/store/ (manifest + seg .docs/.idx)
6// knowledge/store/hub-roles-* -> /volume1/ai/hub/knowledge/store/
7// The gateway reads "knowledge/store/hub-*" relative to its CWD; the hostctl launch cd's to /volume1/ai/hub
8// (mirrors the other services), so the dest prefix is /volume1/ai/hub/knowledge/store/.
9// Pre-req on NAS (operator/publisher): mkdir -p /volume1/ai/hub/knowledge/store. Promote = operator selfswap.
10// Sovereign: nx_syscalls + nx_publisher. license_tier: ORIGINAL
11import "nx_syscalls.nx"
12import "nx_publisher.nx"
13func pp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
14func pn(v: i64) -> i64 { var m: i64=v; if m<0 { sys_write(1,"-" as *u8,1); m=0-m } let bb: *u8=sys_mmap(28); var k: i64=0; if m==0 { bb[0]=48 as u8; sys_write(1,bb,1); return 0 } let t: *u8=sys_mmap(28); while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var i: i64=0; while i<k { bb[i]=t[k-1-i]; i=i+1 } sys_write(1,bb,k); return 0 }
15
16// sovereign self-stage (read+write syscalls, no shell cp) of the build output to a durable repo path.
17func stage(src: *u8, dst: *u8) -> i64 {
18 let lenp: *i64 = sys_mmap(8) as *i64
19 let data: *u8 = sys_read_file(src, lenp)
20 if (data as i64) == 0 { return 0 - 1 }
21 let fd: i64 = sys_openat_wr(dst, 493)
22 if fd < 0 { return 0 - 2 }
23 sys_write(fd, data, lenp[0])
24 sys_close(fd)
25 return 0
26}
27
28func sub(src: *u8, dst: *u8, label: *u8) -> i64 {
29 let r: i64 = pub_submit(src, dst, "nishifamily.com" as *u8, "elderwesto" as *u8, "outward" as *u8)
30 pp(" submit " as *u8); pp(label); pp(" -> " as *u8)
31 if r == 1 { pp("QUEUED\n" as *u8); return 1 }
32 pp("FAIL r=" as *u8); pn(r); pp("\n" as *u8); return 0
33}
34
35func main(argc: i64, argv: *i64) -> i64 {
36 pp("=== nx_hub_deploy_bundle: data-driven hub (gateway + native-store data) -> publisher queue (outward, operator-approval-gated) ===\n" as *u8)
37 let st: i64 = stage("/tmp/nx_hub_gw.sov.elf" as *u8, "_offc/nx_hub_gw.elf" as *u8)
38 pp(" stage nx_hub_gw rc=" as *u8); pn(st); pp("\n" as *u8)
39 var ok: i64 = 0
40 ok = ok + sub("_offc/nx_hub_gw.elf" as *u8, "/volume1/ai/hub/nx_hub_gw.elf.new" as *u8, "nx_hub_gw.elf (data-driven, native store)" as *u8)
41 ok = ok + sub("knowledge/store/hub-cards-manifest.txt" as *u8, "/volume1/ai/hub/knowledge/store/hub-cards-manifest.txt" as *u8, "hub-cards manifest" as *u8)
42 ok = ok + sub("knowledge/store/hub-cards-seg-177542667.docs" as *u8, "/volume1/ai/hub/knowledge/store/hub-cards-seg-177542667.docs" as *u8, "hub-cards seg.docs" as *u8)
43 ok = ok + sub("knowledge/store/hub-cards-seg-177542667.idx" as *u8, "/volume1/ai/hub/knowledge/store/hub-cards-seg-177542667.idx" as *u8, "hub-cards seg.idx" as *u8)
44 ok = ok + sub("knowledge/store/hub-roles-manifest.txt" as *u8, "/volume1/ai/hub/knowledge/store/hub-roles-manifest.txt" as *u8, "hub-roles manifest" as *u8)
45 ok = ok + sub("knowledge/store/hub-roles-seg-178058326.docs" as *u8, "/volume1/ai/hub/knowledge/store/hub-roles-seg-178058326.docs" as *u8, "hub-roles seg.docs" as *u8)
46 ok = ok + sub("knowledge/store/hub-roles-seg-178058326.idx" as *u8, "/volume1/ai/hub/knowledge/store/hub-roles-seg-178058326.idx" as *u8, "hub-roles seg.idx" as *u8)
47 pp("RESULT queued=" as *u8); pn(ok); pp("/7 (operator approve+promote; mkdir -p /volume1/ai/hub/knowledge/store first; then selfswap nx_hub_gw)\n" as *u8)
48 if ok == 7 { sys_exit(0); return 0 }
49 sys_exit(1); return 1
50}