Skip to content

fix(arm): a non-green head is reported, never completed as a failed check run - #314

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/arm-does-not-poison-mergeability
Nov 23, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/arm-does-not-poison-mergeability

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

validate / arm could deadlock a pull request permanently, and the only visible remedy from inside a session was an empty push — which R3 forbids. Closes #313.

Measured on opencharly/gst-wayland-display#12, head 7071384: the ruleset's three required checks (cargo fmt, harness (lint · build · unit), validate / validate) all SUCCESS, the verdict a PASS, and the only red run on the head validate / arm itself — which then failed with GitHub still reports the pull request as unstable after 180s. A re-run of the failed job reproduced it (3m8s), because by then the first arm failure was itself a failing check run on the head.

The mechanism: GitHub computes mergeable_state over every check run on the head. One COMPLETED FAILURE of this non-required check run leaves the PR unstable; enablePullRequestAutoMerge is refused while unstable; and the job that must clear it has to complete in order to fail. The gate poisoned the condition it waits on — the POISON class scripts/check-stalled-automerge.sh shape 3 already documents for the REQUIRED context, one level down.

The fix is three parts, and all three are asserted:

  1. Head check-runs carries continue-on-error: true. Its non-green classes (1 NOT-PASSED, 2 IN-FLIGHT, 3 UNREAD, 4 EMPTY) no longer complete as a FAILED check run. The exit codes and the annotations are unchanged, so the class table, the titles and the remedies the step prints stay exactly as they were; the step additionally writes green=true|false and class=<n> to $GITHUB_OUTPUT.
  2. Enable auto-merge is gated on green == 'true' — continue-on-error alone would let a class 1–4 head reach the mutation — and carries continue-on-error: true itself, so an arming failure (head moved, auth, a persistent unstable) is reported rather than poisoning the head.
  3. A new Report an unarmed head step runs when either did not succeed and updates ONE marker-keyed comment with the class and its remedy. A check run that is green by design can no longer be the alarm, so the comment is; marker-keying keeps a retried job from spamming the PR.

The required validate / validate verdict check is untouched: a BLOCK still fails it, and it is still the merge gate. What changes is that the arm job — a convenience that arms the merge the verdict already authorised — stops being able to veto it permanently.

How tested

The repo's own gate on this tree, every script workflow-checks.yml runs, run locally on the committed tree:

$ for t in image-build-tag_test org-ruleset_test retire-per-repo-dispatchers_test \
           retire-per-repo-candy-gates_test strip-config-version_test head-settle_test \
           retired-sweep-arm_test assert-org-rulebook_test engine-pin-asset_test \
           reconcile-tag-on-merge-callers_test reconcile-tag-on-merge-callers_tag_test \
           backfill-missing-tags_test tag-on-merge-assert_test bootstrap-repo-main_test \
           labels-test; do bash scripts/$t.sh; done
… all 15 PASS
$ bash scripts/governance-reconcile.sh --self-test
PASS
$ python3 -c 'import yaml,sys; yaml.safe_load(open(".github/workflows/pr-validator.yml")); print("yaml ok")'
yaml ok

scripts/head-settle_test.sh — the coverage that extracts the shipped run: and runs THAT:

ok  (A) GREEN            -> exit 0  (all 3 check run(s) on this head passed — safe to arm auto-merge)
ok  (B) NOT-PASSED       -> exit 1  (::error title=A check on this head did not pass::go -> failure)
ok  (C) IN-FLIGHT        -> exit 2  (… still in flight after 3900s — pin-currency)
ok  (D) UNREAD           -> exit 3  (… refusing to arm auto-merge on an unread head)
ok  (E1) derived budget  -> exit 0  (the slow sibling settled inside it)
ok  (E2) pre-#229 budget -> exit 2  (the SAME head, the pre-#229 budget)
ok  (E3) the pre-#229 shape -> exit 1  (reported as a FAILURE, with the old whole-validator remedy)
ok  (F) invariants      -> backstop 4200s == 70m timeout, derived budget 3900s > 1073s
ok  (G1)(G2)(G3) the pre-#229 shape's hole stays closed
ok  (H1) EMPTY           -> exit 4  (… there is nothing to judge)
ok  (H2)(H3) the pre-#248 hole stays closed
ok  (H4) the class table  -> 4 EMPTY is named in the shipped text
ok  (I1) head-checks     -> continue-on-error: true (a non-green head cannot complete as a FAILED check run)
ok  (I2) enable          -> continue-on-error + gated on green == 'true'
ok  (I3) report          -> runs on either failure, updates ONE marker comment
head-settle_test: all assertions passed

