Official Codebase of 3DCodeVerse
Python
languages: one place decides where a language's prompt text lives
gaoypeng27eb9625631c
diff --git a/harness/codeverse/languages/_docs.py b/harness/codeverse/languages/_docs.pynew file mode 100644index 00000000..d5f1de0f--- /dev/null+++ b/harness/codeverse/languages/_docs.py@@ -0,0 +1,53 @@+"""Where a language's prompt text lives — one resolver for all seven runtimes.++Each runtime used to spell this out itself, and in three different shapes: a+``Path.is_file()`` check falling back to a packaged ``CONTRACT.md``; a+``try: load_text(...) except FileNotFoundError`` falling back to an inline string;+and urdf's variant of the second. The only thing that actually differed was the+directory name, so it is a declaration now (2026-08-28).++The packaged ``languages/<lang>/CONTRACT.md`` fallbacks went with the merge: they+were unreachable in any installed state (``pyproject`` ships ``prompts/**/*``, and+every ``contract_doc`` read ``prompts/`` first), and two of their numbers had drifted+out of agreement with ``conventions.py`` — 500 k triangles against+``MAX_TRIS_OBJECT = 600_000``, and a 120 s build budget against 300 s. A second home+for a fact is a second answer, which is what law 2 exists to prevent.+"""++from __future__ import annotations++from pathlib import Path++from codeverse.contracts.common import Language+from codeverse.prompts import PROMPTS_DIR, load_text++#: ``Language.URDF_BLENDER`` is ``"urdf_blender"`` but its prompts live in+#: ``prompts/urdf/``. ONE mapping, here — it was written out three more times+#: across spatial/ and tests/, and silently missing in tracks/common.py.+PROMPT_DIRS: dict[Language, str] = {Language.URDF_BLENDER: "urdf"}++#: only reachable if the wheel shipped without its prompt data+MINIMAL_CONTRACT = "Write raw code in the language's native frame; meters; named parts."+++def prompt_dir_for(language: Language) -> str:+ return PROMPT_DIRS.get(language, language.value)+++class RuntimeDocs:+ """``contract_doc`` / ``cookbook_path`` for every ``LanguageRuntime``."""++ language: Language++ @property+ def prompt_dir(self) -> str:+ return prompt_dir_for(self.language)++ def contract_doc(self) -> str:+ try:+ return load_text(f"{self.prompt_dir}/contract.md")+ except FileNotFoundError:+ return MINIMAL_CONTRACT++ def cookbook_path(self) -> Path:+ return PROMPTS_DIR / self.prompt_dir / "cookbook.md"diff --git a/harness/codeverse/languages/blender/CONTRACT.md b/harness/codeverse/languages/blender/CONTRACT.mddeleted file mode 100644index b8b732e3..00000000--- a/harness/codeverse/languages/blender/CONTRACT.md+++ /dev/null@@ -1,77 +0,0 @@-# Blender (bpy) authoring contract--You write **raw bpy** (Blender 5.x Python API) in a multi-file layout:--* `src/model.py` — the ENTRY: imports the part builders, calls them in plan order, self-checks.- No geometry of its own beyond small glue.-* `src/parts/<snake>.py` — ONE per plan part (`SeatCushion` → `src/parts/seat_cushion.py`), exporting- `def build_seat_cushion() -> bpy.types.Object` that builds the part at its WORLD pose with the exact- object name(s) and returns it (instances `Leg_0..Leg_3` looped inside that one file). Self-contained;- it only DEFINES — never builds at import time. `src/` is on `sys.path`:- `from parts.seat_cushion import build_seat_cushion`. Small objects (1–2 parts) may use one `src/model.py`.--The harness runs `blender -b --factory-startup --python run_bpy.py -- --script src/model.py` in an-**EMPTY scene** (no Cube/Camera/Light), reports errors as `src/parts/<file>.py:<line>`, and exports-`artifacts/object.glb` (+ `object.stl`) itself.--## Frame, units, placement-* **Z is up, -Y is the front** of the object, +X is its right. **Units are meters.**-* The object **stands on z = 0** (lowest point at z = 0) and its footprint is **centred on the Z axis**.-* Dimensions come from the plan's bboxes: respect them to ±1 cm; parts that "attach" must touch (no gaps).--## Objects and names-* One mesh object per part, **named exactly as the plan's PascalCase part name** (`SeatCushion`).- Instances: `Leg_0 … Leg_3`, each a TOP-LEVEL object. **Never parent instances under an- Empty** — the harness measures top-level GLB nodes as parts, so an Empty parent merges all- instances into one part and the plan part is reported missing.-* Helper objects (boolean cutters) must be removed or hidden- (`cutter.hide_set(True); cutter.hide_render = True`) — visible objects are exported as-is.-* Modifiers (bevel, subdivision, boolean, array, solidify, mirror) may stay unapplied:- the exporter applies them. Keep the total under **500 k triangles** and finish in **< 120 s**.--## Materials-* Every visible mesh gets a material: `mat = bpy.data.materials.new(name)`;- `bsdf = mat.node_tree.nodes["Principled BSDF"]`; set `inputs["Base Color"]`, `["Roughness"]`, `["Metallic"]`.- (Blender 4+/5 input names: "Specular IOR Level", "Subsurface Weight", "Transmission Weight",- "Coat Weight", "Sheen Weight", "Emission Color" / "Emission Strength".)-* The GLB keeps only **flat PBR values + image textures + vertex colours**. Procedural node textures- (Noise, Voronoi, Wave …) are NOT exported — express detail with geometry and flat PBR per part.--## Forbidden (the harness owns these; the lint rejects them)-* cameras, lights, world/background, render settings, `bpy.ops.render.*`-* `bpy.ops.export_*`, `bpy.ops.import_*`, `bpy.ops.wm.*`, `bpy.data.libraries`, `open()`, os/shutil/subprocess/network-* imports other than `bpy, bmesh, mathutils, math, random (seeded), numpy` (+ stdlib data helpers)--## Headless pitfalls (these cause most build failures)-* `bpy.ops.*` act on the **selection/active object**: grab `obj = bpy.context.object` right after- `primitive_*_add`; do not rely on `bpy.context.selected_objects`.-* `primitive_cube_add(size=1, scale=(sx,sy,sz))` then- `bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)` — pass all three flags.-* bmesh: call `bm.verts.ensure_lookup_table()` (and edges/faces) before `bm.verts[i]`; finish with- `bm.to_mesh(me); bm.free(); me.update()`.-* `modifier_apply` needs the object active + selected in OBJECT mode — or leave modifiers to the exporter.-* `bpy.ops.object.join` inherits the ACTIVE object's transform — prefer separate named parts.-* `use_auto_smooth` is gone: use `bpy.ops.object.shade_smooth_by_angle(angle=0.52)` or `shade_smooth()`.-* Context dict overrides `bpy.ops.x({...})` are gone: `with bpy.context.temp_override(object=obj): ...`.-* World AABB: `[obj.matrix_world @ Vector(c) for c in obj.bound_box]` after `bpy.context.view_layer.update()`.--## Minimal example (copy the pattern; as a part file: wrap the body in `def build_table_top():` and return `top`)-```python-import bpy-import math--def make_material(name, rgb, roughness=0.5, metallic=0.0):- mat = bpy.data.materials.new(name)- bsdf = mat.node_tree.nodes["Principled BSDF"]- bsdf.inputs["Base Color"].default_value = (*rgb, 1.0)- bsdf.inputs["Roughness"].default_value = roughness- bsdf.inputs["Metallic"].default_value = metallic- return mat--bpy.ops.mesh.primitive_cube_add(size=1, location=(0, 0, 0.02), scale=(0.4, 0.3, 0.04))-top = bpy.context.object-top.name = "TableTop"-bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)-top.data.materials.append(make_material("Oak", (0.55, 0.36, 0.2), roughness=0.6))-bev = top.modifiers.new("Bevel", "BEVEL"); bev.width = 0.005; bev.segments = 3-```diff --git a/harness/codeverse/languages/blender/__init__.py b/harness/codeverse/languages/blender/__init__.pyindex 82505c14..e570d723 100644--- a/harness/codeverse/languages/blender/__init__.py+++ b/harness/codeverse/languages/blender/__init__.py@@ -26,8 +26,8 @@ from codeverse.languages._common import (run_subprocess,strip_blender_noise,)+from codeverse.languages._docs import RuntimeDocsfrom codeverse.proc import scrub_secrets-from codeverse.prompts import PROMPTS_DIRfrom codeverse.workspace import Workspace# ===================================================================== lint@@ -721,7 +721,7 @@ def blender_env() -> dict[str, str]:return env-class BlenderRuntime:+class BlenderRuntime(RuntimeDocs):"""LanguageRuntime for ``Language.BLENDER``."""language = Language.BLENDER@@ -814,11 +814,3 @@ class BlenderRuntime:glb_path=glb, extra_paths={"stl": stl_path, "blend": blend_path}, output_filter=strip_blender_noise,)- def contract_doc(self) -> str:- p = PROMPTS_DIR / "blender" / "contract.md"- if p.is_file():- return p.read_text()- return (_PKG_DIR / "CONTRACT.md").read_text()-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "blender" / "cookbook.md"diff --git a/harness/codeverse/languages/cadquery/CONTRACT.md b/harness/codeverse/languages/cadquery/CONTRACT.mddeleted file mode 100644index 5e699960..00000000--- a/harness/codeverse/languages/cadquery/CONTRACT.md+++ /dev/null@@ -1,52 +0,0 @@-# CadQuery authoring contract--You write ONE file, `src/model.py`, in **raw CadQuery** (`import cadquery as cq`, plus `math` /-`random`). The harness imports it in a sandboxed subprocess, reads the module-level `result` and-exports `artifacts/object.glb` (Y-up, named nodes, part colours), `object.step` and `object.stl` itself.--## Frame, units, placement-* **Z is up, -Y is the front**, +X is the right. **Units are meters.**-* The object **stands on z = 0** and its footprint is **centred on the Z axis**.-* Respect the plan bboxes to ±1 cm; attached parts must touch (tiny overlaps are fine, gaps are not).--## `result`-* **Preferred**: `result = cq.Assembly()` with one `.add(shape, name="PascalName", color=cq.Color(r, g, b))`- per part. Names are the plan's PascalCase part names; instances `Leg_0 … Leg_3`.- Place instances with `loc=cq.Location(cq.Vector(x, y, z))` (shape built at the origin), or translate the shape.- Sub-assemblies are allowed (`legs = cq.Assembly(); ... ; result.add(legs, name="Legs")`).-* Acceptable: `result = <cq.Workplane>` — exported as ONE grey node (no part names → weaker judging).-* `result` must exist **at module level after import** (not only under `if __name__ == "__main__":`).--## Forbidden (lint rejects)-* file IO, `open()`, `cq.exporters.*`, `cq.importers.*`, `.save()` / `.export()`, `show_object()`, `exit()`-* imports other than `cadquery`, `math`, `random`, `numpy` (+ stdlib data helpers)--## CadQuery pitfalls (most build failures)-* `cq.Workplane("XY").box(x, y, z)` is **centred** at the origin; `.cylinder(height, radius)` — height first;- `.circle(r).extrude(h)` starts at the workplane (z = 0) and goes +Z.-* `.translate()`, `.rotate()`, `.mirror()` return **new** objects — always reassign.-* `.rotate(axisStart, axisEnd, angle)` and `cq.Location(vec, axis, angle)` take **degrees**.-* Fillets/chamfers fail with `BRep_API: command not done` when the radius ≥ the adjacent wall thickness- or neighbouring fillets conflict: keep radius < 0.45 × min thickness, fillet few edges- (`.edges("|Z")`, `.edges(">Z")`), fillet before booleans, wrap cosmetic fillets in `try/except`.-* String selectors (`|Z`, `>X`, `%CIRCLE`) are axis aligned; after booleans re-select by geometry, never by index.-* `cq.Solid.makeSphere(r)` → use `cq.Workplane().sphere(r)`; `makeCone(r1, r2, h)` has its base at z = 0.-* Sweeps/lofts: profile perpendicular to the path start; `sweep(path, isFrenet=True)`; loft wires same orientation.-* Revolve on `"XZ"`: `cq.Workplane("XZ").polyline(pts).close().revolve(360, (0, 0, 0), (0, 1, 0))` —- the axis is in workplane-local coordinates (local Y = world Z); the profile must not cross the axis.-* Keep features ≥ 1e-4 m (OCC tolerance is 1e-7); avoid zero-thickness faces; `.clean()` after unions.-* Patterns: `.rarray()`, `.polarArray()`, `.pushPoints()` beat Python loops of `.union()`.--## Minimal example (copy the pattern)-```python-import cadquery as cq--top = cq.Workplane("XY").box(0.5, 0.5, 0.04).edges("|Z").fillet(0.02).translate((0, 0, 0.58))-leg = cq.Workplane("XY").box(0.04, 0.04, 0.56)--result = cq.Assembly(name="SideTable")-result.add(top, name="TableTop", color=cq.Color(0.55, 0.36, 0.2))-for i, (sx, sy) in enumerate([(1, -1), (-1, -1), (-1, 1), (1, 1)]):- result.add(leg, name=f"Leg_{i}", loc=cq.Location(cq.Vector(sx * 0.21, sy * 0.21, 0.28)),- color=cq.Color(0.55, 0.36, 0.2))-```diff --git a/harness/codeverse/languages/cadquery/__init__.py b/harness/codeverse/languages/cadquery/__init__.pyindex 66f90e9f..18667e94 100644--- a/harness/codeverse/languages/cadquery/__init__.py+++ b/harness/codeverse/languages/cadquery/__init__.py@@ -22,9 +22,9 @@ from codeverse.languages._ast_lint import ( # noqa: F401 — dotted re-exportedsafe_parse,)from codeverse.languages._common import compose_build_result, run_subprocess+from codeverse.languages._docs import RuntimeDocsfrom codeverse.languages.blender import finish_for, instance_centersfrom codeverse.proc import scrub_secrets-from codeverse.prompts import PROMPTS_DIRfrom codeverse.workspace import Workspace# ===================================================================== lint@@ -336,7 +336,7 @@ def cadquery_env() -> dict[str, str]:return env-class CadQueryRuntime:+class CadQueryRuntime(RuntimeDocs):"""LanguageRuntime for ``Language.CADQUERY``."""language = Language.CADQUERY@@ -385,11 +385,3 @@ class CadQueryRuntime:return compose_build_result(language=self.language.value, proc=proc, build_json=build_json, census_json=census_json,glb_path=glb, extra_paths={"step": step, "stl": stl})- def contract_doc(self) -> str:- p = PROMPTS_DIR / "cadquery" / "contract.md"- if p.is_file():- return p.read_text()- return (_PKG_DIR / "CONTRACT.md").read_text()-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "cadquery" / "cookbook.md"diff --git a/harness/codeverse/languages/glsl_shader/__init__.py b/harness/codeverse/languages/glsl_shader/__init__.pyindex 3816bdd2..071db05c 100644--- a/harness/codeverse/languages/glsl_shader/__init__.py+++ b/harness/codeverse/languages/glsl_shader/__init__.py@@ -10,6 +10,7 @@ from pathlib import Pathfrom codeverse.contracts.artifacts import BuildResult, GateFinding, GateReport, Severityfrom codeverse.contracts.common import ENTRY_FILE, Languagefrom codeverse.contracts.plan import GraphicsPlan, Plan+from codeverse.languages._docs import RuntimeDocsfrom codeverse.languages._gl_common import ( # noqa: F401 — re-exportedGlslMessage,LineMap,@@ -23,7 +24,6 @@ from codeverse.languages._gl_common import ( # noqa: F401 — re-exportedpreview_times,resolution_for,)-from codeverse.prompts import PROMPTS_DIR, load_textfrom codeverse.spatial.gl_render import GlHost, GlResultfrom codeverse.workspace import Workspace@@ -389,7 +389,7 @@ u_mouse, u_frame, u_prev (previous frame), u_noise (256² noise), u_buffer_a (srOptional src/common.glsl (helpers, pasted in first) and src/buffer_a.frag (one feedback pass). Animate with u_time."""-class GlslShaderRuntime:+class GlslShaderRuntime(RuntimeDocs):language = Language.GLSL_SHADERentry_globs: tuple[str, ...] = (ENTRY_FILE[Language.GLSL_SHADER], COMMON, BUFFER_A)@@ -397,14 +397,6 @@ class GlslShaderRuntime:self._host = host# ------------------------------------------------------------------ contract- def contract_doc(self) -> str:- try:- return load_text("glsl_shader/contract.md")- except FileNotFoundError:- return CONTRACT_FALLBACK-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "glsl_shader" / "cookbook.md"# ------------------------------------------------------------------ skeleton / lintdef skeleton(self, ws: Workspace, plan: Plan | None) -> list[Path]:diff --git a/harness/codeverse/languages/opengl_python/__init__.py b/harness/codeverse/languages/opengl_python/__init__.pyindex 329dedb9..98611a7d 100644--- a/harness/codeverse/languages/opengl_python/__init__.py+++ b/harness/codeverse/languages/opengl_python/__init__.py@@ -15,6 +15,7 @@ from codeverse.languages._ast_lint import (describe_parse_failure,safe_parse,)+from codeverse.languages._docs import RuntimeDocsfrom codeverse.languages._gl_common import (finish_build,invalidate_stale_outputs,@@ -26,7 +27,6 @@ from codeverse.languages._gl_common import (resolution_for,traceback_location,)-from codeverse.prompts import PROMPTS_DIR, load_textfrom codeverse.spatial.gl_render import GlHost, GlResultfrom codeverse.workspace import Workspace@@ -345,7 +345,7 @@ already bound framebuffer; multi-pass via your own FBOs, finish with fbo.use()).no file IO (except src/*.glsl next to program.py). Imports: moderngl, numpy, math, random, struct, array, pathlib."""-class OpenGLPythonRuntime:+class OpenGLPythonRuntime(RuntimeDocs):language = Language.OPENGL_PYTHONentry_globs: tuple[str, ...] = (ENTRY_FILE[Language.OPENGL_PYTHON], "src/*.glsl")@@ -353,14 +353,6 @@ class OpenGLPythonRuntime:self._host = host# ------------------------------------------------------------------ contract- def contract_doc(self) -> str:- try:- return load_text("opengl_python/contract.md")- except FileNotFoundError:- return CONTRACT_FALLBACK-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "opengl_python" / "cookbook.md"# ------------------------------------------------------------------ skeleton / lintdef skeleton(self, ws: Workspace, plan: Plan | None) -> list[Path]:diff --git a/harness/codeverse/languages/scene_threejs/CONTRACT.md b/harness/codeverse/languages/scene_threejs/CONTRACT.mddeleted file mode 100644index 67d891b1..00000000--- a/harness/codeverse/languages/scene_threejs/CONTRACT.md+++ /dev/null@@ -1,74 +0,0 @@-# scene_threejs — authoring contract--You write a **multi-file three.js scene in raw ESM + GLSL**. The harness owns the-page, the renderer, cameras rigs, rendering, probes and judging. Your code never-imports anything but `three`, `three/addons/*` and your own relative files.--## Frame & units-Y is **up**, +Z is the **front**, units are **meters**. Ground is around y = 0-(your `heightAt(x, z)` decides the exact surface). A person is 1.7 m; a door 2.1 m;-a car 4.5 m long. Authored bounds are declared by the plan (`bounds`).--## Entry: `src/scene.js`-```js-import * as THREE from 'three';-export function createScene({ THREE, renderer, loaders }) { // may be async- const scene = new THREE.Scene();- // ... build env + zones, add them to scene ...- return {- scene,- cameras: [ { name: 'overview', position: [26, 14, 34], lookAt: [0, 1.5, 0], fov: 50 } ], // 1-6- update(t, dt) { /* animate: t seconds since start, dt step */ },- };-}-```-* The scene **owns its lights, sky/env and fog** (`scene.fog`, `scene.background`).- No lights → MeshStandardMaterial renders black.-* `cameras`: 1–6 authored shots. Eye ≥ 0.5 m from any surface, above ground,- looking at real content; name them by what they show (`harbour_low`, `overview`).-* `update(t, dt)`: all animation happens here (the host steps it deterministically).- **Never** call `requestAnimationFrame`, create a `WebGLRenderer`, or call- `renderer.render` yourself. `renderer` is passed only for capability checks.-* `loaders.gltf` is a `GLTFLoader`; `loaders.texture` a `TextureLoader`. Assets built- with Blender live in `public/assets/<name>.glb` and are loaded with- `await loaders.gltf.loadAsync('/assets/<name>.glb')` (make `createScene` async).--## Files-| path | export | role |-|---|---|---|-| `src/scene.js` | `createScene(ctx)` | entry; imports env + zones; returns `{scene, cameras, update}` |-| `src/env.js` | `buildEnv(ctx) → {ground, sky, sun, ...}`, `heightAt(x, z)` | ground/terrain, sky, sun + hemisphere light, fog |-| `src/zones/<snake>.js` | `build(ctx) → THREE.Group` | one zone = one **named** group (`group.name = 'PascalCase'`), animated via `group.userData.update(t, dt)` |-| `src/assets/<snake>.js` | `build<Pascal>(THREE) → THREE.Group` | reusable asset factories (origin at the base, +Y up); optionally `<asset>Parts(THREE)` for instancing |-| `src/shaders/<name>.js` | GLSL strings / material factories | `ShaderMaterial` or `onBeforeCompile` patches — raw GLSL |-| `src/fx/<name>.js` | effect helpers | particles, `three/addons/postprocessing/*` |--`ctx` passed to env/zones: `{ THREE, scene, renderer, loaders, env, heightAt }`-(you build it in `scene.js`; keep zones independent of each other).--## GLSL rules (the ones that fail silently)-* `#include <chunk>` **alone on its line**. No `#version`, no `precision` lines- (three prepends them). Use `gl_FragColor` (no `glslVersion`), or set- `glslVersion: THREE.GLSL3` and write your own `out vec4 fragColor` — never both.-* Every uniform you read must be declared in the GLSL **and** bound in JS- (`uniforms: { uTime: { value: 0 } }`, set `.value` in `update`).-* ShaderMaterial gets no lights and no fog unless you add them: for fog,- `fog: true`, `THREE.UniformsUtils.merge([THREE.UniformsLib.fog, {...}])` and the- `fog_pars_vertex / fog_vertex / fog_pars_fragment / fog_fragment` chunks.-* `onBeforeCompile` patches must keep the chunk they extend:- `shader.fragmentShader = shader.fragmentShader.replace('#include <output_fragment>', '#include <output_fragment>\n gl_FragColor.rgb += glow;')`.-* Do not redeclare `position / normal / uv / projectionMatrix / modelViewMatrix / cameraPosition`.--## Performance & hygiene-* Repeats → `InstancedMesh` (trees, posts, windows). Budget ≤ 3 M triangles total.-* Seed your own PRNG (no `Math.random()`) so every render is reproducible.-* `castShadow/receiveShadow` on meshes that matter; one shadow-casting sun.-* Name things: zone groups PascalCase; important meshes too (the census/judge use names).-* No network, no CDN, no DOM besides `document.createElement('canvas')` for procedural textures.--## Harness tools you can call-`build` (probe + shader preflight), `check_placement` (per placed asset: floating / sunken /-unsupported / interpenetration with "lower X by 0.23 m onto Terrain" hints; escape hatch for a-deliberately airborne thing: `obj.userData.placement = 'free'`), `scene_probe` (census: meshes,-tris, lights, zone bboxes, overlaps), `shader_probe` (does your shader actually change the frame?),-`render_views` / `render_sheet` (authored + overview cameras at t = 0 and 1.5 s).diff --git a/harness/codeverse/languages/scene_threejs/__init__.py b/harness/codeverse/languages/scene_threejs/__init__.pyindex b51ac67a..1aad5404 100644--- a/harness/codeverse/languages/scene_threejs/__init__.py+++ b/harness/codeverse/languages/scene_threejs/__init__.py@@ -15,6 +15,7 @@ from codeverse.contracts.artifacts import BuildResult, GateFinding, GateReport,from codeverse.contracts.common import ENTRY_FILE, Languagefrom codeverse.contracts.plan import AssetPlan, CameraPlan, Plan, ScenePlan, ZonePlanfrom codeverse.conventions import to_pascal, to_snake+from codeverse.languages._docs import RuntimeDocsfrom codeverse.languages._js_lint import ImportKind, ImportVerdict, check_imports, node_check_syntaxfrom codeverse.workspace import Workspace@@ -603,11 +604,9 @@ def assemble(ws: Workspace, plan: ScenePlan | None = None, *, cameras: str = "de# ===================================================================== runtime# (merged from codeverse/languages/scene_threejs/runtime.py, 2026-08-28)-_HERE = Path(__file__).resolve().parent-_PROMPTS = _HERE.parent.parent / "prompts" / "scene_threejs"-class SceneThreeJsRuntime:+class SceneThreeJsRuntime(RuntimeDocs):language = Language.SCENE_THREEJSentry_globs: tuple[str, ...] = (ENTRY_FILE[Language.SCENE_THREEJS], "src/zones/*.js", "src/assets/*.js", "src/env.js", "src/shaders/*.js")@@ -659,14 +658,6 @@ class SceneThreeJsRuntime:(ws.artifacts / "build.json").write_text(json.dumps(res.model_dump(mode="json"), indent=1))return res- def contract_doc(self) -> str:- p = _PROMPTS / "contract.md"- if p.is_file():- return p.read_text()- return (_HERE / "CONTRACT.md").read_text()-- def cookbook_path(self) -> Path:- return _PROMPTS / "cookbook.md"def _probe_and_preflight(ws: Workspace, *, timeout_s: float) -> tuple[GateReport, GateReport, dict]:diff --git a/harness/codeverse/languages/threejs/__init__.py b/harness/codeverse/languages/threejs/__init__.pyindex 5a79ebb8..ca035386 100644--- a/harness/codeverse/languages/threejs/__init__.py+++ b/harness/codeverse/languages/threejs/__init__.py@@ -14,12 +14,12 @@ from codeverse.contracts.artifacts import BuildResult, GateFinding, GateReport,from codeverse.contracts.common import ENTRY_FILE, Languagefrom codeverse.contracts.plan import Plan, StaticPlanfrom codeverse.conventions import to_pascal, to_snake+from codeverse.languages._docs import RuntimeDocsfrom codeverse.languages._js_lint import ImportKind, ImportVerdict, check_importsfrom codeverse.languages._js_lint import (node_check_syntax as check_syntax, # module-level name: tests monkeypatch it)from codeverse.proc import read_json_or_none-from codeverse.prompts import PROMPTS_DIR, load_textfrom codeverse.spatial.node import NodeError, NodeResult, run_node, runtime_js_dirfrom codeverse.workspace import Workspace@@ -374,21 +374,13 @@ BUILD_JSON = "build.json"NODE_MEM_LIMIT_GB = 8.0 # RLIMIT_AS for the export process (geometry-bomb protection)-class ThreeJsRuntime:+class ThreeJsRuntime(RuntimeDocs):"""LanguageRuntime for ``Language.THREEJS`` (raw ESM three.js, exported via node)."""language = Language.THREEJSentry_globs: tuple[str, ...] = (ENTRY_FILE[Language.THREEJS], "src/parts/*.js")# ------------------------------------------------------------------ contract- def contract_doc(self) -> str:- try:- return load_text("threejs/contract.md")- except FileNotFoundError:- return CONTRACT_FALLBACK-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "threejs" / "cookbook.md"# ------------------------------------------------------------------ skeleton / lintdef skeleton(self, ws: Workspace, plan: Plan) -> list[Path]:diff --git a/harness/codeverse/languages/urdf/CONTRACT.md b/harness/codeverse/languages/urdf/CONTRACT.mddeleted file mode 100644index 0978b395..00000000--- a/harness/codeverse/languages/urdf/CONTRACT.md+++ /dev/null@@ -1,130 +0,0 @@-# Authoring contract — language `urdf_blender` (articulated objects)--You write exactly TWO raw files. No SDK, no imports from the harness.--```-src/model.py pure bpy — one mesh object per LINK, at its rest-pose WORLD placement-src/robot.urdf native URDF — links + joints; meshes referenced as meshes/<link>.glb-```--The harness runs `model.py` headless, exports `meshes/<link>.glb` per link, lints the-URDF, checks that the URDF frames reproduce your geometry, sweeps every joint through-its range looking for collisions / floating parts, and renders an articulation sheet-(rest + every joint at both limits) for the judge.--## 1. Frame, units, naming--* Z is UP, **-Y is the FRONT** of the object, +X its right. Meters. Radians.-* The object stands on the ground: lowest point at z = 0, footprint centred on the Z axis.-* Link names are `snake_case` part names: `base`, `door`, `drawer`, `lid`, `handle_left`- (the plan's PascalCase spelling is accepted too — identical in both files, never `Door.001`).- Never state words (`door_open`): states come from joints.-* The bpy object for a link is named **exactly** like the link (case-sensitive).--## 2. `src/model.py` — the meshes (pure bpy)--* The scene is EMPTY when your script starts (no default cube). Build geometry with- `bpy.ops.mesh.primitive_*`, `bmesh`, modifiers, booleans — anything in bpy.-* ONE mesh object per URDF link, named exactly `<link>`, placed where the part sits in the- **authored rest pose** (world coordinates). Extra helper objects must be parented under a- link object (`ob.parent = link_obj`) — the wrapper joins every descendant into that link.- Any mesh object that is not a link (or under one) is a build error.-* Visible detail lives in the meshes (panels, bevels, handles, rails, hinge barrels).- Materials are welcome (`ob.data.materials.append(...)`, Principled BSDF colours).-* Do NOT: create cameras/lights, render, export, import files, `bpy.ops.wm.*`, `sys.exit`,- network/subprocess, infinite loops. The harness owns all of that.-* The wrapper exports each link with world-space geometry baked in (`meshes/<link>.glb`,- Z-up raw coordinates — NOT glTF Y-up — so any URDF loader places them correctly).--Copyable helper (raw bpy; keep it in your file if you like):--```python-import bpy--def box(name, center, size):- bpy.ops.mesh.primitive_cube_add(size=1.0, location=center)- ob = bpy.context.active_object- ob.name = name- ob.scale = size- bpy.ops.object.transform_apply(location=False, rotation=False, scale=True)- return ob--body = box("body", (0, 0, 0.40), (0.60, 0.40, 0.80)) # carcass, on the ground-door = box("door", (0, -0.21, 0.40), (0.58, 0.02, 0.78)) # front panel (front = -Y)-```--## 3. `src/robot.urdf` — links and joints (native URDF)--URDF semantics (standard): a joint's `<origin>` places the joint frame in the PARENT link-frame; `<axis>` is in the joint frame; the CHILD link frame coincides with the joint frame at-`q = 0`; `q = 0` is YOUR authored rest pose (the pose the plan's bboxes/pivots describe, so URDF-limits are the plan's `lower − rest .. upper − rest` — the plan's numbers when `rest` is 0).-Positive revolute `q` rotates by the right-hand rule about `<axis>`; positive prismatic `q`-slides along `<axis>`.--### The recipe we enforce (link frames at pivots, meshes authored in world)--1. The **root link frame = world origin** (`0 0 0`).-2. Every other **link frame = its parent joint's pivot point (world, rest pose)**, no- rotation (`rpy="0 0 0"`); express the joint direction with `<axis>`, not with rpy.-3. Joint `<origin xyz>` = `pivot_world(child) − link_frame_world(parent)` (accumulate down the- chain; for a joint whose parent is the root this is just the pivot).-4. Visual AND collision `<origin xyz>` = `−link_frame_world(link)` (the inverse transform,- because `meshes/<link>.glb` holds world coordinates). Root link: `0 0 0`.-5. One `<visual>` + one identical `<collision>` per link; geometry is always- `<mesh filename="meshes/<link>.glb"/>`.-6. `revolute` / `prismatic` need `<limit lower upper effort velocity>` (rad / m) with- `lower ≤ 0 ≤ upper`; `continuous` has no lower/upper; `fixed` has no axis/limit.- If positive motion goes the wrong way, **negate the axis — never swap the limits**.--The harness VERIFIES step 4 numerically (FK at q=0 must reproduce your model.py bboxes-within 1 mm) and tells you the exact corrected numbers if it is wrong.--### Worked example — cabinet with a front door hinged on its left edge--Door panel authored at x ∈ [-0.29, 0.29], y ∈ [-0.22, -0.20], z ∈ [0.01, 0.79]. Hinge axis is-vertical along the door's left edge: pivot world = `(-0.29, -0.20, 0)`. A door opening toward-the viewer (-Y) from a left hinge swings clockwise seen from above ⇒ axis `0 0 -1`.--```xml-<?xml version="1.0"?>-<robot name="cabinet">- <link name="body">- <visual><origin xyz="0 0 0" rpy="0 0 0"/><geometry><mesh filename="meshes/body.glb"/></geometry></visual>- <collision><origin xyz="0 0 0" rpy="0 0 0"/><geometry><mesh filename="meshes/body.glb"/></geometry></collision>- </link>- <link name="door"> <!-- link frame at the hinge pivot (-0.29 -0.20 0) → visual origin is its negation -->- <visual><origin xyz="0.29 0.20 0" rpy="0 0 0"/><geometry><mesh filename="meshes/door.glb"/></geometry></visual>- <collision><origin xyz="0.29 0.20 0" rpy="0 0 0"/><geometry><mesh filename="meshes/door.glb"/></geometry></collision>- </link>- <joint name="hinge" type="revolute">- <parent link="body"/>- <child link="door"/>- <origin xyz="-0.29 -0.20 0" rpy="0 0 0"/> <!-- pivot_world(door) - frame_world(body) -->- <axis xyz="0 0 -1"/>- <limit lower="0" upper="1.7" effort="10" velocity="1"/>- </joint>-</robot>-```--Drawer (prismatic, slides out of the front): pivot anywhere on the drawer, e.g. its rest-centre `(0, -0.05, 0.3)`; `<axis xyz="0 -1 0"/>`, `<limit lower="0" upper="0.35" .../>`;-visual origin `0 0.05 -0.3`. Chain: a handle on the door → parent `door`, pivot = handle-centre, joint `fixed`, joint origin = `handle_pivot − door_pivot`, visual origin = `−handle_pivot`.--## 4. What the harness checks (and tells you, with numbers)--* lint: XML, one root, tree, names, limits, axis, mesh paths, collision twins;- model.py: forbidden calls, every link name present as a string.-* build: `model.py` runs; each link has an object; no stray objects.-* FK consistency: URDF frames reproduce model.py placement (corrected `<origin>` reported).-* pose sweep: rest + each joint at lower/mid/upper + random combos → link pairs must not- interpenetrate (> 2 mm), nothing may float (each link touches the grounded assembly,- ≤ 2 mm gap; hinge clearance ≤ 1 cm is only a warning), per-link islands counted.- Penetration > 5 mm at REST fails the build.-* motion direction (when the plan states it): the child centroid must move the stated way.-* renders: rest and limit poses on one sheet — the judge sees your articulation.--Design advice: give parts 2-5 mm clearance where they move; pivots sit on real hinge lines-(door edge, lid back edge); drawers keep ≥ 1/3 of their depth inside at full extension;-continuous joints only for wheels/knobs; model visible hinges, rails and handles so nothing floats.diff --git a/harness/codeverse/languages/urdf/__init__.py b/harness/codeverse/languages/urdf/__init__.pyindex e7a0f02c..29838fbc 100644--- a/harness/codeverse/languages/urdf/__init__.py+++ b/harness/codeverse/languages/urdf/__init__.py@@ -27,7 +27,7 @@ from codeverse.contracts.plan import ArticulatedPlan, JointPlan, PartPlan, Planfrom codeverse.conventions import to_snakefrom codeverse.languages._ast_lint import describe_parse_failure, safe_parsefrom codeverse.languages._common import ProcResult, read_json_file, run_subprocess-from codeverse.prompts import PROMPTS_DIR, load_text+from codeverse.languages._docs import RuntimeDocsfrom codeverse.spatial.joints import (UrdfError,load_urdf,@@ -647,7 +647,6 @@ def write_skeleton(ws: Workspace, plan: ArticulatedPlan) -> list[Path]:# ===================================================================== runtime# (merged from codeverse/languages/urdf/runtime.py, 2026-08-28)WRAPPER = Path(__file__).resolve().parent / "wrappers" / "run_bpy_links.py"-CONTRACT_MD = Path(__file__).resolve().parent / "CONTRACT.md"REST_PENETRATION_MAX_M = 0.005FK_TOL_M = 0.001@@ -660,7 +659,7 @@ def _tail(s: str, n: int = 3000) -> str:return s[-n:] if s else ""-class UrdfBlenderRuntime:+class UrdfBlenderRuntime(RuntimeDocs):language = Language.URDF_BLENDERentry_globs = (ENTRY_FILE[Language.URDF_BLENDER], "src/robot.urdf")@@ -673,14 +672,6 @@ class UrdfBlenderRuntime:def lint(self, ws: Workspace) -> GateReport:return lint_workspace(ws)- def contract_doc(self) -> str:- try:- return load_text("urdf/contract.md")- except FileNotFoundError:- return CONTRACT_MD.read_text()-- def cookbook_path(self) -> Path:- return PROMPTS_DIR / "urdf" / "cookbook.md"# ------------------------------------------------------------ builddef build(self, ws: Workspace, *, timeout_s: int | None = None) -> BuildResult:diff --git a/harness/pyproject.toml b/harness/pyproject.tomlindex 365a5776..121153a4 100644--- a/harness/pyproject.toml+++ b/harness/pyproject.toml@@ -92,7 +92,7 @@ timeout = 600# -n auto: the offline suite is ~2 800 mostly-independent tests and this box has 24# cores — serial it is ~3 min, parallel ~15 s. -p no:randomly is NOT set: xdist# distributes by file, and every test that touches shared state already uses tmp_path.-addopts = ["-m", "not live", "-n", "auto", "--dist", "loadfile"]+addopts = ["-m", "not live", "-n", "auto", "--dist", "worksteal"]markers = ["live: needs network + API keys (deselect with -m 'not live')","blender: needs a Blender binary",diff --git a/harness/tests/scene_runtime/test_runtime.py b/harness/tests/scene_runtime/test_runtime.pyindex 6f9e9cab..68cbe30a 100644--- a/harness/tests/scene_runtime/test_runtime.py+++ b/harness/tests/scene_runtime/test_runtime.py@@ -21,10 +21,11 @@ def test_runtime_registered_and_conforms():assert "src/scene.js" in rt.entry_globs and "src/zones/*.js" in rt.entry_globsdoc = rt.contract_doc()assert "createScene" in doc and "update(t, dt)" in doc- # the built-in fallback contract is always available and carries the GLSL rules- import codeverse.languages.scene_threejs as rt_mod- fallback = (rt_mod._HERE / "CONTRACT.md").read_text()- assert "createScene" in fallback and "#include" in fallback+ # the GLSL chunk rules are the cookbook's job, not the contract's — this used to+ # assert them against languages/scene_threejs/CONTRACT.md, a file contract_doc()+ # never reached (deleted 2026-08-28); prompts/scene_threejs/glsl_cookbook.md states+ # the same rule and IS delivered+ assert "`#include <...>` alone on its line" in rt.cookbook_path().with_name("glsl_cookbook.md").read_text()assert rt.cookbook_path().name == "cookbook.md"diff --git a/harness/tests/skills/test_contract_agreement.py b/harness/tests/skills/test_contract_agreement.pyindex 9c0f69e7..88dd6e63 100644--- a/harness/tests/skills/test_contract_agreement.py+++ b/harness/tests/skills/test_contract_agreement.py@@ -26,21 +26,23 @@ from pathlib import Pathimport pytestfrom codeverse.conventions import CONTACT_GAP_M+from codeverse.languages._docs import PROMPT_DIRSfrom codeverse.skills import bundle_dirs, iter_skills, skills_dirfrom codeverse.skills.registry import ROUTESfrom codeverse.spatial.connectivity import PENETRATION_WARN_MHARNESS = Path(__file__).resolve().parents[2]PROMPTS = HARNESS / "codeverse" / "prompts"-#: BOTH contract families an agent can read: the prompt-side per-language contract, and-#: the runtime-side CONTRACT.md the language package serves through `contract_doc()`.-CONTRACTS = sorted(PROMPTS.glob("*/contract.md")) + sorted(- (HARNESS / "codeverse" / "languages").glob("*/CONTRACT.md"))+#: the per-language contract an agent reads. There was a second family under+#: languages/<lang>/CONTRACT.md until 2026-08-28; it was unreachable (contract_doc+#: always read prompts/ first) and two of its numbers had drifted, so it is gone.+CONTRACTS = sorted(PROMPTS.glob("*/contract.md"))BUNDLES = bundle_dirs()SKILLS = list(iter_skills()) if BUNDLES else []-#: prompts/<dir> per language id (urdf_blender's docs live under prompts/urdf)-_DIR_FOR_LANG = {"urdf_blender": "urdf"}+#: prompts/<dir> per language id — codeverse.languages._docs owns the mapping now+#: (urdf_blender's docs live under prompts/urdf)+_DIR_FOR_LANG = {k.value: v for k, v in PROMPT_DIRS.items()}WARN_MM = PENETRATION_WARN_M * 1000GAP_MM = CONTACT_GAP_M * 1000