Skip to content

Official Codebase of 3DCodeVerse

Python

spatial: shader_probe reports the build's own probe and preflight

gaoypeng132ca7a804af
diff --git a/harness/codeverse3d/languages/scene_threejs/__init__.py b/harness/codeverse3d/languages/scene_threejs/__init__.py
index f967d2c8..6697e18c 100644
--- a/harness/codeverse3d/languages/scene_threejs/__init__.py
+++ b/harness/codeverse3d/languages/scene_threejs/__init__.py
@@ -771,13 +771,12 @@ class SceneThreeJsRuntime:
(``BuildResult.gates``, which the round appends to its gates) and land
under ``artifacts/gates/`` as well."""
t0 = time.time()
- tmo = min(float(timeout_s or get_settings().limits.build_timeout_s), 120.0)
ws.artifacts.mkdir(parents=True, exist_ok=True)
# a probe/driver crash must not leave the previous round's census or the root
# driver outputs (scene_probe.json / shader_preflight.json) looking current;
# census.json is only rewritten `if census:` below, so it MUST be wiped here
ws.stage_artifacts("census.json", "scene_probe.json", "shader_preflight.json", "build.json").invalidate()
- probe, shaders, census = _probe_and_preflight(ws, timeout_s=tmo)
+ probe, shaders, census = probe_and_preflight(ws, timeout_s=timeout_s)
if census:
(ws.artifacts / "census.json").write_text(json.dumps(census, indent=1))
gates_dir = ws.artifacts / "gates"
@@ -804,7 +803,7 @@ class SceneThreeJsRuntime:
census=census,
gates=[probe, shaders],
# a driver that could not run is not a defect in the scene; `probes.probe_report`
- # and `_probe_and_preflight` already mark it, and `build_with_repair` reads this
+ # and `probe_and_preflight` already mark it, and `build_with_repair` reads this
# so the round does not spend its repair budget rewriting working code
harness_failure=bool(first is not None and first.data.get("harness_failure")),
)
@@ -812,18 +811,20 @@ class SceneThreeJsRuntime:
return res
-def _probe_and_preflight(ws: Workspace, *, timeout_s: float) -> tuple[GateReport, GateReport, dict]:
- """One ``probe_scene.mjs --compile`` run → (scene_probe, shader_preflight, census).
+def probe_and_preflight(ws: Workspace, *, timeout_s: float | None = None) -> tuple[GateReport, GateReport, dict]:
+ """One ``probe_scene.mjs --compile`` run → (scene_probe, shader_preflight, census): the
+ build's two gates, and the ``shader_probe`` tool's verdict.
The driver boots the scene once and runs both stages on the same page;
when the scene never boots the preflight is skipped, matching the old
- two-call behaviour (a failed-empty shader gate).
+ two-call behaviour (a failed-empty shader gate). ``timeout_s`` defaults to
+ the build timeout, capped at 120 s.
"""
- from codeverse3d.contracts.artifacts import GateFinding
from codeverse3d.spatial.probes import PROBE_GATE, SHADER_GATE, probe_report, shader_report
from codeverse3d.spatial.render_scene import SceneRenderError, probe_env_args, run_scene_script
t0 = time.time()
+ timeout_s = min(float(timeout_s or get_settings().limits.build_timeout_s), 120.0)
args = [
"--ws", str(ws.root), "--compile",
"--out", str(ws.artifacts / "scene_probe.json"),
diff --git a/harness/codeverse3d/skills/c3d-threejs-shader-traps/references/shader-gate.md b/harness/codeverse3d/skills/c3d-threejs-shader-traps/references/shader-gate.md
index 012141d2..082d9f61 100644
--- a/harness/codeverse3d/skills/c3d-threejs-shader-traps/references/shader-gate.md
+++ b/harness/codeverse3d/skills/c3d-threejs-shader-traps/references/shader-gate.md
@@ -19,9 +19,9 @@ booted page -> window.__c3v.compileAll() -> shader_errors[] -> errors
-> GateReport(gate="shader_preflight")
```
-`passed` is `report.ok and no ERROR finding`. The agent-facing tool is `shader_probe`
-(`Compile every GLSL/ShaderMaterial in the scene headlessly and report shader errors with line
-numbers`); the same report is produced automatically on every `scene_threejs` build.
+`passed` is `report.ok and no ERROR finding`. The agent-facing tool is `shader_probe`; it runs
+the build's own probe and preflight (one `probe_scene.mjs --compile` boot), so its verdict is
+the build's, and every `scene_threejs` round carries the report among its gates.
A compile error carries `stage`, `material`, the offending `source_line`, surrounding
`context`, and a `fix_hint` derived from the driver message. When the same GLSL line appears in
diff --git a/harness/codeverse3d/spatial/probes.py b/harness/codeverse3d/spatial/probes.py
index e7ff1292..3461b327 100644
--- a/harness/codeverse3d/spatial/probes.py
+++ b/harness/codeverse3d/spatial/probes.py
@@ -1,9 +1,10 @@
-"""Scene probes: import/census gate and shader compile preflight.
+"""Scene probes: the import/census gate and the shader-preflight report reader.
-* ``probe_scene(ws)`` → (GateReport 'scene_probe', census) — the scene build gate
-* ``check_shaders(ws)`` → GateReport 'shader_preflight' (file:line + fix hints)
-
-Both drive the node host (``runtime_js/*.mjs``) via ``run_scene_script``.
+* ``probe_scene(ws)`` → (GateReport 'scene_probe', census) — the standalone probe
+ (the ``scene_probe`` tool, ``check_placement(rebuild=true)``)
+* ``probe_report`` / ``shader_report`` — the two gates, pure over the driver JSON; the
+ scene build (``languages.scene_threejs.probe_and_preflight``: one
+ ``probe_scene.mjs --compile`` boot) and the ``shader_probe`` tool read both through them.
"""
from __future__ import annotations
@@ -144,7 +145,7 @@ def probe_report(summary: dict[str, Any], *, duration_ms: int = 0) -> tuple[Gate
hint="compile the Blender asset to public/assets/<name>.glb (the scene renders without it until then)"))
for e in s.get("shader_errors", []):
findings.append(_f(gate, Severity.ERROR, f"shader {e.get('stage')}: {e.get('message')} at: {e.get('source_line', '')}",
- target=e.get("material") or "shader", hint="run check_shaders for file:line mapping"))
+ target=e.get("material") or "shader", hint="run shader_probe for the file:line mapping"))
if boot.get("raf_calls"):
findings.append(_f(gate, Severity.WARN, f"scene called requestAnimationFrame {boot['raf_calls']}x; animation must live in update(t, dt)",
target="src/scene.js", hint="delete your own render loop; the host drives update()"))
@@ -186,26 +187,10 @@ def _census_findings(c: dict[str, Any]) -> list[GateFinding]:
return out
-def check_shaders(ws: Workspace, *, timeout_s: float = 90.0) -> GateReport:
- """Static GLSL audits + GPU compile preflight with file:line mapped errors."""
- t0 = time.time()
- gate = SHADER_GATE
- out_json = ws.artifacts / "shader_preflight.json"
- args = ["--ws", str(ws.root), "--out", str(out_json), "--timeout-ms", str(int(timeout_s * 1000))]
- findings: list[GateFinding] = []
- try:
- res = run_scene_script("check_shaders.mjs", args, timeout_s=timeout_s + 20)
- except SceneRenderError as e:
- findings.append(_f(gate, Severity.ERROR, f"shader preflight could not run: {e}", target="src/scene.js",
- hint="harness/driver failure; retry or report", harness_failure=True))
- return GateReport(gate=gate, passed=False, findings=findings, duration_ms=int((time.time() - t0) * 1000))
- return shader_report(res.summary, duration_ms=int((time.time() - t0) * 1000))
-
-
def shader_report(report: dict[str, Any], *, duration_ms: int = 0) -> GateReport:
- """Interpret a shader-preflight report (``check_shaders.mjs`` summary, or the
- ``shader_report`` block of ``probe_scene.mjs --compile``) into the
- ``shader_preflight`` GateReport. Pure over the driver JSON."""
+ """Interpret a shader-preflight report (the ``shader_report`` block of
+ ``probe_scene.mjs --compile``) into the ``shader_preflight`` GateReport. Pure over
+ the driver JSON."""
gate = SHADER_GATE
findings: list[GateFinding] = []
rep = report
diff --git a/harness/codeverse3d/spatial/tools.py b/harness/codeverse3d/spatial/tools.py
index e719979a..5d360e49 100644
--- a/harness/codeverse3d/spatial/tools.py
+++ b/harness/codeverse3d/spatial/tools.py
@@ -40,7 +40,7 @@ from codeverse3d.spatial.observe import (
text_observation,
truncate,
)
-from codeverse3d.spatial.probes import check_shaders, probe_scene
+from codeverse3d.spatial.probes import probe_scene
from codeverse3d.spatial.registry import NoArgs, Observation, ToolContext, ToolUsageError, tool
from codeverse3d.spatial.render_scene import read_metrics, render_scene
from codeverse3d.spatial.scene_placement import placement_census as _placement_census
@@ -461,10 +461,23 @@ def joint_sweep(ctx: ToolContext, args: JointSweepArgs) -> Observation:
# ===================================================================== scenes
-@tool("shader_probe", NoArgs, "Compile every GLSL/ShaderMaterial in the scene headlessly and report shader errors with line numbers.",
+@tool("shader_probe", NoArgs, "Compile every GLSL/ShaderMaterial in the scene headlessly and report shader errors with "
+ "line numbers — the build's own probe + preflight, so the verdict is the build's.",
languages=(Language.SCENE_THREEJS.value,), cost_hint="slow")
def shader_probe(ctx: ToolContext, args: NoArgs) -> Observation:
- return gate_observation(check_shaders(ctx.workspace), title="shader probe")
+ """The build's own probe + shader preflight (``probe_and_preflight``: one ``probe_scene.mjs
+ --compile`` boot under the render policy). Until 2026-09-22 this ran a second driver,
+ check_shaders.mjs at 256x144 without the settle / camera-repair / exposure flags, whose
+ verdict could differ from the build's. A scene that never boots gets no preflight:
+ the probe's report says why."""
+ from codeverse3d.languages.scene_threejs import probe_and_preflight
+
+ probe, shaders, _census = probe_and_preflight(ctx.workspace)
+ died = [f.message for f in probe.findings if f.data.get("harness_failure")]
+ if died:
+ return Observation.error(f"shader_probe: {died[0]}")
+ ran = shaders.passed or bool(shaders.findings)
+ return gate_observation(shaders if ran else probe, title="shader probe")
@tool("scene_probe", NoArgs, "Load the scene headlessly: object/material/light census, triangle count, fps, console errors.",
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index 111bb665..30f4a656 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -265,7 +265,7 @@ eval/bench/ run_bench.py + report.py (the battery launcher, `pyth
concurrency_probe.py (in-flight knee sweep), complexity_report.py,
prompts/{static_objects_v1 (24), articulated_v1 (12), scenes_v1 (12), compare_v1 (8)}.yaml
runtime_js/ export_glb.mjs (placement policy, instance baking, selfcheck) render_glb.mjs
- render_scene.mjs probe_scene.mjs check_shaders.mjs gpu_launch.cjs serve.cjs
+ render_scene.mjs probe_scene.mjs check_shaders.mjs (the lib tests' compile driver) gpu_launch.cjs serve.cjs
lib/{resolve_three, scene_host, host_coverage, host_census, host_placement, orbit, instances,
census, glsl_audit, browser/…}
browser/post.js — scene post chain: GTAO + SELECTIVE bloom (an emissive
diff --git a/harness/docs/INTERFACES.md b/harness/docs/INTERFACES.md
index f6fe617d..1214cc37 100644
--- a/harness/docs/INTERFACES.md
+++ b/harness/docs/INTERFACES.md
@@ -234,7 +234,7 @@ BuildResult.error_type spellings (languages/_common.py): MISSING_ENTRY = "Missin
| `CadQueryRuntime` | `src/model.py` | trailing selector on the stack → parent solid exported + warning (ExportError when no solid exists); helper-module errors map to `src/<file>.py:line`; object.glb/stl/step |
| `ThreeJsRuntime` | `src/object.js`, `src/parts/*.js` | **Δ export as authored** (census `placement_offset`); InstancedMesh baked to `<Name>_<i>` meshes (`instanced_meshes_baked`); exported `selfcheck(THREE, root)` is called (throw → SelfCheckError); NaN geometry errors name mesh/part → routed to `src/parts/<snake>.js` |
| `UrdfBlenderRuntime` | `src/model.py`, `src/robot.urdf` | object.glb (Y-up, node=link, joint extras), meshes/<link>.glb (raw Z-up link frames); link name `world` is reserved (lint ERROR + UrdfError); robot GLB root gets `__root` suffix on name clash |
-| `SceneThreeJsRuntime` | `src/scene.js`, `src/zones/*.js`, `src/assets/*.js`, `src/env.js`, `src/shaders/*.js` | glb_path=None; ok iff the probe and the shader preflight (one `probe_scene.mjs --compile` boot) both pass; both reports ride `BuildResult.gates` |
+| `SceneThreeJsRuntime` | `src/scene.js`, `src/zones/*.js`, `src/assets/*.js`, `src/env.js`, `src/shaders/*.js` | glb_path=None; ok iff `probe_and_preflight(ws, *, timeout_s=None) -> (scene_probe, shader_preflight, census)` (one `probe_scene.mjs --compile` boot) passes both; both reports ride `BuildResult.gates`, and the `shader_probe` tool reports the same call |
| `GlslShaderRuntime` | `src/shader.frag`, `src/common.glsl`, `src/buffer_a.frag` (+ the harness-owned `src/recipes.glsl` when seeded) | harness owns `#version`/uniforms/`out` (wrap.HEADER: u_time/u_resolution/u_mouse/u_frame/u_prev/u_noise + iTime/iChannel* aliases); `wrap.compose(shader, common, recipes_src=…)` pastes header < recipes < common < shader; build renders judge frames via GlHost; compile errors → GlslCompileError at mapped src file:line (recipes.glsl included); lint ERROR `redefines_recipe` when an agent file defines a recipes.glsl name; artifacts frames/, frames_sheet.png, preview.gif, metrics.json |
| `OpenGLPythonRuntime` | `src/program.py`, `src/*.glsl` | `setup(ctx,w,h)->state` + `render(ctx,state,t,frame,fbo)` run in a moderngl subprocess (`wrappers/run_gl.py`); exceptions map to src/program.py:line, in-string GLSL errors carry both line numbers |
@@ -249,7 +249,7 @@ once through `_common.compose_build_result` and replaces with the final `BuildRe
EVERY runtime `artifacts/build.json` is the BuildResult (urdf_blender after its post-wrapper
checks). `opengl_python/wrappers/run_gl.py` is the moderngl runner; threejs/scene
export+render live in `runtime_js/` (`export_glb.mjs`, `render_glb.mjs`,
-`render_scene.mjs`, `probe_scene.mjs`, `check_shaders.mjs`, `lib/instances.mjs`).
+`render_scene.mjs`, `probe_scene.mjs`, `lib/instances.mjs`; `check_shaders.mjs` is the effect-library tests' compile driver).
**Placement policy (all languages)**: nothing re-centres or drops to ground at
export; the build warns and the contract/connectivity gates report it.
**Δ Node ESM resolution**: bare `import 'three'` needs
diff --git a/harness/runtime_js/README.md b/harness/runtime_js/README.md
index 4f524812..15362070 100644
--- a/harness/runtime_js/README.md
+++ b/harness/runtime_js/README.md
@@ -91,7 +91,8 @@ lib/browser/*.js page-side ESM (served through /__runtime/): renderer.js (T
probe_scene.mjs scene build gate: boot src/scene.js, census, update(t,dt), first-camera checks;
--compile folds the full shader preflight into the SAME boot (shader_report);
--sun-azimuth returns harness-fitted overview + per-group camera specs (lib/orbit.mjs)
-check_shaders.mjs standalone shader preflight (static GLSL audits + GPU compile, file:line mapped)
+check_shaders.mjs the effect-library tests' compile driver: the same preflight as probe_scene --compile,
+ plus --module to scope the static audit to one fixture file
render_scene.mjs authored cameras + orbit rig renders at times, metrics.json/views.json
lib/host_env.mjs ESM adapters over gpu_launch.cjs + serve.cjs (launchBrowser, serveWorkspace)
lib/host_page.mjs node-side page driver: serve ws, launch, boot scene, collect errors, releaseBrowser
diff --git a/harness/runtime_js/check_shaders.mjs b/harness/runtime_js/check_shaders.mjs
index c9814d76..b238aa56 100644
--- a/harness/runtime_js/check_shaders.mjs
+++ b/harness/runtime_js/check_shaders.mjs
@@ -1,7 +1,10 @@
#!/usr/bin/env node
/**
- * Shader compile preflight for a scene_threejs workspace (standalone tool;
- * the scene build runs the same stages through `probe_scene.mjs --compile`).
+ * Shader compile preflight for a scene_threejs workspace — the effect-library
+ * tests' compile driver (tests/scene_runtime/lib/_probe.py). The scene build and
+ * the `shader_probe` tool run the same two stages through `probe_scene.mjs
+ * --compile`; this driver exists for `--module`, which scopes the static audit to
+ * one fixture file.
*
* node check_shaders.mjs --ws <ws> [--module src/shaders/x.js] [--gpu auto] [--out report.json]
*
diff --git a/harness/runtime_js/lib/glsl_audit.mjs b/harness/runtime_js/lib/glsl_audit.mjs
index 4168fa95..45afc858 100644
--- a/harness/runtime_js/lib/glsl_audit.mjs
+++ b/harness/runtime_js/lib/glsl_audit.mjs
@@ -135,5 +135,5 @@ export function fixHintFor(message) {
if (/redefinition|already defined|redeclaration/i.test(m)) return 'you declared something three.js already injects (position, uv, normal, projectionMatrix, modelViewMatrix, cameraPosition, or a chunk varying); delete your declaration';
if (/l-value|constant expression/i.test(m)) return 'assigning to a read-only/attribute; copy it to a local first';
if (/gl_FragColor/i.test(m)) return 'with glslVersion GLSL3 write to your own `out vec4`; otherwise drop glslVersion';
- return 'fix the quoted GLSL line; run check_shaders again';
+ return 'fix the quoted GLSL line; run shader_probe again';
}
diff --git a/harness/runtime_js/lib/shader_report.mjs b/harness/runtime_js/lib/shader_report.mjs
index 6eb0d5d5..9c4bfb1c 100644
--- a/harness/runtime_js/lib/shader_report.mjs
+++ b/harness/runtime_js/lib/shader_report.mjs
@@ -1,7 +1,8 @@
/**
- * Shader preflight report builder, shared by the standalone tool
- * (`check_shaders.mjs`) and the combined build probe (`probe_scene.mjs
- * --compile`). Two node-side stages over one report shape:
+ * Shader preflight report builder, shared by the build probe (`probe_scene.mjs
+ * --compile` — the scene build's gate and the `shader_probe` tool's verdict) and
+ * the effect-library tests' compile driver (`check_shaders.mjs`). Two node-side
+ * stages over one report shape:
*
* staticShaderReport(ws, module) — walk src/**, run the static GLSL audits
* compileIntoReport(report, ...) — on an already-booted host page, force-
@@ -79,7 +80,7 @@ export async function compileIntoReport(report, files, host) {
const { page, boot } = host;
const { errors, warnings } = report;
if (!boot.ok) {
- errors.push({ file: 'src/scene.js', line: null, kind: 'boot', message: `scene did not boot at stage '${boot.stage}': ${boot.error}`.slice(0, 1200), fix_hint: 'fix the import/runtime error first; then re-run check_shaders' });
+ errors.push({ file: 'src/scene.js', line: null, kind: 'boot', message: `scene did not boot at stage '${boot.stage}': ${boot.error}`.slice(0, 1200), fix_hint: 'fix the import/runtime error first; then compile again' });
} else {
const comp = await page.evaluate((spec) => window.__c3v.compileAll(spec || undefined), null);
const shaderErrors = comp.shader_errors.map(({ _key, ...e }) => e);
diff --git a/harness/tests/scene_runtime/test_probes.py b/harness/tests/scene_runtime/test_probes.py
index 5015c612..e72ee925 100644
--- a/harness/tests/scene_runtime/test_probes.py
+++ b/harness/tests/scene_runtime/test_probes.py
@@ -5,7 +5,8 @@ from __future__ import annotations
import pytest
from codeverse3d.contracts.artifacts import Severity
-from codeverse3d.spatial.probes import check_shaders, probe_scene
+from codeverse3d.languages.scene_threejs import probe_and_preflight
+from codeverse3d.spatial.probes import probe_scene
from tests.scene_runtime.conftest import needs_browser
pytestmark = [pytest.mark.node, needs_browser]
@@ -57,11 +58,17 @@ def test_probe_scene_catches_update_throw_and_console_errors(starter_ws):
assert "update boom" in msgs and "custom failure 42" in msgs
-def test_check_shaders_runs_raw_like_the_build_probe(ws, tmp_path, monkeypatch):
- """The shader_probe tool booted with the post chain ON (openHost's default) while the
+def preflight(ws):
+ """The shader_preflight report the build and the ``shader_probe`` tool both read."""
+ return probe_and_preflight(ws)[1]
+
+
+def test_the_shader_preflight_runs_raw(ws, tmp_path, monkeypatch):
+ """The shader_probe tool once booted with the post chain ON (openHost's default) while the
build's probe_scene --compile runs raw, so it compiled — and counted, and would have
blamed on the scene — the harness's own GTAO / bloom / grade programs. Only the chain
- reads `scene.userData.grade`, so a read of it means the chain was built."""
+ reads `scene.userData.grade`, so a read of it means the chain was built. The tool now
+ reports the build's own probe + preflight, which must stay raw."""
from codeverse3d.spatial.render_scene import render_scene
ws.src.mkdir(parents=True, exist_ok=True)
@@ -72,7 +79,7 @@ def test_check_shaders_runs_raw_like_the_build_probe(ws, tmp_path, monkeypatch):
" Object.defineProperty(scene.userData, 'grade', { get() { console.error('post chain built'); return undefined; } });\n"
" return { scene, cameras: [{ name: 'x', position: [3, 3, 3], lookAt: [0, 0, 0], fov: 50 }], update() {} }; }\n"
)
- rep = check_shaders(ws)
+ rep = preflight(ws)
assert rep.passed and not [f for f in rep.findings if "post chain built" in f.message], [f.message for f in rep.findings]
# control: a scene render DOES build the chain, and the read shows up
monkeypatch.delenv("C3D_POST", raising=False)
@@ -80,14 +87,14 @@ def test_check_shaders_runs_raw_like_the_build_probe(ws, tmp_path, monkeypatch):
assert any("post chain built" in e for e in rs.console_errors), rs.console_errors
-def test_check_shaders_clean_on_example(starter_ws):
- rep = check_shaders(starter_ws)
+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_check_shaders_maps_compile_error_to_file_line(starter_ws):
+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);"
@@ -95,7 +102,7 @@ def test_check_shaders_maps_compile_error_to_file_line(starter_ws):
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 = check_shaders(starter_ws)
+ rep = preflight(starter_ws)
assert not rep.passed
err = rep.errors[0]
assert err.target == f"src/shaders/water.js:{line}", err
@@ -104,7 +111,7 @@ def test_check_shaders_maps_compile_error_to_file_line(starter_ws):
assert err.fix_hint
-def test_check_shaders_on_before_compile_patch_error(starter_ws):
+def test_preflight_on_before_compile_patch_error(starter_ws):
(starter_ws.src / "shaders" / "glow.js").write_text(
"import * as THREE from 'three';\n"
"export function makeGlow(T = THREE) {\n"
@@ -126,18 +133,18 @@ def test_check_shaders_on_before_compile_patch_error(starter_ws):
)
assert "makeGlow(THREE)" in text
p.write_text(text)
- rep = check_shaders(starter_ws)
+ 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_check_shaders_static_audit_without_compile(starter_ws):
+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 = check_shaders(starter_ws)
+ rep = preflight(starter_ws)
kinds = {f.data.get("kind") for f in rep.errors}
assert {"version_directive", "undeclared_uniform", "unbound_uniform"} <= kinds
assert any(f.target == "src/shaders/bad.js:2" for f in rep.errors)
@@ -190,5 +197,8 @@ def test_probe_result_tool_semantics(starter_ws, monkeypatch):
assert not res2.gate.passed and not res2.ok
assert res2.errors and "could not run" in res2.errors[0]
assert res2.gate.errors[0].data.get("harness_failure") is True
- rep = probes_mod.check_shaders(starter_ws)
- assert not rep.passed and rep.errors[0].data.get("harness_failure") is True
+ import codeverse3d.spatial.render_scene as rs_mod
+
+ monkeypatch.setattr(rs_mod, "run_scene_script", fake_run_crash) # the build's probe + preflight
+ probe, shaders, _ = probe_and_preflight(starter_ws)
+ assert probe.errors[0].data.get("harness_failure") is True and not shaders.passed and not shaders.findings
diff --git a/harness/tests/scene_runtime/test_render_scene.py b/harness/tests/scene_runtime/test_render_scene.py
index f7bb260e..8a37bdd4 100644
--- a/harness/tests/scene_runtime/test_render_scene.py
+++ b/harness/tests/scene_runtime/test_render_scene.py
@@ -311,7 +311,7 @@ def test_every_driver_invocation_carries_the_env_flags(monkeypatch, ws, tmp_path
# 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)
+ 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)],
@@ -321,7 +321,7 @@ def test_every_driver_invocation_carries_the_env_flags(monkeypatch, ws, tmp_path
# the A/B words reach every path, including the combined build
monkeypatch.setenv("C3D_SETTLE", "0")
monkeypatch.setenv("C3D_CAMERA_REPAIR", "false")
- st._probe_and_preflight(ws, timeout_s=5.0)
+ 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"]
diff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.py
index fce9bc90..3e7b4ccc 100644
--- a/harness/tests/spatial_tools/test_tools.py
+++ b/harness/tests/spatial_tools/test_tools.py
@@ -324,23 +324,38 @@ def test_render_sheet_and_isolate(stool_ctx: ToolContext, fake_renderer) -> None
def test_scene_tools_with_fake_siblings(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:
+ import codeverse3d.languages.scene_threejs as st
import codeverse3d.spatial.tools as ts
from codeverse3d.spatial.probes import SceneProbeResult
- def fake_check_shaders(ws, *, module=None, timeout_s=90.0):
- return GateReport(gate="shaders", passed=False, findings=[GateFinding(gate="shaders", severity=Severity.ERROR, target="src/shaders/water.js", message="ERROR: 0:12: 'vUv' undeclared", fix_hint="declare varying vec2 vUv")])
-
+ shaders = GateReport.of("shader_preflight", [GateFinding(
+ gate="shader_preflight", severity=Severity.ERROR, target="src/shaders/water.js:12",
+ message="ERROR: 0:12: 'vUv' undeclared", fix_hint="declare varying vec2 vUv")])
failed = GateReport(gate="scene_probe", passed=False, findings=[
GateFinding(gate="scene_probe", severity=Severity.ERROR, target="src/scene.js", message="console: boom")])
def fake_probe_scene(ws, **kw):
return SceneProbeResult(gate=failed, census={"meshes": 12, "lights": 2}, ok=True, findings=["[error] src/scene.js: console: boom"])
- monkeypatch.setattr(ts, "check_shaders", fake_check_shaders)
+ # shader_probe reports the BUILD's probe + preflight (one boot), never a driver of its own
+ monkeypatch.setattr(st, "probe_and_preflight", lambda ws, **kw: (GateReport.of("scene_probe"), shaders, {}))
monkeypatch.setattr(ts, "probe_scene", fake_probe_scene)
obs = get_tool("shader_probe").call(stool_ctx, {})
assert not obs.ok and not obs.failed and "vUv" in obs.text and "declare varying" in obs.text
assert obs.text.startswith("shader probe: FAIL") # a shader that will not compile is a verdict
+ # a scene that never booted has no preflight: the probe's report says why
+ skipped = GateReport(gate="shader_preflight", passed=False)
+ boot = GateReport.of("scene_probe", [GateFinding(gate="scene_probe", severity=Severity.ERROR, target="src/scene.js",
+ message="[import] SyntaxError: Unexpected token")])
+ monkeypatch.setattr(st, "probe_and_preflight", lambda ws, **kw: (boot, skipped, {}))
+ obs = get_tool("shader_probe").call(stool_ctx, {})
+ assert not obs.ok and not obs.failed and "SyntaxError" in obs.text
+ # the driver died: the tool could not run
+ died = GateReport.of("scene_probe", [GateFinding(gate="scene_probe", severity=Severity.ERROR, target="src/scene.js",
+ message="scene probe could not run: timeout", data={"harness_failure": True})])
+ monkeypatch.setattr(st, "probe_and_preflight", lambda ws, **kw: (died, skipped, {}))
+ obs = get_tool("shader_probe").call(stool_ctx, {})
+ assert obs.failed and "could not run" in obs.text
obs = get_tool("scene_probe").call(stool_ctx, {})
# ok = the gate verdict; failed = the probe TOOL could not run. The gate fails on
# agent-fixable findings here, so the observation is a FAIL, not a tool error