Skip to content

Clarify activation and shared stream lifecycle requirements - #274

Merged
kahrendt merged 1 commit into
mainfrom
fix/core-protocol-requirements
Sep 16, 2026
Merged

kahrendt merged 1 commit into
mainfrom
fix/core-protocol-requirements

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

Complete the BCP 14 boilerplate, normalize requirement wording, and move operative text out of non-normative notes. Clarify in CONTRIBUTING that requirements belong outside notes regardless of capitalization. Changes beyond keyword normalization:

  • Make the initial activation message gate mandatory. The server's gate ends when it sends activation, and the client's ends when it receives activation. Preserve server/error for init failures and permit encrypted client/goodbye after the initial Noise handshake without changing silent-failure handling.
  • Base client role eligibility on received activation state. Require servers to ignore inactive-role objects in client/state and client/command without closing solely for their presence, while still processing client-level fields and active-role objects - the client may not yet have received the role removal.
  • Require lifecycle messages to be processed in delivery order even when role data is discarded. Discarding payloads cannot bypass Noise processing, fragment reassembly, or required message checks.
  • Clarify that local unavailability does not end a downstream stream and that clients must continue processing its lifecycle messages. Base the server's stream/start availability check on the latest client state it received.
  • Make buffer clearing on stream/clear explicit and change stream/end output stopping and buffer clearing from a recommendation to a MUST.
  • Restrict stream/clear to active streams: an explicit role list must be non-empty and contain only roles with active streams. Omitting roles clears all active player and visualizer streams, and the message cannot be sent when no targeted streams are active - this keeps clear and end targeting consistent without requiring both roles to be streaming.
  • Restrict stream/end to active streams: an explicit role list must be non-empty and contain only roles with active streams, and the message cannot be sent when none are active. Align role-removal and unavailability teardown with that restriction.
  • Include sources as well as players in the clock-synchronization prerequisite for reporting availability.
  • Define support-object keys in both hello messages as the role-version identifier followed by _support, when that role version defines a support object.
  • Make server/unpair subject to initial and re-handshake sequencing, and prevent the generic permission to omit client/goodbye from overriding cases where it is required.

This is the final PR for addressing the issues I found with #100.

Closes #100.

@balloob balloob added this to the 1.0.0 RC1 milestone Sep 16, 2026

@kahrendt kahrendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very thorough, thank you!

@kahrendt
kahrendt merged commit 5f84f1b into main Sep 16, 2026
1 check passed
@kahrendt
kahrendt deleted the fix/core-protocol-requirements branch September 16, 2026 10:39
chrisuthe added a commit to Sendspin/aiosendspin that referenced this pull request Sep 17, 2026
Part of #386. One commit per item.

- [x] **S-3** – The server sends `start` only after the source object
has arrived, the client is available and the role is no longer held.
- `request_start()` now queues the request and sends it as soon as all
three hold; nothing reaches the wire early.
- `request_stop()`, a disconnect or the role's deactivation cancels a
queued start. `can_start` exposes the same check.
- The source role now uses the activation-state hold from #417, plus one
new base hook, `Role.on_hold_released()`.
  - A `client/state` missing the required `source` object is flagged.
- The client SDK now includes the `source` object in every
`client/state` while the role is active, so a player+source client
includes it in its first state.
- [x] **S-7** – `SourceCapture` drops PCM and encoded frames captured
more than `MAX_CAPTURE_BACKLOG_US` (500 ms) ago, then continues from
live capture without resending `client-stream/start`.
  - The drop only works when callers pass `capture_timestamp_us`.
- A frame the encoder was already holding can still span the gap; the
encoder is deliberately not reset.
- [x] **S-9** – `client-stream/start` accepts any channel count ≥ 1 and
any bit depth from 1 to 32.
- The stream is announced at 16, 24 or 32 bits, and 8-bit PCM is widened
to 16.
  - Only PCM depths that are not whole bytes are flagged and refused.
  - Channel counts without a named layout use PyAV's unnamed layout.
- [x] **S-10** – The client SDK sends `signal` only when it advertised
`line_sense`.
- [x] **S C** – The `SourceCapture.feed()` docstring now covers the
clock and default of `capture_timestamp_us`.

## Breaking

- `SendspinConnection.send_source_signal()` now raises `RuntimeError`
unless the client advertised `source@v1_support.features.line_sense`.
Before, it sent the signal anyway.

## Compatibility

- A client following an older spec revision may never send the `source`
object in `client/state`.
- A lenient server (`allow_noncompliant_clients=True`) flags it and
treats the client as startable once its initial `client/state` has
arrived and it is available. This applies to the initial state only.
  - A strict server rejects it.
- The tolerance is marked `DEPRECATED(spec-pr-195)`: the requirement to
send a role's state object on activation comes from Sendspin/spec#195.
Sendspin/spec#274 only reworded that paragraph.
- **For embedders:** a source can now announce a channel count PyAV
cannot downmix (9, 11, 13, 15, 17–23, 25+ channels). Converting such a
source to a different channel count makes `SourceBridge` /
`AsrcSourceBridge` raise `ValueError` when it is created, so Music
Assistant's bridge will fail for those sources. Converting at the same
channel count works.

## Deferred

- S-4, S-5, S-8 and S-12 move to new issues.
- S-6 is tracked separately.
- S-11 is left to the maintainers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tighter Key Word usage

3 participants