Official Codebase of 3DCodeVerse
Python
Pick: a round failing the project's own checks ranks after every round that passes them
wang Qin37241b131272
diff --git a/harness/codeverse3d/addons/select.py b/harness/codeverse3d/addons/select.pyindex b990c78e..ab61c183 100644--- a/harness/codeverse3d/addons/select.py+++ b/harness/codeverse3d/addons/select.py@@ -45,6 +45,8 @@ class RoundRow(BaseModel):score: float | None = Field(default=None, description="effective judged score; None = unjudged or a degraded verdict")passed: bool | None = Field(default=None, description="the judge's own verdict for THIS round (None = unjudged)")gate_errors: int = 0+ project_errors: int = Field(default=0, description="ERRORs of the project's own measurements: its checks "+ "(project:*, Spec.checks) and fixed parts (contract_fixed, Spec.fixed_parts)")build_ok: bool | None = Nonecommit: str = ""cost_usd: float = 0.0@@ -96,13 +98,27 @@ def round_rows(run_dir: Path | str, *, record: RunRecord | None = None) -> list[j = effective_judgment(r)rows.append(RoundRow(index=r.index, kind=r.kind, score=j.overall if j else None, passed=j.passed if j else None,gate_errors=sum(len(g.errors) for g in r.gates),+ project_errors=sum(len(g.errors) for g in r.gates if is_project_gate(g.gate)),build_ok=None if r.build is None else r.build.ok, commit=r.commit,cost_usd=round(r.usage.cost_usd, 6), minutes=round(r.minutes, 2)))return rows+#: the gates that measure the project's own truth: its registered checks (tracks/project_checks.py) and its+#: fixed parts (spatial/contract.py); named here so the pick never imports a track+PROJECT_GATE_PREFIX = "project:"+FIXED_PARTS_GATE = "contract_fixed"+++def is_project_gate(name: str) -> bool:+ """A gate that measures the project's own truth: its registered checks (``project:*``) or its fixed parts."""+ return name.startswith(PROJECT_GATE_PREFIX) or name == FIXED_PARTS_GATE++def _ranked(rows: list[RoundRow]) -> list[RoundRow]:- return sorted((r for r in rows if r.score is not None), key=lambda r: (-(r.score or 0.0), r.gate_errors, r.index))+ """Judged rounds, best first: no project-check errors, then score, fewer gate errors, earlier round."""+ return sorted((r for r in rows if r.score is not None),+ key=lambda r: (r.project_errors > 0, -(r.score or 0.0), r.gate_errors, r.index))# --------------------------------------------------------------------------- a round's own outputsdiff --git a/harness/tests/flywheel_cli/test_select.py b/harness/tests/flywheel_cli/test_select.pyindex 158d8faf..f3d0daba 100644--- a/harness/tests/flywheel_cli/test_select.py+++ b/harness/tests/flywheel_cli/test_select.py@@ -233,3 +233,22 @@ def test_round_outputs_are_the_rounds_own_never_the_last_builds(tmp_path: Path):assert select.round_file(ws, rec.rounds[0]) is Noneassert select.round_file(ws, rec.rounds[1]) is Noneassert select.round_complexity_block(ws, rec.rounds[1]) is None++[email protected]("gate,rounds,want", [+ ("project:survey", [(0.60, 1), (0.557, 0)], 1), # the round the refine task fixed wins over the higher score+ ("contract_fixed", [(0.80, 1), (0.70, 0), (0.75, 0)], 2), # a moved fixed part loses; the rest by score+ ("project:survey", [(0.60, 1), (0.70, 2)], 1), # every round fails: back to the score+ ("contract", [(0.70, 1), (0.60, 0)], 0), # any other gate's errors still only break score ties+], ids=["project-check", "fixed-part", "all-fail", "other-gate"])+def test_a_round_failing_the_projects_own_checks_loses_to_one_that_passes(tmp_path, gate, rounds, want):+ """The project's own checks outrank the judge score when picking; other gates still only break ties."""+ ws = _run(tmp_path / "r", [(score, 0) for score, _ in rounds])+ rec = json.loads(ws.record_path.read_text())+ for r, (_, errors) in zip(rec["rounds"], rounds, strict=True):+ r["gates"].append({"gate": gate, "passed": not errors, "findings": [+ {"gate": gate, "severity": "error", "message": "footprint overlap 0.79"}] * errors})+ ws.record_path.write_text(json.dumps(rec))+ assert select.pick(ws.root) == want+ rows = select.round_rows(ws.root)+ assert [r.project_errors for r in rows] == ([e for _, e in rounds] if gate != "contract" else [0] * len(rounds))