Initial Commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
# Drive Transport WebRTC — Spec Delta (drive-transport-webrtc-port)
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### TRANSPORT-WRTC-01 — Frame format
|
||||
|
||||
Datachannel messages MUST use the framing `[uint32 BE frameLen][uint8 frameType][payload (frameLen-1 B)]`. `frameType` values: `0x01` chunk-request, `0x02` chunk-response, `0x03` advertisement. Receivers MUST buffer until `frameLen` bytes accumulate before parsing.
|
||||
|
||||
**Verified by:** `src/framing/codec.spec-conformance.test.ts` (`TRANSPORT-WRTC-01`).
|
||||
|
||||
### TRANSPORT-WRTC-02 — Request/response correlation
|
||||
|
||||
Each chunk-response frame MUST be matched to its outstanding chunk-request via `(fileId, chunkId)`. Concurrent requests for different chunks MUST resolve independently. A response with no pending request MUST be discarded silently (with telemetry).
|
||||
|
||||
**Verified by:** `src/transport.spec-conformance.test.ts` (`TRANSPORT-WRTC-02`).
|
||||
|
||||
### TRANSPORT-WRTC-03 — Advertisement broadcast
|
||||
|
||||
`transport.advertise(peerId, fileId, bitset)` MUST send a `0x03` frame on the relevant peer's datachannel. `onAdvertisement` handlers MUST fire on receipt with the decoded `(fileId, bitset)`.
|
||||
|
||||
**Verified by:** `src/transport.spec-conformance.test.ts` (`TRANSPORT-WRTC-03`).
|
||||
|
||||
### TRANSPORT-WRTC-04 — Backpressure honours bufferedAmount
|
||||
|
||||
When `dataChannel.bufferedAmount > highWatermark` (default 16 MiB), the transport MUST stop sending and await the `bufferedamountlow` event before resuming. The watermarks MUST be configurable via `bufferThresholds`.
|
||||
|
||||
**Verified by:** `src/transport.spec-conformance.test.ts` (`TRANSPORT-WRTC-04`).
|
||||
|
||||
### TRANSPORT-WRTC-05 — Lifecycle on peer-connection close
|
||||
|
||||
When a peer's `RTCPeerConnection` transitions to `closed`, `failed`, or `disconnected`, the transport MUST: cancel all pending requests for that peer with `MeshError(MESH.TRANSPORT_ERROR)`, remove the peer from `peers()`, and emit a peer-removed event.
|
||||
|
||||
**Verified by:** `src/transport.spec-conformance.test.ts` (`TRANSPORT-WRTC-05`).
|
||||
Reference in New Issue
Block a user