feat(seer): Run-anchored notify_seer_pr_created RPC for PR attribution (CW-1719)#120583
Open
vaind wants to merge 1 commit into
Open
feat(seer): Run-anchored notify_seer_pr_created RPC for PR attribution (CW-1719)#120583vaind wants to merge 1 commit into
vaind wants to merge 1 commit into
Conversation
Contributor
Author
|
Cross-repo stack for CW-1719:
Deploy this first; then un-draft/merge the Seer PR; then, once the writer path is confirmed live, merge #120584. |
…ution Seer records PR attribution and a run<->PR link only via the autofix completion hook, which fires from the SEER_PR_CREATED webhook and requires both a run_id and a group_id. Any PR from a run that isn't tied to an issue (group_id is None) never reaches the attribution/linking code, so those PRs silently lose attribution and their run link. Add a dedicated, run-anchored, issue-optional inbound RPC that Seer's PR writer can call for every PR it opens. It resolves the org, records the SENTRY_APP/SEER_DATA attribution (still behind organizations:pr-metrics-attribution), and always links the PR to its SeerRun (still behind the linking killswitch), inheriting both gates from the existing helpers. It deliberately does not broadcast to sentry-apps, create an Activity, run analytics, or check SeerAutofixOperator.has_access -- those concerns stay on the completion hook. The shared record_seer_created_pull_requests wrapper encapsulates the flag-guarded attribute+link so the legacy write in process_autofix_updates can be pointed at it and removed in a follow-up once this path is live. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
vaind
force-pushed
the
ivan/cw-1719-notify-seer-pr-created
branch
from
July 25, 2026 11:05
958f2d7 to
e2da0b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Seer records PR attribution and a run↔PR link only as a side effect of the autofix completion hook:
send_seer_webhook→process_autofix_updateshandles theseer.pr_createdevent, but that path requires both arun_idand agroup_id(it bails early onmissing_identifiers). Any PR produced by a run that isn't tied to an issue (group_id is None) never reaches the attribution/linking code, so those PRs silently lose attribution and their run link.What this does
Adds a dedicated, run-anchored, issue-optional inbound seer-rpc method,
notify_seer_pr_created, that Seer's PR writer will call for every PR it opens. The receiver:send_seer_webhook(active-org lookup; returns a typed error response if missing/inactive).SENTRY_APP/SEER_DATAattribution — still gated onorganizations:pr-metrics-attribution.SeerRun— still gated only on its ownseer.pull-request-linking.killswitch.enabledkillswitch.seer.pr_created_notify, tagged with whether a group was present.Both gates are inherited by reusing the existing
attribute_seer_created_pull_requests/link_seer_run_pull_requestshelpers via a small sharedrecord_seer_created_pull_requestswrapper — no new killswitch or option.RPC contract
Each
pull_requestsentry:This is byte-for-byte the entry shape
attribute_seer_created_pull_requestsandlink_seer_run_pull_requestsalready read.Why ungated / no broadcast
This is deliberately independent of the completion hook. It does not check
SeerAutofixOperator.has_access, and does not broadcast to sentry-apps, create anActivity, or run analytics — those concerns stay on the completion hook. The point is that attribution + linking must happen for a superset of PRs (including group-less runs), so this path must not be gated on autofix operator access.Legacy write intentionally kept
The existing attribution/link write inside
process_autofix_updates(theSEER_PR_CREATEDbranch) is kept as-is in this PR. The stacked Phase-2 draft PR removes it, and must stay draft until this PR is deployed and Seer's writer path is live. The sharedrecord_seer_created_pull_requestswrapper is introduced here so Phase 2 is a trivial redirect + delete.Tests run vs deferred
Run locally against the provisioned test DB (all green):
tests/sentry/seer/test_pull_requests.py— 14 passed (6 newNotifySeerPrCreatedTestcases: group-less link+attribution, group_ids populated, idempotent redelivery, links regardless of operator access, links-without-attribution when flag off, org-not-found error).tests/sentry/seer/endpoints/test_seer_rpc.py -k "registry or method or send_seer_webhook"— 27 passed (registry/dispatch unaffected).mypyon all changed source files — passed (seer-rpc plugin accepts the concrete union return).prek run(ruff, ruff-format, flake8, mypy) on the full diff — passed.Deferred to CI: the full backend suite.
🤖 Generated with Claude Code