# SPDX-License-Identifier: Apache-2.0
# (c) 2026 Lutar, Stephen P. - SZL Holdings - ORCID 0009-0001-0110-4173
"""Static presentation of committed benchmark output; no scoring or network."""
from __future__ import annotations
import base64
import hashlib
import html
import json
import os
import re
import stat
from pathlib import Path
ROOT = Path(__file__).resolve().parent
ASSETS = {
"szl-tokens.css": "81f7c9baeef0b435e6e3f9d0c4e0d70e40fa17df5d1f30697f623cd3ef5f8eab",
"SOURCE.json": "967a77235227f1d75852fb61873e46336e67403cbc0e7e12b141e31c83fbd93d",
"szl-icon-32.svg": "6e2b7d72a3af3d9602b79de41df0194ede6496a9661f057108ec224c0efc92e6",
"szl-orbit-holo.svg": "31702790da8f90125ff3f65eda459176e4c169aeef6eb2d9d7c8b0ea21d3a22c",
}
SHA = re.compile(r"[0-9a-f]{40}\Z")
def _file(name: str, native: bool = False) -> bytes:
"""Only literal source-owned files; no manifest or request controls paths."""
if (native and name not in ASSETS) or (not native and name != "bench.css"):
raise ValueError("unknown presentation file")
root_fd = os.open(ROOT, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)
try:
directory = os.open("szl", os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW,
dir_fd=root_fd) if native else os.dup(root_fd)
try:
fd = os.open(name, os.O_RDONLY | os.O_NOFOLLOW, dir_fd=directory)
try:
info = os.fstat(fd)
if not stat.S_ISREG(info.st_mode) or info.st_size > 262144:
raise ValueError("presentation file is not a bounded regular file")
chunks = []
remaining = 262145
while remaining:
chunk = os.read(fd, min(remaining, 65536))
if not chunk:
break
chunks.append(chunk)
remaining -= len(chunk)
data = b"".join(chunks)
if len(data) > 262144:
raise ValueError("presentation file exceeded its bound")
finally:
os.close(fd)
finally:
os.close(directory)
finally:
os.close(root_fd)
if native and hashlib.sha256(data).hexdigest() != ASSETS[name]:
raise ValueError("native asset differs from accepted bytes")
return data
def _image(name: str) -> str:
if name not in {"szl-icon-32.svg", "szl-orbit-holo.svg"}:
raise ValueError("unknown native image")
return "data:image/svg+xml;base64," + base64.b64encode(_file(name, True)).decode("ascii")
def css() -> str:
_file("SOURCE.json", True)
return _file("szl-tokens.css", True).decode() + "\n" + _file("bench.css").decode()
def head() -> str:
return (''
f''
'')
def _text(value: object) -> str:
return html.escape(json.dumps(value) if isinstance(value, bool) else str(value), quote=True)
def _json(value: object) -> str:
return _text(json.dumps(value, indent=2, sort_keys=True, allow_nan=False))
def _pair(label: str, value: object) -> str:
return f'
{label}{_text(value)}'
def render(leaderboard: dict, publication: dict, result: dict) -> str:
"""Render original values, not new evaluator or readiness verdicts."""
revision = publication["source_revision"]
if not isinstance(revision, str) or not SHA.fullmatch(revision):
raise ValueError("publication source must be an immutable commit")
source = f"https://github.com/szl-holdings/a11oy/tree/{revision}/benchmarks/governed-agent-bench"
dataset_revision = publication["dataset_revision"]
dataset_url = "https://huggingface.co/datasets/SZLHOLDINGS/governed-agent-bench"
if isinstance(dataset_revision, str) and SHA.fullmatch(dataset_revision):
dataset_url += "/tree/" + dataset_revision
labels = publication["evidence_labels"]
evidence = "".join(_pair(label, labels[key]) for label, key in [
("Corpus", "corpus"), ("Scores", "score"),
("Receipt checks", "receipt_verification"),
("Cryptographic verification", "cryptographic_verification")])
references = []
for row in leaderboard["reference_rows"]:
references.append(
'Evaluator reference
'
f'
{_text(row["display_name"])}
{_text(row["entry_class"])}
'
'
A reproducible conformance fixture. This entry is not a model ranking.
'
''
+ _pair("Computed score", row["score"])
+ _pair("Passing cases", f'{row["passed"]}/{row["total"]}')
+ _pair("Eligible for model ranking", row["eligible_for_model_ranking"])
+ _pair("Corpus / score / receipt checks",
f'{row["dataset_label"]} / {row["score_label"]} / {row["receipt_verification"]}')
+ '
')
axes = []
for index, (axis, values) in enumerate(sorted(result["axes"].items()), 1):
axes.append(
f'{index:02}'
f'
{_text(axis.replace("_", " ").title())}
'
'
'
+ _pair("Passed / total", f'{values["passed"]} / {values["total"]}')
+ _pair("Pass rate", values["pass_rate"]) + '
')
return f'''
Skip to benchmark
Governability / public reference
Every result.
Within its evidence.
Inspect how a committed reference fixture meets five agent-governance contracts, from fail-closed behavior to rollback discipline.
Inspect the reference ↗
Read-only committed output. No model is called and no score is minted by this page.
01 / Evidence boundary
The labels travel with the result.
{evidence}
02 / Reproducible reference
Conformance, with its limits visible.
{''.join(references)}
03 / Axis closure
Five contracts. Each accounted for.
Values below come directly from the committed reference result. Pass rates retain the evaluator’s original numeric scale.
{''.join(axes)}
04 / Submission boundary
A model row must earn its place.
{_text(leaderboard["submission_rule"])}
This viewer cannot submit a model, grant deployment approval, or cryptographically verify a receipt.
05 / Immutable identity
Inspect what was published.
These are declared package identities, not an independent attestation of runtime readiness.
{_pair("Source commit", revision)}{_pair("Dataset repository", publication["dataset_repository"])}{_pair("Dataset revision", dataset_revision)}{_pair("Source observation timestamp", leaderboard["observed_at"])}
Exact publication identity JSON
{_json(publication)}
Exact leaderboard JSON
{_json(leaderboard)}
Exact reference result JSON
{_json(result)}
'''