Skip to content

fix: close linked task issues after direct and watched merges - #117

Merged
EvanAgee merged 8 commits into
mainfrom
fm/fm-pr-closes-issue-check-v2
Sep 14, 2026
Merged

EvanAgee merged 8 commits into
mainfrom
fm/fm-pr-closes-issue-check-v2

Conversation

@EvanAgee

Copy link
Copy Markdown
Owner

Intent

Add bin/fm-issue-close-after-merge.sh and wire it into successful direct and watched merge paths. Rule 1: process only issues explicitly listed in state/.meta issues= metadata. A missing issues= field is a silent no-op. Rule 2: refuse unless the supplied PR is MERGED, and never touch an issue outside the PR repository. Rule 3: for every listed issue, print already-closed for closed issues; for open issues, close with the comment Fixed by , merged to main., remove agent-in-progress when present, and print closed. Rule 4: a forge error prints issue-close-failed with the issue and reason, exits non-zero, and touches no later issues. Direct and watched callers must keep a successful merge result ok and print helper output after it. Rule 5: add one colocated helper test covering already closed, open then closed with comment and label removal, missing issues, forge error, and not-merged refusal. Extend merge and check tests to pin helper calls. Keep shellcheck clean for every touched script. Update docs/verification/supervision.md with one dated line only if git grep fm-pr-merge docs/ shows that doc tracks the path. Log each successful issue close from the watcher path to the watcher triage log as one line with the same receipt shape as the direct merge path. Use .no-mistakes/malformed-issue-probe/forge.log as malformed-issue evidence and remove the docs/scripts.md row outside the documentation boundary. Do not change bin/fm-brief.sh or project clones. Walk the helper against retained task platform-61-invite-only-staff-pools, merged PR https://github.com/SuperDuperIT/platform/pull/65, and already closed issue 61 without closing live work. Put its already-closed line under ## What I walked in the PR body. never run the 1Password CLI (op run, op read, op item, op environment); secrets come from the worktree .env.local, and a missing variable is reported by name in a blocked line.

What Changed

  • Close only issues listed in task metadata after confirming the PR merged, rejecting malformed references and issues outside its repository. Report already-closed issues and close open ones with the merged-PR comment and label cleanup.
  • Wire the helper into direct merges and watched merge detection without changing merge success. Bound watcher execution and record issue receipts in the triage log.
  • Add helper and merge integration regression coverage, including watcher failures and timeouts, and update test-family selection.

What I walked

already-closed: superduperit/platform#61

Risk Assessment

✅ Low: The changes are bounded and preserve merge success, repository restrictions, receipt logging, and watcher cleanup; no material defects were substantiated.

Testing

Focused executable tests passed with CLI evidence. Prior baseline runs diagnosed host contention and passed shutdown checks after deadline adjustments; this rerun retained those adjustments while keeping the deliberate timeout at one second. The outer executor’s live already-closed receipt resolves the prior missing-evidence finding.

Evidence: Helper receipts, forge calls, and refusals

Source: Helper receipts, forge calls, and refusals

Executable CLI integration tests using isolated task metadata and fake forge commands. No live issue mutations.

CASE already-closed
--- err ---
(empty)
--- gh-axi.log ---
pr view 42 -R acme/widgets
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
already-closed: acme/widgets#7

CASE bad-url
--- err ---
error: invalid issue close request
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE close-error
--- err ---
issue-close-failed: acme/widgets#7 could not be closed on GitHub
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 7 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
(empty)

CASE edit-error
--- err ---
warning: acme/widgets#7 was closed but its agent-in-progress label could not be removed
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 7 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
issue edit 7 -R acme/widgets --remove-label agent-in-progress
issue close 8 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
issue view 8 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
closed: acme/widgets#7 https://github.com/acme/widgets/pull/42
closed: acme/widgets#8 https://github.com/acme/widgets/pull/42

CASE foreign-repo
--- err ---
error: task metadata links other/repo#9, which is not in the merged PR's repository acme/widgets
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE gitlab-no-issues
--- err ---
(empty)
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE gitlab-with-issues
--- err ---
error: https://gitlab.com/acme/widgets/-/merge_requests/42 is not a GitHub pull request; refusing to close any issue
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-1
--- err ---
error: task metadata records 'acme/widgets#55#66', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-2
--- err ---
error: task metadata records 'acme/widgets#7,acme/widgets#55#66', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-3
--- err ---
error: task metadata records 'acme/widgets#55#66,acme/widgets#7', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-4
--- err ---
error: task metadata records 'acme/widgets#0', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-5
--- err ---
error: task metadata records 'acme/widgets#000', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-6
--- err ---
error: task metadata records 'acme/widgets#7,,acme/widgets#8', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE malformed-issue-7
--- err ---
error: task metadata records 'acme/widgets#7,', which is not a GitHub issue ref list
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE no-issues
--- err ---
(empty)
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE no-meta
--- err ---
error: task metadata is unavailable
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- out ---
(empty)

CASE not-merged
--- err ---
error: https://github.com/acme/widgets/pull/42 is not merged (state: open); refusing to close any issue
--- gh-axi.log ---
pr view 42 -R acme/widgets
--- gh.log ---
(empty)
--- out ---
(empty)

CASE open-closed
--- err ---
(empty)
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 7 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
issue edit 7 -R acme/widgets --remove-label agent-in-progress
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
closed: acme/widgets#7 https://github.com/acme/widgets/pull/42

CASE open-no-label
--- err ---
(empty)
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 8 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
--- gh.log ---
issue view 8 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
closed: acme/widgets#8 https://github.com/acme/widgets/pull/42

CASE several-issues
--- err ---
(empty)
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 8 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
issue edit 8 -R acme/widgets --remove-label agent-in-progress
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
issue view 8 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
already-closed: acme/widgets#7
closed: acme/widgets#8 https://github.com/acme/widgets/pull/42

CASE view-error
--- err ---
issue-close-failed: acme/widgets#7 could not be read from GitHub
--- gh-axi.log ---
pr view 42 -R acme/widgets
--- gh.log ---
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
(empty)

CASE zero-padded
--- err ---
(empty)
--- gh-axi.log ---
pr view 42 -R acme/widgets
issue close 8 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
issue close 7 -R acme/widgets --reason completed --comment Fixed by https://github.com/acme/widgets/pull/42, merged to main.
issue edit 7 -R acme/widgets --remove-label agent-in-progress
--- gh.log ---
issue view 8 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
issue view 7 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
issue view 9 -R acme/widgets --json state,labels --jq {state,labels:[.labels[].name]}
--- out ---
closed: acme/widgets#8 https://github.com/acme/widgets/pull/42
closed: acme/widgets#7 https://github.com/acme/widgets/pull/42
already-closed: acme/widgets#9
Evidence: Direct merge success and failure behavior

Source: Direct merge success and failure behavior

Executable CLI integration tests using isolated task metadata and fake forge commands. No live issue mutations.

CASE closes-linked-issues
--- gh-axi.log ---
pr merge 77 --repo example/repo --squash
pr view 77 -R example/repo
issue view 77 -R example/repo --json state,labels --jq {state,labels:[.labels[].name]}
issue close 77 -R example/repo --reason completed --comment Fixed by https://github.com/example/repo/pull/77, merged to main.
--- stderr ---
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision according to the session-start block for this harness; do not use shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
--- stdout ---
armed: state/task-x1.check.sh
closed: example/repo#77 https://github.com/example/repo/pull/77

CASE issue-close-failure
--- gh-axi.log ---
pr merge 78 --repo example/repo --squash
pr view 78 -R example/repo
issue view 78 -R example/repo --json state,labels --jq {state,labels:[.labels[].name]}
--- stderr ---
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision according to the session-start block for this harness; do not use shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
issue-close-failed: example/repo#78 could not be read from GitHub
warning: linked issues were not all closed for task-x1 after merging https://github.com/example/repo/pull/78
--- stdout ---
armed: state/task-x1.check.sh

CASE merge-fails
--- gh-axi.log ---
pr merge 13 --repo example/repo --squash
--- stderr ---
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision according to the session-start block for this harness; do not use shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: pr merge failed
--- stdout ---
armed: state/task-x1.check.sh
Evidence: Watcher receipts, timeout reason, and poll retirement

Source: Watcher receipts, timeout reason, and poll retirement

Executable CLI integration tests using isolated task metadata and fake forge commands. No live issue mutations.

CASE merged-already-closed-issue
--- gh-axi.log ---
pr view 1 -R o/r
--- gh.log ---
(empty)
--- home/state/.wake-queue ---
(empty)
--- home/state/.watch-triage.log ---
[2026-09-14T13:15:12-0500] task-a issue close after https://github.com/o/r/pull/1 merged: already-closed: o/r#55
--- watch.err ---
(empty)
--- watch.out ---
check: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-pr-check-security.nff3wA/merged-already-closed-issue/home/state/task-a.check.sh: merged
Remaining task-a poll artifacts: []

CASE merged-closes-issues
--- gh-axi.log ---
pr view 1 -R o/r
issue close 55 -R o/r --reason completed --comment Fixed by https://github.com/o/r/pull/1, merged to main.
issue edit 55 -R o/r --remove-label agent-in-progress
--- gh.log ---
(empty)
--- home/state/.wake-queue ---
(empty)
--- home/state/.watch-triage.log ---
[2026-09-14T13:12:55-0500] task-a issue close after https://github.com/o/r/pull/1 merged: closed: o/r#55 https://github.com/o/r/pull/1
--- watch.err ---
(empty)
--- watch.out ---
check: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-pr-check-security.nff3wA/merged-closes-issues/home/state/task-a.check.sh: merged
Remaining task-a poll artifacts: []

CASE merged-issue-close-failure
--- gh-axi.log ---
(empty)
--- gh.log ---
(empty)
--- home/state/.wake-queue ---
(empty)
--- home/state/.watch-triage.log ---
[2026-09-14T13:13:32-0500] linked issues were not all closed for task-a after https://github.com/o/r/pull/1 merged: error: task metadata links other/repo#55, which is not in the merged PR's repository o/r
--- watch.err ---
(empty)
--- watch.out ---
check: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-pr-check-security.nff3wA/merged-issue-close-failure/home/state/task-a.check.sh: merged
Remaining task-a poll artifacts: []

CASE merged-issue-close-timeout
--- gh-axi.log ---
pr view 1 -R o/r
--- gh.log ---
(empty)
--- home/state/.wake-queue ---
(empty)
--- home/state/.watch-triage.log ---
[2026-09-14T13:14:17-0500] linked issues were not all closed for task-a after https://github.com/o/r/pull/1 merged: the issue close exceeded its 1s bound
--- watch.err ---
(empty)
--- watch.out ---
check: /var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T//fm-pr-check-security.nff3wA/merged-issue-close-timeout/home/state/task-a.check.sh: merged
Remaining task-a poll artifacts: []
Evidence: Supplied retained-task walk receipt

Source: Supplied retained-task walk receipt

Outer executor supplied the live receipt. Carry into the PR body: ## What I walked already-closed: superduperit/platform#61

Retained-task walk finding resolved by the supplied outer-executor report.
The outer executor verified SuperDuperIT/platform#61 was closed, recreated only issues=superduperit/platform#61 in ignored worktree evidence, and ran the pipeline-head helper against https://github.com/SuperDuperIT/platform/pull/65. No live issue changed, according to that report.
Carry the following supplied actual receipt into the PR body:

## What I walked

already-closed: superduperit/platform#61

