fix(git): reviewer reads must prefer origin over a diverged local ref (#690)

* fix(git): reviewer reads must prefer origin over a diverged local ref

_resolve_head_ref (GitService.diff/list_changed_files/read_file_at_branch)
kept local priority on ANY divergence from origin, real or rewritten. A
reviewer's clone parked on pre-rebase history after the branch's routine
force-push sync stayed frozen there across every subsequent review round,
while origin held every fix commit — QA repeatedly bounced work that had
already landed. Every caller here is a reader, never the branch's own
author mid-write, so origin now wins whenever it carries anything the
local ref lacks; local keeps priority only when it strictly contains
origin (unpushed commits, or equal).

The read-only git MCP surface (roboco_git_log) hit the same staleness
through a separate path: /api/git/log resolved the requested branch as a
bare name straight off whatever the caller's own clone had on disk, with
no fetch at all. It now routes through the same fixed _resolve_head_ref.

* test(e2e): give the armed flow-verb timeout real headroom

The armed value is also verb-2's entire execution budget (claim + every
claim guard + set_plan + start + tracing gate), which grows as guards
land; 1s flaked on loaded CI runners while passing locally. The
cancel-and-release semantics only need the timeout far below the hang.

---------

Co-authored-by: Renn F <rennf93@users.noreply.github.com>
This commit is contained in:
Renzo F
2026-07-24 17:50:13 +02:00
committed by GitHub
co-authored by Renn F
parent eb0dcb6ecb
commit e97f46af6e
8 changed files with 277 additions and 34 deletions
@@ -103,9 +103,12 @@ _BR = "feature/backend/root1234--cellpm56--dev78901"
@pytest.mark.asyncio
async def test_resolve_head_ref_prefers_local_branch_in_dev_clone() -> None:
"""Dev's own clone has the local branch — use it unchanged."""
"""Dev's own clone has the local branch, ahead of/equal to origin
(origin has nothing local lacks) — use it unchanged."""
svc = _git_service()
svc._run_git = AsyncMock()
svc._run_git = AsyncMock(
return_value=type("R", (), {"returncode": 0, "stdout": "0"})()
)
svc._ref_exists = AsyncMock(return_value=True)
head = await svc._resolve_head_ref(Path("/tmp/ws"), _BR)