Skip to content

validate / arm deadlocks: its own failed check run keeps the PR 'unstable', so a PASS never arms auto-merge #313

Closed

Description

@aitrawog

Finding (R1)

The validate / arm step of the org charly/pr-validator workflow can deadlock a PR permanently: it refuses to arm while GitHub reports the pull request as unstable, and its own failed check run is what makes the pull request unstable.

Measured 2026-11-23 on opencharly/gst-wayland-display#12, head 7071384:

$ gh api repos/opencharly/gst-wayland-display/commits/7071384.../check-runs --jq '.check_runs[]|"\(.name) \(.status) \(.conclusion)"'
2 cargo fmt completed success
2 harness (full · GPU) completed skipped          # not a required check
2 harness (lint · build · unit) completed success
1 validate / arm completed failure                # <- the only red run on the head
1 validate / lint completed success
1 validate / validate completed success

The ruleset's required checks are cargo fmt, harness (lint · build · unit) and validate / validate — all three SUCCESS. The validator's own verdict is a PASS on that head. The arm step then failed with:

attempt 24..29: Request failed due to following response errors:
 - Pull request Pull request is in unstable status — re-attempting for up to 35s more
…
##[error]Unhandled error: Error: GitHub still reports the pull request as unstable after 180s

and a re-run of the failed job reproduced it (another 3m8s failure), because by then the FIRST arm failure is itself a failing check run on the head, so mergeable_state can never return to clean.

Why it matters

A PASS verdict does not arm auto-merge, and no agent may merge manually (the rulebook forbids gh pr merge), so the PR is stuck with no legal path: the only remedy visible from inside the session is an empty push to manufacture a head where arm has not yet failed — which is exactly the kind of workaround R3 forbids.

Ask

One of:

  • have the arm step exclude its own check-run name when it decides the pull request is stable (the same way it must already ignore its own in-flight run), and
  • shorten the stability gate to the RULESET's required checks rather than GitHub's coarse mergeable_state, or
  • arm through the API/GraphQL that does not consult mergeable_state at all.

The 180 s window against a 5-minute validator is the second half of the same problem: when the validator is the newest run to finish, other checks may still be settling.

