fix: skip run lookup for direct-PR crew state - #79
Merged
Conversation
added 2 commits
August 6, 2026 03:18
…egraded A kind=ship task whose delivery mode is direct-PR or local-only never starts a no-mistakes run, so the run lookup had nothing to reconcile against and reported degraded (run-lookup-failed) instead of answering honestly. Skip the lookup for these modes the same way it is already skipped for kind=scout and kind=secondmate, and fall back to the pane/status-log reading as before.
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 bin/fm-crew-state.sh so it stops reporting 'degraded' for a finished direct-PR (or local-only) delivery-mode ship task. Root cause: the reader unconditionally attempted a no-mistakes run lookup for every kind=ship task, but direct-PR and local-only modes never start a no-mistakes run at all, so the lookup found nothing to read and answered degraded/run-lookup-failed instead of the true 'nothing here to reconcile' answer. Fix reads the task's recorded delivery mode (state/.meta's mode= field, defaulting to no-mistakes when absent for backward compatibility with older meta files) and skips the run-lookup entirely for kind=ship + mode!=no-mistakes, exactly the same way it already skips it for kind=scout/secondmate, falling through to the existing pane/status-log fallback. New enumerated cause token 'delivery-mode-skips-run-lookup' added to the documented cause vocabulary at the top of the script. Deliberately did NOT touch behavior for mode=no-mistakes tasks: a run that genuinely cannot be consulted must still read degraded, confirmed by the existing regression test test_a_run_lookup_that_fails_is_degraded_not_unknown still passing unmodified. Added three new colocated tests in tests/fm-crew-state.test.sh: test_direct_pr_mode_skips_run_lookup (a fake run exists for the branch but must be ignored under mode=direct-PR), test_cause_delivery_mode_skips_run_lookup (asserts the new cause token), and test_direct_pr_finished_task_is_done_not_degraded (the direct regression case: a finished direct-PR task whose no-mistakes CLI is broken/uninitialized reads state:done from its status log, never degraded). Also renamed the local shell variable used for delivery mode to DELIVERY_MODE (not MODE) to dodge a shellcheck SC2100 false-positive triggered by a variable literally named 'mode' colliding with an unrelated lowercase 'mode' local variable in bin/backends/herdr.sh when shellcheck's -x cross-file analysis runs.
What Changed
bin/fm-crew-state.shto read a ship task’s recorded delivery mode and skip no-mistakes run lookup for non-no-mistakesmodes such asdirect-PRandlocal-only.delivery-mode-skips-run-lookupcause so skipped delivery-mode lookups are reported distinctly from failed or missing run reads.donefrom the status log instead ofdegraded.Risk Assessment
✅ Low: Captain, the change is narrow, matches the recorded delivery-mode contract, and I did not find a material correctness or safety issue in the diff or relevant call sites.
Testing
Startup and diff inspection completed; the full
fm-crew-statebehavior suite passed, including the new direct-PR regressions and the unchanged no-mistakes lookup-failure regression, and manual CLI transcripts show bothdirect-PRandlocal-onlyfinished ship tasks returnstate: donefromstatus-logeven when the no-mistakes CLI is broken.Evidence: direct-PR finished task evidence
direct-PR fixture output: state: done · source: status-log · PR https://github.com/example/repo/pull/1Evidence: local-only finished task evidence
local-only fixture output: state: done · source: status-log · local delivery completedPipeline
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-session-start.shInspected changed files withgit diff --stat 88b8ac636e31bce37e8afaccb25f0d1ff88b5357..HEAD,git diff --name-only 88b8ac636e31bce37e8afaccb25f0d1ff88b5357..HEAD, and targetedrgsearches for delivery-mode/run-lookup behavior.bash tests/fm-crew-state.test.shManual direct-PR fixture:PATH=<fake-broken-no-mistakes>:$PATH FM_STATE_OVERRIDE=<fixture-state> bin/fm-crew-state.sh direct-pr-done, captured in/tmp/no-mistakes-evidence/01KZAHAMRGCEMVVXGJGNKH56BC/direct-pr-finished-fm-crew-state.txt.Manual local-only fixture:PATH=<fake-broken-no-mistakes>:$PATH FM_STATE_OVERRIDE=<fixture-state> bin/fm-crew-state.sh local-only-done, captured in/tmp/no-mistakes-evidence/01KZAHAMRGCEMVVXGJGNKH56BC/local-only-finished-fm-crew-state.txt.Confirmedgit status --shortwas clean after testing.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.