Skip to content

feat(settings): read settings capabilities and effective values from v2 - #365

Merged
Quick104 merged 2 commits into
mainfrom
apiv2-stack/17-settings-reads-v2
Sep 23, 2026
Merged

Quick104 merged 2 commits into
mainfrom
apiv2-stack/17-settings-reads-v2

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

The settings contract capabilities probe and the effective-values read now use /api/v2 through the shared APIv2Client. The v1 read paths and the v1 capability model are gone. Setting writes stay on v1 until W4-B.

Problem

Inventory rows 42 and 43 are live v1 reads:

  • SiloAPI.getContractCapabilities called GET /api/v1/settings/contract/capabilities. The UI customization store (navigation menu, shortcuts, card presentation) uses it as its capability gate.
  • SiloAPI.getEffectiveValues called GET /api/v1/settings/values/effective. Player settings, profile preferences, card overlays and UI customization all read through it.

The v1 capability model can't decode the v2 document. The v2 document makes revision an opaque string, moves the manifest number to manifest_revision, and requires state, allowed and client_families (claim A3). The v2 effective read also changes shape. It takes repeated query parameters, wraps rows in items instead of settings, and sends library_id as a string.

Solution

  • New per-domain files. APIv2Client+Settings.swift adds settingsContractCapabilities and effectiveSettings. APIv2SettingsModels.swift adds APIv2SettingsContractCapabilities. Both reads go through the existing settingsRead. settingsRead checks the probe verdict, captures the owner, refuses a request whose requestIdentity no longer matches, and runs inside withOwnerFence. The owner-fence count in iosApp/iosApp stays at 60.
  • Capabilities. The model decodes revision (an opaque string), state, allowed, manifest_revision, client_families, supports_batched_effective and supports_atomic_shortcuts. contractIsAheadOfServer and the UI customization gate compare manifest_revision. supports_idempotent_writes is no longer decoded, because v2 advertises it without offering replay (A4). getContractCapabilities maps the document as follows:
    • available and allowed: .available. If manifest_revision is behind this build's revision (8), it returns .serverUpgradeRequired instead.
    • unsupported, a v1-only server (the legacy 404 or the probe verdict), or an older manifest: .serverUpgradeRequired.
    • disabled, not_configured, not allowed, or an unknown state: a new .unavailable case. UI customization treats it like a failed probe. It shows the read-only message, sends nothing, and keeps painting the cached layout, because the answer says nothing about the server's version (I9).
    • Any other error: .failed, which stays retryable.
  • UI customization gate. The gate now also requires client_families to contain this client's family, because card presentation is stored at profile_client. The gate no longer checks idempotent writes. refreshSequence and the three-case UICustomizationSupportProjection are unchanged (I8).
  • Effective values.
    • The read sends keys, library_ids (as strings) and series_ids as one repeated query item per value.
    • It never sends the household-parent profile_id. The profileId: parameter had no caller that named another profile, so it is gone. The read always answers for the session's selected profile, or for the profile in requestIdentity.
    • It decodes the items envelope and string library_id. A non-numeric library_id decodes as nil, so a reset can't target that row, but the rest of the batch still loads.
    • It refuses a response that has a row for another profile or the same key twice.
    • The existing contractIsAheadOfServer check on the response revision stays.
  • Errors. SettingsAPIError.from now maps APIv2Error:
    • serverUpdateRequired becomes .serverUpgradeRequired, so OverlayPrefsStore, PlayerSettings and ProfilePrefsEditor keep their update-required paths.
    • A 422 at query.keys becomes .unknownSetting, which is what v1's 404 unknown_setting produced.
    • Other problems become .server(status:code:message:), with the problem identifier as the code.
  • Identity comparison fix. settingsRead now normalizes the caller's server URL before it compares identities. The UI customization identity carries the registry URL spelling, which HTTPClient normalizes the same way.
  • Deleted. The v1 SettingsContractCapabilities struct and the v1 request code in getContractCapabilities and getEffectiveValues. EffectiveSettingValue and EffectiveSettingValuesResponse become Decodable, since nothing encodes them.

Both operations are reads, and a failed read keeps the prior state, so this PR needs no failure-outcome table.

Validation

  • iOS, tvOS and macOS builds passed.
  • iOS tests (SiloTests/SettingValuesAPITests SiloTests/UICustomizationPreferencesTests SiloTests/OverlayPrefsStoreTests SiloTests/PlayerSettingsFlushTests SiloTests/ProfileAndQualitySettingsTests SiloTests/SettingsConformanceTests SiloTests/UpdateRequirementTests SiloTests/APIv2ContractTests) passed: 306 tests, 0 failures. The same classes under SiloTVTests passed: 301 tests, 0 failures.
  • scripts/ci/check-no-api-v1.sh passed. The v1 literal counts drop in SiloAPI+Settings.swift, SettingValueModels.swift and SettingValuesAPITests.swift.
  • New and rewritten tests, all on StubURLProtocol-style stubs:
    • The capability document decodes from the body of the server's get_settings_contract_capabilities_ok fixture at 84ed9e596, and the opaque revision stays separate from manifest_revision. A not_configured document decodes and is not available.
    • Over the wire: a v1-only server's plain 404 returns .serverUpgradeRequired. A current server returns .available from /api/v2/settings/contract/capabilities, and an older manifest returns .serverUpgradeRequired. Each state and allowed combination maps to the expected result. A 500 problem becomes a .failed(.server) with the problem identifier. A stale profile identity is refused before any request, and the registry URL spelling is accepted.
    • Effective reads send repeated keys, library_ids and series_ids, the profile, client-family and device headers, and no profile_id. An older revision and a v1-only server map to .serverUpgradeRequired, and a 422 at query.keys maps to .unknownSetting. Rows for another profile and repeated keys are refused. String library ids decode.
    • UI customization: .unavailable keeps the cached layout and sends no writes or reads. A server that doesn't list this client family counts as needing an update.
    • The HTTPClient refresh tests that used the capabilities route as a vehicle now use the v2 path. OverlayPrefsStoreTests bodies use the v2 items envelope.
  • The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, built for macOS and passed the v1 path guard. Every branch in the stack builds on its own.
  • Not run: the plan's manual check of the settings screens on iOS, tvOS and macOS against a bridge server.

Risks and follow-ups

  • Setting writes (PUT/DELETE /api/v1/settings/values/* and the shortcut item PUT) stay on v1 with mutation IDs until W4-B. The UI customization outbox no longer checks supports_idempotent_writes before replaying. That is safe against a v1 server, which still deduplicates by mutation ID. W4-B replaces this with D4's coalesced retry.
  • A server whose client_families omits this client's family now shows "Update this Silo server to use synced interface settings." Every server at 84ed9e596 lists all five families.
  • .unavailable reuses the existing read-only message ("Interface settings are read-only until server support can be verified."). No new copy.
  • SettingScopeIdentity.profileLibrary still takes an Int. W4-B owns the write-side library id.
  • settingsRead answers any non-200 2xx with APIv2Error.incompleteCatalogRead. That is unchanged and can't happen here, because neither read sends If-None-Match.
  • The body of the server's settings capabilities fixture is inlined in the test instead of vendored. Adding it to scripts/sync-apiv2-fixtures.sh would change the fixture count that other lanes also edit.

AI disclosure

Code and description written by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code), orchestrated by a Claude Code workflow.


Part 17 of 50 in the Apple API v2 stack. Base: apiv2-stack/16-settings-contract-rev-8. Merge in order from the bottom of the stack. The plan and full index are in PR 01.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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: Advanced

Run ID: fb9a7adc-0ef2-42cd-80df-032fcaf4c726

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

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@greptile-apps greptile-apps Bot 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.

Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-23T13:40:52.828443Z cca0d4b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104

Copy link
Copy Markdown
Contributor Author

Code review summary

Reviewed head: 4025c4f0 (apiv2-stack/17-settings-reads-v2).

Process: an adversarial review of this PR's diff with each candidate finding independently verified before any fix, a simplify pass for medium and larger PRs, and a whole-stack review across contract conformance, authority and failure handling, data integrity, user-visible behavior and cross-PR integration.

Verified findings: none.

Validation: this branch builds on its own for iOS, tvOS and macOS, and its focused tests passed. The completed stack passed the full iOS suite (1981 tests) and tvOS suite (1792 tests) with 0 failures, the macOS build and the v1 path guard. The final stack was also exercised on iOS and tvOS simulators against a v1/v2 bridge server: sign-in (password and QR), restore, browse, search, detail, favorites and watchlist, playback (direct play, transcode, subtitles, stop), audiobooks, downloads with offline playback, settings, requests, profiles, push registration and diagnostics. Server logs showed no /api/v1 request from the new builds except the retained health probe.

Remaining: no open verified findings. Merge in stack order.

Mergeability: 8/10 — conditional. The approach holds up and every verified finding is fixed. Conditions: this PR's CI must pass (it was pending at review time), and the owner still plans a physical-device check of the completed stack.

Review by Claude Opus 5.5 (claude-opus-5-5) agents in Claude Code (T3 Code).

@Quick104
Quick104 force-pushed the apiv2-stack/16-settings-contract-rev-8 branch from 2c8222f to 40388ce Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/17-settings-reads-v2 branch from 4025c4f to 01c8da7 Compare September 23, 2026 13:19
@Quick104
Quick104 force-pushed the apiv2-stack/16-settings-contract-rev-8 branch from 40388ce to a5e76cb Compare September 23, 2026 13:36
Base automatically changed from apiv2-stack/16-settings-contract-rev-8 to main September 23, 2026 13:36
Quick104 and others added 2 commits September 23, 2026 09:36
The settings contract capabilities probe and the batched effective-values
read still called /api/v1. The v1 capability model decoded `revision` as
an integer, so it cannot read the v2 document, where `revision` is an
opaque string and the manifest number moves to `manifest_revision`.

Both reads now go through the shared APIv2Client (new
APIv2Client+Settings.swift) and its owner-fenced settingsRead. A new
APIv2SettingsContractCapabilities model decodes revision, state, allowed,
manifest_revision and client_families; the revision gates compare
manifest_revision, and supports_idempotent_writes is no longer read. A
document that is not available and allowed maps to a new `unavailable`
result that keeps cached UI customization; `unsupported`, a v1-only
server, or an older manifest still reports that the server needs an
update. UI customization also requires the server to accept this
client's family for profile_client.

Effective values send keys, library_ids and series_ids as repeated query
items, never send the household-parent profile_id, decode the `items`
envelope and string library ids, and refuse rows for another profile or
repeated keys. v2 errors map onto SettingsAPIError (a 422 at query.keys
is unknownSetting). settingsRead now normalizes the caller's server URL
before comparing identities. The v1 SettingsContractCapabilities model
and the v1 read paths are deleted; tests move to the v2 routes and
shapes.

Stack-PR: W4-A
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Stack-PR: W4-A
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 force-pushed the apiv2-stack/17-settings-reads-v2 branch from 01c8da7 to cca0d4b Compare September 23, 2026 13:36
@Quick104
Quick104 merged commit 5a85ef3 into main Sep 23, 2026
3 of 6 checks passed
@Quick104
Quick104 deleted the apiv2-stack/17-settings-reads-v2 branch September 23, 2026 13:36
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