fix: prevent stale capacity poisoning and deepen recent-only refill scans

Keep ordinary capacity races from lowering persistent per-account limits.
Deepen recent-only discovery within the existing age and quality gates.
Add offline regressions for recovery and reserved-slot refill.
This commit is contained in:
coolboy
2026-10-02 21:24:08 +08:00
parent 6154dc738f
commit dc8365c215
4 changed files with 138 additions and 2 deletions

View File

@@ -822,6 +822,17 @@ def build_adaptive_scan_stages(
"limit": max_models,
}
)
if not allow_older_than_recent_window:
# Reserved positions still need a deep search of eligible recent
# models. Widening the date window alone repeatedly scans the same
# short prefix (often already processed) on every poll cycle.
stages.append(
{
"name": "recent_window_full",
"updatedAfter": recent_cutoff,
"limit": max_models,
}
)
deduped: list[dict[str, Any]] = []
seen: set[tuple[str | None, int, str]] = set()
for stage in stages: