bug(scm): stale transferred PR row can surface false merge conflict
Bug
AO can continue to show a resolved/nonexistent merge conflict for a PR after the PR has moved from the old AgentWrapper GitHub URL to the current Untrivial-ai URL. GitHub and the current AO PR observation both say the PR is not conflicted, but the desktop still surfaces a stale Merge conflict state from an old PR row attached to the same session.
Source: local user report in AO desktop on August 13, 2026
Analyzed against: 461a6df56 (origin/main, feat: add per-PR CI failure injection policy (#3772))
AO daemon under test: locally built /tmp/ao, dev, loopback daemon on 127.0.0.1:3001
Confidence: High — reproduced from the daemon API and traced to stale PR rows/aliasing.
Screenshots


Reproduction / observed state
Live case: PR #2870, session agent-orchestrator-31.
GitHub reports the current PR as mergeable but blocked on review/branch protection, not conflict:
{
"url": "https://github.com/Untrivial-ai/agent-orchestrator/pull/2870",
"mergeable": "MERGEABLE",
"mergeStateStatus": "BLOCKED",
"reviewDecision": "REVIEW_REQUIRED",
"headRefOid": "b960b45af86951ff3770a8f51ae4d2fffcd4d22f"
}
AO's session API returns both the current PR row and a stale row from the old repo owner:
{
"prs": [
{
"url": "https://github.com/Untrivial-ai/agent-orchestrator/pull/2870",
"number": 2870,
"mergeability": "blocked",
"updatedAt": "2026-08-13T03:08:46.531282Z"
},
{
"url": "https://github.com/AgentWrapper/agent-orchestrator/pull/2870",
"number": 2870,
"mergeability": "conflicting",
"updatedAt": "2026-07-26T16:19:15.891494Z"
}
]
}
The detailed PR endpoint also returns both rows. The stale AgentWrapper row has old provider mergeability values:
url=https://github.com/AgentWrapper/agent-orchestrator/pull/2870
head_sha=6273ce786a300757e2cdcf2f2d6ea59ea4435992
mergeability=conflicting
provider_mergeable=CONFLICTING
provider_merge_state_status=DIRTY
updated_at=2026-07-26 16:19:15 UTC
The current row is correct:
url=https://github.com/Untrivial-ai/agent-orchestrator/pull/2870
head_sha=b960b45af86951ff3770a8f51ae4d2fffcd4d22f
mergeability=blocked
provider_mergeable=MERGEABLE
provider_merge_state_status=BLOCKED
updated_at=2026-08-13 03:08:46 UTC
Root Cause
The issue appears to be AO local state/enrichment, not GitHub/SCM:
backend/internal/storage/sqlite/queries/pr.sqlreturns all PR rows attached to the session viaListPRsBySession/ListPRFactsBySession.backend/internal/service/session/pr_summary.gogroups aliases viagroupPullRequestAliasesbefore returning/api/v1/sessions/{sessionId}/pr.backend/internal/service/session/pr_alias.goonly collapses transferred-repo aliases when the alias key matches. When source branch and head SHA are present, the key includes the head SHA. In this live case the oldAgentWrapperrow has an older head SHA, so it does not collapse with the currentUntrivial-airow.- The stale row remains
openandconflicting, so the desktop can render its obsolete conflict state even though the canonical/current PR is not conflicted.
There is also stale last_nudge_signature data containing a prior merge-conflict: key, but the direct UI problem is reproducible from the stale PR row returned by the API.
Expected Behavior
If GitHub redirects/resolves an old repo URL to the current PR, AO should not show stale conflicting state from the old URL. The session should surface the current PR facts only, or supersede/close/filter the stale alias row.
Suggested Fix
Handle repo-transfer/redirect aliases at the daemon/store/read-model boundary. Possible approaches:
- When observing a PR, if the provider returns a canonical
html_url/URL different from the requested/stored URL, migrate or supersede the old row instead of keeping both open. - In the session PR read model, collapse or filter stale aliases for the same session + PR number + source branch/target branch when one URL is canonical/current and the older URL is the previous repo owner, even if the head SHA changed.
- Avoid surfacing stale conflict nudges as current state; clear or ignore
merge-conflict:dedupe entries oncemergeability != conflicting.
The fix should be careful not to collapse unrelated same-number PRs in different repos. There are already tests in backend/internal/service/session/service_test.go around PR aliasing; add a regression for "old owner stale conflicting row + new owner current blocked/mergeable row with newer head".
Impact
- False-positive merge conflict warnings in desktop.
- Agents/users may waste time rebasing already-mergeable PRs.
- Status cards become inconsistent with GitHub and with the current AO PR observation.