Activity

  1. added
    category:governance
    type:fix
    on Nov 23, 2026
  2. aitrawog commented on Nov 23, 2026

    @aitrawog
    ContributorAuthor

    Taking this one over and fixing it in #314, per the operator's explicit direction.

    Root cause, measured. GitHub computes mergeable_state over EVERY check run on the head — including this NON-required one. A COMPLETED FAILURE of validate / arm therefore leaves the PR unstable permanently; enablePullRequestAutoMerge is refused while unstable; and the job that must clear it has to complete in order to fail. The gate is the poison. This is the POISON class scripts/check-stalled-automerge.sh shape 3 already documents for the REQUIRED context (validate / validate), one level down — the script's own vocabulary named the mechanism a year of #229/#248 work had already established.

    The fix (PR #314), in three parts, because any two alone leave a hole:

    1. 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. Exit codes and annotations are UNCHANGED — the class table, titles and remedies stay exactly as they were — and the step now also writes green=true|false and class=<n> to $GITHUB_OUTPUT.
    2. Enable auto-merge is gated on green == 'true' (without the gate, class 1–4 heads would reach the mutation) and carries continue-on-error: true itself.
    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. This is required, not optional: with the check run green by design, the comment is the only alarm left — otherwise the fix would trade a deadlock for a silent stall, which is exactly what check-stalled-automerge.sh exists to catch.

    On the issue's other two "ask" options: I did NOT shorten the stability gate to the ruleset's required checks, and did not bypass the mutation. Once the arm job can no longer poison the head, mergeable_state settles normally and the existing bounded unstable tolerance does the job it was written for; the settle loop above it (3900 s derived budget) already handles the "other checks are still finishing" half, and a genuine 180 s exhaustion is now a reported non-arming rather than a dead PR.

    Proof: scripts/head-settle_test.sh keeps its per-class exit assertions, gains a GITHUB_OUTPUT in its harness and an expect_class assertion per class, and gains section (I) asserting all three parts above. Mutation run pasted on the PR: removing continue-on-error, removing the green gate, and dropping the class-4 report each turn the suite red.

    Landing order from here: #314 merges → gst-wayland-display#12 gets a fresh arm run on a NEW head (its current head still carries the pre-fix failed arm run, so a re-run there may be refused by that history alone — the honest expectation), which is what unblocks opencharly/gst-wayland-display#5, #8 and #11 and then the cstream chain.

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

  3. aitrawog commented on Nov 23, 2026

    @aitrawog
    ContributorAuthor

    STATUS — the fix is proven live, and it exposes ONE remaining gap: it prevents new poisoning but cannot heal a head poisoned before it landed.

    Measured on opencharly/gst-wayland-display#12, head 7071384, first run of the FIXED workflow (attempt 5; the new Report an unarmed head step is present in the job's step list, so pr-validator.yml@main was re-resolved):

    validate / lint           completed success
    validate / validate       completed success
    validate / arm            completed success        <- the job no longer fails
    # GitHub GraphQL: autoMergeRequest null, mergeStateStatus CLEAN, mergeable MERGEABLE
    

    So the self-perpetuating half is gone: the arm job completes SUCCESS, and the pull request reads CLEAN where it had been UNSTABLE for hours. What the enable step still hit, from its own log:

    Error: GitHub still reports the pull request as unstable after 180s:
     - Pull request Pull request is in unstable status
    

    and the new report step posted its class-0 comment, exactly as designed.

    Why it is still refused. That head carries 21 check runs (filter=all), left by the pre-fix rounds:

    137723372074 validate / validate  completed/failure
    137656741900 validate / arm       completed/failure
    137653183379 validate / arm       completed/failure
    137643488301 validate / arm       completed/cancelled
    137643321951 validate / validate  completed/cancelled
    … (the rest success/skipped, plus 137726375410 validate / arm completed/skipped)
    

    enablePullRequestAutoMerge still consults that history even though GraphQL's mergeStateStatus reports CLEAN — the same POISON shape scripts/check-stalled-automerge.sh shape 3 describes, now on the MERGE MUTATION rather than on the merge button. A re-run cannot clear it: check runs are attached to the SHA, so every re-run adds to the same polluted set (that is also why a replacement PR on the same branch tip would not help — it would carry the identical history).

    The only clean escapes, stated so the choice is explicit:

    1. a NEW COMMIT on the branch — a new SHA, an empty history. The branch is level with origin/stable (git rev-list HEAD..origin/stable → 0), so gh pr update-branch has nothing to merge, and manufacturing an empty commit to reset platform state is exactly the workaround R3 forbids. It must carry real work (the MouseScroll arm test, fix(ci): align the auto-merge engine to the org-wide guarded canonical with the finalize-guard fix #13, is the filed candidate).
    2. a maintainer-account merge of the already-green PR — the operator's call, since agents may not merge.

    Nothing else in the gate is open: I am not shipping either without direction.

    Agent: kde-cstream · Claude Code session 25c0bf9d-28ad-4716-bc1b-5ca2118cc942
    Assisted-by: Claude Code deepseek-v4.1-flash (analysed on a live system)

  4. aitrawog commented on Nov 23, 2026

    @aitrawog
    ContributorAuthor

    RESOLVED — fixed in two merged, tagged PRs, and the remaining after-effect is documented where it belongs.

    What landed:

    • fix(arm): a non-green head is reported, never completed as a failed check run #314 → merged, tagged v2026.327.1322. A non-green arm job is REPORTED (annotations + one marker comment) and never completes as a FAILED check run, because that failure was what made a pull request permanently unstable — the gate poisoning the condition it waits on. Enable is gated on green == 'true' and carries continue-on-error.
    • fix(arm): a CLEAN head is a report, not an arming failure #316 → merged, tagged v2026.327.1411 (auto-armed by the fixed logic itself). GitHub's SECOND refusal, Pull request is in clean status, is recognised as "every required check passed; a maintainer merges it" instead of a 180 s retry that ends in a thrown error. Proven by four extracted-text assertions with a negative control.

    And the honest limit, measured: the fix prevents new poisoning but cannot heal a head poisoned BEFORE it landed. gst-wayland-display#12's head carried 21 check runs from the pre-fix rounds (a failed validate / validate, three failed/cancelled validate / arm), and check runs attach to the SHA — so the mutation refused while the head was unstable and refused again once it was clean. That head was landed by a maintainer merge at the operator's explicit authorization (64a6f4f), not by auto-merge. A head that reaches the fixed gate with a clean history arms normally: #316 itself did.

    Why this issue outlived its PR: #314's body wrote Closes **opencharly/.github#313** — the bold markers around the reference stop GitHub's auto-close from recognising the keyword, so the link never fired. Recorded here because the next body that bolds an issue reference will do the same.

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:governancetype:fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions