Official Codebase of 3DCodeVerse
Python
scene: an interior's enclosure has an owner — ScenePlan.interior, roomShell in the starter lib, the skeleton's env.js carries it
gaoypeng6b88862ad4af
diff --git a/harness/codeverse/contracts/plan.py b/harness/codeverse/contracts/plan.pyindex 18e509a2..89eaab98 100644--- a/harness/codeverse/contracts/plan.py+++ b/harness/codeverse/contracts/plan.py@@ -612,6 +612,12 @@ class ScenePlan(BaseModel):mood: str = ""bounds: BBoxenvironment: str = Field(description="sky, sun/moon, fog, ground, water — one paragraph")+ interior: bool = Field(+ default=False,+ description="the view is from INSIDE a built space (workshop, room, cabin, hall, shop): the "+ "environment module owns the enclosure — floor, walls and ceiling on the bounds' faces with "+ "openings where the windows and doors are — and the zones dress the inside; false outdoors",+ )zones: list[ZonePlan] = Field(min_length=1)assets: list[AssetPlan] = Field(default_factory=list)effects: list[EffectPlan] = Field(default_factory=list)diff --git a/harness/codeverse/languages/scene_threejs/__init__.py b/harness/codeverse/languages/scene_threejs/__init__.pyindex 298983df..7e6f4cc5 100644--- a/harness/codeverse/languages/scene_threejs/__init__.py+++ b/harness/codeverse/languages/scene_threejs/__init__.py@@ -214,6 +214,10 @@ def _env_for_plan(plan: ScenePlan) -> str:text = re.sub(r"export const GROUND_SIZE = \d+;", f"export const GROUND_SIZE = {ground};", text)text = re.sub(r"const FOG_NEAR = \d+, FOG_FAR = \d+;", f"const FOG_NEAR = {fog_near}, FOG_FAR = {fog_far};", text)text = re.sub(r"const SKY_RADIUS = \d+;", f"const SKY_RADIUS = {int(max(600, ground * 3))};", text)+ if plan.interior:+ c = [round(float(v), 2) for v in plan.bounds.center]+ e = [round(float(v), 2) for v in ex]+ text = re.sub(r"export const INTERIOR = null;", f"export const INTERIOR = {{ center: {c}, extents: {e}, openings: [] }};", text)header = (f"// ENV PLAN: {plan.environment.strip()}\n"f"// setting: {plan.setting.strip()} mood: {plan.mood.strip()}\n"diff --git a/harness/codeverse/languages/scene_threejs/starter/src/env.js b/harness/codeverse/languages/scene_threejs/starter/src/env.jsindex 616de1b3..f1d3f507 100644--- a/harness/codeverse/languages/scene_threejs/starter/src/env.js+++ b/harness/codeverse/languages/scene_threejs/starter/src/env.js@@ -3,11 +3,15 @@// export function heightAt(x, z) → ground height (m) so zones can seat objects.import * as THREE from 'three';import { makeSkyMaterial } from './shaders/sky.js';-import { sunRig } from './lib/environment.js';+import { roomShell, sunRig } from './lib/environment.js';export const SUN_AZIMUTH_DEG = 60; // where the sun is (0 = +Z front, CCW from above); cameras on the sun side are front-litexport const SUN_ELEVATION_DEG = 38;export const GROUND_SIZE = 160; // ground plane extent (m); fog is tuned to it+// An INTERIOR plan (the skeleton fills this from plan.bounds): the room shell — floor is the+// ground, walls and ceiling on the bounds' faces. Cut the plan's windows and doors as+// `openings` (see lib/environment.js roomShell) and light the inside; never delete it.+export const INTERIOR = null; // e.g. { center: [0, 3, 0], extents: [14, 6, 16], openings: [{ face: 'west', center: [8, 2.5], size: [6, 3] }] }const FOG_NEAR = 60, FOG_FAR = 260;const SKY_RADIUS = 600;@@ -38,6 +42,7 @@ export function buildEnv(ctx) {ground.name = 'Ground';ground.receiveShadow = true;group.add(ground);+ if (INTERIOR) group.add(roomShell(INTERIOR)); // the enclosure exists before anyone dresses the roomconst az = (SUN_AZIMUTH_DEG * Math.PI) / 180, el = (SUN_ELEVATION_DEG * Math.PI) / 180;diff --git a/harness/codeverse/languages/scene_threejs/starter/src/lib/environment.js b/harness/codeverse/languages/scene_threejs/starter/src/lib/environment.jsindex b8850034..923bb425 100644--- a/harness/codeverse/languages/scene_threejs/starter/src/lib/environment.js+++ b/harness/codeverse/languages/scene_threejs/starter/src/lib/environment.js@@ -23,6 +23,81 @@ const MOODS = {fogDensity: 0.003 },};+/**+ * The enclosure of an INTERIOR scene, in one call: four walls and a+ * ceiling on the faces of the plan bounds, with rectangular openings+ * (windows, doors) cut where the plan puts them — so nothing the zones+ * place inside the bounds can be in a wall, and the roof exists before+ * anyone dresses the room. Measured 2026-09-07 over six interior runs:+ * with no owner for walls and roof, every one was judged "not enclosed,+ * a diorama on a flat plane, tool racks floating at a missing wall"+ * (0.0–0.3) until a refine round built them; a bare one-file scene of+ * the same brief built the room first and scored 0.82.+ *+ * @param {object} opts+ * `center` [x, y, z] and `extents` [w, h, d] of the plan bounds (the+ * room's inner box: floor at center.y - h/2, ceiling at center.y + h/2);+ * `thickness` wall thickness in metres (default 0.3, built OUTWARD so+ * the inner face is exactly the bounds face); `openings` list of+ * `{ face: 'west'|'east'|'north'|'south', center: [along, up],+ * size: [width, height] }` in metres — `along` runs +z (west/east+ * faces) or +x (north/south), `up` from the floor; `wallColor`,+ * `ceilingColor` hex; `ceiling` false for an open-topped set.+ * @returns {THREE.Group} named 'RoomShell' — walls 'Wall_<face>' (and+ * 'Wall_<face>_<n>' panels around an opening), ceiling 'Ceiling'.+ * All cast and receive shadows.+ */+export function roomShell(opts = {}) {+ const [cx, cy, cz] = opts.center || [0, 0, 0];+ const [w, h, d] = opts.extents || [10, 3, 10];+ const t = opts.thickness || 0.3;+ const y0 = cy - h / 2;+ const wallMat = new THREE.MeshStandardMaterial({ color: opts.wallColor === undefined ? 0xb9ad98 : opts.wallColor, roughness: 0.92 });+ const ceilMat = new THREE.MeshStandardMaterial({ color: opts.ceilingColor === undefined ? 0x8d7f6a : opts.ceilingColor, roughness: 0.95 });+ const group = new THREE.Group();+ group.name = 'RoomShell';+ const slab = (name, sx, sy, sz, x, y, z, mat) => {+ const m = new THREE.Mesh(new THREE.BoxGeometry(sx, sy, sz), mat);+ m.name = name; m.position.set(x, y, z); m.castShadow = true; m.receiveShadow = true;+ group.add(m);+ return m;+ };+ // each face: its outward normal axis, the length along the face, and where along/up map+ const faces = {+ west: { x: cx - w / 2 - t / 2, z: cz, len: d, axis: 'x' },+ east: { x: cx + w / 2 + t / 2, z: cz, len: d, axis: 'x' },+ north: { x: cx, z: cz - d / 2 - t / 2, len: w, axis: 'z' },+ south: { x: cx, z: cz + d / 2 + t / 2, len: w, axis: 'z' },+ };+ for (const [face, f] of Object.entries(faces)) {+ const holes = (opts.openings || []).filter((o) => o.face === face);+ // 1-D cuts along the face: solid spans between openings, and above/below each opening+ const along = (v) => (f.axis === 'x' ? [f.x, v] : [v, f.z]); // -> [x, z] on the face+ const origin = (f.axis === 'x' ? cz : cx) - f.len / 2;+ const place = (name, a0, a1, b0, b1) => {+ if (a1 - a0 < 0.01 || b1 - b0 < 0.01) return;+ const [x, z] = along(origin + (a0 + a1) / 2);+ const sx = f.axis === 'x' ? t : a1 - a0, sz = f.axis === 'x' ? a1 - a0 : t;+ slab(name, sx, b1 - b0, sz, x, y0 + (b0 + b1) / 2, z, wallMat);+ };+ if (!holes.length) { place(`Wall_${face}`, 0, f.len, 0, h); continue; }+ const sorted = holes.map((o) => ({ a0: o.center[0] - o.size[0] / 2, a1: o.center[0] + o.size[0] / 2,+ b0: o.center[1] - o.size[1] / 2, b1: o.center[1] + o.size[1] / 2 }))+ .sort((p, q) => p.a0 - q.a0);+ let cursor = 0, n = 0;+ for (const o of sorted) {+ const a0 = Math.max(0, o.a0), a1 = Math.min(f.len, o.a1);+ place(`Wall_${face}_${n++}`, cursor, a0, 0, h); // solid span before the opening+ place(`Wall_${face}_${n++}`, a0, a1, 0, Math.max(0, o.b0)); // sill below it+ place(`Wall_${face}_${n++}`, a0, a1, Math.min(h, o.b1), h); // lintel above it+ cursor = a1;+ }+ place(`Wall_${face}_${n++}`, cursor, f.len, 0, h);+ }+ if (opts.ceiling !== false) slab('Ceiling', w + 2 * t, t, d + 2 * t, cx, y0 + h + t / 2, cz, ceilMat);+ return group;+}+/*** Build the sky dome + horizon ridge + matched fog.*diff --git a/harness/codeverse/prompts/scene_threejs/effects_catalog.md b/harness/codeverse/prompts/scene_threejs/effects_catalog.mdindex 610070a2..a2d1ab0d 100644--- a/harness/codeverse/prompts/scene_threejs/effects_catalog.md+++ b/harness/codeverse/prompts/scene_threejs/effects_catalog.md@@ -41,6 +41,7 @@ says `import { makeGrass } from '../lib/grass.js';`, `src/scene.js` says| the land between the content and the horizon | `makeOutskirts({ inner, baseY, heightAt, shellRadius, colors, seed })` — `lib/environment.js`; seam-matched relief, field patchwork and wooded clusters. A bare oversized ground plane measured as "a diorama on a vast, empty flat plane" || a Blender hero's own keyframed motion (the GLB carries a clip) | nothing to call — the assembled scene plays every clone's clips; `clone.userData.clipOffset = 0.7` de-phases a copy || the sun, the fill and the baked environment | `sunRig({ azimuth, elevation })` — `lib/environment.js`; returns `{ sun, fill, sunDisc, envTex, sunDir }`. Add the lights, assign `scene.environment = rig.envTex` |+| an interior's walls, ceiling and window/door openings | `roomShell({ center, extents, openings, thickness, wallColor, ceilingColor })` — `lib/environment.js`; walls outward of the bounds' faces (inner face = bounds face), openings cut as span / sill / lintel panels. The skeleton's env.js builds it from its INTERIOR constant for an interior plan; six runs measured "not enclosed, a diorama on a flat plane" without one || the sky itself | `makeSky(scene, { rig })` — `lib/sky.js`; the dome IS the backdrop, so `scene.background` stays null || cloud, cirrus | `makeClouds({ preset, sunDir })` · `makeCirrus()` — `lib/clouds.js` || stars, the Milky Way, aurora, heat shimmer | `makeStars` · `makeAurora` · `makeHeatShimmer` — `lib/celestial.js` |diff --git a/harness/codeverse/prompts/tracks/plan_scene.j2 b/harness/codeverse/prompts/tracks/plan_scene.j2index 0d43b4a0..05970f54 100644--- a/harness/codeverse/prompts/tracks/plan_scene.j2+++ b/harness/codeverse/prompts/tracks/plan_scene.j2@@ -99,7 +99,12 @@ WHAT TO PRODUCE (JSON, fields: {{ schema_fields }}):2026-08-25: a brief reading "INSIDE a boatbuilder's workshop, sun raking through a dustywindow wall" was planned as "Coastal boatyard, clear dusk" and built faithfully as anoutdoor yard with no walls and no roof — it passed every gate and scored 0.4653. Write- the premise down and the rest of the plan stays anchored to it;+ the premise down and the rest of the plan stays anchored to it — and when that premise+ is INSIDE a built space, set `interior: true`: the environment module then builds the+ enclosure on the bounds' faces (floor, walls, ceiling, with openings where `environment`+ puts the windows and doors) and the zones dress the inside. Measured 2026-09-07 on+ six interior runs: with no owner for walls and roof, every one was judged "not+ enclosed, a diorama on a flat plane" (0.0–0.3) until a refine round built them;- mark everything else `priority: should` — craft goals, counts, specific patterns, exactheights, fps and anything needing evidence the judge may not have;- never write a `must` whose wording contains a number, a named style, or the word "and"diff --git a/harness/codeverse/prompts/tracks/scene_env.j2 b/harness/codeverse/prompts/tracks/scene_env.j2index 622626b0..14fb0560 100644--- a/harness/codeverse/prompts/tracks/scene_env.j2+++ b/harness/codeverse/prompts/tracks/scene_env.j2@@ -6,6 +6,16 @@ Bounds: {{ bounds }}## Environment plan (realise these numbers){{ environment }}+{% if interior %}+## This is an INTERIOR — the enclosure is yours+The skeleton already builds the room: `export const INTERIOR = { center, extents, openings }` feeds+`roomShell()` from `lib/environment.js` — floor (the ground), four walls and a ceiling on the bounds'+faces. Keep it. Your job: cut the plan's windows and doors as `openings` (face, centre along the+wall / up from the floor, size, metres), glaze or frame them, and LIGHT THE INSIDE (the sun rig is+outside: without openings and practicals a closed room reads black). Measured 2026-09-07 over six+interior runs: with no owner for walls and roof, every one was judged "not enclosed, a diorama on+a flat plane, tool racks floating at a missing wall" (0.0–0.3).+{% endif %}## Contract{{ frame_doc }}diff --git a/harness/codeverse/prompts/tracks/scene_zone.j2 b/harness/codeverse/prompts/tracks/scene_zone.j2index cde35577..1921ffa9 100644--- a/harness/codeverse/prompts/tracks/scene_zone.j2+++ b/harness/codeverse/prompts/tracks/scene_zone.j2@@ -5,7 +5,10 @@ Scene: {{ spec_prompt }} · Setting: {{ setting }} · Mood: {{ mood }}## This zone- Description (density counts and depth role are binding): {{ zone_description }}- Bbox: {{ zone_bbox }} — place EVERYTHING inside it (x/z), on the ground via `heightAt`.-- Contents (asset names to place): {{ zone_contents | join(', ') if zone_contents else '(none — build local detail from primitives)' }}+{% if interior %}- INTERIOR: the enclosure (walls, ceiling, roof) is `env.js`'s `roomShell` on the scene bounds' faces —+ never build walls or a roof here. Fixtures on a wall sit flush against the inner face of the bounds;+ a window or door is an OPENING env cut, so glazing and door leaves go in the opening, not through the wall.+{% endif %}- Contents (asset names to place): {{ zone_contents | join(', ') if zone_contents else '(none — build local detail from primitives)' }}{% if layout is defined and layout %}## Zone director's layout (realise EXACTLY these placements; positions are world meters){{ layout }}diff --git a/harness/codeverse/tracks/scene.py b/harness/codeverse/tracks/scene.pyindex ce4ae074..262b9b70 100644--- a/harness/codeverse/tracks/scene.py+++ b/harness/codeverse/tracks/scene.py@@ -511,6 +511,7 @@ class SceneTrack(BaseTrack):effects = "\n".join(f"- {e.name} ({e.kind}, on {e.target or 'scene'}): {e.description}" for e in plan.effects) or "(none)"return base_prompt_context(ctx, title=plan.title, setting=plan.setting, mood=plan.mood, bounds=bbox_line(plan.bounds), environment=plan.environment,+ interior=plan.interior,zones_table=zones_table, cameras=cameras, effects=effects, animation="; ".join(plan.animation) or "(none)",asset_api=ctx.extra.get("asset_api", "(no assets)"),textures=texture_pack_prompt(ctx.extra.get("textures") or {}), **extra)diff --git a/harness/docs/DECISIONS.md b/harness/docs/DECISIONS.mdindex 0d8a030d..19d2896b 100644--- a/harness/docs/DECISIONS.md+++ b/harness/docs/DECISIONS.md@@ -1094,6 +1094,25 @@ written) that were accepted because the code works that way and the tests pin itkeep retrying. `single_shot_agent_id` / `single_shot_ctx` moved from `scene_assets` to`tracks.common` with it (they were never scene-specific).+* **D69 An interior scene's enclosure has an owner: the environment, from the plan's bounds+ (2026-09-07).** Six interior runs of the day (boat workshop x4, clockmaker x2) were judged+ "not enclosed — a diorama on a flat plane, tool racks floating at a missing wall" (0.0–0.3)+ and only a refine round built the walls and roof. The planner already wrote the premise+ ("inside an enclosed workshop") and even a zone called `WindowWall`; the env brief's rules+ were all outdoor (ground, world edge, floor height), the zones dressed their boxes, and+ nobody was told whose the walls are. The bare one-file baseline of the same brief built+ the room first and scored 0.82 under the fixed judge; the harness's own round 0 sat at+ 0.30–0.57 and needed a round (20–30 min) to reach 0.73–0.93. `ScenePlan.interior` names+ the case (typed, set by the planner with the premise); `lib/environment.js roomShell()`+ builds four walls and a ceiling OUTWARD of the bounds' faces (inner face = bounds face, so a+ zone that stays in bounds is never in a wall) with rectangular openings cut as span / sill /+ lintel panels; the skeleton's `env.js` carries `INTERIOR = { center, extents, openings: [] }`+ from the plan so the enclosure exists before any session starts (a storm-dead env session+ ships a room, not a plane); the env brief claims the openings and the light, the zone brief+ forbids walls and puts fixtures flush to the bounds. Not a wrapper that re-centres or+ grounds anything (L7): harness-owned starter geometry, like `worldShell` (D51), that the+ agent edits.+## Rejected / deferred* A versioned `Spec`/`RunRecord`/`RunState` load-normaliser (rejected 2026-08-30: of the sevendiff --git a/harness/tests/scene_prompts/test_quality_teaching.py b/harness/tests/scene_prompts/test_quality_teaching.pyindex bd78cfec..61bbf270 100644--- a/harness/tests/scene_prompts/test_quality_teaching.py+++ b/harness/tests/scene_prompts/test_quality_teaching.py@@ -158,3 +158,23 @@ def test_cookbook_sections_inlines_whole_chapters_and_clips_safely(tmp_path) ->assert cookbook_sections(ctx, ZONE_RECIPES, max_chars=500).rstrip().endswith("cookbook.md]")assert cookbook_sections(SimpleNamespace(cookbook_text=""), ZONE_RECIPES) == ""assert cookbook_sections(ctx, ["zzz qqq"]) == "" # no match → nothing, never junk+++def test_the_env_and_zone_briefs_hand_the_enclosure_to_env_for_an_interior() -> None:+ """2026-09-07: six interior runs were "not enclosed" because no brief said whose the walls+ are. The env brief claims them (and the openings, and the light) only when the plan+ says interior; the zone brief forbids building them and puts fixtures flush to the bounds."""+ from codeverse.prompts import render++ base = dict(title="t", spec_prompt="p", setting="s", mood="m", bounds="b", environment="e", frame_doc="", contract="",+ zones_table="", cameras="", effects="", animation="", asset_api="", textures="", recipes="", constraints_text="",+ references="", skills="", tool_cards="", zone_name="Z", zone_description="d", zone_bbox="bb", zone_contents=[],+ zone_file="src/zones/z.js", neighbours=[], layout="")+ env_in = render("tracks/scene_env.j2", **base, interior=True)+ env_out = render("tracks/scene_env.j2", **base, interior=False)+ assert "the enclosure is yours" in env_in and "roomShell" in env_in and "openings" in env_in+ assert "enclosure is yours" not in env_out+ zone_in = render("tracks/scene_zone.j2", **base, interior=True)+ zone_out = render("tracks/scene_zone.j2", **base, interior=False)+ assert "never build walls or a roof" in zone_in and "flush against the inner face" in zone_in+ assert "never build walls" not in zone_outdiff --git a/harness/tests/scene_runtime/lib/test_room_shell.py b/harness/tests/scene_runtime/lib/test_room_shell.pynew file mode 100644index 00000000..50cf4a96--- /dev/null+++ b/harness/tests/scene_runtime/lib/test_room_shell.py@@ -0,0 +1,55 @@+"""An interior plan gets its enclosure from the skeleton (2026-09-07).++Measured over six interior runs of the day (boat workshop x4, clockmaker x2): the plan+described the premise ("inside an enclosed workshop"), the zones dressed their boxes, the+env built ground, sky and sun — and nobody built walls or a roof. Every one was judged+"not enclosed, a diorama on a flat plane, tool racks floating at a missing wall" (0.0-0.3)+until a refine round built them; a bare one-file scene of the same brief built the room+first and scored 0.82. `ScenePlan.interior` names the case, `roomShell` builds it on the+bounds' faces, the skeleton's env.js carries it before any session starts.+"""+from __future__ import annotations++import pytest+from _probe import measure++from codeverse.contracts.common import Track+from codeverse.contracts.plan import ScenePlan+from codeverse.languages.scene_threejs import _env_for_plan+from codeverse.tracks.planner import plan_example++_SHELL = """+import * as THREE from 'three';+import { roomShell } from './lib/environment.js';+const g = roomShell({ center: [0, 3, 0], extents: [14, 6, 16], thickness: 0.3,+ openings: [{ face: 'west', center: [8, 2.5], size: [6, 3] }] });+const names = g.children.map((m) => m.name);+const box = new THREE.Box3().setFromObject(g);+const west = g.children.filter((m) => m.name.startsWith('Wall_west'));+// the opening: no west panel covers (x = -7.15, y = 2.5, z = 0) — 8 m along the face from z = -8+const covered = west.some((m) => new THREE.Box3().setFromObject(m).containsPoint(new THREE.Vector3(-7.15, 2.5, 0)));+const sill = west.some((m) => new THREE.Box3().setFromObject(m).containsPoint(new THREE.Vector3(-7.15, 0.5, 0)));+console.log(JSON.stringify({ names, min: box.min.toArray(), max: box.max.toArray(), westPanels: west.length, covered, sill,+ shadows: g.children.every((m) => m.castShadow && m.receiveShadow) }));+"""+++def test_the_shell_is_walls_and_ceiling_on_the_bounds_faces_with_openings_cut():+ got = measure(_SHELL, ("environment.js", "sky.js"))+ assert "Ceiling" in got["names"] and "Wall_east" in got["names"] and "Wall_north" in got["names"], got["names"]+ assert got["westPanels"] == 4 and got["covered"] is False and got["sill"] is True, got # span, sill, lintel, span+ # walls are OUTSIDE the bounds (inner face == bounds face), the ceiling sits on top+ assert got["min"][0] == pytest.approx(-7.3, abs=1e-6) and got["max"][0] == pytest.approx(7.3, abs=1e-6)+ assert got["min"][1] == pytest.approx(0.0, abs=1e-6) and got["max"][1] == pytest.approx(6.3, abs=1e-6)+ assert got["shadows"]+++def test_the_skeleton_env_carries_the_shell_only_for_an_interior_plan():+ plan = ScenePlan.model_validate(plan_example(Track.SCENE))+ assert plan.interior is False+ outdoor = _env_for_plan(plan)+ assert "export const INTERIOR = null;" in outdoor+ inside = _env_for_plan(plan.model_copy(update={"interior": True}))+ c, e = plan.bounds.center, plan.bounds.extents+ assert f"export const INTERIOR = {{ center: [{c[0]}, {c[1]}, {c[2]}], extents: [{e[0]}, {e[1]}, {e[2]}], openings: [] }};" in inside+ assert "if (INTERIOR) group.add(roomShell(INTERIOR));" in inside