Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(signals): skip reviewer routing for addressed reports (#130239)

Dylan Martin0867cd0662eb
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index 117904a95cdb..ef3fb7c93889 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -338,6 +338,8 @@ When a project member adds a reviewer, the report shows "Added by" and that memb
Slack notifications for a ready report include only reviewers who have access to the report's project when delivery starts.
The same access rule applies when a reviewer is added later.
If no suggested reviewer has access, the ready report still goes to the configured team channel without reviewer mentions.
+If the latest actionability judgment marks the report as already addressed, the system does not assign a fallback owner or send a reviewer push notification.
+Slack still sends the report to the configured team channel without reviewer mentions.
The notification activity retries transient ClickHouse reads before it claims the report for delivery.
When an implementation pull request has one assignee, the worker requests that person's review, even when another person or team request exists.
diff --git a/products/signals/backend/default_owner.py b/products/signals/backend/default_owner.py
index e8fe5e04d95a..118f837d5245 100644
--- a/products/signals/backend/default_owner.py
+++ b/products/signals/backend/default_owner.py
@@ -188,7 +188,7 @@ def _reviewers_were_curated(team_id: int, report_id: str) -> bool:
def assign_default_owner(team: Team, report_id: str) -> bool:
- """Route a report that has no reviewers to its default owner. Returns whether it wrote one."""
+ """Route an unaddressed report with no reviewers to its default owner. Returns whether it wrote one."""
if not default_owner_fallback_enabled(team.id):
return False
# Where a repository is in reach, commit history names a relevant reviewer often enough that
@@ -205,9 +205,9 @@ def assign_default_owner(team: Team, report_id: str) -> bool:
# while this transaction holds the report row, which is the same row `append_status` locks
# and so costs nothing extra. Without it a person's edit that commits in between is lost.
with transaction.atomic():
- SignalReport.objects.select_for_update().get(team_id=team.id, id=report_id)
+ report = SignalReport.objects.select_for_update().get(team_id=team.id, id=report_id)
snapshot = ReviewerRules.read_for_report(team_id=team.id, report_id=report_id)
- if snapshot.reviewers or snapshot.invalid_reviewers:
+ if report.latest_already_addressed is True or snapshot.reviewers or snapshot.invalid_reviewers:
return False
if _reviewers_were_curated(team.id, report_id):
return False
diff --git a/products/signals/backend/inbox_push_notifications.py b/products/signals/backend/inbox_push_notifications.py
index 78466e1edf48..386832705b4c 100644
--- a/products/signals/backend/inbox_push_notifications.py
+++ b/products/signals/backend/inbox_push_notifications.py
@@ -92,7 +92,7 @@ def schedule_pull_request_ready_push(pull_request: SignalReportPullRequest, *, p
def notify_report_visible(*, team_id: int, report_id: str) -> list[int]:
- """Push the new report to its suggested reviewers. Returns the user ids a push was queued for.
+ """Push an unaddressed new report to its suggested reviewers. Returns the queued user ids.
A report with no reviewer that resolves to a project member pushes to nobody, rather than to
the whole team.
@@ -103,7 +103,7 @@ def notify_report_visible(*, team_id: int, report_id: str) -> list[int]:
.select_related("team")
.first()
)
- if report is None:
+ if report is None or report.latest_already_addressed is True:
return []
reviewer_ids = resolve_org_suggested_reviewer_user_ids(team_id=team_id, report_ids=[str(report.id)]).get(
str(report.id), set()
diff --git a/products/signals/backend/slack_inbox_notifications.py b/products/signals/backend/slack_inbox_notifications.py
index b6d44f6eb8a7..2d4e0ee0def6 100644
--- a/products/signals/backend/slack_inbox_notifications.py
+++ b/products/signals/backend/slack_inbox_notifications.py
@@ -7,6 +7,7 @@ suggested reviewer is also routed to one destination: their own configured targe
by their min-priority), otherwise the team-default channel. A personal target is either a channel
or the reviewer's own Slack account, which Slack delivers as a direct message. Reviewers sharing a
destination get a single post mentioning only the reviewers routed there.
+Already-addressed reports still reach the team channel, but do not notify suggested reviewers.
All sends are best-effort.
"""
@@ -564,7 +565,9 @@ def _build_reviewer_routes(
its own reviewers. The team-default channel (if configured) receives every report, with no
mentions when no reviewer is routed there.
"""
- reviewer_user_ids = resolve_suggested_reviewer_user_ids(report)
+ reviewer_user_ids = (
+ set() if report.latest_already_addressed is True else resolve_suggested_reviewer_user_ids(report)
+ )
reviewer_users = {user.id: user for user in User.objects.filter(id__in=reviewer_user_ids)}
own_configs = _own_target_configs_by_user(report.team_id, reviewer_user_ids)
diff --git a/products/signals/backend/test/test_default_owner.py b/products/signals/backend/test/test_default_owner.py
index 63c8badcb6a8..eec7a1319d1e 100644
--- a/products/signals/backend/test/test_default_owner.py
+++ b/products/signals/backend/test/test_default_owner.py
@@ -181,6 +181,21 @@ class TestDefaultOwner(BaseTest):
assert entry["user_uuid"] == str(self.user.uuid)
assert entry["is_default_owner"] is True
+ def test_does_not_route_an_already_addressed_report_to_the_default_owner(self) -> None:
+ self._activated_by(self.user)
+ self._reviewers([])
+ SignalReportArtefact.objects.create(
+ team=self.team,
+ report=self.report,
+ type=SignalReportArtefact.ArtefactType.ACTIONABILITY_JUDGMENT,
+ content=json.dumps({"actionability": "immediately_actionable", "already_addressed": True}),
+ )
+
+ with patch("products.signals.backend.default_owner.default_owner_fallback_enabled", return_value=True):
+ assert assign_default_owner(self.team, str(self.report.id)) is False
+
+ assert self._latest_reviewers() == []
+
@parameterized.expand([("code_available", True, False), ("no_code_access", False, True)])
def test_assigns_only_when_self_driving_cannot_read_code(self, _name: str, has_code: bool, assigned: bool) -> None:
self._activated_by(self.user)
diff --git a/products/signals/backend/test/test_inbox_push_notifications.py b/products/signals/backend/test/test_inbox_push_notifications.py
index 0e16cee4c3fa..929b87d8c077 100644
--- a/products/signals/backend/test/test_inbox_push_notifications.py
+++ b/products/signals/backend/test/test_inbox_push_notifications.py
@@ -112,18 +112,26 @@ class TestInboxPushNotifications(BaseTest):
@parameterized.expand(
[
- ("no_reviewers", False, True, False),
- ("flag_off", True, False, False),
- ("visible_before", True, True, True),
+ ("no_reviewers", False, True, False, False),
+ ("flag_off", True, False, False, False),
+ ("visible_before", True, True, True, False),
+ ("already_addressed", True, True, False, True),
]
)
def test_report_visibility_pushes_nothing(
- self, _name: str, has_reviewers: bool, flag_enabled: bool, visible_before: bool
+ self, _name: str, has_reviewers: bool, flag_enabled: bool, visible_before: bool, already_addressed: bool
) -> None:
self.flag.return_value = flag_enabled
report = self._report(SignalReport.Status.IN_PROGRESS, first_visible_at=VISIBLE_AT if visible_before else None)
if has_reviewers:
self._add_reviewers(report, self.reviewer)
+ if already_addressed:
+ SignalReportArtefact.objects.create(
+ team=self.team,
+ report=report,
+ type=SignalReportArtefact.ArtefactType.ACTIONABILITY_JUDGMENT,
+ content=json.dumps({"actionability": "immediately_actionable", "already_addressed": True}),
+ )
with self.captureOnCommitCallbacks(execute=True):
self._make_visible(report)
diff --git a/products/signals/backend/test/test_slack_inbox_notifications.py b/products/signals/backend/test/test_slack_inbox_notifications.py
index c76713a62994..00d69a912bad 100644
--- a/products/signals/backend/test/test_slack_inbox_notifications.py
+++ b/products/signals/backend/test/test_slack_inbox_notifications.py
@@ -345,6 +345,7 @@ def _make_ready_report(
summary: str = "Summary text",
priority: str | None = None,
actionability: str | None = ActionabilityChoice.IMMEDIATELY_ACTIONABLE,
+ already_addressed: bool = False,
suggested_logins: list[str] | None = None,
) -> SignalReport:
report = SignalReport.objects.create(
@@ -355,7 +356,7 @@ def _make_ready_report(
team=team,
report=report,
type=SignalReportArtefact.ArtefactType.ACTIONABILITY_JUDGMENT,
- content=json.dumps({"actionability": actionability}),
+ content=json.dumps({"actionability": actionability, "already_addressed": already_addressed}),
)
if priority:
SignalReportArtefact.objects.create(
@@ -816,6 +817,34 @@ def test_dispatch_notifies_requires_human_input_report_without_priority(org_and_
assert fake_client.chat_postMessage.call_args.kwargs["channel"] == "CTEAM"
+def test_dispatch_does_not_route_already_addressed_report_to_reviewer(org_and_team):
+ org, team = org_and_team
+ reviewer = _make_reviewer_user(org, "[email protected]", "handled-reviewer")
+ integration = _make_slack_integration(team, reviewer)
+ _set_team_channel(team, "CTEAM|#team-inbox", integration)
+ SignalUserAutonomyConfig.objects.create(
+ user=reviewer,
+ slack_notification_integration=integration,
+ slack_notification_channel="CREVIEWER|#reviewer-inbox",
+ )
+ report = _make_ready_report(
+ team,
+ priority=AutonomyPriority.P2,
+ already_addressed=True,
+ suggested_logins=["handled-reviewer"],
+ )
+
+ fake_client = MagicMock()
+ with patch("products.signals.backend.slack_inbox_notifications.SlackIntegration") as slack_cls:
+ slack_cls.return_value.client = fake_client
+ sent = dispatch_inbox_item_notifications(str(report.id), team.id)
+
+ assert sent == 1
+ assert fake_client.chat_postMessage.call_args.kwargs["channel"] == "CTEAM"
+ assert "Suggested owner" not in json.dumps(fake_client.chat_postMessage.call_args.kwargs["blocks"])
+
+
@pytest.mark.django_db
def test_dispatch_groups_own_and_fallback_reviewers_sharing_a_channel(org_and_team):
# One reviewer's own channel resolves to the same channel as the team default that