Repository navigation
fix(bin): refuse merges without verified green checks - #1614
Closed
sbracewell64 wants to merge 8 commits into
Closed
sbracewell64 wants to merge 8 commits into
sbracewell64 wants to merge 8 commits into
Conversation
sbracewell64
force-pushed
the
fm/merge-refuses-unverified-green
branch
from
August 3, 2026 21:48
eff6ddf to
ca21ec0
Compare
bin/fm-pr-merge.sh merged whatever head it was handed. It never read check runs, mergeability, or the review decision, so "never merge a red PR" held only while firstmate remembered to check by hand every time. It now re-reads the pull request at merge time in one gh pr view call, rather than trusting a value recorded earlier, and refuses when no check runs exist on that head, any check run is not SUCCESS, the pull request is not MERGEABLE, or a review requests changes. Every refusal names the concrete failing condition and the exact head it evaluated, and leaves the task untouched: no recorded PR, no armed poll, no merge attempt. An empty check rollup refuses on its own count rather than through the failure count, because zero check runs and ten successful check runs both report zero failures. A cross-repo fork pull request held for maintainer approval dispatches no workflows and produces exactly that shape, so reading the absence as success is how an unverified head reaches a merge. --allow-unverified is the captain's explicit override. It is never a default and is never inferred from the environment or from arguments after the -- separator. It records merge_verification=override, while a verified merge records merge_verification=verified alongside merge_verified_head, so absence of both keys reads as unknown rather than as verified. Both keys are written before pr= so the metadata identity contract in bin/fm-pr-lib.sh still parses at every instant. The torn-down-metadata refusal is unchanged and still fires first, before any forge lookup.
An empty or non-verifying check set was readable as success at both points firstmate uses to decide a merge. On 2026-08-02 a validation run reported checks-passed for a head whose check-run set was empty: a cross-repo fork pull request holds its workflows at action_required until a maintainer approves them, so nothing ran, nothing was red, and the absence of failure was read as evidence of success. The merge guard now counts a rollup's members in three disjoint buckets rather than two. A run that failed, errored, timed out, or failed to start returned an adverse verdict; a run that is queued, in progress, skipped, neutral, cancelled, or held at action_required returned no verdict at all. Both refuse and each is named in its own words, so "nothing examined this head" is never reported as "something rejected this head", and a rollup whose buckets do not account for its unsuccessful members is reported as unreadable rather than resolved as either. An empty rollup additionally names why it is empty, separating a head with no CI configured from one whose workflows are waiting on approval, which the check-run set alone cannot distinguish because both arrive as the same empty list. fm-crew-state.sh closed the same false success on its own side. Its ci-log reader mapped "no CI checks reported" to green, and its terminal handler repeated the pipeline's reported checks-passed claim unchecked; the first now reports not-ready and the second is corroborated against the run's own evidence before it is repeated. An unreadable log stays unknown, because a log that could not be read is not evidence that nothing ran. Every refusal added here was watched failing against the unfixed code first, and each is paired with a positive control - a genuinely green pull request, an evidenced checks-passed claim, and an unreadable log - so the guards refuse absence rather than refusing everything.
sbracewell64
force-pushed
the
fm/merge-refuses-unverified-green
branch
from
August 4, 2026 08:48
ca21ec0 to
e3e4b47
Compare
Owner
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1614 at |
sbracewell64
added a commit
to sbracewell64/firstmate
that referenced
this pull request
Aug 6, 2026
kunchenguid#1614) (#48) Ports upstream PR kunchenguid#1614 onto this fork's trunk. Nothing here is redesigned: the guard, its refusal wording, the --allow-unverified override, the merge_verification=/merge_verified_head= metadata keys, and the crew-state mapping changes are upstream's as written. Provenance: upstream PR kunchenguid#1614 head commit e3e4b47 its base c8edff3 landed onto 3611e49 (sbracewell64/firstmate main) The two trunks diverged at upstream kunchenguid#1495, so the diff did not apply cleanly. Resolutions, all of them fork-versus-upstream divergence rather than changes to what kunchenguid#1614 does: bin/fm-pr-merge.sh - this fork resolves a task's identity through either a live meta or the durable landing record a released task keeps, which upstream has no equivalent of. The record resolution stays, and verification is placed between it and the recording step, so upstream's property still holds exactly: a head the guard refuses leaves no pr= recorded and no merge poll armed. META is bound to whichever record the task actually has, so the verification metadata write addresses it unchanged. tests/fm-pr-merge.test.sh - upstream's file is the base, with this fork's six released-task cases and their fixtures re-added. Their gh mocks now answer the verification read as well as the forge-view read. test_missing_meta_refuses_before_merge exists on both trunks asserting opposite behavior: upstream refuses a task with no record before any forge lookup, while this fork deliberately rebuilds that record from the pull request itself. The fork's version of the case is kept, because that reconstruction is this trunk's behavior. AGENTS.md, docs/architecture.md, docs/scripts.md - upstream's sentences folded into the fork's own text for the landing record, the task base references, and the merge poll's conflict reporting. Verified on this fork: fm-lint.sh clean, fm-doc-audience-check.sh ok, and tests/fm-pr-merge.test.sh (34), tests/fm-crew-state.test.sh (54) and tests/fm-pr-check-security.test.sh (41) all pass. Checked once against the live forge with the merge command mocked: the pre-change path issued a squash merge for a pull request with three failing check runs, and this one refused it, naming the head and the failing count, before arming anything.
This was referenced Aug 7, 2026
Closed
sbracewell64
added a commit
to sbracewell64/firstmate
that referenced
this pull request
Aug 9, 2026
kunchenguid#1614) (#48) Ports upstream PR kunchenguid#1614 onto this fork's trunk. Nothing here is redesigned: the guard, its refusal wording, the --allow-unverified override, the merge_verification=/merge_verified_head= metadata keys, and the crew-state mapping changes are upstream's as written. Provenance: upstream PR kunchenguid#1614 head commit e3e4b47 its base c8edff3 landed onto 3611e49 (sbracewell64/firstmate main) The two trunks diverged at upstream kunchenguid#1495, so the diff did not apply cleanly. Resolutions, all of them fork-versus-upstream divergence rather than changes to what kunchenguid#1614 does: bin/fm-pr-merge.sh - this fork resolves a task's identity through either a live meta or the durable landing record a released task keeps, which upstream has no equivalent of. The record resolution stays, and verification is placed between it and the recording step, so upstream's property still holds exactly: a head the guard refuses leaves no pr= recorded and no merge poll armed. META is bound to whichever record the task actually has, so the verification metadata write addresses it unchanged. tests/fm-pr-merge.test.sh - upstream's file is the base, with this fork's six released-task cases and their fixtures re-added. Their gh mocks now answer the verification read as well as the forge-view read. test_missing_meta_refuses_before_merge exists on both trunks asserting opposite behavior: upstream refuses a task with no record before any forge lookup, while this fork deliberately rebuilds that record from the pull request itself. The fork's version of the case is kept, because that reconstruction is this trunk's behavior. AGENTS.md, docs/architecture.md, docs/scripts.md - upstream's sentences folded into the fork's own text for the landing record, the task base references, and the merge poll's conflict reporting. Verified on this fork: fm-lint.sh clean, fm-doc-audience-check.sh ok, and tests/fm-pr-merge.test.sh (34), tests/fm-crew-state.test.sh (54) and tests/fm-pr-check-security.test.sh (41) all pass. Checked once against the live forge with the merge command mocked: the pre-change path issued a squash merge for a pull request with three failing check runs, and this one refused it, naming the head and the failing count, before arming anything.
This was referenced Aug 9, 2026
sbracewell64
added a commit
to sbracewell64/firstmate
that referenced
this pull request
Aug 10, 2026
kunchenguid#1614) (#48) Ports upstream PR kunchenguid#1614 onto this fork's trunk. Nothing here is redesigned: the guard, its refusal wording, the --allow-unverified override, the merge_verification=/merge_verified_head= metadata keys, and the crew-state mapping changes are upstream's as written. Provenance: upstream PR kunchenguid#1614 head commit e3e4b47 its base c8edff3 landed onto 3611e49 (sbracewell64/firstmate main) The two trunks diverged at upstream kunchenguid#1495, so the diff did not apply cleanly. Resolutions, all of them fork-versus-upstream divergence rather than changes to what kunchenguid#1614 does: bin/fm-pr-merge.sh - this fork resolves a task's identity through either a live meta or the durable landing record a released task keeps, which upstream has no equivalent of. The record resolution stays, and verification is placed between it and the recording step, so upstream's property still holds exactly: a head the guard refuses leaves no pr= recorded and no merge poll armed. META is bound to whichever record the task actually has, so the verification metadata write addresses it unchanged. tests/fm-pr-merge.test.sh - upstream's file is the base, with this fork's six released-task cases and their fixtures re-added. Their gh mocks now answer the verification read as well as the forge-view read. test_missing_meta_refuses_before_merge exists on both trunks asserting opposite behavior: upstream refuses a task with no record before any forge lookup, while this fork deliberately rebuilds that record from the pull request itself. The fork's version of the case is kept, because that reconstruction is this trunk's behavior. AGENTS.md, docs/architecture.md, docs/scripts.md - upstream's sentences folded into the fork's own text for the landing record, the task base references, and the merge poll's conflict reporting. Verified on this fork: fm-lint.sh clean, fm-doc-audience-check.sh ok, and tests/fm-pr-merge.test.sh (34), tests/fm-crew-state.test.sh (54) and tests/fm-pr-check-security.test.sh (41) all pass. Checked once against the live forge with the merge command mocked: the pre-change path issued a squash merge for a pull request with three failing check runs, and this one refused it, naming the head and the failing count, before arming anything.
This was referenced Aug 10, 2026
sbracewell64
added a commit
to sbracewell64/firstmate
that referenced
this pull request
Aug 11, 2026
kunchenguid#1614) (#48) Ports upstream PR kunchenguid#1614 onto this fork's trunk. Nothing here is redesigned: the guard, its refusal wording, the --allow-unverified override, the merge_verification=/merge_verified_head= metadata keys, and the crew-state mapping changes are upstream's as written. Provenance: upstream PR kunchenguid#1614 head commit e3e4b47 its base c8edff3 landed onto 3611e49 (sbracewell64/firstmate main) The two trunks diverged at upstream kunchenguid#1495, so the diff did not apply cleanly. Resolutions, all of them fork-versus-upstream divergence rather than changes to what kunchenguid#1614 does: bin/fm-pr-merge.sh - this fork resolves a task's identity through either a live meta or the durable landing record a released task keeps, which upstream has no equivalent of. The record resolution stays, and verification is placed between it and the recording step, so upstream's property still holds exactly: a head the guard refuses leaves no pr= recorded and no merge poll armed. META is bound to whichever record the task actually has, so the verification metadata write addresses it unchanged. tests/fm-pr-merge.test.sh - upstream's file is the base, with this fork's six released-task cases and their fixtures re-added. Their gh mocks now answer the verification read as well as the forge-view read. test_missing_meta_refuses_before_merge exists on both trunks asserting opposite behavior: upstream refuses a task with no record before any forge lookup, while this fork deliberately rebuilds that record from the pull request itself. The fork's version of the case is kept, because that reconstruction is this trunk's behavior. AGENTS.md, docs/architecture.md, docs/scripts.md - upstream's sentences folded into the fork's own text for the landing record, the task base references, and the merge poll's conflict reporting. Verified on this fork: fm-lint.sh clean, fm-doc-audience-check.sh ok, and tests/fm-pr-merge.test.sh (34), tests/fm-crew-state.test.sh (54) and tests/fm-pr-check-security.test.sh (41) all pass. Checked once against the live forge with the merge command mocked: the pre-change path issued a squash merge for a pull request with three failing check runs, and this one refused it, naming the head and the failing count, before arming anything.
sbracewell64
added a commit
to sbracewell64/firstmate
that referenced
this pull request
Aug 11, 2026
kunchenguid#1614) (#48) Ports upstream PR kunchenguid#1614 onto this fork's trunk. Nothing here is redesigned: the guard, its refusal wording, the --allow-unverified override, the merge_verification=/merge_verified_head= metadata keys, and the crew-state mapping changes are upstream's as written. Provenance: upstream PR kunchenguid#1614 head commit e3e4b47 its base c8edff3 landed onto 3611e49 (sbracewell64/firstmate main) The two trunks diverged at upstream kunchenguid#1495, so the diff did not apply cleanly. Resolutions, all of them fork-versus-upstream divergence rather than changes to what kunchenguid#1614 does: bin/fm-pr-merge.sh - this fork resolves a task's identity through either a live meta or the durable landing record a released task keeps, which upstream has no equivalent of. The record resolution stays, and verification is placed between it and the recording step, so upstream's property still holds exactly: a head the guard refuses leaves no pr= recorded and no merge poll armed. META is bound to whichever record the task actually has, so the verification metadata write addresses it unchanged. tests/fm-pr-merge.test.sh - upstream's file is the base, with this fork's six released-task cases and their fixtures re-added. Their gh mocks now answer the verification read as well as the forge-view read. test_missing_meta_refuses_before_merge exists on both trunks asserting opposite behavior: upstream refuses a task with no record before any forge lookup, while this fork deliberately rebuilds that record from the pull request itself. The fork's version of the case is kept, because that reconstruction is this trunk's behavior. AGENTS.md, docs/architecture.md, docs/scripts.md - upstream's sentences folded into the fork's own text for the landing record, the task base references, and the merge poll's conflict reporting. Verified on this fork: fm-lint.sh clean, fm-doc-audience-check.sh ok, and tests/fm-pr-merge.test.sh (34), tests/fm-crew-state.test.sh (54) and tests/fm-pr-check-security.test.sh (41) all pass. Checked once against the live forge with the merge command mocked: the pre-change path issued a squash merge for a pull request with three failing check runs, and this one refused it, naming the head and the failing count, before arming anything.
Owner
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
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
Close a measured false-success class: an empty or non-verifying check set must never be readable as "green" anywhere firstmate decides to merge.
THE MEASURED EVENT. On 2026-08-02 a validation pipeline reported checks-passed while the pull request's check-run set was EMPTY. Nothing was red because nothing had run. The terminal claim was reported rather than computed, so "no evidence of failure" was treated as "evidence of success". This violates the fleet's standing rule that absence is never evidence, at the highest-stakes point it has: the captain's merge authority is explicitly "never a red PR", and a PR with zero check runs is not green, it is unverified, which the old path could not distinguish. The specification is data/eval-merge-eligibility-gate/report.md section 4.2 item R2 and section 3.1, and the rule was already designed as LD-2 (the empty-set law) in data/loop-ld-control-safety/report.md.
THE RULE IMPLEMENTED. The weakest non-empty relevant member decides. An empty check-run set is never pass; it is a distinct outcome meaning not verified. A set containing only neutral/skipped/cancelled members is likewise not pass. The terminal verdict is computed from the returned data, never copied from a reported claim. NOT RUN, FAILED, UNAVAILABLE and PASSED must remain four distinguishable states and must never be collapsed; a forge read that fails is UNAVAILABLE and must not read as either pass or fail.
DELIBERATE DECISIONS A REVIEWER READING ONLY THE DIFF WOULD NOT KNOW:
This branch CARRIES FORWARD an existing, sound, but unlanded repair branch (fork/fm/pipeline-reports-green-on-absent-ci, three commits cut from upstream cd73e75) rather than reimplementing it. Firstmate explicitly directed this: carrying it forward with its proof is better than a fresh implementation. Its first three commits are preserved verbatim, including its own no-mistakes review and document commits. Only one docs/scripts.md conflict was resolved, keeping the base's newer fm-promote.sh wording and taking the branch's fm-pr-merge.sh wording.
The check rollup is counted in THREE disjoint buckets, not two. The carried branch counted only "not SUCCESS", which collapsed a skipped, cancelled, queued, in-progress or action_required run into the same words as a failed one. Failures (FAILURE, ERROR, TIMED_OUT, STARTUP_FAILURE) and non-verdicts are now counted and reported separately, because "nothing examined this head" must never be reported as "something rejected this head". A rollup whose buckets do not account for its unsuccessful members is reported as unreadable rather than resolved either way.
An empty rollup now names WHY it is empty, via a check-suites read on the refusal path only. Firstmate specifically required this: "no checks configured" and "checks exist but are awaiting approval" are DIFFERENT states and both must be refused as not-verified rather than passed. action_required is a real, common, reachable case, not hypothetical: a cross-fork PR holds workflows pending maintainer approval, and this account has pull-only on the upstream repository, so those checks will never run. GitHub reports both causes as the same empty statusCheckRollup, so the check-suites read is the only way to separate them. This enrichment can never turn a refusal into a merge.
SCOPE WAS DELIBERATELY WIDENED by firstmate to cover bin/fm-crew-state.sh as well as the merge path, "since a guard in one with a false green in the other is not a fix". Two false greens were closed there: the ci-log reader mapped "no CI checks reported - still monitoring" to green, and the terminal handler repeated the pipeline's reported checks-passed claim unchecked. An unreadable log deliberately stays unknown, because a log that could not be read is not evidence that nothing ran.
A TEST WAS DELIBERATELY INVERTED. tests/fm-crew-state.test.sh's test_ci_monitoring_no_checks_terminal_surfaces_done ASSERTED the defect: it required "state: done" and "checks green" for a run that saw zero checks. That assertion encoded the exact 2026-08-02 false success, so it is replaced by test_ci_monitoring_no_checks_terminal_is_not_green plus a matched positive control. This is intended, not an accidental weakening of coverage.
VERIFICATION DISCIPLINE WAS THE POINT OF THE TASK, because the defect IS a false success and proving a fix by "it no longer misbehaves" is worthless. Every negative control was run against the CURRENT UNFIXED code and watched go red before any fix was applied: 14 of 15 on the carried branch, 4 more on the three-bucket extension, and 1 on crew-state, which emitted the defect verbatim as "state: done, source: run-step, checks green". Every refusal is paired with a matched POSITIVE control, because a guard that "refuses everything" would satisfy a red-only pin too and would be a worse defect than the one being fixed. Verified against real GitHub data and not only fixtures: live PR 1583 (empty rollup, two check suites held at action_required) refuses end to end with zero merge calls, and real open green PR 1577 (13 successful checks) verifies and reaches the merge call recording merge_verification=verified.
--allow-unverified is the captain's explicit override, deliberately never inferred from the environment, rejected after the -- separator so it cannot leak to gh-axi, and recorded as merge_verification=override so an unverified merge stays visible afterwards.
KNOWN BEHAVIOUR CHANGE, ACCEPTED: the guard also refuses a rollup containing a failing member, so pull requests carrying a FAILURE on the honour-system "PR must be raised via no-mistakes" check now refuse and need that check fixed or an explicit override. This is the correct application of the standing "never merge a red PR" rule.
EXPLICIT EXCLUSIONS. Do NOT change the required-checks configuration on any GitHub repository; repository settings are the captain's. Do NOT attempt to resolve the separate atomic merge head-binding race; it is a registered open captain decision, and the script header documents why gh-axi currently drops --match-head-commit. Do NOT merge anything.
STYLE CONSTRAINTS from the firstmate-coding-guidelines skill, since this is firstmate's own shared tracked material: one sentence per line in tracked Markdown, plain dash and never an em dash, never an agent name as commit co-author, bin/*.sh shellcheck-clean via bin/fm-lint.sh, tests colocated in tests/ extending the existing scripts rather than a new runner, and tests exercising behaviour through an executable interface rather than asserting implementation-source bytes. AGENTS.md additions were kept to three lines total by patching existing sentences rather than appending new clauses, per that skill's size discipline.
What Changed
checks-passedclaims with CI evidence, preserving unavailable evidence as unknown instead of green.Risk Assessment
✅ Low: The corrective commit consistently requires explicit green evidence across terminal, active-run, status-log, and coarse-run mappings, while preserving unavailable and non-ready states distinctly and adding executable matrix coverage against recurrence.
Testing
The focused merge and crew-state behavioral suites passed, and end-to-end CLI evidence confirmed that absence remains unverified and blocked while real successful checks remain green and merge-eligible; no visual artifact was applicable because the changed end-user surfaces are shell CLIs.
Evidence: Merge eligibility CLI transcript
Evidence: Crew-state CLI transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed (2) ✅
bin/fm-crew-state.sh:515- The required criterion says “An unreadable log deliberately stays unknown” and that terminal verdicts must be computed rather than copied from reported claims. Here,checks-passedbecomesdonefor every result exceptnot-ready, so an unavailable/unreadable CI log returnsunknownand still surfaces as “checks green.” Handlegreen,not-ready, andunknowndistinctly; the latter must remain unknown rather than green.🔧 Fix: Preserve unavailable CI corroboration as unknown
1 error still open:
bin/fm-crew-state.sh:583- The required criterion says “NOT RUN, FAILED, UNAVAILABLE and PASSED must remain four distinguishable states” and that a terminal verdict is never copied from a reported claim. When a working run has a status-log claim containing “checks green,” an unavailable CI log producesCI_LOG_STATE=unknown, but this condition accepts every value exceptnot-readyand emitsdone. RequireCI_LOG_STATE=greenexplicitly; preserveunknownas unavailable instead of trusting the status-log claim.🔧 Fix: Require explicit green evidence across crew-state mappings
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
Inspectedgit diff --statand changed files for4ee4a0a2790cfaa5e47b30fa462f16546f2ab5b6..2dea7d6d46c7c83c8073688e7fb2f6f074caa5f0tests/fm-pr-merge.test.shtests/fm-crew-state.test.shExecuted the merge harness'stest_zero_check_runs_refusesandtest_all_successful_checks_still_mergescases while capturing user-visible stderr, merge-call logs, and persisted verification metadataExecutedfm-crew-state.shthrough its behavioral harness with identical terminalchecks-passedclaims backed first by a no-checks log and then by an all-checks-passed log✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.