Skip to content

feat: refuse duplicate GitHub-issue ship dispatches - #60

Merged
EvanAgee merged 3 commits into
mainfrom
fm/fm-spawn-duplicate-issue-guard
Aug 28, 2026
Merged

EvanAgee merged 3 commits into
mainfrom
fm/fm-spawn-duplicate-issue-guard

Conversation

@EvanAgee

@EvanAgee EvanAgee commented Aug 27, 2026 •

Copy link
Copy Markdown
Owner

Intent

Add a dispatch-time guardrail to firstmate that prevents two workers from being started on the same GitHub issue.

Record covered issue(s) on the task: add an optional, repeatable --issue flag to bin/fm-spawn.sh. A is a GitHub issue identity: accept both owner/repo#123 and a bare #123/123 (resolve a bare number against the task already-known project repo). Record the normalized issue ref(s) in the task state/.meta under a new field (for example issues=owner/repo#123,owner/repo#124). If no --issue is passed, behavior is unchanged (the field is simply absent). Update the fm-spawn.sh header/help to document the flag and the meta field, and document the meta field wherever meta fields are documented.

Refuse a spawn that duplicates a claimed issue. Before a ship spawn completes, run a preflight that checks whether any of the --issue refs is already claimed by: a live task in this home (scan state/*.meta for the same normalized issue ref on a task whose worker is still present), or an open pull request in that repo that references the issue (use gh-axi; match the issue number). If a claim is found, the spawn must refuse with a clear, plain-English message naming the exact claiming task id or PR URL, and must NOT create the worktree or launch anything. This is a hard stop, not a warning. Exit non-zero.

The refusal must fail closed on local fleet overlap and fail open on GitHub reachability: if the fleet scan runs but the open-PR check cannot reach GitHub, refuse only on the fleet-scan match and clearly report that the PR check was skipped (do not silently pass, and do not hard-fail the whole spawn just because GitHub is unreachable, since local fleet overlap is the primary case). State this boundary in the help. Matching is by normalized issue ref. Two different issues in the same PR body must not collide. A closed/merged PR does not claim anything. A torn-down task meta must not linger as a false claim (teardown already removes state/.meta; confirm that and rely on it). No --issue passed means no claim recorded and no duplicate check for that spawn. Do not add issue tracking to scout or secondmate spawns unless it falls out naturally; the target is ship dispatch.

Acceptance: fm-spawn.sh --issue #123 (and owner/repo#123) records the normalized ref in meta. A second ship spawn naming an issue already recorded on a live task refuses with a message naming that task, creates no worktree, and exits non-zero. A ship spawn naming an issue that an open PR in the repo references refuses with a message naming that PR URL. When GitHub is unreachable, the spawn still refuses on a local fleet match and reports the PR check was skipped; with no local match it proceeds and says the PR check was skipped. A spawn with no --issue behaves exactly as before. New behavior has tests colocated per repo convention. Header/help and meta-field docs updated. shellcheck clean.

Follow-up, do not do in this change, only note in the PR: firstmate itself should start passing --issue at every issue-backed dispatch, and its dispatch instructions should require it. This task only builds the mechanism and leaves it optional so nothing breaks.

What Changed

  • Add optional, repeatable --issue <ref> on ship spawns in bin/fm-spawn.sh. Refs accept owner/repo#123 or bare #123/123 (resolved against the project origin), and the normalized values are recorded as issues= in state/<id>.meta. Omitting the flag leaves the spawn path and meta unchanged. Scout, secondmate, and relaunch refuse --issue; relaunch keeps any prior issues= through meta preservation.
  • Before creating a worktree or launching, a ship spawn with --issue hard-stops on a live local-fleet claim of the same normalized ref or an open PR that claims that issue, naming the claiming task id or PR URL. Local overlap fails closed; GitHub unreachability skips the PR check with a loud notice and still proceeds when the fleet is clear. Cross-repo #n mentions in a PR do not collide.
  • Extract the preflight into bin/fm-issue-guard-lib.sh, document issues= in spawn help and docs/configuration.md, and add colocated tests/fm-spawn-issue-guard.test.sh.

Follow-up (not in this change): firstmate should start passing --issue at every issue-backed dispatch, and dispatch instructions should require it. This PR only adds the optional mechanism.

Risk Assessment

✅ Low: The duplicate-issue guard is well-bounded, the prior cross-repo #n collision is closed in the text matcher, and remaining behavior matches the stated spawn-time contract.

Testing

Ran the colocated fm-spawn-issue-guard suite and replayed the same ship-spawn paths through real fm-spawn.sh; every required acceptance path passed, including normalized issues= recording, hard-stop refusals that name the claiming task or PR URL with no worktree, fail-open GitHub skip notices, and the follow-up that acme/infra#7 does not claim this repo's #7.

Evidence: Captain-visible spawn-guard CLI transcript

Source: Captain-visible spawn-guard CLI transcript

Duplicate-issue spawn guard — captain-visible CLI evidence
Generated by driving real bin/fm-spawn.sh with fake tmux/gh-axi.

=== 01-record-normalized-refs ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-rec-a1 <project> --mode no-mistakes --yolo off --issue acme/other#99 --issue '#7' --issue 8
exit: 0
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-rec/home/data/issue-rec-a1/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned issue-rec-a1 harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-issue-rec-a1 worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-rec/wt
--- meta ---
# issue-rec-a1.meta
window=firstmate:fm-issue-rec-a1
endpoint_task_id=issue-rec-a1
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-rec/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-spawn-issue-guard-evidence.dullcb/issue-rec/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
tasktmp=/tmp/fm-issue-rec-a1
model=default
effort=default
issues=acme/other#99,acme/widget#7,acme/widget#8
busy_gen=g1787870873.70253.16886
spawn_gen=s1787870873.68569.10796

--- window.log ---
new-window


=== 02-no-issue-flag ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-none-a2 <project> --mode no-mistakes --yolo off
exit: 0
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-none/home/data/issue-none-a2/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned issue-none-a2 harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-issue-none-a2 worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-none/wt
--- meta ---
# issue-none-a2.meta
window=firstmate:fm-issue-none-a2
endpoint_task_id=issue-none-a2
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-none/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-spawn-issue-guard-evidence.dullcb/issue-none/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
tasktmp=/tmp/fm-issue-none-a2
model=default
effort=default
busy_gen=g1787870877.78012.8398
spawn_gen=s1787870877.71623.19190

--- window.log ---
new-window


=== 03-local-fleet-refusal ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-dup-a3 <project> --mode no-mistakes --yolo off --issue 7
exit: 1
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-dup/home/data/issue-dup-a3/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: spawn refused: issue acme/widget#7 is already claimed by live task issue-live-a3 in this home; resolve or tear down that task before dispatching another worker on it
--- meta ---
# issue-live-a3.meta
window=mysession:fm-issue-live-a3
endpoint_task_id=issue-live-a3
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-dup/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-dup/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
issues=acme/widget#7

--- window.log ---


=== 04-open-pr-refusal ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-pr-a5 <project> --mode no-mistakes --yolo off --issue '#7'
exit: 1
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-pr/home/data/issue-pr-a5/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: spawn refused: issue acme/widget#7 is already referenced by open PR https://github.com/acme/widget/pull/4; dispatch only after that PR merges or closes
--- meta ---
--- window.log ---


=== 05-cross-repo-hash-does-not-claim ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-pr-xrepo-a12 <project> --mode no-mistakes --yolo off --issue '#7'
exit: 0
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-pr-xrepo/home/data/issue-pr-xrepo-a12/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawned issue-pr-xrepo-a12 harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-issue-pr-xrepo-a12 worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-pr-xrepo/wt
--- meta ---
# issue-pr-xrepo-a12.meta
window=firstmate:fm-issue-pr-xrepo-a12
endpoint_task_id=issue-pr-xrepo-a12
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-pr-xrepo/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-spawn-issue-guard-evidence.dullcb/issue-pr-xrepo/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
tasktmp=/tmp/fm-issue-pr-xrepo-a12
model=default
effort=default
issues=acme/widget#7
busy_gen=g1787870881.90711.23398
spawn_gen=s1787870881.87134.29205

--- window.log ---
new-window


=== 06-same-repo-slug-claims ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-pr-slug-a13 <project> --mode no-mistakes --yolo off --issue '#7'
exit: 1
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-pr-slug/home/data/issue-pr-slug-a13/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: spawn refused: issue acme/widget#7 is already referenced by open PR https://github.com/acme/widget/pull/4; dispatch only after that PR merges or closes
--- meta ---
--- window.log ---


=== 07-github-down-local-match ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-down-a7 <project> --mode no-mistakes --yolo off --issue 7
exit: 1
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down/home/data/issue-down-a7/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
error: spawn refused: issue acme/widget#7 is already claimed by live task issue-live-a7 in this home; resolve or tear down that task before dispatching another worker on it
notice: open-PR duplicate check could not reach GitHub and was skipped; the spawn is clear only against this home's local fleet, not against open PRs in acme/widget
--- meta ---
# issue-live-a7.meta
window=mysession:fm-issue-live-a7
endpoint_task_id=issue-live-a7
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
issues=acme/widget#7

--- window.log ---


=== 08-github-down-no-local-match ===
command: /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M12NBH8H1CBZ578P9NHCS4NW/bin/fm-spawn.sh issue-down-ok-a8 <project> --mode no-mistakes --yolo off --issue 7
exit: 0
--- output ---
warning: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down-ok/home/data/issue-down-ok-a8/brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
notice: open-PR duplicate check could not reach GitHub and was skipped; the spawn is clear only against this home's local fleet, not against open PRs in acme/widget
spawned issue-down-ok-a8 harness=claude kind=ship mode=no-mistakes yolo=off window=firstmate:fm-issue-down-ok-a8 worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down-ok/wt
--- meta ---
# issue-down-ok-a8.meta
window=firstmate:fm-issue-down-ok-a8
endpoint_task_id=issue-down-ok-a8
worktree=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-spawn-issue-guard-evidence.dullcb/issue-down-ok/wt
project=/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-spawn-issue-guard-evidence.dullcb/issue-down-ok/project
harness=claude
kind=ship
mode=no-mistakes
yolo=off
tasktmp=/tmp/fm-issue-down-ok-a8
model=default
effort=default
issues=acme/widget#7
busy_gen=g1787870886.1138.10890
spawn_gen=s1787870886.98141.24271

--- window.log ---
new-window
Evidence: Captain-visible refusal and skip messages

Source: Captain-visible refusal and skip messages

error: spawn refused: issue acme/widget#7 is already claimed by live task issue-live-a3 in this home; resolve or tear down that task before dispatching another worker on it error: spawn refused: issue acme/widget#7 is already referenced by open PR https://github.com/acme/widget/pull/4; dispatch only after that PR merges or closes notice: open-PR duplicate check could not reach GitHub and was skipped; the spawn is clear only against this home's local fleet, not against open PRs in acme/widget issues=acme/other#99,acme/widget#7,acme/widget#8

Captain-visible spawn-guard messages from real fm-spawn.sh

Local fleet overlap (exit 1, no worktree/window):
  error: spawn refused: issue acme/widget#7 is already claimed by live task issue-live-a3 in this home; resolve or tear down that task before dispatching another worker on it

Open PR claim, including same-repo slug#n (exit 1, no worktree/window):
  error: spawn refused: issue acme/widget#7 is already referenced by open PR https://github.com/acme/widget/pull/4; dispatch only after that PR merges or closes

Cross-repo owner/repo#n does not claim (exit 0; body was "Depends on acme/infra#7"):
  spawned issue-pr-xrepo-a12 ... issues=acme/widget#7

GitHub unreachable + local match (exit 1):
  error: spawn refused: issue acme/widget#7 is already claimed by live task issue-live-a7 in this home; resolve or tear down that task before dispatching another worker on it
  notice: open-PR duplicate check could not reach GitHub and was skipped; the spawn is clear only against this home's local fleet, not against open PRs in acme/widget

GitHub unreachable, no local match (exit 0, claim recorded):
  notice: open-PR duplicate check could not reach GitHub and was skipped; the spawn is clear only against this home's local fleet, not against open PRs in acme/widget
  spawned issue-down-ok-a8 ... issues=acme/widget#7

Normalized record from --issue acme/other#99 --issue '#7' --issue 8:
  issues=acme/other#99,acme/widget#7,acme/widget#8
Evidence: fm-spawn-issue-guard test-run log

Source: fm-spawn-issue-guard test-run log

FM_TEST_BEGIN 2026-08-27T22:46:31Z tests/fm-spawn-issue-guard.test.sh family=backend-dispatch expected_gate_skip=none
ok - repeated and bare --issue refs normalize into the meta record
ok - no --issue means no issues= meta field and no duplicate check
ok - a live task's recorded issue hard-stops a second spawn, naming the task
ok - an authoritatively dead worker does not keep the issue claimed
ok - an open PR referencing the issue hard-stops the spawn, naming the PR URL
ok - issue-number matching is exact, not a prefix match
ok - a different repo's owner/repo#n does not claim this repo's issue
ok - same-repo owner/repo#n in an open PR body still claims the issue
ok - with GitHub down, a local fleet match still refuses and the skip is loud
ok - GitHub down with no local match proceeds with a loud skip notice
ok - --issue is scoped to ship dispatch
ok - unparseable issue refs refuse the spawn
ok - a bare ref that cannot be resolved against the project refuses rather than guessing
# all fm-spawn-issue-guard tests passed
FM_TEST_END 2026-08-27T22:46:54Z tests/fm-spawn-issue-guard.test.sh exit=0 duration_ms=23042 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=23119
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=23042 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-spawn-issue-guard.test.sh duration_ms=23042

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-issue-guard-lib.sh:215 - fm_issue_guard_open_pr_claim treats any #&lt;n&gt; token as a claim for this repo's issue n. A concrete miss: listing open PRs for acme/widget while checking issue 7, with body Depends on acme/infra#7, matches #7([^0-9]|$) and refuses the spawn naming that PR URL even though the mention is a different normalized ref. That violates matching by normalized issue ref (two different issues must not collide). Tighten the scan so #n counts only when it is not a owner/repo#n form, and still count same-repo acme/widget#n and bare #n.

🔧 Fix: Ignore cross-repo hash mentions in PR claims
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • ./bin/fm-test-run.sh tests/fm-spawn-issue-guard.test.sh
  • manual evidence run of real bin/fm-spawn.sh with fake tmux/gh-axi for record, no-flag, local-fleet refusal, open-PR refusal, cross-repo #7 non-claim, same-repo slug claim, and GitHub-down skip paths
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by CodeRabbit

  • New Features

    • Added an optional --issue flag for ship spawns, supporting multiple issue references.
    • Prevents duplicate issue claims across active tasks and open pull requests.
    • Records issue references with task metadata and preserves them during relaunches.
    • Allows spawning to continue when GitHub is temporarily unavailable, with a clear notice.
  • Bug Fixes

    • Rejects malformed issue references, unsupported spawn types, and missing repository origins before creating a task.
  • Documentation

    • Documented issue metadata and duplicate-claim checks in the configuration guide.

Add optional repeatable --issue to ship spawns so the task records the
normalized GitHub issue it covers. Before any worktree or endpoint is
created, refuse when a live task in this home or an open PR already
claims that issue. GitHub unreachability skips the PR check loudly and
still honors local fleet overlap; omitting --issue leaves the spawn path
unchanged.
@coderabbitai

coderabbitai Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3eb77120-e95b-48ec-9320-306b7c2b2dc1

📥 Commits

Reviewing files that changed from the base of the PR and between 4be520b and 9806b4c.

📒 Files selected for processing (5)
  • bin/fm-issue-guard-lib.sh
  • bin/fm-spawn.sh
  • bin/fm-test-run.sh
  • docs/configuration.md
  • tests/fm-spawn-issue-guard.test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds --issue support for ship spawns. The implementation normalizes refs, checks live task and open PR claims, preserves issue metadata on relaunch, and adds comprehensive guardrail tests and documentation.

Changes

Issue duplicate guardrail

Layer / File(s) Summary
Issue reference guard library
bin/fm-issue-guard-lib.sh
Adds issue ref normalization, local task claim detection, open PR matching through gh-axi, and fail-open GitHub handling.
Ship spawn issue handling
bin/fm-spawn.sh, docs/configuration.md
Adds --issue parsing, batch forwarding, ship-only and relaunch validation, preflight checks, and conditional issues= metadata.
Guardrail integration tests
tests/fm-spawn-issue-guard.test.sh, bin/fm-test-run.sh
Adds fixture-based tests for ref resolution, duplicate claims, worker liveness, GitHub failures, invalid inputs, restrictions, and metadata recording.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: 🟡 Moderate · up to 9806b

This change adds issue claims and blocks detected duplicate ship dispatches, but the reservation is released before worker launch is fully established and relaunch uses a separate lock. Concurrent or recovery-related dispatches can still start two workers for the same issue, so merge requires coordination of this handoff or explicit owner acceptance.

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant fm_spawn as fm-spawn.sh
  participant Guard as fm_issue_guard_preflight
  participant State as Home state
  participant gh_axi as gh-axi
  participant Endpoint as Endpoint window
  Operator->>fm_spawn: Start ship spawn with --issue
  fm_spawn->>Guard: Normalize and preflight refs
  Guard->>State: Check live task metadata
  Guard->>gh_axi: List open PRs
  gh_axi-->>Guard: PR claim data or failure
  Guard-->>fm_spawn: Refusal or normalized refs
  fm_spawn->>Endpoint: Create endpoint after successful preflight
  fm_spawn->>State: Record issues= metadata
Loading

Suggested reviewers: kunchenguid

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 4 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing duplicate GitHub-issue ship dispatches.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 46.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fm/fm-spawn-duplicate-issue-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EvanAgee EvanAgee added the agent-pr-watched An agent merge watch is armed on this PR label Aug 28, 2026
@EvanAgee
EvanAgee merged commit 477a27e into main Aug 28, 2026
20 checks passed
EvanAgee added a commit that referenced this pull request Sep 22, 2026
Refs #1
Refs #42
Refs #60
Refs #65
Refs #73
Refs #74
Refs #107
Refs #109
Refs #117

## What I walked

In a throwaway `.scratch-c4-walk/home` and local Git repository:

```
$ FM_HOME=.scratch-c4-walk/home bin/fm-merge-local.sh walk-clean
merged fm/walk-clean into local main (aa84759 -> 1b9c678) in /Users/evanagee/.treehouse/firstmate-df5ff1/9/firstmate/.scratch-c4-walk/project
$ git -C .scratch-c4-walk/project log -1 --format=%s main
clean local landing
```

```
$ FM_HOME=.scratch-c4-walk/home FM_GH_BIN=.scratch-c4-walk/fake-gh bin/fm-flow.sh walk status
matched rulesets: main-protection=1 (rules: pull_request,required_status_checks) review=2 (rules: pull_request)
registry posture: [no-mistakes-prod-only +yolo]
main-protection ruleset 1 enforcement: active
main-protection ruleset gates: pull_request + required_status_checks present
review ruleset 2 enforcement: active
stored previous posture: <none>
verdict: full
```

```
$ FM_HOME=.scratch-c4-walk/home bin/fm-merge-local.sh walk-outage fm/walk-outage
error: task walk-outage is mode=no-mistakes; a PR-bound task lands locally only while GitHub is unreachable (state/.github-down present)
merge its PR with bin/fm-pr-merge.sh after approval
exit=1
```

The flow status used a local fake that returned read-only ruleset data. No GitHub request, PR, or push was made.

## Port record

The root already had guarded `fm-pr-merge.sh` and `fm-merge-local.sh`, canonical v2 PR poll registration and repair, GitLab merge verification, task control locks, leases, captain holds, and persisted merge authority. During the final rebase, the root also gained the outage landing skill unchanged.

I kept those root implementations. The port adds auto-arm, reviewer chase, review-thread gating, issue claims and post-merge closing, GitHub outage landing and return sync, and the project flow switch around them.

I dropped the fork's obsolete `captain-merge` token, `fm-pr-check-migrate.sh`, and C3 delivery timing, backfill, and token ledger changes. The root's captain-hold authority and repairable poll publication cover those seams.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr-watched An agent merge watch is armed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant