Official Codebase of 3DCodeVerse
Python
docs: COST.md §24–26 of today renumbered to §27–29 (the file already had a §24 and a §25); references updated
gaoypeng8a9b29c6e749
diff --git a/harness/codeverse/agents/api_tools.py b/harness/codeverse/agents/api_tools.pyindex ef4bc1b8..9ffadd53 100644--- a/harness/codeverse/agents/api_tools.py+++ b/harness/codeverse/agents/api_tools.py@@ -130,7 +130,7 @@ class FileTools:def specs(self) -> list[ToolSpec]:roots = ", ".join(os.path.relpath(r, self.ws.root) + "/" for r in self.write_roots)# fewer_turns: the write result carries the verdict the agent used to fetch with a- # read_file round trip (docs/COST.md §26)+ # read_file round trip (docs/COST.md §29)no_readback = (" The result reports the line count and a syntax/lint verdict for that file: you do NOT ""need to read a file back after writing it."diff --git a/harness/codeverse/config.py b/harness/codeverse/config.pyindex a69c92f3..001dd62d 100644--- a/harness/codeverse/config.py+++ b/harness/codeverse/config.py@@ -93,7 +93,7 @@ class Limits(BaseModel):default=False,description="fold the cheap gates into `build`, report a per-file lint verdict from ""write_file / edit_file, inline the files a refine task edits, and ask the baseline "- "session for every file in its first turn (docs/COST.md §26). OFF until the A/B "+ "session for every file in its first turn (docs/COST.md §29). OFF until the A/B ""reads out; `CV3D_FEWER_TURNS=1` (read at call time by `fewer_turns_enabled`) is ""what `bench/ab_plan.py --variant-env` flips.",)@@ -137,7 +137,7 @@ class Rate(BaseModel):description="keys a retry is raced on once a call has met its first 503 (1 = off). Measured ""2026-08-26: a failed 503 costs the 21-50 s round-trip the provider holds before rejecting, ""storm streaks average 4.7 attempts, and a 503 bills nothing — so the hedge is free while it "- "storms and wastes one call only when both keys answer (docs/COST.md §24). "+ "storms and wastes one call only when both keys answer (docs/COST.md §27). ""CV3D_RATE__HEDGE=1 for the A/B.")@@ -150,7 +150,7 @@ class Judge(BaseModel):samples: int = Field(default=1, description="default VLM samples per verdict")-#: The fewer-turns switch (docs/COST.md §26). Read at CALL time by+#: The fewer-turns switch (docs/COST.md §29). Read at CALL time by#: :func:`fewer_turns_enabled`, never only through the cached Settings: ``bench/ab_plan.py``#: differs its arms by environment alone, and a value frozen at first ``get_settings()``#: would hand the variant the control's behaviour (the CQ-5 lesson, tracks/plan_features.py).diff --git a/harness/codeverse/languages/file_lint.py b/harness/codeverse/languages/file_lint.pyindex 093c1bd0..e4284c3a 100644--- a/harness/codeverse/languages/file_lint.py+++ b/harness/codeverse/languages/file_lint.py@@ -1,5 +1,5 @@"""One file, one cheap verdict — what ``write_file`` / ``edit_file`` hand back so the agent-never has to ``read_file`` its own output (docs/COST.md §26: ~35 read_file turns per run,+never has to ``read_file`` its own output (docs/COST.md §29: ~35 read_file turns per run,each a 4 s round trip carrying the whole context, to look at a file it wrote a turn ago).This is deliberately the language's OWN per-file lint, not a new rule set: the samediff --git a/harness/codeverse/models/gemini.py b/harness/codeverse/models/gemini.pyindex 645d5a82..82d38de6 100644--- a/harness/codeverse/models/gemini.py+++ b/harness/codeverse/models/gemini.py@@ -193,7 +193,7 @@ class GeminiModel:#: max_attempts, so max_attempts=1 alone still retried a 503 for up to 15 min.self.storm_attempts = storm_attempts#: keys a retry is raced on after the call's first 503 (``Settings.rate.hedge``,- #: 2; 1 = off) — see ``rotate_with_retries`` and docs/COST.md §24+ #: 2; 1 = off) — see ``rotate_with_retries`` and docs/COST.md §27self.hedge = max(1, int(_rate().hedge if hedge is None else hedge))keys = list(keys) if keys is not None else _default_keys()if pool is None and not keys:diff --git a/harness/codeverse/spatial/tools.py b/harness/codeverse/spatial/tools.pyindex a39ad102..abb6d9c1 100644--- a/harness/codeverse/spatial/tools.py+++ b/harness/codeverse/spatial/tools.py@@ -85,7 +85,7 @@ def _no_glb_summary(ctx: ToolContext, br: BuildResult, language: str) -> tuple[breturn True, lines, {"census": keep}-#: what `build` says about itself when the gates ride along (docs/COST.md §26): the agent+#: what `build` says about itself when the gates ride along (docs/COST.md §29): the agent#: must not spend two more round trips asking for what the build observation already holds._BUILD_INCLUDES_CHECKS = ("On success it ALSO runs check_connectivity and check_contract and reports them ""under CONNECTIVITY / CONTRACT — do not call those two tools separately.")@@ -97,7 +97,7 @@ def _folded_checks(ctx: ToolContext, glb: Path, m: Measurement, language: str) -"""The connectivity + contract gates as they would appear from their own tools, foldedinto the build observation: (lines, numbers). Each gate is a few hundred ms on abuilt GLB; each as a separate tool call was a 4 s round trip carrying the whole- context (docs/COST.md §26). Same checkers, same gate JSON files, same formatter."""+ context (docs/COST.md §29). Same checkers, same gate JSON files, same formatter."""ws = ctx.workspacelines: list[str] = []numbers: dict[str, Any] = {}diff --git a/harness/codeverse/tracks/plan_features.py b/harness/codeverse/tracks/plan_features.pyindex 8980c23a..645cf15d 100644--- a/harness/codeverse/tracks/plan_features.py+++ b/harness/codeverse/tracks/plan_features.py@@ -90,7 +90,7 @@ LIVE_SWITCHES: dict[str, str] = {"CV3D_SKILLS_MAX": "codeverse/skills/config.py","CV3D_SKILLS_UNVERIFIED": "codeverse/skills/config.py","CV3D_SKILLS_ONLY": "codeverse/skills/config.py",- # fewer turns (docs/COST.md §26): build folds the gates in, write_file lints, the refine+ # fewer turns (docs/COST.md §29): build folds the gates in, write_file lints, the refine# prompt inlines its files, the baseline prompt asks for every file in turn 1. One# switch, read at call time by config.fewer_turns_enabled; acts after planning."CV3D_FEWER_TURNS": "codeverse/config.py",diff --git a/harness/codeverse/tracks/prompting.py b/harness/codeverse/tracks/prompting.pyindex d7636240..1b4efc0e 100644--- a/harness/codeverse/tracks/prompting.py+++ b/harness/codeverse/tracks/prompting.py@@ -529,7 +529,7 @@ def measurement_vs_plan(return "\n".join(lines + gate_lines)-#: fewer_turns (docs/COST.md §26): the baseline session hit the 60-turn cap in every measured+#: fewer_turns (docs/COST.md §29): the baseline session hit the 60-turn cap in every measured#: run — 22.5 write_file + 8 build + 7.5 read_file + 4.6 check_connectivity + 4.1 check_contract#: per session, each a 4 s round trip re-sending a 35–70 k context. The cap itself is NOT the#: lever (§17: a 28-turn cap cost 0.205 of a score point); the block asks for fewer, fuller turns.@@ -543,7 +543,7 @@ TURN_DISCIPLINE = """## Turn discipline (every tool call is a full round trip- Call `render_sheet` once before you finish; `measure` at most once."""#: the refine prompt inlines the files a scoped task edits when they are few and small, so the-#: session's first turn is the edit, not a read_file (fewer_turns, docs/COST.md §26)+#: session's first turn is the edit, not a read_file (fewer_turns, docs/COST.md §29)INLINE_MAX_FILES = 3INLINE_MAX_CHARS = 12_000diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex aafc83da..8d0f84ac 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -107,7 +107,7 @@ codeverse/languages/ LanguageRuntime; blender/ (multi-file: layout.py, model.py + parts/*.py) cadquery/threejs/ (+ templates.py) urdf/ scene_threejs/ glsl_shader/ (wrap.py header+line-map)opengl_python/ (wrappers/run_gl.py) — each runtime.py, lint.py, skeleton.py, wrappers/;- file_lint.py (one just-written file → syntax/lint verdict for write_file, COST.md §26)+ file_lint.py (one just-written file → syntax/lint verdict for write_file, COST.md §29)spatial/ node.py, render.py, tool_common.py (shared tool plumbing), cookbook_tool.py(read_cookbook), render_scene.py (judge view subset, content-fitted orbit),frame_metrics.py (scene_frames gate), frame_motion.py (measured inter-frame motion),diff --git a/harness/docs/COST.md b/harness/docs/COST.mdindex fd3659e4..e2b6be34 100644--- a/harness/docs/COST.md+++ b/harness/docs/COST.md@@ -1202,7 +1202,7 @@ an API backend are not being held to the same ceiling, so compare them on`notional_usd`, never on `spent_usd`.-## 24. A 503 is per key at any instant — rotate before you wait (2026-08-26)+## 27. A 503 is per key at any instant — rotate before you wait (2026-08-26)The retry path treated Gemini's *"This model is currently experiencing high demand"* (503) asmodel-wide: no rotation, a ≤ 5 s sleep per storm attempt (60 of them), the 900 s per-call@@ -1266,7 +1266,7 @@ in `raw` and `attempts` on the raised `ModelError`; `cost/instrument.py` copiesdefaulted so old rows load); `3dcv cost` / `bench/cost_report.py` add a per-key table and a`tries/call` column (`CostBucket.attempts_per_call`) whenever the ledger carries them.-## 25. Where the time goes — the 2026-08-26 audit (`docs/TIME_AUDIT_2026-08-26.md`)+## 28. Where the time goes — the 2026-08-26 audit (`docs/TIME_AUDIT_2026-08-26.md`)51 storm-day runs against 52 baseline runs, every stage and every model call, scripts in`bench/time_audit/` (read-only over `bench/out`). The numbers that decide what to build next:@@ -1294,10 +1294,9 @@ remaining session / round budget (~1 430 s/run) — (2) hedge a 503 retry across(~900–1 400 s/run) — (3) hedge / cap the planner and judge calls (~400 s/run + the judge tail)— (4) plan cache on re-runs (548 s) — (5) no sleep on 503 (≤ 13 %; landed with §24) — (6) enforcethe ceiling inside a round (837 s sooner on killed runs) — (7) flash as the loop judge (~60 s-baseline) — (8) 30 s render cap (≤ 100 s). (1)–(3) and the key/attempt ledger fields are in-progress on branch `retry-budget`.+baseline) — (8) 30 s render cap (≤ 100 s). (1)–(3) and the key/attempt ledger fields landed the same afternoon (§27's follow-up paragraphs).-## 26. Fewer turns (in measurement) — `CV3D_FEWER_TURNS`, branch `fewer-turns`+## 29. Fewer turns (in measurement) — `CV3D_FEWER_TURNS`, branch `fewer-turns`static_v2_flash (20 blender object runs, healthy provider, api-agent gemini-3.7-flash): wall median1 047 s, of which 823 s (79 %) is model time = **196 flash calls per run** at 4.2 s mean (p50 2.8 s;diff --git a/harness/tests/orchestrator_tracks/test_fewer_turns.py b/harness/tests/orchestrator_tracks/test_fewer_turns.pyindex f75e8460..1d0e52f6 100644--- a/harness/tests/orchestrator_tracks/test_fewer_turns.py+++ b/harness/tests/orchestrator_tracks/test_fewer_turns.py@@ -1,4 +1,4 @@-"""``CV3D_FEWER_TURNS`` (docs/COST.md §26): the refine prompt carries the files it names, the+"""``CV3D_FEWER_TURNS`` (docs/COST.md §29): the refine prompt carries the files it names, thebaseline prompt asks for every file in turn one, and the control arm is byte-identical."""from __future__ import annotationsdiff --git a/harness/tests/spatial_tools/test_tools.py b/harness/tests/spatial_tools/test_tools.pyindex 869e3976..c8900bc9 100644--- a/harness/tests/spatial_tools/test_tools.py+++ b/harness/tests/spatial_tools/test_tools.py@@ -380,7 +380,7 @@ def _stool_plan_with_missing_backrest() -> StaticPlan:def test_build_folds_connectivity_and_contract_in_when_fewer_turns(stool_ctx: ToolContext, monkeypatch: pytest.MonkeyPatch) -> None:- """docs/COST.md §26: ~25 check_connectivity + ~19 check_contract calls per run, each a 4 s+ """docs/COST.md §29: ~25 check_connectivity + ~19 check_contract calls per run, each a 4 sround trip for a < 0.5 s check. With the switch on, one build observation carries both."""monkeypatch.setenv("CV3D_FEWER_TURNS", "1")ws = stool_ctx.workspace