feat(review): detect successor-superseded reversals for the one-shot close culture - #8188
Merged
Conversation
…close culture The reopen-shaped reversal signal is structurally near-impossible under this gate's one-shot design (verified: zero reversal events in the full production ledger), so bot-was-wrong evidence never reaches the calibration corpus's positive class. Detect the culture's actual reversal shape instead: a merged PR that shares a linked issue with a recently bot-closed PR, or the same author reworking a majority of its files, records reversal_superseded plus the per-rule reversed overrides the corpus consumes. Conservative matcher (borderline records nothing), idempotent per closed target, fail-safe on every write, and counted in the public reversal stats. Closes #8166
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 #8188 +/- ##
==========================================
- Coverage 92.07% 89.63% -2.44%
==========================================
Files 769 101 -668
Lines 77882 23021 -54861
Branches 23529 3965 -19564
==========================================
- Hits 71707 20635 -51072
+ Misses 5062 2199 -2863
+ Partials 1113 187 -926
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
Adds the successor-based reversal detector (#8166): when a PR merges, scan the last 30 days of real (non-dry-run) bot closes in the same repo and record a
reversal_supersededevent — plus the per-rulereversedhuman-override events the calibration corpus consumes — for any bot-closed PR the merge supersedes.Why
The gate's own one-shot design tells a wronged contributor "recovery = open a fresh PR", so the reopen-shaped reversal signal is structurally near-impossible here — verified against the full production ledger: zero reversal events ever recorded. This is the culture's actual "the bot was wrong" shape, and it is what finally feeds the corpus's positive class organically.
How
src/review/reversal-superseded.ts— pure, conservative matcher: a shared linked issue (the strongest intent signal), or same author reworking ≥50% of the closed PR's files. Borderline records nothing; unknown authors and file-less closed PRs never match. Every recorded event carries the matched heuristics.recordSupersededReversalsinoutcomes-wire.ts— runs in the merged branch of the existing reversal wire; idempotent per closed target; every write best-effort; reuses the calibration: wire recordRuleFired/recordHumanOverride for the remaining isConfiguredGateBlocker codes (excludes linked_issue_scope_mismatch, covered by #8101) #8104/calibration: wire linked_issue_scope_mismatch into the shared signal-tracking module (fired + reversal) #8101 override recorders so fired rules against the superseded PR get theirreversedverdict.reversal_reopened/reversal_reverted.Validation
npm run test:cigreen locally (1118 test files).srcranges, including the fail-safe arms (forced write rejections, undefined D1 result set, garbage target keys, self-close skip).Closes #8166