Skip to content

fix(metadata): never let a forced AI re-translation replace provider text - #2214

Merged
Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/translation-force-keeps-provider
Oct 14, 2026
Merged

Quick104 merged 3 commits into
Silo-Server:mainfrom
Rhainland:fix/translation-force-keeps-provider

Conversation

@Rhainland

@Rhainland Rhainland commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: #1212
Validation tasks: changes #1213 C2; changes #1214 C1

The metadata editor's re-translate switch let an AI job overwrite localized descriptions a metadata provider had supplied. AC4 of #1212 says machine translations must not overwrite human- or provider-supplied translations.

Approach

AI writes now land only where a field is empty or holds earlier AI text. The translation service and the localization repository both enforce this, so no caller can bypass it. force now means "also refresh earlier AI text"; provider and manual text is always kept. The editor switch is renamed "Re-translate AI text", and its description says existing descriptions are kept. docs/admin-catalog-api.md and the v2 field docs say the same.

Validation

  • Translation service tests and a database test for the repository rule (provider, manual and AI rows for items, seasons and episodes): pass. CI runs the database test in the DB contracts job.
  • Runtime: a forced re-translate of an item with a provider German overview and tagline keeps both and makes no provider call. On main both were replaced and one provider call was made.
  • Runtime with a real model (Codex CLI behind a local OpenAI-compatible adapter): the same forced request made no model call; a forced re-translate of earlier AI text still refreshed it.
  • Runtime checks ran on a local build that combines all eight [v1] AI metadata translation #1212 server branches, against Postgres and Redis containers, synthetic media with NFO IDs, two profiles (German and French) on one account plus a second English account, and a local stub of the AI endpoint so no provider was billed.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-2214/

Risks

Admins who used the switch to replace provider text can't do that any more, which is the point of AC4.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see, or says there is none.

AI Disclosure

Note

Fix forced AI metadata re-translation to preserve provider and manual text

  • Forced translation jobs now re-translate only text previously written by AI; provider and manual values are kept. Empty non-manual fields are still filled.
  • Removes the force parameter from the localization upsert chain: translation.LocalizationStore, the catalog repositories in localization_repo.go, and callers in service.go. SQL conflict updates now replace a value only when its current source is AI or empty.
  • Field eligibility (translation.translatableField) uses shared provenance constants: manual fields are always skipped, even when empty.
  • Updates API docs (OpenAPI, TypeScript schema), admin docs, and the UI panel label in MetadataTranslatePanel.tsx to state the new rule.
  • Adds database-backed test TestAITranslationNeverOverwritesProviderOrManualText and reworked service tests; registered in db-contracts.txt.
  • Behavioral Change: force no longer overwrites any non-AI text; check UpsertAITranslation and the UpsertAIOverview methods in localization_repo.go for the new conflict clauses.

Macroscope summarized 3bfb2c5.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 124fad55-a22a-4dcc-adda-8a37b82d36c4
📥 Commits

Reviewing files that changed from the base of the PR and between 99d5623 and 3bfb2c5.

📒 Files selected for processing: 14
  • contracts/api/v2/openapi.json
  • docs/admin-catalog-api.md
  • internal/apiv2/admin_catalog_translation.go
  • internal/apiv2/catalog_actions.go
  • internal/catalog/localization_ai_upsert_test.go
  • internal/catalog/localization_repo.go
  • internal/metadata/translation/job.go
  • internal/metadata/translation/service.go
  • internal/metadata/translation/service_test.go
  • internal/metadata/translation/store.go
  • internal/models/media.go
  • scripts/ci/db-contracts.txt
  • web/src/api/v2/schema.ts
  • web/src/components/MetadataTranslatePanel.tsx
  • Autofix · 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 10, 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-14T20:22:36.252856Z 3bfb2c5 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.

@silo-kody

silo-kody Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104 Quick104 added priority: P2 Limited scope, workaround exists, or polish impact: usability Core flow broken or severely blocked labels Oct 10, 2026 — with Cursor
@macroscopeapp

macroscopeapp Bot commented Oct 10, 2026

Copy link
Copy Markdown

Visible changes lack evidence: the Evidence section only says the link is forthcoming.

  • web/src/components/MetadataTranslatePanel.tsx: the switch label and explanatory copy change. Add before-and-after captures of the same translation panel on desktop and mobile web, and name the surface and build/commit.
  • internal/metadata/translation/service.go and internal/catalog/localization_repo.go: forced translations now refresh AI-written descriptions while preserving provider/manual text, changing localized metadata users see. Add before-and-after captures of the same item showing that result (a recording of the forced translation and resulting item view would also work), with the surface and build/commit.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@macroscopeapp

macroscopeapp Bot commented Oct 10, 2026

Copy link
Copy Markdown

Both referenced validation cases are Not run; neither task records a failed or blocked case, so this PR does not unblock a recorded result. The force path changes the server AC4 behavior and the Web admin prewarm control. The PR body explains the intent, but these cases still need human validation after merge.

Suggested correction: Validation tasks: changes #1213 C2; changes #1214 C1

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

Posted via Macroscope — v1 validation impact

…text

The metadata editor's re-translate switch (force) let an AI job overwrite
localized descriptions a metadata provider had supplied. AC4 of the AI
metadata translation feature says machine translations must not overwrite
human- or provider-supplied translations.

