feat(transport): negotiate bounded automatic message chunking

This commit is contained in:
cabbage committed 2026-11-09 08:50:51 +00:00
1 parent 474afb3484
commit 8acffac985
20 files changed
+1332 -38

No files matched your search

+21 -2
View File
@@ -1659,8 +1659,13 @@ terminal-age, audit, and tombstone rules match the documented semantics.
Expose an HTTP endpoint suitable for nginx WebSocket proxying. TLS may terminate
at nginx, but the server must verify WebSocket upgrade origin/path/configuration
and impose read limits itself. It accepts one binary protobuf envelope per
message and refuses text messages, fragmentation misuse, oversized frames,
and impose read limits itself. An AgentEnvelope is one logical message. Without
transport negotiation it is one binary WebSocket message; when both peers select
`rvbox.agent.v1.chunked`, the shared `internal/agentwire` layer splits it into
16 KiB-or-smaller packets and reassembles it before protobuf validation. See
[the transport specification](transport-chunking.md) for the exact record format,
bounded independent control/data assemblies, reconnect rules, and rollout hold.
It refuses text messages, fragmentation misuse, oversized frames,
invalid compressed payloads, and malformed/unknown mandatory messages.
Use four independently bounded activities per session:
@@ -1690,6 +1695,20 @@ and split data below the frame ceiling. A full control lane is a session-fatal
internal invariant; a full data lane leaves work durable and wakes the writer
later rather than allocating another goroutine.
For negotiated chunking, apply the write deadline per packet and check the
monotonic heartbeat between packets, including while output stays continuously
queued. Between data packets, drain at most the configured control burst. Large
control messages use their independent assembly lane; do not interleave two
fragmented messages within one lane. `Written`/`OnWritten` fire only after the
whole logical message has crossed the writer, preserving dispatch and
reconciliation barriers. One bounded network read pump services Ping/Pong while
the application writes a large reconciliation snapshot; validated packet
activity advances liveness before full reassembly. Close cancels this pump,
including when its single delivery slot is full. A disconnected assembly is
never persisted or acknowledged: the existing durable sender replays the logical
operation after reconnect. Logical envelope/spec/chunk/script limits remain in
force; transport fragmentation cannot bypass those limits or quota accounting.
The reader checks WebSocket type/size before protobuf decode, validates envelope
session fields before payload allocation, and routes only lightweight immutable
work descriptors. Persistence workers preserve per-command ordering while a fair