fix: tolerate backfill under-delivery, fix predict None-fill, drop dead session_id

This commit is contained in:
2026-07-14 17:07:55 -04:00
parent 1d222d9f18
commit f36eb66c18
4 changed files with 68 additions and 6 deletions
+26
View File
@@ -163,3 +163,29 @@ async def test_rounds_backfill_then_stop_at_max(tmp_path):
ids = {d["question_id"] for d in json.loads(final_path.read_text(encoding="utf-8"))}
assert "q0" in ids and any(x.startswith("bf0_") for x in ids)
store.close()
@pytest.mark.asyncio
async def test_rounds_tolerate_backfill_under_delivery(tmp_path):
"""backfill 欠产(实得 < deficit,被 gate 拒常态)→ 不崩,并入实得题,达上限停。"""
store = QuestionGenStore(str(tmp_path / "q.db"))
agent = _FakeAgent(pred="B")
# 每轮只产出 deficit-1 道(模拟部分题被 gate 拒的真实欠产)
backfill = _CountingBackfill(lambda d, r: [_q(f"bf{r}_{i}") for i in range(max(d - 1, 0))])
final_path = tmp_path / "accepted_questions_final.json"
await run_adversarial_rounds(
[_q("q0")],
agent=agent,
vlm=object(),
store=store,
trees={},
config=AdversarialFilterConfig(adversarial_max_rounds=3),
final_path=final_path,
target=99, # 永远达不到 → 靠 max_rounds 终止,不因欠产崩溃或死循环
backfill=backfill,
session_id="s",
)
assert backfill.calls == 2 # round0/round1 各补一次;round2 达上限 break
ids = {d["question_id"] for d in json.loads(final_path.read_text(encoding="utf-8"))}
assert "q0" in ids and any(x.startswith("bf0_") for x in ids) # 实得欠产题已并入
store.close()