Skip to content

feat(api): preview and check another account's profile page layout - #5877

Merged
Quick104 merged 5 commits into
feat/admin-profile-api-collectionsfrom
feat/admin-profile-api-sections
Dec 5, 2026
Merged

Quick104 merged 5 commits into
feat/admin-profile-api-collectionsfrom
feat/admin-profile-api-sections

Conversation

@Quick104

@Quick104 Quick104 commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none changed; reaches #1140 C3 (the Owner rule on admin layout writes, see Risks)

Other clients: N/A (no client-visible change: the profile's own section routes behave as before, and the web admin's profile layout editor only reorders and hides rows the profile already has, which keep their references)

An administrator can already read and replace one profile's page layout through /api/v2/admin/users/{id}/profiles/{profile_id}/sections, but cannot preview a row as that profile would see it, cannot read the profile's pre-override baseline, and cannot tell which listed rows the profile actually sees. The replace also saves a row that names a collection the profile cannot see without saying so, so an admin tool cannot tell a working layout from one with dead rows.

This adds the preview and baseline operations, marks each settings row with whether the profile sees it, and makes the admin replace refuse collection references the profile cannot see. Last of five stacked pull requests.

Stack, merged in order; each pull request is based on the one before it:

  1. feat(api): manage another account's profile avatars, allowances and home cards #5873: avatars, title allowances, home cards and the shared target handling
  2. feat(api): read and change another account's settings as an administrator #5874: settings, navigation shortcuts and plugin settings
  3. feat(api): browse the catalog and libraries as another account's profile #5875: catalog and library reads
  4. feat(api): manage another account's profile collections as an administrator #5876: personal and server collections
  5. feat(api): preview and check another account's profile page layout #5877: page layout preview, baseline and reference checks (this pull request)

Approach

  • POST .../sections/preview previews a section definition as the profile would see the row, with its library access, hidden libraries, rating limits, metadata language, watch state and Next Up. It checks the definition the way a save does, as a new row the profile builds with the account's own role: 403 for an admin-only recipe (Editor's picks) on an account that is not an admin, 422 for a retired type (next_up). It saves nothing, including the watchlist promotion the profile's own watchlist row runs (sections.WithoutWatchlistPromotion). The cards come back in the profile's metadata language, never the administrator's, and a Home preview leaves out titles the profile has played when it hides watched titles. A library_id the profile can't open answers 404, as the baseline does, library_ids keeps only the libraries the profile may open, and a collection the profile can't see answers 422 at body.config.<path>, as the replace does.
  • GET .../sections/baseline answers the profile's pre-override baseline with tokens bound to that profile, so they compare with a layout export the profile made itself. It needs the layout baseline signing secret.
  • GET .../sections/settings rows carry visible_to_profile, decided by the rule the profile's own getProfileSectionSettings filters with.
  • PUT .../sections checks each collection reference a row did not already hold: a personal collection must be the profile's own or shared on its login, and a server collection must be held by an enabled library the profile may access and, in a row of collections, be one the collection lists show. A failure is 422 at the reference (invalid_type when the value is not a string), and nothing is saved. References are read the way the row renderer reads them: only the members the row's type renders count, and of two ids only the one the row reads, and a row of collections that overrides an admin section refuses personal collections, which it never shows. A row keeps a reference it already held, so a saved layout whose collection was since deleted can still be resent.
  • PUT and DELETE .../sections now follow the Owner rules, like the other admin profile writes.
  • getAdminAccountCapabilities gains profile_section_preview, profile_section_baseline, profile_section_visibility and profile_section_validation, and profile_sections now also requires viewer access, which the settings read and the replace use.

The profile's own PUT /api/v2/profile/sections does not check collection references. The web app's layout import resends server collection references it has no list to check against, so refusing them there would fail whole imports that save today. One fix in the shared save reaches that route, with no visible effect: an override whose section_id names an admin section on another page is no longer treated as that page's admin row, so it no longer queues that section's trending or seasonal refresh. Such an override never renders.

Validation

  • Go build, go vet, gofmt and make lint-changed: clean.
  • go test for internal/api, internal/api/handlers, internal/apiv2 and internal/sections against a Postgres test database: pass. The Postgres test for a watchlist row that skips promotion joins scripts/ci/db-contracts.txt.
  • Contract checks on this branch (verify-apiv2-openapi, -web-types, -fixtures, -contract, verify-route-inventory, verify-size-ratchet, TestCommittedArtifactMatchesRouter): pass; the contract only adds operations, a response field and capability fields.
  • The full gate from CONTRIBUTING on this branch: Go build, gofmt, go mod tidy -diff, go vet ./..., make lint-changed, make lint-router-recovery and make test-go pass. Web install, lint, format check, build and bundle budget pass. make test-web passed 3775 of 3777 tests; the two that timed out under load (AdminCollections.select.test.tsx, rangeReader.test.ts, neither touched here) pass when run again. Every verify target passes except verify-actionlint and verify-shellcheck, which did not run: actionlint 1.7.12 and ShellCheck 0.11.0 are not installed on the test host, and the stack changes no workflow or shell script.
  • End-to-end API script against a local sandbox built from this branch's code before the review fixes: 227 of 227 checks pass, 20 of them on this pull request's operations; the rest are the shared setup, Owner-rule and audit-log checks.
  • Review fixes (92f2da5, then f606a3b for CodeRabbit's findings and 4bf6f0f for Codex's hide-watched finding): each has a Go test that failed on the head before it and passes now, including a Postgres test of the preview's localization (added to scripts/ci/db-contracts.txt). The handler, apiv2, sections and api package tests, lint-changed and the contract checks pass on the new head. The end-to-end script was not rerun.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/admin-profile-api-sections/

Risks

  • Curated home sections — Server #1140 C3 covers an administrator changing one profile's order. That still works for every account the acting administrator may change; an administrator who is not the Owner now gets 403 when changing the layout of the Owner's account or of another admin account.
  • A client of the admin replace that resends a layout naming collections the profile cannot see, in rows that did not already hold them, now gets 422 instead of a silent save.
  • No migration.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code, running in T3 Code
  • Tool(s): Claude Code, with T3 Code delegated sessions for the implementation and Claude Code subagents for a readability pass
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, not yet human verified
  • Adversarial review: a separate Claude Code session reviewed the whole set of operations before it was split into this stack. Its findings for this part were fixed here: references parsed differently from the renderer, an admin section loaded from any page, grandfathering pooled across the page, a library visibility check that ignored disabled libraries and hidden collections, and a preview that skipped the save's admin-only and retired-row checks. This pull request was then reviewed on its own by Claude Code with three cross-provider reviewers (gpt-6.2-sol, claude-opus-5-5, gemini-4-neon); the fixes it found are in 92f2da5, CodeRabbit's later findings are fixed in f606a3b, and Codex's hide-watched finding in 4bf6f0f.

🤖 Generated with Claude Code

Note

Add admin API to preview and baseline another profile's section layout

  • Lets administrators preview a section as an addressed profile sees it: handlers.SectionHandler.PreviewAccountProfileSection fetches with the profile's user/profile IDs and access filter, applies profile-specific localization, hide-watched filtering, and rejects inaccessible collection or library references (sections_account_profile.go).
  • Adds a profile section baseline endpoint (GetAccountProfileSectionBaseline) that returns pre-override sections filtered by the profile's library access and maturity limits (sections_baseline.go).
  • Section settings rows now include a visible_to_profile flag computed under the profile's browsing filter (admin_account_profile_sections.go).
  • Overrides saving is refactored into a shared saveProfileOverrides path with a new typed SectionCollectionRefError for invalid or inaccessible collection references, returned as validation problems at the reference's config member path (sections_collection_refs.go).
  • Previews run under a new sections.WithoutWatchlistPromotion context so a watchlist fetch no longer calls PromoteWatchlist during read-only previews (fetcher.go).
  • Updates the OpenAPI contract, generated web schema, and admin API docs with the new preview, baseline, visibility, and validation capability flags (openapi.json, admin-users-api.md).
  • Behavioral Change: the profile section settings response schema changes from ProfileSectionSettingCollection to AdminProfileSectionSettingCollection, and the profile_sections capability is now false when viewer access is not configured — API consumers using the old schema will break.

