From d12d04bb8f8320ff9d5039802792597b6556e7f0 Mon Sep 17 00:00:00 2001 From: Ranveer Soni Date: Mon, 23 Nov 2026 17:22:53 +0530 Subject: [PATCH] fix: restore status audit and generated progress assets --- docs/assets/xenora-progress.svg | 21 +++++ scripts/audit/status.py | 158 ++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 docs/assets/xenora-progress.svg create mode 100644 scripts/audit/status.py diff --git a/docs/assets/xenora-progress.svg b/docs/assets/xenora-progress.svg new file mode 100644 index 0000000..e499d15 --- /dev/null +++ b/docs/assets/xenora-progress.svg @@ -0,0 +1,21 @@ + +Xenora · recorded progress +Decoded gfx1030 forms: 21 of 21. Accepted Metal forms · Apple M5: 18 of 21. Accepted guest milestones · X1–X4: 4 of 4 + + +RECORDED FIXTURE PROGRESS +Decoded gfx1030 forms +21 / 21 + + +Accepted Metal forms · Apple M5 +18 / 21 + + +Accepted guest milestones · X1–X4 +4 / 4 + + +Scope: tracked instruction forms and four synthetic guest milestones. + + diff --git a/scripts/audit/status.py b/scripts/audit/status.py new file mode 100644 index 0000000..47cb649 --- /dev/null +++ b/scripts/audit/status.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-3.0-or-later + +"""Render the checked-in status tables and progress graphic.""" + +import argparse +from html import escape +from pathlib import Path +import sys +import tomllib + + +def table(headers, rows): + def line(cells): + return "| " + " | ".join(str(cell).replace("|", r"\|") for cell in cells) + " |" + + return "\n".join([line(headers), line(["---"] * len(headers)), *(line(row) for row in rows)]) + + +def replace_block(path, name, body, check): + original = path.read_text() + start = f"\n" + stop = f"\n" + head, _, tail = original.partition(start) + if not tail or stop not in tail: + raise ValueError(f"{path}: missing status markers") + updated = head + start + body + stop + tail.split(stop, 1)[1] + if updated == original: + return True + if check: + print(f"{path}: status table differs from docs/status.toml", file=sys.stderr) + return False + path.write_text(updated) + return True + + +def render_progress(status): + forms = status["instruction"] + milestones = status["guest_milestones"] + verified_gpu = {"fixture verified", "fixture verified on Apple M5"} + local_gpu = "local Apple M5 readback passed; acceptance pending" + if not forms or len({item["form"] for item in forms}) != len(forms): + raise ValueError("expected a nonempty inventory of unique instruction forms") + for item in forms: + if any(type(item[key]) is not bool for key in ("recognized", "decoded")): + raise ValueError(f"{item['form']}: expected boolean decoder status") + if item["decoded"] and not item["recognized"]: + raise ValueError(f"{item['form']}: decoded form must be recognized") + if item["gpu"] in verified_gpu and ( + not item["decoded"] or not item["lowering"] or item["cpu"] != "fixture verified" + ): + raise ValueError(f"{item['form']}: GPU verification requires a verified CPU path") + if item["gpu"] == local_gpu and ( + not item["decoded"] or not item["lowering"] or item["cpu"] != "local known-answer test passed" + ): + raise ValueError(f"{item['form']}: local GPU evidence requires the local CPU result") + if item["gpu"] not in verified_gpu | {"acceptance pending", local_gpu}: + raise ValueError(f"{item['form']}: unknown GPU evidence status") + if set(milestones) != {"X1", "X2", "X3", "X4"} or any( + value not in {"accepted", "pending"} for value in milestones.values() + ): + raise ValueError("expected acceptance status for each of X1–X4") + + rows = [ + ("Decoded gfx1030 forms", sum(item["decoded"] for item in forms), len(forms)), + ("Accepted Metal forms · Apple M5", sum(item["gpu"] in verified_gpu for item in forms), len(forms)), + ("Accepted guest milestones · X1–X4", list(milestones.values()).count("accepted"), len(milestones)), + ] + svg = [ + '', + 'Xenora · recorded progress', + '' + escape(". ".join(f"{label}: {count} of {total}" for label, count, total in rows)) + '', + '', + '', + 'RECORDED FIXTURE PROGRESS', + ] + for y, (label, count, total) in zip((58, 96, 134), rows, strict=True): + svg.extend([ + f'{escape(label)}', + f'{count} / {total}', + f'', + f'', + ]) + svg.extend([ + 'Scope: tracked instruction forms and four synthetic guest milestones.', + '', + '', + ]) + return "\n".join(svg) + "\n" + + +def check_asset(path, svg, check): + if path.exists() and path.read_text() == svg: + return True + if check: + print(f"{path}: progress graphic differs from docs/status.toml", file=sys.stderr) + return False + path.write_text(svg) + return True + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--check", action="store_true") + check = parser.parse_args().check + root = Path(__file__).resolve().parents[2] + docs = root / "docs" + status = tomllib.loads((docs / "status.toml").read_text()) + claims = tomllib.loads((docs / "claims.toml").read_text()) + classes = {claim["id"]: claim["class"] for claim in claims["claim"]} + + features = table( + ("Feature", "Target", "Implementation", "Correctness", "Hardware", "Evidence", "Limits"), + [ + ( + feature["id"], + feature["architecture"], + feature["implementation"], + feature["correctness"], + feature["hardware_verification"] + ( + f" on {feature['hardware_target']}" if "hardware_target" in feature else "" + ), + ", ".join(sorted({classes[claim] for claim in feature["claims"]})), + feature["limitations"], + ) + for feature in status["feature"] + ], + ) + instructions = table( + ("Form", "Operands", "Size or word", "Recognized", "Decoded", "LLVM", + "Lowering", "Reference", "CPU", "GPU"), + [ + ( + f"`{item['form']}`", + item["encoding"], + item["representation"], + "yes" if item["recognized"] else "no", + "yes" if item["decoded"] else "no", + item["llvm"], + item["lowering"], + item["reference"], + item["cpu"], + item["gpu"], + ) + for item in status["instruction"] + ], + ) + svg = render_progress(status) + checks = [ + replace_block(docs / "progress.md", "features", features, check), + check_asset(docs / "assets/xenora-progress.svg", svg, check), + replace_block(docs / "shaders/instruction-coverage.md", "instructions", instructions, check), + ] + return 0 if all(checks) else 1 + + +if __name__ == "__main__": + sys.exit(main())