Skip to content

Official Codebase of 3DCodeVerse

Python

gates: every report whose verdict is its findings is built with GateReport.of — the passed-iff-no-ERROR rule is stated once

gaoypengfc13e1d871df
diff --git a/harness/codeverse3d/languages/blender/__init__.py b/harness/codeverse3d/languages/blender/__init__.py
index bffc0f17..1e8ad237 100644
--- a/harness/codeverse3d/languages/blender/__init__.py
+++ b/harness/codeverse3d/languages/blender/__init__.py
@@ -283,7 +283,7 @@ def lint_blender_source(
if tree is None:
msg, hint, line = describe_parse_failure(exc) # type: ignore[arg-type]
findings.append(_f(Severity.ERROR, msg, line, hint, target))
- return GateReport(gate=GATE, passed=False, findings=findings, duration_ms=int((time.monotonic() - t0) * 1000))
+ return GateReport.of(GATE, findings, duration_ms=int((time.monotonic() - t0) * 1000))
c = _Collector()
c.visit(tree)
findings = _rules(c, source, target=target, expect_names=expect_names, expect_bpy=expect_bpy)
@@ -382,9 +382,9 @@ def _layout_rules(ws: Workspace, parts: list[Path], entry_tree: ast.Module | Non
def lint_workspace(ws: Workspace) -> GateReport:
"""Lint every python file under ``src/`` + the multi-file layout rules (one merged report)."""
t0 = time.monotonic()
- entry = ws.src / "model.py"
+ entry = ws.root / ENTRY_REL
if not entry.is_file():
- return GateReport(gate=GATE, passed=False, duration_ms=0, findings=[_f(
+ return GateReport.of(GATE, [_f(
Severity.ERROR, f"{ENTRY_REL} is missing", target=ENTRY_REL,
hint="create src/model.py (entry: imports src/parts/<snake>.py builders and calls them; see the skeleton)")])
parts = part_files(ws)
diff --git a/harness/codeverse3d/languages/cadquery/__init__.py b/harness/codeverse3d/languages/cadquery/__init__.py
index 4e62cfc5..5e4ecbcf 100644
--- a/harness/codeverse3d/languages/cadquery/__init__.py
+++ b/harness/codeverse3d/languages/cadquery/__init__.py
@@ -196,7 +196,7 @@ def lint_cadquery_source(source: str, *, target: str = "src/model.py") -> GateRe
if tree is None:
msg, hint, line = describe_parse_failure(exc) # type: ignore[arg-type]
f = _f(Severity.ERROR, msg, line, hint, target)
- return GateReport(gate=GATE, passed=False, findings=[f], duration_ms=int((time.monotonic() - t0) * 1000))
+ return GateReport.of(GATE, [f], duration_ms=int((time.monotonic() - t0) * 1000))
c = _Collector()
c.visit(tree)
findings = _rules(c, tree, source)
@@ -207,7 +207,7 @@ def lint_cadquery_source(source: str, *, target: str = "src/model.py") -> GateRe
def lint_cadquery_file(path: Path, *, target: str = "src/model.py") -> GateReport:
if not path.is_file():
- return GateReport(gate=GATE, passed=False, findings=[_f(Severity.ERROR, f"{target} is missing", None, "create src/model.py (see the skeleton)", target)])
+ return GateReport.of(GATE, [_f(Severity.ERROR, f"{target} is missing", None, "create src/model.py (see the skeleton)", target)])
return lint_cadquery_source(path.read_text(), target=target)
diff --git a/harness/codeverse3d/languages/opengl_python/__init__.py b/harness/codeverse3d/languages/opengl_python/__init__.py
index 8d41e381..b0eb2805 100644
--- a/harness/codeverse3d/languages/opengl_python/__init__.py
+++ b/harness/codeverse3d/languages/opengl_python/__init__.py
@@ -169,7 +169,7 @@ def lint_workspace(ws: Workspace) -> GateReport:
if not p.is_file():
f = [_finding(Severity.ERROR, "missing_entry", f"{PROGRAM} is missing",
"create src/program.py with setup(ctx, width, height) and render(ctx, state, t, frame, fbo)")]
- return GateReport(gate=GATE, passed=False, findings=f)
+ return GateReport.of(GATE, f)
findings = lint_source(p.read_text(errors="replace"))
for extra in sorted(ws.src.rglob("*.py")):
rel = ws_rel(ws, extra)
diff --git a/harness/codeverse3d/spatial/connectivity.py b/harness/codeverse3d/spatial/connectivity.py
index 872d0369..4502e7a0 100644
--- a/harness/codeverse3d/spatial/connectivity.py
+++ b/harness/codeverse3d/spatial/connectivity.py
@@ -490,11 +490,11 @@ def check_connectivity(
parts = solid_parts(glb)
except GlbLoadError as e:
findings.append(GateFinding(gate=GATE, severity=Severity.ERROR, message=str(e), fix_hint="run `build` first"))
- return GateReport(gate=GATE, passed=False, findings=findings, duration_ms=int((time.time() - t0) * 1000))
+ return GateReport.of(GATE, findings, duration_ms=int((time.time() - t0) * 1000))
if not parts:
findings.append(GateFinding(gate=GATE, severity=Severity.ERROR, message="GLB has no mesh parts",
fix_hint="the build exported nothing — check the code creates geometry"))
- return GateReport(gate=GATE, passed=False, findings=findings, duration_ms=int((time.time() - t0) * 1000))
+ return GateReport.of(GATE, findings, duration_ms=int((time.time() - t0) * 1000))
names = list(parts)
sizes = {n: float(np.max(parts[n].extents)) for n in names}
diff --git a/harness/codeverse3d/spatial/frame_metrics.py b/harness/codeverse3d/spatial/frame_metrics.py
index ff9b69e8..ca5b46ca 100644
--- a/harness/codeverse3d/spatial/frame_metrics.py
+++ b/harness/codeverse3d/spatial/frame_metrics.py
@@ -438,7 +438,7 @@ def frame_gate_from_renders(source: RenderSet | Path | str) -> GateReport:
path = p if p.is_file() else (p / "metrics.json" if (p / "metrics.json").is_file() else None)
metrics = read_json_or_none(path) if path is not None else None
if metrics is None:
- return GateReport(gate=FRAME_GATE, passed=True, findings=[])
+ return GateReport.of(FRAME_GATE)
return frame_findings(metrics)
diff --git a/harness/codeverse3d/spatial/frame_stats.py b/harness/codeverse3d/spatial/frame_stats.py
index fb518d23..4d7fd0ef 100644
--- a/harness/codeverse3d/spatial/frame_stats.py
+++ b/harness/codeverse3d/spatial/frame_stats.py
@@ -152,7 +152,7 @@ def frame_gate(seq: SequenceStats, *, motion_expected: bool = True, gate: str =
if not seq.frames:
add(Severity.ERROR, "no_frames", "no frames were rendered", "the program must produce at least one frame")
- return GateReport(gate=gate, passed=False, findings=f)
+ return GateReport.of(gate, f)
if seq.any_nan:
bad = [fr for fr in seq.frames if fr.nan or fr.inf]
add(Severity.ERROR, "nan", f"NaN/Inf pixels in {len(bad)} frame(s) (first at t={bad[0].time:g}s: nan={bad[0].nan} inf={bad[0].inf})",
diff --git a/harness/codeverse3d/spatial/probes.py b/harness/codeverse3d/spatial/probes.py
index d95afef0..f5002418 100644
--- a/harness/codeverse3d/spatial/probes.py
+++ b/harness/codeverse3d/spatial/probes.py
@@ -92,7 +92,7 @@ def run_probe(ws: Workspace, *, compile: bool = False, timeout_s: float | None =
except SceneRenderError as e:
finding = _f(PROBE_GATE, Severity.ERROR, f"scene probe could not run: {e}"[:1500], target="src/scene.js",
hint="this is a harness/driver failure, not your code; retry or report", harness_failure=True)
- return GateReport(gate=PROBE_GATE, passed=False, findings=[finding], duration_ms=int((time.time() - t0) * 1000)), no_preflight, {}
+ return GateReport.of(PROBE_GATE, [finding], duration_ms=int((time.time() - t0) * 1000)), no_preflight, {}
probe, census = probe_report(res.summary, duration_ms=int((time.time() - t0) * 1000))
rep = res.summary.get("shader_report") or {}
if not compile or not rep or rep.get("skipped"):
@@ -130,7 +130,7 @@ def probe_report(summary: dict[str, Any], *, duration_ms: int = 0) -> tuple[Gate
target="src/scene.js",
hint="this is a harness/driver failure, not your code; retry or report",
harness_failure=True))
- return GateReport(gate=gate, passed=False, findings=findings, duration_ms=duration_ms), {}
+ return GateReport.of(gate, findings, duration_ms=duration_ms), {}
if not boot.get("ok"):
stage = boot.get("stage", "?")
msg = boot.get("error") or "scene did not boot"
diff --git a/harness/codeverse3d/spatial/scene_placement.py b/harness/codeverse3d/spatial/scene_placement.py
index 2db1bbe0..c43f7fd6 100644
--- a/harness/codeverse3d/spatial/scene_placement.py
+++ b/harness/codeverse3d/spatial/scene_placement.py
@@ -273,7 +273,7 @@ def placement_findings(table: dict[str, Any] | PlacementTable, *, indoor: bool =
"""The ``scene_placement`` GateReport for one census placement table (pure)."""
t = table if isinstance(table, PlacementTable) else PlacementTable.model_validate(table or {})
if t.error:
- return GateReport(gate=GATE, passed=True, findings=[
+ return GateReport.of(GATE, [
_f(Severity.WARN, f"placement probe failed: {t.error[:300]}", target="scene", kind="probe_failed",
hint="harness instrumentation, not your code; the placement check was skipped this round")])
floating_m = FLOATING_INDOOR_M if indoor else FLOATING_OUTDOOR_M
@@ -639,7 +639,7 @@ def placement_gate_safe(census: dict[str, Any] | None, *, plan: Any = None,
return report
except Exception as e: # noqa: BLE001 — advisory instrumentation must not fail the round
log.warning("scene placement gate failed: %s", e)
- return GateReport(gate=GATE, passed=True, findings=[
+ return GateReport.of(GATE, [
_f(Severity.WARN, f"placement probe failed: {type(e).__name__}: {e}"[:400], target="scene", kind="probe_failed")])
diff --git a/harness/codeverse3d/tracks/articulated_object.py b/harness/codeverse3d/tracks/articulated_object.py
index a7675b1f..6fa01c55 100644
--- a/harness/codeverse3d/tracks/articulated_object.py
+++ b/harness/codeverse3d/tracks/articulated_object.py
@@ -355,7 +355,7 @@ def default_motion_checks(ws: Workspace, plan: Plan | None) -> GateReport | None
try:
robot = load_urdf(urdf, ws.artifacts / "meshes")
except UrdfError as e:
- return GateReport(gate=MOTION_GATE, passed=True, findings=[GateFinding(
+ return GateReport.of(MOTION_GATE, [GateFinding(
gate=MOTION_GATE, severity=Severity.WARN, target="robot.urdf", message=f"motion checks skipped: {e}")])
urdf_names = {to_snake(n): n for n in getattr(robot, "joints", {})}
for j, expected in wanted:
diff --git a/harness/codeverse3d/tracks/static_object.py b/harness/codeverse3d/tracks/static_object.py
index dcf3c3f6..8a0a78cf 100644
--- a/harness/codeverse3d/tracks/static_object.py
+++ b/harness/codeverse3d/tracks/static_object.py
@@ -317,7 +317,7 @@ def silhouette_gate(ctx: RunContext, renders: RenderSet) -> GateReport | None:
res = ctx.services.silhouette(view.path, ref)
except Exception as e: # noqa: BLE001 — advisory measurement; never fails a round
log.warning("compare_silhouette failed: %s", e)
- return GateReport(gate=SILHOUETTE_GATE, passed=True, findings=[GateFinding(
+ return GateReport.of(SILHOUETTE_GATE, [GateFinding(
gate=SILHOUETTE_GATE, severity=Severity.INFO, target="overall", message=f"silhouette comparison unavailable: {e}")])
iou = float(res.get("iou", 0.0)) if isinstance(res, dict) else 0.0
reliable = bool(res.get("reliable", True)) if isinstance(res, dict) else False
@@ -331,7 +331,7 @@ def silhouette_gate(ctx: RunContext, renders: RenderSet) -> GateReport | None:
message=msg, data=data,
fix_hint=("match the reference outline: compare proportions (aspect ratio), overall extents and the "
"silhouette of each major part against the reference image" if low else ""))
- return GateReport(gate=SILHOUETTE_GATE, passed=True, findings=[finding])
+ return GateReport.of(SILHOUETTE_GATE, [finding])
def silhouette_iou(rec: RoundRecord) -> tuple[float, dict] | None: