Skip to content

refactor(bin): give fm-crew-state one owner of the CI-ready verdict - #2896

Open
harmeet-1337 wants to merge 1 commit into
kunchenguid:mainfrom
harmeet-1337:fm/fm-fix-ciready
Open

refactor(bin): give fm-crew-state one owner of the CI-ready verdict#2896
harmeet-1337 wants to merge 1 commit into
kunchenguid:mainfrom
harmeet-1337:fm/fm-fix-ciready

Conversation

@harmeet-1337

Copy link
Copy Markdown

Summary

Implements accepted simplification-audit finding F-S07-2 (P0): bin/fm-crew-state.sh derived the CI-readiness verdict twice, and the second derivation was dead code that created a second owner of a safety-relevant rule.

The second block re-ran nm_effective_ci_step_status and a three-way if/elif that can never change CI_LOG_STATE on the full path: RUN_STATE=working reaches that block only from the case "$status" block, which already ran the first derivation (so CI_LOG_STATE is final by then); on the coarse path the block exits at its first emit before reaching it. This reduces the second block to its single live decision — a crew's own done: ... checks green status-log beats a run still monitoring the PR, unless the ci log reads not-ready.

The single-producer invariant was re-verified at HEAD before the change: the outcome branch never yields working, the gate branch yields parked, and no new working producer has appeared.

Behavior is unchanged: output line format, states, sources, and emitted detail strings are identical; no caller edits.

Tests

Adds two colocated cases to tests/fm-crew-state.test.sh covering the surviving emit path:

  • status=running with no ci step row (so CI_LOG_STATE is empty) + a done-checks-green log → reports done/status-log.
  • status=ci with the green marker absent (CI_LOG_STATE unknown) + a done log → reports done/status-log.

All existing CI and coarse cases pass unchanged. bin/fm-lint.sh is green (pinned shellcheck 0.11.0, actionlint 1.7.12).

Note on the validated run

The no-mistakes validation run for this branch passed every step (review, test, document, lint). Its lint step auto-added one extra commit — an environment-induced PATH fallback for the pinned lint tools (bin/fm-lint.sh, bin/fm-lint-workflows.sh) — that only appeared because the gate environment lacked shellcheck/actionlint on PATH. That commit is unrelated to this finding and has been excluded from this PR for scope; this PR contains only the F-S07-2 change.

fm-crew-state.sh derived the CI-readiness verdict twice. The second block
(after the first `case "$status"` derivation) re-ran nm_effective_ci_step_status
and a three-way if/elif that can never change CI_LOG_STATE on the full path:
RUN_STATE=working there is produced only by that case, which already ran the
first derivation, so CI_LOG_STATE is final by then; on the coarse path the block
exited at its first emit before reaching it. Reduce the second block to its one
live decision - a crew's own "checks green" status-log beats a run still
monitoring the PR unless the ci log is not-ready - so a single place decides CI
readiness. Output line format, states, sources, and detail strings are unchanged.

Add two tests covering the surviving emit path: status=running with no ci step
row (CI_LOG_STATE empty) and status=ci with no green marker (CI_LOG_STATE
unknown), each with a done-checks-green log, both reporting done/status-log.
@greptile-apps

greptile-apps Bot commented Aug 23, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge because the simplified guard preserves behavior across every reachable CI and run-source state.

The first derivation always finalizes fixing and running CI states before the changed guard, while the coarse-path short-circuit preserves the former immediate emit.

Reviews (1): Last reviewed commit: "refactor(bin): give fm-crew-state one ow..." | Re-trigger Greptile

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