|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import json |
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +PRE = Path("bringup_validation/pre_silicon_boot_trace.json") |
| 6 | +POST = Path("bringup_validation/post_silicon_boot_trace.json") |
| 7 | +REPORT_JSON = Path("bringup_validation/bringup_comparison_report.json") |
| 8 | +REPORT_MD = Path("bringup_validation/bringup_comparison_report.md") |
| 9 | + |
| 10 | + |
| 11 | +def load_events(path): |
| 12 | + return json.loads(path.read_text())["boot_events"] |
| 13 | + |
| 14 | + |
| 15 | +def signature(event): |
| 16 | + return { |
| 17 | + "phase": event["phase"], |
| 18 | + "event": event["event"], |
| 19 | + "register": event["register"], |
| 20 | + "value": event["value"], |
| 21 | + "calibration_status": event["calibration_status"], |
| 22 | + "status": event["status"], |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | +def main(): |
| 27 | + expected = load_events(PRE) |
| 28 | + observed = load_events(POST) |
| 29 | + |
| 30 | + first_divergence = None |
| 31 | + for idx, (e, a) in enumerate(zip(expected, observed)): |
| 32 | + if signature(e) != signature(a): |
| 33 | + first_divergence = { |
| 34 | + "index": idx, |
| 35 | + "expected": signature(e), |
| 36 | + "observed": signature(a), |
| 37 | + } |
| 38 | + break |
| 39 | + |
| 40 | + timeout_events = [e for e in observed if e["status"] == "timeout" or "timeout" in e["event"]] |
| 41 | + retry_events = [e for e in observed if e["status"] == "retry" or "retry" in e["event"]] |
| 42 | + calibration_issues = [ |
| 43 | + e for e in observed |
| 44 | + if e["calibration_status"] not in {"not_started", "running", "valid"} |
| 45 | + ] |
| 46 | + blocked_or_degraded = [ |
| 47 | + e for e in observed |
| 48 | + if e["status"] in {"blocked", "degraded"} |
| 49 | + ] |
| 50 | + |
| 51 | + report = { |
| 52 | + "workflow": "pre-post-silicon-style-bringup-trace-validation", |
| 53 | + "safe_claim": "firmware-style trace validation; not silicon ownership or hardware lab bring-up", |
| 54 | + "expected_trace": str(PRE), |
| 55 | + "observed_trace": str(POST), |
| 56 | + "expected_event_count": len(expected), |
| 57 | + "observed_event_count": len(observed), |
| 58 | + "first_divergence": first_divergence, |
| 59 | + "timeout_event_count": len(timeout_events), |
| 60 | + "retry_event_count": len(retry_events), |
| 61 | + "calibration_issue_count": len(calibration_issues), |
| 62 | + "blocked_or_degraded_event_count": len(blocked_or_degraded), |
| 63 | + "diagnostic_status": "FAIL" if first_divergence or timeout_events or calibration_issues or blocked_or_degraded else "PASS", |
| 64 | + "root_cause_summary": ( |
| 65 | + "Observed boot trace diverged during register initialization: expected clock_enable but observed " |
| 66 | + "clock_enable_timeout, followed by retry behavior, calibration drift warning, and blocked ready state." |
| 67 | + if first_divergence else |
| 68 | + "Observed boot trace matched expected boot sequence." |
| 69 | + ), |
| 70 | + } |
| 71 | + |
| 72 | + REPORT_JSON.write_text(json.dumps(report, indent=2)) |
| 73 | + |
| 74 | + div = report["first_divergence"] |
| 75 | + REPORT_MD.write_text( |
| 76 | + "# Bring-Up Comparison Report\n\n" |
| 77 | + "## Safe claim\n\n" |
| 78 | + f"{report['safe_claim']}\n\n" |
| 79 | + "## Summary\n\n" |
| 80 | + f"- diagnostic status: `{report['diagnostic_status']}`\n" |
| 81 | + f"- expected event count: `{report['expected_event_count']}`\n" |
| 82 | + f"- observed event count: `{report['observed_event_count']}`\n" |
| 83 | + f"- first divergence index: `{div['index'] if div else 'none'}`\n" |
| 84 | + f"- timeout events: `{report['timeout_event_count']}`\n" |
| 85 | + f"- retry events: `{report['retry_event_count']}`\n" |
| 86 | + f"- calibration issues: `{report['calibration_issue_count']}`\n" |
| 87 | + f"- blocked/degraded events: `{report['blocked_or_degraded_event_count']}`\n\n" |
| 88 | + "## First divergence\n\n" |
| 89 | + f"- expected: `{div['expected'] if div else 'none'}`\n" |
| 90 | + f"- observed: `{div['observed'] if div else 'none'}`\n\n" |
| 91 | + "## Root-cause summary\n\n" |
| 92 | + f"{report['root_cause_summary']}\n" |
| 93 | + ) |
| 94 | + |
| 95 | + print(json.dumps(report, indent=2)) |
| 96 | + |
| 97 | + if report["diagnostic_status"] == "FAIL": |
| 98 | + raise SystemExit(1) |
| 99 | + |
| 100 | + |
| 101 | +if __name__ == "__main__": |
| 102 | + main() |
0 commit comments