code wiki / (root) / nx_transport.nx

nx_transport.nx

buildroot/runtime/nx_transport.nx

3903 B68 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind librarytopic transport
docsdependenciesstructsconstsfunctions

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

nx_transport.nx nx_transport_gate.nx

imports: none

imported by: nx_transport_gate.nx

structs

none

consts

16const TP_MAX_FRAMES: i64 = 64
17const TP_FRAME_CAP: i64 = 2048
18const TP_HDR: i64 = 32 // 4 i64 header
19const TP_SLOT: i64 = 2056 // 8 (len) + TP_FRAME_CAP
21const TP_REGION: i64 = 131616

functions

23func tp_h(mem: *u8, i: i64) -> i64 { let p: *i64 = ((mem as i64) + i * 8) as *i64; return p[0] }
24func tp_hset(mem: *u8, i: i64, v: i64) -> i64 { let p: *i64 = ((mem as i64) + i * 8) as *i64; p[0] = v; return 0 }
25func tp_slot_len(mem: *u8, slot: i64) -> *i64 { return ((mem as i64) + TP_HDR + slot * TP_SLOT) as *i64 }
called by 2: tp_sendtp_recv
26func tp_slot_bytes(mem: *u8, slot: i64) -> *u8 { return ((mem as i64) + TP_HDR + slot * TP_SLOT + 8) as *u8 }
called by 2: tp_sendtp_recv
29func tp_open(mem: *u8) -> i64
called by 1: main calls 1: tp_hset
36func tp_send(h: *u8, frame: *u8, len: i64) -> i64
51func tp_recv(h: *u8, out: *u8, cap: i64) -> i64
65func tp_pending(h: *u8) -> i64 { return tp_h(h, 3) }
called by 1: main calls 1: tp_h
68func tp_close(h: *u8) -> i64 { tp_hset(h, 0, 1); return 0 }
called by 1: main calls 1: tp_hset