Skip to content

fix(bin): refuse false-green CI verdicts when suites never ran - #3

Merged
x45dev merged 13 commits into
mainfrom
fm/fm-validate-on-our-own-fork
Aug 25, 2026
Merged

x45dev merged 13 commits into
mainfrom
fm/fm-validate-on-our-own-fork

Conversation

@x45dev

@x45dev x45dev commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Intent

Make firstmate's PR-check classifier incapable of reporting a false green, by distinguishing three outcomes instead of two.

BACKGROUND - the defect being fixed. firstmate read a pull request's checks and treated "1 passed, 0 failed, 1 total" as CI passing, when that single check was a third-party review bot and none of the repository's own suites had run at all. GitHub holds fork-branch workflow runs until a maintainer approves them, so the repository-owned suites never started. This produced false green verdicts on real pull requests. A prior review of this work raised two unaddressed P1 findings against bin/fm-ci-checks-lib.sh: at line 73, with one successful repository-owned check or head-repo workflow run but the full CI workflow absent or partially skipped, the classifiers returned "passing", so bin/fm-pr-ci-verify.sh authorized a false green without establishing the required suites ran; at line 141, with a rollup containing only one successful CI job such as Lint, fm_ci_state returned "passing" without establishing the other required jobs ran.

The defect has BOTH polarities and the fix handles both: on PR 2584 a lone review bot PASSED while no real suite ran; on PR 2855 the lone bot check FAILED and a validation run still reported outcome passed. Root cause of the original miss: a code comment claimed GitHub cannot conclude a run "success" while a job is missing. It can - skipped jobs do not fail a run.

WHAT THIS TASK DELIVERS. A classifier that distinguishes three outcomes, never two: (1) required suites ran and passed - the only case authorizing a green claim; (2) required suites ran and did not pass; (3) required suites cannot be shown to have run. A lone review-bot check, and a rollup missing required jobs, must both land in case 3 rather than case 1. The suite roster is proven from the run's jobs, not from the run conclusion, in the workflow-runs shape as well as the rollup shape. bin/fm-ci-checks-lib.sh is the single owner of whether a commit's own repository workflows ran; bin/fm-pr-ci-verify.sh is the guard; bin/fm-bearings-snapshot.sh classifies through the same owner; AGENTS.md and the generated ship brief require the check before any green claim. Ships with tests that fail without the change, covering both polarities using the real recorded check shapes from PRs 2584 and 2855 rather than invented ones.

SCOPE EXCLUSION - already done, explicitly NOT this task's work. "Run our own validation on our own fork" was achieved by configuration on 2026-08-24, not by code: origin is now our own copy (push and pull requests go here) and upstream is pull-only with a deliberately invalid push URL. Do not change any remote, gate setting, or repository setting.

CONSTRAINTS. Do not weaken, skip, or narrow any repository suite to make something pass; a suite that genuinely cannot run is a finding to report, not a suite to remove. Do not contact the upstream maintainer, and do not open, close, or modify any upstream pull request - the existing upstream pull request stays exactly as it is as a hopeful contribution and is not this task's success criterion. Anything changing credentials, repository settings a person must click, or the account's security posture is the captain's decision to be reported with exact steps, not made here.

REPORTED, DELIBERATELY NOT CHANGED. A red third-party check blocks a green verdict when repository suites are also present, but does not block when they are absent - the rollup is then classified no-repo-ci and falls through to the fork, which can return green with a red X still on the pull request. Making a red review bot block would conflate review opinions with test failures and block legitimately validated work, so it is a product call above the implementation worker rather than a defect to fix silently.

VERIFICATION STANDARD. Do not accept the pipeline's own verdict as proof of CI. Verify the real repository-owned jobs by name on the pull request and refuse to call anything green on a review bot alone. If the real suites do not appear on a pull request into our own copy, that is a finding to report, not something to work around.

