Repository navigation
fix(apiv2): decode v2 models as the server sends them - #353
Conversation
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (15)
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 ( |
43c7772 to
9fff17c
Compare
84c8934 to
8f69772
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f697728e2
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// player handle, or that names another file, is left out instead of | ||
| /// failing the whole list. | ||
| func playerValues(mediaFileID: Int) -> [DownloadedSubtitle] { | ||
| subtitles.compactMap { try? $0.playerValue(mediaFileID: mediaFileID) } |
There was a problem hiding this comment.
Preserve subtitle ordinals when filtering IDs
When an opaque, oversized, or wrong-file row precedes a valid row, compactMap shifts the valid row's position. Downloaded subtitle stream URLs are addressed by the row's original position in the server listing—not by its database ID—so a downstream firstIndex followed by synthesizedDescriptor(position:) will request the wrong subtitle track. Preserve each row's original ordinal while filtering, or return a projection that carries that ordinal.
AGENTS.md reference: AGENTS.md:L16-L17
Useful? React with 👍 / 👎.
9fff17c to
1231237
Compare
Several unwired APIv2 models disagreed with the server's openapi document. The playback control capabilities model required an ownerLeaseAdmission member the server never sends, so every control-ticket request failed to decode. Catalog search capabilities required provider (optional on the wire) and treated allowed (required) as optional. Metadata AI status ignored allowed. A stored subtitle list could only be projected all or nothing, and catalogFilters captured its own owner instead of taking the caller's, so facet results could not be tied to the profile that asked. Match each model to the 84ed9e596 contract: drop ownerLeaseAdmission and gate the ticket on allowed, state, available and protocol; make provider optional, allowed required and add people_media_scope and person_prefetch; honor allowed for metadata AI while keeping on_view tolerant; add a fail-soft stored-subtitle list projection; and bind catalogFilters to a supplied owner with a required profile. Each fix has a fixture test, using the server's published fixtures where they exist. Stack-PR: F4 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
8f69772 to
16cb951
Compare
Problem
Several APIv2 models that no app code calls yet do not match the server's contract (
contracts/api/v2/openapi.jsonat84ed9e596). The later PRs that wire them would have hit these bugs:APIv2PlaybackControlCapabilitiesrequiredownerLeaseAdmission. The server never sends that member (playback_control_socket_test.go:110, 124checks that it is absent), soplaybackControlRequestfails to decode every capability response. The model also skippedallowed,stateandrevision.APIv2CatalogSearchCapabilitiesrequiredprovider, which the contract marks optional. It treatedallowed, which the contract requires, as optional. It also lackedpeople_media_scopeandperson_prefetch. A server with search not configured omitsprovider, and the whole read failed.APIv2MetadataAICapabilityignoredallowed. A principal the server refuses would still see the translate affordance.try. A list read would fail entirely because of one row whose opaque string ID does not fit the player's integer handle.APIv2Client.catalogFilterscaptured its owner insiderequestGet. The caller could not supply the owner it caches results under, and the read did not require the profile that openapi requires (X-Profile-Id).Solution
APIv2PlaybackControlCapabilitiesnow decodesavailable,protocol,revision,stateandallowed.servesControlHandshakerequiresallowed && state == "available" && available && protocol == "silo.playback-control.v2".playbackControlRequestchecks the 200 status before it decodes and mints a ticket only under that gate. The TLS rule (D11) is left for W2-D.APIv2CatalogSearchCapabilities:provideris optional andallowedis required. It addspeopleMediaScope,personPrefetchand anisAvailablegate (allowed && state == "available", invariant I9).APIv2MetadataAICapabilityrequiresallowed.playerValueis enabled only whenallowed && state == "available".on_viewstays tolerant: an unknown value decodes to.off, as before.APIv2StoredSubtitles.playerValues(mediaFileID:)returns the rows the player can address and drops rows with opaque, oversized or non-canonical IDs, or rows for another file. The single-row projection and the AI job projection stay strict. No code force-unwraps an ID. W5-Q uses this list projection when it movesdownloadedSubtitlesto v2.catalogFilters(libraryId:includeTechnical:auth:)takes the caller's captured owner. It requires a profile, checks that the owner is still current before dispatch, and runs underwithOwnerFence, the same pattern ascalendarandsimilarCards. The fence count iniosApp/iosApprises by one. There are no app callers yet; W5-L wiresCatalogFacets.Fixtures: on top of F0's pin, this PR vendors
get_catalog_search_capabilities_ok,get_metadata_ai_capability_okandget_catalog_filters_okfrom server commit84ed9e596. It adds their bodies, theirindex.jsonentries and their names toSELECTEDinscripts/sync-apiv2-fixtures.sh, and regeneratesSOURCE(36 vendored files). The server publishes no control-capabilities fixture, soplayback_control_capabilities.jsonis written by hand from the openapi schema and added toAUTHORED, next toplayback_stop_draining.Validation
All runs used a local xcodebuild runner (simulator builds with ad-hoc signing):
build ios,build tvos,build macos: PASS.test ios SiloTests/APIv2ContractTests SiloTests/CatalogV2Tests SiloTests/APIv2SubtitleTests SiloTests/PlaybackProtocolV3Tests: PASS, 135 tests, 0 failures.test ios SiloTests/AIModelDecodingTests: PASS, 24 tests.test tvoson the same five classes (SiloTVTests): PASS, 159 tests, 0 failures.New or changed tests:
APIv2ContractTests.testCatalogSearchCapabilitiesFixture: the server fixture, a minimal unconfigured body, a denied principal, and a missingallowed, which must fail to decode.APIv2ContractTests.testMetadataAICapabilityFixture: the server fixture, an unknownon_viewvalue, andallowed: false.APIv2ContractTests.testPlaybackControlCapabilitiesFixtureandtestPlaybackControlRequestMintsOnlyWhenTheServerServesTheHandshake: an allowed capability mints a ticket; a denied capability never sends the ticket POST.APIv2SubtitleTests.testStoredListDropsRowsThatDoNotFitPlayerHandles.CatalogV2Tests.testCatalogFiltersAreBoundToTheCallersOwner: the server fixture, the path, the query andX-Profile-Id; a replaced owner is refused before dispatch; an owner change while the read is in flight is discarded.APIv2ContractTestsgoes from 31 to 34. The owner-fence table inCatalogV2Testsnow callsrequestGetdirectly.scripts/ci/check-no-api-v1.sh: ok. This PR adds no v1 path.Risks and follow-ups
PlaybackSequencedError.invalidResponse, as before. W2-D decides how the remote UI presents that case.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 5 of 50 in the Apple API v2 stack. Base:
apiv2-stack/04-delete-dead-v1-reads. Merge in order from the bottom of the stack. The plan and full index are in PR 01.🤖 Generated with Claude Code