Official Codebase of 3DCodeVerse
Python
lifecycle: a baseline session the clock stopped after it wrote code gets the salvage round (E6)
gaoypenga6bcd2acf5d9
diff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.pyindex 08c127ca..5abada72 100644--- a/harness/codeverse3d/tracks/lifecycle.py+++ b/harness/codeverse3d/tracks/lifecycle.py@@ -45,7 +45,7 @@ from codeverse3d.prompts import load_text, renderfrom codeverse3d.prompts.catalog import language_prompt, language_textfrom codeverse3d.tracks.candidates import run_best_of_nfrom codeverse3d.tracks.common import RunContext, Services-from codeverse3d.tracks.generation import GenerationTask, single_shot_model_id+from codeverse3d.tracks.generation import ALLOWED_ROOTS, GenerationTask, single_shot_model_idfrom codeverse3d.tracks.planner import plan as run_plannerfrom codeverse3d.tracks.planner import plan_temperaturefrom codeverse3d.tracks.prompting import (@@ -177,11 +177,13 @@ class BaseTrack:def prepare_salvage(self, ctx: RunContext) -> bool:"""Make the workspace buildable after a stage tripped the budget beforeround 0. Return False when the track has nothing to salvage. The default- says yes exactly when best-of-N adopted a winner (``rounds/candidates.json``- is written immediately before adoption): the paid, buildable candidate must- not be thrown away by a ceiling trip at the r00 boundary. A bare skeleton- still returns False."""- return (ctx.ws.root / "rounds" / "candidates.json").is_file()+ says yes exactly when the baseline left code past the pre-round stages — a+ session that committed (or wrote) before the clock stopped it, or the adopted+ best-of-N winner: paid code must not be thrown away by a ceiling trip before+ r00 (neon_glsl c007b166 spent $0.254 on a committed baseline and got 0 rounds).+ A bare skeleton still returns False."""+ prepared = ctx.extra.get("prepared_commit")+ return bool(prepared) and any(c.path.startswith(ALLOWED_ROOTS) for c in ctx.ws.changed_files(since=prepared))# ---- refine hooks (the scaffold below is shared; tracks fill in the task)def refine_file_for_target(self, ctx: RunContext) -> Callable[[str], list[str]]:@@ -260,6 +262,7 @@ class BaseTrack:model=self.plan_model)self.after_plan(ctx)self.prepare(ctx, runner)+ ctx.extra["prepared_commit"] = ws.head() # what a salvage compares the baseline's work withstop = self._round_loop(ctx, rounds)except BudgetExceeded as e:events.emit("budget.exceeded", reason=e.reason)diff --git a/harness/tests/orchestrator_tracks/test_budget_snapshot.py b/harness/tests/orchestrator_tracks/test_budget_snapshot.pyindex e4ab6188..6b6d8f3d 100644--- a/harness/tests/orchestrator_tracks/test_budget_snapshot.py+++ b/harness/tests/orchestrator_tracks/test_budget_snapshot.py@@ -244,6 +244,23 @@ def test_the_adopted_best_of_n_winner_survives_a_boundary_budget_stop(tmp_path,assert "budget.salvage" in ev and "budget.salvage_skipped" not in ev+def test_a_baseline_session_the_clock_stopped_after_it_wrote_code_is_salvaged(tmp_path, chair_plan, settings):+ """E6 (neon_glsl c007b166: a committed baseline, then the budget stop, then 0 rounds): code the+ baseline session left behind is built, rendered and judged as one salvaged round."""++ def writer(job, ws_):+ (ws_.src / "object.js").write_text("// paid for\nexport function build(THREE) { return new THREE.Group(); }\n")+ raise BudgetExceeded("elapsed 11.0 min exceeds max_minutes 10.0")++ ws = Workspace(tmp_path / "runs" / "neon")+ 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+ 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):"""No candidate ever finished (the ceiling tripped mid-generation): there is noadopted winner, so the salvage hook must keep saying no off-scene."""