AI writes now land only where a field is empty or holds earlier AI text, in
both the translation service and the localization repository, so no caller
can bypass it. force now means "also refresh earlier AI text"; provider and
manual text is always kept. The editor switch is renamed "Re-translate AI
text" and its description says existing descriptions are kept.
@Rhainland
Rhainland force-pushed the fix/translation-force-keeps-provider branch from 91c8f75 to 7619498 Compare October 10, 2026 10:13
@silo-kody

silo-kody Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Rhainland

Copy link
Copy Markdown
Contributor Author

Evidence is linked in the description now: https://evidence.siloserver.org/r/silo-server/pr-2214/ (an item with a provider German overview after a forced re-translate, and the editor switch, on desktop and mobile web, before and after). The Validation tasks line now says changes.

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

Review of 7619498. The rule itself is right: AI writes now land only on empty or AI-written fields, and the service and the repository agree for every source value the schema allows (provider, ai, manual, enforced by a CHECK constraint). Three inline findings below, plus two items with no diff line:

  • Stale comments (low). internal/models/media.go above LocalizationSourceProvider still says AI may overwrite provider text "when the admin explicitly forces a re-translation", and the collectFields comment in internal/metadata/translation/service.go says force "still respects manual provenance", implying it overrides provider text. Both now describe the behavior this PR removes. I'm fixing both in a commit on this branch, so there's no need to change them yourself.
  • Validation tasks line. #1213 C2 and #1214 C1 haven't been run yet, so this PR can't change a recorded result. It makes their criteria ("without overwriting human/provider values") passable, which the repository's format writes as unblocks #1213 C2; unblocks #1214 C1. I'll update the PR body.

A summary with scores follows once the fixes are pushed.

…otes

List TestAITranslationNeverOverwritesProviderOrManualText in the DB
contracts so CI runs it against a migrated database; it skipped in every
job before. Reuse the models provenance constants in translatableField
and correct two comments that still said a forced job may overwrite
provider text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@silo-kody

silo-kody Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

# Conflicts:
#	docs/admin-catalog-api.md
#	internal/metadata/translation/service_test.go
#	scripts/ci/db-contracts.txt
@Quick104

Quick104 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review summary (reviewed head 3bfb2c5; findings came from 7619498)

Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green)

Fit: #1212 AC4 says machine translations must not overwrite provider or human text. This PR enforces that in the repository, the one place every AI write passes through, and narrows force instead of adding a setting. It adds no new surface. The API change is field documentation only.

Readiness: the rule matches between translatableField and the SQL for every source value the schema allows. The concerns below are fixed, and the new database test now runs in CI. The remaining condition is CI on the new head, where that test runs for the first time.

Addressed

Remaining

Validated features
No passed case is reachable. The calendar, person and branding cases share no code with this diff. #1213 C2 and #1214 C1 haven't been run; this PR changes the behavior their "without overwriting human/provider values" criteria check, so the body says Validation tasks: changes #1213 C2; changes #1214 C1.

User manual
The metadata page under "Running a server" still names the Re-translate existing switch and says it replaces an earlier translation. After this merges, the switch is Re-translate AI text and leaves provider text alone. I recommend a siloserver.org issue for that page.

Apple / Android
No change needed. The Apple app only reads translation status and never sends force. The Android app doesn't call this endpoint. jellycompat doesn't expose translation jobs.

Review method
Claude Code (claude-opus-5-5): three finder agents and a validation agent, plus one gpt-6.1-sol (Codex) cross-provider round on 7619498. Both providers found the refresh relabeling and the CI gap independently.

@macroscopeapp

macroscopeapp Bot commented Oct 14, 2026

Copy link
Copy Markdown

The PR body currently says unblocks #1213 C2; unblocks #1214 C1, but both result rows are Not run, so neither case has a failed or blocked result to unblock. Please change the line to Validation tasks: changes #1213 C2; changes #1214 C1.

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

Posted via Macroscope — v1 validation impact

@Quick104

Copy link
Copy Markdown
Contributor

Agreed. unblocks is for a failed or blocked case, and both are Not run, so I changed the line back to Validation tasks: changes #1213 C2; changes #1214 C1.

@Quick104
Quick104 merged commit ed8adc3 into Silo-Server:main Oct 14, 2026
22 checks passed
@macroscopeapp macroscopeapp Bot mentioned this pull request Oct 30, 2026
4 tasks done
Quick104 added a commit that referenced this pull request Nov 15, 2026
#4234)

* fix(metadata): let a plain AI translation fill only fields still empty

A plain AI translation job collects only fields whose localized value is
empty, but its writes replaced any AI-sourced value. A forced
re-translation that finished while a plain job was still running could
then be overwritten with a translation of the older source text.

The item, season and episode AI writes take the job's force flag again.
A forced job keeps the rule #2214 set: fill an empty field or replace
earlier AI text, never provider or manual text. A plain job fills only a
field that is still empty when it writes.

Closes #2472

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(catalog): reuse localizationTestPool in the plain AI translation test

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Quick104 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact: usability Core flow broken or severely blocked priority: P2 Limited scope, workaround exists, or polish

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants