Official Codebase of 3DCodeVerse
Python
tests: scene_runtime, third pass — browser and node boots fold into scenario tests (229 → 197, −117 lines)
gaoypeng87f52be9cfe2
diff --git a/harness/tests/scene_runtime/lib/test_terrain.py b/harness/tests/scene_runtime/lib/test_terrain.pyindex 7d0ba826..fd636f8c 100644--- a/harness/tests/scene_runtime/lib/test_terrain.py+++ b/harness/tests/scene_runtime/lib/test_terrain.py@@ -2,10 +2,8 @@as a height function that agrees with its mesh; the cliff is one ribbon."""from __future__ import annotations-import re-import pytest-from _probe import LIB_DIR, measure+from _probe import measurepytestmark = pytest.mark.node@@ -127,13 +125,6 @@ def test_ground_textures_by_default_and_tiles_to_its_size(probe):assert abs(g["repeat"] - 200 / 12) < 1e-6, g-def test_ground_source_is_seeded_never_math_random():- src = (LIB_DIR / "terrain.js").read_text(encoding="utf-8")- code = "\n".join(ln for ln in src.splitlines() if not ln.strip().startswith(("*", "//", "/*")))- assert not re.search(r"Math\.random\s*\(", code)- assert "opts.rand" in src and "MAT.soil()" in src--def test_cliff_is_one_connected_ribbon_with_no_gaps(probe):c = probe["cliff"]assert c["meshes"] == 1 and c["children"] == 0diff --git a/harness/tests/scene_runtime/test_assemble.py b/harness/tests/scene_runtime/test_assemble.pyindex 7471cbd1..b8fcbce3 100644--- a/harness/tests/scene_runtime/test_assemble.py+++ b/harness/tests/scene_runtime/test_assemble.py@@ -12,7 +12,6 @@ from codeverse3d.languages.scene_threejs import (assemble,cameras_from_specs,lint,- probe_zone_modules,render_scene_js,sun_azimuth,)@@ -74,14 +73,12 @@ def test_render_scene_js_contents():assert "const env = (await buildEnv(ctx)) || {};" in srcsrc2 = render_scene_js([], cams, [], env_ok=False)assert "env.js" not in src2 and "heightAt: () => 0" in src2---def test_sun_azimuth_reads_env(starter_ws):- assert sun_azimuth(starter_ws) == 60.0+ assert "assetFiles" not in src2 and "loadAsync" not in src2 # no GLB asset, no loader@needs_nodedef test_assemble_without_probe_writes_all_zones(starter_ws):+ assert sun_azimuth(starter_ws) == 60.0 # the starter env's sun: the side every derived camera stands onres = assemble(starter_ws, probe=False)assert set(res.zones_included) == {"meadow", "pondside"}assert (starter_ws.src / "scene.js").read_text().startswith("// src/scene.js — ASSEMBLED")@@ -91,41 +88,14 @@ def test_assemble_without_probe_writes_all_zones(starter_ws):@pytest.mark.node@needs_browser-def test_probe_zone_modules_reports_failures_and_bboxes(starter_ws):- (starter_ws.src / "zones" / "broken.js").write_text("export function build(ctx) { throw new Error('kaboom'); }\n")- (starter_ws.src / "zones" / "nobuild.js").write_text("export const x = 1;\n")- report = probe_zone_modules(starter_ws, sun_azimuth_deg=60.0)- probes = report.probes- assert probes["meadow"].ok and probes["meadow"].bbox and probes["meadow"].meshes > 5- assert probes["pondside"].ok- assert not probes["broken"].ok and "kaboom" in probes["broken"].error- assert not probes["nobuild"].ok and "no export build" in probes["nobuild"].error- assert report.census.get("ground_y") is not None- assert not (starter_ws.root / "src" / "_c3v_assemble_probe.js").exists()- # driver-fitted cameras: an overview plus one eye-level spec per measured zone group- specs = report.camera_specs- assert specs["azimuth"] == 60.0 and specs["overview"]["position"][1] > 0.5- zone_groups = {z["group"] for z in specs["zones"]}- assert {"__zone__meadow", "__zone__pondside"} <= zone_groups---@needs_browser-def test_assemble_end_to_end_excludes_broken_zone(starter_ws):- (starter_ws.src / "zones" / "broken.js").write_text("export function build(ctx) { throw new Error('kaboom'); }\n")- res = assemble(starter_ws)- assert set(res.zones_included) == {"meadow", "pondside"}- assert "broken" in res.zones_failed- assert res.cameras[0].name == "overview" and len(res.cameras) == 3- src = (starter_ws.src / "scene.js").read_text()- assert "broken" not in src- assert lint(starter_ws).passed---@needs_browser-def test_assemble_with_async_zone_boots(starter_ws):- (starter_ws.src / "zones" / "orchard.js").write_text(+def test_assemble_probes_each_zone_excludes_the_broken_and_boots(starter_ws):+ """One probed assembly: a throwing zone and a zone with no build are excluded with+ their reasons, an async build() is awaited, the driver fits an overview plus one+ camera per measured zone, and the assembled scene then boots through the probe."""+ zones = starter_ws.src / "zones"+ (zones / "broken.js").write_text("export function build(ctx) { throw new Error('kaboom'); }\n")+ (zones / "nobuild.js").write_text("export const x = 1;\n")+ (zones / "orchard.js").write_text("import * as THREE from 'three';\n""export async function build(ctx) {\n"" await new Promise((r) => setTimeout(r, 10));\n"@@ -136,7 +106,19 @@ def test_assemble_with_async_zone_boots(starter_ws):"}\n")res = assemble(starter_ws)- assert "orchard" in res.zones_included and res.zones_failed == {}+ assert set(res.zones_included) == {"meadow", "pondside", "orchard"}+ assert "kaboom" in res.zones_failed["broken"]+ assert "no export build" in res.zones_failed["nobuild"]+ assert res.census.get("ground_y") is not None+ assert not (starter_ws.root / "src" / "_c3v_assemble_probe.js").exists()+ # driver-fitted cameras: an overview plus one eye-level camera per measured zone+ assert res.cameras[0].name == "overview" and res.cameras[0].position[1] > 0.5+ assert {"meadow_view", "pondside_view", "orchard_view"} <= {c.name for c in res.cameras}+ src = (starter_ws.src / "scene.js").read_text()+ assert "broken" not in src and "nobuild" not in src+ (zones / "broken.js").unlink()+ (zones / "nobuild.js").unlink()+ assert lint(starter_ws).passedfrom codeverse3d.spatial.probes import probe_sceneprobe = probe_scene(starter_ws)diff --git a/harness/tests/scene_runtime/test_backdrop.py b/harness/tests/scene_runtime/test_backdrop.pyindex d37d4cfb..079f4b52 100644--- a/harness/tests/scene_runtime/test_backdrop.py+++ b/harness/tests/scene_runtime/test_backdrop.py@@ -3,7 +3,6 @@from __future__ import annotationsimport json-import reimport pytest@@ -34,37 +33,25 @@ def _classify(cases):body = f"""import {{ classifyBackdrop }} from '{RUNTIME_JS}/lib/backdrop.mjs';const cases = {json.dumps(cases)};-const out = cases.map(([name, size, instanced, span]) => classifyBackdrop(- {{ name, isInstancedMesh: instanced }},- {{ min: {{ x: -size[0] / 2, y: 0, z: -size[2] / 2 }}, max: {{ x: size[0] / 2, y: size[1], z: size[2] / 2 }} }},- span,-));+const out = cases.map(([name, size, instanced, span, lo]) => {{+ const o = lo || [-size[0] / 2, 0, -size[2] / 2]; // the box's min corner: centred on the origin by default+ return classifyBackdrop(+ {{ name, isInstancedMesh: instanced }},+ {{ min: {{ x: o[0], y: o[1], z: o[2] }}, max: {{ x: o[0] + size[0], y: o[1] + size[1], z: o[2] + size[2] }} }},+ span,+ );+}});console.log(JSON.stringify(out));"""return run_node_json(body)def test_classifier_rule_table():- got = _classify([[c[0], c[1], c[2], c[3]] for c in CASES])- assert got == [c[4] for c in CASES], list(zip([c[0] for c in CASES], got, strict=True))---def test_a_small_thing_kilometres_away_is_sky_whatever_its_name():- """`sunRig` parks its 'SunDisc' (no word boundary for SKY_NAME_RE) at 3 600 m: content by- name, and it blew the content bbox to 2.5 km — the overview rig then framed the sun."""- body = f"""-import {{ classifyBackdrop }} from '{RUNTIME_JS}/lib/backdrop.mjs';-const disc = classifyBackdrop({{ name: 'SunDisc' }}, {{ min: {{ x: 2100, y: 2600, z: 1800 }}, max: {{ x: 2148, y: 2648, z: 1848 }} }}, 40);-const near = classifyBackdrop({{ name: 'SunDisc' }}, {{ min: {{ x: 10, y: 20, z: 10 }}, max: {{ x: 58, y: 68, z: 58 }} }}, 40);-console.log(JSON.stringify([disc, near]));-"""- assert run_node_json(body) == ["sky", "content"]---def test_the_rules_live_in_exactly_one_file():- hits = []- for p in sorted((RUNTIME_JS / "lib").rglob("*.mjs")) + sorted((RUNTIME_JS / "lib").rglob("*.js")):- text = p.read_text()- if re.search(r"skydome\|skybox|\bGROUND_NAME_RE\s*=|\bSKY_NAME_RE\s*=", text):- hits.append(p.name)- assert hits == ["backdrop.mjs"], hits+ got = _classify([[c[0], c[1], c[2], c[3]] for c in CASES] + [+ # `sunRig` parks its 'SunDisc' (no word boundary for SKY_NAME_RE) at 3 600 m: content by+ # name, and it blew the content bbox to 2.5 km — the overview rig then framed the sun.+ # A small thing kilometres away is sky whatever its name; the same disc near is content.+ ["SunDisc", [48, 48, 48], False, 40, [2100, 2600, 1800]],+ ["SunDisc", [48, 48, 48], False, 40, [10, 20, 10]],+ ])+ assert got == [c[4] for c in CASES] + ["sky", "content"], list(zip([c[0] for c in CASES], got, strict=False))diff --git a/harness/tests/scene_runtime/test_camera_inside_volume.py b/harness/tests/scene_runtime/test_camera_inside_volume.pyindex f2192072..59d52b24 100644--- a/harness/tests/scene_runtime/test_camera_inside_volume.py+++ b/harness/tests/scene_runtime/test_camera_inside_volume.py@@ -13,9 +13,14 @@ from tests.scene_runtime.conftest import needs_node, run_node_jsonpytestmark = [pytest.mark.node, needs_node]-JS = """+HEAD = """import * as THREE from 'three';import { nearGeometry } from './lib/host_metrics.mjs';+const out = {};+"""++# one case = one block scope storing its nearGeometry report under KEY+JS = """{const solid = new THREE.MeshStandardMaterial(); // FrontSide: a room seen from inside is all back facesconst scene = new THREE.Scene();const ground = new THREE.Mesh(new THREE.PlaneGeometry(80, 80, 2, 2), solid);@@ -26,7 +31,8 @@ const cam = new THREE.PerspectiveCamera(50, 16 / 9, 0.1, 500);cam.position.set(EYE);cam.lookAt(0, 8, 0);cam.updateMatrixWorld(true);-console.log(JSON.stringify(nearGeometry(scene, cam, THREE, undefined, LOOKAT)));+out[KEY] = nearGeometry(scene, cam, THREE, undefined, LOOKAT);+}"""# four 11 m lattice arms on a hub 12 m up, the sail plane turned 45 deg so the world bbox is a@@ -65,58 +71,73 @@ head.name = 'HeadlandTerrain'; head.rotation.x = -Math.PI / 2; head.position.y ="""-def _run(body: str, eye: str, look_at: str = "null") -> dict:- return run_node_json(JS.replace("BODY", body).replace("EYE", eye).replace("LOOKAT", look_at))+def _case(key: str, body: str, eye: str, look_at: str = "null", js: str = JS) -> str:+ return js.replace("KEY", repr(key)).replace("BODY", body).replace("EYE", eye).replace("LOOKAT", look_at)+++_PILLAR_JS = JS.replace("cam.lookAt(0, 8, 0);", "cam.lookAt(0, 1.6, -10);")++[email protected](scope="module")+def got() -> dict:+ """Every case below, in one node process."""+ return run_node_json(HEAD + "".join([+ _case("sails_near", SAILS, "4.5, 12, 4.5"), # inside the 45-degree sails' world bbox, 6.4 m from the hub, in the air+ _case("room", ROOM, "0.5, 1.6, 0.5"),+ _case("hub", SAILS, "0, 12, 0"), # the hub itself, inside both arms+ _case("mound", MOUND, "0, 1.6, 0"),+ _case("void", MOUND, "60, 1.6, 60"), # off the 80 x 80 m ground: nothing beneath the lens+ _case("pillar", PILLAR, "0, 1.6, 0", "[0, 1.6, -4]", js=_PILLAR_JS),+ _case("clear", "", "0, 1.6, 0", "[0, 1.6, -4]", js=_PILLAR_JS),+ _case("headland", HEADLAND, "0, 1.6, 0"),+ _case("roof", HEADLAND.replace("HeadlandTerrain", "Ceiling"), "0, 1.6, 0"),+ ]) + "console.log(JSON.stringify(out));\n")-def test_a_lens_near_lattice_sails_is_not_inside_them():- got = _run(SAILS, "4.5, 12, 4.5") # inside the 45-degree sails' world bbox, 6.4 m from the hub, in the air- assert got["inside_mesh_bbox"] == [], got- assert got["camera_in_geometry"] is False, got+def test_a_lens_near_lattice_sails_is_not_inside_them(got):+ g = got["sails_near"]+ assert g["inside_mesh_bbox"] == [], g+ assert g["camera_in_geometry"] is False, g-def test_a_lens_in_a_back_face_culled_room_is_still_inside():+def test_a_lens_in_a_back_face_culled_room_is_still_inside(got):"""The case the bbox rule was written for keeps its verdict: a FrontSide box around theeye is all back faces to a Raycaster, and parity still counts it."""- got = _run(ROOM, "0.5, 1.6, 0.5")- assert got["inside_mesh_bbox"] == ["CottageShell"], got- assert got["camera_in_geometry"] is True, got+ g = got["room"]+ assert g["inside_mesh_bbox"] == ["CottageShell"], g+ assert g["camera_in_geometry"] is True, g-def test_a_lens_inside_a_solid_arm_is_inside():- got = _run(SAILS, "0, 12, 0") # the hub itself, inside both arms- assert "Sails_1" in got["inside_mesh_bbox"], got- assert got["camera_in_geometry"] is True, got+def test_a_lens_inside_a_solid_arm_is_inside(got):+ g = got["hub"]+ assert "Sails_1" in g["inside_mesh_bbox"], g+ assert g["camera_in_geometry"] is True, g-def test_the_ground_under_the_lens_is_the_ray_straight_down_not_the_highest_ground():+def test_the_ground_under_the_lens_is_the_ray_straight_down_not_the_highest_ground(got):"""Loop 21's ski station (2026-09-09): eye 3.2 m on relief terrain, the highest snow 3.14 m,the gate said "0.06 m above ground — ant's-eye view" and the judge repeated it."""- got = _run(MOUND, "0, 1.6, 0")- assert abs(got["ground_below_m"] - 1.6) < 1e-3 and got["ground_below_name"] == "Ground", got- void = _run(MOUND, "60, 1.6, 60") # off the 80 x 80 m ground: nothing beneath the lens- assert void["ground_below_m"] is None, void+ g = got["mound"]+ assert abs(g["ground_below_m"] - 1.6) < 1e-3 and g["ground_below_name"] == "Ground", g+ assert got["void"]["ground_below_m"] is None, got["void"]-def test_a_surface_filling_the_lens_counts_its_near_sight_rays():- JS_PILLAR = JS.replace("cam.lookAt(0, 8, 0);", "cam.lookAt(0, 1.6, -10);")- got = run_node_json(JS_PILLAR.replace("BODY", PILLAR).replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]"))- assert got["near_rays"] >= 6 and got["near_limit_m"] == 1.5 and got["nearest_hit_name"] == "StonePillar_3", got- assert got["camera_in_geometry"] is False, got # 0.8 m away is not "inside": a different verdict+def test_a_surface_filling_the_lens_counts_its_near_sight_rays(got):+ g = got["pillar"]+ assert g["near_rays"] >= 6 and g["near_limit_m"] == 1.5 and g["nearest_hit_name"] == "StonePillar_3", g+ assert g["camera_in_geometry"] is False, g # 0.8 m away is not "inside": a different verdict# the line of sight to a subject 4 m away is cut by the pillar at 0.8 m- assert abs(got["target_distance_m"] - 4.0) < 1e-3 and abs(got["target_hit_m"] - 0.8) < 1e-3, got- assert got["target_hit_name"] == "StonePillar_3", got- clear = run_node_json(JS_PILLAR.replace("BODY", "").replace("EYE", "0, 1.6, 0").replace("LOOKAT", "[0, 1.6, -4]"))+ assert abs(g["target_distance_m"] - 4.0) < 1e-3 and abs(g["target_hit_m"] - 0.8) < 1e-3, g+ assert g["target_hit_name"] == "StonePillar_3", g+ clear = got["clear"]assert clear["near_rays"] == 0 and clear["target_hit_m"] is None, clear-def test_a_ground_surface_above_the_lens_is_reported():- got = _run(HEADLAND, "0, 1.6, 0")- assert abs(got["ground_above_m"] - 1.4) < 1e-3 and got["ground_above_name"] == "HeadlandTerrain", got- assert abs(got["ground_below_m"] - 1.6) < 1e-3, got- open_air = _run(MOUND, "0, 1.6, 0")- assert open_air["ground_above_m"] is None, open_air+def test_a_ground_surface_above_the_lens_is_reported(got):+ g = got["headland"]+ assert abs(g["ground_above_m"] - 1.4) < 1e-3 and g["ground_above_name"] == "HeadlandTerrain", g+ assert abs(g["ground_below_m"] - 1.6) < 1e-3, g+ assert got["mound"]["ground_above_m"] is None, got["mound"]# a 60 m 'Ceiling' is ground-SHAPED to the classifier and still a roof: loop 25's cathedral# (2026-09-09) read "camera 17.8 m under Ceiling" on every interior camera- roof = _run(HEADLAND.replace("HeadlandTerrain", "Ceiling"), "0, 1.6, 0")- assert roof["ground_above_m"] is None, roof+ assert got["roof"]["ground_above_m"] is None, got["roof"]diff --git a/harness/tests/scene_runtime/test_camera_volumetric.py b/harness/tests/scene_runtime/test_camera_volumetric.pyindex fd1d393d..ef9fddce 100644--- a/harness/tests/scene_runtime/test_camera_volumetric.py+++ b/harness/tests/scene_runtime/test_camera_volumetric.py@@ -14,9 +14,13 @@ from tests.scene_runtime.conftest import needs_node, run_node_jsonpytestmark = [pytest.mark.node, needs_node]-JS = """+HEAD = """import * as THREE from 'three';-import { nearGeometry } from './lib/host_metrics.mjs';+import { nearGeometry, repairCameraSpec } from './lib/host_metrics.mjs';+const out = {};+"""++JS = """{const solid = new THREE.MeshStandardMaterial();const shaftMat = new THREE.MeshBasicMaterial({color: 0xfff0c0, transparent: true, opacity: 0.075,@@ -35,17 +39,24 @@ const cam = new THREE.PerspectiveCamera(50, 16 / 9, 0.1, 500);cam.position.set(0, 1.6, 0);cam.lookAt(0, 1.2, -3);cam.updateMatrixWorld(true);-console.log(JSON.stringify(nearGeometry(scene, cam, THREE)));+out[KEY] = nearGeometry(scene, cam, THREE);+}"""-def _run(depth_write: str) -> dict:- return run_node_json(JS.replace("DEPTH_WRITE", depth_write))[email protected](scope="module")+def got() -> dict:+ """Both arms of both probes (depthWrite off / on), in one node process."""+ blocks = [JS.replace("KEY", "'shaft'").replace("DEPTH_WRITE", "false"),+ JS.replace("KEY", "'solid_shaft'").replace("DEPTH_WRITE", "true"),+ REPAIR_JS.replace("KEY", "'moonbeam'").replace("DEPTH_WRITE", "false"),+ REPAIR_JS.replace("KEY", "'slab'").replace("DEPTH_WRITE", "true")]+ return run_node_json(HEAD + "".join(blocks) + "console.log(JSON.stringify(out));\n")@pytest.fixture(scope="module")-def shaft() -> dict:- return _run("false")+def shaft(got) -> dict:+ return got["shaft"]def test_a_lens_standing_in_a_god_ray_is_not_in_geometry(shaft):@@ -60,16 +71,14 @@ def test_the_bench_behind_it_is_still_seen(shaft):assert 2.0 < shaft["nearest_hit_m"] < 3.5-def test_the_same_slab_WITH_depth_write_is_still_counted():+def test_the_same_slab_WITH_depth_write_is_still_counted(got):"""The control: the rule is `depthWrite`, not the name or the opacity."""- solid_shaft = _run("true")+ solid_shaft = got["solid_shaft"]assert solid_shaft["inside_mesh_bbox"] == ["SunShaft_0"]assert solid_shaft["camera_in_geometry"] is True-REPAIR_JS = """-import * as THREE from 'three';-import { repairCameraSpec } from './lib/host_metrics.mjs';+REPAIR_JS = """{const solid = new THREE.MeshStandardMaterial();const fog = new THREE.MeshBasicMaterial({transparent: true, opacity: 0.04, depthWrite: DEPTH_WRITE, side: THREE.DoubleSide,@@ -91,23 +100,22 @@ const makeCam = (spec) => {};// the cozy_cabin shape: an eye standing IN the moonbeam, 2.4 m from the nearest thingconst spec = { name: 'ArmchairHearthEye', position: [0, 1.6, 0], lookAt: [0, 1.2, -2.4], fov: 50 };-console.log(JSON.stringify({ fix: repairCameraSpec(scene, spec, THREE, makeCam) }));+out[KEY] = { fix: repairCameraSpec(scene, spec, THREE, makeCam) };+}"""-def test_a_camera_standing_in_a_moonbeam_is_not_retreated():+def test_a_camera_standing_in_a_moonbeam_is_not_retreated(got):"""`repairCameraSpec` is driven by `camera_in_geometry`, so a false "inside" does notonly print a finding — it RETREATS the authored lens. bench/out/scene_baseline(2026-09-05) recorded seven repairs, three of them triggered by fog: cozy_cabin'sArmchairHearthEye and WindowFrostSnow were each moved back 4 m and up 2 m becausethey stood in a `MoonlightShaft`, and the first of those ended NEARER geometry thanit started (2.358 m -> 0.916 m). The judge then scored a shot nobody asked for."""- out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "false"))- assert out["fix"] in (None, False), "standing in a light shaft is the shot, not a defect"+ assert got["moonbeam"]["fix"] in (None, False), "standing in a light shaft is the shot, not a defect"-def test_a_camera_buried_in_a_solid_slab_is_still_retreated():+def test_a_camera_buried_in_a_solid_slab_is_still_retreated(got):"""The control: the same geometry that writes depth is matter, and the lens moves."""- out = run_node_json(REPAIR_JS.replace("DEPTH_WRITE", "true"))- assert out["fix"], "a lens inside a solid slab must still be repaired"+ assert got["slab"]["fix"], "a lens inside a solid slab must still be repaired"diff --git a/harness/tests/scene_runtime/test_glb_asset_naming.py b/harness/tests/scene_runtime/test_glb_asset_naming.pyindex 476db51c..5e772016 100644--- a/harness/tests/scene_runtime/test_glb_asset_naming.py+++ b/harness/tests/scene_runtime/test_glb_asset_naming.py@@ -55,8 +55,7 @@ console.log(JSON.stringify({"""-def loaded(tmp_path) -> dict:+def test_a_loaded_glb_carries_its_planned_name_and_plays_its_clip(tmp_path):(tmp_path / "src" / "zones").mkdir(parents=True)(tmp_path / "src" / "zones" / "pergola_lounge.js").write_text(ZONE_JS)cam = CameraPlan(name="establishing", position=[5, 2, 5], look_at=[0, 1, 0], fov=45)@@ -66,32 +65,18 @@ def loaded(tmp_path) -> dict:driver = tmp_path / "driver.mjs"driver.write_text(DRIVER_JS)res = run_node(driver, [], cwd=tmp_path, three_hook=True, timeout_s=60)- return json.loads(res.stdout.strip().splitlines()[-1])---def test_the_zone_sees_the_asset_under_its_planned_name(loaded):+ loaded = json.loads(res.stdout.strip().splitlines()[-1])assert loaded["zoneSees"] == ["LoungeSofa"], "a glTF root is called 'Scene' until someone names it"---def test_the_clone_plays_its_blender_clip_by_absolute_time(loaded):- """A keyframed Blender part arrives as a clip on the preloaded root, `.clone()` keeps it,- and the assembled scene plays it from `update(t)` with no zone code — the same t gives- the same pose (the harness samples t = 0 and 1.5 s)."""+ # `.clone()` copies the name, so the object actually standing in the zone — the one+ # `scene_placement` matches against the plan — carries it as well+ assert loaded["cloneNames"] == ["LoungeSofa"]+ # a keyframed Blender part arrives as a clip on the preloaded root, `.clone()` keeps it,+ # and the assembled scene plays it from `update(t)` with no zone code — the same t gives+ # the same pose (the harness samples t = 0 and 1.5 s)assert loaded["clipsOnClone"] == [1]assert loaded["at0"] == [-0.35] and loaded["at1"] == [0.35] and loaded["again0"] == loaded["at0"]-def test_the_clone_the_zone_places_carries_the_name_too(loaded):- """`.clone()` copies the name, so the object actually standing in the zone — the- one `scene_placement` matches against the plan — carries it as well."""- assert loaded["cloneNames"] == ["LoungeSofa"]---def test_a_plan_without_glb_assets_emits_no_loader():- src = render_scene_js(["z"], [], [], env_ok=False)- assert "assetFiles" not in src and "loadAsync" not in src--def test_a_procedural_asset_is_rendered_on_the_hero_rig(tmp_ws):"""`render_asset` is the hook `scene_assets` judges a threejs asset through: the module isexported by the object track's exporter and rendered on the quick rig a hero's GLB gets.diff --git a/harness/tests/scene_runtime/test_glsl_audit.py b/harness/tests/scene_runtime/test_glsl_audit.pyindex acc7c970..d9e40e86 100644--- a/harness/tests/scene_runtime/test_glsl_audit.py+++ b/harness/tests/scene_runtime/test_glsl_audit.py@@ -11,11 +11,14 @@ from tests.scene_runtime.conftest import needs_node, run_node_jsonpytestmark = [pytest.mark.node, needs_node]-def audit(source: str, **opts) -> list[dict]:+def audit_all(cases: dict[str, tuple[str, dict]]) -> dict[str, list[dict]]:+ """``auditFile`` over every named ``(source, opts)`` case, in one node process."""body = f"""import {{ auditFile }} from './lib/glsl_audit.mjs';-const src = {json.dumps(source)};-console.log(JSON.stringify(auditFile('src/shaders/x.js', src, {json.dumps(opts)})));+const cases = {json.dumps(cases)};+const out = {{}};+for (const [k, [src, opts]] of Object.entries(cases)) out[k] = auditFile('src/shaders/x.js', src, opts);+console.log(JSON.stringify(out));"""return run_node_json(body)@@ -24,64 +27,61 @@ def kinds(findings: list[dict]) -> set[str]:return {f["kind"] for f in findings}-def test_include_not_alone_and_version_and_precision():- src = """const vs = `+INCLUDE = """const vs = `#version 300 esprecision highp float;#include <common> uniform float uTime;void main() { gl_Position = vec4(position, 1.0); }`;const u = { uTime: { value: 0 } };"""- f = audit(src)- k = kinds(f)- assert {"include_not_alone", "version_directive", "precision_directive"} <= k- inc = next(x for x in f if x["kind"] == "include_not_alone")- assert inc["line"] == 4 # line 1 is `const vs = \``, the include is on file line 4- assert inc["severity"] == "error"- assert next(x for x in f if x["kind"] == "version_directive")["severity"] == "error"---def test_fragment_out_plus_gl_fragcolor_and_glsl3():- src = """import * as THREE from 'three';+OUT_PLUS_FRAGCOLOR = """import * as THREE from 'three';const frag = `out vec4 fragColor;void main() { gl_FragColor = vec4(1.0); }`;new THREE.ShaderMaterial({ glslVersion: THREE.GLSL3, fragmentShader: frag });"""- k = kinds(audit(src))- assert "fragment_out_and_gl_fragcolor" in k- assert "glsl3_gl_fragcolor" in k---def test_utime_undeclared_and_unbound():- src = """const frag = `+UTIME_BARE = """const frag = `void main() { gl_FragColor = vec4(sin(uTime)); }`;"""- f = audit(src)- assert {"undeclared_uniform", "unbound_uniform"} <= kinds(f)- # declared + bound → clean- src2 = """const frag = `+UTIME_OK = """const frag = `uniform float uTime;void main() { gl_FragColor = vec4(sin(uTime)); }`;mat.uniforms.uTime = { value: 0 };"""- assert kinds(audit(src2)) == set()---def test_chunk_dropped_warning_only_when_include_missing():- good = """m.onBeforeCompile = (s) => { s.fragmentShader = s.fragmentShader.replace('#include <output_fragment>', `#include <output_fragment>+CHUNK_KEPT = """m.onBeforeCompile = (s) => { s.fragmentShader = s.fragmentShader.replace('#include <output_fragment>', `#include <output_fragment>gl_FragColor.rgb += vec3(0.1);`); };"""- bad = """m.onBeforeCompile = (s) => { s.vertexShader = s.vertexShader.replace('#include <begin_vertex>', `vec3 transformed = position * 2.0;`); };"""- assert kinds(audit(good)) == set()- f = audit(bad)- assert kinds(f) == {"chunk_dropped"}- assert f[0]["severity"] == "warn"---def test_no_fog_warning_respects_scene_fog_and_opt_out():- src = """import * as THREE from 'three';+CHUNK_DROPPED = """m.onBeforeCompile = (s) => { s.vertexShader = s.vertexShader.replace('#include <begin_vertex>', `vec3 transformed = position * 2.0;`); };"""+NO_FOG = """import * as THREE from 'three';const frag = `void main() { gl_FragColor = vec4(1.0); }`;export const m = new THREE.ShaderMaterial({ fragmentShader: frag });"""- assert "no_fog" not in kinds(audit(src, sceneUsesFog=False))- assert "no_fog" in kinds(audit(src, sceneUsesFog=True))- assert "no_fog" not in kinds(audit(src + "\n// 3dcode: no-fog", sceneUsesFog=True))+++def test_the_static_audit_rules():+ """Every rule the shader preflight reports before (or without) a GPU compile, with its+ severity and its file line — the finding an agent is handed."""+ got = audit_all({+ "include": (INCLUDE, {}), "out_plus": (OUT_PLUS_FRAGCOLOR, {}),+ "utime_bare": (UTIME_BARE, {}), "utime_ok": (UTIME_OK, {}),+ "chunk_kept": (CHUNK_KEPT, {}), "chunk_dropped": (CHUNK_DROPPED, {}),+ "fog_unused": (NO_FOG, {"sceneUsesFog": False}), "fog_used": (NO_FOG, {"sceneUsesFog": True}),+ "fog_opt_out": (NO_FOG + "\n// 3dcode: no-fog", {"sceneUsesFog": True}),+ })+ f = got["include"]+ assert {"include_not_alone", "version_directive", "precision_directive"} <= kinds(f)+ inc = next(x for x in f if x["kind"] == "include_not_alone")+ assert inc["line"] == 4 # line 1 is `const vs = \``, the include is on file line 4+ assert inc["severity"] == "error"+ assert next(x for x in f if x["kind"] == "version_directive")["severity"] == "error"++ assert {"fragment_out_and_gl_fragcolor", "glsl3_gl_fragcolor"} <= kinds(got["out_plus"])++ assert {"undeclared_uniform", "unbound_uniform"} <= kinds(got["utime_bare"])+ assert kinds(got["utime_ok"]) == set() # declared + bound → clean++ assert kinds(got["chunk_kept"]) == set()+ assert kinds(got["chunk_dropped"]) == {"chunk_dropped"}+ assert got["chunk_dropped"][0]["severity"] == "warn"++ assert "no_fog" not in kinds(got["fog_unused"])+ assert "no_fog" in kinds(got["fog_used"])+ assert "no_fog" not in kinds(got["fog_opt_out"])def test_locate_source_line_maps_to_file_and_line():diff --git a/harness/tests/scene_runtime/test_lint.py b/harness/tests/scene_runtime/test_lint.pyindex 224fcf78..77ed66f9 100644--- a/harness/tests/scene_runtime/test_lint.py+++ b/harness/tests/scene_runtime/test_lint.py@@ -15,13 +15,6 @@ def _msgs(report, sev=None):return [(f.target, f.message) for f in report.findings if sev is None or f.severity == sev]-def test_example_scene_lints_clean(starter_ws):- rep = lint(starter_ws)- assert rep.gate == "lint:scene_threejs"- assert rep.passed, _msgs(rep)- assert not [f for f in rep.findings if f.severity == Severity.ERROR]--def test_required_scene_entry_and_export(ws):rep = lint(ws)assert not rep.passeddiff --git a/harness/tests/scene_runtime/test_orbit.py b/harness/tests/scene_runtime/test_orbit.pyindex f8c240dc..dffa97e8 100644--- a/harness/tests/scene_runtime/test_orbit.py+++ b/harness/tests/scene_runtime/test_orbit.py@@ -19,72 +19,54 @@ VIEWS = []-def fit(bbox=BBOX, views=VIEWS, **opts):+def test_orbit_rig_fitting():+ """The rig's convention, the orbit views, the per-zone eye and the overview — every+ camera the harness derives for a scene, in one node process."""body = f"""-import {{ fitOrbitCameras, orbitDirection }} from './lib/orbit.mjs';-console.log(JSON.stringify(fitOrbitCameras({json.dumps(bbox)}, {json.dumps(views)}, {json.dumps(opts)})));+import {{ fitOrbitCameras, fitZoneCamera, fitOverviewCamera, orbitDirection }} from './lib/orbit.mjs';+const zone = {{ min: [20, 0, -5], max: [30, 3, 5], size: [10, 3, 10] }};+console.log(JSON.stringify({{+ front: orbitDirection(0, 0), right: orbitDirection(90, 0),+ none: fitOrbitCameras(null, {json.dumps(VIEWS)}, {{}}),+ cams: fitOrbitCameras({json.dumps(BBOX)}, {json.dumps(VIEWS)}, {{ groundY: 0.0 }}),+ floored: fitZoneCamera(zone, {{ azimuth: 0, floor: 2.0 }}),+ sun_x: fitZoneCamera(zone, {{ azimuth: 90 }}),+ overview: fitOverviewCamera({json.dumps(BBOX)}, {{ azimuth: 90, elevation: 30, groundY: 0.0 }}),+}}));"""- return run_node_json(body)---def test_direction_convention_front_is_plus_z_and_ccw():- body = """-import { orbitDirection } from './lib/orbit.mjs';-console.log(JSON.stringify([orbitDirection(0, 0), orbitDirection(90, 0)]));-"""- front, right = run_node_json(body)+ out = run_node_json(body)+ # direction convention: front is +Z, azimuth turns counter-clockwise to +X+ front, right = out["front"], out["right"]assert front[2] == pytest.approx(1.0) and abs(front[0]) < 1e-9assert right[0] == pytest.approx(1.0) and abs(right[2]) < 1e-9--def test_orbit_cameras_are_above_ground_and_fitted():- assert fit(None) == []- cams = fit(groundY=0.0)+ # orbit cameras: above ground and fitted+ assert out["none"] == []+ cams = out["cams"]by = {c["name"]: c for c in cams}assert set(by) == {"overview_front_right", "overview_top", "eye_front"}for c in cams:assert c["position"][1] > 0.5, cassert c["kind"] == "orbit"ov = by["overview_front_right"]- dist = math.dist(ov["position"], ov["lookAt"])- assert 80 < dist < 200+ assert 80 < math.dist(ov["position"], ov["lookAt"]) < 200assert ov["noFog"] is Trueeye = by["eye_front"]# eye-level: stands just outside the footprint (z > 40), ~1.6-3 m high, fog keptassert 40 < eye["position"][2] < 60assert 1.5 < eye["position"][1] < 4assert eye["noFog"] is False- top = by["overview_top"]- assert top["position"][1] > 100-def test_fit_zone_camera_respects_floor_and_sun_side():- body = """-import { fitZoneCamera } from './lib/orbit.mjs';-const box = { min: [20, 0, -5], max: [30, 3, 5], size: [10, 3, 10] };-console.log(JSON.stringify({- floored: fitZoneCamera(box, { azimuth: 0, floor: 2.0 }),- sun_x: fitZoneCamera(box, { azimuth: 90 }),-}));-"""- out = run_node_json(body)+ assert by["overview_top"]["position"][1] > 100++ # a zone camera respects the floor and stands on the sun sideassert out["floored"]["position"][1] >= 3.5 # floor 2.0 + eye heightassert out["floored"]["lookAt"][1] <= out["floored"]["position"][1]# azimuth 90 → eye on the +X side, outside the footprint (x > 30)assert out["sun_x"]["position"][0] > 30assert out["sun_x"]["lookAt"] == [25, 1.5, 0]--def test_fit_overview_camera_corner_fit_and_ground_aware():- body = """-import { fitOverviewCamera, fitDistance, orbitDirection } from './lib/orbit.mjs';-const box = { min: [-40, -1, -40], max: [40, 9, 40], size: [80, 10, 80] };-const cam = fitOverviewCamera(box, { azimuth: 90, elevation: 30, groundY: 0.0 });-const d = orbitDirection(90, 30);-console.log(JSON.stringify({ cam, d }));-"""- out = run_node_json(body)- cam = out["cam"]- # eye on the +X sun side, above ground, looking at the box centre+ # the overview: eye on the +X sun side, above ground, looking at the box centre+ cam = out["overview"]assert cam["position"][0] > 40 and cam["position"][1] > 0.5assert cam["lookAt"] == [0, 4, 0]- dist = math.dist(cam["position"], cam["lookAt"])- assert 80 < dist < 200 # corner-frustum fit, not a loose sphere fit+ assert 80 < math.dist(cam["position"], cam["lookAt"]) < 200 # corner-frustum fit, not a loose sphere fitdiff --git a/harness/tests/scene_runtime/test_post.py b/harness/tests/scene_runtime/test_post.pyindex bc4bdcba..444e740b 100644--- a/harness/tests/scene_runtime/test_post.py+++ b/harness/tests/scene_runtime/test_post.py@@ -88,26 +88,16 @@ def test_post_chain_args_follow_the_env_switch(switch):@needs_node@needs_browser-def test_chain_alone_is_colour_neutral(tmp_path):- """AO off, bloom off, grade at its defaults → the same picture as no chain.-- Without this the grade could drift and nobody would notice: every later- measurement of AO or bloom is a delta against a raw render.- """- ws = make_ws(tmp_path, "neutral", BRIGHT)- raw = render(ws, tmp_path / "raw", "--no-post")- chain = render(ws, tmp_path / "chain", "--post-options", '{"ao":0,"bloom":0}')- assert abs(mean_lum(chain) - mean_lum(raw)) < 0.005, (mean_lum(raw), mean_lum(chain))---@needs_node-@needs_browser-def test_bloom_is_selective_not_a_brightness_threshold(tmp_path):+def test_bloom_is_selective_and_the_chain_alone_is_colour_neutral(tmp_path):"""An EMISSIVE box blooms; an equally bright NON-emissive box does not.Both scenes are lit the same and the plain box is the brighter of the two inthe raw render — so anything that keys off frame luminance fails this test,which is exactly the reference chain's failure mode.++ And AO off, bloom off, grade at its defaults → the same picture as no chain.+ Without that the grade could drift and nobody would notice: every later+ measurement of AO or bloom is a delta against a raw render."""emissive = make_ws(tmp_path, "emissive", EMISSIVE)plain = make_ws(tmp_path, "plain", BRIGHT)@@ -124,6 +114,8 @@ def test_bloom_is_selective_not_a_brightness_threshold(tmp_path):assert mean_lum(e_post) - mean_lum(e_raw) > 0.004, "emissive box did not bloom"assert abs(mean_lum(p_post) - mean_lum(p_raw)) < 0.005, "a merely bright box must not bloom"+ chain = render(plain, tmp_path / "p_chain", "--post-options", '{"ao":0,"bloom":0}')+ assert abs(mean_lum(chain) - mean_lum(p_raw)) < 0.005, (mean_lum(p_raw), mean_lum(chain))@needs_nodediff --git a/harness/tests/scene_runtime/test_probes.py b/harness/tests/scene_runtime/test_probes.pyindex ad8c5422..3dc3a1a7 100644--- a/harness/tests/scene_runtime/test_probes.py+++ b/harness/tests/scene_runtime/test_probes.py@@ -4,34 +4,12 @@ from __future__ import annotationsimport pytest-from codeverse3d.contracts.artifacts import Severityfrom codeverse3d.spatial.probes import probe_scene, run_probefrom tests.scene_runtime.conftest import needs_browserpytestmark = [pytest.mark.node, needs_browser]-def test_probe_scene_passes_on_example(starter_ws):- res = probe_scene(starter_ws)- gate, census = res- assert gate.gate == "scene_probe" and gate.passed, [(f.target, f.message) for f in gate.findings]- assert res.ok and res.errors == []- assert census["totals"]["meshes"] > 10 and census["totals"]["lights"] == 3- assert {g["name"] for g in census["groups"]} == {"Environment", "Meadow", "Pondside"}- assert census["content_bbox"]["size"][0] > 50- assert (starter_ws.artifacts / "census.json").is_file()- assert gate.duration_ms < 15000---def test_probe_scene_reports_import_error_with_stage(starter_ws):- (starter_ws.src / "scene.js").write_text("import * as THREE from 'three';\nimport { nope } from './does_not_exist.js';\nexport function createScene() {}\n")- gate, census = probe_scene(starter_ws)- assert not gate.passed- err = gate.errors[0]- assert err.data.get("stage") == "import" and err.target == "src/scene.js"- assert "fix the syntax/import error" in err.fix_hint--def test_probe_scene_flags_bad_shape_and_cameras(starter_ws):(starter_ws.src / "scene.js").write_text("import * as THREE from 'three';\n"@@ -86,31 +64,9 @@ def test_the_shader_preflight_runs_raw(ws, tmp_path, monkeypatch):assert any("post chain built" in e for e in rs.console_errors), rs.console_errors-def test_preflight_clean_on_example(starter_ws):- rep = preflight(starter_ws)- assert rep.gate == "shader_preflight" and rep.passed, [(f.target, f.message) for f in rep.findings]- info = [f for f in rep.findings if f.severity == Severity.INFO]- assert info and info[0].data.get("programs", 0) >= 3---def test_preflight_maps_compile_error_to_file_line(starter_ws):- p = starter_ws.src / "shaders" / "water.js"- text = p.read_text()- needle = "float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0);"- assert needle in text- text = text.replace(needle, "float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0) * undefinedThing;")- p.write_text(text)- line = next(i for i, ln in enumerate(text.splitlines(), 1) if "undefinedThing" in ln)- rep = preflight(starter_ws)- assert not rep.passed- err = rep.errors[0]- assert err.target == f"src/shaders/water.js:{line}", err- assert "undeclared identifier" in err.message and "undefinedThing" in err.message- assert err.data.get("material") and "PondWater" in err.data["material"]- assert err.fix_hint---def test_preflight_on_before_compile_patch_error(starter_ws):+def test_preflight_maps_patch_and_static_audit_errors_to_file_line(starter_ws):+ """An onBeforeCompile patch's compile error lands on the patch's own file:line, and+ the static audit reports a shader file no scene imports, all in one preflight."""(starter_ws.src / "shaders" / "glow.js").write_text("import * as THREE from 'three';\n""export function makeGlow(T = THREE) {\n"@@ -132,18 +88,13 @@ def test_preflight_on_before_compile_patch_error(starter_ws):)assert "makeGlow(THREE)" in textp.write_text(text)- rep = preflight(starter_ws)- assert not rep.passed- err = rep.errors[0]- assert err.target == "src/shaders/glow.js:6", err- assert "missingUniform" in err.message---def test_preflight_static_audit_without_compile(starter_ws):(starter_ws.src / "shaders" / "bad.js").write_text("export const frag = `\n#version 300 es\nvoid main() { gl_FragColor = vec4(uTime); }`;\n")rep = preflight(starter_ws)+ assert not rep.passed+ glow = [f for f in rep.errors if f.target == "src/shaders/glow.js:6"]+ assert glow and "missingUniform" in glow[0].message, [(f.target, f.message) for f in rep.errors]kinds = {f.data.get("kind") for f in rep.errors}assert {"version_directive", "undeclared_uniform", "unbound_uniform"} <= kindsassert any(f.target == "src/shaders/bad.js:2" for f in rep.errors)diff --git a/harness/tests/scene_runtime/test_render_scene.py b/harness/tests/scene_runtime/test_render_scene.pyindex feedfe21..470116d8 100644--- a/harness/tests/scene_runtime/test_render_scene.py+++ b/harness/tests/scene_runtime/test_render_scene.py@@ -61,6 +61,8 @@ def fake_runtime(tmp_path, monkeypatch):@needs_nodedef test_render_scene_parses_driver_output(fake_runtime, ws, tmp_path):out = tmp_path / "out"+ out.mkdir() # a previous render's metrics must not leak into this one+ (out / "metrics.json").write_text('{"views": [{"name": "stale", "path": "x.png", "position": [0,0,0], "lookAt": [0,0,0]}]}')cams = [CameraPlan(name="cam_a", position=(1, 2, 3), look_at=(0, 0, 0), fov=45)]rs = render_scene(ws, out, cameras=cams, orbit=True, times=(0.0, 1.5), orbit_views=SCENE_VIEWS[:2], sheet=True)assert len(rs.views) == 2 * 3@@ -80,9 +82,6 @@ def test_driver_failures_raise(fake_runtime):run_scene_script("crash.mjs", [], timeout_s=30)with pytest.raises(SceneRenderError, match="timed out"):run_scene_script("slow.mjs", [], timeout_s=1)---def test_missing_driver_raises(fake_runtime):with pytest.raises(SceneRenderError, match="missing node driver"):run_scene_script("nope.mjs", [], timeout_s=5)@@ -165,16 +164,6 @@ def test_driver_crash_after_metrics_degrades_to_renderset(fake_runtime, ws, tmp_assert any("render_scene.mjs failed (exit 2)" in e for e in rs.console_errors)-@needs_node-def test_render_scene_clears_stale_metrics(fake_runtime, ws, tmp_path):- out = tmp_path / "out"- out.mkdir()- (out / "metrics.json").write_text('{"views": [{"name": "stale", "path": "x.png", "position": [0,0,0], "lookAt": [0,0,0]}]}')- rs = render_scene(ws, out, cameras=[CameraPlan(name="cam_a", position=(1, 2, 3), look_at=(0, 0, 0), fov=45)],- orbit=False, times=(0.0,), sheet=False)- assert all(v.name != "stale" for v in rs.views)--# The post chain cannot read this grade, so it is never built and every frame renders RAW# (a boot-time host warning); the box refuses the coverage instrument's flat-white mask pass# (a warning pushed while the camera checks run, i.e. AFTER boot).@@ -270,12 +259,7 @@ def _flags(args):({}, ["--camera-repair"]),({"C3D_CAMERA_REPAIR": "0"}, []),({"C3D_CAMERA_REPAIR": "false"}, []),- ({"C3D_CAMERA_REPAIR": "off"}, []),- ({"C3D_CAMERA_REPAIR": "no"}, []),- ({"C3D_CAMERA_REPAIR": "true"}, ["--camera-repair"]),- ({"C3D_SETTLE": "0"}, ["--camera-repair", "--no-settle"]),({"C3D_SETTLE": "false"}, ["--camera-repair", "--no-settle"]),- ({"C3D_AUTO_EXPOSURE": "1"}, ["--auto-exposure", "--camera-repair"]),({"C3D_AUTO_EXPOSURE": "true"}, ["--auto-exposure", "--camera-repair"]),({"C3D_AUTO_EXPOSURE": "garbage"}, ["--camera-repair"]),])diff --git a/harness/tests/scene_runtime/test_runtime.py b/harness/tests/scene_runtime/test_runtime.pyindex b9aec9bd..248341b9 100644--- a/harness/tests/scene_runtime/test_runtime.py+++ b/harness/tests/scene_runtime/test_runtime.py@@ -6,6 +6,7 @@ import jsonimport pytest+from codeverse3d.contracts.artifacts import Severityfrom codeverse3d.contracts.common import Languagefrom codeverse3d.languages import get_runtimefrom codeverse3d.languages.base import LanguageRuntime@@ -29,13 +30,22 @@ def test_runtime_registered_conforms_and_writes_skeleton(ws):@pytest.mark.node@needs_browserdef test_build_ok_on_example(starter_ws):+ """The example scene: one probe boot passes both gates and records its census."""rt = SceneThreeJsRuntime()res = rt.build(starter_ws)assert res.ok, res.stdout_tailassert res.language == "scene_threejs" and res.glb_path is None- assert res.census["totals"]["meshes"] > 10+ census = res.census+ assert census["totals"]["meshes"] > 10 and census["totals"]["lights"] == 3+ assert {g["name"] for g in census["groups"]} == {"Environment", "Meadow", "Pondside"}+ assert census["content_bbox"]["size"][0] > 50assert (starter_ws.artifacts / "build.json").is_file() and (starter_ws.artifacts / "census.json").is_file()+ probe, shaders = res.gates+ assert probe.gate == "scene_probe" and probe.passed and probe.duration_ms < 15000assert json.loads((starter_ws.artifacts / "gates" / "shader_preflight.json").read_text())["passed"]+ assert shaders.gate == "shader_preflight"+ info = [f for f in shaders.findings if f.severity == Severity.INFO]+ assert info and info[0].data.get("programs", 0) >= 3@pytest.mark.node@@ -44,14 +54,22 @@ def test_build_fails_with_file_line_on_shader_error(starter_ws):# the pond's water shader: a file the example scene compiles (the starter's sky comes# from lib/environment.js worldShell since D71)p = starter_ws.src / "shaders" / "water.js"- text = p.read_text().replace("float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0);", "float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0) + nope;")- assert "nope" in text+ text = p.read_text()+ needle = "float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0);"+ assert needle in text+ text = text.replace(needle, "float fres = pow(1.0 - max(dot(N, V), 0.0), 3.0) * undefinedThing;")p.write_text(text)+ line = next(i for i, ln in enumerate(text.splitlines(), 1) if "undefinedThing" in ln)res = SceneThreeJsRuntime().build(starter_ws)assert not res.ok- assert res.error_file == "src/shaders/water.js" and res.error_line- assert "nope" in res.error_message+ assert res.error_file == "src/shaders/water.js" and res.error_line == line+ assert "undefinedThing" in res.error_messageassert "shader_preflight: FAILED" in res.stdout_tail+ err = res.gates[1].errors[0]+ assert err.target == f"src/shaders/water.js:{line}", err+ assert "undeclared identifier" in err.message and "undefinedThing" in err.message+ assert err.data.get("material") and "PondWater" in err.data["material"]+ assert err.fix_hint@pytest.mark.node@@ -60,6 +78,9 @@ def test_build_fails_on_import_error(starter_ws):(starter_ws.src / "scene.js").write_text("import { x } from './nope.js';\nexport function createScene() {}\n")res = SceneThreeJsRuntime().build(starter_ws)assert not res.ok and res.error_file == "src/scene.js" and "nope.js" in res.error_message+ err = res.gates[0].errors[0]+ assert err.data.get("stage") == "import" and err.target == "src/scene.js"+ assert "fix the syntax/import error" in err.fix_hintdef test_build_interprets_combined_summary_offline(ws, monkeypatch):diff --git a/harness/tests/scene_runtime/test_skeleton.py b/harness/tests/scene_runtime/test_skeleton.pyindex 43e14c18..3844173f 100644--- a/harness/tests/scene_runtime/test_skeleton.py+++ b/harness/tests/scene_runtime/test_skeleton.py@@ -3,7 +3,7 @@from __future__ import annotationsfrom codeverse3d.contracts.plan import AssetPlan, BBox, CameraPlan, ScenePlan, ZonePlan-from codeverse3d.languages.scene_threejs import STARTER_DIR, lint, write_example, write_skeleton+from codeverse3d.languages.scene_threejs import lint, write_example, write_skeletonfrom codeverse3d.workspace import Workspacefrom tests.scene_runtime.conftest import needs_node@@ -25,23 +25,6 @@ def make_plan() -> ScenePlan:)-def test_example_files_exist_and_are_complete():- names = {p.relative_to(STARTER_DIR).as_posix() for p in STARTER_DIR.rglob("*.js")}- assert {"scene.js", "env.js", "zones/meadow.js", "zones/pondside.js", "assets/pine_tree.js", "assets/windmill.js", "shaders/water.js"} <= names- scene = (STARTER_DIR / "scene.js").read_text()- assert "export function createScene" in scene and "cameras" in scene and "update(t, dt)" in scene- assert "ShaderMaterial" in (STARTER_DIR / "shaders" / "water.js").read_text()- assert "InstancedMesh" in (STARTER_DIR / "zones" / "meadow.js").read_text()---def test_example_writers_copy_all(ws):- paths = write_example(ws)- assert len(paths) >= 8- assert (ws.src / "scene.js").is_file()- fallback = write_skeleton(ws, None)- assert (ws.src / "zones" / "meadow.js") in fallback--@needs_nodedef test_plan_skeleton_writes_zone_and_asset_stubs_and_lints(ws):plan = make_plan()@@ -84,6 +67,8 @@ def test_both_skeleton_paths_ship_the_effect_library(tmp_path):got = {p.name for p in written if p.parent == ws.src / "lib"}assert got == names, (label, sorted(names - got))assert (ws.src / "lib" / "grass.js").is_file(), label+ if plan is None: # no plan: the complete example scene is the skeleton+ assert ws.src / "zones" / "meadow.js" in written and (ws.src / "scene.js").is_file()def test_the_library_is_harness_owned_so_an_agent_cannot_rewrite_it():@@ -117,6 +102,7 @@ def test_the_lint_does_not_judge_the_library_as_agent_code(tmp_path):ws = Workspace(tmp_path / "ws")write_example(ws)report = lint(ws)+ assert report.gate == "lint:scene_threejs"assert report.passed, [f.message for f in report.findings if f.severity == Severity.ERROR]assert not [f for f in report.findings if f.target.startswith("src/lib/")], \[f.target for f in report.findings if f.target.startswith("src/lib/")]