Skip to content

Official Codebase of 3DCodeVerse

Python

tests: orchestrator_tracks, second pass — twelve exceptions did not hold (−204 lines)

gaoypengb4c48b306d37
diff --git a/harness/tests/orchestrator_tracks/test_budget_snapshot.py b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
index 30255f5d..482ffbfc 100644
--- a/harness/tests/orchestrator_tracks/test_budget_snapshot.py
+++ b/harness/tests/orchestrator_tracks/test_budget_snapshot.py
@@ -58,11 +58,6 @@ def test_build_context_restores_the_budget_snapshot(tmp_path, settings):
ws = Workspace(tmp_path / "runs" / "r").create()
track = StaticObjectTrack(services=FakeServices(), settings=settings, runtime=FakeRuntime(Language.THREEJS))
- state = RunState()
- state.extra["budget_snapshot"] = BudgetSnapshot(active_s=240.0).model_dump(mode="json")
- ctx = track.build_context(spec, ws, EventLog(ws.events_path), state)
- assert ctx.budget.elapsed_minutes() == pytest.approx(4.0, abs=0.1)
-
# a snapshot from before the guard lost its money (2026-09-22) still loads: extra keys are ignored
legacy = {"spent": {"cost_usd": 0.4}, "billed_usd": 0.4, "calls": 1, "by_stage": {"baseline": 0.4},
"by_round": {"0": {"baseline": 0.4}}, "active_s": 240.0}
@@ -177,18 +172,3 @@ def test_a_baseline_session_the_clock_stopped_after_it_wrote_code_is_salvaged(tm
rec = track.run(make_spec(max_rounds=0), ws)
assert rec.status is RunStatus.BUDGET
assert len(rec.rounds) == 1 and rec.rounds[0].score == pytest.approx(0.6) and "salvaged" in rec.rounds[0].notes
-
-
-def test_a_skeleton_only_budget_trip_still_salvages_nothing(tmp_path, chair_plan, settings):
-
- def writer(job, ws_):
- raise BudgetExceeded("elapsed 11.0 min exceeds max_minutes 10.0")
-
- ws = Workspace(tmp_path / "runs" / "bare")
- track = StaticObjectTrack(services=FakeServices(), judge=FakeJudge(scores=(0.6,)), agent=FakeAgent(writer),
- planner_model=FakeChatModel(lambda req: chair_plan.model_dump(mode="json")),
- settings=settings, runtime=FakeRuntime(Language.THREEJS), n_candidates=1)
- rec = track.run(make_spec(max_rounds=0), ws)
- assert rec.status is RunStatus.BUDGET and rec.rounds == []
- ev = [e["event"] for e in EventLog(ws.events_path).read()]
- assert "budget.salvage_skipped" in ev
diff --git a/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py b/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
index 593fb18b..01e664e8 100644
--- a/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
+++ b/harness/tests/orchestrator_tracks/test_cookbook_excerpt.py
@@ -1,35 +1,12 @@
-"""Every track sends the whole cookbook; the GLSL cookbook's aurora example ships (Q9)."""
+"""The GLSL cookbook's aurora example ships where the cookbook says it is (Q9)."""
from __future__ import annotations
-from types import SimpleNamespace
-
-from codeverse3d.contracts.common import Language, Track
from codeverse3d.prompts import PROMPTS_DIR, load_text
EXAMPLE = PROMPTS_DIR / "glsl_shader" / "examples" / "aurora_ridge.frag"
-def test_every_track_sends_the_whole_cookbook(monkeypatch) -> None:
- from codeverse3d.languages import get_runtime
- from codeverse3d.tracks import graphics as graphics_steps
- from codeverse3d.tracks.prompting import base_prompt_context
-
- big = "\n\n".join(f"## chapter {i}\n" + "x" * 4000 for i in range(20)) # ~80 000 chars
- ctx = SimpleNamespace(plan=None, spec=SimpleNamespace(prompt="an aurora", constraints=None, must=[], must_not=[],
- dims={}, reference_images=[], reference_notes=""),
- track=Track.GRAPHICS, language=Language.GLSL_SHADER,
- contract_text="CONTRACT",
- cookbook_text=big, tool_cards="", single_shot=True, extra={},
- runtime=get_runtime(Language.GLSL_SHADER))
- monkeypatch.setattr("codeverse3d.tracks.prompting.constraints_text", lambda spec: "")
- monkeypatch.setattr("codeverse3d.tracks.prompting.reference_note", lambda ctx: "")
- monkeypatch.setattr("codeverse3d.tracks.prompting.acceptance_lines", lambda plan: "")
- assert graphics_steps.graphics_prompt_context(ctx)["cookbook_excerpt"] == big
- assert base_prompt_context(ctx)["cookbook_excerpt"] == big
- assert base_prompt_context(ctx)["contract"] == "CONTRACT"
-
-
def test_aurora_example_ships_and_composes() -> None:
from codeverse3d.languages.glsl_shader import compose
diff --git a/harness/tests/orchestrator_tracks/test_cost_latency.py b/harness/tests/orchestrator_tracks/test_cost_latency.py
index 92bd9a53..edc4ed05 100644
--- a/harness/tests/orchestrator_tracks/test_cost_latency.py
+++ b/harness/tests/orchestrator_tracks/test_cost_latency.py
@@ -244,15 +244,6 @@ def test_asset_selection_folds_only_over_the_cap():
kept, alias = select_assets(twins, cap=1)
assert [k.name for k in kept] == ["PondRock"] and alias == {"SteppingStone": "PondRock"}
- assets = [_asset("HeroBoulder", (2.4, 2.0, 2.2)), _asset("Bench", (1.6, 0.9, 0.6)),
- _asset("Lantern", (0.4, 1.2, 0.4)), _asset("Crate", (0.6, 0.5, 0.6)),
- _asset("TalusRock", (1.8, 1.4, 1.6)), _asset("Stool", (0.5, 0.6, 0.5)),
- _asset("Box", (0.5, 0.4, 0.5)), _asset("Sconce", (0.3, 0.5, 0.2))]
- kept, alias = select_assets(assets, cap=4)
- assert len(kept) == 4 and [k.name for k in kept] == ["HeroBoulder", "Bench", "Lantern", "Crate"]
- # every survivor's twin is reachable as a variant instead of vanishing
- assert alias == {"TalusRock": "HeroBoulder", "Stool": "Bench", "Box": "Crate", "Sconce": "Lantern"}
- assert all(v in {k.name for k in kept} for v in alias.values())
def test_a_clock_that_trips_after_a_finished_zones_session_records_what_it_wrote(tmp_path, settings):
diff --git a/harness/tests/orchestrator_tracks/test_fix_batch2.py b/harness/tests/orchestrator_tracks/test_fix_batch2.py
index c7c5520b..c6a22a0e 100644
--- a/harness/tests/orchestrator_tracks/test_fix_batch2.py
+++ b/harness/tests/orchestrator_tracks/test_fix_batch2.py
@@ -97,30 +97,6 @@ class _RebuildFails(FakeRuntime):
# --------------------------------------------------------------------- finding: spent usage persisted on crash paths
-def test_spent_usage_saved_when_a_round_crashes(tmp_path, chair_plan, settings):
- class BoomServices(FakeServices):
- def __init__(self):
- super().__init__()
- self.n = 0
-
- def contract(self, measurement, plan, tol_m, language=""):
- self.n += 1
- if self.n >= 2:
- raise RuntimeError("gate exploded")
- return super().contract(measurement, plan, tol_m, language)
-
- spec = make_spec(max_rounds=3)
- ws = Workspace(tmp_path / "runs" / "r")
- track = StaticObjectTrack(services=BoomServices(), judge=FakeJudge(scores=(0.55,), targets=("Seat",)), agent=FakeAgent(_writer),
- planner_model=_planner(chair_plan.model_dump(mode="json")), settings=settings,
- runtime=FakeRuntime(Language.THREEJS))
- with pytest.raises(RuntimeError, match="gate exploded"):
- track.run(spec, ws)
- # planner 0.002 + r0 agent 0.01 + r0 judge 0.003 + r1 agent 0.01 — the r1 charge must not vanish
- assert json.loads(ws.record_path.read_text())["total_usage"]["cost_usd"] == pytest.approx(0.025, abs=1e-6)
- assert json.loads((ws.root / "rounds" / "aborted_r01.json").read_text())["usage"]["cost_usd"] == pytest.approx(0.01)
-
-
# --------------------------------------------------------------------- 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)
@@ -135,16 +111,10 @@ def test_degraded_verdict_never_scores_and_run_stops_as_judge_unavailable(tmp_pa
assert rec.extra["stop_reason"] == "judge_unavailable" and rec.status is RunStatus.JUDGE_UNAVAILABLE
kinds = [e["event"] for e in EventLog(ws.events_path).read()]
assert "judge.degraded" in kinds and "judge.retry" in kinds
- # the degraded summary never reaches a refine prompt
assert len(judge.all_calls) == 3
- # audit f1/f3: both degraded verdicts were PAID and the glitch note survives the
- # round's notes join — money and note reach the persisted record
- r1 = rec.rounds[1]
- assert "judge degraded" in r1.notes
- assert r1.usage.cost_usd == pytest.approx(0.016, abs=1e-6) # agent 0.01 + 2 x degraded 0.003
+ # both degraded verdicts were PAID, and money and note reach the persisted round
saved = json.loads((ws.root / "rounds" / "r01.json").read_text())
- assert "judge degraded" in saved["notes"]
- assert saved["usage"]["cost_usd"] == pytest.approx(0.016, abs=1e-6)
+ assert "judge degraded" in saved["notes"] and saved["usage"]["cost_usd"] == pytest.approx(0.016, abs=1e-6)
def test_degraded_verdict_recovers_via_rejudge_of_same_commit(tmp_path, chair_plan, settings):
diff --git a/harness/tests/orchestrator_tracks/test_fixed_rounds.py b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
index f9ed6930..e06e60b5 100644
--- a/harness/tests/orchestrator_tracks/test_fixed_rounds.py
+++ b/harness/tests/orchestrator_tracks/test_fixed_rounds.py
@@ -30,8 +30,7 @@ def _track(chair_plan, settings, scores, *, agent=None) -> StaticObjectTrack:
@pytest.mark.parametrize(("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
- ((0.60,), 0),
-], ids=["passing", "regressing", "baseline-only"])
+], 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):
ws = Workspace(tmp_path / "runs" / "fixed")
diff --git a/harness/tests/orchestrator_tracks/test_graphics_recipes.py b/harness/tests/orchestrator_tracks/test_graphics_recipes.py
index 24ded69b..97b420ad 100644
--- a/harness/tests/orchestrator_tracks/test_graphics_recipes.py
+++ b/harness/tests/orchestrator_tracks/test_graphics_recipes.py
@@ -21,24 +21,20 @@ from codeverse3d.languages.glsl_shader import (
)
from codeverse3d.languages.glsl_shader import HEADER as WRAP_HEADER
from codeverse3d.proc import EventLog
-from codeverse3d.prompts import load_text, render
+from codeverse3d.prompts import load_text
from codeverse3d.tracks.graphics import (
HEADER,
RECIPES_REL,
RESUME_HEADER,
cookbook_functions,
defined_names,
- graphics_prompt_context,
is_skeleton_common,
seed_recipes,
seeded_on_disk,
)
-from codeverse3d.tracks.planner import plan_example
from codeverse3d.workspace import Workspace
AURORA = "Aurora borealis over a mountain ridge with a frozen lake, dense stars, green and violet curtains"
-NOTHING = "a rotating rainbow gear wheel" # matches the Instancing chapter, which defines no function
-UNMATCHED = "xyzzy plugh"
AURORA_NAMES = ("curtain", "auroraCol", "aurora", "stars")
HELPERS = ("hash12", "hash22", "noise", "fbm")
_DEF = re.compile(r"^[ \t]*(?:float|vec[234]|mat[234]|int|bool|void)\s+(\w+)\s*\(", re.M)
@@ -146,21 +142,6 @@ def test_an_agent_written_common_is_never_touched(tmp_path) -> None:
assert "`hash12` is already provided by src/recipes.glsl — call it instead of redefining it" in dup[0].message
-def test_nothing_matches_nothing_seeded_no_file_no_block(tmp_path) -> None:
- ws = _ws(tmp_path)
- ctx = _ctx(ws, NOTHING)
- assert seed_recipes(ctx) == []
- assert not _recipes(ws).exists() and (ws.src / "common.glsl").read_text() == COMMON_GLSL
- assert ctx.extra["seeded_recipes"] == []
- d = graphics_prompt_context(ctx, skeleton_files={}, previous_error="")
- assert d["seeded_recipes"] == []
- gen = render("tracks/generate_graphics.j2", **d)
- assert "Verified helpers in the harness-owned" not in gen and "recipes.glsl" not in gen
- ws2 = _ws(tmp_path / "b", skeleton=False)
- assert seed_recipes(_ctx(ws2, NOTHING)) == [] and not _recipes(ws2).exists() and not (ws2.src / "common.glsl").exists()
- assert seed_recipes(_ctx(ws2, UNMATCHED)) == [] and not _recipes(ws2).exists()
-
-
def test_resume_appends_only_new_names(tmp_path) -> None:
ws = _ws(tmp_path)
first = seed_recipes(_ctx(ws))
@@ -235,26 +216,6 @@ def test_recipes_compose_above_common_and_the_seeded_aurora_renders(tmp_path) ->
assert all(v > 0.0 for v in lum), lum
-def test_prompt_block_lists_the_seeded_names(tmp_path) -> None:
- ws = _ws(tmp_path)
- ctx = _ctx(ws, plan=GraphicsPlan.model_validate({**plan_example(Track.GRAPHICS), "key_visuals": ["green aurora curtains", "dense stars"]}))
- names = seed_recipes(ctx)
- d = graphics_prompt_context(ctx, skeleton_files={}, previous_error="")
- assert [r["name"] for r in d["seeded_recipes"]] == names
- gen = render("tracks/generate_graphics.j2", **d)
- assert "Verified helpers in the harness-owned, read-only `src/recipes.glsl`" in gen and "do not redefine them" in gen
- assert "do not copy them into `src/common.glsl`" in gen and "pastes it above" in gen and "ALREADY in `src/common.glsl`" not in gen
- for n in names:
- assert re.search(rf"^- `[^`]*\b{n}\([^`]*\)` — .+$", gen, re.M), n
- assert "float curtain(vec2 p, float t, float seed, out float k)" in gen and "never a comb of bars" in gen
- assert gen.index("Cookbook excerpt:") < gen.index("Verified helpers in the harness-owned") < gen.index("## Plan")
- ref = render("tracks/refine_graphics.j2", **graphics_prompt_context(
- ctx, round_index=1, tasks=["[judge/likeness] overall: no curtain"], targets=["overall"], files=["src/shader.frag"],
- judge_summary="Previous score 0.3", frame_notes="(no frame metrics)", current_files={}))
- assert "harness-owned, read-only `src/recipes.glsl`" in ref and "do not copy them into common.glsl" in ref
- assert all(f"`{n}`" in ref for n in names)
-
-
def test_a_single_shot_repair_never_inlines_the_harness_owned_recipes(tmp_path) -> None:
from codeverse3d.contracts.artifacts import BuildResult, GateReport
from codeverse3d.tracks.repair import files_for_repair
diff --git a/harness/tests/orchestrator_tracks/test_orchestrator.py b/harness/tests/orchestrator_tracks/test_orchestrator.py
index 94ee53c2..8dfcb80d 100644
--- a/harness/tests/orchestrator_tracks/test_orchestrator.py
+++ b/harness/tests/orchestrator_tracks/test_orchestrator.py
@@ -37,6 +37,12 @@ def test_fan_out_preserves_order_and_captures_exceptions():
res = fan_out([0, 1, 2, 3], fn, max_workers=4, label="t")
assert res[0] == 0 and res[1] == 10 and res[3] == 30 and isinstance(res[2], ValueError)
assert fan_out([], fn, 2) == []
+ # workers inherit the caller's context (the run ledger is a contextvar)
+ import contextvars
+
+ var: contextvars.ContextVar[str] = contextvars.ContextVar("attr", default="process-default")
+ var.set("run-42")
+ assert set(fan_out(range(6), lambda _i: var.get(), max_workers=4, label="attr")) == {"run-42"}
def test_a_run_state_saved_before_2026_09_22_still_loads(tmp_ws):
diff --git a/harness/tests/orchestrator_tracks/test_planner_depth.py b/harness/tests/orchestrator_tracks/test_planner_depth.py
index 493e8dac..e4d44372 100644
--- a/harness/tests/orchestrator_tracks/test_planner_depth.py
+++ b/harness/tests/orchestrator_tracks/test_planner_depth.py
@@ -26,7 +26,6 @@ from codeverse3d.tracks import planner as B
from codeverse3d.tracks import planner as BR
from codeverse3d.tracks.planner import (
MAX_QUALITY_REASKS,
- build_system_prompt,
build_user_prompt,
)
from codeverse3d.tracks.planner import plan as run_planner
@@ -93,11 +92,7 @@ def test_subpart_contracts():
# ----------------------------------------------------------------------------- (3) budgets
def test_plan_budget_contracts():
- thin = _plan([_part(f"P{i}", desc=_detailed(i), material=f"m{i}") for i in range(3)])
assert not B.plan_budget(_spec(must=2)).evidence
- assert B.plan_quality_complaint(thin, B.plan_budget(_spec(must=2))) == ""
- assert "Only 3 parts" in B.plan_quality_complaint(thin, B.plan_budget(_spec(must=9)))
-
small = B.plan_budget(_spec(must=3))
big = B.plan_budget(_spec(must=13))
huge = B.plan_budget(_spec(must=40))
@@ -121,14 +116,6 @@ def test_plan_budget_contracts():
assert "PLAN BUDGET" in text and "10 checklist items" in text
-def test_plan_templates_render_the_budget_numbers():
- for track, language, model in ((Track.STATIC_OBJECT, Language.BLENDER, StaticPlan),
- (Track.GRAPHICS, Language.GLSL_SHADER, GraphicsPlan)):
- spec = _spec(must=9, track=track, language=language)
- out = build_system_prompt(spec, model, budget=B.plan_budget(spec))
- assert str(B.plan_budget(spec).target_parts) in out
-
-
# ----------------------------------------------------------------------------- (4) quality gate
def test_plan_quality_gate_contracts():
budget = B.plan_budget(_spec(must=12))
@@ -256,44 +243,6 @@ def test_graphics_pass_elements_are_folded_into_the_one_markdown_row_that_render
assert row.count("|") == 4 and "integer tooth ratios" in row
-def test_truncated_plans_keep_growing_output_room(tmp_path, switch):
- switch("C3D_PLAN_BRIEF", "off")
- from codeverse3d.models.base import ModelError
-
- good = json.loads(_plan([_part(f"P{i}", desc=_detailed(i), material=f"m{i}") for i in range(9)]).model_dump_json())
-
- def run(failures):
- ws = Workspace(tmp_path / f"run-{failures}").create()
- seen: list[int] = []
-
- def responder(req):
- seen.append(req.max_output_tokens)
- if len(seen) <= failures:
- raise ModelError("structured output unavailable (finish_reason=MAX_TOKENS; raise max_output_tokens)")
- return good
-
- return seen, run_planner(_spec(must=8), "fake:planner", StaticPlan, ws, model=FakeChatModel(responder))
-
- for failures in (1, 2):
- seen, got = run(failures)
- assert len(seen) == failures + 1 and seen == sorted(set(seen))
- assert len(got.parts) == 9
-
-
-def test_a_model_error_that_is_not_truncation_still_propagates(tmp_path, switch):
- switch("C3D_PLAN_BRIEF", "off")
- from codeverse3d.models.base import ModelError
-
- ws = Workspace(tmp_path / "run")
- ws.create()
-
- def responder(req):
- raise ModelError("every key is dead")
-
- with pytest.raises(ModelError, match="every key is dead"):
- run_planner(_spec(), "fake:planner", StaticPlan, ws, model=FakeChatModel(responder))
-
-
# ----------------------------------------------------------------------------- the loop
def test_planner_spends_one_quality_reask_then_ships_the_plan(tmp_path, switch):
"""A plan that never satisfies the gate is still USED — a mediocre plan beats no plan."""
diff --git a/harness/tests/orchestrator_tracks/test_planner_restart.py b/harness/tests/orchestrator_tracks/test_planner_restart.py
index e9faa527..8de536fe 100644
--- a/harness/tests/orchestrator_tracks/test_planner_restart.py
+++ b/harness/tests/orchestrator_tracks/test_planner_restart.py
@@ -77,6 +77,11 @@ def test_a_restart_costs_an_attempt_not_one_of_the_two_reask_slots(tmp_ws):
assert len(model.requests) == 4 # first + restart + two re-asks
# 1 = the request alone (a restart replaces the conversation), then one echo+complaint pair each
assert [len(r.messages) for r in model.requests] == [1, 1, 3, 5]
+ # every rejected answer is kept where a dead run can be read
+ from codeverse3d.tracks.planner import INVALID_PLAN_DIR
+
+ written = sorted((tmp_ws.root / INVALID_PLAN_DIR).glob("attempt*.json"))
+ assert len(written) == 4 and [p["name"] for p in json.loads(written[0].read_text())["parts"]] == ["Cabinet"]
def test_a_full_plan_with_one_dangling_link_is_edited_in_context_not_resampled(tmp_ws):
@@ -91,17 +96,3 @@ def test_a_full_plan_with_one_dangling_link_is_edited_in_context_not_resampled(t
assert isinstance(p, ArticulatedPlan) and len(model.requests) == 2
assert len(model.requests[1].messages) == 3 # user + echoed answer + complaint, no restart
assert "failed validation" in model.requests[1].messages[-1].text
-
-
-def test_a_rejected_plan_is_written_where_a_dead_run_can_be_read(tmp_ws):
- from codeverse3d.tracks.planner import INVALID_PLAN_DIR
-
- model = FakeChatModel(lambda req: _degenerate())
- with pytest.raises(PlanningError):
- plan(_spec(), "fake:planner", ArticulatedPlan, tmp_ws, model=model)
-
- written = sorted((tmp_ws.root / INVALID_PLAN_DIR).glob("attempt*.json"))
- assert len(written) == 4, [p.name for p in written] # one per rejected answer
- first = json.loads(written[0].read_text())
- assert [p["name"] for p in first["parts"]] == ["Cabinet"] # the answer, not the error text
- assert first["joints"][0]["child"] == "Drawer" # the link it named and never listed
diff --git a/harness/tests/orchestrator_tracks/test_round_economics.py b/harness/tests/orchestrator_tracks/test_round_economics.py
index b4fcdeaf..2349d0a6 100644
--- a/harness/tests/orchestrator_tracks/test_round_economics.py
+++ b/harness/tests/orchestrator_tracks/test_round_economics.py
@@ -191,19 +191,6 @@ def test_a_regression_changes_nothing_about_the_loop_and_every_round_reports_its
assert "cost_by_stage" not in rec.extra
-def test_fan_out_workers_inherit_the_callers_context():
- import contextvars
-
- from codeverse3d.proc import fan_out
-
- var: contextvars.ContextVar[str] = contextvars.ContextVar("attr", default="process-default")
- var.set("run-42")
- seen = fan_out(range(6), lambda _i: var.get(), max_workers=4, label="attr")
- assert set(seen) == {"run-42"}
- # the caller's own context is untouched by the workers
- assert var.get() == "run-42"
-
-
def test_a_run_past_its_hard_ceiling_cannot_start_another_session(tmp_ws):
from codeverse3d.contracts.spec import Budget
from codeverse3d.orchestrator import BudgetExceeded, BudgetGuard
diff --git a/harness/tests/orchestrator_tracks/test_write_scope.py b/harness/tests/orchestrator_tracks/test_write_scope.py
index 9165a063..7a53eb25 100644
--- a/harness/tests/orchestrator_tracks/test_write_scope.py
+++ b/harness/tests/orchestrator_tracks/test_write_scope.py
@@ -79,21 +79,6 @@ def test_generate_files_enforces_the_task_scope(tmp_path):
assert all("scope" in e["reason"] for e in skips)
-def test_generate_files_never_rewrites_a_harness_owned_file(tmp_path):
- ws = Workspace(tmp_path / "ws").create()
- ws.write_json(ws.spec_path, {"language": "glsl_shader", "track": "graphics"})
- (ws.src / "recipes.glsl").write_text("float aurora(vec2 p){return 0.0;}\n")
- events = EventLog(tmp_path / "e.jsonl")
- answer = ("=== FILE: src/shader.frag ===\nvoid main(){}\n=== END FILE ===\n"
- "=== FILE: src/recipes.glsl ===\n// clobbered\n=== END FILE ===")
- res = generate_files(ws, model=scripted([(answer, "STOP")]),
- task=GenerationTask(label="baseline", prompt="p"), events=events)
- assert res.ok and [c.path for c in res.files_changed] == ["src/shader.frag"]
- assert (ws.src / "recipes.glsl").read_text().startswith("float aurora")
- (skip,) = [e for e in events.read() if e["event"] == "generate.skipped_path"]
- assert skip["path"] == "src/recipes.glsl" and "harness-owned" in skip["reason"]
-
-
def test_generate_files_never_writes_under_a_harness_owned_directory(tmp_path):
"""B1: ``src/lib/`` is a harness-owned DIRECTORY; the envelope checks it by prefix."""
ws = Workspace(tmp_path / "ws").create()