#!/usr/bin/env python3 """Summarize cold and reused validation runs using local evidence only.""" import argparse from datetime import datetime import json from wbv2_autopilot import ROOT, Autopilot, contained, now, read_json, sha, write_json def summarize(runner, directory): path = directory + "/verified-receipt.json" if not runner.receipt_valid({"state": "verified", "receipt": path, "receiptSha256": sha(contained(ROOT, path))}): raise ValueError("benchmark receipt or its bound inputs have drifted") receipt = read_json(contained(ROOT, path)) executed = [check for check in receipt["checks"] if not check.get("reusedFrom")] reused = [check for check in receipt["checks"] if check.get("reusedFrom")] start = min(datetime.fromisoformat(check["startedAt"]) for check in executed) finish = datetime.fromisoformat(receipt["verifiedAt"]) return { "receipt": {"path": path, "sha256": sha(contained(ROOT, path))}, "elapsedSeconds": round((finish - start).total_seconds(), 6), "executedCheckSeconds": round(sum(check["durationSeconds"] for check in executed), 6), "avoidedCheckSeconds": round(sum(check["durationSeconds"] for check in reused), 6), "executedCount": len(executed), "reusedCount": len(reused), "steps": [{"id": check["id"], "execution": "reused" if check.get("reusedFrom") else "executed", "originalDurationSeconds": check["durationSeconds"], "log": check["log"], "exitCode": check["exitCode"], "resourceUsage": check.get("resourceUsage")} for check in receipt["checks"]], } def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--cold-run", required=True) parser.add_argument("--warm-run", required=True) args = parser.parse_args() runner = Autopilot() cold, warm = summarize(runner, args.cold_run), summarize(runner, args.warm_run) inventory = read_json(ROOT / "tests/golden/WBV2/dynamic-inventory.json") report = { "schemaVersion": 1, "task": "WBV2-P1424-001", "recordedAt": now(), "taskStatus": "in_progress", "executionMode": "local_only", "modelRequests": 0, "cold": cold, "warm": warm, "elapsedReductionPercent": round((1 - warm["elapsedSeconds"] / cold["elapsedSeconds"]) * 100, 2), "validation": {"supervisorTests": 89, "nativeProfileTests": 14, "businessGroups": 3, "businessCases": 19, "failedGroups": 0}, "coverage": {"unitCount": inventory["summary"]["unitCount"], "verifiedUnits": inventory["coverage"]["verifiedUnits"], "unverifiedUnits": inventory["coverage"]["unverifiedUnits"], "sourceTreeSha256": inventory["authority"]["sourceTreeSha256"], "newBoundUnits": 0}, "profiling": {"path": "tests/golden/WBV2/autopilot/native-profile-20260909/report.json", "sha256": sha(ROOT / "tests/golden/WBV2/autopilot/native-profile-20260909/report.json")}, "limits": ["Elapsed time is first executed stage to verified receipt publication, including evidence hashing; this is not a clean WASM build benchmark.", "Cached checks retain original logs, timestamps and artifact bindings; no fresh runtime execution is claimed.", "GIL/event-loop findings come from focused transport fixtures, not Blender computational profiling.", "The remaining 33 workflow contracts are still pending; queue and inventory are not advanced."], } path = ROOT / "tests/golden/WBV2-P1424-001/python-checkpoint-efficiency-report.json" write_json(path, report) lines = ["# Python Checkpoint Efficiency", "", "Local source, WASM and valid evidence are reused. Model execution remains disabled.", "", "Stage | Cold Execution (s) | Repeat", "--- | ---: | ---"] repeats = {step["id"]: step for step in warm["steps"]} for step in cold["steps"]: repeat = repeats[step["id"]] label = "reused original evidence" if repeat["execution"] == "reused" else f"{repeat['originalDurationSeconds']:.3f} s" lines.append(f"{step['id']} | {step['originalDurationSeconds']:.3f} | {label}") lines += ["", f"Cold validation: {cold['elapsedSeconds']:.3f} s. Repeat: {warm['elapsedSeconds']:.3f} s. Reduction: {report['elapsedReductionPercent']:.2f}%.", "", "Successful steps are checkpointed immediately. Input, environment, log, WASM or artifact drift invalidates reuse. Native dependency analysis always runs incrementally. Case receipts keep their original locations and hashes.", "", "Main mutation/history, polling boundaries and cross-ABI checks run as independent groups with individual timeouts and output directories. A failed dependency blocks only its dependent checks. Independent groups continue; failure cannot publish a verified aggregate.", "", "89 supervisor tests passed. All 19 related Chromium business cases passed. Focused profiling passed 14 transport/process/resource tests.", "", "HTTP fixture profiling: 4.814 s wall, 0.356 s CPU; expected failure waits dominate. Event-loop utilization 1.78%, P99 delay 10.57 ms. Sampled Python fixtures were single-threaded sleeping processes; no evidence justifies changing the GIL or thread pool.", "", "Repeated default startup is idempotent. Request a workflow check without starting a second instance:", "", "```bash", "python3 my-tools/run_web_product_migration.py verify --job SERVER-OPERATOR-HTTP-PROVIDER", "python3 my-tools/run_web_product_migration.py timings --write", "```", "", "Coverage: " + json.dumps(report["coverage"], ensure_ascii=True), "", *report["limits"]] path.with_suffix(".md").write_text("\n".join(lines) + "\n", encoding="utf-8") print(json.dumps({"report": str(path.relative_to(ROOT)), "coldSeconds": cold["elapsedSeconds"], "warmSeconds": warm["elapsedSeconds"], "reusedSteps": warm["reusedCount"], "reductionPercent": report["elapsedReductionPercent"]})) if __name__ == "__main__": main()