From b968ea44300884ef48fcfa296db0efa7ae731311 Mon Sep 17 00:00:00 2001 From: DEV-bot Date: Fri, 13 Mar 2026 10:08:32 +0000 Subject: [PATCH] test(i18n): guard issue-277 artifact determinism --- docs/ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md | 1 + scripts/check_i18n_parity_artifact.py | 36 +++++++++++++++++++ scripts/report_i18n_parity.py | 1 + 3 files changed, 38 insertions(+) create mode 100644 scripts/check_i18n_parity_artifact.py diff --git a/docs/ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md b/docs/ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md index e0e3afb..bfe3887 100644 --- a/docs/ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md +++ b/docs/ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md @@ -76,4 +76,5 @@ Status: **Shared locale matrix is aligned (`en`, `da`) and backend→frontend er ```bash python3 scripts/check_i18n_drift.py python3 scripts/report_i18n_parity.py +python3 scripts/check_i18n_parity_artifact.py ``` diff --git a/scripts/check_i18n_parity_artifact.py b/scripts/check_i18n_parity_artifact.py new file mode 100644 index 0000000..d8eb091 --- /dev/null +++ b/scripts/check_i18n_parity_artifact.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +"""Guard issue #277 parity artifact against non-deterministic regeneration.""" + +from __future__ import annotations + +import hashlib +import subprocess +import sys +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[1] +ARTIFACT_PATH = REPO_ROOT / "docs" / "ISSUE-277-SHARED-I18N-PARITY-ARTIFACT.md" +REPORT_SCRIPT = REPO_ROOT / "scripts" / "report_i18n_parity.py" + + +def sha256(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def main() -> int: + before = sha256(ARTIFACT_PATH) + + for run in range(1, 3): + subprocess.run([sys.executable, str(REPORT_SCRIPT)], cwd=REPO_ROOT, check=True) + after = sha256(ARTIFACT_PATH) + if after != before: + raise SystemExit( + f"issue #277 parity artifact is not deterministic after run {run}: {before} != {after}" + ) + + print(f"issue #277 parity artifact deterministic: {before}") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/report_i18n_parity.py b/scripts/report_i18n_parity.py index 78de04b..7cdc812 100644 --- a/scripts/report_i18n_parity.py +++ b/scripts/report_i18n_parity.py @@ -179,6 +179,7 @@ def render_report(catalog: dict) -> str: lines.append("```bash") lines.append("python3 scripts/check_i18n_drift.py") lines.append("python3 scripts/report_i18n_parity.py") + lines.append("python3 scripts/check_i18n_parity_artifact.py") lines.append("```") lines.append("") return "\n".join(lines)