Skip to content

protocol: cut the client wire over to the 1.0 spec - #294

Merged
chrisuthe merged 11 commits into
mainfrom
chrisuthe/task/wire-cut-over-to-the-1-0-spec-hello-state-fields
Sep 17, 2026
Merged

chrisuthe merged 11 commits into
mainfrom
chrisuthe/task/wire-cut-over-to-the-1-0-spec-hello-state-fields

Conversation

@chrisuthe

@chrisuthe chrisuthe commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Cuts the SDK's client wire over to the 1.0 spec in a single PR, because the reference server keys its audio-chunk header and fragmentation scheme off whether client/hello still carries player@v1_support.supported_commands — so removing that field must ship together with the parser and framing changes it unlocks. Per Chris (2026-09-16), the acceptance gate is the spec text plus unit tests and known-answer vectors, not interop against the pinned draft server.

Spec of record: Sendspin/spec@main.

Changes

  1. Drop trust_level from client/hello (Sendspin/spec#158) — the field and its emitter are removed; the serializer can no longer emit it.
  2. Move supported_commands out of client/hello (Sendspin/spec#177) — player@v1_support no longer carries it. The client/state player object now reports the real set: volume, mute (the client applies both unconditionally) and set_output_delay when enabled. The reference server derives controller group volume/mute from this list, so an SDK player previously read as volume-incapable.
  3. static_delay_ms -> output_delay_ms, set_static_delay -> set_output_delay, no alias, both directions (Sendspin/spec#164). The inbound dual-name tolerance is gone; the legacy command is ignored.
  4. client_stream/* -> client-stream/* (Sendspin/spec#163). The underscore spelling no longer appears in live code.
  5. Player audio chunk header carries send_ahead (Sendspin/spec#167): [type][timestamp int64 BE][send_ahead uint32 BE], audio from byte 13, exposed as AudioChunk.SendAhead. Per spec it "carries no scheduling meaning and MUST NOT affect when the chunk is played; players use it only to measure arrival delay", so it feeds nothing else. The 13-byte parse is player-only — artwork and visualizer keep the 9-byte [type][timestamp] header.
  6. Fragmentation as binary ID 1 with a flags byte (Sendspin/spec#172): [1][flags][orig_type][data] first, [1][flags][data] after; bit 1 = first, bit 0 = last, bits 2-7 MUST be zero; orig_type MUST NOT be 1; IDs 2 and 3 are reserved and no longer sent or accepted.
  7. Custom roles need an explicit version (Sendspin/spec#243): ClientCapabilities rejects a _-prefixed role without an @v... version at construction.

Docs: MIGRATION-10.0.0.md and README.md updated for the wire cut-over.

Breaking behaviour

All of the above are wire-visible, with no alias in either direction, so a peer still on the pre-1.0 wire will not interop. The C# surface is unchanged (the OutputDelayMs / SupportsSetOutputDelay renames landed earlier); only the wire spellings and the inbound dual-name tolerance changed.

Interop

The aiosendspin pin is untouched. The pinned draft server (892af8c) predates the 1.0 client/hello: its ClientHelloPayload still requires trust_level, which the spec deleted and aiosendspin removed in #355, so it rejects the SDK's 1.0 hello with "Malformed client/hello" and every scenario fails at the handshake. The whole interop matrix is therefore parked (if: false) until the pin moves to a server that accepts the 1.0 hello (aiosendspin #355); the source scenario additionally needs the client-stream/* rename (Sendspin/spec#163). The pin is not bumped and the server is not patched here. Interop is not the acceptance gate for this PR — spec text + unit tests + KATs are.

Tests

dotnet test on both frameworks, on the branch rebased onto current main:

  • net8.0: Passed 1175, Failed 0
  • net10.0: Passed 1177, Failed 0

Removed tests that only pinned the old wire (the cut-over deletes the behaviour they asserted): ServerCommand_SetStaticDelay_Deserializes; the SetStaticDelay_AppliesDelayAndPersists, SetStaticDelay_IgnoredWhenCapabilityDisabled and SetOutputDelay_WithBothFields_PrefersOutputDelayMs cases in the output-delay suite; and the orig_type-2/3 case of the fragmentation orig_type theory. Added: KATs for the audio header (big-endian timestamp/send_ahead, short-chunk rejection, saturated value), a negative test that the legacy set_static_delay command is ignored, malformed-fragment and IDs-2/3 tests, an explicit three-fragment reassembly, and custom-role version tests. Net count is above the pre-change baseline.

Closes #287

Drop trust_level and player supported_commands from client/hello (spec
PR #158, #177); report the real command set (volume, mute, and
set_output_delay when enabled) in the client/state player object.

Rename static_delay_ms -> output_delay_ms and set_static_delay ->
set_output_delay on the wire with no alias, in both directions (#164).
Rename client_stream/* -> client-stream/* (#163).

Carry send_ahead (uint32 BE) in the player audio chunk header, audio
from byte 13, exposed as AudioChunk.SendAhead; it carries no scheduling
meaning (#167). The 13-byte header is parsed on the player path only, so
the 9-byte artwork/visualizer header is untouched.

Frame fragmentation as binary ID 1 with a flags byte ([1][flags][orig_type]
first, [1][flags] after); IDs 2 and 3 are reserved and no longer sent or
accepted (#172).

Reject a custom (_-prefixed) role advertised without an explicit @v
version at construction (#243).

Update MIGRATION-10.0.0.md and README for the wire cut-over.
Assert client/hello omits trust_level and player supported_commands;
client/state reports [volume, mute, set_output_delay]; output_delay_ms /
set_output_delay are the only delay names, and the legacy set_static_delay
is ignored. Rename client_stream/* assertions to client-stream/*.

KATs for the player audio chunk header: a hand-built 13-byte header pins
big-endian timestamp and send_ahead, a short chunk is rejected, and the
saturated send_ahead is surfaced as-is. Player-audio frame builders now
emit the 13-byte header; artwork/visualizer keep the 9-byte one.

Rework fragmentation tests to binary ID 1 with the flags byte, and
recompute the boundary sizes for the wider headers.

Add custom-role version validation coverage. Skip the source interop
scenario until aiosendspin adopts client-stream/*.

Removed tests that only pinned the old wire: the set_static_delay inbound
deserialization/apply tests and the both-fields preference test.
Add silent-failure tests for an opening fragment missing its orig_type
and a fragment with reserved flag bits set, assert IDs 2 and 3 are no
longer treated as fragments, and pin an explicit first/middle/last
three-fragment reassembly (spec #172).
@chrisuthe chrisuthe added the upstream Tracks spec or aiosendspin changes label Sep 17, 2026
@chrisuthe
chrisuthe requested a lite review from Copilot September 17, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Reserved fragmentation IDs can still be surfaced as application messages, and the migration guide understates source-breaking API changes.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates the client wire protocol to the Sendspin 1.0 specification, including message shapes, audio framing, fragmentation, capabilities, and migration documentation.

Changes:

  • Renames output-delay and source-stream fields.
  • Adds 13-byte audio headers and ID-1 fragmentation.
  • Removes obsolete hello fields and validates versioned custom roles.
  • Updates tests, documentation, and interop configuration.
File summaries
File Summary
tests/Sendspin.SDK.Tests/Synchronization/KalmanClockSynchronizerTests.cs Updates timing tests.
tests/Sendspin.SDK.Tests/Protocol/PlayerTimingSerializationTests.cs Updates timing serialization tests.
tests/Sendspin.SDK.Tests/Protocol/MessageSerializerTests.cs Updates message serialization tests.
tests/Sendspin.SDK.Tests/Protocol/ClientStateFullStateTests.cs Updates client-state tests.
tests/Sendspin.SDK.Tests/Connection/TestNoiseServer.cs Updates test server framing support.
tests/Sendspin.SDK.Tests/Connection/NoiseWireFramingTests.cs Tests wire framing behavior.
tests/Sendspin.SDK.Tests/Connection/FragmentationConformanceTests.cs Tests fragmentation conformance.
tests/Sendspin.SDK.Tests/Connection/FragmentationBoundaryTests.cs Tests fragmentation boundaries and malformed inputs.
tests/Sendspin.SDK.Tests/Client/StreamLifecycleOrderingTests.cs Tests stream lifecycle ordering.
tests/Sendspin.SDK.Tests/Client/SendspinHostServiceOutputDelayTests.cs Tests host output-delay behavior.
tests/Sendspin.SDK.Tests/Client/SendspinClientServiceStreamStartTests.cs Tests stream startup.
tests/Sendspin.SDK.Tests/Client/SendspinClientServiceSourceTests.cs Tests source-stream behavior.
tests/Sendspin.SDK.Tests/Client/SendspinClientServiceOutputDelayTests.cs Tests client output-delay behavior.
tests/Sendspin.SDK.Tests/Client/SendspinClientServiceEncryptedFlowTests.cs Tests encrypted client flows.
tests/Sendspin.SDK.Tests/Client/RoleStateBinaryGatingTests.cs Tests role-state binary gating.
tests/Sendspin.SDK.Tests/Client/PlayerStateDelayReportingTests.cs Tests player delay reporting.
tests/Sendspin.SDK.Tests/Client/PlayerAudioDispatchTests.cs Tests audio dispatch and headers.
tests/Sendspin.SDK.Tests/Client/OutputDelayWireProjectionTests.cs Tests output-delay wire projection.
tests/Sendspin.SDK.Tests/Client/MediaDisplaySchedulingTests.cs Tests media scheduling.
tests/Sendspin.SDK.Tests/Client/CustomRoleValidationTests.cs Tests custom-role validation.
tests/Sendspin.SDK.Tests/Audio/SourceStreamPipelineTests.cs Tests source-stream pipelines.
tests/Sendspin.SDK.Tests/Audio/SourceCodecSelectionTests.cs Tests source codec selection.
src/Sendspin.SDK/Synchronization/KalmanClockSynchronizer.cs Updates timing documentation.
src/Sendspin.SDK/README.md Updates protocol examples.
src/Sendspin.SDK/Protocol/MessageSerializer.cs Updates message serialization.
src/Sendspin.SDK/Protocol/Messages/SourceMessages.cs Updates source messages.
src/Sendspin.SDK/Protocol/Messages/ServerCommandMessage.cs Updates server commands.
src/Sendspin.SDK/Protocol/Messages/MessageTypes.cs Updates message types.
src/Sendspin.SDK/Protocol/Messages/ClientStateMessage.cs Updates client-state fields.
src/Sendspin.SDK/Protocol/Messages/ClientHelloMessage.cs Removes obsolete hello fields.
src/Sendspin.SDK/Protocol/Messages/ClientCommandMessage.cs Updates client commands.
src/Sendspin.SDK/Protocol/BinaryMessageParser.cs Parses the new audio header.
src/Sendspin.SDK/MIGRATION-10.0.0.md Documents migration changes.
src/Sendspin.SDK/Connection/Noise/NoiseWireFraming.cs Implements ID-1 fragmentation.
src/Sendspin.SDK/Connection/Noise/NoiseConstants.cs Defines framing constants.
src/Sendspin.SDK/Client/SendSpinHostService.cs Applies capability and role changes.
src/Sendspin.SDK/Client/SendSpinClient.cs Updates client protocol handling.
src/Sendspin.SDK/Client/MediaDisplayScheduler.cs Updates output-delay scheduling references.
src/Sendspin.SDK/Client/ISendSpinClient.cs Updates client API documentation.
src/Sendspin.SDK/Client/IOutputDelayStore.cs Updates delay-store documentation.
src/Sendspin.SDK/Client/ClientCapabilities.cs Validates custom role versions.
src/Sendspin.SDK/Audio/Source/SourceStreamPipeline.cs Updates source-stream handling.
src/Sendspin.SDK/Audio/Source/ISourceAudioEncoder.cs Updates source encoder documentation.
.github/workflows/interop.yml Adjusts incompatible interop coverage.
Review details

Suppressed comments (1)

src/Sendspin.SDK/MIGRATION-10.0.0.md:34

  • These rows understate the API impact as wire-only: removing ClientHelloMessage.Create's public trustLevel parameter and PlayerSupport.SupportedCommands is source-breaking for consumers that call the factory or initialize that property. Please describe the compiler impact here so the migration guide does not tell affected users that no code change is needed.
| `client/hello` | `trust_level` removed (spec PR #158); it is no longer sent | Low — wire-only; a peer parsing it must stop requiring it |
| `client/hello` | `supported_commands` removed from `player@v1_support`; the real set is reported in the `client/state` player object instead (spec PR #177), now `volume`, `mute` and, when enabled, `set_output_delay` | Low — wire-only; a server derives controller group volume/mute from the state list |
  • Files reviewed: 44/44 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The pinned draft server (892af8c) still requires trust_level in its
ClientHelloPayload, which the spec deleted and aiosendspin removed in
#355, so it rejects the SDK's 1.0 client/hello with "Malformed
client/hello" and every scenario fails at the handshake. Skip all four
(unpaired, pairing, static-pin, source) with if: false until the pin
moves to a server that accepts the 1.0 hello; do not bump the pin or
patch the server.
The non-fragment fall-through dispatched every other binary type as an
application message, so the reserved ids 2 and 3 (the pre-1.0 fragment
types) leaked to BinaryMessageParser. The spec reserves them, so treat a
reserved id like a malformed fragment: fail silently and surface nothing.
Removing ClientHelloMessage.Create's trustLevel parameter and
PlayerSupport.SupportedCommands is a compiler error at existing call
sites, not a wire-only change. Reword both impact columns to say so and
what to change.
@chrisuthe

Copy link
Copy Markdown
Member Author

Round-1 suppressed comment (migration rows understating the source-breaking removals): Fixed in 1626aa3

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Reserved fragmentation IDs can still be accepted through orig_type; public supported_commands documentation also needs correction.

Review details

Suppressed comments (2)

src/Sendspin.SDK/Connection/Noise/NoiseWireFraming.cs:478

  • The reserved-ID check only covers a fragment frame's outer type; a fragmented message can still put orig_type 2 or 3 in the opening header and this path reassembles it, then dispatches it as an application binary message at line 504. Since IDs 2 and 3 are reserved and must not be accepted, reject those values alongside MessageTypeFragment when validating _reassemblyOrigType (and add a conformance test for reserved IDs in orig_type).
            _reassemblyOrigType = plaintext.Span[2];
            if (_reassemblyOrigType == NoiseConstants.MessageTypeFragment)
                return Fail("orig_type of 1");

src/Sendspin.SDK/Protocol/Messages/ClientStateMessage.cs:275

  • This summary still says supported_commands contains commands beyond always-available volume/mute, but the new builder now deliberately emits volume and mute in this list. The following remarks also claim a player can send [], which is no longer true for this SDK. Update the public XML documentation to describe the actual list (volume, mute, plus optional set_output_delay) so consumers do not misread the wire contract.
    /// Player commands this client accepts via server/command, beyond the always-available
    /// volume/mute. Currently a subset of: 'set_output_delay'.
    /// </summary>
    /// <remarks>
    /// Not optional and never omitted: spec PR #175 dropped the <c>?</c>, because absence and
  • Files reviewed: 44/44 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

A fragment's orig_type only rejected 1 (the fragment id); ids 2 and 3
are reserved too, so an opening fragment naming one would reassemble and
dispatch to a reserved type. Reject 2 and 3 with the same silent Fail,
matching how they are handled as a top-level frame.
The XML doc still said 'beyond the always-available volume/mute' and
that a player may send []. This SDK always reports volume and mute plus
set_output_delay when enabled, so it is never empty; reword to match,
keeping the #175 never-omitted rationale.
@chrisuthe

Copy link
Copy Markdown
Member Author

Round-2 suppressed comments:

  • NoiseWireFraming.cs ~478 (reserved IDs via a fragment's orig_type): Fixed in 3033587
  • ClientStateMessage.cs ~275 (supported_commands XML doc): Fixed in 6ae6e05

Three Copilot rounds will be complete after this one; no further round will be requested.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Outbound framing can emit reserved type IDs, producing invalid 1.0 wire frames.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

src/Sendspin.SDK/MIGRATION-10.0.0.md:34

  • The new table correctly says the SDK's player state advertises volume and mute (and optionally set_output_delay), but §7.7 later still states that supported_commands: [] is the SDK's no-command representation. That is now stale and contradicts the behavior documented here; update that section to describe the always-present volume/mute entries and the optional delay command.
| `client/hello` | `trust_level` removed (spec PR #158); it is no longer sent | **Source-breaking** — `ClientHelloMessage.Create` drops its `trustLevel` parameter and `ClientHelloPayload.TrustLevel` is gone: a compiler error at any call site that passed the argument or read the property; delete them (a server parsing it must also stop requiring it) |
| `client/hello` | `supported_commands` removed from `player@v1_support`; the real set is reported in the `client/state` player object instead (spec PR #177), now `volume`, `mute` and, when enabled, `set_output_delay` | **Source-breaking** — `PlayerSupport.SupportedCommands` is removed: a compiler error where it was set; drop it, since the advertised set now comes from `client/state`. A server derives controller group volume/mute from the state list |
  • Files reviewed: 44/44 changed files
  • Comments generated: 1
  • Review effort level: Lite

EncodeBinary accepted any type byte, so a caller could make the SDK emit
a reserved id (1 fragmentation, 2-3 reserved) as a small frame or copy
one into a fragment's orig_type. Throw ArgumentOutOfRangeException for
types 1-3 at the entry.
…guide

Section 7 still described []' as the SDK's no-command representation.
The SDK always sends volume and mute plus set_output_delay when enabled,
so it is never empty; reword to match the summary table.
@chrisuthe

Copy link
Copy Markdown
Member Author

Round-3 suppressed comment (migration §7.7 supported_commands representation): Fixed in 77b4ff0

Three Copilot rounds complete; no further round will be requested.

@chrisuthe
chrisuthe marked this pull request as ready for review September 17, 2026 01:21
…ut-over-to-the-1-0-spec-hello-state-fields

# Conflicts:
#	.github/workflows/interop.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

upstream Tracks spec or aiosendspin changes

Projects

None yet

2 participants