nx_h2_flow.nx
buildroot/runtime/nx_h2_flow.nx
about
nx_h2_flow.nx -- TUTOR-BOOTSTRAP SCAFFOLD (Claude, authored under the R4-H2
HTTP/2-transport-ladder workflow), NOT credited as team self-authoring.
R4-H2-005 of the sovereign HTTP/2 transport ladder
(knowledge/specs/2026-06-13-http2-transport-ladder.md). HTTP/2 flow control
(RFC 9113 §5.2 / §6.9). Like the stream state machine this organ emits almost
no wire bytes -- it is the WINDOW ARITHMETIC the RFC dictates: a connection
window (stream 0) and a per-stream window each initialised to
SETTINGS_INITIAL_WINDOW_SIZE (default 65535), debited by the ENTIRE payload of
every DATA frame (and ONLY DATA frames, §5.2.1), replenished by WINDOW_UPDATE
increments, with the hard ceiling 2^31-1. The VALUE SEMANTICS are an allowed
internet-boundary requirement (a peer that disagrees about when a window is
exhausted or overflowed cannot interoperate, exactly as it must agree on the
frame bytes); the IMPLEMENTATION is pure NishiLang via nx_cc -> nxasm_x86:
no gcc, no openssl, no nghttp2.
FOUNDED ON (composes, does not reinvent -- anti-orphan law):
- nx_h2_frame.nx (R4-H2-003, GREEN): imported EXACTLY ONCE. It transitively
splices nx_hpack.nx -> nx_str.nx -> syscalls.nx, so we inherit sys_mmap /
sys_write / sys_exit / sys_openat_append / sys_close from that single
import (importing nx_hpack / nx_str / nx_syscalls / nx_tls13 directly TOO
would be the RC6 double-import landmine). The WINDOW_UPDATE builder
h2_frame_write_window_update (§6.9, type 0x08, 4-octet payload), the
big-endian helpers, and the SETTINGS INITIAL_WINDOW_SIZE param emitter all
live in nx_h2_frame.nx -- this rung emits the SAME WINDOW_UPDATE bytes the
codec does (single source of truth), it does NOT re-roll its own builder.
No floating capability: the frame codec founds this flow-control layer; the
conformance + ALPN-h2 rung (R4-H2-006) founds on this next.
BACK-FILL: the team RE-AUTHORS this from the DATA spec via the
emitter-of-emitters (X-AUT-006c/e/f) -- this hand-authored scaffold is the
sanctioned one-time bootstrap only (meter-integrity, mirror
nx_frame_codec.nx:13-16 / nx_h2_frame.nx:31-34 / nx_h2_stream.nx:27-30).
GATE (main): asserts the RFC 9113 §6.9 known-answers byte-exact AND the window
arithmetic. WINDOW_UPDATE +65535 on the connection (stream 0) and on stream 1,
WINDOW_UPDATE +2147483647 (max) on stream 1, the SETTINGS INITIAL_WINDOW_SIZE
=65535 frame -- all built by the composed nx_h2_frame builders. Value math:
init -> 65535; consume(65535, 100) -> 65435; apply_window_update(0, 65535) ->
65535; is_data_frame(DATA 0x00)==1 / (HEADERS 0x01)==0; apply_settings_initial
dependencies 2 imports · 2 importers
imports: nx_h2_frame.nxnx_itoa_lib.nx
imported by: nx_fabric_flow.nxnx_h2_conformance.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 54 | const K_MAGIC_65535: i64 = 65535 |
| 55 | const K_MAGIC_2147483647: i64 = 2147483647 |
| 56 | const K_MAGIC_65435: i64 = 65435 |
| 57 | const K_MAGIC_130970: i64 = 130970 |
| 58 | const K_MAGIC_100000: i64 = 100000 |
| 59 | const K_MAGIC_34565: i64 = 34565 |
functions
| 70 | func h2_flow_initial_window_default() -> i64 { return K_MAGIC_65535 } called by 1: h2_flow_init |
| 71 | func h2_flow_max_window() -> i64 { return K_MAGIC_2147483647 } |
| 72 | func h2_flow_err_protocol() -> i64 { return 0x01 } |
| 73 | func h2_flow_err_flow_control() -> i64 { return 0x03 } |
| 80 | func h2_flow_init(window: *i64) -> i64 |
| 89 | func h2_flow_init_to(window: *i64, initial: i64) -> i64 |
| 103 | func h2_flow_consume(window: *i64, data_len: i64) -> i64 |
| 119 | func h2_flow_apply_window_update(window: *i64, increment: i64) -> i64 |
| 139 | func h2_flow_apply_settings_initial(window: *i64, old_initial: i64, new_initial: i64) -> i64 |
| 154 | func h2_flow_is_data_frame(ftype: i64) -> i64 |
| 161 | func h2_window_update_length_valid(len: i64) -> i64 called by 1: main |
| 172 | func h2_flow_write_window_update(out: *u8, off: i64, stream_id: i64, increment: i64) -> i64 |
| 182 | func fl_puts(s: *u8) -> i64 |
| 192 | func fl_putn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 193 | func fl_puthex2(v: i64) -> i64 called by 1: fl_check_bytes |
| 206 | func fl_fdn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 208 | func fl_check(name: *u8, got: i64, exp: i64) -> i64 |
| 220 | func fl_check_bytes(name: *u8, got: *u8, glen: i64, exp: *u8, elen: i64) -> i64 |
| 243 | func main() -> i64 |