update
This commit is contained in:
@@ -318,7 +318,7 @@ async def test_writer_prompt_traegt_budget(testdb, tmp_path, monkeypatch):
|
||||
|
||||
monkeypatch.setattr(gb, "run_single_slot", fake_slot)
|
||||
await gb._stage_writer(env, card)
|
||||
assert str(gb._writer_budget(2)) in seen["prompt"] # 800 + 2×400
|
||||
assert str(gb.block_budget(env.subs_by_title["Alpha"])) in seen["prompt"] # 2× Basis-Budget
|
||||
|
||||
|
||||
async def test_pruefer_claims_schwelle(testdb, tmp_path, monkeypatch):
|
||||
@@ -416,7 +416,8 @@ async def test_laengen_trigger_startet_fix(testdb, tmp_path, monkeypatch):
|
||||
assert (await db.list_guide_cards(TOPIC, FMT))[0]["stage"] == "fix"
|
||||
card.update(stage="fix", gate_info=(await db.list_guide_cards(TOPIC, FMT))[0]["gate_info"])
|
||||
assert await gb._stage_fix(env, card)
|
||||
assert "Länge" in seen["auftraege"] and str(round(gb.GUIDE_LAENGE_MAX * 0.75)) in seen["auftraege"]
|
||||
budget = gb.block_budget(env.subs_by_title["Alpha"])
|
||||
assert "Länge" in seen["auftraege"] and f"etwa {budget} Zeichen GESAMT" in seen["auftraege"]
|
||||
|
||||
|
||||
async def test_repair_karten_setzt_befundkarten_auf_pruefer(testdb, tmp_path, monkeypatch):
|
||||
|
||||
@@ -35,10 +35,24 @@ def test_ziel_ohne_anker():
|
||||
|
||||
|
||||
def test_laengen_ausreisser():
|
||||
"""Budget-Band statt Festrahmen: zu dünn und zu dick fallen auf, ohne Budget kein Urteil."""
|
||||
duenn = _card("Alpha", "<!-- ausführlich -->\nkurz")
|
||||
ok = _card("Beta", "<!-- ausführlich -->\n" + "x" * 500)
|
||||
out = gq.laengen_ausreisser([duenn, ok], {"alpha": {"s1"}, "beta": {"s1"}})
|
||||
assert [x["block"] for x in out] == ["Alpha"]
|
||||
dick = _card("Gamma", "<!-- ausführlich -->\n" + "x" * 2000)
|
||||
ohne = _card("Delta", "<!-- ausführlich -->\nkurz")
|
||||
budgets = {"alpha": 500, "beta": 500, "gamma": 500} # delta: kein Inventar → übersprungen
|
||||
out = gq.laengen_ausreisser([duenn, ok, dick, ohne], budgets)
|
||||
assert [x["block"] for x in out] == ["Alpha", "Gamma"]
|
||||
assert out[1]["zeichen"] >= 2000 and out[1]["budget"] == 500
|
||||
|
||||
|
||||
def test_budget_aus_substanz():
|
||||
"""Dichte Subs bekommen mehr Budget; periphere zählen nicht."""
|
||||
dicht = {"relevance": "relevant", "facts": {"key_points": ["a", "b"], "cited_facts": [{}], "example_idea": "x"}}
|
||||
duenn = {"relevance": "relevant", "facts": {}}
|
||||
peripher = {"relevance": "peripheral", "facts": {"key_points": ["a"] * 9}}
|
||||
assert gq.sub_budget(dicht["facts"]) > gq.sub_budget(duenn["facts"])
|
||||
assert gq.block_budget([dicht, duenn, peripher]) == gq.block_budget([dicht, duenn])
|
||||
|
||||
|
||||
def test_redundanz_findet_absatz_doppel():
|
||||
|
||||
@@ -25,7 +25,7 @@ async def test_hedge_zwilling_rettet_stall(monkeypatch):
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "kill_process", lambda k: killed.append(k))
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0.05)
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 60, "claude")
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 0.1, "claude")
|
||||
assert res == ["zwilling"]
|
||||
assert calls == ["k1", "k1-h"]
|
||||
assert "k1" in killed # das hängende Original läuft nicht weiter
|
||||
@@ -43,7 +43,7 @@ async def test_hedge_original_gewinnt_zwilling_wird_gekillt(monkeypatch):
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "kill_process", lambda k: killed.append(k))
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0.05)
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 60, "claude")
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 0.1, "claude")
|
||||
assert res == ["k1"]
|
||||
assert "k1-h" in killed
|
||||
|
||||
@@ -59,7 +59,25 @@ async def test_hedge_aus_bei_null(monkeypatch):
|
||||
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0)
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 60, "claude")
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 0.1, "claude")
|
||||
assert res == ["ok"]
|
||||
assert calls == ["k1"]
|
||||
|
||||
|
||||
async def test_hedge_schwelle_skaliert_mit_timeout(monkeypatch):
|
||||
"""Die Schwelle ist max(HEDGE_NACH_S, timeout/2): ein gesunder Call, der länger als
|
||||
die Untergrenze, aber kürzer als das halbe Timeout läuft, bekommt KEINEN Zwilling
|
||||
(pauschale 90 s hedgten jeden normalen Fix-Call)."""
|
||||
calls = []
|
||||
|
||||
async def fake_agent(key, prompt, timeout, **kw):
|
||||
calls.append(key)
|
||||
await asyncio.sleep(0.15) # > Untergrenze 0.05, < timeout/2 = 0.5
|
||||
return (0, "ok", "")
|
||||
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0.05)
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 1.0, "claude")
|
||||
assert res == ["ok"]
|
||||
assert calls == ["k1"]
|
||||
|
||||
@@ -133,6 +151,6 @@ async def test_hedge_zwilling_ersetzt_restart(monkeypatch):
|
||||
monkeypatch.setattr(pipeline, "run_agent", fake_agent)
|
||||
monkeypatch.setattr(pipeline, "kill_process", lambda k: None)
|
||||
monkeypatch.setattr(pipeline, "_HEDGE_NACH_S", 0.05)
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 60, "claude")
|
||||
res = await pipeline._race("t", "Test", [_slot()], 1, 0.1, "claude")
|
||||
assert res == ["zwilling"]
|
||||
assert calls == ["k1", "k1-h"] # kein dritter Spawn
|
||||
|
||||
Reference in New Issue
Block a user