Auditor recorded output

← All 27 packs

Proven

Events marked announced before the report is delivered; a delivery failure silently drops the news

bugmedium src/argus_scout/cycles.py:104

The finding

In _report, every event in the reported groups is passed to store.mark_announced before await self.deliver(report) runs. If delivery raises (for example the echo/mask channel is down, a network error, or a timeout), the events already have last_broadcast_at set. On the next tick is_news returns False for them, so report_due stays False until the reannounce interval expires. With voice_on_change_only, they are also kept out of speech. The alert is effectively lost even though nobody received it. The exception also escapes __call__ before self.last is updated.

   92|     quiet: bool = False
   93|     groups: list[EventGroup] = field(default_factory=list)
   94|     decisions: list[Decision] = field(default_factory=list)
   95|     """One per group, decided on the group's latest event."""
   96|     report: Report | None = None
   97|     """The status report written this cycle, if one was due."""
   98| 
   99|     @property
  100|     def reportable(self) -> list[Decision]:
  101|         return [d for d in self.decisions if d.report]
  102| 
  103| 
  104| class StatusCycle:
  105|     """One status tick: load the policy, read the inbox, decide what is worth reporting."""
  106| 
  107|     def __init__(
  108|         self,
  109|         store: Store,
  110|         policy_file: PolicyFile,
  111|         *,
  112|         inbox: Inbox | None = None,
  113|         tz: ZoneInfo | None = None,
  114|         clock: Clock = utc_now,
  115|         narrator: Narrator | None = None,
  116|         deliver: Deliver | None = None,

The work pack

Recommendation. Call await self.deliver(report) first, and only mark events announced after it succeeds. Alternatively, wrap delivery in try/except so a failure leaves the announce state untouched and the report is retried on the next cycle.

Acceptance criteria

  • Address: Events marked announced before the report is delivered; a delivery failure silently drops the news
  • Keep the change scoped to the cited file/symbols unless impact requires otherwise
  • Call await self.deliver(report) first, and only mark events announced after it succeeds. Alternatively, wrap delivery in try/except so a failure leaves the announce state untouched and the report is retried on the next cycle.
  • Re-check src/argus_scout/cycles.py after the fix

Status

  1. claimed
  2. resolved

The fix

d9f93cad4c fix: mark status events announced only after the report is delivered.

diff --git a/src/argus_scout/cycles.py b/src/argus_scout/cycles.pyindex f37a45c..a628a38 100644--- a/src/argus_scout/cycles.py+++ b/src/argus_scout/cycles.py@@ -202,10 +202,11 @@ class StatusCycle:         decisions = {g.fingerprint: d for g, d in zip(result.groups, result.decisions, strict=True)}         speakable = self.speech(groups, decisions, policy, now)         report = await self.narrator.report("status", groups=groups, meta={"speakable": speakable})+        # Deliver first: if delivery raises, nothing is marked announced and the next tick reports it again.+        await self.deliver(report)         for group in groups:             for event in group.events:                 self.store.mark_announced(event.source, event.event_id, at=now)-        await self.deliver(report)         return report  diff --git a/tests/test_status_reports.py b/tests/test_status_reports.pyindex 64a673f..69eebc6 100644--- a/tests/test_status_reports.py+++ b/tests/test_status_reports.py@@ -265,6 +265,25 @@ async def test_a_condition_that_clears_and_recurs_is_reported_again(store):     assert again is not None and again.meta["facts"]["events"] == ["e1"]  +async def test_a_delivery_that_raises_leaves_the_news_unannounced(store):+    clock = Clock()+    inbox = Inbox(store, clock=clock)+    inbox.ingest(ev("e1", "warning", "Disk 90% full"))++    async def broken(report: Report) -> None:+        raise RuntimeError("channel exploded")++    cycle = StatusCycle(+        store, PolicyFile(None), clock=clock, inbox=inbox, narrator=Narrator(store, clock=clock), deliver=broken+    )+    with pytest.raises(RuntimeError):+        await cycle()+    assert all(e.last_broadcast_at is None for g in inbox.open_grouped() for e in g.events)+    clock.advance(minutes=5)+    again = (await status_cycle(store, PolicyFile(None), clock, inbox=inbox)()).report+    assert again is not None and again.meta["facts"]["events"] == ["e1"]++ async def test_a_new_item_is_news_and_the_old_one_rides_along(store):     clock = Clock()     inbox = Inbox(store, clock=clock)

How it was judged

Proven 1 test(s) fail on dev and pass with the fix: tests/test_status_reports.py::test_a_delivery_that_raises_leaves_the_news_unannounced

Judged 24 Nov 2026, 04:47 UTC against dev at d0c0f66.

Teston devdev + patch
tests/test_status_reports.py::test_a_delivery_that_raises_leaves_the_news_unannouncedfailedpassed
The other 17 tests in the run (17 with the same result on both trees)
tests/test_status_reports.py::test_a_condition_that_clears_and_recurs_is_reported_againpassedpassed
tests/test_status_reports.py::test_a_fresh_id_repeating_an_announced_item_is_not_newspassedpassed
tests/test_status_reports.py::test_a_new_item_is_news_and_the_old_one_rides_alongpassedpassed
tests/test_status_reports.py::test_an_escalation_is_newspassedpassed
tests/test_status_reports.py::test_an_item_clearing_is_not_newspassedpassed
tests/test_status_reports.py::test_an_item_clearing_reannounces_only_when_duepassedpassed
tests/test_status_reports.py::test_an_item_held_back_by_quiet_hours_is_reported_after_thempassedpassed
tests/test_status_reports.py::test_briefing_severity_counts_items_and_open_recommendationspassedpassed
tests/test_status_reports.py::test_critical_status_report_is_spoken_in_quiet_hourspassedpassed
tests/test_status_reports.py::test_critical_status_report_reaches_a_critical_only_channelpassedpassed
tests/test_status_reports.py::test_on_change_only_keeps_repeats_text_onlypassedpassed
tests/test_status_reports.py::test_quiet_exempt_status_report_is_spoken_in_quiet_hourspassedpassed
tests/test_status_reports.py::test_speech_holds_only_the_voice_eligible_itemspassedpassed
tests/test_status_reports.py::test_speech_uses_an_events_own_spoken_text_when_it_has_onepassedpassed
tests/test_status_reports.py::test_text_only_and_unspeakable_items_are_not_spokenpassedpassed
tests/test_status_reports.py::test_unspeakable_report_skips_synthesis_whatever_the_gates_saypassedpassed
tests/test_status_reports.py::test_warning_report_is_filtered_off_a_critical_only_channelpassedpassed