What Changed

  • Added bin/fm-ci-checks-lib.sh, the single owner of a three-way CI classification (passing / failing+pending / none+no-repo-ci+incomplete) that proves the required suite roster from a run's actual jobs rather than its conclusion or a raw pass/fail tally, for both the check-rollup shape and the workflow-runs+jobs shape.
  • Added bin/fm-pr-ci-verify.sh, which reads a pull request's checks through that classifier, falls through to check the head repository's (fork's) own workflow runs when the base repository shows no evidence, and reports exactly which suites ran and where before ever returning a green verdict.
  • Rewired bin/fm-bearings-snapshot.sh's PR check classification to go through the shared fm_ci_state function instead of its own inline pass/fail/pending logic, so a row with only a third-party check reports no-repo-ci instead of passing.
  • Updated .github/workflows/ci.yml to trigger on push to every branch except no-mistakes/** (previously main only), so a fork gets its own validation run instead of relying solely on the upstream pull_request event; also bumped the expected Bearings test count from 42 to 43.
  • Updated bin/fm-brief.sh and AGENTS.md to require running fm-pr-ci-verify.sh before reporting a PR checks-green claim, and CONTRIBUTING.md with a new "Where your changes are validated" section explaining the fork-vs-upstream-PR distinction.
  • Fixed bin/fm-test-run.sh's coverage guard to run every comm invocation under LC_ALL=C, matching the collation the compared lists were sorted with.
  • Added tests/fm-ci-checks.test.sh covering both classifier shapes using the real recorded check shapes from PRs 2584 and 2855, and extended tests/fm-bearings-snapshot.test.sh with a fixture PR carrying a check its own workflow produced.

Risk Assessment

✅ Low: The change is a well-bounded, thoroughly-tested classifier fix that closes both previously-reported P1 findings (rollup-shape single-suite false green and workflow-runs-shape run-conclusion false green), covers both defect polarities with real recorded fixture data from PRs 2584/2855, keeps fm-ci-checks-lib.sh as the single owner consumed consistently by fm-pr-ci-verify.sh and fm-bearings-snapshot.sh, and stays within the stated scope exclusions (no remote/credential/repo-setting changes, no upstream PR interaction).

Testing

Ran the targeted fm-ci-checks and fm-bearings-snapshot suites (all pass), reproduced the pre-fix failure on the prior commit to prove the tests are regression-proof, and drove bin/fm-pr-ci-verify.sh through five real CLI scenarios (the recorded PR 2584/2855 shapes, the cli/cli 32701833535 workflow-runs shape, a Lint-only roster, and a fully-green roster) — every false-green path (lone bot pass, lone bot fail, run-conclusion-success-with-skipped-job, run-conclusion-success-with-missing-jobs) correctly exits 1 with a message naming the missing suites, and only the fully-green roster exits 0 as "validated". No test failures or setup issues found.

Evidence: fm-pr-ci-verify.sh CLI transcript across 5 scenarios (PR 2584, PR 2855, skipped-job false green, missing-jobs false green, legitimate fork pass)

Source: fm-pr-ci-verify.sh CLI transcript across 5 scenarios (PR 2584, PR 2855, skipped-job false green, missing-jobs false green, legitimate fork pass)

=== Scenario 1: PR 2584 real shape (lone Greptile bot PASSED, no repository suite ran, no fork run reachable) ===
Command: bin/fm-pr-ci-verify.sh https://github.com/example/repo/pull/2584
https://github.com/example/repo/pull/2584
  other SUCCESS	- / Greptile Review
example/repo checks: no-repo-ci (0 repository-owned)
error: refusing to call https://github.com/example/repo/pull/2584 green: no example/repo suite ran on this commit.
A third-party check passing is not this repository's CI passing, and there is
no separate head repository whose own run could have validated it.
Exit code: 1

=== Scenario 2: PR 2855 real shape (lone Greptile bot FAILED, no repository suite ran) ===
Command: bin/fm-pr-ci-verify.sh https://github.com/example/repo/pull/2855
https://github.com/example/repo/pull/2855
  other FAILURE	- / Greptile Review
example/repo checks: no-repo-ci (0 repository-owned)
error: refusing to call https://github.com/example/repo/pull/2855 green: no example/repo suite ran on this commit.
A third-party check passing is not this repository's CI passing, and there is
no separate head repository whose own run could have validated it.
Exit code: 1

=== Scenario 3: workflow-runs false green (cli/cli 32701833535 shape) - fork run concluded 'success' with only Lint reporting, Repo invariants skipped ===
Command: bin/fm-pr-ci-verify.sh https://github.com/example/repo/pull/3001
https://github.com/example/repo/pull/3001
example/repo checks: none (0 repository-owned)
no example/repo suite ran on this commit; reading contributor/firstmate at deadbeef
  run 42 success	CI (push)
  job success	Lint
  job skipped	Repo invariants
contributor/firstmate runs: failing
error: refusing to call https://github.com/example/repo/pull/3001 green: the contributor/firstmate runs are failing (see above).
Exit code: 1

=== Scenario 4: legitimate fork validation - fork run concluded success with the complete required-suite roster green ===
Command: bin/fm-pr-ci-verify.sh https://github.com/example/repo/pull/3002
https://github.com/example/repo/pull/3002
example/repo checks: none (0 repository-owned)
no example/repo suite ran on this commit; reading contributor/firstmate at deadbeef
  run 42 success	CI (push)
  job success	Lint
  job success	Test coverage guard
  job success	Behavior portable parallel 1
  job success	Behavior portable parallel 2
  job success	Behavior portable serial 1
  job success	Behavior portable serial 2
  job success	Behavior portable serial 3
  job success	Behavior portable serial 4
  job success	Behavior tests (Herdr)
  job success	Behavior timing aggregate
  job success	Stock macOS Bash snapshot compatibility
  job success	Repo invariants
contributor/firstmate runs: passing
validated: contributor/firstmate suites passed on deadbeef in contributor/firstmate; example/repo has not run its own and does not need to for this to be validated
Exit code: 0

=== Scenario 5: workflow-runs false green, roster shape - fork run concluded 'success' and its only job is Lint (rest of roster never reported at all) ===
Command: bin/fm-pr-ci-verify.sh https://github.com/example/repo/pull/3003
https://github.com/example/repo/pull/3003
example/repo checks: none (0 repository-owned)
no example/repo suite ran on this commit; reading contributor/firstmate at deadbeef
  run 42 success	CI (push)
  job success	Lint
contributor/firstmate runs: incomplete
missing required suites:
  Test coverage guard
  Behavior portable parallel 1
  Behavior portable parallel 2
  Behavior portable serial 1
  Behavior portable serial 2
  Behavior portable serial 3
  Behavior portable serial 4
  Behavior tests (Herdr)
  Behavior timing aggregate
  Stock macOS Bash snapshot compatibility
  Repo invariants
error: refusing to call https://github.com/example/repo/pull/3003 green: the contributor/firstmate CI run does not cover the required suite roster (see above).
A workflow run concludes success when no job failed, which a run whose jobs
were skipped or never expanded also does, so that is not evidence the suites ran.
Exit code: 1

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.

  • bash tests/fm-ci-checks.test.sh — all 41 assertions pass, including the real recorded PR 2584 (bot PASSED) and PR 2855 (bot FAILED) rollup shapes classifying as no-repo-ci, and the new fm_ci_run_jobs_state assertions covering the cli/cli 32701833535 skipped-job shape
  • bash tests/fm-bearings-snapshot.test.sh — all assertions pass, including the bearings-row integration test for a PR with only third-party checks
  • Regression proof: copied the new test file onto commit 0bd79d8 (parent of the final fix, in a throwaway git worktree) and reran it — failed with fm_ci_run_jobs_state: command not found, confirming the new tests fail without e6cb4e3's change and pass with it
  • Manual CLI transcript: ran bin/fm-pr-ci-verify.sh end-to-end against a stubbed gh reproducing PR 2584, PR 2855, a fork run with the cli/cli-32701833535 skipped-job shape, a fork run reporting only Lint (roster shape), and a fully-green fork roster — verified exit codes and refusal messages match intent for all five scenarios
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

x45dev added 13 commits August 24, 2026 23:16
Broadening the push trigger to every branch would have started a source-tree
suite against the orphan branches the gate publishes test evidence to, which
carry no source tree and so could only ever fail. branches-ignore keeps a new
branch validated by default and excludes only that namespace.
…ver ran

Three pull requests were reported green whose repository suites had never
started. Each carried exactly one check, a third-party review bot reporting
success, which reads as "1 passed, 0 failed, 1 total" to anything that only
tallies conclusions. bin/fm-bearings-snapshot.sh classified that as passing for
the same reason: a rollup with nothing red and nothing waiting.

bin/fm-ci-checks-lib.sh now owns the rule, structurally rather than by bot name:
a GitHub Actions check run records the workflow that produced it, and a check
run created by a third-party App has no workflow behind it and so no name. A
rollup with no repository-owned check classifies as no-repo-ci, decided ahead of
failing and pending so missing suites are never reported as a different problem.

bin/fm-pr-ci-verify.sh asks the question directly for one pull request, and
resolves the case those three were actually in: it reads the head repository's
own workflow runs at the same commit, so a fork run that validated the change
counts while GitHub still holds the upstream run. The verdict names which
repository the evidence came from, so fork-validated is never reported as the
upstream pull request having been checked.
The workflow told a contributor to fork and then aimed everything at the pull
request here, leaving no statement that the fork is where the suites actually
run. That is what let a held upstream run read as a blocker on knowing whether
the change works, when it is only a wait on a maintainer decision.

CONTRIBUTING.md now states the split and says why an all-green check list is not
evidence anything ran. The generated ship brief and the firstmate contract both
require confirming a green claim with bin/fm-pr-ci-verify.sh rather than reading
a check total.
…ere sorted in

Pre-existing and unrelated to the rest of this branch, reported here rather than
left silent. The guard builds every list with LC_ALL=C sort but ran comm under
the ambient locale, so on a UTF-8 host comm rejected the C-sorted input as
unsorted and the guard failed with a message about sort order rather than about
the partition it exists to prove. CI runs under a C locale and never saw it.

Verified before and after on the same machine: bin/fm-test-run.sh
--check-coverage exited 1 with "comm: file 2 is not in sorted order" under
LANG=en_US.UTF-8 and 0 under LC_ALL=C; it now exits 0 under both.
…w produced

The bearings fixture rollup carried a bare passing entry with no producer on
it, which is what a review bot's check looks like rather than a suite's. Now
that the row is classified by whether the repository's own workflows ran, that
fixture reads no-repo-ci, which is correct for what it describes and wrong for
what the test means. Give it the workflow name a real CI check run carries.

Add the bot-only rollup as its own fixture and assert the row reads no-repo-ci
and never passing, so the case the classifier exists for is pinned here too.
Self-update reads whatever remote the home calls origin, so a fleet that runs
its own suites can update from the fork those runs validated rather than from
a repository whose answer it is still waiting on. Nothing in the code has to
change for that; the sentence exists because the option is invisible from the
outside, and reading origin as a fixed repository is what makes a fork look
like a place work goes and never a place work comes from.
The stock-Bash lane pins an exact count so a test cannot quietly stop running.
The bot-only rollup case is a new test, so the floor moves with it.
The rollup shape learned to require the full required-suite roster, but the
workflow-runs shape - the one that answers "did MY fork validate this commit?"
- still granted a passing verdict on the run's own conclusion. That left the
false green this change exists to remove alive on the second evidence path:
fm-pr-ci-verify.sh reported a commit validated whenever one successful CI run
existed at it, without establishing that the required suites were inside that
run. Both P1 findings on the pull request named this, at fm-ci-checks-lib.sh
lines 73 and 141; the second was already closed for the rollup, this closes the
first for the runs.

The comment that justified skipping the roster here was wrong. It claimed
GitHub cannot conclude a run "success" while a job in it is missing, so the
platform already enforced the roster for this shape. GitHub concludes a run
success whenever no job in it FAILED, and a job that never ran because it was
skipped does not fail: cli/cli run 32701833535 concluded success with one job
successful and two skipped. A CI run that lost most of its roster to an if:
condition, a matrix that did not expand, a path filter, or a thinner ci.yml on
the branch under test therefore still reports success.

fm_ci_run_jobs_state takes the jobs of the CI runs alongside the runs and
applies the same roster to them, so both shapes now answer the same three
outcomes and only one of them authorizes a green claim: the suites ran and
passed, the suites ran and did not pass, or the suites cannot be shown to have
run. Jobs that cannot be read at all fall in the third, never inheriting the
run's verdict. The verifier prints the job roster for every outcome, including
the passing one, and names the missing suites when it refuses.

Tests use the shapes actually recorded on the two pull requests, covering both
polarities of the defect: the bot that PASSED on 2584 with no suite behind it,
and the bot that FAILED on 2855 while the run reporting on it read as passed.
Neither may classify as passing. Verified against pre-change code, where the
new assertions fail and the guard exits 0 reporting "validated" on a fork run
whose only job was Lint.

CONTRIBUTING.md no longer tells a contributor to treat a fork run's conclusion
as the answer, which was the same false green in prose.
@x45dev
x45dev merged commit 3ae095b into main Aug 25, 2026
25 checks passed
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