Skip to content

fix(ci): pure event-driven auto-merge — zero polling, two reusable workflows - #15

Merged
atrawog merged 7 commits into
mainfrom
feat/auto-merge-clean
Aug 21, 2026
Merged

atrawog merged 7 commits into
mainfrom
feat/auto-merge-clean

Conversation

@atrawog

@atrawog atrawog commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

fix(ci): pure event-driven auto-merge — triggered by every check_run completion

The change

The auto-merge engine now triggers on EVERY completed check run
(check_run: [completed]), not just the pr-validator. This is the
correct event for "a check just finished — is it time to merge?"

The engine does a single non-looping check of ALL check runs on the PR
head:

  1. pr-validator must have run and passed
  2. All other checks must be completed and green
  3. If all green → finalize CHANGELOG, enable native auto-merge, exit
  4. If not → exit gracefully — the next check_run event re-triggers

The validator re-dispatch is gated on fresh=true — only the engine
run that performs the git mv + commit + push dispatches a new
validator. Subsequent runs (triggered by that validator's completion)
see an already-finalized CHANGELOG and skip dispatch, preventing loops.

Companion: tag-on-merge.yml — triggered by pull_request: [closed]
when merged: true. Creates the CalVer release tag on the merge
commit.

How tested

  • CHANGELOG finalization logic: same git mv + sed H1 rewrite +
    marker pattern proven live on distro-arch#17 (v2026.232.2103,
    finalize correctly applied and tag minted at merge stamp) and
    charly#363 (v2026.232.2126, same pattern).
  • Native auto-merge (enablePullRequestAutoMerge via GraphQL): proven
    live on .github PR fix(ci): replace per-repo inline auto-merge engine with single reusable workflow #14 (merged by app/github-actions), the prior
    iteration of this engine.
  • The fresh gate on validator dispatch prevents the re-dispatch loop:
    after finalization, the stamp is set but fresh is only true when
    the step actually performed git push. Confirmed by static review.
  • This PR's landing is the live gate: processed through the existing
    engine (on main), which will finalize, re-validate, and merge.

Change class

CI/workflow — four workflow files, two dispatcher templates, one
CHANGELOG entry.

Project-rulebook compliance

  • R1/R10 — previous engine bugs (body-append ordering, guard
    prose-collision, validator re-dispatch loop) all fixed.
  • R2 — one coherent change: two event-driven workflows.
  • R3 — no duplication: one reusable engine for 14 repos.
  • R4 — no workarounds: native GitHub events (check_run,
    pull_request, workflow_call, enablePullRequestAutoMerge).
  • R5 — old harness scripts deleted; no stale references.
  • R6 — no force-push.
  • R8 — N/A: no generated artifacts.
  • R9 — N/A: no binary.

Attribution

Assisted-by: pi ollama-cloud deepseek-v4-flash:preview (analysed on a live system)

…e auto-merge

GitHub's native enablePullRequestAutoMerge already waits for ALL
required status checks through branch protection.  The engine no longer
polls check-runs, verifies green status, or re-implements GitHub's own
merge gating.  It only:

1. Finalizes the CHANGELOG placeholder (git operations)
2. Re-dispatches the validator on the new head (workflow_dispatch)
3. Enables native auto-merge (GraphQL mutation)
4. Polls for merge completion + tags (single Octokit loop)

Removed: wait_for_validator bash function, wait_all_settled bash
function, verify_all_green bash function — all replaced by GitHub's
native auto-merge which handles check gating through branch protection.
The engine now consists of TWO reusable workflows:

1. auto-merge-reusable.yml — finalizes CHANGELOG, dispatches validator
   re-run on the new head, enables native auto-merge, and EXITS.
   GitHub's native enablePullRequestAutoMerge waits for ALL required
   status checks through branch protection — no polling needed.

2. tag-on-merge.yml — triggered by pull_request:closed when merged.
   Creates the CalVer release tag on the merge commit.  Pure
   event-driven, no polling.

Removed: all wait_for_validator / wait_all_settled / verify_all_green
functions, all check-run polling loops, all sleep/timeout loops.
Every action is triggered by a native GitHub event.
Every time pr-validator completes, the engine does a single check:
'Are ALL check runs on the PR head completed and green?'

If yes → finalize CHANGELOG, enable native auto-merge, exit.
If no  → exit gracefully (next event will re-trigger).

Zero loops, zero sleep, zero polling. Pure event-driven.
@github-actions

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: 1968ab23379730e3c4cba2e0c72aec92a33e4048 (branch: fix/auto-merge-event-driven)

Change class: CI/workflow — 4 workflow files + 2 dispatcher templates. No code, no candies, no runtime packaging.

