Attention: long rate-limit item scans active sources only
Per Codex: a paused/retired source with a future retry_after_at shouldn't nag 'rate-limited for 12h+' — it's intentionally out of polling. Scope long_rest to active (matching the other operational items). Test: paused/retired rate-limited sources stay quiet. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -395,7 +395,7 @@ def _attention(content: dict, sources: list[dict], feedback_unread: int, now: da
|
|||||||
|
|
||||||
# Long rate-limit rest (info).
|
# Long rate-limit rest (info).
|
||||||
rest_cutoff = (now + timedelta(hours=_LONG_REST_HOURS)).strftime("%Y-%m-%d %H:%M:%S")
|
rest_cutoff = (now + timedelta(hours=_LONG_REST_HOURS)).strftime("%Y-%m-%d %H:%M:%S")
|
||||||
long_rest = [s for s in sources if s.get("retry_after_at") and s["retry_after_at"] > rest_cutoff]
|
long_rest = [s for s in active if s.get("retry_after_at") and s["retry_after_at"] > rest_cutoff]
|
||||||
if long_rest:
|
if long_rest:
|
||||||
items.append({"level": "info", "text": f"{len(long_rest)} source{n(len(long_rest))} rate-limited for {_LONG_REST_HOURS}h+"})
|
items.append({"level": "info", "text": f"{len(long_rest)} source{n(len(long_rest))} rate-limited for {_LONG_REST_HOURS}h+"})
|
||||||
|
|
||||||
|
|||||||
@@ -114,3 +114,16 @@ def test_attention_quiet_below_thresholds():
|
|||||||
{"status": "paused", "content_visible": 1, "last_success_at": "2020-01-01 00:00:00"}, # paused → ignored
|
{"status": "paused", "content_visible": 1, "last_success_at": "2020-01-01 00:00:00"}, # paused → ignored
|
||||||
]
|
]
|
||||||
assert queries._attention(content, sources, 0, now=now) == []
|
assert queries._attention(content, sources, 0, now=now) == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_attention_ignores_rate_limit_on_paused_or_retired():
|
||||||
|
from datetime import UTC, datetime
|
||||||
|
from goodnews import queries
|
||||||
|
now = datetime(2026, 6, 9, 12, 0, 0, tzinfo=UTC)
|
||||||
|
content = {"served": 100, "with_image": 95, "latest_brief_size": 7}
|
||||||
|
sources = [
|
||||||
|
{"status": "paused", "retry_after_at": "2026-06-12 00:00:00"}, # intentionally not polling
|
||||||
|
{"status": "retired", "retry_after_at": "2026-06-12 00:00:00"},
|
||||||
|
]
|
||||||
|
# neither should nag about a rate-limit rest
|
||||||
|
assert queries._attention(content, sources, 0, now=now) == []
|
||||||
|
|||||||
Reference in New Issue
Block a user