fix(crew-state): gate terminal PR read on real gh state#404
Open
lukeforshort wants to merge 4 commits into
Open
fix(crew-state): gate terminal PR read on real gh state#404lukeforshort wants to merge 4 commits into
lukeforshort wants to merge 4 commits into
Conversation
outcome=passed was read as a terminal "run passed: PR merged/closed", but no-mistakes reports passed while a PR is still open and unmerged (mgmt-audit 2026-07-10, finding B4/L1). That false terminal can end supervision of unlanded work. Confirm merged/closed with a direct, bounded gh read before reporting the terminal state: an open PR reads as non-terminal working (awaiting merge), a merged or closed PR stays terminal done, and an unverifiable PR reports done without claiming merged/closed. Adds regression coverage for all three paths.
…inst env assumptions
…als, not just EXIT
Closed
5 tasks
Owner
|
Thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#404 at |
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
Fix false-terminal read in bin/fm-crew-state.sh: gate the 'passed: merged/closed' report on real gh PR state instead of inferring it from a no-mistakes outcome label that also covers checks-passed-awaiting-merge, so supervision never ends on unlanded work.
What Changed
fm-crew-state.sh'soutcome=passedterminal reading on a directgh pr viewcheck via a newpr_landed_statehelper:merged/closedreportsdone, an open PR reportsworking(unlanded, awaiting merge), and an unresolvable/gh-unavailable state degrades todone (merge state unverified), so supervision is never ended on unlanded work by a false terminal label. Refactored the boundedno-mistakesrunner into a genericrun_boundedreused for the gh call.fm-watch.shsingleton-lock release by adding explicit TERM/INT/HUP traps alongside the existing EXIT trap, so a checkpoint killed bytimeout's SIGTERM deterministically frees the lock instead of leaving a stale "already running" holder.fm-crew-state,fm-session-start, andfm-dispatch-selecttests against environment assumptions and syncedAGENTS.md,CONTRIBUTING.md, and thedocs/references for the gh-gated terminal read.Risk Assessment
✅ Low: A tightly-scoped, well-tested fix that adds a real gh state check before a terminal supervision read, is safe by construction (open→working, unverifiable→done-without-merged-claim), backstopped by teardown's own landed-work verification, and introduces no correctness regressions.
Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-crew-state.sh:508- During the passed-but-still-open awaiting-merge window, every fm-crew-state.sh read for that crew now issues a boundedgh pr viewAPI call (previously the outcome=passed path was purely log/pane-local). The watcher already runs a dedicated merge-detection poll (fm-pr-check's check.sh), so this is somewhat redundant network work on the supervision read path. It is bounded by NM_TIMEOUT (10s) and only fires on outcome=passed, so it is acceptable, but worth being aware of if crew-state read frequency grows.bin/fm-crew-state.sh:511- When gh is unavailable/unauthenticated the outcome=passed path degrades todone (merge state unverified), i.e. the pre-fix behavior of reading a possibly-open PR as terminal. This is a deliberate, documented tradeoff and is backstopped by fm-teardown.sh's independent landed-work check, so unlanded work still cannot be torn down; noting it only so the protection's dependence on gh availability is explicit.command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: harden session-start and dispatch-select tests against env assumptions
1 error still open:
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: crew-state tests pass; remaining failures are herdr-env and flaky watcher-lock
1 error still open:
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"🔧 Fix: release watcher singleton lock on terminating signals, not just EXIT
1 error still open:
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.