Repository navigation
fix(metadata): stop specialist providers hijacking new library chains - #294
Conversation
…ared levels New library provider chains were seeded from every enabled metadata provider, ordered purely by each plugin's declared default_priority and enabled whenever that priority was > 0. Two consequences: - A specialist provider (e.g. silo.sportarr, which declares series/season/ episode) could out-rank the general providers and land at position 1, enabled, on every new TV series library. - Single-purpose providers that declare only their own level (audiobook / ebook / manga metadata) were still attached as disabled rows to series and movie libraries, cluttering the chain editor with providers that cannot serve that content. Introduce a `default_enabled` capability-metadata flag (defaults to true, so every existing plugin is unaffected). A provider sets it false to be seeded installed-but-disabled while keeping its declared priority, so a user can opt in per-library and it slots in where the manifest intends instead of jumping to the top. At the same time, seedDefaultChain and AppendProviderToAllChains now drop providers that do not declare a content level, reusing the same providerSupportsLevel rule as the chain-less fallback (issue Silo-Server#106). LookupSeedPlacement resolves support/priority/enabled with a single metadata fetch. buildSeededChainEntries is extracted as a pure, unit-tested helper. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…editor
The library provider-chain editor showed the same provider differently
depending on where the chain came from: a freshly defaulted chain used the
capability display name ("TMDB"), while a chain loaded from the server used
the capability id ("tmdb", which the API returns as provider_slug). So a
provider read one way before saving and another after, and differed between
library types depending on which levels already had a saved chain.
Standardize on the capability id everywhere (matches the server's
provider_slug and the mono/slug styling). Extract the provider mapping into a
pure, unit-tested metadataProvidersFromInstallations helper.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughBackend seeding now uses ChangesSeed placement metadata and library defaults
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant PluginsHandler as syncMetadataProviders
participant LibrariesHandler as seedDefaultChain
participant Metadata as LookupSeedPlacement
participant ChainRepo as AppendProviderToAllChains
PluginsHandler->>Metadata: LookupSeedPlacement(pluginID, capabilityID, contentLevel)
Metadata-->>PluginsHandler: SeedPlacement
PluginsHandler->>ChainRepo: AppendProviderToAllChains(placement)
ChainRepo->>ChainRepo: skip if !SupportsLevel
ChainRepo->>ChainRepo: enabled = DefaultPriority > 0 && DefaultEnabled
LibrariesHandler->>Metadata: LookupSeedPlacement per content level
Metadata-->>LibrariesHandler: SeedPlacement
LibrariesHandler->>LibrariesHandler: buildSeededChainEntries(candidates)
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9225c5c1c8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| result.push({ | ||
| plugin_installation_id: inst.id, | ||
| capability_id: cap.id, | ||
| slug: cap.id, | ||
| defaultPriority: dp, |
There was a problem hiding this comment.
Preserve placement flags for client-seeded chains
When a new library's type is changed in the admin form, handleTypeChange marks the chain dirty and submit sends this client-built chain instead of relying on the server seed. This new mapper only carries defaultPriority, so buildDefaultLevelChains still enables every provider with a priority and keeps providers that do not support the level; with a Sportarr capability that has default_enabled:false, creating a TV library through the UI submits Sportarr enabled again, bypassing the backend fix.
Useful? React with 👍 / 👎.
| CapabilityType: "metadata_provider.v1", | ||
| ContentLevel: level, | ||
| Priority: i, | ||
| Enabled: c.declaredPriority > 0 && c.defaultEnabled, |
There was a problem hiding this comment.
Keep all-disabled seeded chains from falling back
If an opted-out provider is the only candidate for a content level, this writes an explicit disabled row, but ResolveChain later filters disabled rows and treats the resulting empty list as no configured chain, falling back to all enabled plugin providers by priority. Since that fallback ignores default_enabled, the provider that was seeded installed-but-off still runs for that level instead of remaining disabled.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
internal/api/handlers/libraries.go (1)
2067-2079: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueMetadata is refetched per content level for each capability.
LookupSeedPlacementfetches capability metadata (lookupCapabilityMetadata) on every call, but the underlying metadata is level-invariant — onlyproviderSupportsLevel/extractDefaultPriorityvary bylevel. Iteratinglevels × capsre-fetches the same capability's metadata once per level (e.g. ~4× for movie/series/season/episode). You could fetch metadata once per capability outside thelevelsloop and derive per-level placement in memory.Library creation is infrequent, so this is optional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/api/handlers/libraries.go` around lines 2067 - 2079, The seeded chain assembly in the levels loop is repeatedly calling LookupSeedPlacement for the same capability metadata, even though lookupCapabilityMetadata is level-invariant. Refactor the logic around buildSeededChainEntries so metadata is fetched once per capability outside the levels loop, then compute the per-level supportsLevel/defaultPriority/defaultEnabled values in memory for each level using the already-fetched metadata.internal/metadata/chain.go (1)
182-206: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueMove
placement()after the membership check to avoid a redundant metadata fetch.
placement(g.contentLevel)runsLookupSeedPlacement, which performs a DB fetch, for every(folder, level)group — including groups where the provider already exists and will becontinued out. Evaluating the cheapexistscheck first skips the metadata round-trip for already-seeded chains.Since appends only happen on plugin install this is low-frequency, so treat as optional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/metadata/chain.go` around lines 182 - 206, The chain-building loop in the metadata logic is doing an unnecessary `placement(g.contentLevel)` lookup before confirming whether the provider already exists in the chain. Reorder the checks in the `groups` loop so the `library_provider_chains` membership query runs first, then call `placement()` only for entries that are not already present. Keep the existing `SupportsLevel` guard and use the `placement`, `LookupSeedPlacement`, and membership-check block in `chain.go` as the main points to update.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/api/handlers/libraries.go`:
- Around line 2067-2079: The seeded chain assembly in the levels loop is
repeatedly calling LookupSeedPlacement for the same capability metadata, even
though lookupCapabilityMetadata is level-invariant. Refactor the logic around
buildSeededChainEntries so metadata is fetched once per capability outside the
levels loop, then compute the per-level
supportsLevel/defaultPriority/defaultEnabled values in memory for each level
using the already-fetched metadata.
In `@internal/metadata/chain.go`:
- Around line 182-206: The chain-building loop in the metadata logic is doing an
unnecessary `placement(g.contentLevel)` lookup before confirming whether the
provider already exists in the chain. Reorder the checks in the `groups` loop so
the `library_provider_chains` membership query runs first, then call
`placement()` only for entries that are not already present. Keep the existing
`SupportsLevel` guard and use the `placement`, `LookupSeedPlacement`, and
membership-check block in `chain.go` as the main points to update.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 40a1edd6-5314-48e1-b364-993443a4ef82
📒 Files selected for processing (7)
internal/api/handlers/libraries.gointernal/api/handlers/libraries_seed_chain_test.gointernal/api/handlers/plugins.gointernal/metadata/chain.gointernal/metadata/chain_test.goweb/src/components/admin/libraries/LibraryForm.test.tsxweb/src/components/admin/libraries/useLibraryForm.ts
…hain The form builds its own default chain client-side, and any touch (including changing the library type on create, the normal path for a series library) marks it dirty and POSTs it after create — replacing the server-seeded chain. That chain still enabled every provider with a declared priority and listed unsupported providers as disabled rows, so the server-side fix evaporated on the UI create path. buildDefaultLevelChains now applies the same rules as buildSeededChainEntries: providers that don't declare the level are dropped, a declaring provider is enabled only if it doesn't opt out via default_enabled, and a legacy catch-all (no declared levels) is parked last, disabled. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Pushed |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/components/admin/libraries/useLibraryForm.ts`:
- Around line 51-53: The `useLibraryForm` default-enabled resolution is treating
a nested `default_enabled` as a fallback when the top-level value is `null`, but
the fail-open rule requires top-level precedence unless it is exactly `false`.
Update the `rawEnabled` logic in `useLibraryForm` so a present top-level
`cap.metadata.default_enabled` always wins over the nested
`metadata.default_enabled`, and only consult the nested field when the top-level
value is truly absent. Keep the behavior in `useLibraryForm` consistent with the
literal-false check used for enabling.
- Around line 107-142: The priority ordering in buildDefaultLevelChains uses
LEGACY_CATCH_ALL_PRIORITY as a fixed sentinel, which can sort legacy providers
ahead of declared providers with very high priorities. Update the ranking logic
in buildDefaultLevelChains (and the LEGACY_CATCH_ALL_PRIORITY handling) so
legacy catch-all providers are always ordered after every provider that declares
a positive priority, regardless of how large that priority is, while keeping
declaredPriority and providerSupportsLevel behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 911e44ca-80e0-43e1-91b5-bc31a0bffb34
📒 Files selected for processing (2)
web/src/components/admin/libraries/LibraryForm.test.tsxweb/src/components/admin/libraries/useLibraryForm.ts
Replace the form's client-side reimplementation of the seeding rules with a new additive endpoint, GET /api/v1/libraries/provider-defaults?library_type=X, which returns the exact chain seedDefaultChain would write for that type. The create form now renders those server-computed defaults, changing the library type just refetches them (no longer marking the chain dirty), and a create with an untouched chain lets the server-seeded chain stand instead of writing one back. Editing an existing library uses the same defaults to fill levels its saved chain doesn't cover. Types the server seeds no metadata levels for (e.g. podcasts) return an empty levels map rather than an error. This removes buildDefaultLevelChains / metadataProvidersFromInstallations and the default_priority/default_enabled manifest parsing from the frontend — one source of truth for default ordering and enablement. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Follow-up push |
While the server chain (for an existing library) or the type's defaults are still in flight, the editor rendered empty provider lists for a moment. Show a spinner row instead; local edits always render immediately. Co-Authored-By: Claude Fable 5 <[email protected]>
…#294) * fix(metadata): seed specialist providers off and scope chains to declared levels New library provider chains were seeded from every enabled metadata provider, ordered purely by each plugin's declared default_priority and enabled whenever that priority was > 0. Two consequences: - A specialist provider (e.g. silo.sportarr, which declares series/season/ episode) could out-rank the general providers and land at position 1, enabled, on every new TV series library. - Single-purpose providers that declare only their own level (audiobook / ebook / manga metadata) were still attached as disabled rows to series and movie libraries, cluttering the chain editor with providers that cannot serve that content. Introduce a `default_enabled` capability-metadata flag (defaults to true, so every existing plugin is unaffected). A provider sets it false to be seeded installed-but-disabled while keeping its declared priority, so a user can opt in per-library and it slots in where the manifest intends instead of jumping to the top. At the same time, seedDefaultChain and AppendProviderToAllChains now drop providers that do not declare a content level, reusing the same providerSupportsLevel rule as the chain-less fallback (issue #106). LookupSeedPlacement resolves support/priority/enabled with a single metadata fetch. buildSeededChainEntries is extracted as a pure, unit-tested helper. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(web): standardize metadata provider slug casing in library chain editor The library provider-chain editor showed the same provider differently depending on where the chain came from: a freshly defaulted chain used the capability display name ("TMDB"), while a chain loaded from the server used the capability id ("tmdb", which the API returns as provider_slug). So a provider read one way before saving and another after, and differed between library types depending on which levels already had a saved chain. Standardize on the capability id everywhere (matches the server's provider_slug and the mono/slug styling). Extract the provider mapping into a pure, unit-tested metadataProvidersFromInstallations helper. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(web): mirror server seeding rules in the library form's default chain The form builds its own default chain client-side, and any touch (including changing the library type on create, the normal path for a series library) marks it dirty and POSTs it after create — replacing the server-seeded chain. That chain still enabled every provider with a declared priority and listed unsupported providers as disabled rows, so the server-side fix evaporated on the UI create path. buildDefaultLevelChains now applies the same rules as buildSeededChainEntries: providers that don't declare the level are dropped, a declaring provider is enabled only if it doesn't opt out via default_enabled, and a legacy catch-all (no declared levels) is parked last, disabled. Co-Authored-By: Claude Fable 5 <[email protected]> * refactor(web,api): serve default provider chains from the server Replace the form's client-side reimplementation of the seeding rules with a new additive endpoint, GET /api/v1/libraries/provider-defaults?library_type=X, which returns the exact chain seedDefaultChain would write for that type. The create form now renders those server-computed defaults, changing the library type just refetches them (no longer marking the chain dirty), and a create with an untouched chain lets the server-seeded chain stand instead of writing one back. Editing an existing library uses the same defaults to fill levels its saved chain doesn't cover. Types the server seeds no metadata levels for (e.g. podcasts) return an empty levels map rather than an error. This removes buildDefaultLevelChains / metadataProvidersFromInstallations and the default_priority/default_enabled manifest parsing from the frontend — one source of truth for default ordering and enablement. Co-Authored-By: Claude Fable 5 <[email protected]> * feat(web): show a loading state in the provider chain editor While the server chain (for an existing library) or the type's defaults are still in flight, the editor rendered empty provider lists for a moment. Show a spinner row instead; local edits always render immediately. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Co-authored-by: Quick <[email protected]>
Problem
When creating a new TV series library, the provider chain defaulted to the Sportarr plugin at position 1 (enabled). More broadly, the chain-seeding logic had two flaws:
seedDefaultChainenabled every provider whose declareddefault_priority > 0and ordered purely by that number. Sportarr declaresseries/season/episode = 1, which out-ranks TVDB (2) and TMDB (3), so it landed at position 1 enabled on every new series library.The same happened to existing libraries whenever a plugin was installed, via
AppendProviderToAllChains.Approach
default_enabledcapability-metadata flag. Defaults totrue, so every existing plugin behaves exactly as before. A provider sets itfalseto be seeded installed-but-disabled while keeping its declared priority — so a user can opt in per-library and it slots in where the manifest intends rather than jumping to the top.providerSupportsLevelrule as the chain-less fallback (fix(metadata): exclude providers from content levels they don't declare #106). Audiobook/ebook/manga no longer appear in series/movie chains.LookupSeedPlacementresolves support/priority/enabled in a single metadata fetch;buildSeededChainEntriesis extracted as a pure, unit-tested helper.Paired with a Sportarr manifest change (
default_enabled: false, priority50) inSilo-Server/silo-plugin-sportarr.Frontend
Second commit standardizes the provider slug casing in the library chain editor: defaulted chains showed the display name (
TMDB) while server-loaded chains showed the capability id (tmdb). Now the capability id is used everywhere (matches the API'sprovider_slugand the mono styling).Testing
go test ./internal/metadata/ ./internal/api/handlers/— pass (newTestExtractDefaultEnabled,TestBuildSeededChainEntries_*).pnpm vitest runonLibraryForm.test.tsx— pass (newmetadataProvidersFromInstallationstests).pnpm run lint(0 errors),pnpm run format:check,tsc --noEmitclean.Behavior change affects new library creation and new plugin installs; existing seeded chains are unchanged (operator DB cleanup can follow separately).
AI use
Implemented with Claude Code (Opus 4.8), test-driven. Reviewed by the author.
🤖 Generated with Claude Code
Summary by CodeRabbit
default_enabled:false) are added but kept disabled; legacy providers are parked last and disabled.