Skip to content

Official Codebase of 3DCodeVerse

Python

tests: judges, reference, texturing, third pass — manifest-pinned judge text goes, shared setups fold (183 → 145, −198 lines)

gaoypeng2c9485a3a371
diff --git a/harness/tests/judges/test_calibration.py b/harness/tests/judges/test_calibration.py
index 2d707abf..c1370238 100644
--- a/harness/tests/judges/test_calibration.py
+++ b/harness/tests/judges/test_calibration.py
@@ -3,7 +3,7 @@ from pathlib import Path
import pytest
-from codeverse3d.addons.calibration import calibrate, load_run_cases, pearson, spearman
+from codeverse3d.addons.calibration import calibrate, load_run_cases
from codeverse3d.contracts.artifacts import GateFinding, GateReport, Severity
from codeverse3d.contracts.run import RoundRecord
from codeverse3d.judges.rubrics import load_rubric
@@ -40,9 +40,13 @@ def _fake_run(root: Path, name: str) -> Path:
return run
-def test_load_cases_reads_the_plan_the_in_run_judge_read(tmp_path):
+def test_load_cases_reads_the_plan_and_picks_the_last_round_that_kept_a_glb(tmp_path, caplog):
"""No usable record.json: the plan comes from plan.json, typed, and its digest is the
- in-run one — a Z-up object's size in the measurement frame (W×H×D)."""
+ in-run one — a Z-up object's size in the measurement frame (W×H×D). No picked round: the
+ geometry montage used the last round even when IT kept no GLB (and the render was skipped in
+ silence) while an earlier round kept one."""
+ from codeverse3d.addons.calibration import render_geometry_views
+
run = _fake_run(tmp_path, "runA")
cases = load_run_cases(run)
assert [c.round_index for c in cases] == [0, 1] and cases[0].gate_errors == 1 and cases[1].gate_errors == 0
@@ -51,13 +55,6 @@ def test_load_cases_reads_the_plan_the_in_run_judge_read(tmp_path):
assert cases[0].inp.plan_summary == "Chair: a chair. Overall 0.50×0.90×0.50 m (W×H×D). Parts: Seat, Leg×4."
assert load_run_cases(run, rounds=[1])[0].round_index == 1
-
-def test_with_nothing_picked_the_stand_in_is_the_last_round_that_kept_a_glb(tmp_path, caplog):
- """No picked round: the geometry montage used the last round even when IT kept no GLB (and
- the render was skipped in silence) while an earlier round kept one."""
- from codeverse3d.addons.calibration import render_geometry_views
-
- run = _fake_run(tmp_path, "runB")
(run / "artifacts" / "r00").mkdir(parents=True)
(run / "artifacts" / "r00" / "object.glb").write_bytes(b"glTF")
cases = load_run_cases(run)
@@ -66,12 +63,6 @@ def test_with_nothing_picked_the_stand_in_is_the_last_round_that_kept_a_glb(tmp_
assert "kept no GLB" in caplog.text
-def test_correlations():
- assert pearson([0, 1, 2], [2, 1, 0]) == -1.0 and spearman([0, 1, 5], [5, 3, 1]) == -1.0
- assert pearson([1, 1], [0, 1]) is None and spearman([], []) is None
- assert spearman([1, 1, 2], [1, 2, 3]) == pytest.approx(0.866, abs=1e-3)
-
-
def test_calibrate_offline(tmp_path):
runs = [_fake_run(tmp_path, "runA"), _fake_run(tmp_path, "runB")]
ids = ["A1", "A2"]
diff --git a/harness/tests/judges/test_detail_anchors.py b/harness/tests/judges/test_detail_anchors.py
index c8119b1c..74974d45 100644
--- a/harness/tests/judges/test_detail_anchors.py
+++ b/harness/tests/judges/test_detail_anchors.py
@@ -5,22 +5,13 @@ from __future__ import annotations
import pytest
from codeverse3d.contracts.plan import AcceptanceItem
-from codeverse3d.judges.prompt_builder import build_system_prompt
from codeverse3d.judges.rubrics import _rule_hit, load_rubric
-#: rubric -> the id of its geometry-detail criterion
-DETAIL_CRITERION = {
- "static_object_v1": "geometry_detail",
- "articulated_v1": "geometry_detail",
- "asset_v1": "detail_level",
- "reference_v1": "detail",
-}
-
[email protected](("rubric", "criterion"), sorted(DETAIL_CRITERION.items()))
-def test_detail_anchors_are_a_graded_countable_geometry_ladder(rubric: str, criterion: str) -> None:
- r = load_rubric(rubric)
- c = r.criterion(criterion)
+def test_detail_anchors_are_a_graded_countable_geometry_ladder() -> None:
+ """reference_v1 only: the other rubrics' system prompts are pinned by tests/prompts/manifest.json."""
+ r = load_rubric("reference_v1")
+ c = r.criterion("detail")
levels = sorted((float(k) for k in c.anchors), reverse=True)
assert len(levels) >= 5 and levels[0] == 1.0 and levels[-1] == 0.1, levels
top = c.anchors["1.0"].lower()
@@ -30,19 +21,6 @@ def test_detail_anchors_are_a_graded_countable_geometry_ladder(rubric: str, crit
assert "colour" in text and ("not" in text or "never" in text), "colour is not geometry"
-def test_static_notes_carry_the_refinement_kinds_and_the_majority_primitive_rule() -> None:
- r = load_rubric("static_object_v1")
- prompt = build_system_prompt(r)
- for kind in ("REFINEMENT KINDS", "bevel", "taper", "cut-out", "wall thickness", "surface relief", "hardware",
- "DETAIL AND SIZE", "box-stack"):
- assert kind in prompt, kind
- text = r.defect("primitive_only").text.lower()
- assert "two thirds" in text and "colour" in text
- for rubric in ("static_object_v1", "articulated_v1"):
- c = load_rubric(rubric).criterion("craftsmanship_no_artifacts")
- assert "detail scale" in c.anchors["1.0"].lower() and "0.85" in c.anchors
-
-
def test_physical_plausibility_caps_are_untouched() -> None:
"""The complexity wave may sharpen detail; it may never soften the gates."""
caps = {c.id: c for c in load_rubric("static_object_v1").caps}
diff --git a/harness/tests/judges/test_judge_slices.py b/harness/tests/judges/test_judge_slices.py
index 45fcf10e..62434233 100644
--- a/harness/tests/judges/test_judge_slices.py
+++ b/harness/tests/judges/test_judge_slices.py
@@ -81,20 +81,6 @@ def text_of(req) -> str:
return "\n".join(p.text for m in req.messages for p in m.parts if isinstance(p, TextPart))
-# --------------------------------------------------------------------- (a) clean = byte-identical
-def test_clean_gates_build_byte_identical_messages(tmp_path, cache_dir):
- """The invariant: glb present + knob on, but no gate ERROR → the exact pre-D48 payload."""
- inp = make_input(make_renders(tmp_path / "r"), clean_gates(), two_box_glb(tmp_path / "o.glb"))
- req = judge_request(inp, cache_dir)
- system, messages = build_judge_messages(inp, R, cache_dir=cache_dir) # the baseline builder
- assert req.system == system
- assert [m.model_dump() for m in req.messages] == [m.model_dump() for m in messages]
- assert PROVENANCE_ELICITATION not in req.system
- assert "cross-section" not in text_of(req)
- # and the protocol hash is untouched: the hash builds the default (elicitation-free) prompt
- assert judge_prompt_hash(R) == VlmJudge("static_object_v1", model_id="fake:fake-1").prompt_hash
-
-
def test_knob_off_wrong_track_and_missing_glb_stay_baseline(tmp_path, cache_dir, monkeypatch):
renders = make_renders(tmp_path / "r")
glb = two_box_glb(tmp_path / "o.glb")
@@ -120,11 +106,22 @@ def test_knob_off_wrong_track_and_missing_glb_stay_baseline(tmp_path, cache_dir,
get_settings.cache_clear()
-# --------------------------------------------------------------------- (b) dirty = slices appended
-def test_dirty_gates_append_slices_after_crops_with_rig_text_and_one_elicitation(tmp_path, cache_dir):
- inp = make_input(make_renders(tmp_path / "r"), dirty_gates(), two_box_glb(tmp_path / "o.glb"))
+# --------------------------------------------------------------------- clean = byte-identical, dirty = slices appended
+def test_slices_ride_only_on_a_connectivity_error(tmp_path, cache_dir):
+ """The invariant: glb present + knob on, but no gate ERROR → the exact pre-D48 payload. Any
+ connectivity ERROR (a penetration pair, or a floating part alone) appends the slices after the crops."""
+ renders, glb = make_renders(tmp_path / "r"), two_box_glb(tmp_path / "o.glb")
+ inp = make_input(renders, clean_gates(), glb)
req = judge_request(inp, cache_dir)
+ system, messages = build_judge_messages(inp, R, cache_dir=cache_dir) # the baseline builder
+ assert req.system == system
+ assert [m.model_dump() for m in req.messages] == [m.model_dump() for m in messages]
+ assert PROVENANCE_ELICITATION not in req.system
+ assert "cross-section" not in text_of(req)
+ # and the protocol hash is untouched: the hash builds the default (elicitation-free) prompt
+ assert judge_prompt_hash(R) == VlmJudge("static_object_v1", model_id="fake:fake-1").prompt_hash
+ req = judge_request(make_input(renders, dirty_gates(), glb), cache_dir)
# placement: montage, 2 detail crops, THEN the two slices — never prepended
lbls = labels(req)
assert lbls[-2:] == [SLICE_LABELS["front_back"], SLICE_LABELS["left_right"]]
@@ -146,6 +143,14 @@ def test_dirty_gates_append_slices_after_crops_with_rig_text_and_one_elicitation
assert man.error_pairs == [("A", "B")]
assert all({p.a, p.b} == {"A", "B"} for s in man.rendered() for p in s.hatched_pairs)
+ # the trigger is ANY connectivity ERROR, not only a penetration pair
+ floating = [GateReport(gate="connectivity", passed=False, findings=[
+ GateFinding(gate="connectivity", severity=Severity.ERROR, target="B",
+ message="part 'B' is floating", data={"kind": "floating"})])]
+ req = judge_request(make_input(renders, floating, glb), cache_dir)
+ assert req.system.count(PROVENANCE_ELICITATION) == 1
+ assert labels(req)[-2:] == [SLICE_LABELS["front_back"], SLICE_LABELS["left_right"]]
+
def test_error_pair_extraction_reads_target_and_other(tmp_path):
# target/other win over entering/container (the probe's direction is not the finding's)
@@ -162,17 +167,6 @@ def test_error_pair_extraction_reads_target_and_other(tmp_path):
assert connectivity_error_pairs([GateReport(gate="contract", passed=False, findings=[])]) == []
-def test_a_dirty_round_with_a_floating_only_error_still_elicits(tmp_path, cache_dir):
- """The trigger is ANY connectivity ERROR, not only a penetration pair."""
- gates = [GateReport(gate="connectivity", passed=False, findings=[
- GateFinding(gate="connectivity", severity=Severity.ERROR, target="B",
- message="part 'B' is floating", data={"kind": "floating"})])]
- inp = make_input(make_renders(tmp_path / "r"), gates, two_box_glb(tmp_path / "o.glb"))
- req = judge_request(inp, cache_dir)
- assert req.system.count(PROVENANCE_ELICITATION) == 1
- assert labels(req)[-2:] == [SLICE_LABELS["front_back"], SLICE_LABELS["left_right"]]
-
-
# --------------------------------------------------------------------- (d) 3dcode judge replay
def test_replay_reproduces_the_conditional_payload_from_stored_gates_and_glb(tmp_ws: Workspace, tmp_path, cache_dir):
from codeverse3d.cli._judge import build_judge_input
diff --git a/harness/tests/judges/test_montage.py b/harness/tests/judges/test_montage.py
index 68b18188..c2453701 100644
--- a/harness/tests/judges/test_montage.py
+++ b/harness/tests/judges/test_montage.py
@@ -37,6 +37,10 @@ def test_rank_views_objects_and_scenes():
# and the eye-level rig last
sv = [RenderView(name=n, path="x") for n in ("overview_top", "Establishing", "eye_front", "BridgeView", "cam_b")]
assert [v.name for v in rank_views(sv, scene=True)] == ["Establishing", "BridgeView", "cam_b", "overview_top", "eye_front"]
+ # a re-judged stored pre-D47 8-view run ranks its legacy hero names first
+ legacy = ["front_right_34", "back_left_34", "front", "right", "back", "left", "top", "low_front_left"]
+ ranked = [v.name for v in rank_views([RenderView(name=n, path=f"/x/{n}.png") for n in legacy], scene=False)]
+ assert ranked[:2] == ["front_right_34", "back_left_34"], ranked
def test_plan_montages_full_rig_plus_clay_is_the_measured_cprod_plan(tmp_path):
@@ -91,9 +95,3 @@ def test_missing_tile_is_judge_image_error(tmp_path):
with pytest.raises(JudgeImageError):
render_montage(m, cache_dir=tmp_path / "cache")
-
-def test_a_stored_pre_d47_render_set_still_leads_with_its_hero_views():
- """A re-judged stored 8-view run ranks its legacy hero names first."""
- legacy = ["front_right_34", "back_left_34", "front", "right", "back", "left", "top", "low_front_left"]
- ranked = [v.name for v in rank_views([RenderView(name=n, path=f"/x/{n}.png") for n in legacy], scene=False)]
- assert ranked[:2] == ["front_right_34", "back_left_34"], ranked
diff --git a/harness/tests/judges/test_output_schema.py b/harness/tests/judges/test_output_schema.py
index fd6447b5..3529e8f8 100644
--- a/harness/tests/judges/test_output_schema.py
+++ b/harness/tests/judges/test_output_schema.py
@@ -1,4 +1,3 @@
-
import pytest
from codeverse3d.judges.rubrics import (
@@ -23,32 +22,25 @@ def test_wire_schema_has_fixed_keys_and_no_overall():
assert "acceptance" not in wire_schema(R, [])["properties"]
-def test_parse_bare_bool_acceptance_and_numeric_scores():
+def test_parse_accepts_bare_values_defaults_missing_acceptance_and_rejects_bad_criteria():
rep = good_reply(R, IDS)
rep["acceptance"] = {"A1": True, "must-2": False}
rep["criteria"] = {k: v["score"] for k, v in rep["criteria"].items()}
out = parse_judge_output(rep, R, IDS)
assert out.acceptance_bools == {"A1": True, "must-2": False}
assert out.criteria["materials"].evidence == ""
-
-
-def test_missing_criterion_raises():
- rep = good_reply(R, IDS)
- rep["criteria"].pop("materials")
- with pytest.raises(JudgeParseError, match="missing criteria"):
- parse_judge_output(rep, R, IDS)
-
-
-def test_missing_acceptance_defaults_false_and_unknown_criteria_dropped():
+ # a missing acceptance item is unverified; an unknown criterion is dropped
rep = good_reply(R, IDS)
rep["acceptance"].pop("must-2")
rep["criteria"]["bogus"] = {"score": 1.0, "evidence": ""}
out = parse_judge_output(rep, R, IDS)
assert out.acceptance_bools["must-2"] is False
assert "bogus" not in out.criteria
-
-
-def test_out_of_range_score_raises():
+ # a missing criterion, or a score out of range, is a parse error (the judge retries)
+ rep = good_reply(R, IDS)
+ rep["criteria"].pop("materials")
+ with pytest.raises(JudgeParseError, match="missing criteria"):
+ parse_judge_output(rep, R, IDS)
rep = good_reply(R, IDS)
rep["criteria"]["materials"]["score"] = 1.4
with pytest.raises(JudgeParseError):
diff --git a/harness/tests/judges/test_pairwise.py b/harness/tests/judges/test_pairwise.py
index 35d7397e..666b82e7 100644
--- a/harness/tests/judges/test_pairwise.py
+++ b/harness/tests/judges/test_pairwise.py
@@ -9,7 +9,7 @@ def _reply(w, conf=0.8):
return {"winner": w, "confidence": conf, "reasons": [f"{w} has four legs"], "criteria_won": [{"criterion": "intent_fidelity", "winner": w}]}
-def test_agreement_across_swap(tmp_path, cache_dir):
+def test_the_swap_decides_the_winner_and_its_confidence(tmp_path, cache_dir):
ra, rb = make_renders(tmp_path / "a"), make_renders(tmp_path / "b")
# ordering 1: A=ra,B=rb → "A" wins; ordering 2 (swapped): A=rb,B=ra → "B" wins → both say ra
model = FakeChatModel(by_label={":fwd": [_reply("A", 0.9)], ":swap": [_reply("B", 0.7)]})
@@ -26,13 +26,17 @@ def test_agreement_across_swap(tmp_path, cache_dir):
labels2 = [p.label for p in image_parts(reqs["pairwise:swap"])]
assert labels2[0].startswith("CANDIDATE A — MONTAGE")
-
-def test_disagreement_is_tie(tmp_path, cache_dir):
- ra, rb = make_renders(tmp_path / "a"), make_renders(tmp_path / "b")
- model = FakeChatModel([_reply("A", 0.9), _reply("A", 0.9)]) # position bias: always first
+ # the orderings disagree (position bias: always first) → a tie
+ model = FakeChatModel([_reply("A", 0.9), _reply("A", 0.9)])
res = PairwiseJudge("fake:fake-1", chat_model=model, cache_dir=cache_dir).compare(make_spec(), ra, rb)
assert res.winner == "tie" and res.confidence <= 0.4 and res.error == "orderings disagree"
+ # one ordering fails → the other's verdict at half confidence
+ model = FakeChatModel(by_label={":fwd": [ModelError("x", retryable=True)],
+ ":swap": [_reply("A", 0.8)]}) # swapped ordering: A=rb → b wins
+ res = PairwiseJudge("fake:fake-1", chat_model=model, cache_dir=cache_dir).compare(make_spec(), ra, rb)
+ assert res.winner == "b" and res.confidence == 0.4
+
def test_tie_and_errors(tmp_path, cache_dir):
ra, rb = make_renders(tmp_path / "a", sheet=False), make_renders(tmp_path / "b", sheet=False)
@@ -45,14 +49,6 @@ def test_tie_and_errors(tmp_path, cache_dir):
assert res2.winner == "tie" and res2.confidence == 0.0 and "ModelError" in res2.error
-def test_single_ordering_success_halves_confidence(tmp_path, cache_dir):
- ra, rb = make_renders(tmp_path / "a"), make_renders(tmp_path / "b")
- model = FakeChatModel(by_label={":fwd": [ModelError("x", retryable=True)],
- ":swap": [_reply("A", 0.8)]}) # swapped ordering: A=rb → b wins
- res = PairwiseJudge("fake:fake-1", chat_model=model, cache_dir=cache_dir).compare(make_spec(), ra, rb)
- assert res.winner == "b" and res.confidence == 0.4
-
-
def test_a_scene_pair_is_ranked_as_a_scene_from_the_views_the_judge_saw(tmp_path, cache_dir):
"""A scene's own camera leads, and a view the verdict judge never saw (judge=False) is left out."""
from codeverse3d.contracts.artifacts import RenderSet, RenderView
diff --git a/harness/tests/judges/test_prompt_builder.py b/harness/tests/judges/test_prompt_builder.py
index bcba6cf1..3072e1ac 100644
--- a/harness/tests/judges/test_prompt_builder.py
+++ b/harness/tests/judges/test_prompt_builder.py
@@ -11,11 +11,10 @@ from codeverse3d.contracts.artifacts import (
RenderView,
Severity,
)
-from codeverse3d.contracts.chat import ImagePart, TextPart
+from codeverse3d.contracts.chat import ImagePart
from codeverse3d.judges.prompt_builder import (
TEXT_BUDGET_CHARS,
build_judge_messages,
- build_system_prompt,
view_az_el,
)
from codeverse3d.judges.rubrics import load_rubric
@@ -32,48 +31,11 @@ def _images(msgs):
return [p for p in _parts(msgs) if isinstance(p, ImagePart)]
-def test_the_scene_rig_rule_names_every_harness_camera_and_no_authored_prefix():
- from codeverse3d.conventions import SCENE_VIEWS
- from codeverse3d.judges.prompt_builder import RIG_RULES
-
- rule = RIG_RULES["scene_cams"]
- assert "cam_*" not in rule
- assert all(f"{v.name.split('_')[0]}_*" in rule for v in SCENE_VIEWS)
-
-
-def test_system_has_role_rubric_anchors_and_defects():
- system = build_system_prompt(R)
- assert "BLIND JUDGE" in system
- for c in R.criteria:
- assert c.id in system and c.anchors["0.4"][:30] in system
- assert "Do NOT compute an overall" in system
- assert "DEFECT CHECKLIST" in system
- for d in R.defects:
- assert f"- {d.id}:" in system
- assert "[-0.10, cap 0.60]" in system # floating_part penalty + cap shown
-
-
-def test_user_message_layout(judge_input, cache_dir):
- system, msgs = build_judge_messages(judge_input, R, cache_dir=cache_dir)
- parts = _parts(msgs)
- assert isinstance(parts[0], TextPart)
- text = parts[0].text
- for section in ("BRIEF", "PLAN DIGEST", "ACCEPTANCE CHECKLIST", "MEASUREMENTS", "GATE FINDINGS", "VIEW RIG"):
- assert section in text, section
- assert "A1 [must, via measure]" in text
- assert "Seat" in text and "Backrest" in text # measurement table (spatial or local fallback)
+def test_montage_images_are_cached_at_the_payload_size(judge_input, cache_dir):
+ """The labels and text are pinned by tests/prompts/manifest.json; the image bytes are not."""
+ _, msgs = build_judge_messages(judge_input, R, cache_dir=cache_dir)
imgs = _images(msgs)
- # 4 shaded views → ONE 2×2 montage + centre crop + ground-contact crop
- assert len(imgs) == 3
- assert imgs[0].label.startswith("MONTAGE 1/1 — SHADED views: top-left = front_right_high · az 45° el 30°")
- assert "bottom-left = top · az 0° el 90°, bottom-right = front · az 0° el 0°" in imgs[0].label
- assert imgs[1].label.startswith("DETAIL CROP — centre of front_right_high")
- assert imgs[2].label.startswith("DETAIL CROP — ground-contact band of front") # lowest elevation (0°)
- # labelled text precedes each image; the rig paragraph lists images in send order
- idx = parts.index(imgs[0])
- assert isinstance(parts[idx - 1], TextPart) and parts[idx - 1].text == imgs[0].label
- assert "- image 1: SHADED views" in text and "- detail crop 2: ground-contact band" in text
- assert "MONTAGE k <position> (<view name>)" in text
+ assert len(imgs) == 3 # 4 shaded views → ONE 2×2 montage + centre crop + ground-contact crop
for ip in imgs:
assert Path(ip.path).is_file() and Path(ip.path).parent == cache_dir
with Image.open(imgs[0].path) as im:
diff --git a/harness/tests/judges/test_rubrics.py b/harness/tests/judges/test_rubrics.py
index 1278de1b..82274a0a 100644
--- a/harness/tests/judges/test_rubrics.py
+++ b/harness/tests/judges/test_rubrics.py
@@ -3,12 +3,6 @@ import pytest
from codeverse3d.judges.rubrics import RubricError, load_rubric, rubric_from_dict
-def test_reference_rubric_has_measured_silhouette():
- r = load_rubric("reference_v1")
- assert [c.id for c in r.measured_criteria()] == ["silhouette_match"]
- assert r.criterion("silhouette_match").weight == 0.25
-
-
def test_unknown_and_invalid_rubric():
with pytest.raises(RubricError):
load_rubric("nope_v9")
diff --git a/harness/tests/judges/test_vlm_judge.py b/harness/tests/judges/test_vlm_judge.py
index e2dbd0e4..20e289e0 100644
--- a/harness/tests/judges/test_vlm_judge.py
+++ b/harness/tests/judges/test_vlm_judge.py
@@ -33,6 +33,11 @@ def test_full_path_single_sample(judge_input, cache_dir):
assert len(image_parts(req)) == 3 # 2×2 montage + 2 detail crops
assert "Defects" in req.response_schema["$defs"]
assert raw["defects"] == {d.id: False for d in R.defects} and raw["defect_penalty"] == 0.0
+ # D37: the judge protocol hash is recorded in every verdict, beside (not instead of) the rubric hash
+ from codeverse3d.judges.prompt_builder import judge_prompt_hash
+ assert raw["judge_prompt_hash"] == judge_prompt_hash(R) and len(raw["judge_prompt_hash"]) == 12
+ assert raw["judge_prompt_hash"] != raw["rubric_hash"]
+ assert _judge(FakeChatModel([]), cache_dir=cache_dir).prompt_hash == judge_prompt_hash(R)
@pytest.mark.parametrize("fixed_order", [False, True])
@@ -73,6 +78,9 @@ def test_a_failing_model_degrades_the_verdict(judge_input, cache_dir, retryable,
assert not j.passed and j.overall == 0.0 and j.summary.startswith("judge_error:")
assert j.degraded and json.loads(j.raw)["status"] == "degraded" and j.n_samples == 0
assert len(model.requests) == calls # max_attempts, or at once when not retryable
+ # a degraded verdict carries the protocol hash too, so a glitch is still attributable to a protocol
+ from codeverse3d.judges.prompt_builder import judge_prompt_hash
+ assert json.loads(j.raw)["judge_prompt_hash"] == judge_prompt_hash(R)
def test_base_judge_rejects_measured_rubric(judge_input, cache_dir):
@@ -103,19 +111,6 @@ def test_judge_payload_size_comes_from_the_settings_dial(monkeypatch):
# ----------------------------------------------------------------------------- D37 judge protocol hash
-def test_judge_prompt_hash_is_recorded_in_every_verdict(judge_input, cache_dir):
- from codeverse3d.judges.prompt_builder import judge_prompt_hash
-
- j = _judge(FakeChatModel([good_reply(R, IDS, 0.8)]), cache_dir=cache_dir).judge(judge_input)
- raw = json.loads(j.raw)
- assert raw["judge_prompt_hash"] == judge_prompt_hash(R) and len(raw["judge_prompt_hash"]) == 12
- assert raw["rubric_hash"] == R.content_hash() and raw["judge_prompt_hash"] != raw["rubric_hash"]
- # a degraded verdict carries it too, so a glitch is still attributable to a protocol
- d = _judge(FakeChatModel([ModelError("down", retryable=False)]), cache_dir=cache_dir).judge(judge_input)
- assert d.degraded and json.loads(d.raw)["judge_prompt_hash"] == judge_prompt_hash(R)
- assert _judge(FakeChatModel([]), cache_dir=cache_dir).prompt_hash == judge_prompt_hash(R)
-
-
def test_judge_prompt_hash_tracks_the_protocol_not_the_run(monkeypatch):
from codeverse3d.judges import prompt_builder as pb
from codeverse3d.judges.prompt_builder import judge_prompt_hash
@@ -137,22 +132,16 @@ def test_judge_prompt_hash_tracks_the_protocol_not_the_run(monkeypatch):
# ---------------------------------------------------------------------- per-sample retry budget
-def _fake_clock(monkeypatch):
+def test_a_sample_stops_when_its_budget_is_spent(judge_input, cache_dir, monkeypatch):
import time as real_time
from types import SimpleNamespace
import codeverse3d.judges.vlm_judge as mod
+ from codeverse3d.judges.vlm_judge import SAMPLE_BUDGET_S, SAMPLE_MIN_WAIT_S
clock = {"t": 0.0}
monkeypatch.setattr(mod, "time", SimpleNamespace(monotonic=lambda: clock["t"], time=real_time.time,
sleep=real_time.sleep))
- return clock
-
-
-def test_a_sample_stops_when_its_budget_is_spent(judge_input, cache_dir, monkeypatch):
- from codeverse3d.judges.vlm_judge import SAMPLE_BUDGET_S
-
- clock = _fake_clock(monkeypatch)
def spent(request):
clock["t"] += SAMPLE_BUDGET_S + 10.0 # one attempt that retried for the whole budget
@@ -170,12 +159,7 @@ def test_a_sample_stops_when_its_budget_is_spent(judge_input, cache_dir, monkeyp
burn = SAMPLE_BUDGET_S + 10.0
assert [r.max_wait_s for r in model.requests] == [roomy, roomy - burn, roomy - 2 * burn]
-
-def test_the_last_attempt_still_gets_a_real_try(judge_input, cache_dir, monkeypatch):
- from codeverse3d.judges.vlm_judge import SAMPLE_BUDGET_S, SAMPLE_MIN_WAIT_S
-
- clock = _fake_clock(monkeypatch)
-
+ # the last attempt still gets a real try (SAMPLE_MIN_WAIT_S) when the budget is nearly spent
def nearly_spent(request):
clock["t"] += SAMPLE_BUDGET_S - 5.0
return ModelError("503", retryable=True, status=503)
@@ -184,7 +168,6 @@ def test_the_last_attempt_still_gets_a_real_try(judge_input, cache_dir, monkeypa
j = _judge(model, cache_dir=cache_dir).judge(judge_input)
assert j.passed and [r.max_wait_s for r in model.requests] == [SAMPLE_BUDGET_S, SAMPLE_MIN_WAIT_S]
-
def test_scene_and_graphics_keep_the_pre_d47_montage_ceiling():
"""D47's 5 montages were measured on the object rig only; the other tracks keep 3."""
from codeverse3d.contracts.artifacts import RenderSet
diff --git a/harness/tests/reference/test_attach.py b/harness/tests/reference/test_attach.py
index c186c424..78cc05b5 100644
--- a/harness/tests/reference/test_attach.py
+++ b/harness/tests/reference/test_attach.py
@@ -31,14 +31,12 @@ def _set(tmp_path: Path, views=("three_quarter", "front"), accepted=(True, True)
return rs
-def test_user_images_always_win(tmp_path: Path):
- spec = make_spec(references=[ReferenceImage(path=str(tmp_path / "mine.png"), note="my photo")])
- assert has_user_references(spec)
- out, why = attach(spec, _set(tmp_path))
- assert out is spec and "user --image references win" in why
-
+def test_user_images_win_and_synthesized_ones_are_marked_everywhere(tmp_path: Path):
+ mine = make_spec(references=[ReferenceImage(path=str(tmp_path / "mine.png"), note="my photo")])
+ assert has_user_references(mine)
+ out, why = attach(mine, _set(tmp_path))
+ assert out is mine and "user --image references win" in why
-def test_attach_marks_synthesized_everywhere_and_keeps_constraints(tmp_path: Path):
spec = make_spec()
out, why = attach(spec, _set(tmp_path))
assert out is not spec and "synthesized" in why.lower() and len(out.references) == 2
diff --git a/harness/tests/reference/test_judge_diff.py b/harness/tests/reference/test_judge_diff.py
index ed334cff..80aedb66 100644
--- a/harness/tests/reference/test_judge_diff.py
+++ b/harness/tests/reference/test_judge_diff.py
@@ -63,12 +63,6 @@ def test_a_failing_diff_never_breaks_the_verdict(ref_input, cache_dir):
assert j.overall > 0 and j.rubric == "reference_v1"
-def test_diff_can_be_switched_off(ref_input, cache_dir):
- model = FakeChatModel(by_label={"judge": [good_reply(REF, ["A1", "A2"], 0.8)]})
- _judge(model, cache_dir=cache_dir, diff=False).judge(ref_input)
- assert all(not r.label.startswith("reference_diff") for r in model.requests)
-
-
@pytest.mark.parametrize(("value", "diffed"), [("off", False), ("OFF", False), ("of", True)])
def test_diff_off_via_env(ref_input, cache_dir, switch, value, diffed):
"""D44 (c): ``C3D_REFERENCE_DIFF=off`` switches the pass off; a typo keeps the default (on)."""
@@ -124,3 +118,4 @@ def test_the_diff_call_is_charged_to_the_verdict(ref_input, cache_dir):
model2 = FakeChatModel(by_label={"judge": [good_reply(REF, ["A1", "A2"], 0.8)]}, cost=0.01)
without = _judge(model2, cache_dir=cache_dir, diff=False).judge(ref_input)
assert with_diff.usage.cost_usd > without.usage.cost_usd
+ assert all(not r.label.startswith("reference_diff") for r in model2.requests) # diff=False: no diff call
diff --git a/harness/tests/reference/test_mismatch.py b/harness/tests/reference/test_mismatch.py
index fe2cee65..fe480f72 100644
--- a/harness/tests/reference/test_mismatch.py
+++ b/harness/tests/reference/test_mismatch.py
@@ -47,12 +47,9 @@ def test_compare_names_mismatches_and_builds_text(tmp_path: Path):
assert [m.severity for m in d.top(3)] == ["critical", "major", "minor"]
-def test_model_failure_is_soft(tmp_path: Path):
+def test_a_failed_or_impossible_diff_is_soft(tmp_path: Path):
ref, ren = _png(tmp_path / "ref.png"), _png(tmp_path / "ren.png")
d = compare(make_spec(), [ref], [ren], model=FakeChatModel(by_label={"reference_diff": [ModelError("nope")]}))
assert d.mismatches == [] and "diff call failed" in d.error and d.as_text() == ""
-
-
-def test_missing_images_short_circuit(tmp_path: Path):
- d = compare(make_spec(), [tmp_path / "gone.png"], [_png(tmp_path / "r.png")], model=FakeChatModel())
+ d = compare(make_spec(), [tmp_path / "gone.png"], [ren], model=FakeChatModel())
assert "nothing to compare" in d.error
diff --git a/harness/tests/reference/test_proportions.py b/harness/tests/reference/test_proportions.py
index 248f7f44..a1ae7e2f 100644
--- a/harness/tests/reference/test_proportions.py
+++ b/harness/tests/reference/test_proportions.py
@@ -41,24 +41,21 @@ def test_expected_aspect_is_a_band_over_every_horizontal_extent():
CHAIR = {"width": 0.45, "depth": 0.50, "height": 0.9}
-def test_a_photo_within_the_tolerance_is_not_a_conflict(tmp_path: Path):
- """The measured chair: band 0.50-0.56, photo 0.64 → 16 % outside, kept."""
+def test_only_a_photo_beyond_the_tolerance_is_a_conflict(tmp_path: Path):
+ """The measured chair: band 0.50-0.56, photo 0.64 → 16 % outside, kept. The coffee grinder:
+ the brief says 0.47 w/h; the studio photo includes the crank arm and is ~0.70 → flagged. An
+ unreadable image is never a conflict."""
from codeverse3d.contracts.spec import Constraints
spec = make_spec(constraints=Constraints(dimensions_m=CHAIR))
info = dimension_conflict(spec, _box(tmp_path / "p.png", 128, 200))
assert not info["conflict"] and info["relative_error"] < ASPECT_TOL and conflict_note(info) == ""
-
-def test_the_coffee_grinder_case_is_flagged(tmp_path: Path):
- """The brief says 0.47 w/h; the studio photo includes the crank arm and is ~0.70."""
info = dimension_conflict(make_spec(), _box(tmp_path / "crank.png", 210, 300))
assert info["conflict"] and info["relative_error"] > 0.4
note = conflict_note(info)
assert "BRIEF's dimensions are correct" in note and "part inventory" in note
assert "0.47-0.47" in note
-
-def test_unreadable_image_is_never_a_conflict(tmp_path: Path):
info = dimension_conflict(make_spec(), tmp_path / "missing.png")
assert info["conflict"] is False and info["error"]
diff --git a/harness/tests/reference/test_run_and_cli.py b/harness/tests/reference/test_run_and_cli.py
index cb5957fd..f34047c0 100644
--- a/harness/tests/reference/test_run_and_cli.py
+++ b/harness/tests/reference/test_run_and_cli.py
@@ -36,24 +36,20 @@ def test_ground_spec_rewrites_the_spec_and_records_everything(tmp_ws: Workspace,
assert "reference.start" in names and "reference.done" in names
-def test_ground_spec_leaves_a_user_reference_alone(tmp_ws: Workspace, cache_dir: Path):
+def test_ground_spec_leaves_a_user_reference_alone_and_survives_every_failure(tmp_ws: Workspace, monkeypatch,
+ cache_dir: Path):
spec = make_spec(references=[ReferenceImage(path=str(tmp_ws.root / "mine.png"), note="my photo")])
out, refset, why = ground_spec(spec, tmp_ws, model=_chat(), image_model=FakeImageModel(), cache_dir=cache_dir)
assert out is spec and refset.views == [] and "user --image references win" in why
-
-
-def test_ground_spec_survives_a_rejected_reference(tmp_ws: Workspace, cache_dir: Path):
+ # a rejected reference: the run goes on without one
bad = dict(GOOD_GATE, plain_background=False)
spec = make_spec()
out, refset, why = ground_spec(spec, tmp_ws, model=_chat([bad, bad]), image_model=FakeImageModel(),
cache_dir=cache_dir)
assert out is spec and not refset.ok and "running without one" in why
-
-
-def test_ground_spec_survives_a_dead_backend(tmp_ws: Workspace, monkeypatch, cache_dir: Path):
+ # a dead backend
monkeypatch.setattr("codeverse3d.reference._chat_model",
lambda mid: (_ for _ in ()).throw(RuntimeError("no keys")))
- spec = make_spec()
out, refset, why = ground_spec(spec, tmp_ws, cache_dir=cache_dir)
assert out is spec and "reference grounding unavailable" in why
diff --git a/harness/tests/reference/test_silhouette_best_view.py b/harness/tests/reference/test_silhouette_best_view.py
index 7d3390e8..83a64962 100644
--- a/harness/tests/reference/test_silhouette_best_view.py
+++ b/harness/tests/reference/test_silhouette_best_view.py
@@ -26,19 +26,15 @@ def _views(tmp: Path) -> list[RenderView]:
for n, b in boxes.items()]
-def test_candidate_filter_excludes_top_and_low_cameras(tmp_path: Path) -> None:
+def test_best_view_skips_top_and_low_cameras_and_writes_the_diff(tmp_path: Path) -> None:
assert "top" not in CANDIDATE_VIEWS and "bottom" not in CANDIDATE_VIEWS
assert "low_front_left" not in CANDIDATE_VIEWS and "front_right_low" not in CANDIDATE_VIEWS
# pre-D47 stored runs must still match their own cameras
assert "front_right_34" in CANDIDATE_VIEWS and "back_left_34" in CANDIDATE_VIEWS
views = _views(tmp_path / "r")
views.append(RenderView(name="top", path=views[0].path, width=256, height=256))
- res = best_view_match(views, _shape(tmp_path / "ref.png", (20, 95, 236, 165)))
- assert "top" not in res["per_view"]
-
-
-def test_diff_png_and_empty_input(tmp_path: Path) -> None:
ref = _shape(tmp_path / "ref.png", (20, 95, 236, 165))
- res = best_view_match(_views(tmp_path / "r"), ref, diff_png=tmp_path / "d.png")
+ res = best_view_match(views, ref, diff_png=tmp_path / "d.png")
+ assert "top" not in res["per_view"]
assert (tmp_path / "d.png").is_file() and res["view"] == "right"
assert "error" in best_view_match([], ref)
diff --git a/harness/tests/reference/test_synth.py b/harness/tests/reference/test_synth.py
index 732915e0..285213e7 100644
--- a/harness/tests/reference/test_synth.py
+++ b/harness/tests/reference/test_synth.py
@@ -7,10 +7,8 @@ from pathlib import Path
from codeverse3d.models.base import ModelError
from codeverse3d.reference import (
STUDIO_SUFFIX,
- cache_key,
compose_image_prompt,
synth_reference,
- template_hash,
views_for,
)
from tests.orchestrator_tracks.fakes import FakeChatModel
@@ -46,27 +44,16 @@ def test_synth_accepts_and_caches(cache_dir: Path):
assert [v.path for v in again.accepted] == [v.path for v in rs.accepted]
-def test_cache_key_moves_with_the_brief_and_the_prompts(cache_dir: Path):
- a = cache_key(make_spec(), n_views=2, text_model="m", image_model="i")
- b = cache_key(make_spec(prompt="a teapot"), n_views=2, text_model="m", image_model="i")
- c = cache_key(make_spec(), n_views=1, text_model="m", image_model="i")
- d = cache_key(make_spec(), n_views=2, text_model="m", image_model="other")
- assert len({a, b, c, d}) == 4 and len(template_hash()) == 12
-
-
-def test_gate_rejects_wrong_object_and_falls_back(cache_dir: Path):
+def test_gate_rejects_wrong_object_collage_and_contradiction(cache_dir: Path):
bad = dict(GOOD_GATE, shows_requested_object=False, depicted_object="a pepper mill")
rs = synth_reference(make_spec(), model=_chat([bad, bad]), image_model=FakeImageModel(),
n_views=2, cache_dir=cache_dir)
assert not rs.ok and len(rs.rejected) == 2
assert "shows a pepper mill" in rs.rejected[0].verdict.failure()
-
-
-def test_gate_rejects_collage_watermark_and_contradiction(cache_dir: Path):
replies = [dict(GOOD_GATE, is_photo_collage=True),
dict(GOOD_GATE, contradictions=["brief says a front drawer; the image shows no drawer"])]
rs = synth_reference(make_spec(), model=_chat(replies), image_model=FakeImageModel(),
- n_views=2, cache_dir=cache_dir)
+ n_views=2, cache_dir=cache_dir / "b") # the rejected set above is cached
assert not rs.ok
assert "collage" in rs.views[0].verdict.failure()
assert "contradicts:" in rs.views[1].verdict.failure()
@@ -78,18 +65,13 @@ def test_unverifiable_image_is_never_accepted(cache_dir: Path):
assert not rs.ok and len(rs.views) == 1 and rs.views[0].verdict is None
-def test_image_failure_is_not_fatal(cache_dir: Path):
+def test_no_failure_is_fatal(cache_dir: Path):
rs = synth_reference(make_spec(), model=_chat(), image_model=FakeImageModel(fail=True),
n_views=2, cache_dir=cache_dir)
assert not rs.ok and "image model exploded" in rs.error
-
-
-def test_no_image_model_is_not_fatal(cache_dir: Path):
rs = synth_reference(make_spec(), model=_chat(), image_model=None, cache_dir=cache_dir)
assert not rs.ok and rs.error == "no image model configured"
-
-
-def test_prompt_writer_failure_falls_back_to_the_brief(cache_dir: Path):
+ # the prompt writer failed: the brief is the prompt
chat = FakeChatModel(by_label={"reference_prompt": [ModelError("boom")], "reference_gate": [GOOD_GATE]})
rs = synth_reference(make_spec(), model=chat, image_model=FakeImageModel(), n_views=1, cache_dir=cache_dir)
assert rs.ok and "coffee grinder" in rs.subject
diff --git a/harness/tests/texturing/test_apply.py b/harness/tests/texturing/test_apply.py
index c3b3cbae..eef202f4 100644
--- a/harness/tests/texturing/test_apply.py
+++ b/harness/tests/texturing/test_apply.py
@@ -35,10 +35,7 @@ def test_apply_textures_end_to_end(tmp_path: Path, chair_glb: Path, chair_plan):
# UVs present and per-vertex on textured parts
seat = s.geometry["Seat"]
assert seat.visual.uv is not None and len(seat.visual.uv) == len(seat.vertices)
-
-
-def test_apply_with_missing_texture_file_warns(tmp_path: Path, chair_glb: Path, chair_plan):
- tp = default_plan(chair_plan)
+ # a missing texture file warns and textures nothing
rep = apply_textures(chair_glb, tp, {tp.texture_ids()[0]: tmp_path / "missing.png"}, tmp_path / "o.glb")
assert any("missing" in w for w in rep.warnings)
assert rep.parts_textured == []
diff --git a/harness/tests/texturing/test_maps.py b/harness/tests/texturing/test_maps.py
index 53ba8e55..b982b28e 100644
--- a/harness/tests/texturing/test_maps.py
+++ b/harness/tests/texturing/test_maps.py
@@ -20,7 +20,8 @@ def _grain(size: int = 64) -> Image.Image:
return Image.fromarray(np.round(rgb * 255).astype(np.uint8), mode="RGB")
-def test_metallic_roughness_image_uses_the_gltf_channel_packing():
+def test_derived_maps_use_the_gltf_encodings():
+ """metallicRoughness: glTF channel packing; normal: tangent space, as seamless as the albedo."""
img = _grain()
mr = metallic_roughness_image(img, 0.62, 1.0, "cast_iron")
a = np.asarray(mr)
@@ -28,10 +29,6 @@ def test_metallic_roughness_image_uses_the_gltf_channel_packing():
assert (a[..., 2] == 255).all(), "metallic lives in B"
assert a[..., 1].std() > 3, "roughness lives in G and must actually vary"
assert 140 < a[..., 1].mean() < 180
-
-
-def test_normal_map_is_tangent_space_and_tiles():
- img = _grain()
n = np.asarray(normal_image(img, "cast_iron"), dtype=np.float32) / 255.0 * 2.0 - 1.0
assert np.allclose(np.linalg.norm(n, axis=-1), 1.0, atol=1e-2)
assert (n[..., 2] > 0).all(), "z always points out of the surface"
diff --git a/harness/tests/texturing/test_materials.py b/harness/tests/texturing/test_materials.py
index 47f03d7c..b6da060a 100644
--- a/harness/tests/texturing/test_materials.py
+++ b/harness/tests/texturing/test_materials.py
@@ -18,17 +18,6 @@ from codeverse3d.texturing.materials import (
from codeverse3d.texturing.plan import FAMILY_DEFAULTS
-def test_every_family_is_self_consistent():
- for name, p in MATERIALS.items():
- assert p.family == name
- lo, hi = p.roughness_band
- assert lo <= p.roughness <= hi, f"{name}: canonical roughness outside its own band"
- lo, hi = p.metallic_band
- assert lo <= p.metallic <= hi, f"{name}: canonical metallic outside its own band"
- assert 1.0 <= p.ior <= 2.5
- assert p.note, f"{name}: a row without a note teaches nothing"
-
-
def test_coarse_families_of_the_texture_planner_all_resolve():
assert set(COARSE_TO_FINE) == set(FAMILY_DEFAULTS)
for coarse, fine in COARSE_TO_FINE.items():
diff --git a/harness/tests/texturing/test_normalise.py b/harness/tests/texturing/test_normalise.py
index b685dab8..71831c8b 100644
--- a/harness/tests/texturing/test_normalise.py
+++ b/harness/tests/texturing/test_normalise.py
@@ -74,15 +74,12 @@ def test_normalise_materials_rewrites_only_the_factors(tmp_path: Path):
assert after == before, "base colour is the agent's decision and must survive"
-def test_nothing_to_do_writes_nothing(tmp_path: Path):
+def test_nothing_to_do_writes_nothing_and_a_texture_is_never_second_guessed(tmp_path: Path):
glb = _glb(tmp_path, [("Bit", "PolishedSteelBit", 0.98, 0.15, (215, 215, 224, 255))])
out = tmp_path / "out.glb"
rep = normalise_materials(glb, out)
assert not rep.changed() and rep.glb_out == "" and not out.exists()
assert rep.table() == "no material needed normalising"
-
-
-def test_a_textured_material_is_never_second_guessed(tmp_path: Path):
glb = _glb(tmp_path, [("Seat", "OakSeat", 0.0, 0.5, (150, 100, 60, 255))])
scene = load_scene(glb)
scene.geometry["Seat"].visual.material.baseColorTexture = Image.new("RGB", (8, 8), (120, 90, 40))
diff --git a/harness/tests/texturing/test_run.py b/harness/tests/texturing/test_run.py
index 47be0237..a579d5aa 100644
--- a/harness/tests/texturing/test_run.py
+++ b/harness/tests/texturing/test_run.py
@@ -6,6 +6,8 @@ import json
import shutil
from pathlib import Path
+from typer.testing import CliRunner
+
from codeverse3d.contracts.run import RunRecord
from codeverse3d.texturing.run import (
TextureReport,
@@ -27,7 +29,7 @@ def _ws(tmp_path: Path, chair_glb: Path, chair_spec, chair_plan) -> Workspace:
return ws
-def test_texture_pass_ships_and_records(tmp_path, chair_glb, chair_spec, chair_plan):
+def test_texture_pass_ships_records_and_shows(tmp_path, chair_glb, chair_spec, chair_plan):
ws = _ws(tmp_path, chair_glb, chair_spec, chair_plan)
judge = FakeJudge([(0.70, {"materials": 0.6, "intent_fidelity": 0.8}), (0.73, {"materials": 0.75, "intent_fidelity": 0.8})])
img = FakeImageModel(usd_per_image=0.05)
@@ -49,6 +51,17 @@ def test_texture_pass_ships_and_records(tmp_path, chair_glb, chair_spec, chair_p
assert load_report(ws).shipped
# planner quick render was written because there was no sheet
assert latest_sheet(ws) is None and (ws.artifacts / "textures" / "planner_views" / "sheet.png").is_file()
+ # `3dcode texture show` reads it back
+ from codeverse3d.cli.main import app
+
+ runner = CliRunner()
+ res = runner.invoke(app, ["texture", "show", str(ws.root)])
+ assert res.exit_code == 0, res.output
+ assert "texture pass" in res.output and "wood_oiled_oak" in res.output
+ res = runner.invoke(app, ["texture", "--help"])
+ assert res.exit_code == 0 and "scene-pack" in res.output and "pass" in res.output
+ res = runner.invoke(app, ["texture", "show", str(tmp_path / "nowhere")])
+ assert res.exit_code != 0
def test_texture_pass_no_judge_and_all_failed(tmp_path, chair_glb, chair_spec, chair_plan):
diff --git a/harness/tests/texturing/test_tile.py b/harness/tests/texturing/test_tile.py
index 0315ca3f..3a6d13a8 100644
--- a/harness/tests/texturing/test_tile.py
+++ b/harness/tests/texturing/test_tile.py
@@ -1,32 +1,10 @@
-"""tile.py: seam score, mirror-blend tileability, sizing."""
+"""tile.py: sizing and saving (the seam score is gated in test_generate)."""
from __future__ import annotations
-import numpy as np
from PIL import Image
-from codeverse3d.texturing.generate import (
- SEAM_MAX,
- fit_size,
- make_tileable,
- save_texture,
- seam_score,
-)
-from tests.texturing.conftest import procedural_texture
-
-
-def test_make_tileable_makes_wrap_edges_equal_and_lowers_score():
- bad = procedural_texture("wood", size=128)
- before = seam_score(bad)
- fixed = make_tileable(bad, 0.12)
- after = seam_score(fixed)
- assert after < before and after <= SEAM_MAX
- a = np.asarray(fixed).astype(int)
- assert np.abs(a[:, 0, :] - a[:, -1, :]).mean() < 2.0 # wrap-exact horizontally
- assert np.abs(a[0, :, :] - a[-1, :, :]).mean() < 2.0
- # centre untouched
- b = np.asarray(bad).astype(int)
- assert np.array_equal(a[40:88, 40:88], b[40:88, 40:88])
+from codeverse3d.texturing.generate import fit_size, save_texture
def test_fit_size_save_and_helpers(tmp_path):
diff --git a/harness/tests/texturing/test_tools_cli.py b/harness/tests/texturing/test_tools_cli.py
index b683eacc..4a29b5df 100644
--- a/harness/tests/texturing/test_tools_cli.py
+++ b/harness/tests/texturing/test_tools_cli.py
@@ -1,4 +1,4 @@
-"""The texture pass with every dependency injected, and the `3dcode texture` CLI, offline."""
+"""The texture pass with every dependency injected, and `3dcode texture scene-pack`, offline (`show`: test_run)."""
from __future__ import annotations
@@ -32,22 +32,6 @@ def test_texture_pass_runs_with_injected_fakes(tmp_path, chair_glb, chair_spec,
assert (ws.artifacts / "object_textured.glb").is_file()
-def test_cli_texture_show_and_help(tmp_path, chair_glb, chair_spec, chair_plan):
- from codeverse3d.cli.main import app
-
- ws = _ws(tmp_path, chair_glb, chair_spec, chair_plan)
- texture_pass(ws, chair_spec, chair_plan, model_id="", image_model=FakeImageModel(), judge=False, render=fake_render,
- cache_dir=tmp_path / "c")
- runner = CliRunner()
- res = runner.invoke(app, ["texture", "show", str(ws.root)])
- assert res.exit_code == 0, res.output
- assert "texture pass" in res.output and "wood_oiled_oak" in res.output
- res = runner.invoke(app, ["texture", "--help"])
- assert res.exit_code == 0 and "scene-pack" in res.output and "pass" in res.output
- res = runner.invoke(app, ["texture", "show", str(tmp_path / "nowhere")])
- assert res.exit_code != 0
-
-
def test_cli_scene_pack_spend_joins_the_runs_ledger(tmp_path, chair_spec, monkeypatch):
"""`3dcode texture scene-pack` opened no run_ledger (`pass` did), so its plan + image
spend went to the per-process log instead of the run's telemetry/cost.jsonl."""
diff --git a/harness/tests/texturing/test_uv.py b/harness/tests/texturing/test_uv.py
index 68e80c4f..8c241307 100644
--- a/harness/tests/texturing/test_uv.py
+++ b/harness/tests/texturing/test_uv.py
@@ -18,7 +18,7 @@ def test_choose_projection_rules():
assert choose_projection(np.array([0.1, 2.0, 0.1]), "cylinder") == ("cylinder", 1)
-def test_box_projection_world_scale_and_splits():
+def test_box_and_cylinder_projections_keep_world_scale_and_split_seams():
m = trimesh.creation.box(extents=(0.6, 0.3, 0.3))
uw = unwrap(m.vertices, m.faces, np.eye(4), projection="box", tile_size_m=0.3)
assert uw.projection == "box"
@@ -36,8 +36,6 @@ def test_box_projection_world_scale_and_splits():
uw2 = unwrap(m.vertices, m.faces, T, projection="box", tile_size_m=0.3)
assert (uw2.uv.max(0) - uw2.uv.min(0)) == pytest.approx(2 * (uw.uv.max(0) - uw.uv.min(0)), abs=1e-6)
-
-def test_cylinder_projection_seam_and_caps():
m = trimesh.creation.cylinder(radius=0.05, height=0.5, sections=32) # along z
uw = unwrap(m.vertices, m.faces, np.eye(4), projection="auto", tile_size_m=0.1)
assert uw.projection == "cylinder" and uw.axis == 2