Official Codebase of 3DCodeVerse
Python
doctor: the live check is health.probe, and a configured Blender is never substituted
gaoypeng68387cc5a7d0
diff --git a/harness/codeverse3d/config.py b/harness/codeverse3d/config.pyindex 2b7d8d6f..c6bd24ca 100644--- a/harness/codeverse3d/config.py+++ b/harness/codeverse3d/config.py@@ -67,6 +67,10 @@ Flag = Annotated[bool, WrapValidator(_or_default)]Count = Annotated[int, Field(ge=0), WrapValidator(_or_default)]+#: the oldest Blender the wrappers support (docs/INSTALL.md §2.1); ``3dcode doctor`` checks it+BLENDER_MIN: tuple[int, int] = (4, 2)++class Binaries(BaseModel):blender: str = Field(default="", description="path to a Blender 4.2+/5.x binary (headless capable)")node: str = "node"@@ -364,8 +368,10 @@ class Settings(BaseSettings):return pdef resolve_blender(self) -> str:- if self.binaries.blender and Path(self.binaries.blender).exists():- return self.binaries.blender+ """The configured binary (a path or a name on PATH), else the first Blender on PATH. A+ configured one that is not there is "none", never a silent substitute for it."""+ if self.binaries.blender:+ return shutil.which(self.binaries.blender) or ""for cand in ("blender-5.0", "blender", "blender-5.1", "blender-4.2"):p = shutil.which(cand)if p:diff --git a/harness/codeverse3d/doctor.py b/harness/codeverse3d/doctor.pyindex ed28fd53..c578863f 100644--- a/harness/codeverse3d/doctor.py+++ b/harness/codeverse3d/doctor.py@@ -7,11 +7,11 @@ shim is a CLI concern (tests/install imports these checks as documentation factsfrom __future__ import annotationsimport importlib+import reimport shutilfrom pathlib import Path-from codeverse3d.config import get_settings-from codeverse3d.models import get_chat_model+from codeverse3d.config import BLENDER_MIN, get_settingsfrom codeverse3d.proc import read_json_or_none, run_subprocess, version_lineRow = tuple[str, str, str]@@ -68,8 +68,12 @@ def check_blender() -> list[Row]:s = get_settings()b = s.resolve_blender()if not b:- return [("blender", "FAIL", "no binary (set C3D_BINARIES__BLENDER or put blender-5.0 on PATH)")]+ return [("blender", "FAIL", f"C3D_BINARIES__BLENDER={s.binaries.blender} is not an executable"+ if s.binaries.blender else "no binary (set C3D_BINARIES__BLENDER or put blender-5.0 on PATH)")]okk, v = _ver([b, "--version"], timeout=60)+ m = re.search(r"Blender (\d+)\.(\d+)", v)+ if okk and m and (int(m[1]), int(m[2])) < BLENDER_MIN:+ return [("blender", "FAIL", f"{v} @ {b} — too old, need >= {'.'.join(map(str, BLENDER_MIN))}")]return [("blender", "OK" if okk else "FAIL", f"{v} @ {b}")]@@ -180,18 +184,10 @@ def check_keys(live: bool) -> list[Row]:rows.append(("anthropic key", "OK" if s.anthropic_api_key else "WARN", "set" if s.anthropic_api_key else "not set (anthropic:* backends unavailable)"))rows.append(("openai key", "OK" if s.openai_api_key else "WARN", "set" if s.openai_api_key else "not set (openai:* backends unavailable)"))if live and n:- try:- from codeverse3d.contracts.chat import ChatMessage, ChatRequest-- m = get_chat_model("gemini:gemini-3.7-flash")- r = m.generate(ChatRequest(messages=[ChatMessage.user("Reply with the single word: pong")],- # 256, not 16: gemini-3.x spends output tokens on thoughts even- # with thinking="off", and a 16-token budget comes back empty- temperature=0.0, max_output_tokens=256, thinking="off", label="doctor"))- rows.append(("gemini live call", "OK" if "pong" in r.text.lower() else "WARN",- f"{r.text.strip()[:40]!r} cost=${r.usage.cost_usd:.5f}"))- except Exception as e:- rows.append(("gemini live call", "FAIL", f"{type(e).__name__}: {str(e)[:120]}"))+ from codeverse3d.models.health import probe++ h = probe(sample=1) # one workload-sized call, no retries; never raises+ rows.append(("gemini live call", "OK" if h.ok else "FAIL", str(h)))return rowsdiff --git a/harness/codeverse3d/models/health.py b/harness/codeverse3d/models/health.pyindex 4abc87fc..228b9e17 100644--- a/harness/codeverse3d/models/health.py+++ b/harness/codeverse3d/models/health.py@@ -23,6 +23,7 @@ import concurrent.futures as cfimport loggingfrom dataclasses import dataclass+from codeverse3d.contracts.common import Backendsfrom codeverse3d.models.registry import build_chat_modellog = logging.getLogger(__name__)@@ -68,7 +69,7 @@ class Health:def probe(- model: str = "gemini:gemini-3.7-flash",+ model: str = Backends().planner,*,sample: int = DEFAULT_SAMPLE,timeout_s: float = DEFAULT_TIMEOUT_S,diff --git a/harness/setup.sh b/harness/setup.shindex 367c2327..64b698d6 100755--- a/harness/setup.sh+++ b/harness/setup.sh@@ -3,7 +3,7 @@## bash harness/setup.sh [options]#-# Does, in order: version checks (python >= 3.10, node >= 20.6) -> `pip install -e+# Does, in order: version checks (python 3.13, node >= 20.6) -> `pip install -e# harness[<extras>]` -> `npm ci` in runtime_js *only when the lockfile moved* -># puppeteer chrome download (no-op when cached) -> `3dcodeverse doctor`.# Re-running is safe: every step is a no-op when it is already satisfied.@@ -125,11 +125,8 @@ elseinfo "node not found (three.js / scene / GLB export tracks will not run)"fi-if command -v blender-5.0 >/dev/null 2>&1 || command -v blender >/dev/null 2>&1 || [ -n "${C3D_BINARIES__BLENDER:-}" ]; then- info "blender found"-else- info "blender not found (optional: blender / urdf_blender tracks unavailable — docs/INSTALL.md §6)"-fi+# Blender (optional: the blender / urdf_blender tracks) is found and version-checked by the+# closing doctor, through the harness's own resolver (docs/INSTALL.md §6).# ------------------------------------------------------------------ python pkgif [ "$DO_PYTHON" -eq 1 ]; thendiff --git a/harness/tests/core/test_portability.py b/harness/tests/core/test_portability.pyindex d782693a..c0609c18 100644--- a/harness/tests/core/test_portability.py+++ b/harness/tests/core/test_portability.py@@ -28,6 +28,7 @@ def test_setup_and_runtime_js_declare_the_same_runtime_floors() -> None:assert re.search(rf"^MIN_PY_MINOR={PY_FLOOR[1]}\b", text, re.M), "setup.sh python floor drifted"assert re.search(rf"^MIN_NODE_MAJOR={NODE_MIN[0]}\b", text, re.M), "setup.sh node major floor drifted"assert re.search(rf"^MIN_NODE_MINOR={NODE_MIN[1]}\b", text, re.M), "setup.sh node minor floor drifted"+ assert f"(python {PY_FLOOR[0]}.{PY_FLOOR[1]}," in text, "setup.sh's header states another python floor"pkg = json.loads((HARNESS / "runtime_js" / "package.json").read_text())assert pkg["engines"]["node"] == f">={NODE_MIN_STR}"@@ -78,3 +79,19 @@ def test_run_node_enforces_the_version_floor(tmp_path, monkeypatch) -> None:node_mod.run_node(script)monkeypatch.setattr(node_mod, "node_version", lambda _bin: (20, 6, 0))require_node_version("node") # must not raise+++def test_a_configured_blender_is_never_substituted_and_its_floor_is_checked(tmp_path: Path, switch) -> None:+ """N67: a typo'd C3D_BINARIES__BLENDER silently fell back to whatever was on PATH; 4.2 was unchecked."""+ from codeverse3d import doctor+ from codeverse3d.config import get_settings++ switch("C3D_BINARIES__BLENDER", str(tmp_path / "blendr"))+ assert get_settings().resolve_blender() == ""+ assert doctor.check_blender()[0][1] == "FAIL" and "blendr" in doctor.check_blender()[0][2]+ old = tmp_path / "blender-3.6"+ old.write_text("#!/bin/sh\necho 'Blender 3.6.5'\n")+ old.chmod(0o755)+ switch("C3D_BINARIES__BLENDER", str(old))+ name, status, detail = doctor.check_blender()[0]+ assert get_settings().resolve_blender() == str(old) and status == "FAIL" and "too old" in detaildiff --git a/harness/tests/install/test_docs.py b/harness/tests/install/test_docs.pyindex ceff7944..94b5d13b 100644--- a/harness/tests/install/test_docs.py+++ b/harness/tests/install/test_docs.py@@ -237,11 +237,9 @@ def test_doctor_rows_have_troubleshooting_entries(monkeypatch) -> None:lambda keys, **kw: SimpleNamespace(slots=busy, stats=lambda: {"n_keys": 1, "in_flight": 0, "peak_in_flight": 0, "acquired": 0, "ok": 0,"429": 0, "5xx": 0, "n_dead": 0, "n_cooling": 0}))- monkeypatch.setattr(- "codeverse3d.models.get_chat_model",- lambda model: SimpleNamespace(generate=lambda request: SimpleNamespace(- text="pong", usage=SimpleNamespace(cost_usd=0.0))),- )+ from codeverse3d.models.health import Health++ monkeypatch.setattr("codeverse3d.models.health.probe", lambda **kw: Health(model="gemini:m", n_ok=1, n_tried=1))monkeypatch.setattr("codeverse3d.skills.registry.ROUTED_SKILLS", ("missing",))rows = doctor_mod.run_doctor(live=True, gpu=True, skills=True)