Repository navigation
Description
This was generated by AI during triage.
Problem
When a Review run fails in delivery (Step 3) after earlier editing steps (code-review or security-review) have already committed repairs onto the local PR branch, thirdshift rightly preserves the worktree and local branch so work is not lost:
thirdshift: 10:44:44 step delivery: 6m 23s failed: codex exited by signal (delivery; worktree review; codex · gpt-6.1-sol · high)
thirdshift: 10:44:44 cleaning up the worktree and local branch marketing/group-signup-email-card
thirdshift: 10:44:45 warning: retaining checkout /tmp/thirdshift-review-Pn08bZ and local branch marketing/group-signup-email-card at 4fc9a72ac439cabcfb5e0313d62701156cef0cfa: the worktree has unpushed commits
However, when thirdshift review runs on a 2-minute cron (thirdshift review --author hlieberman-bit), every subsequent cron tick selects the same PR (Educational-Travel-Adventures/tourbot#2060), immediately fails preflight in 4–5 seconds:
Result: failed
Command: Review run
Repository: Educational-Travel-Adventures/tourbot
Pull request: https://github.com/Educational-Travel-Adventures/tourbot/pull/2060
Cause: the local branch marketing/group-signup-email-card differs from origin/marketing/group-signup-email-card
...
Occupied checkout /tmp/thirdshift-review-Pn08bZ on refs/heads/marketing/group-signup-email-card.
and sends the identical failure email every 2 minutes (20261105T104602-0500~X9OSYdV9VrrHr0Vm, 20261105T105001-0500~52PXQsoQPVB9mYxb, etc.) while also preventing the scheduled thirdshift review pass from advancing to any other PRs until a human pauses the cron or cleans up the retained worktree.
Options to weigh
- Deduplicate notifications and skip unchanged branch/worktree conflicts during scheduled passes:
- Record the conflict state
(pr_number, branch, local_oid, remote_oid, occupied_worktree)when aReview run(orPickup run) fails preflight because a local branch or retained worktree differs fromorigin. - On subsequent scheduled discovery passes, if
local_oid,remote_oid, and the occupied worktree are unchanged, skip that PR without failing the pass or sending duplicate failure emails every cron tick (similar to Tell the Day shift once when Pickup is held at its Claim limit, with each holder's pull request #959 for Pickup Claim holds), and clear the suppression once either ref or the worktree changes.
- Record the conflict state
- Resume or finish
deliveryfrom athirdshift-retained Review worktree:- When the occupied worktree
/tmp/thirdshift-review-*was retained by a previousReview runon the same PR, its working tree is clean, and its local commits sit directly on top of the currentorigin/<branch>head (8abc3e0a6..4fc9a72ac),thirdshiftitself created those commits during Steps 1–2. A subsequentReview runcould either resume atdelivery(final validation + push + comment) or push the preserved review commits so the normal continuation path can proceed, instead of treating its own retained review commits as an unknown divergence.
- When the occupied worktree
Activity
JacobStephens2 commentedon Nov 5, 2026
Agent Brief
Root Cause & Context
In
src/processes/review.rs(run, lines 15–58),thirdshift review --author <author>:github.waiting_review_pull_requests(&repo, &author, None)?Reservationon the first eligible PR and breaks out of the loopReviewProcess::execute(line 133), which createsRunNotification(line 181) and then callsSkillWorktree::on_pull_request(&launch, &snapshot.branch, &snapshot.head)(line 239) →acquisition::add_review(src/worktree/acquisition.rs:23).When a prior
Review runon that PR died in step 3 (delivery) aftercode-revieworsecurity-reviewcommitted fixes locally:SkillWorktree'sDrop(cleanup_preserving_workinsrc/worktree/ownership.rs:167) rightly retains/tmp/thirdshift-review-*and local branchrefs/heads/<branch>becauseHEADhas unpushed commits.Publication::publishinsrc/worktree/review_recovery.rs(called fromsrc/worktree/acquisition.rs:62) only writes durable ownership evidence (.thirdshift-review-token+thirdshift-review.json) whenbranch.is_none()(detached checkouts), not foradd_review(SkillWorktree::on_pull_request).thirdshift review --authorcron tick (e.g. every 2 minutes),waiting_review_pull_requestsreturns the same PR first,acquisition::add_reviewrefuses because localrefs/heads/<branch>differs fromorigin/<branch>and/tmp/thirdshift-review-*is still checked out onrefs/heads/<branch>,Reservationis released on drop,RunNotificationsends a failure email, and every subsequent cron tick repeats the same failure email while starving any other waiting PRs by that author.Agreed Design: Auto-Recover Owned Review Worktrees (Option B) with Skip + Notify-Once Fallback (Option A)
1. Primary path (Option B): Publish durable ownership evidence for Review worktrees and auto-recover clean, fast-forward retained Review worktrees
src/worktree/review_recovery.rs,src/worktree/acquisition.rs):Record/Publication::publishinsrc/worktree/review_recovery.rssoadd_review(SkillWorktree::on_pull_request) also records durable ownership evidence (.thirdshift-review-tokenin the worktree root +thirdshift-review.jsonin the worktree admin dir, withroot/admin/common(path, dev, ino)records,branch: Some(branch),captured_head: start, and whether the local branch pre-existed).src/worktree/skill.rs,src/worktree/acquisition.rs,src/worktree/review_recovery.rs):SkillWorktree::on_pull_request(launch, branch, start)sees thatrefs/heads/<branch>already exists locally and/or is checked out in a registered/tmp/thirdshift-review-*worktree, inspect that registered worktree under the launch worktree lock and refs lock:thirdshift-review.jsonand.thirdshift-review-tokenagainst the checkout'sroot,admin, andcommondirectory(path, dev, ino)handles (using the same symlink/inode verification asreview_recovery::recover).branchandcaptured_head == start(the PR's currentorigin/<branch>head).uncommitted_changes(..., UntrackedFiles::DiscardValidationArtifacts)isfalse).startis an ancestor of the worktree'sHEAD(git merge-base --is-ancestor <start> HEAD)..thirdshift-review-tokenandthirdshift-review.json) and adopt the verifiedCheckout(or inMode::RecommendOnly, reset tostartif needed).src/processes/review.rs(unchanged_checkout, line 675 / line 289), permitHEADto be a fast-forward descendant ofsnapshot.head(merge-base --is-ancestor snapshot.head HEAD) whenmode == Mode::Addresson a recovered Review worktree soReviewAndAddress,SecurityReview, andDelivery(push_fixesinsrc/processes/review/delivery.rs:228, which already checksmerge-base --is-ancestor snapshot.head HEAD) can complete and publish the preserved + new commits and post the review comment.2. Fallback path (Option A): When a PR's local branch/worktree cannot be auto-recovered, skip it in
--authordiscovery and notify at most once per staterefs/heads/<branch>or an occupied worktree fails the auto-recovery checks above (e.g., it has uncommitted tracked edits, was created/modified outsidethirdshift, or is not a fast-forward descendant oforigin/<branch>):thirdshift review <pr-url>): Fail loudly and send theRunNotificationwith recovery advice as today.thirdshift review --author <author>insrc/processes/review.rs):waiting_review_pull_requestsloop so that if one PR is blocked by an unrecoverable local branch/worktree conflict,--authorcontinues scanning later waiting PRs by that author instead of aborting the whole pass.~/.thirdshift/(keyed by(repo, pr_number, branch)with fingerprint(local_head, remote_head, occupied_worktree_path)) when sending the failure notification for a blocked PR during an--authorpass. On subsequent--authorpasses where the fingerprint for that PR is unchanged, log a skip/progress message (progress::step/logs::skipped) and suppress duplicate failure emails. As soon aslocal_head,remote_head, or the occupied worktree state changes (or the conflict is cleared), clear/update the record.Verification & Tests
src/worktree/review_recovery_tests.rs&src/worktree/acquisition_tests.rs:SkillWorktree::on_pull_requestcheckout with clean committed fixes ahead ofstart(origin/<branch>) and valid.thirdshift-review-token+thirdshift-review.jsonis automatically recovered on the nextSkillWorktree::on_pull_request(launch, branch, start)call.HEAD, or a human-created local branch is not auto-recovered and still returns the preservation advice.src/processes/review.rs(ortests/):thirdshift review --author, an unrecoverable local branch conflict on PR Test #1 notifies once, suppresses duplicate emails on subsequent identical passes, and allows waiting PR Spec: thirdshift, turn a GitHub issue into a ready-for-review PR unattended #2 by the same author to be selected and reviewed.JacobStephens2 commentedon Nov 5, 2026
Closed by #1787, merged into main by a thirdshift Ticket run with Self-merge.