Skip to content

Decision: how changes should land on main — the merge queue, direct merges, or a defined mix? (83 of 123 merges since 10 Oct skipped the queue) #4873

Open

Description

@yannickmonney

Summary

The repository documents one way onto main: the merge queue. In practice two ways are in use. Since 10 October, 83 of 123 merged PRs have no merge-queue event; 80 of those merged before at least one required check had reported its first result, and 4 merged with a required check already failed or cancelled. Two regressions reached main that way and were reported by the PR's own checks after it had merged. Each direct merge also moves the base of every group waiting in the queue, so queued PRs are rebuilt: #4849 went through nine merge groups in 2.5 hours.

This issue collects the numbers and the options. It does not say which path is right and proposes no change. It asks the team to decide what the intended paths are, because right now the documented rule and the observed practice differ.

What the repository says

  • .agents/repo.md:171-176: "Land through the merge queue … never bypass the queue with an admin merge. A PR's own CI is the fast tier (format, lint, types, knip, unit, commitlint, SAST); E2E, Build, CLI, UI, Browser and backend integration run only in the queue."
  • .github/CI.md:963-995 (### Merge queue): ruleset Tale required CI, squash merges, groups of up to five, all-green grouping, a 360-minute timeout; "Most validation runs only in the queue"; its rationale cites "about 75 merges a day".
  • The ruleset (id 24697330) has the merge_queue rule and the seven CI ready (…) contexts as required checks, bypass_actors: [] at rest and current_user_can_bypass: never.
  • The ruleset's history (admin view) shows 76 short windows since 10 October in which a bypass entry (repository role admin, mode pull_request) was present, a median of about five seconds each (maximum 69 s). That is close to the number of direct merges below; it is not matched PR by PR.

What happens

Merged to main from 2026-10-10 00:00 UTC to 2026-10-12 about 16:25 UTC. "Direct" means the PR's timeline has a merged event and no added-to-merge-queue event.

Day (UTC) through the queue direct
10-10 2 33
10-11 20 30
10-12 18 20
total 40 (33%) 83 (67%)

For the 83 direct merges, from the check runs of each PR's head commit:

Two regressions reached main this way; in both cases the PR's own checks reported the problem after the PR had merged:

PR merged (UTC) what its own checks reported afterwards effect on main
#4846 11:15:00 Knip failed at 11:18, Unit (platform 2/2) at 11:23 Knip reported scripts/publish-package.ts unused on main until #4851 merged at 12:38: 83 minutes in which any PR run on top of main failed Knip with the same finding (seen on #4849 and #4850)
#4855 13:14:56 Unit (workspaces) failed at 13:25 The CLI target guard failed on main. A merge group built on it failed CLI and #4849 was removed from the queue at 13:32. It stayed red until #4857 merged at 14:00:45: 46 minutes

What it does to queued PRs

The queue builds each group on the current tip of main. When main moves, the groups are rebuilt on the new tip: a new temporary branch and seven new workflow runs. The 400 most recent merge_group runs (2026-10-11 23:22Z to 2026-10-12 14:54Z) cover 57 groups for 21 PRs. Of the 330 of them that had settled by 14:35 UTC, 247 succeeded, 18 failed and 65 ended cancelled.

PRs that saw main stay still built one group: #4844 (enqueue to merge 14 minutes) and #4851 (10 minutes). #4849 built nine between 13:03 and 14:54 and merged at 15:30, together with #4853, which had built six:

UTC event
13:03 #4849 enters the queue; group 1
13:12 #4854 merged directly
13:13 group 2
13:14 #4855 merged directly
13:15 group 3
13:32 #4849 removed from the queue (failed_checks: the CLI guard #4855 broke)
13:51 #4849 added again; group 4
14:00 #4857 merged directly (it fixes the CLI guard)
14:01 group 5
14:04 group 6
14:21 #4858 merged directly; group 7
14:47 #4861 merged directly
14:48 group 8
14:53 #4862 merged directly
14:54 group 9
15:30 #4849 and #4853 merged

Six of the nine builds started within two minutes of a direct merge. Two are the first build and the re-entry; one (14:04) I cannot tie to an event.

Direct merges are not the only cause of waiting. #4384, #4325 and #4682 merged 128 to 171 minutes after their last enqueue with no direct merge in between, each after two removals. Across the 40 queue-merged PRs the removals were: failed_checks 39, manual 51, merge_conflict 3, queue_cleared 2.

On the runner side, .github/CI.md:968 states the budget: the free plan "runs about 20 jobs at once across every PR and queue run, a full merge-group run needs dozens … a queued run can wait hours for a runner". At 14:34 UTC the Commitlint run of #4849's live group, whose one job takes about half a minute when it runs, had been queued for 13 minutes. See #4874 for the runs of dissolved groups.

What this issue does not claim

  • That direct merges are wrong. They are fast, and the queue's latency is real (10 to 14 minutes on a quiet main, 95 to 99 minutes while main moved).
  • Why each direct merge happened. Every merge in the period, queued or direct, was made by the repository owner's account.
  • That the failing checks at merge time were all caused by the PR: fix(platform): say retention values and bound changes in words #4850's Knip failure at 12:17 was the same scripts/publish-package.ts finding, inherited from main.

Options (not exhaustive, no preference stated)

  1. One path. Every change, documentation and tests included, goes through the queue. Latency stays at the numbers above unless main is quiet; the rebuild churn disappears when nothing else lands on main.
  2. Two defined paths. Name the class of change that may merge directly (for example documentation or test-only) or the condition (every required PR check green, local checks run), write it into .agents/repo.md and CI.md, and express it in the ruleset so that no hand-edited bypass is needed.
  3. Make a queue attempt cheaper. Retire dissolved groups' runs automatically (ci: runs of merge groups the queue dissolved are not reliably cancelled and compete with the live group for runners #4874), put fewer jobs in a group, or add runner capacity (the free plan's ~20 concurrent jobs is the stated budget).
  4. Validate after the merge. Run the full tier on main itself and fix forward. This is how the repository worked before the queue; it needs the main push runs to finish, and they cancel each other under the current concurrency setting (checks.yml:23-25, cancel-in-progress true for pushes).
  5. Record the path. Whatever is chosen, label or note direct merges so their share can be measured without a script.

