Repository navigation
feat(bin): add in-house merge queue with landing-crew briefs - #38
Conversation
State the batch-landing policy in AGENTS.md section 7, add the batch procedure to the ship-landing skill, scaffold the landing crew contract with fm-brief.sh --landing-crew, and make docs/merge-queue.md the owner of the queue mechanics and rationale.
A batch can land as one pull request; after a squash or rebase merge each member pull request is closed with a comment naming the batch PR and the default-branch commit. Members must be mergeable at lease time, and every candidate is built on the default branch after the latest merge.
Reviewer's GuideThis PR adds an in-house merge queue centered on a lease-gated landing crew: it builds immutable candidate branches from freshly fetched default-branch state, uses one admitted CI run as shared candidate proof, and lands members through guarded batch-PR or unchanged-head merges. The implementation is primarily procedural documentation plus a new Sequence diagram for lease-gated merge queue landingsequenceDiagram
participant Firstmate
participant Crew as LandingCrew
participant Forge
participant CI
participant Merge as GuardedMerge
Firstmate->>Crew: Name member PR heads in landing order
Crew->>Forge: git fetch origin and build fm/batch-n
Crew->>Crew: Drop moved or conflicting members
Crew-->>Firstmate: needs-decision batch-n-lease
Firstmate->>CI: Check concurrent full-run cap
Firstmate-->>Crew: Grant one push lease for exact head
Crew->>Forge: git push origin fm/batch-n
Forge->>CI: Run full CI for candidate
CI-->>Firstmate: Candidate result
Firstmate->>Merge: Guarded merge of batch PR or unchanged member heads
Merge->>Forge: Land approved changes
Flow diagram for merge queue candidate constructionflowchart TD
A[Freshly fetch origin default branch] --> B[Create fm/batch-n]
B --> C[Merge named member heads in landing order]
C --> D{Member head unchanged?}
D -- No --> E[Drop member and report head moved]
D -- Yes --> F{Merge conflicts?}
F -- Yes --> G[git merge --abort and drop member]
F -- No --> H[Keep member in candidate]
E --> I[Request firstmate lease]
G --> I
H --> I
I --> J{Lease granted under CI cap?}
J -- No --> I
J -- Yes --> K[Push candidate once]
K --> L[Candidate CI run proves combination]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65434142e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| 6. Close out: after a batch pull request squash-merges, close each member pull request with `Landed on main in batch PR #<n> (<sha>)`, because the forge still shows every member open; skip this when the project merges with merge commits, since the forge then marks the members merged. | ||
| Tear down each member's task once its pull request is merged or closed as landed, and never the crew on a batch pull request's merged notification, which is informational; only the crew's own `done:` line and report end it. |
There was a problem hiding this comment.
Recheck member heads before closing their pull requests
If a contributor pushes to a member branch after the pre-merge check but before this close-out step, the batch contains only the previously named head, yet this procedure closes the updated pull request with a false “Landed” comment and tears down its task. Re-read each member's head after the batch merge and only close it when it still equals the head included in the batch; moved members must remain open and return to the queue.
AGENTS.md reference: AGENTS.md:L238-L239
Useful? React with 👍 / 👎.
| Immediately before merging it, confirm for every member that its head still equals its named head, no captain hold is open on its task, its review-ledger generation passes with no unreleased hold, and its own required checks are green or a current explicit captain waiver names the check; drop a member that fails and have the crew rebuild without it. | ||
| Then merge the batch pull request once under the crew's task id with `bin/fm-pr-review.sh merge <crew-task> <batch-url>` when the reviewed-head handoff is required or the away-posture record exists, and otherwise `bin/fm-pr-merge.sh <crew-task> <batch-url>`; that records the batch pull request on the crew's task and arms its merge poll. |
There was a problem hiding this comment.
Revalidate the candidate base immediately before merging
When an unrelated change lands on the default branch after the candidate's green run, this checklist verifies member heads and ledgers but never verifies that the candidate's recorded base is still the current default head. Because the new preconditions explicitly allow projects without an up-to-date-branch requirement, the guarded merge can then land the candidate against a combination CI never tested; compare the current default SHA with the candidate base immediately before merging and rebuild on any mismatch.
AGENTS.md reference: AGENTS.md:L255-L256
Useful? React with 👍 / 👎.
| The crew pushes with a plain `git push origin fm/batch-<n>`. | ||
| Unless the project lands through member merges, Firstmate then opens the batch pull request from `fm/batch-<n>`, and the landing crew never opens, edits, or merges any pull request. | ||
| The batch pull request's `pull_request` CI run is the one the push lease admitted, so there is no separate unadmitted run and the lease covers the run that proves the batch. | ||
| Firstmate finds the candidate's run with `gh-axi run list --branch fm/batch-<n>` and accepts it as proof only when the run's head commit equals the leased head and every full-run job passed. |
There was a problem hiding this comment.
Admit the action that actually starts candidate CI
For the documented batch-PR path, the full run starts only when Firstmate opens the pull request, but capacity is checked earlier when the crew requests permission to push. A default-branch run can occupy the last slot between those actions, and opening the PR then exceeds the configured cap; moreover, a push-triggered full workflow would create an additional unadmitted run. Recheck capacity immediately before the PR-opening action and require queue preconditions to exclude an independent full push workflow.
AGENTS.md reference: AGENTS.md:L255-L255
Useful? React with 👍 / 👎.
| `bin/fm-pr-merge.sh` accepts the crew's next batch URL by itself only once the previous batch pull request's merge has been notified, so after a batch pull request that was refused or abandoned without merging, Firstmate first rebinds the crew with `bin/fm-pr-check.sh <crew-task> <next-batch-url>`, otherwise the merge refuses with `bound to <old>, not <new>`. | ||
| On 2026-10-20 bbchat's batch pull request https://github.com/twilwa/bbchat/pull/404 carried three members and merged green on its first run. | ||
| A squash merge leaves the member heads unreachable from the default branch, so the forge keeps every member pull request open. | ||
| After it, Firstmate closes each member with `gh-axi pr close <number> --comment "Landed on main in batch PR #<n> (<sha>)"` and tears down the member tasks. |
There was a problem hiding this comment.
Close each member by URL or explicit repository
When Firstmate runs this command from its own repository rather than the member project's clone, the bare pull-request number is resolved against the current repository, so the command can fail or close an unrelated pull request with the same number. The checked gh pr close --help confirms that -R/--repo selects another repository and that a full URL is accepted; use the already-recorded member URL or pass the owning repository explicitly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Hey - I've found 10 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".agents/skills/ship-landing/SKILL.md" line_range="41-42" />
<code_context>
+ Immediately before merging it, confirm for every member that its head still equals its named head, no captain hold is open on its task, its review-ledger generation passes with no unreleased hold, and its own required checks are green or a current explicit captain waiver names the check; drop a member that fails and have the crew rebuild without it.
</code_context>
<issue_to_address>
**Changed members still land**
When a member's head or guard state changes after the preflight but before the batch PR merges, the batch merge checks the crew and batch PR, not each member's current state, so it still lands a member that is now held or red. If the head moves, the batch can merge the older snapshot and close the newer member PR, leaving its current changes unlanded.
Make member-head and guard validation atomic with the batch merge, and refuse the merge so the candidate can be rebuilt whenever a member changes.
Also at `docs/merge-queue.md:86-88`.
</issue_to_address>
### Comment 2
<location path=".agents/skills/ship-landing/SKILL.md" line_range="46" />
<code_context>
+ If anything outside the batch lands on the default branch mid-batch, stop and put the unmerged members into a new candidate.
</code_context>
<issue_to_address>
**Stale-base proof can land**
When the default branch advances after candidate CI passes but before the batch PR merges, the batch PR need not be up to date, and the instruction to stop when an outside landing is noticed does not serialize that check with merging. The merge can therefore land a combination that the candidate run did not prove.
Prevent the merge when the default branch has advanced since the candidate was tested, and rebuild and rerun proof against the new base.
Also at `docs/merge-queue.md:33`, `docs/merge-queue.md:100`, `.agents/skills/ship-landing/SKILL.md:47`.
</issue_to_address>
### Comment 3
<location path=".agents/skills/ship-landing/SKILL.md" line_range="40-42" />
<code_context>
+ Primarily, initialize the batch pull request's review ledger under the landing crew's task id with `bin/fm-pr-review.sh init <crew-task> <batch-url>`.
</code_context>
<issue_to_address>
**Review gate blocks landing**
When the batch uses reviewed-head handoff or away posture and its new review generation has pending gates, `init` creates a generation without checkpoints or final disposition, while `fm-pr-review.sh merge` runs the readiness gate and refuses when required reviews, dispositions, or attestations are missing. The batch does not land.
Document and complete the required review checkpoints, dispositions, and attestations after initialization and before invoking the guarded merge.
Also at `docs/merge-queue.md:85-88`.
</issue_to_address>
### Comment 4
<location path=".agents/skills/ship-landing/SKILL.md" line_range="47" />
<code_context>
+6. Close out: after a batch pull request squash-merges, close each member pull request with `Landed on main in batch PR #<n> (<sha>)`, because the forge still shows every member open; skip this when the project merges with merge commits, since the forge then marks the members merged.
</code_context>
<issue_to_address>
**Rebase leaves member PRs open**
When a batch PR is merged with GitHub rebase-and-merge, rebase rewrites the commits, so the original member heads are not marked merged. The close-out instructions only close member PRs after squash merges, leaving them open and eligible for another batch.
Close each member PR as landed after a rebase merge as well as after a squash merge, then tear down its task.
Also at `docs/merge-queue.md:93-95`, `.agents/skills/ship-landing/SKILL.md:48`.
</issue_to_address>
### Comment 5
<location path=".agents/skills/ship-landing/SKILL.md" line_range="47-48" />
<code_context>
+6. Close out: after a batch pull request squash-merges, close each member pull request with `Landed on main in batch PR #<n> (<sha>)`, because the forge still shows every member open; skip this when the project merges with merge commits, since the forge then marks the members merged.
</code_context>
<issue_to_address>
**Interrupted closeout leaves work open**
When firstmate stops after the batch PR merges but before all member PRs are closed, the remaining member PRs stay open and their tasks are not torn down; an open PR can also be selected in a later batch and land the same changes again.
Make member closeout resumable and idempotent, recording and completing each PR's closure and task teardown.
Also at `docs/merge-queue.md:94`.
</issue_to_address>
### Comment 6
<location path=".agents/skills/ship-landing/SKILL.md" line_range="48" />
<code_context>
+ Tear down each member's task once its pull request is merged or closed as landed, and never the crew on a batch pull request's merged notification, which is informational; only the crew's own `done:` line and report end it.
</code_context>
<issue_to_address>
**Updated member work gets closed**
When a member PR receives a new commit after the pre-merge head check but before Firstmate closes it as landed, the batch contains the named head, not a later push. Firstmate closes the member PR after merging without rechecking its head, so a push between the pre-merge check and close leaves those newer commits unlanded on a closed PR.
Prevent member updates until batch closeout is complete, or leave/reopen any PR whose head changed and keep its task active for the unlanded work.
Also at `docs/merge-queue.md:94`.
</issue_to_address>
### Comment 7
<location path="docs/merge-queue.md" line_range="101" />
<code_context>
+ After the last member lands, `git diff --quiet origin/<default-branch> fm/batch-<n>` should report no tree difference after a fresh fetch, and a difference means something outside the batch landed and the proof no longer covers what follows.
+
+Every merge moves the default branch, so the next candidate is always built on the default branch as it stands after the latest merge, and a pushed candidate whose base is no longer that head, other than through its own members landing, is rebuilt before it can prove anything.
+The crew deletes the remote candidate with `git push origin --delete fm/batch-<n>` on Firstmate's steer and keeps its local branch.
+Cleanup of each member's task follows once its pull request is merged or closed as landed, and cleanup of the crew's copy follows its report.
+
</code_context>
<issue_to_address>
**Already-deleted branch blocks cleanup**
When the repository has automatic deletion of merged pull-request head branches enabled, gitHub deletes the merged batch head branch automatically, so the crew's later `git push origin --delete` fails because the remote ref is absent. The instructions provide no absent-branch success path, leaving cleanup liable to stop despite the branch already being deleted.
Check whether the remote candidate ref still exists and treat its absence as successful cleanup.
Also at `.agents/skills/ship-landing/SKILL.md:49`.
</issue_to_address>
### Comment 8
<location path="bin/fm-brief.sh" line_range="745" />
<code_context>
+# Landing crew: the merge-queue contract. docs/merge-queue.md owns the build,
+# lease, and cleanup mechanics; this text owns only what the crew may do.
+if [ "$KIND" = landing ]; then
+cat > "$BRIEF" <<EOF
+You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.
+
</code_context>
<issue_to_address>
**Interrupted scaffold blocks retry**
When the scaffold process is interrupted while writing the landing-crew brief, the landing brief is written directly to its final path. If the process stops during the heredoc, the partial file remains, and a retry refuses because the brief already exists, leaving the task with no usable scaffold until someone repairs or removes the file.
Write the complete brief to a temporary file in the task directory and atomically publish it only after generation succeeds.
</issue_to_address>
### Comment 9
<location path=".agents/skills/ship-landing/SKILL.md" line_range="48" />
<code_context>
+ Tear down each member's task once its pull request is merged or closed as landed, and never the crew on a batch pull request's merged notification, which is informational; only the crew's own `done:` line and report end it.
</code_context>
<issue_to_address>
**Landed members cannot be torn down**
When a batch PR squash-merges and its member PRs are closed as landed, `fm-teardown.sh` treats a closed-but-unmerged member PR as not merged, so the member task’s normal cleanup refuses even though the batch PR landed its changes. The member task remains active after the procedure says it can be torn down.
Teach teardown to accept an explicit, validated batch-landing record for a closed member PR, or keep member tasks until teardown can prove their work landed another way.
Also at `docs/merge-queue.md:94`.
</issue_to_address>
### Comment 10
<location path="AGENTS.md" line_range="254" />
<code_context>
+Never merge or rebase the default branch into a PR branch that does not conflict with it, because a refresh discards that head's green checks and review-ledger generation and costs a full CI run.
</code_context>
<issue_to_address>
**Some PRs cannot land**
When a project requires PR branches to be up to date before merging and the PR branch does not conflict with the default branch, the ordinary landing fallback cannot satisfy the forge's required up-to-date protection: the forge refuses to merge an unchanged PR branch until the default branch is merged or rebased into it, while `AGENTS.md` forbids that refresh when the branch does not conflict. The PR remains unlandable.
Allow the guarded refresh required by the forge in this case, or provide another explicit path for resolving the up-to-date requirement.
Also at `docs/merge-queue.md:33-36`.
</issue_to_address>| Immediately before merging it, confirm for every member that its head still equals its named head, no captain hold is open on its task, its review-ledger generation passes with no unreleased hold, and its own required checks are green or a current explicit captain waiver names the check; drop a member that fails and have the crew rebuild without it. | ||
| Then merge the batch pull request once under the crew's task id with `bin/fm-pr-review.sh merge <crew-task> <batch-url>` when the reviewed-head handoff is required or the away-posture record exists, and otherwise `bin/fm-pr-merge.sh <crew-task> <batch-url>`; that records the batch pull request on the crew's task and arms its merge poll. |
There was a problem hiding this comment.
🟠 High · Changed members still land
When a member's head or guard state changes after the preflight but before the batch PR merges, the batch merge checks the crew and batch PR, not each member's current state, so it still lands a member that is now held or red. If the head moves, the batch can merge the older snapshot and close the newer member PR, leaving its current changes unlanded.
Make member-head and guard validation atomic with the batch merge, and refuse the merge so the candidate can be rebuilt whenever a member changes.
Also at docs/merge-queue.md:86-88.
Prompt for AI agents
In `.agents/skills/ship-landing/SKILL.md` at lines 41-42:
**Changed members still land**
When a member's head or guard state changes after the preflight but before the batch PR merges, the batch merge checks the crew and batch PR, not each member's current state, so it still lands a member that is now held or red. If the head moves, the batch can merge the older snapshot and close the newer member PR, leaving its current changes unlanded.
Make member-head and guard validation atomic with the batch merge, and refuse the merge so the candidate can be rebuilt whenever a member changes.
Also at `docs/merge-queue.md:86-88`.| After a batch pull request that was refused or abandoned without merging, rebind the crew with `bin/fm-pr-check.sh <crew-task> <next-batch-url>` before merging the next one, or the merge refuses with `bound to <old>, not <new>`. | ||
| For a project that does not land through a batch pull request, merge the members in landing order instead, each on its own unchanged head. | ||
| In either shape, a member still red on its own head waits for a rerun of only its failed job or a current explicit captain waiver naming that check, and never lands red, whether inside a batch pull request or by its own merge. | ||
| If anything outside the batch lands on the default branch mid-batch, stop and put the unmerged members into a new candidate. |
There was a problem hiding this comment.
🟠 High · Stale-base proof can land
When the default branch advances after candidate CI passes but before the batch PR merges, the batch PR need not be up to date, and the instruction to stop when an outside landing is noticed does not serialize that check with merging. The merge can therefore land a combination that the candidate run did not prove.
Prevent the merge when the default branch has advanced since the candidate was tested, and rebuild and rerun proof against the new base.
Also at docs/merge-queue.md:33, docs/merge-queue.md:100, .agents/skills/ship-landing/SKILL.md:47.
Prompt for AI agents
In `.agents/skills/ship-landing/SKILL.md` at line 46:
**Stale-base proof can land**
When the default branch advances after candidate CI passes but before the batch PR merges, the batch PR need not be up to date, and the instruction to stop when an outside landing is noticed does not serialize that check with merging. The merge can therefore land a combination that the candidate run did not prove.
Prevent the merge when the default branch has advanced since the candidate was tested, and rebuild and rerun proof against the new base.
Also at `docs/merge-queue.md:33`, `docs/merge-queue.md:100`, `.agents/skills/ship-landing/SKILL.md:47`.| # Landing crew: the merge-queue contract. docs/merge-queue.md owns the build, | ||
| # lease, and cleanup mechanics; this text owns only what the crew may do. | ||
| if [ "$KIND" = landing ]; then | ||
| cat > "$BRIEF" <<EOF |
There was a problem hiding this comment.
🟡 Medium · Interrupted scaffold blocks retry
When the scaffold process is interrupted while writing the landing-crew brief, the landing brief is written directly to its final path. If the process stops during the heredoc, the partial file remains, and a retry refuses because the brief already exists, leaving the task with no usable scaffold until someone repairs or removes the file.
Write the complete brief to a temporary file in the task directory and atomically publish it only after generation succeeds.
Prompt for AI agents
In `bin/fm-brief.sh` at line 745:
**Interrupted scaffold blocks retry**
When the scaffold process is interrupted while writing the landing-crew brief, the landing brief is written directly to its final path. If the process stops during the heredoc, the partial file remains, and a retry refuses because the brief already exists, leaving the task with no usable scaffold until someone repairs or removes the file.
Write the complete brief to a temporary file in the task directory and atomically publish it only after generation succeeds.| In either shape, a member still red on its own head waits for a rerun of only its failed job or a current explicit captain waiver naming that check, and never lands red, whether inside a batch pull request or by its own merge. | ||
| If anything outside the batch lands on the default branch mid-batch, stop and put the unmerged members into a new candidate. | ||
| 6. Close out: after a batch pull request squash-merges, close each member pull request with `Landed on main in batch PR #<n> (<sha>)`, because the forge still shows every member open; skip this when the project merges with merge commits, since the forge then marks the members merged. | ||
| Tear down each member's task once its pull request is merged or closed as landed, and never the crew on a batch pull request's merged notification, which is informational; only the crew's own `done:` line and report end it. |
There was a problem hiding this comment.
🟡 Medium · Landed members cannot be torn down
When a batch PR squash-merges and its member PRs are closed as landed, fm-teardown.sh treats a closed-but-unmerged member PR as not merged, so the member task’s normal cleanup refuses even though the batch PR landed its changes. The member task remains active after the procedure says it can be torn down.
Teach teardown to accept an explicit, validated batch-landing record for a closed member PR, or keep member tasks until teardown can prove their work landed another way.
Also at docs/merge-queue.md:94.
Prompt for AI agents
In `.agents/skills/ship-landing/SKILL.md` at line 48:
**Landed members cannot be torn down**
When a batch PR squash-merges and its member PRs are closed as landed, `fm-teardown.sh` treats a closed-but-unmerged member PR as not merged, so the member task’s normal cleanup refuses even though the batch PR landed its changes. The member task remains active after the procedure says it can be torn down.
Teach teardown to accept an explicit, validated batch-landing record for a closed member PR, or keep member tasks until teardown can prove their work landed another way.
Also at `docs/merge-queue.md:94`.
Local full-suite evidenceThe full local suite was run on this branch before the pipeline, and the complete record is in the operator's private evidence file
|
Recheck a member's head before closing it as landed and close it in its own repository, revalidate the candidate base and member guards as the last step before the batch merge, complete the batch PR's review ledger, admit the full run at the action that starts it, make close-out resumable, treat an already-deleted candidate branch as cleaned up, and allow the refresh a forge requires for an up-to-date branch.
… flake in tests/fm-startup-network.test.sh. This PR didn't cause it: the PR changes only docs, bin/fm-brief.sh, a comment and the landing case in bin/fm-dod-lib.sh, and tests/fm-brief.test.sh, none of which this test exercises. The same assertion ("summary did not retain and report its capped deadline") also failed on main in run 38196263317 on 2026-10-12. Invariant: the test may assert on the persisted .home-summary-refresh.log only after the summary parent has had time to write it. `fm-startup-network.sh wait` returns as soon as the network result is published. The best-effort summary parent writes its "N-second deadline" line through a `--_log-failure` child, bounded at 2s, only after its own timeout fires. That timeout is capped to the same 5s stage budget, so on a loaded runner the test can grep the log before the line exists. Fix (test-only, tests/fm-startup-network.test.sh, test_summary_is_authorized_and_bounded): before the existing assert_grep, poll for the log line for up to 10s, using the same loop style the test already uses. I first tried waiting for the worker to exit and rejected it, because the worker can block up to 120s in await_delivery while the test shell's harvest claim is outstanding. No production code changed, and this is the only assertion on that log. Verification: I added a temporary 1s sleep to the log-failure path of bin/fm-home-summary-refresh.sh, which stays inside the 2s bound. With it, the old test failed with the exact CI message and the new test passed. I then reverted the sleep. The full tests/fm-startup-network.test.sh passes with "all assertions passed". The only shellcheck output is info-level SC1091/SC2153 notes on lines this fix didn't touch
tests/fm-supervision-host.test.sh alone ran 1296-1788 s in Behavior portable serial 2 (and 1662 s on main) against the lane's 30-minute cap. Move the shared fixture, stub engine, and helpers into tests/supervision-host-helpers.sh, keep the run list through test_report_without_acknowledgement_hands_the_wake_to_main in the original script, and run the rest from tests/fm-supervision-host-late.test.sh. Every case and function body is unchanged; the two run lists together are the original one. bin/fm-test-run.sh names the new script in the afk family and the supervision __script__ selection, and replaces the stale 789123 ms hint with 900000 ms placeholders for each half so the packer puts them on different shards. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Final review disposition at b794b2bEvery review item on this PR has a recorded disposition at head Addressed (12 inline threads):
Rejected (2 inline threads):
Summaries (2 review submissions and 3 top-level comments): none of these asks for a change beyond the inline threads above. Validation: no-mistakes run CI-step commits after review approval at
|
Intent
Ask: if we can do a merge queue in house and effectively add that as a firstmate policy, that's good enough. Context: on 2026-10-19 the bbchat queue of 39 open PRs landed at two to three merges per hour on six self-hosted runners because each landing cost about 4.5 full CI runs (54 runner-minutes each): a run per fix round, a fresh run every time main was merged into the branch, and reruns for flakes. A GitHub merge queue is unavailable (private repo without Pro) and a hosted queue would have to take over merging from firstmate's review ledger and merge guards, so the decision is an in-house queue. The captain also decided: stop merging main into branches that do not conflict, batch the lineup ("batch it"), one scoped Feedback run for intermediate fixes with the full four-job run only as the final merge proof, and CI admission with a cap on concurrent full runs (two including main tonight) enforced by a pre-push lease hook that firstmate grants. Tonight's manual version: a landing crew builds a candidate branch fm/batch- from current main plus the next review-complete PRs in landing order, firstmate leases one push, one CI run proves the candidate, then every member PR merges on its own already-green head through bin/fm-pr-merge.sh without being refreshed; a member that conflicts with the batch is dropped from it and refreshed alone; the candidate branch is deleted after the batch lands.
What Changed
bin/fm-brief.shhas a new--landing-crewscaffold, with tests intests/fm-brief.test.sh. The brief tells the crew to buildfm/batch-<n>candidate branches from a fresh fetch of origin's default branch plus the member PRs at the heads firstmate names, in the order it names them. A member that conflicts, or whose head has moved, is dropped. The crew pushes only under a firstmate lease, never with--no-verify. It never opens or merges a PR, never rewrites history and never deletes a local branch. The next batch number is one more than the highestfm/batch-*number among remote and local refs, and the crew detaches before teardown so local batch refs are kept. The scaffold refuses--mode,--forge,--shapeand--base-branch, and its test scope defaults tonone.bin/fm-dod-lib.shrenders that scope as "the candidate's CI run is the only proof."New
docs/merge-queue.md, registered indocs/documentation-audiences.json, covers the queue's mechanics and why it exists:AGENTS.mdand theship-landingskill set the policy:The skill adds the batch procedure: choosing members, how to handle a red candidate (bisect by halving, one rerun for a flaky job), and the backlog record to keep.
docs/configuration.mdanddocs/scripts.mdnow list the landing-crew brief.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change is mostly policy documentation plus a self-contained
--landing-crewbrief scaffold with strict flag refusals, and the latest fix round only narrows one sentence of brief wording to match docs/merge-queue.md; earlier recorded human decisions already settled the batch-PR-primary shape and the batch numbering.Testing
I ran the targeted brief test file, then drove the landing-crew surface live in throwaway lab homes. I scaffolded the brief, tested refusals, and diffed ship, scout, and secondmate briefs against the base commit (all identical). I then ran a real end-to-end landing crew: a real Claude crewmate spawned through bin/fm-spawn.sh --scout against a local bare origin with PR refs. It built fm/batch-4 on the advanced main, merged PRs 1, 2, and 5 at their named heads, and dropped PR3 for a conflict and PR4 because its head moved. It asked for a lease without pushing and pushed exactly once after bin/fm-send.sh granted it. On steer it deleted the remote candidate and detached before its done line. bin/fm-teardown.sh then kept the local batch refs, so the next number is 5. Every driven scenario passed. The forge-side firstmate steps (opening the batch PR, counting GitHub CI runs under the cap, the guarded merge of the batch PR, member close-out, the pre-push lease hook) could not be driven, because no disposable GitHub repository with Actions is available. They are reported untested. Everything this change adds is brief text plus documented procedure; the scripts it names were not changed. The only change outside the labs is Claude's own workspace-trust and session entries for the lab path, written under the normal Claude config dir, which the runbook treats as expected. All labs were removed.
bin/fm-brief.sh <id> <repo> --landing-crewand gets a brief that declares the landing kind, carries no delivery contract, defaults to test scope none with the…bin/fm-spawn.sh <id> <project> --scoutand a real Claude crewmate launches as kind=scoutbin/fm-send.sh --resolve-key batch-4-lease, parks paused, and never touches main or any member refbin/fm-teardown.shthen keeps local fm/batch-4, so the next batch number i…Evidence: Targeted brief suite log (landing-crew tests included)
Source: Targeted brief suite log (landing-crew tests included)
Evidence: S1: generated landing-crew brief from bin/fm-brief.sh --landing-crew
Source: S1: generated landing-crew brief from bin/fm-brief.sh --landing-crew
Evidence: S2: --landing-crew refusals for ship-only and conflicting flags
Source: S2: --landing-crew refusals for ship-only and conflicting flags
Evidence: S3: ship/scout/secondmate briefs identical to base commit
Source: S3: ship/scout/secondmate briefs identical to base commit
Evidence: S4: filled landing-crew brief as spawned
Source: S4: filled landing-crew brief as spawned
Evidence: S4a: lease request status, untouched origin refs, candidate graph before lease
Source: S4a: lease request status, untouched origin refs, candidate graph before lease
Evidence: S5: next batch number after teardown is 5
Source: S5: next batch number after teardown is 5
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
⏭️ **Rebase** - skipped
Step was skipped.
🔧 **Review** - 1 issue found → auto-fixed (3) ✅
bin/fm-brief.sh:763- The landing-crew contract leavesfm/batch-<n>branches behind in the repository that every pool slot shares, and no one numbers batches across crews. Rule 2 says the crew must "never delete a local branch", and docs/merge-queue.md:107 says the crew "keeps its local branch" after deleting the remote one. Each candidate is created withgit switch --no-track -c fm/batch-<n>(docs/merge-queue.md:46). Scout teardown deletes only the branch that is checked out at teardown (bin/fm-teardown.sh:3709-3715). So one crew that builds batch-1 through batch-k leaves k-1 refs in the shared repository. A later landing crew for the same project gets its batch number only by convention: docs/merge-queue.md:53 says 'Batch numbers only increase' but names no counter, and the brief says only 'the next batch number'. If that crew reuses a number,git switch -cfails with 'a branch named fm/batch-<n> already exists' and the crew goes blocked. It fails safe, but leaked refs pile up across every queue run. Possible remedies: let the crew delete its own localfm/batch-*branch once the remote one is deleted, or name a durable source for n, for example the highestfm/batch-*seen withgit ls-remoteplus the local refs. Either one changes a rule the author wrote on purpose (no local branch deletion), so this needs the author's decision. Other sites: docs/merge-queue.md:53 and docs/merge-queue.md:107.🔧 Fix applied.
2 warnings still open:
bin/fm-brief.sh:763- The landing-crew contract leavesfm/batch-<n>branches behind in the repository that every pool slot shares, and no one numbers batches across crews. Rule 2 says the crew must "never delete a local branch", and docs/merge-queue.md:107 says the crew "keeps its local branch" after deleting the remote one. Each candidate is created withgit switch --no-track -c fm/batch-<n>(docs/merge-queue.md:46). Scout teardown deletes only the branch that is checked out at teardown (bin/fm-teardown.sh:3709-3715). So one crew that builds batch-1 through batch-k leaves k-1 refs in the shared repository. A later landing crew for the same project gets its batch number only by convention: docs/merge-queue.md:53 says 'Batch numbers only increase' but names no counter, and the brief says only 'the next batch number'. If that crew reuses a number,git switch -cfails with 'a branch named fm/batch-<n> already exists' and the crew goes blocked. It fails safe, but leaked refs pile up across every queue run. Possible remedies: let the crew delete its own localfm/batch-*branch once the remote one is deleted, or name a durable source for n, for example the highestfm/batch-*seen withgit ls-remoteplus the local refs. Either one changes a rule the author wrote on purpose (no local branch deletion), so this needs the author's decision. Other sites: docs/merge-queue.md:53 and docs/merge-queue.md:107.bin/fm-brief.sh:764- The numbering source added in review fix round 1 does not stop reuse, although the brief and docs say "no batch number is ever reused, even by a later landing crew". This defect comes from that fix round. The rule computes n = 1 + the highest fm/batch-<n> acrossgit ls-remote --heads originand the local refs. Teardown removes the one ref that matters. Nothing in the crew contract switches away from the last candidate, so the crew's worktree is still on fm/batch-k when bin/fm-teardown.sh runs, and both teardown paths delete the checked-out branch (bin/fm-teardown.sh:3693-3696 and 3711-3714 runcheckout --detachthenbranch -D). The remote fm/batch-k is already gone: step 7 deletes it on steer, or the forge deletes it after the merge. Concrete sequence: crew A builds only fm/batch-1, which is the common case. The batch lands, the remote is deleted, and teardown deletes local fm/batch-1. Crew B then sees no fm/batch-* refs and computes n = 1 again. With several batches, A leaves batch-1..k-1 locally, and B reuses k. Runninggit switch -csucceeds, so nothing fails. But fm/batch-k now names two candidates. A merged or closed batch PR from the same head name already exists,gh-axi run list --branch fm/batch-kreturns the old runs as well (the leased-head check still guards the proof), and the backlog and report records become ambiguous. Sibling sites with the same claim: docs/merge-queue.md:54 ("even by a later landing crew") and docs/merge-queue.md:109 ("until then they still count toward the next batch number", which teardown's own deletion of the last ref also makes false). tests/fm-brief.test.sh:1066 asserts only the brief wording, so it passes regardless. The human prescribed this exact source and kept the no-delete rule, so the remedy needs their approval. Two options: (a) have the crew rungit switch --detachbefore its done: line, which keeps every local fm/batch-* ref so teardown deletes none, or (b) add the forge's batch pull-request head names (for examplegh-axi pr list --state all --search head:fm/batch-) to the numbering source.🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:
bin/fm-brief.sh:763- The landing-crew contract leavesfm/batch-<n>branches behind in the repository that every pool slot shares, and no one numbers batches across crews. Rule 2 says the crew must "never delete a local branch", and docs/merge-queue.md:107 says the crew "keeps its local branch" after deleting the remote one. Each candidate is created withgit switch --no-track -c fm/batch-<n>(docs/merge-queue.md:46). Scout teardown deletes only the branch that is checked out at teardown (bin/fm-teardown.sh:3709-3715). So one crew that builds batch-1 through batch-k leaves k-1 refs in the shared repository. A later landing crew for the same project gets its batch number only by convention: docs/merge-queue.md:53 says 'Batch numbers only increase' but names no counter, and the brief says only 'the next batch number'. If that crew reuses a number,git switch -cfails with 'a branch named fm/batch-<n> already exists' and the crew goes blocked. It fails safe, but leaked refs pile up across every queue run. Possible remedies: let the crew delete its own localfm/batch-*branch once the remote one is deleted, or name a durable source for n, for example the highestfm/batch-*seen withgit ls-remoteplus the local refs. Either one changes a rule the author wrote on purpose (no local branch deletion), so this needs the author's decision. Other sites: docs/merge-queue.md:53 and docs/merge-queue.md:107.bin/fm-brief.sh:764- The numbering source added in review fix round 1 does not stop reuse, although the brief and docs say "no batch number is ever reused, even by a later landing crew". This defect comes from that fix round. The rule computes n = 1 + the highest fm/batch-<n> acrossgit ls-remote --heads originand the local refs. Teardown removes the one ref that matters. Nothing in the crew contract switches away from the last candidate, so the crew's worktree is still on fm/batch-k when bin/fm-teardown.sh runs, and both teardown paths delete the checked-out branch (bin/fm-teardown.sh:3693-3696 and 3711-3714 runcheckout --detachthenbranch -D). The remote fm/batch-k is already gone: step 7 deletes it on steer, or the forge deletes it after the merge. Concrete sequence: crew A builds only fm/batch-1, which is the common case. The batch lands, the remote is deleted, and teardown deletes local fm/batch-1. Crew B then sees no fm/batch-* refs and computes n = 1 again. With several batches, A leaves batch-1..k-1 locally, and B reuses k. Runninggit switch -csucceeds, so nothing fails. But fm/batch-k now names two candidates. A merged or closed batch PR from the same head name already exists,gh-axi run list --branch fm/batch-kreturns the old runs as well (the leased-head check still guards the proof), and the backlog and report records become ambiguous. Sibling sites with the same claim: docs/merge-queue.md:54 ("even by a later landing crew") and docs/merge-queue.md:109 ("until then they still count toward the next batch number", which teardown's own deletion of the last ref also makes false). tests/fm-brief.test.sh:1066 asserts only the brief wording, so it passes regardless. The human prescribed this exact source and kept the no-delete rule, so the remedy needs their approval. Two options: (a) have the crew rungit switch --detachbefore its done: line, which keeps every local fm/batch-* ref so teardown deletes none, or (b) add the forge's batch pull-request head names (for examplegh-axi pr list --state all --search head:fm/batch-) to the numbering source.bin/fm-brief.sh:764- Fix round 2 left one sibling behind. In docs/merge-queue.md:56 it correctly narrowed the numbering claim to "never reuses a batch number while those refs remain", because docs/merge-queue.md:111 lets Firstmate or the captain prune leftover local fm/batch-* refs. Rule 2 of the generated landing-crew brief still says "so no batch number is ever reused". How it goes wrong: Firstmate prunes every local fm/batch-* ref as the docs allow, and the forge has already deleted the remote candidates. A later crew then sees no refs and computes n = 1 again, which contradicts what its brief promises. Teardown also still deletes a checked-out fm/batch-k when a crew is torn down without writing a done, failed, or stopping blocked line. Example: Firstmate answers a needs-decision task-budget line with stop and then tears the crew down. Smallest fix: end the brief sentence the way the docs do ("...so no batch number is reused while those refs remain"), or drop the clause. tests/fm-brief.test.sh:1066 matches only the sentence prefix, so it keeps passing.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bin/fm-brief.sh <id> <repo> --landing-crewand gets a brief that declares the landing kind, carries no delivery contract, defaults to test scope none with the…bin/fm-spawn.sh <id> <project> --scoutand a real Claude crewmate launches as kind=scoutbin/fm-send.sh --resolve-key batch-4-lease, parks paused, and never touches main or any member refbin/fm-teardown.shthen keeps local fm/batch-4, so the next batch number i…bash tests/fm-brief.test.sh(targeted brief suite, including test_landing_crew_scaffold and test_landing_crew_refuses_delivery_flags), exit 0FM_HOME=<lab> bin/fm-brief.sh landing-q1 alpha --landing-crewin a disposable lab home, with the generated brief inspectedbin/fm-brief.shwith --landing-crew combined with --mode, --scout, --secondmate, --base-branch, --forge/--shape, --branch-prefix (refused, no brief written) and --tests full (accepted)Ship (no-mistakes, local-only, direct-PR), scout (default and --tests none), and secondmate briefs generated by base d447e08 (git archive) and head c7f3850 in disposable homes, then diffedDisposable lab: fm-lab-home.sh home, local bare origin with refs/pull/1..5/head (PR3 conflicts with PR2, PR4 head moved after naming), remote fm/batch-2 plus local fm/batch-3 leftovers, origin main advanced, treehouse pool under the lab HOME, private tmux socket fm-labbin/fm-spawn.sh lq1 <lab>/projects/alpha --scoutlaunching a realclaudecrewmate on the filled landing-crew briefWatched the crew's status file and origin refs until theneeds-decision [key=batch-4-lease]line, confirming nothing was pushed before the leasebin/fm-send.sh lq1 --resolve-key batch-4-lease 'Lease granted ...', then verified exactly one push of the leased head and that main and member refs were untouchedSimulated the batch landing on origin main, sent the 'CI green, batch landed, delete remote, queue finished' steer withbin/fm-send.sh lq1 ..., and verified the remote deletion, the detached HEAD, and the done linebin/fm-captain-hold.sh complete lq1 --nonethenbin/fm-teardown.sh lq1, verifying local fm/batch-3 and fm/batch-4 survive teardownRecomputed the brief's next-batch-number rule (git ls-remote --heads origin plus git for-each-ref refs/heads/fm/batch-*) after teardown: next=5Killed the lab tmux server and rm -rf'd every lab, base-archive, and comparison directory; the worktree is clean✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Summary by Sourcery
Introduce an in-house merge queue that batches compatible pull requests behind a leased candidate branch and a shared CI proof while retaining existing review and merge safeguards.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: