Official Codebase of 3DCodeVerse
Python
lifecycle: the last round is re-judged before the run ends, so `--rounds 0` with a failed judge says judge_unavailable
gaoypeng76f2560cdf88
diff --git a/harness/codeverse3d/tracks/lifecycle.py b/harness/codeverse3d/tracks/lifecycle.pyindex 63398839..e5c1d2c6 100644--- a/harness/codeverse3d/tracks/lifecycle.py+++ b/harness/codeverse3d/tracks/lifecycle.py@@ -549,36 +549,39 @@ class BaseTrack:ctx.events.emit("stop", reason=reason.value, rounds=len(rounds))return reason+ def _unjudged(rec: RoundRecord | None) -> bool:+ return rec is not None and rec.judgment is None and rec.build is not None and rec.build.ok+while True:index = len(rounds)+ last = rounds[-1] if rounds else None+ if _unjudged(last) and last.index not in rejudged and ctx.budget.ok():+ # judge outage/degraded verdict on a clean build: re-judge the SAME commit once+ # (no regeneration) — before planning refinements from nothing, and before the+ # last round ends the run unscored (`--rounds 0` used to stop MAX_ROUNDS with an+ # unjudged baseline: the re-judge lived in the refine branch only)+ rejudged.add(last.index)+ prev_j = rounds[-2].judgment if len(rounds) > 1 else None+ if rejudge_round(ctx, pipeline, last, previous=prev_j):+ self._save_budget(ctx)if index > ctx.policy.max_rounds: # the baseline + max_rounds refine rounds all ran- return _stop(RunStatus.MAX_ROUNDS)+ return _stop(RunStatus.JUDGE_UNAVAILABLE if _unjudged(last) else RunStatus.MAX_ROUNDS)if not ctx.budget.ok():if not rounds: # the stages spent the clock without raising: the ONE budget path (salvage)ctx.budget.check()return _stop(RunStatus.BUDGET)- previous = rounds[-1].judgment if rounds else None- if index == 0:+ previous = last.judgment if last else None+ if last is None:ctx.state.status = RunStatus.GENERATINGtasks, instructions, kind = self.baseline_tasks(ctx), [], "baseline"else:ctx.state.status = RunStatus.REFINING- last = rounds[-1]- if last.judgment is None and last.build is not None and last.build.ok and last.index not in rejudged:- # judge outage/degraded verdict on a clean build: re-judge the SAME- # commit once (no regeneration) before planning refinements from nothing.- rejudged.add(last.index)- prev_j = rounds[-2].judgment if len(rounds) > 1 else None- if rejudge_round(ctx, pipeline, last, previous=prev_j):- self._save_budget(ctx)- continue # plan the next round from the recovered verdicttasks, instructions = self.refine_tasks(ctx, last)kind = "refine"if not tasks:# no gate error, no failed must-item, no judge plan: nothing to ask for. When# that is only because the judge never scored the round, say so.- unjudged = last.judgment is None and last.build is not None and last.build.ok- return _stop(RunStatus.JUDGE_UNAVAILABLE if unjudged else RunStatus.NO_REFINE_TASKS)+ return _stop(RunStatus.JUDGE_UNAVAILABLE if _unjudged(last) else RunStatus.NO_REFINE_TASKS)ctx.state.save(ctx.ws)try:if index == 0 and tasks and ctx.policy.n_candidates > 1:diff --git a/harness/docs/ARCHITECTURE.md b/harness/docs/ARCHITECTURE.mdindex 7f8ef147..449c1310 100644--- a/harness/docs/ARCHITECTURE.md+++ b/harness/docs/ARCHITECTURE.md@@ -487,7 +487,8 @@ plateau, regression or diminishing-returns stop, no rewrite or surface-detail roescalates on identical signatures) → gates → … → judge (SKIPPED only where the verdict is neverbought at all: no judge or no renders — a round that finishes past the clock is still judged)→ commit src/ (the round's commit) and copy its build to artifacts/rNN/- a round left without a verdict (judge outage / degraded) is re-judged once before the next is planned+ a round left without a verdict (judge outage / degraded) is re-judged once before the next is planned,+ and so is the LAST round before the run ends (still none → judge_unavailable, `--rounds 0` included)a round's cost is the ledger rows it booked (a cost.tally) and its steps are timed (RoundRecord.steps); a roundthat raises mid-way still reports what it burned (rounds/aborted_rNN.json + record.extra["aborted_rounds"])a round whose every task failed raises RoundFailed, TYPED (2026-09-22 — the loop never reads its message):diff --git a/harness/tests/orchestrator_tracks/test_fix_batch2.py b/harness/tests/orchestrator_tracks/test_fix_batch2.pyindex c4c6bdb2..300e7013 100644--- a/harness/tests/orchestrator_tracks/test_fix_batch2.py+++ b/harness/tests/orchestrator_tracks/test_fix_batch2.py@@ -116,6 +116,24 @@ def test_degraded_verdict_never_scores_and_run_stops_as_judge_unavailable(tmp_paassert "judge degraded" in saved["notes"] and saved["usage"]["cost_usd"] == pytest.approx(0.016, abs=1e-6)[email protected](("verdicts", "status", "score"), [+ (["degraded", 0.7], RunStatus.MAX_ROUNDS, 0.7),+ (["degraded", "degraded"], RunStatus.JUDGE_UNAVAILABLE, None),+])+def test_the_last_round_is_rejudged_before_the_run_ends(tmp_path, chair_plan, settings, verdicts, status, score):+ """`--rounds 0`: the baseline IS the last round. Its failed verdict was never re-judged (the+ re-judge lived in the refine branch) and the run stopped MAX_ROUNDS unscored; now it gets the+ same one re-judge as any round, and a second failure says judge_unavailable (D80)."""+ ws = Workspace(tmp_path / "runs" / "r")+ judge = ScriptedJudge(verdicts)+ 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(make_spec(max_rounds=0), ws)+ assert rec.status is status and len(rec.rounds) == 1 and len(judge.all_calls) == 2+ assert rec.rounds[0].score == (pytest.approx(score) if score is not None else None)++def test_degraded_verdict_recovers_via_rejudge_of_same_commit(tmp_path, chair_plan, settings):spec = make_spec(max_rounds=3)ws = Workspace(tmp_path / "runs" / "r")