Files
amethyst/quic
Claude 6e054583a9 fix(quic): RFC 9000 §4.1 connection-level inbound flow-control enforcement
Pre-fix the receiver enforced ONLY per-stream `receiveLimit`. The
aggregate cap (`initial_max_data` / latest MAX_DATA) was advertised and
respected on the SEND side but never checked on the RECEIVE side — a
peer that opened many streams and pushed each up to its per-stream cap
could collectively exceed `initial_max_data` without us closing.

Implementation:

  * `QuicStream.receiveHighestOffset`: per-stream high-water mark of
    "largest stream offset received" — the spec quantity that gets
    summed across streams for the connection-level check.
  * `QuicConnection.connectionInboundOffsetSum`: running sum across
    all streams of `receiveHighestOffset`. Updated in the parser at
    STREAM and RESET_STREAM frame ingest time.
  * Parser closes with FLOW_CONTROL_ERROR whenever the running sum
    exceeds `advertisedMaxData`.
  * RESET_STREAM final-size accounting: per §4.5 the finalSize counts
    toward connection-level flow control even though no STREAM frame
    delivered those bytes — a peer that resets a stream at a finalSize
    larger than it had previously sent gets the extra bytes added to
    the running sum at RESET arrival.

Different from the writer's MAX_DATA threshold logic (which uses the
cheaper contiguous-end approximation): the receiver-side enforcement
needs the strict spec quantity to close before bookkeeping diverges.

Test: `ConnectionLevelFlowControlTest` (5 cases) covers below-cap pass,
over-cap close, retransmit-doesn't-double-count, RESET_STREAM
finalSize counts toward limit, fresh-handshake invariants.

https://claude.ai/code/session_01XGmmaVuy2wsSZQx2AqN2ik
2026-05-09 04:44:04 +00:00
..