Skip to content

Review run checks out stale PR head.sha when origin/<branch> is already ahead, failing at delivery after full session run #1800

Open

Description

@JacobStephens2

This was generated by AI during triage.

Problem

When starting a Review run, github.review_pull_request samples snapshot.head from GitHub's pull request REST object (node["head"]["sha"]) and launch.fetch fetches both &snapshot.branch and &snapshot.head:

  • src/processes/review/conflicts.rs:
    let snapshot = github.review_pull_request(pr)?;
    launch.fetch(&[&snapshot.branch, &snapshot.head])?;
    let conflict = SkillWorktree::pull_request_conflict(launch, &snapshot.branch, &snapshot.head)?;
  • src/processes/review.rs:
    launch.fetch(&[
        &snapshot.branch,
        &snapshot.base,
        &snapshot.head,
        &snapshot.base_head,
    ])?;
    let mut worktree = SkillWorktree::on_pull_request(&launch, &snapshot.branch, &snapshot.head)

However, neither conflicts::eligible nor SkillWorktree::on_pull_request (acquisition::inspect_review / Acquisition::inspect) checks that the fetched remote-tracking ref refs/remotes/origin/<snapshot.branch> (fetched_origin(&snapshot.branch, ...)) actually points to snapshot.head.

If refs/heads/<branch> on origin has moved ahead of the head.sha reported by GitHub's pull request API—either because GitHub's PR metadata lagged behind a push to origin/<branch> or because a push landed between github.review_pull_request and launch.fetch—the Review run:

  1. Creates the review worktree and local branch refs/heads/<branch> at the stale snapshot.head commit (behind refs/remotes/origin/<branch>).
  2. Runs every review, security, and validation session (code-review, security-review, process-step-3) on the stale commit.
  3. Fails at the very end in Delivery::push_fixes (src/processes/review/delivery.rs) when --force-with-lease=refs/heads/<branch>:<snapshot.head> is rejected by origin:
    git push --no-verify --force-with-lease=refs/heads/marketing/group-signup-email-card:8abc3e0a6a147e489882ec970e156d1d376d8f60 origin 437e1188b6711dbbe6ef093e98e589ea2d9a0e4f:refs/heads/marketing/group-signup-email-card failed: error: failed to push some refs to 'https://github.com/Educational-Travel-Adventures/tourbot.git'
    To https://github.com/Educational-Travel-Adventures/tourbot.git
     ! [rejected]            437e1188b6711dbbe6ef093e98e589ea2d9a0e4f -> marketing/group-signup-email-card (stale info)
    
  4. Retains the review worktree with new commits parented on the stale snapshot.head, producing a two-headed divergence between the retained local branch and origin/<branch> that cannot be fast-forwarded or automatically recovered by Recover retained Review fixes and skip unchanged local conflicts #1787.

