fix(github): scope PR selection and clear rejected cached links

Apply the default-branch policy while probing each repository, so an
integration PR cannot preempt a valid result or suppress the same number
in another repository. Check branch heads by repository and server.

Invalidate remote defaults when their review scope or SSH provider changes.
Report rejected PR URLs through an optional refresh-result field, so merged
integration PRs clear from both caches even at the current worktree head.
Share the manual and coordinator cache update implementation.

Co-authored-by: petersindex <287557875+petersindex@users.noreply.github.com>
This commit is contained in:
Neil
2026-10-10 17:08:10 -07:00
committed by Neil
co-authored by petersindex
parent 0bc07c9954
commit 82c5484f66
15 changed files with 505 additions and 193 deletions
@@ -19,6 +19,13 @@ describe('normalizeGitHubPRForBranchOutcome', () => {
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toBe(outcome)
})
it.each([
{ kind: 'no-pr' as const, fetchedAt: 10 },
{ kind: 'no-pr' as const, fetchedAt: 10, rejectedPRUrls: [PR.url] }
])('preserves no-PR responses from older and newer hosts', (outcome) => {
expect(normalizeGitHubPRForBranchOutcome(outcome, 20)).toEqual(outcome)
})
it('normalizes legacy PRInfo and null responses', () => {
expect(normalizeGitHubPRForBranchOutcome(PR, 20)).toEqual({
kind: 'found',
@@ -22,7 +22,7 @@ export type PRRefreshUpstreamErrorType = PRRefreshErrorType
export type PRRefreshOutcome =
| { kind: 'found'; pr: PRInfo; fetchedAt: number }
| { kind: 'no-pr'; fetchedAt: number }
| { kind: 'no-pr'; fetchedAt: number; rejectedPRUrls?: string[] }
| {
kind: 'upstream-error'
errorType: PRRefreshErrorType