Questions

  • Is the direct path intended, and for what? Who may use it?
  • What time-to-land is acceptable for a queued PR?
  • Should a PR be allowed to merge before its own required checks have reported?

Reproduce

Both scripts need an authenticated gh. The ruleset history needs admin access: gh api repos/tale-project/tale/rulesets/24697330/history.

Routes, and what the required checks had done at merge (merge-route-stats.py 2026-10-10)
#!/usr/bin/env python3
"""How did pull requests reach main, and what had their required checks done when they merged?

usage: python3 merge-route-stats.py 2026-10-10        (needs an authenticated `gh`)

A PR "went through the queue" when its timeline has an AddedToMergeQueueEvent; otherwise it is a "direct" merge.
For each direct merge the check runs of the PR's head commit are read (all runs, not only the latest), and each of the
seven required `CI ready (...)` contexts is compared with the merge time.
"""
import collections
import datetime as dt
import json
import statistics
import subprocess
import sys
from concurrent.futures import ThreadPoolExecutor

REPO = 'tale-project/tale'
REQUIRED = [f'CI ready ({name})' for name in ('Commitlint', 'SAST', 'E2E', 'CLI', 'Security', 'Checks', 'Build')]
SINCE = sys.argv[1] if len(sys.argv) > 1 else '2026-10-10'


def gh(*args):
    return subprocess.run(['gh', *args], capture_output=True, text=True, check=True).stdout


def when(text):
    return dt.datetime.fromisoformat(text.replace('Z', '+00:00')) if text else None


QUERY = '''query($q:String!, $after:String) { search(query:$q, type:ISSUE, first:100, after:$after) {
  pageInfo { hasNextPage endCursor }
  nodes { ... on PullRequest { number title mergedAt headRefOid
    timelineItems(first:50, itemTypes:[ADDED_TO_MERGE_QUEUE_EVENT, REMOVED_FROM_MERGE_QUEUE_EVENT]) {
      nodes { __typename ... on RemovedFromMergeQueueEvent { reason } } } } } } }'''

prs, after = [], None
while True:
    args = ['api', 'graphql', '-f', f'query={QUERY}', '-f', f'q=repo:{REPO} is:pr is:merged base:main merged:>={SINCE}']
    if after:
        args += ['-f', f'after={after}']
    page = json.loads(gh(*args))['data']['search']
    prs += page['nodes']
    if not page['pageInfo']['hasNextPage']:
        break
    after = page['pageInfo']['endCursor']

for pr in prs:
    events = pr['timelineItems']['nodes']
    pr['merged'] = when(pr['mergedAt'])
    pr['queued'] = any(e['__typename'] == 'AddedToMergeQueueEvent' for e in events)
    pr['removals'] = [e['reason'] for e in events if e['__typename'] == 'RemovedFromMergeQueueEvent']
prs.sort(key=lambda pr: pr['merged'])
direct = [pr for pr in prs if not pr['queued']]
queued = [pr for pr in prs if pr['queued']]

print(f"merged to main since {SINCE}: {len(prs)}; through the queue: {len(queued)}; without a queue event: {len(direct)}")
per_day = collections.defaultdict(lambda: [0, 0])
for pr in prs:
    per_day[pr['merged'].date().isoformat()][0 if pr['queued'] else 1] += 1
for day, (via_queue, not_queued) in sorted(per_day.items()):
    print(f"  {day}: queue {via_queue:3d}   direct {not_queued:3d}")
