Repository navigation
fix: surface green PRs during CI monitoring - #297
Merged
Merged
Conversation
fm-crew-state.sh's ci step never distinguishes "still waiting on checks" from "checks green, waiting on merge" via axi status alone, since a repo that defers merge to the captain keeps the ci step at status=running for the whole monitor phase. Read the ci step's own log tail (axi logs) for the checks-passed marker and surface done instead of a false "validating (running)" - verified against the real PR #252 run's ci.log. The watcher's wedge timer can re-escalate the same stale pane forever without ever signaling that it is a repeat; track a per-pane consecutive escalation count and add a demand-deep-inspection marker to the wake payload once it crosses a threshold, so the supervisor can no longer dismiss each one as an isolated, still-validating pane. Also clarify the ship-brief's checks-green line: it is owed at the CI-ready return point, not after the background monitor-until-merge loop finishes.
mielyemitchell
added a commit
to mielyemitchell/firstmate
that referenced
this pull request
Jul 6, 2026
Intent
Fix the fm-crew-state green-PR detection gap (backlog crewstate-green-pr-gap-p6). A no-mistakes run in its CI-monitor phase whose PR is already green was reading as 'working - validating (running)' from bin/fm-crew-state.sh instead of surfacing done/checks-passed, because axi status's steps[] table cannot distinguish 'still waiting on checks' from 'checks green, waiting on merge' - both read as plain ci,running. Root-caused this empirically against the real PR #252 run's ci.log (verified via ~/.no-mistakes/state.sqlite and ~/.no-mistakes/logs//ci.log on the installed v1.32.2 binary), which literally logs 'all CI checks passed - still monitoring until merged or closed' while axi status kept showing ci,running with no outcome. Fixed bin/fm-crew-state.sh to read the ci step's log tail via 'axi logs --step ci' and scan for the most recent recognized marker (green vs a later relapse into issues-detected/fixing), overriding working -> done once checks read green. As a safety net (since the watcher's wedge timer can re-escalate the same wedged pane forever, each escalation looking identical and easy to keep dismissing as 'still validating'), added a per-pane consecutive wedge-escalation counter to bin/fm-watch.sh that appends a demand-deep-inspection marker to the wake payload once a configurable threshold (default 3) is crossed; the counter resets when the pane's hash changes or becomes busy again. Also lightly clarified one line in bin/fm-brief.sh's ship-brief wording: the crew's own final 'done: PR {url} checks green' status line is owed at the CI-ready return point (when axi run first reports CI green), not after the background monitor-until-merge loop fully finishes - since in the incident the crew's foreground axi run call may never have returned promptly due to base-branch churn extending the ci step. Extended tests/fm-crew-state.test.sh (three new cases: checks-green-surfaces-done, still-waiting-stays-working, a later relapse-after-green is not masked) and tests/fm-watch-triage.test.sh (two new cases: consecutive escalations accumulate and demand-deep-inspection at the threshold, and the counter resets when the pane becomes active again) following the existing hermetic-fake patterns in each file. All 44 tests/.test.sh files pass and shellcheck bin/.sh bin/backends/.sh tests/*.sh is clean.
What Changed
fm-crew-stateto inspect no-mistakes CI step logs so green PRs surface as done while pending, relapsed, fixing, or rearmed CI states remain working.Risk Assessment
Testing
The pre-run full test baseline was already green; I reran the two focused behavior suites and captured a reviewer-visible CLI transcript proving green PRs surface as done, waiting or relapsed CI stays working, and repeated wedge escalation demands deep inspection. Overall result: pass.
Evidence: fm-crew-state green PR gap E2E transcript
Shows realbin/fm-crew-state.shreturningstate: donefor a green CI-monitor log,state: workingwhile checks are still running or relapsed, and realbin/fm-watch.shaddingdemand-deep-inspectionon the third same-pane wedge escalation.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (6) ✅
bin/fm-crew-state.sh:320- The green marker accepts any line containingno CI checks reported, but the real no-mistakes binary also emitsno CI checks reported yet, waiting for checks to register...for a still-pending CI phase. If that is the latest marker, this reportsstate: donebefore checks have even registered. Match only the terminalno CI checks reported - still monitoring...form, or treat the...yet...form as waiting.🔧 Fix: Captain, distinguish pending no-checks CI marker
2 errors still open:
bin/fm-crew-state.sh:476- A staledone: ... checks greenstatus still wins even after the new CI-log parser sees a later relapse. If a crew wrote the expected done line at first green and no-mistakes later logsissues detectedorCI checks running,RUN_STATEstaysworkingand this branch emitsdonefrom the status log anyway, so the new relapse guard is bypassed in the common reported-status path. Gate this override on the CI log still being green, or skip it when the active CI log has a newer non-green marker.bin/fm-crew-state.sh:292-ci,fixingis eligible for the green override, so a current CI fix phase can be converted todoneif the log tail's last recognized marker is an earlier green line. Afixingstep is already current evidence that the run is not PR-ready; require the CI row to berunningfor the green-monitor override, or treatci,fixingas an explicit non-green marker.🔧 Fix: Harden CI relapse handling
1 error still open:
bin/fm-crew-state.sh:499- A staledone: PR ... checks greenline can still override an active top-levelstatus: fixingwhen the steps table is absent or thecirow is unparseable:CI_STEP_STATUSstays empty,CI_LOG_STATEstays empty, and this branch emitsdone. Treat top-levelfixingas not-ready before allowing the status-log fallback.🔧 Fix: Block stale done during fixing
2 issues (1 error, 1 warning) still open:
bin/fm-crew-state.sh:479- A top-levelstatus: fixingrun can still be converted todonewhen the steps table still containsci,runningand the CI log's last recognized marker is an earlier green line. Since top-levelfixingis current evidence that the run is not PR-ready, skip the CI-green override wheneverRUN_STATUS=fixing, not only in the status-log fallback.bin/fm-crew-state.sh:477- The green override only consults the CI log when aci,runningsteps row is parsed. The same mapper still supports top-levelstatus: ci, but that shape leavesCI_STEP_STATUSempty and continues to reportci runningeven if the CI log says checks are green. TreatRUN_STATUS=cias a running CI step fallback.🔧 Fix: Captain, tighten CI status gating
2 errors still open:
bin/fm-crew-state.sh:335- The CI log scanner ignores thebase branch advanced, re-arming CI monitor timeoutmarker that the new tests already model. If that line is the latest log event after an earlier green marker, the grep filters it out andtail -1still sees the old green line, sofm-crew-statecan reportdonewhile CI has been invalidated by base-branch churn. Treat the re-arm/base-advanced marker asnot-ready.bin/fm-crew-state.sh:511- The status-log relapse guard can run whileRUN_SOURCE=coarse, but in that modeRUN_OUTstill belongs to the other branch returned by the initialaxi status. Callingnm_effective_ci_step_status/nm_ci_checks_statehere can suppress this crew's owndone: PR ... checks greenline based on another branch's CI log, and the same coarse path still cannot detect a green PR when the crew never wrote that done line. Avoid CI-log probing in coarse mode unless you first obtain branch-specific run details or a branch-specific run id.🔧 Fix: Captain, harden stale CI green handling
1 error still open:
bin/fm-crew-state.sh:335- The re-arm guard still misses the real no-mistakes v1.32.2 marker, which isbase branch advanced (<old>..<new>), re-arming CI monitor timeout. This matcher only recognizesbase branch advanced, re-arming..., so after an earlier green line and a later real base-advance line, the later line is filtered out and the stale green marker still wins. Matchbase branch advanced.*re-arming CI monitor timeoutand update the test fixture to include the commit range.🔧 Fix: Captain, recognize ranged CI rearm markers
✅ Re-checked - no issues remain.
🔧 **Test** - 1 issue found → auto-fixed ✅
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: Confirm test suite passes
✅ Re-checked - no issues remain.
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"Baseline already completed before this validation: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"bash tests/fm-crew-state.test.shbash tests/fm-watch-triage.test.shManual evidence run captured at/var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KWW88CMAVCF1BE1ZK4FXTCF2/fm-crew-state-green-pr-gap-e2e-transcript.txt: hermetic fakeno-mistakes/tmuxfixtures drove the realbin/fm-crew-state.shandbin/fm-watch.shentrypoints for green CI, waiting CI, relapsed CI, and three consecutive wedge escalations.git status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.