Skip to content

Official Codebase of 3DCodeVerse

Python

scene_stats: count a dead browser apart from a defect

ziyaod7723e121962
diff --git a/harness/bench/scene_stats.py b/harness/bench/scene_stats.py
index da0188e4..1e389226 100644
--- a/harness/bench/scene_stats.py
+++ b/harness/bench/scene_stats.py
@@ -20,9 +20,14 @@ from __future__ import annotations
import argparse
import json
import statistics
+import sys
from collections import Counter
from pathlib import Path
+sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) # this tree's codeverse, not the editable install
+
+from codeverse.spatial.node import browser_was_lost # noqa: E402
+
#: pipeline stages in the order the scene track runs them
STAGES = ("plan", "skeleton", "assets", "env", "layouts", "assemble", "generate", "build")
@@ -89,14 +94,26 @@ def layers(rows: list[tuple[str, dict, list[dict]]]) -> dict:
for a in (rec.get("plan") or {}).get("assets") or []:
asset_kind[str(a.get("kind"))] += 1
for rnd in rec.get("rounds") or []:
+ round_lost = False
for g in rnd.get("gates") or []:
name = g.get("gate", "?")
gates[name] += 1
+ errors = [f for f in (g.get("findings") or []) if f.get("severity") == "error"]
+ # A finding that names a browser which died under the driver measures the
+ # BOX, not the scene (`node.BROWSER_LOST_MARKERS`). Counting it as a gate
+ # failure makes every battery run on a loaded machine look like a defective
+ # generator: on scene_baseline (2026-09-05) three of six cells kept zero
+ # renders and lost their judge that way. Reported, never mixed in.
+ lost = [f for f in errors if browser_was_lost(f.get("message", ""))]
+ real = [f for f in errors if f not in lost]
+ gate_errors[name] += len(real)
+ if lost:
+ gates[f"{name}:LOST"] += len(lost)
+ round_lost = True
if not g.get("passed"):
- gates[f"{name}:FAILED"] += 1
- for f in g.get("findings") or []:
- if f.get("severity") == "error":
- gate_errors[name] += 1
+ gates[f"{name}:FAILED" if real or not lost else f"{name}:BOX"] += 1
+ if round_lost:
+ gates["rounds_lost_to_the_box"] += 1
j = rnd.get("judgment") or {}
if j.get("score") is not None:
scores.append(float(j["score"]))
@@ -126,9 +143,15 @@ def report(root: Path) -> str:
if d["placements"]:
out.append(f"\n## layout\n placements per zone: median {statistics.median(d['placements']):.0f}, "
f"zones {len(d['placements'])}")
- out += ["", "## gates", "| gate | ran | failed | ERROR findings |", "|---|--:|--:|--:|"]
- for name in sorted(n for n in d["gates"] if not n.endswith(":FAILED")):
- out.append(f"| {name} | {d['gates'][name]} | {d['gates'][f'{name}:FAILED']} | {d['gate_errors'][name]} |")
+ out += ["", "## gates", "| gate | ran | failed | ERROR findings | lost to the box |", "|---|--:|--:|--:|--:|"]
+ skip = (":FAILED", ":LOST", ":BOX")
+ for name in sorted(n for n in d["gates"] if not n.endswith(skip) and n != "rounds_lost_to_the_box"):
+ out.append(f"| {name} | {d['gates'][name]} | {d['gates'][f'{name}:FAILED']} | "
+ f"{d['gate_errors'][name]} | {d['gates'][f'{name}:LOST']} |")
+ lost_rounds = d["gates"]["rounds_lost_to_the_box"]
+ if lost_rounds:
+ out.append(f"\n {lost_rounds} round(s) lost their browser mid-render: those findings are the "
+ f"machine, not the scene, and are counted in the last column only.")
if d["judge"]:
out += ["", "## judge issues (severity/kind)"]
out += [f" {n:3}x {k}" for k, n in d["judge"].most_common(12)]
diff --git a/harness/tests/compare_bench/test_scene_stats.py b/harness/tests/compare_bench/test_scene_stats.py
new file mode 100644
index 00000000..316a10e1
--- /dev/null
+++ b/harness/tests/compare_bench/test_scene_stats.py
@@ -0,0 +1,67 @@
+"""``bench/scene_stats.py``: a gate finding that names a dead browser is the machine.
+
+Measured on `bench/out/scene_baseline` (2026-09-05): three of six scene cells built,
+passed every gate that does not need pixels, and then kept ZERO renders because Chrome
+reaped the tab under a box at load 93 with swap full. Each one left a `render_console`
+ERROR reading "driver: Attempted to use detached Frame '<id>'". Counted as a gate
+failure, that reads as a defective generator; the layer attribution the scene battery
+exists to produce is then wrong for half its cells.
+"""
+
+from __future__ import annotations
+
+import json
+from pathlib import Path
+
+from bench.scene_stats import layers, runs
+
+DETACHED = "driver: Attempted to use detached Frame '10276B428E350BFA074A02AF37D52E6C'."
+
+
+def _run(root: Path, name: str, gates: list[dict]) -> None:
+ d = root / name / "run"
+ d.mkdir(parents=True, exist_ok=True)
+ (d / "record.json").write_text(json.dumps({
+ "spec": {"track": "scene", "id": name},
+ "plan": {"assets": []},
+ "rounds": [{"index": 0, "gates": gates, "judgment": {}}],
+ }))
+
+
+def _gate(name: str, passed: bool, messages: list[str]) -> dict:
+ return {"gate": name, "passed": passed,
+ "findings": [{"severity": "error", "message": m} for m in messages]}
+
+
+def test_a_dead_browser_is_counted_apart_from_a_defect(tmp_path: Path) -> None:
+ _run(tmp_path, "lost", [
+ _gate("render_console", False, [DETACHED]),
+ _gate("scene_placement", False, ["Crate is sunken 0.9 m into Wall"]),
+ ])
+ d = layers(runs(tmp_path))
+ g = d["gates"]
+ # the browser loss lands in its own column and does NOT inflate the gate's failures
+ assert g["render_console:LOST"] == 1
+ assert g["render_console:FAILED"] == 0
+ assert d["gate_errors"]["render_console"] == 0
+ # the real defect in the same round is untouched
+ assert g["scene_placement:FAILED"] == 1 and d["gate_errors"]["scene_placement"] == 1
+ assert g["rounds_lost_to_the_box"] == 1
+
+
+def test_a_round_that_kept_its_browser_reports_no_loss(tmp_path: Path) -> None:
+ _run(tmp_path, "clean", [_gate("render_console", True, []),
+ _gate("scene_frames", False, ["frame too dark: mean luminance 0.13"])])
+ d = layers(runs(tmp_path))
+ assert d["gates"]["rounds_lost_to_the_box"] == 0
+ assert d["gates"]["scene_frames:FAILED"] == 1 and d["gate_errors"]["scene_frames"] == 1
+
+
+def test_a_gate_that_failed_ONLY_on_the_browser_is_not_a_failure(tmp_path: Path) -> None:
+ """`scene_frames` fails when it has no frames to look at. With the renders lost
+ that is the same event reported twice, not a second defect."""
+ _run(tmp_path, "both", [_gate("render_console", False, [DETACHED]),
+ _gate("scene_frames", False, ["render produced no result: " + DETACHED])])
+ d = layers(runs(tmp_path))
+ assert d["gates"]["scene_frames:FAILED"] == 0 and d["gates"]["scene_frames:LOST"] == 1
+ assert sum(d["gate_errors"].values()) == 0