Official Codebase of 3DCodeVerse
Python
d48 review nits: sorted degenerate-area iteration, tmp-dir cleanup on a mid-render crash, the scene-track guard tested directly
gaoypengd6020e786345
diff --git a/harness/codeverse/judges/vlm_judge.py b/harness/codeverse/judges/vlm_judge.pyindex a09e5c98..d17d69f4 100644--- a/harness/codeverse/judges/vlm_judge.py+++ b/harness/codeverse/judges/vlm_judge.py@@ -17,6 +17,7 @@ to treat as a glitch, never as a score.from __future__ import annotations+import contextlibimport hashlibimport loggingimport os@@ -275,10 +276,12 @@ class VlmJudge:if not mpath.is_file():tmp = cache / f"slices_{key}.{os.getpid()}-{threading.get_ident()}.tmp"shutil.rmtree(tmp, ignore_errors=True)- judge_slices(glb, pairs, tmp)try:- tmp.rename(out_dir)- except OSError: # a concurrent writer got there first — use theirs+ judge_slices(glb, pairs, tmp)+ # a concurrent identical writer may have renamed first — then use theirs+ with contextlib.suppress(OSError):+ tmp.rename(out_dir)+ finally: # a mid-render crash (or losing the race) must not leave the .tmp behindshutil.rmtree(tmp, ignore_errors=True)return out_dir, SliceManifest.model_validate_json(mpath.read_text())diff --git a/harness/codeverse/spatial/sections.py b/harness/codeverse/spatial/sections.pyindex e59b51d5..476be329 100644--- a/harness/codeverse/spatial/sections.py+++ b/harness/codeverse/spatial/sections.py@@ -541,7 +541,7 @@ def judge_slices(_hull_area(np.vstack(lines)) for p, lines in strokes.items() if p not in sections)effective_area = filled_area + stroke_hull_areaproj_area = 0.0- for pname in set(sections) | set(strokes):+ for pname in sorted(set(sections) | set(strokes)):v = np.asarray(parts[pname].vertices)proj_area += _hull_area(np.column_stack([v[:, horiz], v[:, 1]]))frac = effective_area / proj_area if proj_area > 0 else 0.0diff --git a/harness/tests/judges/test_judge_slices.py b/harness/tests/judges/test_judge_slices.pyindex 6e3f2ff5..25324ea1 100644--- a/harness/tests/judges/test_judge_slices.py+++ b/harness/tests/judges/test_judge_slices.py@@ -107,6 +107,13 @@ def test_knob_off_wrong_track_and_missing_glb_stay_baseline(tmp_path, cache_dir,assert req.system == baseline[0] and PROVENANCE_ELICITATION not in req.systemassert [m.model_dump() for m in req.messages] == [m.model_dump() for m in baseline[1]]+ # dirty gates + glb on a NON-OBJECT track (stray glb_path on a scene input): baseline —+ # the SLICE_TRACKS guard, tested directly at the VlmJudge layer+ req = judge_request(make_input(renders, dirty_gates(), glb,+ spec_kw={"track": "scene", "language": "scene_threejs"}), cache_dir)+ assert req.system == baseline[0] and PROVENANCE_ELICITATION not in req.system+ assert "cross-section" not in text_of(req)+# dirty gates + glb, but the knob is off: baselinemonkeypatch.setattr("codeverse.judges.vlm_judge.get_settings",lambda: Settings(judge={"slices": "off"}))