Files
FabledCurator/tests/test_translation_gate.py
T
bvandeusen 6ab7fd5c7f
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 21s
CI / backend-lint-and-test (push) Successful in 31s
CI / integration (push) Successful in 3m42s
tune(translation): set latin acceptance floor to 0.80 (#1376)
Calibrated against fresh probes once Interpreter returned real langdetect
confidence: genuine German detected at 1.0, a correctly-detected but ambiguous
latin string at 0.86. Set _MIN_LATIN_CONFIDENCE to 0.80 (below that band) so
legitimate ambiguous non-English still translates while genuinely-unsure guesses
are rejected. Real langdetect also fixed the original mis-flag at the source, so
this floor is a safety net, not the primary fix. Pin 0.86-accepted in the gate
test to guard against bumping the floor back up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CgZP9v2otxVJymiYsnVuMy
2026-07-09 16:40:02 -04:00

35 lines
1.5 KiB
Python

"""Translation acceptance gate (#1376) — pure unit tests for ``_accept``, which
decides whether curator stores Interpreter's translation or keeps the original.
Curator does no detection of its own; it only thresholds Interpreter's reported
detected language + confidence (Scribe rule 133). No DB, no network."""
from backend.app.tasks.translation import _MIN_LATIN_CONFIDENCE, _accept
def test_accept_trusts_cjk_regardless_of_confidence():
# ja/ko/zh are script-detected — accepted even at a low reported number
# (pure-kanji Japanese can come back labelled zh ~0.75, still translated).
assert _accept("ja", None) is True
assert _accept("ja", 0.10) is True
assert _accept("ko", 0.99) is True
assert _accept("zh", 0.75) is True
assert _accept("zh-CN", 0.20) is True # region suffix is still CJK
def test_accept_requires_floor_for_latin():
assert _accept("de", 0.98) is True
assert _accept("de", 0.86) is True # calibrated: ambiguous-but-correct German stays
assert _accept("de", _MIN_LATIN_CONFIDENCE) is True # exactly at floor
assert _accept("de", _MIN_LATIN_CONFIDENCE - 0.01) is False
assert _accept("fr", 0.40) is False # short mis-flag
def test_accept_is_case_insensitive():
assert _accept("JA", None) is True
assert _accept("DE", 0.40) is False
def test_accept_missing_confidence_fails_open():
# No confidence reported → don't silently drop a translation.
assert _accept("de", None) is True
assert _accept("", None) is True