Skip to content

Official Codebase of 3DCodeVerse

Python

judges: the reference diff takes the plan's part names from JudgeInput.part_names — the regex over plan_summary dropped the last part of every articulated plan (bug fix, re-blessed)

gaoypengfb258242010a
diff --git a/harness/codeverse3d/judges/base.py b/harness/codeverse3d/judges/base.py
index c77f723b..6b985688 100644
--- a/harness/codeverse3d/judges/base.py
+++ b/harness/codeverse3d/judges/base.py
@@ -33,6 +33,7 @@ class JudgeInput(BaseModel):
gates: list[GateReport] = Field(default_factory=list)
acceptance: list[AcceptanceItem] = Field(default_factory=list)
plan_summary: str = Field(default="", description="short plan digest (parts/zones/joints) for grounding")
+ part_names: list[str] = Field(default_factory=list, description="an object plan's part names (the reference diff)")
round_index: int = 0
previous: Judgment | None = Field(default=None, description="last verdict (for delta framing)")
extra_context: str = ""
@@ -80,6 +81,7 @@ def round_input(spec: Spec, plan: Plan | None, rnd: RoundRecord, *, renders: Ren
return JudgeInput(
spec=spec, renders=renders, measurement=rnd.measurement, gates=list(gates),
acceptance=list(getattr(plan, "acceptance", None) or []), plan_summary=plan_summary(plan, spec.language),
+ part_names=[p.name for p in plan.parts] if isinstance(plan, StaticPlan) else [],
round_index=rnd.index, previous=previous, extra_context=extra_context, geometry_views=geometry_views,
# D48: the round's canonical GLB feeds the conditional slice channel (object tracks only)
glb_path=glb_path if spec.track.value in SLICE_TRACKS else None,
diff --git a/harness/codeverse3d/judges/vlm_judge.py b/harness/codeverse3d/judges/vlm_judge.py
index 3dde046c..7353b58c 100644
--- a/harness/codeverse3d/judges/vlm_judge.py
+++ b/harness/codeverse3d/judges/vlm_judge.py
@@ -19,7 +19,6 @@ from __future__ import annotations
import contextlib
import logging
-import re
import shutil
import time
from collections.abc import Callable
@@ -471,7 +470,7 @@ class ReferenceJudge(VlmJudge):
measured.setdefault("view", info.get("render", ""))
try:
return compare(inp.spec, targets, renders, model=self._pick_diff_model(),
- part_names=_plan_part_names(inp), measured=measured, synthesized=synthesized)
+ part_names=inp.part_names, measured=measured, synthesized=synthesized)
except Exception as e: # noqa: BLE001 — an advisory pass must never fail a verdict
log.warning("reference diff pass failed: %s", e)
return None
@@ -545,31 +544,6 @@ class ReferenceJudge(VlmJudge):
return self.silhouette_fn(view.path, reference), view.name
-def _plan_part_names(inp: JudgeInput) -> list[str]:
- """Part names from the plan digest the judge already receives (best effort).
-
- ``judges.base.plan_summary`` writes them as one ``Parts: A, B×2, C`` segment;
- a multi-line digest lists one ``- Name · role · …`` per line. Both are handled, and
- an unrecognised digest simply yields no names (the diff prompt then says so).
- """
- text = getattr(inp, "plan_summary", "") or ""
- names: list[str] = []
- for chunk in re.split(r"(?i)\bparts\s*:", text)[1:]:
- for raw in chunk.split("\n")[0].split(","):
- names.append(raw.split("\u00d7")[0].split("(")[0].strip().rstrip("."))
- for line in text.splitlines():
- line = line.strip()
- if not line.startswith(("-", "*", "\u00b7")):
- continue
- head = line.lstrip("-*\u00b7 ").split("\u00b7")[0].split("(")[0].split(":")[0].strip()
- names.append(head)
- seen: list[str] = []
- for n in names:
- if n and " " not in n and 2 < len(n) <= 40 and n[:1].isupper() and n not in seen:
- seen.append(n)
- return seen[:40]
-
-
LIKENESS_NOTE = (
"REAL-WORLD REFERENCE PHOTOS are attached (labelled REAL-WORLD REFERENCE n/N). They are not a "
"composition to copy; they are what the thing the brief names ACTUALLY looks like. Score "
diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.md
index fd8107a3..edcfe486 100644
--- a/harness/docs/INTERFACES.md
+++ b/harness/docs/INTERFACES.md
@@ -402,12 +402,13 @@ VlmJudge.slice_payload(inp) -> (list[(label, png_path)], provenance_elicitation:
# Settings.judge.slices=="on-error" AND spec.track in judges.base.SLICE_TRACKS AND inp.glb_path exists AND the
# connectivity gate has ≥1 ERROR; renders judge_slices into the judge cache (keyed by glb identity + error pairs)
from codeverse3d.judges.base import JudgeInput # (spec, renders, measurement=None, gates=[], acceptance=[], plan_summary="",
+ # part_names=[] (an object plan's parts: ReferenceJudge's mismatch diff),
# round_index=0, previous=None, extra_context="", geometry_views=None,
# glb_path=None (D48: the round's canonical GLB; object tracks + 3dcode judge fill it))
from codeverse3d.judges.base import round_input, plan_summary
round_input(spec, plan, rnd, *, renders, gates, previous, extra_context, geometry_views, glb_path) -> JudgeInput
# THE payload of one round: tracks/steps._judge builds it from the round in hand, cli/_judge.build_judge_input
- # (`3dcode judge`, addons/calibration) from the stored one — acceptance + digest from the plan, glb_path only on
+ # (`3dcode judge`, addons/calibration) from the stored one — acceptance + digest + part_names from the plan, glb_path only on
# SLICE_TRACKS. Δ 2026-09-22: replays used a dict digest of plan.json (a Z-up object read W×D×H, a shader lost
# style / passes / key visuals / motion); cli/_judge.stored_plan types plan.json when record.json has no plan
plan_summary(plan, language) -> str # the digest for every track (object: "Overall W×H×D m" in the GLB frame);
diff --git a/harness/tests/reference/test_judge_diff.py b/harness/tests/reference/test_judge_diff.py
index 9a5ab3f5..24a0a68f 100644
--- a/harness/tests/reference/test_judge_diff.py
+++ b/harness/tests/reference/test_judge_diff.py
@@ -36,7 +36,8 @@ def ref_input(tmp_path):
spec=spec, renders=make_renders(tmp_path / "renders"), measurement=make_measurement(),
acceptance=[AcceptanceItem(id="A1", text="four legs", how="measure", priority="must"),
AcceptanceItem(id="A2", text="slatted back", how="visual", priority="should")],
- plan_summary="parts: Seat, Backrest, LegFrontLeft, LegFrontRight")
+ plan_summary="parts: Seat, Backrest, LegFrontLeft, LegFrontRight",
+ part_names=["Seat", "Backrest", "LegFrontLeft", "LegFrontRight"])
def _judge(model, **kw):
@@ -120,18 +121,24 @@ def test_reference_that_contradicts_the_brief_scores_neutral(tmp_path, cache_dir
assert "NEUTRAL" in text
-def test_part_names_are_read_from_both_plan_digest_shapes():
- from codeverse3d.judges.vlm_judge import _plan_part_names
-
- class One:
- plan_summary = ("Chair: a chair. Overall 0.5x0.5x0.9 m. "
- "Parts: Seat, SeatFrameApron, FrontLeg×2, CurvedBackrest.")
-
- class Many:
- plan_summary = "- Seat · surface · walnut\n- BackRail · frame · walnut\n- (no parts)"
-
- assert _plan_part_names(One()) == ["Seat", "SeatFrameApron", "FrontLeg", "CurvedBackrest"]
- assert _plan_part_names(Many()) == ["Seat", "BackRail"]
+def test_the_diff_call_names_every_part_of_an_articulated_plan(ref_input, cache_dir):
+ """The part list came from a regex over plan_summary, whose articulated digest runs on
+ 'Parts: Base, Lid. Root link Base. Joints: …' — so the last part was always dropped."""
+ from codeverse3d.contracts.plan import ArticulatedPlan
+ from codeverse3d.contracts.run import RoundRecord
+ from codeverse3d.contracts.spec import Track
+ from codeverse3d.judges.base import round_input
+ from codeverse3d.tracks.planner import plan_example
+
+ plan = ArticulatedPlan.model_validate(plan_example(Track.ARTICULATED_OBJECT))
+ names = [p.name for p in plan.parts]
+ inp = round_input(ref_input.spec, plan, RoundRecord(index=0, kind="baseline"), renders=ref_input.renders,
+ gates=[], previous=None, extra_context="", geometry_views=None, glb_path=None)
+ assert len(names) >= 2 and inp.part_names == names
+ model = FakeChatModel(by_label={"reference_diff": [DIFF], "judge": [good_reply(REF, [], 0.8)]})
+ _judge(model, cache_dir=cache_dir).judge(inp)
+ diff = [r for r in model.requests if r.label == "reference_diff"][0]
+ assert ", ".join(names) in "".join(getattr(pt, "text", "") for m in diff.messages for pt in m.parts)
def test_the_diff_call_is_charged_to_the_verdict(ref_input, cache_dir):