fix(h2): review batch 2 — RFC compliance, HPACK/Huffman, Response & drain hardening #55
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.50) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 575 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.380
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #55"
general
weight: 0.35
cursor[bot]
Summary
Implements Batch 2 of the comprehensive code review (
code_review_report.md): RFC 9113 / 9110 / 8941 / 9218 compliance, HPACK/Huffman edge-case & OOM hardening,Response/H2Sinkstate-machine safety, and server/client concurrency & timeout fixes.Protocol & HPACK (
src/proto.zig,src/hpack_codec.zig,src/hpack.zig)proto.zig):- Assert
length <= 0xff_ffffinputHeader.- Validate
.push_promise(sid == 0,payload.len < 4) and.priority_update(Prioritized Element ID == 0) invalidateInboundFrame.- Add RFC 3986 §3.2
isValidAuthority()rejecting userinfo (@), path/query/fragment delimiters (/,?,#,\), CTLs, malformed IPv6 brackets, and invalid/out-of-range ports (> 65535).- Enforce RFC 8941 §4.2 / §4.2.4 Structured Fields rules in
Priorityparser: SP-only outer trimming (rejectingHTAB), integer (<= 15digits) & decimal (<= 12int,1..3frac) limits, and resetting duplicate"u"/"i"keys to defaults when overwritten with out-of-range or mismatched types.DynamicTable(hpack_codec.zig):- Replace the
O(256)linear scan in Huffman decoding (decode,decodeLengthOnly,decodeIntoScratch) with a comptime-verified canonical Huffman lookup table (CanonicalTable, ~450 B in.rodata).- Pre-allocate growth buffers in
DynamicTable.addWithAllocatorbefore evicting live entries (strong OOM exception safety) and capmin_storage <= maxInt(u32).hpack.zig):- Preserve
error.OutOfMemoryinDecoder.literalinstead of swallowing it aserror.Truncated.- Fix
EncoderContext.configureLocalMaxrevert-to-dyn.max_sizeTSU tracking andnotePeerHeaderTableSizereduction tracking againstprev_peer(RFC 7541 §4.2).- Reject invalid
:status(< 100,> 599,101) and suppress explicit/autocontent-lengthon1xx/204inEncoderContext.encodeResponse.- Support plain RFC 9113 §8.5
CONNECT(valid:authority, omitting:scheme/:path) inencodeRequestEx, and reject connection-specific/teheaders inEncoderContext.encodeTrailers.Response, Server & Client (
src/types.zig,src/server.zig,src/client.zig)Response&H2Sinkhardening (types.zig,server.zig):- Give
Requestsafe field defaults (eliminating all 11.req = undefinedinitializations inserver.zig).- Guard
Response.header(error.HeadAlreadySent),Response.trailer(error.ResponseFinished),Response.status/setContentLengthpost-head no-ops,Response.sendpost-head rejection + pre-mutation validation +204CL omission + consistentfinish()on fallback sinks.- Preserve
cork_bufandbody_byteswhen a sink write fails, and coalescecork_bufwith caller slices inwriteVec.- Enforce RFC 9110/9113 rules in
H2Sink: valid final status (200..599), suppressDATAonHEAD/204/304, omitcontent-lengthon204, and omit trailers on204/304.server.zig):- Make
drainTimerThunkwakeable viaConnection.drain_wake: Io.Event(signaled onenterDraining,notePeerWaitBegin/End, and worker exit) so a tightened peer-wait deadline never waits behind a longdrain_timeout_ms.- Enforce a total
head_timeout_msdeadline across the entireCONTINUATIONframe loop (instead of resetting per frame).- Accept single trailing
HEADERS(END_STREAM)onearly_closedstreams cleanly (decode HPACK without spuriousRST_STREAM(STREAM_CLOSED)) on both direct and race paths.- Replace separate
rx_eof_atomic+resp_end_stream_queuedDekker pairs with a singleclose_flagsatomic bitmask (fetchOr(..., .acq_rel)).- Skip
half-closed (local)streams inapplyInitialWindow(RFC 9113 §6.9.2).- Enforce
isValidAuthorityon:authority/hostand accept standard RFC 9113 §8.5CONNECTinbuildRequestEx.client.zig):- Reject server-sent
PRIORITY_UPDATEframes withGOAWAY(PROTOCOL_ERROR)+ teardown (RFC 9218 §7.1).- Support plain RFC 9113 §8.5
CONNECT(defaultRequestHead.path = "", strictisValidAuthority).- Skip
local_closedstreams inapplyInitialWindow(RFC 9113 §6.9.2).Verification
zig test src/lib.zig -lc(Debug + leak detection): 237/237 passed (includes 6 new Batch 2 regression suites).zig build test -Doptimize=ReleaseSafe --summary all: 237/237 passed (10s, MaxRSS 19M).zig fmt --check src/ build.zig: clean (0 diffs).