code wiki / (root) / nx_h2_flow.nx

nx_h2_flow.nx

buildroot/runtime/nx_h2_flow.nx

25567 B426 linesdepth 6pulls 8 transitivereach 16 importersview sourcekind tooltopic h2
docsdependenciesstructsconstsfunctions

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

nx_h2_frame.nx nx_itoa_lib.nx nx_h2_flow.nx nx_fabric_flow.nx nx_h2_conformance.nx

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

main fl_puts h2_flow_write_window_updat h2_frame_write_window_upda h2_frame_write_header tls_write_u24_be h2_write_u32_be h2_write_u32_be ↻ fl_check_bytes fl_puts ↻ fl_putn nxi_out nxi_fd sys_mmap ccz_cat_num sys_write sys_munmap fl_puthex2 h2_frame_write_settings_pa h2_frame_write_header ↻ tls_write_u16_be h2_write_u32_be ↻ fl_check fl_puts ↻ fl_putn ↻ h2_flow_init h2_flow_initial_window_def h2_flow_consume h2_flow_err_flow_control h2_flow_apply_window_updat h2_flow_err_protocol h2_flow_max_window h2_flow_err_flow_control ↻ h2_flow_is_data_frame h2_window_update_length_va h2_flow_apply_settings_ini h2_flow_err_flow_control ↻ h2_flow_max_window ↻ h2_flow_err_protocol ↻ fl_putn ↻

structs

none

consts

54const K_MAGIC_65535: i64 = 65535
55const K_MAGIC_2147483647: i64 = 2147483647
56const K_MAGIC_65435: i64 = 65435
57const K_MAGIC_130970: i64 = 130970
58const K_MAGIC_100000: i64 = 100000
59const K_MAGIC_34565: i64 = 34565

functions

70func h2_flow_initial_window_default() -> i64 { return K_MAGIC_65535 }
called by 1: h2_flow_init
71func h2_flow_max_window() -> i64 { return K_MAGIC_2147483647 }
72func h2_flow_err_protocol() -> i64 { return 0x01 }
73func h2_flow_err_flow_control() -> i64 { return 0x03 }
80func h2_flow_init(window: *i64) -> i64
89func h2_flow_init_to(window: *i64, initial: i64) -> i64
103func h2_flow_consume(window: *i64, data_len: i64) -> i64
119func h2_flow_apply_window_update(window: *i64, increment: i64) -> i64
139func h2_flow_apply_settings_initial(window: *i64, old_initial: i64, new_initial: i64) -> i64
154func h2_flow_is_data_frame(ftype: i64) -> i64
161func h2_window_update_length_valid(len: i64) -> i64
called by 1: main
172func h2_flow_write_window_update(out: *u8, off: i64, stream_id: i64, increment: i64) -> i64
called by 1: main calls 1: h2_frame_write_window_update
182func fl_puts(s: *u8) -> i64
192func fl_putn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 3: fl_checkfl_check_bytesmain calls 1: nxi_out
193func fl_puthex2(v: i64) -> i64
called by 1: fl_check_bytes
206func fl_fdn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
208func fl_check(name: *u8, got: i64, exp: i64) -> i64
called by 1: main calls 2: fl_putsfl_putn
220func fl_check_bytes(name: *u8, got: *u8, glen: i64, exp: *u8, elen: i64) -> i64
called by 1: main calls 3: fl_putsfl_putnfl_puthex2
243func main() -> i64