Safety assertion passes vacuously when no recommendations are produced
The finding
The test checks statuses <= {PROPOSED, APPROVED, RETIRED}. If run_cycle stores nothing (for example, a regression where hits are dropped, or a fixture or analyzer mismatch), statuses is the empty set. The empty set is a subset of anything, so the test still passes. The guarantee 'never moves anything past approved' is therefore never actually exercised.
1| from __future__ import annotations
2|
3| from datetime import UTC, datetime, timedelta
4|
5| import pytest
6|
7| from argus_scout.approvals import StandingApprovals
8| from argus_scout.cycles import AnalysisCycle
9| from argus_scout.engine import RecommendationEngine
10| from argus_scout.prometheus import PrometheusUnavailable, Sample
11| from argus_scout.recommendations import Confidence, Recommendation, Status
12| from argus_scout.severity import Severity
13| from argus_scout.signals import Evaluation, SignalHit, SignalRulesFile
14| from argus_scout.store import SqliteStore
15|
16| T0 = datetime(2026, 3, 1, 12, 0, tzinfo=UTC)
17| KEY = 'disk-filling{instance="node-a:9100",mountpoint="/data"}'
18|
19|
20| class Clock:
21| def __init__(self, at: datetime = T0) -> None:The work pack
Recommendation. Assert that recommendations were actually produced before checking the subset. For example: recs = store.list_recommendations(); assert recs; assert any(r.status == Status.APPROVED for r in recs). Optionally, also assert that the CRITICAL hits remain PROPOSED, since max_impact: medium should not auto-approve them.
Acceptance criteria
- Address: Safety assertion passes vacuously when no recommendations are produced
- Keep the change scoped to the cited file/symbols unless impact requires otherwise
- Assert that recommendations were actually produced before checking the subset. For example:
recs = store.list_recommendations(); assert recs; assert any(r.status == Status.APPROVED for r in recs). Optionally, also assert that the CRITICAL - Re-check
tests/test_engine.pyafter the fix
Status
- claimed
- resolved
The fix
693944b9fa test: engine guardrail and advisory-only tests can no longer pass vacuously. This commit closes 2 packs.
@@ -4,7 +4,7 @@ from datetime import UTC, datetime, timedelta import pytest -from argus_scout.approvals import StandingApprovals+from argus_scout.approvals import StandingApprovals, StandingRule from argus_scout.cycles import AnalysisCycle from argus_scout.engine import RecommendationEngine from argus_scout.prometheus import PrometheusUnavailable, Sample@@ -186,15 +186,17 @@ def test_standing_approval_applies_on_proposed(store, clock, write_file): @pytest.mark.parametrize("guarded", [{"severity": Severity.CRITICAL}, {"impact": "high: takes the host offline"}])-def test_guardrails_refuse_auto_approval(store, clock, write_file, guarded):- path = write_file(- "approvals.yaml",- "rules:\n - id: anything\n analyzer: '*'\n max_impact: medium\n min_confidence: low\n",- )- engine = RecommendationEngine(store, StandingApprovals(path), clock=clock)- report = engine.run_cycle(ran(hit(**guarded)))- assert report.auto_approved == []- assert report.new[0].status == Status.PROPOSED+def test_guardrails_refuse_auto_approval(store, clock, guarded):+ # A rule wider than the schema allows (max_impact: high), so its own scope refuses nothing: only the+ # guardrail stands between these hits and an auto-approval.+ approvals = StandingApprovals()+ approvals._api_rules["anything"] = StandingRule("anything", max_impact="high", min_confidence="low")+ engine = RecommendationEngine(store, approvals, clock=clock)+ report = engine.run_cycle(ran(hit(**guarded), hit("control")))+ [control] = report.auto_approved # the same rule approves an unguarded hit+ assert control.key == "control" and control.approved_by_rule == "anything"+ [refused] = [r for r in report.new if r.key == KEY]+ assert refused.status == Status.PROPOSED DISKS_RULE = "rules:\n - id: disks\n analyzer: disk-filling\n max_impact: low\n"@@ -324,8 +326,10 @@ def test_engine_never_moves_anything_past_approved(store, clock, write_file): for i in range(5): engine.run_cycle(ran(hit(f"k{i}"), hit(f"c{i}", severity=Severity.CRITICAL))) clock.advance(days=3)- statuses = {r.status for r in store.list_recommendations()}- assert statuses <= {Status.PROPOSED, Status.APPROVED, Status.RETIRED}+ recs = store.list_recommendations()+ assert recs and any(r.status == Status.APPROVED for r in recs) # not vacuous: the rule did approve+ assert {r.status for r in recs} <= {Status.PROPOSED, Status.APPROVED, Status.RETIRED}+ assert all(r.status != Status.APPROVED for r in recs if r.severity == Severity.CRITICAL) # --- the scheduled analysis cycle -----------------------------------------------------------------------------How it was judged
Waiver evidence waived: Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is b
Judged 24 Nov 2026, 04:53 UTC against dev at d0c0f66.
This fix strengthens a test. The stronger test passes on dev's code as well, so there is no failure on dev for it to show. It resolved on a written waiver of at least twenty characters, recorded with the pack:
Test-only finding: the fix strengthens a test, so the same test runs on both trees and passes on dev's source. Verified locally by mutation: the strengthened test fails when the guarded behaviour is broken, where the old one passed.