Official Codebase of 3DCodeVerse
Python
scene flags: one env-flag parser, and the combined build gets the flags
gaoypeng1d01ef5efbc9
diff --git a/harness/codeverse/languages/scene_threejs/__init__.py b/harness/codeverse/languages/scene_threejs/__init__.pyindex ec91ecab..0f637d01 100644--- a/harness/codeverse/languages/scene_threejs/__init__.py+++ b/harness/codeverse/languages/scene_threejs/__init__.py@@ -684,7 +684,7 @@ def _probe_and_preflight(ws: Workspace, *, timeout_s: float) -> tuple[GateReport"""from codeverse.contracts.artifacts import GateFindingfrom codeverse.spatial.probes import PROBE_GATE, SHADER_GATE, probe_report, shader_report- from codeverse.spatial.render_scene import SceneRenderError, run_scene_script+ from codeverse.spatial.render_scene import SceneRenderError, probe_env_args, run_scene_scriptt0 = time.time()args = [@@ -693,6 +693,10 @@ def _probe_and_preflight(ws: Workspace, *, timeout_s: float) -> tuple[GateReport"--shaders-out", str(ws.artifacts / "shader_preflight.json"),"--timeout-ms", str(int(timeout_s * 1000)),]+ # the production build probes under the SAME settle / camera-repair / auto-exposure+ # policy every render uses (review-3 S4: it used to carry none of the flags, so the+ # build gate measured a census the renders then contradicted)+ args += probe_env_args()try:res = run_scene_script("probe_scene.mjs", args, timeout_s=timeout_s + 20)except SceneRenderError as e:diff --git a/harness/codeverse/spatial/probes.py b/harness/codeverse/spatial/probes.pyindex f1ff7624..fffe87e0 100644--- a/harness/codeverse/spatial/probes.py+++ b/harness/codeverse/spatial/probes.py@@ -9,7 +9,6 @@ Both drive the node host (``runtime_js/*.mjs``) via ``run_scene_script``.from __future__ import annotationsimport json-import osimport timefrom typing import Any@@ -17,7 +16,7 @@ from pydantic import BaseModel, Fieldfrom codeverse.contracts.artifacts import GateFinding, GateReport, Severityfrom codeverse.conventions import MAX_TRIS_SCENE-from codeverse.spatial.render_scene import SceneRenderError, run_scene_script+from codeverse.spatial.render_scene import SceneRenderError, probe_env_args, run_scene_scriptfrom codeverse.workspace import WorkspacePROBE_GATE = "scene_probe"@@ -70,15 +69,7 @@ def probe_scene(ws: Workspace, *, timeout_s: float = 60.0, write_census: bool =out_json = ws.artifacts / "scene_probe.json"try:args = ["--ws", str(ws.root), "--out", str(out_json), "--timeout-ms", str(int(timeout_s * 1000))]- if os.environ.get("CV3D_SETTLE") == "0": # A/B switch for the boot-time auto-seat- args.append("--no-settle")- if os.environ.get("CV3D_CAMERA_REPAIR") != "0": # default ON since 2026-08-30: pure insurance —- # zero triggers across a whole healthy battery (scene_px_v1: layout camera-clearance- # already keeps lenses out of furniture), and the one class it exists for- # (fv_izakaya: three rounds of camera_in_geometry nobody could fix) is fatal.- args.append("--camera-repair")- if os.environ.get("CV3D_AUTO_EXPOSURE") == "1": # opt-in: bounded scene-wide exposure into the healthy band- args.append("--auto-exposure")+ args += probe_env_args() # settle / camera-repair / auto-exposure: ONE parser (render_scene)res = run_scene_script("probe_scene.mjs", args, timeout_s=timeout_s + 20)except SceneRenderError as e:findings.append(_f(gate, Severity.ERROR, f"scene probe could not run: {e}", target="src/scene.js",diff --git a/harness/codeverse/spatial/render_scene.py b/harness/codeverse/spatial/render_scene.pyindex 6d75994d..d1a40e80 100644--- a/harness/codeverse/spatial/render_scene.py+++ b/harness/codeverse/spatial/render_scene.py@@ -21,7 +21,7 @@ from collections.abc import Sequencefrom pathlib import Pathfrom typing import Any-from codeverse.config import get_settings+from codeverse.config import env_flag, get_settingsfrom codeverse.contracts.artifacts import RenderSet, RenderViewfrom codeverse.contracts.plan import BBox, CameraPlanfrom codeverse.conventions import SCENE_VIEWS, ViewPreset@@ -72,6 +72,26 @@ def run_scene_script(script: str, args: Sequence[str], *, timeout_s: float, cwd:return r+def probe_env_args() -> list[str]:+ """Scene-driver flags from the ``CV3D_*`` switches — the ONE parser (review-3 S4),+ on the canonical ``env_flag`` words, so ``CV3D_CAMERA_REPAIR=false`` really+ disables and ``CV3D_AUTO_EXPOSURE=true`` really enables. Every driver+ invocation — standalone probe, render, and the combined single-boot build —+ appends these, so a census is always measured under the same settle /+ camera-repair / auto-exposure policy the renders use."""+ args: list[str] = []+ if not env_flag("CV3D_SETTLE", True): # A/B switch for the boot-time auto-seat+ args.append("--no-settle")+ if env_flag("CV3D_CAMERA_REPAIR", True): # default ON since 2026-08-30: pure insurance —+ # zero triggers across a whole healthy battery (scene_px_v1: layout camera-clearance+ # already keeps lenses out of furniture), and the one class it exists for+ # (fv_izakaya: three rounds of camera_in_geometry nobody could fix) is fatal.+ args.append("--camera-repair")+ if env_flag("CV3D_AUTO_EXPOSURE", False): # opt-in: bounded scene-wide exposure into the healthy band+ args.append("--auto-exposure")+ return args++def _camera_json(cams: Sequence[CameraPlan]) -> str:return json.dumps([{"name": c.name, "position": list(c.position), "lookAt": list(c.look_at), "fov": c.fov} for c in cams@@ -140,15 +160,7 @@ def render_scene(args += ["--bounds", _bounds_json(bounds)]tmo = timeout_s or settings.limits.render_timeout_sargs += ["--timeout-ms", str(int(tmo * 1000))]- if os.environ.get("CV3D_SETTLE") == "0": # A/B switch for the boot-time auto-seat- args.append("--no-settle")- if os.environ.get("CV3D_CAMERA_REPAIR") != "0": # default ON since 2026-08-30: pure insurance —- # zero triggers across a whole healthy battery (scene_px_v1: layout camera-clearance- # already keeps lenses out of furniture), and the one class it exists for- # (fv_izakaya: three rounds of camera_in_geometry nobody could fix) is fatal.- args.append("--camera-repair")- if os.environ.get("CV3D_AUTO_EXPOSURE") == "1": # opt-in: bounded scene-wide exposure into the healthy band- args.append("--auto-exposure")+ args += probe_env_args()driver_error = ""try:res = run_scene_script("render_scene.mjs", args, timeout_s=tmo + 30)diff --git a/harness/tests/scene_runtime/test_render_scene.py b/harness/tests/scene_runtime/test_render_scene.pyindex ffbe6c97..266f2e40 100644--- a/harness/tests/scene_runtime/test_render_scene.py+++ b/harness/tests/scene_runtime/test_render_scene.py@@ -12,6 +12,7 @@ from codeverse.conventions import SCENE_VIEWSfrom codeverse.spatial import render_scene as rs_modfrom codeverse.spatial.render_scene import (SceneRenderError,+ probe_env_args,read_metrics,render_scene,run_scene_script,@@ -169,3 +170,72 @@ def test_request_failure_line_filters_phantom_aborts():assert res["real"] == "request failed: /assets/a.glb (net::ERR_CONNECTION_REFUSED)"assert res["offsite"] is Noneassert res["cs_default"] == 20000 and res["cs_flag"] == 3000 and res["cs_small_budget"] == 6000+++# ---------------------------------------------------------------- env flags (review-3 S4)+_FLAG_WORDS = ("--no-settle", "--camera-repair", "--auto-exposure")+++def _flags(args):+ return sorted(a for a in args if a in _FLAG_WORDS)++[email protected](("env", "expect"), [+ ({}, ["--camera-repair"]),+ ({"CV3D_CAMERA_REPAIR": "0"}, []),+ ({"CV3D_CAMERA_REPAIR": "false"}, []),+ ({"CV3D_CAMERA_REPAIR": "off"}, []),+ ({"CV3D_CAMERA_REPAIR": "no"}, []),+ ({"CV3D_CAMERA_REPAIR": "true"}, ["--camera-repair"]),+ ({"CV3D_SETTLE": "0"}, ["--camera-repair", "--no-settle"]),+ ({"CV3D_SETTLE": "false"}, ["--camera-repair", "--no-settle"]),+ ({"CV3D_AUTO_EXPOSURE": "1"}, ["--auto-exposure", "--camera-repair"]),+ ({"CV3D_AUTO_EXPOSURE": "true"}, ["--auto-exposure", "--camera-repair"]),+ ({"CV3D_AUTO_EXPOSURE": "garbage"}, ["--camera-repair"]),+])+def test_probe_env_args_speaks_the_canonical_flag_words(monkeypatch, env, expect):+ """CV3D_CAMERA_REPAIR=false must DISABLE, CV3D_SETTLE=false must disable,+ CV3D_AUTO_EXPOSURE=true must enable — the raw '0'/'1' compares silently+ ignored every other word the doc'd env_flag vocabulary accepts."""+ for k in ("CV3D_SETTLE", "CV3D_CAMERA_REPAIR", "CV3D_AUTO_EXPOSURE"):+ monkeypatch.delenv(k, raising=False)+ for k, v in env.items():+ monkeypatch.setenv(k, v)+ assert _flags(probe_env_args()) == expect+++def test_every_driver_invocation_carries_the_env_flags(monkeypatch, ws, tmp_path):+ """Review-3 S4 (V7c): the combined single-boot build probes under the SAME+ settle / camera-repair / auto-exposure flags as the standalone probe and+ render paths — it used to pass none of them."""+ import codeverse.languages.scene_threejs as st+ import codeverse.spatial.probes as probes_mod++ captured: dict[str, list[str]] = {}++ def fake_run(script, args, *, timeout_s=0.0, cwd=None):+ captured[script] = list(map(str, args))+ raise SceneRenderError("captured")++ monkeypatch.setattr(probes_mod, "run_scene_script", fake_run)+ monkeypatch.setattr(rs_mod, "run_scene_script", fake_run)+ for k in ("CV3D_SETTLE", "CV3D_CAMERA_REPAIR", "CV3D_AUTO_EXPOSURE"):+ monkeypatch.delenv(k, raising=False)++ # defaults: camera repair ON everywhere, settle on (no flag), exposure off+ probes_mod.probe_scene(ws)+ assert _flags(captured["probe_scene.mjs"]) == ["--camera-repair"]+ st._probe_and_preflight(ws, timeout_s=5.0)+ assert _flags(captured["probe_scene.mjs"]) == ["--camera-repair"], "combined build lost the default-ON policy"+ with pytest.raises(SceneRenderError):+ render_scene(ws, tmp_path / "out_flags", cameras=[CameraPlan(name="c", position=(1, 2, 3), look_at=(0, 0, 0), fov=45)],+ orbit=False, times=(0.0,), sheet=False)+ assert _flags(captured["render_scene.mjs"]) == ["--camera-repair"]++ # the A/B words reach every path, including the combined build+ monkeypatch.setenv("CV3D_SETTLE", "0")+ monkeypatch.setenv("CV3D_CAMERA_REPAIR", "false")+ st._probe_and_preflight(ws, timeout_s=5.0)+ assert _flags(captured["probe_scene.mjs"]) == ["--no-settle"]+ probes_mod.probe_scene(ws)+ assert _flags(captured["probe_scene.mjs"]) == ["--no-settle"]