#!/usr/bin/env python3 """Regenerate the golden confidence baseline. Runs the confidence regression harness with MNEMA_UPDATE_GOLDEN=1, which makes it execute the full default-deriver pipeline over the sample corpus and (re)write tests/regression/golden/confidence.golden.json. Usage: python scripts/update_goldens.py Then review the diff and commit the golden file. """ from __future__ import annotations import os import sys from pathlib import Path def main() -> int: repo_root = Path(__file__).resolve().parents[1] target = repo_root / "tests" / "regression" / "test_confidence_golden.py" golden = repo_root / "tests" / "regression" / "golden" / "confidence.golden.json" os.environ["MNEMA_UPDATE_GOLDEN"] = "1" import pytest # declared as a dev dependency in pyproject.toml code = pytest.main(["-q", str(target)]) # Under MNEMA_UPDATE_GOLDEN the comparison test writes the file and # skips, so exit code 0 means the regeneration ran cleanly. if code == 0 and golden.exists(): print(f"golden baseline written: {golden.relative_to(repo_root)}") print("review the diff, then commit it:") print(f" git add {golden.relative_to(repo_root)}") return 0 print("golden regeneration failed; see pytest output above", file=sys.stderr) return int(code) or 1 if __name__ == "__main__": raise SystemExit(main())