leo: prioritize fresh PRs over re-evals in eval queue

Unevaluated PRs (eval_attempts=0) now sort before re-evals in the
eval cycle query. Fresh PRs have a higher chance of passing (~12%)
vs re-evals of already-rejected PRs. Prevents migration-reset PRs
from consuming eval slots that fresh PRs could use.

Pentagon-Agent: Leo <294C3CA1-0205-4668-82FA-B984D54F48AD>
This commit is contained in:
m3taversal 2026-03-13 17:32:07 +00:00
parent 93e6f16144
commit 615af9b53d

View file

@ -520,6 +520,8 @@ async def evaluate_cycle(conn, max_workers=None) -> tuple[int, int]:
AND (p.last_attempt IS NULL
OR p.last_attempt < datetime('now', '-10 minutes'))
ORDER BY
-- Fresh PRs before re-evals: unevaluated PRs have higher chance of passing
CASE WHEN COALESCE(p.eval_attempts, 0) = 0 THEN 0 ELSE 1 END,
CASE COALESCE(p.priority, s.priority, 'medium')
WHEN 'critical' THEN 0
WHEN 'high' THEN 1