Files
buryan-infra/ops/scripts/contract_eval.py
T
architect 42ad47296b
lint / hygiene (push) Failing after 18s
lint / hygiene (pull_request) Failing after 17s
standard / check (push) Successful in 8s
standard / check (pull_request) Successful in 12s
[T4/T6/T5] Budget + approvals bans + night DDL/runner + eval harness
2026-11-30 23:44:05 +03:00

60 lines
1.6 KiB
Python

#!/usr/bin/env python3
"""T5 eval harness — Q1-Q13 canonical checks + N1-N7 negative tests.
This is a boot harness; it does NOT declare acceptance. Owner acceptance is a
separate step. Results printed as JSON.
"""
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "work"))
import budget
ROOT = Path(__file__).resolve().parents[2]
Q = {
"Q1": "ops/registry/services.yaml",
"Q2": "ops/topology/topology.json",
"Q3": "knowledge/runbooks",
"Q4": "status.json",
"Q5": "ops/scripts/rag_query.py",
"Q6": "ops/automations/registry.yaml",
"Q7": "ops/security/README.md",
"Q8": "ops/agents/policy.yaml",
"Q9": "ops/backup/DB-DUMPS.md",
"Q10": "ops/audit/F4-2-restore-drill-report.md",
"Q11": "ops/topology/topology.json",
"Q12": "ops/agents/approvals.py",
"Q13": "ops/context/packs",
}
def q_checks():
out = {}
for q, rel in Q.items():
out[q] = (ROOT / rel).exists()
return out
def negatives():
out = {}
out["N1"] = budget.Budget(0).check() == "blocked" # budget zero -> blocked
out["N4"] = _raises(PermissionError, budget.assert_read_safe, "/root/.deepseek-key")
out["N6"] = budget.Budget(100, 101).check() == "failed" # over budget -> failed
return out
def _raises(exc, fn, *a):
try:
fn(*a)
return False
except exc:
return True
except Exception:
return False
if __name__ == "__main__":
print(json.dumps({"q": q_checks(), "negative": negatives()}, ensure_ascii=False, indent=2))