print('removals from the queue among queue-merged PRs:',
      dict(collections.Counter(reason for pr in queued for reason in pr['removals'])))


def check_state(pr):
    runs, page = [], 1
    while True:
        batch = json.loads(gh('api', f"repos/{REPO}/commits/{pr['headRefOid']}/check-runs?filter=all&per_page=100&page={page}"))['check_runs']
        runs += batch
        if len(batch) < 100:
            break
        page += 1
    unfinished, failed_before, last_lag = [], [], None
    for name in REQUIRED:
        completed = sorted((run for run in runs if run['name'] == name and run['completed_at']), key=lambda run: run['completed_at'])
        if not completed:
            continue
        # The first result of this context against the merge: positive = it arrived after the PR had merged.
        lag = (when(completed[0]['completed_at']) - pr['merged']).total_seconds()
        last_lag = lag if last_lag is None else max(last_lag, lag)
        if lag > 0:
            unfinished.append(name)
        before = [run for run in completed if when(run['completed_at']) <= pr['merged']]
        if before and before[-1]['conclusion'] in ('failure', 'cancelled', 'timed_out'):
            failed_before.append(name)
    return pr['number'], unfinished, failed_before, last_lag


with ThreadPoolExecutor(max_workers=8) as pool:
    states = list(pool.map(check_state, direct))
unfinished = [s for s in states if s[1]]
failed = [s for s in states if s[2]]
lags = sorted(s[3] for s in states if s[3] is not None and s[3] > 0)
print(f"\ndirect merges: {len(direct)}")
print(f"  at least one required check had not reported its first result when the PR merged: {len(unfinished)}")
if lags:
    print(f"  seconds from the merge until the last required check reported its first result: median {statistics.median(lags):.0f}, "
          f"p90 {lags[int(len(lags) * 0.9)]:.0f}, max {lags[-1]:.0f}")
print(f"  at least one required check had failed or been cancelled when the PR merged: {len(failed)} "
      f"({', '.join('#' + str(s[0]) for s in failed)})")
Merge groups per PR (merge-group-stats.py)
#!/usr/bin/env python3
"""How many merge groups does a queued PR go through, and how many merge-group runs end cancelled?

usage: python3 merge-group-stats.py          (needs an authenticated `gh`)

A merge group is built on a temporary branch `gh-readonly-queue/main/pr-<number>-<sha>`; the queue builds a new one
(a new branch, seven new workflow runs) whenever the base moves or the entries ahead change.
"""
import collections
import json
import subprocess

REPO = 'tale-project/tale'


def gh(*args):
    return subprocess.run(['gh', *args], capture_output=True, text=True, check=True).stdout


runs = []
for page in range(1, 5):
    out = gh('api', f'repos/{REPO}/actions/runs?event=merge_group&per_page=100&page={page}',
             '--jq', '.workflow_runs[] | {head_branch, created_at, status, conclusion}')
    runs += [json.loads(line) for line in out.splitlines() if line.strip()]

groups = collections.defaultdict(lambda: collections.defaultdict(list))
for run in runs:
    _, number, sha = run['head_branch'].rsplit('/', 1)[-1].split('-', 2)
    groups[number][sha].append(run)

print(f"{len(runs)} merge_group runs, {min(r['created_at'] for r in runs)} .. {max(r['created_at'] for r in runs)}")
print('outcomes:', dict(collections.Counter(r['conclusion'] or r['status'] for r in runs)))
print(f"{sum(len(g) for g in groups.values())} merge groups for {len(groups)} pull requests")
print('\nPR     groups  first build -> last build (UTC)')
for number in sorted(groups, key=int, reverse=True):
    built = sorted(min(r['created_at'] for r in rs) for rs in groups[number].values())
    print(f"#{number}  {len(built):5d}   {built[0][5:16]} -> {built[-1][5:16]}")

Observed at main a83e645e27; counts as of 2026-10-12 about 16:25 UTC.

Activity

  1. added
    priority: medium
    needs discussion
    improvement
    on Oct 12, 2026
  2. yannickmonney commented on Oct 13, 2026

    @yannickmonney
    ContributorAuthor

    One more data point for the question above, from 2026-10-13 (UTC), as the queue timeline of six pull requests shows it. It does not say which path is right.

    PR Entered the queue Left it Landed
    #4396 16:11:48 and 18:50:29 18:38:53 failed_checks; 19:47:29 failed_checks merged directly 19:51:24
    #4582 17:08:51 and 18:50:31 19:49:17 failed_checks merged directly 19:51:32
    #4954 19:33:27 and 21:35:17 20:50:29 failed_checks still queued
    #4966 19:46:36 21:18:01 failed_checks merged directly 21:32:43
    #4967 19:48:41 21:33:17 manual merged directly 21:33:40
    #4968 21:19:15 21:34:11 manual merged directly 21:34:27
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

    improvementneeds discussionpriority: medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions