Download scripts/production_check.py from Codexcoder/sovereign-integration: direct link, hf CLI and curl.
- Browser
- Download file 4.36 kB
-
https://huggingface.co/datasets/Codexcoder/sovereign-integration/resolve/main/scripts/production_check.py
- Command line
-
hf download hf://datasets/Codexcoder/sovereign-integration/scripts/production_check.py
-
curl -L -o production_check.py https://huggingface.co/datasets/Codexcoder/sovereign-integration/resolve/main/scripts/production_check.py
4.36 kB
| #!/usr/bin/env python3 | |
| """ | |
| Production readiness check β the "production" gate of the agent | |
| build/deploy workflow. Verifies: package imports, API route surfaces, | |
| registry cross-references, test suite health, docker/deploy assets. | |
| Usage: | |
| python3 scripts/production_check.py | |
| Exits 0 (PASS) or 1 (FAIL) with a structured report. | |
| """ | |
| from __future__ import annotations | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT)) | |
| sys.path.insert(0, str(ROOT / "src")) # src-layout for the sovereign package | |
| CHECKS: list[tuple[str, callable]] = [] | |
| def check(name: str, fn) -> None: | |
| CHECKS.append((name, fn)) | |
| def run(cmd: list[str], timeout: int = 300) -> subprocess.CompletedProcess: | |
| return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout, | |
| cwd=ROOT) | |
| # ββ Imports βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _imports() -> bool: | |
| import importlib | |
| import os | |
| # The orchestrator requires a JWT secret at import; production supplies | |
| # it via env β the check only verifies importability. | |
| os.environ.setdefault("JWT_SECRET", "production-check-dummy") | |
| for mod in ["sovereign.main", "kyrexis.core", "kyrexis.api.routes", | |
| "pec5d.core", "pec5d.api.routes", "coldcase.api.routes", | |
| "chat.core", "chat.api.routes"]: | |
| importlib.import_module(mod) | |
| return True | |
| check("imports (all modules)", _imports) | |
| # ββ Route surfaces ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _routes() -> bool: | |
| from kyrexis.api.routes import router as k | |
| from pec5d.api.routes import router as p | |
| from coldcase.api.routes import router as c | |
| from chat.api.routes import router as t | |
| counts = {"kyrexis": len(k.routes), "pec5d": len(p.routes), | |
| "coldcase": len(c.routes), "chat": len(t.routes)} | |
| return counts["kyrexis"] == 19 and counts["pec5d"] == 22 and counts["chat"] == 5 | |
| check("API routes (kyrexis 19 Β· pec5d 22 Β· chat 5)", _routes) | |
| # ββ Registry validator ββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _registries() -> bool: | |
| proc = run([sys.executable, "scripts/verify_registries.py"]) | |
| return "ALL REGISTRY CROSS-REFERENCES VALID" in proc.stdout | |
| check("registry cross-references", _registries) | |
| # ββ Test suite health βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _tests() -> bool: | |
| proc = run([str(ROOT / ".venv/bin/pytest"), "tests/", "-q", | |
| "--ignore=tests/test_72h_closed_loop.py"]) | |
| return proc.returncode == 0 and "passed" in proc.stdout | |
| check("fast test suite (140+)", _tests) | |
| # ββ Deploy assets βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| def _assets() -> bool: | |
| required = [ | |
| "docker/Dockerfile.kyrexis", "docker-compose.kyrexis.yml", | |
| "site/manifest.webmanifest", "site/sw.js", "site/chat.html", | |
| "site/store.html", "scripts/build_agents.py", "proofs/theory_proofs.py", | |
| ] | |
| return all((ROOT / p).exists() for p in required) | |
| check("deploy assets present", _assets) | |
| def main() -> int: | |
| print("π Production Readiness Check") | |
| print("=" * 56) | |
| results = [] | |
| for name, fn in CHECKS: | |
| try: | |
| ok = bool(fn()) | |
| except Exception as exc: # noqa: BLE001 | |
| ok = False | |
| print(f" β {name} β raised {exc}") | |
| else: | |
| print(f" {'β ' if ok else 'β'} {name}") | |
| results.append(ok) | |
| passed = sum(results) | |
| status = "PASS" if passed == len(results) else "FAIL" | |
| print("=" * 56) | |
| print(f" PRODUCTION: {status} ({passed}/{len(results)})") | |
| return 0 if status == "PASS" else 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |