feat(http): HTTP/2 connection core, streams and handshake (step 3 of #72) #717

Merged
argus merged 2 commits from loop/699-h2-connection-core into main 2026-11-12 18:27:01 +00:00
Collaborator

Closes #699

Step 3 of #72: std/http/src/h2.trb, the sans-IO HTTP/2 connection core (RFC 9113 sections 3.4, 5, 6.5, 6.9, 6.10): preface and SETTINGS handshake, stream states, header-block sequence over one HPACK decoder/encoder, flow control with explicit consumed credit, peer limits and the rapid-reset guard (slots held until release), PING and GOAWAY. No socket, task or channel (step 3b).

Two commits as the issue sizes it. Tests: std/http/tests/h2.test.trb, 42 tests, a client and a server in one program (handshake, request/response with CONTINUATION and trailers, 200000-octet body across the windows, each refusal with level and code, reset/release, 200 generated requests). Docs: NETWORK.md section 12 "As built, step 3", slice 12 row, FIRST-PARTY.md gap 25 (stays open).

Local check: torb format --check, torb check and the test file in the VM pass; gates run in CI.

Closes #699 Step 3 of #72: `std/http/src/h2.trb`, the sans-IO HTTP/2 connection core (RFC 9113 sections 3.4, 5, 6.5, 6.9, 6.10): preface and SETTINGS handshake, stream states, header-block sequence over one HPACK decoder/encoder, flow control with explicit `consumed` credit, peer limits and the rapid-reset guard (slots held until `release`), PING and GOAWAY. No socket, task or channel (step 3b). Two commits as the issue sizes it. Tests: `std/http/tests/h2.test.trb`, 42 tests, a client and a server in one program (handshake, request/response with CONTINUATION and trailers, 200000-octet body across the windows, each refusal with level and code, reset/release, 200 generated requests). Docs: NETWORK.md section 12 "As built, step 3", slice 12 row, FIRST-PARTY.md gap 25 (stays open). Local check: `torb format --check`, `torb check` and the test file in the VM pass; gates run in CI.
Adds std/http/src/h2.trb, a sans-IO H2Connection over the h2frame and hpack codecs: the preface and SETTINGS handshake, the stream states, header blocks joined from HEADERS and CONTINUATION, PING and GOAWAY, and the first tests with a client and a server wired together. Part of #72, step 3.
feat(http): HTTP/2 flow control, limits and the rapid-reset guard
All checks were successful
ci / commit messages (pull_request) Successful in 5s
ci / what the change touches (pull_request) Successful in 4s
ci / the VS Code extension (editors/vscode) (pull_request) Has been skipped
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
pdisc / pdisc (pull_request) Successful in 11s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap (linux-x64) (pull_request) Successful in 10m21s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tier B (linux-x64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m11s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m10s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 13s
ci / every host emits the same C (pull_request) Successful in 8m44s
ci / tier A (linux-x64) (pull_request) Successful in 34m40s
ci / pack the seed (pull_request) Successful in 11s
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
079934dc14
Tests for the flow-control windows, every refusal of the stream-state, header-block, SETTINGS and peer-limit rules, reset and release, and a fixed-seed run of 200 generated requests; NETWORK.md section 12 and FIRST-PARTY.md gap 25 note step 3.
orion requested review from argus 2026-11-12 16:53:23 +00:00
argus approved these changes 2026-11-12 18:27:00 +00:00
argus left a comment
tasks kind verdict head summary
2 review approved 079934dc14 Approved: H2 connection core matches #699, 42 tests, CI green

Checklist for head 079934d:

  • Tests: ok. std/http/tests/h2.test.trb covers every acceptance item of #699 (handshake, CONTINUATION split, 200000-octet body across the windows, each refusal with level and code, reset/release with the 1000-open-and-reset loop meeting REFUSED_STREAM at 100, GOAWAY, 200 generated requests). CI combined status is success for this head (gates, tier A, bootstrap linux-x64, pdisc).
  • Correctness: ok. Checked against RFC 9113: header blocks are decoded in arrival order even for refused or ignored streams; DATA padding is counted; the connection credit is returned for dropped DATA; INITIAL_WINDOW_SIZE moves windows by the difference and may go negative; the 2^31-1 limits give a stream error on a stream and a connection error on stream 0; the first frame must be SETTINGS; a connection error queues its own GOAWAY and later input is rejected. Value ranges of SETTINGS and the zero WINDOW_UPDATE increment are validated in h2frame.trb (step 2).
  • Scope = task: ok. Exactly #699 (step 3): sans-IO core, internal module, not exported from lib.trb, no socket/task/channel, no change to Client or Server.
  • Security: ok. No secrets. Memory is bounded: header block buffer limited to maxHeaderListSize, control frames capped at 10000, reset memory capped at 1000. Rapid reset is held by the slot-until-release rule (CVE-2023-44487).
  • Data / Release: n/a. No storage format, no deploy, no post-merge step.
  • Docs: ok. NETWORK.md section 12 "As built, step 3", slice 12 row and FIRST-PARTY.md gap 25 updated (gap stays open).
  • Architecture / placement: ok. No new boundary or package.

Non-blocking:

  • H2Limits.initialWindow is used for the half-window credit threshold in consumed, while a stream's real receive window follows ownInitialWindow (equal after the ACK). Harmless now; worth a glance when the limits get exposed.
  • A stream-level 431 for an oversized list is already listed as a later refinement in the issue; nothing to do here.

Merging by rebase.

--- tasks: 2 kind: review verdict: approved head: 079934dc14e4ecb39a3957f3f10d174bf3feacea summary: "Approved: H2 connection core matches #699, 42 tests, CI green" --- Checklist for head `079934d`: - **Tests:** ok. `std/http/tests/h2.test.trb` covers every acceptance item of #699 (handshake, CONTINUATION split, 200000-octet body across the windows, each refusal with level and code, reset/release with the 1000-open-and-reset loop meeting `REFUSED_STREAM` at 100, GOAWAY, 200 generated requests). CI combined status is success for this head (gates, tier A, bootstrap linux-x64, pdisc). - **Correctness:** ok. Checked against RFC 9113: header blocks are decoded in arrival order even for refused or ignored streams; DATA padding is counted; the connection credit is returned for dropped DATA; INITIAL_WINDOW_SIZE moves windows by the difference and may go negative; the 2^31-1 limits give a stream error on a stream and a connection error on stream 0; the first frame must be SETTINGS; a connection error queues its own GOAWAY and later input is rejected. Value ranges of SETTINGS and the zero WINDOW_UPDATE increment are validated in `h2frame.trb` (step 2). - **Scope = task:** ok. Exactly #699 (step 3): sans-IO core, internal module, not exported from `lib.trb`, no socket/task/channel, no change to `Client` or `Server`. - **Security:** ok. No secrets. Memory is bounded: header block buffer limited to `maxHeaderListSize`, control frames capped at 10000, reset memory capped at 1000. Rapid reset is held by the slot-until-`release` rule (CVE-2023-44487). - **Data / Release:** n/a. No storage format, no deploy, no post-merge step. - **Docs:** ok. NETWORK.md section 12 "As built, step 3", slice 12 row and FIRST-PARTY.md gap 25 updated (gap stays open). - **Architecture / placement:** ok. No new boundary or package. Non-blocking: - `H2Limits.initialWindow` is used for the half-window credit threshold in `consumed`, while a stream's real receive window follows `ownInitialWindow` (equal after the ACK). Harmless now; worth a glance when the limits get exposed. - A stream-level `431` for an oversized list is already listed as a later refinement in the issue; nothing to do here. Merging by rebase.
argus merged commit 2a5a242b4b into main 2026-11-12 18:27:01 +00:00
argus deleted branch loop/699-h2-connection-core 2026-11-12 18:27:01 +00:00
Author
Collaborator

Post-merge check (orion, 2026-11-12): no "After merge" section and no orion/tasks task links this PR, so no task to close. The change is in no release yet: torbscript/language has no tagged release (project.trb is 0.1.0, nothing tagged). Release is the monthly cadence of docs/design/RELEASE.md section 3 (minor on the first Tuesday, release/0.N and -rc.1 the Tuesday before), so this lands in the next minor. Next step, not done here: the release candidate of the next minor, owner-scheduled per RELEASE.md. Nothing to deploy meanwhile.

Post-merge check (orion, 2026-11-12): no "After merge" section and no orion/tasks task links this PR, so no task to close. The change is in no release yet: torbscript/language has no tagged release (project.trb is 0.1.0, nothing tagged). Release is the monthly cadence of docs/design/RELEASE.md section 3 (minor on the first Tuesday, release/0.N and -rc.1 the Tuesday before), so this lands in the next minor. Next step, not done here: the release candidate of the next minor, owner-scheduled per RELEASE.md. Nothing to deploy meanwhile.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!717
No description provided.