Official Codebase of 3DCodeVerse
Python
throughput + scene quality: TPM-aware key scheduling at the measured knee, and the scene gates stop failing their own good runs
gaoypeng5a6e620a0ba6
diff --git a/harness/bench/_oneshot.py b/harness/bench/_oneshot.pyindex d35e0795..fed279a8 100644--- a/harness/bench/_oneshot.py+++ b/harness/bench/_oneshot.py@@ -10,8 +10,9 @@ Backends (``get_oneshot_backend``):* ``claude-code`` / ``claude-code:<model>`` — ``claude -p`` with ``--tools ""``and ``--max-turns 1`` (subscription; model default when none given).-* ``codex`` / ``codex:<model>`` — ``codex exec`` read-only sandbox, JSONL events- (subscription; model default when none given).+* ``codex`` / ``codex:<model>[@<effort>]`` — ``codex exec`` read-only sandbox, JSONL+ events, ``-c model_reasoning_effort=`` (default ``high``, see+ ``Settings.agents.codex_reasoning_effort``) (subscription; model default when none given).* ``gemini:<m>`` / ``anthropic:<m>`` / ``openai:<m>`` — ``codeverse.models``chat model, one ``ChatRequest``.@@ -34,7 +35,7 @@ from pydantic import BaseModel, Fieldfrom codeverse.agents.claude_code import parse_claude_json, usage_from_envelopefrom codeverse.agents.cli_common import is_secret_env, tail-from codeverse.agents.codex import parse_codex_jsonl+from codeverse.agents.codex import effort_overrides, parse_codex_jsonl, split_model_effortfrom codeverse.agents.watchdog import run_with_watchdogfrom codeverse.config import get_settingsfrom codeverse.contracts.artifacts import BuildResult, GateReport@@ -233,16 +234,17 @@ class CodexOneShot:kind = "codex"- def __init__(self, model: str = "", binary: str | None = None):- self.model = model+ def __init__(self, model: str = "", binary: str | None = None, reasoning_effort: str | None = None):+ self.model, self.reasoning_effort = split_model_effort(model, reasoning_effort)self.binary = binary or get_settings().binaries.codex_cli- self.id = f"oneshot:{self.kind}" + (f":{model}" if model else "")+ self.id = f"oneshot:{self.kind}" + (f":{self.model}" if self.model else "")def argv(self, cwd: Path, last_msg: Path) -> list[str]:argv = [self.binary, "exec", "--json", "-C", str(cwd), "--sandbox", "read-only", "--skip-git-repo-check","--ephemeral", "--color", "never", "-o", str(last_msg)]if self.model:argv += ["--model", self.model]+ argv += effort_overrides(self.reasoning_effort)argv.append("-") # prompt on stdinreturn argvdiff --git a/harness/bench/concurrency_probe.py b/harness/bench/concurrency_probe.pyindex 7445a415..c8457d53 100644--- a/harness/bench/concurrency_probe.py+++ b/harness/bench/concurrency_probe.py@@ -116,7 +116,10 @@ def run_level() -> LevelResult:pool = KeyPool(keys, rpm_per_key=rpm_per_key, tpm_per_key=tpm_per_key)gate = StormGate(f"probe:{model}:c{level}") if storm_gate else None- m = GeminiModel(model, pool=pool, storm_gate=gate)+ m = GeminiModel(model, pool=pool)+ # assign directly: passing storm_gate=None to the constructor means "use the+ # process-wide gate", and this probe has to be able to switch it off entirely+ m.storm_gate = gatebody = filler(in_tokens)gauge = _Gauge()lat: list[float] = []diff --git a/harness/bench/run_bench.py b/harness/bench/run_bench.pyindex caa25f3b..2734e018 100644--- a/harness/bench/run_bench.py+++ b/harness/bench/run_bench.py@@ -94,7 +94,10 @@ class BenchOptions(BaseModel):rounds: int = 4max_usd: float = 5.0max_minutes: float = 60.0- parallel: int = 2+ #: measured (docs/COST.md Part III): one bench cell holds ~0.9 model calls+ #: in flight, so 8 cells sit near 7 — far inside the 64-call model knee — and+ #: their builds sit inside the 16-build subprocess knee.+ parallel: int = 8limit: int | None = Noneids: list[str] = Field(default_factory=list)tiers: list[str] = Field(default_factory=list)diff --git a/harness/codeverse/agents/codex.py b/harness/codeverse/agents/codex.pyindex c5996e39..39e6a3b1 100644--- a/harness/codeverse/agents/codex.py+++ b/harness/codeverse/agents/codex.py@@ -1,7 +1,8 @@"""``codex:<model>`` — headless OpenAI Codex CLI session on a workspace.argv: ``codex exec --json -C <ws> --sandbox workspace-write --skip-git-repo-check-[--model <model>] [-c mcp_servers.3dcv.command=... -c mcp_servers.3dcv.args=[...]] <prompt>``+[--model <model>] [-c model_reasoning_effort=<effort>]+[-c mcp_servers.3dcv.command=... -c mcp_servers.3dcv.args=[...]] <prompt>``(prompt on stdin when long). stdout is JSONL:* ``{"type":"thread.started","thread_id":...}`` / ``turn.started``@@ -37,6 +38,30 @@ IDLE_GRACE_S = 300.0STDIN_PROMPT_BYTES = 100_000_TOOL_ITEMS = ("command_execution", "file_change", "mcp_tool_call", "web_search", "tool_call")+#: what ``-c model_reasoning_effort=`` accepts; ``""`` means "leave it to ~/.codex/config.toml"+REASONING_EFFORTS = ("", "minimal", "low", "medium", "high", "xhigh")+++def split_model_effort(model: str, effort: str | None = None) -> tuple[str, str]:+ """``('gpt-5.6-sol@low', None) -> ('gpt-5.6-sol', 'low')``.++ Precedence: an explicit ``effort`` argument, then an ``@<effort>`` suffix on the+ model id, then ``Settings.agents.codex_reasoning_effort`` (default ``high`` — the+ codex CLI's own default is *medium*, and the harness would rather pay for thinking).+ ``""`` at any level means "pass no override and let ~/.codex/config.toml decide".+ """+ name, _, suffix = model.partition("@")+ chosen = effort if effort is not None else (suffix or get_settings().agents.codex_reasoning_effort)+ chosen = chosen.strip().lower()+ if chosen not in REASONING_EFFORTS:+ raise ValueError(f"bad codex reasoning effort {chosen!r}; expected one of {REASONING_EFFORTS}")+ return name.strip(), chosen+++def effort_overrides(effort: str) -> list[str]:+ """The ``-c`` pair for a reasoning effort (empty when nothing should be forced)."""+ return ["-c", f"model_reasoning_effort={effort}"] if effort else []+class CodexEvents:"""Folded view over the JSONL event stream."""@@ -80,11 +105,18 @@ class CodexEvents:self.errors.append(str(ev.get("message") or ev))def usage(self, model: str) -> Usage:+ # `output_tokens` from the Responses API already CONTAINS+ # `reasoning_output_tokens` (measured: output − reasoning tracks the answer+ # length across every recorded cell). `estimate_cost` bills output ++ # thoughts, so the reasoning share is subtracted here instead of being+ # charged twice — it stays visible in `thoughts_tokens`.+ reasoning = self.usage_raw["reasoning_output_tokens"]u = Usage(backend="codex", model=model,- input_tokens=self.usage_raw["input_tokens"], output_tokens=self.usage_raw["output_tokens"],+ input_tokens=self.usage_raw["input_tokens"],+ output_tokens=max(0, self.usage_raw["output_tokens"] - reasoning),cached_tokens=self.usage_raw["cached_input_tokens"], tool_calls=self.tool_calls,- thoughts_tokens=self.usage_raw["reasoning_output_tokens"],+ thoughts_tokens=reasoning,)u.cost_usd = estimate_cost_safe("openai", model, u)return u@@ -100,8 +132,8 @@ def parse_codex_jsonl(stdout: str) -> CodexEvents:class CodexAgent:kind = "codex"- def __init__(self, model: str, binary: str | None = None):- self.model = model+ def __init__(self, model: str, binary: str | None = None, reasoning_effort: str | None = None):+ self.model, self.reasoning_effort = split_model_effort(model, reasoning_effort)self.binary = binary or get_settings().binaries.codex_cli@property@@ -120,6 +152,7 @@ class CodexAgent:"--skip-git-repo-check", "--ephemeral", "--color", "never"]if self.model:argv += ["--model", self.model]+ argv += effort_overrides(self.reasoning_effort)if job.spatial_tools:argv += codex_mcp_overrides(mcp_command_for(s.ws, job))argv.append(prompt if prompt is not None else "-")@@ -178,4 +211,5 @@ def _compose_prompt(job: AgentJob) -> str:return f"<harness_instructions>\n{job.system_append}\n</harness_instructions>\n\n{job.prompt}"-__all__ = ["CodexAgent", "CodexEvents", "parse_codex_jsonl"]+__all__ = ["REASONING_EFFORTS", "CodexAgent", "CodexEvents", "effort_overrides", "parse_codex_jsonl",+ "split_model_effort"]diff --git a/harness/codeverse/cli/doctor.py b/harness/codeverse/cli/doctor.pyindex cb271f45..56e69a07 100644--- a/harness/codeverse/cli/doctor.py+++ b/harness/codeverse/cli/doctor.py@@ -183,7 +183,9 @@ def check_keys(live: bool) -> list[Row]:m = get_chat_model("gemini:gemini-3.7-flash")r = m.generate(ChatRequest(messages=[ChatMessage.user("Reply with the single word: pong")],- temperature=0.0, max_output_tokens=16, thinking="off", label="doctor"))+ # 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:diff --git a/harness/codeverse/config.py b/harness/codeverse/config.pyindex e2cc2956..2ea6cb8f 100644--- a/harness/codeverse/config.py+++ b/harness/codeverse/config.py@@ -37,6 +37,16 @@ class Binaries(BaseModel):ffmpeg: str = "ffmpeg"+class Agents(BaseModel):+ """Knobs for the CLI-backed coding agents (the subscription CLIs)."""++ codex_reasoning_effort: str = Field(+ default="high",+ description="`-c model_reasoning_effort=` passed to every `codex:` call (agent and one-shot). "+ "One of minimal|low|medium|high|xhigh, or '' to leave the choice to ~/.codex/config.toml. "+ "Override per id with `codex:<model>@<effort>`.")++class Render(BaseModel):width: int = 768height: int = 768@@ -52,8 +62,15 @@ class Limits(BaseModel):render_timeout_s: int = 300agent_timeout_s: int = 1800bpy_rlimit_gb: int = 12- max_parallel_agents: int = 6- max_parallel_builds: int = 3+ # Both measured, not guessed (docs/COST.md Part III). These size the+ # *subprocess* side (blender / node / chrome), which is bound by cores — 24+ # here — and NOT by the provider: the model-call ceiling is Rate.max_in_flight.+ # 32 concurrent blender builds of a recorded model.py peaked at 16 workers+ # (1 392 builds/min; 24 workers gave 1 168, 32 gave 1 019), so a fan-out of 12+ # agent tasks x their own builds stays inside the knee and leaves cores for the+ # render pass, whose tail is minutes long.+ max_parallel_agents: int = 12+ max_parallel_builds: int = 8agent_max_turns: int = Field(default=0,description="hard cap on model turns per agent session (0 = the backend's own default, "@@ -78,8 +95,18 @@ class Rate(BaseModel):rpm_per_key: int = Field(default=1000, description="requests/minute allowed per API key")tpm_per_key: int = Field(default=1_000_000, description="prompt tokens/minute allowed per API key")- max_in_flight: int = Field(default=32, description="process-wide cap on concurrent model calls (0 = off)")- storm_gate: bool = Field(default=True, description="share 503 capacity-storm back-pressure across workers")+ max_in_flight: int = Field(+ default=64,+ description="process-wide cap on concurrent model calls (0 = off). Measured knee: a "+ "128-call burst of 12k-token prompts ran 29.6 calls/min at 16 in-flight, 43.9 at 32, "+ "72.9 at 64 and fell back to 47.2 at 128 (docs/COST.md Part III).")+ storm_gate: bool = Field(+ default=False,+ description="share 503 capacity-storm back-pressure across workers. OFF: measured and it "+ "LOST — 30.0/45.4 calls/min without it vs 18.2/20.0 with it, because Gemini's 503s are "+ "intermittent rather than a clean outage, so parking every worker starves the unlucky call "+ "(docs/COST.md §21). The mechanism and its counters are kept so the experiment is "+ "reproducible: CV3D_RATE__STORM_GATE=1, or bench/concurrency_probe.py --storm-gate.")class Judge(BaseModel):@@ -97,6 +124,7 @@ class Settings(BaseSettings):runs_dir: Path = Field(default=Path("runs"))cache_dir: Path = Field(default=Path.home() / ".cache" / "codeverse")binaries: Binaries = Field(default_factory=Binaries)+ agents: Agents = Field(default_factory=Agents)render: Render = Field(default_factory=Render)limits: Limits = Field(default_factory=Limits)rate: Rate = Field(default_factory=Rate)@@ -117,6 +145,11 @@ class Settings(BaseSettings):# Cost dial: one name that sets model-per-role, judge samples, rounds, candidates,# turn cap, montage size and the texture pass together (codeverse/cost/profiles.py).+ model_timeout_s: float = Field(+ default=300.0,+ description="HTTP read timeout for ONE API model call (per attempt; retries multiply it). "+ "Raise it when the provider is degraded and big structured calls (planner, judge) time out "+ "before they answer: CV3D_MODEL_TIMEOUT_S=900.")profile: str = Field(default="balanced", description="economy | balanced | quality")cost_ledger: bool = Field(default=True, description="append one priced row per model call ""to the run's telemetry/cost.jsonl (or a per-process log)")diff --git a/harness/codeverse/fanout.py b/harness/codeverse/fanout.pyindex 9d5a8fdb..ecb35a78 100644--- a/harness/codeverse/fanout.py+++ b/harness/codeverse/fanout.py@@ -56,7 +56,7 @@ def _in_caller_context(snapshot: contextvars.Context, fn: Callable[[int], None],def fan_out(items: Sequence[T] | Iterable[T],fn: Callable[[T], R],- max_workers: int = 4,+ max_workers: int = 8,*,label: str = "fanout",item_name: Callable[[T], str] | None = None,@@ -67,6 +67,11 @@ def fan_out(Each result is the return value or the raised ``Exception``. ``on_done``(if given) is called from the worker thread with ``(index, item, result,seconds)`` — keep it cheap and thread-safe (e.g. an EventLog.emit).++ ``max_workers`` is a *fallback*: every caller in the harness states its own,+ sized from the measured ceilings in ``docs/COST.md`` Part III+ (``Settings.limits`` for the subprocess side, ``Settings.rate.max_in_flight``+ for model calls). 8 is the largest width that is inside both knees."""items = list(items)# Workers inherit the caller's context so ambient state set with contextvarsdiff --git a/harness/codeverse/models/gemini.py b/harness/codeverse/models/gemini.pyindex 8c9082f6..5bc917f1 100644--- a/harness/codeverse/models/gemini.py+++ b/harness/codeverse/models/gemini.py@@ -88,6 +88,15 @@ def _rate() -> Any:return Rate()+def _default_timeout_s() -> float:+ from codeverse.config import get_settings++ try:+ return float(get_settings().model_timeout_s)+ except Exception: # pragma: no cover - settings must never break a model call+ return 300.0++def _default_keys() -> list[str]:from codeverse.config import get_settings@@ -166,7 +175,7 @@ class GeminiModel:*,keys: list[str] | None = None,pool: KeyPool | None = None,- timeout_s: float = 300.0,+ timeout_s: float | None = None,max_attempts: int = 6,base_delay: float = 1.0,max_delay: float = MAX_WAIT_S,@@ -186,7 +195,7 @@ class GeminiModel:self.storm_gate = storm_gate if storm_gate is not None else (storm_gate_for(f"gemini:{model}") if _rate().storm_gate else None)- self.timeout_s = timeout_s+ self.timeout_s = _default_timeout_s() if timeout_s is None else timeout_sself.max_attempts = max(1, max_attempts)self.base_delay = base_delayself.max_delay = max_delaydiff --git a/harness/codeverse/models/keypool.py b/harness/codeverse/models/keypool.pyindex b5492c5a..202de9f9 100644--- a/harness/codeverse/models/keypool.py+++ b/harness/codeverse/models/keypool.py@@ -5,12 +5,20 @@ Used by ``GeminiModel`` (22 keys on the owner's box) but provider-neutral.* ``acquire()`` picks the next healthy key round-robin, honouring per-keyRPM / TPM token buckets and 429 cool-downs; it blocks (bounded) when everykey is throttled and raises ``KeyPoolExhausted`` after ``timeout_s``.+ ``tokens_hint`` reserves the pending call's estimated prompt tokens, so a+ 200 k-token judge verdict and a 2 k-token caption are scheduled differently+ (``docs/COST.md`` Part III); ``max_in_flight`` additionally caps how many calls+ may be out at once, and :meth:`KeyPool.release` (a ``finally`` in+ ``rotate_with_retries``) hands the slot back.* ``report(key, outcome)`` feeds back ``ok | 429 | 5xx | error | dead`` so thepool can cool a key down and adjust its health score. ``dead`` is forkey-scoped auth/permission failures (revoked / suspended / invalid key): thekey is benched for ``dead_cooldown_s`` (default one hour) and re-probed oncethat elapses — a dead key must never keep failing its share of calls.-* ``stats()`` exposes counters for logs / ``3dcv doctor``.+ ``report(..., tokens=actual, reserved=hint)`` reconciles the reservation with+ the provider's real prompt-token count (refund or top-up).+* ``stats()`` exposes counters for logs / ``3dcv doctor --live``: per-key health+ and cooldown, pool RPM/TPM capacity and headroom, in-flight and peak in-flight.Thread-safe; ``clock`` / ``sleep`` are injectable for deterministic tests."""diff --git a/harness/codeverse/models/pricing.py b/harness/codeverse/models/pricing.pyindex 89d54f0d..9257952e 100644--- a/harness/codeverse/models/pricing.py+++ b/harness/codeverse/models/pricing.py@@ -131,6 +131,8 @@ PRICES: dict[tuple[str, str], Price] = {# ---------------------------------------------------------------- openai# gpt-5.6-sol is CHEAPER than gpt-5.6 (was priced as its equal until 2026-08-23).("openai", "gpt-5.6-sol"): Price(4.00, 20.00, 0.40),+ ("openai", "gpt-5.6-terra"): Price(2.00, 12.00, 0.20),+ ("openai", "gpt-5.6-luna"): Price(0.20, 1.20, 0.02),("openai", "gpt-5.6"): Price(5.00, 30.00, 0.50),("openai", "gpt-5.5"): Price(5.00, 30.00, 0.50),("openai", "gpt-5.4"): Price(2.50, 15.00, 0.25),@@ -190,6 +192,10 @@ PROVENANCE: dict[tuple[str, str], Provenance] = {note="not listed on the pricing page; assumed = haiku-4.5"),("anthropic", "claude-haiku-3-5"): _V("anthropic", note="retired except on Bedrock / Google Cloud"),("openai", "gpt-5.6-sol"): _V("openai", note="4.00/20.00/0.40; was 5.00/30.00/0.50 here until 2026-08-23"),+ ("openai", "gpt-5.6-terra"): _V("openai", checked="2026-08-24",+ note="mid tier; fast mode is 4.00/24.00 (not modelled)"),+ ("openai", "gpt-5.6-luna"): _V("openai", checked="2026-08-24",+ note="small tier, cut 80% on 2026-07-30; fast mode is 0.40/2.40 (not modelled)"),("openai", "gpt-5.6"): _V("openai"),("openai", "gpt-5.5"): _V("openai"),("openai", "gpt-5.4"): _V("openai"),diff --git a/harness/codeverse/spatial/frame_motion.py b/harness/codeverse/spatial/frame_motion.pyindex 779268e2..8c7820df 100644--- a/harness/codeverse/spatial/frame_motion.py+++ b/harness/codeverse/spatial/frame_motion.py@@ -18,6 +18,7 @@ context and into the ``scene_frames`` gate.from __future__ import annotationsimport json+import loggingfrom collections.abc import Sequencefrom dataclasses import dataclassfrom pathlib import Path@@ -34,6 +35,8 @@ MOVING_FRAC = 0.004STRONG_DELTA = 60STRONG_FRAC = 0.0008+log = logging.getLogger(__name__)+@dataclass(frozen=True)class MotionRow:@@ -156,3 +159,15 @@ def motion_from_dir(out_dir: Path | str) -> list[MotionRow]:except (OSError, ValueError):return []return motion_rows(metrics, d)+++def motion_text_for(out_dir: Path | str) -> str:+ """``motion_summary_text`` for one render directory; ``""`` on any problem.++ This is what a track puts in front of the judge, so it must never be the reason a+ round fails: instrumentation that cannot be read is simply absent."""+ try:+ return motion_summary_text(motion_from_dir(out_dir))+ except Exception as e: # noqa: BLE001 — judge context must never break a round+ log.warning("motion text failed for %s: %s", out_dir, e)+ return ""diff --git a/harness/codeverse/spatial/render_scene.py b/harness/codeverse/spatial/render_scene.pyindex 1569aeb2..1f348172 100644--- a/harness/codeverse/spatial/render_scene.py+++ b/harness/codeverse/spatial/render_scene.py@@ -228,6 +228,25 @@ def _store_motion(out_dir: Path, metrics: dict[str, Any]) -> None:log.warning("could not write motion into %s: %s", path, e)+def perf_detail(rs: RenderSet) -> str:+ """`` — 5028 draw calls (budget 200), 191k triangles`` from a render's own instruments.++ The number is what makes a low-fps finding actionable: "low fps" is a mood, "5028 draw+ calls against a budget of 200" names the fix. ``""`` when the instruments are missing."""+ try:+ path = metrics_path_for(rs)+ if path is None:+ return ""+ fps = (json.loads(path.read_text()).get("fps") or {})+ calls, tris = fps.get("draw_calls"), fps.get("triangles")+ bits = [f"{int(calls)} draw calls (budget 200)" if isinstance(calls, (int, float)) else "",+ f"{int(tris) / 1000:.0f}k triangles" if isinstance(tris, (int, float)) else ""]+ inner = ", ".join(b for b in bits if b)+ return f" — {inner}" if inner else ""+ except (OSError, ValueError, TypeError):+ return ""++def select_judge_views(rs: RenderSet, max_n: int = JUDGE_MAX_VIEWS, *, orbit_names: Sequence[str] | None = None) -> RenderSet:"""Copy of ``rs`` with the views a judge should see (≤ ``max_n``), in priority order:authored cameras at the first time · the first two overview orbit views at that timediff --git a/harness/codeverse/texturing/materials.py b/harness/codeverse/texturing/materials.pyindex 5df12626..3bacd493 100644--- a/harness/codeverse/texturing/materials.py+++ b/harness/codeverse/texturing/materials.py@@ -386,9 +386,12 @@ def cookbook_block() -> str:"});","```","",- "Roughness variation without a texture file: give the part 2-3 materials that differ",- "only in roughness (a worn edge strip at -0.15, a recessed face at +0.12), or drive",- "roughness from a `NoiseTexture` (Blender) / a small `DataTexture` (three).",+ "**Roughness variation without a texture file.** GLB export keeps only base colour,",+ "metallic, roughness, emission, alpha and normal *textures* — a Blender noise node tree",+ "does NOT survive it. What does survive: give one part 2-3 materials that differ only in",+ "roughness and assign them per face group (a worn edge strip at -0.15, a recessed panel at",+ "+0.12, the underside at +0.20). Two materials on one part is the cheapest thing that",+ "stops a surface reading as plastic.",]return "\n".join(rows) + "\n"diff --git a/harness/codeverse/tracks/scene.py b/harness/codeverse/tracks/scene.pyindex 02cece4c..b51e0653 100644--- a/harness/codeverse/tracks/scene.py+++ b/harness/codeverse/tracks/scene.py@@ -21,7 +21,6 @@ refine rounds nothing):from __future__ import annotations-import jsonimport loggingimport timefrom collections.abc import Sequence@@ -43,7 +42,8 @@ from codeverse.orchestrator.fanout import fan_outfrom codeverse.orchestrator.rounds import TaskGroup, compact_instructionsfrom codeverse.orchestrator.runner import StageRunnerfrom codeverse.prompts import render-from codeverse.spatial.render_scene import JUDGE_MAX_VIEWS+from codeverse.spatial.frame_motion import motion_text_for+from codeverse.spatial.render_scene import JUDGE_MAX_VIEWS, perf_detailfrom codeverse.tracks.common import RunContext, ServiceUnavailablefrom codeverse.tracks.generation import GenerationResult, GenerationTask, generatefrom codeverse.tracks.lifecycle import BaseTrack@@ -121,7 +121,7 @@ class ScenePipeline:for e in errs[:MAX_CONSOLE_ERRORS]]if renders.fps is not None and renders.fps < 20:findings.append(GateFinding(gate="render_console", severity=Severity.WARN, target="overall",- message=f"low frame rate {renders.fps:.0f} fps" + _perf_detail(renders),+ message=f"low frame rate {renders.fps:.0f} fps" + perf_detail(renders),fix_hint="the budget is <= 200 draw calls and <= 2 M triangles: merge static geometry ""(BufferGeometryUtils.mergeGeometries) and put anything repeated > 5x in ONE ""InstancedMesh per material — a per-object mesh loop is what costs the frame rate"))@@ -155,7 +155,7 @@ class ScenePipeline:return ""# the measured motion goes FIRST: this block is clipped to ~2.5 k chars in the judge# prompt and a long environment plan used to push everything after it off the end- lines = [t for t in (scene_motion_text(ws, round_index),) if t]+ lines = [t for t in (motion_text_for(ws.renders_dir(round_index)),) if t]lines.append(f"Environment plan: {plan.environment}"[:1200])lines.append("Animation plan: " + "; ".join(plan.animation))lines.append("Cameras: " + "; ".join(f"{c.name} ({c.purpose})" for c in plan.cameras))@@ -397,42 +397,6 @@ def refine_recipes(ctx: RunContext, files: Sequence[str]) -> str:return cookbook_sections(ctx, names)-def _perf_detail(renders: RenderSet) -> str:- """`` (5028 draw calls, 191 k triangles)`` from the render's own instruments, or ``""``.-- The number is what makes the finding actionable: "low fps" is a mood, "5028 draw calls- against a budget of 200" names the fix."""- from codeverse.spatial.render_scene import metrics_path_for-- try:- path = metrics_path_for(renders)- if path is None:- return ""- fps = (json.loads(path.read_text()).get("fps") or {})- calls, tris = fps.get("draw_calls"), fps.get("triangles")- bits = [f"{int(calls)} draw calls (budget 200)" if isinstance(calls, (int, float)) else "",- f"{int(tris) / 1000:.0f}k triangles" if isinstance(tris, (int, float)) else ""]- inner = ", ".join(b for b in bits if b)- return f" — {inner}" if inner else ""- except (OSError, ValueError, TypeError):- return ""---def scene_motion_text(ws: Workspace, round_index: int) -> str:- """The measured motion table for this round's renders (``""`` when not measured).-- The two animation times reach the judge as tiles in DIFFERENT montage images, so- "did anything move?" is not a perception task it can win — the harness measures it- (``spatial.frame_motion``) and states the numbers as facts."""- from codeverse.spatial.frame_motion import motion_from_dir, motion_summary_text-- try:- return motion_summary_text(motion_from_dir(ws.renders_dir(round_index)))- except Exception as e: # noqa: BLE001 — judge context must never break a round- log.warning("scene motion context failed: %s", e)- return ""--def zone_file(zone: ZonePlan) -> str:return f"src/zones/{to_snake(zone.name)}.js"diff --git a/harness/docs/COMPLEXITY.md b/harness/docs/COMPLEXITY.mdindex 648fea0d..4096ea9d 100644--- a/harness/docs/COMPLEXITY.md+++ b/harness/docs/COMPLEXITY.md@@ -302,7 +302,47 @@ number the next wave should move.----## 5. Caveats+## 5. Live check: three `static_objects_v2` prompts re-run (2026-08-24)++Re-run on the current tree with the same generator and judge as their recorded+baselines (`api-agent:gemini:gemini-3.7-flash` / `gemini-3.1-pro-preview`), and+scored against the recorded run of the same prompt:++| run / arm | index | parts | tris | silhouette | feature density | hollow | overall | detail | fit | materials | $ | min |+|---|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|--:|+| dining chair — recorded | 0.554 | 12 | 4 160 | 14.3 | 778 | 0.13 | 0.60 | 0.80 | 0.90 | 0.70 | 2.21 | 15 |+| dining chair — new | **0.686** | 14 | 19 480 | 13.8 | **3 663** | 0.14 | **0.93** | 0.85 | 0.85 | 0.70 | 1.45 | 150* |+| birdcage — recorded | 0.746 | 14 | 17 492 | 52.3 | 6 229 | 0.79 | 0.67 | 0.60 | 0.60 | 0.80 | 1.93 | 37 |+| birdcage — new | **0.825** | 15 | 33 804 | 55.2 | **13 568** | 0.90 | **0.85** | 0.85 | 0.85 | 0.85 | 1.76 | 131* |+| toaster — recorded | 0.420 | 11 | 4 722 | 1.7 | 474 | 0.13 | **0.95** | 0.90 | 0.90 | 0.95 | 0.61 | 8 |+| toaster — new | **0.517** | 11 | 15 986 | 1.7 | **2 375** | 0.10 | 0.66 | 0.75 | **0.60** | 0.75 | 0.90 | 84* |++\* the wall clocks are not comparable: this window sat inside a sustained+`gemini-3.7-flash` 503 storm and each run was restarted at least once. Cost is+comparable and did not rise.++**Read with the eyes, not only the index.** The chair really is richer: the+recorded one is a flat square seat slab with straight rails; the new one has a+dished seat with a shaped front edge, a curved crest rail with turned+terminals, tapered legs, side/rear aprons and corner blocks — 14 parts, 4.7× the+feature density, and the score went 0.60 → 0.93. The birdcage gained a wire+floor grid, a framed door, more dome ribs and a trapeze — but it also lost its+brass colour and now reads near-white, which the index cannot see and the judge+did not punish. The toaster is the finding of this document acted out: 5× the+feature density, and the score **fell** 0.95 → 0.66 because the new detail+interpenetrates (`assembly_fit` 0.90 → 0.60). More artifact, worse verdict —+F1, live.++**What this does and does not prove.** It proves the vector is produced,+recorded and readable in a real run (`record.extra["complexity"]`, the per-round+trail, the gallery chip). It does **not** isolate this owner's changes: the+same tree carries a parallel wave's generation work (scoped part generation, a+`detail_budget` gate, planner-brief changes), which is the likelier cause of the+extra geometry. The rubric A/B in §3.1 is the isolated experiment.++---++## 6. Caveats* Object tracks only. A shader or a scene has no `object.glb`; the report countsthose runs as skipped rather than pretending they scored 0 complexity.diff --git a/harness/docs/COST.md b/harness/docs/COST.mdindex 25a50306..4b0fb097 100644--- a/harness/docs/COST.md+++ b/harness/docs/COST.md@@ -283,6 +283,7 @@ made:**| `gemini:gemini-2.5-flash-lite` cached | 0.025 | **0.01** | idem || `gemini:gemini-3.1-pro-preview`, `gemini-3-pro-preview`, `gemini-2.5-pro` | one tier | **+ >200k tier** (4.00 / 18.00 / 0.40) | `estimate_cost` now applies the long-context tier automatically || added | – | `claude-haiku-3-5`, `claude-mythos-5` | were unknown ⇒ silently $0 |+| added 2026-08-24 | – | `openai:gpt-5.6-terra` **2.00 / 12.00 / 0.20**, `openai:gpt-5.6-luna` **0.20 / 1.20 / 0.02** | the other two codex tiers were unknown ⇒ silently $0 (luna was cut 80% on 2026-07-30) || verified (no change) | – | every other gemini / anthropic / openai row | now flagged `verified` rather than "approximate" || still `inferred` / `unverified` | – | `claude-haiku-4`, `o1-mini`, `gpt-5-codex`, `gpt-5.1-codex`, `gpt-5.2-codex`, `gemini-2.5-flash-image` | not listed on the pricing pages; `3dcv cost prices --unverified` lists them |@@ -790,3 +791,214 @@ correction: the regression "switch then stop" rule and the r03+ marginal stopstill cut 2 runs / **$1.14** with **0 best rounds lost** over the 107 recordedrounds (`waste-and-accounting/replay_stops.py`), and every round still emits its`cost.round` event.++---++# Part III — throughput: using the 22 keys (wave 3, 2026-08-24)++Parts I and II are about **money**. Part III is about **wall clock**: the owner has+22 Gemini keys at 1 000 RPM / 1 000 000 TPM each and asked whether the harness rotates+them and whether more parallelism would buy speed. It does rotate — `KeyPool` has done+round-robin + per-key RPM buckets + 429 cooldown + dead-key benching since wave 1. The+finding is that **rotation was never the constraint**: the pool was running at 0.7 % of+its request quota and 1.6 % (median) of its token quota.++Everything below is measured on this box (24 cores, 22 keys, `gemini-3.7-flash`), from+the 6 014 live priced calls in `bench/out/**` and three probes; the reusable one is+`bench/concurrency_probe.py`.++## 18. The baseline: 3 % of the quota, and 17.7 h asleep++| | measured | pool capacity | used |+|---|---|---|---|+| peak requests/minute | 154 | 22 000 | **0.7 %** |+| peak prompt-tokens/minute | 4.00 M | 22.0 M | **18.2 %** |+| median prompt-tokens/minute | 0.36 M | 22.0 M | **1.6 %** |+| peak concurrent calls | 13 | 64 (§20) | 20 % |+| mean concurrent calls | 2.05 | 64 | **3.2 %** |+| 429s in 6 014 calls | 4 | — | all on one key |+| 503 "capacity storm" waits | **2 833** | — | **17.72 h of thread time asleep** |++Reconstructed per battery from `(ts, latency_ms)` in the cost ledgers — `mean_if` is+the time-weighted mean of concurrent Gemini calls, `idle` the share of the span with+none in flight:++| battery | span | `--parallel` | calls | mean_if | peak_if | idle | model time | 503 sleep |+|---|---|---|---|---|---|---|---|---|+| static_v2_flash | 2.49 h | 3 | 4 453 | 2.57 | 10 | 5.3 % | 6.40 h | 1.65 h (504 waits) |+| articulated_v2_flash | 5.95 h | 2 | 1 335 | 0.94 | 3 | 29.1 % | 5.60 h | 4.67 h (560) |+| graphics_v2_flash | 1.10 h | 3 | 67 | 1.07 | 4 | 41.3 % | 1.18 h | 1.23 h (131) |+| compare_v2_full | 1.41 h | 3 | 36 | 1.31 | 4 | 41.0 % | 1.85 h | 1.16 h (79) |++Where a worker's time went, against the six candidates:++* **our own thread pools — the dominant sink.** `max_parallel_agents=6`,+ `max_parallel_builds=3`, `bench --parallel 2`, `fan_out(max_workers=4)`: the harness+ never *asked* for more than 13 concurrent calls out of a measured ceiling of 64.+* **the pool's RPM buckets — ~0.** 154 RPM peak against a 22 000 RPM bucket.+* **provider 429 — ~0.** 4 events in 6 014 calls, all on one key, all rotated away free.+* **provider 503 storms — 22 – 39 % of every battery's wall clock**, 17.7 h in total,+ ≈108 % of all model generation time. Model-wide, so rotation cannot help (§21).+* **subprocesses — negligible for build.** 351 recorded blender builds cost **325 s in+ total** (mean 0.9 s, p50 0.2 s); a fresh build of a recorded `model.py` is 0.37 s.+* **the model generating — 36 – 86 %** of worker time (p50 3.3 s, p90 14.5 s, p99 53 s).++There is nothing to read from the provider: a live `POST …:generateContent` returns no+`x-ratelimit-*` header at all, only `x-gemini-service-tier: standard`. Headroom has to+be modelled from the quota, which is what `Settings.rate` now does.++## 19. TPM, not RPM, is the binding limit++Prompt tokens dominate completely — over the corpus, output + thoughts were **2 % of+input** (243.9 M in vs 4.0 M out) — and a generator call averages **41 739 prompt+tokens**. At that size 1 M TPM is ~24 calls/min per key (528 pool-wide) while the RPM+quota would allow 1 000 per key. So the meaningful limiter is a *token* rate:++* `KeyPool` had a `tpm_per_key` hook that was never set (`None`). It is now wired from+ `Settings.rate.tpm_per_key` (default 1 000 000) via `shared_pool`, whose registry key+ now includes the quota so two different quotas cannot silently share one set of buckets.+* `acquire(tokens_hint=…)` **reserves** the estimated prompt tokens of the pending call.+ The estimate is `codeverse.models.tokens.request_tokens`, a thin wrapper over+ `cost.guard.estimate_call` that walks the whole request (system prompt, tool schemas,+ response schema, tool results, a flat 1 290 per image).+* `report(key, outcome, tokens=actual, reserved=hint)` **reconciles**: the bucket is+ charged `actual - hint`, so an over-estimate is refunded, an under-estimate is paid off+ (the bucket may go negative and is cleared by the next refill), and a call that never+ reached the model — 429 or capacity storm — gets the whole reservation back.++That is what makes a 200 k judge verdict and a 2 k caption schedule differently, and §20+shows it is not theoretical.++## 20. The measured knee — and why one number is not enough++`bench/concurrency_probe.py` runs a fixed workload at several in-flight levels with a+fresh `KeyPool` each time, so the `ok / 429 / 5xx` counters are exact deltas.++**Generator-shaped (12 k-token prompt, 128 calls per level):**++| in-flight | wall | calls/min | Mtok/min | mean_if | p50 | 429 | 5xx | $ |+|---|---|---|---|---|---|---|---|---|+| 16 | 259.8 s | 29.6 | 0.75 | 12.7 | 17.6 s | 0 | 32 | 0.71 |+| 32 | 175.0 s | 43.9 | 1.12 | 24.5 | 28.6 s | 0 | 35 | 0.72 |+| **64** | **105.4 s** | **72.9** | **1.86** | 24.6 | 13.4 s | 0 | 67 | 0.70 |+| 128 | 162.9 s | 47.2 | 1.20 | 22.7 | 20.5 s | 0 | 41 | 0.71 |++Throughput rises **2.5x** from 16 to 64 and falls back 35 % at 128 — the knee is 64.+Cost per call is flat within ±2 % across the whole range: **concurrency buys wall clock,+not money.**++**Judge-shaped (200 k-token prompt, 32 calls per level):**++| in-flight | calls/min | Mtok/min | 429 |+|---|---|---|---|+| 8 | 19.8 | 8.50 | 0 |+| **16** | **46.8** | **20.05** | 2 |+| 32 | 29.5 | 12.66 | 3 |++429s appear exactly where the arithmetic predicts: 16 x 200 k ≈ **20.0 M prompt-tokens+per minute against a 22 M pool quota** — a direct confirmation of the 1 M TPM per key+(measured onset ≈ 0.91 M/key) and the reason a single fixed concurrency number is wrong:+*the same in-flight count that is 3 % of quota for a caption is 91 % of it for a judge+verdict.* The TPM buckets, not a call counter, are what keep the big-call regime honest.++**The subprocess ceiling is a different, much lower number.** 32 replays of a recorded+blender `model.py`:++| workers | 1 | 4 | 8 | **16** | 24 | 32 |+|---|---|---|---|---|---|---|+| builds/min | 155.9 | 590.3 | 1 051.7 | **1 392.0** | 1 167.6 | 1 018.7 |++Knee = **16 concurrent blender builds** on 24 cores. Headless-Chrome renders could not+be measured cleanly (12 distinct GLBs at 1 – 12 workers, forwards and backwards, gave+2.5 – 220 renders/min with single renders from 1.5 s to 153 s): that variance is the+renderer's own tail, not parallelism. Renders are treated as "1.5 – 3 s typical with a+minutes-long tail" and the subprocess pools are sized from the clean build number.++**64 model calls vs 16 subprocesses is 4x apart, so the two are capped separately:**+`Settings.rate.max_in_flight` is a semaphore inside `KeyPool` (network-bound, provider-+sized), `Settings.limits.max_parallel_*` size the thread pools (CPU-bound, core-sized).++### Defaults changed, each from a number above++| knob | was | now | basis |+|---|---|---|---|+| `Rate.tpm_per_key` | *(unset)* | 1 000 000 | owner's quota; 429 onset measured at ~0.91 M/key |+| `Rate.rpm_per_key` | 900 | 1 000 | owner's quota (never binding: 0.7 % used) |+| `Rate.max_in_flight` | *(none)* | 64 | §20 knee |+| `Limits.max_parallel_agents` | 6 | 12 | build knee 16, derated for the render tail |+| `Limits.max_parallel_builds` | 3 | 8 | build knee 16 |+| `bench --parallel` (both drivers) | 2 / 3 | 8 | a cell holds ~0.9 calls in flight → 8 cells ≈ 7, far inside the 64 knee |+| `fan_out(max_workers=…)` fallback | 4 | 8 | inside both knees (every real caller states its own) |++## 21. Making 503 storms cheap: one shared wait instead of thirty++A 429 is per key and rotation cures it. A 503 *"this model is currently experiencing+high demand"* is **model-wide**: every key sees it at once, so each worker that meets a+storm independently spends a full failed round-trip to learn what its siblings already+know, then sleeps on its own private backoff schedule. That is the 2 833 waits / 17.7 h+in §18.++`codeverse/models/storm.py` adds a process-wide `StormGate` per model:++* the first worker to see a 503 calls `hit()`, which closes the gate for a short,+ escalating window (never longer than `MAX_WAIT_S` — patience comes from the *number*+ of waits, not the length of one);+* every other worker parks in `enter()` instead of issuing a call that is almost+ certain to fail;+* once the window elapses exactly **one** worker is let through as a probe, under a+ lease so a crashed prober cannot wedge the gate. Its success (`ok()`) reopens the+ gate for everybody.++It never adds waiting when no storm is running. **And it lost its own A/B, so it ships+OFF.** Same workload (48 calls, 32 in flight, 12 k prompts), alternated to control for+drift in the provider's mood:++| round | gate | wall | calls/min | mean_if | p50 | max | 5xx attempts | parked |+|---|---|---|---|---|---|---|---|---|+| 1 | off | 96.0 s | **30.0** | 14.27 | 25.8 s | 71.0 s | 18 | — |+| 1 | on | 158.3 s | 18.2 | 5.54 | 11.7 s | **158.2 s** | 27 | 140 s |+| 2 | off | 63.4 s | **45.4** | 13.20 | 15.6 s | 63.4 s | 6 | — |+| 2 | on | 144.1 s | 20.0 | 9.92 | 16.0 s | **142.8 s** | 20 | 100 s |++The gate costs **45 – 56 % of throughput**, consistently, and the two columns that+explain why are `5xx` and `max`:++* it produced **more** 503s, not fewer (27 vs 18, 20 vs 6) — the opposite of its purpose.+ A gate that reopens on one probe's success releases all 31 parked workers at the same+ instant, and that thundering herd is exactly the burst the provider was 503-ing.+* median latency **improved** (11.7 s vs 25.8 s in round 1 — parking really does spare a+ worker some doomed round-trips) while the maximum blew out to the whole run length:+ with one probe at a time, whichever call keeps losing the race is starved.++Underneath both is the same misreading: Gemini's 503s here are **intermittent, not an+outage** — most calls succeed while some 503 — so treating the first 503 as "the model+is down" parks 31 healthy workers for nothing. A shared signal only pays when the+failure really is all-or-nothing.++The A/B was run during *intermittent* 503s, which is what the logs show most of the+time. A single sustained outage is the case the gate was designed for and is not+covered by this measurement — that is why the mechanism is kept rather than deleted.+So `Settings.rate.storm_gate` defaults to **False**. The mechanism, its counters and+the probe flag are kept so the experiment is reproducible+(`CV3D_RATE__STORM_GATE=1`, or `bench/concurrency_probe.py --storm-gate`) — the same+treatment §13 gave cache-friendly prompt ordering.++**Caveat on the knee under a storm.** §20's knee optimises *throughput* — total calls+per minute. A bench cell is judged on *latency* instead: it has a `--max-minutes`+budget, and under the sustained 503 storm of 2026-08-24 03:00–05:00 one planner call+took **2 218 s** and cells hit the old 45-minute ceiling before producing code. When+the provider is capacity-limited, extra concurrency cannot add throughput but does add+per-cell latency, so a long battery run in that state wants a *bigger time budget*+(`--max-minutes 180`), not a smaller `--parallel`.++What *did* make storms cheap is smaller and already in the retry loop: no single wait+may exceed `MAX_WAIT_S` = 5 s (patience comes from the number of attempts, 60 of them),+so a storm no longer blocks a worker for minutes — and with `--parallel 8` and+`max_in_flight 64` the other seven cells keep working through it. Deferring a+storm-hit item to the back of the queue was **not** built: at the gate-off settings a+whole 128-call level costs 6 – 35 storm attempts and **zero failures**, which does not+justify a scheduler rewrite in `fan_out`.++`3dcv doctor --live` prints the pool's live picture — keys, in-flight and peak in-flight,+RPM/TPM headroom used, 429/5xx/dead counts this process — plus one row per storm gate+with its storm count, 503 count, probe count and parked seconds.diff --git a/harness/runtime_js/lib/browser/render_rig.js b/harness/runtime_js/lib/browser/render_rig.jsindex 904b5832..513aaf7b 100644--- a/harness/runtime_js/lib/browser/render_rig.js+++ b/harness/runtime_js/lib/browser/render_rig.js@@ -14,6 +14,9 @@ const FOV_DEG = 35;* different distance); everything in the orbit band shares one distance so the object* keeps the same apparent size across the montage. */const UNIFORM_FRAMING_MAX_ELEVATION = 60;+/** ...but never pull a view back by more than this, or a deep object shrinks every other+ * frame to the size its widest side needs and the judge loses detail resolution. */+const UNIFORM_FRAMING_MAX_PULLBACK = 1.10;function loadGlb(url) {return new Promise((resolve, reject) => {@@ -140,13 +143,14 @@ export async function renderGlbViews(cfg) {const rig = buildStudio(renderer, scene, box, { background, shadow: look.shadow && cfg.shadow !== false, lights: look.lights });const camera = new THREE.PerspectiveCamera(FOV_DEG, width / height, 0.01, 100);- const fill = cfg.fill || 0.88;+ const fill = cfg.fill || 0.90;const uniform = uniformDistance(camera, box, cfg.views, fill);const views = [];for (const v of cfg.views) {let fit = fitCameraToBox(camera, box, v.azimuth, v.elevation, { fill });if (uniform != null && Math.abs(v.elevation) <= UNIFORM_FRAMING_MAX_ELEVATION && uniform > fit.distance) {- fit = placeAt(camera, box, v.azimuth, v.elevation, uniform);+ fit = placeAt(camera, box, v.azimuth, v.elevation,+ Math.min(uniform, fit.distance * UNIFORM_FRAMING_MAX_PULLBACK));}aimStudio(rig, v.azimuth, v.elevation);renderer.render(scene, camera);diff --git a/harness/runtime_js/lib/browser/studio.js b/harness/runtime_js/lib/browser/studio.jsindex 8c423f5c..474977f4 100644--- a/harness/runtime_js/lib/browser/studio.js+++ b/harness/runtime_js/lib/browser/studio.js@@ -27,23 +27,33 @@ export const RIG_VERSION = 2;export const BACKGROUNDS = { studio: 0xe9e9ec, white: 0xffffff, transparent: null };/** Tone-mapping exposure per background. MEASURED over 12 recorded artifacts x 8 views- * (96 frames), on the same 96x54 sampling grid `lib/host_metrics.mjs` uses, plus the- * object-only statistics from an alpha-matted render of the same 96 frames:+ * (96 frames), on the 96x54 sampling grid `lib/host_metrics.mjs` uses, plus object-only+ * statistics from an alpha-matted render of the same 96 frames:*- * rig frame mean_lum frame modal_frac object std object p95-p05- * v1 (flat bg) 0.865 0.789 0.135 0.406- * v2 (sweep) 0.774 0.492 0.130 0.395+ * rig frame mean_lum frame modal_frac object lum std object p95-p05+ * v1 (flat bg) 0.865 0.789 0.135 0.406+ * v2 (sweep) 0.702 0.516 0.131 0.400** v2 is DARKER, not brighter, and the object's own shading range is unchanged: the* difference is contrast STRUCTURE (a swept backdrop, a shaped environment), not* exposure. 25 of the 96 v1 frames were over the flat-frame threshold in- * spatial/frame_metrics.py (modal_frac > 0.85); 0 of the v2 frames are, and neither- * rig comes near the dark (< 0.12) or blown (> 20 %) limits. */+ * spatial/frame_metrics.py (modal_frac > 0.85); 0 of the v2 frames are, and neither rig+ * comes near the dark (mean_lum < 0.12) or blown (> 20 % pure white) limits.+ * Cost (median of 4 runs x 3 objects, warm browser): 8 views at 768 px = 97 ms/view wall+ * (v1: 117) and 60 ms/view page-side (v1: 61) — the VSM blur spends what the two fewer+ * lights save, and the driver round trip got cheaper. */const EXPOSURE = { studio: 1.0, white: 1.05, transparent: 1.0 };-const ENV_INTENSITY = 1.15;-const KEY_INTENSITY = 1.35;-const RIM_INTENSITY = 0.45;+// The environment gives metals something shaped to reflect; the DIRECTIONALS are what+// separate one flat panel of a box-shaped object from the next. Measured on 96 frames:+// dropping the directional total from v1's 4.0 to 1.8 flattened panelled objects (an+// espresso machine's steel sides stopped reading as three different planes), so the key+// is back up and a low fill returns — the object's shading range now matches v1's while+// the reflections are v2's.+const ENV_INTENSITY = 1.0;+const KEY_INTENSITY = 2.0;+const FILL_INTENSITY = 0.5;+const RIM_INTENSITY = 0.5;/** Key/rim placement relative to the CAMERA azimuth (deg from the view direction) and* their elevations. Camera-relative is what a turntable product rig does: the key* stays over the photographer's left shoulder, so the cast shadow always falls away@@ -52,10 +62,14 @@ const RIM_INTENSITY = 0.45;* frames of every object. */const KEY_YAW_DEG = 38;const KEY_ELEVATION_DEG = 52;+const FILL_YAW_DEG = -58;+const FILL_ELEVATION_DEG = 12;const RIM_YAW_DEG = -152;const RIM_ELEVATION_DEG = 34;-/** Cast-shadow darkness and the ambient contact blob under the object. */-const CAST_SHADOW_OPACITY = 0.30;+/** Cast-shadow darkness and the ambient contact blob under the object. The cast+ * shadow is soft (VSM, see buildStudio): a hard-edged slab under a product shot+ * reads as a rendering mistake, not as light. */+const CAST_SHADOW_OPACITY = 0.24;const CONTACT_OPACITY = 0.34;const CONTACT_SPREAD = 1.9;@@ -114,24 +128,25 @@ function lightDirection(yawDeg, elevationDeg) {*/export function aimStudio(rig, azimuthDeg, elevationDeg = 0) {if (!rig || !rig.key) return;- const { center, radius, key, rim, scene } = rig;+ const { center, radius, key, fill, rim, scene } = rig;const d = radius * 4;// a plan view needs the key nearly overhead, or the shadow sprawls across the frameconst keyEl = Math.min(80, Math.max(KEY_ELEVATION_DEG, Math.abs(elevationDeg) * 0.85));key.position.copy(center).addScaledVector(lightDirection(azimuthDeg + KEY_YAW_DEG, keyEl), d);key.target.position.copy(center);key.target.updateMatrixWorld();- if (rim) {- rim.position.copy(center).addScaledVector(lightDirection(azimuthDeg + RIM_YAW_DEG, RIM_ELEVATION_DEG), d);- rim.target.position.copy(center);- rim.target.updateMatrixWorld();+ for (const [light, yaw, el] of [[fill, FILL_YAW_DEG, FILL_ELEVATION_DEG], [rim, RIM_YAW_DEG, RIM_ELEVATION_DEG]]) {+ if (!light) continue;+ light.position.copy(center).addScaledVector(lightDirection(azimuthDeg + yaw, el), d);+ light.target.position.copy(center);+ light.target.updateMatrixWorld();}if (scene) scene.environmentRotation.set(0, azimuthDeg * DEG, 0);}/*** Add environment + backdrop + lights (+ shadow catcher) to `scene`, scaled to `box`.- * Returns the rig handle `{catcher, key, rim, blob, center, radius, scene}` — `catcher`+ * Returns the rig handle `{catcher, key, fill, rim, blob, center, radius, scene}` — `catcher`* is the shadow plane callers exclude from framing, the rest is what `aimStudio` moves.*/export function buildStudio(renderer, scene, box, { background = 'studio', shadow = true, lights = true } = {}) {@@ -149,7 +164,7 @@ export function buildStudio(renderer, scene, box, { background = 'studio', shadoconst center = box.getCenter(new THREE.Vector3());const radius = Math.max(box.getSize(new THREE.Vector3()).length() / 2, 1e-3);- const rig = { catcher: null, key: null, rim: null, blob: null, center, radius, scene };+ const rig = { catcher: null, key: null, fill: null, rim: null, blob: null, center, radius, scene };if (lights) {scene.environment = environmentTexture(renderer);@@ -163,7 +178,13 @@ export function buildStudio(renderer, scene, box, { background = 'studio', shadokey.shadow.mapSize.set(2048, 2048);key.shadow.bias = -0.0004;key.shadow.normalBias = radius * 0.012;- key.shadow.radius = 3;+ // VSM is the only three shadow map whose blur radius actually does anything+ // (PCFSoftShadowMap ignores `shadow.radius`), and a soft-edged contact shadow is+ // most of what separates a product shot from a viewport grab. Object rig only —+ // renderer.js keeps PCF for the scene host.+ renderer.shadowMap.type = THREE.VSMShadowMap;+ key.shadow.radius = 5;+ key.shadow.blurSamples = 12;const cam = key.shadow.camera;cam.left = cam.bottom = -radius * 1.45;cam.right = cam.top = radius * 1.45;@@ -171,11 +192,12 @@ export function buildStudio(renderer, scene, box, { background = 'studio', shadocam.far = radius * 8;scene.add(key, key.target);- // A low back-rim keeps a dark object off a dark backdrop; the softboxes in the- // environment do the rest of the work the v1 fill/rim directionals used to do.+ // A low fill opens the shadow side; a back-rim keeps a dark object off the backdrop.+ const fill = new THREE.DirectionalLight(0xffffff, FILL_INTENSITY);const rim = new THREE.DirectionalLight(0xffffff, RIM_INTENSITY);- scene.add(rim, rim.target);+ scene.add(fill, fill.target, rim, rim.target);rig.key = key;+ rig.fill = fill;rig.rim = rim;aimStudio(rig, 0);}diff --git a/harness/runtime_js/lib/browser/studio_env.js b/harness/runtime_js/lib/browser/studio_env.jsindex be631a67..fd4f0925 100644--- a/harness/runtime_js/lib/browser/studio_env.js+++ b/harness/runtime_js/lib/browser/studio_env.js@@ -96,8 +96,13 @@ export function softboxEnvironment() {* Backdrop for `scene.background`: a neutral sweep — bright hotspot a little above* the frame centre falling off to a darker rim, i.e. what a lit paper cyclorama* looks like. No hue, so it never tints a judge's read of the object's colour.+ *+ * The default sits BELOW mid-white (0.90 at the hotspot, 0.60 at the corners) on+ * purpose: rig v1's flat 0xe9e9ec (0.91 everywhere) left a white appliance with+ * nothing to separate against, and put 79 % of an average frame into one luminance+ * bucket — over the flat-frame threshold in spatial/frame_metrics.py.*/-export function backdropTexture(size = 256, { centre = 0.955, edge = 0.70, hotspotY = 0.60 } = {}) {+export function backdropTexture(size = 256, { centre = 0.90, edge = 0.60, hotspotY = 0.60 } = {}) {const data = new Uint8Array(size * size * 4);for (let y = 0; y < size; y++) {// texture row 0 is the BOTTOM of the screen for a background texturediff --git a/harness/runtime_js/render_glb.mjs b/harness/runtime_js/render_glb.mjsindex f962c64b..e991f940 100644--- a/harness/runtime_js/render_glb.mjs+++ b/harness/runtime_js/render_glb.mjs@@ -4,7 +4,7 @@// node runtime_js/render_glb.mjs --glb <path> --out <dir> --views '<json [{name,azimuth,elevation}]>'// [--mode shaded|wire|normals|silhouette|clay] [--width 768] [--height 768]// [--isolate Name1,Name2] [--explode 0.3] [--background studio|white|transparent]-// [--anim-time t] [--gpu auto|on|off] [--shadow 1|0] [--fill 0.88] [--timeout-s 240]+// [--anim-time t] [--gpu auto|on|off] [--shadow 1|0] [--fill 0.90] [--timeout-s 240]//// Writes <out>/view_<name>.png for every view + <out>/views.json, and prints one JSON// line last on stdout: {ok, renderer, gpu, views:[{name,path,camera_position,look_at,fov,...}],@@ -28,7 +28,7 @@ function config() {glb: {}, out: {}, views: {},mode: { default: 'shaded' }, width: { default: '768' }, height: { default: '768' },isolate: { default: '' }, explode: { default: '0' }, background: { default: 'studio' },- 'anim-time': {}, gpu: { default: 'auto' }, shadow: { default: '1' }, fill: { default: '0.88' },+ 'anim-time': {}, gpu: { default: 'auto' }, shadow: { default: '1' }, fill: { default: '0.90' },'timeout-s': { default: '240' },});if (!values.glb || !values.out || !values.views) throw new Error('--glb, --out and --views are required');@@ -52,7 +52,7 @@ function config() {animTime: values['anim-time'] != null ? Number(values['anim-time']) : null,gpu: values.gpu,shadow: values.shadow !== '0',- fill: Number(values.fill) || 0.88,+ fill: Number(values.fill) || 0.90,timeoutMs: Number(values['timeout-s']) * 1000,};}diff --git a/harness/tests/agents/test_codex.py b/harness/tests/agents/test_codex.pyindex 9027bcd9..ffe9394b 100644--- a/harness/tests/agents/test_codex.py+++ b/harness/tests/agents/test_codex.py@@ -9,7 +9,7 @@ from pathlib import Pathimport pytestfrom codeverse.agents.cli_common import begin_session-from codeverse.agents.codex import CodexAgent, parse_codex_jsonl+from codeverse.agents.codex import CodexAgent, parse_codex_jsonl, split_model_effortfrom codeverse.contracts.agent import AgentJobfrom codeverse.workspace import Workspace@@ -49,6 +49,17 @@ def test_parse_jsonl():assert u.input_tokens == 1000 and u.cached_tokens == 600 and u.output_tokens == 50 and u.tool_calls == 2+def test_reasoning_tokens_are_not_billed_twice():+ """`output_tokens` already contains `reasoning_output_tokens` (Responses API)."""+ ev = parse_codex_jsonl(json.dumps(+ {"type": "turn.completed", "usage": {"input_tokens": 1000, "output_tokens": 9000,+ "reasoning_output_tokens": 5000}}))+ u = ev.usage("gpt-5.6-sol")+ assert (u.output_tokens, u.thoughts_tokens) == (4000, 5000)+ # 1000 in @ $4/M + 9000 billable output @ $20/M — the reasoning share counted once+ assert u.cost_usd == pytest.approx(1000 * 4.0 / 1e6 + 9000 * 20.0 / 1e6)++def test_argv_with_mcp_overrides(tmp_ws: Workspace):a = CodexAgent("gpt-5.6-sol", binary="codex")s = begin_session(AgentJob(workspace=str(tmp_ws.root), prompt="p"), "codex")@@ -64,6 +75,21 @@ def test_argv_with_mcp_overrides(tmp_ws: Workspace):assert "mcp_servers" not in " ".join(a.build_argv(s2, None)) and a.build_argv(s2, None)[-1] == "-"+def test_reasoning_effort_is_explicit(tmp_ws: Workspace, monkeypatch):+ """`codex exec` defaults to medium; every harness call states the effort instead."""+ s = begin_session(AgentJob(workspace=str(tmp_ws.root), prompt="p", spatial_tools=False), "codex")+ argv = CodexAgent("gpt-5.6-sol", binary="codex").build_argv(s, "p")+ assert argv[argv.index("-c") + 1] == "model_reasoning_effort=high"+ a = CodexAgent("gpt-5.6-terra@medium", binary="codex")+ assert (a.model, a.reasoning_effort, a.id) == ("gpt-5.6-terra", "medium", "codex:gpt-5.6-terra")+ assert "model_reasoning_effort=medium" in a.build_argv(s, "p")+ assert "model_reasoning_effort" not in " ".join(CodexAgent("gpt-5.6-sol", binary="codex",+ reasoning_effort="").build_argv(s, "p"))+ assert split_model_effort("gpt-5.6-luna", "high") == ("gpt-5.6-luna", "high")+ with pytest.raises(ValueError, match="reasoning effort"):+ CodexAgent("gpt-5.6-sol", binary="codex", reasoning_effort="ludicrous")++def test_fake_run(tmp_ws: Workspace, fake_bin, monkeypatch):a = CodexAgent("gpt-5.6-sol", binary=fake_bin("codex", FAKE_CODEX))res = a.run(AgentJob(workspace=str(tmp_ws.root), prompt="hello", label="x", timeout_s=30))diff --git a/harness/tests/compare_bench/test_oneshot.py b/harness/tests/compare_bench/test_oneshot.pyindex 84fb70b7..30d28df7 100644--- a/harness/tests/compare_bench/test_oneshot.py+++ b/harness/tests/compare_bench/test_oneshot.py@@ -87,6 +87,18 @@ def test_codex_argv_is_read_only_and_reads_prompt_from_stdin(tmp_path: Path):assert "--ephemeral" in argv and "-o" in argv and "mcp_servers" not in " ".join(argv)+def test_codex_oneshot_forces_a_reasoning_effort(tmp_path: Path):+ """Default high (Settings.agents.codex_reasoning_effort); `@effort` on the id wins; '' opts out."""+ argv = CodexOneShot("gpt-5.6-terra", binary="codex").argv(tmp_path, tmp_path / "last.md")+ assert argv[argv.index("--model") + 1] == "gpt-5.6-terra"+ assert "model_reasoning_effort=high" in argv and argv[argv.index("-c") + 1] == "model_reasoning_effort=high"+ b = CodexOneShot("gpt-5.6-luna@low", binary="codex")+ assert b.model == "gpt-5.6-luna" and b.id == "oneshot:codex:gpt-5.6-luna"+ assert "model_reasoning_effort=low" in b.argv(tmp_path, tmp_path / "last.md")+ plain = CodexOneShot("gpt-5.6-sol", binary="codex", reasoning_effort="").argv(tmp_path, tmp_path / "l.md")+ assert "model_reasoning_effort" not in " ".join(plain)++def test_registry():assert isinstance(get_oneshot_backend("claude-code"), ClaudeOneShot)assert get_oneshot_backend("claude-code:sonnet").model == "sonnet"diff --git a/harness/tests/core/test_portability.py b/harness/tests/core/test_portability.pyindex b75fc820..510a432b 100644--- a/harness/tests/core/test_portability.py+++ b/harness/tests/core/test_portability.py@@ -46,10 +46,20 @@ FLOOR_VIOLATIONS = {}+#: directories under the scanned trees that hold *run output*, not harness source:+#: `bench/out/` is gitignored and full of LLM-authored `model.py` files, which are+#: written by whatever model ran that battery and are not held to our python floor.+_NOT_SOURCE = ("__pycache__", "out")++def _py_files() -> list[Path]:out: list[Path] = []for sub in ("codeverse", "bench", "tests"):- out += [p for p in (HARNESS / sub).rglob("*.py") if "__pycache__" not in p.parts]+ root = HARNESS / sub+ out += [+ p for p in root.rglob("*.py")+ if not any(part in _NOT_SOURCE for part in p.relative_to(root).parts)+ ]return sorted(out)diff --git a/harness/tests/install/test_docs.py b/harness/tests/install/test_docs.pyindex b174ed36..f2498696 100644--- a/harness/tests/install/test_docs.py+++ b/harness/tests/install/test_docs.py@@ -186,8 +186,8 @@ def test_doctor_rows_have_troubleshooting_entries() -> None:text = INSTALL.read_text()names = {"python", "python deps", "blender", "node", "three", "puppeteer", "chrome webgl",- "gemini keys", "anthropic key", "openai key", "gemini-cli", "claude", "codex", "agy",- "git", "ffmpeg", "mcp"}+ "gemini keys", "anthropic key", "openai key", "gemini quota", "gemini pool",+ "storm gate", "gemini-cli", "claude", "codex", "agy", "git", "ffmpeg", "mcp"}assert hasattr(doctor_mod, "run_doctor")missing = [n for n in sorted(names) if f"`{n}`" not in text]assert not missing, f"doctor rows undocumented in docs/INSTALL.md: {missing}"diff --git a/harness/tests/models/test_gemini.py b/harness/tests/models/test_gemini.pyindex 89cacc8d..b9548b32 100644--- a/harness/tests/models/test_gemini.py+++ b/harness/tests/models/test_gemini.py@@ -95,6 +95,21 @@ def make_model(script: list[Any], keys=("k1", "k2", "k3"), pool: KeyPool | Nonereturn m, log, pool+def test_read_timeout_comes_from_settings(monkeypatch):+ """CV3D_MODEL_TIMEOUT_S raises the per-attempt HTTP read timeout (degraded-provider escape hatch)."""+ from codeverse.config import get_settings+ from codeverse.models.gemini import GeminiModel++ monkeypatch.setenv("GEMINI_API_KEYS", "k1")+ get_settings.cache_clear()+ assert GeminiModel("gemini-3.7-flash").timeout_s == 300.0+ monkeypatch.setenv("CV3D_MODEL_TIMEOUT_S", "900")+ get_settings.cache_clear()+ assert GeminiModel("gemini-3.7-flash").timeout_s == 900.0+ assert GeminiModel("gemini-3.7-flash", timeout_s=42.0).timeout_s == 42.0+ get_settings.cache_clear()++def test_text_usage_cost_and_raw():m, log, _ = make_model([text_response("hello")])r = m.generate(diff --git a/harness/tests/models/test_gemini_scheduling.py b/harness/tests/models/test_gemini_scheduling.pynew file mode 100644index 00000000..f13e04a5--- /dev/null+++ b/harness/tests/models/test_gemini_scheduling.py@@ -0,0 +1,148 @@+"""GeminiModel's side of TPM-aware scheduling and the shared storm gate.++Offline: the provider is a fake client, the pool is real, and nothing sleeps.+"""++from __future__ import annotations++import contextlib++from google.genai import errors as genai_errors++from codeverse.contracts.chat import ChatMessage, ChatRequest, ImagePart+from codeverse.models.gemini import GeminiModel, shared_pool+from codeverse.models.keypool import KeyPool+from codeverse.models.storm import StormGate+from codeverse.models.tokens import request_tokens+from tests.models.test_gemini import PNG_1PX, make_model, text_response+++def api_error(code: int, msg: str = "boom") -> genai_errors.APIError:+ return genai_errors.APIError(code, {"error": {"message": msg, "code": code}})+++# ------------------------------------------------------------------ estimates+def test_request_tokens_scales_with_the_prompt():+ small = ChatRequest(messages=[ChatMessage.user("caption this")])+ big = ChatRequest(messages=[ChatMessage.user("x" * 800_000)])+ assert request_tokens(small) < 100+ assert 150_000 < request_tokens(big) < 250_000+++def test_request_tokens_counts_system_tools_schema_and_images():+ plain = ChatRequest(messages=[ChatMessage.user("hi")])+ rich = ChatRequest(+ messages=[ChatMessage.user("hi", images=[ImagePart(data_b64="x", label="a")])],+ system="a system prompt that is quite long " * 20,+ response_schema={"type": "object", "properties": {"score": {"type": "number"}}},+ )+ assert request_tokens(rich) > request_tokens(plain) + 1000 # the image alone is ~1290+++def test_an_image_heavy_judge_request_reserves_far_more_than_a_caption():+ caption = ChatRequest(messages=[ChatMessage.user("name this object in three words")])+ verdict = ChatRequest(+ messages=[ChatMessage.user(+ "score this", images=[ImagePart(data_b64="x") for _ in range(5)])],+ system="rubric " * 5000,+ )+ assert request_tokens(verdict) > 30 * request_tokens(caption)+++# --------------------------------------------------------------- reservations+def test_generate_reserves_and_reconciles_tpm():+ pool = KeyPool(["k1"], tpm_per_key=1_000_000)+ m, _log, _ = make_model([text_response("hi")], pool=pool)+ before = pool._by_key["k1"].tpm.tokens # noqa: SLF001+ m.generate(ChatRequest(messages=[ChatMessage.user("y" * 40_000)]))+ after = pool._by_key["k1"].tpm.tokens # noqa: SLF001+ # the fake provider reports prompt_token_count=100, so the ~10k estimate is+ # refunded down to the real 100 (allow a little refill on the wall clock)+ assert before - after < 500, f"reservation was not reconciled: {before - after}"+++def test_a_failed_call_gives_its_reservation_back():+ pool = KeyPool(["k1", "k2"], tpm_per_key=1_000_000, cooldown_s=0.0)+ m, _log, _ = make_model([api_error(500), text_response("ok")], pool=pool, max_attempts=3)+ m.generate(ChatRequest(messages=[ChatMessage.user("z" * 40_000)]))+ total = sum(s.tpm.tokens for s in pool._states) # noqa: SLF001+ assert total > 2_000_000 - 5_000 # only the one real 100-token call was charged+++def test_in_flight_returns_to_zero_after_success_and_after_failure():+ pool = KeyPool(["k1", "k2"], cooldown_s=0.0)+ m, _log, _ = make_model([text_response("hi")], pool=pool)+ m.generate(ChatRequest(messages=[ChatMessage.user("hi")]))+ assert pool.stats()["in_flight"] == 0+ m2, _log2, _ = make_model([api_error(400, "bad request")], pool=pool, max_attempts=1)+ with contextlib.suppress(Exception): # the point is the gauge, not the error+ m2.generate(ChatRequest(messages=[ChatMessage.user("hi")]))+ assert pool.stats()["in_flight"] == 0+++# ---------------------------------------------------------------- shared pool+def test_shared_pool_is_keyed_by_quota_not_only_by_keys():+ a = shared_pool(["x1", "x2"], rpm_per_key=100, tpm_per_key=1000)+ b = shared_pool(["x1", "x2"], rpm_per_key=100, tpm_per_key=1000)+ c = shared_pool(["x1", "x2"], rpm_per_key=100, tpm_per_key=2000)+ assert a is b+ assert a is not c, "a different quota must not silently reuse another pool's buckets"+++def test_shared_pool_takes_its_defaults_from_settings():+ from codeverse.config import get_settings++ r = get_settings().rate+ pool = shared_pool(["y1"])+ st = pool.stats()+ assert st["rpm_capacity"] == r.rpm_per_key+ assert st["tpm_capacity"] == r.tpm_per_key+++# ----------------------------------------------------------------- storm gate+def test_a_503_closes_the_shared_gate_and_the_call_still_succeeds():+ gate = StormGate("test", base_delay=0.0, max_wait_s=0.0)+ pool = KeyPool(["k1", "k2"], cooldown_s=0.0)+ m, _log, _ = make_model([api_error(503, "high demand"), text_response("ok")],+ pool=pool, max_attempts=3)+ m.storm_gate = gate+ r = m.generate(ChatRequest(messages=[ChatMessage.user("hi")]))+ assert r.text == "ok"+ assert gate.n_hits == 1 and gate.n_storms == 1+ assert not gate.storming, "the success must reopen the gate"+++def test_the_gate_is_off_by_default_because_it_lost_its_ab():+ """docs/COST.md §21: the shared gate cost 45-56 % of throughput, so it ships off."""+ from codeverse.config import get_settings++ assert get_settings().rate.storm_gate is False+ assert GeminiModel("gemini-3.7-flash", keys=["z1"]).storm_gate is None+++def test_when_enabled_the_gate_is_shared_per_model(monkeypatch):+ from codeverse.config import Rate, get_settings++ s = get_settings()+ monkeypatch.setattr(s, "rate", Rate(storm_gate=True))+ a = GeminiModel("gemini-3.7-flash", keys=["z1"])+ b = GeminiModel("gemini-3.7-flash", keys=["z1"])+ c = GeminiModel("gemini-3.1-pro-preview", keys=["z1"])+ assert a.storm_gate is not None+ assert a.storm_gate is b.storm_gate+ assert a.storm_gate is not c.storm_gate+++def test_image_part_without_data_still_estimates():+ """request_tokens must never raise on a part the estimator cannot read."""+ req = ChatRequest(messages=[ChatMessage.user("hi", images=[ImagePart(path="/nope.png")])])+ assert request_tokens(req) > 1000+++def test_png_bytes_are_not_counted_as_text():+ """A base64 image is a flat per-image cost, not len(b64)/4 tokens."""+ import base64++ b64 = base64.b64encode(PNG_1PX * 500).decode()+ req = ChatRequest(messages=[ChatMessage.user("hi", images=[ImagePart(data_b64=b64)])])+ assert request_tokens(req) < 2000diff --git a/harness/tests/threejs_render/test_studio_rig.py b/harness/tests/threejs_render/test_studio_rig.pyindex cec6dbee..1b9847b8 100644--- a/harness/tests/threejs_render/test_studio_rig.py+++ b/harness/tests/threejs_render/test_studio_rig.py@@ -86,6 +86,8 @@ def test_studio_render_is_reproducible_and_stamps_the_rig_version(stool_glb: Patsheet=False, use_cache=False)meta = json.loads((tmp_path / "a" / "views.json").read_text())assert meta["rig_version"] == 2+ if a.renderer != b.renderer:+ pytest.skip(f"different GL backends between runs ({a.renderer} vs {b.renderer})")for va, vb in zip(a.views, b.views, strict=True):assert Path(va.path).read_bytes() == Path(vb.path).read_bytes(), f"{va.name} is not reproducible"@@ -102,8 +104,10 @@ def test_the_render_cache_still_hits_after_the_rig_change(stool_glb: Path, tmp_p@pytest.mark.nodedef test_orbit_views_share_one_camera_distance(stool_glb: Path, tmp_path: Path):- """Consistent framing: every view in the orbit band (|elevation| <= 60) sits at the- same distance, so the object does not change apparent size across the montage."""+ """Consistent framing: views in the orbit band (|elevation| <= 60) share one camera+ distance so the object keeps its apparent size across the montage — but no view is+ pulled back by more than 10 %, or a deep object shrinks every frame to what its+ widest side needs and the judge loses detail resolution."""from codeverse.conventions import OBJECT_VIEWSrender_glb(stool_glb, tmp_path / "o", views=OBJECT_VIEWS, width=192, height=192,@@ -113,7 +117,8 @@ def test_orbit_views_share_one_camera_distance(stool_glb: Path, tmp_path: Path):for v in meta["views"]:d = float(np.linalg.norm(np.array(v["camera_position"]) - np.array(v["look_at"])))(steep if abs(v["elevation"]) > 60 else band).append(d)- assert len(band) >= 4 and max(band) - min(band) < 1e-4 * max(band)+ assert len(band) >= 4+ assert max(band) / min(band) <= 1.10 + 1e-6, f"orbit distances spread too far: {sorted(band)}"assert steep, "OBJECT_VIEWS should still contain a plan view that fits itself"