Official Codebase of 3DCodeVerse
Python
bench: the battery launcher leaves the harness CLI — python -m bench.run_bench / bench.report
gaoypeng2f5624665b91
diff --git a/CLAUDE.md b/CLAUDE.mdindex ad948bc8..d25786a5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -6,7 +6,8 @@ The harness lives in **`harness/`** — read `harness/CLAUDE.md` +`cd harness && python -m pytest tests -q -m "not live"`.**`eval/`** evaluates things and is never imported by the harness: `eval/bench` evaluates the HARNESS-(batteries, A/B rigs, reports — `cd eval && python -m pytest`), `eval/llm` evaluates a bare LLM/VLM+(batteries — `cd eval && python -m bench.run_bench <battery.yaml>`, which replaced `3dcode bench` —+A/B rigs, reports; its tests: `cd eval && python -m pytest`), `eval/llm` evaluates a bare LLM/VLM(was `finetune/3dcodeverse_eval`). Read `eval/README.md` first.Other top-level folders are separate components (`toolkits/` data tooling, `finetune/` training).diff --git a/eval/README.md b/eval/README.mdindex 5bf9ca96..948f6313 100644--- a/eval/README.md+++ b/eval/README.md@@ -17,7 +17,8 @@ ask one-shot from there (`llm/config.py: HARNESS_BATTERIES`).```bashpip install -e ../harness # once; both evaluations import codeverse3dcd eval-3dcode bench run bench/prompts/static_objects_v1.yaml --generator gemini-cli:gemini-3.7-flash+python -m bench.run_bench bench/prompts/static_objects_v1.yaml --generator gemini-cli:gemini-3.7-flash+python -m bench.report bench/out/static_objects_v1 # rebuild report.md + report.htmlpython bench/compare_backends.py --prompts bench/prompts/compare_v1.yaml --arms harness:gemini-cli:gemini-3.7-flash,oneshot:gemini:gemini-3.7-flash --out bench/out/compare_v1python -m llm.config # doctor for the LLM evaluation: tools and assets it can / cannot findpython -m pytest # the bench tests (offline)diff --git a/eval/bench/__init__.py b/eval/bench/__init__.pyindex 9f9572fe..87307884 100644--- a/eval/bench/__init__.py+++ b/eval/bench/__init__.py@@ -1,4 +1,4 @@-"""Prompt batteries + bench runner/report (``3dcode bench run|report``).+"""Prompt batteries + bench runner/report (``python -m bench.run_bench`` / ``python -m bench.report``).Methodology: paired runs (same battery, same fixed judge model) acrossgenerators; prompts stratified by tier (easy/medium/hard) and category.diff --git a/eval/bench/h2h_glb.py b/eval/bench/h2h_glb.pyindex 9bd88811..86780a99 100644--- a/eval/bench/h2h_glb.py+++ b/eval/bench/h2h_glb.py@@ -296,7 +296,7 @@ def main() -> None:ap.add_argument("batteries", nargs="+", type=Path)ap.add_argument("--gallery", type=Path, default=Path("/home/yipeng/projects/astra3d-brilliana/gallery"))ap.add_argument("--bench-out", type=Path, default=here / "out" / "h2h_brilliana_v1",- help="root holding <lang>/runs/<id>/ (one `3dcode bench run --out <root>/<lang>` per battery)")+ help="root holding <lang>/runs/<id>/ (one `python -m bench.run_bench --out <root>/<lang>` per battery)")ap.add_argument("--out", type=Path, default=None, help="where h2h.jsonl / pairs/ / h2h_summary.md go (default: --bench-out)")ap.add_argument("--id", action="append", default=[], help="only these prompt ids")ap.add_argument("--theirs-only", action="store_true", help="judge only the gallery GLBs (proof of the judge path)")diff --git a/eval/bench/prompts/complexity_v3.yaml b/eval/bench/prompts/complexity_v3.yamlindex 797a3d04..965c5ec0 100644--- a/eval/bench/prompts/complexity_v3.yaml+++ b/eval/bench/prompts/complexity_v3.yaml@@ -14,7 +14,7 @@# mode this battery exists to catch. `expected_complexity` is not read by run_bench# (extra keys are ignored); `bench/complexity_report.py --battery` reads it.#-# 3dcode bench run bench/prompts/complexity_v3.yaml --out bench/out/complexity_v3 \+# python -m bench.run_bench bench/prompts/complexity_v3.yaml --out bench/out/complexity_v3 \# --generator gemini-cli:gemini-3.6-flash --judge gemini:gemini-3.1-pro-preview# python bench/complexity_report.py bench/out/complexity_v3 --battery bench/prompts/complexity_v3.yaml#diff --git a/eval/bench/refs/README.md b/eval/bench/refs/README.mdindex 3a1bde6d..e297d8a2 100644--- a/eval/bench/refs/README.md+++ b/eval/bench/refs/README.md@@ -7,7 +7,7 @@ bench/refs/<prompt_id>/<what_it_shows>.png|jpg|jpeg|webp````bench/run_bench.py::discover_references` attaches every image in the folder to the prompt's-`Spec.references` for every bench driver (`3dcode bench run`, `bench/compare_backends.py`,+`Spec.references` for every bench driver (`bench/run_bench.py`, `bench/compare_backends.py`,`bench/ab_plan.py`), in sorted filename order, with the file stem (underscores → spaces) as thenote the agent and the judge read. A prompt may also list `references:` paths in its yaml.diff --git a/eval/bench/report.py b/eval/bench/report.pyindex 9b8dc7ff..2c3b746d 100644--- a/eval/bench/report.py+++ b/eval/bench/report.py@@ -1,5 +1,7 @@"""Aggregate a bench run: per-tier / per-category stats → markdown + HTML gallery.+ cd eval && python -m bench.report bench/out/static_objects_v1 (was ``3dcode bench report``)+``build_report(out_dir)`` reads ``results.jsonl`` (or results.json), aggregatesbaseline / picked-round mean + median, the delta and cost per tier and category (no passrate: a run is not passed or failed since 2026-09-22), writes ``report.md`` and@@ -10,21 +12,33 @@ summary strip.from __future__ import annotations+import argparseimport htmlimport jsonimport statistics+import sys+from collections.abc import Sequencefrom pathlib import Pathfrom pydantic import BaseModel, Field-from bench._compare_report import _f as _fmt-from bench._compare_report import _mean-from bench._jsonl import latest, read_jsonl-from bench.run_bench import BenchItemResult-from codeverse3d.addons.gallery import GalleryIndex, RootSection, RunEntry, render_static-from codeverse3d.addons.gallery.index import entry_from_record-from codeverse3d.record.record import RecordError, load_record-from codeverse3d.workspace import Workspace+for _p in (Path(__file__).resolve().parents[2] / "harness", Path(__file__).resolve().parents[1]):+ if str(_p) not in sys.path: # this tree's codeverse3d (harness/) + the `bench` package (eval/)+ sys.path.insert(0, str(_p))++from bench._compare_report import _f as _fmt # noqa: E402+from bench._compare_report import _mean # noqa: E402+from bench._jsonl import latest, read_jsonl # noqa: E402+from bench.run_bench import BenchItemResult # noqa: E402+from codeverse3d.addons.gallery import ( # noqa: E402+ GalleryIndex,+ RootSection,+ RunEntry,+ render_static,+)+from codeverse3d.addons.gallery.index import entry_from_record # noqa: E402+from codeverse3d.record.record import RecordError, load_record # noqa: E402+from codeverse3d.workspace import Workspace # noqa: E402TIER_ORDER = {"easy": 0, "medium": 1, "hard": 2}@@ -173,3 +187,21 @@ def _html_gallery(out: Path, name: str, results: list[BenchItemResult], rep: Bensections.setdefault(r.tier, RootSection(label=r.tier, path=str(out / "runs"))).entries.append(_entry_for(r))index = GalleryIndex(sections=list(sections.values()), roots=[str(out)])return render_static(index, title=f"bench — {name}", embed=True, extra_html=tables)+++def main(argv: Sequence[str] | None = None) -> int:+ ap = argparse.ArgumentParser(description="Aggregate results.jsonl → report.md + report.html "+ "(gallery of contact sheets).")+ ap.add_argument("out_dir", type=Path, help="a battery's output directory (holds results.jsonl)")+ ns = ap.parse_args(argv)+ try:+ rep = build_report(ns.out_dir)+ except FileNotFoundError as e:+ ap.error(str(e))+ print(rep.markdown)+ print(f"report → {ns.out_dir / 'report.md'} / report.html")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/eval/bench/run_bench.py b/eval/bench/run_bench.pyindex 480b875e..b0749bd3 100644--- a/eval/bench/run_bench.py+++ b/eval/bench/run_bench.py@@ -1,5 +1,14 @@"""Run a prompt battery through a track with N parallel workers; resumable.+ cd eval && python -m bench.run_bench bench/prompts/static_objects_v1.yaml \+ --generator gemini-cli:gemini-3.7-flash --judge gemini:gemini-3.1-pro-preview [--rounds 2] \+ [--parallel 4] [--tier easy] [--id furn_easy_stool] [--limit 6] [--out bench/out/x] \+ [--redo-status infra_failed] [--no-report]++(``3dcode bench run`` until 2026-09-22: the launcher lives with the evaluation now, and like+every bench script it imports THIS tree's ``codeverse3d`` — a console script resolved the+editable install's, so a battery launched from a worktree ran the main checkout's code.)+Layout of ``out_dir``::battery.json the battery as loaded (+ overrides used)@@ -21,9 +30,11 @@ The binding is context-local, so ``--parallel N`` keeps N ledgers apart. And lifrom __future__ import annotations+import argparseimport csvimport jsonimport logging+import sysimport timeimport tracebackfrom collections.abc import Callable, Sequence@@ -35,16 +46,20 @@ from typing import Anyimport yamlfrom pydantic import AliasChoices, BaseModel, Field-from bench._infra import is_infra_failure-from bench._jsonl import latest, read_jsonl, seal_for_append-from codeverse3d.addons import select-from codeverse3d.config import get_settings-from codeverse3d.contracts.common import Backends, Budget, Language, Track-from codeverse3d.contracts.run import RunRecord-from codeverse3d.contracts.spec import Constraints, ReferenceImage, Spec-from codeverse3d.cost import run_ledger-from codeverse3d.proc import exclusive-from codeverse3d.workspace import Workspace+for _p in (Path(__file__).resolve().parents[2] / "harness", Path(__file__).resolve().parents[1]):+ if str(_p) not in sys.path: # this tree's codeverse3d (harness/) + the `bench` package (eval/)+ sys.path.insert(0, str(_p))++from bench._infra import is_infra_failure # noqa: E402+from bench._jsonl import latest, read_jsonl, seal_for_append # noqa: E402+from codeverse3d.addons import select # noqa: E402+from codeverse3d.config import get_settings # noqa: E402+from codeverse3d.contracts.common import Backends, Budget, Language, Track # noqa: E402+from codeverse3d.contracts.run import RunRecord # noqa: E402+from codeverse3d.contracts.spec import Constraints, ReferenceImage, Spec # noqa: E402+from codeverse3d.cost import run_ledger # noqa: E402+from codeverse3d.proc import exclusive # noqa: E402+from codeverse3d.workspace import Workspace # noqa: E402log = logging.getLogger(__name__)@@ -330,3 +345,56 @@ def write_results(out_dir: Path, results: list[BenchItemResult]) -> None:w.writeheader()for r in rows:w.writerow({k: r.get(k) for k in RESULT_FIELDS})+++def main(argv: Sequence[str] | None = None) -> int:+ ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])+ ap.add_argument("battery", type=Path, help="bench/prompts/<name>.yaml")+ ap.add_argument("--out", type=Path, default=None, help="default bench/out/<battery name>")+ ap.add_argument("--generator")+ ap.add_argument("--planner")+ ap.add_argument("--judge", help="fixed judge model for the whole battery")+ ap.add_argument("--parallel", type=int, default=None,+ help="workers (default: BenchOptions.parallel — the measured knee)")+ ap.add_argument("--rounds", type=int, default=4)+ ap.add_argument("--max-minutes", type=float, default=60.0,+ help="wall-clock budget per run; size it to the weather (RUNBOOK 7.x: 120 in a 503 storm, "+ "else runs burn the hour with no judged round)")+ ap.add_argument("--limit", type=int, default=None)+ ap.add_argument("--id", dest="ids", action="append", default=[], help="only this prompt id (repeatable)")+ ap.add_argument("--tier", dest="tiers", action="append", default=[], help="only this tier (repeatable)")+ ap.add_argument("--redo-status", default="",+ help="comma list of recorded statuses to re-run, e.g. infra_failed once the provider recovers")+ ap.add_argument("--report", action=argparse.BooleanOptionalAction, default=True,+ help="write report.md + report.html when the battery ends")+ ns = ap.parse_args(argv)+ if not ns.battery.is_file():+ ap.error(f"battery not found: {ns.battery}")+ if ns.rounds < 0 or (ns.parallel is not None and ns.parallel < 1):+ ap.error("--rounds must be >= 0 and --parallel >= 1")+ # one source of truth for the worker count: BenchOptions.parallel (the measured knee)+ opts = BenchOptions(generator=ns.generator, planner=ns.planner, judge=ns.judge, rounds=ns.rounds,+ max_minutes=ns.max_minutes, limit=ns.limit, ids=ns.ids, tiers=ns.tiers,+ redo_status=[x for x in ns.redo_status.split(",") if x],+ **({} if ns.parallel is None else {"parallel": ns.parallel}))+ out = ns.out or Path(__file__).resolve().parent / "out" / ns.battery.stem+ print(f"battery={ns.battery} out={out} generator={ns.generator or 'default'} judge={ns.judge or 'default'}",+ flush=True)++ def _on(res: BenchItemResult) -> None:+ print(f" [{res.status}] {res.id}: baseline={res.score_baseline} picked={res.score_picked} "+ f"rounds={res.rounds} ${res.cost_usd:.2f} {res.minutes:.1f}min"+ + (f" {res.errors[:80]}" if res.errors else ""), flush=True)++ results = run_battery(ns.battery, out, opts, on_result=_on)+ print(f"{len(results)} results → {out / 'results.csv'}")+ if ns.report:+ from bench.report import build_report++ print(build_report(out).markdown)+ print(f"report → {out / 'report.md'} / report.html")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/eval/docs/COMPLEXITY.md b/eval/docs/COMPLEXITY.mdindex 88b43e1d..1b80792c 100644--- a/eval/docs/COMPLEXITY.md+++ b/eval/docs/COMPLEXITY.md@@ -300,7 +300,7 @@ in a documented order. Every prompt declares the band its **built** artifact isexpected to reach:```-3dcode bench run bench/prompts/complexity_v3.yaml --out bench/out/complexity_v3 \+python -m bench.run_bench bench/prompts/complexity_v3.yaml --out bench/out/complexity_v3 \--generator gemini-cli:gemini-3.6-flash --judge gemini:gemini-3.1-pro-previewpython bench/complexity_report.py bench/out/complexity_v3 --battery bench/prompts/complexity_v3.yaml```diff --git a/eval/docs/EVAL.md b/eval/docs/EVAL.mdindex 4b9b4b60..0f8385ef 100644--- a/eval/docs/EVAL.md+++ b/eval/docs/EVAL.md@@ -6,7 +6,7 @@How we decide whether the harness (plan → generate → gate → render → judge →refine) beats raw generation, and whether one backend beats another, without-fooling ourselves. Tools: `3dcode bench`, `bench/compare_backends.py`,+fooling ourselves. Tools: `bench/run_bench.py`, `bench/compare_backends.py`,`codeverse3d.judges.{vlm_judge, pairwise, calibration, metrics}`.## 1. Principles@@ -54,15 +54,19 @@ becomes acceptance items (planner-appended in the loop, fixed-judge checklist incomparisons); `dimensions_m` becomes `Spec.constraints.dimensions_m` and adeterministic contract check.-## 3. Harness battery runs (`3dcode bench run`)+## 3. Harness battery runs (`python -m bench.run_bench`)```bash-3dcode bench run bench/prompts/static_objects_v1.yaml \+cd eval # was `3dcode bench run|report` until 2026-09-22: the launcher lives with the evaluation now+python -m bench.run_bench bench/prompts/static_objects_v1.yaml \--generator gemini-cli:gemini-3.7-flash --judge gemini:gemini-3.1-pro-preview \--rounds 2 --parallel 4 --out bench/out/static_v1_apiagent-3dcode bench run bench/prompts/static_objects_v1.yaml --generator gemini-cli:gemini-3.7-flash --judge gemini:gemini-3.1-pro-preview --out bench/out/static_v1_gemcli-3dcode bench report bench/out/static_v1_apiagent+python -m bench.run_bench bench/prompts/static_objects_v1.yaml --generator gemini-cli:gemini-3.7-flash --judge gemini:gemini-3.1-pro-preview --out bench/out/static_v1_gemcli+python -m bench.report bench/out/static_v1_apiagent```+Like every bench script it imports THIS tree's `codeverse3d` (`../harness`), so a battery+launched from a worktree measures the worktree — the `3dcode` console script resolved the+editable install instead.Each item = one full `3dcode make` run (its own workspace under `--out`) followed by thehand-over `make` does — `addons/select.pick` by score, then `package` (deliverable/ +selection.json); `results.jsonl` rows carry `score_baseline`, `score_picked` (rows writtendiff --git a/eval/tests/test_bench.py b/eval/tests/test_bench.pyindex 7f48d846..0cc0fbaa 100644--- a/eval/tests/test_bench.py+++ b/eval/tests/test_bench.py@@ -231,3 +231,42 @@ def test_a_redo_starts_from_a_fresh_workspace(tmp_path):assert seen == [False], "the redo ran fresh, not resumed"assert (out / "runs" / f"{pid}.attempt1" / "src" / "old.py").exists(), "the old tree is archived beside the new one"assert archive_attempt(out / "runs" / pid).name == f"{pid}.attempt2"+++def test_the_launcher_hands_its_flags_to_run_battery(tmp_path: Path, monkeypatch, capsys):+ """``python -m bench.run_bench`` replaced ``3dcode bench run`` (2026-09-22) with the same flags."""+ import bench.run_bench as rb++ seen: dict = {}++ def fake(battery, out, opts, *, on_result=None):+ seen.update(battery=battery, out=out, opts=opts)+ return []++ monkeypatch.setattr(rb, "run_battery", fake)+ battery = REPO / "bench" / "prompts" / "static_objects_v1.yaml"+ assert rb.main([str(battery), "--out", str(tmp_path), "--generator", "g", "--judge", "j", "--rounds", "2",+ "--max-minutes", "120", "--parallel", "3", "--id", "a", "--id", "b", "--tier", "easy",+ "--limit", "5", "--redo-status", "infra_failed,error", "--no-report"]) == 0+ o = seen["opts"]+ assert (o.generator, o.judge, o.rounds, o.max_minutes, o.parallel, o.limit) == ("g", "j", 2, 120.0, 3, 5)+ assert o.ids == ["a", "b"] and o.tiers == ["easy"] and o.redo_status == ["infra_failed", "error"]+ assert seen["out"] == tmp_path and "0 results" in capsys.readouterr().out+ # no --parallel / --out: BenchOptions' measured knee, and bench/out/<battery name>+ assert rb.main([str(battery), "--no-report"]) == 0+ assert seen["opts"].parallel == BenchOptions().parallel+ assert seen["out"] == REPO / "bench" / "out" / "static_objects_v1"+ with pytest.raises(SystemExit):+ rb.main([str(battery), "--rounds", "-1"])+++def test_the_report_command_rebuilds_the_report(tmp_path: Path, capsys):+ """``python -m bench.report <out>`` replaced ``3dcode bench report``."""+ from bench.report import main++ battery = REPO / "bench" / "prompts" / "static_objects_v1.yaml"+ run_battery(battery, tmp_path, BenchOptions(parallel=1, limit=1), run_fn=_fake_run_fn({}))+ assert main([str(tmp_path)]) == 0+ assert "# bench report" in capsys.readouterr().out and (tmp_path / "report.html").is_file()+ with pytest.raises(SystemExit):+ main([str(tmp_path / "missing")])diff --git a/harness/CLAUDE.md b/harness/CLAUDE.mdindex ed127460..f44f940d 100644--- a/harness/CLAUDE.md+++ b/harness/CLAUDE.md@@ -99,7 +99,7 @@ cd /home/yipeng/3dcodeverse/harness3dcode flywheel export runs/ dataset/ [--pack --drop-duplicates --captions-dir d/] · 3dcode flywheel pairs runs/ pairs.jsonl3dcode flywheel caption <slug> [--out dir] # the gallery is `3dcode gallery build --embed`3dcode gallery serve [ROOTS...] [--port 8765] [--reload] · 3dcode gallery build --out gallery.html [--embed]-3dcode bench run ../eval/bench/prompts/static_objects_v1.yaml --generator ... --judge gemini:gemini-3.1-pro-preview+(cd ../eval && python -m bench.run_bench bench/prompts/static_objects_v1.yaml --generator ... --judge gemini:gemini-3.1-pro-preview) # report: python -m bench.report bench/out/<battery>python -m codeverse3d.addons.calibration runs/<slug>... --model gemini:gemini-3.1-pro-preview --n 3 --out out/python ../eval/bench/complexity_report.py ../eval/bench/out --recursive # score-vs-complexity + $/complexity point (eval/docs/COMPLEXITY.md)python ../eval/bench/compare_backends.py --prompts ../eval/bench/prompts/compare_v1.yaml --arms harness:gemini-cli:gemini-3.6-flash,oneshot:claude-code --judge gemini:gemini-3.1-pro-preview --out ../eval/bench/out/compare_v1diff --git a/harness/codeverse3d/cli/_common.py b/harness/codeverse3d/cli/_common.pyindex c1ff5217..eb6c06e9 100644--- a/harness/codeverse3d/cli/_common.py+++ b/harness/codeverse3d/cli/_common.py@@ -1,13 +1,11 @@"""Shared CLI plumbing: Rich formatting (run summaries, tables, observations, doctor-rows), the run-mutation mutex, workspace opening / creation, the ``bench`` import and-the cost-quality dial resolution every command goes through."""+rows), the run-mutation mutex, workspace opening / creation and the cost-quality dial+resolution every command goes through."""from __future__ import annotationsimport hashlib-import importlibimport shutil-import sysfrom collections.abc import Iteratorfrom contextlib import ExitStack, contextmanagerfrom dataclasses import dataclass@@ -147,26 +145,11 @@ class CliError(typer.Exit):super().__init__(code=code)-#: the evaluation code lives NEXT TO the harness (``<repo>/eval``), not inside it+#: the evaluation lives NEXT TO the harness (``<repo>/eval``) and is never imported by it;+#: the gallery only looks for the batteries' run directories under ``eval/bench/out``EVAL_ROOT = REPO_ROOT.parent / "eval"-def import_bench(module: str) -> Any:- """``bench.<module>``: ``bench`` is ``<repo>/eval/bench`` (not part of the package), so it- is made importable here, and a checkout without it is a clear exit, not a traceback."""- name = f"bench.{module}"- try:- return importlib.import_module(name)- except ImportError:- if str(EVAL_ROOT) not in sys.path:- sys.path.insert(0, str(EVAL_ROOT))- try:- return importlib.import_module(name)- except ImportError as e:- raise CliError(f"{name} is not available ({e}). This command needs the evaluation code "- f"next to the harness ({EVAL_ROOT}).", code=2) from e--def runs_root(runs_dir: Path | None) -> Path:return Path(runs_dir) if runs_dir is not None else Path(get_settings().runs_dir)diff --git a/harness/codeverse3d/cli/main.py b/harness/codeverse3d/cli/main.pyindex 36e85915..0c1fdc13 100644--- a/harness/codeverse3d/cli/main.py+++ b/harness/codeverse3d/cli/main.py@@ -88,61 +88,6 @@ def tools(raise typer.Exit(code=1)-# ===================================================================== bench_cmd-bench_app = typer.Typer(no_args_is_help=True)---@bench_app.command("run")-def run_cmd(- battery: Annotated[Path, typer.Argument(help="eval/bench/prompts/<name>.yaml")],- out: Annotated[Path | None, typer.Option("--out", help="default eval/bench/out/<battery name>")] = None,- generator: Annotated[str | None, typer.Option("--generator")] = None,- planner: Annotated[str | None, typer.Option("--planner")] = None,- judge: Annotated[str | None, typer.Option("--judge", help="fixed judge model for the whole battery")] = None,- parallel: Annotated[int | None, typer.Option(- "--parallel", min=1, help="workers (default: BenchOptions.parallel — the measured knee)")] = None,- rounds: Annotated[int, typer.Option("--rounds", min=0)] = 4,- max_minutes: Annotated[float, typer.Option("--max-minutes", help="wall-clock budget per run; size it to the weather "- "(RUNBOOK 7.x: 120 in a 503 storm, else runs burn the hour with no judged round)")] = 60.0,- limit: Annotated[int | None, typer.Option("--limit")] = None,- ids: Annotated[list[str] | None, typer.Option("--id", help="only these prompt ids")] = None,- tiers: Annotated[list[str] | None, typer.Option("--tier")] = None,- redo_status: Annotated[str, typer.Option("--redo-status", help="comma list of recorded statuses to re-run, "- "e.g. infra_failed once the provider recovers")] = "",- report: Annotated[bool, typer.Option("--report/--no-report")] = True,-) -> None:- """Run every prompt of a battery through its track (N parallel workers); resumable."""- if not battery.is_file():- raise C.CliError(f"battery not found: {battery}")- run_bench = C.import_bench("run_bench")- # one source of truth for the worker count: BenchOptions.parallel (the measured knee)- par = {"parallel": parallel} if parallel is not None else {}- opts = run_bench.BenchOptions(generator=generator, planner=planner, judge=judge, rounds=rounds, max_minutes=max_minutes,- limit=limit, ids=ids or [], tiers=tiers or [],- redo_status=[x for x in redo_status.split(",") if x], **par)- out_dir = out or (C.EVAL_ROOT / "bench" / "out" / battery.stem)- console.print(f"battery={battery} out={out_dir} generator={generator or 'default'} judge={judge or 'default'}")-- def _on(res) -> None:- console.print(f" [{res.status}] {res.id}: baseline={res.score_baseline} picked={res.score_picked} "- f"rounds={res.rounds} ${res.cost_usd:.2f} {res.minutes:.1f}min" + (f" [red]{res.errors[:80]}[/red]" if res.errors else ""))-- results = run_bench.run_battery(battery, out_dir, opts, on_result=_on)- ok(f"{len(results)} results → {out_dir / 'results.csv'}")- if report:- rep = C.import_bench("report").build_report(out_dir)- console.print(rep.markdown)- ok(f"report → {out_dir / 'report.md'} / report.html")---@bench_app.command("report")-def report_cmd(out_dir: Annotated[Path, typer.Argument()]) -> None:- """Aggregate results.jsonl → report.md + report.html (gallery of contact sheets)."""- rep = C.import_bench("report").build_report(out_dir)- console.print(rep.markdown)- ok(f"report → {out_dir / 'report.md'} / report.html")--# ===================================================================== gallery_cmdgallery_app = typer.Typer(no_args_is_help=True)@@ -238,7 +183,6 @@ app.add_typer(name="gallery",help="Look at runs locally: `serve` on localhost, `build` one shareable HTML file.",)-app.add_typer(bench_app, name="bench", help="Prompt batteries: run + report.")app.add_typer(cost_app, name="cost", help="Cost audit: per stage/role/model, waste, $ per run.")diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex ff7adb96..f33f21f2 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -230,20 +230,23 @@ codeverse3d/The other half of the split: codeverse3d/skills/ is what an AGENT choosesto read (SKILL.md + references/ + a _claims file pinning its numbers tolive constants). A file that tries to be both is the bug this prevents.- cli/ main.py (app wiring, make/resume/mcp + the tools/bench/gallery+ cli/ main.py (app wiring, make/resume/mcp + the tools/gallerycommands), inspect_cmd.py (status/render/judge on one existing run),flywheel_cmd.py, texture_cmd.py, cost_cmd.py (`3dcode cost`), layout_cmd.py, doctor.py(`--skills` checks the library + its discovery wiring),skills_cmd.py (`3dcode skills list|show|validate|report` — the read-rate report)-eval/bench/ run_bench.py, report.py (renders through codeverse3d/addons/gallery), compare_backends.py+eval/bench/ run_bench.py + report.py (the battery launcher, `python -m bench.run_bench` / `bench.report`;+ the report renders through codeverse3d/addons/gallery), compare_backends.py(preflights every model it needs; --wait-for-provider / --no-preflight),_infra.py (outage vs model failure: infra_failed / budget_exhausted, eval/docs/EVAL.md §7),pin_plan.py (seed one plan into both arms so the paired delta stops carryingthe planner's spread — permitted only by plan_features.pin_plan_blockers),_compare_report.py (arm table incl. the `dropped` / `over budget` loss columns;- dedups the append-only rows per (prompt, arm) so every reader agrees),- _jsonl.py (the ONE tolerant reader/append-sealer for the resumable- *.jsonl journals — a truncated last line never costs the paid rows),+ ArmStats, the one arm aggregate — the A/B summary reads it too),+ _jsonl.py (the ONE tolerant reader, dedup rule — `latest`, the last row per+ key — and append-sealer for the resumable *.jsonl journals: a truncated last+ line never costs the paid rows), stats.py (the one t-interval, exact sign+ test and correlation every report states),ab_plan.py (paired control/variant A/B for plan + brief switches, --aacalibration mode; pins both children to the cap the §23 admission checkreserved), _ab_report.py,diff --git a/harness/docs/COST.md b/harness/docs/COST.mdindex 23dc8825..b0d10ff2 100644--- a/harness/docs/COST.md+++ b/harness/docs/COST.md@@ -1105,7 +1105,7 @@ _pools: dict[tuple[str, ...], KeyPool] = {} # codeverse3d/models/gemini.pydef shared_pool(...): """One KeyPool per distinct (key list, quota) so limiters are process-wide."""```-Process-wide is not machine-wide. Every `3dcode bench run`, every `compare_backends.py`+Process-wide is not machine-wide. Every `bench/run_bench.py`, every `compare_backends.py`and every `3dcode make` is its own OS process with its own pool, each believing it owns thewhole 22-key quota and each allowing its own 64 in-flight. On 2026-08-24 six batteriesfrom different waves ran at once: **~384 concurrent calls against a quota sized for 64**.diff --git a/harness/docs/RUNBOOK.md b/harness/docs/RUNBOOK.mdindex 40fb30f2..f969eeb4 100644--- a/harness/docs/RUNBOOK.md+++ b/harness/docs/RUNBOOK.md@@ -229,9 +229,9 @@ render cache separates with it, which an A/B wants.Also halve each arm's `--parallel`: two arms at 3 workers is six concurrent renders, and around with no renders skips the judge, so the loop stops at `judge_unavailable` and the-cell is finished with no score (`bench run` will not re-run it: the row exists). Redo the+cell is finished with no score (`run_bench` will not re-run it: the row exists). Redo thescoreless cells afterwards — delete the row from `results.jsonl` and the run directory,-then `bench run --id <prompt>`.+then `python -m bench.run_bench <battery> --id <prompt>`.A refine session that dies on the VENDOR's usage limit ("You've hit your usage limit … try again atSep 14th", `RESOURCE_EXHAUSTED`, `insufficient_quota`) stops the run at `agent_quota`: every round@@ -249,17 +249,19 @@ in a `lost to the box` column instead of counting them as gate failures. A battreport shows that column non-zero has to be re-run for those cells before it is read as astatement about the generator.-**A battery launched with `3dcode` from a worktree runs the MAIN checkout's code.** `3dcode`+**Anything launched with `3dcode` from a worktree runs the MAIN checkout's code.** `3dcode`is a console script, so `sys.path[0]` is the venv's `bin`, never the cwd, and `import-codeverse3d` finds the editable install. `--out eval/bench/out/<name>` IS relative to the cwd,-so the OUTPUT lands in the worktree while the CODE that produced it is the main tree's —-an arm that looks like it is testing your branch and is testing `main` (measured-2026-09-05: the first `scenes_v1` battery, launched from `local/worktrees/integrate`, ran-entirely on the main checkout). `python -c` and `pytest` do not have this problem because-they put the cwd on the path. Export `PYTHONPATH=<worktree>/harness` before the command,-and have the arm script REFUSE TO RUN when `codeverse3d.__file__` and `runtime_js_dir()` are-not the tree you meant — `local/scripts/run_scene_fixed.sh` is the pattern, and it also-asserts that the specific fixes the arm exists to measure are present.+codeverse3d` finds the editable install. `--out` IS relative to the cwd, so the OUTPUT lands+in the worktree while the CODE that produced it is the main tree's — an arm that looks like it+is testing your branch and is testing `main` (measured 2026-09-05: the first `scenes_v1`+battery, launched with `3dcode bench run` from `local/worktrees/integrate`, ran entirely on the+main checkout). Batteries no longer have this problem: `python -m bench.run_bench` (the+launcher since 2026-09-22) bootstraps `sys.path` to its own tree's `harness/` like every bench+script (`eval/tests/test_worktree_import.py`). For `3dcode make` from a worktree, export+`PYTHONPATH=<worktree>/harness` before the command, and have an arm script REFUSE TO RUN when+`codeverse3d.__file__` and `runtime_js_dir()` are not the tree you meant —+`local/scripts/run_scene_fixed.sh` is the pattern, and it also asserts that the specific fixes+the arm exists to measure are present.**A new worktree needs `runtime_js/node_modules` before it can run a battery.** Without it`render_glb` dies on every round, the judge is skipped for want of renders, and the cells@@ -289,9 +291,11 @@ call the `texture_pass` / `texture_preview` tools mid-session.## 7. Benchmarks```bash-3dcode bench run ../eval/bench/prompts/static_objects_v1.yaml --generator single-shot:gemini:gemini-3.7-flash \- --judge gemini:gemini-3.1-pro-preview --rounds 2 --parallel 4 [--tier easy] [--id furn_easy_stool] [--limit 6] [--out ../eval/bench/out/x]-3dcode bench report ../eval/bench/out/static_objects_v1 # report.md + self-contained report.html (gallery)+cd ../eval # the battery launcher is the evaluation's (`3dcode bench` until 2026-09-22)+python -m bench.run_bench bench/prompts/static_objects_v1.yaml --generator single-shot:gemini:gemini-3.7-flash \+ --judge gemini:gemini-3.1-pro-preview --rounds 2 --parallel 4 [--tier easy] [--id furn_easy_stool] [--limit 6] [--out bench/out/x]+python -m bench.report bench/out/static_objects_v1 # report.md + self-contained report.html (gallery)+cd ../harnesspython ../eval/bench/compare_backends.py --prompts ../eval/bench/prompts/compare_v1.yaml \--arms harness:gemini-cli:gemini-3.7-flash,oneshot:claude-code --judge gemini:gemini-3.1-pro-preview --out ../eval/bench/out/compare_v1```@@ -315,7 +319,7 @@ undefined`, four prompts recorded `error` at 0 min. Rule: every new template vaguarded `{% if name is defined and name %}` for at least one wave, and the "Landing sourcechanges while a wave is running" rule covers `codeverse3d/prompts/**` as well as moved names.-### 7.u `bench run --redo-status` starts the redo fresh (since c828637)+### 7.u `run_bench --redo-status` starts the redo fresh (since c828637)Before it, a redo resumed the old workspace — old `spec.json` (the old `max_minutes`) and theold clock — so a `budget` row redone with `--max-minutes 120` was over budget before its first@@ -323,22 +327,22 @@ round (clock_q4, lighthouse_1: `budget`, 0 rounds, "60.3 / 76.7 min elapsed").tree is archived as `runs/<id>.attempt<N>` and the prompt runs from scratch with the newoptions, the way `ab_plan` has done since the skills wave.-It is also the ONLY way: `bench run --no-resume` was deleted 2026-08-30. It dropped the+It is also the ONLY way: `run_bench --no-resume` was deleted 2026-08-30. It dropped therecorded rows and then resumed the workspace anyway — `resume = ws.exists()` never read theflag — so a "fresh" rerun carried the old spec, rounds, spend and clock and appended a secondresults row for the same tree. `compare_backends --no-resume` kept its flag (it is documentedand has three readers) and now archives the harness cell's `run/` before re-running it.-### 7.w One driver per out dir — a second `bench run` re-runs what the first is still running+### 7.w One driver per out dir — a second `run_bench` re-runs what the first is still runningMeasured 2026-08-26 (refs_v1_graphics): a redo driver (`--redo-status budget`) started while theoriginal driver was still working the same battery resumed a prompt the first driver had inflight, re-ran its last round in the same workspace and rewrote `rounds/r02.json` (0.600 →0.944 for the same sheet: judge/acceptance variance, not a new picture) and appended a second`results.jsonl` row. `run_battery` decides what to run from `results.jsonl`, and a prompt with no-row yet is fair game to both. Rule: never start a second `3dcode bench run` on an out dir with a-live driver; wait for the driver to exit (exact pid, `kill -0`), then redo once with-`--redo-status infra_failed,error,budget --max-minutes 120`. `bench run` grew `--max-minutes`+row yet is fair game to both. Rule: never start a second `python -m bench.run_bench` on an out dir+with a live driver; wait for the driver to exit (exact pid, `kill -0`), then redo once with+`--redo-status infra_failed,error,budget --max-minutes 120`. `run_bench` grew `--max-minutes`the same day so the storm budget no longer needs `ab_plan`.### 7.x Size `--max-minutes` to the weatherdiff --git a/harness/tests/flywheel_cli/test_cli.py b/harness/tests/flywheel_cli/test_cli.pyindex 92eb7ba8..cef42b52 100644--- a/harness/tests/flywheel_cli/test_cli.py+++ b/harness/tests/flywheel_cli/test_cli.py@@ -8,7 +8,6 @@ from pathlib import Pathimport pytestfrom typer.testing import CliRunner-from codeverse3d.cli import _common as Cfrom codeverse3d.cli.main import appfrom codeverse3d.cli.main import make as make_cmdfrom codeverse3d.contracts.spec import Spec@@ -105,11 +104,6 @@ def test_tools_list_handles_an_optional_spatial_install():assert "Traceback" not in r.output-def test_a_missing_bench_module_is_a_clear_exit():- with pytest.raises(C.CliError):- C.import_bench("definitely_missing_module")--def test_doctor_json(monkeypatch):"""The CLI serialises doctor rows; the checks themselves are tested by install tests."""import codeverse3d.cli.doctor as doctor_cli