run_config_gate.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. """V2-M1 config gate: run all config guards, fail if any fails (V2-M1E).
  2. Chains the canonical check, the Excel→JSON byte-equal check, and the three
  3. config validators. Any non-zero child exit fails the gate. Run with openpyxl
  4. available (the Excel checks need it):
  5. uv run --with openpyxl python scripts/run_config_gate.py
  6. """
  7. from __future__ import annotations
  8. import json
  9. import subprocess
  10. import sys
  11. from pathlib import Path
  12. ROOT = Path(__file__).resolve().parents[1]
  13. GATES = [
  14. ("canonical", ["scripts/check_config_json_canonical.py"]),
  15. ("excel_json_byte_equal", ["scripts/build_config_from_excel.py", "--check"]),
  16. ("rule_pack_fk", ["scripts/validate_rule_pack_config.py"]),
  17. ("excel_json_sync", ["scripts/validate_config_excel_sync.py"]),
  18. ("query_prompts", ["scripts/validate_query_prompts_config.py"]),
  19. ("v4_config_contract", ["scripts/validate_v4_config_contract.py"]),
  20. ("v5_m4_dead_config_archive", ["scripts/validate_v5_m4_dead_config_archive.py"]),
  21. ]
  22. def main() -> int:
  23. results = []
  24. failed = False
  25. for name, argv in GATES:
  26. proc = subprocess.run([sys.executable, *argv], cwd=ROOT, capture_output=True, text=True)
  27. ok = proc.returncode == 0
  28. failed = failed or not ok
  29. results.append({"gate": name, "status": "pass" if ok else "fail", "returncode": proc.returncode})
  30. print(json.dumps({"status": "fail" if failed else "pass", "gates": results}, ensure_ascii=False, indent=2))
  31. return 1 if failed else 0
  32. if __name__ == "__main__":
  33. sys.exit(main())