Skip to content

Official Codebase of 3DCodeVerse

Python

budget: remove the cost ceiling from the harness

gaoypeng562795bb9f6a
diff --git a/harness/CLAUDE.md b/harness/CLAUDE.md
index db19485e..c24fadab 100644
--- a/harness/CLAUDE.md
+++ b/harness/CLAUDE.md
@@ -85,7 +85,10 @@ cd /home/yipeng/3dcodeverse/harness
3dcodeverse make "..." --profile economy|balanced|quality # one dial: models, judge n, rounds, candidates, texture, ceilings (--profile == CV3D_PROFILE)
3dcodeverse make "..." --track static_object --language threejs --generator gemini-cli:gemini-3.7-flash
3dcodeverse make "..." --track articulated_object --language urdf_blender
-3dcodeverse make "..." --track scene --language scene_threejs --rounds 2 # --max-usd is OFF by default (0 = no ceiling); cost is still recorded
+3dcodeverse make "..." --track scene --language scene_threejs --rounds 2 --max-minutes 60
+# There is NO cost ceiling and no --max-usd (owner, 2026-08-28: run first, count later).
+# Cost is still priced onto every call — 3dcv cost, the ledger and the run record are
+# untouched; --max-minutes / --rounds are what bound a run.
3dcodeverse make "neon rain on a window" --track graphics --language glsl_shader
3dcodeverse make "..." --image ref.png --candidates 3 --rounds 2 --dim height=0.45 --must "three legs" --texture --no-run
3dcv resume <slug> · 3dcv status <slug> · 3dcv render <slug> [--mode wire] · 3dcv judge <slug> [--model ... --n 3]
diff --git a/harness/bench/_compare_report.py b/harness/bench/_compare_report.py
index 8fb1984d..c35b5cbe 100644
--- a/harness/bench/_compare_report.py
+++ b/harness/bench/_compare_report.py
@@ -237,7 +237,7 @@ def compare_markdown(out: Path, rows: list[CellResult], pairs: list[PairRow], me
md = [f"# harness vs one-shot — {meta.get('battery', {}).get('name', out.name)}", "",
f"fixed judge: **{opts.get('judge', '?')}** (rubric {battery_rubric(meta)}, n_samples={opts.get('n_samples', 2)}, "
f"acceptance = must_have list) · harness loop judge: {opts.get('loop_judge') or 'settings default'} · "
- f"harness rounds ≤ {opts.get('rounds', '?')}, ≤ ${opts.get('max_usd', '?')} · cells: {len(rows)}", "",
+ f"harness rounds ≤ {opts.get('rounds', '?')} · cells: {len(rows)}", "",
"Every arm's final `src/model.py` is re-built, re-rendered and judged by the same evaluator; a failed "
"build scores 0. `$gen` for harness arms is the whole run (planner + generator + its loop judge); for "
"one-shot arms it is the single call (subscription CLIs report 0 unless the CLI returns a cost). "
diff --git a/harness/bench/_infra.py b/harness/bench/_infra.py
index abe920a2..6da1e984 100644
--- a/harness/bench/_infra.py
+++ b/harness/bench/_infra.py
@@ -117,11 +117,13 @@ def is_infra_failure(err: object) -> bool:
return False
-#: a run that hit its wall-clock / dollar ceiling before producing anything. Distinct
-#: from an outage: we DID ask the model, it just never delivered inside the budget.
+#: a run that hit its ceiling before producing anything. Distinct from an outage: we DID
+#: ask the model, it just never delivered inside the budget. ``max_usd`` stays in the
+#: list although the money ceiling was removed on 2026-08-28 — recorded runs from before
+#: then still carry that wording, and this classifier reads history.
BUDGET_MARKERS: tuple[str, ...] = (
"exceeds max_minutes",
- "exceeds max_usd",
+ "exceeds max_usd", # historical runs only
"budget exhausted",
"wall-clock ceiling",
)
diff --git a/harness/bench/ab_plan.py b/harness/bench/ab_plan.py
index 811a1c05..1837c96f 100644
--- a/harness/bench/ab_plan.py
+++ b/harness/bench/ab_plan.py
@@ -137,7 +137,6 @@ class AbOptions(BaseModel):
default=None, description="planner for BOTH arms (None → settings default)"
)
rounds: int = 2
- max_usd: float = 2.5
max_minutes: float = 45.0
n_samples: int = 2
ids: list[str] = Field(default_factory=list)
@@ -171,7 +170,6 @@ class AbOptions(BaseModel):
loop_judge=self.loop_judge,
planner=self.planner,
rounds=self.rounds,
- max_usd=self.max_usd,
max_minutes=self.max_minutes,
n_samples=self.n_samples,
resume=self.resume,
@@ -655,7 +653,6 @@ def main(argv: Sequence[str] | None = None) -> int:
loop_judge=ns.loop_judge,
planner=ns.planner,
rounds=ns.rounds,
- max_usd=ns.max_usd,
max_minutes=ns.max_minutes,
n_samples=ns.n_samples,
ids=[i for i in ns.ids.split(",") if i],
diff --git a/harness/bench/compare_backends.py b/harness/bench/compare_backends.py
index 5bc4c3bc..38c8646b 100644
--- a/harness/bench/compare_backends.py
+++ b/harness/bench/compare_backends.py
@@ -82,7 +82,7 @@ from bench.run_bench import ( # noqa: E402
)
from codeverse.config import get_settings # noqa: E402
from codeverse.contracts.artifacts import RenderSet # noqa: E402
-from codeverse.contracts.common import ENTRY_FILE, has_money_ceiling # noqa: E402
+from codeverse.contracts.common import ENTRY_FILE # noqa: E402
from codeverse.contracts.run import RunRecord # noqa: E402
from codeverse.contracts.spec import Spec # noqa: E402
from codeverse.cost import run_ledger # noqa: E402
@@ -130,7 +130,6 @@ class CompareOptions(BaseModel):
loop_judge: str | None = Field(default=None, description="harness in-loop judge (None → settings default)")
planner: str | None = None
rounds: int = 3
- max_usd: float = 2.5
max_minutes: float = 45.0
parallel: int = 8 # measured knee, see BenchOptions.parallel / docs/COST.md Part III
limit: int | None = None
@@ -149,7 +148,7 @@ class CompareOptions(BaseModel):
def spec_for(battery: Battery, item: BenchPrompt, arm: Arm, opts: CompareOptions) -> Spec:
generator = arm.target if arm.kind == "harness" else f"single-shot:{arm.target}"
backends = get_settings().backends(generator=generator, judge=opts.loop_judge, planner=opts.planner)
- return build_spec(battery, item, backends=backends, rounds=opts.rounds, max_usd=opts.max_usd,
+ return build_spec(battery, item, backends=backends, rounds=opts.rounds,
max_minutes=opts.max_minutes, tag0="compare", extra_tags=(arm.kind,))
@@ -339,15 +338,14 @@ def flag_degraded(res: CellResult, opts: CompareOptions) -> None:
"""
if res.kind != "harness" or res.status not in ("scored", "build_failed"):
return
- # ``max_usd == 0`` is "no ceiling", so there is no such thing as a money stop —
- # without this guard the comparison is `cost >= 0`, true for every cell, and the
- # degraded flag this function exists to raise never fires again.
- money_stop = has_money_ceiling(opts.max_usd) and res.gen_cost_usd >= 0.9 * opts.max_usd
- if (res.harness_stop_reason == "budget" and not money_stop and res.harness_rounds <= opts.degraded_max_rounds
+ # There is no money ceiling any more (2026-08-28), so a "budget" stop is always the
+ # clock — which is exactly the case this flag was written for. The old money_stop
+ # test is gone with the ceiling it read.
+ if (res.harness_stop_reason == "budget" and res.harness_rounds <= opts.degraded_max_rounds
and res.wall_s >= opts.degraded_min_wall_s):
res.degraded = True
res.degraded_reason = (f"ceiling stop after {res.harness_rounds} completed round(s) in {res.wall_s / 60:.0f} min "
- f"with ${opts.max_usd - res.gen_cost_usd:.2f} of the budget unspent")
+ f"having spent ${res.gen_cost_usd:.2f}")
def _fill_from_outcome(res: CellResult, o: EvalOutcome) -> None:
@@ -538,7 +536,7 @@ def main(argv: Sequence[str] | None = None) -> int:
if ns.report_only:
build_compare_report(Path(ns.out))
return 0
- opts = CompareOptions(judge=ns.judge, loop_judge=ns.loop_judge, rounds=ns.rounds, max_usd=ns.max_usd,
+ opts = CompareOptions(judge=ns.judge, loop_judge=ns.loop_judge, rounds=ns.rounds,
max_minutes=ns.max_minutes, parallel=ns.parallel,
limit=ns.limit, ids=[i for i in ns.ids.split(",") if i],
tiers=[t for t in ns.tiers.split(",") if t], resume=not ns.no_resume,
diff --git a/harness/bench/run_bench.py b/harness/bench/run_bench.py
index 028b3a84..4d546aa9 100644
--- a/harness/bench/run_bench.py
+++ b/harness/bench/run_bench.py
@@ -98,7 +98,6 @@ class BenchOptions(BaseModel):
planner: str | None = None
judge: str | None = None
rounds: int = 4
- max_usd: float = 0.0 # 0 = no money ceiling; cost is still recorded (contracts.common)
max_minutes: float = 60.0
#: 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
@@ -146,7 +145,7 @@ def discover_references(item: BenchPrompt, track: Track, *, battery_dir: Path |
def build_spec(
- battery: Battery, item: BenchPrompt, *, backends: Backends, rounds: int, max_usd: float,
+ battery: Battery, item: BenchPrompt, *, backends: Backends, rounds: int,
max_minutes: float, tag0: str, extra_tags: Sequence[str] = (),
) -> Spec:
"""Shared Spec core for bench drivers (``run_bench`` / ``compare_backends``).
@@ -155,14 +154,14 @@ def build_spec(
id=f"{battery.name}/{item.id}", track=battery.track, language=item.language or battery.language, prompt=item.prompt,
constraints=Constraints(must_have=list(item.must_have), dimensions_m=item.dimensions_m),
references=discover_references(item, battery.track, battery_dir=battery.source_dir),
- budget=Budget(max_rounds=rounds, max_usd=max_usd, max_minutes=max_minutes),
+ budget=Budget(max_rounds=rounds, max_minutes=max_minutes),
backends=backends, tags=[tag0, battery.name, item.tier, item.category, *extra_tags, *item.tags],
)
def spec_for(battery: Battery, item: BenchPrompt, opts: BenchOptions) -> Spec:
backends = get_settings().backends(generator=opts.generator, planner=opts.planner, judge=opts.judge)
- return build_spec(battery, item, backends=backends, rounds=opts.rounds, max_usd=opts.max_usd,
+ return build_spec(battery, item, backends=backends, rounds=opts.rounds,
max_minutes=opts.max_minutes, tag0="bench")
diff --git a/harness/codeverse/cli/_common.py b/harness/codeverse/cli/_common.py
index 992b0657..d313032e 100644
--- a/harness/codeverse/cli/_common.py
+++ b/harness/codeverse/cli/_common.py
@@ -259,7 +259,6 @@ class ResolvedDial:
rounds: int
candidates: int
texture: bool
- max_usd: float
max_minutes: float
@@ -269,7 +268,6 @@ def resolve_dial(
*,
rounds: int | None = None,
candidates: int | None = None,
- max_usd: float | None = None,
max_minutes: float | None = None,
texture: bool = False,
) -> ResolvedDial:
@@ -305,7 +303,6 @@ def resolve_dial(
rounds=prof.rounds if rounds is None else int(rounds),
candidates=int(settings.default_candidates if candidates is None else candidates),
texture=bool(texture or prof.texture),
- max_usd=prof.max_usd if max_usd is None else float(max_usd),
max_minutes=prof.max_minutes if max_minutes is None else float(max_minutes),
)
diff --git a/harness/codeverse/cli/cost_cmd.py b/harness/codeverse/cli/cost_cmd.py
index 33945bc6..82bb8902 100644
--- a/harness/codeverse/cli/cost_cmd.py
+++ b/harness/codeverse/cli/cost_cmd.py
@@ -129,7 +129,6 @@ def _single_run_lines(run: object) -> None:
"record.total_usage": f"${recorded:.4f}",
"difference": f"${drift:+.4f} ({pct:+.2f}%)",
"status": f"{getattr(run, 'status', '')} ({getattr(run, 'stop_reason', '')})",
- "budget": f"${float(getattr(run, 'budget_usd', 0.0)):.2f}",
}
console.print("")
console.print(kv_table("reconciliation", rows))
diff --git a/harness/codeverse/cli/layout_cmd.py b/harness/codeverse/cli/layout_cmd.py
index f24687b0..c9ded1d5 100644
--- a/harness/codeverse/cli/layout_cmd.py
+++ b/harness/codeverse/cli/layout_cmd.py
@@ -176,8 +176,7 @@ def print_cost_and_settings(ws: Workspace, record: RunRecord) -> None:
cost, settings = tele.cost, tele.settings
if cost is not None:
u = cost.tokens
- budget_line = (f"{fmt_usd(cost.total_usd)} of {fmt_usd(cost.budget_usd)}"
- f"{'' if cost.budget_used_pct is None else f' ({cost.budget_used_pct:.0f}%)'}")
+ budget_line = fmt_usd(cost.total_usd)
console.print(kv_table("cost", {
"spent / budget": budget_line,
"wall clock": f"{cost.wall_clock_s / 60:.1f} min of {cost.max_minutes:.0f} min",
diff --git a/harness/codeverse/cli/main.py b/harness/codeverse/cli/main.py
index 38936ddb..bae9b6c8 100644
--- a/harness/codeverse/cli/main.py
+++ b/harness/codeverse/cli/main.py
@@ -104,7 +104,6 @@ def run_cmd(
judge: Annotated[str | None, typer.Option("--judge", help="fixed judge model for the whole battery")] = None,
parallel: Annotated[int, typer.Option("--parallel", min=1)] = 4,
rounds: Annotated[int, typer.Option("--rounds", min=0)] = 4,
- max_usd: Annotated[float, typer.Option("--max-usd", help="0 = no ceiling (cost is still recorded)")] = 0.0,
max_minutes: Annotated[float, typer.Option("--max-minutes", help="wall-clock budget per run; size it to the weather "
"(RUNBOOK 7.x: 120 in a 503 storm, else runs burn the hour with no judged round)")] = 60.0,
limit: Annotated[int | None, typer.Option("--limit")] = None,
@@ -120,7 +119,7 @@ def run_cmd(
raise C.CliError(f"battery not found: {battery}")
b = C.import_bench()
run_bench = C.lazy("bench.run_bench")
- opts = run_bench.BenchOptions(generator=generator, planner=planner, judge=judge, rounds=rounds, max_usd=max_usd, max_minutes=max_minutes,
+ opts = run_bench.BenchOptions(generator=generator, planner=planner, judge=judge, rounds=rounds, max_minutes=max_minutes,
parallel=parallel, limit=limit, ids=ids or [], tiers=tiers or [], resume=not no_resume,
redo_status=[x for x in redo_status.split(",") if x])
out_dir = out or (C.REPO_ROOT / "bench" / "out" / battery.stem)
@@ -349,7 +348,6 @@ def make(
"--rounds", min=0, help="refine rounds after the baseline (default: the profile's)"
),
] = None,
- max_usd: Annotated[float | None, typer.Option("--max-usd", min=0)] = None,
max_minutes: Annotated[float | None, typer.Option("--max-minutes", min=0)] = None,
candidates: Annotated[
int | None,
@@ -406,11 +404,10 @@ def make(
profile,
rounds=rounds,
candidates=candidates,
- max_usd=max_usd,
max_minutes=max_minutes,
texture=texture,
)
- rounds, max_usd, max_minutes = dial.rounds, dial.max_usd, dial.max_minutes
+ rounds, max_minutes = dial.rounds, dial.max_minutes
candidates, texture = dial.candidates, dial.texture
# A run must not record and display a pass it cannot run. `3dcv texture pass` already
# refuses non-object tracks; `3dcv make` accepted --texture (and --profile quality,
@@ -443,7 +440,7 @@ def make(
must_not=must_not,
style=style,
),
- budget=Budget(max_rounds=rounds, max_usd=max_usd, max_minutes=max_minutes),
+ budget=Budget(max_rounds=rounds, max_minutes=max_minutes),
# options.profile records the dial this run resolved to, whichever way it was
# named (flag, CV3D_PROFILE, config.yaml), so `3dcv resume` re-applies it
backends=backends,
@@ -473,7 +470,6 @@ def make(
"judge": f"{backends.judge} n={dial.judge_samples} "
f"({dial.judge_max_px}px/{dial.judge_detail_crops}crop)",
"rounds": rounds,
- "max_usd": max_usd,
"candidates": candidates,
"texture": texture,
},
@@ -600,14 +596,6 @@ def resume(
"--candidates", min=1, help="best-of-N baseline width (only matters before round 0 ran)"
),
] = None,
- max_usd: Annotated[
- float | None,
- typer.Option(
- "--max-usd", min=0,
- help="raise the budget cap before resuming (rewrites spec.json; prior spend is "
- "restored on resume, so the run gets the new cap MINUS what it already spent)",
- ),
- ] = None,
max_minutes: Annotated[
float | None,
typer.Option("--max-minutes", min=0, help="raise the time cap before resuming"),
@@ -645,7 +633,7 @@ def resume(
raise C.CliError(f"{ws.spec_path}: {e}", code=2) from e
raised = {
k: v
- for k, v in {"max_usd": max_usd, "max_minutes": max_minutes, "max_rounds": rounds}.items()
+ for k, v in {"max_minutes": max_minutes, "max_rounds": rounds}.items()
if v is not None
}
if not force and (why := _finished_reason(ws, raised)):
diff --git a/harness/codeverse/contracts/common.py b/harness/codeverse/contracts/common.py
index abd39335..5a690e1f 100644
--- a/harness/codeverse/contracts/common.py
+++ b/harness/codeverse/contracts/common.py
@@ -128,17 +128,6 @@ class Usage(BaseModel):
)
-def has_money_ceiling(max_usd: float) -> bool:
- """Is there a money ceiling at all? ``max_usd == 0`` means no (owner, 2026-08-28).
-
- Ask this BEFORE comparing a cost against a ceiling. Without it the comparison
- silently inverts: ``spent >= 0.9 * 0`` is true for every non-negative cost, so a
- guard written as "did we stop for money?" answers yes always and the thing it
- protects never fires. That is exactly what happened to bench's degraded-cell flag.
- """
- return max_usd > 0
-
-
class Budget(BaseModel):
"""Hard ceilings for a run. The orchestrator stops (cleanly) when any is hit.
@@ -147,15 +136,14 @@ class Budget(BaseModel):
token is spent and ``grant_grace`` cannot lift a hard ceiling back above zero —
so the workspace and the git-committed spec are created for a run that can only die.
- ``max_usd = 0`` means NO MONEY CEILING, and that is the default (owner, 2026-08-28:
- "先不计成本,就是run就好了"). Cost is still measured on every call — the ledger,
- `3dcv cost`, the run record and the bench economics are untouched; money simply
- stops being a thing that can end a run. Pass ``--max-usd`` to put the ceiling back.
- Time still bounds a run: that is ``max_minutes``, and without it nothing ends.
+ There is NO money ceiling and no way to set one (owner, 2026-08-28: run first, count
+ later). Cost is still measured on every call — the ledger, ``3dcv cost``, the run
+ record and the bench economics are untouched — it simply cannot end a run. What
+ bounds a run is ``max_rounds`` and ``max_minutes``; a spec.json written before the
+ removal still loads, its money ceiling ignored (pydantic drops the unknown field).
"""
max_rounds: int = Field(default=4, ge=0)
- max_usd: float = Field(default=0.0, ge=0, description="0 = no ceiling (cost is still recorded)")
max_minutes: float = Field(default=60.0, ge=0)
max_repair_attempts: int = Field(default=3, ge=0) # per build failure before escalating
diff --git a/harness/codeverse/contracts/run.py b/harness/codeverse/contracts/run.py
index 2dfbd6a1..8b6b409b 100644
--- a/harness/codeverse/contracts/run.py
+++ b/harness/codeverse/contracts/run.py
@@ -210,7 +210,7 @@ class SettingsSnapshot(BaseModel):
schema_version: int = 1
roles: list[RoleSettings] = Field(default_factory=list)
- budget: dict[str, Any] = Field(default_factory=dict, description="max_rounds / max_usd / max_minutes / max_repair_attempts")
+ budget: dict[str, Any] = Field(default_factory=dict, description="max_rounds / max_minutes / max_repair_attempts")
candidates: int | None = Field(default=None, description="best-of-N baseline width, resolved")
texture: bool = False
seed: int = 0
@@ -244,8 +244,6 @@ class CostSummary(BaseModel):
schema_version: int = 1
total_usd: float = 0.0
- budget_usd: float = 0.0
- budget_used_pct: float | None = None
wall_clock_s: float = 0.0
max_minutes: float = 0.0
n_calls: int = 0
diff --git a/harness/codeverse/cost/profiles.py b/harness/codeverse/cost/profiles.py
index 7bab4a9a..72e51a12 100644
--- a/harness/codeverse/cost/profiles.py
+++ b/harness/codeverse/cost/profiles.py
@@ -66,7 +66,6 @@ class Profile:
# NOT reduced by any profile — the score effect is inside the
# judge's own noise in both directions (docs/COST.md §14)
#: budget ceilings a run of this shape should not need to exceed
- max_usd: float = 0.0 # 0 = no ceiling; cost is still recorded
max_minutes: float = 60.0
#: measured expectation (docs/COST.md) — reported by ``3dcv cost profiles``
expected_usd: float = 0.0
@@ -109,7 +108,7 @@ PROFILES: dict[str, Profile] = {
# the instrument's noise do not license a payload cut worth a fifth of a cent, so the
# experiment is recorded as INCONCLUSIVE in docs/COST.md §14 and the budget is unchanged.
judge_max_px=1024, judge_montages=3, judge_detail_crops=2,
- max_usd=0.0, max_minutes=30.0,
+ max_minutes=30.0,
expected_usd=0.30,
expected_score="graphics 0.81 median (5/6 passed); objects clear the gates less often "
"— a one-shot flash generator scored 0.14 on compare_v1's hard cells",
@@ -124,7 +123,7 @@ PROFILES: dict[str, Profile] = {
captioner="gemini:gemini-3.7-flash",
rounds=4, candidates=1, judge_samples=1, max_turns=0, texture=False,
judge_max_px=1024, judge_montages=3, judge_detail_crops=2,
- max_usd=0.0, max_minutes=60.0,
+ max_minutes=60.0,
expected_usd=1.47,
expected_score="0.835 mean on compare_v1, 36/61 runs passed ($2.50 per passing artifact) "
"— MEASURED ON gemini-cli:gemini-3.6-flash, not on this dial's generator",
@@ -141,7 +140,7 @@ PROFILES: dict[str, Profile] = {
captioner="gemini:gemini-3.7-flash",
rounds=4, candidates=2, judge_samples=3, max_turns=0, texture=True,
judge_max_px=1024, judge_montages=3, judge_detail_crops=2,
- max_usd=0.0, max_minutes=90.0,
+ max_minutes=90.0,
expected_usd=3.20,
expected_score="best-of-2 lifted the stool baseline 0.563 → 0.612 and the texture pass "
"0.686 → 0.701; judge σ 0.017 at n=3",
diff --git a/harness/codeverse/cost/reconstruct.py b/harness/codeverse/cost/reconstruct.py
index 2e77b39f..45b94e03 100644
--- a/harness/codeverse/cost/reconstruct.py
+++ b/harness/codeverse/cost/reconstruct.py
@@ -93,7 +93,6 @@ class RunLedger:
wall_s: float = 0.0 # time the run was actually working (budget elapsed / stage+round durations)
span_s: float = 0.0 # first to last event — includes time queued behind other runs
model_s: float = 0.0
- budget_usd: float = 0.0
selected_candidate: str = "" # "c1" when the run ran best-of-N and c1 won
source: str = "reconstructed" # live (the run wrote its own ledger) | reconstructed
rows: list[CallCost] = field(default_factory=list)
@@ -273,7 +272,6 @@ def reconstruct_run(run_dir: str | Path, *, recheck: bool = False) -> RunLedger:
status=str(record.get("status") or ""), stop_reason=str(extra.get("stop_reason") or ""),
baseline_score=record.get("baseline_score"), final_score=record.get("final_score"),
recorded_usd=float(total.cost_usd),
- budget_usd=float(((spec.get("budget") or {}).get("max_usd")) or 0.0),
)
cands = _read_json(root / "rounds" / "candidates.json") or (extra.get("candidates") or {})
if isinstance(cands, dict) and cands.get("selected") is not None:
diff --git a/harness/codeverse/flywheel/telemetry.py b/harness/codeverse/flywheel/telemetry.py
index fb7497fc..c921f95f 100644
--- a/harness/codeverse/flywheel/telemetry.py
+++ b/harness/codeverse/flywheel/telemetry.py
@@ -280,8 +280,6 @@ def cost_summary(record: RunRecord, rows: list[dict[str, Any]]) -> CostSummary:
budget = record.spec.budget
return CostSummary(
total_usd=round(total, 6),
- budget_usd=budget.max_usd,
- budget_used_pct=round(100.0 * total / budget.max_usd, 1) if budget.max_usd else None,
wall_clock_s=round(wall, 1),
max_minutes=budget.max_minutes,
n_calls=sum(int(r.get("n_calls") or 1) for r in rows),
diff --git a/harness/codeverse/gallery/detail.py b/harness/codeverse/gallery/detail.py
index a56dc1e7..2c4adc16 100644
--- a/harness/codeverse/gallery/detail.py
+++ b/harness/codeverse/gallery/detail.py
@@ -279,8 +279,7 @@ def _cost_panel(entry: RunEntry, ws: Workspace, rec: RunRecord) -> str:
for s in sorted(cost.by_stage, key=lambda s: -s.cost_usd))
totals = "".join([
_kv("total", f"${cost.total_usd:.4f}"),
- _kv("budget", f"${cost.budget_usd:.2f}" + (f" ({cost.budget_used_pct:.0f}% used)"
- if cost.budget_used_pct is not None else "")),
+
_kv("calls", str(cost.n_calls)),
_kv("wall clock", f"{cost.wall_clock_s / 60:.1f} min"),
_kv("unattributed", f"${cost.unattributed_usd:.4f}"),
diff --git a/harness/codeverse/orchestrator.py b/harness/codeverse/orchestrator.py
index 102368b6..34dcf15a 100644
--- a/harness/codeverse/orchestrator.py
+++ b/harness/codeverse/orchestrator.py
@@ -11,7 +11,6 @@ from __future__ import annotations
import hashlib
import json
import logging
-import math
import re
import threading
import time
@@ -24,7 +23,7 @@ from typing import Any, Literal, TypeVar
from pydantic import BaseModel, Field, ValidationError
from codeverse.contracts.artifacts import GateReport, Judgment
-from codeverse.contracts.common import Budget, Usage, has_money_ceiling
+from codeverse.contracts.common import Budget, Usage
from codeverse.contracts.plan import AcceptanceItem, Plan
from codeverse.contracts.run import RoundRecord, RunStatus
from codeverse.conventions import to_snake
@@ -818,7 +817,8 @@ class BudgetGuard:
"""Thread-safe accumulator of ``Usage`` against a ``Budget``.
``charge`` adds usage and then calls ``check``; ``check`` raises
- ``BudgetExceeded`` when ``max_usd`` or ``max_minutes`` is exceeded.
+ ``BudgetExceeded`` when ``max_minutes`` is exceeded. Money is measured, never
+ enforced (2026-08-28): there is no cost ceiling.
"""
def __init__(
@@ -845,8 +845,7 @@ class BudgetGuard:
self.calls = 0
#: fraction of the hard ceilings the *baseline* may use (1.0 = no soft cap)
self.soft_fraction = min(1.0, max(0.0, float(soft_fraction)))
- #: one-off extension of the HARD ceilings (finalise/salvage headroom)
- self.grace_usd = 0.0
+ #: one-off extension of the HARD wall-clock ceiling (finalise/salvage headroom)
self.grace_minutes = 0.0
#: run slug + ledger sink for the per-call rows (None = do not write a ledger)
self.run = run
@@ -989,34 +988,22 @@ class BudgetGuard:
return (self._active_s + (time.time() - self.start_time)) / 60.0
# ----------------------------------------------------------------- ceilings
- @property
- def hard_usd(self) -> float:
- return self.budget.max_usd + self.grace_usd
-
@property
def hard_minutes(self) -> float:
return self.budget.max_minutes + self.grace_minutes
- def grant_grace(self, *, usd: float = 0.0, minutes: float = 0.0) -> None:
- """Extend the HARD ceilings (never shrink them). Used once by finalise /
- salvage so a run that tripped the budget mid-stage can still deliver a
- judged round instead of no score at all."""
+ def grant_grace(self, *, minutes: float = 0.0) -> None:
+ """Extend the HARD wall-clock ceiling (never shrink it). Used once by finalise /
+ salvage so a run that tripped the clock mid-stage can still deliver a judged
+ round instead of no score at all."""
with self._lock:
- self.grace_usd = max(self.grace_usd, max(0.0, float(usd)))
self.grace_minutes = max(self.grace_minutes, max(0.0, float(minutes)))
def check(self) -> None:
"""Raise ``BudgetExceeded`` if any hard ceiling has been crossed."""
spent = self.billed_usd
elapsed = self.elapsed_minutes()
- # max_usd == 0 means no money ceiling (the default since 2026-08-28); cost is
- # still accumulated above, so every report and the ledger still know what it cost.
- if has_money_ceiling(self.budget.max_usd) and spent > self.hard_usd:
- raise BudgetExceeded(
- f"cost ${spent:.3f} exceeds max_usd ${self.hard_usd:.2f}",
- spent_usd=spent,
- elapsed_min=elapsed,
- )
+ # money is measured, never enforced (2026-08-28). The clock is the only ceiling.
if elapsed > self.hard_minutes:
raise BudgetExceeded(
f"elapsed {elapsed:.1f} min exceeds max_minutes {self.hard_minutes:.1f}",
@@ -1025,19 +1012,14 @@ class BudgetGuard:
)
# ----------------------------------------------------------------- soft cap
- def soft_limits(self) -> tuple[float, float]:
- """(usd, minutes) the soft sub-budget allows (grace is hard-only)."""
- return (
- self.budget.max_usd * self.soft_fraction,
- self.budget.max_minutes * self.soft_fraction,
- )
+ def soft_minutes(self) -> float:
+ """The wall clock the soft sub-budget allows (grace is hard-only)."""
+ return self.budget.max_minutes * self.soft_fraction
def soft_exceeded(self) -> str:
"""Reason string when the soft sub-budget is used up, else ``""``."""
- usd, minutes = self.soft_limits()
- spent, elapsed = self.billed_usd, self.elapsed_minutes()
- if has_money_ceiling(self.budget.max_usd) and spent > usd:
- return f"cost ${spent:.3f} exceeds soft cap ${usd:.2f} ({self.soft_fraction:.0%} of ${self.budget.max_usd:.2f})"
+ minutes = self.soft_minutes()
+ elapsed = self.elapsed_minutes()
if elapsed > minutes:
return f"elapsed {elapsed:.1f} min exceeds soft cap {minutes:.1f} min ({self.soft_fraction:.0%} of {self.budget.max_minutes:.1f})"
return ""
@@ -1048,11 +1030,7 @@ class BudgetGuard:
def soft_remaining(self) -> dict[str, float]:
"""Headroom left inside the soft sub-budget (never negative)."""
- usd, minutes = self.soft_limits()
- return {
- "usd": max(0.0, usd - self.billed_usd),
- "minutes": max(0.0, minutes - self.elapsed_minutes()),
- }
+ return {"minutes": max(0.0, self.soft_minutes() - self.elapsed_minutes())}
def ok(self) -> bool:
"""True when no ceiling is crossed (non-raising variant of ``check``)."""
@@ -1064,14 +1042,9 @@ class BudgetGuard:
def remaining(self) -> dict[str, float]:
"""Remaining headroom: ``{"usd": ..., "minutes": ..., "fraction": ...}``."""
- capped = has_money_ceiling(self.budget.max_usd)
- # with no ceiling the honest answer is "unlimited", not "$0 left" — a reader
- # (or a future caller) must not read the sentinel as an exhausted budget
- usd = max(0.0, self.hard_usd - self.billed_usd) if capped else math.inf
minutes = max(0.0, self.hard_minutes - self.elapsed_minutes())
- frac_usd = (usd / self.hard_usd if self.hard_usd > 0 else 0.0) if capped else 1.0
- frac_min = minutes / self.hard_minutes if self.hard_minutes > 0 else 0.0
- return {"usd": usd, "minutes": minutes, "fraction": min(frac_usd, frac_min)}
+ frac = minutes / self.hard_minutes if self.hard_minutes > 0 else 0.0
+ return {"minutes": minutes, "fraction": frac}
def timeout_s(self, want_s: float, *, floor_s: float = 60.0, soft: bool = True) -> int:
"""``want_s`` clipped to the wall-clock actually left (soft cap when ``soft``).
@@ -1090,7 +1063,6 @@ class BudgetGuard:
"notional_usd": round(self.spent.cost_usd, 4),
"elapsed_min": round(self.elapsed_minutes(), 2),
"soft_fraction": round(self.soft_fraction, 3),
- "grace_usd": round(self.grace_usd, 4),
"calls": self.calls,
"input_tokens": self.spent.input_tokens,
"output_tokens": self.spent.output_tokens,
@@ -1105,7 +1077,7 @@ class BudgetSnapshot(BaseModel):
"""What survives a resume (``run_state.extra["budget_snapshot"]``).
The five accumulator fields of :class:`BudgetGuard` plus cumulative ACTIVE
- seconds. Grace (``grace_usd``/``grace_minutes``) and config (ceilings, soft
+ seconds. Grace (``grace_minutes``) and config (ceilings, soft
fraction, run, ledger) are EXCLUDED on purpose: grace is per-attempt salvage
headroom — persisting it would ratchet the hard ceiling — and config always
comes from the current spec/settings."""
diff --git a/harness/codeverse/prompts/glsl_shader/system.md b/harness/codeverse/prompts/glsl_shader/system.md
index 6b7b9d25..d2452af3 100644
--- a/harness/codeverse/prompts/glsl_shader/system.md
+++ b/harness/codeverse/prompts/glsl_shader/system.md
@@ -4,6 +4,7 @@ state between frames: every frame is a pure function of the pixel and of absolut
The harness owns the `#version` header, the uniform block and `common.glsl` — never
redeclare them.
+{% if tools %}
The loop that decides whether your work ships:
write → `gl_probe` (compiles? one frame) → fix everything it reports → repeat
@@ -14,6 +15,18 @@ ten-rung ladder of shader briefs, the agent that ran this loop compiled 10 of 10
one given the same reference material WITHOUT the loop compiled 5 of 10 — and the loop's
code came out shorter and cheaper, not longer. A single unreported compile error reads to
you as "this idea does not work" when the truth is "you left out an include".
+{% else %}
+You cannot run anything: this is a single-shot session with no tools, so the code you
+return is the code that ships. Read it back before you finish as if you were the
+compiler — an undeclared name, a missing include, a term multiplied to zero. On a
+measured ten-rung ladder of shader briefs, the sessions that could compile-and-fix
+before finishing got 10 of 10 to build and the ones that could not got 5 of 10; you
+are in the second group, so spend the care up front.
+
+* **Compiles but invisible** — the effect is in source and contributes nothing to the
+ frame. Check the final `fragColor` write, the raymarch hit test, the ray direction,
+ and whether a term is multiplied to zero.
+{% endif %}
What the judge will name if you skip it:
diff --git a/harness/codeverse/prompts/opengl_python/system.md b/harness/codeverse/prompts/opengl_python/system.md
index a882cbc5..cc9b0738 100644
--- a/harness/codeverse/prompts/opengl_python/system.md
+++ b/harness/codeverse/prompts/opengl_python/system.md
@@ -4,6 +4,7 @@ state; `render(ctx, state, t, frame, fbo)` is **sampled** at unequal times, out
and must draw the frame for that `t` into the framebuffer it is handed. There is no window,
no context creation and no clock of your own.
+{% if tools %}
The loop that decides whether your work ships:
write → `gl_probe` (imports? one frame) → fix everything it reports → repeat
@@ -13,6 +14,17 @@ Do not finish while `gl_probe` reports anything. This is not advice. On a measur
of graphics briefs, the agent that ran this loop got every rung to compile and the one
given the same reference material WITHOUT the loop got half — and the loop's code came out
shorter and cheaper, not longer.
+{% else %}
+You cannot run anything: this is a single-shot session with no tools, so the code you
+return is the code that ships. Read it back before you finish as if you were the
+compiler — an undeclared name, a missing include, a term multiplied to zero. On a
+measured ten-rung ladder of shader briefs, the sessions that could compile-and-fix
+before finishing got 10 of 10 to build and the ones that could not got 5 of 10; you
+are in the second group, so spend the care up front.
+
+* **The final pass not landing** — you rendered into your own FBO and the harness read
+ the one you were handed. The last thing `render` does is draw into `fbo`.
+{% endif %}
What the judge will name if you skip it:
diff --git a/harness/codeverse/tracks/articulated_object.py b/harness/codeverse/tracks/articulated_object.py
index 50746ac7..ba79b60f 100644
--- a/harness/codeverse/tracks/articulated_object.py
+++ b/harness/codeverse/tracks/articulated_object.py
@@ -100,7 +100,7 @@ class ArticulatedObjectTrack(StaticObjectTrack):
return ArticulatedPipeline()
def system_prompt(self, ctx: RunContext) -> str:
- return language_system_prompt(ctx.language)
+ return language_system_prompt(ctx.language, tools=not ctx.single_shot)
# ----------------------------------------------------------------------------- sweep adapter
diff --git a/harness/codeverse/tracks/graphics.py b/harness/codeverse/tracks/graphics.py
index 72004767..15ee782a 100644
--- a/harness/codeverse/tracks/graphics.py
+++ b/harness/codeverse/tracks/graphics.py
@@ -488,7 +488,7 @@ class GraphicsTrack(BaseTrack):
# ------------------------------------------------------------------ baseline
def system_prompt(self, ctx: RunContext) -> str:
- return language_system_prompt(ctx.language)
+ return language_system_prompt(ctx.language, tools=not ctx.single_shot)
def baseline_tasks(self, ctx: RunContext) -> list[GenerationTask]:
files = graphics_expected_files(ctx)
diff --git a/harness/codeverse/tracks/lifecycle.py b/harness/codeverse/tracks/lifecycle.py
index e20248b3..1ae0706d 100644
--- a/harness/codeverse/tracks/lifecycle.py
+++ b/harness/codeverse/tracks/lifecycle.py
@@ -148,7 +148,7 @@ _STATUS: dict[str, RunStatus] = {
def plan_stage_inputs(spec: Spec) -> dict[str, Any]:
"""Only the spec fields the PLAN depends on: hashing the whole Spec meant that
- raising ``budget.max_usd`` in spec.json (the only way to continue a BUDGET-stopped
+ raising ``budget.max_minutes`` in spec.json (the only way to continue a BUDGET-stopped
run) re-planned + re-skeletoned on resume, overwriting src/ under existing rounds."""
return {
"prompt": spec.prompt,
@@ -709,14 +709,10 @@ class BaseTrack:
already stopping on budget."""
if rounds or ctx.state.completed_rounds or ctx.plan is None:
return # nothing was built yet (the PLAN itself blew the budget) → nothing to salvage
- cap = ctx.spec.budget.max_usd
- if cap > 0 and not ctx.budget.ok() and ctx.budget.spent.cost_usd > ctx.budget.hard_usd * 2:
- return # runaway spend against a real ceiling: do not throw good money after bad
- grace_usd = max(0.15, cap * 0.10)
grace_min = max(5.0, ctx.spec.budget.max_minutes * 0.15)
- ctx.budget.grant_grace(usd=grace_usd, minutes=grace_min)
- ctx.events.emit("budget.salvage", reason="no round completed before the budget stop",
- grace_usd=round(grace_usd, 3), grace_minutes=round(grace_min, 1))
+ ctx.budget.grant_grace(minutes=grace_min)
+ ctx.events.emit("budget.salvage", reason="no round completed before the clock stop",
+ grace_minutes=round(grace_min, 1))
try:
if not self.prepare_salvage(ctx):
ctx.events.emit("budget.salvage_skipped", reason="nothing buildable to salvage")
@@ -820,8 +816,8 @@ class BaseTrack:
# visible, but NOT `budget.exceeded`: that event means "the loop stopped",
# and a texture pass runs after the loop has already finished.
ctx.events.emit("budget.overrun", stage="texture",
- reason=f"the texture pass took the run past its ceiling "
- f"(${ctx.budget.spent.cost_usd:.3f} of ${ctx.budget.hard_usd:.2f})",
+ reason=f"the texture pass took the run past its wall-clock ceiling "
+ f"(spent ${ctx.budget.spent.cost_usd:.3f})",
spent_usd=round(ctx.budget.spent.cost_usd, 4))
@staticmethod
diff --git a/harness/codeverse/tracks/prompting.py b/harness/codeverse/tracks/prompting.py
index 136b231e..63ae119d 100644
--- a/harness/codeverse/tracks/prompting.py
+++ b/harness/codeverse/tracks/prompting.py
@@ -14,6 +14,8 @@ from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any
+from jinja2 import TemplateNotFound
+
from codeverse.config import fewer_turns_enabled
from codeverse.contracts.chat import ImagePart
from codeverse.contracts.common import Language, Track
@@ -21,7 +23,7 @@ from codeverse.contracts.plan import Plan, StaticPlan
from codeverse.contracts.run import RoundRecord
from codeverse.conventions import LANGUAGE_FRAME, Frame, frame_doc, to_snake
from codeverse.languages._docs import prompt_dir_for
-from codeverse.prompts import load_text, render
+from codeverse.prompts import render
from codeverse.tracks.common import RunContext
from codeverse.tracks.depth import DepthBudget, PartScope, depth_budget, interfaces_text
from codeverse.tracks.generation import SINGLE_SHOT_FORMAT
@@ -268,7 +270,7 @@ def select_cookbook_chapters(ctx: RunContext, brief: str, *, budget: int = 9000,
return [chapters[i] for i in sorted(chosen)]
-def language_system_prompt(language: Language, *, role: str = "", **vars: Any) -> str:
+def language_system_prompt(language: Language, *, role: str = "", tools: bool = True, **vars: Any) -> str:
"""The generator's system prompt: ``prompts/<dir>/system.md``, or a role template.
These were f-strings inside each track class until 2026-08-28 — two sentences each,
@@ -281,10 +283,13 @@ def language_system_prompt(language: Language, *, role: str = "", **vars: Any) -
# CV3D_SYSPROMPT=v0 serves the pre-2026-08-28 two-sentence prompt so an A/B can run
# both arms from one tree. Delete the v0 files and this branch once it has an answer.
name = "system_v0.md" if os.environ.get("CV3D_SYSPROMPT") == "v0" else "system.md"
+ # rendered, not read raw: a system prompt that tells a SINGLE-SHOT session to call
+ # gl_probe is instructing something it has no tools to do, and the self-check loop is
+ # the whole point of the graphics prompt. `tools` lets the file say so itself.
try:
- base = load_text(f"{d}/{name}").strip()
- except FileNotFoundError:
- base = load_text(f"{d}/system.md").strip()
+ base = render(f"{d}/{name}", tools=tools).strip()
+ except (FileNotFoundError, TemplateNotFound):
+ base = render(f"{d}/system.md", tools=tools).strip()
if not role:
return base
# roles COMPOSE with the language base rather than replacing it. Replacing was the
diff --git a/harness/codeverse/tracks/scene.py b/harness/codeverse/tracks/scene.py
index 61d60a47..a0f15e71 100644
--- a/harness/codeverse/tracks/scene.py
+++ b/harness/codeverse/tracks/scene.py
@@ -434,7 +434,7 @@ class SceneTrack(BaseTrack):
# ------------------------------------------------------------------ helpers
def system_prompt(self, ctx: RunContext) -> str:
- return language_system_prompt(ctx.language)
+ return language_system_prompt(ctx.language, tools=not ctx.single_shot)
def _ctx(self, ctx: RunContext, **extra: Any) -> dict[str, Any]:
plan: ScenePlan = ctx.plan # type: ignore[assignment]
diff --git a/harness/codeverse/tracks/static_object.py b/harness/codeverse/tracks/static_object.py
index 9c8244df..468128c5 100644
--- a/harness/codeverse/tracks/static_object.py
+++ b/harness/codeverse/tracks/static_object.py
@@ -311,7 +311,7 @@ class StaticObjectTrack(BaseTrack):
n_parts=len(scope.parts), names=", ".join(scope.names))
def system_prompt(self, ctx: RunContext) -> str:
- return language_system_prompt(ctx.language)
+ return language_system_prompt(ctx.language, tools=not ctx.single_shot)
def round_files_hint(self, ctx: RunContext) -> list[str]:
return expected_files(ctx)
diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.md
index b88a0510..b98e8a24 100644
--- a/harness/docs/ARCHITECTURE.md
+++ b/harness/docs/ARCHITECTURE.md
@@ -136,7 +136,7 @@ codeverse/
profiles.py (economy|balanced|quality; cli._common.resolve_dial is THE resolver)
caching.py (Block/order_blocks/session_cache — measurement only, docs/COST.md §13)
billing.py (SUBSCRIPTION_BACKENDS/bills_usd — which backends take real dollars,
- so max_usd guards money and not list price; docs/COST.md §25)
+ so the ledger bills real money and not list price; docs/COST.md §25)
guard.py routing.py reconstruct.py (old runs) audit.py report.py
judges/ base.py (Judge protocol + the pure round-replay pieces `3dcv judge` and
calibration share), rubrics.py + rubrics/*.yaml (defect checklists, the wire
@@ -445,7 +445,7 @@ $0.02–0.03 (flash) / ~$0.2 (pro); api-agent generation 3–6 min per object ro
* agy exposes no per-workspace MCP, cost or served model.
* Anthropic / OpenAI backends are mock-tested only (no keys on this box).
* Budget checks run between steps: a refine round that finishes its judge and then
- trips the budget is not promoted to best — give scenes `--max-minutes 60 --max-usd 4`.
+ trips the budget is not promoted to best — give scenes `--max-minutes 60`.
* Gemini flash 503 storms happen; dead keys and 429s rotate freely now, but a
sustained outage can still fail a round (`3dcv resume` re-uses cached stages).
* `ffmpeg` absent here → turntables fall back to GIF. A few single-file wrappers
diff --git a/harness/docs/INSTALL.md b/harness/docs/INSTALL.md
index 87edba06..effd7e69 100644
--- a/harness/docs/INSTALL.md
+++ b/harness/docs/INSTALL.md
@@ -516,7 +516,7 @@ cd harness
3dcv make "a slow rotating neon hex grid" \
--track graphics --language glsl_shader \
--generator single-shot:gemini:gemini-3.7-flash \
- --rounds 0 --max-usd 0.30 --max-minutes 20 \
+ --rounds 0 --max-minutes 20 \
--runs-dir /tmp/cv3d_smoke
3dcv status <slug> --runs-dir /tmp/cv3d_smoke
```
diff --git a/harness/docs/RUNBOOK.md b/harness/docs/RUNBOOK.md
index 97a2d86e..7ef39932 100644
--- a/harness/docs/RUNBOOK.md
+++ b/harness/docs/RUNBOOK.md
@@ -49,7 +49,7 @@ python -m pytest tests -q -m live # OPT-IN: real API calls
# articulated object — bpy links + URDF
3dcv make "a bedside cabinet with one hinged door and one drawer" --track articulated_object --language urdf_blender
# scene — multi-file three.js + GLSL (+ optional bpy GLB assets chosen by the planner)
-3dcv make "a small japanese garden at dusk with a koi pond" --track scene --language scene_threejs --rounds 2 --max-usd 3 --max-minutes 60
+3dcv make "a small japanese garden at dusk with a koi pond" --track scene --language scene_threejs --rounds 2 --max-minutes 60
# graphics — animated shader / raw OpenGL program
3dcv make "neon cyberpunk rain on a window with bokeh city lights" --track graphics --language glsl_shader
3dcv make "instanced pastel cubes with bloom" --track graphics --language opengl_python
@@ -60,7 +60,7 @@ silhouette gate + IoU refine tasks), `--rounds N` (refine rounds after the basel
`--candidates N` (best-of-N baseline: N parallel candidates in `<ws>/_cand/`,
quick-judged, pairwise tie-break, winner kept; multiplies baseline cost ≈ N;
default from `settings.default_candidates`), `--texture` (run the texture pass after
-finalise; see §6), `--max-usd`, `--max-minutes`, `--dim height=0.45`, `--must`,
+finalise; see §6), `--max-minutes` (there is no cost ceiling), `--dim height=0.45`, `--must`,
`--must-not`, `--style`, `--tag`, `--seed`, `--slug`, `--runs-dir`, `--force`,
`--no-run` (workspace + spec.json only — except that `--reference` still runs its
paid grounding pass first, since the grounded spec is what it writes).
@@ -68,7 +68,7 @@ paid grounding pass first, since the grounded spec is what it writes).
Expected cost/time with gemini-3.7-flash: object tracks ≈ $0.7–0.9 and 12–36 min for
baseline + 1 refine; best-of-2 single-shot ≈ $0.25 / 8 min; graphics single-shot
≈ $0.05 / 2 min per judged round; scenes ≈ $2.3 and 30 min before the first judged
-round, then ≈ $0.36 / ~7 min per refine (give scenes `--max-minutes 60 --max-usd 4`).
+round, then ≈ $0.36 / ~7 min per refine (give scenes `--max-minutes 60`).
## 3. Backends
@@ -146,7 +146,7 @@ unless you type `--host` yourself; it never serves a path outside the declared r
```bash
3dcv resume <slug> [--candidates N] # continues from run_state + stages/*.json (input-hash cached). The budget
# SNAPSHOT is restored: money/calls/active-minutes already spent still count,
- # so a raised --max-usd grants only the difference (downtime is never billed)
+ # so a raised --max-minutes grants only the difference (downtime never counts)
3dcv render <slug> [--round N] [--mode shaded|wire|normals|clay|silhouette] [--out dir]
3dcv judge <slug> [--round N] [--rubric static_object_v1] [--model gemini:gemini-3.1-pro-preview] [--n 3]
# re-judges a round's recorded renders → artifacts/judge/rNN_cli.json
diff --git a/harness/tests/bench_prompts/test_v2_batteries.py b/harness/tests/bench_prompts/test_v2_batteries.py
index 427deb61..10f6d22f 100644
--- a/harness/tests/bench_prompts/test_v2_batteries.py
+++ b/harness/tests/bench_prompts/test_v2_batteries.py
@@ -153,7 +153,7 @@ def test_graphics_v2_opengl_prompts_carry_language_override():
assert prompt.language == Language.OPENGL_PYTHON, f"{prompt.id}: missing language override"
else:
assert prompt.language is None, f"{prompt.id}: unexpected language override"
- spec = build_spec(b, prompt, backends=backends, rounds=1, max_usd=1, max_minutes=1, tag0="t")
+ spec = build_spec(b, prompt, backends=backends, rounds=1, max_minutes=1, tag0="t")
want = Language.OPENGL_PYTHON if prompt.id.startswith("ogl_") else Language.GLSL_SHADER
assert spec.language == want, f"{prompt.id}: spec language {spec.language} != {want}"
diff --git a/harness/tests/compare_bench/test_bench_shared.py b/harness/tests/compare_bench/test_bench_shared.py
index eacdea22..622b463a 100644
--- a/harness/tests/compare_bench/test_bench_shared.py
+++ b/harness/tests/compare_bench/test_bench_shared.py
@@ -34,10 +34,10 @@ def test_select_prompts_is_single_owner_for_both_drivers():
def test_build_spec_tags_and_budget():
b = _battery()
item = b.prompts[0]
- spec = build_spec(b, item, backends=rb.get_settings().backends(), rounds=2, max_usd=1.5,
+ spec = build_spec(b, item, backends=rb.get_settings().backends(), rounds=2,
max_minutes=10, tag0="compare", extra_tags=("harness",))
assert spec.tags[:4] == ["compare", b.name, item.tier, item.category] and "harness" in spec.tags
- assert spec.budget.max_rounds == 2 and spec.budget.max_usd == 1.5
+ assert spec.budget.max_rounds == 2 and not hasattr(spec.budget, "max_usd")
assert spec.id == f"{b.name}/{item.id}"
diff --git a/harness/tests/compare_bench/test_compare_matrix.py b/harness/tests/compare_bench/test_compare_matrix.py
index 4761baac..09864f28 100644
--- a/harness/tests/compare_bench/test_compare_matrix.py
+++ b/harness/tests/compare_bench/test_compare_matrix.py
@@ -69,7 +69,7 @@ def test_spec_for_and_acceptance():
harness = spec_for(b, b.prompts[0], parse_arm("harness:gemini-cli:gemini-3.7-flash"), opts)
one = spec_for(b, b.prompts[0], parse_arm("oneshot:codex"), opts)
assert harness.backends.generator == "gemini-cli:gemini-3.7-flash" and harness.backends.judge == "gemini:gemini-3.7-flash"
- assert harness.budget.max_rounds == 3 and harness.budget.max_usd == 2.5
+ assert harness.budget.max_rounds == 3 and not hasattr(harness.budget, "max_usd")
assert one.backends.generator == "single-shot:codex" and one.constraints.must_have == b.prompts[0].must_have
acc = acceptance_from_spec(one)
assert [a.id for a in acc] == ["must_1", "must_2", "must_3"] and all(a.priority == "must" for a in acc)
diff --git a/harness/tests/compare_bench/test_degraded.py b/harness/tests/compare_bench/test_degraded.py
index 7fc3fb93..e99daa9e 100644
--- a/harness/tests/compare_bench/test_degraded.py
+++ b/harness/tests/compare_bench/test_degraded.py
@@ -44,23 +44,24 @@ def _track(status: RunStatus, stop_reason: str, rounds: int, cost: float, aborte
@pytest.mark.parametrize("status,stop,rounds,cost,aborted,expect", [
- (RunStatus.BUDGET, "budget", 1, 1.2, 1, True), # the storm case: clock stop, 1 round, money left
+ (RunStatus.BUDGET, "budget", 1, 1.2, 1, True), # the storm case: clock stop after 1 round
(RunStatus.BUDGET, "budget", 0, 0.9, 1, True), # never completed a round
(RunStatus.BUDGET, "budget", 2, 1.5, 1, False), # iterated twice: cut, but not degraded
- (RunStatus.BUDGET, "budget", 1, 2.4, 0, False), # a MONEY stop (>= 90% of max_usd) is the protocol, not weather
+ # the money-stop row is gone with the money ceiling (2026-08-28): a "budget" stop is
+ # now always the clock, which is exactly the case this flag exists for
(RunStatus.PASSED, "pass", 1, 0.8, 0, False), # passed after one round: fine
(RunStatus.PLATEAU, "plateau", 1, 0.7, 0, False),
])
def test_flag_degraded_rule(tmp_path, status, stop, rounds, cost, aborted, expect):
battery = Battery.load(BATTERY)
- opts = CompareOptions(judge="gemini:x", loop_judge="gemini:x", max_usd=2.5, degraded_min_wall_s=0)
+ opts = CompareOptions(judge="gemini:x", loop_judge="gemini:x", degraded_min_wall_s=0)
deps = CompareDeps(FakeEvaluator(), run_track=_track(status, stop, rounds, cost, aborted))
r = run_cell(battery, battery.prompts[0], parse_arm("harness:gemini-cli:gemini-3.6-flash"), tmp_path, opts, deps)
assert r.status == "scored" and r.score is not None
assert (r.harness_stop_reason, r.harness_rounds, r.harness_aborted_rounds) == (stop, rounds, aborted)
assert r.degraded is expect, r
if expect:
- assert "ceiling stop" in r.degraded_reason and "unspent" in r.degraded_reason
+ assert "ceiling stop" in r.degraded_reason and "having spent" in r.degraded_reason
def test_degraded_needs_the_wall_clock_floor():
diff --git a/harness/tests/compare_bench/test_infra_failures.py b/harness/tests/compare_bench/test_infra_failures.py
index 78c08270..d250f217 100644
--- a/harness/tests/compare_bench/test_infra_failures.py
+++ b/harness/tests/compare_bench/test_infra_failures.py
@@ -379,32 +379,18 @@ def test_the_ab_viewer_refuses_to_call_a_winner_it_cannot_support():
assert head.startswith("Inconclusive") and "1 of 1" in why
-def test_no_money_ceiling_does_not_silently_disable_the_degraded_flag():
- """`max_usd = 0` means no ceiling — it must not read as "the ceiling is $0".
-
- The flag exists because of compare_v4 (2026-08-25): under a day-long 503 storm 37 of
- 40 harness runs stopped on the WALL CLOCK with 0-2 rounds while the 3 that met a calm
- window scored 0.92-0.95, so a paired mean over them measured the weather. Its test
- is `did we stop for the clock rather than the dollars`, written as
- `cost >= 0.9 * max_usd` — and with max_usd 0 that is `cost >= 0`, true for every
- cell, so every time-capped cell reads as a money stop and the flag never fires again.
+def test_a_clock_stopped_cell_is_flagged_degraded():
+ """compare_v4 (2026-08-25): under a day-long 503 storm 37 of 40 harness runs stopped
+ on the WALL CLOCK with 0-2 rounds while the 3 that met a calm window scored
+ 0.92-0.95, so a paired mean over them measures the weather. With the money ceiling
+ removed (2026-08-28) a "budget" stop is always the clock, and this is the whole test.
"""
from bench.compare_backends import CompareOptions, flag_degraded
- def timed_out_cell(cost: float = 0.9) -> CellResult:
- return CellResult(prompt_id="p", arm="harness:x", kind="harness", status="scored",
- harness_stop_reason="budget", harness_rounds=1, wall_s=2400,
- gen_cost_usd=cost)
-
- for cap in (0.0, 1.5): # no ceiling, and an explicit one
- c = timed_out_cell()
- flag_degraded(c, CompareOptions(judge="g:x", loop_judge="g:x", max_usd=cap))
- assert c.degraded, f"a clock-stopped one-round cell must be flagged (max_usd={cap})"
-
- # a cell that really did spend its ceiling is NOT degraded — it iterated, it just ran out
- c = timed_out_cell(cost=0.99)
- flag_degraded(c, CompareOptions(judge="g:x", loop_judge="g:x", max_usd=1.0))
- assert not c.degraded, "a money stop is not the waited-instead-of-iterating case"
+ c = CellResult(prompt_id="p", arm="harness:x", kind="harness", status="scored",
+ harness_stop_reason="budget", harness_rounds=1, wall_s=2400, gen_cost_usd=0.9)
+ flag_degraded(c, CompareOptions(judge="g:x", loop_judge="g:x"))
+ assert c.degraded and "0.90" in c.degraded_reason # it says what the cell actually spent
def test_the_default_generator_and_the_cost_router_name_the_same_model():
diff --git a/harness/tests/cost/conftest.py b/harness/tests/cost/conftest.py
index 383262cc..b9e186d5 100644
--- a/harness/tests/cost/conftest.py
+++ b/harness/tests/cost/conftest.py
@@ -47,7 +47,7 @@ def fake_run(tmp_path: Path) -> Path:
"spec": {"track": "static_object", "language": "blender",
"backends": {"generator": "gemini-cli:gemini-3.6-flash",
"judge": "gemini:gemini-3.1-pro-preview"},
- "budget": {"max_usd": 5.0}},
+ "budget": {"max_minutes": 60.0}},
"status": "passed", "baseline_score": 0.6, "final_score": 0.8, "best_round": 0,
"total_usage": total, "extra": {"stop_reason": "pass", "budget": {"elapsed_min": 2.0}},
"rounds": [{"index": 0, "kind": "baseline", "usage": session, "gates": [],
diff --git a/harness/tests/cost/test_live.py b/harness/tests/cost/test_live.py
index 51442ab3..d0909b8d 100644
--- a/harness/tests/cost/test_live.py
+++ b/harness/tests/cost/test_live.py
@@ -61,7 +61,7 @@ def test_a_metered_run_reconciles_with_its_own_record(tmp_path: Path):
r = CliRunner().invoke(app, [
"make", "a smooth grey ceramic bowl", "--track", "static_object", "--language", "blender",
"--generator", "single-shot:gemini:gemini-3.7-flash", "--judge", "gemini:gemini-3.7-flash",
- "--rounds", "0", "--max-usd", "1", "--max-minutes", "15",
+ "--rounds", "0", "--max-minutes", "15",
"--runs-dir", str(runs), "--slug", "cost_live_bowl"])
assert r.exit_code in (0, 1), r.output # a failed judge/build is still a metered run
ws = Workspace(runs / "cost_live_bowl")
diff --git a/harness/tests/cost/test_profiles.py b/harness/tests/cost/test_profiles.py
index 1b466fec..369ab5ed 100644
--- a/harness/tests/cost/test_profiles.py
+++ b/harness/tests/cost/test_profiles.py
@@ -46,8 +46,8 @@ def test_balanced_is_todays_defaults():
s = Settings()
assert (p.generator, p.planner, p.judge) == (s.default_generator, s.default_planner, s.default_judge)
assert p.rounds == 4 and p.candidates == s.default_candidates and p.judge_samples == 1
- # max_usd 0 = no money ceiling (owner, 2026-08-28); cost is still recorded on every call
- assert p.max_usd == 0.0 and p.max_minutes == 60.0 and p.judge_max_px == 1024
+ # a profile has no money dial at all: the ceiling was removed on 2026-08-28
+ assert not hasattr(p, "max_usd") and p.max_minutes == 60.0 and p.judge_max_px == 1024
def test_economy_is_single_shot_flash_and_two_rounds_with_no_turn_cap_of_its_own():
@@ -157,18 +157,18 @@ def test_make_profile_writes_the_whole_shape_onto_the_spec(tmp_path: Path):
assert r.exit_code == 0, r.output
spec = json.loads((runs / "pot" / "spec.json").read_text())
assert spec["options"] == {"candidates": 2, "texture": True, "profile": "quality"}
- assert spec["budget"]["max_rounds"] == 4 and spec["budget"]["max_usd"] == 0.0
+ assert spec["budget"]["max_rounds"] == 4 and "max_usd" not in spec["budget"]
assert spec["backends"]["judge"] == "gemini:gemini-3.1-pro-preview"
def test_an_explicit_flag_beats_the_profile(tmp_path: Path):
runs = tmp_path / "runs"
r = runner.invoke(app, ["make", "a clay pot", "--runs-dir", str(runs), "--no-run", "--slug", "pot",
- "--profile", "economy", "--rounds", "4", "--max-usd", "9",
+ "--profile", "economy", "--rounds", "4",
"--generator", "gemini-cli:gemini-3.6-flash"])
assert r.exit_code == 0, r.output
spec = json.loads((runs / "pot" / "spec.json").read_text())
- assert spec["budget"]["max_rounds"] == 4 and spec["budget"]["max_usd"] == 9.0
+ assert spec["budget"]["max_rounds"] == 4 and "max_usd" not in spec["budget"]
assert spec["backends"]["generator"] == "gemini-cli:gemini-3.6-flash"
assert spec["backends"]["judge"] == "gemini:gemini-3.7-flash" # unstated → still the profile's
@@ -181,7 +181,7 @@ def test_no_profile_flag_leaves_the_defaults_alone(tmp_path: Path):
# the resolved dial is recorded whichever way it was named, so `3dcv resume`
# reproduces it; with no flag and no env that dial is the default, balanced
assert spec["options"]["profile"] == "balanced" and spec["options"]["texture"] is False
- assert spec["budget"]["max_rounds"] == 4 and spec["budget"]["max_usd"] == 0.0
+ assert spec["budget"]["max_rounds"] == 4 and "max_usd" not in spec["budget"]
def test_judge_samples_reach_the_round_policy_only_when_a_profile_asks(tmp_path: Path):
@@ -235,17 +235,17 @@ def test_the_flag_and_the_env_var_resolve_to_the_same_dial(name, monkeypatch):
"judge": "gemini:gemini-3.7-flash", "judge_samples": 2,
"rounds": 2, "candidates": 1, "texture": False,
"judge_max_px": 1024, "judge_montages": 3, "judge_detail_crops": 2,
- "agent_max_turns": 0, "max_usd": 0.0, "max_minutes": 30.0}),
+ "agent_max_turns": 0, "max_minutes": 30.0}),
("balanced", {"generator": "gemini-cli:gemini-3.7-flash",
"judge": "gemini:gemini-3.1-pro-preview", "judge_samples": 1,
"rounds": 4, "candidates": 1, "texture": False,
"judge_max_px": 1024, "judge_montages": 3, "judge_detail_crops": 2,
- "agent_max_turns": 0, "max_usd": 0.0, "max_minutes": 60.0}),
+ "agent_max_turns": 0, "max_minutes": 60.0}),
("quality", {"generator": "gemini-cli:gemini-3.7-flash",
"judge": "gemini:gemini-3.1-pro-preview", "judge_samples": 3,
"rounds": 4, "candidates": 2, "texture": True,
"judge_max_px": 1024, "judge_montages": 3, "judge_detail_crops": 2,
- "agent_max_turns": 0, "max_usd": 0.0, "max_minutes": 90.0}),
+ "agent_max_turns": 0, "max_minutes": 90.0}),
],
)
def test_each_profile_resolves_to_its_documented_dial(name, expected, monkeypatch):
@@ -269,5 +269,5 @@ def test_the_env_var_reaches_the_spec_a_make_writes(name, tmp_path: Path, monkey
assert r.exit_code == 0, r.output
spec = json.loads((runs / "pot" / "spec.json").read_text())
assert spec["options"] == {"candidates": p.candidates, "texture": p.texture, "profile": name}
- assert spec["budget"]["max_rounds"] == p.rounds and spec["budget"]["max_usd"] == p.max_usd
+ assert spec["budget"]["max_rounds"] == p.rounds and spec["budget"]["max_minutes"] == p.max_minutes
assert spec["backends"]["judge"] == p.judge and spec["backends"]["generator"] == p.generator
diff --git a/harness/tests/flywheel_cli/test_cli.py b/harness/tests/flywheel_cli/test_cli.py
index 244ae005..beb529f7 100644
--- a/harness/tests/flywheel_cli/test_cli.py
+++ b/harness/tests/flywheel_cli/test_cli.py
@@ -58,7 +58,7 @@ def test_make_no_run_creates_valid_workspace(tmp_path: Path):
runs = tmp_path / "runs"
r = runner.invoke(app, ["make", "a wooden dining chair", "--track", "static_object", "--language", "blender",
"--runs-dir", str(runs), "--no-run", "--dim", "width=0.5", "--must", "four legs",
- "--rounds", "2", "--max-usd", "1.5", "--generator", "gemini-cli:gemini-3.7-flash"])
+ "--rounds", "2", "--generator", "gemini-cli:gemini-3.7-flash"])
assert r.exit_code == 0, r.output
# `.locks/` (runlock.exclusive) lives beside the run dirs on purpose — a lock inside
# the directory a --force wipe deletes is no lock
@@ -68,7 +68,7 @@ def test_make_no_run_creates_valid_workspace(tmp_path: Path):
assert ws.name.startswith("a_wooden_dining_chair_") and (ws / "spec.json").is_file() and (ws / ".git").is_dir()
spec = Spec.model_validate_json((ws / "spec.json").read_text())
assert spec.constraints.dimensions_m == {"width": 0.5} and spec.constraints.must_have == ["four legs"]
- assert spec.budget.max_rounds == 2 and spec.budget.max_usd == 1.5
+ assert spec.budget.max_rounds == 2 and spec.budget.max_minutes == 60.0
assert spec.backends.generator == "gemini-cli:gemini-3.7-flash"
assert (ws / "src").is_dir() and (ws / "artifacts" / "renders").is_dir()
# same prompt again → same slug → refuse without --force
@@ -273,17 +273,17 @@ def test_make_invalid_combo_leaves_no_orphan_workspace(tmp_path: Path):
def test_resume_budget_flags_rewrite_spec_and_emit_event(made_run, stub_track):
- runs, ws = made_run("--max-usd", "1.0", "--rounds", "1")
+ runs, ws = made_run("--max-minutes", "1.0", "--rounds", "1")
seen = {}
stub_track(lambda spec, resume, force: seen.__setitem__("spec", spec))
- r2 = runner.invoke(app, ["resume", ws.name, "--runs-dir", str(runs), "--max-usd", "4.5", "--rounds", "3"])
+ r2 = runner.invoke(app, ["resume", ws.name, "--runs-dir", str(runs), "--max-minutes", "60", "--rounds", "3"])
assert r2.exit_code == 130
spec = Spec.model_validate_json((ws / "spec.json").read_text())
- assert spec.budget.max_usd == 4.5 and spec.budget.max_rounds == 3 and spec.budget.max_minutes == 60.0
- assert seen["spec"].budget.max_usd == 4.5, "the resumed run must see the raised budget"
+ assert spec.budget.max_rounds == 3 and spec.budget.max_minutes == 60.0
+ assert seen["spec"].budget.max_minutes == 60.0, "the resumed run must see the raised ceiling"
events = [json.loads(line) for line in (ws / "events.jsonl").read_text().splitlines()]
raised = [e for e in events if e.get("event") == "budget.raised"]
- assert raised and raised[0]["max_usd"] == 4.5 and raised[0]["max_rounds"] == 3
+ assert raised and raised[0]["max_rounds"] == 3
def test_resume_refuses_a_finished_run_and_never_re_enters_it(made_run, stub_track):
@@ -313,7 +313,7 @@ def test_resume_refuses_a_finished_run_and_never_re_enters_it(made_run, stub_tra
# a budget stop is the documented exception: it resumes when a cap is raised
RunState(status=RunStatus.BUDGET, stop_reason="budget").save(ws)
assert runner.invoke(app, ["resume", ws.root.name, "--runs-dir", str(runs)]).exit_code == 1
- assert runner.invoke(app, ["resume", ws.root.name, "--runs-dir", str(runs), "--max-usd", "4.5"]).exit_code == 130
+ assert runner.invoke(app, ["resume", ws.root.name, "--runs-dir", str(runs), "--max-minutes", "60"]).exit_code == 130
# an interrupted run is untouched by the guard
RunState(status=RunStatus.REFINING).save(ws)
@@ -435,13 +435,13 @@ def test_an_unknown_profile_is_a_clean_error_not_a_traceback(tmp_path: Path):
def test_a_negative_budget_is_rejected_before_the_workspace_exists(tmp_path: Path):
- """SM-11: --max-usd took any float. A negative ceiling is not a small budget, it is
- an unrunnable one — BudgetGuard.ok() is False before a single token is spent, the
- first charge raises "cost $0.001 exceeds max_usd $-2.50", and grant_grace cannot
- lift a hard ceiling back above zero. `3dcv make` nonetheless printed
- `max_usd -3.0`, created the workspace and git-committed the spec."""
+ """SM-11: a ceiling flag took any float. A negative ceiling is not a small budget,
+ it is an unrunnable one — BudgetGuard.ok() is False before a single token is spent
+ and grant_grace cannot lift a hard ceiling back above zero — yet `3dcv make` printed
+ it, created the workspace and git-committed the spec. The money ceiling is gone
+ (2026-08-28); the rule holds for the one that remains."""
runs = tmp_path / "runs"
- for flag, value in (("--max-usd", "-3"), ("--max-minutes", "-10")):
+ for flag, value in (("--max-minutes", "-10"),):
r = runner.invoke(app, ["make", "a chair", flag, value, "--no-run",
"--runs-dir", str(runs), "--slug", "neg"])
assert r.exit_code != 0, f"{flag} {value} was accepted"
@@ -449,7 +449,7 @@ def test_a_negative_budget_is_rejected_before_the_workspace_exists(tmp_path: Pat
assert not (runs / "neg").exists(), "no workspace may be created for a rejected budget"
# 0 stays legal (documented: a run at 0 degrades from its first check) ...
- r = runner.invoke(app, ["make", "a chair", "--max-usd", "0", "--no-run",
+ r = runner.invoke(app, ["make", "a chair", "--max-minutes", "0", "--no-run",
"--runs-dir", str(runs), "--slug", "zero"])
assert r.exit_code == 0 and (runs / "zero" / "spec.json").is_file()
# ... and the contract refuses a negative ceiling even when built directly
@@ -459,8 +459,10 @@ def test_a_negative_budget_is_rejected_before_the_workspace_exists(tmp_path: Pat
from codeverse.contracts.common import Budget
with _pytest.raises(ValidationError):
- Budget(max_usd=-3.0)
- assert Budget(max_usd=0.0).max_usd == 0.0
+ Budget(max_minutes=-3.0)
+ assert Budget(max_minutes=0.0).max_minutes == 0.0
+ # and there is no money ceiling to reject: the field is gone
+ assert "max_usd" not in Budget().model_dump()
def test_texture_is_not_offered_on_tracks_that_have_no_glb(tmp_path: Path):
diff --git a/harness/tests/flywheel_cli/test_run_layout_cli.py b/harness/tests/flywheel_cli/test_run_layout_cli.py
index ff337384..9eb1d985 100644
--- a/harness/tests/flywheel_cli/test_run_layout_cli.py
+++ b/harness/tests/flywheel_cli/test_run_layout_cli.py
@@ -72,7 +72,7 @@ def test_package_run_builds_deliverable_and_telemetry(fake_run):
assert ws.settings_path.is_file() and ws.cost_path.is_file() and ws.usage_path.is_file()
cost = json.loads(ws.cost_path.read_text())
assert cost["total_usd"] == rec.total_usage.cost_usd
- assert cost["by_round"] and cost["budget_usd"] == rec.spec.budget.max_usd
+ assert cost["by_round"] and "budget_usd" not in cost # no money ceiling to report
settings = json.loads(ws.settings_path.read_text())
assert {r["role"] for r in settings["roles"]} == {"planner", "generator", "judge", "captioner"}
assert settings["rubric"] and settings["rubric_hash"] and settings["price_table_version"]
@@ -111,7 +111,7 @@ def test_cost_summary_reconciles_with_the_record_total(fake_run):
assert abs(cost.ledger_usd - cost.total_usd) < 1e-9
assert cost.by_role["judge"] > 0 and cost.unattributed_usd > 0 # judge verdicts + the residual
assert {s.stage for s in cost.by_stage} <= set(stage_order())
- assert cost.budget_usd == rec.spec.budget.max_usd
+ assert not hasattr(cost, "budget_usd") # the money ceiling and its report are gone
def test_usage_rows_alias_a_live_ledger_instead_of_copying_it(fake_run):
diff --git a/harness/tests/orchestrator_tracks/conftest.py b/harness/tests/orchestrator_tracks/conftest.py
index 941ecc2c..3078dad6 100644
--- a/harness/tests/orchestrator_tracks/conftest.py
+++ b/harness/tests/orchestrator_tracks/conftest.py
@@ -2,6 +2,8 @@
from __future__ import annotations
+import contextlib
+
import pytest
from codeverse.config import Settings
@@ -46,13 +48,48 @@ def chair_plan() -> StaticPlan:
def make_spec(track: Track = Track.STATIC_OBJECT, language: Language = Language.THREEJS, *, generator: str = "fake:fake-model",
- max_rounds: int = 3, max_usd: float = 5.0, prompt: str = "a mid-century wooden dining chair", **kw) -> Spec:
+ max_rounds: int = 3, max_minutes: float = 10.0, prompt: str = "a mid-century wooden dining chair", **kw) -> Spec:
+ """``max_minutes`` is how a test makes a run run out: money stopped being a ceiling
+ on 2026-08-28, so a scenario that needs a budget stop sets a tight CLOCK."""
return Spec(id="t1", track=track, language=language, prompt=prompt,
constraints=Constraints(dimensions_m={"height": 0.82}, must_have=["armrests"]),
- budget=Budget(max_rounds=max_rounds, max_usd=max_usd, max_minutes=10, max_repair_attempts=2),
+ budget=Budget(max_rounds=max_rounds, max_minutes=max_minutes, max_repair_attempts=2),
backends=Backends(planner="fake:planner", generator=generator, judge="fake:judge"), **kw)
@pytest.fixture
def spec() -> Spec:
return make_spec()
+
+
+def clock_trips_after(n_reads: int):
+ """Make the wall-clock ceiling be crossed after ``n_reads`` elapsed-time reads.
+
+ Money stopped being a ceiling on 2026-08-28, so a scenario that needs a run to stop
+ MID-RUN drives the clock. It has to be driven rather than waited for: a fake model
+ answers instantly, so real wall time never moves and `max_minutes` alone either stops
+ the run before round 0 or never. This lets a test say "stop after the work I care
+ about has happened" without sleeping.
+ """
+ from codeverse.orchestrator import BudgetGuard
+
+ real = BudgetGuard.elapsed_minutes
+ state = {"n": 0}
+
+ def fake(self: BudgetGuard) -> float:
+ state["n"] += 1
+ if state["n"] <= n_reads:
+ return 0.0
+ # LOCK the reading at the moment it first trips. Salvage answers a stop by
+ # granting wall-clock grace, so a clock recomputed against the raised ceiling
+ # would stay past it for ever and the salvaged round could never run — which is
+ # the behaviour these scenarios exist to check.
+ state.setdefault("at", self.hard_minutes + 0.001)
+ return state["at"]
+
+ BudgetGuard.elapsed_minutes = fake # type: ignore[method-assign]
+ try:
+ yield state
+ finally:
+ BudgetGuard.elapsed_minutes = real # type: ignore[method-assign]
diff --git a/harness/tests/orchestrator_tracks/test_budget_snapshot.py b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
index 8fdff6e0..770ea33e 100644
--- a/harness/tests/orchestrator_tracks/test_budget_snapshot.py
+++ b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
@@ -39,7 +39,7 @@ from tests.orchestrator_tracks.fakes import (
# --------------------------------------------------------------- snapshot / restore
def test_resume_restores_money_calls_and_active_time_but_not_downtime():
- g1 = BudgetGuard(Budget(max_usd=1.0, max_minutes=10.0))
+ g1 = BudgetGuard(Budget(max_minutes=10.0))
g1.charge(Usage(backend="gemini", cost_usd=0.6), stage="baseline", round_index=0, label="baseline")
g1.add(Usage(backend="gemini", cost_usd=0.05), stage="judge", role="judge", round_index=0)
g1.start_time -= 120 # two minutes of ACTIVE work in the first session
@@ -48,7 +48,7 @@ def test_resume_restores_money_calls_and_active_time_but_not_downtime():
# the exact round-trip run_state.json takes: model_dump(mode="json") → validate
revived = BudgetSnapshot.model_validate(json.loads(json.dumps(snap.model_dump(mode="json"))))
- g2 = BudgetGuard(Budget(max_usd=1.0, max_minutes=10.0))
+ g2 = BudgetGuard(Budget(max_minutes=10.0))
g2.restore(revived)
assert g2.billed_usd == pytest.approx(0.65) and g2.calls == 2
assert g2.by_stage == {"baseline": pytest.approx(0.6), "judge": pytest.approx(0.05)}
@@ -57,39 +57,43 @@ def test_resume_restores_money_calls_and_active_time_but_not_downtime():
assert g2.elapsed_minutes() == pytest.approx(2.0, abs=0.1)
g2.start_time -= 60 # one more ACTIVE minute in THIS session accumulates on top
assert g2.elapsed_minutes() == pytest.approx(3.0, abs=0.1)
- # prior spend still constrains new work: 0.65 + 0.5 > 1.0
- with pytest.raises(BudgetExceeded):
- g2.charge(Usage(backend="gemini", cost_usd=0.5), stage="refine")
+ # prior spend is still restored and still accumulates — it just is not a ceiling
+ g2.charge(Usage(backend="gemini", cost_usd=0.5), stage="refine")
+ assert g2.billed_usd == pytest.approx(1.15) and g2.calls == 3
# prior ACTIVE time still constrains the wall clock immediately after a resume
- g3 = BudgetGuard(Budget(max_usd=10.0, max_minutes=1.0))
+ g3 = BudgetGuard(Budget(max_minutes=1.0))
g3.restore(revived)
with pytest.raises(BudgetExceeded):
g3.check()
def test_a_raised_cap_grants_only_the_difference_and_grace_never_persists():
- g1 = BudgetGuard(Budget(max_usd=1.0, max_minutes=10.0))
+ """A resumed run gets the raised ceiling MINUS what it already used, not a fresh one.
+ The ceiling is the wall clock (money stopped being one on 2026-08-28); the money the
+ snapshot carries is still restored, it just cannot end the run."""
+ import time as _t
+
+ g1 = BudgetGuard(Budget(max_minutes=10.0), start_time=_t.time())
g1.charge(Usage(backend="gemini", cost_usd=0.9), stage="baseline")
- g1.grant_grace(usd=5.0, minutes=30.0) # per-attempt salvage headroom — must NOT survive
+ g1._active_s = 8.0 * 60 # noqa: SLF001 — 8 of its 10 min
+ g1.grant_grace(minutes=30.0) # per-attempt salvage headroom — must NOT survive
snap = g1.snapshot()
- assert "grace_usd" not in snap.model_dump() and "soft_fraction" not in snap.model_dump()
+ assert "grace_minutes" not in snap.model_dump() and "soft_fraction" not in snap.model_dump()
- g2 = BudgetGuard(Budget(max_usd=1.5, max_minutes=10.0)) # --max-usd raised 1.0 → 1.5
+ g2 = BudgetGuard(Budget(max_minutes=15.0)) # --max-minutes raised 10 → 15
g2.restore(snap)
- assert g2.grace_usd == 0.0 and g2.grace_minutes == 0.0
- assert g2.remaining()["usd"] == pytest.approx(0.6) # the difference, never a fresh $1.50
- g2.charge(Usage(backend="gemini", cost_usd=0.5), stage="refine") # fits
- with pytest.raises(BudgetExceeded):
- g2.charge(Usage(backend="gemini", cost_usd=0.2), stage="refine")
+ assert g2.grace_minutes == 0.0
+ assert g2.billed_usd == pytest.approx(0.9), "the money is restored, it just is not a ceiling"
+ assert g2.remaining()["minutes"] == pytest.approx(7.0, abs=0.1) # 15 − 8, never a fresh 15
def test_build_context_restores_the_snapshot_and_falls_back_to_legacy_spent(tmp_path, settings):
- spec = make_spec(max_usd=1.0)
+ spec = make_spec()
ws = Workspace(tmp_path / "runs" / "r").create()
track = StaticObjectTrack(services=FakeServices(), settings=settings, runtime=FakeRuntime(Language.THREEJS))
- g = BudgetGuard(Budget(max_usd=1.0, max_minutes=10.0))
+ g = BudgetGuard(Budget(max_minutes=10.0))
g.charge(Usage(backend="gemini", cost_usd=0.4), stage="baseline", round_index=0)
state = RunState()
state.extra["budget_snapshot"] = g.snapshot().model_dump(mode="json")
@@ -107,11 +111,14 @@ def test_build_context_restores_the_snapshot_and_falls_back_to_legacy_spent(tmp_
# --------------------------------------------------------------- ordering: single-shot
def test_a_paid_single_shot_response_is_persisted_when_the_budget_trips(tmp_path):
ws = Workspace(tmp_path / "ws").create()
- guard = BudgetGuard(Budget(max_usd=0.01, max_minutes=10.0))
+ # a wall-clock ceiling already crossed: the phase boundary turns this into the stop,
+ # and the point of the test is that the PAID response is on disk before it does
+ guard = BudgetGuard(Budget(max_minutes=1.0))
+ guard._active_s = 120.0 # noqa: SLF001 — already past 1 min
answer = ("=== FILE: src/object.js ===\n"
"export function build(THREE) { return new THREE.Group(); }\n"
"=== END FILE ===")
- model = FakeChatModel(lambda req: answer, cost=0.05) # this ONE call crosses max_usd
+ model = FakeChatModel(lambda req: answer, cost=0.05) # paid work, booked before the stop
task = GenerationTask(label="baseline", prompt="p", files_hint=["src/object.js"])
res = generate_files(ws, model=model, task=task, budget=guard) # must NOT raise
assert res.ok and (ws.src / "object.js").is_file()
@@ -144,7 +151,7 @@ def test_a_budget_tripped_candidate_still_lets_the_sibling_be_adopted(tmp_path,
# --------------------------------------------------------------- ordering: planner attempts
def test_planner_attempt_zero_usage_reaches_the_guard_when_attempt_one_raises(tmp_path):
- guard = BudgetGuard(Budget(max_usd=5.0, max_minutes=10.0))
+ guard = BudgetGuard(Budget(max_minutes=10.0))
ws = Workspace(tmp_path / "run").create()
calls = {"n": 0}
@@ -163,7 +170,7 @@ def test_planner_attempt_zero_usage_reaches_the_guard_when_attempt_one_raises(tm
def test_planning_error_dollars_are_booked_exactly_once(tmp_path):
- guard = BudgetGuard(Budget(max_usd=5.0, max_minutes=10.0))
+ guard = BudgetGuard(Budget(max_minutes=10.0))
ws = Workspace(tmp_path / "run").create()
def responder(req):
diff --git a/harness/tests/orchestrator_tracks/test_cost_accounting.py b/harness/tests/orchestrator_tracks/test_cost_accounting.py
index 0e26e06b..94b3ce9c 100644
--- a/harness/tests/orchestrator_tracks/test_cost_accounting.py
+++ b/harness/tests/orchestrator_tracks/test_cost_accounting.py
@@ -12,6 +12,8 @@ guard, in one ledger row, and in a round bucket.
from __future__ import annotations
import json
+import time
+from functools import partial
from pathlib import Path
import pytest
@@ -48,7 +50,7 @@ class _RecordedAgent:
def replay(name: str, ledger: Path | None, *, texture: bool = True) -> BudgetGuard:
"""Spend one recorded run's money through today's accounting path."""
fx = FIXTURES[name]
- guard = BudgetGuard(Budget(max_usd=10_000, max_minutes=10_000), run=name, ledger=ledger)
+ guard = BudgetGuard(Budget(max_minutes=10_000), run=name, ledger=ledger)
tasks: dict[tuple[str, int], list[dict]] = {}
for s in fx["sessions"]:
tasks.setdefault((s["job_label"] or s["label"], int(s["round"] or 0)), []).append(s)
@@ -116,17 +118,23 @@ def test_post_hoc_texture_passes_are_inside_the_total_now():
# ----------------------------------------------------------------------------- guard mechanics
def test_spend_buckets_by_stage_and_round_and_only_charge_enforces():
- g = BudgetGuard(Budget(max_usd=1.0, max_minutes=60))
- g.charge(Usage(cost_usd=0.4), stage="baseline", round_index=0, label="baseline")
- g.add(Usage(cost_usd=0.05), stage="judge", role="judge", round_index=0)
- assert g.by_stage == {"baseline": pytest.approx(0.4), "judge": pytest.approx(0.05)}
- assert g.round_costs(0)["judge"] == pytest.approx(0.05) and g.round_costs(9) == {}
- g.add(Usage(cost_usd=0.9), stage="texture", role="image") # over the ceiling, but never raises
- assert not g.ok() and g.spent.cost_usd == pytest.approx(1.35)
+ # the ceiling is the clock (money stopped being one on 2026-08-28); what this test
+ # pins is unchanged — the buckets, and that only `charge` enforces while `add` books
+ g = BudgetGuard(Budget(max_minutes=1.0), start_time=time.time() - 600)
+ g.charge = partial(BudgetGuard.charge, g) # keep the bound method after the clock trick
+ g0 = BudgetGuard(Budget(max_minutes=60))
+ g0.charge(Usage(cost_usd=0.4), stage="baseline", round_index=0, label="baseline")
+ g0.add(Usage(cost_usd=0.05), stage="judge", role="judge", round_index=0)
+ assert g0.by_stage == {"baseline": pytest.approx(0.4), "judge": pytest.approx(0.05)}
+ assert g0.round_costs(0)["judge"] == pytest.approx(0.05) and g0.round_costs(9) == {}
+ assert list(g0.stage_summary())[0] == "baseline" # biggest bucket first
+
+ g = BudgetGuard(Budget(max_minutes=1.0), start_time=time.time() - 600) # already past
+ g.add(Usage(cost_usd=0.9), stage="texture", role="image") # over the ceiling, never raises
+ assert not g.ok() and g.spent.cost_usd == pytest.approx(0.9)
with pytest.raises(BudgetExceeded):
g.charge(Usage(cost_usd=0.01), stage="refine")
- assert g.spent.cost_usd == pytest.approx(1.36) # the money is counted even when it raises
- assert list(g.stage_summary())[0] == "texture" # biggest bucket first
+ assert g.spent.cost_usd == pytest.approx(0.91) # the money is counted even when it raises
def test_usage_delta_reports_what_a_round_burned():
@@ -138,10 +146,10 @@ def test_usage_delta_reports_what_a_round_burned():
def test_the_ledger_is_optional_and_never_breaks_a_run(tmp_path):
- g = BudgetGuard(Budget(max_usd=1.0, max_minutes=60), ledger=tmp_path / "sub" / "dir" / "l.jsonl")
+ g = BudgetGuard(Budget(max_minutes=60), ledger=tmp_path / "sub" / "dir" / "l.jsonl")
g.charge(Usage(cost_usd=0.1), stage="plan", role="planner")
assert len(load_ledger(tmp_path / "sub" / "dir" / "l.jsonl")) == 1
- quiet = BudgetGuard(Budget(max_usd=1.0, max_minutes=60)) # no ledger configured
+ quiet = BudgetGuard(Budget(max_minutes=60)) # no ledger configured
quiet.charge(Usage(cost_usd=0.1))
assert quiet.spent.cost_usd == pytest.approx(0.1)
@@ -159,7 +167,7 @@ def test_a_subscription_backend_does_not_consume_the_spend_guard():
from codeverse.contracts.common import Budget, Usage
from codeverse.orchestrator import BudgetGuard
- g = BudgetGuard(Budget(max_usd=8.0, max_minutes=60.0), soft_fraction=0.55)
+ g = BudgetGuard(Budget(max_minutes=60.0), soft_fraction=0.55)
g.spend(Usage(backend="codex", model="gpt-5.6-sol", cost_usd=7.712), enforce=False)
assert g.billed_usd == 0.0
@@ -177,13 +185,15 @@ def test_the_guard_still_enforces_backends_that_really_bill():
from codeverse.contracts.common import Budget, Usage
from codeverse.orchestrator import BudgetExceeded, BudgetGuard
- g = BudgetGuard(Budget(max_usd=8.0, max_minutes=60.0), soft_fraction=0.55)
- g.spend(Usage(backend="codex", cost_usd=99.0), enforce=False) # free, ignored
- g.spend(Usage(backend="gemini", cost_usd=5.0), enforce=False)
- assert g.soft_exceeded() # soft cap fires on the real $5
- assert g.ok() # but the hard ceiling has not
+ g = BudgetGuard(Budget(max_minutes=60.0), soft_fraction=0.55)
+ g.spend(Usage(backend="codex", cost_usd=99.0), enforce=False) # subscription: notional
+ g.spend(Usage(backend="gemini", cost_usd=5.0), enforce=False) # API: real dollars
+ assert g.billed_usd == pytest.approx(5.0), "a subscription must not bill"
+ assert g.ok() and not g.soft_exceeded() # neither ceiling is money any more
g.spend(Usage(backend="some-new-provider", cost_usd=4.0), enforce=False)
assert g.billed_usd == pytest.approx(9.0), "an unknown backend must bill, not be exempt"
+ # ...and the clock is what can still end it
+ g._active_s = 3600.0 # noqa: SLF001
with pytest.raises(BudgetExceeded):
g.check()
diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.py
index 4b366c45..3799e8aa 100644
--- a/harness/tests/orchestrator_tracks/test_cost_latency.py
+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py
@@ -29,7 +29,7 @@ from codeverse.tracks.scene_assets import (
variant_index,
)
from codeverse.workspace import Workspace
-from tests.orchestrator_tracks.conftest import make_spec
+from tests.orchestrator_tracks.conftest import clock_trips_after, make_spec
from tests.orchestrator_tracks.fakes import (
FakeAgent,
FakeChatModel,
@@ -46,24 +46,29 @@ needs_node = pytest.mark.skipif(
# ----------------------------------------------------------------------------- soft budget
def test_soft_budget_degrades_before_the_hard_cap_and_grace_reopens_it():
- g = BudgetGuard(Budget(max_usd=1.0, max_minutes=60.0), soft_fraction=0.55)
- assert g.soft_ok() and g.soft_remaining()["usd"] == pytest.approx(0.55)
- g.add(_usage(0.6))
+ """The sub-budget is the WALL CLOCK: money stopped being a ceiling on 2026-08-28,
+ so the baseline's share, the degrade-do-not-die step and grace are all in minutes."""
+ clock = {"t": 0.0}
+ g = BudgetGuard(Budget(max_minutes=10.0), soft_fraction=0.55)
+ g.start_time = 0.0
+ g.elapsed_minutes = lambda: clock["t"] # type: ignore[method-assign]
+ assert g.soft_ok() and g.soft_remaining()["minutes"] == pytest.approx(5.5)
+ clock["t"] = 6.0
assert not g.soft_ok() and "soft cap" in g.soft_exceeded()
assert g.ok() # the HARD ceiling is untouched: degrade, do not die
- g.add(_usage(0.5))
+ clock["t"] = 11.0
assert not g.ok()
with pytest.raises(BudgetExceeded):
g.check()
- g.grant_grace(usd=0.3, minutes=5.0)
- assert g.ok() and g.hard_usd == pytest.approx(1.3)
- g.grant_grace(usd=0.1) # never shrinks
- assert g.hard_usd == pytest.approx(1.3)
+ g.grant_grace(minutes=5.0)
+ assert g.ok() and g.hard_minutes == pytest.approx(15.0)
+ g.grant_grace(minutes=1.0) # never shrinks
+ assert g.hard_minutes == pytest.approx(15.0)
assert g.summary()["soft_fraction"] == 0.55
def test_timeout_is_clipped_to_the_wall_clock_left():
- g = BudgetGuard(Budget(max_usd=5.0, max_minutes=10.0), soft_fraction=0.5)
+ g = BudgetGuard(Budget(max_minutes=10.0), soft_fraction=0.5)
assert g.timeout_s(1800, floor_s=60) == pytest.approx(300, abs=2) # 50 % of 10 min
assert g.timeout_s(120, floor_s=60) == pytest.approx(120, abs=2) # never inflates
g.start_time -= 600 # the run is already over its wall clock
@@ -165,9 +170,9 @@ def _envelope(rel: str, body: str) -> str:
def _scene_ctx(tmp_path, settings, *, services, agent=None, plan=None, agent_id="fake-agent:gemini:x",
- max_usd=5.0) -> RunContext:
+ max_minutes: float = 10.0) -> RunContext:
plan = plan or ScenePlan.model_validate(plan_example(Track.SCENE))
- spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, generator=agent_id, max_usd=max_usd)
+ spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, generator=agent_id, max_minutes=max_minutes)
ws = Workspace(tmp_path / "ws").create()
ws.write_json(ws.spec_path, spec)
rt = FakeRuntime(Language.SCENE_THREEJS)
@@ -289,7 +294,7 @@ def _threejs_scene_plan() -> ScenePlan:
def test_a_budget_stop_before_round_zero_still_delivers_a_judged_round(tmp_path, settings):
plan = _threejs_scene_plan()
- spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=1, max_usd=5.0)
+ spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=1)
ws = Workspace(tmp_path / "runs" / "greenhouse")
services = FakeServices(assemble=True)
@@ -305,7 +310,9 @@ def test_a_budget_stop_before_round_zero_still_delivers_a_judged_round(tmp_path,
track = SceneTrack(services=services, judge=FakeJudge(scores=(0.58,)), agent=FakeAgent(writer, cost=1.3),
planner_model=_planner(plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.SCENE_THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(20):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET and rec.extra["stop_reason"] == "budget"
# …and, unlike the greenhouse run, it has a score
assert rec.best_round == 0 and rec.final_score == pytest.approx(0.58)
@@ -315,12 +322,12 @@ def test_a_budget_stop_before_round_zero_still_delivers_a_judged_round(tmp_path,
names = [e["event"] for e in ev]
assert "budget.salvage" in names and names.count("best.updated") == 1
salvage = next(e for e in ev if e["event"] == "budget.salvage")
- assert salvage["grace_usd"] > 0 and salvage["grace_minutes"] > 0
+ assert salvage["grace_minutes"] > 0 and "grace_usd" not in salvage # wall clock only now
def test_soft_budget_notes_land_in_the_round_record(tmp_path, settings):
plan = _threejs_scene_plan()
- spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0, max_usd=5.0)
+ spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
ws = Workspace(tmp_path / "runs" / "degraded")
services = FakeServices(assemble=True)
# an expensive agent: the soft cap (55 % of $5) is crossed during the asset stage
@@ -328,7 +335,9 @@ def test_soft_budget_notes_land_in_the_round_record(tmp_path, settings):
track = SceneTrack(services=services, judge=FakeJudge(scores=(0.5,)), agent=agent,
planner_model=_planner(plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.SCENE_THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(12):
+ rec = track.run(spec, ws)
ev = [json.loads(x) for x in (ws.root / "events.jsonl").read_text().splitlines() if x.strip()]
degraded = [e for e in ev if e["event"] == "budget.degraded"]
assert degraded, "the soft cap must be reported before the hard cap kills the run"
@@ -435,13 +444,15 @@ def test_a_scene_round_judged_at_the_ceiling_is_still_promoted(tmp_path, setting
recorded and promoted BEFORE the loop notices the budget is gone — and the salvage
must not then run a second round 0 on top of it."""
plan = _threejs_scene_plan()
- spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=2, max_usd=0.10)
+ spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=2)
ws = Workspace(tmp_path / "runs" / "ceiling")
- judge = FakeJudge(scores=(0.61,), cost=0.5) # the single verdict blows max_usd
+ judge = FakeJudge(scores=(0.61,), cost=0.5)
track = SceneTrack(services=FakeServices(assemble=True), judge=judge, agent=FakeAgent(_writer, cost=0.001),
planner_model=_planner(plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.SCENE_THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(26):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET and rec.best_round == 0 and rec.final_score == pytest.approx(0.61)
assert len(rec.rounds) == 1 and rec.rounds[0].judgment is not None
names = [json.loads(x)["event"] for x in (ws.root / "events.jsonl").read_text().splitlines() if x.strip()]
@@ -478,7 +489,7 @@ def test_a_generation_session_never_outlives_the_wall_budget():
from codeverse.contracts.spec import Budget
from codeverse.orchestrator import BudgetGuard
- g = BudgetGuard(Budget(max_usd=10.0, max_minutes=30.0, max_rounds=4), run="t")
+ g = BudgetGuard(Budget(max_minutes=30.0, max_rounds=4), run="t")
assert g.timeout_s(1800, floor_s=120.0) == pytest.approx(1800, abs=60) # fresh run: full session
g.start_time -= 27 * 60 # 3 minutes left
clipped = g.timeout_s(1800, floor_s=120.0)
@@ -501,7 +512,7 @@ def test_one_asset_cannot_eat_the_scene_run():
)
class Ctx:
- budget = BudgetGuard(Budget(max_usd=10.0, max_minutes=25.0, max_rounds=4), run="t")
+ budget = BudgetGuard(Budget(max_minutes=25.0, max_rounds=4), run="t")
fresh = asset_timeout_s(Ctx, 120)
assert fresh < ASSET_AGENT_TIMEOUT_S, "one asset may not have the whole preparation budget"
@@ -510,6 +521,6 @@ def test_one_asset_cannot_eat_the_scene_run():
assert asset_timeout_s(Ctx, 120) == 120, "and never past the wall clock, floor aside"
class Long:
- budget = BudgetGuard(Budget(max_usd=10.0, max_minutes=90.0, max_rounds=4), run="t")
+ budget = BudgetGuard(Budget(max_minutes=90.0, max_rounds=4), run="t")
assert asset_timeout_s(Long, 120) == ASSET_AGENT_TIMEOUT_S, "a long run keeps the ceiling"
diff --git a/harness/tests/orchestrator_tracks/test_fix_batch2.py b/harness/tests/orchestrator_tracks/test_fix_batch2.py
index 6a6b0d8a..67e841ec 100644
--- a/harness/tests/orchestrator_tracks/test_fix_batch2.py
+++ b/harness/tests/orchestrator_tracks/test_fix_batch2.py
@@ -18,7 +18,7 @@ from codeverse.tracks.planner import plan_example
from codeverse.tracks.scene import SceneTrack
from codeverse.tracks.static_object import ObjectPipeline, StaticObjectTrack
from codeverse.workspace import Workspace
-from tests.orchestrator_tracks.conftest import make_spec
+from tests.orchestrator_tracks.conftest import clock_trips_after, make_spec
from tests.orchestrator_tracks.fakes import (
FakeAgent,
FakeChatModel,
@@ -66,13 +66,15 @@ class ScriptedJudge(FakeJudge):
def test_judged_round_survives_budget_ceiling_crossed_by_judge(tmp_path, chair_plan, settings):
"""steps.py:148 — the judge's own charge used to raise BudgetExceeded BEFORE the round
was committed/recorded, throwing away a complete judged round (scene r2 case)."""
- spec = make_spec(max_rounds=3, max_usd=0.02)
+ spec = make_spec(max_rounds=3)
ws = Workspace(tmp_path / "runs" / "r")
judge = FakeJudge(scores=(0.55,), cost=0.05) # this single verdict crosses max_usd
track = StaticObjectTrack(services=FakeServices(), judge=judge, agent=FakeAgent(_writer),
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(8):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET and rec.extra["stop_reason"] == "budget"
assert len(rec.rounds) == 1 and rec.rounds[0].judgment is not None
assert rec.best_round == 0 and rec.final_score == pytest.approx(0.55) # promoted BEFORE the budget stop
@@ -87,14 +89,16 @@ def test_judged_round_survives_budget_ceiling_crossed_by_judge(tmp_path, chair_p
def test_finalise_restores_best_when_aborted_round_dirtied_src(tmp_path, chair_plan, settings):
"""lifecycle.py:263 — a refine round that wrote files but died on the generation charge
left HEAD at the best commit with foreign src/: the run then shipped unjudged code."""
- spec = make_spec(max_rounds=3, max_usd=0.02)
+ spec = make_spec(max_rounds=3)
ws = Workspace(tmp_path / "runs" / "r")
# planner 0.002 + baseline agent 0.01 + judge 0.003 = 0.015 < 0.02; the refine agent's
# 0.01 charge crosses the ceiling AFTER its files hit the disk.
track = StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=(0.55, 0.7), targets=("Seat",)), agent=FakeAgent(_writer),
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(10):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET and rec.best_round == 0 and len(rec.rounds) == 1
text = (ws.src / "object.js").read_text()
assert "baseline r0" in text and "refine" not in text # restored, not the aborted round's edits
@@ -193,7 +197,7 @@ def test_degraded_verdict_recovers_via_rejudge_of_same_commit(tmp_path, chair_pl
# --------------------------------------------------------------------- finding: plan stage hash covers the whole Spec
def test_resume_with_raised_budget_does_not_replan_or_reskeleton(tmp_path, chair_plan, settings):
- spec = make_spec(max_rounds=1, max_usd=5.0)
+ spec = make_spec(max_rounds=1)
ws = Workspace(tmp_path / "runs" / "r")
planner = _planner(chair_plan.model_dump(mode="json"))
services = FakeServices()
@@ -204,7 +208,7 @@ def test_resume_with_raised_budget_does_not_replan_or_reskeleton(tmp_path, chair
n_plan_calls = len(planner.requests)
src_before = (ws.src / "object.js").read_text()
# the only way to continue a BUDGET-stopped run: raise the budget in the spec
- spec2 = make_spec(max_rounds=1, max_usd=50.0)
+ spec2 = make_spec(max_rounds=1)
rec2 = mk().run(spec2, ws, resume=True)
assert len(planner.requests) == n_plan_calls # plan stage still cached
assert (ws.src / "object.js").read_text() == src_before or "r0" in (ws.src / "object.js").read_text()
diff --git a/harness/tests/orchestrator_tracks/test_orchestrator.py b/harness/tests/orchestrator_tracks/test_orchestrator.py
index c168fbff..1912eb07 100644
--- a/harness/tests/orchestrator_tracks/test_orchestrator.py
+++ b/harness/tests/orchestrator_tracks/test_orchestrator.py
@@ -36,17 +36,19 @@ from codeverse.proc import EventLog, fan_out, split_results
# ----------------------------------------------------------------------------- budget
def test_budget_guard_charges_and_raises():
- g = BudgetGuard(Budget(max_usd=0.05, max_minutes=60))
+ g = BudgetGuard(Budget(max_minutes=10.0))
g.charge(Usage(cost_usd=0.02))
g.charge(Usage(cost_usd=0.02))
- assert g.ok() and g.remaining()["usd"] == pytest.approx(0.01)
+ assert g.ok() and "usd" not in g.remaining() # headroom is wall clock only
+ g._active_s = 11 * 60 # noqa: SLF001 — past the ceiling
with pytest.raises(BudgetExceeded) as ei:
g.charge(Usage(cost_usd=0.02))
- assert "max_usd" in ei.value.reason and g.spent.cost_usd == pytest.approx(0.06)
+ # the money is still counted on the call that raises; it just is not what raised
+ assert "max_minutes" in ei.value.reason and g.spent.cost_usd == pytest.approx(0.06)
def test_budget_guard_time_ceiling():
- g = BudgetGuard(Budget(max_usd=10, max_minutes=0.0001), start_time=time.time() - 10)
+ g = BudgetGuard(Budget(max_minutes=0.0001), start_time=time.time() - 10)
with pytest.raises(BudgetExceeded):
g.check()
assert g.remaining()["minutes"] == 0.0
diff --git a/harness/tests/orchestrator_tracks/test_refactor_batch2.py b/harness/tests/orchestrator_tracks/test_refactor_batch2.py
index 8c3d28a8..43474462 100644
--- a/harness/tests/orchestrator_tracks/test_refactor_batch2.py
+++ b/harness/tests/orchestrator_tracks/test_refactor_batch2.py
@@ -159,7 +159,7 @@ def test_graphics_planner_hooks_charge_budget_on_planning_error(tmp_ws):
from codeverse.tracks.planner import plan as run_planner
spec = make_spec(Track.GRAPHICS, Language.GLSL_SHADER)
- budget = BudgetGuard(Budget(max_usd=5.0, max_minutes=10))
+ budget = BudgetGuard(Budget(max_minutes=10))
always_bad = FakeChatModel(lambda req: {"title": "x"})
with pytest.raises(PlanningError):
run_planner(spec, "fake:planner", GraphicsPlan, tmp_ws, model=always_bad, budget=budget,
diff --git a/harness/tests/orchestrator_tracks/test_resume_reconcile.py b/harness/tests/orchestrator_tracks/test_resume_reconcile.py
index 827b02f8..9bb3fd65 100644
--- a/harness/tests/orchestrator_tracks/test_resume_reconcile.py
+++ b/harness/tests/orchestrator_tracks/test_resume_reconcile.py
@@ -193,7 +193,7 @@ def test_a_spec_edit_without_force_is_refused_before_anything_runs(completed_run
assert json.loads(ws.record_path.read_text())["status"] != "failed"
# the sanctioned budget raise (outside the fingerprint) still resumes plainly
- spec3 = make_spec(language=Language.BLENDER, max_rounds=0, max_usd=50.0)
+ spec3 = make_spec(language=Language.BLENDER, max_rounds=0)
ws.write_json(ws.spec_path, spec3)
rec3 = run.rerun(spec=spec3, resume=True)
assert [r.index for r in rec3.rounds] == [0]
diff --git a/harness/tests/orchestrator_tracks/test_round_economics.py b/harness/tests/orchestrator_tracks/test_round_economics.py
index 19b35008..ddd272d8 100644
--- a/harness/tests/orchestrator_tracks/test_round_economics.py
+++ b/harness/tests/orchestrator_tracks/test_round_economics.py
@@ -41,7 +41,7 @@ from codeverse.tracks.generation import (
)
from codeverse.tracks.static_object import StaticObjectTrack
from codeverse.workspace import Workspace
-from tests.orchestrator_tracks.conftest import make_spec
+from tests.orchestrator_tracks.conftest import clock_trips_after, make_spec
from tests.orchestrator_tracks.fakes import (
FakeAgent,
FakeChatModel,
@@ -283,7 +283,7 @@ def _guard():
from codeverse.contracts.common import Budget
from codeverse.orchestrator import BudgetGuard
- return BudgetGuard(Budget(max_usd=100, max_minutes=100))
+ return BudgetGuard(Budget(max_minutes=100))
def test_task_stage_names_the_cost_bucket_a_task_spends_in():
@@ -332,7 +332,8 @@ def test_skip_judge_reasons_are_only_states_where_the_verdict_is_never_bought(tm
assert skip_judge_reason(strict, gates=_gates(0), renders=_renders()) == ""
# ... the budget/clock stop: the loop's next budget_ok check ends the run, so this
# verdict cannot promote anything (audit: 2 verdicts / $0.09 bought past the clock)
- ctx.budget.add(Usage(cost_usd=99.0), stage="refine")
+ ctx.budget.add(Usage(cost_usd=99.0), stage="refine") # booked, but money is not a ceiling
+ ctx.budget._active_s = (ctx.budget.budget.max_minutes + 1) * 60 # noqa: SLF001 — the clock is
assert skip_judge_reason(ctx, gates=_gates(), renders=_renders()) == "budget already exceeded"
assert StopPolicy(ctx.policy).evaluate([_round(0, 0.5)], budget_ok=ctx.budget.ok()).reason == "budget"
ctx.judge = None
@@ -409,7 +410,7 @@ def _ctx(tmp_path, spec, settings, *, policy: RoundPolicy | None = None, agent=N
ws = Workspace(tmp_path / "runs" / name)
ws.create()
return RunContext(spec=spec, ws=ws, events=EventLog(ws.events_path), settings=settings,
- budget=BudgetGuard(Budget(max_usd=1.0, max_minutes=60)), runtime=FakeRuntime(Language.THREEJS),
+ budget=BudgetGuard(Budget(max_minutes=60)), runtime=FakeRuntime(Language.THREEJS),
services=FakeServices(), state=RunState(), policy=policy or RoundPolicy(), track=spec.track,
rubric="static_object_v1", agent_id="fake:fake-model", judge=FakeJudge(), agent=agent)
@@ -486,7 +487,7 @@ def test_a_lint_stuck_run_keeps_every_score_instead_of_deferring_the_verdict(tmp
def test_a_round_that_raises_still_reports_what_it_burned(tmp_path, chair_plan, settings):
- spec = make_spec(max_rounds=2, max_usd=0.05)
+ spec = make_spec(max_rounds=2, max_minutes=0.0)
ws = Workspace(tmp_path / "runs" / "cut")
class _Expensive(FakeAgent):
@@ -497,7 +498,9 @@ def test_a_round_that_raises_still_reports_what_it_burned(tmp_path, chair_plan,
track = StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=(0.5, 0.6)), agent=_Expensive(_writer),
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
runtime=FakeRuntime(Language.THREEJS), policy=RoundPolicy(max_rounds=2, target=0.9))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(10):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET
aborted = json.loads((ws.root / "rounds" / "aborted_r01.json").read_text())
assert aborted["index"] == 1 and aborted["usage"]["cost_usd"] > 0 and "BudgetExceeded" in aborted["notes"]
@@ -533,7 +536,7 @@ def test_a_run_past_its_hard_ceiling_cannot_start_another_session(tmp_ws):
from codeverse.contracts.spec import Budget
from codeverse.orchestrator import BudgetExceeded, BudgetGuard
- g = BudgetGuard(Budget(max_usd=10.0, max_minutes=30.0, max_rounds=4), run="t")
+ g = BudgetGuard(Budget(max_minutes=30.0, max_rounds=4), run="t")
g.start_time -= 36 * 60 # ceiling long crossed, nothing billed along the way
agent = _TurnAgent(writes_on=1)
with pytest.raises(BudgetExceeded):
diff --git a/harness/tests/orchestrator_tracks/test_tracks.py b/harness/tests/orchestrator_tracks/test_tracks.py
index a0f696ed..6fc29a5f 100644
--- a/harness/tests/orchestrator_tracks/test_tracks.py
+++ b/harness/tests/orchestrator_tracks/test_tracks.py
@@ -17,7 +17,7 @@ from codeverse.tracks.planner import plan_example
from codeverse.tracks.scene import SceneTrack
from codeverse.tracks.static_object import StaticObjectTrack
from codeverse.workspace import Workspace
-from tests.orchestrator_tracks.conftest import make_spec
+from tests.orchestrator_tracks.conftest import clock_trips_after, make_spec
from tests.orchestrator_tracks.fakes import (
FAIL_MARK,
FakeAgent,
@@ -86,7 +86,7 @@ def test_static_track_end_to_end_agent_path(tmp_path, chair_plan, settings):
def test_static_track_single_shot_with_repair_and_budget_stop(tmp_path, chair_plan, settings):
- spec = make_spec(generator="single-shot:gemini:fake", max_rounds=4, max_usd=0.03)
+ spec = make_spec(generator="single-shot:gemini:fake", max_rounds=4, max_minutes=0.0)
ws = Workspace(tmp_path / "runs" / "chair2")
n = {"gen": 0}
@@ -99,7 +99,9 @@ def test_static_track_single_shot_with_repair_and_budget_stop(tmp_path, chair_pl
model = FakeChatModel(responder, cost=0.004)
track = StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=(0.5, 0.55, 0.6, 0.62)), model=model,
planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings, runtime=FakeRuntime(Language.THREEJS))
- rec = track.run(spec, ws)
+ # the clock runs out mid-run: what this pins never depended on money
+ with clock_trips_after(8):
+ rec = track.run(spec, ws)
assert rec.status is RunStatus.BUDGET and rec.rounds[0].build.ok and "repair attempts: 1/2 (fixed)" in rec.rounds[0].notes
assert rec.rounds[0].score == pytest.approx(0.5)
assert any(r.label.startswith("r00_baseline_repair") for r in model.requests) or any("Repair" in r.messages[0].text for r in model.requests)