expect_class is new in the harness: every case now also asserts the class=<n> the step REPORTS, because the report comment is what replaces the failing check run.

Mutation proofs (R7) — each part of the new contract removed from a copy of the tree, the suite run against that copy:

=== remove continue-on-error from head-checks
FAIL: (I1) the head-checks step must carry continue-on-error: true — without it a non-green
      head completes as a FAILED check run and poisons mergeability forever (#313)
=== remove the enable green gate
FAIL: (I2) the enable step must be GATED on the green output — continue-on-error alone would
      let a class 1-4 head reach the mutation
=== stop reporting class=4
FAIL: /tmp/…/h1.out reported class [], want [4]

RCA of a failure this change itself produced (R1), already fixed in the tree: the first run of the updated step failed case (A) with step.sh: line 169: : No such file or directory. Mechanism: the step now writes $GITHUB_OUTPUT, and the harness — like the pre-change step — never exported one; on a runner GitHub always sets it, in the harness nothing did. Missed control: the harness must mirror the runner's environment for every variable the shipped text reads, not only the ones it read yesterday. Fix: the harness exports a per-case GITHUB_OUTPUT (and expect_class reads it), which is what makes the class assertions possible at all.

Live proof of the deadlock itself is on opencharly/gst-wayland-display#12 (the measurement quoted above). Live proof of the FIX is that PR's arm job after this merges: its head still carries the failed validate / arm run from before, so the first attempt there may still be refused — the honest expectation is that a new head (or a re-run creating a fresh job) arms, and that no future head can reach this state.

Rulebook compliance

  • R0: /charly-internals:git-workflow, /charly-internals:repo-setup, /charly-internals:strict-policy, /charly-internals:root-cause-analyzer, /charly-check:check.
  • R1: the finding (#313) is root-caused to the mechanism (mergeability counts every run; the non-required job's own failure is the poison); the one failure this change caused is RCA'd above and fixed; the stale claim "Arming errors fail this required check" and the step name "… then fail on any check that did not pass" both became false the moment the step learned continue-on-error, and both are corrected in this same commit (claim-keyed grep: grep -n 'then fail on any check' .github/workflows/pr-validator.yml → no hit).
  • R2: no second copy of the settle logic — the test extracts the SHIPPED step text through the shared scripts/lib-org.sh, and the report step is the one place the non-green class is described to a human.
  • R3: no retry, no sleep added, no mergeable_state polling reintroduced; the existing bounded unstable tolerance is untouched.
  • R4: the product (the gate) is fixed; no doc routes around it.
  • R5: nothing legacy is left behind — the pre-change shape survives only as the test's negative controls, which is where an old shape belongs.
  • R6: branch feat/arm-does-not-poison-mergeability off fresh origin/main (6c43b85); no force-push, no direct push to main.
  • R7: the mutation proofs above; every new assertion fails without its code.
  • R8: no live service boundary is involved.
  • R9/R10: the repo's own gate is workflow-checks.yml, reproduced above on the committed tree; the validator itself runs live on this PR.
  • R11: this repo carries no DESIGN surface; the change adds no field, shape, kind, verb or capability.
  • T4: this is the gate itself, so it needs a maintainer-account sign-off naming the head — posted on this PR before the run that is expected to produce a verdict, at the operator's explicit direction.

Change classification

  • Change class: CI workflow + its test script (the org PR gate).
  • Attribution tier: fully tested and validated — the repo's full local gate passed on the committed tree, and every new assertion is mutation-proven.
  • Breaking change + rollback: none — no repo-facing input, output or contract changes; the class exits and annotations are identical, and the arm job's check-run conclusion changes from failure to success on a non-green head (which is the fix). Rollback: revert this commit; the gate returns to poisoning its own heads.

Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)

…heck run

`validate / arm` could deadlock a pull request permanently (#313).
Measured on opencharly/gst-wayland-display#12, head 7071384: the ruleset's three
required checks all SUCCESS, the verdict a PASS, and the only red run on the head
`validate / arm` itself. GitHub computes `mergeable_state` over EVERY check run on
the head, so one COMPLETED FAILURE of that NON-required check run leaves the PR
`unstable`; `enablePullRequestAutoMerge` is refused while unstable, and the job that
must clear it has to complete in order to fail. The gate poisoned the condition it
waits on — the POISON class scripts/check-stalled-automerge.sh shape 3 already
documents for the REQUIRED context, one level down.

The contract that closes it, in three parts:

* `Head check-runs` carries `continue-on-error: true`, so its non-green classes
  (1 NOT-PASSED, 2 IN-FLIGHT, 3 UNREAD, 4 EMPTY) no longer complete as a FAILED
  check run. The exit codes and the annotations are UNCHANGED, so the class table and
  the remedies the job prints stay exactly as they were; the step also writes
  `green=true|false` and `class=<n>` to `$GITHUB_OUTPUT`.
* `Enable auto-merge` is gated on `green == 'true'` (continue-on-error alone would
  let a class 1-4 head reach the mutation) and carries `continue-on-error: true` too.
* A new `Report an unarmed head` step runs when either did not succeed and updates
  ONE marker comment with the class and its remedy — a check run that is green by
  design can no longer be the alarm, so the comment is, and marker-keying means a
  retried job does not spam the PR.

`scripts/head-settle_test.sh` keeps its per-class assertions (the exits did not
move), gains a `GITHUB_OUTPUT` in its harness plus an `expect_class` assertion per
class, and gains section (I), which asserts all three parts of the new contract.
The harness update is itself the RCA of a failure this change caused: without a
`GITHUB_OUTPUT` the step's own output writes were a redirect error, and case (A)
failed on the first run.

*Agent: `kde-cstream` · Claude Code session `25c0bf9d-28ad-4716-bc1b-5ca2118cc942`*
*Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)*
@aitrawog

Copy link
Copy Markdown
Contributor Author

T4 maintainer-account sign-off — head 3ac020eefbe0c48cb329a5da1d63b734dcef1d2d.

This change is the gate itself (pr-validator.yml), so it carries a T4 sign-off on the account that posted it: aitrawog. It is posted at the operator's explicit direction — the operator asked this session to take over and fix #313 — not on the agent's own initiative.

What is signed: the gate stops being able to veto a verdict it already gave. Head check-runs and Enable auto-merge gain continue-on-error: true, the enable step is additionally gated on green == 'true', and a new Report an unarmed head step comments the class and remedy. The required validate / validate verdict check, its BLOCK path, and every settle class and exit code are unchanged; the only behavioural difference is that a non-green arm job completes as SUCCESS instead of FAILURE, which is the fix (a FAILED non-required run is what leaves a PR unstable forever — the #313 measurement).

Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)

@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 3ac020eefbe0c48cb329a5da1d63b734dcef1d2d (branch: feat/arm-does-not-poison-mergeability)

Security screen: PASS — self-modifying gate change (T4) carries a valid maintainer-account sign-off from @aitrawog (in the configured set), naming this head, posted at operator direction; authorship is irrelevant under the account-gated model. The required validate / validate verdict gate and its BLOCK path are untouched; only the non-required arm job's conclusion changes, and its alarm is preserved as a marker-keyed comment. No secrets, no new deps, github-script pin unchanged.

Checklist: All applicable rules PASS or NA.

  • Change class: CI workflow + its test script. The repo's own gate (workflow-checks.yml scripts) is the correct gate for this class; pasted output (15 suites, head-settle_test cases A–I incl. expect_class, mutation proofs) is internally consistent and matches the diff.
  • The new Report an unarmed head JS path cannot execute before this installs (it only fires on a failing arm on a real PR) — ground rule 3: not self-blocking; mechanism is statically asserted (I1/I2/I3) and the tier is endorsed by the sign-off.
  • Comment disposition: T4 sign-off (@aitrawog, comment 7102358266) → verified-non-blocking / valid sign-off.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 23, 2026 13:22
@github-actions
github-actions Bot merged commit 33d4b2a into main Nov 23, 2026
4 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 23, 2026
github-actions Bot pushed a commit that referenced this pull request Nov 23, 2026
* fix(arm): a CLEAN head is a report, not an arming failure

#313's follow-up, measured on opencharly/gst-wayland-display#12
after #314 merged. GitHub refuses `enablePullRequestAutoMerge` in TWO states, and only
one of them is a fault:

* `unstable` — some check on the head did not pass (the poison #314 removed), and
* `Pull request is in clean status` — every required check PASSED and the merge is
  available NOW, so there is nothing for auto-merge to wait for.

The second refusal is not a failure, but the step treated every non-`unstable` error as
one: the 180 s budget was spent retrying the single state in which arming is
unnecessary, and the session was told the gate had failed on a pull request that was
simply ready to merge. Measured directly on that PR once its head settled:

```
$ gh api graphql -f query='mutation { enablePullRequestAutoMerge(…) }'
{"errors":[{"type":"UNPROCESSABLE","message":"Pull request Pull request is in clean status"}]}
```

The enable step now recognises that message, logs a notice naming the state and the
remedy ("a maintainer merges this pull request") and returns — no retry, no thrown
error, and therefore no unarmed-head comment either, because nothing is unarmed: the
merge button is live.

*Agent: `kde-cstream` · Claude Code session `25c0bf9d-28ad-4716-bc1b-5ca2118cc942`*
*Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)*

* test(arm): prove both arming refusals against the shipped step

Review Block 1 on #316 is correct: the new clean-status branch shipped no test that would
fail without it, and the body's only "proof" was the hope that the PR's own arm job would
take the path. This adds the deterministic coverage.

`Enable auto-merge` is shipped JAVASCRIPT (`uses: actions/github-script`), so the shell
`run:` extraction does not reach it. `scripts/lib-org.sh` gains `extract_step_script`, the
same one-algorithm/different-selector helper the shell steps use, and
`scripts/arm-enable_test.sh` runs the EXTRACTED text under node with mocked
`github`/`context`/`core`:

  1. `Pull request is in clean status` -> the step returns and emits the CLEAN notice
     (fails without this change);
  2. the pre-#316 shape, with EXACTLY that branch removed, THROWS on the same input — the
     negative control, so the coverage can fire and cannot rot into a tautology;
  3. an unrelated refusal ("Resource not accessible by integration") still throws, so the
     recogniser is narrow rather than a blanket swallow.

Registered in `workflow-checks.yml` beside the head-settle test, which it mirrors.

*Agent: `kde-cstream` · Claude Code session `25c0bf9d-28ad-4716-bc1b-5ca2118cc942`*
*Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)*

* test(arm): the happy path is asserted too, and the header says only what runs

Review round 2 on #316, three findings, all in the test and the body:

* R1/QUAL — the test's header listed "no refusal -> arms and verifies" as assertion 3
  while the implementation's third case was the narrow-recogniser case, and the harness
  could never reach its success path at all (the mutation branch returned before the
  `armed` branch). The header claimed coverage the code did not have. Fixed by ADDING the
  assertion rather than by trimming the claim: the harness's mutation now SUCCEEDS for
  `mode=armed` and the following read reflects the armed state, so case (4) runs the
  verification line (`Native squash auto-merge verified`) and asserts it was reached.
* A1 — the Summary now accounts for every file in the diff (`pr-validator.yml`, the
  `extract_step_script` helper, the test, and its registration in `workflow-checks.yml`).
* A1/A3 — "How tested" pastes `arm-enable_test.sh`'s own output and drops the conditional
  ("will take the clean-status path if its head is green"), which was never evidence.

*Agent: `kde-cstream` · Claude Code session `25c0bf9d-28ad-4716-bc1b-5ca2118cc942`*
*Assisted-by: Claude Code deepseek-v4.1-flash (fully tested and validated)*
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