Repository navigation
feat(settings): read settings capabilities and effective values from v2 - #365
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Quick104 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code review summaryReviewed head: 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 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 ( |
2c8222f to
40388ce
Compare
4025c4f to
01c8da7
Compare
40388ce to
a5e76cb
Compare
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]>
01c8da7 to
cca0d4b
Compare
The settings contract capabilities probe and the effective-values read now use
/api/v2through the sharedAPIv2Client. 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.getContractCapabilitiescalledGET /api/v1/settings/contract/capabilities. The UI customization store (navigation menu, shortcuts, card presentation) uses it as its capability gate.SiloAPI.getEffectiveValuescalledGET /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
revisionan opaque string, moves the manifest number tomanifest_revision, and requiresstate,allowedandclient_families(claim A3). The v2 effective read also changes shape. It takes repeated query parameters, wraps rows initemsinstead ofsettings, and sendslibrary_idas a string.Solution
APIv2Client+Settings.swiftaddssettingsContractCapabilitiesandeffectiveSettings.APIv2SettingsModels.swiftaddsAPIv2SettingsContractCapabilities. Both reads go through the existingsettingsRead.settingsReadchecks the probe verdict, captures the owner, refuses a request whoserequestIdentityno longer matches, and runs insidewithOwnerFence. The owner-fence count iniosApp/iosAppstays at 60.revision(an opaque string),state,allowed,manifest_revision,client_families,supports_batched_effectiveandsupports_atomic_shortcuts.contractIsAheadOfServerand the UI customization gate comparemanifest_revision.supports_idempotent_writesis no longer decoded, because v2 advertises it without offering replay (A4).getContractCapabilitiesmaps the document as follows:availableandallowed:.available. Ifmanifest_revisionis behind this build's revision (8), it returns.serverUpgradeRequiredinstead.unsupported, a v1-only server (the legacy 404 or the probe verdict), or an older manifest:.serverUpgradeRequired.disabled,not_configured, notallowed, or an unknown state: a new.unavailablecase. 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)..failed, which stays retryable.client_familiesto contain this client's family, because card presentation is stored atprofile_client. The gate no longer checks idempotent writes.refreshSequenceand the three-caseUICustomizationSupportProjectionare unchanged (I8).keys,library_ids(as strings) andseries_idsas one repeated query item per value.profile_id. TheprofileId: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 inrequestIdentity.itemsenvelope and stringlibrary_id. A non-numericlibrary_iddecodes as nil, so a reset can't target that row, but the rest of the batch still loads.contractIsAheadOfServercheck on the responserevisionstays.SettingsAPIError.fromnow mapsAPIv2Error:serverUpdateRequiredbecomes.serverUpgradeRequired, soOverlayPrefsStore,PlayerSettingsandProfilePrefsEditorkeep their update-required paths.query.keysbecomes.unknownSetting, which is what v1's 404unknown_settingproduced..server(status:code:message:), with the problem identifier as the code.settingsReadnow normalizes the caller's server URL before it compares identities. The UI customization identity carries the registry URL spelling, whichHTTPClientnormalizes the same way.SettingsContractCapabilitiesstruct and the v1 request code ingetContractCapabilitiesandgetEffectiveValues.EffectiveSettingValueandEffectiveSettingValuesResponsebecomeDecodable, 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
SiloTests/SettingValuesAPITests SiloTests/UICustomizationPreferencesTests SiloTests/OverlayPrefsStoreTests SiloTests/PlayerSettingsFlushTests SiloTests/ProfileAndQualitySettingsTests SiloTests/SettingsConformanceTests SiloTests/UpdateRequirementTests SiloTests/APIv2ContractTests) passed: 306 tests, 0 failures. The same classes underSiloTVTestspassed: 301 tests, 0 failures.scripts/ci/check-no-api-v1.shpassed. The v1 literal counts drop inSiloAPI+Settings.swift,SettingValueModels.swiftandSettingValuesAPITests.swift.StubURLProtocol-style stubs:get_settings_contract_capabilities_okfixture at84ed9e596, and the opaque revision stays separate frommanifest_revision. Anot_configureddocument decodes and is not available..serverUpgradeRequired. A current server returns.availablefrom/api/v2/settings/contract/capabilities, and an older manifest returns.serverUpgradeRequired. Each state andallowedcombination 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.keys,library_idsandseries_ids, the profile, client-family and device headers, and noprofile_id. An older revision and a v1-only server map to.serverUpgradeRequired, and a 422 atquery.keysmaps to.unknownSetting. Rows for another profile and repeated keys are refused. String library ids decode..unavailablekeeps the cached layout and sends no writes or reads. A server that doesn't list this client family counts as needing an update.OverlayPrefsStoreTestsbodies use the v2itemsenvelope.Risks and follow-ups
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 checkssupports_idempotent_writesbefore replaying. That is safe against a v1 server, which still deduplicates by mutation ID. W4-B replaces this with D4's coalesced retry.client_familiesomits this client's family now shows "Update this Silo server to use synced interface settings." Every server at84ed9e596lists all five families..unavailablereuses the existing read-only message ("Interface settings are read-only until server support can be verified."). No new copy.SettingScopeIdentity.profileLibrarystill takes anInt. W4-B owns the write-side library id.settingsReadanswers any non-200 2xx withAPIv2Error.incompleteCatalogRead. That is unchanged and can't happen here, because neither read sendsIf-None-Match.scripts/sync-apiv2-fixtures.shwould 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