Repository navigation
feat(access): let a profile hide titles with no advisory age - #1441
Conversation
A profile's advisory-age limit from #1429 fails open: a title with no advisory age passes, and the content-rating ceiling alone decides it. That keeps the limit from emptying a library the provider has not reached yet, but it makes the limit weak for a young child. Until lookups finish, it restricts nothing on its own, and titles no advisory service covers are never limited by it at all. A profile can now set require_advisory_age. With a limit set, a title with no advisory age is hidden too, so the profile sees only titles rated at or under the limit. It is per profile because one household can want this for a young child and not a teenager. Both advisory sources count. It defaults off, so every existing profile keeps today's behavior, and it has no effect without a limit: the resolvers fold it to false, so a stored flag with no limit changes no predicate, cache key or cursor digest. The predicate goes through ApplyMaturityLimits, so it reaches every read the limit already covers. The flag comes straight from the profile in both resolvers, the way AllowUnratedContent comes from the server setting, rather than through the scope policy: it only ever hides more, so no override needs to loosen it. Changing it bumps the access policy revision like the limit. A strict profile's predicate is most selective right after a library enables the provider, when almost no title has an age. A browse sorted by title then falls back to a full scan, so the migration adds partial indexes over rows that have an age. On 150,000 titles with 5 rated, that took the query from 46 ms to 5 ms. With dense coverage the planner uses the sort index instead. /api/v1 stays frozen. v2 profiles gain require_advisory_age and listProfiles reports require_advisory_age_supported, separate from max_advisory_age_supported because a server can support the limit without this. The web profile editor shows the switch once a limit is set and sends the field only to a server that reports support. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Warning Review limit reachedNext included review available in 17 minutes. View limit detailsLimit details: You’ve used all 2 included reviews 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 (42)
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. |
Problem
The advisory-age limit from #1429 fails open. A title with no advisory age passes it, and the content-rating ceiling alone decides that title.
That default is deliberate. Advisory ages come from a rate-limited provider (1,000 lookups a day on MDBList's free tier), so right after a library enables it almost no title has one. A limit that hid every unrated title would empty the library. But it leaves the limit weak for a young child. Until lookups finish, it restricts nothing on its own. And titles no advisory service covers are never limited by it at all. A parent who wants a profile to see only titles an advisory service has vetted can't express that today.
Solution
A profile can set
require_advisory_age. With a limit set, a title with no advisory age is hidden too, so the profile sees only titles rated at or under the limit. The web editor shows it as a switch under Maximum advisory age: "Hide titles without an advisory age".max_advisory_ageit does nothing. Both resolvers fold it to false, so a stored flag with no limit changes no predicate, cache key or cursor digest. The web editor also clears it when the limit is removed, so a later limit doesn't come back strict without warning.ApplyMaturityLimits, so it applies to browse, search, detail, episodes, sections, progress, recommendations and jellycompat.access_policy_revision.AllowUnratedContentcomes from the server setting. It only ever hides more, so no override needs to loosen it. It applies to whatever limit the policy settles on, including one an override lowered.Index
The strict predicate is at its most selective right after a library enables the provider, when almost no title has an age. A browse sorted by title then walks the whole sort index for matches that barely exist and falls back to a full scan. The migration adds partial indexes on
media_itemsandepisode_catalog_entriesover rows that have an age.Measured on 150,000 titles:
type, sort_titleindex)The indexes hold only rows that have an age, so they stay small. The lenient predicate can't use them and doesn't need to.
Contract
json:"-". A test checks that a v1 body can neither set it nor read it back.Profile.require_advisory_ageis a boolean, always present.createProfileandupdateProfiletake it as optional, and null is rejected because it isn't a clearing member.listProfilesreturnsrequire_advisory_age_supported. It's separate frommax_advisory_age_supportedbecause a server can support the limit without this. The profile operations reject unknown members, so clients must check the flag before sending the field.Validation
FilterAccessibleContentIDs,EnsureAccessible, browse,BrowseEpisodes, mixed search, theepisode_catalog_entriesread model, and ANDing with the ceiling. Under a strict limit of 12 only the title rated 10 survives. I also disabled the strict predicate on purpose, and all seven strict subtests failed.HidesUnadvised;make test-db-pins(20/20) and the web suite (5,175/5,175). Three DB-backed tests fail against the shared test database, and they fail the same way onmain:TestOrphanCleanupAfterPlexTableDropPostgres,TestAdminSubtitleListPageDBandTestCatalogTransferPersistsJobsAndSignedLink. This branch touches none of their files.Risks
advisory_titlesfrom the admin dashboard would explain an empty strict profile, but it's admin-only and a household manager usually isn't a server admin. Showing it in the editor needs a new endpoint, left for later.access_policy_revisionfor this flag. It never has for any access field, including the limit from feat(access): limit a profile by advisory age #1429, so this matches existing behavior. The default Postgres store bumps it.Follow-up
require_advisory_age_supported, andmake apiv2-fixtures-syncfor the moved profile fixtures. I'll add this to silo-apple#416 and silo-android#375.storetest.RunSuiteisn't called by any test, so the profile-store assertions in it, including feat(access): limit a profile by advisory age #1429's, have never run. Its Progress section fails on SQLite today. This PR adds direct store tests instead. Wiring the suite in is separate work.Related issue: N/A
Validation tasks: reaches #1180 C2, #1181 C1 and C4, #1250 C4, #1246 C2. Profiles without
require_advisory_agebehave as before; this adds an opt-in restriction and changes no passed case.AI disclosure
Written by Claude Opus 5.5 (model identifier
claude-opus-5-5[1m]) running in Claude Code as the agent harness, driven interactively by the maintainer. No other AI tooling was used. The maintainer chose to make the option per profile and to count every advisory source.🤖 Generated with Claude Code