Skip to content

feat(access): limit a profile by advisory age - #1429

Merged
Quick104 merged 5 commits into
mainfrom
feat/advisory-age-limit
Sep 25, 2026
Merged

Quick104 merged 5 commits into
mainfrom
feat/advisory-age-limit

Conversation

@Quick104

@Quick104 Quick104 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A household manager can restrict a profile by content rating only. Rating tiers are coarse: PG-13 covers titles a 10-year-old can watch and titles that are close to an R. The advisory age from #1417 (Common Sense Media's "13+", or MDBList's own estimate) separates those titles. It is also how many parents already decide what a child may watch. Today Silo shows that age as a badge and ignores it for access.

Solution

A profile can carry max_advisory_age, from 1 to 21, or null for no limit. Silo hides a title whose advisory age is above the limit.

  • Tighten-only. The limit is ANDed with the content-rating ceiling, so a title must pass both. A title with no advisory age is never hidden by the limit; the ceiling alone decides it. access.unrated_content does not apply to the advisory limit.
  • Both sources count. Ages attributed to Common Sense and ages MDBList estimated itself are treated the same.
  • Same reach as the ceiling. The limit goes through the one SQL point the ceiling already uses (renamed ApplyMaturityLimits), so it applies to browse, search, detail, episodes, sections, progress, recommendations and jellycompat.
  • Episodes. episode_catalog_entries gains advisory_age, filled from the series by the refresh function and kept current by the series trigger. Episodes follow their series' advisory age.
  • Movies and series only. The plugin provider drops an advisory age reported for any other item type, and the migration clears any such age already stored, so the limit can never hide a title in the beta book libraries. Those libraries keep their current behavior, including the Audiobookshelf author list's precomputed counts.
  • Who can change it. Only a household manager (a server admin, or the primary profile). A restricted profile cannot change its own limit. Changing it bumps access_policy_revision, like the ceiling.
  • Policy. The scope policy carries the limit. A custom override can lower it but never raise it. An unusable override value fails closed to 1.

One value for every maturity limit

The ceiling, the unrated-content flag and the new limit now travel as one access.MaturityLimits value. It is embedded in access.Scope and in each catalog filter (AccessFilter, BrowseFilters, CalendarFilter, BrowseFavoritesFilters).

About 25 call sites rebuild a narrowed filter. They now copy the whole value (AccessFilter{MaturityLimits: f.MaturityLimits}) instead of listing fields. This touches many files, but a missed site became a compile error instead of a silently dropped limit, and a future limit cannot be dropped the same way. catalog_resolver.go already records a past fix for exactly this bug, where a read kept the ceiling and dropped the unrated flag. FilterAccessibleContentIDs takes the value instead of a positional string and bool.

Contract

  • v1 is frozen. The field rides the shared Go structs with json:"-", and a test checks that v1 bodies neither accept nor return it.
  • v2 profiles. Profile.max_advisory_age is an integer or null. createProfile takes it as optional, and updateProfile takes a Patch member where null clears it.
  • Feature detection. listProfiles returns max_advisory_age_supported. The profile operations reject unknown members, so clients must check the flag before sending the field.
  • Admin coverage. getAdminDashboardStats returns advisory_titles: the number of movies and series with an advisory age. The web dashboard can show it as an optional "Advisory ages" tile.
  • Settings contract. Only the notes on catalog.show_advisory_age changed: the badge setting still only controls display. The revision moved from 10 to 11, per settings-contract.md.
  • Web. The profile editor gains a "Maximum advisory age" select next to the content rating. It shows the control and sends the field only when max_advisory_age_supported is true, so a frontend talking to an older server keeps saving profiles. The display-only wording is gone from the web and docs.

Deploy effects

  • The cursor digest and the access.Scope JSON only change for a profile that has a limit. In-flight cursors, socket tickets and progress snapshots survive the upgrade.
  • Cache keys include the limit, so a list cached for one limit is never served to another.
  • No indexes are added. Coverage is sparse and the limit admits a title with no advisory age, so advisory_age IS NULL OR advisory_age <= $n matches nearly every row. The migration comment says so.

Validation

  • Catalog DB test. A new test runs the limit through FilterAccessibleContentIDs, EnsureAccessible and EnsureAccessibleIDs, browse and genres, BrowseEpisodes, mixed search, and the episode_catalog_entries read model. It also checks that a series advisory change reaches its episodes, and that the limit ANDs with the ceiling. A relation missing the column only fails once a limit is set, which is why the test runs every read with one.
  • Unit tests cover:
    • the SQL predicate and bind order;
    • a reflection guard that every MaturityLimits field changes the cache key;
    • the cursor digest;
    • Rego scope rules, including overrides;
    • legacy and policy resolver parity;
    • v1 and v2 profile handlers: authorization, bounds, set, clear and untouched;
    • both user stores;
    • the SQLite v27 migration;
    • the policy revision bump.
  • Migrations apply, roll back and re-apply cleanly.
  • Gates. The full pre-PR gate from CONTRIBUTING.md and make test-db-pins pass.
  • By hand, against a local server on a scratch database, with a PG-13 ceiling and an advisory limit of 10:
    • The profile saw only the unadvised PG title and the Common Sense 10 title.
    • The Common Sense 13 title returned 404.
    • The R title was hidden by the ceiling even though its advisory age of 9 passes.
    • Clearing the limit brought the 13 title back.
    • The web editor saved the limit and the profile summary showed it.

Risks

  • The hidden set changes over time. Coverage grows as MDBList enriches the library at up to 1000 titles a day. A title a limited profile could see yesterday can disappear once it gains an advisory age above the limit, including from Continue Watching. The docs say so, and advisory_titles shows how much of the library the limit acts on.
  • Media-request discovery cannot apply the limit. Titles outside the library carry no advisory age. Let a household manager block a profile from requests and discovery #1430 covers blocking a profile from requests entirely.
  • Peer matching in collaborative recommendations still compares ceilings only. The recommended items themselves are filtered.

Follow-up

  • silo-apple and silo-android: an editor control gated on max_advisory_age_supported, and make apiv2-fixtures-sync for the new profile fixtures.

Related issue: N/A
Validation tasks: reaches #1180 C2, #1181 C1 and C4, #1250 C4, #1246 C2. Profiles without a limit behave as before; this adds a 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. Claude Code subagents on the same model were used for code search and planning. No other AI tooling was used. The maintainer chose to enforce the advisory age, to count both advisory sources, and to keep the limit tighten-only with no hiding of titles that have no advisory age.

🤖 Generated with Claude Code

Household managers could restrict a profile by content rating only. The
advisory age from #1417 (Common Sense Media's "13+", or MDBList's own
estimate) was a badge, although it separates titles that one rating tier
lumps together, which is how many parents already decide.

A profile now carries max_advisory_age (1..21, null for none). A title is
hidden when its advisory age is above the limit, ANDed with the
content-rating ceiling. A title with no advisory age is never hidden by it:
coverage comes from a rate-limited provider, so a missing age means "not
fetched yet", and the ceiling alone decides it. The limit can only tighten
what a profile sees, never widen it.

Enforcement goes through the one SQL point the ceiling already uses,
renamed ApplyMaturityLimits. The ceiling, the unrated-content flag and the
new limit now travel as one access.MaturityLimits value, embedded in
access.Scope and every catalog filter. The ~25 sites that rebuild a narrowed
filter copy it whole, so a later limit cannot be dropped the way the unrated
flag once was. episode_catalog_entries gains advisory_age, maintained by the
series trigger, so episode listings apply the limit too.

Profile storage (Postgres and SQLite), the scope policy (Rego, with an
override that can only lower the limit), both resolvers, cache keys and the
cursor digest carry it. Changing it bumps access_policy_revision like the
ceiling does. /api/v1 is frozen, so the field rides the shared structs with
json:"-"; /api/v2 profiles expose it with max_advisory_age_supported as the
feature flag, and the admin dashboard stats report advisory_titles so an
admin can see the coverage the limit acts on. The web profile editor gains
the control and the docs drop the display-only wording.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@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.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 137 files, which is 37 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Check out review usage here.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5a7e8bce-0e27-4da8-8234-1b9131fe8e8d

📥 Commits

Reviewing files that changed from the base of the PR and between c972b54 and 711d48a.

