bug(scm): SCM observer never attributes PRs pushed to a fork remote, leaving 'no PR yet' / empty PR data for the standard fork-contribution workflow
Bug
The background SCM observer (backend/internal/observe/scm/observer.go) silently drops every PR whose branch was pushed to a fork remote rather than the project's registered origin — even though the project origin is the correct upstream target for that PR. In this environment (project registered to AgentWrapper/agent-orchestrator, with a separate personal fork remote used to push branches for PRs against upstream — the standard OSS contribution pattern), this means the pr table in ~/.ao/data/ao.db is empty (0 rows) across every project, and every session's Kanban card / PR page shows "no PR yet" regardless of real, open PRs on GitHub.
Analyzed against: 821cda64 (main) | Confidence: High — traced exact code path, mechanism confirmed, reproduced live against a real PR.
Reproduction
- Register a project whose repo is the true upstream (e.g.
AgentWrapper/agent-orchestrator), with a second git remote (fork) pointing at a personal fork used to push worker branches. - Spawn a worker session; let it push a branch to the
forkremote and open a PR fromfork:<branch>against the project's upstreammain. - Observe: the PR exists and is open on GitHub (confirmed live:
AgentWrapper/agent-orchestrator#2602, headmukesher4/agent-orchestrator:ao/agent-orchestrator-14/fix-tmux-attach-utf8,isCrossRepository: true). - Query the daemon:
GET /api/v1/sessions/agent-orchestrator-14/pr→{"sessionId":"agent-orchestrator-14","prs":[]}.sqlite3 ~/.ao/data/ao.db "select count(*) from pr;"→0, for every session in every registered project, not just this one. - Dashboard Kanban card and PR page both show "no PR yet" indefinitely — this never resolves because the observer never persists the discovery.
Root Cause
backend/internal/observe/scm/observer.go:475 builds each session's sessionRepo with:
sessionRepos = append(sessionRepos, sessionRepo{session: sess, repo: repo, headRepo: origin, branch: branch})
headRepo is unconditionally set to origin — the project's registered repo (p.RepoOriginURL, resolved from the project's configured/origin git remote). It is never derived from the actual remote a session's branch was pushed to.
Later, candidatesForHeadRepo (observer.go:685-694) uses this field as a fork-misattribution guard:
func candidatesForHeadRepo(candidates []sessionRepo, headRepo string) []sessionRepo {
...
for _, sr := range candidates {
if strings.EqualFold(repoFullName(sr.headRepo), headRepo) {
out = append(out, sr)
}
}
return out
}
For any PR pushed to a fork (pr.HeadRepo == "mukesher4/agent-orchestrator"), this compares against sr.headRepo == "AgentWrapper/agent-orchestrator" (the hardcoded origin) — they never match, so matchSession is never even reached, and the PR is dropped every single poll, forever. The guard's own doc comment (observer.go:198-200) says headRepo should be "the repo the session's head branch actually lives in (the push origin)... for a cross-fork PR ... headRepo is the fork origin" — but the implementation never computes it that way; it just reuses the project's single origin repo for every session.
Notably, resolveScanRepos (observer.go:507-526) does correctly enumerate every git remote of the local checkout (including the fork) for the purposes of which repos to scan for PR lists — proving the code already has the information needed to also resolve per-session headRepo, it just isn't wired into the sessionRepos construction.
Impact
This affects the standard/expected fork-based contribution workflow (project registered to upstream, worker branches pushed to a personal fork remote, PR opened fork→upstream) — which, in this environment, is essentially every worker session. The result: the pr table stays empty, Kanban cards and the PR page permanently show "no PR yet"/no PR info even for real, open, active PRs, and downstream features that depend on PR facts (CI/review/mergeability nudges, attention-zone routing, claim-pr auto-attach, completion detection) never fire for these sessions.
Related
- #2479 — a sibling gap in the manual
claim-prpath for the mirror-image setup (project registered to a fork, PR against a separately-configuredupstreamremote); already fixed. This issue is the analogous gap in the automatic background discovery path, for the (equally common) setup where the project is registered to the true origin/upstream and a separateforkremote is used to push branches. - #2509 — different bug in the same subsystem (repo owner/name reload causing check-run 404s), unrelated mechanism.
Suggested Fix
When building sessionRepos, resolve each session's actual push-remote repo (e.g. by matching the session's branch/worktree to its configured push remote, or by trying every git remote parsed in resolveScanRepos as a headRepo candidate) instead of hardcoding origin. candidatesForHeadRepo should accept a match against any remote the session could plausibly have pushed to, not just the project's single registered origin.
New Report — corroborating evidence
Hit this independently while triaging why workers in this environment never progress to In Review/Ready to Merge/Done and pile up instead of terminating.
Confirmed two more live instances of the exact same mechanism (checkout 821cda64):
agent-orchestrator-6— branchao/agent-orchestrator-6/root, real open fork PR AgentWrapper/agent-orchestrator#2485 (headmukesher4/agent-orchestrator:ao/agent-orchestrator-6/terminal-focus-fix)agent-orchestrator-15— branchao/agent-orchestrator-15/root, real open fork PR AgentWrapper/agent-orchestrator#2593 (headmukesher4/agent-orchestrator:ao/agent-orchestrator-15/spawn-confirmation-name-fork)
sqlite3 ~/.ao/data/ao.db "select * from pr where session_id in ('agent-orchestrator-6','agent-orchestrator-15');" returns 0 rows for both, matching the reported root cause exactly: sessionRepo.headRepo is hardcoded to the project's registered origin for every entry in the scanRepos loop (observer.go:475), so candidatesForHeadRepo (observer.go:685) never matches a fork-authored PR's real head repo and discoverNewPRs silently drops it before matchSession even runs — even though the branch-matching logic itself (sessionBranchPrefixes/matchSession) would correctly attribute these stacked branches to their owning session if it ever got the chance to run.
Compounding effect: because these sessions also never accumulate real activity signal after a daemon restart (see #2604), they show no_signal instead of any PR-derived status, and never terminate — both bugs together are why workers in a fork-based project pile up indefinitely instead of reaching pr_open/review_pending/mergeable/merged/terminated.
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @neversettle17-101
- @somewherelostt
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @somewherelostt here. You can also join the AO Discord if you want faster context, want to ask questions live, or just want to follow what the community is building.
You are also welcome to join the AO Discord community.
We do daily Discord calls at 10 PM IST, except Saturday.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
UI/UX Audit cross-reference — AO-13 (P2)
This issue relates to AO-13: "No PR yet" is misleading for tasks that do not need a PR from the UI/UX Audit (15 July 2026).
The audit recommends context-aware PR status copy:
- No PR required
- PR not created yet: agent still working
- PR creation failed: review error
- Ready for review: PR #123
PR status should be derived from task intent and lifecycle state.
Tracking epic: #2728
Assigned to @Ayash-Bera