Skip to content

Official Codebase of 3DCodeVerse

Python

tests: orchestrator_tracks, third pass — scenario tests share one run (164 → 139, −160 lines)

gaoypengf01eb3fa2564
diff --git a/harness/tests/orchestrator_tracks/test_budget_snapshot.py b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
index 482ffbfc..0006d13f 100644
--- a/harness/tests/orchestrator_tracks/test_budget_snapshot.py
+++ b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
@@ -68,7 +68,7 @@ def test_build_context_restores_the_budget_snapshot(tmp_path, settings):
# --------------------------------------------------------------- ordering: single-shot
-def test_a_paid_single_shot_response_is_persisted_when_the_budget_trips(tmp_path):
+def test_a_paid_single_shot_response_is_persisted_when_the_budget_trips_and_the_next_is_not_bought(tmp_path):
ws = Workspace(tmp_path / "ws").create()
guard = BudgetGuard(Budget(max_minutes=1.0))
answer = ("=== FILE: src/object.js ===\n"
@@ -87,17 +87,11 @@ def test_a_paid_single_shot_response_is_persisted_when_the_budget_trips(tmp_path
assert res.transcript_path and Path(res.transcript_path).is_file()
assert sum(r.cost_usd for r in load_ledger(ws.root)) == pytest.approx(0.05) # booked, dollar for dollar
assert not guard.ok() # the phase boundary (steps._run_phase) turns this into the stop
-
-
-def test_single_shot_past_the_ceiling_buys_no_call(tmp_path):
- ws = Workspace(tmp_path / "ws").create()
- task = GenerationTask(label="baseline", prompt="p", files_hint=["src/object.js"], max_output_tokens=1000)
+ # and once past the ceiling a single-shot buys no call at all
calls: list = []
model = FakeChatModel(lambda req: calls.append(req) or "", cost=0.01)
- past = BudgetGuard(Budget(max_minutes=1.0))
- past._active_s = 120.0 # noqa: SLF001 — already past 1 min
with pytest.raises(BudgetExceeded):
- generate_files(ws, model=model, task=task, budget=past)
+ generate_files(ws, model=model, task=task.model_copy(update={"max_output_tokens": 1000}), budget=guard)
assert calls == [] # refused BEFORE any model call
@@ -124,7 +118,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_ledger_when_attempt_one_raises(tmp_path):
+def test_every_paid_planner_attempt_is_booked_once_whether_the_next_raises_or_never_validates(tmp_path):
guard = BudgetGuard(Budget(max_minutes=10.0))
ws = Workspace(tmp_path / "run").create()
calls = {"n": 0}
@@ -141,18 +135,11 @@ def test_planner_attempt_zero_usage_reaches_the_ledger_when_attempt_one_raises(t
assert calls["n"] == 2
paid, failed = load_ledger(ws.root) # attempt 0's dollars are booked; the crash is a $0 error row
assert (paid.stage, paid.cost_usd, failed.outcome, failed.cost_usd) == ("plan", pytest.approx(0.01), "error", 0.0)
-
-
-def test_planning_error_dollars_are_booked_exactly_once(tmp_path):
- guard = BudgetGuard(Budget(max_minutes=10.0))
- ws = Workspace(tmp_path / "run").create()
-
- def responder(req):
- return {"object_name": "Chair"} # never validates
-
+ # a plan that never validates: every paid attempt is booked exactly once
+ ws = Workspace(tmp_path / "run2").create()
with run_ledger(ws.root), pytest.raises(PlanningError) as ei:
run_planner(make_spec(), "fake:planner", StaticPlan, ws,
- model=metered_chat_model(FakeChatModel(responder, cost=0.01)), budget=guard)
+ model=metered_chat_model(FakeChatModel(lambda req: {"object_name": "Chair"}, cost=0.01)), budget=guard)
n = 1 + MAX_VALIDATION_REASKS # every paid attempt, each booked once
assert sum(r.cost_usd for r in load_ledger(ws.root)) == pytest.approx(0.01 * n)
assert ei.value.usage.cost_usd == pytest.approx(0.01 * n) # the error still reports the total
diff --git a/harness/tests/orchestrator_tracks/test_cost_accounting.py b/harness/tests/orchestrator_tracks/test_cost_accounting.py
index 534a4666..bec438d0 100644
--- a/harness/tests/orchestrator_tracks/test_cost_accounting.py
+++ b/harness/tests/orchestrator_tracks/test_cost_accounting.py
@@ -80,13 +80,3 @@ def test_every_recorded_dollar_reaches_the_ledger_once(name, tmp_path):
retried = [s for s in fx["sessions"] if s["attempt"] > 1]
assert sum(1 for r in rows if r.label.endswith(".a2")) == len(retried)
-
-def test_the_round_the_budget_cut_is_still_in_the_total(tmp_path):
- fx = FIXTURES["tool_med_hand_drill"]
- assert fx["rounds_in_record"] == [0, 1]
- cut = [s for s in fx["sessions"] if s["round"] == 2]
- assert cut, "fixture must contain the round the budget cut"
- total = replay("tool_med_hand_drill", tmp_path)
- burned = sum(s["cost_usd"] for s in cut)
- assert sum(r.cost_usd for r in load_ledger(tmp_path) if r.round == 2) == pytest.approx(burned, abs=1e-6)
- assert burned > 0.8 and total > burned # $0.86 that record.rounds never mentioned, inside the total
diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.py
index 60a5a06f..d2804530 100644
--- a/harness/tests/orchestrator_tracks/test_cost_latency.py
+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py
@@ -26,7 +26,6 @@ from codeverse3d.tracks.scene_assets import (
check_threejs_asset,
dedupe_assets,
run_asset_stage,
- select_assets,
variant_index,
)
from codeverse3d.workspace import Workspace
@@ -48,7 +47,7 @@ needs_node = pytest.mark.skipif(
# ----------------------------------------------------------------------------- soft budget
-def test_soft_budget_degrades_before_the_hard_cap_and_grace_reopens_it():
+def test_soft_budget_degrades_before_the_hard_cap_and_the_timeout_is_clipped():
clock = {"t": 0.0}
g = BudgetGuard(Budget(max_minutes=10.0), soft_fraction=0.55)
g.start_time = 0.0
@@ -67,9 +66,7 @@ def test_soft_budget_degrades_before_the_hard_cap_and_grace_reopens_it():
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)
-
-
-def test_timeout_is_clipped_to_the_wall_clock_left():
+ # a session timeout is clipped to the wall clock left
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
@@ -93,9 +90,7 @@ def test_dedupe_folds_near_identical_props_into_one_variant_factory():
assert "opts.variant" in kept[0].description and "variant 1 = PondRock" in kept[0].description
# HeroBoulder is 6× the stepping stone → a different prop, not a variant
assert "HeroBoulder" not in alias
-
-
-def test_dedupe_is_a_no_op_for_unrelated_assets_and_reaches_the_zone_prompt():
+ # a no-op for unrelated assets, and the merge reaches the zone prompt
plan = ScenePlan.model_validate(plan_example(Track.SCENE))
kept, alias = dedupe_assets(list(plan.assets))
assert not alias and len(kept) == len(plan.assets)
@@ -158,13 +153,6 @@ def _events(ctx) -> list[dict]:
return [json.loads(line) for line in ctx.ws.events_path.read_text().splitlines() if line.strip()]
-def test_asset_check_names_the_file_that_was_never_written(tmp_path, settings):
- services = FakeServices()
- ctx = _scene_ctx(tmp_path, settings, services=services)
- chk = check_threejs_asset(ctx, "src/assets/missing.js", "Missing")
- assert not chk.ok and chk.ran and chk.fatal and "was not written" in chk.errors[0]
-
-
# a CLI session that died at the wall after a 503 streak: nothing written, transient
STORM_DEATH = AgentResult(ok=False, exit_reason="timeout", transient=True,
errors=["killed by watchdog (hard_timeout) after 720s", "11 x 503 inside the CLI's own retry loop before the wall; nothing produced"])
@@ -237,15 +225,6 @@ def test_a_merged_asset_leaves_a_working_shim_not_the_placeholder_box(tmp_path,
assert chk.ok and chk.meshes == 2, "the shim resolves to the real factory, not the blockout stub"
-def test_asset_selection_folds_only_over_the_cap():
- twins = [_asset("PondRock", (1.1, 0.75, 0.9)), _asset("SteppingStone", (0.65, 0.12, 0.55))]
- kept, alias = select_assets(twins, cap=8)
- assert [k.name for k in kept] == ["PondRock", "SteppingStone"] and not alias
- kept, alias = select_assets(twins, cap=1)
- assert [k.name for k in kept] == ["PondRock"] and alias == {"SteppingStone": "PondRock"}
-
-
-
def test_a_clock_that_trips_after_a_finished_zones_session_records_what_it_wrote(tmp_path, settings):
"""Q1: the cached zones result records the zones the session wrote before its charge crossed the ceiling."""
from tests.orchestrator_tracks.conftest import FAKE_CLOCK
@@ -303,6 +282,8 @@ def test_stages_that_spend_the_clock_without_raising_still_get_a_salvaged_round(
def test_an_imperfect_asset_stays_available_but_a_broken_one_does_not(tmp_path, settings):
services = FakeServices()
ctx = _scene_ctx(tmp_path, settings, services=services)
+ chk = check_threejs_asset(ctx, "src/assets/missing.js", "Missing")
+ assert not chk.ok and chk.ran and chk.fatal and "was not written" in chk.errors[0]
(ctx.ws.src / "assets").mkdir(parents=True, exist_ok=True)
(ctx.ws.src / "assets" / "small.js").write_text(_module("Small", 0.5, 0.5, 0.5))
off = check_threejs_asset(ctx, "src/assets/small.js", "Small", expected_size_m=(4.0, 4.0, 4.0))
diff --git a/harness/tests/orchestrator_tracks/test_fix_batch2.py b/harness/tests/orchestrator_tracks/test_fix_batch2.py
index c6a22a0e..c4c6bdb2 100644
--- a/harness/tests/orchestrator_tracks/test_fix_batch2.py
+++ b/harness/tests/orchestrator_tracks/test_fix_batch2.py
@@ -96,7 +96,6 @@ class _RebuildFails(FakeRuntime):
return super().build(ws, timeout_s=timeout_s)
-# --------------------------------------------------------------------- finding: spent usage persisted on crash paths
# --------------------------------------------------------------------- finding: degraded judge verdicts are glitches, not scores
def test_degraded_verdict_never_scores_and_run_stops_as_judge_unavailable(tmp_path, chair_plan, settings):
spec = make_spec(max_rounds=3)
diff --git a/harness/tests/orchestrator_tracks/test_fixed_rounds.py b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
index e06e60b5..dde431b7 100644
--- a/harness/tests/orchestrator_tracks/test_fixed_rounds.py
+++ b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
@@ -3,8 +3,6 @@ each built on the round before it, and only the clock or a hard failure ends it
from __future__ import annotations
-import pytest
-
from codeverse3d.contracts.common import Language
from codeverse3d.contracts.run import RunStatus
from codeverse3d.proc import EventLog
@@ -27,12 +25,10 @@ def _track(chair_plan, settings, scores, *, agent=None) -> StaticObjectTrack:
runtime=FakeRuntime(Language.CADQUERY))
[email protected](("scores", "max_rounds"), [
- ((0.55, 0.85, 0.95), 3), # passes at r01 — once a "pass" stop
- ((0.70, 0.40, 0.30), 3), # regresses twice — once a "regression" stop
-], ids=["passing", "regressing"])
-def test_a_run_is_the_baseline_plus_max_rounds_whatever_the_judge_says(tmp_path, chair_plan, settings, scores,
- max_rounds):
+def test_a_run_is_the_baseline_plus_max_rounds_whatever_the_judge_says(tmp_path, chair_plan, settings):
+ """A run that passes at r01 (once a "pass" stop) still runs every round; the regressing twin
+ is ``test_every_refine_starts_from_the_previous_rounds_commit`` and the D84 loop test."""
+ scores, max_rounds = (0.55, 0.85, 0.95), 3
ws = Workspace(tmp_path / "runs" / "fixed")
rec = _track(chair_plan, settings, scores).run(make_spec(language=Language.CADQUERY, max_rounds=max_rounds), ws)
assert len(rec.rounds) == max_rounds + 1
diff --git a/harness/tests/orchestrator_tracks/test_generation_depth.py b/harness/tests/orchestrator_tracks/test_generation_depth.py
index caba67c7..c6b016e5 100644
--- a/harness/tests/orchestrator_tracks/test_generation_depth.py
+++ b/harness/tests/orchestrator_tracks/test_generation_depth.py
@@ -2,13 +2,9 @@
from __future__ import annotations
-import re
-
from codeverse3d.contracts.common import Language
-from codeverse3d.contracts.plan import BBox, PartPlan, StaticPlan
from codeverse3d.conventions import to_snake
from codeverse3d.tracks.depth import (
- DETAIL_ADVICE,
PartScope,
interfaces_text,
scope_groups,
@@ -23,7 +19,7 @@ def _files_for(name):
# ----------------------------------------------------------------------------- scoping
-def test_scope_groups_partitions_along_the_attachment_tree(chair_plan):
+def test_scope_groups_partition_the_attachment_tree_and_name_the_outside_neighbours(chair_plan):
scopes = scope_groups(chair_plan, files_for=_files_for, max_groups=6, min_parts=3)
assert len(scopes) >= 2
names = [n for s in scopes for n in s.names]
@@ -36,10 +32,7 @@ def test_scope_groups_partitions_along_the_attachment_tree(chair_plan):
assert scope_groups(chair_plan, files_for=_files_for, min_parts=99) == [] # small plan
assert scope_groups(chair_plan, files_for=None, min_parts=3) == [] # no per-part files
assert scope_groups(chair_plan, files_for=_files_for, max_groups=1, min_parts=3) == []
-
-
-def test_interfaces_text_names_only_the_neighbours_outside_the_scope(chair_plan):
- scopes = scope_groups(chair_plan, files_for=_files_for, max_groups=6, min_parts=3)
+ # the interface table names only the neighbours outside the scope
backleg = next(s for s in scopes if "BackLeg" in s.names)
text = interfaces_text(chair_plan, backleg)
rows = [ln for ln in text.splitlines() if ln.startswith("| ") and "---" not in ln][1:]
@@ -52,19 +45,6 @@ def test_interfaces_text_names_only_the_neighbours_outside_the_scope(chair_plan)
# ----------------------------------------------------------------------------- the track wiring
-def big_plan(n: int = 11) -> StaticPlan:
- """A plan past the scoping threshold, with a real attachment tree (Body → N children)."""
- parts = [PartPlan(name="Body", role="main mass", description="the shell",
- bbox=BBox(center=(0, 0.5, 0), extents=(0.6, 1.0, 0.4)))]
- for i in range(n - 1):
- parts.append(PartPlan(name=f"Fitting{i}", role=f"fitting {i}", description="a fitting with a bevel",
- bbox=BBox(center=(0.05 * i, 0.2 + 0.05 * i, 0.1), extents=(0.05, 0.05, 0.05)),
- attach_to="Body"))
- return StaticPlan(object_name="Machine", summary="A machine, 0.6 x 0.4 x 1.0 m.",
- overall_bbox=BBox(center=(0, 0.5, 0), extents=(0.6, 1.0, 0.4)), parts=parts,
- acceptance=[])
-
-
def _ctx(tmp_path, plan, settings, *, language=Language.THREEJS, agent_id="fake-agent:m"):
from codeverse3d.orchestrator import RunState
from codeverse3d.proc import EventLog
@@ -80,23 +60,6 @@ def _ctx(tmp_path, plan, settings, *, language=Language.THREEJS, agent_id="fake-
return track, ctx
-def test_scoped_baseline_fans_out_and_the_assembly_session_owns_the_entry(tmp_path, settings):
- track, ctx = _ctx(tmp_path, big_plan(), settings)
- tasks = track.baseline_tasks(ctx)
- assert len(tasks) >= 3
- parts, assemble = tasks[:-1], tasks[-1]
- assert {t.phase for t in parts} == {0} and assemble.phase == 1 # assembly sees the part files
- assert assemble.label == "assemble" and assemble.files_hint == ["src/object.js"]
- owned = [f for t in parts for f in t.files_hint]
- assert len(owned) == len(set(owned)) and "src/object.js" not in owned # file-disjoint, no entry
- assert all(t.kind == "baseline" and t.round == 0 for t in tasks)
- # every scoped prompt carries ITS parts, the interface table and the detail advice — not the plan
- one = parts[0]
- assert "Interfaces" in one.prompt and DETAIL_ADVICE in one.prompt
- assert not re.search(r"\d", DETAIL_ADVICE), "the budget is enforced by budget_gate; the advice states no number"
- assert "FILES YOU MAY WRITE" in one.prompt
-
-
def test_phases_run_in_order_and_a_failed_phase_does_not_kill_the_round(tmp_path, chair_plan, settings):
"""``run_generation_tasks`` is the only place that knows about phases."""
from codeverse3d.tracks.generation import GenerationResult, GenerationTask
diff --git a/harness/tests/orchestrator_tracks/test_generation_planner_repair.py b/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
index 3e30a6b5..e6473e28 100644
--- a/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
+++ b/harness/tests/orchestrator_tracks/test_generation_planner_repair.py
@@ -28,7 +28,6 @@ from codeverse3d.tracks.planner import (
)
from codeverse3d.tracks.repair import (
build_with_repair,
- relevant_cookbook_section,
)
from tests.orchestrator_tracks.conftest import make_spec
from tests.orchestrator_tracks.fakes import (
@@ -140,7 +139,7 @@ def test_planner_validates_retries_and_writes(tmp_ws):
assert "plan.invalid" in kinds and "plan.done" in kinds
-def test_ensure_acceptance_is_idempotent():
+def test_ensure_acceptance_is_idempotent_and_only_the_scene_spec_must_haves_gate():
p = StaticPlan.model_validate(_valid_plan_dict())
spec = make_spec()
n1 = len(ensure_acceptance(p, spec).acceptance)
@@ -148,9 +147,7 @@ def test_ensure_acceptance_is_idempotent():
assert n1 == n2 and any(a.how == "measure" for a in p.acceptance)
# an object plan's own items keep their priority: there IS a measurement pass to settle them
assert all(a.priority == "must" for a in p.acceptance)
-
-
-def test_scene_plan_items_are_advisory_and_only_the_spec_must_haves_gate():
+ # a scene plan's own items are advisory: only the spec's must-haves gate
from codeverse3d.contracts.plan import AcceptanceItem
p = ScenePlan.model_validate(plan_example(Track.SCENE))
@@ -193,15 +190,6 @@ def test_build_with_repair_single_shot_sends_file_contents_and_stops_at_max(tmp_
assert out.usage.cost_usd == pytest.approx(0.004)
-def test_repair_cookbook_sections_are_the_prompt_sections():
- """Repair splits the cookbook with ``prompts.sections`` (its own ``^##+`` regex went,
- identical on all 7 shipped cookbooks): a ``## `` comment inside a fence is code, not
- a heading that cuts the recipe in half."""
- cb = ("## Hinges\nhinge pivot axis revolute\n```python\n## pivot axis note\nhinge = 1\n```\n"
- "## Materials\nroughness metalness\n")
- got = relevant_cookbook_section(cb, "hinge pivot axis wrong")
- assert got.startswith("## Hinges") and "hinge = 1" in got and "Materials" not in got
-
def test_repair_rel_strips_a_prefix_not_a_character_set(tmp_ws):
"""B14: ``lstrip("./")`` turned ``../x`` into ``x`` and ``.env.js`` into ``env.js``."""
from types import SimpleNamespace
diff --git a/harness/tests/orchestrator_tracks/test_integrations2.py b/harness/tests/orchestrator_tracks/test_integrations2.py
index 11f31ecb..2c4e17c1 100644
--- a/harness/tests/orchestrator_tracks/test_integrations2.py
+++ b/harness/tests/orchestrator_tracks/test_integrations2.py
@@ -58,13 +58,16 @@ def test_each_runtime_states_which_file_owns_what(chair_plan):
# --------------------------------------------------------------------- (f) no texture pass in the run
def test_the_run_itself_never_textures_even_when_asked(tmp_path, chair_plan, settings, monkeypatch):
- """The texture pass belongs to the hand-over of the PICKED round, not to finalise."""
+ """D31: the texture pass belongs to the hand-over of the PICKED round, not to finalise. The same
+ run shows the track handing the plan's attach_to pairs to the connectivity gate, spelled in the
+ GLB's part names (the gate's contact ledger is the judge's assembly_fit ground truth)."""
import codeverse3d.texturing.run as trun
def boom(*a, **kw):
raise AssertionError("texture_pass must not run inside a run")
monkeypatch.setattr(trun, "texture_pass", boom)
- for tags in ([], ["texture"]):
- rec, ws, judge, services = _static_run(tmp_path / (tags[0] if tags else "plain"), chair_plan, settings, tags=tags)
- assert "texturing" not in rec.extra
+ rec, _ws, _judge, services = _static_run(tmp_path, chair_plan, settings, tags=["texture"])
+ assert "texturing" not in rec.extra
+ # the fake build exports one node per plan part under the plan's own name (no instance copies)
+ assert services.planned_edges == [[("FrontLeg", ("Seat",)), ("BackLeg", ("Seat",)), ("Backrest", ("BackLeg",)), ("Armrest", ("BackLeg",))]]
diff --git a/harness/tests/orchestrator_tracks/test_likeness_routing.py b/harness/tests/orchestrator_tracks/test_likeness_routing.py
index 64a050e4..14225770 100644
--- a/harness/tests/orchestrator_tracks/test_likeness_routing.py
+++ b/harness/tests/orchestrator_tracks/test_likeness_routing.py
@@ -28,7 +28,7 @@ def test_graphics_note_asks_for_the_physics_not_a_silhouette(tmp_path):
assert reference_note(_ctx(Track.GRAPHICS, [str(tmp_path / "gone.png")])) == ""
-def test_make_judge_routes_photos_to_the_likeness_judge():
+def test_make_judge_routes_photos_to_the_likeness_judge_and_a_replay_picks_the_same():
calls: list[tuple[str, str]] = []
services = SimpleNamespace(
likeness_judge=lambda model, n_samples, rubric: calls.append(("likeness", rubric)) or "L",
@@ -41,11 +41,9 @@ def test_make_judge_routes_photos_to_the_likeness_judge():
assert BaseTrack.make_judge(me, _ctx(Track.STATIC_OBJECT, ["/x.png"])) == "R"
assert BaseTrack.make_judge(me, _ctx(Track.GRAPHICS, [])) == "P"
assert calls[0] == ("likeness", "shader_v1")
-
-
-def test_a_replay_picks_the_judge_the_live_run_did():
- """`3dcode judge` / calibration and the live run share `judge_for`: a graphics or scene run
- with photos was re-judged by ReferenceJudge (silhouette + diff pass) where the run used likeness."""
+ # a replay picks the judge the live run did: `3dcode judge` / calibration and the live run share
+ # `judge_for` — a graphics or scene run with photos was re-judged by ReferenceJudge (silhouette +
+ # diff pass) where the run used likeness
from codeverse3d.cli._judge import make_judge
from codeverse3d.judges.vlm_judge import LikenessJudge, ReferenceJudge, VlmJudge, judge_for
diff --git a/harness/tests/orchestrator_tracks/test_orchestrator.py b/harness/tests/orchestrator_tracks/test_orchestrator.py
index 8dfcb80d..48c72363 100644
--- a/harness/tests/orchestrator_tracks/test_orchestrator.py
+++ b/harness/tests/orchestrator_tracks/test_orchestrator.py
@@ -90,7 +90,7 @@ def test_an_unreadable_cached_stage_is_a_miss_not_a_dead_run(tmp_ws):
# ----------------------------------------------------------------------------- refine instructions
-def test_build_refine_instructions_merges_and_groups(chair_plan):
+def test_build_refine_instructions_merges_groups_and_the_cap_protects_gate_tasks(chair_plan):
judgment = Judgment(rubric="r", scores={}, overall=0.6, passed=False, improvement_plan=[
ImprovementItem(target="seat", kind="geometry", instruction="thicker seat", priority=2),
ImprovementItem(target="Backrest", kind="material", instruction="warmer oak", priority=1),
@@ -119,9 +119,7 @@ def test_build_refine_instructions_merges_and_groups(chair_plan):
one = plan_parallel_groups(tasks + [RefineTask(target="x", kind="geometry", instruction="i", priority=3)])
assert len(one) == 1
assert build_refine_instructions(None, [], [], chair_plan) == []
-
-
-def test_refine_cap_protects_gate_tasks(chair_plan):
+ # the task cap never drops a gate task
gates = [GateReport(gate="g", passed=False, findings=[GateFinding(gate="g", severity=Severity.ERROR, target=f"P{i}", message=f"e{i}") for i in range(8)])]
judgment = Judgment(rubric="r", scores={}, overall=0.5, passed=False, improvement_plan=[
ImprovementItem(target=f"J{i}", kind="geometry", instruction="x", priority=1) for i in range(5)])
diff --git a/harness/tests/orchestrator_tracks/test_planner_depth.py b/harness/tests/orchestrator_tracks/test_planner_depth.py
index e4d44372..99fd8bab 100644
--- a/harness/tests/orchestrator_tracks/test_planner_depth.py
+++ b/harness/tests/orchestrator_tracks/test_planner_depth.py
@@ -23,7 +23,6 @@ from codeverse3d.contracts.plan import (
from codeverse3d.contracts.spec import Constraints, ReferenceImage, Spec
from codeverse3d.models.base import ModelError
from codeverse3d.tracks import planner as B
-from codeverse3d.tracks import planner as BR
from codeverse3d.tracks.planner import (
MAX_QUALITY_REASKS,
build_user_prompt,
@@ -158,12 +157,18 @@ def _brief() -> EngineeringBrief:
materials=["body: beech, warm brown"])
-def test_brief_block_carries_every_lever_into_the_prompt():
- text = BR.brief_block(_brief())
+def test_brief_block_and_enrichment_carry_every_lever_into_the_plan():
+ text = B.brief_block(_brief())
for needle in ("Peugeot", "burr mechanism", "does NOT have", "electric motor", "SIGNATURE FEATURES",
"open hopper", "NOT visible", "0.140"):
assert needle in text
- assert BR.brief_block(None) == ""
+ assert B.brief_block(None) == ""
+ # enrichment adds the signature features as SHOULD items only
+ plan = _plan([_part("P0")])
+ B.enrich_plan(plan, _brief())
+ sig = [a for a in plan.acceptance if a.id.startswith("sig")]
+ assert len(sig) == 3 and all(a.priority == "should" for a in sig)
+ assert "Peugeot" in plan.style_notes and "electric motor" in plan.style_notes
def test_brief_is_cached_by_prompt_hash_and_the_second_call_is_free(tmp_path):
@@ -175,11 +180,11 @@ def test_brief_is_cached_by_prompt_hash_and_the_second_call_is_free(tmp_path):
model = FakeChatModel(responder)
spec = _spec()
- first, u1 = BR.expand_brief(spec, "fake:planner", model=model, cache_dir=tmp_path)
- second, u2 = BR.expand_brief(spec, "fake:planner", model=model, cache_dir=tmp_path)
+ first, u1 = B.expand_brief(spec, "fake:planner", model=model, cache_dir=tmp_path)
+ second, u2 = B.expand_brief(spec, "fake:planner", model=model, cache_dir=tmp_path)
assert calls["n"] == 1 and first == second and u2.cost_usd == 0.0
# a different request is a different key
- BR.expand_brief(_spec("a violin"), "fake:planner", model=model, cache_dir=tmp_path)
+ B.expand_brief(_spec("a violin"), "fake:planner", model=model, cache_dir=tmp_path)
assert calls["n"] == 2
@@ -197,15 +202,13 @@ def test_an_image_run_does_not_drink_the_no_image_brief(tmp_path):
model = FakeChatModel(responder)
plain = _spec()
withref = plain.model_copy(update={"references": [ReferenceImage(path=str(img))]})
- BR.expand_brief(plain, "fake:planner", model=model, cache_dir=cache)
- BR.expand_brief(withref, "fake:planner", model=model, cache_dir=cache)
+ B.expand_brief(plain, "fake:planner", model=model, cache_dir=cache)
+ B.expand_brief(withref, "fake:planner", model=model, cache_dir=cache)
assert calls == [0, 1] # the reference run made its own, grounded call
-
-
-def test_an_unreadable_reference_never_collapses_onto_no_references(tmp_path):
+ # an unreadable reference never collapses onto no references
missing = _spec().model_copy(update={"references": [ReferenceImage(path=str(tmp_path / "gone.png"))]})
- assert BR.brief_cache_key(missing, "m") != BR.brief_cache_key(_spec(), "m")
+ assert B.brief_cache_key(missing, "m") != B.brief_cache_key(_spec(), "m")
@pytest.mark.parametrize("error, billed", [
@@ -213,18 +216,10 @@ def test_an_unreadable_reference_never_collapses_onto_no_references(tmp_path):
(ModelError("bad json", usage=Usage(backend="fake", cost_usd=0.002)), 0.002),
])
def test_a_failed_brief_is_never_fatal_and_keeps_what_the_provider_billed(tmp_path, error, billed):
- brief, usage = BR.expand_brief(_spec(), "fake:planner", model=FakeChatModel([error]), cache_dir=tmp_path)
+ brief, usage = B.expand_brief(_spec(), "fake:planner", model=FakeChatModel([error]), cache_dir=tmp_path)
assert brief is None and usage.cost_usd == pytest.approx(billed)
-def test_enrichment_adds_signature_features_as_SHOULD_items_only():
- plan = _plan([_part("P0")])
- B.enrich_plan(plan, _brief())
- sig = [a for a in plan.acceptance if a.id.startswith("sig")]
- assert len(sig) == 3 and all(a.priority == "should" for a in sig)
- assert "Peugeot" in plan.style_notes and "electric motor" in plan.style_notes
-
-
def test_graphics_pass_elements_are_folded_into_the_one_markdown_row_that_renders_them():
"""The fold into the passes table row is single-line and idempotent."""
from codeverse3d.contracts.plan import PassPlan
diff --git a/harness/tests/orchestrator_tracks/test_planner_reask.py b/harness/tests/orchestrator_tracks/test_planner_reask.py
index 70025233..9cb58c12 100644
--- a/harness/tests/orchestrator_tracks/test_planner_reask.py
+++ b/harness/tests/orchestrator_tracks/test_planner_reask.py
@@ -46,26 +46,20 @@ def test_every_moving_joint_gets_an_articulation_acceptance_item(tmp_ws):
assert ids.count("art_drawer") == 1 and ids.count("art_lid") == 1
-def test_validation_reask_names_the_missing_parts_when_the_plan_is_thin(tmp_ws):
+def test_the_validation_reask_names_a_thin_plans_missing_parts_and_a_schema_echo(tmp_ws):
thin = _good()
thin["parts"] = thin["parts"][:1] # only the cabinet ...
thin["joints"] = [] # ... and no joint references the dropped link
thin["root_link"] = "NoSuchLink" # a plain validation failure to trigger the re-ask
- answers = [thin, _good()]
- model = FakeChatModel(lambda req: answers.pop(0))
- p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model)
- assert isinstance(p, ArticulatedPlan) and len(model.requests) == 2
- reask = model.requests[1].messages[-1].text
- assert "failed validation" in reask and "lists only 1 part(s)" in reask and "needs about" in reask
-
-
-def test_schema_echo_is_named_in_the_reask(tmp_ws):
echo = _good()
echo["joints"][0]["name"] = "string"
echo["joints"][0]["axis"] = [0, 0, 0]
- answers = [echo, _good()]
+ answers = [thin, _good(), echo, _good()]
model = FakeChatModel(lambda req: answers.pop(0))
- p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model)
- assert isinstance(p, ArticulatedPlan) and len(model.requests) == 2
- reask = model.requests[1].messages[-1].text
- assert "echoes the schema" in reask and "joints[0].name" in reask and "zero axis" not in reask
+ for n, needles, absent in ((2, ("failed validation", "lists only 1 part(s)", "needs about"), None),
+ (4, ("echoes the schema", "joints[0].name"), "zero axis")):
+ p = plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model)
+ assert isinstance(p, ArticulatedPlan) and len(model.requests) == n
+ reask = model.requests[n - 1].messages[-1].text
+ assert all(x in reask for x in needles), reask
+ assert absent is None or absent not in reask
diff --git a/harness/tests/orchestrator_tracks/test_prompts_assets.py b/harness/tests/orchestrator_tracks/test_prompts_assets.py
index 151db856..8e9478ca 100644
--- a/harness/tests/orchestrator_tracks/test_prompts_assets.py
+++ b/harness/tests/orchestrator_tracks/test_prompts_assets.py
@@ -66,10 +66,15 @@ def test_scene_templates_render_and_asset_stage_with_blender(tmp_ws, settings):
assert crate_jobs == ["asset_crate", "asset_crate_fix"] and crate.fixed
assert (tmp_ws.root / "_assets" / "crate" / "src" / "model.py").is_file() and "_assets/" in (tmp_ws.root / ".gitignore").read_text()
assert results["FishingBoat"].ok and results["FishingBoat"].path == "src/assets/fishing_boat.js"
- # blender twin of the S2 reuse: the committed GLB short-circuits the second stage run
+ # S2 reuse: a committed GLB and a committed, import-clean module short-circuit the second
+ # stage run without a model call ...
n_jobs = len(agent.jobs)
again = run_asset_stage(ctx)
- assert len(agent.jobs) == n_jobs and again["Crate"].strategy == "reused" and again["Crate"].ok
+ assert len(agent.jobs) == n_jobs, "a committed passing asset must not be re-paid"
+ assert again["Crate"].strategy == "reused" and again["Crate"].ok
+ boat = results["FishingBoat"]
+ assert again["FishingBoat"].strategy == "reused" and again["FishingBoat"].ok
+ assert again["FishingBoat"].path == boat.path and again["FishingBoat"].size_m is not None
api = asset_api_summary(plan, results)
assert "buildFishingBoat" in api and "public/assets/crate.glb" in api
sub = asset_plan(plan.assets[2])
@@ -86,26 +91,8 @@ def test_scene_templates_render_and_asset_stage_with_blender(tmp_ws, settings):
sa = render("tracks/scene_asset.j2", **base_prompt_context(ctx, asset_name="Bollard", asset_kind="threejs", asset_description="d", asset_size=(0.3, 0.5, 0.3),
asset_file="src/assets/bollard.js", asset_language="scene_threejs", fix_instructions=["- x"], current_code=""))
assert "buildBollard" in sa and "FIX PASS" in sa
+ # ... but a committed, import-broken module is NOT reused: it goes back through generation
+ (tmp_ws.root / boat.path).write_text("export function nope() {}\n")
+ third = run_asset_stage(ctx)
+ assert len(agent.jobs) > n_jobs and third["FishingBoat"].strategy != "reused"
-
[email protected] # the threejs asset check imports three under node
-def test_a_committed_asset_is_reused_on_a_second_stage_run(tmp_ws, settings):
- """A committed, import-clean module is reused without a model call; a broken one is regenerated."""
- plan = ScenePlan.model_validate(plan_example(Track.SCENE))
- plan.assets = [a for a in plan.assets if a.kind == "threejs"]
- spec = make_spec(Track.SCENE, Language.SCENE_THREEJS)
- agent = FakeAgent(lambda job, ws: {job.prompt.split("write `")[1].split("`")[0] if "write `" in job.prompt else "src/x.js": _asset_module(job)})
- ctx = _ctx(tmp_ws, settings, spec, plan, agent_id="fake:x", services=FakeServices(judge=FakeJudge(scores=(0.9, 0.9))), agent=agent)
- ctx.runtime.skeleton(tmp_ws, plan)
- tmp_ws.commit("skeleton")
- results = run_asset_stage(ctx)
- assert results["FishingBoat"].ok and results["FishingBoat"].strategy != "reused"
- n_jobs = len(agent.jobs)
- results2 = run_asset_stage(ctx)
- assert len(agent.jobs) == n_jobs, "a committed passing asset must not be re-paid"
- assert results2["FishingBoat"].strategy == "reused" and results2["FishingBoat"].ok
- assert results2["FishingBoat"].path == results["FishingBoat"].path and results2["FishingBoat"].size_m is not None
- # a committed but import-broken module is NOT reused: it goes back through generation
- (tmp_ws.root / results["FishingBoat"].path).write_text("export function nope() {}\n")
- results3 = run_asset_stage(ctx)
- assert len(agent.jobs) > n_jobs and results3["FishingBoat"].strategy != "reused"
diff --git a/harness/tests/orchestrator_tracks/test_refactor_batch2.py b/harness/tests/orchestrator_tracks/test_refactor_batch2.py
index 6f09c669..9dbb2b1d 100644
--- a/harness/tests/orchestrator_tracks/test_refactor_batch2.py
+++ b/harness/tests/orchestrator_tracks/test_refactor_batch2.py
@@ -11,10 +11,6 @@ from tests.orchestrator_tracks.fakes import (
)
-def _writer(job, ws):
- return {"src/object.js": f"// {job.label} r{job.round}\nexport function build(THREE) {{ return new THREE.Group(); }}\n"}
-
-
# --------------------------------------------------------------------- plan_refine_groups
def _task(target: str, files: list[str] | None = None, priority: int = 2) -> RefineTask:
return RefineTask(target=target, kind="geometry", instruction=f"fix {target}", priority=priority, files=files or [])
diff --git a/harness/tests/orchestrator_tracks/test_resume_reconcile.py b/harness/tests/orchestrator_tracks/test_resume_reconcile.py
index 30505882..a4073f9b 100644
--- a/harness/tests/orchestrator_tracks/test_resume_reconcile.py
+++ b/harness/tests/orchestrator_tracks/test_resume_reconcile.py
@@ -131,8 +131,9 @@ def test_a_planner_outage_on_resume_keeps_the_recorded_history(completed_run):
# --------------------------------------------------------------------- (d) force provenance
-def test_force_resume_with_an_edited_prompt_archives_the_old_rounds(completed_run):
- """`resume --force` after a prompt edit archives the old journal and record under rounds/pre_force/."""
+def test_a_spec_edit_is_refused_without_force_and_archives_the_old_rounds_with_it(completed_run):
+ """A resume after a prompt edit is refused before anything runs; `resume --force` then archives
+ the old journal and record under rounds/pre_force/."""
run = completed_run(max_rounds=0)
ws = run.ws
old_commit = run.record.rounds[0].commit
@@ -141,8 +142,15 @@ def test_force_resume_with_an_edited_prompt_archives_the_old_rounds(completed_ru
prompt="a completely different bar stool")
ws.write_json(ws.spec_path, spec2) # the user edited the prompt
p2 = _planner(run.plan)
- rec2 = run.rerun(planner=p2, spec=spec2, resume=True, force=True)
+ with pytest.raises(SpecChanged, match="--force"):
+ run.rerun(planner=p2, spec=spec2, resume=True)
+ # refused cleanly: nothing archived, nothing spent, nothing overwritten
+ assert p2.requests == [], "no model call before the refusal"
+ assert not (ws.root / "rounds" / "pre_force").exists()
+ assert (ws.root / "rounds" / "r00.json").is_file()
+ assert json.loads(ws.record_path.read_text())["status"] != "failed"
+ rec2 = run.rerun(planner=p2, spec=spec2, resume=True, force=True)
# the old journal + record are ARCHIVED, never paired with the new spec
assert (ws.root / "rounds" / "pre_force" / "r00.json").is_file()
assert (ws.root / "rounds" / "pre_force" / "record.json").is_file()
@@ -159,23 +167,6 @@ def test_force_resume_with_an_edited_prompt_archives_the_old_rounds(completed_ru
assert "resume.spec_changed" in kinds and "resume.reconciled" in kinds
-def test_a_spec_edit_without_force_is_refused_before_anything_runs(completed_run):
- run = completed_run(max_rounds=0)
- ws = run.ws
-
- spec2 = make_spec(language=Language.BLENDER, max_rounds=0,
- prompt="a completely different bar stool")
- ws.write_json(ws.spec_path, spec2)
- p2 = _planner(run.plan)
- with pytest.raises(SpecChanged, match="--force"):
- run.rerun(planner=p2, spec=spec2, resume=True)
- # refused cleanly: nothing archived, nothing spent, nothing overwritten
- assert p2.requests == [], "no model call before the refusal"
- assert not (ws.root / "rounds" / "pre_force").exists()
- assert (ws.root / "rounds" / "r00.json").is_file()
- assert json.loads(ws.record_path.read_text())["status"] != "failed"
-
-
# --------------------------------------------------------------------- (f3) notes survive
def test_notes_survive_a_judge_crash(tmp_path, chair_plan, settings):
class BoomJudge(FakeJudge):
diff --git a/harness/tests/orchestrator_tracks/test_round_economics.py b/harness/tests/orchestrator_tracks/test_round_economics.py
index 2349d0a6..15d2d5d5 100644
--- a/harness/tests/orchestrator_tracks/test_round_economics.py
+++ b/harness/tests/orchestrator_tracks/test_round_economics.py
@@ -140,26 +140,17 @@ def test_skip_judge_reasons_are_only_states_where_the_verdict_is_never_bought(tm
assert skip_judge_reason(ctx, renders=_renders()) == "no judge configured"
-def test_a_round_that_changed_no_file_never_reaches_the_judge_question(tmp_path, spec, settings):
- from codeverse3d.tracks.steps import RoundFailed, run_generation_tasks
-
- idle = FakeAgent(lambda job, ws: AgentResult(ok=True, exit_reason="completed", files_changed=[], usage=Usage(cost_usd=0.01)))
- ctx = _ctx(tmp_path, spec, settings, agent=idle, name="nochange")
- with pytest.raises(RoundFailed):
- run_generation_tasks(ctx, [GenerationTask(label="refine", prompt="p", round=1, kind="refine")])
-
-
-def _ctx(tmp_path, spec, settings, *, policy: RoundPolicy | None = None, agent=None, name: str = "skip"):
+def _ctx(tmp_path, spec, settings):
from codeverse3d.contracts.common import Budget
from codeverse3d.orchestrator import BudgetGuard, RunState
from codeverse3d.tracks.common import RunContext
- ws = Workspace(tmp_path / "runs" / name)
+ ws = Workspace(tmp_path / "runs" / "skip")
ws.create()
return RunContext(spec=spec, ws=ws, events=EventLog(ws.events_path), settings=settings,
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)
+ services=FakeServices(), state=RunState(), policy=RoundPolicy(), track=spec.track,
+ rubric="static_object_v1", agent_id="fake:fake-model", judge=FakeJudge())
# ----------------------------------------------------------------------------- end to end
diff --git a/harness/tests/orchestrator_tracks/test_static_judge_context.py b/harness/tests/orchestrator_tracks/test_static_judge_context.py
index f2e545ae..5d983390 100644
--- a/harness/tests/orchestrator_tracks/test_static_judge_context.py
+++ b/harness/tests/orchestrator_tracks/test_static_judge_context.py
@@ -1,13 +1,12 @@
-"""The static track hands the plan's attach_to pairs to the connectivity gate, spelled in the
-GLB's part names, so the gate's contact ledger can list each planned join as contact/open
-(the judge's assembly_fit ground truth, ``prompt_builder.gates_section``)."""
+"""``planned_joins``: the plan's attach_to pairs spelled in the GLB's part names, so the connectivity
+gate's contact ledger can list each planned join as contact/open (the judge's assembly_fit ground
+truth, ``prompt_builder.gates_section``). The track wiring is in ``test_integrations2``."""
from __future__ import annotations
from codeverse3d.contracts.artifacts import Measurement, PartMeasure
from codeverse3d.contracts.plan import BBox, PartPlan, StaticPlan
from codeverse3d.spatial.contract import planned_joins
-from tests.orchestrator_tracks.test_integrations2 import _static_run
def _measurement(parts: dict[str, tuple[tuple[float, float, float], tuple[float, float, float]]]) -> Measurement:
@@ -16,12 +15,6 @@ def _measurement(parts: dict[str, tuple[tuple[float, float, float], tuple[float,
tri_count=12 * len(rows), n_meshes=len(rows), n_islands=len(rows), parts=rows)
-def test_track_passes_attach_to_pairs_to_the_connectivity_gate(tmp_path, chair_plan, settings):
- _rec, _ws, _judge, services = _static_run(tmp_path, chair_plan, settings)
- # the fake build exports one node per plan part under the plan's own name (no instance copies)
- assert services.planned_edges == [[("FrontLeg", ("Seat",)), ("BackLeg", ("Seat",)), ("Backrest", ("BackLeg",)), ("Armrest", ("BackLeg",))]]
-
-
def test_planned_joins_spell_instances_as_the_glb_does_and_pair_every_touching_parent_copy(chair_plan):
"""Each child copy joins every parent copy it touches, never the cross product."""
leg = lambda x, z: ((x - 0.02, 0.0, z - 0.02), (x + 0.02, 0.41, z + 0.02)) # noqa: E731
@@ -35,9 +28,7 @@ def test_planned_joins_spell_instances_as_the_glb_does_and_pair_every_touching_p
edges = planned_joins(chair_plan, m)
assert edges == [('FrontLeg_0', ('Seat',)), ('FrontLeg_1', ('Seat',)), ('BackLeg_0', ('Seat',)), ('BackLeg_1', ('Seat',)), ('Backrest', ('BackLeg_0', 'BackLeg_1')), ('Armrest_0', ('BackLeg_0',)), ('Armrest_1', ('BackLeg_1',))]
assert "BackLeg_1" not in dict(edges)["Armrest_0"]
-
-
-def test_planned_joins_drop_what_the_mesh_does_not_have():
+ # and a join drops what the mesh does not have
plan = StaticPlan(
object_name="Stool", summary="a stool", overall_bbox=BBox(center=(0, 0.2, 0), extents=(0.3, 0.4, 0.3)),
parts=[PartPlan(name="Top", role="top", description="disc", bbox=BBox(center=(0, 0.39, 0), extents=(0.3, 0.02, 0.3))),
diff --git a/harness/tests/orchestrator_tracks/test_tracks.py b/harness/tests/orchestrator_tracks/test_tracks.py
index 5b5a8eae..41585a84 100644
--- a/harness/tests/orchestrator_tracks/test_tracks.py
+++ b/harness/tests/orchestrator_tracks/test_tracks.py
@@ -122,12 +122,13 @@ def test_scene_children_are_stages_and_a_failed_env_never_repays_assets(tmp_path
assert len(rec.rounds) == 1
-def _mood_replanned(tmp_path, settings, name, *, force):
- """A scene run with r00, whose plan then changes ONLY in `mood` (the spec does not change); resumed,
- with ``--force`` when ``force``. Returns (resumed job labels, event names)."""
+def test_a_mood_only_replan_is_served_from_the_stages_until_a_forced_resume(tmp_path, settings):
+ """A scene run with r00 whose plan then changes ONLY in `mood` (the spec does not change).
+ F5: with r00 on disk, the drifted key serves the recorded stages instead of re-paying them.
+ Q2: the stage key is the whole plan; `resume --force` archives the rounds, so it re-runs env."""
plan = small_scene()
spec = make_spec(Track.SCENE, Language.SCENE_THREEJS, max_rounds=0)
- ws = Workspace(tmp_path / "runs" / name)
+ ws = Workspace(tmp_path / "runs" / "harbour4")
agent = FakeAgent(_scene_writer)
mk = lambda: SceneTrack(services=FakeServices(assemble=True), judge=FakeJudge(scores=(0.6, 0.6)), agent=agent, # noqa: E731
planner_model=_planner(plan.model_dump(mode="json")), settings=settings,
@@ -139,26 +140,21 @@ def _mood_replanned(tmp_path, settings, name, *, force):
assert data["result"]["mood"] != "desolate, horror"
data["result"]["mood"] = "desolate, horror"
stage_file.write_text(json.dumps(data))
- agent.jobs.clear()
- n_events = len(EventLog(ws.events_path).read())
- mk().run(spec, ws, resume=True, force=force)
- return [j.label for j in agent.jobs], [e["event"] for e in EventLog(ws.events_path).read()[n_events:]]
-
-def test_a_mood_only_replan_invalidates_the_env_stage(tmp_path, settings):
- """Q2: the stage key is the whole plan; `resume --force` archives the rounds, so a mood-only re-plan re-runs env."""
- labels, events = _mood_replanned(tmp_path, settings, "harbour4", force=True)
- assert "env" in labels # a stale cached env must not be served
- assert "resume.archived" in events and "resume.spec_changed" not in events and "stage.frozen" not in events
- assert (tmp_path / "runs" / "harbour4" / "rounds" / "pre_force" / "r00.json").is_file()
+ def resume(force: bool) -> tuple[list[str], list[str]]:
+ agent.jobs.clear()
+ n_events = len(EventLog(ws.events_path).read())
+ mk().run(spec, ws, resume=True, force=force)
+ return [j.label for j in agent.jobs], [e["event"] for e in EventLog(ws.events_path).read()[n_events:]]
-
-def test_a_drifted_stage_key_never_reruns_a_stage_under_existing_rounds(tmp_path, settings):
- """F5: with r00 on disk, a drifted key serves the recorded stages instead of re-paying them."""
- labels, events = _mood_replanned(tmp_path, settings, "harbour5", force=False)
+ labels, events = resume(force=False)
assert labels == []
assert events.count("stage.frozen") >= 3 # env, zones, assets (at least)
assert "stage.start" not in events
+ labels, events = resume(force=True)
+ assert "env" in labels # a stale cached env must not be served
+ assert "resume.archived" in events and "resume.spec_changed" not in events and "stage.frozen" not in events
+ assert (ws.root / "rounds" / "pre_force" / "r00.json").is_file()
def test_a_render_timeout_degrades_the_round_instead_of_failing_the_run(tmp_path, chair_plan, settings):
diff --git a/harness/tests/orchestrator_tracks/test_transport_retry.py b/harness/tests/orchestrator_tracks/test_transport_retry.py
index 38adff73..a7da0809 100644
--- a/harness/tests/orchestrator_tracks/test_transport_retry.py
+++ b/harness/tests/orchestrator_tracks/test_transport_retry.py
@@ -25,7 +25,7 @@ from tests.orchestrator_tracks.test_tracks import _agent_writer as _writer
# --------------------------------------------------------------- the typed failure
-def test_round_failed_carries_the_flags_of_its_tasks_never_their_words():
+def test_round_failed_carries_the_typed_flags_of_its_tasks_never_their_words():
ok = GenerationResult(ok=False, notes="exit=completed; errors=['503 in a code comment']", label="a")
storm = GenerationResult(ok=False, notes="exit=error", label="b", transient=True)
spent = GenerationResult(ok=False, notes="exit=error", label="c", quota=True)
@@ -34,9 +34,7 @@ def test_round_failed_carries_the_flags_of_its_tasks_never_their_words():
assert e.transient and not e.quota and str(e) == "a: exit=completed; errors=['503 in a code comment']; b: exit=error"
assert RoundFailed.of([ok, spent], "x").quota
assert str(RoundFailed.of([], "no generation task succeeded")) == "no generation task succeeded"
-
-
-def test_a_raised_error_is_classified_by_its_type():
+ # a raised error is classified by its type
assert GenerationResult.from_error("g", ModelError("Gemini request timed out", retryable=True, status=408)).transient
assert GenerationResult.from_error("g", ModelError("Gemini API error 503", status=503)).transient
assert GenerationResult.from_error("g", ModelError("overloaded", status=529)).transient
diff --git a/harness/tests/orchestrator_tracks/test_zone_layout.py b/harness/tests/orchestrator_tracks/test_zone_layout.py
index 9b2345f4..b0776fac 100644
--- a/harness/tests/orchestrator_tracks/test_zone_layout.py
+++ b/harness/tests/orchestrator_tracks/test_zone_layout.py
@@ -83,15 +83,13 @@ def test_layout_block_renders_numbers_the_builder_can_follow():
assert layout_block(None) == ""
-def test_layout_zones_drops_a_twice_rejected_zone_instead_of_dying():
+def test_layout_zones_drops_a_twice_rejected_zone_and_buys_nothing_past_the_ceiling():
plan = _plan()
bad = {"zone": "Quay", "placements": [{"asset": "Kraken", "count": 1, "cluster": (0.0, 0.0), "spread_m": 1.0}]}
good_market = {"zone": "Market", "placements": [{"asset": "Stall", "count": 4, "cluster": (10.0, 0.0), "spread_m": 5.0}]}
out = layout_zones(plan, FakeChatModel([bad, bad, good_market]), max_workers=1)
assert set(out) == {"Market"}
-
-
-def test_a_run_past_its_ceiling_buys_no_layout_calls():
+ # a run past its ceiling buys no layout calls
import time
from codeverse3d.contracts.common import Budget
@@ -99,5 +97,5 @@ def test_a_run_past_its_ceiling_buys_no_layout_calls():
model = FakeChatModel() # any call finds no reply and raises
guard = BudgetGuard(Budget(max_minutes=30), start_time=time.time() - 45 * 60)
- out = layout_zones(_plan(), model, budget=guard, max_workers=1)
+ out = layout_zones(plan, model, budget=guard, max_workers=1)
assert out == {} and len(model.requests) == 0