An open source design system that's fully customizable and agent ready
TypeScript
ci: a waiting run looks again every two minutes while main waits and every four within ten jobs of room (AST-030 FR16, DEC-16) (#9381)
Cindy Zhang021bfb5ed97d
diff --git a/.github/actions/ci-admission/action.yml b/.github/actions/ci-admission/action.ymlindex f7bd68f757..1cb6339cd1 100644--- a/.github/actions/ci-admission/action.yml+++ b/.github/actions/ci-admission/action.yml@@ -18,8 +18,8 @@# that message. `main` runs are never turned away.# - A run starts once the other active runs' estimated jobs plus `peak` fit# under the ceiling. Small workflows that are not admitted (one or two slim-# jobs a run) always count at least their measured most at once, so the room-# they can still take is kept free. A pull-request run (`main: false`) also+# jobs a run) always count at least eighteen jobs, which covers all but their+# rarest bursts, so the room they can still take is kept free. A pull-request run (`main: false`) also# waits while a# `main` full check or release re-check is waiting, so `main` fits first;# pull-request runs never wait for each other.@@ -37,7 +37,10 @@# stale record GitHub still lists as active, and counts nothing.# - A look costs two run listings plus one call per active CI or Main run, and# a run looks at most `max-looks` times: twice for a pull request (at once and-# after its longest wait), every two minutes for the rare `main` run. When the+# after its longest wait), every two minutes for the rare `main` run. A+# pull-request run that would fit but yields to a waiting `main` check looks+# again every two minutes while it does, and a run within ten jobs of room+# every four, both outside that count and inside the run's longest wait. When the# repository's API budget is low, the run starts rather than spend it.# - A pull request that may not run CI (a draft, or a fork without `ci:run`)# starts at once, so its required contexts report their failure (FR17).@@ -78,7 +81,11 @@ inputs:required: falsedefault: ''looks:- description: "For 'rest': how many looks 'room' made."+ description: "For 'rest': how many of its looks 'room' spent."+ required: false+ default: ''+ next:+ description: "For 'rest': when 'room' planned the next look, in milliseconds since the epoch."required: falsedefault: ''@@ -93,8 +100,11 @@ outputs:description: When the wait started, in milliseconds since the epoch.value: ${{ steps.wait.outputs.started }}looks:- description: How many looks the wait made.+ description: How many of its looks the wait spent.value: ${{ steps.wait.outputs.looks }}+ next:+ description: When the wait planned its next look, in milliseconds since the epoch.+ value: ${{ steps.wait.outputs.next }}runs:using: composite@@ -105,6 +115,7 @@ runs:PHASE: ${{ inputs.phase }}FITS: ${{ inputs.fits }}STARTED: ${{ inputs.started }}+ NEXT: ${{ inputs.next }}LOOKS: ${{ inputs.looks }}PEAK: ${{ inputs.peak }}MAIN: ${{ inputs.main }}@@ -122,6 +133,23 @@ runs:const MAX_WAIT_MS = Number(process.env.MAX_WAIT_MINUTES || '15') * 60_000;const MAX_LOOKS = Math.max(1, Number(process.env.MAX_LOOKS || '8'));const LOOK_MS = MAX_LOOKS > 1 ? (MAX_WAIT_MS - JITTER_MS) / (MAX_LOOKS - 1) : MAX_WAIT_MS;+ // A run that would fit but yields to a waiting `main` check looks+ // again this soon, outside its count of looks, since `main` waits+ // are short.+ const YIELD_LOOK_MS = 2 * 60_000;+ // A run with no room but within this many jobs of it looks again+ // this soon, also outside its count of looks: near-full CI frees+ // that much in minutes. A run further from room keeps its looks.+ const NEAR_JOBS = 10;+ const NEAR_LOOK_MS = 4 * 60_000;+ // After a look without room: whether it spends one of the run's+ // looks, and how soon the next look comes. `over` is how many jobs+ // past the ceiling admitting would go.+ const plan = (over, yieldsToMain) => {+ if (yieldsToMain && over <= 0) return {spends: false, interval: YIELD_LOOK_MS};+ if (over <= NEAR_JOBS) return {spends: false, interval: Math.min(NEAR_LOOK_MS, LOOK_MS)};+ return {spends: true, interval: LOOK_MS};+ };const STEP = 'Wait for room under the CI ceiling';// At most this many pull-request runs wait at once; one more finding// no room is turned away (spec:AST-030 DEC-16).@@ -137,8 +165,9 @@ runs:'.github/workflows/review-signal.yml': () => 2,};const estimate = run => (ESTIMATE[run.path] ?? (() => 1))(run);- // The most jobs small, unadmitted workflows ran at once, measured- // over a busy evening (spec:AST-030 DEC-16).+ // Jobs always counted for small, unadmitted workflows: they peaked at+ // twenty at once in a day's runs and rose by fourteen within two+ // minutes in ninety-nine looks of a hundred (spec:AST-030 DEC-16).const SMALL_MOST = 18;const ADMITTED = ['.github/workflows/ci.yml', '.github/workflows/deploy.yml'];const admitted = run => ADMITTED.includes(run.path);@@ -183,17 +212,26 @@ runs:}let calls = 0;try {- if (looked > 0) {- // The next look falls where the wait's schedule puts it.- const next = started + looked * LOOK_MS - Date.now();- if (looked >= MAX_LOOKS || next > MAX_WAIT_MS - (Date.now() - started)) {+ if (PHASE === 'rest') {+ // The next look falls where room planned it.+ const planned = Number(process.env.NEXT);+ // A look planned past the longest wait comes at its end instead.+ const left = MAX_WAIT_MS - (Date.now() - started);+ const next = Math.min((planned > 0 ? planned : started + Math.max(1, looked) * LOOK_MS) - Date.now(), left - JITTER_MS);+ if (looked >= MAX_LOOKS || left <= 0) {core.warning(`Still no room after ${MAX_WAIT_MS / 60_000} minutes; starting.`);return;}if (next > 0) await new Promise(resolve => setTimeout(resolve, next + Math.floor(Math.random() * JITTER_MS)));}+ // Looks that found no room; a look that only yielded to `main` is+ // not one of them.+ let spent = looked;for (let look = looked + 1; ; look += 1) {- core.setOutput('looks', String(look));+ // A look that stops early (a low budget, a failed lookup) leaves+ // `fits` unset, so the rest starts rather than wait on an older look.+ core.setOutput('fits', '');+ core.setOutput('looks', String(spent + 1));const seen = new Set();let large = 0;let small = 0;@@ -240,7 +278,7 @@ runs:// which starts beside it.const holds = isMain(run) ? estimate(run) : Math.max(1, jobs.filter(job => LIVE.includes(job.status)).length);if (isMain(run) && !main) mainWaiting = true;- if (!isMain(run)) waitingPulls += 1;+ if (run.event === 'pull_request') waitingPulls += 1;large += holds;counted.push(`${short(run)} ${run.id} ${run.event}: ${holds} waiting`);continue;@@ -271,15 +309,23 @@ runs:return;}if (others + 1 <= CI_CEILING && !mainWaiting) {+ // The rest of the run carries on this wait from this look.+ const next = plan(others + peak - CI_CEILING, false);+ core.setOutput('looks', String(spent + (next.spends ? 1 : 0)));+ core.setOutput('next', String(Date.now() + next.interval));core.info(`Room for the Storybook build: about ${others} other jobs + 1 <= ${CI_CEILING}; the rest of the run waits.`);return;}}+ // Room for what this look admits, if no `main` check waited.+ const next = plan(others + (PHASE === 'room' ? 1 : peak) - CI_CEILING, mainWaiting);+ if (next.spends) spent += 1;+ core.setOutput('looks', String(spent));// The time left decides, not the look's own API time: a slow// look still waits the rest of the way for its next one.const left = MAX_WAIT_MS - (Date.now() - started);- const wait = Math.min(LOOK_MS + Math.floor(Math.random() * JITTER_MS), left);- if (look >= MAX_LOOKS || wait <= 0) {+ const wait = Math.min(next.interval + Math.floor(Math.random() * JITTER_MS), left);+ if (spent >= MAX_LOOKS || wait <= 0) {core.warning(`Still no room after ${MAX_WAIT_MS / 60_000} minutes (about ${others} other jobs${mainWaiting ? ', a main check waiting' : ''}); starting.`);return;}diff --git a/.github/scripts/ci-admission.test.mjs b/.github/scripts/ci-admission.test.mjsindex ac138936a0..2ae4c468ab 100644--- a/.github/scripts/ci-admission.test.mjs+++ b/.github/scripts/ci-admission.test.mjs@@ -61,9 +61,9 @@ describe('where runs wait', () => {expect(needsOf(admission)).toEqual(['room']);expect(room.permissions).toEqual({actions: 'read', contents: 'read'});// The rest of the wait carries on from where room left off.- for (const key of ['fits', 'started', 'looks'])+ for (const key of ['fits', 'started', 'looks', 'next'])expect(wait.with[key]).toBe(`\${{ needs.room.outputs.${key} }}`);- for (const key of ['fits', 'full', 'started', 'looks'])+ for (const key of ['fits', 'full', 'started', 'looks', 'next'])expect(room.outputs[key]).toBe(`\${{ steps.room.outputs.${key} }}`);// Every job but the Storybook build reaches admission, directly or through// the jobs it needs, never only through the build.@@ -395,6 +395,7 @@ describe('ci admission', () => {fits = '',started = '',looked = '',+ next = '',} = {}) {vi.useFakeTimers({now: NOW});vi.spyOn(Math, 'random').mockReturnValue(random);@@ -421,7 +422,11 @@ describe('ci admission', () => {data: {workflow_runs: runs().filter(run => run.status === status),},- headers: {'x-ratelimit-remaining': String(budget)},+ headers: {+ 'x-ratelimit-remaining': String(+ typeof budget === 'function' ? budget() : budget,+ ),+ },};},listJobsForWorkflowRun: async ({run_id, per_page}) => {@@ -464,6 +469,7 @@ describe('ci admission', () => {FITS: fits,STARTED: started,LOOKS: looked,+ NEXT: next,});const done = new AsyncFunction('github', 'context', 'core', script)(github,@@ -606,15 +612,17 @@ describe('ci admission', () => {maxLooks: 2,});expect(result.looks).toBe(1);- expect(result.outputs).toMatchObject({fits: 'false', looks: '1'});+ // Near room (four over), so that look spent none of the run's two.+ expect(result.outputs).toMatchObject({fits: 'false', looks: '0'});expect(result.outputs.full).toBeUndefined();expect(result.info.at(-2)).toContain('Room for the Storybook build');});it('holds the build too when there is no room even for it', async () => {- // 6 x 12 + 18 = 90: not one more job fits, so nothing of the run starts.+ // 7 x 12 + 18 = 102: not one more job fits, and room is further than ten+ // jobs away, so nothing of the run starts and it keeps its two looks.const result = await admit({- active: prs(6),+ active: prs(7),peak: 16,phase: 'room',maxWait: 12,@@ -661,28 +669,43 @@ describe('ci admission', () => {phase: 'room',error: new Error('rate limited'),});- expect(room.outputs.fits).toBeUndefined();+ expect(room.outputs.fits ?? '').toBe('');});- it('carries the wait on from room: its clock and its looks', async () => {- // Room looked at once and found room for the build only; the rest looks- // once more at the second look of the same twelve-minute wait.- const rest = await admit({- active: prs(5),+ it('carries the wait on from room: its clock, its looks and its next look', async () => {+ // Far from room (7 x 12 + 18 + 16 = 118): room planned the second look+ // at the end of the twelve-minute wait, and the rest looks then.+ const far = await admit({+ active: prs(7),peak: 16,phase: 'rest',fits: 'false',started: String(NOW),looked: '1',+ next: String(NOW + 11.67 * 60_000),maxWait: 12,maxLooks: 2,});- expect(rest.looks).toBe(1);- expect(rest.lookTimes[0]).toBeGreaterThan(11 * 60_000);- expect(rest.lookTimes[0]).toBeLessThanOrEqual(12 * 60_000);+ expect(far.looks).toBe(1);+ expect(far.lookTimes[0]).toBeGreaterThan(11 * 60_000);+ expect(far.lookTimes[0]).toBeLessThanOrEqual(12 * 60_000);+ // Near room, room planned the next look four minutes on.+ const near = await admit({+ active: prs(5),+ peak: 16,+ phase: 'rest',+ fits: 'false',+ started: String(NOW),+ looked: '0',+ next: String(NOW + 4 * 60_000),+ maxWait: 12,+ maxLooks: 2,+ });+ expect(near.lookTimes[0]).toBeGreaterThanOrEqual(4 * 60_000);+ expect(near.lookTimes[0]).toBeLessThanOrEqual(4 * 60_000 + 20_000);// Room already spent both looks: the rest starts at once.const spent = await admit({- active: prs(6),+ active: prs(7),peak: 16,phase: 'rest',fits: 'false',@@ -694,6 +717,85 @@ describe('ci admission', () => {expect(spent).toMatchObject({looks: 0, calls: 0});});+ it('leaves fits unset when a later look stops early, so the rest starts', async () => {+ // Room's first look finds no room even for the build (far over) and+ // records that the run did not fit; its second look meets a low budget+ // and stops.+ let looksSoFar = 0;+ const room = await admit({+ active: looks => {+ looksSoFar = looks;+ return prs(7);+ },+ peak: 16,+ phase: 'room',+ maxWait: 12,+ maxLooks: 4,+ budget: () => (looksSoFar >= 2 ? 1000 : 4000),+ });+ expect(room.looks).toBe(2);+ expect(room.warning.at(-1)).toContain('API calls left this hour');+ expect(room.outputs.fits).toBe('');+ const rest = await admit({+ active: prs(7),+ peak: 16,+ phase: 'rest',+ fits: room.outputs.fits,+ started: String(NOW),+ looked: room.outputs.looks,+ maxWait: 12,+ maxLooks: 4,+ });+ expect(rest).toMatchObject({looks: 0, calls: 0});+ });++ it('looks at the end of the wait, never starts early, when room planned a look past it', async () => {+ // Room found the build room four minutes in, after a near look, with the+ // run then far over; its plan of four plus twelve minutes passes the+ // wait. The rest looks once at the end of the wait, then starts.+ vi.useFakeTimers({now: NOW});+ const started = NOW - 4 * 60_000;+ const rest = await admit({+ active: prs(7),+ peak: 16,+ phase: 'rest',+ fits: 'false',+ started: String(started),+ looked: '1',+ next: String(NOW + 11.67 * 60_000),+ maxWait: 12,+ maxLooks: 2,+ });+ expect(rest.looks).toBe(1);+ expect(rest.lookTimes[0]).toBeGreaterThan(7 * 60_000);+ expect(rest.lookTimes[0]).toBeLessThanOrEqual(8 * 60_000);+ expect(rest.warning[0]).toContain('Still no room');+ });++ it('plans the rest of the run four minutes on when room finds the build room and the run near it', async () => {+ // 5 x 12 + 18 = 78: the build fits; + 16 = 94 is four over, near room.+ const room = await admit({+ active: prs(5),+ peak: 16,+ phase: 'room',+ maxWait: 12,+ maxLooks: 2,+ });+ expect(room.outputs.looks).toBe('0');+ expect(Number(room.outputs.next) - NOW).toBe(4 * 60_000);+ // Far: 6 x 12 + 18 + 1 = 91 does not fit even the build; with 5 runs of+ // 14 (88), the build fits and the run, 16 more, is fourteen over.+ const wide = await admit({+ active: prs(5, 14),+ peak: 16,+ phase: 'room',+ maxWait: 12,+ maxLooks: 2,+ });+ expect(wide.outputs.looks).toBe('1');+ expect(Number(wide.outputs.next) - NOW).toBeGreaterThan(11 * 60_000);+ });+it('sees a run as waiting while either of its waits is in progress', async () => {// Room is done and admission waits: a waiting pull-request run that holds// its waiting job and the build that found room.@@ -738,6 +840,20 @@ describe('ci admission', () => {);});+ it('counts only waiting pull-request runs toward the ten', async () => {+ const queued = Array.from({length: 12}, (_, i) =>+ waitingRun(400 + i, {event: 'merge_group'}),+ );+ const result = await admit({+ active: [...prs(5), ...waiting(9), ...queued],+ peak: 16,+ phase: 'room',+ maxWait: 12,+ maxLooks: 2,+ });+ expect(result.outputs.full).toBeUndefined();+ });+it('never turns away a merge-queue entry', async () => {// A merge-queue run is not `main`, and carries no pull request.const entry = await admit({@@ -749,7 +865,8 @@ describe('ci admission', () => {maxLooks: 2,});expect(entry.outputs.full).toBeUndefined();- expect(entry.looks).toBe(2);+ // It waits (one job past room, so it looks every four minutes).+ expect(entry.looks).toBeGreaterThan(1);});it('lets the tenth waiter wait, and never turns away a run that fits or a main run', async () => {@@ -827,6 +944,88 @@ describe('ci admission', () => {expect(freed.looks).toBe(3);});+ it('starts a pull-request run within one two-minute look of a waiting main check starting', async () => {+ // 2026-11-01 16:16Z: a pull-request run yielded to a main push waiting+ // for room, slept to its second look twelve minutes later, though the push+ // started at 16:17. Here main waits two and a half minutes.+ const MAIN_WAIT = 150_000;+ const others = prs(3);+ const result = await admit({+ active: () =>+ Date.now() - NOW < MAIN_WAIT+ ? [+ ...others,+ waitingRun(71, {+ event: 'push',+ path: '.github/workflows/deploy.yml',+ }),+ ]+ : [+ ...others,+ admittedRun(71, 4, {+ event: 'push',+ path: '.github/workflows/deploy.yml',+ }),+ ],+ peak: 16,+ maxWait: 12,+ maxLooks: 2,+ });+ expect(result.warning).toEqual([]);+ const started = result.lookTimes.at(-1);+ expect(started).toBeGreaterThanOrEqual(MAIN_WAIT);+ expect(started - MAIN_WAIT).toBeLessThanOrEqual(2 * 60_000 + 20_000);+ // Yield looks do not spend the run's two looks.+ expect(result.looks).toBe(3);+ });++ it('looks every four minutes when a run is within ten jobs of room', async () => {+ // 2026-11-01 18:42Z: a pull-request run was two jobs over (64 live + 18+ // kept for small workflows + 16 = 98), and its only other look came+ // twelve minutes later. Here room frees five minutes in.+ const FREES = 5 * 60_000;+ const result = await admit({+ active: () => {+ const runs = [...prs(5), admittedRun(60, 4)];+ return Date.now() - NOW < FREES ? runs : runs.slice(1);+ },+ peak: 16,+ maxWait: 12,+ maxLooks: 2,+ });+ expect(result.warning).toEqual([]);+ // Looks at 0, about 4 and about 8 minutes: room by the third.+ expect(result.looks).toBe(3);+ expect(result.lookTimes[1]).toBeGreaterThanOrEqual(4 * 60_000);+ expect(result.lookTimes[1]).toBeLessThanOrEqual(4 * 60_000 + 20_000);+ expect(result.lookTimes[2] - FREES).toBeLessThanOrEqual(+ 4 * 60_000 + 20_000,+ );+ // Near looks stay inside the twelve-minute wait.+ const stuck = await admit({+ active: [...prs(5), admittedRun(60, 4)],+ peak: 16,+ maxWait: 12,+ maxLooks: 2,+ });+ expect(stuck.looks).toBe(4);+ expect(stuck.lookTimes.at(-1)).toBeLessThanOrEqual(12 * 60_000);+ expect(stuck.warning[0]).toContain('Still no room');+ });++ it('keeps two looks when there is no room, a waiting main check or not', async () => {+ // 6 x 12 + 18 + 16 = 106: sixteen over, further than ten from room, so+ // neither the yield nor nearness shortens the wait.+ const result = await admit({+ active: [...prs(6), waitingRun(72, {event: 'workflow_dispatch'})],+ peak: 16,+ maxWait: 12,+ maxLooks: 2,+ });+ expect(result.looks).toBe(2);+ expect(result.lookTimes[1]).toBeGreaterThan(11 * 60_000);+ });+it('lets a waiting main run go first, counting its whole peak; never waits for a pull-request run', async () => {const mainWaiting = waitingRun(70, {event: 'workflow_dispatch'});const held = await admit({@@ -838,6 +1037,8 @@ describe('ci admission', () => {maxLooks: 2,});expect(held.looks).toBe(2);+ // It would fit but yields, so it looks again in two minutes, not twelve.+ expect(held.lookTimes[1]).toBeLessThanOrEqual(2 * 60_000 + 20_000);// A waiting pull-request run whose Storybook build started beside its// wait holds both: 48 + 2 x 4 + 18 + 16 = 90 fits; a fifth does not.const building = id => ({diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex c0d4b833f7..932ca55b29 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -121,6 +121,7 @@ jobs:full: ${{ steps.room.outputs.full }}started: ${{ steps.room.outputs.started }}looks: ${{ steps.room.outputs.looks }}+ next: ${{ steps.room.outputs.next }}steps:- name: Check out the admission actionuses: actions/checkout@v7@@ -173,6 +174,7 @@ jobs:fits: ${{ needs.room.outputs.fits }}started: ${{ needs.room.outputs.started }}looks: ${{ needs.room.outputs.looks }}+ next: ${{ needs.room.outputs.next }}peak: ${{ github.event_name == 'workflow_dispatch' && 37 || 16 }}main: ${{ github.event_name == 'workflow_dispatch' }}max-wait-minutes: ${{ github.event_name == 'workflow_dispatch' && 15 || 12 }}diff --git a/docs/specs/AST-030/spec.md b/docs/specs/AST-030/spec.mdindex c383c92101..8b48125e65 100644--- a/docs/specs/AST-030/spec.md+++ b/docs/specs/AST-030/spec.md@@ -346,11 +346,13 @@ they are separately named.about ninety, and a pull-request run also waits while a `main` full check,release re-check or baseline capture is waiting, looking twice on a pullrequest, at once and after twelve minutes, and every two minutes for at most- fifteen for `main` (DEC-16). At most ten pull-request runs wait at once: one- more that finds no room stops at once with "CI is full: re-run all jobs or push later",- and its required checks report the stopped run. A pull request that may not- run CI admits nothing, and waiting never fails a job, so every required- context reports as before.+ fifteen for `main` (DEC-16); a pull-request run that would fit but waits for a+ `main` check looks again every two minutes while it does, and a run within ten+ jobs of room every four minutes, inside its longest wait. At most ten+ pull-request runs wait at once: one more that finds no room stops at once with+ "CI is full: re-run all jobs or push later", and its required checks report+ the stopped run. A pull request that may not run CI admits nothing, and+ waiting never fails a job, so every required context reports as before.- **FR17 — A pull request runs CI when it is ready and a maintainer can vouchfor it.** A draft pull request runs no CI, and marking it ready for reviewstarts its pull-request run, which runs what the change reaches (FR13,@@ -740,26 +742,35 @@ GitHub offers no repository-wide limit on concurrent jobs: a `concurrency` groupserializes runs and does not count jobs. So every run of the CI and Mainworkflows waits at its start until the other active runs' estimated jobs plusits own fit under ninety. Small workflows that are not admitted (linting, review-bookkeeping, report publishing) always count at least the most they were-measured running at once, eighteen jobs, so the room they can take stays free.-Each CI or Main run counts its live jobs: a pull-request run still waiting-counts the jobs it runs, the job that waits and a Storybook build that found-room, so waiting runs hold each other back by no more than they use, and a run-admitted in the last forty-five seconds, before its jobs appear, counts at least-its planned most. A run GitHub still lists as active but has not updated in two-hours holds no runner and counts nothing. A look reads the active runs and each-CI or Main run's jobs once, so it costs two run listings plus one call per-active CI or Main run. A pull request looks at most twice, and a run starts-rather than spend a low API budget. A `main` full check, release re-check or-baseline capture (every dispatch of the CI workflow) goes first: while one-waits, pull-request runs wait too, their Storybook builds included. Every job-ends within its fifteen-minute budget, so `main` fits within fifteen minutes.-Nothing is reserved for `main` outside those minutes. At most ten pull-request-runs wait at once; one more that finds no room stops at once, "CI is full:+bookkeeping, report publishing) always count at least eighteen jobs, so the room+they can take stays free. Over a day's runs they peaked at twenty jobs at once,+and rose by at most fourteen within two minutes in ninety-nine looks of a+hundred (seventeen at most), so a margin over the jobs they run at a look would+not hold the ceiling, and eighteen covers all but the rarest rises without+lengthening every run's wait. Each CI or Main run counts its live jobs: a+pull-request run still waiting counts the jobs it runs, the job that waits and a+Storybook build that found room, so waiting runs hold each other back by no more+than they use, and a run admitted in the last forty-five seconds, before its+jobs appear, counts at least its planned most. A run GitHub still lists as+active but has not updated in two hours holds no runner and counts nothing. A+look reads the active runs and each CI or Main run's jobs once, so it costs two+run listings plus one call per active CI or Main run. A pull request spends at+most two looks, at once and after twelve minutes; a look that finds it within+ten jobs of room spends none, and the next comes four minutes later, so a nearly+full CI admits it within minutes of the room freeing. A run starts rather than+spend a low API budget. A `main` full check, release re-check or baseline+capture (every dispatch of the CI workflow) goes first: while one waits,+pull-request runs wait too, their Storybook builds included. A pull-request run+that would fit and waits only for a `main` check looks again every two minutes+until it starts, since `main` waits are short. The extra looks happen only while+CI is near full or `main` waits. Every job ends within its fifteen-minute+budget, so `main` fits within fifteen minutes. Nothing is reserved for `main`+outside those minutes. At most ten pull-request runs wait at once, counting+pull-request runs only; one more that finds no room stops at once, "CI is full:re-run all jobs or push later", rather than add a waiting job to a full CI. A`main` run is never stopped.-CI can still pass ninety in four bounded ways, the first three rare:+CI can still pass ninety in five bounded ways, the first three rare:- A run that has waited its longest (fifteen minutes for `main`, twelve for apull request) starts whatever the load, even while a `main` check waits. That@@ -775,6 +786,8 @@ CI can still pass ninety in four bounded ways, the first three rare:job per waiting run: at most ten for pull requests, plus one for each waitingmerge-queue entry and `main` run, which are never turned away, for at most await (twelve minutes for a pull request, fifteen for `main`).+- Small workflows can run more jobs at once than the eighteen counted for them:+ they peaked at twenty in a day's runs, two over, while their jobs ran.Rejected: a fixed reserve for `main` (it left about half the ceiling idle andstalled the pull-request queue); starting `main`'s checks at once (a burst would