fix(orb): record PR outcomes from the bot's own action, not the webhook alone - #8824
Merged
Merged
Conversation
…ok alone pr_outcome was written ONLY from the inbound pull_request.closed webhook, so any delivery this instance never processed lost that PR's ground truth permanently. The fleet export inner-joins gate_decision to pr_outcome, so an outcome-less PR drops out of calibration entirely -- contributing to neither numerator nor denominator. Measured on the live self-host: ~55% of bot closes since 2026-07-18 had no pr_outcome row while the PRs were verifiably closed on GitHub (0 missing before that date -- a clean regression). 40 of the 66 PRs carrying a reversal_superseded marker were among them. Because the lost rows skew toward the gate's MISTAKES (a superseded close is by definition a wrong close), their absence biased published accuracy upward. Closes #8823. - outcomes-wire: recordTerminalActionOutcome writes the realized outcome directly, idempotent against the webhook path and best-effort so bookkeeping can never fail an action that already succeeded - agent-action-executor: call it after a successful merge and close - scripts/backfill-pr-outcomes{,-core}.ts: dry-run/apply backfill for the historical gap, keyed off completed terminal actions; skips already-recorded targets and the legacy target-id shape the fleet export excludes
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8824 +/- ##
=======================================
Coverage 93.83% 93.83%
=======================================
Files 800 800
Lines 79831 79842 +11
Branches 24196 24197 +1
=======================================
+ Hits 74908 74919 +11
Misses 3558 3558
Partials 1365 1365
Flags with carried forward coverage won't be shown. Click here to find out more.
|
This was referenced Jul 26, 2026
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.
What
Makes a PR's realized outcome depend on the action the bot actually completed, not on GitHub redelivering a webhook. Closes #8823.
Why — a silent, measurable regression that biased accuracy upward
pr_outcomewas written only from the inboundpull_request.closedwebhook. Any delivery this instance never processed — a dropped brokered relay event, a restart mid-delivery — lost that PR's ground truth permanently. Because the fleet export inner-joinsgate_decisiontopr_outcome, an outcome-less PR falls out of calibration entirely: it contributes to neither the numerator nor the denominator of any accuracy metric.Measured on the live self-host (2026-07-26), bot closes with no
pr_outcomerow, by day:A clean regression starting 2026-07-18, running at ~55% loss since. Spot-checked against GitHub — the PRs are genuinely closed:
pr_outcomeIt is not specific to one close path (contributor-cap closes and ordinary gate closes are both affected), which is why the fix targets the dependency itself rather than a call site.
This is the same root cause behind 40 of the 66
reversal_supersededmarkers never reaching fleet calibration (#8820). Since the lost rows skew toward the gate's mistakes — a superseded close is by definition a wrong close — their absence pushed published accuracy up.How
outcomes-wire.ts:recordTerminalActionOutcome(env, repo, pr, decision)writes the realized outcome directly. Idempotent — skips when apr_outcomerow already exists, so whichever of the two paths wins the race, exactly one row survives. Best-effort throughout: bookkeeping can never fail an action that already succeeded against GitHub, and if the idempotency probe itself fails it writes anyway (a duplicate is strictly better than a lost outcome; both readers take the latest row).agent-action-executor.ts: call it after a successfulmergeandclose.scripts/backfill-pr-outcomes{,-core}.ts: closes the historical hole. The completed terminal action is the ground truth — GitHub rejects a merge the actor may not perform, and a completed close is the repository's realized decision. Pure planning core + thin IO wrapper, dry-run by default, idempotent, and it skips the legacyproject:pull_request:owner/repo#Ntarget shape the fleet export already excludes rather than fabricating outcomes for pre-cutover rows.Ops (after merge, on the self-host)
then rewind
orb_export_cursorso the corrected rows re-export to fleet calibration (ingest upserts, so replay is safe).Verification
audit_eventsmirror never breaking the canonicalreview_auditwrite.