Skip to content

fix: skip run lookup for direct-PR crew state - #79

Merged
Freudator86 merged 2 commits into
mainfrom
fm/fm-crew-state-direct-pr-degraded
Aug 6, 2026
Merged

fix: skip run lookup for direct-PR crew state#79
Freudator86 merged 2 commits into
mainfrom
fm/fm-crew-state-direct-pr-degraded

Conversation

@Freudator86

Copy link
Copy Markdown
Owner

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

  • Updated bin/fm-crew-state.sh to read a ship task’s recorded delivery mode and skip no-mistakes run lookup for non-no-mistakes modes such as direct-PR and local-only.
  • Added the documented delivery-mode-skips-run-lookup cause so skipped delivery-mode lookups are reported distinctly from failed or missing run reads.
  • Added regression coverage for direct-PR crew-state fallback behavior, including finished tasks reading done from the status log instead of degraded.

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-state behavior suite passed, including the new direct-PR regressions and the unchanged no-mistakes lookup-failure regression, and manual CLI transcripts show both direct-PR and local-only finished ship tasks return state: done from status-log even 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/1

Manual evidence for finished direct-PR delivery-mode ship task

Recorded metadata:
window=fm:fm-direct-pr-done
worktree=<fixture-worktree>
kind=ship
mode=direct-PR

Status log:
done: PR https://github.com/example/repo/pull/1

Control: fake no-mistakes CLI exits with: 7

Command:
PATH=<fake-broken-no-mistakes>:$PATH FM_STATE_OVERRIDE=<fixture-state> bin/fm-crew-state.sh direct-pr-done

Output:
state: done · source: status-log · PR https://github.com/example/repo/pull/1
Evidence: local-only finished task evidence

local-only fixture output: state: done · source: status-log · local delivery completed

Manual evidence for finished local-only delivery-mode ship task

Recorded metadata:
window=fm:fm-local-only-done
worktree=<fixture-worktree>
kind=ship
mode=local-only

Status log:
done: local delivery completed

Control: fake no-mistakes CLI exits with: 7

Command:
PATH=<fake-broken-no-mistakes>:$PATH FM_STATE_OVERRIDE=<fixture-state> bin/fm-crew-state.sh local-only-done

Output:
state: done · source: status-log · local delivery completed

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-session-start.sh
  • Inspected changed files with git diff --stat 88b8ac636e31bce37e8afaccb25f0d1ff88b5357..HEAD, git diff --name-only 88b8ac636e31bce37e8afaccb25f0d1ff88b5357..HEAD, and targeted rg searches for delivery-mode/run-lookup behavior.
  • bash tests/fm-crew-state.test.sh
  • Manual direct-PR fixture: PATH=&lt;fake-broken-no-mistakes&gt;:$PATH FM_STATE_OVERRIDE=&lt;fixture-state&gt; 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=&lt;fake-broken-no-mistakes&gt;:$PATH FM_STATE_OVERRIDE=&lt;fixture-state&gt; bin/fm-crew-state.sh local-only-done, captured in /tmp/no-mistakes-evidence/01KZAHAMRGCEMVVXGJGNKH56BC/local-only-finished-fm-crew-state.txt.
  • Confirmed git status --short was clean after testing.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Crew Agent 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.
@Freudator86
Freudator86 merged commit 6dcc9c4 into main Aug 6, 2026
10 checks passed
@Freudator86
Freudator86 deleted the fm/fm-crew-state-direct-pr-degraded branch August 6, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant