Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Route: a task needing more CI jobs than the account limit is offered on an idle account (Diego) (#2502)

0xken1570638c5b8247
diff --git a/cli/src/superTabs/machineFit.spec.ts b/cli/src/superTabs/machineFit.spec.ts
index 0c19f0858..61f03a017 100644
--- a/cli/src/superTabs/machineFit.spec.ts
+++ b/cli/src/superTabs/machineFit.spec.ts
@@ -1,7 +1,7 @@
// cli/src/superTabs/machineFit.spec.ts
import { describe, expect, it, vi } from 'vitest'
import { START_REQUIREMENTS, startRequirements } from './capacity.js'
-import { CI_LIMIT, CI_READ_MS, CI_RETRY_MINUTES, CI_UNCHECKED, ciHold, ciLoadOf, floorOf, heavyNeed, MACHINE_FIT_MAKER, machineFit, PLACED_RECENT_MS, placedHeavyWork,
+import { CI_LIMIT, CI_OVER_NOTE, CI_READ_MS, CI_RETRY_MINUTES, CI_UNCHECKED, ciHold, ciLoadOf, floorOf, heavyNeed, MACHINE_FIT_MAKER, machineFit, PLACED_RECENT_MS, placedHeavyWork,
type CiLoad } from './machineFit.js'
import { choose, parseAssessment, type Assessment, type Catalog, type Probe } from './route.js'
import { ROUTE_PLUGIN_MAKERS, type PluginInput } from './routePlugins.js'
@@ -178,6 +178,39 @@ describe('the CI jobs limit', () => {
expect(ciHold({ ci: { jobs: 2, macos: 2 } }, load(4, 0, 3, 0))).toBeNull()
expect(ciHold({ ci: { jobs: 2, macos: 2 } }, load(4, 0, 3, 1))).toContain('4 on macOS against 5, and this task starts 2 more (2 on macOS).')
})
+ it('a need above the limit counts as the limit, so an idle account starts it and GitHub queues the rest (Diego, 11-02)', () => {
+ // More jobs than the account runs at once could never fit under the limit: it was held "for 10 minutes" forever at zero load.
+ expect(ciHold({ ci: { jobs: 21, macos: 0 } }, load(0))).toBeNull()
+ expect(ciHold({ ci: { jobs: 100, macos: 0 } }, load(0))).toBeNull()
+ expect(ciHold({ ci: { jobs: 6, macos: 6 } }, load(0))).toBeNull()
+ expect(ciHold({ ci: { jobs: 21, macos: 6 } }, load(0))).toBeNull()
+ // The cap is the whole need, not a free pass: any load at all still holds it, and a small need is judged as before.
+ expect(ciHold({ ci: { jobs: 21, macos: 0 } }, load(1))).toContain('this task starts 20 more')
+ expect(ciHold({ ci: { jobs: 6, macos: 6 } }, load(0, 0, 1))).toContain('this task starts 6 more (5 on macOS)')
+ expect(ciHold({ ci: { jobs: 5, macos: 0 } }, load(18))).toContain('18 running or queued against the account\'s limit of 20')
+ expect(ciHold({ ci: { jobs: 5, macos: 0 } }, load(15))).toBeNull()
+ })
+ it('says in the route answer when a need is above the limit, held or not, and nothing when it fits', () => {
+ const idle = ok(route([on('a', { memory: 16, disk: 100 })], a({ ci: { jobs: 21, macos: 0 } }), machineFit({ ci: load(0) })))
+ expect(idle.shown[0]!.notes).toEqual([`Machine fit: ${CI_OVER_NOTE({ ci: { jobs: 21, macos: 0 } })}`])
+ expect(CI_OVER_NOTE({ ci: { jobs: 21, macos: 0 } })).toBe("This task starts 21 CI jobs, more than the account's limit of 20 at once: it is counted as 20, and GitHub queues the rest.")
+ expect(CI_OVER_NOTE({ ci: { jobs: 8, macos: 6 } })).toBe("This task starts 6 CI jobs on macOS, more than the account's limit of 5 at once: it is counted as 5, and GitHub queues the rest.")
+ expect(CI_OVER_NOTE({ ci: { jobs: 30, macos: 7 } })).toContain('30 CI jobs')
+ expect(CI_OVER_NOTE({ ci: { jobs: 30, macos: 7 } })).toContain('7 CI jobs on macOS')
+ expect(CI_OVER_NOTE({ ci: { jobs: 20, macos: 5 } })).toBeNull()
+ expect(CI_OVER_NOTE({})).toBeNull()
+ // Unread load: the unchecked note and the over-limit note both show.
+ expect(ok(route([on('a', { memory: 16, disk: 100 })], a({ ci: { jobs: 21, macos: 0 } }))).shown[0]!.notes).toEqual([`Machine fit: ${CI_UNCHECKED} ${CI_OVER_NOTE({ ci: { jobs: 21, macos: 0 } })}`])
+ // Beside a heavy fit.
+ expect(ok(route([on('a', { memory: 5, disk: 100 })], a({ ci: { jobs: 21, macos: 0 }, heavy: ['build'] }), machineFit({ ci: load(0) }))).shown[0]!.notes[0]).toMatch(/rank first\. This task starts 21 CI jobs/)
+ // Held by the load, the hold's reason is the answer, and it too names the cap.
+ const held = route([on('a', { memory: 16, disk: 100 })], a({ ci: { jobs: 21, macos: 0 } }), machineFit({ ci: load(3) }))
+ expect(held).toMatchObject({ error: 'NO_CANDIDATE' })
+ const reason = 'error' in held ? held.excluded[0]!.reason : ''
+ expect(reason).toContain('this task starts 20 more')
+ expect(reason).toContain(CI_OVER_NOTE({ ci: { jobs: 21, macos: 0 } }))
+ expect(reason).toContain('it is counted as 20, and GitHub queues the rest.')
+ })
it('never holds work that declares no CI of its own, nor when the load is unknown', () => {
expect(ciHold({}, load(40, 10, 5, 5))).toBeNull()
expect(ciHold({ ci: { jobs: 4, macos: 4 } }, null)).toBeNull()
diff --git a/cli/src/superTabs/machineFit.ts b/cli/src/superTabs/machineFit.ts
index 826698a94..39aaa5d3a 100644
--- a/cli/src/superTabs/machineFit.ts
+++ b/cli/src/superTabs/machineFit.ts
@@ -73,16 +73,30 @@ export function placedHeavyWork(starts: Json[], now: number, hostOf: (machineId:
/** Jobs running and queued on GitHub Actions, in all and on macOS runners (the server's read of the project's repository). */
export interface CiLoad { running: number; queued: number; macosRunning: number; macosQueued: number }
+/** The CI jobs a task is counted as starting: at most the account's limit, since it can never run more at once and GitHub queues
+ * the rest. Counting the full need held a task of 21 jobs "for 10 minutes" forever, even on an idle account (Diego, 11-02). */
+const counted = (ci: { jobs: number; macos: number }) => ({ jobs: Math.min(ci.jobs, CI_LIMIT.jobs), macos: Math.min(ci.macos, CI_LIMIT.macos) })
+/** Said when a task starts more CI jobs than the account runs at once, or null when it fits; the route counts it as
+ * the limit, whether it then offers it or holds it. */
+export function CI_OVER_NOTE(needs: Pick<Needs, 'ci'>): string | null {
+ if (!needs.ci) return null
+ const { jobs, macos } = needs.ci, over: string[] = []
+ if (jobs > CI_LIMIT.jobs) over.push(`${jobs} CI jobs, more than the account's limit of ${CI_LIMIT.jobs} at once: it is counted as ${CI_LIMIT.jobs}`)
+ if (macos > CI_LIMIT.macos) over.push(`${macos} CI jobs on macOS, more than the account's limit of ${CI_LIMIT.macos} at once: it is counted as ${CI_LIMIT.macos}`)
+ return over.length ? `This task starts ${over.join('. It also starts ')}, and GitHub queues the rest.` : null
+}
/** Why work that starts [needs.ci] must wait for CI, or null when it fits under the limit, or declares no CI, or the load is
- * unknown (the route then says the limit was not checked). Queued jobs count: they already wait for the limit. */
+ * unknown (the route then says the limit was not checked). Queued jobs count: they already wait for the limit. A need above
+ * the limit counts as the limit ([counted]), so only the load can hold it. */
export function ciHold(needs: Pick<Needs, 'ci'>, load: CiLoad | null): string | null {
if (!needs.ci || !load) return null
- const busy = load.running + load.queued, mac = load.macosRunning + load.macosQueued
- const over = busy + needs.ci.jobs > CI_LIMIT.jobs || mac + needs.ci.macos > CI_LIMIT.macos
+ const busy = load.running + load.queued, mac = load.macosRunning + load.macosQueued, need = counted(needs.ci)
+ const over = busy + need.jobs > CI_LIMIT.jobs || mac + need.macos > CI_LIMIT.macos
if (!over) return null
- const starts = `${needs.ci.jobs} more${needs.ci.macos ? ` (${needs.ci.macos} on macOS)` : ''}`
+ const starts = `${need.jobs} more${need.macos ? ` (${need.macos} on macOS)` : ''}`
+ const above = CI_OVER_NOTE(needs)
return `${CI_HOLD_OPENING}: ${busy} running or queued against the account's limit of ${CI_LIMIT.jobs}, ${mac} on macOS against ${CI_LIMIT.macos}, `
- + `and this task starts ${starts}. Route it again in ${CI_RETRY_MINUTES} minutes.`
+ + `and this task starts ${starts}. Route it again in ${CI_RETRY_MINUTES} minutes.${above ? ` ${above}` : ''}`
}
/** Said when a task starts CI and the load could not be read. */
export const CI_UNCHECKED = `This repository's running CI jobs could not be read, so the account's limit of ${CI_LIMIT.jobs} jobs (${CI_LIMIT.macos} on macOS) was not checked.`
@@ -99,8 +113,9 @@ export function machineFit(input: { placed?: ReadonlyMap<string, Placed>; hostOf
const hold = ciHold(needs, input.ci ?? null)
if (hold) return { refuse: true, reason: hold }
const fit = fitOf(candidate, needs, input.placed?.get(hostOf(candidate.machineId)))
- if (!needs.ci || input.ci) return fit
- return fit ? { ...fit, reason: `${fit.reason} ${CI_UNCHECKED}` } : { reason: CI_UNCHECKED }
+ const said = [needs.ci && !input.ci ? CI_UNCHECKED : null, CI_OVER_NOTE(needs)].filter((w): w is string => !!w).join(' ')
+ if (!said) return fit
+ return fit ? { ...fit, reason: `${fit.reason} ${said}` } : { reason: said }
},
}
}
diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.ts
index b19c099c6..6187e65fb 100644
--- a/cli/src/superTabs/route.ts
+++ b/cli/src/superTabs/route.ts
@@ -18,7 +18,7 @@ export type Size = 'small' | 'medium' | 'large'
* whatever their strength (owner, 2026-10-23: a Builder on a named API model was ranked below Opus and never offered). */
/** `needs.heavy`: the work runs a heavy build or end-to-end tests on its machine, so it needs more free memory and disk than a
* start (machineFit.ts). `needs.ci`: the CI jobs the work starts at once, and how many of them on macOS runners, held against
- * the account's running-jobs limit. Both are left out when not given, so a request without them answers as before. */
+ * the account's running-jobs limit; a need above that limit counts as the limit and the route says so (machineFit.ts). Both are left out when not given, so a request without them answers as before. */
export type HeavyWork = 'build' | 'e2e'
export interface Needs { tools: string[]; devices: string[]; cwd?: string; heavy?: HeavyWork[]; ci?: { jobs: number; macos: number } }
export interface Assessment { difficulty: Level; risk: Level; size: Size; why: string; kind?: string; local?: boolean; model?: string; needs: Needs }