Observed incident (Educational-Travel-Adventures/tourbot#2060)

  1. At 09:54–10:44, Review run 20261105T095401-0500~MM5zYQxi5VURKHIC reviewed PR Exclude Suspended time from Slow and Silent #2060 at 8abc3e0a6, committed fixes (c4262be01, 4fc9a72ac), and failed in process-step-3 before pushing, retaining /tmp/thirdshift-review-Pn08bZ and local branch marketing/group-signup-email-card at 4fc9a72ac.
  2. At 11:01:49, 4fc9a72ac was pushed from the Launch directory to origin/marketing/group-signup-email-card and the retained worktree/branch was removed.
  3. GitHub updated refs/heads/marketing/group-signup-email-card to 4fc9a72ac, but GitHub's PR object (pulls/2060 head.sha / refs/pull/2060/head) failed to resync and remained stuck at 8abc3e0a6.
  4. At 12:20, Review run 20261105T122002-0500~qZDSwMTgoBLZ2xkz sampled snapshot.head = 8abc3e0a6, fetched origin/marketing/group-signup-email-card (4fc9a72ac), checked out 8abc3e0a6 anyway, spent 1h 07m 55s generating new review commits (cb106ee8c, 437e1188b) on top of 8abc3e0a6, and failed at Delivery::push_fixes with (stale info), leaving /tmp/thirdshift-review-Rn12ZN diverged from origin/marketing/group-signup-email-card.

Direction

Verify after launch.fetch (in acquisition::inspect_review / Acquisition::inspect, shared by SkillWorktree::pull_request_conflict and SkillWorktree::on_pull_request) that fetched_origin(branch) equals the expected PR start (snapshot.head):

  • If refs/remotes/origin/<branch> does not match snapshot.head, refuse acquisition before creating the worktree or starting any session.
  • Because conflicts::eligible calls SkillWorktree::pull_request_conflict, an unattended thirdshift review --author Pass will skip the PR while GitHub's PR head.sha and origin/<branch> disagree, suppress repeated failure notifications via ~/.thirdshift/review-conflicts/ while the fingerprint (including the observed origin/<branch> head) is unchanged, and automatically clear the suppression once snapshot.head and origin/<branch> converge.

Activity

  1. added
    bug
    needs-triage
    in-progress
    and removed
    needs-triage
    on Nov 5, 2026
  2. JacobStephens2 commented on Nov 10, 2026

    @JacobStephens2
    OwnerAuthor

    This was generated by AI during triage.

    Investigation summary

    Confirmed on selected Base dbdd894.

    The real CLI, using local Git repositories and the repository's fake GitHub/Harness adapters, accepted a stale PR head despite a newer fetched origin branch. Three sessions ran: review, security review and final validation. Delivery then failed with stale info, retaining two fix commits divergent from one newer origin commit. Origin remained unchanged. An author Pass with --recommend-only also reviewed the stale commit and created no conflict suppression record. A matching-head control delivered successfully.

    Diagnosis

    src/github/review.rs:324 captures head.sha. src/processes/review.rs:235 fetches the branch and captured commits, but src/worktree/acquisition.rs:48 and :161 compare local branch state against the captured head without requiring equality with the fetched origin branch. src/worktree/review_recovery.rs:395 consequently reports no conflict for an absent local branch. Its fingerprint has no explicit fetched-origin-head component. src/processes/review/delivery.rs:228 ultimately pushes with the captured-head lease, correctly rejecting the mismatch.

    Recommended work

    Require exact equality between the captured PR head and the fully qualified fetched origin branch before Review acquisition creates a checkout or adopts retained work. Diagnose both expected and observed commits. Keep this check Review-specific: generic acquisition also creates fresh Issue branches without an origin counterpart. Preserve existing ownership checks and the Delivery lease.

    Author Pass admission should skip mismatches, continue to later eligible PRs, notify once per unchanged fingerprint, include the observed origin head in that fingerprint, and clear suppression when the heads converge. Cover explicit runs, absent/equal local branches, retained worktrees and matching-head success. Update Review fixtures that currently omit an origin feature branch, plus the manual and relevant hand-written site pages.

    This is distinct from open #1961, which concerns movement during a session. After simulated API convergence, the already-diverged checkout still failed recovery before another session because its captured head differed. Preventing new divergence does not repair existing retained work.

    Recommend ready-for-human for the requested Ticket split; no publication was performed.

    Questionnaire

    For the Day shift shaping #1800: the stale-head acquisition bug is reproduced locally; no production access is needed to confirm the code defect.

    1. Should Review run checks out stale PR head.sha when origin/<branch> is already ahead, failing at delivery after full session run #1800 be published as two linked Tickets, with B blocked by A? Proposed A: add the Review-specific fetched-head equality guard before new acquisition or retained-checkout adoption, with real-Git regression coverage and preservation checks. Proposed B: complete author-Pass mismatch admission and notification fingerprint behavior, testing unchanged suppression, changed origin heads, convergence, selection of a later PR, and the user documentation. This decision settles publication and ordering. Keep recovery of already-diverged work outside these Tickets; Review run: a pull request that changes mid-run strands its fixes in a retained worktree and is never reviewed again #1961 covers that separate problem.
  3. added
    ready-for-human
    and removed
    in-progress
    on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions