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.

feat(signals): route reviewerless reports to a default owner (#125864)

Dylan Martin73103cba8a80
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.md
index 9682fe541b39..580e58f1b90b 100644
--- a/docs/internal/signals-pr-lifecycle.md
+++ b/docs/internal/signals-pr-lifecycle.md
@@ -213,6 +213,8 @@ Research without a repository retains the writing rules, attached-image inspecti
With `signals-research-reviewer-selection` enabled, project context, report evidence, and scoped human corrections can identify reviewers without GitHub. Research verifies their project membership with `scout-members-list` and suggests nobody when evidence is insufficient. A GitHub identity is not required to receive a report.
+With `signals-default-owner-fallback` enabled, a report that still has no reviewers when its inbox notification settles goes to a default owner. It runs only where Self-driving cannot read the team's code, meaning no GitHub installation, none that still reaches a repository, or none healthy enough to use. Where a repository is in reach, commit history names a relevant reviewer often enough that a report with no reviewers is left unassigned instead. The candidates are, in order: the configured owners of the scout that authored the report, then whoever enabled or created that scout, the person who activated Self-Driving, the people who enabled a signal source, and finally the organization's owner and admins. Each candidate must be an active member with project access when the fallback runs. The entry carries `is_default_owner` and shows as "Default owner". It never selects the autostart task identity. The fallback does not run on a report whose reviewers a person already edited, on a report that already had a default owner, or on a report that its scout keeps out of the inbox. When a person removes a default owner, no scout correction note is sent and the reviewer-corrections profile does not show the removal.
+
## Repository selection
For reports built from GitHub issues, the issue repository is a default when it is an eligible candidate.
diff --git a/products/signals/backend/artefact_schemas.py b/products/signals/backend/artefact_schemas.py
index 56b3cad82178..7886c25ea279 100644
--- a/products/signals/backend/artefact_schemas.py
+++ b/products/signals/backend/artefact_schemas.py
@@ -254,6 +254,14 @@ class SuggestedReviewerEntry(BaseModel):
default=False,
description="Research selected this reviewer. Autostart requires independent ownership or commit confirmation.",
)
+ is_default_owner: bool = Field(
+ default=False,
+ description=(
+ "True when no evidence selected anyone and the report fell back to the project's default owner. "
+ "The entry routes the report, but it is not ownership evidence: removing it is not a routing "
+ "correction, and it never selects the autostart task identity."
+ ),
+ )
source_skill: str | None = Field(
default=None,
description=(
diff --git a/products/signals/backend/assignment_flags.py b/products/signals/backend/assignment_flags.py
index 2af6f009a328..50c38e791fc6 100644
--- a/products/signals/backend/assignment_flags.py
+++ b/products/signals/backend/assignment_flags.py
@@ -35,6 +35,10 @@ def assignment_side_effects_enabled(team_id: int) -> bool:
return _enabled("signals-assignment-side-effects", team_id)
+def default_owner_fallback_enabled(team_id: int) -> bool:
+ return _enabled("signals-default-owner-fallback", team_id)
+
+
def assignment_side_effects_allowed(*, team_id: int, report_id: str) -> bool:
# Keep the trial boundary after a writer flag is disabled, including for queued work.
if not SignalReportArtefact.objects.filter(
diff --git a/products/signals/backend/auto_start.py b/products/signals/backend/auto_start.py
index 90a01c5a31a6..22489d38033b 100644
--- a/products/signals/backend/auto_start.py
+++ b/products/signals/backend/auto_start.py
@@ -18,7 +18,6 @@ from posthog.dataclasses import frozen
from posthog.egress.limiter.policies import Priority as EgressPriority
from posthog.event_usage import groups
from posthog.models import Team, User
-from posthog.models.organization import OrganizationMembership
from posthog.sync import database_sync_to_async
from posthog.temporal.oauth import McpScopePreset, grants_scratchpad_write
from posthog.user_permissions import UserPermissions
@@ -38,6 +37,7 @@ from products.signals.backend.billing import (
mark_report_billing_exempt,
system_billing_exempt_reason,
)
+from products.signals.backend.default_owner import resolve_signals_enabler
from products.signals.backend.enums import ReportLinkKind
from products.signals.backend.free_trial import capture_signal_report_free_trial_paused, self_driving_free_trial_enabled
from products.signals.backend.github_optional import ResearchAccessPolicy
@@ -47,7 +47,6 @@ from products.signals.backend.models import (
MAX_SCOUT_CONTENT_REVISIONS,
SignalReport,
SignalReportArtefact,
- SignalSourceConfig,
SignalTeamConfig,
SignalUserAutonomyConfig,
)
@@ -182,6 +181,8 @@ class ReviewerContent(TypedDict):
# was stamped for it. These route the report but are never eligible to select the autostart task identity.
is_skill_owner: bool
is_research_selected: NotRequired[bool]
+ # A fallback when no evidence picked anyone. It routes the report but never selects the task identity.
+ is_default_owner: NotRequired[bool]
# The scout skill whose run wrote this entry (None when no scout did). Carried so the live owner
# exclusion still knows the writing scout when the run's best-effort edit tally was lost.
source_skill: str | None
@@ -1246,6 +1247,7 @@ def _resolve_autostart_assignee(
r
for r in reviewers_content
if not r.get("is_skill_owner")
+ and not r.get("is_default_owner")
and (not r.get("is_research_selected") or r.get("user_uuid") in confirmed_uuids)
and not owners.covers(user_uuid=r.get("user_uuid"), github_login=r.get("github_login"))
]
@@ -1305,51 +1307,10 @@ def _resolve_autostart_fallback_user(team_id: int) -> User | None:
Rather than drop the auto-start, run the implementation task under the human who turned signals
on for this team. Enabling a signal source is the team's opt-in to the signals product, of which
autonomous PRs are a part, so attributing the task to that member is within the team's consent.
-
- Resolution, restricted at every tier to *active* org members (still in the org and not
- deactivated) — the task mints a PostHog OAuth token as this user, so a departed or disabled
- account can't run it:
-
- 1. The earliest active member who enabled a ``SignalSourceConfig`` for this team (ordered by
- the source's creation time) — who first turned signals on.
- 2. If none (sources enabled by a system path leave ``created_by`` null), the organization's
- owner, then an admin — the accountable human for an org that is clearly running signals.
- 3. Otherwise ``None`` — no eligible human, so nothing auto-starts.
-
- Deterministic within each tier so concurrent evaluations pick the same user.
+ The task mints a PostHog OAuth token as this user, which is why `resolve_signals_enabler` only
+ returns active org members.
"""
- org_id = Team.objects.filter(id=team_id).values_list("organization_id", flat=True).first()
- if org_id is None:
- return None
-
- active_member_ids = OrganizationMembership.objects.filter(organization_id=org_id, user__is_active=True).values_list(
- "user_id", flat=True
- )
-
- # Tier 1: the earliest active member who enabled a signal source for this team.
- enabler_id = (
- SignalSourceConfig.objects.filter(team_id=team_id, created_by_id__in=active_member_ids)
- .order_by("created_at")
- .values_list("created_by_id", flat=True)
- .first()
- )
- if enabler_id is not None:
- return User.objects.filter(id=enabler_id).first()
-
- # Tier 2: no active enabler — fall back to the org's owner, then an admin (highest level first).
- fallback_id = (
- OrganizationMembership.objects.filter(
- organization_id=org_id,
- user__is_active=True,
- level__gte=OrganizationMembership.Level.ADMIN,
- )
- .order_by("-level", "user_id")
- .values_list("user_id", flat=True)
- .first()
- )
- if fallback_id is not None:
- return User.objects.filter(id=fallback_id).first()
- return None
+ return resolve_signals_enabler(team_id)
def _resolve_triggering_user(
@@ -1771,6 +1732,7 @@ async def _latest_reviewers_content(report_id: str) -> tuple[list[ReviewerConten
reason=entry.get("reason"),
is_skill_owner=bool(entry.get("is_skill_owner")),
is_research_selected=bool(entry.get("is_research_selected")),
+ is_default_owner=bool(entry.get("is_default_owner")),
source_skill=str(source_skill) if source_skill else None,
)
)
diff --git a/products/signals/backend/default_owner.py b/products/signals/backend/default_owner.py
new file mode 100644
index 000000000000..e8fe5e04d95a
--- /dev/null
+++ b/products/signals/backend/default_owner.py
@@ -0,0 +1,239 @@
+"""The person a report routes to when no evidence selected anyone.
+
+A report with no suggested reviewers notifies nobody: no Slack mention, no push, and no "For you"
+entry. The default owner gives that report one accountable person. The entry carries
+`is_default_owner`, so readers can tell it from an evidence-based pick, and its removal does not
+teach routing anything.
+"""
+
+from __future__ import annotations
+
+import json
+
+from django.db import transaction
+
+import structlog
+
+from posthog.models import Team, User
+from posthog.models.organization import OrganizationMembership
+
+from products.signals.backend.artefact_attribution import ArtefactAttribution
+from products.signals.backend.artefact_schemas import ReviewerProposal, SuggestedReviewerEntry, SuggestedReviewers
+from products.signals.backend.assignment_flags import default_owner_fallback_enabled
+from products.signals.backend.github_optional import team_has_code_access
+from products.signals.backend.models import (
+ SignalReport,
+ SignalReportArtefact,
+ SignalScoutConfig,
+ SignalSourceConfig,
+ SignalTeamConfig,
+)
+from products.signals.backend.report_access import may_read_reports
+from products.signals.backend.reviewer_rules import (
+ ReviewerRules,
+ ReviewerWriteError,
+ StaleReviewerProposal,
+ contains_reviewer,
+)
+from products.signals.backend.scout_authorship import report_is_hidden_from_inbox, resolve_report_scout_skill
+from products.signals.backend.scout_harness.skill_loader import resolve_skill_owner_user_uuids
+
+logger = structlog.get_logger(__name__)
+
+DEFAULT_OWNER_REASON = "No reviewer matched the evidence for this report, so it went to the default owner."
+
+
+def accountable_candidate_ids(team_id: int) -> list[int]:
+ """Who answers for signals on this team, most accountable first.
+
+ Restricted at every tier to *active* org members (still in the org and not deactivated),
+ because callers act as this user and a departed or disabled account must not:
+
+ 1. The members who enabled a ``SignalSourceConfig`` for this team, earliest source first,
+ which is who turned signals on.
+ 2. The organization's owner, then its admins, which is the accountable human for an org that
+ is clearly running signals.
+
+ Both tiers are returned, not just the first that matches: sources enabled by a system path
+ leave ``created_by`` null, and an enabler can also have lost access to the project since, so a
+ caller that rejects a candidate still has somewhere to go.
+
+ Deterministic within each tier so concurrent evaluations pick the same user.
+ """
+ org_id = Team.objects.filter(id=team_id).values_list("organization_id", flat=True).first()
+ if org_id is None:
+ return []
+
+ active_member_ids = OrganizationMembership.objects.filter(organization_id=org_id, user__is_active=True).values_list(
+ "user_id", flat=True
+ )
+
+ enabler_ids = (
+ SignalSourceConfig.objects.filter(team_id=team_id, created_by_id__in=active_member_ids)
+ .order_by("created_at")
+ .values_list("created_by_id", flat=True)
+ )
+ admin_ids = (
+ OrganizationMembership.objects.filter(
+ organization_id=org_id,
+ user__is_active=True,
+ level__gte=OrganizationMembership.Level.ADMIN,
+ )
+ .order_by("-level", "user_id")
+ .values_list("user_id", flat=True)
+ )
+ return list(dict.fromkeys([*enabler_ids, *admin_ids]))
+
+
+def resolve_signals_enabler(team_id: int) -> User | None:
+ """The human who turned signals on for this team, or the org's accountable admin.
+
+ The first of `accountable_candidate_ids`, for a caller that can only act as one person. A
+ caller that can reject a candidate on its own terms walks the whole list instead.
+ """
+ candidate_id = next(iter(accountable_candidate_ids(team_id)), None)
+ if candidate_id is None:
+ return None
+ return User.objects.filter(id=candidate_id).first()
+
+
+def _scout_owner_ids(team: Team, report_id: str) -> list[int]:
+ skill_name = resolve_report_scout_skill(team.id, report_id)
+ if not skill_name:
+ return []
+ # The configured owners come first: that list is the durable answer to who reviews a scout's
+ # reports, while the config only records who switched the scout on.
+ owner_uuids = resolve_skill_owner_user_uuids(team, skill_name)
+ ids_by_uuid = {
+ str(uuid): user_id for uuid, user_id in User.objects.filter(uuid__in=owner_uuids).values_list("uuid", "id")
+ }
+ owner_ids = [ids_by_uuid[uuid] for uuid in owner_uuids if uuid in ids_by_uuid]
+ # Scout rows live under the canonical parent team, while the report can sit in a child environment.
+ canonical_team_id = team.parent_team_id or team.id
+ row = (
+ SignalScoutConfig.objects.for_team(canonical_team_id)
+ .filter(skill_name=skill_name)
+ .values_list("enabled_by_id", "created_by_id")
+ .first()
+ )
+ return [*owner_ids, *(user_id for user_id in row or () if user_id is not None)]
+
+
+def _activator_ids(team: Team) -> list[int]:
+ team_ids = [team.id] + ([team.parent_team_id] if team.parent_team_id else [])
+ onboarding_by_team = dict(
+ SignalTeamConfig.objects.filter(team_id__in=team_ids).values_list("team_id", "onboarding")
+ )
+ ids: list[int] = []
+ for team_id in team_ids:
+ activated_by = (onboarding_by_team.get(team_id) or {}).get("activated_by")
+ if isinstance(activated_by, int):
+ ids.append(activated_by)
+ return ids
+
+
+def resolve_default_owner(team: Team, report_id: str) -> User | None:
+ """The first eligible person among the authoring scout's owners, the Self-Driving activator, and the enablers.
+
+ The scout owners come first because those people asked for this kind of report. Every candidate
+ must be an active member who can read the project's reports when the fallback runs, not only
+ when the candidate was recorded, so each tier offers everyone it has rather than only its best
+ pick. Report access is checked as well as project access, because the entry puts the report in
+ front of whoever it names: a Slack card, a push, and a "For you" row.
+ """
+ candidate_ids = [
+ *_scout_owner_ids(team, report_id),
+ *_activator_ids(team),
+ *accountable_candidate_ids(team.id),
+ ]
+ candidate_ids = list(dict.fromkeys(candidate_ids))
+ if not candidate_ids:
+ return None
+ candidates = {user.id: user for user in User.objects.filter(id__in=candidate_ids, is_active=True)}
+ if not candidates:
+ return None
+ eligible = {
+ user.id for user in team.all_users_with_access(user_uuids={str(user.uuid) for user in candidates.values()})
+ }
+ # Lazily, so a report whose first candidate is eligible costs one access-control resolution.
+ return next(
+ (
+ candidates[user_id]
+ for user_id in candidate_ids
+ if user_id in eligible and may_read_reports(user=candidates[user_id], team=team)
+ ),
+ None,
+ )
+
+
+def _reviewers_were_curated(team_id: int, report_id: str) -> bool:
+ """Whether a person already edited this report's reviewers, or the default owner was already assigned once.
+
+ Either way the fallback must stay out. Without this check, a person who removes the default
+ owner would get them back on the next notification settle.
+ """
+ rows = SignalReportArtefact.objects.filter(
+ team_id=team_id, report_id=report_id, type=SignalReportArtefact.ArtefactType.SUGGESTED_REVIEWERS
+ ).values_list("actor_kind", "created_by_id", "content")
+ for actor_kind, created_by_id, content in rows:
+ if actor_kind == "user" or (actor_kind is None and created_by_id is not None):
+ return True
+ try:
+ entries = json.loads(content)
+ except (TypeError, ValueError):
+ continue
+ if isinstance(entries, list) and any(isinstance(e, dict) and e.get("is_default_owner") for e in entries):
+ return True
+ return False
+
+
+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."""
+ 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
+ # leaving the occasional report unassigned is better than sending it to whoever switched the
+ # scout on.
+ if team_has_code_access(team.id):
+ return False
+ # The authoring scout sends these reports to another audience, so nobody in the project owns them.
+ if report_is_hidden_from_inbox(team.id, report_id):
+ return False
+ try:
+ # `expected_state` only guards the write once the assignment writer is enrolled, so on the
+ # legacy path the checks below are the whole guard. They hold until the write lands only
+ # 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)
+ snapshot = ReviewerRules.read_for_report(team_id=team.id, report_id=report_id)
+ if snapshot.reviewers or snapshot.invalid_reviewers:
+ return False
+ if _reviewers_were_curated(team.id, report_id):
+ return False
+ owner = resolve_default_owner(team, report_id)
+ if owner is None:
+ return False
+ entry = SuggestedReviewerEntry(
+ user_uuid=str(owner.uuid),
+ reason=DEFAULT_OWNER_REASON,
+ is_default_owner=True,
+ )
+ if contains_reviewer(snapshot.corrections.excluded, entry):
+ return False
+ artefact = SignalReportArtefact.append_status(
+ team_id=team.id,
+ report_id=report_id,
+ content=SuggestedReviewers(root=[entry]),
+ attribution=ArtefactAttribution.system(),
+ # Autostart never runs as a default owner, so this write cannot change its decision.
+ reevaluate_autostart=False,
+ reviewer_proposal=ReviewerProposal(expected_state=snapshot.state, source="default_owner"),
+ )
+ except (StaleReviewerProposal, ReviewerWriteError):
+ logger.info("signals.default_owner.skipped_concurrent_write", team_id=team.id, report_id=report_id)
+ return False
+ wrote = artefact.id != snapshot.state.reviewers_id and bool(json.loads(artefact.content))
+ if wrote:
+ logger.info("signals.default_owner.assigned", team_id=team.id, report_id=report_id)
+ return wrote
diff --git a/products/signals/backend/github_optional.py b/products/signals/backend/github_optional.py
index eb14fae12ec6..79c04aa604c6 100644
--- a/products/signals/backend/github_optional.py
+++ b/products/signals/backend/github_optional.py
@@ -112,3 +112,20 @@ class ResearchAccessPolicy:
for project in Team.objects.filter(id__in=projects).only("id", "uuid")
if ResearchAccessPolicy.enabled_for_project(project, only_evaluate_locally=True)
}
+
+
+def team_has_code_access(team_id: int) -> bool:
+ """Whether Self-driving can read this team's code.
+
+ False is what "running Self-driving without GitHub" means: no installation, none that still
+ reaches a repository, or none healthy enough to use. This is the branch that decides whether
+ report research runs in `code` or `data_only` mode, so a caller that gates on code access must
+ use it rather than test for an installation itself. Answered from Postgres alone, so a caller
+ on a per-report path can afford it.
+ """
+ # The repo-selection agent is not importable at django.setup().
+ from products.tasks.backend.facade.repo_selection import resolve_team_github_integration # noqa: PLC0415
+
+ # `team_only` because the personal and org-owner fallbacks would make a team that never
+ # connected GitHub itself look connected.
+ return resolve_team_github_integration(team_id, team_only=True) is not None
diff --git a/products/signals/backend/report_generation/resolve_reviewers.py b/products/signals/backend/report_generation/resolve_reviewers.py
index 4f41384f62f8..a11d59722425 100644
--- a/products/signals/backend/report_generation/resolve_reviewers.py
+++ b/products/signals/backend/report_generation/resolve_reviewers.py
@@ -297,7 +297,10 @@ def _with_reviewer_presentation(
safe_reason = bounded_reviewer_reason(reason)
explanation: str | None
- if safe_commits:
+ if reviewer.get("is_default_owner"):
+ source_label = "Default owner"
+ explanation = safe_reason
+ elif safe_commits:
source_label = "Code history"
explanation = _commit_explanation(safe_commits)
elif isinstance(source_skill, str) and source_skill:
diff --git a/products/signals/backend/scout_authorship.py b/products/signals/backend/scout_authorship.py
index 95eec76ec9cd..da416c6aadb9 100644
--- a/products/signals/backend/scout_authorship.py
+++ b/products/signals/backend/scout_authorship.py
@@ -71,7 +71,9 @@ def resolve_authoring_skill_names(team_id: int, report_ids: list[str]) -> dict[s
for report_id in report_ids:
touched |= Q(emitted_report_ids__contains=[report_id]) | Q(edited_report_ids__contains=[report_id])
runs = (
- SignalScoutRun.objects.filter(team_id=team_id)
+ # `for_team`, not an ambient-scope filter: the default-owner caller runs in a Temporal
+ # activity, which sets no team scope, and the fail-closed manager raises there.
+ SignalScoutRun.objects.for_team(team_id)
.filter(touched)
# Ascending so that when several runs touched the same report the newest one, applied last,
# is the skill that ends up owning it.
diff --git a/products/signals/backend/scout_harness/profile/builders.py b/products/signals/backend/scout_harness/profile/builders.py
index 880ba1f2bf46..c43503b8ad9e 100644
--- a/products/signals/backend/scout_harness/profile/builders.py
+++ b/products/signals/backend/scout_harness/profile/builders.py
@@ -844,12 +844,18 @@ def _recent_reviewer_corrections(team: Team) -> dict[str, Any]:
changes = detail.get("changes") or []
change = changes[0] if changes and isinstance(changes[0], dict) else {}
stated = {c.get("field"): c.get("after") for c in changes if isinstance(c, dict)}
+ # A default owner was a fallback, not a routing pick, so adding or removing one is not precedent.
+ default_owners = set(stated.get("default_owner_reviewers") or [])
+ before = [label for label in change.get("before") or [] if label not in default_owners]
+ after = [label for label in change.get("after") or [] if label not in default_owners]
+ if default_owners and set(before) == set(after):
+ continue
corrections.append(
{
"report_id": str(row.item_id),
"report_title": detail.get("name"),
- "before": change.get("before") or [],
- "after": change.get("after") or [],
+ "before": before,
+ "after": after,
"removal_reason": stated.get("removal_reason"),
"removal_reason_reviewers": stated.get("removal_reason_reviewers") or [],
"at": row.created_at.isoformat() if row.created_at else None,
diff --git a/products/signals/backend/serializers.py b/products/signals/backend/serializers.py
index 08836e32e701..ebe0a82aa42f 100644
--- a/products/signals/backend/serializers.py
+++ b/products/signals/backend/serializers.py
@@ -3215,6 +3215,12 @@ class SuggestedReviewerEntryReadSerializer(serializers.Serializer):
is_skill_owner = serializers.BooleanField(
help_text="True when the scout owner guardrail added the entry rather than commit authorship."
)
+ is_default_owner = serializers.BooleanField(
+ help_text=(
+ "True when no evidence selected anyone and the report fell back to the project's default owner. "
+ "The entry routes the report, but it is not ownership evidence."
+ )
+ )
source_skill = serializers.CharField(
allow_null=True, help_text="Scout skill whose run wrote the entry. Null when no scout did."
)
diff --git a/products/signals/backend/temporal/agentic/select_repository.py b/products/signals/backend/temporal/agentic/select_repository.py
index 387a4c96e20e..3f560589d7a4 100644
--- a/products/signals/backend/temporal/agentic/select_repository.py
+++ b/products/signals/backend/temporal/agentic/select_repository.py
@@ -17,7 +17,7 @@ from posthog.temporal.common.heartbeat import Heartbeater
from posthog.temporal.common.scoped import scoped_temporal
from posthog.temporal.common.utils import aretry_on_db_connection_drop, close_db_connections
-from products.signals.backend.github_optional import ResearchAccessPolicy
+from products.signals.backend.github_optional import ResearchAccessPolicy, team_has_code_access
from products.signals.backend.recurrence import recurrence_rejects_repository
from products.signals.backend.report_generation.select_repo import (
RepoSelectionResult,
@@ -76,7 +76,7 @@ def _pilot_code_availability(team_id: int) -> ReportResearchContext:
for adapter in adapters
):
return ReportResearchContext(mode="data_only", repository_status="no_repositories")
- if resolve_team_github_integration(team_id, team_only=True) is None:
+ if not team_has_code_access(team_id):
return ReportResearchContext(mode="data_only", repository_status="github_unavailable")
return ReportResearchContext(mode="code", repository_status="available")
diff --git a/products/signals/backend/temporal/inbox_notification.py b/products/signals/backend/temporal/inbox_notification.py
index f2af99ae75d0..aeed6e5e050b 100644
--- a/products/signals/backend/temporal/inbox_notification.py
+++ b/products/signals/backend/temporal/inbox_notification.py
@@ -30,6 +30,7 @@ from posthog.models import Team
from posthog.sync import database_sync_to_async
from posthog.temporal.common.scoped import scoped_temporal
+from products.signals.backend.default_owner import assign_default_owner
from products.signals.backend.github_writeback import post_report_link_to_github_issues
from products.signals.backend.models import SignalReport, SignalTeamConfig
from products.signals.backend.signal_metadata import fetch_signals_for_report_sync
@@ -146,6 +147,19 @@ def _send_report_inbox_notifications(team_id: int, report_id: str) -> int:
logger.info("inbox notification skipped: team gone", report_id=report_id, team_id=team_id)
return 0
+ # Before the card goes out, so the Slack card and "For you" both name the default owner. The
+ # "new report" push is queued on `first_visible_at` instead, when the report still had nobody,
+ # so an assignment queues that push again. Its per-user cooldown stops a second push to anyone
+ # it already reached. Guarded because the fallback is supplementary, the same way as the
+ # support write-back below.
+ try:
+ if assign_default_owner(team, report_id):
+ from products.signals.backend.inbox_push_notifications import schedule_report_visible_push
+
+ schedule_report_visible_push(team_id=team_id, report_id=report_id)
+ except Exception:
+ logger.exception("inbox notification: default owner assignment failed", report_id=report_id, team_id=team_id)
+
# Re-fetched at send time so a deferred write-back reflects the current signals.
signals = _fetch_signals_for_notification(team, report_id)
diff --git a/products/signals/backend/test/test_default_owner.py b/products/signals/backend/test/test_default_owner.py
new file mode 100644
index 000000000000..63c8badcb6a8
--- /dev/null
+++ b/products/signals/backend/test/test_default_owner.py
@@ -0,0 +1,211 @@
+import json
+
+from posthog.test.base import BaseTest
+from unittest.mock import patch
+
+from django.apps import apps
+
+from parameterized import parameterized
+
+from posthog.constants import AvailableFeature
+from posthog.models import User
+from posthog.models.organization import OrganizationMembership
+from posthog.models.scoping import reset_current_team_id, set_current_team_id
+
+from products.access_control.backend.models.access_control import AccessControl
+from products.signals.backend.default_owner import assign_default_owner, resolve_default_owner
+from products.signals.backend.models import (
+ SignalReport,
+ SignalReportArtefact,
+ SignalScoutConfig,
+ SignalScoutRun,
+ SignalSourceConfig,
+ SignalTeamConfig,
+)
+from products.skills.backend.models.skills import LLMSkill, LLMSkillOwner
+
+
+class TestDefaultOwner(BaseTest):
+ def setUp(self) -> None:
+ super().setUp()
+ self.report = SignalReport.objects.create(team=self.team, status="ready", title="A report")
+
+ def _member(self, email: str, *, active: bool = True, level: int = OrganizationMembership.Level.MEMBER) -> User:
+ user = User.objects.create(email=email, is_active=active)
+ OrganizationMembership.objects.create(user=user, organization=self.organization, level=level)
+ return user
+
+ def _make_project_private(self) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL}
+ ]
+ self.organization.save(update_fields=["available_product_features"])
+ AccessControl.objects.create(
+ team=self.team, resource="project", resource_id=str(self.team.id), access_level="none"
+ )
+
+ def _deny_reports_for(self, user: User) -> None:
+ self.organization.available_product_features = [
+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},
+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},
+ ]
+ self.organization.save(update_fields=["available_product_features"])
+ AccessControl.objects.create(
+ team=self.team,
+ resource="task",
+ access_level="none",
+ organization_member=OrganizationMembership.objects.get(organization=self.organization, user=user),
+ )
+
+ def _activated_by(self, user: User) -> None:
+ SignalTeamConfig.objects.update_or_create(team=self.team, defaults={"onboarding": {"activated_by": user.pk}})
+
+ def _enabled_source(self, user: User) -> None:
+ SignalSourceConfig.objects.create(
+ team=self.team, source_product="error_tracking", source_type="issue_created", created_by=user
+ )
+
+ def _authored_by_scout_of(self, user: User) -> None:
+ LLMSkill.objects.create(team=self.team, name="signals-scout-general", description="d", body="b")
+ config = SignalScoutConfig.objects.create(team=self.team, skill_name="signals-scout-general", created_by=user)
+ task = apps.get_model("tasks", "Task").objects.create(team=self.team, title="scout", description="d")
+ task_run = apps.get_model("tasks", "TaskRun").objects.create(team=self.team, task=task)
+ SignalScoutRun.objects.create(
+ team=self.team,
+ task_run=task_run,
+ scout_config=config,
+ skill_name=config.skill_name,
+ skill_version=1,
+ emitted_report_ids=[str(self.report.id)],
+ )
+
+ def _reviewers(self, content: list[dict], *, by: User | None = None) -> None:
+ SignalReportArtefact.objects.create(
+ team=self.team,
+ report=self.report,
+ type=SignalReportArtefact.ArtefactType.SUGGESTED_REVIEWERS,
+ content=json.dumps(content),
+ actor_kind="user" if by else "system",
+ created_by=by,
+ )
+
+ def _latest_reviewers(self) -> list[dict]:
+ latest = (
+ SignalReportArtefact.objects.filter(
+ report=self.report, type=SignalReportArtefact.ArtefactType.SUGGESTED_REVIEWERS
+ )
+ .order_by("-created_at", "-id")
+ .first()
+ )
+ return json.loads(latest.content) if latest else []
+
+ @parameterized.expand(
+ [
+ ("skill_owner_before_whoever_enabled_the_scout", True, True, True, "skill_owner"),
+ ("scout_owner_before_activator", True, False, True, "scout"),
+ ("activator_before_enabler", False, False, True, "activator"),
+ ("enabler_when_activator_is_deactivated", False, False, False, "enabler"),
+ ]
+ )
+ def test_picks_the_first_eligible_candidate(
+ self, _name: str, from_scout: bool, scout_has_owner: bool, activator_active: bool, expected: str
+ ) -> None:
+ people = {
+ "skill_owner": self._member("[email protected]"),
+ "scout": self._member("[email protected]"),
+ "activator": self._member("[email protected]", active=activator_active),
+ "enabler": self._member("[email protected]"),
+ }
+ if from_scout:
+ self._authored_by_scout_of(people["scout"])
+ if scout_has_owner:
+ LLMSkillOwner.objects.create(team=self.team, skill_name="signals-scout-general", user=people["skill_owner"])
+ self._activated_by(people["activator"])
+ self._enabled_source(people["enabler"])
+
+ owner = resolve_default_owner(self.team, str(self.report.id))
+
+ assert owner is not None
+ assert owner.id == people[expected].id
+
+ def test_falls_through_to_an_admin_when_the_enabler_cannot_see_the_project(self) -> None:
+ self._make_project_private()
+ enabler = self._member("[email protected]")
+ self._member("[email protected]", level=OrganizationMembership.Level.ADMIN)
+ self._enabled_source(enabler)
+
+ owner = resolve_default_owner(self.team, str(self.report.id))
+
+ assert owner is not None
+ assert owner.id != enabler.id
+
+ def test_skips_a_candidate_who_cannot_read_reports(self) -> None:
+ # Project access is not report access: the entry puts the report in front of whoever it names,
+ # so a candidate whose report access was revoked must be passed over for the next one.
+ enabler = self._member("[email protected]")
+ admin = self._member("[email protected]", level=OrganizationMembership.Level.ADMIN)
+ self._enabled_source(enabler)
+ self._deny_reports_for(enabler)
+
+ owner = resolve_default_owner(self.team, str(self.report.id))
+
+ assert owner is not None
+ assert owner.id == admin.id
+
+ def test_assigns_an_owner_outside_team_scope(self) -> None:
+ self._authored_by_scout_of(self._member("[email protected]"))
+ self._reviewers([])
+ token = set_current_team_id(None)
+
+ try:
+ 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 True
+ finally:
+ reset_current_team_id(token)
+
+ (entry,) = self._latest_reviewers()
+ assert entry["is_default_owner"] is True
+
+ @parameterized.expand([("legacy_writer", False), ("protected_writer", True)])
+ def test_routes_a_report_with_no_reviewers_to_the_default_owner(self, _name: str, writer_enabled: bool) -> None:
+ self._activated_by(self.user)
+ self._reviewers([])
+
+ with (
+ patch("products.signals.backend.default_owner.default_owner_fallback_enabled", return_value=True),
+ patch("products.signals.backend.reviewer_rules.assignment_writer_enabled", return_value=writer_enabled),
+ ):
+ assert assign_default_owner(self.team, str(self.report.id)) is True
+
+ (entry,) = self._latest_reviewers()
+ assert entry["user_uuid"] == str(self.user.uuid)
+ assert entry["is_default_owner"] is True
+
+ @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)
+ self._reviewers([])
+
+ with (
+ patch("products.signals.backend.default_owner.default_owner_fallback_enabled", return_value=True),
+ patch("products.signals.backend.default_owner.team_has_code_access", return_value=has_code),
+ ):
+ assert assign_default_owner(self.team, str(self.report.id)) is assigned
+
+ assert bool(self._latest_reviewers()) is assigned
+
+ @parameterized.expand([("evidence_reviewer_exists", False), ("person_removed_the_default_owner", True)])
+ def test_leaves_the_report_alone(self, _name: str, person_removed_default_owner: bool) -> None:
+ self._activated_by(self.user)
+ teammate = self._member("[email protected]")
+ if person_removed_default_owner:
+ self._reviewers([{"user_uuid": str(self.user.uuid), "is_default_owner": True}])
+ self._reviewers([], by=self.user)
+ else:
+ self._reviewers([{"user_uuid": str(teammate.uuid)}])
+ before = self._latest_reviewers()
+
+ 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() == before
diff --git a/products/signals/backend/test/test_inbox_notification_workflow.py b/products/signals/backend/test/test_inbox_notification_workflow.py
index 69eb3eef04c1..1e27f1ddd7c6 100644
--- a/products/signals/backend/test/test_inbox_notification_workflow.py
+++ b/products/signals/backend/test/test_inbox_notification_workflow.py
@@ -323,3 +323,24 @@ async def test_workflow_skips_the_pr_wait_when_the_report_already_notified():
await _run_workflow(recorder)
assert recorder.state_calls == 1
assert recorder.dispatch_calls == 1
+
+
[email protected]("assigned", [True, False])
+def test_send_queues_the_report_push_again_only_after_assigning_a_default_owner(team, assigned):
+ # The "new report" push is queued on `first_visible_at`, when a reviewerless report pushes to
+ # nobody, so a default owner assigned here only hears about the report if this requeues it.
+ report = _make_report(team)
+ with (
+ patch(
+ "products.signals.backend.temporal.inbox_notification.assign_default_owner", return_value=assigned
+ ) as assign,
+ patch("products.signals.backend.inbox_push_notifications.schedule_report_visible_push") as push,
+ patch("products.signals.backend.temporal.inbox_notification.post_report_findings_to_tickets"),
+ patch("products.signals.backend.temporal.inbox_notification.fetch_signals_for_report_sync", return_value=[]),
+ patch("products.signals.backend.slack_inbox_notifications.dispatch_inbox_item_notifications", return_value=1),
+ ):
+ assert _send_report_inbox_notifications(team.id, str(report.id)) == 1
+
+ assign.assert_called_once()
+ assert push.call_count == (1 if assigned else 0)
diff --git a/products/signals/backend/test/test_resolve_reviewers.py b/products/signals/backend/test/test_resolve_reviewers.py
index 7a7f5a2507a0..d318bb210266 100644
--- a/products/signals/backend/test/test_resolve_reviewers.py
+++ b/products/signals/backend/test/test_resolve_reviewers.py
@@ -176,6 +176,13 @@ def test_enriches_reviewer_sources_and_explanations():
"relevant_commits": [],
"reason": "Added as a reviewer by Morgan Lee",
},
+ {
+ "github_login": "fallback-owner",
+ "relevant_commits": [],
+ "reason": "Nobody owns this area yet, so it went to the project's default owner.",
+ "source_skill": "signals-scout-checkout-reliability",
+ "is_default_owner": True,
+ },
],
login_to_user={},
uuid_to_user={},
@@ -190,6 +197,8 @@ def test_enriches_reviewer_sources_and_explanations():
assert enriched[3]["source_label"] == "Added by teammate"
assert enriched[3]["explanation"] is None
assert enriched[4]["explanation"] is None
+ assert enriched[5]["source_label"] == "Default owner"
+ assert enriched[5]["explanation"] == "Nobody owns this area yet, so it went to the project's default owner."
@pytest.mark.django_db
diff --git a/products/signals/backend/test/test_signal_report_artefact_api.py b/products/signals/backend/test/test_signal_report_artefact_api.py
index a930e399e49d..076f07f79ad0 100644
--- a/products/signals/backend/test/test_signal_report_artefact_api.py
+++ b/products/signals/backend/test/test_signal_report_artefact_api.py
@@ -1431,6 +1431,106 @@ class TestSignalReportArtefactViewSet(APIBaseTest):
assert [r["user_uuid"] for r in self._latest_reviewers(report)] == [str(teammate.uuid)]
assert not self._reviewer_filter_matches(report, self.user)
+ def test_leaving_as_the_default_owner_is_not_a_routing_correction(self):
+ report = self._create_report()
+ self._create_artefact(report, content=[{"user_uuid": str(self.user.uuid), "is_default_owner": True}])
+
+ with (
+ patch("products.signals.backend.views.forward_reviewer_correction_note") as forward,
+ self.captureOnCommitCallbacks(execute=True),
+ ):
+ response = self.client.delete(self._leave_reviewers_url(str(report.id)))
+
+ assert response.status_code == status.HTTP_204_NO_CONTENT
+ assert self._latest_reviewers(report) == []
+ forward.assert_not_called()
+ assert _recent_reviewer_corrections(self.team)["corrections"] == []
+
+ @parameterized.expand(
+ [
+ # Set outright on an entry the stored list never marked.
+ ("claimed_outright", False),
+ # Inherited by pairing the stored owner's login with another member's uuid.
+ ("transferred_by_login", True),
+ ]
+ )
+ def test_posting_reviewers_cannot_forge_the_default_owner_flag(self, _name: str, borrow_owner_login: bool):
+ # Only the fallback may set is_default_owner: it is the mark the removal paths read to skip a
+ # routing correction, so a client that could set it could suppress someone else's correction.
+ report = self._create_report()
+ owner = self._create_org_member("[email protected]")
+ _attach_github_login(owner, "owner-login")
+ teammate = self._create_org_member("[email protected]")
+ self._create_artefact(
+ report,
+ content=[{"user_uuid": str(owner.uuid), "github_login": "owner-login", "is_default_owner": True}],
+ )
+ entry: dict = {"user_uuid": str(teammate.uuid)}
+ if borrow_owner_login:
+ entry["github_login"] = "owner-login"
+ else:
+ entry["is_default_owner"] = True
+
+ response = self.client.post(
+ self._list_url(str(report.id)),
+ {"artefact_type": "suggested_reviewers", "content": [entry]},
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ reviewers = self._latest_reviewers(report)
+ assert [item["user_uuid"] for item in reviewers] == [str(teammate.uuid)]
+ assert all(item["is_default_owner"] is False for item in reviewers)
+
+ @parameterized.expand(
+ [
+ # Names a teammate today.
+ ("another_members_login", "teammate-login"),
+ # Names nobody today, and whoever links that account tomorrow.
+ ("an_unlinked_login", "nobody-here"),
+ ]
+ )
+ def test_posting_reviewers_drops_the_default_owner_flag_on_a_mismatched_identity(self, _name: str, login: str):
+ # An unprotected report stores the pair as given, and a later edit matches the stored login.
+ report = self._create_report()
+ owner = self._create_org_member("[email protected]", github_login="owner-login")
+ self._create_org_member("[email protected]", github_login="teammate-login")
+ self._create_artefact(report, content=[{"user_uuid": str(owner.uuid), "is_default_owner": True}])
+
+ response = self.client.post(
+ self._list_url(str(report.id)),
+ {
+ "artefact_type": "suggested_reviewers",
+ "content": [{"user_uuid": str(owner.uuid), "github_login": login}],
+ },
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ assert [item["is_default_owner"] for item in self._latest_reviewers(report)] == [False]
+
+ @parameterized.expand(
+ [
+ ("by_uuid", False),
+ # A caller can name the same member by login alone, as the merge itself resolves it.
+ ("by_login", True),
+ ]
+ )
+ def test_posting_reviewers_keeps_the_stored_default_owner_flag(self, _name: str, by_login: bool):
+ report = self._create_report()
+ owner = self._create_org_member("[email protected]", github_login="owner-login")
+ self._create_artefact(report, content=[{"user_uuid": str(owner.uuid), "is_default_owner": True}])
+ entry = {"github_login": "owner-login"} if by_login else {"user_uuid": str(owner.uuid)}
+
+ response = self.client.post(
+ self._list_url(str(report.id)),
+ {"artefact_type": "suggested_reviewers", "content": [entry]},
+ format="json",
+ )
+
+ assert response.status_code == status.HTTP_201_CREATED, response.json()
+ assert [item["is_default_owner"] for item in self._latest_reviewers(report)] == [True]
+
def test_leave_reviewers_keeps_an_entry_whose_login_was_reassigned(self):
_attach_github_login(self.user, "CallerCase")
teammate = self._create_org_member("[email protected]", github_login=None)
diff --git a/products/signals/backend/views.py b/products/signals/backend/views.py
index 88694815598c..6391bbb3189c 100644
--- a/products/signals/backend/views.py
+++ b/products/signals/backend/views.py
@@ -193,6 +193,7 @@ from products.signals.backend.report_content_gates import (
from products.signals.backend.report_generation.research import ActionabilityChoice
from products.signals.backend.report_generation.resolve_reviewers import (
ReviewerPayloadIndex,
+ _normalized_reviewer_user_uuid,
bounded_reviewer_reason,
get_org_member_github_logins_by_user_uuid,
normalized_github_logins_from_suggested_reviewer_artefacts,
@@ -5667,6 +5668,7 @@ def append_suggested_reviewers(
"reason": effective_reason or None,
"source_skill": prior_source_skill if isinstance(prior_source_skill, str) else None,
"is_skill_owner": bool(prior.get("is_skill_owner")) if prior else False,
+ "is_default_owner": bool(prior.get("is_default_owner")) if prior else False,
}
)
@@ -5715,6 +5717,8 @@ def append_suggested_reviewers(
if (requested.get(user_uuid=prior.get("user_uuid"), github_login=prior.get("github_login")) is not None)
== (edit.action == "remove")
]
+ default_owner_labels = _default_owner_labels(prior_payloads)
+ evidence_removals = [label for label in chosen_removals if label not in default_owner_labels]
correction: ReviewerCorrection | None = None
if attribution.kind == "user" and (removed_payloads or added_entries):
# Read impersonation once: the activity row records it, and a support-staff edit made
@@ -5726,7 +5730,7 @@ def append_suggested_reviewers(
team=team,
user=cast(User, request.user),
scoped_team_ids=scoped_team_id_tuple,
- note=removal_note if chosen_removals else None,
+ note=removal_note if evidence_removals else None,
)
log_activity(
organization_id=None,
@@ -5746,7 +5750,8 @@ def append_suggested_reviewers(
before=prior_identities,
after=new_identities,
),
- *_removal_reason_changes(removal_reason if chosen_removals else None, chosen_removals),
+ *_removal_reason_changes(removal_reason if evidence_removals else None, evidence_removals),
+ *_default_owner_changes(default_owner_labels),
],
),
)
@@ -5787,10 +5792,10 @@ def append_suggested_reviewers(
correction = ReviewerCorrection(
report_id=str(report_id),
added_reviewers=tuple(_reviewer_identity_label(entry) for entry in added_entries),
- removed_reviewers=tuple(chosen_removals),
+ removed_reviewers=tuple(evidence_removals),
actor_user_id=user_id,
scoped_team_ids=scoped_team_id_tuple,
- removal_reason=removal_reason if chosen_removals else None,
+ removal_reason=removal_reason if evidence_removals else None,
removal_note=shared_note,
)
@@ -5841,9 +5846,68 @@ def _stored_reviewer_entry(entry: dict) -> dict:
"reason": bounded_reviewer_reason(entry.get("reason")) or None,
"source_skill": entry.get("source_skill"),
"is_skill_owner": bool(entry.get("is_skill_owner")),
+ "is_default_owner": bool(entry.get("is_default_owner")),
}
+def _with_carried_default_owner(
+ content: SuggestedReviewers, prior: Sequence[SuggestedReviewerEntry], *, team_id: int
+) -> SuggestedReviewers:
+ """`is_default_owner` taken from the stored entry rather than from the request.
+
+ Only the fallback writes the flag, and it tells the removal paths that the entry is routing and
+ not an ownership verdict. A caller that could set it on someone else's entry could suppress the
+ correction their removal should record, so the write API carries the stored value the same way
+ the add/remove endpoints do.
+
+ Both identity fields are resolved to the org member they name first, the way the reviewer merge
+ resolves them a step later. A login this organization cannot place, or one that places a
+ different member, carries nothing: this endpoint stores the pair as given on an unprotected
+ report, and a later edit matching that login would hand the mark to whoever ends up behind it.
+ """
+ stored_owners = {
+ normalized
+ for entry in prior
+ if entry.is_default_owner and (normalized := _normalized_reviewer_user_uuid(entry.user_uuid))
+ }
+ logins_to_resolve = {entry.github_login for entry in content.root if entry.github_login} if stored_owners else set()
+ login_to_org_user = resolve_org_github_login_to_users(team_id, logins_to_resolve) if logins_to_resolve else {}
+
+ def carried(entry: SuggestedReviewerEntry) -> bool:
+ user_uuid = _normalized_reviewer_user_uuid(entry.user_uuid)
+ if not entry.github_login:
+ return user_uuid in stored_owners
+ member = login_to_org_user.get(entry.github_login.strip().lower())
+ if member is None or (user_uuid and user_uuid != str(member.uuid)):
+ return False
+ return str(member.uuid) in stored_owners
+
+ return SuggestedReviewers(
+ root=[entry.model_copy(update={"is_default_owner": carried(entry)}) for entry in content.root]
+ )
+
+
+def _default_owner_labels(payloads: list[dict]) -> list[str]:
+ return [
+ label
+ for payload in payloads
+ if isinstance(payload, dict)
+ and payload.get("is_default_owner")
+ and (label := _reviewer_identity_label(payload))
+ ]
+
+
+def _default_owner_changes(labels: list[str]) -> list[Change]:
+ """The activity-row change that marks which reviewers were only the default owner.
+
+ The reviewer-corrections profile drops these labels, so a person who takes the default owner off
+ a report does not read to the scouts as an ownership verdict.
+ """
+ if not labels:
+ return []
+ return [Change(type="SignalReport", action="changed", field="default_owner_reviewers", after=labels)]
+
+
def _removal_reason_changes(reason: str | None, reviewers: list[str]) -> list[Change]:
"""The activity-row changes that record why the editor removed these reviewers.
@@ -5955,6 +6019,8 @@ def remove_suggested_reviewer(
if len(kept) == len(prior):
return False
new_content = SuggestedReviewers.model_validate_json(new_artefact.content).model_dump(mode="json")
+ default_owner_labels = _default_owner_labels(prior)
+ removed_default_owner = any(entry.get("is_default_owner") for entry in prior if entry not in kept)
log_activity(
organization_id=None,
@@ -5974,13 +6040,17 @@ def remove_suggested_reviewer(
before=list(dict.fromkeys(_reviewer_identity_label(entry) for entry in prior)),
after=list(dict.fromkeys(_reviewer_identity_label(entry) for entry in new_content)),
),
- *_removal_reason_changes(removal_reason, [github_login or str(user.uuid)]),
+ *_removal_reason_changes(
+ None if removed_default_owner else removal_reason,
+ [] if removed_default_owner else [github_login or str(user.uuid)],
+ ),
+ *_default_owner_changes(default_owner_labels),
],
),
)
correction = (
None
- if was_impersonated
+ if was_impersonated or removed_default_owner
else ReviewerCorrection(
report_id=str(report_id),
added_reviewers=(),
@@ -6519,9 +6589,11 @@ class SignalReportArtefactViewSet(
reviewer_outcome = request.validated_data.get("reviewer_outcome", "selected")
with transaction.atomic():
SignalReport.objects.select_for_update().get(team_id=self.team.id, id=report_id)
- previous = ReviewerRules.read_for_report(
- team_id=self.team.id, report_id=report_id
- ).state.reviewers_id
+ snapshot = ReviewerRules.read_for_report(team_id=self.team.id, report_id=report_id)
+ previous = snapshot.state.reviewers_id
+ parsed_content = _with_carried_default_owner(
+ parsed_content, snapshot.reviewers, team_id=self.team.id
+ )
artefact = SignalReportArtefact.append_status(
team_id=self.team.id,
report_id=report_id,
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 449e1cf7cd3c..bf59f1b94e60 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -3404,6 +3404,8 @@ export interface SuggestedReviewerEntryReadApi {
reason: string | null
/** True when the scout owner guardrail added the entry rather than commit authorship. */
is_skill_owner: boolean
+ /** True when no evidence selected anyone and the report fell back to the project's default owner. The entry routes the report, but it is not ownership evidence. */
+ is_default_owner: boolean
/**
* Scout skill whose run wrote the entry. Null when no scout did.
* @nullable
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 1d7cc8765685..ea6b41067920 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -111775,6 +111775,8 @@ export namespace Schemas {
reason: string | null;
/** True when the scout owner guardrail added the entry rather than commit authorship. */
is_skill_owner: boolean;
+ /** True when no evidence selected anyone and the report fell back to the project's default owner. The entry routes the report, but it is not ownership evidence. */
+ is_default_owner: boolean;
/**
* Scout skill whose run wrote the entry. Null when no scout did.
* @nullable