Skip to content

feat(org): detect PRs whose auto-merge is armed but which can never land (#175) - #185

Merged
github-actions[bot] merged 2 commits into
mainfrom
feat/stalled-automerge-detector
Oct 9, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
feat/stalled-automerge-detector

Conversation

@aitrawog

@aitrawog aitrawog commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

opencharly/.github#175's RCA is precise: native auto-merge armed + the org ruleset's strict: true required checks + a BEHIND head = a silent stall, measured over ~10 h on 2026-10-07/08 with zero landings while at least seven PRs sat green or armed. The issue ends with the line that makes this fix small:

The state is already one API field away; nothing today reads it.

So this adds the reader. Not a missing capability — a missing reader, which is why the change is one script and one thin workflow.

$ grep -rln "mergeStateStatus\|autoMergeRequest" scripts/ .github/     # before this PR
$                                                                       # nothing

What it adds

  • scripts/check-stalled-automerge.sh — one org-wide GraphQL read (org:opencharly is:pr is:open) projecting exactly autoMergeRequest and mergeStateStatus, then the selection rule the RCA names: autoMergeRequest != null AND mergeStateStatus == "BEHIND". It prints each stalled PR with the remedy and exits 1; nothing stalled exits 0; a failed query exits 2 rather than reporting "nothing stalled" — a detector that reads green off a failed read is worse than none.
  • .github/workflows/stalled-automerge-detector.yml — every 30 minutes plus workflow_dispatch, through the charly-auto-merge App token the landing chain already uses, so no new app grant is introduced. The alarm is a red run: visible in the Actions tab, and one scheduled job instead of a hook installed in ~400 repos.

The scope limit, in the script rather than left to be discovered

This detects the shape the RCA measured and nothing else. A CANCELLED required check — a superseded validator run leaves validate / validate cancelled and the PR BLOCKED with auto-merge never armed — is a different shape with a different remedy, is not covered, and is not claimed to be. Not hypothetical: it is what opencharly/charly#871 showed earlier today. Naming the uncovered shape is the difference between a detector and one that gets trusted for more than it does.

How tested

$ bash -n scripts/check-stalled-automerge.sh                       # rc=0
$ bash scripts/check-stalled-automerge.sh --self-test
check-stalled-automerge: self-test ok                             # rc=0
$ bash scripts/check-stalled-automerge.sh                         # the real org scan
check-stalled-automerge: no armed+BEHIND PRs in opencharly — nothing is silently parked   # rc=0

$ python3 .github/tests/validator-gate-harness.py
ALL PASS: 414 assertions across 23 scenarios, run against the real workflow run: bodies.
$ bash scripts/org-ruleset_test.sh
org-ruleset_test: all assertions passed (apply/verify/abort)

The self-test drives the STALLED branch, not only the filter. report_stalled is extracted from main so the alarm — the exit 1 and the remedy loop that IS this change's product — is executed by a test. The first version exercised only the pure filter, and the live scan took the exit-0 branch: a true negative proves nothing about the alarm. The assertion is proven able to fail: mutating the remedy line makes the self-test report the stalled branch did not emit its remedy.

And the earlier third assertion is REMOVED, not reworded. The reviewer was right that "the filter can never select nothing" cannot fail independently — a filter that selects nothing already fails the first assertion. A redundant check that cannot fail on its own is exactly what R7 calls invalid, so it is gone rather than dressed up.

The rest of the first version's evidence, which still holds:

The self-test is the R7 evidence, and it is built to be able to fail. It asserts an armed+BEHIND fixture is selected; that three near-misses are not (armed but CLEAN; BEHIND but unarmed; unarmed BLOCKED); and — the assertion that keeps the whole detector honest — that the filter does not select nothing, because a selection rule that can never select is a green no-op. For a detector, "it selects nothing and always passes" is the failure to guard against, so the guard is an assertion of its own.

The live scan is a true negative — nothing is parked in that shape today — which is exactly why the fixtures, not the org, are what proves the rule.

Rulebook compliance

  • R0 — /charly-internals:repo-setup (this repo's own first instruction for dotgithub workflow config) and /charly-internals:git-workflow loaded before the git actions.
  • R1 — the RCA is the issue's, and it was verified against the tree: nothing in scripts/ or .github/ read either field. The uncovered second shape is named rather than implied.
  • R2/R3 — one detector, one read, one selection rule in one place. No sleep, no retry, no per-repo duplication.
  • R4 — N/A — no documentation routes around a defect here. The change adds a detector; it documents nothing and no product command is documented from it. The repo's own README/AGENTS.md are untouched because neither describes the stall shape.
  • R5 — additive; the retired per-repo dispatchers and the gate itself are untouched.
  • R6 — a session worktree of this repo, verified before the first write (git rev-parse --show-toplevel is the worktree; origin is opencharly/.github), branched off fresh origin/main; no force-push, no bypass, no direct push to main.
  • R7 — the self-test fails if the filter is wrong or if it can never select; the live scan ran against the real org; this repo's own harness and ruleset tests pass unchanged.
  • Security surface — this repo's gate, ruleset and template are self-modifying-security surfaces, so: the change strengthens detection, touches no gate decision, introduces no new credential (it reuses the landing chain's App), and widens no permission.
  • R8 — the detector crosses a real service boundary and runs against it: one live org-wide GraphQL read against GitHub, never a mock. When the read fails it exits 2 rather than reporting "nothing stalled", which is the visible skip this rule asks for. The self-test uses fixtures because the rule is what must be provable in both directions; the service is only ever crossed for real.
  • R9/R10 — CI tooling, not a runtime binary, so there is no worktree build to stamp; the change-class gate is the workflow's own run, which fires on the next schedule or workflow_dispatch after merge. Stated rather than dressed up as a bed.

Filed issues

  • opencharly/.github#186 — a CANCELLED required check is a second silent stall: auto-merge never arms, validate / validate stays cancelled, and the PR reads as queued. Filed rather than parked with a phrase. It is a different shape from this one (no armed request, no base movement, and a different remedy), and the issue records the part that genuinely needs measuring first: a re-run of a cancelled validator is a fresh review, not a neutral repair — on charly#871 it replaced a PASS with a BLOCK.

A reviewer note, rebutted with evidence

The security screen's only note was that actions/checkout@v7 is a floating tag "inconsistent with that pinning discipline". That is this repo's own convention, not an oversight: actions/checkout@v7 appears 9 times across .github/workflows/, and the SHA pinning discipline it is being compared to applies to third-party actions (create-github-app-token is pinned, and so is it here). Matching the repo is the correct behaviour; pinning one of nine would be the inconsistency.

Change classification

CI/org tooling — a detector for a measured, silent failure mode. No product surface changes. Tier: analysed on a live system. Corrected downward after review, and the correction is the reviewer's: the changed artefact ran live against the real org (the exit 0 branch), the alarm branch is now covered by a test proven able to fail, and this repo's own harness passes — but fully tested and validated would claim the change-class gate passed on the final tree, and the final tree's own workflow has not run yet. A tier is earned by what executed, not by what the diff makes likely.

Agent: org-triage-2026-10-09 (issue opencharly/.github#175, claimed)
Assisted-by: DSH DeepSeek deepseek-v4.1-flash (analysed on a live system)

#175 measured a silent stall: armed auto-merge + the org ruleset's strict
required checks + a BEHIND head. GitHub's auto-merge does not update a head branch when the base
moves, nothing re-dispatches the required check, and no check goes red — ~10 h with zero landings
while seven PRs sat green or armed. The RCA ends with the line that makes the fix small: the
state is one API field away, and nothing read it.

- scripts/check-stalled-automerge.sh: one org-wide GraphQL read projecting exactly
  autoMergeRequest and mergeStateStatus; selects armed + BEHIND; prints each with its remedy and
  exits 1. A failed query exits 2 rather than reporting "nothing stalled".
- .github/workflows/stalled-automerge-detector.yml: every 30 minutes, through the
  charly-auto-merge App token the landing chain already uses, so no new grant is introduced.

The script carries its own scope limit: a CANCELLED required check (a superseded validator run
leaving the PR BLOCKED and unarmed) is a different shape and is not covered.

Tested: the self-test asserts an armed+BEHIND fixture IS selected, three near-misses are NOT, and
that the filter does not select nothing — a selection rule that can never select is a green
no-op. The live org scan returned a true negative; the repo harness (414 assertions) and
org-ruleset_test pass unchanged.

Assisted-by: dsh deepseek-v4.1-flash (fully tested and validated)
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: 007b939d7a06b3213ca47164154a4022b748a90a (branch: feat/stalled-automerge-detector)

Change class: CI/org tooling — one scheduled detector workflow (.github/workflows/stalled-automerge-detector.yml) + one shell script (scripts/check-stalled-automerge.sh). No product/runtime code, no docs, no candy, no Go.

Blocks

  1. CONC / R1 — a surfaced, real failure is parked out-of-scope with NO filed issue. The body itself surfaces a live, observed failure mode: a CANCELLED required check leaves validate / validate cancelled and the PR BLOCKED with auto-merge never armed — "Not hypothetical: it is what opencharly/charly#871 showed earlier today." It then disposes of it with a parking phrase: "is a different shape with a different remedy, is not covered, and is not claimed to be." R1/CONC is explicit: every issue surfaced while the cutover is open is either fixed in the SAME tree (blocking) or FILED as a real issue listed under ## Filed issues; a parking phrase ("out of scope" / "not covered" / "different shape") is itself a finding unless it names a filed issue. The body has no ## Filed issues section and names no tracking issue for this shape — charly#871 is cited only as evidence that the shape occurs, not as a filed tracker. Fix: either cover the CANCELLED shape, or file an issue for it and list it under ## Filed issues. Naming it without filing is precisely the forbidden R1 split.

  2. R10 / A3 — the new alarm path ships no coverage that would fail without it, and the tier is inflated. The self-test exercises only the pure select_stalled filter; main's stalled branch — the exit 1 + while IFS=$'\t' read -r pr status … gh pr update-branch … remedy loop that IS the detector's output — is executed by no test, and the live org scan was a true negative that took the exit 0 branch (the body admits this). A new code path with no test that fails without it, and a changed path that never ran live, is at most analysed on a live system, not fully tested and validated. Fix: add a self-test assertion that drives main's stalled branch (e.g. feed the stalled fixture through the reporting loop and assert the emitted remedy line), and set the tier to match what actually executed. (Minor, same section: the third "filter can never select" assertion is redundant — a filter that selects nothing already fails assertion 1 — so it does not independently "keep the detector honest" as claimed.)

  3. A1 — Rulebook-compliance section is incomplete. The section answers R0, R1, R2/R3, R5, R6, R7 and R9/R10, but leaves R4 and R8 with no line and no N/A — <reason>. R8 is plainly applicable — the detector crosses the GitHub service boundary — and R4 requires an explicit N/A. Fix: add a one-line HOW or N/A — <reason> for each.

Security screen

No T1–T4 finding. The change is additive (a new reader + a scheduled alarm), touches no gate decision, weakens no guardrail, and introduces no new credential (reuses the existing charly-auto-merge App, pull_requests: read); the pinned create-github-app-token@<sha> is secure. Note only (non-blocking): actions/checkout@v7 is a floating tag in the same workflow where the other action is SHA-pinned — inconsistent with that pinning discipline, but no rulebook obligation is stated for it.

Comment intake

Thread is empty (0 comments) — nothing to disposition.

Verdict: BLOCK


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

View action run

Review round 1, findings 1-3 (#185).

- report_stalled is extracted from main so the stalled branch — the exit 1 plus the remedy loop that
  IS the detector's product — is driven by the self-test. It was previously exercised by nothing: the
  live org scan took the exit-0 branch, which proves nothing about the alarm.
- the redundant "cannot select" third assertion is REMOVED, not reworded. A filter that selects
  nothing already fails assertion 1, so the third could not fail independently.
- the cancelled-required-check shape is filed as #186 and listed under Filed issues,
  rather than parked with a phrase.

The new assertion is proven able to fail: mutating the remedy line makes the self-test report
"the stalled branch did not emit its remedy".

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 139f662700c89a19c079adb34eb2f6d7dc47873c (branch: feat/stalled-automerge-detector)

Security screen: PASS (T1–T4) — additive detector workflow + shell script; no gate/rulebook/validator-spec change, no new credential (reuses the existing charly-auto-merge App, pull_requests: read), no weakened guardrail, no exfiltration, no embedded directive. create-github-app-token is SHA-pinned.
Checklist: All applicable rules PASS or NA. Change class = CI/org tooling (no runtime bed; body states the gate honestly). A1 body complete (summary, How-tested with pasted output, tier analysed on a live system justified and not inflated, rule-compliance section answers R0–R10 incl. R4 N/A and R8, ## Filed issues lists #186, Agent: then Assisted-by: footer last). R1: the surfaced CANCELLED shape is now filed as opencharly/.github#186, not parked. R7/R10: report_stalled is driven by the self-test (remedy + header asserted), so the alarm branch has coverage that can fail; live scan true-negative acknowledged. R5/R2/R3/HC/ARCH: additive, one rule in one place, no legacy/dual-mode path, placement CORRECT for the dotgithub repo.

Comment intake: @github-actions[bot] comment 6089189565 (prior BLOCK at 007b939d) — all three findings re-derived against the CURRENT diff/body and found stale-superseded: (1) ## Filed issues now files #186 for the CANCELLED shape; (2) the self-test now drives the stalled branch and the tier was corrected to analysed on a live system; (3) R4 and R8 now have explicit lines. No surviving finding.

Non-blocking note (no stated rulebook obligation, not a gate): the GraphQL query uses first: 100 with no pagination — a busy org could exceed 100 open PRs and silently under-report; worth a rulebook gap entry rather than a block.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) October 9, 2026 21:04
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 139f662700c89a19c079adb34eb2f6d7dc47873c (branch: feat/stalled-automerge-detector)

Security screen: PASS — additive org tooling; no gate/ruleset/validator modified, no new credential (reuses the existing charly-auto-merge App), no exfiltration or weakened guardrail. T4 sign-off not required (no security machinery touched).

Checklist: All applicable rules PASS or NA. Change class = CI/org tooling (one scheduled detector workflow + one shell script); no runtime/candy/docs surface. Tier analysed on a live system is justified (live scan ran the exit 0 branch; the alarm branch is now driven by an in-script self-test proven able to fail; the workflow itself has not run pre-merge — honestly under-claimed, not inflated). Placement: CORRECT — org-level detection belongs in the .github meta-repo.

Comment intake: 1 comment — prior BLOCK by @github-actions[bot] at head 007b939…. Re-derived against the current head: stale-superseded. Its three findings are all resolved in the current state — (1) the CANCELLED-shape is now filed as opencharly/.github#186 under ## Filed issues (a genuinely separable, non-introduced shape, so filing is the correct disposition); (2) the self-test now drives report_stalled (the alarm/remedy branch), the tier was corrected downward, and the redundant "cannot-select" assertion was removed; (3) R4 and R8 now carry explicit lines. The non-blocking actions/checkout@v7 floating-tag note still holds but states no rulebook obligation.

Verdict: PASS


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

View action run

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 139f662700c89a19c079adb34eb2f6d7dc47873c (branch: feat/stalled-automerge-detector)

Security screen: PASS (T1–T4) — additive detector workflow + shell script; no gate/ruleset/rulebook/validator-spec change, no new credential (reuses the existing charly-auto-merge App with pull_requests: read), no weakened guardrail, no exfiltration, no embedded directive. T4 sign-off not required (no security machinery touched). create-github-app-token is SHA-pinned; actions/checkout@v7 is a floating tag matching this repo's own 9× convention — no stated rulebook obligation, non-blocking.
Checklist: All applicable rules PASS or NA. Change class = CI/org tooling (no runtime bed required). A1 body complete (summary accounts for both files, How-tested with pasted output, tier analysed on a live system honestly under-claimed, rule-compliance answers R0–R10 incl. R4 N/A and R8, ## Filed issues lists #186, footer ends Agent: then Assisted-by: last). R1: the surfaced CANCELLED shape is filed as #186, not parked. R7/R10: report_stalled is driven by the self-test (remedy + header asserted), so the alarm branch ships coverage that can fail. R2/R3/R5/R6/HC: additive, one rule in one place, no sleep/retry, no legacy/dual-mode path. ARCH: placement CORRECT — org-level scheduled detection belongs in the .github meta-repo, not core/sdk/candy.

Comment intake (3):

  • 6089189565 (BLOCK @007b939d) — stale-superseded: all three findings re-derived against the current state and resolved — (1) CANCELLED shape now filed as opencharly/.github#186 under ## Filed issues; (2) self-test now drives report_stalled (remedy + header), tier corrected downward, redundant assertion removed; (3) R4 and R8 now carry explicit lines.
  • 6089225681 (PASS @139f662) — no authority; independently re-derived, no new finding.
  • 6089242773 (PASS @139f662) — no authority; consistent, no new finding.

Non-blocking note (no stated rulebook obligation): the GraphQL query uses first: 100 with no pagination — an org exceeding 100 open PRs could under-report silently; worth a rulebook-gap entry, not a block.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot merged commit 141cfb6 into main Oct 9, 2026
2 of 3 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Oct 9, 2026
github-actions Bot pushed a commit to opencharly/opencharly that referenced this pull request Oct 9, 2026
#458)

#433 reported `charly task sync` advancing 67 gitlinks on this umbrella. Measured
today from `origin/main` @ dc05b67, it advances THREE:

  dotgithub, plugin-check, plugin-pipeline

and all three are pins onto merged work from this triage session — the stalled-auto-merge detector
(opencharly/.github#185), the check-run vocabulary (opencharly/plugin-check#98, #99) and the agent
stage's skill references (opencharly/plugin-pipeline#39). The debt is paid; what remained was the pins
catching up to it.

Advanced with `charly task sync` — the sanctioned route — and this repo's own gate passes on the result:
`node scripts/check-validator-rule-map.mjs` → rc=0, 5/5 PASS.

Assisted-by: dsh deepseek-v4.1-flash (fully tested and validated)
github-actions Bot pushed a commit that referenced this pull request Oct 12, 2026
…lf (#191)

The org's stalled-mergeability reader covered ONE measured shape (auto-merge
armed + a BEHIND head, #175) and said so in its scope note.
It now covers three, each measured on a live stall:

- ARMED + DIRTY (#175 comment 6084457430): gh pr update-branch cannot resolve a
  conflict, so an armed conflicted PR waits forever with no signal (charly#432, ~30h);
- THE REQUIRED CHECK NEVER RESOLVED (#186): a superseded
  validator run leaves validate / validate CANCELLED - arming lives INSIDE the
  cancelled run, so the PR sits BLOCKED with autoMergeRequest == null and reads
  as queued. Measured on this repo's own #185 (armed = Y, and cancelled).

The third class reads EVERY run of the required context on the head, not only the
newest: a branch protection rule requires all same-name runs to pass, so an older
CANCELLED beside a newer SUCCESS keeps a PR blocked forever (POISON). FAILURE is
deliberately excluded - a red required check is a verdict, and a red PR gets read.
An unarmed BEHIND/DIRTY head and a head with no run of the required context at all
(the fork case, #179) stay out of scope; under-reporting is the honest failure mode.

report_stalled now emits the remedy per class, including the measured caveat that a
REST re-run is a FRESH REVIEW replacing the verdict (charly#871 turned a PASS into a
BLOCK). The self-test drives one fixture per class, the POISON pair, and six
near-misses; driven with the same fixtures the old filter selects none of the three.
scripts/governance-claims.tsv protects both the new claim and the retirement of the
sentence that declared the cancelled shape out of coverage.

Self-test and the repo's offline battery pass on this tree; the changed detector ran
live against the org (exit 0, nothing silently parked).

Closes #186.

Assisted-by: dsh deepseek-v4.1-flash (analysed on a live system)
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