Repository navigation
fix(bin): silence healthy PR autoarm lanes and match branches by name - #109
Merged
Merged
Conversation
|
Warning Review limit reachedNext included review available in 11 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 (3)
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
Stop bin/fm-pr-autoarm.sh from queuing wake events for healthy lanes and make it find a pull request pushed from the pipeline's own worktree. The sweep must skip kind=scout silently, as it skips kind=secondmate. When a named local branch has no upstream, do not queue a wake; look up that exact branch name on the project's forge, arm exactly one open match through fm-pr-check.sh, keep no match silent, and retain the wake for multiple exact matches. A detached HEAD must stay silent so the next scan retries; only a missing or unreadable recorded worktree is a broken-lane wake. Preserve existing pr= metadata without touching it, keep secondmates skipped, leave announce behavior unchanged, and keep forge failures or malformed forge output silent. Update the script header with one sentence per rule. Add dated docs/verification/supervision.md evidence only if that file already tracks this script. Add regression tests red first, run tests/fm-pr-autoarm.test.sh through bin/fm-test-run.sh, keep shellcheck clean, and record a real sweep against live metadata with all queue writes isolated in scratch state for the PR's What I walked section. 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
bin/fm-pr-autoarm.shsweep now skipskind=scoutmetadata the same way it already skipskind=secondmate, so scout lanes never reach the forge or arm a PR..) now falls back to the branch's own name onoriginand looks it up on the forge, arming exactly one open match throughfm-pr-check.sh. Detached HEAD, a non-matching ref record, an unreadable remote, and an unparsable remote URL now return silently instead of queuing a task wake; a missing or unreadable worktree and multiple exact matches still wake.tests/fm-pr-autoarm.test.shadds cases for the scout sweep exclusion, unchanged scout announcement handling, and the no-upstream path (zero matches silent, one match armed, two matches waking, forge failure/malformed output silent, missingoriginsilent); the script header comment and thedocs/scripts.mdrow were reworded to match the new resolution rules.Risk Assessment
✅ Low: The change is a tightly scoped rewrite of one function's silent-vs-wake branches in a single script, every new code path was traced against real git behavior and computes correct remote/branch values, the header matches the implemented rules, and the added tests are behavioral and red-first against the base commit.
Testing
The existing suite
tests/fm-pr-autoarm.test.shpasses in full throughbin/fm-test-run.sh(30 ok, exit=0), and shellcheck is clean on both the script and the test file. I confirmed the added tests are genuinely red-first by running them against the base-commit script, where 11 assertions fail, all inside the new scout/detached-HEAD/no-upstream groups while every pre-existing group stays green. Beyond unit tests, I drove the realsweep-oneinterface across twelve purpose-built worktrees to check each rule in the intent independently, confirming scouts and secondmates are skipped before any forge call, detached HEAD is silent, a no-upstream branch queries origin for its exact local branch name and arms exactly one open match, zero matches and forge failure/malformed output stay silent, two matches still wake, a missing worktree still wakes, and existing pr= metadata is left alone. The decisive end-to-end evidence is a real sweep over all 14 live task metadata files (copied into an isolated scratch state dir, with real authenticated gh calls and a recording arm stub): the base script queued 10 wake events to the durable queue and found no PRs, while the fixed script queued zero (the .wake-queue file was never created) and discovered one real open PR, #108 on branch fm/fm-brief-no-1password, verified via the GitHub API. Live metadata was unchanged afterwards and the worktree is clean. docs/verification/supervision.md tracks a different script (fm-claude-stop-autoarm.sh), so the intent's conditional docs requirement correctly does not apply.Evidence: Real sweep against 14 live task metadata: 10 wakes before vs 0 wakes and 1 real PR after
Source: Real sweep against 14 live task metadata: 10 wakes before vs 0 wakes and 1 real PR after
Evidence: Rule-by-rule behavioral matrix of sweep-one against the user intent
Source: Rule-by-rule behavioral matrix of sweep-one against the user intent
Evidence: Red-first proof: new tests failing on base commit, green on target
Source: Red-first proof: new tests failing on base commit, green on target
Evidence: Real sweep side-by-side (walked path)
Evidence: Targeted suite result on target commit
What I walked
I ran
bin/fm-pr-autoarm.sh sweepagainst copies of all 14 live task metadata files with state and arm writes isolated in a scratch directory. The fixed sweep produced no output and queued no wakes.It skipped
aos-3430-writer-capture,aos-3601-desktop-home-scout, andaos-triage-standingbecause they are scouts. It skipped detachedaos-2223-full-safety-trackso a later scan can retry. It silently found no open exact-branch PR foraos-3527-sandbox-symlink-bounce,aos-no-1password-local-dev,fm-autoarm-skip-scouts,fm-relaunch-after-restart, andsdi-715-qbo-live-foundation. Existingpr=metadata remained untouched.The same sweep found
fm-brief-no-1passwordby its local branch name despite no upstream and would arm #108. Live metadata did not change.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-pr-autoarm.test.shon the target commit - 30 ok, exit=0, failed=0Red-first proof: ran the newtests/fm-pr-autoarm.test.shagainst the pre-fixbin/fm-pr-autoarm.shfrom base 87890f7 in a throwaway scratch repo; 11not oklines, all confined to groups added/changed by this commit, with all pre-existing groups still greenRule-by-rule behavioral matrix via the realfm-pr-autoarm.sh sweep-one different-taskentry point across 12 purpose-built worktrees: kind=scout, kind=secondmate, detached HEAD, no-upstream with 0/1/2 open PRs, no-upstream with forge exit 1, no-upstream with malformed forge output, no-upstream with no origin remote, with-upstream 1 PR, missing worktree, and pre-existingpr=metadataVerified the no-upstream lookup issues the exact-branch forge queryrepos/acme/widget/pulls -f state=open -f head=acme:actual-feature -f per_page=2Real sweep:fm-pr-autoarm.sh sweepagainst all 14 live.metafiles copied from/Users/evanagee/Sites/firstmate/state/into an isolated scratch state dir, with real authenticatedghforge calls andFM_PR_CHECK_BINpointed at a recording stubSame real sweep re-run with the base 87890f7 script for a side-by-side comparison, capturing the durablestate/.wake-queuecontents from both runsgh api repos/EvanAgee/firstmate/pulls/108to confirm the auto-discovered PR is genuinely open and its head ref matches the local branch exactlygh auth statusto confirm forge credentials come from the gh keyring, and verified the 1Password CLI (op) was never invokedshellcheck bin/fm-pr-autoarm.sh tests/fm-pr-autoarm.test.sh- cleanIsolation checks:git -C /Users/evanagee/Sites/firstmate status --porcelain state/confirmed live metadata untouched, andgit status --porcelainconfirmed the worktree is clean after removing a stray scratch file my own test stub created✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.