fix(robomp): deferred rate-limited submissions

Stored a bounded per-login overflow backlog and promoted deferred events oldest-first as rolling-window capacity became available. Surfaced the deferred state through the dashboard contract and documented admission behavior.

Fixes #5882
This commit is contained in:
roboomp
2026-07-17 17:26:39 +00:00
parent 0f9fceeea4
commit aecef46436
12 changed files with 297 additions and 32 deletions
@@ -92,3 +92,25 @@ async def test_dispatch_pr_synchronize_is_noop(
await _make_pool(settings, db)._dispatch(_pr_row("synchronize")) # noqa: SLF001
assert called is False
@pytest.mark.asyncio
async def test_claim_promotes_deferred_submission_after_window_frees(settings: Settings, db: Database) -> None:
assert db.record_submission(delivery_id="accepted", login="alice", repo="octo/widget")
assert db.defer_submission_event(
delivery_id="deferred",
event_type="issues",
login="alice",
repo="octo/widget",
issue_key="octo/widget#8",
payload={"action": "opened", "issue": {"number": 8}},
cap=1,
reason="rate limit",
)
settings.rate_limit_window_seconds = -1
row = await _make_pool(settings, db)._claim_next_unique() # noqa: SLF001
assert row is not None
assert row.delivery_id == "deferred"
assert row.state == "running"