33import json
44from pathlib import Path
55
6- from .model import Comparability , ExecutionState
6+ from .model import Comparability , ExecutionState , transition
77
88
99def _cell (value : object ) -> str :
@@ -164,8 +164,9 @@ def _prompt(results: dict) -> list[str]:
164164def render_report (run_dir : Path ) -> Path :
165165 manifest = json .loads ((run_dir / "manifest.json" ).read_text (encoding = "utf-8" ))
166166 results = json .loads ((run_dir / "results.json" ).read_text (encoding = "utf-8" ))
167- if manifest ["state" ] != ExecutionState .BENCHMARKED or results ["state" ] != ExecutionState .BENCHMARKED :
168- raise ValueError ("report requires benchmarked manifest and results" )
167+ reportable = {ExecutionState .BENCHMARKED , ExecutionState .REPORTED }
168+ if manifest ["state" ] not in reportable or results ["state" ] not in reportable :
169+ raise ValueError ("report requires benchmarked or reported manifest and results" )
169170 if manifest ["dataset_id" ] != results ["dataset_id" ]:
170171 raise ValueError ("manifest and results dataset mismatch" )
171172 profile = results ["profile" ]
@@ -188,4 +189,14 @@ def render_report(run_dir: Path) -> Path:
188189 ]
189190 path = run_dir / "report.md"
190191 path .write_text ("\n " .join (lines ), encoding = "utf-8" )
192+ # LLM contract: BENCHMARKED -> REPORTED after the human-readable evidence exists.
193+ for payload , json_path in (
194+ (manifest , run_dir / "manifest.json" ),
195+ (results , run_dir / "results.json" ),
196+ ):
197+ if payload ["state" ] == ExecutionState .BENCHMARKED :
198+ payload ["state" ] = transition (ExecutionState .BENCHMARKED , ExecutionState .REPORTED )
199+ json_path .write_text (
200+ json .dumps (payload , indent = 2 , sort_keys = True ) + "\n " , encoding = "utf-8"
201+ )
191202 return path
0 commit comments