From 9f0c97768cc3609b52bdd46e085bac25dd965f6f Mon Sep 17 00:00:00 2001 From: ProtocolWarden Date: Tue, 14 Jul 2026 12:52:52 -0400 Subject: [PATCH] fix(OperationsCenter): suppress zero-finding custodian sweep Plane noise --- .../entrypoints/custodian_sweep/main.py | 2 ++ tests/test_custodian_sweep.py | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/operations_center/entrypoints/custodian_sweep/main.py b/src/operations_center/entrypoints/custodian_sweep/main.py index b2bf78b73..a8b872ee1 100644 --- a/src/operations_center/entrypoints/custodian_sweep/main.py +++ b/src/operations_center/entrypoints/custodian_sweep/main.py @@ -220,6 +220,8 @@ def _emit( dry_run: bool, ) -> str: """Create-or-comment one Plane task per repo. Returns action label.""" + if not sweep.error and sweep.total == 0: + return "skipped-zero-findings" title = f"[{sweep.repo_key}] custodian sweep: {sweep.total} findings" body = _render_body(sweep, deltas) existing = existing_tasks.get(sweep.repo_key) diff --git a/tests/test_custodian_sweep.py b/tests/test_custodian_sweep.py index d45ee8c03..aa5e9f652 100644 --- a/tests/test_custodian_sweep.py +++ b/tests/test_custodian_sweep.py @@ -18,6 +18,7 @@ _DEDUP_LABEL_PREFIX, _delta, _discover_targets, + _emit, _find_open_sweep_task, _index_open_sweep_tasks, _render_body, @@ -96,6 +97,30 @@ def test_find_open_sweep_task_returns_none_when_absent() -> None: assert _find_open_sweep_task(plane, "Demo") is None +def test_emit_skips_plane_mutation_for_zero_findings() -> None: + plane = SimpleNamespace( + comment_issue=lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected")), + create_issue=lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected")), + ) + sweep = _RepoSweep(repo_key="Demo", envelope=_envelope()) + + action = _emit(sweep, {}, plane, existing_tasks={}, dry_run=False) + + assert action == "skipped-zero-findings" + + +def test_emit_still_reports_zero_findings_skip_in_dry_run() -> None: + plane = SimpleNamespace( + comment_issue=lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected")), + create_issue=lambda *args, **kwargs: (_ for _ in ()).throw(AssertionError("unexpected")), + ) + sweep = _RepoSweep(repo_key="Demo", envelope=_envelope()) + + action = _emit(sweep, {}, plane, existing_tasks={}, dry_run=True) + + assert action == "skipped-zero-findings" + + def test_index_open_sweep_tasks_maps_repo_key_to_issue() -> None: plane = SimpleNamespace( list_issues=lambda: [