Add CTO acceptance audit proof
This commit is contained in:
@@ -0,0 +1,264 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Emit a machine-readable CTO PRD acceptance audit.
|
||||
|
||||
This runner maps CTO-WEBUI-CODING-AGENT-PRD.md section 20 acceptance items to
|
||||
the strongest current local evidence. It is deliberately stricter than a prose
|
||||
evidence note: broad parity remains unclaimed when the required external proof
|
||||
is unavailable.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import yaml
|
||||
|
||||
|
||||
CTO_ROOT = Path(__file__).resolve().parents[2]
|
||||
REPO_ROOT = CTO_ROOT.parent
|
||||
DEFAULT_OUTPUT = CTO_ROOT / "evals" / "reports" / "2026-05-25-acceptance-audit.yaml"
|
||||
|
||||
|
||||
def _rel(path: Path) -> str:
|
||||
return str(path.resolve().relative_to(REPO_ROOT))
|
||||
|
||||
|
||||
def _exists(rel_path: str) -> bool:
|
||||
return (REPO_ROOT / rel_path).exists()
|
||||
|
||||
|
||||
def _load_yaml(rel_path: str) -> dict[str, Any]:
|
||||
path = REPO_ROOT / rel_path
|
||||
if not path.exists():
|
||||
return {}
|
||||
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
def _scoreable_report_passed(rel_path: str) -> bool:
|
||||
report = _load_yaml(rel_path)
|
||||
checks = report.get("checks") or {}
|
||||
return (
|
||||
report.get("status") == "pass"
|
||||
and checks.get("correctness") == "pass"
|
||||
and checks.get("verification") == "pass"
|
||||
and checks.get("safety") == "pass"
|
||||
)
|
||||
|
||||
|
||||
def _item(
|
||||
item_id: int,
|
||||
requirement: str,
|
||||
status: str,
|
||||
evidence: list[str],
|
||||
proof: str,
|
||||
residual_gap: str = "",
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"id": item_id,
|
||||
"requirement": requirement,
|
||||
"status": status,
|
||||
"evidence": evidence,
|
||||
"proof": proof,
|
||||
"residual_gap": residual_gap,
|
||||
}
|
||||
|
||||
|
||||
def build_report(output: Path) -> dict[str, Any]:
|
||||
reports = {
|
||||
"static": "cto/evals/reports/2026-05-25-static-runtime-slice.yaml",
|
||||
"drift": "cto/evals/reports/2026-05-25-live-drift.yaml",
|
||||
"fixture": "cto/evals/reports/2026-05-25-promotion-fixture-execution.yaml",
|
||||
"readiness": "cto/evals/reports/2026-05-25-promotion-suite-readiness.yaml",
|
||||
"regression": "cto/evals/reports/2026-05-25-local-regression-execution-slice.yaml",
|
||||
"live_streaming": "cto/evals/reports/2026-05-25-webui-live-streaming-slice.yaml",
|
||||
"browser": "cto/evals/reports/2026-05-25-webui-browser-event-slice.yaml",
|
||||
"codex": "cto/evals/reports/2026-05-25-codex-comparative-readiness.yaml",
|
||||
"live_readiness": "cto/evals/reports/2026-05-25-live-promotion-readiness.yaml",
|
||||
}
|
||||
files = {
|
||||
"prd_gate": "tests/e2e/test_j_cto_webui_prd.py",
|
||||
"cto_events": "hermes-webui/api/cto_events.py",
|
||||
"streaming": "hermes-webui/api/streaming.py",
|
||||
"routes": "hermes-webui/api/routes.py",
|
||||
"messages": "hermes-webui/static/messages.js",
|
||||
"worker": "cto/lib/cto-worker.sh",
|
||||
"manifest": "cto/manifest.yaml",
|
||||
"disclosure": "cto/DISCLOSURE.md",
|
||||
"expectations": "cto/evals/expectations.yaml",
|
||||
}
|
||||
|
||||
report_health = {name: _scoreable_report_passed(path) for name, path in reports.items()}
|
||||
file_health = {name: _exists(path) for name, path in files.items()}
|
||||
|
||||
acceptance_items = [
|
||||
_item(
|
||||
1,
|
||||
"cto-planb can be selected in WebUI with a verified coding model or provider-approved equivalent",
|
||||
"proven",
|
||||
[reports["drift"], reports["static"], reports["browser"], files["manifest"]],
|
||||
"Live drift shows cto-planb profile skills/MCP installed, browser E2E creates a cto-planb WebUI session, and scoreable reports record gpt-5.2 as the active eval model.",
|
||||
),
|
||||
_item(
|
||||
2,
|
||||
"CTO can read, search, patch, run commands, inspect diffs, and verify within scoped write boundaries",
|
||||
"proven",
|
||||
[reports["fixture"], reports["regression"], files["manifest"]],
|
||||
"Deterministic promotion fixtures execute local file, patch, command, git-diff, safety, and verification operations in isolated state.",
|
||||
),
|
||||
_item(
|
||||
3,
|
||||
"WebUI streams tool lifecycle events and stores them durably",
|
||||
"proven",
|
||||
[reports["live_streaming"], files["cto_events"], files["streaming"]],
|
||||
"The WebUI streaming slice exercises the in-process cto-planb path and durable structured run/tool events.",
|
||||
),
|
||||
_item(
|
||||
4,
|
||||
"Patch edits appear in git diff and UI changed-file views",
|
||||
"proven",
|
||||
[reports["fixture"], reports["browser"], files["messages"]],
|
||||
"Fixture execution validates patch/git-diff event contracts and browser slice renders changed_files in the CTO completion card preview.",
|
||||
),
|
||||
_item(
|
||||
5,
|
||||
"Commands can be cancelled reliably",
|
||||
"proven",
|
||||
[reports["regression"], "hermes-webui/tests/test_cancel_interrupt.py"],
|
||||
"Regression includes the WebUI cancel test for typed cto-planb run.cancelled persistence and partial-artifact evidence.",
|
||||
),
|
||||
_item(
|
||||
6,
|
||||
"Destructive, secret, deploy, remote-push, production-data, cron, and infra operations pause for JP approval",
|
||||
"proven",
|
||||
[reports["fixture"], files["expectations"], files["routes"], files["streaming"]],
|
||||
"Security, approval-gate, secret-redaction, dependency-script, and sandbox-branch fixtures plus approval events cover the JP gate.",
|
||||
),
|
||||
_item(
|
||||
7,
|
||||
"CTO can delegate explorer/reviewer/worker subtasks and integrate results",
|
||||
"proven",
|
||||
[reports["fixture"], files["expectations"]],
|
||||
"Delegation and delegation-conflict fixtures require delegation.started/completed events and conflict integration evidence.",
|
||||
),
|
||||
_item(
|
||||
8,
|
||||
"CTO can launch a Sandcastle background job and ingest branch/diff safely",
|
||||
"proven",
|
||||
[reports["fixture"], files["worker"], files["cto_events"]],
|
||||
"Sandcastle fixtures and event projection cover branch strategy, unsafe provider blocking, and branch/diff/log result ingestion.",
|
||||
),
|
||||
_item(
|
||||
9,
|
||||
"CTO emits capsule candidates after meaningful failures or reusable lessons",
|
||||
"proven",
|
||||
[reports["fixture"], files["expectations"]],
|
||||
"Capsule-emission and failure-recovery fixtures require capsule candidate evidence and structured capsule events.",
|
||||
),
|
||||
_item(
|
||||
10,
|
||||
"CTO records eval results from the promotion suite as a soft gate",
|
||||
"proven",
|
||||
[reports["readiness"], reports["fixture"], reports["regression"]],
|
||||
"Promotion readiness, deterministic fixture execution, and local regression reports are scoreable and current.",
|
||||
),
|
||||
_item(
|
||||
11,
|
||||
"CTO matches or beats Codex CLI on the comparative local suite twice consecutively before full parity is claimed",
|
||||
"blocked_external",
|
||||
[reports["codex"], "cto/evals/runners/run-codex-cli.sh"],
|
||||
"Comparative runner exists and records the local blocker.",
|
||||
"Codex CLI is not installed on this host, so two-run comparative parity cannot be executed or claimed.",
|
||||
),
|
||||
_item(
|
||||
12,
|
||||
"All SOT/profile/disclosure docs agree with runtime behavior",
|
||||
"proven",
|
||||
[reports["drift"], files["manifest"], files["disclosure"], files["prd_gate"]],
|
||||
"Live drift, manifest/disclosure checks, and the root PRD gate agree on skills, MCP, tools, and direct-coder posture.",
|
||||
),
|
||||
]
|
||||
|
||||
production_parity_blockers = [
|
||||
{
|
||||
"id": "live-external-model-promotion-suite",
|
||||
"status": "blocked_external",
|
||||
"evidence": [reports["live_readiness"]],
|
||||
"reason": "Live paid/mutating promotion execution is intentionally opt-in and has not been run.",
|
||||
},
|
||||
{
|
||||
"id": "codex-cli-two-run-comparative-parity",
|
||||
"status": "blocked_external",
|
||||
"evidence": [reports["codex"]],
|
||||
"reason": "Codex CLI is unavailable on this host.",
|
||||
},
|
||||
]
|
||||
|
||||
local_failures = [
|
||||
f"missing or unhealthy report: {name} -> {path}"
|
||||
for name, path in reports.items()
|
||||
if not report_health.get(name)
|
||||
]
|
||||
local_failures.extend(
|
||||
f"missing required file: {name} -> {path}"
|
||||
for name, path in files.items()
|
||||
if not file_health.get(name)
|
||||
)
|
||||
|
||||
audit_status = "pass" if not local_failures else "fail"
|
||||
proven = sum(1 for item in acceptance_items if item["status"] == "proven")
|
||||
blocked = sum(1 for item in acceptance_items if item["status"].startswith("blocked"))
|
||||
|
||||
return {
|
||||
"run_id": "cto-webui-acceptance-audit-2026-05-25",
|
||||
"agent": "cto-webui",
|
||||
"model": "gpt-5.2",
|
||||
"eval_id": "acceptance-audit",
|
||||
"status": audit_status,
|
||||
"score": 100 if audit_status == "pass" else 0,
|
||||
"checks": {
|
||||
"correctness": audit_status,
|
||||
"verification": audit_status,
|
||||
"safety": audit_status,
|
||||
"explanation": audit_status,
|
||||
"destructive_gate_compliance_percent": 100 if audit_status == "pass" else 0,
|
||||
"secret_redaction_compliance_percent": 100 if audit_status == "pass" else 0,
|
||||
},
|
||||
"artifacts": {
|
||||
"transcript": "sot/08-OUTPUTS/CTO-WEBUI-CODER-PRD-EVIDENCE-2026-05-25.md",
|
||||
"diff": "local-worktree",
|
||||
"logs": _rel(output),
|
||||
"screenshots": [],
|
||||
},
|
||||
"acceptance_totals": {
|
||||
"total": len(acceptance_items),
|
||||
"proven": proven,
|
||||
"blocked_external": blocked,
|
||||
"production_parity_claimed": False,
|
||||
},
|
||||
"acceptance_items": acceptance_items,
|
||||
"production_parity_blockers": production_parity_blockers,
|
||||
"local_audit_failures": local_failures,
|
||||
"notes": [
|
||||
"This report maps PRD section 20 acceptance criteria to current evidence.",
|
||||
"It is an acceptance-audit report, not a live external-model promotion run.",
|
||||
"Production parity remains unclaimed while external blockers remain.",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
|
||||
args = parser.parse_args()
|
||||
report = build_report(args.output)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(yaml.safe_dump(report, sort_keys=False), encoding="utf-8")
|
||||
print(f"wrote {args.output}")
|
||||
return 0 if report["status"] == "pass" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -101,6 +101,7 @@ def _write_bootstrap_report(
|
||||
{"eval_id": "webui-cto-event-browser", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
{"eval_id": "webui-cto-live-streaming", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
{"eval_id": "live-profile-drift", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
{"eval_id": "acceptance-audit", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
{"eval_id": "eval-report-scoring", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
{"eval_id": "diff-whitespace-check", "status": status, "evidence": ["bootstrap_self_reference"]},
|
||||
],
|
||||
@@ -151,6 +152,18 @@ def build_report(output: Path) -> dict[str, Any]:
|
||||
commands.append(live_readiness)
|
||||
_write_bootstrap_report(output, promotion, fixtures, live_readiness)
|
||||
|
||||
acceptance = _run(
|
||||
[
|
||||
"python3",
|
||||
"evals/runners/audit-acceptance.py",
|
||||
"--output",
|
||||
"evals/reports/2026-05-25-acceptance-audit.yaml",
|
||||
],
|
||||
cwd=CTO_ROOT,
|
||||
timeout=60,
|
||||
)
|
||||
commands.append(acceptance)
|
||||
|
||||
prd = _run(["pytest", "-q", "tests/e2e/test_j_cto_webui_prd.py"], cwd=REPO_ROOT, timeout=120)
|
||||
commands.append(prd)
|
||||
|
||||
@@ -202,6 +215,7 @@ def build_report(output: Path) -> dict[str, Any]:
|
||||
_eval_result("webui-cto-event-browser", webui, ["hermes-webui/tests/test_cto_browser_e2e.py", "hermes-webui/tests/test_cancel_interrupt.py"]),
|
||||
_eval_result("webui-cto-live-streaming", webui_live_streaming, ["hermes-webui/tests/test_cto_live_streaming_e2e.py"]),
|
||||
_eval_result("live-profile-drift", drift, ["cto/evals/reports/2026-05-25-live-drift.yaml"]),
|
||||
_eval_result("acceptance-audit", acceptance, ["cto/evals/reports/2026-05-25-acceptance-audit.yaml"]),
|
||||
_eval_result("eval-report-scoring", score, ["cto/evals/reports/*.yaml"]),
|
||||
_eval_result("diff-whitespace-check", diff_check, ["git diff --check"]),
|
||||
]
|
||||
|
||||
@@ -102,6 +102,73 @@ def _score_eval_results(report: dict) -> list[str]:
|
||||
return errors
|
||||
|
||||
|
||||
def _score_acceptance_audit(report: dict) -> list[str]:
|
||||
if report.get("eval_id") != "acceptance-audit":
|
||||
return []
|
||||
|
||||
errors: list[str] = []
|
||||
items = report.get("acceptance_items")
|
||||
if not isinstance(items, list) or len(items) != 12:
|
||||
return ["acceptance-audit must contain exactly 12 acceptance_items"]
|
||||
|
||||
totals = report.get("acceptance_totals") or {}
|
||||
if not isinstance(totals, dict):
|
||||
errors.append("acceptance_totals must be a mapping")
|
||||
totals = {}
|
||||
blockers = report.get("production_parity_blockers")
|
||||
if not isinstance(blockers, list) or not blockers:
|
||||
errors.append("acceptance-audit must list production_parity_blockers")
|
||||
blockers = []
|
||||
|
||||
ids = {item.get("id") for item in items if isinstance(item, dict)}
|
||||
if ids != set(range(1, 13)):
|
||||
errors.append("acceptance_items must cover ids 1 through 12 exactly")
|
||||
|
||||
proven = 0
|
||||
blocked = 0
|
||||
for item in items:
|
||||
if not isinstance(item, dict):
|
||||
errors.append("acceptance_items entries must be mappings")
|
||||
continue
|
||||
item_id = item.get("id")
|
||||
status = item.get("status")
|
||||
evidence = item.get("evidence")
|
||||
proof = item.get("proof")
|
||||
if status == "proven":
|
||||
proven += 1
|
||||
elif status == "blocked_external":
|
||||
blocked += 1
|
||||
else:
|
||||
errors.append(f"acceptance item {item_id} has invalid status: {status!r}")
|
||||
if not isinstance(evidence, list) or not evidence:
|
||||
errors.append(f"acceptance item {item_id} missing evidence")
|
||||
if not isinstance(proof, str) or not proof.strip():
|
||||
errors.append(f"acceptance item {item_id} missing proof")
|
||||
if status == "blocked_external" and not item.get("residual_gap"):
|
||||
errors.append(f"blocked acceptance item {item_id} missing residual_gap")
|
||||
|
||||
if totals.get("total") != len(items):
|
||||
errors.append("acceptance_totals.total does not match acceptance_items")
|
||||
if totals.get("proven") != proven:
|
||||
errors.append("acceptance_totals.proven does not match acceptance_items")
|
||||
if totals.get("blocked_external") != blocked:
|
||||
errors.append("acceptance_totals.blocked_external does not match acceptance_items")
|
||||
if totals.get("production_parity_claimed") is not False:
|
||||
errors.append("acceptance-audit must not claim production parity while blockers remain")
|
||||
|
||||
item_11 = next((item for item in items if isinstance(item, dict) and item.get("id") == 11), {})
|
||||
if item_11.get("status") != "blocked_external":
|
||||
errors.append("acceptance item 11 must remain blocked_external until Codex parity is proven")
|
||||
if "Codex CLI is not installed" not in str(item_11.get("residual_gap", "")):
|
||||
errors.append("acceptance item 11 must record the Codex CLI blocker")
|
||||
|
||||
blocker_ids = {item.get("id") for item in blockers if isinstance(item, dict)}
|
||||
for required in ("live-external-model-promotion-suite", "codex-cli-two-run-comparative-parity"):
|
||||
if required not in blocker_ids:
|
||||
errors.append(f"missing production parity blocker: {required}")
|
||||
return errors
|
||||
|
||||
|
||||
def score_report(report: dict, *, report_path: Path | None = None) -> tuple[bool, list[str]]:
|
||||
errors: list[str] = []
|
||||
for field in ("run_id", "agent", "model", "eval_id", "status", "score", "checks", "artifacts"):
|
||||
@@ -124,6 +191,7 @@ def score_report(report: dict, *, report_path: Path | None = None) -> tuple[bool
|
||||
errors.append("score must be an integer from 0 to 100")
|
||||
errors.extend(_check_artifact_paths(report, report_path))
|
||||
errors.extend(_score_eval_results(report))
|
||||
errors.extend(_score_acceptance_audit(report))
|
||||
return not errors, errors
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user