📒 Files selected for processing (137)
  • contracts/api/v2/fixtures/admin_policy_vendor.json
  • contracts/api/v2/fixtures/create_profile_created.json
  • contracts/api/v2/fixtures/get_system_info_ok.json
  • contracts/api/v2/fixtures/list_profiles_ok.json
  • contracts/api/v2/fixtures/update_profile_ok.json
  • contracts/api/v2/fixtures/upload_profile_avatar_ok.json
  • contracts/api/v2/openapi.json
  • contracts/settings/v1/manifest.json
  • docs/architecture/api-contract.md
  • docs/catalog-api.md
  • docs/settings-api.md
  • internal/access/rating.go
  • internal/access/resolver.go
  • internal/access/types.go
  • internal/access/types_test.go
  • internal/api/handlers/access_filter.go
  • internal/api/handlers/admin_sections_service_test.go
  • internal/api/handlers/admin_stats.go
  • internal/api/handlers/calendar.go
  • internal/api/handlers/catalog_items_service.go
  • internal/api/handlers/collections_mutation_guards_test.go
  • internal/api/handlers/items.go
  • internal/api/handlers/metadata_ai.go
  • internal/api/handlers/profiles.go
  • internal/api/handlers/profiles_advisory_age_test.go
  • internal/api/handlers/progress.go
  • internal/api/handlers/progress_access_test.go
  • internal/api/handlers/progress_bulk_test.go
  • internal/api/handlers/recommendations.go
  • internal/api/handlers/sections.go
  • internal/api/handlers/settings_values_http.go
  • internal/api/handlers/settings_values_test.go
  • internal/api/handlers/theme_songs_test.go
  • internal/api/handlers/watch_together_member_state_v2_test.go
  • internal/apiv2/admin_dashboard_stats.go
  • internal/apiv2/catalog_types.go
  • internal/apiv2/cursor.go
  • internal/apiv2/cursor_scope_digest_test.go
  • internal/apiv2/profiles.go
  • internal/apiv2/profiles_test.go
  • internal/apiv2/progress_test.go
  • internal/audiobooks/access_resolver.go
  • internal/audiobooks/media_store.go
  • internal/catalog/access_cache_key.go
  • internal/catalog/access_cache_key_test.go
  • internal/catalog/access_filter.go
  • internal/catalog/advisory_age_limit_db_test.go
  • internal/catalog/audiobook_groups_cursor_db_test.go
  • internal/catalog/browse.go
  • internal/catalog/browse_compat_predicates_test.go
  • internal/catalog/calendar_repo.go
  • internal/catalog/catalog_collection_cursor_db_test.go
  • internal/catalog/catalog_personal_cursor_db_test.go
  • internal/catalog/catalog_resolver.go
  • internal/catalog/catalog_section_cursor_db_test.go
  • internal/catalog/content_rating_ceiling_db_test.go
  • internal/catalog/detail.go
  • internal/catalog/detail_batch_equivalence_test.go
  • internal/catalog/detail_versions_test.go
  • internal/catalog/discovery_repo_test.go
  • internal/catalog/episode_page_hydration_db_test.go
  • internal/catalog/favorites_browse.go
  • internal/catalog/history_source_test.go
  • internal/catalog/item_repo.go
  • internal/catalog/item_repo_access_db_test.go
  • internal/catalog/item_repo_test.go
  • internal/catalog/jellycompat_predicates_db_test.go
  • internal/catalog/library_repo.go
  • internal/catalog/library_repo_access_test.go
  • internal/catalog/person_repo.go
  • internal/catalog/person_search_db_test.go
  • internal/catalog/query_executor_access_test.go
  • internal/catalog/query_work_groups_db_test.go
  • internal/catalog/recent_tv.go
  • internal/catalog/search_cursor.go
  • internal/catalog/search_postgres_mixed.go
  • internal/catalog/search_session_db_test.go
  • internal/catalogseed/service.go
  • internal/catalogseed/types.go
  • internal/jellycompat/access_filter.go
  • internal/jellycompat/access_filter_test.go
  • internal/jellycompat/audiobook_exclusion_test.go
  • internal/jellycompat/catalog_contract_test.go
  • internal/jellycompat/content_direct.go
  • internal/jellycompat/content_direct_test.go
  • internal/jellycompat/handlers_items.go
  • internal/literaryworks/repository.go
  • internal/metadata/advisory_age_test.go
  • internal/metadata/plugin_provider.go
  • internal/models/advisory_test.go
  • internal/models/media.go
  • internal/policy/input.go
  • internal/policy/scope_parity_test.go
  • internal/policy/simulate.go
  • internal/policy/vendor/scope.rego
  • internal/policy/vendor/scope_test.rego
  • internal/policy/viewer_resolver.go
  • internal/policy/viewer_resolver_test.go
  • internal/progresssync/service.go
  • internal/recommendations/engine.go
  • internal/recommendations/repo.go
  • internal/recommendations/signals_test.go
  • internal/sections/editorial_candidate_cache_test.go
  • internal/sections/recently_added_query_test.go
  • internal/sections/resolvedlistcache_test.go
  • internal/sections/seasonal_query_test.go
  • internal/userdb/migrate.go
  • internal/userdb/migrate_v27_test.go
  • internal/userdb/profiles.go
  • internal/userdb/schema.go
  • internal/userstore/pgstore/profile_advisory_age_test.go
  • internal/userstore/pgstore/profiles.go
  • internal/userstore/storetest/suite.go
  • internal/userstore/types.go
  • internal/watchtogether/selection_resolver.go
  • migrations/sql/20260924233144_add_profile_max_advisory_age.sql
  • migrations/sql/20260924233146_episode_catalog_advisory_age.sql
  • web/src/api/types.ts
  • web/src/api/v2/schema.ts
  • web/src/components/admin/dashboard/registry.tsx
  • web/src/components/admin/dashboard/types.ts
  • web/src/components/admin/dashboard/widgets/statTiles.tsx
  • web/src/components/profiles/ProfileEditorDialog.test.tsx
  • web/src/components/profiles/ProfileEditorDialog.tsx
  • web/src/hooks/queries/profiles.test.ts
  • web/src/hooks/queries/profiles.ts
  • web/src/hooks/useShowAdvisoryAge.ts
  • web/src/lib/profile-management.test.ts
  • web/src/lib/profile-management.ts
  • web/src/pages/HouseholdSetup.tsx
  • web/src/pages/ItemDetail/components/MetadataBadges.test.tsx
  • web/src/pages/ItemDetail/components/MetadataBadges.tsx
  • web/src/pages/Profiles.tsx
  • web/src/pages/admin-policy/PolicySimulatePanel.tsx
  • web/src/pages/admin-policy/policyExamples.ts
  • web/src/pages/settings/PlaybackSettings.tsx
  • web/src/pages/settings/ProfilesSettings.tsx

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 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-25T01:34:22.660130Z 711d48a 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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61faddd4b7

