Add CCLite 0.2.9 real worker gate
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from common_csv import add_failure, write_verification_report
|
||||
|
||||
|
||||
REQUIRED_PATH_RESULTS = [
|
||||
"real_sphlite_mock_fem_1step",
|
||||
"mock_sphlite_real_femlite_1step",
|
||||
"single_real_worker_100step",
|
||||
"payload_read_smoke",
|
||||
"load_import_smoke",
|
||||
]
|
||||
|
||||
ACCEPTED_GATE_STATUSES = {
|
||||
"PASS",
|
||||
"CONTROLLED_PROTOCOL_GAP",
|
||||
}
|
||||
|
||||
|
||||
def build_report(args: argparse.Namespace) -> dict:
|
||||
audit_report_path = Path(args.audit_report)
|
||||
failed: list[str] = []
|
||||
metrics: dict[str, int | str] = {}
|
||||
|
||||
if not audit_report_path.exists():
|
||||
failed.append(f"missing audit report: {audit_report_path}")
|
||||
audit = {}
|
||||
else:
|
||||
audit = json.loads(audit_report_path.read_text(encoding="utf-8"))
|
||||
|
||||
gate = audit.get("v020_adapter_gate", {})
|
||||
gate_status = gate.get("status", "")
|
||||
metrics["gate_status"] = gate_status
|
||||
|
||||
if gate.get("gate_id") != args.case_id:
|
||||
add_failure(failed, "v020_adapter_gate", "gate_id", args.case_id, gate.get("gate_id"))
|
||||
if gate_status not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(failed, "v020_adapter_gate", "status", sorted(ACCEPTED_GATE_STATUSES), gate_status)
|
||||
|
||||
validate_adapter_strategy(audit, failed)
|
||||
validate_worker_summary(audit, failed, metrics)
|
||||
validate_path_results(gate, failed, metrics)
|
||||
|
||||
status = "PASS" if not failed else "FAIL"
|
||||
return {
|
||||
"case_id": args.case_id,
|
||||
"status": status,
|
||||
"metrics": metrics,
|
||||
"failed_checks": failed,
|
||||
"input": str(audit_report_path),
|
||||
"output_files": {
|
||||
"audit_report": str(audit_report_path),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def validate_adapter_strategy(audit: dict, failed: list[str]) -> None:
|
||||
strategy = audit.get("adapter_strategy", {})
|
||||
selected = strategy.get("selected_strategy", "")
|
||||
if selected != "HYBRID_GENERIC_BLOCK_PLUS_SOLVER_ADAPTER":
|
||||
add_failure(
|
||||
failed,
|
||||
"adapter_strategy",
|
||||
"selected_strategy",
|
||||
"HYBRID_GENERIC_BLOCK_PLUS_SOLVER_ADAPTER",
|
||||
selected,
|
||||
)
|
||||
required_fields = strategy.get("required_adapter_fields", [])
|
||||
if len(required_fields) < 5:
|
||||
add_failure(failed, "adapter_strategy", "required_adapter_fields", "at least 5", len(required_fields))
|
||||
|
||||
|
||||
def validate_worker_summary(audit: dict, failed: list[str], metrics: dict[str, int | str]) -> None:
|
||||
summary = audit.get("worker_capability_summary", {})
|
||||
for worker_key in ("sphlite", "femlite"):
|
||||
worker = summary.get(worker_key, {})
|
||||
location = f"worker_capability_summary.{worker_key}"
|
||||
for field in ("worker_name", "version", "capability_probe_status", "gap_status"):
|
||||
if not worker.get(field):
|
||||
add_failure(failed, location, field, "non-empty", worker.get(field))
|
||||
ipc = worker.get("ipc", {})
|
||||
if not ipc.get("backend"):
|
||||
add_failure(failed, location, "ipc.backend", "non-empty", ipc.get("backend"))
|
||||
if "supports_real_ipc" not in ipc:
|
||||
add_failure(failed, location, "ipc.supports_real_ipc", "present", "missing")
|
||||
block_capabilities = worker.get("block_capabilities", {})
|
||||
if not block_capabilities:
|
||||
add_failure(failed, location, "block_capabilities", "non-empty", block_capabilities)
|
||||
if worker.get("gap_status") not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(
|
||||
failed,
|
||||
location,
|
||||
"gap_status",
|
||||
sorted(ACCEPTED_GATE_STATUSES),
|
||||
worker.get("gap_status"),
|
||||
)
|
||||
metrics[f"{worker_key}_capability_fields"] = len(block_capabilities)
|
||||
|
||||
|
||||
def validate_path_results(gate: dict, failed: list[str], metrics: dict[str, int | str]) -> None:
|
||||
path_results = gate.get("path_results", {})
|
||||
controlled_gap_count = 0
|
||||
pass_count = 0
|
||||
for path_id in REQUIRED_PATH_RESULTS:
|
||||
path_result = path_results.get(path_id, {})
|
||||
status = path_result.get("status", "")
|
||||
location = f"v020_adapter_gate.path_results.{path_id}"
|
||||
if status not in ACCEPTED_GATE_STATUSES:
|
||||
add_failure(failed, location, "status", sorted(ACCEPTED_GATE_STATUSES), status)
|
||||
if status == "CONTROLLED_PROTOCOL_GAP":
|
||||
controlled_gap_count += 1
|
||||
blockers = path_result.get("blocking_fields", [])
|
||||
if not blockers:
|
||||
add_failure(failed, location, "blocking_fields", "non-empty", blockers)
|
||||
elif status == "PASS":
|
||||
pass_count += 1
|
||||
|
||||
metrics["path_result_count"] = len(path_results)
|
||||
metrics["pass_count"] = pass_count
|
||||
metrics["controlled_protocol_gap_count"] = controlled_gap_count
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--case-id", required=True)
|
||||
parser.add_argument("--audit-report", required=True)
|
||||
parser.add_argument("--report", required=True)
|
||||
args = parser.parse_args()
|
||||
|
||||
report = build_report(args)
|
||||
report_path = Path(args.report)
|
||||
write_verification_report(report_path, report)
|
||||
print(f"{report['case_id']} {report['status']} -> {report_path}")
|
||||
return 0 if report["status"] == "PASS" else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user