fix: panel logo (#160), diff base fallback (#161), doc branch checkout (#162)

#160 — panel /roboco-logo.png "received null":
    next/image optimizer fails for static public assets in Next.js
    standalone mode. Added `unoptimized` to the sidebar logo Image so
    it serves the static file directly (validated on panel rebuild).

#161 — QA/doc evidence pr_diff_summary empty:
    A leaf dev branch's parent_branch_for is the cell-PM branch, which
    is never pushed (only devs push their leaf branch). diff against a
    non-existent origin/<parent> returned empty. Added
    GitService._resolve_diff_base + _default_branch_ref + _ref_exists:
    diff/list_changed_files fall back to the repo default branch
    (origin/HEAD → master/main) when origin/<parent> is absent.

#162 — claim_doc_task BRANCH_MISMATCH loop:
    The documenter's clone is separate from the dev's; the task branch
    already existed (dev created it) so no checkout ran in the doc
    workspace — roboco_docs_write / commit failed BRANCH_MISMATCH and
    the doc looped. Fixes:
    (a) new GitService.checkout_branch_in_agent_workspace; claim_doc_task
        checks out the task branch into the doc clone (best-effort —
        a checkout hiccup never fails the claim).
    (b) BRANCH_MISMATCH remediate now lists all four role claim verbs
        (i_will_work_on / i_will_plan / claim_doc_task / claim_review).
    (d) give_me_work next-hint is role+status aware via _claim_verb_hint
        (doc→claim_doc_task, qa→claim_review, pm→i_will_plan, else dev).
    Facet (c) (i_am_blocked "Not Found" for doc) was only reachable via
    the stuck-without-checkout path; primary fix removes it.

Smoke-11 reached dev→QA→doc (deepest ever) and validated the prior
6 fixes (panel flood gone, #158/#159/#157 confirmed). These three
clear the doc-phase blockers found in that run.
This commit is contained in:
Renn F
2026-05-16 00:13:14 +02:00
parent 5da909d9d7
commit aa2e6bc5ed
6 changed files with 404 additions and 22 deletions
@@ -0,0 +1,90 @@
"""Task #161: GitService diff base falls back to default branch.
A leaf dev branch's parent (per parent_branch_for) is the cell-PM
branch feature/{team}/{root}--{cellpm}, which is NEVER pushed — only
devs push their own leaf branch. Diffing against a non-existent
origin/<parent> returns an empty diff, so QA / docs saw nothing.
_resolve_diff_base must fall back to the repo default branch when the
parent ref is absent on origin.
"""
from __future__ import annotations
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock
import pytest
from roboco.services.git import GitService
def _git_service() -> GitService:
return GitService.__new__(GitService)
@pytest.mark.asyncio
async def test_resolve_diff_base_uses_parent_when_pushed() -> None:
"""When origin/<parent> exists, use it (normal case)."""
svc = _git_service()
svc._run_git = AsyncMock() # type: ignore[method-assign]
svc._ref_exists = AsyncMock(return_value=True) # type: ignore[method-assign]
ws = Path("/tmp/ws")
base = await svc._resolve_diff_base(
ws, "feature/backend/root1234--cellpm56--dev78901"
)
# parent_branch_for strips the last --segment.
assert base == "origin/feature/backend/root1234--cellpm56"
@pytest.mark.asyncio
async def test_resolve_diff_base_falls_back_when_parent_absent() -> None:
"""When origin/<parent> does NOT exist (cell-PM branch never pushed),
fall back to the repo default branch via origin/HEAD."""
svc = _git_service()
svc._run_git = AsyncMock() # type: ignore[method-assign]
# parent ref absent → _ref_exists False for the parent check.
svc._ref_exists = AsyncMock(return_value=False) # type: ignore[method-assign]
svc._default_branch_ref = AsyncMock( # type: ignore[method-assign]
return_value="origin/master"
)
ws = Path("/tmp/ws")
base = await svc._resolve_diff_base(
ws, "feature/backend/root1234--cellpm56--dev78901"
)
assert base == "origin/master"
svc._default_branch_ref.assert_awaited_once()
@pytest.mark.asyncio
async def test_default_branch_ref_prefers_origin_head() -> None:
"""origin/HEAD symbolic-ref is the canonical default-branch pointer."""
svc = _git_service()
async def fake_run(_ws: Any, args: list[str], **_kw: Any) -> Any:
if args[:2] == ["symbolic-ref", "--quiet"]:
return type(
"R", (), {"returncode": 0, "stdout": "refs/remotes/origin/main\n"}
)()
return type("R", (), {"returncode": 1, "stdout": ""})()
svc._run_git = fake_run # type: ignore[method-assign]
ref = await svc._default_branch_ref(Path("/tmp/ws"))
assert ref == "origin/main"
@pytest.mark.asyncio
async def test_default_branch_ref_fallback_when_no_head() -> None:
"""No origin/HEAD → probe origin/master then origin/main; final
hard fallback is origin/master so the git invocation stays valid."""
svc = _git_service()
async def fake_run(_ws: Any, _args: list[str], **_kw: Any) -> Any:
# symbolic-ref fails; fetches succeed but ref never verifies.
return type("R", (), {"returncode": 1, "stdout": ""})()
svc._run_git = fake_run # type: ignore[method-assign]
svc._ref_exists = AsyncMock(return_value=False) # type: ignore[method-assign]
ref = await svc._default_branch_ref(Path("/tmp/ws"))
assert ref == "origin/master"