ℹ️ 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".

Comment thread internal/catalog/access_filter.go Resolved
Comment thread web/src/lib/profile-management.ts Resolved
… servers

Review follow-ups on the advisory-age limit.

Only movies and series carry an advisory age now: the plugin provider
drops one reported for any other item type, so the profile limit can
never hide an audiobook or ebook in the beta book libraries. The
Audiobookshelf author list keeps its precomputed-count path when only an
advisory limit is set, since that limit cannot hide a book.

The web profile editor honors max_advisory_age_supported: it shows the
control and sends max_advisory_age only when listProfiles reports the
server supports it. An older server rejects unknown members, so a
frontend pointed at one would otherwise fail every profile save.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95f05c58d0

ℹ️ 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".

Comment thread internal/metadata/plugin_provider.go Resolved
Comment thread web/src/lib/profile-management.ts Resolved
Review follow-ups on the advisory-age limit.

The migration clears advisory ages on rows that are not movies or
series. The host now drops such ages on intake, but a refresh never
clears a stored one, so an age a book picked up earlier would have kept
it under the limit. The provider that supplies advisory ages only
answers for movies and series, so this normally matches nothing.

The web editor offers every limit the server accepts, 1 through 21, so
a profile set to any valid limit by another client opens on a matching
option.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19fd631da2

ℹ️ 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".

Quick104 and others added 2 commits September 25, 2026 01:27
A catalog-bundle import could still write an advisory age onto an
audiobook or ebook row after the migration cleared them, which would
bring the book back under a profile's advisory-age limit.

models.AdvisoryColumns, the one function every advisory write goes
through (item upserts and every catalog-bundle import path), now takes
the item type and stores NULL for anything but a movie or series. The
plugin provider uses the same models.AdvisoryAgeApplies rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@Quick104
Quick104 merged commit 7cc2c1f into main Sep 25, 2026
12 checks passed
@Quick104
Quick104 deleted the feat/advisory-age-limit branch September 25, 2026 01:47
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