Macroscope summarized 4bf6f0f.

Add admin operations that preview a section definition as one profile of
another account would see the row, and read that profile's pre-override
section baseline with tokens bound to it. Rows of the admin settings read
carry visible_to_profile. A preview saves nothing, including the watchlist
promotion the profile's own watchlist row runs, and applies the save's
checks for admin-only recipes and retired row types.

The admin replace now checks each collection reference a row did not
already hold: it must name a collection the profile can see and the row
would show, or the save is refused with 422 at that reference
(invalid_type when it is not a string). A row keeps a reference it already
held, so a saved layout can be resent. The profile's own save leaves
references unchecked, because the web layout import resends server
collection references it cannot check. Admin layout writes follow the
Owner rules.

The admin settings fixture is validated against the admin row schema.

New capability flags: profile_section_preview, profile_section_baseline,
profile_section_visibility, profile_section_validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/XXXL 3000+ added + deleted lines (all files); change volume, not priority. label Dec 5, 2026
@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

This change adds profile-scoped section preview and baseline routes, collection-reference validation for administrator layout writes, and visibility metadata for section settings. It also updates capability reporting and adds OpenAPI declarations for profile home dismissals and library listings.

Changes: Admin profile sections

Layer / File(s) Summary
Profile-section API contracts and capabilities
contracts/api/v2/fixtures/*, contracts/api/v2/openapi.json, internal/apiv2/admin_account_profile_sections.go, internal/apiv2/admin_account_target.go, internal/apiv2/admin_accounts.go, web/src/api/v2/schema.ts, docs/admin-users-api.md
The API schemas and capability reporting add profile-section preview, baseline, validation, and visibility declarations. Admin settings use a response type with per-row visibility metadata.
Profile-scoped writes and collection validation
internal/api/handlers/sections.go, internal/api/handlers/sections_account_profile.go, internal/api/handlers/sections_collection_refs.go, internal/apiv2/admin_account_profile_sections.go, internal/apiv2/profile_sections.go, internal/api/handlers/sections_collection_refs_test.go, internal/apiv2/admin_account_profile_sections_test.go, docs/admin-users-api.md
Administrator saves receive the target profile’s access scope. Collection references are checked for type and visibility. Existing references can be retained on the same row or matching admin section. The write path also applies role and refused-row checks.
Profile-scoped baseline and preview
internal/api/handlers/admin_sections_service.go, internal/api/handlers/sections_account_profile.go, internal/api/handlers/sections_baseline.go, internal/sections/fetcher.go, internal/apiv2/admin_account_profile_sections.go, internal/apiv2/admin_sections_extras.go, internal/apiv2/profile_sections.go, web/src/api/v2/operations.ts, web/src/api/v2/schema.ts, internal/api/handlers/sections_account_profile_*_test.go, internal/sections/watchlist_promotion_db_test.go, scripts/ci/db-contracts.txt, internal/api/testdata/media_routes.txt, docs/admin-users-api.md
Baseline and preview operations resolve the target profile and apply its access scope. Previews validate collection references, skip watchlist promotion, and localize items using the profile’s language preference. Tests cover scope filtering, collection access, route behavior, and localization.

Profile home and library API declarations

Layer / File(s) Summary
Home dismissal and library endpoint declarations
contracts/api/v2/openapi.json
The OpenAPI document declares profile dismissal reads and writes, library listings, and paginated library-collection listings. The dismissal write uses a request body and returns 204.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AdminClient
  participant AdminProfileSectionsHandler
  participant SectionHandler
  participant SectionFetcher
  AdminClient->>AdminProfileSectionsHandler: Submit profile section preview
  AdminProfileSectionsHandler->>SectionHandler: Pass profile scope and preview request
  SectionHandler->>SectionFetcher: Fetch preview without watchlist promotion
  SectionHandler->>SectionHandler: Localize items using profile language
  SectionHandler-->>AdminProfileSectionsHandler: Return preview result
  AdminProfileSectionsHandler-->>AdminClient: Return profile section preview
Loading

Possibly related issues

  • Issue 1137: The changes add per-profile baseline and preview behavior and validate collection references against the profile’s access.
  • Issue 192: The changes reject new administrator collection references that the target profile cannot see.

Suggested reviewers: darthshadow, rhainland

Merge Risk: Low · up to 92f2d

Preview can show titles from libraries the target profile cannot access when an explicit library list is supplied. Administrator saves can also be rejected for an ignored list entry on collection rows. Both are narrow, administrator-facing issues that are worth fixing, but they do not block the rest of the feature.

Security architecture risk: Low · up to 92f2d

The Owner rule strengthens protection for administrator layouts, and previews use the target profile’s access rather than the administrator’s. The remaining risk is narrow: a save overlapping a reset can restore an invalid collection reference that the reset removed, even though a fresh save would reject it.

Retained concerns

  • Trivial · reliability · inferred: The same-row exception is intended to let an editor keep an invalid collection reference already saved on that row. The handler grants the exception from an unlocked snapshot. If a reset commits after that read but before the replacement takes the store lock, the replacement can restore the removed reference and return success. The locked merge enforces row collisions and limits, not whether the reference is still grandfathered. This can undo cleanup for the same profile and page; it is not evidence of access to otherwise forbidden media.

View findings in the submitted review

Security review details

Security Blast Radius

  • observed — The new reads are available to acting administrators across server accounts, including protected accounts. Each request targets one account/profile pair. Preview can return cards shaped by that profile’s watch state and progress; the Owner rule protects writes, not reads.

Trust Boundaries and Controls

  • observed — Admin delegation skips the target profile’s PIN; it does not use the caller’s browsing identity to fetch target cards. The API resolves the requested profile under the addressed account, the handler checks membership, and an explicitly selected preview library must be accessible and enabled. Personal collection validation checks target-profile ownership or sharing within the target login.

Dependencies

  • observed — Scoped operations depend on ViewerAccess. Collection validation uses the target account’s user store for personal collections and the section handler’s collection and folder repositories for server collections. The inspected DB-backed router wires the same server collection repository into the section handler and fetcher.

Data and control flow

  • observed — Preview validates the supplied definition as a new profile-built row using the target account’s role. It then fetches and localizes with the target profile’s identifiers, browsing scope, and metadata language. Collection validation counts libraries the profile merely hides; the preview fetch uses the browsing scope, so passing validation does not imply that the row will show cards.

Resilience and Maintainability Implications

  • observed — A collection validation refusal happens before persistence and does not start post-save refreshes. The store commits the page update in one transaction; refresh work starts after store success and is not part of that transaction. The storage lock protects the merge but does not make the earlier collection decision current at commit.
  • observed — Preview explicitly bypasses watchlist promotion, so repeating it does not promote arrived titles into the target’s watchlist. Ordinary watchlist rendering can still run promotion. Preview may warm the shared cache for cacheable rows; personalized query definitions and personal collection rows are excluded from that cache.

Hardening Proposals

  • proposed — Tie the same-row exception to the page version checked by the locked write. If a save or reset intervenes, reject the stale replacement and require the editor to reload, rather than carrying an exception forward from the earlier layout.

Rollout and rollback

  • observed — After rollout, a non-Owner administrator can still edit an ordinary account or their own account, but must hand off replacement or reset of another administrator’s layout to the server Owner. The API checks the target and, where required, the acting account’s current Owner status before the service mutates the layout. This is server-enforced; clients cannot use the feature flags as a substitute for authorization.
  • observed — To enable admin baseline, the operator must supply the layout-baseline signing secret. Capability discovery checks for it, and the baseline handler independently rejects the request with 503 before resolving the target if it is absent. Preview does not require that secret.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(api): preview and check another account's profile page layout" matches the main change. The PR adds an admin preview endpoint for a profile's page layout, a baseline endpoint, and coll…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is specific and related to the changeset. It states the problem (admins cannot preview a profile's section layout, read its baseline, or see which rows the profile sees; replace accept…
Full details: Title check

Explanation

The title "feat(api): preview and check another account's profile page layout" matches the main change. The PR adds an admin preview endpoint for a profile's page layout, a baseline endpoint, and collection-reference checks on admin saves. The title is specific and concise. It omits the baseline and visibility additions, which is acceptable.

Full details: Description check

Explanation

The description is specific and related to the changeset. It states the problem (admins cannot preview a profile's section layout, read its baseline, or see which rows the profile sees; replace accepts dead collection references). It lists the new preview, baseline, visible_to_profile, and collection-reference validation operations, the Owner-rule change on admin PUT/DELETE, the stack position, validation performed, and risks. Each part matches the raw summary's file-level changes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T20:42:15.593209Z 4bf6f0f New commits
🔒 Security Review ✅ Completed 2026-12-05T20:43:45.971783Z 4bf6f0f 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: 1a714e073f

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

…file-api-sections

Brings in the review fixes from #5876 (40a60b2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Quick104 Quick104 left a comment

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.

🤖 Claude Code (claude-opus-5-5)

Review of 1a714e0. Five findings are on the diff lines below, and one is here because its line isn't in the diff. I'm fixing all of them in commits on this branch, so there's no need to change anything yourself. Codex's localization finding is confirmed in its own thread.

Medium: profile_sections now promises a 503. getAdminUserProfileSectionSettings and replaceAdminUserProfileSectionOverrides now resolve the profile's scope through adminProfileTarget, which answers 503 when ViewerAccess isn't wired. The flag in getAdminAccountCapabilities (internal/apiv2/admin_accounts.go:287) still checks only AdminAccounts and AdminProfileSections, so it can report true for operations that answer 503. Repair: also require ViewerAccess, as the four new flags already do through target.

Comment thread docs/admin-users-api.md Resolved
Comment thread docs/admin-users-api.md Resolved
…view in the profile's language

The admin profile section preview now localizes its cards for the profile,
never the administrator, refuses a library page the profile cannot open, and
reports a collection the profile cannot see as 422 at the reference, as the
replace does. The reference check reads only the id each row renderer reads,
refuses personal collections in an admin row of collections, looks up a
collection row's server id as stored, and keys list entries apart from
collection rows. profile_sections now also needs viewer access, which the
settings read and the replace use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Quick104

Quick104 commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Claude Code (claude-opus-5-5)

Review summary

Reviewed at 1a714e0; fixes are at 92f2da5 f606a3b for CodeRabbit's two findings, and 4bf6f0f (current head) for Codex's hide-watched finding. The branch was rebuilt as a fast-forward on fc41f93, the base merge another session pushed during the review, so no history was rewritten.

Fit: 7/10 · Readiness: 8/10 — conditional (assuming CI is green)

  • Fit 7: the change lets an admin tool preview and check one profile's layout without signing in as that profile, and it builds on the existing admin profile-sections routes. It adds API surface: two operations, one response field and four capability flags. Before 1.0 that is a named stretch.
  • Readiness 8: every defect the review found is fixed, and each fix has a test that failed on 1a714e0. Two things keep it from 9. The end-to-end API run predates the fixes and wasn't repeated. Two client-facing questions below are still open.

Fixed on this branch (92f2da5, f606a3b, 4bf6f0f)

  • The preview now shows titles in the profile's metadata language, never the administrator's. This was Codex's finding.
  • The preview answers 404 for a library page the profile can't open, as the baseline does.
  • The preview answers 422 at body.config.<path> for a collection the profile can't see, matching the replace.
  • The reference check now reads only the id each row renderer reads. It refuses personal collections in an admin row of collections, looks up a collection row's server id as stored, and keys list entries apart from collection rows.
  • The check reads only the members the row's type renders (a collection row's top-level ids, a row of collections' list), and still refuses a non-string id on any row. The preview keeps only the library_ids the profile may open. Both are from CodeRabbit, in f606a3b.
  • A Home preview leaves out titles the profile has played when it hides watched titles, using that profile's preference and watch state. This is from Codex, in 4bf6f0f.
  • profile_sections also requires viewer access, since the settings read and the replace now resolve the profile's scope.
  • The docs and operation descriptions now state the recipe-first invalid answer for a non-string id, and they name the four new flags.

Left for the maintainers to settle

  • Web Home sections card under the Owner rule. A non-Owner admin can still drag, hide and reset rows on the Owner's or another admin's profile. The save now fails with a toast, and no field tells the client which accounts it may change.
  • Capability flags. profile_section_preview, profile_section_visibility and profile_section_validation are always equal. Once /api/v2 locks, the three can't be merged.
  • Smaller, not fixed:
    • Whether a row already held a reference is decided before the store's write lock. A concurrent reset or unshare can let a stale reference stay on that row, and the row then renders empty. CodeRabbit raised the same race.
    • On a library page, the collection-row rule is stricter than the row itself. The row also shows titles of a collection held by another library.
    • Watchlist promotion now has two opt-outs: the new context marker and CatalogRequest.SkipWatchlistPromotion.

Checked and not changed

  • No breaking-approvals.json entry is needed for the new 403 and 422 answers. /api/v2 isn't locked, no release contains the admin layout routes, the PR body lists both answers under Risks, and the semantic diff check passes.
  • Rating limits that hide every title in a collection don't fail the check. The doc says the titles a profile sees don't count.
  • Changing a row's recipe can keep an unused id that the row already held. Only the profile's own save, which checks nothing, can store such an id.
  • The preview runs only when the section fetcher is wired, and production always wires it.

Verification

  • Tests that failed on 1a714e0 and pass on 92f2da5, plus the new library_ids and row-type cases, which failed on 92f2da5, and TestPreviewAccountProfileSectionHidesWatchedOnHome, which failed on f606a3b; all pass on 4bf6f0f: TestPreviewAccountProfileSectionLocalizesForTheProfileDB (new, Postgres, added to db-contracts.txt), TestPreviewAccountProfileSectionFetchesAsTheProfile, TestSectionCollectionRefsReadEachMemberAsTheRowDoes and TestLibraryCollectionRefsFollowWhatTheRowShows. A save-side probe proved the admin-row case on 1a714e0.
  • On 4bf6f0f, the internal/api/handlers, internal/apiv2, internal/sections and internal/api tests pass against Postgres. Three diagnostics and plugin upload tests fail the same way on 1a714e0 on the test host and pass in CI. lint-changed and the contract checks (verify-apiv2-openapi, -web-types, -fixtures, -contract, verify-route-inventory) also pass.
  • Evidence: https://evidence.siloserver.org/r/silo-server/admin-profile-api-sections/

Validated features: the board check ran. No passed case regresses or changes. #1140 C3 and its web counterpart #1141 C3 use the same endpoint. Their recorded steps don't have a non-Owner admin change an admin's or the Owner's profile, so their results stand. Validation tasks: none changed holds.

User manual: "Fix a profile's home screen" (help-a-user) and the "What profiles can change" section of Home Sections tell any admin to fix or reset one profile's Home. Neither says that only the Owner can do that for the Owner's or another admin's profile. They need a siloserver.org issue.

Other clients: Apple, Android and Roku are N/A, because these are admin-only routes with no counterpart in those apps. The web admin's card is covered by the first open question above.

Cross-provider review (round 1, on 1a714e0)

  • Sol (gpt-6.2-sol, medium): 6/10
  • Opus (claude-opus-5-5, medium): 7/10
  • Gemini (gemini-4-neon, medium): 7.5/10

The fixes above include their verified findings. The others are answered in the two sections above. A second round on the fixes did not run.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments

Minor 2
  1. Intersect library_ids with the target profile's access.
  2. Collection rows can be refused for a collections member they never read.
Trivial 1
  1. The same-row exception is intended to let an editor keep an invalid collection reference already saved on that row. The handler grants the exception from an unlocked snapshot. If a reset commits after that read but before the replacement takes the store lock, the replacement can restore the removed reference and return success. The locked merge enforces row collisions and limits, not whether the reference is still grandfathered. This can undo cleanup for the same profile and page; it is not evidence of access to otherwise forbidden media.
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 421de8e9-a875-44cc-b6b3-90999f63491a
Commits

Reviewing files that changed from the base of the PR and between 40a60b2 and 92f2da5.

Files selected for processing: 29

  • contracts/api/v2/fixtures/admin_account_capabilities.json
  • contracts/api/v2/fixtures/admin_account_profile_section_settings.json
  • contracts/api/v2/fixtures/index.json
  • contracts/api/v2/openapi.json
  • docs/admin-users-api.md
  • internal/api/handlers/admin_sections_service.go
  • internal/api/handlers/sections.go
  • internal/api/handlers/sections_account_profile.go
  • internal/api/handlers/sections_account_profile_preview_db_test.go
  • internal/api/handlers/sections_account_profile_reads_test.go
  • internal/api/handlers/sections_account_profile_test.go
  • internal/api/handlers/sections_baseline.go
  • internal/api/handlers/sections_collection_refs.go
  • internal/api/handlers/sections_collection_refs_test.go
  • internal/api/handlers/sections_listed_ids_db_test.go
  • internal/api/testdata/media_routes.txt
  • internal/apiv2/admin_account_profile_sections.go
  • internal/apiv2/admin_account_profile_sections_test.go
  • internal/apiv2/admin_account_target.go
  • internal/apiv2/admin_account_target_test.go
  • internal/apiv2/admin_accounts.go
  • internal/apiv2/admin_accounts_fixtures_test.go
  • internal/apiv2/admin_sections_extras.go
  • internal/apiv2/profile_sections.go
  • internal/sections/fetcher.go
  • internal/sections/watchlist_promotion_db_test.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/operations.ts
  • web/src/api/v2/schema.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

…n the profile's libraries

The reference check now reads a collection row's top-level ids, a row of
collections' list, and neither on other rows, so a save is no longer
refused for a member its row never shows. A member of the wrong type is
still refused on any row. The profile preview keeps only the library_ids
the profile may open, since a collection rail queries those in place of
the viewer's libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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: f606a3b9af

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

…at hides them

A profile that turns on home.hide_watched_items never sees titles it has
played in ordinary Home rows, but the admin preview of its rows listed
them. The preview now reads that profile's preference and watch state,
widens the candidate window and filters played titles the way Home does.
Library pages are unchanged, as on the profile's own pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Quick104
Quick104 merged commit 7f4a9ee into feat/admin-profile-api-collections Dec 5, 2026
7 checks passed
@Quick104
Quick104 deleted the feat/admin-profile-api-sections branch December 5, 2026 20:41
Quick104 added a commit that referenced this pull request Dec 5, 2026
…trator (#5876)

* feat(api): manage another account's profile avatars, allowances and home cards

Add admin operations under /api/v2/admin/users/{id}/profiles/{profile_id}
that act on one profile of another account with that profile's access:
avatar upload and removal, allowed titles and collections, the title
allowance overview for every profile, and home card dismissals with a list
of the current ones. Reads are open to every administrator; writes follow
the Owner rules and are audited. The request identity is never swapped.

New capability flags: profile_avatar_writes, title_allowances,
home_dismissals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(api): read and change another account's settings as an administrator

Add admin operations for one account's settings: effective settings for
the account or one of its profiles, an all-or-nothing batch write of up to
200 values, scope/profile/key filters on the settings list, adding or
removing one navigation shortcut of a profile, and the account's plugin
settings. Plugin secrets are never returned: reads list which secrets are
set, and a write keeps or clears them inside the store transaction.

A setting identity member the key's scope does not use is refused with 422
at that member instead of silently writing the broader value. Saving a
profile's own plugin settings now answers 500, not 422, when the store
fails.

New capability flags: settings_effective, settings_batch,
settings_filters, navigation_shortcuts, plugin_settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(api): browse the catalog and libraries as another account's profile

Add admin operations that search, query and read the catalog as one
profile of another account sees it, with that profile's libraries, limits,
metadata language and watch state, and list the libraries the profile
browses, resolved by the server (include_hidden lists the ones it hides).
Cursors and ETags are bound to the target profile.

Admin reads change nothing: they skip the step where the profile's own item
and watchlist reads move arrived watchlist titles onto its library
watchlist. Catalog pages, the profile's own included, now answer 503
dependency_unavailable instead of 500 when no pagination signing secret is
configured.

New capability flags: profile_catalog, profile_libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(api): manage another account's profile collections as an administrator

Add admin operations for one profile's personal collections: list, create,
read, update, delete, preview, items (single and batch add, remove,
reorder), posters and images, collection order, sort preferences (with a
list of every saved one), MDBList and TMDB imports with
include_in_server_collections, and sync. Also list the server collections
the profile can see, overall and paged per library with include_hidden.
Each operation takes the bodies and returns the shapes of the profile's own
routes, with the profile's access, cursors and ETags bound to it.

The batch add takes up to 500 titles and reports the ones it skipped. Two
new optional user store methods back the batch add and the sort preference
list; the notifications store wrapper forwards both, so production stores
keep them.

New capability flag: profile_collections.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): count a row's smart collections as its profile, and hold the SQLite writer for batch adds

- A row of collections on the profile's own Home or library page names the
  profile on its filter again. Smart rules on the profile's watch state were
  refused without it, so those cards showed a count of 0.
- The SQLite batch add takes the writer before it reads the last position;
  concurrent batch adds failed with "database is locked".
- The sort-preference list answers 500 when a collection read fails, instead
  of leaving that preference out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(api): preview and check another account's profile page layout (#5877)

* feat(api): preview and check another account's profile page layout

Add admin operations that preview a section definition as one profile of
another account would see the row, and read that profile's pre-override
section baseline with tokens bound to it. Rows of the admin settings read
carry visible_to_profile. A preview saves nothing, including the watchlist
promotion the profile's own watchlist row runs, and applies the save's
checks for admin-only recipes and retired row types.

The admin replace now checks each collection reference a row did not
already hold: it must name a collection the profile can see and the row
would show, or the save is refused with 422 at that reference
(invalid_type when it is not a string). A row keeps a reference it already
held, so a saved layout can be resent. The profile's own save leaves
references unchecked, because the web layout import resends server
collection references it cannot check. Admin layout writes follow the
Owner rules.

The admin settings fixture is validated against the admin row schema.

New capability flags: profile_section_preview, profile_section_baseline,
profile_section_visibility, profile_section_validation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): read section collection references as their rows do and preview in the profile's language

The admin profile section preview now localizes its cards for the profile,
never the administrator, refuses a library page the profile cannot open, and
reports a collection the profile cannot see as 422 at the reference, as the
replace does. The reference check reads only the id each row renderer reads,
refuses personal collections in an admin row of collections, looks up a
collection row's server id as stored, and keys list entries apart from
collection rows. profile_sections now also needs viewer access, which the
settings read and the replace use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): check only the collections a row reads, and keep previews in the profile's libraries

The reference check now reads a collection row's top-level ids, a row of
collections' list, and neither on other rows, so a save is no longer
refused for a member its row never shows. A member of the wrong type is
still refused on any row. The profile preview keeps only the library_ids
the profile may open, since a collection rail queries those in place of
the viewer's libraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): leave watched titles out of a Home preview for a profile that hides them

A profile that turns on home.hide_watched_items never sees titles it has
played in ordinary Home rows, but the admin preview of its rows listed
them. The preview now reads that profile's preference and watch state,
widens the candidate window and filters played titles the way Home does.
Library pages are unchanged, as on the profile's own pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix(api): leave out a sort preference whose server collection was deleted

The library collection repository answers a missing collection with
catalog.ErrLibraryCollectionNotFound, not pgx.ErrNoRows, so a stale
preference for a deleted server collection failed the whole preference
list with a 500. Match the repository's sentinel, and make the test fake
answer the way the repository does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(api): check that a refused collection preview never reaches the fetcher

The test saved the fetcher's call count before previewing collections the
profile can't see but never compared it, which lint flags as an unused
assignment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXXL 3000+ added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant