fix(signals): include recent merged PRs in outcome analysis - #313
Merged
JSONbored merged 4 commits intoJun 3, 2026
Merged
Conversation
philluiz2323
force-pushed
the
fix/repo-outcome-include-merged
branch
from
June 2, 2026 15:41
c9dc438 to
beea306
Compare
JSONbored
requested changes
Jun 2, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@philluiz2323 the fix looks useful and CI is green, but the PR title needs to follow the repo title convention.
Required change:
- Retitle this to something like
fix(signals): include recent merged PRs in outcome analysis.
Validation expected:
- Keep npm run test:ci green after any update.
Contributor
Author
done |
JSONbored
approved these changes
Jun 3, 2026
JSONbored
left a comment
Owner
There was a problem hiding this comment.
@philluiz2323 this still needs cleanup before it can be reviewed.
A few notes:
- The problem area is valid.
- The title has a trailing period and does not meet this repo's PR-title policy. (fixed)
- The PR body is missing the current template evidence.
Required changes:
- None for now.
Validation expected:
- Focused repo outcome pattern tests.
- Full CI green after any rebase.
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.
Closes #312.
Problem
buildRepoOutcomePatternsbuilt its analyzed PR set from onlyargs.pullRequestsand usedrecentMergedPullRequestspurely as a by-number enrichment lookup. But the loader readspullRequests(thepull_requeststable) andrecentMergedPullRequests(the separaterecent_merged_pull_requeststable) independently, and the backfill writes open PRs topull_requests(marking vanished ones closed with nomergedAt) while merged PRs go to the separate table. So a repo's historical merged PRs were absent from the analysis:outsideContributorMergeRatecollapsed toward 0, falsely firing the "Outside contributor PRs rarely merge here / high closure risk" pattern and suppressing "merge well here", and every outcome dimension was blind to merged history. This feedsbuildContributorStrategy, repo-fit, reward-risk, and the decision pack, so healthy repos were reported as high-closure-risk.Fix
normalizeRecentMergedOutcomehelper converts arecent_merged_pull_requestsrecord into a decided/mergedRepoOutcomePullRequest, deriving maintainer-lane / author-role from the stored payload'sauthor_association(the table has no association column).pull_requestsrows and merged records that exist only inrecent_merged_pull_requests(deduped by PR number, requiring a realmergedAt).mergedAt) is counted asmerged, notclosed_unmerged, even when the open-PR reconciliation only saw it vanish. A recent-merged enrichment record withmergedAt: nulldoes not flip a PR to merged.Tests
Added a fail-on-revert test: with only closed shells in
pullRequestsand 9 merged PRs living only inrecent_merged_pull_requests, the result must reporttotals.merged: 9and the "Outside contributors merge well here" success pattern, not the false high-closure-risk pattern. The existing recent-merged tests only used merged PRs that also appear inpullRequests, so they never exercised the merged-only path.vitest runrepo-outcome-patterns (+service) 30/30; consumers + e2e (signals, signals-v2, decision-pack, queue, integration/api) 143/143;tsc --noEmitclean.