Official Codebase of 3DCodeVerse
Python
judges: one judge_for picks the judge class for the live run and every replay (B2)
gaoypengd8ab6b2ae1b0
diff --git a/harness/codeverse3d/addons/calibration.py b/harness/codeverse3d/addons/calibration.pyindex 958190cf..fcd8e155 100644--- a/harness/codeverse3d/addons/calibration.py+++ b/harness/codeverse3d/addons/calibration.py@@ -274,8 +274,8 @@ def calibrate(want = geometry_mode and c.is_picked and c.inp.geometry_views is Nonegeometry[i] = render_geometry_views(c, out, geometry_mode) if want else None- def kind(c: RoundCase) -> tuple[str, bool]: # what make_judge's choice of class depends on- return c.rubric, bool(c.inp.spec.references)+ def kind(c: RoundCase) -> tuple[str, str, bool]: # what make_judge's choice of class depends on+ return c.rubric, c.inp.spec.track.value, bool(c.inp.spec.references)judges = {kind(c): make_judge(c.inp.spec, c.rubric, model_id, n_samples, thinking=thinking,cache_dir=out / "cache", label="calibrate", chat_model=chat_model,diff --git a/harness/codeverse3d/cli/_judge.py b/harness/codeverse3d/cli/_judge.pyindex a23ea4e8..4ccf741c 100644--- a/harness/codeverse3d/cli/_judge.py+++ b/harness/codeverse3d/cli/_judge.py@@ -6,9 +6,8 @@ disk: the round's renders / measurement / gates from ``rounds/rNN.json`` (fallbaround inside record.json), the typed plan from record.json (else ``plan.json``), ``previous``the preceding round's (non-degraded) verdict, the track's ``extra_context`` rebuilt from thestored gates / frame metrics, and the clay geometry views rendered for the in-run judge-(``renders/rNN/clay/``) reattached when present. The judge class matches the in-run choice:-``ReferenceJudge`` when the rubric has measured criteria or the spec carries reference-images, ``VlmJudge`` otherwise.+(``renders/rNN/clay/``) reattached when present. The judge class is the in-run one:+``judges.vlm_judge.judge_for``, the rule the live run uses."""from __future__ import annotations@@ -118,8 +117,8 @@ def stored_glb_path(ws: Workspace, rnd: RoundRecord) -> str | None:def make_judge(spec: Spec, rubric_name: str, model_id: str, n: int, **options: Any) -> Any:- """ReferenceJudge for measured rubrics / reference specs, VlmJudge otherwise; ``options``- go to the judge (calibration's cache dir, thinking level, fixed order)."""+ """The class the live run would use (``vlm_judge.judge_for``); ``options`` go to the+ judge (calibration's cache dir, thinking level, fixed order)."""from codeverse3d.judges import vlm_judgefrom codeverse3d.judges.rubrics import load_rubric@@ -127,9 +126,8 @@ def make_judge(spec: Spec, rubric_name: str, model_id: str, n: int, **options: Arubric = load_rubric(rubric_name)except Exception as e: # unknown rubric name / bad yamlraise C.CliError(f"cannot load rubric {rubric_name!r}: {e}") from e- if rubric.measured_criteria() or spec.references:- return vlm_judge.ReferenceJudge(model_id=model_id, n_samples=n, rubric=rubric_name, **options)- return vlm_judge.VlmJudge(rubric=rubric_name, model_id=model_id, n_samples=n, **options)+ cls = vlm_judge.judge_for(spec.track, rubric, references=bool(spec.references))+ return cls(model_id=model_id, n_samples=n, rubric=rubric_name, **options)def count_prompt_images(inp: Any, rubric_name: str, judge: Any = None) -> int | None:diff --git a/harness/codeverse3d/judges/vlm_judge.py b/harness/codeverse3d/judges/vlm_judge.pyindex 1e891414..ce32c9c6 100644--- a/harness/codeverse3d/judges/vlm_judge.py+++ b/harness/codeverse3d/judges/vlm_judge.py@@ -29,7 +29,7 @@ from typing import Any, Literalfrom codeverse3d.config import get_settingsfrom codeverse3d.contracts.artifacts import Judgment, RenderViewfrom codeverse3d.contracts.chat import ChatRequest, ChatResponse-from codeverse3d.contracts.common import Usage+from codeverse3d.contracts.common import Track, Usagefrom codeverse3d.conventions import front_viewfrom codeverse3d.judges.base import SLICE_TRACKS, JudgeInputfrom codeverse3d.judges.prompt_builder import (@@ -580,3 +580,16 @@ class LikenessJudge(VlmJudge):class ReferenceJudgeError(RuntimeError):"""The reference judge cannot compute its measured criteria."""+++def judge_for(track: Track, rubric: str | Rubric, *, references: bool) -> type[VlmJudge]:+ """The judge class that scores a round: ONE rule for the live run (``BaseTrack.make_judge``)+ and every replay (``3dcode judge``, calibration), so a replay is judged as the run was.++ A rubric with measured criteria needs :class:`ReferenceJudge`, the judge that computes+ them; reference photos get :class:`LikenessJudge` on graphics and scene (nothing there to+ silhouette-match) and :class:`ReferenceJudge` on the object tracks; else :class:`VlmJudge`."""+ rub = rubric if isinstance(rubric, Rubric) else load_rubric(rubric)+ if rub.measured_criteria() or (references and track not in (Track.GRAPHICS, Track.SCENE)):+ return ReferenceJudge+ return LikenessJudge if references else VlmJudgediff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.pyindex 2870881b..d384e8b1 100644--- a/harness/codeverse3d/tracks/lifecycle.py+++ b/harness/codeverse3d/tracks/lifecycle.py@@ -382,13 +382,17 @@ class BaseTrack:return max(1, int(n or 1))def make_judge(self, ctx: RunContext, *, n_samples: int | None = None) -> Any:- """The main judge: injected → reference / likeness judge when the spec has images → rubric VLM judge."""+ """The main judge: injected, else the class ``judges.vlm_judge.judge_for`` names (the rule+ ``3dcode judge`` and calibration replay with), built through the services seam."""if self._judge is not None:return self._judge+ from codeverse3d.judges.vlm_judge import LikenessJudge, ReferenceJudge, judge_for+n_samples = ctx.policy.judge_samples if n_samples is None else n_samples- if ctx.spec.references:- if ctx.track in (Track.GRAPHICS, Track.SCENE): # nothing to silhouette-match: likeness only- return self.services.likeness_judge(ctx.spec.backends.judge, n_samples=n_samples, rubric=ctx.rubric)+ cls = judge_for(ctx.track, ctx.rubric, references=bool(ctx.spec.references))+ if cls is LikenessJudge:+ return self.services.likeness_judge(ctx.spec.backends.judge, n_samples=n_samples, rubric=ctx.rubric)+ if cls is ReferenceJudge:return self.services.reference_judge(ctx.spec.backends.judge, n_samples=n_samples, rubric=ctx.rubric)return self.services.judge(ctx.rubric, ctx.spec.backends.judge, n_samples=n_samples)diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.mdindex 4e9d6849..de38107f 100644--- a/harness/docs/INTERFACES.md+++ b/harness/docs/INTERFACES.md@@ -442,6 +442,9 @@ from codeverse3d.judges.pairwise import PairwiseJudge # .compare(spec, renderfrom codeverse3d.addons.calibration import calibrate, CalibrationTable # (run_dirs, *, model_id, n_samples=3, out_dir, geometry_mode,# rounds, …) -> rows + pearson/spearman(errors vs score), mean_std, cost; CLI: python -m codeverse3d.addons.calibration RUN… --n 3from codeverse3d.judges.vlm_judge import ReferenceJudge # image-conditioned specs+from codeverse3d.judges.vlm_judge import judge_for # (track, rubric, *, references) -> type[VlmJudge]: the ONE class rule+ # for the live run (BaseTrack.make_judge) and every replay (3dcode judge, calibration): measured rubric or photos on an+ # object track -> ReferenceJudge, photos on graphics/scene -> LikenessJudge, else VlmJudge```Rubrics: `static_object_v1` (0.72), `articulated_v1` (requires pose views via`missing_pose_sheet` cap), `scene_v1` (frame-gate caps dark/blown/flat/content_small),@@ -572,8 +575,8 @@ post-render gates → the build's own `BuildResult.gates` (also when the build f(when references), articulated `joint_sweep` + `motion_direction`, scene`render_console` + `scene_frames` (via `ctx.services.frame_gate` ->`frame_gate_from_renders`; advisory, a failure is logged not raised), graphics `gl_frames`. Reference specs get a-`ReferenceJudge` (rubric `reference_v1` for static_object) and images attached to-generation prompts.+`ReferenceJudge` (rubric `reference_v1` for static_object; `LikenessJudge` on graphics/scene —+`vlm_judge.judge_for`) and images attached to generation prompts.## texturing/ (derived asset pack; code stays truth — object.glb is never touched)```pythondiff --git a/harness/tests/orchestrator_tracks/test_likeness_routing.py b/harness/tests/orchestrator_tracks/test_likeness_routing.pyindex 102239c9..64a050e4 100644--- a/harness/tests/orchestrator_tracks/test_likeness_routing.py+++ b/harness/tests/orchestrator_tracks/test_likeness_routing.py@@ -41,3 +41,18 @@ def test_make_judge_routes_photos_to_the_likeness_judge():assert BaseTrack.make_judge(me, _ctx(Track.STATIC_OBJECT, ["/x.png"])) == "R"assert BaseTrack.make_judge(me, _ctx(Track.GRAPHICS, [])) == "P"assert calls[0] == ("likeness", "shader_v1")+++def test_a_replay_picks_the_judge_the_live_run_did():+ """`3dcode judge` / calibration and the live run share `judge_for`: a graphics or scene run+ with photos was re-judged by ReferenceJudge (silhouette + diff pass) where the run used likeness."""+ from codeverse3d.cli._judge import make_judge+ from codeverse3d.judges.vlm_judge import LikenessJudge, ReferenceJudge, VlmJudge, judge_for++ assert judge_for(Track.GRAPHICS, "shader_v2", references=True) is LikenessJudge+ assert judge_for(Track.SCENE, "scene_v1", references=True) is LikenessJudge+ assert judge_for(Track.STATIC_OBJECT, "reference_v1", references=True) is ReferenceJudge+ assert judge_for(Track.STATIC_OBJECT, "reference_v1", references=False) is ReferenceJudge # measured criteria+ assert judge_for(Track.GRAPHICS, "shader_v2", references=False) is VlmJudge+ spec = SimpleNamespace(track=Track.GRAPHICS, references=[ReferenceImage(path="/x.png", role="likeness", note="")])+ assert type(make_judge(spec, "shader_v2", "gemini:pro", 1)) is LikenessJudge