code wiki / _hdl_build / _galx_serve_setup.nx
_galx_serve_setup.nx source
↩ module page · 49 lines · 2695 B
1// _galx_serve_setup.nx -- OFF-BAND test-data setup for the gallery daemon (not the deliverable).
2// Ingests the two REAL corpus PNGs into the /tmp/galx-serve- namespace using the PROVEN
3// nx_store_ingest_ingest organ (real ingestion, no fake), and writes the CID->path sidecar TSV.
4// Re-runnable (rule 10): a fresh namespace + idempotent ingest. license_tier: ORIGINAL
5import "nx_store_ingest.nx"
6import "nx_seg_store.nx"
7import "nx_syscalls.nx"
8
9func sw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
10
11func freshns(prefix: *u8) -> i64 {
12 let mfn: *u8 = sys_mmap(64)
13 var mo: i64 = 0
14 while (prefix[mo] & 0xff) != 0 { mfn[mo] = prefix[mo]; mo = mo + 1 }
15 let suf: *u8 = "manifest.txt" as *u8
16 var so: i64 = 0
17 while (suf[so] & 0xff) != 0 { mfn[mo + so] = suf[so]; so = so + 1 }
18 mfn[mo + so] = 0 as u8
19 let cfd: i64 = sys_openat_wr(mfn, 0x1a4)
20 if cfd >= 0 { sys_close(cfd) }
21 return 0
22}
23
24func main() -> i64 {
25 let prefix: *u8 = "/tmp/galx-serve-" as *u8
26 freshns(prefix)
27 let lenA: *i64 = sys_mmap(16) as *i64
28 let bufA: *u8 = sys_read_file("_g1work/genrec_multi.png" as *u8, lenA)
29 if (bufA as i64) == 0 { sw("SETUP FAIL: cannot read _g1work/genrec_multi.png\n" as *u8); sys_exit(1); return 1 }
30 let lenB: *i64 = sys_mmap(16) as *i64
31 let bufB: *u8 = sys_read_file("_g1work/genrec_multi_b.png" as *u8, lenB)
32 if (bufB as i64) == 0 { sw("SETUP FAIL: cannot read _g1work/genrec_multi_b.png\n" as *u8); sys_exit(1); return 1 }
33 let rA: i64 = nx_store_ingest_ingest(bufA, lenA[0], prefix)
34 let rB: i64 = nx_store_ingest_ingest(bufB, lenB[0], prefix)
35 // write the CID->path sidecar TSV (the two PROVEN real CIDs from _galx_ingest_gate.nx:103-104)
36 let fd: i64 = sys_openat_wr("knowledge/status/galx_cid_paths.tsv" as *u8, 0x1a4)
37 if fd < 0 { sw("SETUP FAIL: sidecar unwritable\n" as *u8); sys_exit(1); return 1 }
38 sw("SETUP rA="); let wb: *u8 = sys_mmap(8); wb[0]=(48+rA) as u8; sys_write(1,wb,1); sw(" rB="); wb[0]=(48+rB) as u8; sys_write(1,wb,1); sw("\n");
39 let l1: *u8 = "nxc1-6a59140bf7491b8c70f94820872874c73d3737603db1dc100a6bdcfbb2081738\t/mnt/c/Users/elder/nishi-core/nxc2/_g1work/genrec_multi.png\n" as *u8
40 var n1: i64=0; while l1[n1]!=(0 as u8){n1=n1+1}
41 sys_write(fd, l1, n1)
42 let l2: *u8 = "nxc1-8600a9243cc7614463a825e3a1129f37f3c047de5ea52726bfa764baa87e58b5\t/mnt/c/Users/elder/nishi-core/nxc2/_g1work/genrec_multi_b.png\n" as *u8
43 var n2: i64=0; while l2[n2]!=(0 as u8){n2=n2+1}
44 sys_write(fd, l2, n2)
45 sys_close(fd)
46 sw("SETUP done: 2 real images ingested into /tmp/galx-serve-, sidecar written\n" as *u8)
47 sys_exit(0)
48 return 0
49}