nx_transport.nx
buildroot/runtime/nx_transport.nx
about
nx_transport.nx -- SOVEREIGN transport CONTRACT + loopback reference impl (operator 2026-07-04: "we
wont have websocket ... built from the hardware rung up"). A TRANSPORT moves opaque wire FRAMES between
endpoints. The core PRODUCES/CONSUMES frames (vc_wire_pack/parse, FEC, sequencing); the transport only
MOVES bytes. The browser adapter satisfies this contract with WebSocket; the NishiOS adapter satisfies
it with the sovereign datagram/QUIC leg (task #15). Nothing above the transport names WebSocket -> swap
the impl, everything else is unchanged. Reliability/ordering VARY by impl (WS = reliable-ordered,
datagram = best-effort); the core's jitter-buffer / NACK / FEC rungs provide the reliability layer ABOVE
this best-effort mover -- so the CONTRACT is only "move a frame, in order, intact, or drop it".
This reference impl is a bounded FIFO ring in a FLAT memory region (WAT-safe: no struct -> compiles to
wasm for the browser adapter's buffer AND native for the NishiOS queue, from one source). Layout:
header i64[4] @ byte 0 : [0]=closed [1]=head [2]=tail [3]=count
frame slots @ byte TP_HDR : slot i = [len:i64][bytes:TP_FRAME_CAP], stride TP_SLOT
license_tier: ORIGINAL
dependencies 0 imports · 1 importers
imports: none
imported by: nx_transport_gate.nx
structs
| none |
consts
| 16 | const TP_MAX_FRAMES: i64 = 64 |
| 17 | const TP_FRAME_CAP: i64 = 2048 |
| 18 | const TP_HDR: i64 = 32 // 4 i64 header |
| 19 | const TP_SLOT: i64 = 2056 // 8 (len) + TP_FRAME_CAP |
| 21 | const TP_REGION: i64 = 131616 |
functions
| 23 | func tp_h(mem: *u8, i: i64) -> i64 { let p: *i64 = ((mem as i64) + i * 8) as *i64; return p[0] } |
| 24 | func tp_hset(mem: *u8, i: i64, v: i64) -> i64 { let p: *i64 = ((mem as i64) + i * 8) as *i64; p[0] = v; return 0 } |
| 25 | func tp_slot_len(mem: *u8, slot: i64) -> *i64 { return ((mem as i64) + TP_HDR + slot * TP_SLOT) as *i64 } |
| 26 | func tp_slot_bytes(mem: *u8, slot: i64) -> *u8 { return ((mem as i64) + TP_HDR + slot * TP_SLOT + 8) as *u8 } |
| 29 | func tp_open(mem: *u8) -> i64 |
| 36 | func tp_send(h: *u8, frame: *u8, len: i64) -> i64 |
| 51 | func tp_recv(h: *u8, out: *u8, cap: i64) -> i64 |
| 65 | func tp_pending(h: *u8) -> i64 { return tp_h(h, 3) } |
| 68 | func tp_close(h: *u8) -> i64 { tp_hset(h, 0, 1); return 0 } |