Skip to content

Clarify client/state delta vs full updates - #101

Merged
maximmaxim345 merged 1 commit into
mainfrom
client-state-delta-updates
Jun 16, 2026
Merged

maximmaxim345 merged 1 commit into
mainfrom
client-state-delta-updates

Conversation

@kahrendt

Copy link
Copy Markdown
Contributor

client/state said deltas "only include fields that have changed," but static_delay_ms, required_lead_time_ms, and min_buffer_ms were marked "always required for players." A delta changing one field can't satisfy both rules (#98). Separately, the spec didn't make clear whether a client may send full state instead of a delta, or what the server does with an absent field (#91, item 3).

Changes:

  • Drop "always" from the three player fields and scope all field-presence rules to a player's full state.
  • State the update model once: the initial message MUST be complete; later messages MAY send only changed fields; the server MUST merge and retain the last value of any absent field; a client MAY resend unchanged fields up to its full state.
  • Replace the per-field delta wording with a single "Delta updates" note.
  • Use RFC 2119 keywords in the affected passages.

A missing field always means "unchanged" — client/state has no null-clearing semantics, so the server never has to tell a delta apart from a full update; it merges either one the same way.

Out of scope: the other two items in #91 (default goodbye reason, external_source SDK API).

Closes #98
Refs #91

Resolve the contradiction (#98) between the client/state delta rule and
the player fields marked "always required for players": deltas could not
satisfy both. The "always" wording is dropped and the field-presence
rules are scoped to a player's full state.

Permit clients to send either deltas or full state updates with the
server merging both (#91): the initial message MUST be complete, later
messages MAY send only changed fields, and the server MUST retain the
last value of any absent field. A single "Delta updates" note replaces
the per-field repetition.

Use RFC 2119 keywords in the affected passages.

@maximmaxim345 maximmaxim345 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@maximmaxim345
maximmaxim345 merged commit 127a0c7 into main Jun 16, 2026
@kahrendt
kahrendt deleted the client-state-delta-updates branch June 16, 2026 16:15
maximmaxim345 added a commit to Sendspin/sendspin-js that referenced this pull request Jul 13, 2026
Every `client/state` previously resent the full player payload. Now the
first send after each connect is a full snapshot and later sends are
deltas carrying only the changed fields, which the server merges.
This is specifically allowed since
Sendspin/spec#101.

Closes #114
maximmaxim345 added a commit that referenced this pull request Aug 28, 2026
`client/state`, `server/state` and `group/update` each defined their own
merge rules, and the three disagreed on whether merging was required,
whether `null` cleared a field, how deep the merge went, and which
message had to be complete (#149). Rather than reconcile them into one
rule, drop merging.

## Changes:

- All three messages carry full state on every message.
- For `client/state` and `server/state` the role object is the unit: an
included object carries that role's full state, and an omitted one
leaves that role's state unchanged. Differential updates survive at role
granularity, which is what the optional role objects were always for.
- Drop the `| null` variant from leaf fields in the `metadata` and
`color` objects. A role object may still be `null` in `server/state`,
which is how the server ends a role's state when it drops the role from
`active_roles`, and it was never a delta mechanism.
- `group/update`'s `playback_state`, `group_id` and `group_name` are no
longer optional.

What this costs is bandwidth on metadata text, which is sent on state
change rather than continuously; anything large already travels as a
binary message. What it saves is the reconciliation layer on the
receiving side, which has been a steady source of bugs and runs to a few
hundred lines in a client that gets it right.

## Fields whose absence carried a second meaning

Dropping the merge silently repurposes every optional field that used to
mean "unchanged". Each one is now stated where the reader meets the
field, rather than in a rule they have to remember:

- `metadata.progress`: omitting it clears the client's position, so the
server includes it in every `metadata` state that has a position to
report. Track position is calculated from the current metadata state
rather than from the last message that happened to include `progress`,
which only made sense while absent meant unchanged. A resent `progress`
is measured at the new `timestamp` rather than copied forward under it,
which the merge rules used to make moot by never resending it at all.
- The player state object's `supported_commands`: absence now says the
player accepts no commands, which is what `[]` already says. The `?`
goes rather than the redundant encoding staying around to silently
revoke `set_output_delay`. Both other `supported_commands` in the spec
are already non-optional.
- Role objects themselves, covered by the omitted-object rule above.

## Follow-on cleanups

- The player role's "Delta updates" paragraph is gone.
- `REQUIRED for players` on the three non-optional fields in the player
state object goes with it. It was an anchor for that paragraph, `?`
already marks optionality (see the note under Communication), and the
object is player-only.
- The `available: false` handling no longer describes sending a
`group/update` carrying only `playback_state`.

This conflicts with #135 on `messaging.md`, `roles/metadata/v1.md` and
`roles/color/v1.md`, in that PR's favour: with no merging, its rule that
the first message after a scheduled one must repeat the scheduled
message's fields has nothing left to do.

Out of scope: the `management/set-pairing-config` patch semantics in
`management.md`, which is a configuration API rather than state
streaming.

Closes #149
Refs #101

## Breaking changes

Both directions break, not just the server.

Servers must send full `server/state` and `group/update` messages
instead of deltas. A client that still merges keeps stale leaves,
because clearing a leaf is now omission rather than an explicit `null`.

Clients must send full `client/state` messages, and a player must now
always carry `supported_commands`. A client that still sends deltas has
them read as full state, so every field it omits is dropped rather than
retained. Neither side errors.

---------

Co-authored-by: Maxim Raznatovski <[email protected]>
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.

client/state delta rule contradicts "always required" player fields

2 participants