run_config_gate.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. ]
  20. def main() -> int:
  21. results = []
  22. failed = False
  23. for name, argv in GATES:
  24. proc = subprocess.run([sys.executable, *argv], cwd=ROOT, capture_output=True, text=True)
  25. ok = proc.returncode == 0
  26. failed = failed or not ok
  27. results.append({"gate": name, "status": "pass" if ok else "fail", "returncode": proc.returncode})
  28. print(json.dumps({"status": "fail" if failed else "pass", "gates": results}, ensure_ascii=False, indent=2))
  29. return 1 if failed else 0
  30. if __name__ == "__main__":
  31. sys.exit(main())