Run CI's full Pyright with two workers in merge groups and on `main` so it fits the runner's memory

Merged
DO
6d ago
+15-10

This pull request was posted by Claude Code using claude-opus-5-5 on behalf of Douwe.

Why we make these changes

Merge-group runs keep losing their runner partway through the full Pyright step: make[1]: *** [Makefile:55: typecheck-pyright] Terminated, then The runner has received a shutdown signal. Each such run takes about 57 minutes to report red and holds the head of the queue meanwhile. Douwe asked for this change as part of the merge-queue speed work, and the .github change is his request.

I measured instead of assuming OOM. A temporary workflow ran the full pyright on ubuntu-latest (16 GB) while sampling /proc every 2 s (run 1, 4 GB --verbose, 2 workers --verbose):

workers, heappeak RSSlowest free memoryswap usedseconds
3, 6 GB (today)14.5–14.7 GB~100 MB3 GB (all of it)396, 724
2, 6 GB (this PR, outside PRs)11.6–11.9 GB2.9–3.3 GB0231–374 (5 runs)
3, 4 GB11.8–11.9 GB3.0 GB0230–271 (5 runs)
pyright-rs7.0–7.1 GB7.3 GB036–52

Today's configuration fills the runner's memory and swap. 3 workers with a 4 GB heap fit and are the fastest, but the workers empty their type cache 29–36 times a run, and one of three --verbose runs failed on a spurious Unnecessary "# pyright: ignore" at tests/test_history_properties.py:280 that the other runs didn't report. So this PR keeps the 6 GB heap and runs 2 workers on merge groups and pushes to main. Pull requests reach full Pyright only when pyright-rs doesn't pass. They keep 3 workers, because 2 workers would run up to the 370 s pull-request budget.

None of the 15 probe runs reproduced the investigation's reportUnusedImport false positives.

New public surface

none (CI only)

Verification

  • test_ci_matrix.py passes. The merge-group path itself is verified only by the probe runs above, on the same runner type.

What changes for existing users

Nothing. CI only: Pyright in merge groups and on main takes about 1 minute longer, which stays off the critical path (quality checks ends several minutes before the slowest test shard).

PR decisions

2026-11-30 · adopted PR #15042 at 2026-11-30 · iter -

  • Decision: Branch-context bootstrapped from existing PR (no linked issue, no review threads). Takeover from DouweM by ci-health-mgr lane; David picked it 2026-11-30 05:51Z.
  • Why: PR predates the branch-context setup
  • Source: https://github.com/pydantic/pydantic-ai/pull/15042
  • Session: 229b18c5-3a75-45f0-9029-df8b640fc5b6

2026-11-30 · pre-push gate exempt at 3f600cc58a: main merge · iter -

  • Decision: No pre-push review: target-branch merge with no conflict resolution; exemption chains from f19e5528aa (douwebot clean APPROVE, receipt run=46052549639).
  • Why: tree 0f6db3e83c; git diff main...f19e5528aa equals git diff main...HEAD modulo hunk offsets and blob ids, main=ff32d39cb1 freshly fetched; no local pre-push record exists for f19e5528aa, so the hosted clean approval is the reviewed anchor
  • Source: https://github.com/pydantic/pydantic-ai/pull/15042
  • Session: 229b18c5-3a75-45f0-9029-df8b640fc5b6

2026-11-30 · skip douwebot optional: tag pushes in worker-count docs · iter -

  • Decision: Skipped: docs/contributing.md says 2 workers on merge groups and main pushes; tag pushes also get 2. No push for an Optional finding on an approved head.
  • Why: Valid but incomplete-not-wrong wording; an Optional finding alone never earns a push (ci-health-mgr dispatch). Worth folding into any later push on this branch.
  • Source: https://github.com/pydantic/pydantic-ai/pull/15042#discussion_r4735732896
  • Session: 229b18c5-3a75-45f0-9029-df8b640fc5b6

2026-11-30 · step 7 second opinion: none · iter -

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BYcNCmKSAGoxnbcniBLfNR


Summary by cubic

Fixes merge-group CI runs losing their runner partway through the full Pyright check, which took about 57 minutes to report red and held the head of the queue.

Pyright on merge groups and pushes to main now runs 2 workers with a 6 GB heap instead of 3, so the type checker fits in the runner's 16 GB with about 3 GB to spare. Pull requests keep 3 workers because they reach the full check only when the faster pyright-rs did not pass, and 2 workers would exceed the 370-second pull request budget. A 3-worker configuration with a 4 GB heap also fits and is fastest, but probe runs showed it empties the workers' type cache roughly 30 times per run and produced a spurious Unnecessary "# pyright: ignore" error, so the 6 GB heap is kept.

The merge-group and main check takes about one minute longer, which stays off the critical path because the quality checks finish before the slowest test shard. No breaking changes and no user-facing impact.

  • docs/contributing.md now documents that CI runs 2 workers outside pull requests and 3 on them.