Skip to content

Fix selective retranslation when glossary aliases change#16

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-5c5e
Draft

Fix selective retranslation when glossary aliases change#16
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-5c5e

Conversation

@cursor

@cursor cursor Bot commented Jun 5, 2026

Copy link
Copy Markdown

Bug and impact

When a chunk already matched a canonical glossary term, adding a new alias for that same term did not trigger selective retranslation. A concrete case is a chunk containing both Tai and Taig: after recording state with only Tai, adding Taig as an alias left the selected term ID list unchanged and the term hash unchanged, so run_state plan incorrectly marked the stale output as unchanged. This can silently leave untranslated or inconsistent alias usage in final book outputs.

Root cause

scripts/glossary.py::term_hash only included source, target, and category, while run_state.plan relies on selected term hashes to detect prompt-affecting glossary changes for already-selected terms. Alias changes affect both matching and the term table injected into translation prompts, but were omitted from the hash.

Fix

Include sorted aliases in the structured term hash payload, so alias additions/removals trigger retranslation without treating alias reorderings as semantic changes.

Validation

  • python3 -m unittest tests.test_glossary.HashTests tests.test_run_state.RunStateTests -v — 16 tests passed
  • python3 -m unittest discover -s tests -p 'test_*.py' -v — 208 tests passed, 3 skipped
  • python3 -m compileall scripts tests — passed
  • Re-ran the original minimal reproducer: adding alias Taig now returns translation_chunk_ids: ["chunk0001"] with reason glossary_term_hash_changed.
Open in Web View Automation 

Co-authored-by: Rainman <deusyu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant