---
site/architecture/index.html | 2 +-
site/how-it-works/index.html | 2 +-
site/index.html | 2 +-
src/main.rs | 4 ++--
src/setup.rs | 1 +
tests/ci.rs | 2 +-
tests/setup.rs | 1 +
7 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/site/architecture/index.html b/site/architecture/index.html
index 814ac82c0..3a0ef0add 100644
--- a/site/architecture/index.html
+++ b/site/architecture/index.html
@@ -586,7 +586,7 @@ Architecture
Once a Pickup run, an Architect run or a Security run knows its repository, it replaces that kind's last-fired time under the repository's log folder, before launch checks or the Command limit. Repeated skips update the time without adding Activity log lines. thirdshift status, thirdshift cronjobs and their Console views read the same per-repository times; no reader starts work. A Custom process started with no issue, and neither an Issue-branch nor a Spec-branch worktree, counts toward the Command limit, runs beside other Passes up to it, takes no lock of a kind, and does not record a last-fired time. A file that declares either branch worktree is refused when no issue is given, before the Command limit.
A Pass takes no Issue URL, so your operating system's scheduler can start it; thirdshift never schedules itself. A Pass is skipped while its repository is at its Command limit, [pass] command_limit, 1 by default: every live Command on the repository on the machine counts, a Ticket run started on an Issue URL included, but only a Pass is skipped. Passes of different kinds share a repository up to the limit, but never two Architect runs or two Security runs at once: each of those holds a lock of its kind and a review worktree of its own, and reserves the plan or fix it dispatches on origin, as a Pickup run reserves its Ready issue. A Pass with nothing to do is skipped, not failed. Architect and Security runs wait while a Ready issue is open, so work you shaped goes first. A Custom process started with no issue is a Pass for that rule and does not wait on a Ready issue or an Architect idea, unless the file declares either branch worktree: that is refused before any session, rather than skipped. One started with an issue is not a Pass. Your scheduler can start Architect runs every few minutes and Security runs on a schedule, with fixing allowed.
A Fix run, thirdshift fix <PR URL or number>, targets an explicit PR; with no PR target it is a Pass sharing the repository up to its Command limit. Without --author, it first checks the Base branch's origin tip. A failed first push attempt gets one failed-jobs re-run, then PR selection continues without waiting. Persistent or non-rerunnable failures get a CI-fix session on fix-<base>-<short-sha> and a repair PR targeting the Base branch; that Fix run ends the Pass. All red checks are its own, existing repair PRs prevent duplicates, and merge and email policy apply. Self-merge closes the Base branch's CI-red reports and Base fix issues.
- The Pass otherwise searches open, non-draft, same-repository PRs by Trusted accounts, giving Merge conflicts and current-head CI red priority in ascending PR number. behind <n> or the repository’s fix.behind setting adds PRs at least that many commits behind, furthest behind first. The Pass skips a PR held only by a Sign-off hold or whose latest Run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or settled CI red apart from the Sign-off hold keeps the PR eligible. An explicit Fix run facing a Sign-off hold leaves the PR ready for review and names the check and label. Optional base <branch> and --author <login> scope that search. Selection skips in-progress PRs and passes over head branches checked out locally, naming the PR and occupying path on stderr. When none can be taken, the Activity log skip includes those reasons without recording a failed Fix run. Occupied checkouts remain intact; an explicit PR target still fails and names the occupying path. Selection reserves and rechecks candidates before dispatch. Busy reservations pass through to the next candidate. Its fix-run Built-in process is delivery → self-merge, using the existing PR's head branch and Base branch without implementation or initial code review. It holds an origin reservation and in-progress through Repair and failure preservation, and records its own Command log and Run notification. Self-merge requires recorded agent authorship or review of the exact adopted head by thirdshift's GitHub account; completed Ticket, Spec and Base CI Deliveries record their delivered heads too. Absent that evidence, the repaired PR stays ready for review, preserving ADR 0004. Skips record an Activity log reason when it changes and send no notification. Later Passes skip PRs left as drafts. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state.
+ The Pass otherwise searches open, non-draft, same-repository PRs by Trusted accounts, giving Merge conflicts and current-head CI red priority in ascending PR number. behind <n> or the repository’s fix.behind setting adds PRs at least that many commits behind, furthest behind first. The Pass skips a PR held only by a Sign-off hold or whose latest run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or settled CI red apart from the Sign-off hold keeps the PR eligible. An explicit Fix run facing a Sign-off hold leaves the PR ready for review and names the check and label. Optional base <branch> and --author <login> scope that search. Selection skips in-progress PRs and passes over head branches checked out locally, naming the PR and occupying path on stderr. When none can be taken, the Activity log skip includes those reasons without recording a failed Fix run. Occupied checkouts remain intact; an explicit PR target still fails and names the occupying path. Selection reserves and rechecks candidates before dispatch. Busy reservations pass through to the next candidate. Its fix-run Built-in process is delivery → self-merge, using the existing PR's head branch and Base branch without implementation or initial code review. It holds an origin reservation and in-progress through Repair and failure preservation, and records its own Command log and Run notification. Self-merge requires recorded agent authorship or review of the exact adopted head by thirdshift's GitHub account; completed Ticket, Spec and Base CI Deliveries record their delivered heads too. Absent that evidence, the repaired PR stays ready for review, preserving ADR 0004. Skips record an Activity log reason when it changes and send no notification. Later Passes skip PRs left as drafts. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state.
The Fix-Pass-only word merge-base-fix grants Self-merge only to a repair newly authored by the Base branch CI step, through the usual Delivery and Self-merge gates. Selected PRs keep the ordinary merge / no-merge and merge.always policy. Thus thirdshift fix base master no-merge merge-base-fix merges a new Base branch repair and leaves selected feature PRs ready for review even when merge.always = true. Existing repair PRs selected later or retried gain no permission from this word or their branch name; merging one requires the usual merge policy, such as targeted fix <PR> merge. Omission, --author scoping and Ticket-run base-fix behavior are unchanged.
A Fix Pass checks every linked closing issue before and after reserving the PR. An in-progress Claim on a Spec or standalone Ticket run's issue, including on another host, makes it skip the PR and name the claimed issue on stderr. It can adopt the PR on a later Pass after the Claim ends. Unreadable links or labels fail closed; explicit PR targets keep their existing behavior. Once the Pass has selected a pull request, an untrusted author of a linked closing issue, or any title or body edit by an account that is not a Trusted account, stops the Fix run before the issue is used and does not take the next candidate.
Pending or re-running Base branch checks, an occupied CI reservation, or an existing repair branch or PR skip only Base branch maintenance and leave PR selection available. Stderr and the Activity log record the reason, including when no eligible PR is found. Failed opening Base CI sessions publish preserved work as draft repair PRs with a Fix Recovery command. An existing repair branch prevents another attempt if PR creation failed.
diff --git a/site/how-it-works/index.html b/site/how-it-works/index.html
index d7eb6f811..0641b5110 100644
--- a/site/how-it-works/index.html
+++ b/site/how-it-works/index.html
@@ -136,7 +136,7 @@ How thirdshift works
Self-merge requires recorded agent authorship or review of the adopted head. Without it, a Fix Pass, even with merge, or a targeted Fix run asked to merge only by merge.always, still repairs the PR and checks CI, then finishes successfully Ready for review (exit 0) and logs the hold. An explicit thirdshift fix <PR> merge still fails with the hold and leaves the repaired PR ready for review.
With no PR target, thirdshift fix [base <branch>] [--author <login>] is a Pass. Without --author, it first checks the Base branch's origin tip: a failed first push attempt gets one failed-jobs re-run, then PR selection continues without waiting. Persistent or non-rerunnable failures get a CI-fix session on fix-<base>-<short-sha> and a repair PR targeting the Base branch, treating every red check as its own; that Fix run ends the Pass. Existing PRs from that branch prevent duplicates, failed drafts included. Merge and email policy apply, and Self-merge closes the Base branch's CI-red reports and Base fix issues.
Use thirdshift fix base master no-merge merge-base-fix to Self-merge only a newly authored Base branch CI repair and leave selected PRs ready for review, even with merge.always = true. merge-base-fix (also --merge-base-fix) changes that new repair's merge permission alone; the usual Delivery and Self-merge gates still apply. Selected PRs follow merge, no-merge and the User config. An existing repair PR selected later or retried gains no permission from its branch name or this word; request fix <PR> merge explicitly. The word is rejected outside a Fix Pass. Omission preserves existing behavior, --author still skips Base branch maintenance, and a Ticket run's base-fix still always merges.
- Otherwise the Pass selects an eligible open, non-draft, same-repository PR targeting the selected Base branch. A Merge conflict or CI red on the current head comes first, lowest PR number first. With behind <n> or the repository’s fix.behind setting, PRs at least that many commits behind also qualify, furthest behind first. The Pass skips a PR held only by a Sign-off hold or whose latest Run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or other settled CI red keeps it eligible, and the held check stays out of the Repair's failure list. It skips untrusted authors and in-progress PRs, passing over busy reservations and head branches already checked out locally. Local occupancy reasons name the PR and occupying path on stderr and, when no candidate can be taken, in the Activity log. The check preserves occupied worktrees; an explicit PR target still fails and names the occupying path. At the Command limit or with no eligible PR left, it records a skip, exits successfully and sends no Run notification. Later Passes skip PRs left as drafts. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state.
+ Otherwise the Pass selects an eligible open, non-draft, same-repository PR targeting the selected Base branch. A Merge conflict or CI red on the current head comes first, lowest PR number first. With behind <n> or the repository’s fix.behind setting, PRs at least that many commits behind also qualify, furthest behind first. The Pass skips a PR held only by a Sign-off hold or whose latest run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or other settled CI red keeps it eligible, and the held check stays out of the Repair's failure list. It skips untrusted authors and in-progress PRs, passing over busy reservations and head branches already checked out locally. Local occupancy reasons name the PR and occupying path on stderr and, when no candidate can be taken, in the Activity log. The check preserves occupied worktrees; an explicit PR target still fails and names the occupying path. At the Command limit or with no eligible PR left, it records a skip, exits successfully and sends no Run notification. Later Passes skip PRs left as drafts. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state.
A Fix Pass checks every linked closing issue before and after reserving the PR. An in-progress Claim on a Spec or standalone Ticket run's issue, including on another host, makes it skip the PR and name the claimed issue on stderr. It can adopt the PR on a later Pass after the Claim ends. Unreadable links or labels fail closed; explicit PR targets keep their existing behavior. Once the Pass has selected a pull request, an untrusted author of a linked closing issue, or any title or body edit by an account that is not a Trusted account, stops the Fix run before the issue is used and does not take the next candidate.
A Fix run's Self-merge needs recorded agent authorship or review covering the exact adopted head, written by the GitHub account thirdshift acts as. Completed Ticket, Spec and Base CI Deliveries record their delivered heads for later Fix runs. Without that evidence the repaired PR stays ready for review; run thirdshift review <PR URL> before retrying Self-merge.
Pending or re-running Base branch checks, an occupied CI reservation, or an existing repair branch or PR skip only Base branch maintenance and leave PR selection available. Stderr and the Activity log record the reason, including when no eligible PR is found. Failed opening Base CI sessions publish preserved work as draft repair PRs with a Fix Recovery command; an existing repair branch also prevents another attempt if PR creation failed.
diff --git a/site/index.html b/site/index.html
index cf43821b9..60d3d2009 100644
--- a/site/index.html
+++ b/site/index.html
@@ -123,7 +123,7 @@ Your issues become pull requests overnight.
Review Passes (review --author) and Fix Passes skip release-* pull requests targeting main, leaving their version-only heads to the Release run. Explicit thirdshift fix <pr-url> --no-merge --no-base-fix still repairs those pull requests.
Review retries recover clean retained worktrees with verified ownership and committed fixes above the same captured PR head. Author Passes skip other local conflicts, notify once per state and continue to later waiting pull requests. An explicit PR URL still fails with preservation advice.
Review runs and pull-request Custom processes record their target PR URL and title before the first session starts. It appears in thirdshift status and the Command log while the run is live, and Command log and Session trace pages show the selected Command's GitHub issue or pull request link and title below the page heading (including a Pickup or Pass run's opened pull requests). Compact Working rows, including Overview, show live Fix and Review targets as clickable PR #number links beside the repository and run type, on desktop and phone, locally and across the Fleet. Explicit and Pass-selected targets appear alike. A Base branch CI repair shows its exact Base branch before publication and keeps it beside the PR link afterwards; older records without a target keep their Command label.
- thirdshift fix <PR URL or number> takes an open pull request by a Trusted account, ready or draft, straight through Delivery and the Repair loop against its own Base branch. With no PR target, thirdshift fix [base <branch>] [--author <login>] [behind <n>] is a Pass taking eligible ready PRs with a Merge conflict or CI red first, lowest number first. behind <n> or the repository’s fix.behind setting also admits PRs at least that many commits behind, furthest behind first. A Fix Pass skips a PR held only by a Sign-off hold or whose latest Run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or settled CI red apart from the Sign-off hold keeps the PR eligible. An explicit Fix run facing a Sign-off hold leaves the PR ready for review and names the check and label. The Pass skips head branches checked out locally, passing over them with the PR URL and occupying path on stderr. It skips cleanly at the Command limit or when none can be taken, recording occupancy reasons in the Activity log. An explicit PR target still fails and names the occupying worktree. A Fix run skips implementation and initial code review, reserves the PR until it ends, and supplies Repairs with trusted PR and linked closing-issue context. It stops before using a linked closing issue, including when started as a Pass, unless that issue's author is a Trusted account and no account that is not one has edited its title or body. Add merge for Self-merge or base-fix for inherited failures; the usual User config defaults apply. Self-merge needs recorded agent review of the adopted head; without it a Fix Pass, or a targeted Fix run asked to merge only by merge.always, repairs the PR and finishes successfully Ready for review, logging the hold. An explicit thirdshift fix <PR> merge still fails with the hold and leaves the repaired PR ready. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state. Other Delivery failures preserve work, draft the PR and offer a Fix run retry. Fix runs
+ thirdshift fix <PR URL or number> takes an open pull request by a Trusted account, ready or draft, straight through Delivery and the Repair loop against its own Base branch. With no PR target, thirdshift fix [base <branch>] [--author <login>] [behind <n>] is a Pass taking eligible ready PRs with a Merge conflict or CI red first, lowest number first. behind <n> or the repository’s fix.behind setting also admits PRs at least that many commits behind, furthest behind first. A Fix Pass skips a PR held only by a Sign-off hold or whose latest run on this machine ended at a Self-merge check hold, even when it meets the behind threshold. A Merge conflict or settled CI red apart from the Sign-off hold keeps the PR eligible. An explicit Fix run facing a Sign-off hold leaves the PR ready for review and names the check and label. The Pass skips head branches checked out locally, passing over them with the PR URL and occupying path on stderr. It skips cleanly at the Command limit or when none can be taken, recording occupancy reasons in the Activity log. An explicit PR target still fails and names the occupying worktree. A Fix run skips implementation and initial code review, reserves the PR until it ends, and supplies Repairs with trusted PR and linked closing-issue context. It stops before using a linked closing issue, including when started as a Pass, unless that issue's author is a Trusted account and no account that is not one has edited its title or body. Add merge for Self-merge or base-fix for inherited failures; the usual User config defaults apply. Self-merge needs recorded agent review of the adopted head; without it a Fix Pass, or a targeted Fix run asked to merge only by merge.always, repairs the PR and finishes successfully Ready for review, logging the hold. An explicit thirdshift fix <PR> merge still fails with the hold and leaves the repaired PR ready. A closing-issue trust stop keeps unpublished Repair work local and leaves the PR in its current state. Other Delivery failures preserve work, draft the PR and offer a Fix run retry. Fix runs
A Fix Pass checks every linked closing issue before and after reserving the PR. An in-progress Claim on a Spec or standalone Ticket run's issue, including on another host, makes it skip the PR and name the claimed issue on stderr. It can adopt the PR on a later Pass after the Claim ends. Unreadable links or labels fail closed; explicit PR targets keep their existing behavior. Once the Pass has selected a pull request, an untrusted author of a linked closing issue, or any title or body edit by an account that is not a Trusted account, stops the Fix run before the issue is used and does not take the next candidate.
thirdshift fix base master no-merge merge-base-fix lets a newly authored Base branch CI repair Self-merge through the usual gates while leaving selected PRs ready for review, even with merge.always = true. The Fix-Pass-only merge-base-fix word changes only that new repair's merge permission; selected PRs keep following merge, no-merge and the User config. Existing repair PRs gain no permission from their branch names or this word; use an explicit targeted fix <PR> merge to merge one. Omission keeps the existing policy, --author still skips Base branch CI, and a Ticket run's own base-fix still always merges. Fix Pass merge policy.
Without --author, a Fix Pass first checks Base branch CI on origin. A failed first push attempt gets one failed-jobs re-run, then PR selection continues without waiting. Pending or re-running Base checks, an occupied CI reservation, or an existing repair branch or PR skip only Base branch maintenance; stderr and the Activity log record the reason. Persistent or non-rerunnable failures get a CI-fix session on fix-<base>-<short-sha> and a repair PR targeting the Base branch, with every red check its own to fix; that Fix run ends the Pass. Failed opening sessions publish preserved work as draft repair PRs with a Fix Recovery command. An existing repair branch or PR prevents duplicates, including failed drafts. Completed Ticket, Spec and Base CI Deliveries record their exact agent-authored or reviewed heads for later Fix Self-merge. Merge and email flags and User config apply; Self-merge also closes the Base branch's CI-red reports and Base fix issues.
diff --git a/src/main.rs b/src/main.rs
index f63d41535..44aaf2a83 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -125,6 +125,7 @@ mod scoring;
mod scratch;
#[cfg(target_os = "linux")]
mod security;
+#[cfg(target_os = "linux")]
mod self_merge_check;
#[cfg(target_os = "linux")]
mod session;
@@ -239,8 +240,7 @@ usage: thirdshift [--trust-author ] Run the factory on the is
Start from the issue's clone. The Base branch is the branch checked out; positive issue numbers use origin, even in nested directories.
An issue with sub-issues starts a Spec run: its Tickets merge into a Spec branch; merge on a Spec merges the Spec PR. is one quoted free-text argument.
Shared options (before or after the Issue URL or number, or after a Pass command; -- prefixes accepted, once each, without opposites):
- merge / no-merge Merge the pull request / leave it for review
- self-merge-check / no-self-merge-check Enable / disable the repository's Self-merge check for this Command
+ merge / no-merge Merge the pull request / leave it for review (self-merge-check / no-self-merge-check: use the repository's check)
email [] / no-email Send a Run notification / skip it (email-unless-merged []: unless merged)
base-fix / no-base-fix Allow / forbid fixing inherited CI failures
parallel Run up to Tickets at once (Spec runs; default 3)
diff --git a/src/setup.rs b/src/setup.rs
index f7ef13463..412d7a458 100644
--- a/src/setup.rs
+++ b/src/setup.rs
@@ -1457,6 +1457,7 @@ launch_directories = []
[merge]
always = true
label_from = { \"Acme/Widgets\" = [\"maintainer\"] }
+self_merge_check = {}
[base]
fix = true
diff --git a/tests/ci.rs b/tests/ci.rs
index 41ec5054e..da94b5fc3 100644
--- a/tests/ci.rs
+++ b/tests/ci.rs
@@ -162,7 +162,7 @@ if [[ "${1-} ${2-}" == "pr view" && "$*" == *",headRefOid,isCrossRepository"* ]]
if [[ -f "$marker" && ! -f "$marker.removed" ]]; then
"$delegate" fake labels 1 '[]'
: > "$marker.removed"
- elif [[ " $* " == *",headRefOid,isCrossRepository,labels "* ]]; then
+ elif [[ " $* " == *",headRefOid,isCrossRepository,body,labels "* ]]; then
: > "$marker"
fi
fi
diff --git a/tests/setup.rs b/tests/setup.rs
index 66837b43c..247596687 100644
--- a/tests/setup.rs
+++ b/tests/setup.rs
@@ -594,6 +594,7 @@ fn completing_an_existing_file_replaces_it_atomically_keeps_permissions_and_then
waiting_line_minutes = 2 # waiting\n\
[merge]\nalways = true # merge\n\
label_from = { 'Acme/Widgets' = ['maintainer'] } # merge-label approval\n\
+ self_merge_check = {} # no check\n\
[pickup]\nwait_minutes = 60 # time to attach Tickets\n";
let path = scenario.user_config_is(original);
fs::set_permissions(&path, fs::Permissions::from_mode(0o640)).unwrap();
From d17f1275f33242de300f5f63a58070d243778f87 Mon Sep 17 00:00:00 2001
From: Jacob Stephens
Date: Fri, 4 Dec 2026 11:39:40 -0500
Subject: [PATCH 09/27] Resolve Base branch Self-merge policy links and clarify
overrides (#2423)
---
docs/guide.md | 1 +
site/docs/index.html | 1 +
src/git.rs | 29 +++++++++++++++++++++-
src/main.rs | 2 +-
src/self_merge_check.rs | 12 ++++-----
tests/ci.rs | 15 +++++++++--
tests/command_surface.rs | 15 +++++++++++
tests/self_merge_check.rs | 52 +++++++++++++++++++++++++++++++++++++++
8 files changed, 117 insertions(+), 10 deletions(-)
diff --git a/docs/guide.md b/docs/guide.md
index 5eab1b63e..6c3650848 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -2922,6 +2922,7 @@ The first word is the executable and the remaining words are its arguments.
Use shell quoting to group words. A relative path names a repository script.
Immediately before the check, thirdshift reads the committed script at the tip
of the Base branch on `origin`, copies it to Command scratch and runs that copy.
+A symbolic link must resolve to a file in that same commit.
To change the rule, merge a pull request that updates the script. Edits on the
Issue branch have no effect on the check judging that branch. If the script is
absent from the Base branch, the hold reason reports the missing path.
diff --git a/site/docs/index.html b/site/docs/index.html
index 5b671ebee..8688cba9d 100644
--- a/site/docs/index.html
+++ b/site/docs/index.html
@@ -2892,6 +2892,7 @@
Use shell quoting to group words. A relative path names a repository script.
Immediately before the check, thirdshift reads the committed script at the tip
of the Base branch on origin, copies it to Command scratch and runs that copy.
+A symbolic link must resolve to a file in that same commit.
To change the rule, merge a pull request that updates the script. Edits on the
Issue branch have no effect on the check judging that branch. If the script is
absent from the Base branch, the hold reason reports the missing path.