: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): select one pr owner from report recipients (#120694)
Dylan Martine999aa968161
diff --git a/docs/internal/signals-pr-lifecycle.md b/docs/internal/signals-pr-lifecycle.mdindex f0e62495f970..264661381bf5 100644--- a/docs/internal/signals-pr-lifecycle.md+++ b/docs/internal/signals-pr-lifecycle.md@@ -167,16 +167,27 @@ This is prompt guidance, not an enforced access control, and it does not validat## Reviewer notifications-Research suggests reviewers from relevant commit authors and recent code activity. It also checks the finding's relevant paths against `owners.yaml` and the connected repository's CODEOWNERS. When they disagree, the `owners.yaml` owner comes first and a routable CODEOWNERS owner follows. A human edit to the report's reviewer list stays in place on later research runs. Missing ownership files or paths leave the existing author-based suggestions unchanged. Scout-authored reports use their own reviewer selection guidance.--The `signals-research-reviewer-selection` flag lets research choose reviewers and preserve its selected order.+With `signals-research-reviewer-selection` enabled, the research agent chooses report recipients in relevance order.+Ownership files, CODEOWNERS, code history, report findings, and human corrections supply evidence for that choice.+They cannot replace it with an ownership-first or commit-count selection.Research first reads recent human corrections from the project profile, which is available on every plan.It also reads relevant notes, older activity logs when available, and `reviewer:` scratchpad entries.Corrections apply only to the affected area. Research does not save its own choices as reviewer memory.The existing limit remains three reviewers.-The pipeline skips a reviewer row when ordered identities and authorization evidence are unchanged.-A different explanation alone does not add a row. Human edits retain precedence.+A missing, malformed, or entirely ineligible decision retains valid existing recipients and records a failed selection.+An explicit empty decision clears automatic recipients while preserving pins and confirmed lists.+The artefact write path rechecks project access before saving; if all proposed candidates have become ineligible, it retains valid existing recipients.+Report recipients need project access, but do not need GitHub accounts.+Scout and custom-agent reports also preserve the agent's selected order through the existing artefact path.+The saved list drives both the Inbox index and notification recipients; no later ownership selector reranks it.++With research selection disabled, research uses the legacy ownership-and-commit selector.+That rollback does not release corrections or bypass the artefact rules.+The legacy resolver also remains an independent task-runner permission check; selecting a report recipient does not authorize a task.++The pipeline skips a reviewer row when the accepted content is unchanged.+Human corrections retain precedence.A real selection change after the first Slack notification can still leave that notification out of date.Automatic reviewer changes do not send additional Slack notifications.@@ -242,7 +253,7 @@ The same artefact table stores `reviewer_corrections`, with pins, exclusions, coCorrections and membership are saved atomically with the existing actor and process attribution.The first protected reviewer write recovers old corrections from reviewer deltas matched to activity records, under the report lock.It saves the result once. Reads use saved corrections; before recovery, they mark reports with old human edits as needing review.-During rollout, automatic task start and PR owner selection wait for that recovery.+During rollout, automatic task start and PR assignment wait for that recovery.A human-authored snapshot alone does not prove approval of the complete list.Incomplete history stops automatic changes until a person confirms the current list through the API.@@ -272,6 +283,73 @@ Generic artefact PATCH and DELETE cannot change reviewer history, and clients caIf stored reviewer data is invalid, a person can replace the list with matching state, even with the writer flag off.The repair keeps the old rows and existing corrections. It does not confirm the list or clear the history-review marker.+### Shared report and PR assignment++With `signals-research-reviewer-selection` and `signals-assignment-writer` enabled, the saved report assignment supplies candidates for one PR owner.+`signals-assignment-side-effects` must allow delivery. The legacy DRI flag does not change this rule.++```mermaid+flowchart LR+ A{{Research or scout reads feedback}} --> B[Choose assignees]+ B --> C[Check access and human corrections]+ C --> D[(suggested_reviewers)]+ D --> E[Inbox report]+ D --> F[Check personal settings, accounts, and GitHub access]+ F --> G[First eligible recipient becomes PR owner]+ E --> H[Human edit and reason]+ H --> I[(Existing corrections and notes)]+ I --> A+ classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;+ classDef phRed fill:#f54e00,stroke:#f54e00,color:#fff;+ classDef phYellow fill:#f9bd2b,stroke:#f9bd2b,color:#000;+ classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;+ class A phBlue;+ class G phRed;+ class E,H phYellow;+ class B,C,D,F,I phGray;+```++The worker maps selected project members to their current personal GitHub accounts and checks repository assignability.+Each attempt checks at most ten eligible candidates, in the saved order.+It assigns the first eligible person whose **Assign me on GitHub** setting is on, then stops.+A missing settings row, a missing GitHub account, or lost access skips that person. The worker can choose the next saved recipient, but nobody outside the report.+If no saved recipient qualifies, the PR remains unassigned.+The personal setting does not remove anyone from the report. Claims and owning teams do not change the selected list or its order.+The report remains the source of the assignment. Logs record unavailable accounts, permission failures, and GitHub delivery failures.++The worker rechecks the report state, personal settings, account links, project access, GitHub state, and delivery controls before assigning.+Queued work and retries use the current personal setting.+Existing GitHub assignees and manual unassignment remain authoritative. Incomplete human-edit history blocks automatic assignment.+The legacy DRI path also respects report exclusions and rechecks human choices before assignment.+Claimants and suggested reviewers must be active project members to receive assignments or review requests.+This first version selects an owner only when the PR is unassigned. Synchronizing later report edits to an already assigned PR remains follow-up work.+That work must preserve human GitHub changes and use the same ordered report candidates.+GitHub's final read and write are not atomic, so a small external race remains.++There is no separate PR model call, evidence collector, decision cache, or assignment artefact.+The existing task permission checks remain separate. Report assignment does not authorize an agent to run under that person's account.+GitHub review requests still use the current report list, subject to the existing request policy.++The first loop trial uses one correction with a reason, a new related report, and an unrelated control case.+Inspect the existing research trace and selection reason, then check the saved report list and PR assignment.+Confirm that feedback changes the relevant choice and leaves the unrelated case unchanged.+Confirm that selected people with the GitHub setting off remain on the report but receive no automatic GitHub assignment.+The live trial remains pending; automated delivery tests do not establish research selection quality.++### Identity and organization changes++`resolve_reviewers.py` maps linked PostHog and GitHub identities in both directions. The existing `scout-members-list` tool+exposes project members and known GitHub accounts to agents. Personal GitHub integrations and GitHub OAuth provide identity links;+some existing lookup paths also use the GitHub App installer identity. Report recipients can use PostHog user UUIDs without GitHub accounts.++The PR worker uses current personal GitHub integrations and OAuth links. It does not use the team installer identity as a personal link or discover new accounts.+Verified discovery for unlinked accounts remains future work. It should extend the existing member tools, record the source and age of each link,+and reject uncertain or conflicting matches. Similar names alone do not prove an identity.++Access loss removes an ineligible report recipient on the next protected reviewer write. A team move with access retained changes selection evidence;+it does not cancel a human pin. No general process currently finds and reassesses all old reports after organization changes.+Such a process remains future work and must use the same correction rules. Existing manual GitHub choices remain authoritative.+### Rollout and rollback| Control | Allows |@@ -280,6 +358,9 @@ The repair keeps the old rows and existing corrections. It does not confirm the| `signals-assignment-side-effects` | Existing Slack delivery, automatic task start, GitHub assignment, review requests, and ready-state changes for enrolled reports. |Both flags support organization targeting and require explicit enablement.+The existing `signals-research-reviewer-selection` flag controls research selection and, with the writer enabled, shared report and PR assignment.+PR delivery also requires the side-effect flag, including before a report enters the writer.+Disabling research selection restores the legacy PR policies. Saved report corrections remain protected.They use local evaluation, so a report lock never waits for the flag service.Missing flag definitions keep the new behavior disabled.Enable the writer with side effects disabled to test real assignment changes without external delivery or task start.diff --git a/products/signals/backend/report_generation/AGENTS.md b/products/signals/backend/report_generation/AGENTS.mdindex 1e1d83bb0e97..e92869ebffd2 100644--- a/products/signals/backend/report_generation/AGENTS.md+++ b/products/signals/backend/report_generation/AGENTS.md@@ -31,10 +31,10 @@ It is exercised locally via management commands, and it is also used by the prodThe repository used for research is tracked separately via the `repo_selection` artefact.- `ownership_reviewers.py`- Matches a finding's relevant code paths against the repository's `owners.yaml` and CODEOWNERS on the connected GitHub repository. When both name different project members, it suggests the `owners.yaml` owner first and the CODEOWNERS owner second. A human reviewer edit prevents subsequent research runs from replacing the selection.+ Matches a finding's relevant code paths against the repository's `owners.yaml` and CODEOWNERS on the connected GitHub repository. When both name different project members, it suggests the `owners.yaml` owner first and the CODEOWNERS owner second. The artefact write path preserves human pins, exclusions, and confirmed lists during later research.- `research_reviewers.py`- Validates research reviewer decisions against active project members. The `signals-research-reviewer-selection` flag enables this step. Research reads ownership evidence, recent profile corrections, notes, and relevant `reviewer:` scratchpad entries. It returns member UUIDs with reasons. Research picks route reports. Autostart independently confirms the same member through the ownership and commit resolver before applying personal thresholds. Confirmation uses current project access and a linked GitHub identity. Lookup failures retain the existing team fallback and no-runner behavior. An empty decision clears automatic suggestions and records its reason. A decision with no valid members uses the commit resolver. Lookup failures leave report findings intact. Human edits take precedence. Unchanged ordered identities and authorization evidence do not add reviewer rows. Telemetry records the resolution outcome and whether notification already occurred.+ Validates research reviewer decisions against active project members. The `signals-research-reviewer-selection` flag enables this step. Research reads ownership evidence, recent profile corrections, notes, and relevant `reviewer:` scratchpad entries. It returns member UUIDs with reasons. Research picks are the report recipients and the ordered candidates for one PR owner. The PR worker chooses the first eligible person with a linked GitHub account and assignment enabled; it never adds a candidate outside the report. Autostart independently confirms the same member through the ownership and commit resolver before applying personal thresholds. Confirmation uses current project access and a linked GitHub identity. Lookup failures retain the existing team fallback and no-runner behavior. An empty decision clears automatic suggestions and records its reason. Missing, malformed, or entirely rejected decisions retain valid existing recipients and record failure; they never invoke the legacy selector while selection is enabled. The artefact write path rechecks access and corrections before saving. Lookup failures leave report findings intact. Human corrections take precedence. Unchanged accepted content does not add reviewer rows. Telemetry records the resolution outcome and whether notification already occurred.- `team_membership.py`Resolves which teams a person belongs to, so a report can be routed at a team slug rather than at a name. Provider-neutral by design (a membership is a slug, a display name, and whether the person maintains the team); the synced GitHub org roster read through the engineering_analytics facade is the only source behind it today.diff --git a/products/signals/backend/reviewer_pr_assignment.py b/products/signals/backend/reviewer_pr_assignment.pyindex de376ef2a02c..28e0bfc5dcaf 100644--- a/products/signals/backend/reviewer_pr_assignment.py+++ b/products/signals/backend/reviewer_pr_assignment.py@@ -1,28 +1,18 @@-"""Assign ownership and request reviews on a report's implementation PR.+"""Apply report assignments and request reviews on implementation pull requests.-Somebody whose workflow is GitHub's "Assigned to me" never sees an inbox PR otherwise, because-every self-driving pull request opens with no assignee.+With research selection and the assignment writer enabled, the first eligible saved report+reviewer becomes the PR's single owner. Personal preferences and GitHub access checks can+reject a person but never select someone outside the report.+Existing GitHub assignments and manual unassignment remain authoritative.-Under the `signals-pr-dri-assignee` flag, a pull request with no assignee gets exactly one-directly responsible individual (DRI): the person who chose the work, else somebody who asked to-be assigned, else a member of the team that owns the changed code (see `pr_owning_team.py`), else-the most relevant suggested reviewer. A pull request that everybody could pick up is a pull request-nobody picks up, and a wrong owner costs one reassignment.--Without the flag the older rule stands: every suggested reviewer who opted in through-`SignalUserAutonomyConfig.github_assign_on_pull_request` is added, and there is no DRI.--Suggested reviewers with a connected GitHub account receive review requests. The pull request-author, assignees, and existing requested reviewers are left alone.--Best effort throughout: a GitHub failure must never break the claim, sync, or reviewer edit that-triggered it.+Other projects retain the legacy DRI and opt-in policies. Task execution permission is+separate from report and PR assignment. GitHub failures must not break report writes."""from __future__ import annotationsimport json-from typing import Any+from typing import TYPE_CHECKING, Anyfrom uuid import UUIDfrom django.conf import settings@@ -37,8 +27,16 @@ from posthog.models.github_integration_base import PullRequestReffrom posthog.models.integration import GitHubIntegrationfrom posthog.ph_client import feature_enabled_or_false-from products.signals.backend.artefact_schemas import TASK_RUN_TYPE_IMPLEMENTATION, TaskRunArtefact-from products.signals.backend.assignment_flags import assignment_side_effects_allowed+from products.signals.backend.artefact_schemas import (+ TASK_RUN_TYPE_IMPLEMENTATION,+ SuggestedReviewerEntry,+ TaskRunArtefact,+)+from products.signals.backend.assignment_flags import (+ assignment_side_effects_allowed,+ assignment_side_effects_enabled,+ assignment_writer_enabled,+)from products.signals.backend.models import (SignalActorKind,SignalReport,@@ -48,12 +46,18 @@ from products.signals.backend.models import ()from products.signals.backend.pr_owning_team import OwningTeam, OwningTeamResolverfrom products.signals.backend.report_claims import get_active_claim, responsible_user+from products.signals.backend.report_content_gates import team_research_reviewer_selection_enabledfrom products.signals.backend.report_generation.resolve_reviewers import (+ _github_identity_prefetches,_normalized_reviewer_user_uuid,get_org_member_github_logins_by_user_uuid,normalized_github_logins_from_reviewer_payloads,resolve_org_github_login_to_users,)+from products.signals.backend.reviewer_rules import ReviewerRules, contains_reviewer++if TYPE_CHECKING:+ from products.signals.backend.reviewer_rules import ReviewerSnapshotlogger = structlog.get_logger(__name__)@@ -62,6 +66,7 @@ PR_DRI_FEATURE_FLAG = "signals-pr-dri-assignee"# Each DRI candidate costs one GitHub read, so this stops a large team or a long scout reviewer# list from turning one pull request into ten reads.MAX_DRI_CHECKS = 4+MAX_REPORT_ASSIGNEE_CHECKS = 10# Assign only while the pull request can still be reviewed. UNKNOWN is included because a PR whose# state could not be read is far more often open than closed, and the task re-reads the real state@@ -216,6 +221,8 @@ def human_claimant_login(*, team_id: int, report_id: str) -> str | None:if user is None:return Noneuser_uuid = str(user.uuid)+ if not (Team.objects.get(id=team_id).all_users_with_access(user_uuids=[user_uuid]).filter(is_active=True).exists()):+ return Nonereturn get_org_member_github_logins_by_user_uuid(team_id, [user_uuid]).get(user_uuid)@@ -234,14 +241,25 @@ def ranked_reviewer_logins(*, team_id: int, report_id: str) -> list[str]:team_id,normalized_github_logins_from_reviewer_payloads(row for row, uuid in rows_with_uuid if uuid is None),)+ user_uuids = [uuid for _, uuid in rows_with_uuid if uuid] + [str(user.uuid) for user in member_logins.values()]+ if not user_uuids:+ return []+ eligible_uuids = {+ str(uuid)+ for uuid in Team.objects.get(id=team_id)+ .all_users_with_access(user_uuids=user_uuids)+ .filter(is_active=True)+ .values_list("uuid", flat=True)+ }candidates: list[str | None] = []for row, uuid in rows_with_uuid:if uuid is not None:- candidates.append(login_by_uuid.get(uuid))+ candidates.append(login_by_uuid.get(uuid) if uuid in eligible_uuids else None)else:login = str(row.get("github_login") or "").strip().lower()- candidates.append(login if login in member_logins else None)+ member = member_logins.get(login)+ candidates.append(login if member is not None and str(member.uuid) in eligible_uuids else None)return list(dict.fromkeys(login for login in candidates if login))@@ -458,8 +476,95 @@ def dri_candidate_logins(return list(dict.fromkeys(login for login in candidates if login))+def _report_assignee_logins(team: Team, snapshot: ReviewerSnapshot, *, require_opt_in: bool = True) -> list[str]:+ linked = resolve_org_github_login_to_users(+ team.id, [entry.github_login for entry in snapshot.reviewers if entry.github_login and not entry.user_uuid]+ )+ identities = [+ entry.model_copy(update={"user_uuid": str(member.uuid)})+ if not entry.user_uuid and entry.github_login and (member := linked.get(entry.github_login.lower()))+ else entry+ for entry in snapshot.reviewers+ ]+ uuids = [entry.user_uuid for entry in identities if entry.user_uuid]+ if not uuids:+ return []+ members = (+ team.all_users_with_access(user_uuids=uuids)+ .filter(is_active=True)+ .prefetch_related(*_github_identity_prefetches())+ )+ if require_opt_in:+ members = members.filter(signal_autonomy_config__github_assign_on_pull_request=True)+ logins = {+ str(member.uuid): login.lower()+ for member in members+ if (login := member.get_github_login(include_team_fallback=False))+ }+ return list(+ dict.fromkeys(+ login+ for entry in identities+ if entry.user_uuid+ and (login := logins.get(entry.user_uuid))+ and not contains_reviewer(snapshot.corrections.excluded, entry)+ )+ )+++def _assign_report_reviewers(+ github: GitHubIntegration, *, team_id: int, report_id: str, parsed: PullRequestRef, pr: dict[str, Any]+) -> list[str]:+ if pr.get("assignees") or _was_unassigned_by_hand(github, team_id=team_id, report_id=report_id, parsed=parsed):+ return []++ log = logger.bind(team_id=team_id, report_id=report_id)+ try:+ team = Team.objects.get(id=team_id)+ snapshot = ReviewerRules.read_for_report(team_id=team_id, report_id=report_id)+ if snapshot.corrections.needs_review:+ return []+ candidates = _report_assignee_logins(team, snapshot)+ if len(candidates) < len(snapshot.reviewers):+ log.info(+ "signals.reviewer_pr_assignment.unavailable_accounts",+ selected=len(snapshot.reviewers),+ linked=len(candidates),+ )+ assignable: list[str] = []+ for login in candidates[:MAX_REPORT_ASSIGNEE_CHECKS]:+ result = github.is_assignable(parsed.repository, login)+ if not result.get("success"):+ log.warning("signals.reviewer_pr_assignment.assignable_check_failed")+ return []+ if result.get("assignable"):+ assignable.append(login)+ break+ if not assignable:+ return []++ current_pr = _assignable_pull_request(github, team_id=team_id, report_id=report_id, parsed=parsed)+ if current_pr is None or current_pr.get("assignees"):+ return []+ if _was_unassigned_by_hand(github, team_id=team_id, report_id=report_id, parsed=parsed):+ return []+ current = ReviewerRules.read_for_report(team_id=team_id, report_id=report_id)+ if current.state != snapshot.state or _report_assignee_logins(team, current) != candidates:+ return []+ if not (+ assignment_writer_enabled(team_id)+ and team_research_reviewer_selection_enabled(team_id)+ and assignment_side_effects_enabled(team_id)+ ):+ return []+ return _add_assignees(github, team_id=team_id, report_id=report_id, parsed=parsed, logins=assignable) or []+ except Exception:+ log.exception("signals.reviewer_pr_assignment.report_assignment_failed")+ return []++def assign_reviewers_to_pull_request(*, team_id: int, report_id: str, pr_url: str) -> list[str]:- """Request reviews and assign one DRI under the flag, else every opted-in reviewer.+ """Apply the shared report assignment, or the legacy DRI/opt-in policy, and request reviews.Returns the assignees GitHub accepted. Never unassigns: the add-assignees endpoint is additive,so a person somebody assigned by hand stays on the pull request. Returns an empty list when@@ -471,7 +576,10 @@ def assign_reviewers_to_pull_request(*, team_id: int, report_id: str, pr_url: stif not SignalReport.objects.filter(id=report_id, team_id=team_id).exists():return []- logins = opted_in_assignee_logins(team_id=team_id, report_id=report_id)+ shared_assignment = assignment_writer_enabled(team_id) and team_research_reviewer_selection_enabled(team_id)+ if shared_assignment and not assignment_side_effects_enabled(team_id):+ return []+ logins = [] if shared_assignment else opted_in_assignee_logins(team_id=team_id, report_id=report_id)reviewers = ranked_reviewer_logins(team_id=team_id, report_id=report_id)dri_enabled = _pr_dri_enabled(team_id)if not reviewers and not logins and not dri_enabled:@@ -489,7 +597,9 @@ def assign_reviewers_to_pull_request(*, team_id: int, report_id: str, pr_url: stif pr is None:return []- if dri_enabled:+ if shared_assignment:+ assigned = _assign_report_reviewers(github, team_id=team_id, report_id=report_id, parsed=parsed, pr=pr)+ elif dri_enabled:assigned = _assign_one_dri(github,team_id=team_id,@@ -506,6 +616,27 @@ def assign_reviewers_to_pull_request(*, team_id: int, report_id: str, pr_url: stelse [])+ if shared_assignment:+ if not (+ assignment_writer_enabled(team_id)+ and team_research_reviewer_selection_enabled(team_id)+ and assignment_side_effects_enabled(team_id)+ ):+ return assigned+ try:+ snapshot = ReviewerRules.read_for_report(team_id=team_id, report_id=report_id)+ if snapshot.corrections.needs_review:+ return assigned+ reviewers = _report_assignee_logins(Team.objects.get(id=team_id), snapshot, require_opt_in=False)+ except Exception:+ logger.exception(+ "signals.reviewer_pr_assignment.reviewers_lookup_failed", team_id=team_id, report_id=report_id+ )+ return assigned+ current_pr = _assignable_pull_request(github, team_id=team_id, report_id=report_id, parsed=parsed)+ if current_pr is None:+ return assigned+ pr = current_pr_request_reviews(github,team_id=team_id,@@ -537,13 +668,40 @@ def _assign_one_dri(if _was_unassigned_by_hand(github, team_id=team_id, report_id=report_id, parsed=parsed):return []+ snapshot = ReviewerRules.read_for_report(team_id=team_id, report_id=report_id)+ if snapshot.corrections.needs_review:+ return []+ claimant = human_claimant_login(team_id=team_id, report_id=report_id)candidates = dri_candidate_logins(- claimant=human_claimant_login(team_id=team_id, report_id=report_id),+ claimant=claimant,opted_in=opted_in,team=_owning_team(github, team_id=team_id, report_id=report_id, parsed=parsed),reviewers=reviewers,)+ members = resolve_org_github_login_to_users(team_id, candidates)+ candidates = [+ login+ for login in candidates+ if not contains_reviewer(+ snapshot.corrections.excluded,+ SuggestedReviewerEntry(+ github_login=login, user_uuid=str(members[login].uuid) if login in members else None+ ),+ )+ ]dri = _first_assignable_login(github, team_id=team_id, report_id=report_id, parsed=parsed, candidates=candidates)if dri is None:return []+ current_pr = _assignable_pull_request(github, team_id=team_id, report_id=report_id, parsed=parsed)+ if current_pr is None or current_pr.get("assignees"):+ return []+ if _was_unassigned_by_hand(github, team_id=team_id, report_id=report_id, parsed=parsed):+ return []+ current = ReviewerRules.read_for_report(team_id=team_id, report_id=report_id)+ if (+ current.state != snapshot.state+ or human_claimant_login(team_id=team_id, report_id=report_id) != claimant+ or ranked_reviewer_logins(team_id=team_id, report_id=report_id) != reviewers+ ):+ return []return _add_assignees(github, team_id=team_id, report_id=report_id, parsed=parsed, logins=[dri]) or []diff --git a/products/signals/backend/temporal/agentic/report.py b/products/signals/backend/temporal/agentic/report.pyindex 08bdafebfc52..c4fbd5560cf6 100644--- a/products/signals/backend/temporal/agentic/report.py+++ b/products/signals/backend/temporal/agentic/report.py@@ -782,6 +782,7 @@ async def _persist_agentic_report_artefacts(repo_selection_as_of: datetime | None = None,priority_judgment_id: UUID | None = None,reviewer_proposal: ReviewerProposal | None = None,+ reviewer_selection_enabled: bool = False,) -> None:reviewer_resolution = Nonereviewers_content: list[ReviewerContent] = []@@ -804,7 +805,9 @@ async def _persist_agentic_report_artefacts(research_outcome = "research_selected"else:research_outcome = "research_candidates_rejected"- if decision is None or research_outcome == "research_candidates_rejected":+ elif reviewer_selection_enabled:+ research_outcome = "research_decision_missing"+ if not reviewer_selection_enabled and (decision is None or research_outcome == "research_candidates_rejected"):try:reviewer_resolution = await database_sync_to_async(_build_reviewers_content, thread_sensitive=False)(team_id=team_id,@@ -824,6 +827,19 @@ async def _persist_agentic_report_artefacts():research_outcome = "research_lookup_failed"+ failure_reason = {+ "research_decision_missing": "Research did not return a valid reviewer decision",+ "research_candidates_rejected": "No selected reviewer is an eligible project member",+ "research_lookup_failed": "Reviewer lookup unavailable",+ }.get(research_outcome or "")+ if failure_reason:+ logger.warning(+ "signals.assignment.research_selection_failed",+ team_id=team_id,+ report_id=report_id,+ outcome=research_outcome,+ )+# Persist only what's new this run; values the agent confirmed unchanged keep their latest# persisted row. An explicit reviewer decision can change even when the findings do not.#@@ -898,7 +914,7 @@ async def _persist_agentic_report_artefacts()(team_id):outcome = ("lookup_failed"- if research_outcome == "research_lookup_failed"+ if failure_reason and not reviewers_contentelse "selected"if reviewers_contentelse "no_suitable_owner"@@ -906,7 +922,7 @@ async def _persist_agentic_report_artefacts(reviewer_proposal = reviewer_proposal.model_copy(update={"outcome": outcome,- "retry_reason": "Reviewer lookup unavailable" if outcome == "lookup_failed" else None,+ "retry_reason": failure_reason if outcome == "lookup_failed" else None,})if not any(isinstance(draft.content, SuggestedReviewers) for draft in artefacts):@@ -1213,6 +1229,7 @@ async def run_agentic_report_activity(input: RunAgenticReportInput) -> RunAgentirepo_selection_as_of=input.repo_selection_as_of,priority_judgment_id=priority_judgment_id,reviewer_proposal=reviewer_proposal,+ reviewer_selection_enabled=reviewer_selection_enabled,)actionability = result.effective_actionability()priority = result.effective_priority()diff --git a/products/signals/backend/test/test_custom_agent_log_artefacts.py b/products/signals/backend/test/test_custom_agent_log_artefacts.pyindex a24284d5b400..68f70f35c861 100644--- a/products/signals/backend/test/test_custom_agent_log_artefacts.py+++ b/products/signals/backend/test/test_custom_agent_log_artefacts.py@@ -7,6 +7,8 @@ from unittest.mock import AsyncMock, patchfrom asgiref.sync import async_to_syncfrom pydantic import BaseModel+from posthog.models import OrganizationMembership, User+import products.signals.backend.temporal.custom_agent # noqa: F401 (warms the base<->temporal import cycle so standalone collection works)from products.signals.backend.artefact_schemas import (ArtefactContentValidationError,@@ -21,7 +23,7 @@ from products.signals.backend.custom_agent.persistence import (create_custom_agent_ready_report,)from products.signals.backend.custom_agent.schemas import CustomAgentFinalReport-from products.signals.backend.models import SignalReportArtefact+from products.signals.backend.models import SignalReport, SignalReportArtefactfrom products.signals.backend.report_generation.research import (ActionabilityAssessment,ActionabilityChoice,@@ -29,6 +31,7 @@ from products.signals.backend.report_generation.research import (PriorityAssessment,)from products.signals.backend.report_generation.select_repo import RepoSelectionResult+from products.signals.backend.slack_inbox_notifications import resolve_suggested_reviewer_user_ids# Task ORM model needed to build cross-product fixtures; the tasks facade exposes DTOs only.from products.tasks.backend.models import Task@@ -70,6 +73,8 @@ class TestCustomAgentLogArtefacts(BaseTest):@patch("products.signals.backend.reviewer_rules.assignment_writer_enabled", return_value=True)def test_registered_reviewers_use_shared_writer(self, _writer) -> None:+ member = User.objects.create(email="[email protected]")+ OrganizationMembership.objects.create(user=member, organization=self.organization)result = create_custom_agent_ready_report(team_id=self.team.id,final_report=self._final_report(),@@ -78,6 +83,7 @@ class TestCustomAgentLogArtefacts(BaseTest):registered_artefacts=[SuggestedReviewers(root=[+ SuggestedReviewerEntry(user_uuid=str(member.uuid), reason="Maintains the affected feature."),SuggestedReviewerEntry(user_uuid=str(self.user.uuid)),SuggestedReviewerEntry(github_login="unlinked-example"),]@@ -87,7 +93,15 @@ class TestCustomAgentLogArtefacts(BaseTest):reviewers = SignalReportArtefact.latest_content(team_id=self.team.id, report_id=result.report_id, model=SuggestedReviewers)- assert reviewers is not None and [entry.user_uuid for entry in reviewers.root] == [str(self.user.uuid)]+ assert reviewers is not None and [entry.user_uuid for entry in reviewers.root] == [+ str(member.uuid),+ str(self.user.uuid),+ ]+ assert reviewers.root[0].reason == "Maintains the affected feature."+ assert resolve_suggested_reviewer_user_ids(SignalReport.objects.get(id=result.report_id)) == {+ member.id,+ self.user.id,+ }assert SignalReportArtefact.objects.filter(report_id=result.report_id, type="reviewer_corrections").count() == 1def test_register_artefact_queues_any_content_model(self):diff --git a/products/signals/backend/test/test_ownership_reviewers.py b/products/signals/backend/test/test_ownership_reviewers.pyindex 9685b827fd48..f5fe3023af24 100644--- a/products/signals/backend/test/test_ownership_reviewers.py+++ b/products/signals/backend/test/test_ownership_reviewers.py@@ -292,7 +292,8 @@ def test_pipeline_skips_unchanged_reviewer_selections(team, change):@pytest.mark.django_db@pytest.mark.parametrize("selection", ["member", "empty", "inactive", "outsider", "private_project", "missing"])-def test_research_decision_controls_persisted_reviewers(team, selection):[email protected]("selection_enabled", [False, True])+def test_research_decision_controls_persisted_reviewers(team, selection, selection_enabled):member = User.objects.create(email="[email protected]", is_active=selection != "inactive")if selection != "outsider":OrganizationMembership.objects.create(organization=team.organization, user=member)@@ -345,12 +346,20 @@ def test_research_decision_controls_persisted_reviewers(team, selection):),):async_to_sync(_persist_agentic_report_artefacts)(- team.id, str(report.id), result, RepoSelectionResult(repository=None, reason="No repository")+ team.id,+ str(report.id),+ result,+ RepoSelectionResult(repository=None, reason="No repository"),+ reviewer_selection_enabled=selection_enabled,)latest = SignalReportArtefact.objects.filter(report=report, type=SignalReportArtefact.ArtefactType.SUGGESTED_REVIEWERS).latest("created_at")reviewers = SuggestedReviewers.model_validate_json(latest.content).root+ if selection_enabled and selection not in {"member", "empty"}:+ assert [entry.github_login for entry in reviewers] == ["previous"]+ capture.assert_not_called()+ returnassert capture.call_args.kwargs["after_inbox_notification"] is Trueif selection == "member":assert len(reviewers) == 1diff --git a/products/signals/backend/test/test_report_pr_assignment.py b/products/signals/backend/test/test_report_pr_assignment.pynew file mode 100644index 000000000000..93db21756eb2--- /dev/null+++ b/products/signals/backend/test/test_report_pr_assignment.py@@ -0,0 +1,234 @@+import json++import pytest+from unittest.mock import MagicMock, patch++from posthog.constants import AvailableFeature+from posthog.models import Organization, Team+from posthog.models.organization import OrganizationMembership++from products.access_control.backend.models.access_control import AccessControl+from products.signals.backend.artefact_attribution import ArtefactAttribution+from products.signals.backend.artefact_schemas import ReviewerEdit, SuggestedReviewerEntry, SuggestedReviewers+from products.signals.backend.models import SignalReport, SignalReportArtefact, SignalUserAutonomyConfig+from products.signals.backend.report_assignments import claim_report+from products.signals.backend.reviewer_pr_assignment import assign_reviewers_to_pull_request+from products.signals.backend.test.test_reviewer_pr_assignment import (+ _NOT_UNASSIGNED,+ PR_URL,+ _make_report,+ _make_reviewer,+ _open_pr_github,+ dri_flag as dri_flag,+ org_and_team as org_and_team,+)+++class TestReportPRAssignment:+ @pytest.fixture(autouse=True)+ def shared_assignment(self):+ with (+ patch("products.signals.backend.reviewer_pr_assignment.assignment_writer_enabled", return_value=True),+ patch("products.signals.backend.reviewer_pr_assignment.assignment_side_effects_enabled", return_value=True),+ patch("products.signals.backend.reviewer_pr_assignment.assignment_side_effects_allowed", return_value=True),+ patch("products.signals.backend.reviewer_rules.assignment_writer_enabled", return_value=True),+ patch("products.signals.backend.reviewer_rules.assignment_side_effects_enabled", return_value=False),+ patch(+ "products.signals.backend.reviewer_pr_assignment.team_research_reviewer_selection_enabled",+ return_value=True,+ ),+ ):+ yield++ def github(self) -> MagicMock:+ github = _open_pr_github()+ github.was_ever_unassigned.return_value = _NOT_UNASSIGNED+ github.is_assignable.return_value = {"success": True, "assignable": True}+ github.add_pull_request_assignees.side_effect = lambda _repo, _number, logins: {+ "success": True,+ "assignees": logins,+ }+ return github++ def assign(self, report: SignalReport, github: MagicMock) -> list[str]:+ with patch(+ "products.signals.backend.reviewer_pr_assignment.GitHubIntegration.first_for_team_repository",+ return_value=github,+ ):+ return assign_reviewers_to_pull_request(team_id=report.team_id, report_id=str(report.id), pr_url=PR_URL)++ @pytest.mark.parametrize("dri_enabled", [False, True])+ @pytest.mark.parametrize("first_assignable", [False, True])+ def test_pr_selects_one_eligible_owner_without_changing_report_recipients(+ self, org_and_team: tuple[Organization, Team], dri_flag: MagicMock, dri_enabled: bool, first_assignable: bool+ ) -> None:+ org, team = org_and_team+ dri_flag.return_value = dri_enabled+ _make_reviewer(org, "selected-first", opted_in=True)+ _make_reviewer(org, "selected-second", opted_in=True)+ _make_reviewer(org, "opted-out", opted_in=False)+ claimant = _make_reviewer(org, "claimant", opted_in=True)+ report_logins = ["opted-out", "selected-second", "selected-first"]+ report = _make_report(team, report_logins)+ claim_report(+ report=report, actor=ArtefactAttribution.from_user(claimant.id), user=claimant, was_impersonated=False+ )+ github = self.github()+ github.is_assignable.side_effect = lambda _repo, login: {+ "success": True,+ "assignable": first_assignable or login != "selected-second",+ }+ expected_owner = "selected-second" if first_assignable else "selected-first"++ assert self.assign(report, github) == [expected_owner]+ github.add_pull_request_assignees.assert_called_once_with("PostHog/posthog", 123, [expected_owner])+ assert json.loads(report.artefacts.get(type="suggested_reviewers").content) == [+ {"github_login": login} for login in report_logins+ ]++ @pytest.mark.parametrize(+ "unavailable", ["account", "repository", "inactive", "membership", "project", "opted-out", "no-config"]+ )+ def test_unavailable_people_are_not_replaced(self, org_and_team, unavailable):+ org, team = org_and_team+ selected = _make_reviewer(org, "selected", opted_in=True)+ _make_reviewer(org, "outside-list", opted_in=True)+ report = _make_report(team, ["selected"])+ report.artefacts.filter(type="suggested_reviewers").update(+ content=json.dumps([{"user_uuid": str(selected.uuid), "github_login": "selected"}])+ )+ github = self.github()+ if unavailable == "account":+ selected.social_auth.all().delete()+ elif unavailable == "repository":+ github.is_assignable.return_value = {"success": True, "assignable": False}+ elif unavailable == "inactive":+ selected.is_active = False+ selected.save(update_fields=["is_active"])+ elif unavailable == "membership":+ OrganizationMembership.objects.filter(organization=org, user=selected).delete()+ elif unavailable == "opted-out":+ SignalUserAutonomyConfig.objects.filter(user=selected).update(github_assign_on_pull_request=False)+ elif unavailable == "no-config":+ SignalUserAutonomyConfig.objects.filter(user=selected).delete()+ else:+ org.available_product_features = [{"key": AvailableFeature.ACCESS_CONTROL, "name": "Access control"}]+ org.save(update_fields=["available_product_features"])+ AccessControl.objects.create(team=team, resource="project", resource_id=str(team.id), access_level="none")++ assert self.assign(report, github) == []+ github.add_pull_request_assignees.assert_not_called()+ assert json.loads(report.artefacts.get(type="suggested_reviewers").content)[0]["user_uuid"] == str(+ selected.uuid+ )++ @pytest.mark.parametrize("protection", ["assigned", "unassigned", "history-unavailable", "needs-review", "empty"])+ def test_existing_choices_and_empty_reports_are_left_alone(self, org_and_team, protection):+ org, team = org_and_team+ reviewer = _make_reviewer(org, "selected", opted_in=True)+ report = _make_report(team, [] if protection == "empty" else ["selected"])+ github = self.github()+ if protection == "assigned":+ github.get_pull_request.return_value["assignees"] = ["manual-owner"]+ elif protection == "unassigned":+ github.was_ever_unassigned.return_value = {"success": True, "unassigned": True}+ elif protection == "history-unavailable":+ github.was_ever_unassigned.return_value = {"success": False}+ elif protection == "needs-review":+ report.artefacts.filter(type="suggested_reviewers").update(actor_kind="user", created_by=reviewer)+ github.get_pull_request.return_value["assignees"] = ["selected"]++ assert self.assign(report, github) == []+ github.add_pull_request_assignees.assert_not_called()+ if protection == "needs-review":+ github.request_pull_request_reviews.assert_not_called()++ def test_saved_human_edits_are_used_by_the_pr(self, org_and_team):+ org, team = org_and_team+ removed = _make_reviewer(org, "removed", opted_in=True)+ editor = _make_reviewer(org, "retained", opted_in=True)+ added = _make_reviewer(org, "added", opted_in=True)+ report = _make_report(team, ["removed", "retained"])+ for action, user in [("remove", removed), ("add", added)]:+ SignalReportArtefact.append(+ team_id=team.id,+ report_id=str(report.id),+ content=SuggestedReviewers(root=[SuggestedReviewerEntry(user_uuid=str(user.uuid))]),+ attribution=ArtefactAttribution.from_user(editor.id),+ reviewer_edit=ReviewerEdit(action=action),+ )+ github = self.github()++ assert self.assign(report, github) == ["retained"]+ github.add_pull_request_assignees.assert_called_once_with("PostHog/posthog", 123, ["retained"])++ @pytest.mark.parametrize("assignable", [False, True])+ def test_large_reviewer_lists_have_bounded_github_checks(+ self, org_and_team: tuple[Organization, Team], assignable: bool+ ) -> None:+ org, team = org_and_team+ logins = [f"reviewer-{index}" for index in range(12)]+ for login in logins:+ _make_reviewer(org, login, opted_in=True)+ report = _make_report(team, logins)+ github = self.github()+ github.is_assignable.return_value = {"success": True, "assignable": assignable}++ assert self.assign(report, github) == (logins[:1] if assignable else [])+ assert github.is_assignable.call_count == (1 if assignable else 10)++ @pytest.mark.parametrize(+ "change", ["reviewers", "identity", "access", "preference", "github", "delivery", "writer", "selection"]+ )+ def test_a_change_during_permission_checks_stops_assignment(self, org_and_team, change):+ org, team = org_and_team+ selected = _make_reviewer(org, "selected", opted_in=True)+ report = _make_report(team, ["selected"])+ github = self.github()++ def check(_repo, _login):+ if change == "reviewers":+ SignalReportArtefact.objects.create(team=team, report=report, type="suggested_reviewers", content="[]")+ elif change == "identity":+ selected.social_auth.update(extra_data={"login": "renamed"})+ elif change == "access":+ OrganizationMembership.objects.filter(organization=org, user=selected).delete()+ elif change == "preference":+ SignalUserAutonomyConfig.objects.filter(user=selected).update(github_assign_on_pull_request=False)+ elif change == "github":+ github.get_pull_request.return_value["assignees"] = ["manual-owner"]+ return {"success": True, "assignable": True}++ github.is_assignable.side_effect = check+ flag = {+ "delivery": "assignment_side_effects_enabled",+ "writer": "assignment_writer_enabled",+ "selection": "team_research_reviewer_selection_enabled",+ }.get(change)+ if flag:+ with patch(f"products.signals.backend.reviewer_pr_assignment.{flag}", side_effect=[True, False, False]):+ assert self.assign(report, github) == []+ else:+ assert self.assign(report, github) == []+ github.add_pull_request_assignees.assert_not_called()++ @pytest.mark.parametrize("opted_in", [False, True])+ def test_retry_uses_current_github_assignment_preference(+ self, org_and_team: tuple[Organization, Team], opted_in: bool+ ) -> None:+ org, team = org_and_team+ selected = _make_reviewer(org, "selected", opted_in=True)+ report = _make_report(team, ["selected"])+ github = self.github()+ github.add_pull_request_assignees.side_effect = [+ {"success": False, "status_code": 503},+ {"success": True, "assignees": ["selected"]},+ ]++ assert self.assign(report, github) == []++ SignalUserAutonomyConfig.objects.filter(user=selected).update(github_assign_on_pull_request=opted_in)++ assert self.assign(report, github) == (["selected"] if opted_in else [])+ assert github.add_pull_request_assignees.call_count == (2 if opted_in else 1)diff --git a/products/signals/backend/test/test_reviewer_pr_assignment.py b/products/signals/backend/test/test_reviewer_pr_assignment.pyindex 5cef8f17cca1..10aa912d7475 100644--- a/products/signals/backend/test/test_reviewer_pr_assignment.py+++ b/products/signals/backend/test/test_reviewer_pr_assignment.py@@ -5,11 +5,14 @@ from unittest.mock import MagicMock, patchfrom social_django.models import UserSocialAuth+from posthog.constants import AvailableFeaturefrom posthog.models import Organization, Team, Userfrom posthog.models.organization import OrganizationMembershipfrom posthog.ownership.paths import UNOWNED_TEAM, PathOwnership+from products.access_control.backend.models.access_control import AccessControlfrom products.signals.backend.artefact_attribution import ArtefactAttribution+from products.signals.backend.artefact_schemas import ReviewerCorrections, SuggestedReviewerEntryfrom products.signals.backend.models import (SignalReport,SignalReportArtefact,@@ -660,6 +663,82 @@ class TestDirectlyResponsibleIndividual:assert self._assign(team, report, github) == []assert github.is_assignable.call_count == 1+ @pytest.mark.django_db+ @pytest.mark.parametrize("correction", ["needs-review", "excluded-uuid", "excluded-login"])+ def test_report_corrections_apply_to_owning_team_candidates(+ self, org_and_team: tuple[Organization, Team], ownership: MagicMock, correction: str+ ) -> None:+ org, team = org_and_team+ report, users = self._setup(org, team, ["alice"])+ ownership.return_value = PathOwnership(team_by_path={"posthog/api/a.py": "team-x"}, registry={}, resolved=True)+ github = self._github(existing_assignees=[], assignable=None)+ github.list_team_members.return_value = {"success": True, "logins": ["alice"]}+ rules = ReviewerCorrections(+ needs_review=correction == "needs-review",+ excluded=(SuggestedReviewerEntry(user_uuid=str(users["alice"].uuid)),)+ if correction == "excluded-uuid"+ else (SuggestedReviewerEntry(github_login="alice"),)+ if correction == "excluded-login"+ else (),+ )+ SignalReportArtefact.objects.create(+ team=team, report=report, type="reviewer_corrections", content=rules.model_dump_json()+ )++ assert self._assign(team, report, github) == []++ @pytest.mark.django_db+ @pytest.mark.parametrize("source", ["claimant", "reviewer-uuid", "reviewer-login"])+ @pytest.mark.parametrize("unavailable", ["inactive", "project"])+ def test_ineligible_members_receive_no_assignment_or_review_request(+ self, org_and_team: tuple[Organization, Team], source: str, unavailable: str+ ) -> None:+ org, team = org_and_team+ reviewers = [] if source == "claimant" else ["uuid:alice" if source == "reviewer-uuid" else "alice"]+ report, users = self._setup(org, team, reviewers)+ if source == "claimant":+ self._claim(team, report, users, kind="user", login="alice")+ if unavailable == "inactive":+ User.objects.filter(id=users["alice"].id).update(is_active=False)+ else:+ org.available_product_features = [{"key": AvailableFeature.ACCESS_CONTROL, "name": "Access control"}]+ org.save(update_fields=["available_product_features"])+ AccessControl.objects.create(team=team, resource="project", resource_id=str(team.id), access_level="none")+ github = self._github(existing_assignees=[], assignable=None)++ assert self._assign(team, report, github) == []+ github.request_pull_request_reviews.assert_not_called()++ @pytest.mark.django_db+ @pytest.mark.parametrize(+ "change", ["assigned", "unassigned", "closed", "history-unavailable", "report", "claimant"]+ )+ def test_changes_during_github_checks_stop_dri_assignment(+ self, org_and_team: tuple[Organization, Team], change: str+ ) -> None:+ org, team = org_and_team+ report, users = self._setup(org, team, ["alice"])+ github = self._github(existing_assignees=[], assignable=None)++ def check(_repo: str, _login: str) -> dict[str, bool]:+ if change == "assigned":+ github.get_pull_request.return_value["assignees"] = ["manual-owner"]+ elif change == "unassigned":+ github.was_ever_unassigned.return_value = {"success": True, "unassigned": True}+ elif change == "closed":+ github.get_pull_request.return_value["state"] = "closed"+ elif change == "history-unavailable":+ github.was_ever_unassigned.return_value = {"success": False}+ elif change == "report":+ SignalReportArtefact.objects.create(team=team, report=report, type="suggested_reviewers", content="[]")+ elif change == "claimant":+ self._claim(team, report, users, kind="user", login="bob")+ return {"success": True, "assignable": True}++ github.is_assignable.side_effect = check++ assert self._assign(team, report, github) == []+@pytest.mark.django_db@pytest.mark.parametrize(("reviewers", "team_by_path", "members", "claimant", "expected_owner"),diff --git a/products/signals/backend/test/test_scout_report_persistence.py b/products/signals/backend/test/test_scout_report_persistence.pyindex 885b80e99ac7..98f9ed90b334 100644--- a/products/signals/backend/test/test_scout_report_persistence.py+++ b/products/signals/backend/test/test_scout_report_persistence.py@@ -12,7 +12,7 @@ from django.utils import timezonefrom parameterized import parameterized-from posthog.models import Organization, Team+from posthog.models import Organization, OrganizationMembership, Team, Userfrom posthog.models.scoping import team_scopefrom products.signals.backend.artefact_schemas import (@@ -58,6 +58,7 @@ from products.signals.backend.scout_report import ()from products.signals.backend.scout_report.judge import resolve_authored_report_statusfrom products.signals.backend.scout_report.persistence import _report_metrics_unchanged+from products.signals.backend.slack_inbox_notifications import resolve_suggested_reviewer_user_idsfrom products.signals.backend.spend import signal_spend_totalsfrom products.tasks.backend.models import Task, TaskRun@@ -102,21 +103,31 @@ class TestScoutReportPersistence(BaseTest):)return run- def test_empty_selection_enrolls_a_new_report_in_the_writer(self) -> None:+ @parameterized.expand([False, True])+ def test_agent_selection_enrolls_a_new_report_in_the_writer(self, selected: bool) -> None:+ member = User.objects.create(email="[email protected]")+ OrganizationMembership.objects.create(user=member, organization=self.organization)+ chosen = [member, self.user] if selected else []with (patch("products.signals.backend.reviewer_rules.assignment_writer_enabled", return_value=True),patch("products.signals.backend.assignment_flags.feature_enabled_or_false", return_value=False),):result = create_scout_report(team_id=self.team.id,- title="A report without reviewers",- summary="No suitable owner was selected.",+ title="A report with an agent reviewer decision",+ summary="Checked current responsibility.",signals=[ScoutReportSignal(description="A synthetic finding", source_id="example", weight=1.0)],attribution=ArtefactAttribution.system(),+ suggested_reviewers=SuggestedReviewers(+ root=[SuggestedReviewerEntry(user_uuid=str(user.uuid)) for user in chosen]+ ),)snapshot = ReviewerRules.read_for_report(team_id=self.team.id, report_id=result.report_id)assert snapshot.state.corrections_id is not None- assert snapshot.reviewers == ()+ assert [entry.user_uuid for entry in snapshot.reviewers] == [str(user.uuid) for user in chosen]+ assert resolve_suggested_reviewer_user_ids(SignalReport.objects.get(id=result.report_id)) == {+ user.id for user in chosen+ }assert not assignment_side_effects_allowed(team_id=self.team.id, report_id=result.report_id)@parameterized.expand(