Skip to content

docs: define cross-platform user settings contract - #377

Closed
Quick104 wants to merge 5 commits into
mainfrom
docs/cross-platform-settings-contract
Closed

Quick104 wants to merge 5 commits into
mainfrom
docs/cross-platform-settings-contract

Conversation

@Quick104

@Quick104 Quick104 commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Design-only draft for standardizing user settings across the server, bundled web client, Apple clients, and Android clients.

This turns the findings in #376 into a typed, decision-complete contract covering ownership, value types, persistence scopes, resolution order, storage, API shape, client synchronization, UX language, migration, and release gates.

No runtime behavior changes in this PR.

Core decisions for review

  1. Every production user-facing setting requires a server-owned manifest entry, including settings whose values remain client-local.
  2. Only private local.<client>.* implementation, diagnostics, or experimental knobs may bypass the server contract; they must never reach the API or normal production Settings UI.
  3. One coordinated breaking release. The manifest, typed API, canonical storage, migration, and removal of the legacy settings surface ship together; server, bundled web, Apple, and Android update at the same time. Mixed-version operation is an explicit non-goal — no shim, no projection, no client fallback. After the cutover, no future setting requires coordination; manifest revisions move independently per repository.
  4. internal/policy stays authoritative for restrictions. Definitions declare constrained_by, the effective response reports the permitted value alongside the user's stored preference, and a restriction filters what a preference does rather than validating what it is.
  5. Account/profile values roam into a new browser or incognito session; profile-device overrides do not. Appearance and date/time settings live at profile scope, not account.
  6. jellycompat (third-party Jellyfin clients) carries no contract negotiation; its DisplayPreferences seed repoints to the canonical resolver at profile scope and its blobs move off the legacy user_settings store.

Changed in the latest revision

The 426 upgrade gate is withdrawn — but the coordinated cutover it was meant to enforce is not. Removing the legacy routes already produces the break: an old client gets 404 and its settings screens fail, which is what "update both" means. Adding a version header to every request plus a check in the authenticated middleware is strictly more code, in four repositories, for the same user-visible outcome — and it permanently couples every endpoint in the product to one subsystem's versioning for a one-time event. Route removal has no such tail.

Preferences versus restrictions is new. internal/policy already resolves max_playback_quality and metadata-language restrictions over the same controls this contract resolves preferences for. Without an explicit seam, a child profile capped at 720p gets an effective value of 2160p, renders 4K as selectable, and playback silently disagrees. Adds constrained_by, requested_value/permitted_values reporting, and the rule that mutations exceeding a restriction are stored, not rejected — a stored 4K preference should take effect the day the cap lifts, not be destroyed by it.

Compatibility rules split widening from narrowing. Blanket definition immutability was simultaneously too strict (scope widening is backward-safe) and too weak (defaults and enum widening were already permitted, which broke the safety argument). introduced_in is now a manifest revision, and enum members, scopes, and widened bounds carry their own so a newer client never offers a choice an older server will reject.

Appearance and date/time move from account to profile scope. Account scope was an artifact of pre-profile user_settings storage; under the old rules a household shared one theme and text size, and any non-child profile could restyle everyone else permanently. Account writes now require the primary profile.

A read path section: batched context-resolution endpoint (profile_series resolution is per-item, so a season view would otherwise issue one request per episode), index requirements, session-snapshot rule, and a no-regression benchmark against the specialized tables being replaced.

Also: degraded settings mode instead of account lockout when a per-user SQLite database is quarantined; a separate user_settings event channel rather than overloading the admin-only one; an idempotency sweeper; advisory platforms; and clearer device-scope UX copy ("This device, for this profile").

Finally, a phase that ships the #376 P1 fixes ahead of the contract — the Apple audio-language no-op, Android's key/clamp/default drift, the durable outboxes, and web cache owner-tagging are all independent of the manifest and shouldn't wait on the migration.

Review focus

  • Is one coordinated switchover right, given it means no old client works until both sides update?
  • Is constrained_by the right seam between this contract and internal/policy, particularly the rule that mutations exceeding a restriction are stored rather than rejected?
  • Is moving appearance and date/time to profile scope correct, given it costs a fan-out migration rule now to avoid a new-key migration later?
  • Is the widening-vs-narrowing compatibility table complete?
  • Is retaining superseded columns for one release (rather than dropping them in the migration) worth the follow-up migration?
  • Is the standardized scope copy clear enough for web, Apple, and Android UX?

