fix: route None/degraded diagnoses to lapse; abort on high degrade rate

This commit is contained in:
2026-07-16 06:24:11 -04:00
parent 65126feada
commit efbdeb1647
4 changed files with 91 additions and 4 deletions
@@ -212,6 +212,32 @@ async def test_diagnosis_reads_traces_from_steps_json(
assert traces[0]["tool_name"] == "search_tree"
@pytest.mark.asyncio
async def test_run_step_aborts_on_high_degrade_rate(
runner_with_real_store: Runner, monkeypatch: pytest.MonkeyPatch
) -> None:
"""诊断降级占比 > 50% 时 _run_step 中止(疑似 judge 基础设施故障)。"""
from unittest.mock import AsyncMock
batch = [_fake_question("q1", "vA"), _fake_question("q2", "vA")]
runner_with_real_store._rollout_batch = AsyncMock()
monkeypatch.setattr("app.harness.runner._apply_batch_correctness", lambda *a, **k: None)
runner_with_real_store._run_diagnosis = AsyncMock(
return_value=DiagnosisResult(run_id="r", degraded_count=2)
)
runner_with_real_store._gate_batch_skills = AsyncMock()
state = MagicMock()
state.correctness = {"q1": False, "q2": False}
state.gate_cooldown = {}
pools = MagicMock()
pools.baseline_run_id = "infer_adhoc"
with pytest.raises(RuntimeError, match="降级占比"):
await runner_with_real_store._run_step(1, 0, 10, batch, pools, state)
@pytest.mark.asyncio
async def test_run_diagnosis_full_scan_loads_all_video_trees(
runner_with_real_store: Runner,