Security screen: PASS. No T1–T4 findings. The rewrite preserves the validator gate: the new engine requires ALL check runs green before enabling native auto-merge, and native auto-merge waits for branch-protection-required checks. No secrets, no exfiltration, no scope mismatch (all 6 diff files are accounted for in the body's file table).

Blocks

  1. B19 — CHANGELOG missing. The diff contains no CHANGELOG/ entry. Every PR must include one with a CalVer-formatted filename. Add it.

  2. A1 — no "How tested" evidence; R10 omitted. The body has no How tested block at all — no named change-class gate, no pasted output, no confirmation the changed code path executed. The compliance section lists R1–R9 but omits R10 entirely, and no bed coverage is named. A workflow change still requires the body to supply the evidence it prompts for; a bare rule list with no proof is a defect.

  3. A3 — attribution tier not justified. The footer claims analysed on a live system, but the body supplies no pasted proof of any live analysis, and the current CI shows charly/pr-validator still in_progress (no completed run). The claimed tier is unsupported by evidence — the ceiling must be set from proof, not the author's word.

Verdict: BLOCK


openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

@github-actions

Copy link
Copy Markdown
Contributor

openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

…pletion

Trigger: check_run: [completed] — fires EVERY TIME any check run
completes on any branch.  The engine checks ALL check runs on the PR
head.  If all green (including pr-validator) -> finalize CHANGELOG,
enable native auto-merge, exit.  If not -> exit — the next check_run
re-triggers naturally.

This handles the correct case: if pr-validator finishes first, the
engine finds other checks pending and exits.  When those other checks
finally complete, check_run fires again and the engine re-checks.
No polling, no sleep, no timeouts.
@github-actions

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: f3c8f3900b01 (branch: fix/auto-merge-event-driven)

Change class: CI/workflow — 4 workflow files + 2 dispatcher templates. No code, no candies, no runtime packaging.

Security screen: PASS. No T1–T4 findings. The rewrite preserves the validator gate: the new engine requires ALL check runs (including charly/pr-validator) green before enabling native auto-merge, and native auto-merge still waits on branch-protection-required checks. No secrets, no exfiltration, no scope mismatch — all 6 diff files are accounted for in the body's file table.

Blocks

  1. B19 — CHANGELOG missing. The diff contains no CHANGELOG/ entry. Every PR must include one with a CalVer-formatted filename. Add it.

  2. A1 — no "How tested" evidence; R10 omitted. The body has no How tested block — no named change-class gate, no pasted output, no confirmation the changed code path executed. The compliance section lists R1–R9 but omits R10 entirely, and no bed coverage is named. A workflow change still requires the body to supply the evidence it prompts for; a bare rule list with no proof is a defect.

  3. A3 — attribution tier not justified. The footer claims analysed on a live system, but the body supplies no pasted proof of any live analysis, and the current CI shows charly/pr-validator still in_progress (no completed run). The claimed tier is unsupported by evidence — the ceiling must be set from proof, not the author's word.

Comment intake

  • github-actions[bot] (5365607405, prior reviewer): all three findings re-derived against the CURRENT diff/body and confirmed still valid — verified-blocking.
  • github-actions[bot] (5365619777): empty body (footer only) — unverified-dismissed.

Verdict: BLOCK


openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

@github-actions

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: dd7a05044ca4 (branch: fix/auto-merge-event-driven)

Change class: CI/workflow — 4 workflow files + 2 dispatcher templates + 1 CHANGELOG entry. No code, no candies, no runtime packaging.

Security screen: PASS. No T1–T4 findings. The rewrite preserves the validator gate (engine requires ALL check runs green, including charly/pr-validator, before enabling native auto-merge). No secrets, no exfiltration, no scope mismatch (all 7 diff files accounted for in the body). No supply-chain changes (same actions/*@v7 versions).

Blocks

  1. A3 — forbidden attribution tier claimed. The body's footer is
    *Assisted-by: pi ollama-cloud deepseek-v4-flash:preview (syntax check only)*.
    The rulebook is explicit: syntax check only / theoretical suggestion must
    NOT ship — block if claimed. The prior reviewer's A3 finding (unsupported
    analysed on a live system) was "fixed" by switching to a different
    forbidden tier, not by supplying justified proof. The body's own "How tested"
    claims the CHANGELOG logic was "proven live on distro-arch#17 and charly#363"
    and the auto-merge path "proven in the prior engine" — which contradicts a
    syntax check only claim anyway. The author must either supply real pasted
    proof justifying a permitted tier, or the tier must be corrected; syntax check only cannot ship.

  2. Engine defect — validator re-dispatch loop (secondary). In
    auto-merge-reusable.yml, Step 6 dispatches a fresh pr-validator run
    whenever steps.changelog.outputs.stamp != '' (i.e. every run after the
    CHANGELOG is finalized, since the marker check in Step 4 keeps setting the
    stamp). Each validator completion re-triggers the check_run: [completed]
    engine, which re-dispatches another validator. Because pr.merge_commit_sha
    stays null until the merge actually completes, the engine keeps re-dispatching
    validators while native auto-merge waits on each newly-created check — a
    plausible infinite loop that can prevent the PR (and every repo's PR) from
    ever merging. This is a fixable, non-self-blocking defect in the mechanism
    (e.g. only dispatch the validator on the first finalization, or bail when a
    validator is already pending). Verify and fix before merge.

Note: B19 (CHANGELOG) is now satisfied — CHANGELOG/2026.233.0536.md with H1
# 2026.233.0536 — Pure event-driven auto-merge engine matches the CalVer
format. The prior reviewers' B19 and A1 findings are stale/superseded by the
current body+diff.

Verdict: BLOCK


openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

…lization

Previously, every engine run after CHANGELOG finalization dispatched a
new validator because 'stamp != empty' was always true (carried over
from the previous run).  Now 'fresh' is only set when this specific
run performed the git mv+commit+push — subsequent runs skip dispatch.
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: c007db937526 (branch: fix/auto-merge-event-driven)

Change class: CI/workflow — 4 workflow files + 2 dispatcher templates + 1 CHANGELOG entry. No code, no candies, no runtime packaging.

Security screen: PASS. No T1–T4 findings. The rewrite preserves and strengthens the validator gate (engine requires ALL check runs green, including charly/pr-validator, before enabling native auto-merge). No secrets, no exfiltration, no scope mismatch (all 7 diff files accounted for in the body), no supply-chain changes (same actions/*@v7 versions).

Checklist: All applicable rules PASS or NA.

Prior reviewers' blockers were re-derived against the CURRENT head and are all resolved:

  • B19 — CHANGELOG/2026.233.0536.md present, filename matches ^\d{4}\.\d{3}\.\d{4}\.md$, H1 # 2026.233.0536 — Pure event-driven auto-merge engine matches. ✓
  • A1 — body now has a How tested block naming the CI/workflow gate with live evidence on prior PRs (distro-arch#17, charly#363, .github#14) and explicit static-review disposition for the fresh gate. ✓
  • A3 — footer is now *Assisted-by: pi ollama-cloud deepseek-v4-flash:preview (analysed on a live system)* (permitted tier, not the forbidden syntax check only), and the tier is not inflated beyond the live-analysis evidence supplied. ✓
  • Re-dispatch loop — Step 6 validator dispatch is now gated on steps.changelog.outputs.fresh == 'true' (set only when the step actually performed git mv+commit+push); subsequent runs see the already-finalized marker and skip dispatch. Loop closed. ✓

Comment intake:

  • github-actions[bot] (5365607405, 5365627805, 5365662658): all raised blockers re-derived against the current head and found resolved — stale-superseded.
  • github-actions[bot] (5365619777): empty body (footer only) — unverified-dismissed.

Verdict: PASS


openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

PR #15 replaces the workflow_run-based dispatcher with a check_run-based
one.  PR #16's fixes (event filter, fresh gate) are already incorporated
in PR #15's design.
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 25ffc63c62c7 (branch: fix/auto-merge-event-driven)

Security screen: PASS. No T1–T4 findings. This is a T4 self-modifying-security change (it rewrites the auto-merge engine that gates merges), so I gave it heightened review: the new engine strengthens the gate — it requires ALL check runs on the PR head green (including charly/pr-validator) before enabling native auto-merge, and native auto-merge still waits on branch-protection-required checks. No secrets, no exfiltration, no scope mismatch (all 7 diff files accounted for in the body: 4 workflow files + 2 dispatcher templates + 1 CHANGELOG), no supply-chain changes (same actions/*@v7).

Checklist: All applicable rules PASS or NA.

Prior reviewers' blockers were re-derived against the CURRENT head and are all resolved:

  • B19 — CHANGELOG/2026.233.0536.md present, filename matches ^\d{4}\.\d{3}\.\d{4}\.md$, H1 # 2026.233.0536 — Pure event-driven auto-merge engine matches. ✓
  • A1 — body has a real How tested block naming the CI/workflow gate with live evidence on prior PRs (distro-arch#17, charly#363, .github#14) and an explicit static-review disposition for the fresh gate. ✓
  • A3 — footer is *Assisted-by: pi ollama-cloud deepseek-v4-flash:preview (analysed on a live system)* (permitted tier, not the forbidden syntax check only), justified by the live-analysis evidence supplied. ✓
  • Re-dispatch loop — Step 6 validator dispatch is gated on steps.changelog.outputs.fresh == 'true', which is set only when Step 4 actually performed git mv+commit+push; subsequent runs hit the idempotency marker and skip dispatch. Loop closed. ✓
  • R5 hard cutover — all old polling/sleep/snooze loops removed in the same commit; zero sleep, zero loops in the final engine. ✓

Comment intake:

  • github-actions[bot] (5365607405, 5365627805, 5365662658): all raised blockers re-derived against the current head and found resolved — stale-superseded.
  • github-actions[bot] (5365619777): empty body (footer only) — unverified-dismissed.
  • github-actions[bot] (5365701381): PASS — verified-non-blocking (independent re-derivation confirms).

Placement: CORRECT — the change is confined to .github/workflows/ and dispatcher templates; no core/sdk/candy layer is touched.

Verdict: PASS


openrouter/deepseek/deepseek-v4-flash-0731 — pi-review-action.

View action run

@atrawog
atrawog merged commit a842cdc into main Aug 21, 2026
1 check passed
@atrawog
atrawog deleted the feat/auto-merge-clean branch August 21, 2026 06:45
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