Verification

  • Reconciled against the current server, Apple, and Android implementations documented in Unify roaming and device-scoped user settings across web, Apple, and Android #376.
  • Review pass (2026-07-11) re-verified every drift claim against silo-server, silo-apple, silo-android at the pinned baselines, plus the jellycompat surface.
  • Revision pass (2026-07-25) re-checked the design against internal/api/handlers/settings.go, web/src/lib/settingsManifest.ts, internal/policy, internal/events, internal/jellycompat/handlers_displayprefs.go, internal/userdb, internal/userstore/pgstore, and docs/architecture/v1-scope.md. Confirmed: the unknown-key extension bag (keyUsesUserScope accepts any unregistered key), the web manifest's 18 definitions with zero user-scope entries against ~24 server keys, the settings event channel being admin-granted with no publishers, and v1 scope reading NOT LOCKED — which is why the removal needs no amendment if it lands before lock.
  • make verify-local-paths passes.
  • Spec-only change; no source tests were required.

Related to #376. This PR intentionally does not close the implementation issue.

AI-use disclosure

The original design and its revisions were drafted with AI assistance (Claude Opus 5) under maintainer direction. All claims about current behavior were verified against the cited source files; the rollout model, policy seam, and scope assignments were reviewed and decided by the maintainer.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ec44d5b-76b7-4e15-8866-9a312042fb23

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/cross-platform-settings-contract

Comment @coderabbitai help to get the list of available commands.

Part of #376. Amends the draft in PR #377 per review:

- Scope the post-cutover hard gate to the protocol version only;
  manifest revisions become monotone-compatible within protocol 1
  (clients hide definitions newer than the connected server), so
  additive settings no longer require four-platform lockstep releases.
  Acknowledge the store-auto-update vs operator-upgrade window.
- Add the Jellyfin compatibility surface section: jellycompat is
  exempt from the handshake, DisplayPreferences seed repoints to the
  canonical resolver, and its blobs move off the legacy user_settings
  store before that table is dropped.
- Correct the foreign-key claim: delete behavior is application-
  enforced (SQLite store has no FKs; Postgres has none on
  library/series/device columns) and covered by the conformance suite.
- Soften migration failure semantics: recognized-but-unnormalizable
  values are quarantined to the rejects table; hard abort is reserved
  for structural failures. Define per-user SQLite migration atomicity.
- Specify account-scope authorization (child profiles cannot mutate),
  last-write-wins concurrency, outbox hold behavior on 426, RFC 8785
  canonical JSON for the manifest digest, delivery of settings-changed
  events over the existing internal/events hub, and note the silo-apple
  baseline branch.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Quick104

Copy link
Copy Markdown
Contributor Author

Applied the design-review findings in 9314df1 (review pass verified every claim against silo-server, silo-apple, and silo-android code plus the jellycompat surface — all drift claims held):

Design changes

  • Post-cutover gate softened to protocol version only. The cutover release is still built and verified as one exact version+revision set, but afterwards manifest revisions are monotone-compatible within protocol 1: the server accepts any revision, and clients hide definitions newer than the connected server. Rationale: definition immutability already prevents split-brain for additive revisions, and exact-match would have made every new setting a four-platform lockstep release — recreating the pressure to smuggle knobs through local.*. Also documents the store-auto-update vs operator-upgrade window and requires both upgrade screens to name which side is behind.
  • New "Jellyfin compatibility surface" section. jellycompat runs on its own router/listener and is exempt from the handshake (third-party clients can never be gated). Its DisplayPreferences handler was the one real breakage found: it seeds from profile subtitle_language/subtitle_mode/auto_skip_credits columns this migration removes and persists via the legacy user_settings store. The spec now moves those blobs to dedicated jellycompat storage and repoints the seed at the canonical resolver; the user_settings table is then dropped explicitly.

Corrections & hardening

  • Foreign-key claim corrected: the per-user SQLite store declares no FKs and Postgres has none on library/series/device columns, so delete behavior is application-enforced and covered by the store conformance suite.
  • Migration failure semantics: recognized keys with unnormalizable values are quarantined to the rejects table (reported, resolve to default) instead of bricking startup; hard abort is reserved for structural failures. Per-user SQLite databases migrate atomically and independently with completion markers — one damaged user DB cannot block the whole server.
  • Account-scope authorization specified: child profiles cannot mutate account-scope values.
  • Native outboxes treat 426 as a hold state (queue kept, upgrade surfaced), not a failure.
  • Last-write-wins concurrency stated explicitly; manifest digest defined over RFC 8785 canonical JSON; settings-changed events ride the existing internal/events hub (its settings channel re-scoped from admin-only to per-user routing).
  • Baseline note: the silo-apple commit sits on feature/tvos-manual-up-next (merge base 169e4917 with main); all cited files are identical on both, so findings hold on main.

PR body updated to match (core decision 3, review focus).

Quick104 and others added 3 commits July 25, 2026 07:24
Revises the cross-platform settings contract design after review against the
current server, web, and policy implementations. The contract model itself —
server-owned manifest, typed values, per-definition resolution order, generated
bindings, durable client outbox — is unchanged. What changes is how it ships and
what it reconciles with.

Rollout. The hard `426 Upgrade Required` gate is withdrawn. It sat on the whole
first-party authenticated chain, so a settings-version mismatch made the entire
app unusable, and app-store auto-update against self-hosted servers guarantees
that window happens. It was also version sniffing, which docs/architecture/
v1-scope.md rules against in favor of capability endpoints, and it contradicted
the coexistence approach the playback protocol v3 plan chose for a larger
cross-platform change. Detection now uses the manifest endpoint; older clients
fall back to the legacy string API through a projection over the canonical
resolver instead of being blocked.

Staging. The design is split into three independently shippable stages: A binds
the manifest to existing storage (additive, fixes all of #376's P1s, no data
moves), B consolidates storage behind an unchanged API, C retires the legacy
surface. Nothing requires a lockstep four-repository release, which also removes
the incentive to route around the contract via unregistered local.* keys.

Policy seam. internal/policy already resolves max_playback_quality and metadata
language restrictions over the same controls this contract resolves preferences
for. Adds `constrained_by`, permitted-value reporting, and the rule that a
restriction filters what a preference does rather than validating what it is, so
a capped profile never renders a choice playback will refuse.

Also: revision-tagged enum members, scopes, and bounds so widening stays safe
where the previous blanket immutability rule was both too strict (scope
widening) and too weak (defaults and enum widening were already mutable);
appearance and date/time moved from account to profile scope, since account
scope was an artifact of pre-profile storage and let any non-child profile
restyle the household; account writes narrowed to the primary profile; a read
path section with a batched context endpoint, index requirements, and a
no-regression gate on stage B; degraded settings mode instead of account
lockout on a quarantined per-user SQLite database; a separate user_settings
event channel; an idempotency sweeper; jellycompat seeding pinned to profile
scope; and clearer device-scope UX copy.

Related to #376. Still design-only; no runtime behavior changes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Reverts the staged A/B/C rollout from the previous commit. Phasing required a
compatibility projection of the old string API over the new resolver, plus
manifest bindings to the very tables the migration replaces — both written only
to be deleted, and a meaningful fraction of the permanent code in this
subsystem. The project is pre-1.0, v1 scope is unlocked, and data volumes are
small, so one clean switchover costs less than the scaffolding needed to avoid
it. Server, bundled web, Apple, and Android now update together, and mixed
version operation is an explicit non-goal.

No client fallback either. A new client against a pre-contract server shows
server-upgrade-required rather than degrading to local defaults; there is no
legacy write path.

The 426 middleware gate stays withdrawn, on narrower grounds than before. It is
not about giving mismatched clients grace — it is that deleting the routes
already produces the break, so the gate is strictly more code in four repos for
the same outcome, and it permanently couples every endpoint in the product to
one subsystem's versioning for a one-time event. Route removal has no such tail.
An old client gets 404 on removed routes; that is what "update both" means.

Kept from the staging pass, since it costs nothing: the migration does not DROP
superseded columns. It stops reading them and leaves them for a trivial
follow-up migration one release later, which turns recovery from "restore the
backup and the prior binary" into "revert the binary". Nothing reads them and no
client can reach them, so this is an operator affordance, not a compatibility
path.

Also adds a phase that ships the #376 P1 fixes ahead of the contract — the Apple
audio-language no-op, Android's key/clamp/default drift, the durable outboxes,
and web cache owner-tagging are all independent of the manifest and should not
wait on the migration. Notes the release-ordering hazard found while checking
this: silo-android publishes plain versions straight to Play Store while
silo-server has no versioned releases at all, only Docker latest, so operators
have no version number to reason about.

Unchanged from the prior revision: the policy seam and constrained_by, the
widening-vs-narrowing compatibility rules and revision-tagged sub-elements,
appearance and date/time at profile scope, the read path section, degraded
settings mode on a quarantined user database, the separate user_settings event
channel, the idempotency sweeper, jellycompat seeding at profile scope, and the
device-scope UX copy. Those are orthogonal to rollout.

Related to #376. Still design-only; no runtime behavior changes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Coordinated server/client updates are expected during beta, so the pre-release
gate no longer frames the Play Store / Docker latest ordering as a hazard. Keeps
the actionable part: release notes name the server build to pull alongside the
client versions, since image tags do not carry that pairing.

Related to #376.

Co-Authored-By: Claude Opus 5 (1M context) <[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.

1 participant