nx_mesh_stream.nx
buildroot/runtime/nx_mesh_stream.nx
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
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
structs
| none |
consts
| 16 | const K_MAGIC_65536: i64 = 65536 |
| 17 | const K_MAGIC_4096: i64 = 4096 |
| 18 | const K_MAGIC_1048576: i64 = 1048576 |
functions
| 20 | func 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 |
| 21 | func 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 } |
| 22 | func sm_b(v: i64) -> i64 { if v == 1 { sm_p("1" as *u8) } else { sm_p("0" as *u8) } return 0 } |
| 23 | func sm_num(buf: *u8, o: i64, v: i64) -> i64 |
| 33 | func sm_q(buf: *u8, o: i64) -> i64 { buf[o] = 34 as u8; return o + 1 } // " called by 1: sm_build |
| 34 | func 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 |
| 35 | func 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 |
| 39 | func sm_build(buf: *u8, total: i64) -> i64 |
| 68 | func sm_count(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 called by 1: sm_gate |
| 80 | func sm_rfind(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 called by 1: sm_gate |
| 93 | func sm_gate() -> i64 |
| 148 | func main(argc: i64, argv: *i64) -> i64 |