Official Codebase of 3DCodeVerse
Python
config: CV3D_MAX_IN_FLIGHT was read by nothing; and a "no-retry" probe retried a 503 sixty times
gaoypengba7c4f5b22ff
diff --git a/harness/codeverse/cli/doctor.py b/harness/codeverse/cli/doctor.pyindex f4d84b81..38087906 100644--- a/harness/codeverse/cli/doctor.py+++ b/harness/codeverse/cli/doctor.py@@ -190,7 +190,7 @@ def check_keys(live: bool) -> list[Row]:"OK" if sib == 0 else "WARN",f"{sib} other harness process(es) running — each keeps its OWN key pool, so the real "f"concurrency is ~{(sib + 1) * cap} in-flight against one shared quota "- f"(docs/COST.md §23; run one battery at a time or set CV3D_RATE__MAX_IN_FLIGHT={max(1, cap // (sib + 1))})"+ f"(docs/COST.md §23; run one battery at a time or set CV3D_MAX_IN_FLIGHT={max(1, cap // (sib + 1))})"if sib else "sole harness process: max_in_flight applies as configured",))rows.append(("anthropic key", "OK" if s.anthropic_api_key else "WARN", "set" if s.anthropic_api_key else "not set (anthropic:* backends unavailable)"))diff --git a/harness/codeverse/config.py b/harness/codeverse/config.pyindex 2ea6cb8f..b5f91be6 100644--- a/harness/codeverse/config.py+++ b/harness/codeverse/config.py@@ -15,10 +15,10 @@ import reimport shutilfrom functools import lru_cachefrom pathlib import Path-from typing import Any+from typing import Any, ClassVarimport yaml-from pydantic import BaseModel, Field+from pydantic import BaseModel, Field, model_validatorfrom pydantic_settings import BaseSettings, SettingsConfigDictfrom codeverse.contracts.common import Backends@@ -121,6 +121,28 @@ class Judge(BaseModel):class Settings(BaseSettings):model_config = SettingsConfigDict(env_prefix="CV3D_", env_nested_delimiter="__", extra="ignore")+ #: Flat aliases for nested knobs people actually type. ``CV3D_MAX_IN_FLIGHT=16`` was+ #: written into three launch commands and two workflow briefs on 2026-08-24 before anyone+ #: noticed pydantic-settings only reads ``CV3D_RATE__MAX_IN_FLIGHT`` — every one of them+ #: silently ran at the default 64. An env knob that is read by nothing is worse than no+ #: knob; both spellings now work and the doctor prints the short one.+ _FLAT_ALIASES: ClassVar[dict[str, tuple[str, str]]] = {+ "CV3D_MAX_IN_FLIGHT": ("rate", "max_in_flight"),+ }++ @model_validator(mode="after")+ def _apply_flat_aliases(self) -> Settings:+ for env, (section, field) in self._FLAT_ALIASES.items():+ raw = os.environ.get(env)+ if raw is None or raw.strip() == "":+ continue+ try:+ value = int(raw)+ except ValueError as e:+ raise ValueError(f"{env}={raw!r}: expected an integer") from e+ setattr(getattr(self, section), field, value)+ return self+runs_dir: Path = Field(default=Path("runs"))cache_dir: Path = Field(default=Path.home() / ".cache" / "codeverse")binaries: Binaries = Field(default_factory=Binaries)diff --git a/harness/codeverse/models/gemini.py b/harness/codeverse/models/gemini.pyindex 5bc917f1..e53410ae 100644--- a/harness/codeverse/models/gemini.py+++ b/harness/codeverse/models/gemini.py@@ -182,10 +182,15 @@ class GeminiModel:rpm_per_key: int | None = None,tpm_per_key: int | None = None,storm_gate: StormGate | None = None,+ storm_attempts: int | None = None,sleep: Callable[[float], None] = time.sleep,client_factory: Callable[[str], Any] | None = None,) -> None:self.model = model+ #: None = rotate_with_retries' default (60). 0 = a 503 is final: for probes,+ #: whose whole point is a fast verdict — the storm branch does NOT consume+ #: max_attempts, so max_attempts=1 alone still retried a 503 for up to 15 min.+ self.storm_attempts = storm_attemptskeys = list(keys) if keys is not None else _default_keys()if pool is None and not keys:raise ModelError(@@ -255,6 +260,7 @@ class GeminiModel:tokens_hint=request_tokens(request, model_id=self.id),storm_gate=self.storm_gate,label=f"gemini {self.model}",+ **({} if self.storm_attempts is None else {"storm_attempts": self.storm_attempts}),)def _config(self, request: ChatRequest, warnings: list[str]) -> types.GenerateContentConfig:diff --git a/harness/codeverse/models/health.py b/harness/codeverse/models/health.pyindex c04ecada..aaf62cde 100644--- a/harness/codeverse/models/health.py+++ b/harness/codeverse/models/health.py@@ -106,7 +106,7 @@ def _bare_model(model_id: str, timeout_s: float):if provider == "gemini":from codeverse.models.gemini import GeminiModel- return GeminiModel(name, timeout_s=timeout_s, max_attempts=1)+ return GeminiModel(name, timeout_s=timeout_s, max_attempts=1, storm_attempts=0)from codeverse.models import get_chat_model # other providers: no bare constructor needed yetreturn get_chat_model(model_id)diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex eba24e93..d43c507e 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -131,6 +131,8 @@ codeverse/brief.py (cached EngineeringBrief: one cheap call turns a one-line prompt intoreal dimensions / sub-assemblies / signature features; never fatal, CV3D_PLAN_BRIEF),plan_budget.py (plan size derived from the request, capped per language),+ plan_features.py (CV3D_PLAN_FEATURES: one switch per plan-loop change, so each+ can be A/B'd alone — docs/PLAN_LOOP.md),plan_examples.py (worked plans shown to the planner), depth.py + detailing.py(per-part detail pass), envelope.py (bbox envelope), scene_asset_gen.pyflywheel/ record.py, export.py, pack.py, sample.py, pairs.py, migrate.py (schema moves),diff --git a/harness/docs/COST.md b/harness/docs/COST.mdindex 39277867..a46880da 100644--- a/harness/docs/COST.md+++ b/harness/docs/COST.md@@ -1081,9 +1081,12 @@ Three consequences:latency and its siblings took the capacity it freed. The gate was measured in asetting where it could not win. Its negative result stands for the configurationtested and should NOT be read as "back-pressure does not help".-3. **Operational rule until a cross-process limiter exists**: run ONE battery at a time,- or set `CV3D_RATE__MAX_IN_FLIGHT` (the name `Settings.rate` actually reads; the flat- `CV3D_MAX_IN_FLIGHT` is read by nothing) to `64 / (concurrent processes)`.+3. **Operational rule until a cross-process limiter exists**: keep the SUM of+ `max_in_flight` across every harness process on the machine at or below the measured+ knee (64). One battery at 64, or N batteries at `64 / N` each via+ `CV3D_MAX_IN_FLIGHT=<n>` (`CV3D_RATE__MAX_IN_FLIGHT` is the same knob; the flat name was+ read by nothing until 2026-08-24 — three launches that "set" it ran at 64). `3dcv doctor`'s+ `pool sharing` row prints the current sibling count and the value to use.The real fix is a machine-wide limiter — a file-locked token bucket under`~/.cache/codeverse/` that every process shares — so the quota is enforced where itdiff --git a/harness/tests/core/test_config_env_aliases.py b/harness/tests/core/test_config_env_aliases.pynew file mode 100644index 00000000..3bb80a39--- /dev/null+++ b/harness/tests/core/test_config_env_aliases.py@@ -0,0 +1,51 @@+"""Flat env aliases for nested settings (codeverse/config.py Settings._FLAT_ALIASES).++Regression (2026-08-24): ``CV3D_MAX_IN_FLIGHT=16`` was written into three battery launches+and two workflow briefs, and pydantic-settings only read ``CV3D_RATE__MAX_IN_FLIGHT`` — so+every one of them silently ran at the default 64 while docs/COST.md §23 was telling people+to set it. An env knob that is read by nothing is worse than no knob.+"""++from __future__ import annotations++import pytest++from codeverse.config import Settings+++def test_flat_alias_sets_the_nested_field(monkeypatch):+ monkeypatch.delenv("CV3D_RATE__MAX_IN_FLIGHT", raising=False)+ monkeypatch.setenv("CV3D_MAX_IN_FLIGHT", "16")+ assert Settings().rate.max_in_flight == 16+++def test_nested_name_still_works(monkeypatch):+ monkeypatch.delenv("CV3D_MAX_IN_FLIGHT", raising=False)+ monkeypatch.setenv("CV3D_RATE__MAX_IN_FLIGHT", "24")+ assert Settings().rate.max_in_flight == 24+++def test_flat_alias_wins_when_both_are_set(monkeypatch):+ """The short name is what the doctor prints and what people type; if both are present+ the one a person set on the command line should win."""+ monkeypatch.setenv("CV3D_RATE__MAX_IN_FLIGHT", "24")+ monkeypatch.setenv("CV3D_MAX_IN_FLIGHT", "8")+ assert Settings().rate.max_in_flight == 8+++def test_empty_alias_is_ignored_and_garbage_is_loud(monkeypatch):+ monkeypatch.delenv("CV3D_RATE__MAX_IN_FLIGHT", raising=False)+ monkeypatch.setenv("CV3D_MAX_IN_FLIGHT", "")+ assert Settings().rate.max_in_flight == 64+ monkeypatch.setenv("CV3D_MAX_IN_FLIGHT", "sixteen")+ with pytest.raises(ValueError, match="CV3D_MAX_IN_FLIGHT"):+ Settings()+++def test_doctor_prints_a_name_that_is_actually_read():+ """The `pool sharing` row tells people which env var to set; it must be one that works."""+ from pathlib import Path++ src = (Path(__file__).resolve().parents[2] / "codeverse" / "cli" / "doctor.py").read_text()+ assert "CV3D_MAX_IN_FLIGHT=" in src+ assert "CV3D_MAX_IN_FLIGHT" in Settings._FLAT_ALIASESdiff --git a/harness/tests/models/test_health.py b/harness/tests/models/test_health.pyindex bc994c3a..c4c34a5e 100644--- a/harness/tests/models/test_health.py+++ b/harness/tests/models/test_health.py@@ -86,3 +86,30 @@ def test_sibling_count_never_raises(monkeypatch):monkeypatch.setattr(Path, "iterdir", boom)assert health.sibling_processes() == 0+++def test_probe_model_treats_a_503_as_final(monkeypatch):+ """"No retries" must include the storm branch. rotate_with_retries' capacity-storm+ branch does NOT consume max_attempts, so max_attempts=1 alone still retried a 503+ up to 60 times (bounded only by the 900 s deadline) — a "30-second" probe that could+ take 15 minutes. Observed 2026-08-24 in the parked compare_v2 preflight log."""+ import codeverse.models.gemini as gm+ from codeverse.models.health import _bare_model++ captured: dict = {}++ def fake_rotate(pool, call, **kw):+ captured.update(kw)+ return "unused"++ monkeypatch.setattr(gm, "rotate_with_retries", fake_rotate)+ m = _bare_model("gemini:gemini-3.7-flash", 30.0)+ assert m.storm_attempts == 0 and m.max_attempts == 1+ import contextlib++ from codeverse.contracts.chat import ChatMessage, ChatRequest++ with contextlib.suppress(Exception): # the fake returns a non-response; only the kwargs matter+ m.generate(ChatRequest(messages=[ChatMessage.user("pong")], max_output_tokens=8))+ assert captured.get("storm_attempts") == 0, captured.keys()+ assert captured.get("max_attempts") == 1