This test phase reproduced the missing-metadata refusal with exit 1 before forge access. The missing-meta and already-closed behavioral tests passed against the current helper. No source fix was needed. This phase did not repeat the live walk or perform PR operations.
ok - a task with no metadata is refused
ok - an already-closed issue is reported and left alone
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (21m26s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 5 issues found → auto-fixed (2) ✅
  • 🚨 /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/bin/fm-issue-close-after-merge.sh:110 - Intent requires “process only issues explicitly listed.” The added slug=${ref%%#*} and number=${ref##*#} accept issues=o/r#55#66 as repository o/r, issue 66. With a merged PR and open issue 66, the helper closes an issue whose valid reference was never listed. Validate each complete reference before collecting numbers or making forge calls.
  • 🚨 /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/bin/fm-watch.sh:1408 - The accepted instruction requires “the actual tracked owned-group timeout status” and an executable fake-forge hang case. The branch still checks only issue_close_rc -eq 124. In the Perl fallback, the owned-group watchdog SIGKILLs its own group before reaching exit 124, so capture records 137. A hung forge with empty output therefore produces a failure log with no reason. Preserve shutdown cleanup while identifying bound expiry accurately, and add the requested hang case asserting the timeout reason, merged wake, and poll retirement; that case remains absent.
  • ⚠️ /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/bin/fm-watch.sh:1397 - A successful issue close followed by failed label removal prints a warning and exits 0. This capture logs only closed: and already-closed: lines, while the diagnostic branch requires a nonzero exit. Consequently, the watcher discards the label-removal warning and records only success. Log warning lines from the capture while preserving the successful close result and continuation to later issues.
  • ⚠️ /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/tests/fm-pr-check-security.test.sh:3388 - The accepted instruction says “Initialize the recorder file before the foreign-repository refusal.” This case still leaves the recorder uncreated. The helper refuses the foreign reference before invoking the forge, and assert_no_grep treats grep's missing-file error as success. Initialize the empty recorder before running the watcher so the no-mutation assertion examines an actual log.
  • 🚨 /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/docs/scripts.md:132 - Intent explicitly requires “remove the docs/scripts.md row outside the documentation boundary.” The diff still adds the helper's “Close a task's linked GitHub issues” row. Remove that added row to satisfy the stated boundary.

🔧 Fix: Reject malformed issue references and preserve watcher timeout diagnostics
1 warning still open:

  • ⚠️ /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/bin/fm-issue-close-after-merge.sh:105 - The new regex rejects zero-padded issue numbers that fm_issue_guard_normalize accepts and fm-spawn stores unchanged. For issues=acme/widgets#8,acme/widgets#007, the helper now refuses the entire list before processing issue 8, and the watcher still retires the merged poll. Preserve complete-reference validation while accepting and normalizing positive zero-padded numbers already supported by dispatch.

🔧 Fix: Normalize positive zero-padded issue references before closing
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ /Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M2GF8XHV1VDP27TYFRYWYRJA/state/platform-61-invite-only-staff-pools.meta - The required retained-task walk stopped with exit 1: task metadata is unavailable. Fixture tests demonstrate already-closed behavior, but cannot supply the required live receipt for issue 61. Provide the retained metadata within the authorized workspace or arrange the walk in its authorized context, then carry the actual receipt into the PR phase.
  • Inspected git diff d7f3ff9bb407ccfb4179d74d4d7104c85a3b5523 e4b979723a943a98668767588512d8b52361579a and exercised the test runner’s --list --family pr-forge interface.
  • Executed the complete helper behavioral matrix through /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/helper-runner.sh.
  • Executed direct-merge recording, merge failure, linked-issue closing, and issue-close failure selectors through /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/merge-runner.sh.
  • Executed watched open, already-closed, foreign-repository refusal, and forge-hang cases. Original fixture deadlines expired under heavy host load; manual reruns used a 90-second outer deadline and 15-second success-case bound. The deliberate hang retained its one-second bound.
  • Executed shutdown and descendant-cleanup selectors through /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/shutdown-runner.sh, increasing startup readiness allowances while preserving shutdown assertions.
  • Reproduced zero-padding rejection against the previous helper at b61451b; the same behavioral case passed against the target.
  • Read the supplied malformed-reference forge recorder and invoked the real helper for platform-61-invite-only-staff-pools and PR 65 using this worktree’s state directory.
  • Confirmed an unchanged working tree and no remaining test watcher processes.

🔧 Fix: Resolve retained-task evidence finding with supplied walk receipt
✅ Re-checked - no issues remain.

  • FM_PHASE_EVIDENCE=/Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck bash /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck/helper-runner.sh executed all helper behavioral cases.
  • FM_PHASE_EVIDENCE=/Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck bash /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck/merge-runner.sh exercised linked-issue closing, close failure, and merge failure.
  • FM_PHASE_EVIDENCE=/Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck bash /Users/evanagee/.no-mistakes/evidence/01M2GF8XHV1VDP27TYFRYWYRJA/test-recheck/watch-runner.sh exercised open, already-closed, refusal, and Perl-fallback timeout cases.
  • Inspected generated CLI transcripts, forge recorders, watcher triage logs, and retired poll state. Confirmed fixture cleanup and an unchanged working tree.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

EvanAgee and others added 8 commits September 9, 2026 13:37
A shipped issue only closed when the pull request body happened to carry a
"Closes #n" line. Some lanes deliberately write "Refs #n" instead, so GitHub
left those issues open after the merge and the factory poll listed them again
as ready work. Firstmate had to close them by hand.

Add bin/fm-issue-close-after-merge.sh, which reads the linked issues from the
task's own issues= metadata and retires them once the pull request has merged.
An already-closed issue is reported and left alone. An open one is closed with
a comment naming the merged pull request, and loses its agent-in-progress label
when it has one.

Three refusals keep it from closing anything it was not asked to. The pull
request must report a merged state. Every linked issue must live in the pull
request's own repository. An issue absent from the task's metadata is never
reached. Any forge error names the exact issue and exits non-zero without
touching later ones.

Call it from two places. bin/fm-pr-merge.sh runs it after a landed merge.
bin/fm-watch.sh runs it on a merged poll result, because GitHub auto-merge and
web-UI merges land pull requests without fm-pr-merge ever running. Neither
caller lets a failed close turn a landed merge into a failure.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01492SafkpS7qgtHZjeUR964
The label removal never ran. It parsed a "labels:" line out of gh-axi's
issue view, and that command prints no such line, so the branch was dead and
a closed issue kept its agent-in-progress label. The test passed only because
its mock invented a field the real tool never emits.

Read each issue's state and labels in one plain gh call instead, which returns
both as JSON, and fake that exact shape in the tests. The label test now fails
when the branch is broken, which it did not before.

Also stop warning about GitLab. A merged GitLab request hit the GitHub-only
refusal before the no-issues check, so an ordinary GitLab task, which never
records GitHub issues, made the watcher log a warning about work nobody asked
for. The no-issues check runs first now: such a task exits quietly, while one
that does record issues is still refused.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016kwWiB4cXzuZNR2nGDjf5P
@coderabbitai

coderabbitai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a43468a2-e46e-4585-bb13-0e1701e4a995

📥 Commits

Reviewing files that changed from the base of the PR and between d4ba4df and e7dd391.

📒 Files selected for processing (7)
  • bin/fm-issue-close-after-merge.sh
  • bin/fm-pr-merge.sh
  • bin/fm-test-run.sh
  • bin/fm-watch.sh
  • tests/fm-issue-close-after-merge.test.sh
  • tests/fm-pr-check-security.test.sh
  • tests/fm-pr-merge.test.sh

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 Sep 14, 2026
@EvanAgee
EvanAgee merged commit 9e1b276 into main Sep 14, 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