code wiki / (root) / nx_mesh_stream.nx

nx_mesh_stream.nx

buildroot/runtime/nx_mesh_stream.nx

8700 B163 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic mesh
docsdependenciesstructsconstsfunctions

about

nx_mesh_stream.nx -- WORKER MESH: STREAMING responses (the Triton decoupled / OpenAI-stream analog). A long job (image diffusion steps, video frames, LLM tokens) should report progress AS IT HAPPENS, not block until done. This emits a valid Server-Sent-Events stream (text/event-stream, the same shape a browser EventSource + our /api/events already speak): an `accepted` event, then one `progress` event per step (step/total/pct), then a terminal `result` event carrying the artifact URL. A client renders a live progress bar and knows exactly when the job is done. This is the streaming PROTOCOL/emitter (the sovereign contribution); the worker-side hook (real diffusion-step or frame callbacks) feeds the step numbers. For video on the west 3090 this is the natural frame-delivery channel. CLI: (no args) -> self-test GATE (SSE framing + one progress-per-step + monotonic pct + terminal result) stream <total> -> emit a real text/event-stream to stdout (the HTTP response body in a daemon) NO fake greens: the gate parses the emitted bytes back and proves the frame count, that pct rises 0->100, and that the stream TERMINATES with exactly one result (a client can detect completion). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_runtime.nx nx_mesh_stream.nx

imports: nx_syscalls.nxnx_runtime.nx

imported by: nobody (leaf or entry point)

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

main sm_streq sm_atoi sys_mmap sm_build sm_lit sm_q sm_num sys_mmap ↻ sys_write sm_gate sm_p sys_write ↻ sys_mmap ↻ sm_build ↻ sm_count sm_rfind sm_b sm_p ↻ sys_openat_wr sys_write ↻ sys_close

structs

none

consts

16const K_MAGIC_65536: i64 = 65536
17const K_MAGIC_4096: i64 = 4096
18const K_MAGIC_1048576: i64 = 1048576

functions

20func sm_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 }
called by 1: sm_build
21func sm_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 2: sm_bsm_gate calls 1: sys_write
22func sm_b(v: i64) -> i64 { if v == 1 { sm_p("1" as *u8) } else { sm_p("0" as *u8) } return 0 }
called by 1: sm_gate calls 1: sm_p
23func sm_num(buf: *u8, o: i64, v: i64) -> i64
called by 1: sm_build calls 1: sys_mmap
33func sm_q(buf: *u8, o: i64) -> i64 { buf[o] = 34 as u8; return o + 1 } // "
called by 1: sm_build
34func sm_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
35func sm_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while b[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if a[i] != (0 as u8) { return 0 } return 1 }
called by 1: main
39func sm_build(buf: *u8, total: i64) -> i64
called by 2: sm_gatemain calls 3: sm_litsm_qsm_num
68func sm_count(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64
called by 1: sm_gate
80func sm_rfind(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64
called by 1: sm_gate
93func sm_gate() -> i64
148func main(argc: i64, argv: *i64) -> i64