mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-08 19:56:53 +00:00
The gateway answered two sources with "<source>\n---\n<rendering>" and the
whole answer was stored, so twenty languages shipped the English text as
their own translation and the release gate stayed green. Every criterion
passed it: echo compares for equality and the answer is longer, the markup
comparison counts only []{}`*() so a rule of hyphens is invisible to it, and
the rendering the server appended keeps the spans, the names and the length.
echoes() reports the same "echo" criterion when the translation contains its
whole source, under the floor the equality case already uses: a short source
may legitimately survive inside a longer rendering, a sentence may not.
reason() is the single source of truth for both ends, so the client now drops
such an answer on arrival and the gate reports one that got in earlier; make
i18n-prune clears those.
Swept every core catalog: exactly the 21 damaged entries are reported, all as
echo, and nothing else in the corpus. The old predicate returns no reason at
all for the same input.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""Unit tests for the criterion that condemns an answer carrying its source.
|
|
|
|
The shape is one the gateway produced across twenty languages: the English
|
|
source, a markdown rule, then a rendering. Every other criterion passed it,
|
|
because the rendering keeps the spans and the names and the separator is made
|
|
of characters the markup comparison does not count.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
from typing import ClassVar
|
|
|
|
from utils.i18n.damage import reason
|
|
|
|
|
|
class TestEchoAndContinue(unittest.TestCase):
|
|
"""A translation holding its whole source is the server failing, not translating."""
|
|
|
|
SOURCE: ClassVar[str] = (
|
|
"Corporate design injection for NGINX-served apps, unifying light and "
|
|
"dark theming from OKLCH design tokens"
|
|
)
|
|
RENDERING: ClassVar[str] = (
|
|
"Corporate-Design-Injection für NGINX-bediente Anwendungen, vereinheitlicht "
|
|
"helles und dunkles Theming aus OKLCH-Design-Tokens"
|
|
)
|
|
|
|
def test_an_answer_that_prepends_its_source_is_condemned(self) -> None:
|
|
answer = f"{self.SOURCE}\n---\n\n{self.RENDERING}"
|
|
self.assertEqual(reason(self.SOURCE, answer, "de"), "echo")
|
|
|
|
def test_an_answer_that_appends_its_source_is_condemned(self) -> None:
|
|
answer = f"{self.RENDERING}\n\n{self.SOURCE}"
|
|
self.assertEqual(reason(self.SOURCE, answer, "de"), "echo")
|
|
|
|
def test_a_rendering_that_drops_the_source_is_kept(self) -> None:
|
|
self.assertEqual(reason(self.SOURCE, self.RENDERING, "de"), "")
|
|
|
|
def test_a_short_source_may_live_inside_a_longer_rendering(self) -> None:
|
|
source = "Mail"
|
|
self.assertEqual(reason(source, "Mail-Konto des Benutzers", "de"), "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|