Official Codebase of 3DCodeVerse
Python
object texts name instances Name_0.., the spelling the contract gate splits
gaoypengf2be65e02775
diff --git a/harness/codeverse3d/prompts/blender/contract.md b/harness/codeverse3d/prompts/blender/contract.mdindex 588ddcb1..2d0ed09f 100644--- a/harness/codeverse3d/prompts/blender/contract.md+++ b/harness/codeverse3d/prompts/blender/contract.md@@ -131,8 +131,8 @@ def build_seat() -> bpy.types.Object:def build_leg(i: int) -> bpy.types.Object:a, h = 2 * math.pi * i / LEG_N, SEAT_Z - SEAT_T + 0.001 # 1 mm into the seat (weld)- leg = make_cylinder(f"Leg{i + 1}", LEG_R, h, (LEG_RING * math.cos(a), LEG_RING * math.sin(a), h / 2), 24)- leg.data.materials.append(make_material(f"Steel{i + 1}", (0.6, 0.6, 0.62), 0.35, 1.0))+ leg = make_cylinder(f"Leg_{i}", LEG_R, h, (LEG_RING * math.cos(a), LEG_RING * math.sin(a), h / 2), 24)+ leg.data.materials.append(make_material(f"Steel_{i}", (0.6, 0.6, 0.62), 0.35, 1.0))return legdef _selfcheck() -> None:diff --git a/harness/codeverse3d/prompts/blender/cookbook.md b/harness/codeverse3d/prompts/blender/cookbook.mdindex 3d602a2e..0729dd61 100644--- a/harness/codeverse3d/prompts/blender/cookbook.md+++ b/harness/codeverse3d/prompts/blender/cookbook.md@@ -522,9 +522,9 @@ def separate_loose(obj) -> list:return [obj] + sorted(set(bpy.data.objects) - before, key=lambda o: o.name)legs = collection("Legs")-leg0 = make_cylinder("Leg1", 0.02, 0.42, (0.18, 0.18, 0.21), 16)-for i, (sx, sy) in enumerate([(-1, 1), (-1, -1), (1, -1)], start=2):- linked_copy(leg0, f"Leg{i}", (sx * 0.18, sy * 0.18, 0.21))+leg0 = make_cylinder("Leg_0", 0.02, 0.42, (0.18, 0.18, 0.21), 16)+for i, (sx, sy) in enumerate([(-1, 1), (-1, -1), (1, -1)], start=1):+ linked_copy(leg0, f"Leg_{i}", (sx * 0.18, sy * 0.18, 0.21))for o in bpy.data.objects:if o.name.startswith("Leg"): move_to(o, legs)```@@ -844,8 +844,8 @@ it part by part with what the density table adds.|---|---|---|---|| dining chair | 0.45 × 0.50 × 0.90 | Seat, Backrest, LegFrontLeft/Right, LegBackLeft/Right, Stretchers | seat h 0.45, seat t 0.04, leg Ø/□ 0.035, back top 0.90, back rake 8° || armchair / sofa seat | 0.85 × 0.90 × 0.85 (sofa W 1.8–2.2) | Base, SeatCushion(s), BackCushion(s), ArmLeft, ArmRight, Legs | seat h 0.42, cushion 0.10–0.12, arm h 0.60, arm w 0.15–0.25 |-| dining table | 1.6 × 0.9 × 0.75 | Top, Apron, Leg1..4 | top t 0.03–0.04, leg 0.07 □ at 0.05 inset |-| coffee table | 1.2 × 0.6 × 0.45 | Top, Leg1..4 or Base | top t 0.025 |+| dining table | 1.6 × 0.9 × 0.75 | Top, Apron, Leg ×4 | top t 0.03–0.04, leg 0.07 □ at 0.05 inset |+| coffee table | 1.2 × 0.6 × 0.45 | Top, Leg ×4 or Base | top t 0.025 || desk lamp | 0.18 Ø base, H 0.45–0.60 | Base, ArmLower, ArmUpper, Shade, Bulb | base t 0.02, arm Ø 0.012, shade Ø 0.15 h 0.12 || floor lamp | 0.30 Ø base, H 1.6 | Base, Pole, Shade | pole Ø 0.025, shade Ø 0.40 || mug | Ø 0.085 × 0.095 | MugBody, MugHandle | wall 4 mm, bottom 6 mm, handle tube Ø 12 mm |@@ -855,7 +855,7 @@ it part by part with what the density table adds.| house (small) | 10 × 8 × 7 | Walls, Roof, Door, Windows, Chimney, Steps | wall h 2.8/storey, roof pitch 30–40°, door 0.9 × 2.1, window 1.2 × 1.2 at sill 0.9 || tree (deciduous) | crown Ø 6–9, H 10–14 | Trunk, Branches, Crown(s) | trunk Ø 0.4 at base, first branch at 2.5, crown = 3–6 overlapping spheres || door | 0.9 × 0.045 × 2.05 | Leaf, Frame, Handle, Hinges | handle h 1.05, frame 0.07 wide |-| bookshelf | 0.80 × 0.30 × 1.80 | SideLeft, SideRight, Top, Bottom, Shelf1..4, Back | panel 18 mm, shelf pitch 0.33 |+| bookshelf | 0.80 × 0.30 × 1.80 | SideLeft, SideRight, Top, Bottom, Shelf ×4, Back | panel 18 mm, shelf pitch 0.33 || kitchen cabinet | 0.60 × 0.58 × 0.87 | Carcass, Door(s)/Drawer(s), Handle(s), Plinth | plinth h 0.10, front 18 mm, handle proud 30 mm || monitor | 0.62 × 0.20 × 0.45 | Panel, Stand, Base | panel t 0.02, bezel 8 mm, base 0.25 × 0.20 || keyboard | 0.44 × 0.14 × 0.03 | Body, Keys(instanced) | key 0.018 pitch 0.019 |@@ -920,7 +920,7 @@ def build_sail_rotor() -> bpy.types.Object:4. **Modifier apply fails "Modifier cannot be applied to a multi-user mesh"** →`obj.data = obj.data.copy()` first (`apply_modifiers` does it).5. **Names like `Leg.001`** → you created two objects/meshes with the same name; give every- instance its plan name (`Leg2`); rename meshes too if you care (`o.data.name = o.name`).+ instance its plan name (`Leg_2`); rename meshes too if you care (`o.data.name = o.name`).6. **Boolean does nothing / leaves holes** → cutter coplanar with a face or not closed.Overshoot the cutter by ≥ 5 mm, make it watertight (`cap_ends=True`), use `EXACT`.7. **Dark/inverted shading, inside-out parts** → flipped normals after `bmesh.ops.scale`diff --git a/harness/codeverse3d/prompts/cadquery/contract.md b/harness/codeverse3d/prompts/cadquery/contract.mdindex ad38abcf..20e10483 100644--- a/harness/codeverse3d/prompts/cadquery/contract.md+++ b/harness/codeverse3d/prompts/cadquery/contract.md@@ -74,7 +74,7 @@ def build_leg(sx: int, sy: int) -> cq.Workplane:assy = cq.Assembly(name="SideTable")assy.add(build_top(), name="Top", color=cq.Color(0.55, 0.33, 0.16))for i, (sx, sy) in enumerate([(1, 1), (-1, 1), (-1, -1), (1, -1)]):- assy.add(build_leg(sx, sy), name=f"Leg{i + 1}", color=cq.Color(0.2, 0.2, 0.22))+ assy.add(build_leg(sx, sy), name=f"Leg_{i}", color=cq.Color(0.2, 0.2, 0.22))_selfcheck(assy)result = assydiff --git a/harness/codeverse3d/prompts/cadquery/cookbook.md b/harness/codeverse3d/prompts/cadquery/cookbook.mdindex ca0776f8..b3c1ab91 100644--- a/harness/codeverse3d/prompts/cadquery/cookbook.md+++ b/harness/codeverse3d/prompts/cadquery/cookbook.md@@ -183,7 +183,7 @@ stool.add(seat, name="Seat", color=cq.Color(0.55, 0.34, 0.16))leg = cq.Workplane("XY").circle(0.015).extrude(0.41 + WELD) # authored at the originfor i in range(3):a = math.radians(90 + 120 * i)- stool.add(leg, name=f"Leg{i + 1}", color=cq.Color(0.3, 0.3, 0.32),+ stool.add(leg, name=f"Leg_{i}", color=cq.Color(0.3, 0.3, 0.32),loc=place(leg, (0.12 * math.cos(a), 0.12 * math.sin(a), 0)))# sub-assemblies nest: stool.add(other_assy, name="Footrest", loc=...)names = [c.name for c in stool.children]@@ -363,7 +363,7 @@ def selfcheck(assy: cq.Assembly, expected_parts, overall_hint=None, tol=0.01) ->for a, b in zip(ext, overall_hint):assert abs(a - b) < 0.05, f"extents {ext} vs plan {overall_hint}"-selfcheck(stool, ["Seat", "Leg1", "Leg2", "Leg3"], (0.34, 0.34, 0.45))+selfcheck(stool, ["Seat", "Leg_0", "Leg_1", "Leg_2"], (0.34, 0.34, 0.45))selfcheck(result, ["Body", "Lid"])```@@ -399,13 +399,13 @@ def chair_back():chair = cq.Assembly(name="DiningChair")chair.add(chair_seat(), name="Seat", color=cq.Color(0.6, 0.4, 0.2))for i, (sx, sy) in enumerate([(1, 1), (-1, 1), (-1, -1), (1, -1)]):- chair.add(chair_leg(SEAT_H - SEAT_T), name=f"Leg{i + 1}", color=cq.Color(0.45, 0.3, 0.15),+ chair.add(chair_leg(SEAT_H - SEAT_T), name=f"Leg_{i}", color=cq.Color(0.45, 0.3, 0.15),loc=cq.Location(cq.Vector(sx * (SEAT_W / 2 - LEG / 2 - 0.01), sy * (SEAT_D / 2 - LEG / 2 - 0.01), 0)))chair.add(chair_back(), name="Backrest", color=cq.Color(0.45, 0.3, 0.15))stretch = cq.Workplane("XY").box(SEAT_W - LEG - 0.02 + 2 * WELD, 0.02, 0.02).translate((0, 0, 0.20))chair.add(stretch.translate((0, SEAT_D / 2 - LEG / 2 - 0.01, 0)), name="StretcherBack", color=cq.Color(0.45, 0.3, 0.15))chair.add(stretch.translate((0, -(SEAT_D / 2 - LEG / 2 - 0.01), 0)), name="StretcherFront", color=cq.Color(0.45, 0.3, 0.15))-selfcheck(chair, ["Seat", "Leg1", "Leg2", "Leg3", "Leg4", "Backrest", "StretcherBack", "StretcherFront"])+selfcheck(chair, ["Seat", "Leg_0", "Leg_1", "Leg_2", "Leg_3", "Backrest", "StretcherBack", "StretcherFront"])```Why: the plan's numbers appear once as constants; legs are one solid placed four times;diff --git a/harness/codeverse3d/prompts/threejs/contract.md b/harness/codeverse3d/prompts/threejs/contract.mdindex 99732e6a..c5a88dbd 100644--- a/harness/codeverse3d/prompts/threejs/contract.md+++ b/harness/codeverse3d/prompts/threejs/contract.md@@ -24,7 +24,7 @@ The harness loads `src/object.js` in node, calls `build(THREE)`, and exports## Naming* Part Group: `g.name = "<PartName>"` — PascalCase exactly as the plan (`SeatCushion`);meshes inside may be unnamed or `<PartName>_<detail>`. Unique names; instances get- their own names (`Leg1`…`Leg4`) even if built by one function.+ their own names (`Leg_0`…`Leg_3`) even if built by one function.* Optional animation hook: `root.userData.tick = (dt) => { ... }` on a pivot Group(position + rotation only; identity scale). No other userData contract.@@ -85,7 +85,7 @@ export function buildLegs(THREE) {const geo = new THREE.CylinderGeometry(LEG_R, LEG_R, LEG_H, 24);const mat = new THREE.MeshStandardMaterial({ color: 0x555a60, roughness: 0.35, metalness: 0.9 });[[1, 1], [-1, 1], [-1, -1], [1, -1]].forEach(([sx, sz], i) => {- const m = new THREE.Mesh(geo, mat); m.name = `Leg${i + 1}`;+ const m = new THREE.Mesh(geo, mat); m.name = `Leg_${i}`;m.position.set(sx * LEG_XZ, LEG_H / 2, sz * LEG_XZ);g.add(m);});diff --git a/harness/codeverse3d/prompts/threejs/cookbook.md b/harness/codeverse3d/prompts/threejs/cookbook.mdindex c133bce2..53aeda7f 100644--- a/harness/codeverse3d/prompts/threejs/cookbook.md+++ b/harness/codeverse3d/prompts/threejs/cookbook.md@@ -36,7 +36,7 @@ export function buildLegs(THREE) {const g = new THREE.Group(); g.name = 'Legs';const geo = new THREE.BoxGeometry(LEG, SEAT_H - SEAT_T + WELD, LEG);[[1, 1], [-1, 1], [-1, -1], [1, -1]].forEach(([sx, sz], i) =>- g.add(mesh(geo, MAT.oak(), `Leg${i + 1}`, sx * (SEAT_W / 2 - LEG / 2 - 0.01),+ g.add(mesh(geo, MAT.oak(), `Leg_${i}`, sx * (SEAT_W / 2 - LEG / 2 - 0.01),(SEAT_H - SEAT_T + WELD) / 2, sz * (SEAT_D / 2 - LEG / 2 - 0.01))));return g;}@@ -121,7 +121,7 @@ function buildFan(THREE) {const bladeGeo = new THREE.BoxGeometry(0.02, 0.4, 0.004).translate(0, 0.25, 0); // blade root at the hubfor (let i = 0; i < 3; i++) {const b = new THREE.Mesh(bladeGeo, new THREE.MeshStandardMaterial({ color: 0xdddddd }));- b.name = `Blade${i + 1}`; b.rotation.z = i * Math.PI * 2 / 3; hub.add(b);+ b.name = `Blade_${i}`; b.rotation.z = i * Math.PI * 2 / 3; hub.add(b);}g.add(hub);g.userData.tick = (dt) => { hub.rotation.z += dt * 2.0; }; // rad/s@@ -348,9 +348,9 @@ if (densityTris < 3000) throw new Error('density recipes produced almost no geom| object | W × D × H | parts | key numbers ||---|---|---|---|-| dining chair | 0.45 × 0.50 × 0.90 | Seat, Backrest, Leg1..4, Stretchers | seat y 0.45, t 0.035, leg 0.035, rake 8° |-| sofa | 2.0 × 0.9 × 0.85 | Base, SeatCushion1..3, BackCushion1..3, ArmLeft/Right, Legs | seat y 0.42, arm y 0.60, cushion 0.11 |-| table | 1.6 × 0.9 × 0.75 | Top, Apron, Leg1..4 | top t 0.035, legs 0.07 at 0.05 inset |+| dining chair | 0.45 × 0.50 × 0.90 | Seat, Backrest, Leg ×4, Stretchers | seat y 0.45, t 0.035, leg 0.035, rake 8° |+| sofa | 2.0 × 0.9 × 0.85 | Base, SeatCushion ×3, BackCushion ×3, ArmLeft/Right, Legs | seat y 0.42, arm y 0.60, cushion 0.11 |+| table | 1.6 × 0.9 × 0.75 | Top, Apron, Leg ×4 | top t 0.035, legs 0.07 at 0.05 inset || desk lamp | Ø 0.18 × 0.55 | Base, ArmLower, ArmUpper, Shade, Bulb | arm Ø 0.012, shade Ø 0.15 || mug | Ø 0.085 × 0.095 | Body (Lathe), Handle (Tube) | wall 4 mm, handle Ø 12 mm || bottle | Ø 0.075 × 0.30 | Body (Lathe), Cap | neck Ø 0.028 |@@ -358,7 +358,7 @@ if (densityTris < 3000) throw new Error('density recipes produced almost no geom| car | 4.6 × 1.85 × 1.45 | Body(Extrude side profile), Cabin, Wheel×4, Bumpers, Mirrors, Lights | wheel Ø 0.65, wheelbase 2.7, clearance 0.15 || house | 10 × 8 × 7 | Walls, Roof(Extrude triangle), Door, Windows, Chimney | storey 2.8, pitch 35°, door 0.9 × 2.1 || tree | crown Ø 7 × H 12 | Trunk(Cylinder taper), Branches(Tube), Crown(3–6 spheres, vertex colours) | trunk Ø 0.4 |-| bookshelf | 0.8 × 0.3 × 1.8 | SideLeft/Right, Top, Bottom, Shelf1..4, Back | panel 18 mm |+| bookshelf | 0.8 × 0.3 × 1.8 | SideLeft/Right, Top, Bottom, Shelf ×4, Back | panel 18 mm || monitor | 0.62 × 0.2 × 0.45 | Panel, Stand, Base | bezel 8 mm |Decomposition: 1 main mass → 2–6 secondary masses touching it → attachments overlapping@@ -464,7 +464,7 @@ export function selfcheck(THREE, root, expectedNames = [], extentsHint = null) {console.log(`[selfcheck] parts=${names.size} tris=${tris} extents=${size.toArray().map(v => v.toFixed(3))}`);return { tris, size };}-selfcheck(THREE, build(THREE), ['Seat', 'Legs', 'Leg1', 'Leg4'], [0.44, 0.45, 0.44]);+selfcheck(THREE, build(THREE), ['Seat', 'Legs', 'Leg_0', 'Leg_3'], [0.44, 0.45, 0.44]);```The harness also calls an exported `selfcheck(THREE, root)` on the built group (defaultsabove make that call permissive); a throw fails the build as `SelfCheckError` with yourdiff --git a/harness/codeverse3d/prompts/tracks/generate_static.j2 b/harness/codeverse3d/prompts/tracks/generate_static.j2index ef4beba3..f06d9636 100644--- a/harness/codeverse3d/prompts/tracks/generate_static.j2+++ b/harness/codeverse3d/prompts/tracks/generate_static.j2@@ -46,8 +46,8 @@ Construction notes per part:with the stated radii and counts. Primitives alone are not enough; combine and shape them.- Materials per part with the stated colour (sRGB hex or 0-1 floats); roughness/metalness sensible.- Segments 24-48 for round things.-- Name parts EXACTLY as in the table (PascalCase). One named node/object per part (instances may- be `Name`, `Name_2`, … or a single parent named `Name`).+- Name parts EXACTLY as in the table (PascalCase). One named node/object per part; the+ instances of a part are top-level nodes `Name_0`, `Name_1`, ….## Detail{{ detail_advice }}diff --git a/harness/codeverse3d/prompts/urdf/cookbook.md b/harness/codeverse3d/prompts/urdf/cookbook.mdindex d26f27db..ba9fce62 100644--- a/harness/codeverse3d/prompts/urdf/cookbook.md+++ b/harness/codeverse3d/prompts/urdf/cookbook.md@@ -230,7 +230,7 @@ WR, WT = 0.10, 0.03 # wheel radius / widthPOST_Y, POST_Z0, POST_H, POST_W, WALL = CD / 2 - 0.016, WR + CH, 0.60, 0.032, 0.003deck = make_box("deck", (CW, CD, CH), (0, 0, WR + CH / 2)) # deck rides above the axle height# the handle post is a HOLLOW square tube (4 walls) so the telescopic grip can slide inside it-walls = [make_box(f"deck_post_w{i}", s, c) for i, (s, c) in enumerate([+walls = [make_box(f"deck_post_w_{i}", s, c) for i, (s, c) in enumerate([((POST_W, WALL, POST_H), (0, POST_Y - POST_W / 2 + WALL / 2, POST_Z0 + POST_H / 2)),((POST_W, WALL, POST_H), (0, POST_Y + POST_W / 2 - WALL / 2, POST_Z0 + POST_H / 2)),((WALL, POST_W - 2 * WALL, POST_H), (-POST_W / 2 + WALL / 2, POST_Y, POST_Z0 + POST_H / 2)),diff --git a/harness/codeverse3d/skills/c3d-repeats-and-mirrors/SKILL.md b/harness/codeverse3d/skills/c3d-repeats-and-mirrors/SKILL.mdindex 38fa87a0..4a658f73 100644--- a/harness/codeverse3d/skills/c3d-repeats-and-mirrors/SKILL.md+++ b/harness/codeverse3d/skills/c3d-repeats-and-mirrors/SKILL.md@@ -28,7 +28,7 @@ of the plan row. A hand-typed second copy is how the pair stops matching.`check_contract` (`spatial/contract.py`) treats an instanced part differently from a single part.* **Naming.** The gate first claims the node named exactly like the plan part, then claims- `Name_0`, `Name_1`, ... (regex `^name([_.-]?\d{1,3})?$`, so `Leg1` and `Leg.2` also match).+ `Name_0`, `Name_1`, ... (`Leg1`, with no separator, is NOT an instance of `Leg`).A node whose name is exactly *another* plan part's name is never stolen. Use`Name_0 .. Name_{N-1}` — that is the string the gate's own fix hint asks for.* **Count.** `instances = N` but a different number of nodes found is a WARN:diff --git a/harness/codeverse3d/skills/c3d-repeats-and-mirrors/references/instances.md b/harness/codeverse3d/skills/c3d-repeats-and-mirrors/references/instances.mdindex cb596abc..66b55e58 100644--- a/harness/codeverse3d/skills/c3d-repeats-and-mirrors/references/instances.md+++ b/harness/codeverse3d/skills/c3d-repeats-and-mirrors/references/instances.md@@ -11,9 +11,9 @@ Everything here was read out of the live harness on 2026-08-25:1. **Exact pass.** For each plan part, claim every node whose `to_snake(name)` equals the planpart's `to_snake(name)`.-2. **Instance pass.** For each plan part, claim the remaining nodes matching- `^{snake}(?:[_.-]?\d{1,3})?$` — but never a node whose snake name is *reserved*, i.e. is the- exact snake name of some other plan part.+2. **Instance pass.** For each plan part, claim the remaining nodes named `{snake}`, a+ separator (`_`, `.` or `-`) and one to three digits (`conventions.split_instance`) — but never+ a node whose snake name is *reserved*, i.e. is the exact snake name of some other plan part.Pass 2's reservation exists because of a real regression: a plan with `Shelf` and `Shelf2` had`Shelf` swallow the `Shelf2` node, producing a false `plan part 'Shelf2' is missing from the@@ -21,8 +21,8 @@ GLB` ERROR on geometry that matched the plan exactly.Consequences you can act on:-* `Leg_0`, `Leg.1`, `Leg-2`, `Leg3` all count as instances of plan part `Leg`. Only up to three- digits.+* `Leg_0`, `Leg.1`, `Leg-2` all count as instances of plan part `Leg`; `Leg3` does NOT (no+ separator: it is another name, so plan part `Leg` is reported missing). Only up to three digits.* Blender's auto-suffix `Leg.001` also matches (3 digits) — but do not rely on it; auto-suffixesmean you created a name collision and the numbering is not yours.* `LegFront` does **not** match `Leg` (the regex allows digits only after the stem).diff --git a/harness/tests/skills/test_contract_agreement.py b/harness/tests/skills/test_contract_agreement.pyindex 4452d92e..fe0c0aba 100644--- a/harness/tests/skills/test_contract_agreement.py+++ b/harness/tests/skills/test_contract_agreement.py@@ -134,3 +134,21 @@ def test_skill_advice_respects_gates_and_language_contracts():f"{skill.name} recommends {api!r}, forbidden by {language}/contract.md:\n"f" {' '.join(paragraph.split())[:160]}")+++#: a node name built from a loop index with nothing between the stem and the index+#: (``f"Leg{i + 1}"``, `` `Leg${i}` ``): `conventions.split_instance` does not split it+_GLUED_INDEX = re.compile(r"[A-Za-z]\$?\{i\b")+_OBJECT_TEXTS = [p for d in ("blender", "cadquery", "threejs", "urdf") for p in sorted((PROMPTS / d).glob("*.md"))] \+ + sorted((PROMPTS / "tracks").glob("generate_*.j2")) + sorted(skills_dir().rglob("*.md"))+++def test_object_texts_name_instances_the_way_the_gate_splits_them():+ """Audit 2026-09-24 N1: the contracts' own examples named copies ``Leg1``..``Leg4``, which+ the contract gate does not count as instances of plan part ``Leg`` (missing-part ERROR)."""+ from codeverse3d.conventions import split_instance, to_snake++ assert split_instance(to_snake("Leg1")) == ("leg1", "") and split_instance(to_snake("Leg_1")) == ("leg", "1")+ glued = [f"{p.relative_to(HARNESS)}:{n}: {line.strip()}" for p in _OBJECT_TEXTS+ for n, line in enumerate(p.read_text().splitlines(), 1) if _GLUED_INDEX.search(line)]+ assert not glued, "name instances Name_{i}:\n" + "\n".join(glued)