feat(quic): bestEffort streams + park CC plan indefinitely

After drafting the congestion-control plan we concluded the audio-rooms
workload doesn't actually need CC — speakers push ~8 KB/sec, which
never fills any modern link's capacity. The one real concern that
surfaced — STREAM retransmit wasting bandwidth on stale Opus frames
on lossy uplinks — is much cheaper to fix directly than to bound via
a 14-test CC subsystem.

SendBuffer gains a `bestEffort: Boolean = false` constructor flag.
When true, markLost drops the lost ranges instead of moving them to
the retransmit queue and lets the underlying byte storage compact as
if the bytes had been ACK'd. The FIN flag (if covered) also stays
sent — best-effort skips FIN re-emission too. The peer may end up
with a truncated stream; moq-lite's per-stream timeouts handle that.

Plumbed through QuicStream → QuicConnection.openUniStream(bestEffort)
→ QuicWebTransportSessionState.openUniStream(bestEffort) →
WebTransportSession.openUniStream(bestEffort). Default is false
everywhere, so reliable streams (HTTP/3 control, moq-lite SUBSCRIBE
bidi, etc.) keep RFC 9000 §3.5 semantics.

MoqLiteSession.openGroupStream now passes `bestEffort = true` —
group streams carry a single Opus packet, are real-time, and don't
benefit from retransmit.

Internal cleanup: `removeOverlap`'s `ackedNotLost: Boolean` parameter
became `OverlapAction { ACK, RETRANSMIT, DROP }` so the third best-
effort disposition has a name. Same code paths, same tests, just
clearer at the call site.

CC plan (quic/plans/2026-05-05-congestion-control.md) is updated to
"parked indefinitely" with a note that this commit is the lighter-
weight alternative that addresses the only practical concern. The
plan is preserved as a reference if a future workload justifies CC.

New tests: SendBufferBestEffortTest (6 cases — reliable baseline,
best-effort drops, FIN drop in best-effort mode, partial overlap,
idempotent stale loss, ACK path still works).

https://claude.ai/code/session_01PYYez8a6sjiakyjAxsfCEQ
This commit is contained in:
Claude
2026-05-05 02:06:08 +00:00
parent 08bb3e14e1
commit fba0a5c952
10 changed files with 296 additions and 36 deletions
@@ -696,7 +696,14 @@ class MoqLiteSession internal constructor(
subscribeId: Long,
sequence: Long,
): com.vitorpamplona.nestsclient.transport.WebTransportWriteStream {
val uni = transport.openUniStream()
// Group streams carry a single Opus packet. They're real-time
// and best-effort — a STREAM frame arriving 200 ms late is
// worse than useless because the listener has already moved
// past that group's sequence number. Setting bestEffort=true
// tells the underlying QUIC SendBuffer to drop lost ranges
// instead of retransmitting them, bounding the bandwidth waste
// we'd otherwise incur on a lossy uplink.
val uni = transport.openUniStream(bestEffort = true)
uni.write(Varint.encode(MoqLiteDataType.Group.code))
uni.write(MoqLiteCodec.encodeGroupHeader(MoqLiteGroupHeader(subscribeId, sequence)))
return uni
@@ -73,7 +73,9 @@ class FakeWebTransport private constructor(
* the moq-lite publisher path to push group data. The peer side
* receives the new stream via [incomingUniStreams].
*/
override suspend fun openUniStream(): WebTransportWriteStream {
override suspend fun openUniStream(bestEffort: Boolean): WebTransportWriteStream {
// The fake transport ignores [bestEffort] — there's no loss to
// simulate in the in-memory channel.
stateLock.withLock { check(open) { "session closed" } }
val pipe = Channel<ByteArray>(Channel.BUFFERED)
outboundUniStreams.send(FakeReadStream(pipe))
@@ -55,8 +55,14 @@ interface WebTransportSession {
* audio frames is pushed on a fresh uni stream that the publisher
* opens see `rs/moq-lite/src/lite/publisher.rs:338`
* (`session.open_uni()`).
*
* If [bestEffort] is true, the underlying QUIC stream drops lost
* STREAM bytes instead of retransmitting them for real-time
* audio (Opus group streams) this avoids pushing 200-ms-stale
* frames after a loss. Default false (RFC 9000 §3.5 reliable byte
* sequence).
*/
suspend fun openUniStream(): WebTransportWriteStream
suspend fun openUniStream(bestEffort: Boolean = false): WebTransportWriteStream
/**
* Flow of inbound unidirectional streams initiated by the peer.