Skip to content

feat(collections): limit shared personal collections to what their owner can access - #1873

Merged
Quick104 merged 10 commits into
feat/collections-revampfrom
feat/personal-collections-owner-access
Oct 4, 2026
Merged

Quick104 merged 10 commits into
feat/collections-revampfrom
feat/personal-collections-owner-access

Conversation

@Quick104

@Quick104 Quick104 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1615
Validation tasks: changes #193 S2, S3, S4; partly unblocks #193 S7, #195 W7

When a profile shares a personal collection with another profile on the same login, the viewer sees every member it can access itself, whatever the owner's limits are. A PG profile's smart collection, shared with an unrestricted profile, lists titles rated above PG. A manual collection keeps showing titles from a library its owner has since lost. #1615 says a shared collection carries its owner's restrictions: each viewer sees only the titles both the owner and the viewer can access. This change applies that rule everywhere a personal collection's members or count are read. Who can see a collection still comes from today's per-profile sharing lists. Showing shared collections to every profile on the login, owner-only ordering and removing personal collection groups are later #1615 changes.

It also closes a gap in the /api/v1 bridge. GET /api/v1/collections/{id}/items returned every stored member ID of a visible collection, including titles neither the owner nor the viewer can access. It now returns only the members the reader can access, with the owner's limit applied to another profile's collection.

The recorded #193 S2 and S3 results should still hold. Their shared collection had an unrestricted owner and a PG viewer, and the owner's limit leaves that case unchanged. A restricted owner, the case this changes, was not covered. S7 also needs the rest of #1615.

#193 S2, S3 and S4 were recorded with an unrestricted owner. Counts and members of another profile's shared collection now also depend on the owner's access, so a stricter owner shows fewer titles than those runs did. All three need a re-test after merge.

Approach

  • On each read of another profile's collection, the server resolves the owner's access with the same resolver the request gates use, without the owner's PIN. It combines that with the viewer's access. Allowed libraries intersect, the stricter rating ceiling and the smaller advisory-age limit apply, and if either side requires an advisory age, unadvised titles are hidden. Everything else stays the viewer's, including the viewer's hidden libraries, the unrated-title policy and presentation settings.

  • Per the maintainer's decision on Personal collections: owner-only management and a single share-with-all-profiles switch #1615, libraries the owner hides from its own browsing don't count as a limit. access.ResolveInput gains ContentAccessOnly, which both the policy resolver and the legacy resolver honor.

  • Also per that decision, smart rules on watch state, favorites and watchlist, and display filters, still use the viewer's own data. A shared collection never reveals the owner's activity.

  • The limit applies to:

    • item_count in the collection list and detail
    • /api/v2 item pages
    • the catalog user_collection source, which serves the collection page, its filters and its facets
    • home and recommendation rows
    • the library Collections tab
    • the v1 item list

    Manual members the owner can't access are hidden, not deleted, and they come back when the owner's access does.

  • A profile reading its own collection needs no extra lookup. A listing resolves each other owner once per request. Nothing is cached between requests, so a change to an owner's access applies on every node at the next read.

  • It fails closed. If an owner can't be resolved, listings and the library tab leave that collection out and log a warning. Detail, item pages and the catalog source answer 500, and the collection's home row comes back empty. The server never falls back to the viewer's access alone.

  • The order editor now reads collections directly from the store instead of from the counted listing. That way a failed owner lookup can't drop a collection from the order and cause a 422 on the client's submitted order.

Library limits intersect as lists, not title by title. Take a title linked into two libraries, where the owner may open only one and the viewer only the other. The shared collection hides that title, even though each profile can open it on its own. This errs toward hiding. A per-title check would need a second library condition on every catalog read path. A DB test records this behavior.

