code wiki / (root) / nx_mesh_gen.nx

nx_mesh_gen.nx

buildroot/runtime/nx_mesh_gen.nx

18487 B347 linesdepth 6pulls 10 transitivereach 0 importersview sourcekind tooltopic mesh
docsdependenciesstructsconstsfunctions

about

nx_mesh_gen.nx -- WORKER MESH R2: the SOVEREIGN end-to-end actuator. Retires the curl/base64 shell from the dispatch loop. Runs on the orchestrator (NAS): given a prompt, it POSTs a gen job to a GPU worker over sovereign TCP (nx_http_client), drains the OpenAI-compat response, extracts the base64 image, DECODES it (nx_base64), and WRITES the PNG to the gallery docroot -- a complete NAS-organ -> worker -> gallery loop with ZERO shell. CLI: (no args) -> self-test GATE (b64 round-trip + JSON body build + response extraction) gen <prompt> <outpath> -> live: POST to the gpu-image worker (laptop 5080), decode, write <outpath> gen <prompt> <outpath> <a> <b> <c> <d> -> same, to an explicit worker ipv4 a.b.c.d:7861 The capability enforcement is nx_worker_dispatch's job (proven, deny-by-default); this is the ACTUATION it calls. NO fake greens: the gate proves decode correctness + that the extractor pulls the value from a real JSON shape. license_tier: ORIGINAL

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_connect.nx nx_runtime.nx nx_http_client.nx nx_base64.nx nx_mesh_gen.nx

imports: nx_syscalls.nxnx_connect.nxnx_runtime.nxnx_http_client.nxnx_base64.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main mg_w sys_write mg_atoi mg_p mg_w ↻ mg_pn mg_wn sys_mmap sys_write ↻ mg_gen sys_mmap ↻ nx_http_client_sockaddr_ip sys_socket nx_connect_bounded nx_fcntl sys_connect sys_mmap ↻ sys_poll sys_close mg_body mg_lit nx_http_client_build_reque nx_dec_emit_u63 sys_write ↻ mg_drain sys_read mg_extract_b64 mg_find b64_decode b64_grab b64_dec_char sys_openat_wr mg_p ↻ mg_pn ↻ mg_genbatch sys_mmap ↻ nx_http_client_sockaddr_ip ↻ sys_socket ↻ nx_connect_bounded ↻

structs

none

consts

17const MG_MAGIC_8192: i64 = 8192
18const MG_MAGIC_16384: i64 = 16384
19const MG_MAGIC_8388608: i64 = 8388608
20const MG_MAGIC_4096: i64 = 4096
21const MG_MAGIC_5080: i64 = 5080
23const MG_PORT: i64 = 7861
24const MG_RESP_CAP: i64 = 2097152 // 2 MB (image response ~550KB base64)

functions

26func mg_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 2: mg_pmain calls 1: sys_write
27func mg_wn(fd: i64, v: i64) -> i64
called by 1: mg_pn calls 2: sys_mmapsys_write
40func mg_p(s: *u8) -> i64 { return mg_w(1, s) }
called by 4: mg_genmg_genbatchmg_gatemain calls 1: mg_w
41func mg_pn(v: i64) -> i64 { return mg_wn(1, v) }
called by 4: mg_genmg_genbatchmg_gatemain calls 1: mg_wn
42func mg_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
43func mg_lit(buf: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { buf[o+i] = s[i]; i = i + 1 } return o + i }
44func mg_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v }
called by 1: main
48func mg_body(buf: *u8, prompt: *u8) -> i64
called by 2: mg_genmg_gate calls 1: mg_lit
62func mg_find(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64
74func mg_extract_b64(buf: *u8, n: i64, vstartbox: *i64, vlenbox: *i64) -> i64
called by 2: mg_genmg_gate calls 1: mg_find
93func mg_drain(fd: i64, buf: *u8, cap: i64) -> i64
called by 2: mg_genmg_genbatch calls 1: sys_read
107func mg_gen(a: i64, b: i64, c: i64, d: i64, prompt: *u8, outpath: *u8) -> i64
140func mg_num_buf(buf: *u8, o: i64, v: i64) -> i64
called by 2: mg_body_nmg_genbatch calls 1: sys_mmap
150func mg_body_n(buf: *u8, prompt: *u8, nval: i64) -> i64
called by 1: mg_genbatch calls 2: mg_litmg_num_buf
162func mg_find_from(buf: *u8, n: i64, pat: *u8, pl: i64, start: i64) -> i64
called by 1: mg_extract_from
174func mg_extract_from(buf: *u8, n: i64, start: i64, vsb: *i64, vlb: *i64) -> i64
called by 2: mg_genbatchmg_gate calls 1: mg_find_from
191func mg_genbatch(a: i64, b: i64, c: i64, d: i64, prompt: *u8, kk: i64, outprefix: *u8) -> i64
233func mg_gate() -> i64
304func main(argc: i64, argv: *i64) -> i64