Skip to main content

Module committed

Module committed 

Source
Expand description

A session’s committed set and the range scheduler’s plan over it.

The server holds the only truth about what a session has made durable: its committed set, a list of coalesced byte ranges it spells on X-Capsule-Committed as comma-separated inclusive ranges (0-1048575,2097152-4194303). The client re-plans from that set, never from its own record of what it sent (transfer upload doc, §Idempotency and Resumption).

next_range is the scheduler’s one decision: the lowest gap first. It picks the lowest byte neither committed nor in flight, and plans a range from it of at most the chunk size, ending early where the next committed or in-flight range begins. Every start it picks is the end of a range the server committed or the client planned, so a range is on the 4 KiB grid by construction, and a sequential schedule is the case of a window of one.

Everything here is a pure function over values, so the scheduler is tested without a server.

Structs§

CommittedSet
A session’s committed set: sorted, disjoint, coalesced, half-open byte ranges inside [0, size).

Constants§

GRID
The protocol’s block grid: every range starts on it, and every range but the one ending at the declared size has a length on it.
MAX_FRAGMENTS
The most fragments a committed set holds on the wire (the server’s fragment bound). A header naming more is malformed.

Functions§

next_range
The next range to send: the lowest byte of [0, size) that is neither committed nor in in_flight, and from it at most want bytes, ending where the next committed or in-flight range begins. None once every byte is committed or in flight.