Validation

  • Go build, gofmt, go vet ./... and make lint-changed against the base branch: clean.

  • make test-go: pass.

  • DB-backed tests on a freshly migrated PostgreSQL database, for the changed packages and their dependents (access, policy, usercollections, sections, catalog, api, handlers, apiv2, userstore, jellycompat, recommendations): pass, except three that fail the same way on the base branch. TestAdminSubtitleListPageDB and TestCatalogTransferPersistsJobsAndSignedLink fail on timezone comparisons, and TestOrphanCleanupAfterPlexTableDropPostgres fails on a fixture that leaves users.role empty.

  • The new DB tests use the production policy resolver and real profiles. They run manual, smart and display-filtered collections through every surface listed above, with these owner and viewer setups:

    • a PG owner with an unrestricted viewer, and the reverse
    • an owner that loses a library, then gets it back
    • both limits at once
    • a library the owner hides from its own browsing
    • disjoint library limits
    • an owner reading its own collections
    • an owner that can't be resolved

    They fail if the owner's limit is removed from the item path or the filters path, or if ContentAccessOnly is ignored. They also pass under -race.

  • make test-db-pins: every pin passes. That includes a new one checking that a listing resolves each other owner once and that a profile's own collections need no owner lookup.

  • Contract and generated artifacts: verify-apiv2-openapi, verify-apiv2-contract (no difference from the base), verify-apiv2-fixtures, TestCommittedArtifactMatchesRouter, verify-route-inventory, verify-migration-ledger, verify-scenario-catalogs, verify-offline-routes, verify-settings-bindings, verify-playback-fixtures and verify-local-paths all pass.

  • Not run: the web checks, because no web files change, and verify-apiv2-web-types, because the contract doesn't change. Nobody has walked Collections — Server #193 S2, S3, S4 or S7 on a running server.

