Skip to content

fix(metadata): let a plain AI translation fill only fields still empty - #4234

Merged
Quick104 merged 2 commits into
Silo-Server:mainfrom
rangoDJ:fix/plain-ai-translation-keeps-newer-2472
Nov 15, 2026
Merged

Quick104 merged 2 commits into
Silo-Server:mainfrom
rangoDJ:fix/plain-ai-translation-keeps-newer-2472

Conversation

@rangoDJ

@rangoDJ rangoDJ commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2472
Related issue: #2214 (removed the force parameter from these writes)
Validation tasks: none

Other clients: Apple, Android, Roku and Jellyfin-compatible clients N/A: they show the stored localized descriptions, and only which text gets stored changes.

A plain (not forced) AI translation job collects only fields whose localized value is empty (translatableField), 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.

This PR has no dependencies and can merge in any order. #2214, which the issue said to follow, is merged.

Approach

  • UpsertAITranslation and the season and episode UpsertAIOverview (internal/catalog/localization_repo.go) take the job's force flag again, and LocalizationStore passes it from persistField (job.Force).
  • A forced job keeps fix(metadata): never let a forced AI re-translation replace provider text #2214's rule: 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.

Validation

  • gofmt, go vet and the changed-lines lint are clean.
  • TestAITranslationNeverOverwritesProviderOrManualText now passes force=true, the rule it describes; its assertions are unchanged.
  • New TestPlainAITranslationFillsOnlyEmptyFields (Postgres 18.6, listed in db-contracts.txt): a plain write keeps an item's, season's and episode's newer AI overview and fills the item's empty tagline.
  • Negative: with the plain rule disabled ($5 OR true), the new test fails on all three writes.
  • go test ./internal/catalog/ ./internal/metadata/translation/ passes.
  • Not run: a plain and a forced job racing against a real model; the full make test-go.

Evidence

No visible layout change. The evidence is what a plain write stores, from the DB tests on WSL2 (Ubuntu, go1.26.4 linux/amd64), main at 43405eb2a, this PR at fe9b93792.

Stored localized value Plain job writes main This PR
newer forced AI overview older translation replaced kept
empty tagline translation filled filled
provider or manual text translation kept kept
$ go test -count=1 -run TestPlainAITranslationFillsOnlyEmptyFields ./internal/catalog/   # plain rule disabled
    localization_ai_upsert_test.go:136: item = &{... Overview:Alter Text. Tagline:Alter Text. ...}, want the forced overview kept and the empty tagline filled
    localization_ai_upsert_test.go:143: season overview = "Alter Text.", want the forced one kept
    localization_ai_upsert_test.go:150: episode overview = "Alter Text.", want the forced one kept
FAIL

$ go test -count=1 -v -run 'TestAITranslationNeverOverwritesProviderOrManualText|TestPlainAITranslationFillsOnlyEmptyFields' ./internal/catalog/
--- PASS: TestAITranslationNeverOverwritesProviderOrManualText (0.03s)
--- PASS: TestPlainAITranslationFillsOnlyEmptyFields (0.03s)
ok  	github.com/Silo-Server/silo-server/internal/catalog	0.121s

Risks

  • The three repository methods and the LocalizationStore interface change signature; every implementation in the tree is updated.
  • A plain job no longer refreshes AI text it finds stale; a forced job still does.

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 (Claude desktop app, Code tab)
  • Tool(s): Claude Code; GitHub CLI
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated, human verified
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Add force flag to AI translation upserts so plain writes fill only empty fields

  • Adds a force parameter to UpsertAITranslation, UpsertAIOverview (season and episode), and the LocalizationStore interface in localization_repo.go and store.go
  • With force false, AI writes fill only empty overview/tagline fields and never replace existing AI-sourced text. With force true, AI-sourced text is replaced. Manual- and provider-sourced text stays protected in both modes.
  • Service.persistField now passes job.Force to each localization write, and a database-backed test covers the plain-write behavior.
  • Risk: any caller of the changed LocalizationStore methods must pass the new force argument; in-tree callers are updated in service.go.

Macroscope summarized b2fca36.

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 Silo-Server#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 Silo-Server#2472

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

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 15 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

  • 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: d7a36590-6e9f-4c17-999c-96dc3ab55a04
Commits

Reviewing files that changed from the base of the PR and between 436f0fb and b2fca36.

Files selected for processing: 6

  • internal/catalog/localization_ai_upsert_test.go
  • internal/catalog/localization_repo.go
  • internal/metadata/translation/service.go
  • internal/metadata/translation/service_test.go
  • internal/metadata/translation/store.go
  • scripts/ci/db-contracts.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Nov 15, 2026
@silo-kody

silo-kody Bot commented Nov 15, 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 ❌

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Nov 15, 2026

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

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

The fix holds up: the new test fails on the base for the reported reason and passes here, and a separate Codex review found no defects in the diff. One cleanup finding below. I'm fixing it in a commit on this branch, so you don't need to change anything.

@silo-kody

silo-kody Bot commented Nov 15, 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

Copy link
Copy Markdown
Contributor

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

Review summary

Reviewed head: b2fca36769b47418e47941dd377ecfb387415edd (code review on fe9b93792, plus one test-only commit from this review).

The fix does what #2472 asks. A plain job now writes only into a field that is still empty, which matches the fields its collection step picks (translatableField), so a plain job can no longer replace a forced re-translation that finished first. Forced jobs keep #2214's rule, and provider and manual text stay protected in every case.

How it was checked

  • TestPlainAITranslationFillsOnlyEmptyFields fails on the base for the reported reason. With the force argument removed so it compiles there, the item, season and episode overviews all end up as the older translation. It passes on this branch, and TestAITranslationNeverOverwritesProviderOrManualText passes too. Both ran against Postgres 18 with every migration applied. go test ./internal/metadata/translation/ passes.
  • Code review covered the diff and its callers, contract and failure paths, and cleanup. A separate Codex review (gpt-6.1-sol) went through every combination of stored source, force flag and nil field, and found no defects. job.Force is stored with the job, a forced request never reuses a plain job, and library prewarm is always plain, so no existing path relied on a plain write replacing AI text.
  • Not checked live: two real jobs racing against a model.

Findings

  • Cleanup: the new test copied the localizationTestPool setup. Fixed in b2fca36 (thread resolved).

Left for maintainers

Validated features

No passed validation case changes. The AI translation cases (#1213 C1 and C2, #1214 C1, and the client display cases) behave the same, because a plain job already picked only empty fields; the only difference is the race this PR closes. Validation tasks: none is correct.

User manual

No change needed. The metadata page already says a plain translation keeps existing descriptions and that Re-translate AI text is what refreshes earlier AI translations. This PR makes the server match that.

Other clients

N/A, as the PR body says: clients only display the stored descriptions, and jellycompat reads the same rows.

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

  • Fit: a small correctness fix to an existing feature at the write that causes the problem. It's the repair the issue proposed, with no new setting or API surface.
  • Readiness: the regression test fails on the base and passes here, two independent reviews found no defects, and the only finding is fixed.

@Quick104
Quick104 merged commit 4330f08 into Silo-Server:main Nov 15, 2026
7 checks passed
@rangoDJ
rangoDJ deleted the fix/plain-ai-translation-keeps-newer-2472 branch November 15, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] A plain AI metadata translation job can overwrite a newer forced translation

2 participants