Repository navigation
fix: close linked task issues after direct and watched merges - #117
Merged
Merged
Conversation
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
…atcher timeout diagnostics
… timeout comments
|
Warning Review limit reachedNext included review available in 20 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
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. Comment |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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
Evidence: Direct merge success and failure behavior
Source: Direct merge success and failure behavior
Evidence: Watcher receipts, timeout reason, and poll retirement
Source: Watcher receipts, timeout reason, and poll retirement
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#61Pipeline
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 addedslug=${ref%%#*}andnumber=${ref##*#}acceptissues=o/r#55#66as 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 onlyissue_close_rc -eq 124. In the Perl fallback, the owned-group watchdog SIGKILLs its own group before reachingexit 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 onlyclosed:andalready-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, andassert_no_greptreats 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.Inspectedgit diff d7f3ff9bb407ccfb4179d74d4d7104c85a3b5523 e4b979723a943a98668767588512d8b52361579aand exercised the test runner’s--list --family pr-forgeinterface.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.shexecuted 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.shexercised 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.shexercised 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.