Risks

  • Migration: none. There's no schema change.
  • Compatibility:
    • /api/v2's schema doesn't change, so shipped Apple and Android builds need no update. Viewers of a shared collection can now see fewer members and a smaller item_count.
    • On /api/v1, GET /collections/{id}/items now leaves out members the reader can't access, including for the owner, as /api/v2 item pages already do. This is a bridge security fix under the v1 freeze.
    • No Jellyfin-compatible route exposes personal collections today. When Jellyfin BoxSets (fix(jellycompat): expose opted-in personal collections as BoxSets #862) land, they need to use the same filter. So does fix(web): hide collection actions on seasons and episodes #1755 (seasons in personal collections), which changes the same read paths.
  • Security: owner lookups stay within the reader's login, and a failed lookup hides the collection. As decided, if the owner hides a library from its own browsing, viewers who can access that library still see its titles in the collection.
  • Operational: reading other profiles' collections costs one access resolution per distinct owner per request, at most the number of profiles on the login. The new query-budget pin covers this. If owner resolution fails, for example during a database fault, shared collections drop out of listings and their pages answer 500 until it recovers.
  • Left as is: on the SQLite user store, item_count in the list and detail is still the stored count, with neither the owner's nor the viewer's limit applied. Item pages and catalog reads on that store apply both. This predates the change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents (implementer, independent reviewer)
  • Model(s): claude-opus-5-5[1m]
  • Involvement: Fully AI-generated, human review pending
  • Adversarial review: an independent reviewer agent checked the diff against the Personal collections: owner-only management and a single share-with-all-profiles switch #1615 implementation plan. It traced every read path for personal collections, ran the unit and DB tests, and tested by mutation. It reported three minor issues and two nits:
    • Fixed: the catalog filters and facets path had no test. New assertions now fail if the owner's limit is removed there.
    • Fixed: the v1 item list returned every stored member ID. It's now filtered.
    • Fixed: the order editor could leave out a collection whose owner couldn't be resolved, so a submitted order failed with 422. It now reads from the store.
    • Kept and documented: library limits intersect as lists, which can hide a title that both profiles reach through different libraries. It fails closed and is recorded in code and in a DB test.
    • Left as is: SQLite list counts ignore access limits. This predates the change (see Risks).

🤖 Generated with Claude Code

Note

Limit shared personal collections to what their owner can access

  • Adds a usercollections.OwnerAccess adapter that resolves the collection owner's content access (allowed libraries and maturity limits, skipping PIN and hidden-library preferences) on each call, and wires it into collection, catalog, section, library, and items handlers.
  • All read surfaces for another profile's personal collection — lists, library tab, detail, paged items, cursor catalog reads, and legacy item lists — now intersect the viewer's access with the owner's access, and skip or error on collections whose owner access cannot be resolved.
  • Section fetching now distinguishes an empty library scope (deny-all) from nil (unrestricted) via narrowLibraryScope and applySectionLibraryScopeToQuery, so disjoint scopes return no items instead of widening access.
  • access.ResolveInput gains a ContentAccessOnly flag so owner lookups ignore UI-hidden libraries; access.Resolver.Resolve and policy.ViewerResolver.ResolveFacts honor it.
  • Adds database-backed integration tests covering shared-collection reads, owner-lookup budget (one resolution per distinct owner), and scope-narrowing edge cases.
  • Behavioral Change: shared collections can return fewer items or become unavailable when the owner's access is narrower than the viewer's; owner-access resolution failures now fail closed with errors instead of falling back to viewer-only access. Check ownerScopedCollectionCounts and Fetcher.fetchUserCollection in fetcher.go.

Macroscope summarized a21f7a7.

Quick104 and others added 7 commits October 3, 2026 19:04
…ibraries

A shared personal collection is limited to what its owner can access.
The owner's hidden libraries are a browsing preference, not access, so
they must not shrink what the collection shows other profiles.
ContentAccessOnly leaves them out of both the legacy resolver and the
policy-backed viewer resolver.

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

catalog.IntersectAccess limits a viewer's filter to an owner's
libraries and maturity limits, keeping the viewer's identity, hidden
libraries and presentation. usercollections.OwnerAccess resolves the
owner's content access on every call, with no PIN check and no
cross-request cache. catalog.PersonalCollectionFilter short-circuits a
profile's own collections and fails closed when another owner cannot be
resolved.

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

A profile reading another profile's shared collection now sees only the
titles both can access, on every read path: listing and detail counts,
item pages, the catalog user_collection source and cursor, home rows,
and the library Collections tab. Own collections skip the owner lookup;
a listing resolves each other owner once, pinned by a DB budget test.
If an owner cannot be resolved, listings drop that collection and reads
of it fail rather than falling back to the viewer's access.

Refs #1615.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The catalog filters and facet search for a user_collection source build
their values from the collection's members, so they must follow the same
owner-and-viewer limit as the item reads. No test exercised that path, and
dropping the limit there went unnoticed.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
GET /api/v1/collections/{id}/items returned every stored member ID, so a
profile reading another profile's shared collection saw IDs of titles
outside its own access and outside the owner's. The bridge list now keeps
only the members the reader can access, limited to the owner's access for
another profile's collection, the same rule as every other read. Hidden
members stay stored.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The order editor built its list from the counted collection listing, which
leaves out a shared collection whose owner's access cannot be resolved.
The store still orders that row, so a client submitting the list it was
given got 422. Ordering reads no members, so the editor now lists the
profile's collections straight from the store.

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

IntersectAccess intersects the owner's and viewer's allowed library lists,
so a title in two libraries, one allowed to each profile, is hidden from a
shared collection although both can open it. Document the limit and pin
that it fails closed, so a later per-title check changes the test on
purpose.

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

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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: 6428903a-c8d3-4f4d-83f4-d4daa2154172

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
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 4, 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-10-04T05:17:42.776680Z a21f7a7 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: e47c1f1de2

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

}
}
// Another profile's collection shows only what its owner can access too.
filter, err = catalog.PersonalCollectionFilter(ctx, f.CollectionOwners, filter, userID, profileID, collection.CreatorProfileID)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve owner library limits in home collection rails

When both profiles are library-restricted and the owner has a narrower or different allowlist, the home-section path still exposes manual collection members from libraries the owner cannot access. loadResolvedHomeSections passes the viewer's original non-nil libraryIDs; after this line intersects filter with the owner's access, the sorted branch's collectionRailQueryAccess and the unsorted branch's fetchItemsByContentIDs prefer that original slice and effectively replace the narrowed allowlist. Intersect the section library scope with the owner-scoped filter before either manual branch; the new tests currently pass nil for libraryIDs, so they do not cover this production path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1ed894a and ee3a0cc. Home rows now intersect the section library scope with the owner-narrowed allowlist before both manual branches, and an empty scope stays non-nil so it still denies (that also closes a sorted-rail hole for a profile allowed no library). Review found the smart path could widen too when a query's libraries share none with the allowlist; the executor now adds 1 = 0 in that case, and a disjoint section scope returns an empty row. The DB test now drives the production home path with non-nil viewer libraryIDs, sorted and unsorted manual collections, and smart collections outside the allowed libraries; it fails without the fix.

@macroscopeapp

macroscopeapp Bot commented Oct 4, 2026

Copy link
Copy Markdown

The recorded Server cases S2–S4 need re-validation after merge. This is a major behavior change: collection counts and personal-collection member/catalog reads now apply the owner’s access filter, so a stricter owner can reduce the displayed members and counts. The recorded build 927/1012 scenarios used an unrestricted owner for the shared collection and do not cover that result. The PR explains the intended policy; it should also make clear that these prior results need re-validation after merge.

The owner-access portions of #193 S7 and Web #195 W7 are partly unblocked: their member/count data can now be checked. The full cases remain blocked because this PR does not add the all-profiles sharing switch, owner-only edits/reordering, or the Web “Your collections”/“Shared with me” UI. S6 remains partial: this changes the order-editor read path, not the cross-profile reorder mutation behind #1616.

Suggested Validation tasks line:
Validation tasks: changes #193 S2, S3, S4; partly unblocks #193 S7, #195 W7

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104

Quick104 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Validation line updated to changes #193 S2, S3, S4; partly unblocks #193 S7, #195 W7, and Problem now says S2–S4 were recorded with an unrestricted owner and need a re-test after merge.

Quick104 and others added 3 commits October 4, 2026 00:51
…s libraries

The home page passes the viewer's allowed libraries as the row's library
scope, and the manual collection lookups prefer that scope over the
owner-narrowed access filter. A library-restricted viewer therefore saw
members from libraries the owner cannot access. Limit the scope to the
narrowed filter before the manual lookups.

collectionRailQueryAccess also turned an empty library scope into nil,
which is unrestricted, so a sorted collection row showed every member to a
viewer allowed no library. Keep the empty scope non-nil.

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

When a query's own library_ids shared no library with the reader's allowed
libraries, the empty intersection dropped the library predicate and the
query ran across every library. A shared smart collection scoped to a
library its owner cannot access then showed the viewer titles from every
library on the home row, catalog source, items page and counts. Deny the
query instead whenever a non-nil allowed list leaves no library.

Section rows had the same hole one level up: a section scope disjoint from
the query's libraries cleared def.LibraryIDs, which reads as every library.
Return an empty row instead.

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

# Conflicts:
#	internal/catalog/query_executor.go
#	internal/catalog/query_executor_access_test.go
@Quick104
Quick104 merged commit 9e73822 into feat/collections-revamp Oct 4, 2026
32 of 36 checks passed
@Quick104
Quick104 deleted the feat/personal-collections-owner-access branch October 4, 2026 06:03
bulderi added a commit to bulderi/silo-server that referenced this pull request Oct 5, 2026
…'s access

Build on the collections revamp so personal BoxSets follow Silo-Server#1873: a
collection another profile shares shows each viewer only the titles its
owner can access too. The Jellyfin catalog resolver gets the same owner
access as the native routes, and BoxSet counts use the revamp's
owner-scoped count, now shared from the catalog package. A collection
whose owner cannot be resolved is left out of listings and Ids
re-hydration, and its detail route errors, as on the native routes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zZebrahz zZebrahz mentioned this pull request Nov 15, 2026
17 tasks
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