Prepare versioned live syntax demo [skip ci]
myfileagent-python-ci/pipeline/head This commit looks good

This commit is contained in:
Codex Agent
2026-11-28 20:44:52 +00:00
parent 8fac256aac
commit 1bb4e0a9dd
15 changed files with 845 additions and 35 deletions
+12 -3
View File
@@ -1,4 +1,13 @@
# Controlled syntax-review demo
‘demo.py‘ intentionally contains ‘print("hello"‘ with one missing closing
parenthesis. The live reviewer writes the repaired ‘reviewed.py‘ separately;
it preserves the committed input.
The prepared baseline in `demo.py` is valid: `print("hello")`.
During the live rehearsal, delete only its final closing parenthesis and commit
the result. The Actions reviewer then sends exactly `print("hello"` to the
SmolLM2 model. It preserves the committed input and writes the validated repair
to `reviewed.py` in the review bundle. Jenkins verifies that bundle, builds the
short versioned demo PDF, tests the reviewed program, and packages the release.
The dashboard's cumulative live token panels update after Jenkins verifies and
publishes the measured review metrics. The prepared baseline uses `[skip ci]`
so the live inference and counter change happen during the rehearsal.
+117
View File
@@ -0,0 +1,117 @@
#!/usr/bin/env python3
"""Build a short versioned LaTeX PDF from an exact verified review bundle."""
import argparse
import hashlib
import json
from pathlib import Path
import re
import shutil
import subprocess
import sys
import tempfile
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from ci.final_project import digest, identity, read_bundle
def tex(value):
mapping = {"\\": r"\textbackslash{}", "{": r"\{", "}": r"\}",
"_": r"\_", "%": r"\%", "&": r"\&", "#": r"\#", "$": r"\$",
"^": r"\textasciicircum{}", "~": r"\textasciitilde{}"}
return "".join(mapping.get(c, c) for c in str(value))
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--sha", required=True)
parser.add_argument("--run-number", required=True)
parser.add_argument("--run-id", required=True)
parser.add_argument("--attempt", required=True)
parser.add_argument("--review-bundle", required=True)
parser.add_argument("--release-version", required=True)
parser.add_argument("--mode", choices=("live", "fixture"), required=True)
parser.add_argument("--jenkins-build", required=True)
args = parser.parse_args()
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+", args.release_version):
raise ValueError("Major.Minor.Changelist release version required")
if not re.fullmatch(r"[1-9][0-9]*", args.run_number):
raise ValueError("Positive Actions run number required")
if not re.fullmatch(r"[A-Za-z0-9_-]{1,80}", args.jenkins_build):
raise ValueError("Invalid Jenkins build ID")
head = subprocess.check_output(("git", "-C", str(ROOT), "rev-parse", "HEAD"), text=True).strip()
if head != args.sha:
raise ValueError("Checkout does not match source commit")
expected = identity(args.sha, args.run_id, args.attempt, args.mode)
files = read_bundle(args.review_bundle, expected)
review = json.loads(files["review.json"])
source_path = ROOT / ("demo/demo.py" if args.mode == "live" else "ci/fixtures/demo_broken.txt")
source = source_path.read_bytes()
if source != b'print("hello"\n' or files["reviewed.py"] != b'print("hello")\n':
raise ValueError("Demo PDF requires the exact one-character syntax repair")
if review["status"] != "corrected" or "+print(\"hello\")" not in review["diff"]:
raise ValueError("Review does not show the permitted correction")
if review.get("input_sha256") and review["input_sha256"] != digest(source):
raise ValueError("Review input hash differs from committed demo source")
if args.mode == "live" and not review.get("raw_response"):
raise ValueError("Live demo PDF requires the recorded real model response")
resource = review.get("resource_measurement") or {}
values = {
"ReleaseVersion": args.release_version, "ReviewMode": args.mode,
"SourceCommit": args.sha, "ActionsRun": args.run_id,
"ActionsAttempt": args.attempt, "JenkinsBuild": args.jenkins_build,
"ModelName": review["model_id"], "ReviewStatus": review["status"],
"InputTokens": review.get("input_tokens") if review.get("input_tokens") is not None else "unknown",
"OutputTokens": review.get("output_tokens") if review.get("output_tokens") is not None else "unknown",
"ElapsedSeconds": review.get("elapsed_seconds", "unknown"),
"MemoryPeak": resource.get("memory_peak_bytes", "unknown"),
"MemoryLimit": resource.get("memory_limit_bytes", "unknown"),
"OOMKills": (resource.get("memory_events") or {}).get("oom_kill", "unknown"),
"ReviewHash": digest(files["review.json"]), "ReviewedHash": digest(files["reviewed.py"]),
}
output = ROOT / "documentation/build"
output.mkdir(parents=True, exist_ok=True)
for name in ("main.pdf", "build-manifest.json"):
(output / name).unlink(missing_ok=True)
with tempfile.TemporaryDirectory(prefix="demo-pdf-") as temporary:
work = Path(temporary)
shutil.copy2(ROOT / "demo/demo_report.tex", work / "demo-report.tex")
(work / "demo-data.tex").write_text("% Generated from verified run metadata.\n" +
"".join(f"\\newcommand{{\\{key}}}{{{tex(value)}}}\n" for key, value in values.items()))
(work / "source-before.txt").write_bytes(source)
(work / "reviewed-after.txt").write_bytes(files["reviewed.py"])
(work / "review-diff.txt").write_text(review["diff"])
(work / "raw-response.txt").write_text(review.get("raw_response") or "SIMULATED fixture response; no real model inference.\n")
result = subprocess.run(("pdflatex", "-no-shell-escape", "-interaction=nonstopmode",
"-halt-on-error", "demo-report.tex"), cwd=work,
capture_output=True, text=True, timeout=60)
log = work / "demo-report.log"
if log.exists():
shutil.copy2(log, output / "demo-report.log")
if result.returncode:
raise RuntimeError("Demo LaTeX compile failed: " + result.stdout[-1800:])
pdf = work / "demo-report.pdf"
from pypdf import PdfReader
reader = PdfReader(pdf)
if not 1 <= len(reader.pages) <= 3:
raise ValueError("Demo PDF must be one to three pages")
extracted = "\n".join(page.extract_text() or "" for page in reader.pages)
for value in (args.release_version, args.sha, review["model_id"], "print(\"hello\")"):
if str(value) not in extracted:
raise ValueError("Demo PDF omitted visible evidence: " + str(value))
shutil.copy2(pdf, output / "main.pdf")
manifest = dict(kind="demo-syntax-review", document_version=args.release_version,
release_version=args.release_version, commit=args.sha,
run_number=args.run_number, run_id=args.run_id, attempt=args.attempt,
mode=args.mode, jenkins_build=args.jenkins_build,
review_status=review["status"], model_id=review["model_id"],
review_sha256=digest(files["review.json"]),
reviewed_sha256=digest(files["reviewed.py"]),
pdf_sha256=hashlib.sha256(pdf.read_bytes()).hexdigest(),
pages=len(reader.pages))
(output / "build-manifest.json").write_text(json.dumps(manifest, sort_keys=True, indent=2) + "\n")
print(json.dumps(manifest, sort_keys=True, indent=2))
if __name__ == "__main__":
main()
+1 -1
View File
@@ -1 +1 @@
print("hello"
print("hello")
+41
View File
@@ -0,0 +1,41 @@
\documentclass[10pt,letterpaper]{article}
\usepackage[margin=0.7in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{fancyvrb}
\usepackage{hyperref}
\setlength{\parindent}{0pt}
\setlength{\parskip}{4pt}
\input{demo-data.tex}
\begin{document}
\begin{center}
{\LARGE\bfseries Model-Assisted Syntax Review}\par
{\large Version \ReleaseVersion\quad|\quad \ReviewMode\ demonstration}\par
\end{center}
\textbf{Exact source commit:} \texttt{\SourceCommit}\\
\textbf{Actions run / attempt:} \ActionsRun\ / \ActionsAttempt\quad
\textbf{Jenkins build:} \JenkinsBuild\\
\textbf{Model:} \ModelName\quad
\textbf{Review status:} \ReviewStatus\\
\textbf{Measured tokens:} \InputTokens\ input / \OutputTokens\ output\quad
\textbf{Elapsed:} \ElapsedSeconds\ seconds\\
\textbf{Complete Actions-job memory:} \MemoryPeak\ bytes peak / \MemoryLimit\ bytes limit; OOM kills: \OOMKills.
\section*{The committed input}
The source at the commit above has one missing closing parenthesis. The reviewer preserves it and writes a separate reviewed file.
\VerbatimInput[fontsize=\small,frame=single]{source-before.txt}
\section*{The model's recorded proposal}
These bytes came from the real model response in \texttt{review.json}. In fixture mode, this section is clearly labeled simulated. The validator accepts only the single permitted repair.
\VerbatimInput[fontsize=\small,frame=single]{raw-response.txt}
\section*{The accepted reviewed program}
\VerbatimInput[fontsize=\small,frame=single]{reviewed-after.txt}
\section*{Exact source diff}
\VerbatimInput[fontsize=\small,frame=single]{review-diff.txt}
\textbf{Evidence binding.} Review JSON SHA-256: \texttt{\ReviewHash}. Reviewed program SHA-256: \texttt{\ReviewedHash}. The release ZIP and manifest carry version \ReleaseVersion. Jenkins tests the reviewed program and publishes only after its remaining gates pass. This short PDF is demo evidence; it is not the team's full manual.
\end{document}