Official Codebase of 3DCodeVerse
Python
cleanup: D1+D2 — Retire flywheel/gallery.py; bench/report.py renders through codeverse/gallery
gaoypeng2b08794e374e
diff --git a/harness/bench/report.py b/harness/bench/report.pyindex bb7bef6c..42c4f938 100644--- a/harness/bench/report.py+++ b/harness/bench/report.py@@ -2,8 +2,9 @@``build_report(out_dir)`` reads ``results.jsonl`` (or results.json), aggregatesmean/median/pass-rate/cost per tier and category, writes ``report.md`` and-``report.html`` — the same self-contained gallery as ``3dcv flywheel gallery``-(``codeverse.flywheel.gallery``) with the stats tables above the cards.+``report.html`` — the same self-contained page as ``3dcv gallery build --embed``+(``codeverse.gallery``), one section per tier, with the stats tables under the+summary strip."""from __future__ import annotations@@ -17,8 +18,9 @@ from pydantic import BaseModel, Fieldfrom bench._jsonl import read_jsonlfrom bench.run_bench import BenchItemResult-from codeverse.flywheel.gallery import GalleryItem, item_from_run, render_galleryfrom codeverse.flywheel.record import RecordError, load_record+from codeverse.gallery import GalleryIndex, RootSection, RunEntry, render_static+from codeverse.gallery.index import entry_from_recordfrom codeverse.workspace import WorkspaceTIER_ORDER = {"easy": 0, "medium": 1, "hard": 2}@@ -111,26 +113,26 @@ def _md_table(title: str, stats: list[GroupStats]) -> str:return "\n".join(lines) + "\n"-def _item_for(r: BenchItemResult) -> GalleryItem:+def _entry_for(r: BenchItemResult) -> RunEntry:"""Gallery card for one bench result: the run record when the workspace has one,- else a card built from the result row alone (errors, never-started runs)."""+ else a card built from the result row alone (errors, never-started runs — a+ bare ``entry_for_dir`` would show those as pending/broken without the scores)."""ws_path = Path(r.workspace) if r.workspace else Noneif ws_path is not None and (ws_path / "record.json").is_file():try:- item = item_from_run(Workspace(ws_path), load_record(ws_path))+ entry = entry_from_record(r.tier, Workspace(ws_path), load_record(ws_path))except RecordError:- item = None- if item is not None:- item.key = r.id- item.group = f"{r.tier} · {r.category}" if r.category else r.tier- item.minutes = r.minutes or item.minutes- item.error = item.error or r.errors- return item- return GalleryItem(- key=r.id, title=r.id, group=f"{r.tier} · {r.category}" if r.category else r.tier,+ entry = None+ if entry is not None:+ entry.slug = r.id+ entry.minutes = r.minutes or entry.minutes+ entry.error = entry.error or r.errors+ return entry+ return RunEntry(+ battery=r.tier, slug=r.id, path=r.workspace or "", state="ok", title=r.id,generator=r.generator, judge=r.judge, score=r.score_final, baseline_score=r.score_baseline,passed=r.passed, rounds=r.rounds, cost_usd=r.cost_usd, minutes=r.minutes, status=r.status,- error=r.errors, links={"workspace": r.workspace} if r.workspace else {},+ error=r.errors,)@@ -175,5 +177,8 @@ def _html_gallery(out: Path, name: str, results: list[BenchItemResult], rep: Benstyle = "<style>table{border-collapse:collapse;margin:8px 0 12px}td,th{border:1px solid #444;padding:3px 10px;font-size:13px}</style>"tables = (style + "<h3>overall + by tier</h3>" + _html_table(([rep.overall] if rep.overall else []) + rep.by_tier)+ "<h3>by category</h3>" + _html_table(rep.by_category))- items = [_item_for(r) for r in results]- return render_gallery(items, f"bench — {name}", extra_html=tables)+ sections: dict[str, RootSection] = {}+ for r in results: # one section per tier (results are already tier-sorted)+ sections.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)diff --git a/harness/codeverse/flywheel/__init__.py b/harness/codeverse/flywheel/__init__.pyindex 33b5eb5e..55f9d005 100644--- a/harness/codeverse/flywheel/__init__.py+++ b/harness/codeverse/flywheel/__init__.py@@ -10,6 +10,5 @@ Public API (see docs/INTERFACES.md):* ``dedupe`` ``code_fingerprint`` · ``mesh_fingerprint`` · ``near_duplicates``* ``quality`` ``quality_tier`` (A/B/C/D) · ``prompt_hash`` · exact (code, prompt) duplicate groups* ``trajectories`` in-session repair pairs mined from api-agent transcripts-* ``gallery`` ``write_gallery(runs_dir, out_html)`` · ``render_gallery(items, title)`` (shared with bench/report.py)* ``index`` ``build_index(runs_dir, out_sqlite)`` + query helpers"""diff --git a/harness/codeverse/flywheel/gallery.py b/harness/codeverse/flywheel/gallery.pydeleted file mode 100644index 03a8317c..00000000--- a/harness/codeverse/flywheel/gallery.py+++ /dev/null@@ -1,235 +0,0 @@-"""Self-contained HTML gallery of runs: one card per run with the best round's-contact sheet (embedded thumbnail), score / cost / rounds / tier, prompt,-track · language · backend and ``file://`` links to the artifacts.--``render_gallery(items, title)`` is the shared renderer: ``3dcv flywheel gallery``-feeds it run records (``gallery_items``), ``bench/report.py`` feeds it bench-results. No external assets — images are base64 JPEG thumbnails, the filter /-sort controls are a few lines of inline JS.-"""--from __future__ import annotations--import base64-import html-import io-import statistics-from pathlib import Path--from pydantic import BaseModel, Field--from codeverse.contracts.run import RunRecord-from codeverse.flywheel.deliverable import load_deliverable-from codeverse.flywheel.quality import quality_tier-from codeverse.flywheel.record import effective_judgment, iter_runs-from codeverse.flywheel.sample import best_round_record, gate_error_summary, telemetry_digest-from codeverse.workspace import Workspace--THUMB_PX = 640-JPEG_QUALITY = 78---class GalleryItem(BaseModel):- key: str- title: str = ""- prompt: str = ""- track: str = ""- language: str = ""- generator: str = ""- judge: str = ""- score: float | None = None- baseline_score: float | None = None- passed: bool | None = None- quality_tier: str = "D"- gate_errors: int = 0- cost_usd: float = 0.0- rounds: int = 0- best_round: int | None = None- minutes: float | None = None- status: str = ""- error: str = ""- group: str = Field(default="", description="bench tier / category label shown on the card")- caption: str = Field(default="", description="instruction caption when available")- cost_by_stage: dict[str, float] = Field(default_factory=dict, description="stage → USD (telemetry, when present)")- models: dict[str, str] = Field(default_factory=dict, description="role → model id (telemetry, when present)")- sheet: str | None = Field(default=None, description="contact sheet path (best round)")- links: dict[str, str] = Field(default_factory=dict, description="label → absolute path")---def item_from_run(ws: Workspace, rec: RunRecord) -> GalleryItem:- rnd = best_round_record(rec)- j = effective_judgment(rnd) if rnd is not None else None # degraded → unjudged- gates = gate_error_summary(rnd)- n_err = sum(gates.values())- sheet = None- if rnd is not None and rnd.renders is not None and rnd.renders.contact_sheet:- p = Path(rnd.renders.contact_sheet)- p = p if p.is_absolute() else ws.root / p- sheet = str(p) if p.is_file() else None- if sheet is None and (ws.deliverable / "sheet.png").is_file():- sheet = str(ws.deliverable / "sheet.png") # new layout: the packaged best sheet- links = {"workspace": str(ws.root), "record.json": str(ws.record_path)}- if sheet:- links["sheet"] = sheet- deliverable = load_deliverable(ws, rec)- if deliverable is not None and ws.deliverable.is_dir():- links["deliverable/"] = str(ws.deliverable)- for name in ("object.glb", "robot.urdf", "object.stl"):- path = next((d / name for d in (ws.deliverable, ws.artifacts) if (d / name).is_file()), None)- if path is not None:- links[name] = str(path)- if (ws.root / "src").is_dir():- links["src/"] = str(ws.root / "src")- if ws.cost_path.is_file():- links["cost.json"] = str(ws.cost_path)- digest = telemetry_digest(ws, rec)- minutes = ((rec.finished_at - rec.started_at).total_seconds() / 60.0) if rec.finished_at else None- caps = rec.extra.get("captions") or {}- return GalleryItem(- key=ws.root.name,- title=(getattr(rec.plan, "object_name", "") or getattr(rec.plan, "title", "") or "") if rec.plan else "",- prompt=rec.spec.prompt, track=rec.spec.track.value, language=rec.spec.language.value,- generator=rec.spec.backends.generator, judge=rec.spec.backends.judge,- score=j.overall if j else rec.final_score, baseline_score=rec.baseline_score,- passed=j.passed if j else None,- quality_tier=quality_tier(passed=j.passed if j else None, gate_errors=n_err, score=j.overall if j else None),- gate_errors=n_err, cost_usd=rec.total_usage.cost_usd, rounds=len(rec.rounds), best_round=rec.best_round,- minutes=round(minutes, 1) if minutes is not None else None, status=rec.status.value, error=rec.error,- caption=str(caps.get("instruction", "") or ""),- cost_by_stage={k: round(v, 4) for k, v in (digest.get("by_stage") or {}).items()},- models=dict(digest.get("models") or {}),- sheet=sheet, links=links,- )---def gallery_items(runs_dir: Path | str) -> list[GalleryItem]:- items: list[GalleryItem] = []- for ws, rec in iter_runs(runs_dir, on_error=lambda d, e: items.append(- GalleryItem(key=d.name, status="invalid", error=str(e), links={"workspace": str(d)}))):- items.append(item_from_run(ws, rec))- return items---# --------------------------------------------------------------------------- rendering-def thumbnail_data_uri(path: Path | str, *, max_px: int = THUMB_PX) -> str:- """Downscaled JPEG as a ``data:`` URI (``""`` when the image cannot be read)."""- try:- from PIL import Image-- with Image.open(path) as im:- im = im.convert("RGB")- im.thumbnail((max_px, max_px))- buf = io.BytesIO()- im.save(buf, format="JPEG", quality=JPEG_QUALITY, optimize=True)- except Exception: # missing PIL, unreadable file, …- return ""- return "data:image/jpeg;base64," + base64.b64encode(buf.getvalue()).decode()---def _fmt(v: float | None, spec: str = ".3f") -> str:- return "-" if v is None else format(v, spec)---def _file_href(path: str) -> str:- p = Path(path)- return p.as_uri() if p.is_absolute() else html.escape(path)---def _card(it: GalleryItem, *, thumb_px: int) -> str:- img = thumbnail_data_uri(it.sheet, max_px=thumb_px) if it.sheet else ""- pic = f'<a href="{_file_href(it.sheet)}"><img src="{img}" alt="contact sheet" loading="lazy"></a>' if img else \- '<div class="noimg">no render</div>'- badge = "pass" if it.passed else ("fail" if it.passed is False else "na")- links = " · ".join(f'<a href="{_file_href(p)}">{html.escape(n)}</a>' for n, p in it.links.items())- head = html.escape(it.title or it.key)- grp = f' · <span class="grp">{html.escape(it.group)}</span>' if it.group else ""- err = f'<div class="err">{html.escape(it.error[:300])}</div>' if it.error else ""- cap = f'<div class="cap">{html.escape(it.caption)}</div>' if it.caption else ""- mins = f" · {it.minutes:.1f} min" if it.minutes is not None else ""- stage_costs = " · ".join(f"{html.escape(k)} ${v:.3f}"- for k, v in sorted(it.cost_by_stage.items(), key=lambda kv: -kv[1]))- stages = f'<div class="kv">cost: {stage_costs}</div>' if stage_costs else ""- return (- f'<div class="card {badge}" data-track="{html.escape(it.track)}" data-tier="{it.quality_tier}" '- f'data-score="{it.score if it.score is not None else -1}" data-cost="{it.cost_usd}" data-key="{html.escape(it.key)}">'- f'{pic}<div class="meta">'- f'<div class="row1"><b>{head}</b> <span class="tier t{it.quality_tier}">{it.quality_tier}</span>'- f'<span class="score">{_fmt(it.score)}</span></div>'- f'<div class="prompt">{html.escape(it.prompt)}</div>{cap}'- f'<div class="kv">{html.escape(it.track)} · {html.escape(it.language)} · {html.escape(it.generator)}{grp}</div>'- f'<div class="kv">baseline {_fmt(it.baseline_score)} → best {_fmt(it.score)} (r{it.best_round if it.best_round is not None else "-"}) · '- f'rounds {it.rounds} · gate err {it.gate_errors} · ${it.cost_usd:.2f}{mins} · {html.escape(it.status)}</div>'- f'{stages}{err}<div class="links">{links}</div></div></div>'- )---def _summary(items: list[GalleryItem]) -> str:- scored = [i.score for i in items if i.score is not None]- judged = [i.passed for i in items if i.passed is not None]- tiers = {t: sum(1 for i in items if i.quality_tier == t) for t in "ABCD"}- parts = [- f"{len(items)} runs",- f"pass {sum(judged)}/{len(judged)}" if judged else "pass -",- f"mean score {statistics.fmean(scored):.3f}" if scored else "mean score -",- f"total ${sum(i.cost_usd for i in items):.2f}",- "tiers " + " ".join(f"{t}:{n}" for t, n in tiers.items()),- ]- return " · ".join(html.escape(p) for p in parts)---_STYLE = """-body{font-family:system-ui,sans-serif;margin:20px;background:#111;color:#eee}-h1{font-size:20px;margin:0 0 6px}.sum{color:#bbb;margin-bottom:10px}-.ctl{margin:8px 0 14px;display:flex;gap:10px;flex-wrap:wrap;align-items:center;font-size:13px}-.ctl select,.ctl input{background:#222;color:#eee;border:1px solid #444;padding:3px 6px;border-radius:4px}-.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(380px,1fr));gap:14px}-.card{background:#1c1c1c;border-radius:8px;overflow:hidden;border:2px solid #333;display:flex;flex-direction:column}-.card.pass{border-color:#2e7d32}.card.fail{border-color:#8a1c1c}.card img{width:100%;max-height:420px;object-fit:contain;display:block;background:#fff}-.noimg{height:160px;display:flex;align-items:center;justify-content:center;color:#777}-.meta{padding:8px 10px;font-size:13px;line-height:1.4}.row1{display:flex;gap:8px;align-items:center}-.score{margin-left:auto;font-weight:600;font-size:15px}.tier{padding:0 6px;border-radius:4px;font-weight:700;font-size:12px}-.tA{background:#2e7d32}.tB{background:#558b2f}.tC{background:#b07a00}.tD{background:#8a1c1c}-.prompt{color:#ddd;margin:4px 0}.cap{color:#9bd;font-style:italic;margin:2px 0 4px}.kv{color:#aaa}.grp{color:#cba}-.err{color:#f88;white-space:pre-wrap;margin-top:4px}.links{margin-top:6px}.links a{color:#8cf;margin-right:4px}-.hidden{display:none}-"""--_SCRIPT = """-function apply(){const t=document.getElementById('ftrack').value,q=document.getElementById('ftier').value,-s=document.getElementById('sort').value,g=document.getElementById('grid'),cards=[...g.children];-cards.forEach(c=>{const ok=(t===''||c.dataset.track===t)&&(q===''||c.dataset.tier===q);c.classList.toggle('hidden',!ok);});-const key={score:c=>-parseFloat(c.dataset.score),cost:c=>-parseFloat(c.dataset.cost),key:c=>c.dataset.key,-tier:c=>c.dataset.tier+(1-parseFloat(c.dataset.score))}[s];-cards.sort((a,b)=>{const x=key(a),y=key(b);return x<y?-1:x>y?1:0}).forEach(c=>g.appendChild(c));}-document.querySelectorAll('#ftrack,#ftier,#sort').forEach(e=>e.addEventListener('change',apply));-"""---def render_gallery(items: list[GalleryItem], title: str, *, thumb_px: int = THUMB_PX, extra_html: str = "") -> str:- """Complete HTML document (images embedded) for ``items``. ``extra_html`` is- inserted above the grid (bench report tables, for example)."""- tracks = sorted({i.track for i in items if i.track})- opts = "".join(f'<option value="{html.escape(t)}">{html.escape(t)}</option>' for t in tracks)- cards = "".join(_card(it, thumb_px=thumb_px) for it in items)- return (- f"<!doctype html><html><head><meta charset='utf-8'><title>{html.escape(title)}</title>"- f"<style>{_STYLE}</style></head><body><h1>{html.escape(title)}</h1>"- f"<div class='sum'>{_summary(items)}</div>{extra_html}"- f"<div class='ctl'>track <select id='ftrack'><option value=''>all</option>{opts}</select>"- f"tier <select id='ftier'><option value=''>all</option>"- + "".join(f"<option>{t}</option>" for t in "ABCD")- + "</select>sort <select id='sort'><option value='score'>score</option><option value='tier'>tier</option>"- f"<option value='cost'>cost</option><option value='key'>name</option></select></div>"- f"<div class='grid' id='grid'>{cards}</div><script>{_SCRIPT}</script></body></html>"- )---def write_gallery(runs_dir: Path | str, out_html: Path | str, *, title: str | None = None,- thumb_px: int = THUMB_PX) -> tuple[Path, int]:- """Render every run under ``runs_dir`` into ``out_html``; returns (path, n_items)."""- items = gallery_items(runs_dir)- items.sort(key=lambda i: (-(i.score if i.score is not None else -1.0), i.key))- out = Path(out_html)- out.parent.mkdir(parents=True, exist_ok=True)- out.write_text(render_gallery(items, title or f"3dcv gallery — {Path(runs_dir).name}", thumb_px=thumb_px))- return out, len(items)diff --git a/harness/codeverse/gallery/page.py b/harness/codeverse/gallery/page.pyindex a0b82b81..d4cb3de9 100644--- a/harness/codeverse/gallery/page.py+++ b/harness/codeverse/gallery/page.py@@ -148,8 +148,9 @@ def _section(label: str, path: str, entries: list[RunEntry], hidden: set[str], udef render_index(index: GalleryIndex, urls: UrlMaker, *, title: str = "3dcv gallery",flt: dict[str, str] | None = None, sort: str = "score", view: str = "cards",- note: str = "") -> str:- """The whole index page as one HTML document."""+ note: str = "", extra_html: str = "") -> str:+ """The whole index page as one HTML document. ``extra_html`` (already+ escaped markup, e.g. bench/report.py's stats tables) goes under the summary strip."""flt = {k: (flt or {}).get(k, "") for k in FILTER_KEYS}all_entries = index.entries()selected = [e for e in all_entries if match(e, flt)]@@ -169,6 +170,7 @@ def render_index(index: GalleryIndex, urls: UrlMaker, *, title: str = "3dcv gall+ "<main class='wrap'>"+ (f"<p class='small muted'>{esc(note)}</p>" if note else "")+ _summary_strip(selected, len(all_entries))+ + extra_html+ _controls(index, flt, sort)+ sections + empty + "</main>"+ (_bulk_bar() if urls.has_detail else "")diff --git a/harness/codeverse/gallery/static_site.py b/harness/codeverse/gallery/static_site.pyindex 4fe75691..a8c54550 100644--- a/harness/codeverse/gallery/static_site.py+++ b/harness/codeverse/gallery/static_site.py@@ -20,13 +20,14 @@ from codeverse.proc import write_text_atomicdef render_static(index: GalleryIndex, *, title: str = "3dcv gallery", embed: bool = False,- thumb_px: int = THUMB_PX, sort: str = "score", view: str = "cards") -> str:+ thumb_px: int = THUMB_PX, sort: str = "score", view: str = "cards",+ extra_html: str = "") -> str:"""The complete HTML document for ``index`` (no server involved)."""note = ("images are inlined; the links open the original run directories on this machine"if embed else "images and links point at the run directories with file:// — ""use `3dcv gallery serve` for a page that works anywhere")return render_index(index, StaticUrls(embed=embed, thumb_px=thumb_px),- title=title, sort=sort, view=view, note=note)+ title=title, sort=sort, view=view, note=note, extra_html=extra_html)def write_atomic(path: Path, text: str) -> Path:diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex 47c9157e..20d9ba98 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -169,8 +169,7 @@ codeverse/probe reads after — a no-op unless CV3D_SKILLS is on)flywheel/ record.py, export.py, pack.py, sample.py, pairs.py, migrate.py (schema moves),deliverable.py, telemetry.py, trajectories.py (repair-pair- mining), captions.py, quality.py (tiers + dedupe), gallery.py (the shared- self-contained renderer bench/report.py reuses), dedupe.py, index.py,+ mining), captions.py, quality.py (tiers + dedupe), dedupe.py, index.py,code_quality.py (the delivered CODE's own vector — magic numbers per 100 LOC,function length, dead functions, duplication, docstrings → record.extra["code_quality"].index, a flywheel filter beside score and complexity)@@ -187,7 +186,7 @@ codeverse/texture_cmd.py, cost_cmd.py (`3dcv cost`), layout_cmd.py, doctor.py(`--skills` checks the library + its discovery wiring),skills_cmd.py (`3dcv skills list|show|validate|report` — the read-rate report)-bench/ run_bench.py, report.py (reuses flywheel gallery), compare_backends.py+bench/ run_bench.py, report.py (renders through codeverse/gallery), compare_backends.py(preflights every model it needs; --wait-for-provider / --no-preflight),_infra.py (outage vs model failure: infra_failed / budget_exhausted, docs/EVAL.md §7),ab_plan.py (the paired control/variant A/B rig, --aa calibration mode),@@ -442,8 +441,8 @@ errors, cost, fingerprints, `duplicate_of`; `--pack` tars with byte-range locatorepair pairs and **in-session repair pairs mined from api-agent transcripts**(replay-verified against the git snapshots); `flywheel caption` adds{detailed, instruction, factory} captions (image-grounded, brand-free, `--out` for-side-car mode); `flywheel gallery` renders a self-contained HTML gallery (tier-badges, thumbnails, filter/sort) that `bench/report.py` reuses.+side-car mode); `flywheel gallery` is an alias of `3dcv gallery build --embed`+(the flywheel package has no renderer of its own).`codeverse/gallery/` is the **local** answer to the same question: `3dcv galleryserve` indexes `runs/` + every `bench/out/*/runs`, serves the page **and the rundiff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.mdindex 4378df82..4e0dc497 100644--- a/harness/docs/INTERFACES.md+++ b/harness/docs/INTERFACES.md@@ -401,11 +401,10 @@ from codeverse.flywheel.pairs import build_pairs # (runs_dir, out_jsonl, *from codeverse.flywheel.trajectories import mine_run # in-session repair pairs from api-agent transcripts (replay-verified)from codeverse.flywheel.captions import caption_sample # Δ (ws, record, model_id, *, model=None, out_dir=None) -> Captions;# out_dir → side-car <out_dir>/<slug>.json, run untouched-from codeverse.flywheel.gallery import write_gallery, gallery_items, render_gallery # self-contained HTML gallery (tier badges,- # thumbs); bench/report.py reuses itfrom codeverse.gallery import build_index, default_roots, build_static, serve, GalleryApp # THE local gallery# build_index(roots) -> GalleryIndex (sections of RunEntry; never raises per run)# build_static(roots, out_html, *, embed=False) -> (path, n, index)+ # render_static(index, *, embed=…, extra_html="") — bench/report.py's page# GalleryApp(roots, reload=False).route(path, query) -> Response (pure, testable)# serve(roots, *, host=None, host_explicit=False, port=8765, reload=False)from codeverse.gallery.paths import safe_join # (root, rel) -> Path inside root, else PathErrordiff --git a/harness/docs/RUN_LAYOUT.md b/harness/docs/RUN_LAYOUT.mdindex 22bec101..8e895c5f 100644--- a/harness/docs/RUN_LAYOUT.md+++ b/harness/docs/RUN_LAYOUT.md@@ -170,6 +170,7 @@ runs) get the layout only.* `flywheel export` reads the packaged code snapshot only when git cannot answer(`meta.code_source == "deliverable"`), and adds a compact `meta.telemetry`digest when the run has one (`{}` otherwise).-* `flywheel gallery` links `deliverable/` and `cost.json` when they exist and- falls back to `artifacts/` otherwise; the per-stage cost line appears only for- runs that carry telemetry.+* the gallery (`3dcv gallery build` / `flywheel gallery`) links the packaged+ `deliverable/object.glb` and `cost.json` when they exist and falls back to+ `artifacts/` otherwise; the per-stage cost line appears only for runs that+ carry telemetry.diff --git a/harness/tests/flywheel_cli/test_bench.py b/harness/tests/flywheel_cli/test_bench.pyindex a38b2ecc..544490c6 100644--- a/harness/tests/flywheel_cli/test_bench.py+++ b/harness/tests/flywheel_cli/test_bench.py@@ -83,6 +83,9 @@ def test_run_battery_resume_and_report(tmp_path: Path):page = (out / "report.html").read_text()assert "data:image/jpeg;base64," in page and "furn_easy_stool" in page # self-contained galleryassert "veh_easy_toy_car" in page and "boom" in page # errored prompt still gets a card+ # pin (REVIEW_2026-08-26 D1+D2): the stats tables sit in the page and every card carries its tier+ assert "<table>" in page and "by category" in page and page.count("<h3>") == 2+ assert page.count("easy") >= 2 and "<title>bench — " in pagedef test_every_bench_prompt_opens_its_own_run_ledger(tmp_path: Path):diff --git a/harness/tests/flywheel_cli/test_quality_gallery.py b/harness/tests/flywheel_cli/test_quality_gallery.pyindex eb1bd288..59705efb 100644--- a/harness/tests/flywheel_cli/test_quality_gallery.py+++ b/harness/tests/flywheel_cli/test_quality_gallery.py@@ -8,11 +8,18 @@ from pathlib import Pathfrom codeverse.contracts.common import Languagefrom codeverse.flywheel.captions import caption_samplefrom codeverse.flywheel.export import export_samples, load_captions-from codeverse.flywheel.gallery import GalleryItem, gallery_items, render_gallery, write_galleryfrom codeverse.flywheel.pairs import build_pairsfrom codeverse.flywheel.quality import find_duplicates, mark_duplicates, prompt_hash, quality_tierfrom codeverse.flywheel.record import load_recordfrom codeverse.flywheel.trajectories import mine_run, parse_trajectory_name+from codeverse.gallery import (+ GalleryIndex,+ RootSection,+ RunEntry,+ build_index,+ build_static,+ render_static,+)from codeverse.workspace import Workspacefrom tests.flywheel_cli.conftest import make_fake_runfrom tests.flywheel_cli.test_captions import GOOD, FakeModel@@ -126,17 +133,21 @@ def test_caption_out_dir_leaves_run_untouched(fake_run, tmp_path: Path):def test_gallery_from_runs(runs_dir: Path, tmp_path: Path):- items = gallery_items(runs_dir)- assert {i.key for i in items} == {"wooden_chair_ab12cd34", "wooden_chair_codex", "lamp_three"}- chair = next(i for i in items if i.key == "wooden_chair_ab12cd34")- assert chair.score == 0.80 and chair.passed is True and chair.quality_tier == "A" and chair.sheet- assert "object.glb" in chair.links and "record.json" in chair.links- path, n = write_gallery(runs_dir, tmp_path / "g" / "gallery.html")+ items = build_index([runs_dir]).entries()+ assert {i.slug for i in items} == {"wooden_chair_ab12cd34", "wooden_chair_codex", "lamp_three"}+ chair = next(i for i in items if i.slug == "wooden_chair_ab12cd34")+ assert chair.score == 0.80 and chair.passed is True and chair.tier == "A" and chair.sheet+ labels = {ln.label for ln in chair.links}+ assert "glb" in labels and "record.json" in labels+ path, n, _ = build_static([runs_dir], tmp_path / "g" / "gallery.html", embed=True)page = path.read_text()- assert n == 3 and page.count("data:image/jpeg;base64,") == 3+ assert n == 3 and page.count("data:image/jpeg;base64,") >= 3assert "a desk lamp" in page and "wooden_chair_codex" in page and "file://" in page- # items without renders or records still render- html = render_gallery([GalleryItem(key="x", error="boom <b>")], "t")+ # entries without renders or records still render+ section = RootSection(label="t", path="", entries=[+ RunEntry(battery="t", slug="x", path=""),+ RunEntry(battery="t", slug="y", path="", state="broken", error="boom <b>")])+ html = render_static(GalleryIndex(sections=[section]), title="t")assert "no render" in html and "boom <b>" in htmldiff --git a/harness/tests/flywheel_cli/test_run_layout_cli.py b/harness/tests/flywheel_cli/test_run_layout_cli.pyindex 045fa7d5..89a95374 100644--- a/harness/tests/flywheel_cli/test_run_layout_cli.py+++ b/harness/tests/flywheel_cli/test_run_layout_cli.py@@ -13,7 +13,6 @@ from codeverse.cli.main import appfrom codeverse.contracts.run import RunRecordfrom codeverse.flywheel.deliverable import build_deliverable, deliverable_path, load_deliverablefrom codeverse.flywheel.export import export_samples-from codeverse.flywheel.gallery import item_from_run, write_galleryfrom codeverse.flywheel.migrate import MIGRATED, UP_TO_DATE, migrate_run, migrate_runsfrom codeverse.flywheel.record import load_record, package_runfrom codeverse.flywheel.telemetry import (@@ -23,6 +22,8 @@ from codeverse.flywheel.telemetry import (load_telemetry,stage_order,)+from codeverse.gallery import build_static+from codeverse.gallery.index import entry_from_recordfrom codeverse.workspace import LAYOUT_ALIASES, Workspacefrom .conftest import make_fake_run@@ -254,14 +255,15 @@ def test_export_and_gallery_on_both_layouts(tmp_path: Path):assert meta["code_source"] == "commit" and "renders/sheet.png" in meta["renders"]out_html = tmp_path / "g.html"- path, n = write_gallery(runs, out_html)+ path, n, _ = build_static([runs], out_html)assert n == 2 and "deliverable" in path.read_text()- new_item = item_from_run(ws_new, load_record(ws_new))- old_item = item_from_run(ws_old, load_record(ws_old))+ new_item = entry_from_record("runs", ws_new, load_record(ws_new))+ old_item = entry_from_record("runs", ws_old, load_record(ws_old))assert new_item.cost_by_stage == {} or isinstance(new_item.cost_by_stage, dict)- assert "deliverable/" in new_item.links and "deliverable/" not in old_item.links- assert old_item.links["object.glb"].endswith("artifacts/object.glb")- assert new_item.links["object.glb"].endswith("deliverable/object.glb")+ new_links = {ln.label: ln.rel for ln in new_item.links}+ old_links = {ln.label: ln.rel for ln in old_item.links}+ assert old_links["glb"] == "artifacts/object.glb"+ assert new_links["glb"] == "deliverable/object.glb"def test_export_falls_back_to_the_packaged_snapshot_without_git(tmp_path: Path):