Official Codebase of 3DCodeVerse
Python
texture gate: the rubric names its materials criterion — no criterion id is sniffed by prefix
gaoypeng7015583a04fa
diff --git a/harness/codeverse3d/judges/rubrics.py b/harness/codeverse3d/judges/rubrics.pyindex 9704a516..37221cf5 100644--- a/harness/codeverse3d/judges/rubrics.py+++ b/harness/codeverse3d/judges/rubrics.py@@ -68,6 +68,7 @@ class Criterion(BaseModel):anchors: dict[str, str] = Field(description="score level → what it looks like; keys 1.0/0.7/0.4/0.1")floor: float | None = Field(default=None, ge=0.0, le=1.0, description="hard floor: below → verdict fails")kind: Literal["visual", "measured"] = "visual"+ materials: bool = Field(default=False, description="this criterion judges the surfaces: the texture gate reads it")@field_validator("id")@classmethod@@ -182,6 +183,8 @@ class Rubric(BaseModel):d_ids = [d.id for d in self.defects]if len(d_ids) != len(set(d_ids)):raise ValueError(f"duplicate defect ids in rubric {self.name}")+ if sum(c.materials for c in self.criteria) > 1:+ raise ValueError(f"rubric {self.name}: more than one criterion is flagged materials")return self# ------------------------------------------------------------------ helpers@@ -189,6 +192,11 @@ class Rubric(BaseModel):def weights(self) -> dict[str, float]:return {c.id: c.weight for c in self.criteria}+ @property+ def materials_criterion(self) -> str:+ """The id of the criterion flagged ``materials``, or "" when the rubric has none."""+ return next((c.id for c in self.criteria if c.materials), "")+def criterion(self, cid: str) -> Criterion:for c in self.criteria:if c.id == cid:diff --git a/harness/codeverse3d/judges/rubrics/asset_v1.yaml b/harness/codeverse3d/judges/rubrics/asset_v1.yamlindex 41c55eb9..41f318b7 100644--- a/harness/codeverse3d/judges/rubrics/asset_v1.yaml+++ b/harness/codeverse3d/judges/rubrics/asset_v1.yaml@@ -92,6 +92,7 @@ criteria:- id: material_truthweight: 0.10+ materials: truetitle: Material truthdescription: >Do the surfaces read as the right materials (stone, wood, glass, foliage, metal)diff --git a/harness/codeverse3d/judges/rubrics/reference_v1.yaml b/harness/codeverse3d/judges/rubrics/reference_v1.yamlindex 72a15d7b..b12851c3 100644--- a/harness/codeverse3d/judges/rubrics/reference_v1.yaml+++ b/harness/codeverse3d/judges/rubrics/reference_v1.yaml@@ -58,6 +58,7 @@ criteria:- id: material_colorweight: 0.15+ materials: truetitle: Material and colourdescription: >Do the colours and material types match the reference per part (wood vs metal,diff --git a/harness/codeverse3d/judges/rubrics/scene_v1.yaml b/harness/codeverse3d/judges/rubrics/scene_v1.yamlindex cc8848e0..9d70bedc 100644--- a/harness/codeverse3d/judges/rubrics/scene_v1.yaml+++ b/harness/codeverse3d/judges/rubrics/scene_v1.yaml@@ -113,6 +113,7 @@ criteria:- id: materials_shaders_effectsweight: 0.12+ materials: truetitle: Materials, shaders and effectsdescription: >Do surfaces read as materials (water with specular life, glass, foliage,diff --git a/harness/codeverse3d/judges/rubrics/static_object_v1.yaml b/harness/codeverse3d/judges/rubrics/static_object_v1.yamlindex d1c0c9c2..b30e3a61 100644--- a/harness/codeverse3d/judges/rubrics/static_object_v1.yaml+++ b/harness/codeverse3d/judges/rubrics/static_object_v1.yaml@@ -119,6 +119,7 @@ criteria:- id: materialsweight: 0.10+ materials: truetitle: Materialsdescription: >Do surfaces read as sensible materials for each part (colour, roughness,diff --git a/harness/codeverse3d/texturing/generate.py b/harness/codeverse3d/texturing/generate.pyindex 7528607d..1f298b00 100644--- a/harness/codeverse3d/texturing/generate.py+++ b/harness/codeverse3d/texturing/generate.py@@ -30,6 +30,7 @@ from codeverse3d.contracts.plan import AcceptanceItem, StaticPlanfrom codeverse3d.contracts.spec import Specfrom codeverse3d.conventions import OBJECT_VIEWS_QUICK, ViewPresetfrom codeverse3d.judges.base import JudgeInput, plan_summary+from codeverse3d.judges.rubrics import load_rubricfrom codeverse3d.proc import fan_out, unique_tmp#: seam score above which a texture is considered NOT tileable (after make_tileable)@@ -303,18 +304,6 @@ class GateResult(BaseModel):duration_s: float = 0.0-def material_criterion(scores: dict[str, float]) -> str:- """The rubric criterion that tracks surface quality (``materials``,- ``material_color``, ``materials_shaders_effects``, ``material_truth`` ...)."""- for k in scores:- if k.startswith("material"):- return k- for k in scores:- if "material" in k or "texture" in k or "surface" in k:- return k- return ""--def judge_gate(spec: Spec,plan: StaticPlan | None,@@ -357,7 +346,7 @@ def judge_gate(return resres.overall_before, res.overall_after = float(jb.overall), float(ja.overall)res.delta = round(res.overall_after - res.overall_before, 4)- crit = material_criterion(ja.scores)+ crit = load_rubric(ja.rubric).materials_criterion # "" (articulated_v1): Δoverall alone decidesres.materials_criterion = critif crit:res.materials_before = float(jb.scores.get(crit, 0.0))diff --git a/harness/tests/texturing/test_gate.py b/harness/tests/texturing/test_gate.pyindex 0128928c..3d44518c 100644--- a/harness/tests/texturing/test_gate.py+++ b/harness/tests/texturing/test_gate.py@@ -4,7 +4,10 @@ from __future__ import annotationsfrom pathlib import Path-from codeverse3d.texturing.generate import TextureAsset, judge_gate, material_criterion+import pytest++from codeverse3d.judges.rubrics import load_rubric+from codeverse3d.texturing.generate import TextureAsset, judge_gatefrom tests.texturing.conftest import FakeJudge, fake_render@@ -12,10 +15,13 @@ def _asset(tid: str, seam: float, ok_path: Path) -> TextureAsset:return TextureAsset(texture_id=tid, path=str(ok_path), prompt="p", prompt_hash="h", seam_score=seam)-def test_material_criterion_lookup():- assert material_criterion({"intent_fidelity": 1, "materials": 0.5}) == "materials"- assert material_criterion({"a": 1, "materials_shaders_effects": 0.2}) == "materials_shaders_effects"- assert material_criterion({"x": 1}) == ""[email protected](("rubric", "criterion"), [+ ("static_object_v1", "materials"), ("reference_v1", "material_color"), ("asset_v1", "material_truth"),+ ("scene_v1", "materials_shaders_effects"), ("articulated_v1", ""), ("shader_v2", ""),+])+def test_the_rubric_flags_its_materials_criterion(rubric, criterion):+ """N64: the gate sniffed criterion ids by prefix (law 4); a rubric now says which one it is."""+ assert load_rubric(rubric).materials_criterion == criteriondef _run(tmp_path, chair_spec, chair_plan, chair_glb, verdicts, **kw):