Official Codebase of 3DCodeVerse
Python
triangle ceiling: the depth gate is the one object ceiling; no build wrapper errors or warns on a count
gaoypeng2b1a4d011ab9
diff --git a/eval/llm/docs/inventory_harness_bench.md b/eval/llm/docs/inventory_harness_bench.mdindex d1dc9ed1..5512e9d5 100644--- a/eval/llm/docs/inventory_harness_bench.md+++ b/eval/llm/docs/inventory_harness_bench.md@@ -46,7 +46,7 @@ Schema (`bench/run_bench.py:49-71`): `Battery{name, track, language, description## 4. Renderers / executors (`codeverse3d/languages/<lang>`)| language | build | outputs ||---|---|---|-| blender | `blender -b --factory-startup --python wrappers/run_bpy.py -- --script src/model.py --out artifacts --rlimit-gb 12 --tri-limit 600000 --seed 0 --stl` | `object.glb` (Y-up), `object.stl`, `build.json`, `census.json` |+| blender | `blender -b --factory-startup --python wrappers/run_bpy.py -- --script src/model.py --out artifacts --rlimit-gb 12 --seed 0 --stl` | `object.glb` (Y-up), `object.stl`, `build.json`, `census.json` || cadquery | `wrappers/run_cq.py --script … --tolerance 0.001` | `object.glb/.step/.stl` || threejs | `node runtime_js/export_glb.mjs` ([email protected]) | `object.glb` || urdf_blender | `run_bpy_links.py` + FK check + fcl sweep | `robot.urdf`, `meshes/*.glb`, pose renders |diff --git a/harness/codeverse3d/conventions.py b/harness/codeverse3d/conventions.pyindex b7de7257..0058d9d8 100644--- a/harness/codeverse3d/conventions.py+++ b/harness/codeverse3d/conventions.py@@ -266,7 +266,8 @@ def fmt3(vec: Sequence[float]) -> str:# --------------------------------------------------------------------------- limits-#: Triangle budgets used by gates/prompts (soft caps; judge sees the count).+#: Triangle ceilings: the object one is the depth gate's upper clamp (``tracks/depth.budget_gate``),+#: the only place an object's triangle count is enforced — no build wrapper checks it.MAX_TRIS_OBJECT = 600_000MAX_TRIS_SCENE = 3_000_000#: Default tolerance for bbox contract checks, in meters.diff --git a/harness/codeverse3d/languages/blender/__init__.py b/harness/codeverse3d/languages/blender/__init__.pyindex 93c7a85e..e3a5e31a 100644--- a/harness/codeverse3d/languages/blender/__init__.py+++ b/harness/codeverse3d/languages/blender/__init__.py@@ -12,14 +12,7 @@ from codeverse3d.config import Settings, get_settingsfrom codeverse3d.contracts.artifacts import BuildResult, GateFinding, GateReport, Severityfrom codeverse3d.contracts.common import ENTRY_FILE, Languagefrom codeverse3d.contracts.plan import BBox, PartPlan, Plan, StaticPlan-from codeverse3d.conventions import (- GROUND_TOL_M,- MAX_TRIS_OBJECT,- PASCAL_RE,- fmt3,- to_pascal,- to_snake,-)+from codeverse3d.conventions import GROUND_TOL_M, PASCAL_RE, fmt3, to_pascal, to_snakefrom codeverse3d.languages._ast_lint import (BASE_FORBIDDEN_IMPORTS,check_imports,@@ -727,13 +720,12 @@ class BlenderRuntime(RuntimeLayout):def build_command(self, ws: Workspace, *, stl: bool = True, blend: bool = False, seed: int = 0,- tri_limit: int = MAX_TRIS_OBJECT,) -> list[str]:cmd = [self.blender_binary(), "-b", "--factory-startup", "--python", str(WRAPPER), "--","--script", str(self.entry_file(ws)), "--out", str(ws.artifacts),"--rlimit-gb", str(self._settings.limits.bpy_rlimit_gb),- "--tri-limit", str(tri_limit), "--seed", str(seed),+ "--seed", str(seed),]if stl:cmd.append("--stl")@@ -753,11 +745,11 @@ class BlenderRuntime(RuntimeLayout):def build(self, ws: Workspace, *, timeout_s: int | None = None, stl: bool = True, blend: bool = False,- seed: int = 0, tri_limit: int = MAX_TRIS_OBJECT,+ seed: int = 0,) -> BuildResult:"""Run the wrapper; never raises for agent-code failures (typed BuildResult instead)."""return run_wrapper_build(ws, language=self.language, extras={"stl": "object.stl", "blend": "object.blend"},- argv=lambda: self.build_command(ws, stl=stl, blend=blend, seed=seed, tri_limit=tri_limit),+ argv=lambda: self.build_command(ws, stl=stl, blend=blend, seed=seed),env=blender_env(), timeout_s=timeout_s or self._settings.limits.build_timeout_s, output_filter=strip_blender_noise)diff --git a/harness/codeverse3d/languages/cadquery/__init__.py b/harness/codeverse3d/languages/cadquery/__init__.pyindex bd001eb3..fa6ea0b8 100644--- a/harness/codeverse3d/languages/cadquery/__init__.py+++ b/harness/codeverse3d/languages/cadquery/__init__.py@@ -13,7 +13,7 @@ from codeverse3d.config import Settings, get_settingsfrom codeverse3d.contracts.artifacts import BuildResult, GateFinding, GateReport, Severityfrom codeverse3d.contracts.common import ENTRY_FILE, Languagefrom codeverse3d.contracts.plan import PartPlan, Plan, StaticPlan-from codeverse3d.conventions import MAX_TRIS_OBJECT, PASCAL_RE, fmt3, to_pascal, to_snake+from codeverse3d.conventions import PASCAL_RE, fmt3, to_pascal, to_snakefrom codeverse3d.languages._ast_lint import (BASE_FORBIDDEN_IMPORTS,ImportCollector,@@ -331,11 +331,11 @@ class CadQueryRuntime(RuntimeLayout):def entry_file(self, ws: Workspace) -> Path:return ws.src / "model.py"- def build_command(self, ws: Workspace, *, seed: int = 0, tri_limit: int = MAX_TRIS_OBJECT) -> list[str]:+ def build_command(self, ws: Workspace, *, seed: int = 0) -> list[str]:"""The wrapper's own --tolerance / --angular-tolerance defaults are the tessellation."""return [self._python, str(WRAPPER), "--script", str(self.entry_file(ws)), "--out", str(ws.artifacts),- "--rlimit-gb", str(self._rlimit_gb), "--tri-limit", str(tri_limit), "--seed", str(seed),+ "--rlimit-gb", str(self._rlimit_gb), "--seed", str(seed),]# ------------------------------------------------------------------ protocol@@ -347,10 +347,9 @@ class CadQueryRuntime(RuntimeLayout):def lint(self, ws: Workspace) -> GateReport:return lint_cadquery_file(self.entry_file(ws))- def build(self, ws: Workspace, *, timeout_s: int | None = None, seed: int = 0,- tri_limit: int = MAX_TRIS_OBJECT) -> BuildResult:+ def build(self, ws: Workspace, *, timeout_s: int | None = None, seed: int = 0) -> BuildResult:return run_wrapper_build(ws, language=self.language, extras={"step": "object.step", "stl": "object.stl"},- argv=lambda: self.build_command(ws, seed=seed, tri_limit=tri_limit),+ argv=lambda: self.build_command(ws, seed=seed),env=cadquery_env(), timeout_s=timeout_s or self._settings.limits.build_timeout_s)diff --git a/harness/codeverse3d/languages/wrappers/_census.py b/harness/codeverse3d/languages/wrappers/_census.pyindex 3805620f..faddb2a0 100644--- a/harness/codeverse3d/languages/wrappers/_census.py+++ b/harness/codeverse3d/languages/wrappers/_census.py@@ -125,7 +125,7 @@ def material_slot_warnings(meshes: list[dict[str, Any]]) -> list[str]:def _warnings(bpy: Any, objects: list[dict[str, Any]], boolean_operands: dict[str, list[str]],- scene_objects: set[str], vl_names: set[str], total_tris: int, tri_limit: int) -> list[str]:+ scene_objects: set[str], vl_names: set[str]) -> list[str]:warnings: list[str] = []excluded = [o["name"] for o in objects if o["in_scene"] and not o["in_view_layer"]]if excluded:@@ -157,12 +157,10 @@ def _warnings(bpy: Any, objects: list[dict[str, Any]], boolean_operands: dict[stif unlinked:warnings.append(f"mesh object(s) {unlinked} were created but never linked to the scene → not exported; ""call bpy.context.collection.objects.link(obj)")- if total_tris > tri_limit:- warnings.append(f"triangle budget exceeded: {total_tris} > {tri_limit}")return warnings-def collect_census(bpy: Any, tri_limit: int) -> dict[str, Any]:+def collect_census(bpy: Any) -> dict[str, Any]:"""Census of every object in ``bpy.data`` (visible meshes count toward the scene bbox / tris)."""from mathutils import Vector@@ -191,11 +189,10 @@ def collect_census(bpy: Any, tri_limit: int) -> dict[str, Any]:"objects": objects,"n_mesh_objects": len(visible),"tri_count": total_tris,- "tri_limit": tri_limit,"materials": [m.name for m in bpy.data.materials],"cameras": [o.name for o in bpy.data.objects if o.type == "CAMERA"],"lights": [o.name for o in bpy.data.objects if o.type == "LIGHT"],- "warnings": _warnings(bpy, objects, boolean_operands, scene_objects, vl_names, total_tris, tri_limit),+ "warnings": _warnings(bpy, objects, boolean_operands, scene_objects, vl_names),"frame": "z_up_neg_y_front",}if mins:diff --git a/harness/codeverse3d/languages/wrappers/run_bpy.py b/harness/codeverse3d/languages/wrappers/run_bpy.pyindex 99e7f8c2..5576f506 100644--- a/harness/codeverse3d/languages/wrappers/run_bpy.py+++ b/harness/codeverse3d/languages/wrappers/run_bpy.py@@ -2,7 +2,7 @@blender -b --factory-startup --python run_bpy.py -- \--script /abs/src/model.py --out /abs/artifacts [--stl] [--blend] \- [--rlimit-gb 12] [--tri-limit 600000] [--seed 0]+ [--rlimit-gb 12] [--seed 0]What it does (in order):1. caps the address space (RLIMIT_AS) so geometry bombs die in-process;@@ -59,7 +59,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:p.add_argument("--stl", action="store_true")p.add_argument("--blend", action="store_true")p.add_argument("--rlimit-gb", type=float, default=12.0)- p.add_argument("--tri-limit", type=int, default=600_000)p.add_argument("--seed", type=int, default=0)return p.parse_args(argv)@@ -190,17 +189,11 @@ def main() -> int:except RuntimeError:pass- census = collect_census(bpy, args.tri_limit)+ census = collect_census(bpy)if render_fingerprint(bpy) != render_before:census["warnings"].append("script changed render settings (engine/resolution/filepath/frames): remove that code")report["warnings"] = census["warnings"]- if exc is None and census["tri_count"] > args.tri_limit:- report.update(- error_type="TriangleBudgetExceeded",- error_message=f"{census['tri_count']} triangles > limit {args.tri_limit}; lower subdivision levels / segment counts",- )-chosen = select_exportables(bpy)if chosen:glb = os.path.join(out_dir, GLB_NAME)diff --git a/harness/codeverse3d/languages/wrappers/run_bpy_links.py b/harness/codeverse3d/languages/wrappers/run_bpy_links.pyindex ba756528..97c6f65b 100644--- a/harness/codeverse3d/languages/wrappers/run_bpy_links.py+++ b/harness/codeverse3d/languages/wrappers/run_bpy_links.py@@ -45,8 +45,6 @@ from _wrapper_common import ( # noqa: E402write_report,)-TRI_LIMIT = 600_000 # a warning here (census), the blender language's build error-def _snake(name: str) -> str:s = re.sub(r"[^0-9A-Za-z]+", "_", name.strip())@@ -150,7 +148,7 @@ def main() -> int:write_report(str(out), report, census, t0)return 0- census.update(collect_census(bpy, TRI_LIMIT))+ census.update(collect_census(bpy))depsgraph = bpy.context.evaluated_depsgraph_get()by_name = {ob.name: ob for ob in bpy.data.objects if ob.type in MEASURABLE_TYPES or ob.type == "EMPTY"}# a hidden object (a boolean cutter, as the census tells agents to hide one) is notdiff --git a/harness/codeverse3d/languages/wrappers/run_cq.py b/harness/codeverse3d/languages/wrappers/run_cq.pyindex c183643b..146eeb04 100644--- a/harness/codeverse3d/languages/wrappers/run_cq.py+++ b/harness/codeverse3d/languages/wrappers/run_cq.py@@ -1,7 +1,7 @@"""CadQuery build wrapper — run by the harness in a subprocess, never imported.python run_cq.py --script /abs/src/model.py --out /abs/artifacts \- [--rlimit-gb 8] [--tri-limit 600000] [--tolerance 0.001] [--angular-tolerance 0.15] [--seed 0]+ [--rlimit-gb 8] [--tolerance 0.001] [--angular-tolerance 0.15] [--seed 0]Steps: RLIMIT_AS → seed → exec model.py with traceback→line mapping (``_wrapper_common``,shared with the Blender wrappers) → read the module-level ``result`` (cq.Assembly@@ -44,7 +44,6 @@ def parse_args(argv: list[str]) -> argparse.Namespace:p.add_argument("--script", required=True)p.add_argument("--out", required=True)p.add_argument("--rlimit-gb", type=float, default=8.0)- p.add_argument("--tri-limit", type=int, default=600_000)p.add_argument("--tolerance", type=float, default=0.001)p.add_argument("--angular-tolerance", type=float, default=0.15)p.add_argument("--seed", type=int, default=0)@@ -244,9 +243,6 @@ def main() -> int:if census["parts"]:census["scene_bbox_min"] = [min(p["bbox_min"][i] for p in census["parts"]) for i in range(3)]census["scene_bbox_max"] = [max(p["bbox_max"][i] for p in census["parts"]) for i in range(3)]- if census["tri_count"] > args.tri_limit:- err = {"error_type": "TriangleBudgetExceeded",- "error_message": f"{census['tri_count']} triangles > limit {args.tri_limit}; simplify (fewer pattern copies / coarser curves)"}glb = os.path.join(out_dir, GLB_NAME)build_glb(meshes, glb)report["exported"]["glb"] = glbdiff --git a/harness/tests/blender_cadquery/test_blender_runtime.py b/harness/tests/blender_cadquery/test_blender_runtime.pyindex fdb138dd..f3ca3f43 100644--- a/harness/tests/blender_cadquery/test_blender_runtime.py+++ b/harness/tests/blender_cadquery/test_blender_runtime.py@@ -94,3 +94,15 @@ def test_live_selfcheck_skips_hidden_cutters(tmp_ws, blender_bin) -> None:r = BlenderRuntime(blender=blender_bin).build(tmp_ws, timeout_s=120)assert r.ok, (r.error_type, r.error_message)assert "[selfcheck] 1 mesh objects, z_min=0.0050" in r.stdout_tail+++def test_live_triangle_count_is_not_a_build_error(tmp_ws, blender_bin) -> None:+ """Audit 2026-09-24 N22: a 720k-triangle object failed the Blender build+ (`TriangleBudgetExceeded`) while three.js built it clean; the depth gate is the one ceiling."""+ (tmp_ws.src / "model.py").write_text(+ "import bpy\nbpy.ops.mesh.primitive_grid_add(x_subdivisions=600, y_subdivisions=600, size=1)\n"+ "bpy.context.object.name = 'Sheet'\n")+ r = BlenderRuntime(blender=blender_bin).build(tmp_ws, timeout_s=120)+ assert r.ok and r.census["tri_count"] == 720_000, (r.error_type, r.error_message)+ assert not any("triangle" in w for w in r.census["warnings"])