Skip to content

Add P-038 ratchet test: English identifiers/comments in .py/.js - #406

Merged
dholbach merged 2 commits into
mainfrom
chore/german-identifier-ratchet-test
Sep 1, 2026
Merged

Add P-038 ratchet test: English identifiers/comments in .py/.js#406
dholbach merged 2 commits into
mainfrom
chore/german-identifier-ratchet-test

Conversation

@dholbach

@dholbach dholbach commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • New test_code_language_policy.py closes a real gap found during the 2026-09-01 quarterly review: test_i18n_coverage.py (P-039) only scans template text for leaked German UI strings — it never touches .py/.js source, so a German identifier/comment was only ever caught by a manual grep once per review (the rechnung_pl finding from the 2026-08-10 review is the precedent).
  • Flags German diacritics + a curated German-word list in Python identifiers/comments (via ast/tokenize) and declared JS identifiers/comments (regex-based). Deliberately never inspects string literal values — German data content (bilingual email subjects, clinical scaffolding text, tag descriptions) is legitimate and out of scope by construction, mirroring the existing i18n exemptions.
  • TERM_EXEMPTIONS covers untranslatable domain proper nouns (GebüH, EÜR, GOÄ, "Leistung") the same way test_i18n_coverage.py already exempts them. KNOWN_VIOLATIONS is the ratchet allowlist for pre-existing debt not yet cleaned up (currently 2 entries: two test_gebueh.py names using the German word for "total").
  • Fixed 3 real (harmless but real) findings rather than allowlisting them: a bank-statement-parsing comment/test name that literally spelled out the German keyword it recognizes, and two test_contract_form.py test names using the German word for "date" — all renamed to describe the same behavior in English.

Test plan

  • ./dev.py test my_practice.tests.test_code_language_policy my_practice.tests.test_bank_import_utils my_practice.tests.test_contract_form my_practice.tests.test_gebueh my_practice.tests.test_i18n_coverage — 100 passed
  • ./dev.py test --fast — full suite (Django + JS) green
  • ./dev.py lint — ruff format/lint + Tailwind build clean

🤖 Generated with Claude Code

https://claude.ai/code/session_0171DPyqvcb88YiNzRmqMqBA

test_i18n_coverage.py (P-039) only scans template text for leaked
German UI strings — it never looks at .py/.js source, so a German
identifier or comment (the rechnung_pl case from the 2026-08-10
review) was only ever caught by a manual grep during periodic
reviews. New test_code_language_policy.py automates that check:
flags German diacritics and a curated list of German domain words in
Python identifiers/comments (via ast + tokenize) and declared JS
identifiers/comments (via regex), while leaving string literal
*values* untouched — German data content (bilingual email subjects,
clinical scaffolding text, tag descriptions) stays out of scope by
construction, same as the existing i18n exemptions.

Two pre-existing findings, fixed rather than allowlisted: a
bank-statement-parsing comment and matching test name literally named
the German keyword they parse for; test_contract_form.py had two test
names describing German-vs-English PDF assertions using the German
word for "date". Renamed to describe the same behavior in English. A
third finding (two GebüH-billing test names using the German word for
"total") is domain-adjacent but not itself untranslatable terminology,
so it's recorded in KNOWN_VIOLATIONS as pre-existing debt instead.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0171DPyqvcb88YiNzRmqMqBA
@dholbach
dholbach merged commit 4d9d2eb into main Sep 1, 2026
2 checks passed
@dholbach
dholbach deleted the chore/german-identifier-ratchet-test branch September 1, 2026 21:35
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