fix: справочный путь уходит на зайку при отказе дипсика, сторож видит пустой счёт, телеграм через впн сервера

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-09-24 02:14:23 +10:00
co-authored by Claude Opus 5.5
parent f7b1aebe07
commit 454108655b
7 changed files with 267 additions and 97 deletions
+14 -4
View File
@@ -167,8 +167,9 @@ def test_success_closes_the_streak(env):
assert ph.snapshot()["deepseek"]["streak"] == 0
def test_probe_slot_is_released_on_failure(env, monkeypatch):
"""Порча: убрать release_probe → проба зайки залипнет, и она не вернётся до TTL."""
def test_probe_slot_is_released_when_the_person_leaves(env, monkeypatch):
"""Человек закрыл вкладку посреди ответа пробной попытки — вердикта нет, но слот пробы
обязан освободиться. Порча: убрать release_probe → зайка залипнет до TTL (21 минута)."""
qf, ph, db, calls, script = env
now = [1000.0]
monkeypatch.setattr(ph, "_now", lambda: now[0])
@@ -176,9 +177,18 @@ def test_probe_slot_is_released_on_failure(env, monkeypatch):
ph.record_failure("glm")
now[0] += 61
script["deepseek"] = [("text", refused(402))]
script["glm"] = [("text", httpx.ConnectError("x"))]
run(qf)
script["glm"] = [("text", "начало"), ("text", "продолжение")]
async def go():
agen = qf.stream_with_fallback([{"role": "user", "content": "в"}], primary=primary(qf),
username="u@x", tab_id="t")
first = await agen.__anext__()
await agen.aclose()
return first
assert asyncio.run(go()) == ("text", "начало")
assert ph.snapshot()["glm"]["half_open_inflight"] is False
assert ph.snapshot()["glm"]["status"] == ph.HALF_OPEN
def test_quota_mark_skips_zaika(env):