From 7d93564ac917ccc9b2861628fcdc6f579ae5b9d6 Mon Sep 17 00:00:00 2001 From: bcloud Date: Sat, 14 Nov 2026 07:00:38 -0400 Subject: [PATCH] hip_f16_audit: print AUDITED before the counts, so a pasted report is evidence engine#2416's playbook now asks a pin-bump PR body for "the commit audited", and the tool never printed it: measured on the from-pointer tree, the sha appeared 0 times in the output. So that line depended on the reporter remembering to run rev-parse as well, which is the fragility the pin gate (engine#2411) exists to remove -- a report that does not name its tree cannot be checked by the person reading it. AUDITED 7d63abfe239e39436847334e70afd46b121b8b25 fa_prompt_q8w.hip 336 lines narrowings 2 f16 accumulators - ... Same convention as the Loom ratchet's CORPUS and FINGERPRINT lines, and printed BEFORE the verdict for the same reason stated there: a FAIL is when the identity of the tree matters most. A tree that is not a git checkout prints "AUDITED no commit: is not a git checkout" rather than a blank or a guess -- an audit of a tree whose commit is unknown is still a legitimate thing to run (plain --dir), it just cannot claim an identity. --self-test gains two cases, both driven through main() rather than the helper: the report names the commit it audited, and a non-checkout tree says so instead of printing a sha. Driving main() is deliberate -- the caller removed earlier today passed its own self-test while its default path skipped the pin gate, because the test called the function directly and never the entry point. Verified: --dir --expect-sha -> AUDITED then the rows --dir -> AUDITED no commit: ... then the rows --self-test -> ok --- tools/ci/hip_f16_audit.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/ci/hip_f16_audit.py b/tools/ci/hip_f16_audit.py index 95a45c69d..981fde34f 100644 --- a/tools/ci/hip_f16_audit.py +++ b/tools/ci/hip_f16_audit.py @@ -144,6 +144,7 @@ def report(rows, as_json, top=None): def self_test(): + import subprocess import tempfile problems = [] @@ -172,6 +173,28 @@ def chk(want, got, what): by = {row["file"]: row for row in rows} chk(1, by["format.hip"]["narrowings"], "the block scale is one narrowing") chk([], by["format.hip"]["accumulators"], "a narrowing alone is not an accumulator") + + # the AUDITED line: a pasted report is only evidence if it names the commit it read (engine#2416's playbook + # asks a pin-bump PR body for exactly that). Asserted through main() so the wiring is covered, not just the + # helper -- a self-test that calls the function directly is how the missing default-path gate got through. + import contextlib + import io + repo = Path(tmp) / "git-tree" + (repo / KERNEL_SUBDIR).mkdir(parents=True) + (repo / KERNEL_SUBDIR / "clean.hip").write_text("float acc[4] = {0}; acc[0] = fmaf(d, q, acc[0]);\n") + for cmd in (["git", "init", "-q"], ["git", "add", "-A"], + ["git", "-c", "user.email=t@t", "-c", "user.name=t", "commit", "-q", "--allow-empty", "-m", "x"]): + subprocess.run(cmd, cwd=repo, capture_output=True) + at_repo = subprocess.run(["git", "rev-parse", "HEAD"], cwd=repo, capture_output=True, text=True).stdout.strip() + buf = io.StringIO() + with contextlib.redirect_stdout(buf): + main(["--dir", str(repo)]) + chk(True, "AUDITED" in buf.getvalue() and at_repo[:12] in buf.getvalue(), + "the report names the commit it audited") + buf = io.StringIO() + with contextlib.redirect_stdout(buf): + main(["--dir", str(kernels.parent.parent.parent)]) # a tree that is not a checkout + chk(True, "no commit" in buf.getvalue(), "a tree that is not a checkout says so instead of printing a sha") chk(0, by["clean.hip"]["narrowings"], "fmaf accumulation narrows nothing") # `_Float16` is the spelling the add-on's kernels actually use (engine#2405: every cast in its three new # kernels is `(_Float16)`), so a pattern that only knew `half`/`__half` reported zero of them. @@ -301,6 +324,13 @@ def main(argv): print(f"hip_f16_audit: {Path(a.dir) / KERNEL_SUBDIR} is not a directory - cannot tell, " f"and that is not a pass", file=sys.stderr) return 2 + # Say WHICH commit was audited, before the counts and on stdout, for the same reason the Loom ratchet prints + # CORPUS and FINGERPRINT before its verdict: a report is evidence only if it names the tree it read, and a FAIL + # is when the identity matters most. engine#2416's playbook asks a pin-bump PR body for "the commit audited" -- + # until now the tool never printed it, so that line depended on someone remembering to run rev-parse as well. + if not a.json: + audited = head_sha(a.dir) + print(f"AUDITED {audited if audited else 'no commit: ' + str(a.dir) + ' is not a git checkout'}") bad = report(rows, a.json, a.top) if bad: for row in bad: