Repository navigation
Labels
enhancementNew feature or request
Description
Problem Statement
When a pull request waiting in Ready for review in the Inbox develops a Merge conflict with its Base branch or has CI red, or when the Base branch itself goes red on origin, the Day shift currently has no way to ask the factory to simply heal the branch or pull request:
- Re-running a Ticket run on the originating Issue URL re-runs the entire Process from the opening implementation and code-review sessions, requires an issue (which standalone or Review run pull requests lack), and cannot be triggered across all waiting pull requests as a Pass.
- A Review run reviews the diff on the Standards and Spec axes and never merges the Base branch in or resolves merge conflicts.
- A Pickup run only opens an unready
CI red on <base>stub issue when the Base branch stays red, waiting for a human to write a task before any agent can touch it, while a Base fix only runs inside another active Ticket run that hits an Inherited failure and always forces a silent Self-merge with no Run notification. - From the Console, a Ready for review row showing
CI redorMerge conflictoffers no one-click command to copy and run a repair.
Solution
Introduce Fix run (thirdshift fix), a new Command with its own Built-in process (fix-run) that repairs either a specific open pull request or, when started with no pull request as a Pass, monitors and repairs a red Base branch and open pull requests with merge conflicts or failing CI:
- Targeted pull request Fix run (
thirdshift fix <PR URL or number>): Checks out the pull request's head branch in a Worktree, reserves the pull request within-progress, writes the trusted pull request and linked closing-issue context for Repair sessions, skips any opening implementation or review session, and takes the pull request straight through the Repair loop against its Base branch (merging the Base branch in, resolving merge conflicts via conflict Repairs, pushing, watching CI, fixing failing checks via CI-fix Repairs, and optionally starting a Base fix on Inherited failures). - Unattended Pass mode (
thirdshift fix [base <branch>] [--author <login>]):- Respects the repository's Command limit on the machine (
UpToTheLimit). - When
--authoris not given, first checks the Base branch's latest push CI onorigin. On a failed first attempt with failed jobs, requests one re-run of the failed jobs and skips the pass while the re-run runs. If the Base branch remains red and no fix pull request already exists for that Base branch tip commit, branchesfix-<base>-<short-sha>off the Base branch in a Worktree, runs a CI-fix session with the failing check details, opens a pull request titledFix CI on <base>: <check>[, <check>…]targeting the Base branch, and takes it through Delivery. - When the Base branch is green (or when
--author <login>scopes the pass to pull requests), selects the lowest-numbered open, non-draft, same-repository pull request targeting the Base branch by a Trusted account (or--author) that is notin-progressand has a Merge conflict or CI red, and takes it through the Repair loop.
- Respects the repository's Command limit on the machine (
- Configurable Self-merge and Run notification: Follows the standard
merge/no-mergeflags andmerge.alwaysUser config setting, plusemail/email-unless-merged/no-emailandemail.always/email.unless_merged, so the operator or cron schedule can choose whether a Fix run automatically performs a Self-merge once green or leaves the pull request ready for review and emails a Run notification. - Failure handling and repeat-Pass prevention: When a Fix run fails or is interrupted, it salvages uncommitted work as
thirdshift: failed fix run (<reason>), pushes, converts the pull request back to a draft (unless it is already mergeable and green and only a requested Self-merge was refused), and prints a Recovery command (thirdshift fix <PR URL>). Because the unattended Pass only selects non-draft pull requests and deduplicates Base branch fixes by tip commit SHA, failed attempts are never retried in an infinite loop, while a targetedthirdshift fix <PR URL or number>accepts draft pull requests and marks them ready once green. - Inbox hand-off and Console
Copy fix command: In the Console, every Ready for review row withCI redorMerge conflictdisplaysthirdshift fix <PR URL>with aCopy fix commandbutton (both on the row and in Command details). Starting a later Command on the same pull request URL takes over an earlier row waiting in Ready for review or Needs you (taken up by a later Command started at <time>), just as a later Command on the same issue does.
User Stories
- As a Day shift operator looking at a Ready for review row in the Console with
Merge conflictorCI red, I want aCopy fix commandbutton on the row and in Command details that copiesthirdshift fix <PR URL>, so that I can start a repair immediately without typing the pull request URL by hand. - As a Day shift operator, I want to run
thirdshift fix <PR URL>orthirdshift fix <PR number>from the Launch directory, so that thirdshift checks out that pull request's head branch in a Worktree and takes it straight through the Repair loop against its Base branch without re-running implementation or code review. - As a Day shift operator, I want a targeted
thirdshift fix <PR URL or number>to work on an open pull request by a Trusted account even when it has no linked closing issue, so that hand-opened pull requests and Review run pull requests can be repaired the same way as Ticket run and Spec run pull requests. - As a Day shift operator, I want conflict Repairs and CI-fix Repairs in a Fix run to receive the pull request's title, body, any linked closing issues, and Trusted account comments from the pull request and its closing issues, so that the agent resolves conflicts and test failures in alignment with the Spec and review discussion.
- As a Day shift operator, I want every Fix run on a pull request to reserve the pull request on
originand label itin-progressuntil the run ends, so that concurrent machines or passes never work on the same pull request at the same time. - As a Day shift operator, I want a failed or interrupted Fix run to commit uncommitted work as
thirdshift: failed fix run (<reason>), push, convert the pull request back to a draft (unless it is already mergeable and green and only Self-merge was refused), and printthirdshift fix <PR URL>as its Recovery, so that no work is lost and the pull request only claims to be ready when the factory stands behind it. - As a Day shift operator retrying a failed Fix run, I want a targeted
thirdshift fix <PR URL or number>to accept an open draft pull request and mark it ready for review once the Repair loop succeeds, so that the Recovery command works directly on the draft pull request left by the failure. - As a Day shift operator, I want a Fix run on a pull request to support
base-fix/no-base-fixandbase.fixin the User config, so that when the pull request hits an Inherited failure on its Base branch, it can start or wait on a Base fix just like a Ticket run. - As a Day shift operator scheduling unattended maintenance, I want
thirdshift fixwith no pull request argument (and optionalbase <branch>/--base <branch>) to run as a Pass that respects the repository's Command limit (UpToTheLimit) and skips cleanly with exit0and no Run notification when nothing needs fixing. - As a Day shift operator scheduling
thirdshift fix, I want the Pass (when--authoris not given) to check the Base branch's latest push CI onoriginfirst, re-running failed jobs once on a first failed attempt and skipping while the re-run runs, so that transient flakes on the Base branch heal without opening a pull request. - As a Day shift operator scheduling
thirdshift fix, I want the Pass to repair a persistently red Base branch by branchingfix-<base>-<short-sha>off the Base branch in a Worktree, running a CI-fix session with the failing check details, opening a pull request titledFix CI on <base>: <check>[, <check>…]targeting the Base branch, and taking it through Delivery (treating all red checks as its own to fix rather than Inherited failures), so that a broken default or release branch is repaired automatically. - As a Day shift operator scheduling
thirdshift fix, I want the Pass to skip opening another Base branch fix pull request if afix-<base>-<short-sha>pull request already exists for that exact Base branch tip commit (whether open and ready,in-progress, or draft after a failed attempt), so that the schedule never opens duplicate pull requests or loops on an unfixable Base branch failure. - As a Day shift operator scheduling
thirdshift fix, I want a Base branch fix that merges to close any openCI red on <base>orbase-fixissue for that branch, so that stale red-branch issues do not linger after the branch is green. - As a Day shift operator scheduling
thirdshift fix, when the Base branch is green (or when--author <login>is given), I want the Pass to select the lowest-numbered open, non-draft, same-repository pull request targeting the Base branch by a Trusted account (or--author) that is notin-progressand has a Merge conflict or CI red, and run a Fix run on it. - As a Day shift operator, I want
merge/no-mergeon the command line andmerge.alwaysin the User config, together withemail/email-unless-merged/no-emailandemail.always/email.unless_merged, to control whether a Fix run (for either a Base branch or a pull request) performs a Self-merge once green or leaves the pull request ready for review and emails a Run notification. - As a Day shift operator viewing the Inbox in
thirdshift statusor the Console, when a Fix run (or any later Command) starts on a pull request that has an earlier row waiting in Ready for review or Needs you, I want the earlier row to leave that group withtaken up by a later Command started at <time>and the Fix run's own row to represent the pull request in Ready for review (when ready) or Needs you (when failed). - As a developer customizing factory workflows, I want
fix-runto ship as a Built-in process (deliveryfollowed byself-merge) that is listed bythirdshift processesand recorded in Command records, Command logs, and the Activity log.
Implementation Decisions
- CLI Surface and Argument Parsing:
thirdshift fixis a top-level Command.- Target argument: optional pull request URL or bare pull request number (
thirdshift fix [<PR URL or number>]). - Pass-only flags:
base <branch>/--base <branch>(naming the Base branch when no pull request is given; rejected with an argument error if combined with a pull request target, since a pull request defines its own Base branch) and--author <login>/author <login>(filtering open pull requests by author in Pass mode; rejected when combined with a pull request target). - Shared execution flags:
merge/--merge,no-merge/--no-merge,base-fix/--base-fix,no-base-fix/--no-base-fix,harness <name>,model <name>,effort <level>,email [<address>],email-unless-merged [<address>], andno-email.
- Built-in Process (
fix-run):- Ships as a Built-in process with steps
deliveryfollowed byself-mergeon the pull request's Worktree. - Recorded as a Fix run in Command records, Command logs, the Activity log, and Run notifications.
- Ships as a Built-in process with steps
- Pull Request Reservation and Worktree Acquisition:
- Reuses the pull request reservation mechanism (
refs/thirdshift/reservations/<pr-number>onoriginplus thein-progresslabel on the pull request) for the duration of a pull request Fix run. - Refuses pull requests from outside the repository at
origin, closed or merged pull requests, and pull requests authored by untrusted accounts. - A targeted
thirdshift fix <PR URL or number>accepts both ready and draft open pull requests; the unattended Pass only selects non-draft open pull requests.
- Reuses the pull request reservation mechanism (
- Repair Context Bundle:
- Writes a worktree context file containing the pull request's title, body, any linked closing issues, and Trusted account comments on the pull request and its linked closing issues.
- Conflict Repair, CI-fix Repair, and Foreign-commit review Repair Session prompts read this context file when the Delivery is running on a pull request without a standalone Issue branch issue file.
- Delivery and Failure Salvage:
- Pull request Fix runs enter Delivery's publication and Repair loop directly (
merge Base branch→ conflict Repair →push→mark ready→ CI watch → CI-fix Repair → optional Base fix → optional Self-merge). - If the Fix run fails or is interrupted, uncommitted work is committed with
thirdshift: failed fix run (<reason>)and pushed, the pull request is converted back to a draft unless it is already mergeable and green and only Self-merge was refused, and Recovery offersthirdshift fix <PR URL>(preserving the command's flags).
- Pull request Fix runs enter Delivery's publication and Repair loop directly (
- Base Branch Monitoring and Repair in Pass Mode:
- When
thirdshift fixruns as a Pass without--author, it checks the Base branch onoriginbefore searching open pull requests. - Uses the cross-host Base branch CI reservation ref to inspect the latest push workflow run and check runs on the Base branch tip commit.
- If the latest workflow run on the Base branch tip failed on attempt
1with rerunnable failed jobs, it requestsgh run rerun <id> --failedand finishes the pass as skipped so transient flakes do not spin up a session. - If checks on the Base branch tip remain red (attempt > 1, or non-rerunnable check failure) and no pull request from
fix-<base>-<short-sha>already exists (open or draft) in the repository, the Fix run creates branchfix-<base>-<short-sha>from the Base branch tip in a Worktree, runs a CI-fix session with the failing check names and URLs, opens a pull request titledFix CI on <base>: <check>[, <check>…]targeting<base>, and runs Delivery with Base fix inheritance disabled (every red check is its own to fix). - When that pull request merges via Self-merge, thirdshift closes any open
CI red on <base>orbase-fixissue covering<base>.
- When
- Inbox Hand-off and Console
Copy fix command:- In Inbox reading,
superseded_atmatches both(repository, issue.number)and(repository, pull_request_url), so starting a Fix run (or Review run) on a pull request moves an earlier waiting row for that pull request out of Ready for review or Needs you withtaken up by a later Command started at <time>. - In the Console and status presentation, a row in Ready for review whose
pull_requestis present and that hasci == Redormerge_conflict == trueexposesfix_command(thirdshift fix <PR URL>), rendered in both the Inbox row template and the Command details (Peek) template as<code>thirdshift fix <PR URL></code> <button type="button" data-copy-cli="thirdshift fix <PR URL>">Copy fix command</button>.
- In Inbox reading,
Testing Decisions
- Good tests verify observable external behavior: exit codes, stdout/stderr progress and Recovery lines, Git branch and commit state on
origin, GitHub pull request readiness/draft state, labels, comments and merges via fakegh, Command records, Command logs, Activity log entries, Run notifications, and rendered Console HTML/DOM behavior. - Primary seam — CLI + Fake Boundary (
Scenario::run):- Test targeted
thirdshift fix <PR URL or number>,thirdshift fixPass mode for pull requests, andthirdshift fixPass mode for a red Base branch through the binary entry point against real Git repositories and fakegh, fake Harnesses, and fake Resend (following the patterns intests/review_run.rs,tests/review_pass.rs,tests/base_fix.rs, andtests/status.rs).
- Test targeted
- Secondary seam — Console HTTP and Browser (
tests/console.rsandconsole/):- Test
Copy fix commandrendering and clipboard interaction on Ready for review rows withCI redorMerge conflictand in Command details (Peek), and verify Inbox row hand-off when a Fix run starts on a waiting pull request.
- Test
Out of Scope
- Starting a Fix run directly via a POST action button in the Console (split out into Console: start a Fix run from a Ready for review row #1788, to follow the Console HTTP API in Spec: the Fleet in the Console #1142 / ADR 0026).
- Separate CLI flags for conflict-only or CI-only repair (a Fix run always runs the unified Repair loop so every conflict resolution has its CI watched before completion).
Further Notes
- Refined from Spec: Fix run #1784 during
/grill-with-docs.
Sub-issues
Collapse Sub-issuesSub-issues
Loading 4 sub-issues
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
[-]add thirdshift fix run if we don't already have it[/-][+]Spec: Fix run[/+]