Repository navigation
Conversation
First implementation step for the cross-platform settings contract (#376). Adds the artifact everything else depends on: the manifest, its JSON Schema, the object value schemas, and a Go loader that validates the whole thing at load time. No routes, no storage, no behavior change — nothing reads this yet. contracts/settings/v1/ holds the artifact at a stable path because clients vendor it and generate bindings from it. The embed directive has to sit beside it (go:embed cannot reach outside its own directory), so that directory is a tiny Go package containing nothing else; loading and validation live in internal/settingscontract. 38 definitions: 35 remote, 3 contract-known client_local. That covers every key the legacy registry accepts, every unregistered key the extension bag was silently accepting from the web client, every unregistered device key Android writes, and the profile preference columns that become settings. Registering the previously-unregistered keys is where the drift shows up, and the manifest records each case in a notes field: - ui_theme, ui_text_scale, ui_text_weight, ui_high_contrast, ui_custom_theme_vars, and ui_custom_css reached the server only because keyUsesUserScope returns true for any unregistered key. They are now typed, renamed to the dotted convention every other key uses, and moved to profile scope per the design. - player.match_frame_rate and player.sleep_timer_default_minutes are written by Android against a server that does not register them, so every write and reset is currently rejected. Registered. - player.next_up_prompt_seconds is Android's alias for playback.next_up_prompt_seconds and does not become a definition; the test matrix pins it as a migration alias. - player.playback_speed is capped at 3.0, matching the server rather than Android's 4.0. - subtitle_appearance becomes playback.subtitle_appearance. Every other canonical key carries a domain prefix, and preserving accidental key names is an explicit non-goal of the design. Validation is deliberately stricter than the schema can express. Beyond shape, it enforces that a resolution order ends in "default", that it only resolves scopes the definition allows, and — the one most likely to bite — that every writable scope is actually read, so a setting cannot accept writes at a scope it will never honor. Defaults are validated against their own value schema, so a default that violates its own range or enum fails at load. Revision tags are checked to never run ahead of the manifest revision, which is what makes revision-aware client filtering trustworthy. Ceiling and floor policy constraints are rejected on unordered types, where capping would silently do nothing; playback.preferred_quality's enum is therefore ordered ascending. ValidateValue is the single validation path, so the mutation endpoint, the migration, and the manifest's own default checks cannot diverge later. Numbers decode through json.Number so an integer setting rejects 30.5 rather than truncating, and object values validate against their referenced JSON Schema instead of accepting arbitrary JSON the way validateJSONSetting does today. Canonicalization implements RFC 8785 over the value domain the contract uses: sorted keys, no insignificant whitespace, ECMAScript number formatting. The digest is the ETag, and PublicBytes strips maintainer notes so the served manifest never carries internal commentary. Promotes santhosh-tekuri/jsonschema/v6 from indirect to direct. Verification: 124 tests pass across 16 cases; golangci-lint clean; make verify-local-paths passes. Two failures in internal/api/handlers (TestRemoveJellyfinCompatWebDisablesWebSetting, the playback v3 seek recovery test) reproduce unchanged on main and are unrelated. Part of #376. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Theme joins text scale, text weight, and high contrast as a profile default with an optional per-device override, resolving profile_device -> profile -> default. The right theme is partly a function of the screen and the room — a light theme on a phone in daylight, a dark one on a TV at night — which is the same reasoning the other three appearance keys already used. All four appearance settings now cascade consistently, which also means one rule to explain in the UI rather than "these three follow the device, that one does not". ui.custom_theme_vars and ui.custom_css stay profile-wide. They are authored styling rather than a contextual preference, so a profile's custom tokens still apply on top of whichever theme a device resolves to. Recorded in the definition notes because it is a visible consequence: vars tuned against a dark theme will sit on top of a light one if a device overrides the theme. Widening those to profile_device later is an additive revision bump if it turns out to matter. Part of #376. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This was referenced Jul 25, 2026
Contributor
Author
|
Superseded by #479, which combines the design, the manifest, the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First implementation step for the settings contract (#477). Adds the artifact everything else depends on. Nothing reads it yet — no routes, no storage, no behavior change.
What changed
contracts/settings/v1/— the artifact, at a stable path because clients vendor it and generate bindings from itmanifest.json— 38 definitions (35 remote, 3 contract-knownclient_local)manifest.schema.json— the contract formatschemas/— object value schemas for subtitle appearance, theme variable overrides, library page stateembed.go— a package containing nothing but the embed directive, becausego:embedcannot reach outside its own directoryinternal/settingscontract/— loading, structural validation, value validation, RFC 8785 canonicalization, ETag, and a public projection that strips maintainer notesWhat the inventory turned up
The manifest covers every key the legacy registry accepts, every key the extension bag was silently accepting, every unregistered device key Android writes, and the profile columns that become settings. Each non-obvious case is recorded in a
notesfield:ui_theme,ui_text_scale,ui_text_weight,ui_high_contrast,ui_custom_theme_vars,ui_custom_cssreached the server only via the unknown-key extension bag — untyped and unvalidated, withui_custom_theme_varsstoring arbitrary JSONplayer.match_frame_rateandplayer.sleep_timer_default_minutesare written by Android against a server that registers neither, so every write and every reset returns 400 todayplayer.next_up_prompt_secondsis Android's alias forplayback.next_up_prompt_seconds4.0, the server to3.03.0subtitle_appearanceis the only key with no domain prefixplayback.subtitle_appearanceValidation is stricter than the schema
The JSON Schema checks shape. The Go layer checks what actually causes bugs:
defaultand may only resolve scopes the definition allowsceiling/floorpolicy constraints are rejected on unordered types, where capping would silently do nothing. This forcedplayback.preferred_quality's enum to be ordered ascending so itsmax_playback_qualityceiling has a defined directionValidateValueis the single validation path, so the mutation endpoint, the migration, and the manifest's own default checks cannot diverge later. Numbers decode throughjson.Number, so an integer setting rejects30.5instead of truncating, and object values validate against their referenced schema rather than accepting any JSON the wayvalidateJSONSettingdoes today.Verification
golangci-lint run ./internal/settingscontract/... ./contracts/...→ 0 issuesmake verify-local-pathspasses;go build ./...cleaninternal/api/handlersreproduce unchanged onmainand are unrelated (one needs ffmpeg, one is a temp-dir cleanup race)Notes for review
santhosh-tekuri/jsonschema/v6from indirect to directclient_localdefinitions (downloads.wifi_only,downloads.keep_watched,subtitle.matches_device) are contract-owned because Apple and Android both implement them with shared semantics, but the value never leaves the device. Validation enforces exactly oneclient_localscope and no policy constraintui.themecarries a device override, added in the second commit — light theme on a phone in daylight, dark on a TV.ui.custom_theme_varsandui.custom_cssstay profile-wide, so custom tokens tuned against a dark theme will sit on top of a light one if a device overrides. Widening those later is an additive revision bumpPart of #376. Design: #477.
AI-use disclosure
Implemented with AI assistance (Claude Opus 5) under maintainer direction. The inventory was derived by reading the current server registry, web manifest, Android
PlaybackSettingsKeys, and the profile/library/series preference stores; every drift claim is reproducible from those sources.