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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Swarm routing: place heavy work by machine fit (Scholes's goals, piece 5) (#2426)
0xken1566a2c795ebe2
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex a30b0ada7..6842f2439 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -653,6 +653,17 @@ describe('deleting abandoned swarm projects', () => {await expect(run(tab, command, peer, undefined, operationId)).rejects.toMatchObject({ code: 'FORBIDDEN' })})+ // Scholes's goals, piece 5: the heavy work a start declares is stored with it and read back, so later routes count it.+ it('stores the heavy work a start declares and reads it back with the start and the Super Tab', async () => {+ const { tab } = await fixture()+ const { conversationId } = (await run(tab, { type: 'project.create', name: 'Heavy start', visibility: 'public', brief: '' })).result as { conversationId: string }+ const request = { conversationId, machineId: 'test-host', engine: 'codex', name: 'Builder', cwd: '/work', worktree: true, heavy: ['build'],+ requirements: { memoryBytes: 4e9, diskBytes: 15e9, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }+ const startId = String((await run(tab, { type: 'agent.start', request } as Command)).result.startId)+ expect((await store.start(owner, tab, startId)).request).toMatchObject({ heavy: ['build'] })+ expect((await store.read(owner, tab)).state.starts?.find(s => s.id === startId)?.request).toMatchObject({ heavy: ['build'], requirements: { memoryBytes: 4e9 } })+ })+it('refuses pending starts and prevents a failed start from joining after deletion', async () => {const { tab } = await fixture()const { projectId, conversationId } = (await run(tab, { type: 'project.create', name: 'Failed start', visibility: 'public', brief: '' })).result as { projectId: string; conversationId: string }diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.tsindex 23e09b4dc..4509a3c99 100644--- a/backend/src/superTabs/commands.test.ts+++ b/backend/src/superTabs/commands.test.ts@@ -825,6 +825,18 @@ describe('agent.start on the Swarm\'s listed machines', () => {expect(f.state.starts).toHaveLength(1)})+ // Scholes's goals, piece 5: a start says the heavy work it runs, which later routes count on its machine.+ it('keeps the heavy work a start declares, and refuses any other value', () => {+ const f = fixture(), group = f.group()+ f.run({ type: 'agent.start', request: { ...request(group, 'my-laptop'), heavy: ['build', 'e2e'] } }, owner, { contribution: grant })+ expect(f.state.starts![0]!.request.heavy).toEqual(['build', 'e2e'])+ const parse = (heavy: unknown) => commandSchema.safeParse({ type: 'agent.start', request: { ...request(group, 'm'), heavy } }).success+ expect(parse(['e2e'])).toBe(true)+ for (const heavy of [[], ['compile'], ['build', 'build'], 'build', ['build', 'e2e', 'build']]) expect(parse(heavy)).toBe(false)+ // A start without it is as before.+ expect(commandSchema.safeParse({ type: 'agent.start', request: request(group, 'm') }).success).toBe(true)+ })+it('keeps a person\'s start on a machine of their own, before anything is listed', () => {const f = fixture(), group = f.group()f.run({ type: 'agent.start', request: request(group, 'my-laptop') }, owner, { contribution: grant })diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex c74907b67..c40bb96b0 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -95,6 +95,8 @@ export const startRequestSchema = z.object({model: z.string().trim().min(1).max(200).optional(), effort: z.string().trim().min(1).max(80).optional(),permissionMode: z.string().min(1).max(80).optional(), codexHome: path.optional(),gridModel: z.string().min(1).max(2048).optional(), gridName: z.string().min(1).max(2048).optional(),+ // The heavy work the task declared (model.ts AgentStartRequest.heavy). An older client sends none.+ heavy: z.array(z.enum(['build', 'e2e'])).min(1).max(2).refine(h => new Set(h).size === h.length, 'Name each kind of heavy work once.').optional(),requirements: z.object({ memoryBytes: z.number().int().nonnegative().safe(), diskBytes: z.number().int().nonnegative().safe(),maxCpuPercent: z.number().min(0).max(100), tools: z.array(z.string().regex(/^[A-Za-z0-9_.+-]{1,80}$/)).max(20),devices: z.array(path).max(20), quotaRequired: z.boolean() }).strict(),diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 409d3f5d2..12dae74c5 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -127,6 +127,10 @@ export interface AgentStartRequest {codexHome?: stringgridModel?: stringgridName?: string+ /** The heavy work the task declared it runs on its machine (a heavy build, end-to-end tests): later routes count such a start+ * on its machine for a few minutes, before the machine's reading shows it (cli superTabs/machineFit.ts, Scholes's goals,+ * piece 5). Its requirements ask only the least the work runs with, so this says what it is. */+ heavy?: Array<'build' | 'e2e'>requirements: { memoryBytes: number; diskBytes: number; maxCpuPercent: number; tools: string[]; devices: string[]; quotaRequired: boolean }/** A Buddy's start (buddies.ts): written by buddy.create alone, never taken from an agent.start. */buddyOf?: { personId: string; generation: string }diff --git a/cli/src/superTabs/capacity.ts b/cli/src/superTabs/capacity.tsindex 7b9dcfd85..0037e7b31 100644--- a/cli/src/superTabs/capacity.ts+++ b/cli/src/superTabs/capacity.ts@@ -6,6 +6,8 @@ import { commandAvailableInInteractiveShell, type CommandAvailability } from '..import { launchModelEngines } from '../lib/launchModel.js'import { object } from './wire.js'import { readCapacityDisk } from './disk.js'+import { floorOf, heavyNeed } from './machineFit.js'+import type { Needs } from './route.js'type Json = Record<string, unknown>export interface Requirements {@@ -15,9 +17,14 @@ export interface Requirements {/** What `start` asks of a machine when the Lead has no reason to ask for more: the help's template. CPU use is only a momentary* reading: a busy machine would refuse every start (seen in the route e2e at 98.7%), so no cap; memory, disk and pressure gate it. */export const START_REQUIREMENTS: Requirements = { memoryBytes: 2147483648, diskBytes: 10737418240, maxCpuPercent: 100, tools: ['git'], devices: [], quotaRequired: false }-/** The same plus what the task needs. The route admits a pick on exactly this, so the start it suggests is admitted too. */-export const startRequirements = (needs: { tools: string[]; devices: string[] }): Requirements =>- ({ ...START_REQUIREMENTS, tools: [...new Set([...START_REQUIREMENTS.tools, ...needs.tools])], devices: needs.devices })+/** The same plus what the task needs. The route admits a pick on exactly this, so the start it suggests is admitted too. Heavy+ * work asks only the least it can run with (machineFit.ts floorOf), so a machine the route ranks later, between half the need+ * and the need, still admits its start (Lead, 10-31); the start says it is heavy in its own `heavy` field. */+export const startRequirements = (needs: Pick<Needs, 'tools' | 'devices' | 'heavy'>): Requirements => {+ const need = heavyNeed(needs), floor = need ? floorOf(need) : null+ return { ...START_REQUIREMENTS, tools: [...new Set([...START_REQUIREMENTS.tools, ...needs.tools])], devices: needs.devices,+ ...(floor ? { memoryBytes: Math.max(START_REQUIREMENTS.memoryBytes, floor.memoryBytes), diskBytes: Math.max(START_REQUIREMENTS.diskBytes, floor.diskBytes) } : {}) }+}/** A missing result is a completed check; an absent value or failed check is only unverified. */export function requiredToolReason(tool: string, reported: unknown, failure?: unknown): string | null {diff --git a/cli/src/superTabs/machineFit.spec.ts b/cli/src/superTabs/machineFit.spec.tsnew file mode 100644index 000000000..0161085e7--- /dev/null+++ b/cli/src/superTabs/machineFit.spec.ts@@ -0,0 +1,220 @@+// cli/src/superTabs/machineFit.spec.ts+import { describe, expect, it } from 'vitest'+import { START_REQUIREMENTS, startRequirements } from './capacity.js'+import { CI_LIMIT, CI_RETRY_MINUTES, CI_UNCHECKED, ciHold, 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'++const GB = 1e9, NOW = 1_000_000_000, M = 60_000+const catalog: Catalog = { grid: { strength: 1, models: [] }, models: [+ { engine: 'claude', model: 'opus', effort: 'high', strength: 3, cost: 3, offered: true },+ { engine: 'claude', model: 'sonnet', effort: 'medium', strength: 2, cost: 2, offered: true },+] }+const a = (needs: Partial<Assessment['needs']> = {}): Assessment => ({ difficulty: 'medium', risk: 'low', size: 'medium', why: 'Desktop build.', needs: { tools: [], devices: [], ...needs } })+/** A new agent on [machine] with [free] memory and disk, in GB. */+const on = (machine: string, free: { memory: number | null; disk: number | null; cpu?: number }, patch: Partial<Probe> = {}): Probe => ({+ kind: 'new', machineId: machine, machineName: machine, engine: 'claude', model: 'opus', effort: 'high', quality: 3, cost: 3,+ quota: { known: true, leftPercent: null, resetsAt: null, metered: true }, activity: 'new agent', known: true, refusals: [], notes: [],+ load: { agents: 0, freeMemoryBytes: free.memory === null ? null : free.memory * GB, hasFolder: true, freeDiskBytes: free.disk === null ? null : free.disk * GB,+ ...(free.cpu === undefined ? {} : { cpuPercent: free.cpu }) }, ...patch })+const ok = (r: ReturnType<typeof choose>) => { if ('error' in r) throw new Error(JSON.stringify(r)); return r }+const route = (probes: Probe[], task: Assessment, plugin = machineFit()) => choose(probes, catalog, task, NOW, [], [], [], [plugin])+/** A start as the route's hint makes it: its requirements, and the heavy work it declared in its own field. */+const heavyStart = (machineId: string, at: number, heavy: Assessment['needs']['heavy'] = ['build'], patch: Record<string, unknown> = {}) =>+ ({ request: { machineId, requirements: startRequirements({ tools: [], devices: [], heavy }), ...(heavy?.length ? { heavy } : {}) }, requestedAt: at, ...patch })++describe('the task says its heavy work and its CI', () => {+ it('parses heavy work and the CI jobs it starts, and leaves both out when not given', () => {+ const base = { difficulty: 'low', risk: 'low', why: 'x' }+ expect(parseAssessment({ ...base, needs: { heavy: ['build', 'e2e', 'build'], ci: { jobs: 4, macos: 2 } } }))+ .toMatchObject({ needs: { tools: [], devices: [], heavy: ['build', 'e2e'], ci: { jobs: 4, macos: 2 } } })+ expect(parseAssessment({ ...base, needs: { ci: { jobs: 1 } } })).toMatchObject({ needs: { ci: { jobs: 1, macos: 0 } } })+ // An empty list says nothing, and a request without either answers exactly as before.+ expect(parseAssessment({ ...base, needs: { heavy: [] } })).toEqual({ ...base, size: 'medium', needs: { tools: [], devices: [] } })+ expect(parseAssessment({ ...base, needs: {} })).toEqual({ ...base, size: 'medium', needs: { tools: [], devices: [] } })+ })+ it('explains what is wrong with them', () => {+ const base = { difficulty: 'low', risk: 'low', why: 'x' }+ for (const heavy of ['build', ['compile'], [1]]) expect(parseAssessment({ ...base, needs: { heavy } })).toContain('needs.heavy')+ for (const ci of [true, {}, { jobs: 0 }, { jobs: 1.5 }, { jobs: 101 }, { jobs: 2, macos: 3 }, { jobs: 2, macos: -1 }, { jobs: '2' }]) {+ expect(parseAssessment({ ...base, needs: { ci } })).toContain('needs.ci')+ }+ })+ it('takes the largest need of its kinds, and none without heavy work', () => {+ expect(heavyNeed({})).toBeNull()+ expect(heavyNeed({ heavy: [] })).toBeNull()+ expect(heavyNeed({ heavy: ['e2e'] })).toEqual({ memoryBytes: 6 * GB, diskBytes: 10 * GB, words: 'end-to-end tests' })+ expect(heavyNeed({ heavy: ['e2e', 'build'] })).toEqual({ memoryBytes: 8 * GB, diskBytes: 30 * GB, words: 'end-to-end tests and a heavy build' })+ })+ it('a heavy task\'s start asks its machine for half the need, so a machine ranked later still admits it; any other start asks what it always did', () => {+ expect(startRequirements({ tools: [], devices: [] })).toEqual(START_REQUIREMENTS)+ expect(startRequirements({ tools: [], devices: [], heavy: ['build'] })).toMatchObject({ memoryBytes: 4 * GB, diskBytes: 15 * GB })+ // End-to-end's half of the disk is less than any start asks, so the start's own stays.+ expect(startRequirements({ tools: [], devices: [], heavy: ['e2e'] })).toMatchObject({ memoryBytes: 3 * GB, diskBytes: START_REQUIREMENTS.diskBytes })+ expect(floorOf({ memoryBytes: 8 * GB, diskBytes: 30 * GB })).toEqual({ memoryBytes: 4 * GB, diskBytes: 15 * GB })+ })+})++describe('machine fit', () => {+ it('a heavy build avoids a low-memory machine: the one that has what it needs ranks first, and the other says why', () => {+ const choice = ok(route([on('small', { memory: 5, disk: 100 }), on('big', { memory: 16, disk: 100 })], a({ heavy: ['build'] })))+ expect(choice.shown.map(s => s.machineId)).toEqual(['big', 'small'])+ expect(choice.shown[1]!.notes).toEqual(['Machine fit: Short of free memory for a heavy build: it needs 8 GB memory and 30 GB disk free, '+ + 'so equally strong candidates that have it rank first.'])+ expect(choice.shown[0]!.notes).toEqual([])+ // Without heavy work the same machines rank as they always did, by title.+ expect(ok(route([on('small', { memory: 5, disk: 100 }), on('big', { memory: 16, disk: 100 })], a())).shown.map(s => s.machineId)).toEqual(['big', 'small'])+ expect(ok(route([on('a-small', { memory: 5, disk: 100 }), on('big', { memory: 16, disk: 100 })], a())).shown.map(s => s.machineId)).toEqual(['a-small', 'big'])+ expect(ok(route([on('a-small', { memory: 5, disk: 100 }), on('big', { memory: 16, disk: 100 })], a({ heavy: ['build'] }))).shown.map(s => s.machineId)).toEqual(['big', 'a-small'])+ })+ it('short of disk counts like short of memory', () => {+ const choice = ok(route([on('a-full', { memory: 16, disk: 20 }), on('b', { memory: 16, disk: 100 })], a({ heavy: ['build'] })))+ expect(choice.shown.map(s => s.machineId)).toEqual(['b', 'a-full'])+ expect(choice.shown[1]!.notes[0]).toMatch(/^Machine fit: Short of free disk for a heavy build:/)+ })+ it('never passes over a stronger model for a machine: a short machine still ranks above a weaker model that fits', () => {+ const choice = ok(route([on('short', { memory: 5, disk: 100 }), on('big', { memory: 16, disk: 100 }, { model: 'sonnet', effort: 'medium', quality: 2, cost: 2 })],+ a({ heavy: ['build'] })))+ expect(choice.shown.map(s => `${s.machineId} ${s.model}`)).toEqual(['short opus', 'big sonnet'])+ // What the candidate is shown and recorded as stays as measured.+ expect(choice.shown[0]!.quality).toBe(3)+ })+ it('below half the need the machine cannot run the work: left out with why, and none left is no candidate', () => {+ const choice = ok(route([on('tiny', { memory: 3, disk: 100 }), on('big', { memory: 16, disk: 100 })], a({ heavy: ['build'] })))+ expect(choice.shown.map(s => s.machineId)).toEqual(['big'])+ expect(choice.excluded).toEqual([{ title: 'New agent · Claude opus high · tiny', machine: 'tiny',+ reason: 'Machine fit: Too little free memory for a heavy build: it needs 8 GB memory and 30 GB disk free, and at least half to run at all.' }])+ expect(route([on('tiny', { memory: 16, disk: 10 })], a({ heavy: ['build'] }))).toMatchObject({ error: 'NO_CANDIDATE' })+ // Exactly half is enough to run.+ expect(ok(route([on('half', { memory: 4, disk: 15 })], a({ heavy: ['build'] }))).shown).toHaveLength(1)+ })+ it('says an unknown reading and ranks it after a machine known to fit, never leaving it out', () => {+ const choice = ok(route([on('a-unread', { memory: null, disk: 100 }), on('b', { memory: 16, disk: 100 })], a({ heavy: ['e2e'] })))+ expect(choice.shown.map(s => s.machineId)).toEqual(['b', 'a-unread'])+ expect(choice.shown[1]!.notes).toEqual(['Machine fit: Free memory unknown here; end-to-end tests: it needs 6 GB memory and 10 GB disk free.'])+ const both = ok(route([on('blind', { memory: null, disk: null })], a({ heavy: ['e2e'] })))+ expect(both.shown[0]!.notes).toEqual(['Machine fit: Free memory and disk unknown here; end-to-end tests: it needs 6 GB memory and 10 GB disk free.'])+ expect(ok(route([on('d', { memory: 16, disk: null })], a({ heavy: ['e2e'] }))).shown[0]!.notes)+ .toEqual(['Machine fit: Free disk unknown here; end-to-end tests: it needs 6 GB memory and 10 GB disk free.'])+ // A short machine whose disk is unknown is short: what is known decides.+ expect(ok(route([on('x', { memory: 5, disk: null })], a({ heavy: ['build'] }))).shown[0]!.notes[0]).toMatch(/^Machine fit: Short of free memory for a heavy build:/)+ // A probe with no machine reading at all is unknown too.+ expect(ok(route([on('none', { memory: 16, disk: 100 }, { load: undefined })], a({ heavy: ['build'] }))).shown[0]!.notes[0]).toContain('Free memory and disk unknown here')+ })+ it('a busy CPU ranks a machine later among equals, never leaving it out, and is said', () => {+ const choice = ok(route([on('a-busy', { memory: 16, disk: 100, cpu: 92.4 }), on('b', { memory: 16, disk: 100, cpu: 30 })], a({ heavy: ['build'] })))+ expect(choice.shown.map(s => s.machineId)).toEqual(['b', 'a-busy'])+ expect(choice.shown[1]!.notes).toEqual(['Machine fit: Its CPU is busy; it has what a heavy build needs.'])+ expect(ok(route([on('s', { memory: 5, disk: 100, cpu: 99 })], a({ heavy: ['build'] }))).shown[0]!.notes[0]).toMatch(/rank first\. Its CPU is busy\.$/)+ expect(ok(route([on('u', { memory: null, disk: 100, cpu: 99 })], a({ heavy: ['build'] }))).shown[0]!.notes[0]).toMatch(/free\. Its CPU is busy\.$/)+ })+ it('a member is judged by its machine\'s reading too', () => {+ const member = on('small', { memory: 5, disk: 100 }, { kind: 'member', agentId: 'ag1', name: 'Builder', repo: 'same' })+ const choice = ok(route([member, on('big', { memory: 16, disk: 100 })], a({ heavy: ['build'] })))+ expect(choice.shown.map(s => s.kind)).toEqual(['new', 'member'])+ })+ it('says nothing at all for work that is not heavy and starts no CI', () => {+ const plain = choose([on('small', { memory: 1, disk: 1 })], catalog, a(), NOW, [], [], [], [machineFit()])+ expect(ok(plain).adjusted).toBeUndefined()+ expect(ok(plain).shown[0]!.notes).toEqual([])+ })+})++describe('heavy work placed but not yet in the reading', () => {+ it('subtracts only heavy starts from the last 15 minutes: an agent running longer already shows in the free memory', () => {+ const starts = [heavyStart('studio', NOW - 3 * 60 * M, ['build'], { harnessId: 'h-old' }), heavyStart('studio', NOW - 5 * M, ['build'], { harnessId: 'h-new' })]+ expect(placedHeavyWork(starts, NOW)).toEqual(new Map([['studio', { memoryBytes: 8 * GB, diskBytes: 30 * GB, agents: 1 }]]))+ })+ it('counts heavy starts only: not a failed one, an ordinary one, one with no time or machine, or one at the edge of the window', () => {+ const starts = [+ heavyStart('m', NOW - M, ['build'], { error: 'Refused.' }),+ heavyStart('m', NOW - M, []),+ { request: { machineId: 'm', requirements: startRequirements({ tools: [], devices: [] }) }, requestedAt: NOW - M },+ // Asking as much memory as heavy work does not make a start heavy: only its own field does.+ { request: { machineId: 'm', requirements: { ...startRequirements({ tools: [], devices: [] }), memoryBytes: 16 * GB } }, requestedAt: NOW - M },+ { request: { machineId: 'm', heavy: 'build' }, requestedAt: NOW - M },+ { request: { machineId: 'm', heavy: ['compile', 3] }, requestedAt: NOW - M },+ { request: { heavy: ['build'] }, requestedAt: NOW - M },+ { request: { machineId: 'm', heavy: ['build'] } },+ heavyStart('m', NOW - PLACED_RECENT_MS),+ heavyStart('m', NOW + 2 * M),+ // An ordinary Builder's start asks 4 GB, under every heavy need.+ { request: { machineId: 'm', requirements: { ...startRequirements({ tools: [], devices: [] }), memoryBytes: 4 * 2 ** 30 } }, requestedAt: NOW - M },+ ]+ expect(placedHeavyWork(starts, NOW).size).toBe(0)+ // Its kind is read back from the memory its start asked for, and a start known only by its dispatch time counts too.+ const e2e = { request: { machineId: 'm', requirements: startRequirements({ tools: [], devices: [], heavy: ['e2e'] }), heavy: ['e2e'] }, dispatchedAt: NOW - M }+ expect(placedHeavyWork([e2e, heavyStart('m', NOW - M)], NOW).get('m')).toEqual({ memoryBytes: 14 * GB, diskBytes: 40 * GB, agents: 2 })+ // A start stamped up to a minute ahead of this clock counts.+ expect(placedHeavyWork([heavyStart('m', NOW + 50_000)], NOW).get('m')).toMatchObject({ agents: 1 })+ })+ it('a Harness Team account\'s start counts on its Mac, whose memory it shares', () => {+ const hostOf = (id: string) => id === 'team' ? 'mac' : id+ expect([...placedHeavyWork([heavyStart('team', NOW - M), heavyStart('mac', NOW - M)], NOW, hostOf)]).toEqual([['mac', { memoryBytes: 16 * GB, diskBytes: 60 * GB, agents: 2 }]])+ })+ it('a machine that fits by its reading is short, or left out, once the heavy work just started there is counted, and says so', () => {+ const plugin = (starts: Array<Record<string, unknown>>) => machineFit({ placed: placedHeavyWork(starts, NOW) })+ const probes = [on('studio', { memory: 14, disk: 100 }), on('z-other', { memory: 16, disk: 100 })]+ expect(ok(route(probes, a({ heavy: ['build'] }), plugin([]))).shown.map(s => s.machineId)).toEqual(['studio', 'z-other'])+ const one = ok(route(probes, a({ heavy: ['build'] }), plugin([heavyStart('studio', NOW - 5 * M), heavyStart('studio', NOW - 4 * 60 * M)])))+ expect(one.shown.map(s => s.machineId)).toEqual(['z-other', 'studio'])+ expect(one.shown[1]!.notes[0]).toBe('Machine fit: Short of free memory for a heavy build, counting heavy work started there in the last 15 minutes: '+ + 'it needs 8 GB memory and 30 GB disk free, so equally strong candidates that have it rank first.')+ const three = ok(route(probes, a({ heavy: ['build'] }), plugin([1, 2, 3].map(i => heavyStart('studio', NOW - i * M)))))+ expect(three.shown.map(s => s.machineId)).toEqual(['z-other'])+ expect(three.excluded[0]!.reason).toBe('Machine fit: Too little free memory and disk for a heavy build, counting heavy work started there in the last 15 minutes: '+ + 'it needs 8 GB memory and 30 GB disk free, and at least half to run at all.')+ })+})++describe('the CI jobs limit', () => {+ const load = (running: number, queued = 0, macosRunning = 0, macosQueued = 0): CiLoad => ({ running, queued, macosRunning, macosQueued })+ it('holds work that starts CI past the account\'s limit, counting queued jobs, with a time to route it again', () => {+ expect(ciHold({ ci: { jobs: 4, macos: 0 } }, load(16))).toBeNull()+ expect(ciHold({ ci: { jobs: 4, macos: 0 } }, load(16, 1))).toBe(`CI is at the account's limit: 17 of ${CI_LIMIT.jobs} jobs running or queued, 0 of ${CI_LIMIT.macos} on macOS, `+ + `and this task starts 4 more. Route it again in ${CI_RETRY_MINUTES} minutes.`)+ // The macOS runners have their own, smaller 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 of 5 on macOS, and this task starts 2 more (2 on macOS).')+ })+ 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()+ })+ it('a held task has no candidate: every one is left out with the hold\'s reason', () => {+ const held = route([on('a', { memory: 16, disk: 100 }), on('b', { memory: 16, disk: 100 })], a({ ci: { jobs: 3, macos: 0 } }), machineFit({ ci: load(19) }))+ expect(held).toMatchObject({ error: 'NO_CANDIDATE' })+ expect('error' in held && held.excluded.map(e => e.reason)).toEqual(['a', 'b'].map(() => `Machine fit: ${ciHold({ ci: { jobs: 3, macos: 0 } }, load(19))}`))+ // Under the limit the CI says nothing, and heavy work is judged as before.+ expect(ok(route([on('a', { memory: 16, disk: 100 })], a({ ci: { jobs: 3, macos: 0 } }), machineFit({ ci: load(2) }))).shown[0]!.notes).toEqual([])+ })+ it('a task that starts CI is told when the limit could not be checked, beside its fit', () => {+ expect(ok(route([on('a', { memory: 16, disk: 100 })], a({ ci: { jobs: 1, macos: 0 } }))).shown[0]!.notes).toEqual([`Machine fit: ${CI_UNCHECKED}`])+ expect(ok(route([on('a', { memory: 5, disk: 100 })], a({ ci: { jobs: 1, macos: 0 }, heavy: ['build'] }))).shown[0]!.notes[0]).toMatch(/rank first\. The running CI jobs could not be read/)+ })+})++describe('its maker', () => {+ const input = (assessment: Assessment, state: Record<string, unknown>): PluginInput => ({ conversationId: 'g1', assessment, read: { tab: { state } },+ catalog, history: Promise.resolve(null), request: async () => ({}) })+ it('is on the route\'s list of makers', () => { expect(ROUTE_PLUGIN_MAKERS).toContain(MACHINE_FIT_MAKER) })+ it('has nothing to say for work that is not heavy and starts no CI', async () => {+ expect(await MACHINE_FIT_MAKER.make(input(a(), {}))).toBeNull()+ })+ it('reads the heavy work just started off the route\'s own read, a Harness Team account\'s on its Mac', async () => {+ const now = Date.now()+ const state = { machines: [{ machineId: 'team', hostMachineId: 'mac' }, { machineId: 'mac' }],+ starts: [{ request: { machineId: 'team', requirements: startRequirements({ tools: [], devices: [], heavy: ['build'] }), heavy: ['build'] }, requestedAt: now - M }] }+ const plugin = (await MACHINE_FIT_MAKER.make(input(a({ heavy: ['build'] }), state)))!+ const choice = ok(choose([on('mac', { memory: 12, disk: 100 }), on('z', { memory: 12, disk: 100 })], catalog, a({ heavy: ['build'] }), now, [], [], [], [plugin]))+ expect(choice.shown.map(s => s.machineId)).toEqual(['z', 'mac'])+ expect(choice.shown[1]!.notes[0]).toContain('counting heavy work started there in the last 15 minutes')+ // A tab read with no machines or starts reads as nothing placed.+ const bare = (await MACHINE_FIT_MAKER.make(input(a({ heavy: ['build'] }), {})))!+ expect(ok(choose([on('mac', { memory: 12, disk: 100 })], catalog, a({ heavy: ['build'] }), now, [], [], [], [bare])).shown).toHaveLength(1)+ // The CI load is not read yet, so a task that starts CI hears that.+ const ci = (await MACHINE_FIT_MAKER.make(input(a({ ci: { jobs: 1, macos: 0 } }), {})))!+ expect(ok(choose([on('mac', { memory: 12, disk: 100 })], catalog, a({ ci: { jobs: 1, macos: 0 } }), now, [], [], [], [ci])).shown[0]!.notes).toEqual([`Machine fit: ${CI_UNCHECKED}`])+ })+})diff --git a/cli/src/superTabs/machineFit.ts b/cli/src/superTabs/machineFit.tsnew file mode 100644index 000000000..2feab2e62--- /dev/null+++ b/cli/src/superTabs/machineFit.ts@@ -0,0 +1,145 @@+/** Scholes's goals, piece 5: place work by what its machine has. A task can say it runs a heavy build or end-to-end tests on+ * its machine (`needs.heavy`), or starts heavy CI workflows itself (`needs.ci`: OS images, end-to-end, macOS jobs). The+ * route's plug-in (route.ts RoutePlugin) then+ * - leaves out a machine with less than half of what the work needs free, which cannot run it;+ * - ranks one with less than the need after every equally strong candidate that has it, never above a weaker model;+ * - says when a reading is unknown, and ranks a busy CPU later among equals;+ * - counts heavy work started there in the last minutes, which its reading may not show yet (pieces 3 to 6 all started on+ * one Mac within ten minutes, and every route saw the same free memory, 2026-10-31);+ * - holds work that would start CI past the account's running-jobs limit, with a time to route it again.+ * Everything it needs is read before the route ([placedHeavyWork], the CI reading); the plug-in itself is pure. */+import type { Adjustment, HeavyWork, Needs, Probe, RoutePlugin } from './route.js'+import type { PluginMaker } from './routePlugins.js'+import { object } from './wire.js'++type Json = Record<string, unknown>+const GB = 1e9+/** What a machine needs free for each kind of heavy work: a Desktop, Flutter or OS image build, or the end-to-end suites. */+export const HEAVY_NEEDS: Record<HeavyWork, { memoryBytes: number; diskBytes: number; words: string }> = {+ build: { memoryBytes: 8 * GB, diskBytes: 30 * GB, words: 'a heavy build' },+ e2e: { memoryBytes: 6 * GB, diskBytes: 10 * GB, words: 'end-to-end tests' },+}+/** Below this share of the need the machine cannot run the work: it is left out. */+export const FLOOR_SHARE = 0.5+/** How far a short or unread machine ranks down, in catalog strength: less than one step, so a stronger model is never+ * passed over for a machine, while an equally strong one that fits always ranks first. */+export const SHORT_STRENGTH = -0.5, UNKNOWN_STRENGTH = -0.25+/** A CPU this busy ranks a machine later among equals; one reading is only a moment, so it never leaves one out. */+export const BUSY_CPU_PERCENT = 85, BUSY_CPU_COST = 1+/** A heavy start this recent may not show in its machine's reading yet. */+export const PLACED_RECENT_MS = 15 * 60_000+/** The account's running-jobs limit on GitHub Actions (docs/validation-and-release.md). */+export const CI_LIMIT = { jobs: 20, macos: 5 }+/** How long a held task waits before the route is asked again: a CI job takes minutes, not hours. */+export const CI_RETRY_MINUTES = 10++export interface Need { memoryBytes: number; diskBytes: number; words: string }+/** What the task's heavy work needs free, the largest of its kinds; null when it declares none. */+export function heavyNeed(needs: Pick<Needs, 'heavy'>): Need | null {+ const kinds = (needs.heavy ?? []).filter(k => Object.hasOwn(HEAVY_NEEDS, k))+ if (!kinds.length) return null+ return { memoryBytes: Math.max(...kinds.map(k => HEAVY_NEEDS[k].memoryBytes)), diskBytes: Math.max(...kinds.map(k => HEAVY_NEEDS[k].diskBytes)),+ words: kinds.map(k => HEAVY_NEEDS[k].words).join(' and ') }+}+/** The least a machine must have free to run [need] at all: below it the route leaves the machine out. */+export const floorOf = (need: Pick<Need, 'memoryBytes' | 'diskBytes'>) => ({ memoryBytes: need.memoryBytes * FLOOR_SHARE, diskBytes: need.diskBytes * FLOOR_SHARE })++/** Heavy work already placed on each machine: what it is expected to use, and how many agents. */+export interface Placed { memoryBytes: number; diskBytes: number; agents: number }+const finite = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v)+/** The heavy work a start declared in its own field (backend superTabs/model.ts AgentStartRequest.heavy), or none. Never read+ * from the memory it asked: an ordinary Builder's start may ask as much as a heavy one (review of #2426). */+function heavyOfStart(start: Json): Need | null {+ const heavy = object(start.request).heavy+ return Array.isArray(heavy) ? heavyNeed({ heavy: heavy.filter((k): k is HeavyWork => typeof k === 'string' && Object.hasOwn(HEAVY_NEEDS, k)) }) : null+}+/** A start stamped this far ahead of this machine's clock still counts: clocks differ a little (as the window pull allows). */+export const CLOCK_SKEW_MS = 60_000+/** Heavy work placed per machine and not yet in its reading: a heavy start that did not fail, made in the last+ * [PLACED_RECENT_MS]. An agent running longer already shows in its machine's free memory, so it is never subtracted again:+ * Builders waiting hours on review would otherwise push every heavy task off the machine (Lead, 10-31). [hostOf] names the+ * machine whose memory a machine shares (a Harness Team account is its Mac). */+export function placedHeavyWork(starts: Json[], now: number, hostOf: (machineId: string) => string = id => id): Map<string, Placed> {+ const placed = new Map<string, Placed>()+ for (const start of starts) {+ const need = heavyOfStart(start), machineId = object(start.request).machineId+ const at = finite(start.requestedAt) ? start.requestedAt : finite(start.dispatchedAt) ? start.dispatchedAt : null+ if (!need || start.error || typeof machineId !== 'string' || at === null || now - at >= PLACED_RECENT_MS || at > now + CLOCK_SKEW_MS) continue+ const host = hostOf(machineId), sum = placed.get(host) ?? { memoryBytes: 0, diskBytes: 0, agents: 0 }+ placed.set(host, { memoryBytes: sum.memoryBytes + need.memoryBytes, diskBytes: sum.diskBytes + need.diskBytes, agents: sum.agents + 1 })+ }+ return placed+}++/** 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 }+/** 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. */+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+ if (!over) return null+ const starts = `${needs.ci.jobs} more${needs.ci.macos ? ` (${needs.ci.macos} on macOS)` : ''}`+ return `CI is at the account's limit: ${busy} of ${CI_LIMIT.jobs} jobs running or queued, ${mac} of ${CI_LIMIT.macos} on macOS, and this task `+ + `starts ${starts}. Route it again in ${CI_RETRY_MINUTES} minutes.`+}+/** Said when a task starts CI and the load could not be read. */+export const CI_UNCHECKED = `The 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.`++/** A need in whole gigabytes, as the needs are set. */+const gb = (n: number) => `${Math.round(n / GB)} GB`+/** The machine-fit plug-in. [placed]: [placedHeavyWork]; [hostOf]: as there; [ci]: the CI load, null when unread. */+export function machineFit(input: { placed?: ReadonlyMap<string, Placed>; hostOf?: (machineId: string) => string; ci?: CiLoad | null } = {}): RoutePlugin {+ const hostOf = input.hostOf ?? (id => id)+ return {+ name: 'Machine fit',+ adjust(candidate, context) {+ const needs = context.assessment.needs+ 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 }+ },+ }+}++/** How [candidate]'s machine fits the task's heavy work, with [held] already placed there; null when the task has none, or+ * the machine has all it needs and an idle CPU. Its reason names only which resource is short and what the work needs, never+ * the machine's measured memory, disk or CPU: every reader of the route log reads it, also of a machine the route shows+ * nothing else of (paused, folded, or reached only for its member; review of #2426). */+function fitOf(candidate: Pick<Probe, 'load'>, needs: Needs, held: Placed | undefined): Adjustment | null {+ const need = heavyNeed(needs)+ if (!need) return null+ const floor = floorOf(need), load = candidate.load+ const left = (free: number | null | undefined, use: number) => finite(free) ? free - use : null+ const memory = left(load?.freeMemoryBytes, held?.memoryBytes ?? 0), disk = left(load?.freeDiskBytes, held?.diskBytes ?? 0)+ const which = (memoryShort: boolean, diskShort: boolean) => [memoryShort ? 'memory' : null, diskShort ? 'disk' : null].filter(Boolean).join(' and ')+ const counting = held?.agents ? `, counting heavy work started there in the last ${PLACED_RECENT_MS / 60_000} minutes` : ''+ const wants = `it needs ${gb(need.memoryBytes)} memory and ${gb(need.diskBytes)} disk free`+ const busy = finite(load?.cpuPercent) && load.cpuPercent >= BUSY_CPU_PERCENT+ const cpu = busy ? { cost: BUSY_CPU_COST } : {}, cpuWords = busy ? ' Its CPU is busy.' : ''+ const out = which(memory !== null && memory < floor.memoryBytes, disk !== null && disk < floor.diskBytes)+ if (out) return { refuse: true, reason: `Too little free ${out} for ${need.words}${counting}: ${wants}, and at least half to run at all.` }+ const short = which(memory !== null && memory < need.memoryBytes, disk !== null && disk < need.diskBytes)+ if (short) return { strength: SHORT_STRENGTH, ...cpu, reason: `Short of free ${short} for ${need.words}${counting}: ${wants}, so equally strong candidates that have it rank first.${cpuWords}` }+ const unknown = which(memory === null, disk === null)+ if (unknown) return { strength: UNKNOWN_STRENGTH, ...cpu, reason: `Free ${unknown} unknown here; ${need.words}: ${wants}.${cpuWords}` }+ return busy ? { cost: BUSY_CPU_COST, reason: `Its CPU is busy; it has what ${need.words} needs.` } : null+}++/** Piece 5's maker (routePlugins.ts): the heavy work placed on each machine, read off the route's own Super Tab read. Nothing+ * to say for a task with no heavy work and no CI. The CI load is not read yet: a task that starts CI is told so. */+export const MACHINE_FIT_MAKER: PluginMaker = {+ name: 'Machine fit',+ async make({ read, assessment }) {+ if (!heavyNeed(assessment.needs) && !assessment.needs.ci) return null+ const state = object(object(read.tab).state)+ const machines = Array.isArray(state.machines) ? state.machines.map(object) : []+ const macOf = new Map(machines.filter(m => typeof m.hostMachineId === 'string').map(m => [String(m.machineId), String(m.hostMachineId)]))+ const hostOf = (id: string) => macOf.get(id) ?? id+ const starts = Array.isArray(state.starts) ? state.starts.map(object) : []+ return machineFit({ placed: placedHeavyWork(starts, Date.now(), hostOf), hostOf, ci: null })+ },+}diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.tsindex ac2038013..b19c099c6 100644--- a/cli/src/superTabs/route.ts+++ b/cli/src/superTabs/route.ts@@ -16,7 +16,12 @@ export type Size = 'small' | 'medium' | 'large'* (docs/plans/2026-10-23-swarm-local-models.md). *//** `model`: a model a person named, in their words ("deepseek 4.1 flash"); only candidates running it are considered,* whatever their strength (owner, 2026-10-23: a Builder on a named API model was ranked below Opus and never offered). */-export interface Assessment { difficulty: Level; risk: Level; size: Size; why: string; kind?: string; local?: boolean; model?: string; needs: { tools: string[]; devices: string[]; cwd?: string } }+/** `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. */+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 }/** A model of the reviewed catalog (backend superTabs/catalog.ts): how strong it is, what it costs, and whether it is offered* when nobody names it. */export interface CatalogModel { engine: 'claude' | 'codex'; model: string; effort: string; strength: number; cost: number; offered: boolean; note?: string }@@ -39,8 +44,9 @@ export interface Quota { known: boolean; leftPercent: number | null; resetsAt: nexport interface TaskFolder { cwd: string; kind: 'git' | 'none' | 'missing' | 'unknown'; name: string | null; root: string | null; remote: string | null }/** What a member's `agents_list` frame says it is working on; every field is null when the frame does not say. */export interface MemberFrame { title: string | null; project: string | null; cwd: string | null; root: string | null; remote: string | null; branch: string | null; updatedAt: number | null }-/** What a machine offers a new agent. Each field is null when it could not be read. */-export interface MachineLoad { agents: number | null; freeMemoryBytes: number | null; hasFolder: boolean | null }+/** What a machine offers an agent. Each field is null when it could not be read; `freeDiskBytes` (the project's disk) and+ * `cpuPercent` are absent where the probe did not read them. */+export interface MachineLoad { agents: number | null; freeMemoryBytes: number | null; hasFolder: boolean | null; freeDiskBytes?: number | null; cpuPercent?: number | null }export interface Probe {kind: 'member' | 'new'; agentId?: string; name?: string; machineId: string; machineName: string/** `quality` is the catalog's strength, 1 for a model it does not rate (`unrated`). */@@ -55,7 +61,7 @@ export interface Probe {/** Members: the frame (null when it could not be read), whether the member is in the task's repository, and its earlier work in this Super Tab. */frame?: MemberFrame | null; repo?: 'same' | 'different' | 'unknown'; earlier?: Array<{ group: string; outcome: string }>terminalUnverified?: boolean- /** New agents: what the machine has. */+ /** What the machine has: for new agents, and for members where their machine's reading is known. */load?: MachineLoad/** A new agent on a model served on the Swarm's grid: free, reached through the grid relay, `model`/`effort` `default`.* [gridKind]: a member's engine (`local`), a member's API (`api`), or a model shared with this machine's owner. */@@ -170,6 +176,7 @@ function pluginAdjustments<T extends Probe & { fit: Fit }>(ranked: T[], plugins:export interface Verdict { pick: Shown; via: 'order' | 'only'; p: null; why: string }const LEVELS: Level[] = ['low', 'medium', 'high']+const HEAVY_WORK: unknown[] = ['build', 'e2e'] satisfies HeavyWork[]/** Run time and spend per window by task size, for a catalog row of cost 2 (owner's table, 2026-10-21). */export const SIZES: Record<Size, { minutes: number; spend: Record<Window, number> }> = {small: { minutes: 20, spend: { '5-hour': 10, weekly: 1 } },@@ -219,9 +226,18 @@ export function parseAssessment(value: unknown): Assessment | string {if (v.kind !== undefined && (typeof v.kind !== 'string' || !/^[a-z][a-z0-9-]{0,39}$/.test(v.kind))) return 'Set kind to one lowercase word, such as ui or docs.'if (v.local !== undefined && typeof v.local !== 'boolean') return 'Set local to true only when a person asked for a local model.'if (v.model !== undefined && (typeof v.model !== 'string' || !words(v.model).length || v.model.length > 200)) return 'Set model to the model a person named, in their words.'+ const heavy = needs.heavy+ if (heavy !== undefined && (!Array.isArray(heavy) || !heavy.every(h => HEAVY_WORK.includes(h)))) return 'Set needs.heavy to a list of build and e2e.'+ const ci = needs.ci === undefined ? undefined : object(needs.ci)+ const count = (n: unknown, max: number) => Number.isInteger(n) && (n as number) >= 0 && (n as number) <= max+ if (ci && (!count(ci.jobs, 100) || (ci.jobs as number) < 1 || (ci.macos !== undefined && !count(ci.macos, ci.jobs as number)))) {+ return 'Set needs.ci to the CI jobs the work starts, as {"jobs": 1 to 100, "macos": how many of them run on macOS}.'+ }return { difficulty: v.difficulty as Level, risk: v.risk as Level, size: size as Size, why, ...(v.kind ? { kind: v.kind as string } : {}),...(v.local === true ? { local: true } : {}), ...(typeof v.model === 'string' ? { model: v.model.trim() } : {}),- needs: { tools: list(needs.tools), devices: list(needs.devices), ...(cwd ? { cwd } : {}) } }+ needs: { tools: list(needs.tools), devices: list(needs.devices), ...(cwd ? { cwd } : {}),+ ...(Array.isArray(heavy) && heavy.length ? { heavy: [...new Set(heavy as HeavyWork[])] } : {}),+ ...(ci ? { ci: { jobs: ci.jobs as number, macos: (ci.macos as number | undefined) ?? 0 } } : {}) } }}/** Claude sends ISO strings, Codex epoch seconds; anything above 1e10 is already milliseconds. */diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.tsindex 55aea7d06..9b36c5d33 100644--- a/cli/src/superTabs/routeCommand.spec.ts+++ b/cli/src/superTabs/routeCommand.spec.ts@@ -8,6 +8,8 @@ import type { describeScmProject } from '../scm/scmProjects.js'import { admission, quotaOf, RELAYED_QUOTA, USED_UP_WINDOW } from './capacity.js'import { OTHER_REPOSITORY, type Catalog, type Probe, type RoutePlugin } from './route.js'import { MAKER_TIMEOUT_MS, type PluginInput, type PluginMaker } from './routePlugins.js'+import { placedHeavyWork } from './machineFit.js'+import { inspectCapacity } from './start.js'import { EARLIER_UNREADABLE, FIRST_ATTEMPT_ONLY, GRID_FIRST, GRID_LIMITS, NEVER_REVIEWS } from './routeCheapFirst.js'// Sonnet rated 3, as an owner who wants Sonnet Builders rates it (a build needs 3: route.ts buildRefusals), so the member these@@ -189,6 +191,39 @@ describe('routeTask', () => {} finally { vi.useRealTimers() }})// A member at work is not offered; one whose task was lost is, with a note ('a member whose last task was lost').+ it('judges heavy work by a machine reached directly, its members too, by the disk its capacity read measured', async () => {+ const heavy = (needs: Record<string, unknown>) => ({ ...input, assessment: { ...input.assessment, needs: { heavy: ['build'], ...needs } } })+ const reading = (resources: Record<string, unknown>) => opener(id => daemon(id, { agents: id === 'm1' ? ['h1'] : [], capacity: { resources, tools: { git: true }, devices: {} } }))+ const disky = { memoryTotalBytes: 16e9, memoryUsedBytes: 2e9, cpuPercent: 10, projectDiskFreeBytes: 20e9 }+ const short = 'Machine fit: Short of free disk for a heavy build: it needs 8 GB memory and 30 GB disk free, so equally strong candidates that have it rank first.'+ const answer = await routeTask(heavy({}), scoped(), where as never, reading(disky))+ const shown = [answer.pick, ...answer.alternatives as unknown[]] as Array<{ kind: string; notes?: string[] }>+ expect(new Set(shown.map(c => c.kind))).toEqual(new Set(['member', 'new']))+ for (const c of shown) expect(c.notes).toContain(short)+ const folder = { describe: async () => null, isDirectory: async () => true }+ expect(await routeTask(heavy({ cwd: '/repo' }), scoped(), where as never, reading(disky), () => 'op', folder)).toMatchObject({ ok: true, pick: { notes: expect.arrayContaining([short]) } })+ // A read that measured no disk says so; its new agents' starts could not verify the disk either.+ const blind = await routeTask(heavy({}), scoped(), where as never, reading({ memoryTotalBytes: 16e9, memoryUsedBytes: 2e9, cpuPercent: 10 }))+ expect(blind).toMatchObject({ pick: { kind: 'member', notes: expect.arrayContaining(['Machine fit: Free disk unknown here; a heavy build: it needs 8 GB memory and 30 GB disk free.']) } })+ })+ // Lead, 10-31: a routed heavy start is never refused on the machine the route offered.+ it('ranks a machine between half the need and the need later, and the start there is admitted and counts as heavy', async () => {+ const between = { memoryTotalBytes: 16e9, memoryUsedBytes: 10e9, cpuPercent: 10, projectDiskFreeBytes: 100e9 }+ const roomy = { memoryTotalBytes: 32e9, memoryUsedBytes: 2e9, cpuPercent: 10, projectDiskFreeBytes: 100e9 }+ const machines = (id: string) => daemon(id, { capacity: { resources: id === 'm1' ? between : roomy, tools: { git: true }, devices: {} } })+ const heavy = { ...input, assessment: { ...input.assessment, needs: { heavy: ['build'] } } }+ const noMembers = tab(); noMembers.state.agents = agents.filter(a => a.id === 'a2') as never+ const answer = await routeTask(heavy, scoped({ tab: noMembers }), where as never, opener(machines))+ expect(answer).toMatchObject({ ok: true, pick: { machineId: 'm2' } })+ const later = (answer.alternatives as Array<{ machineId: string; engine: string; notes?: string[] }>).find(c => c.machineId === 'm1')!+ expect(later.notes).toContain('Machine fit: Short of free memory for a heavy build: it needs 8 GB memory and 30 GB disk free, so equally strong candidates that have it rank first.')+ // The start the route suggests, on that machine: its own check admits it, and later routes count it as heavy work there.+ const hint = JSON.parse(String(answer.next).replace(/^Start with: start OPERATION_ID /, '').replace(/, then assign[\s\S]*$/, ''))+ const request = { ...hint, machineId: 'm1', engine: later.engine }+ expect(await inspectCapacity(machines('m1') as never, request)).toMatchObject({ allowed: true })+ expect(request.heavy).toEqual(['build'])+ expect(placedHeavyWork([{ request, requestedAt: Date.now() }], Date.now()).get('m1')).toMatchObject({ agents: 1, memoryBytes: 8e9 })+ })it('does not offer a member whose task is working', async () => {const state = tab({ id: 'x', agentId: 'a1', status: 'working' })const s = scoped({ tab: state })@@ -1015,6 +1050,32 @@ describe('routing contributed capacity', () => {const member = await runPool(healthy(), true)expect(member.answer.ok).toBe(true)})+ // Scholes's goals, piece 5 (machineFit.ts): heavy work is judged by the machine's reading, for its members as for new agents.+ it('judges heavy work by the contributed machine\'s free memory, disk and CPU, for members too, and its start says it is heavy', async () => {+ const pool = healthy(); Object.assign(pool.observation.resources, { memoryUsedBytes: 26e9, cpuPercent: 92 })+ const { answer } = await runPool(pool, true, { heavy: ['build'] })+ const short = 'Machine fit: Short of free memory for a heavy build: it needs 8 GB memory and 30 GB disk free, so equally strong candidates that have it rank first. Its CPU is busy.'+ const shown = [answer.pick, ...answer.alternatives as unknown[]] as Array<{ kind: string; notes?: string[] }>+ expect(new Set(shown.map(c => c.kind))).toEqual(new Set(['member', 'new']))+ for (const c of shown) expect(c.notes).toContain(short)+ expect((await runPool(healthy(), false, { heavy: ['build'] })).answer.next).toContain('"requirements":{"memoryBytes":4000000000,"diskBytes":15000000000')+ expect((await runPool(healthy(), false, { heavy: ['build'] })).answer.next).toContain('"heavy":["build"]')+ expect((await runPool(healthy(), false)).answer.next).not.toContain('heavy')+ // A reading with no CPU says nothing of it, and a machine that has what it needs says nothing at all.+ const roomy = await runPool(healthy(), true, { heavy: ['build'] })+ expect((roomy.answer.pick as { notes?: string[] }).notes ?? []).not.toEqual(expect.arrayContaining([expect.stringContaining('Machine fit')]))+ })+ // Review of #2426 (privacy): every reader of the route log reads the reasons, also for a machine the route shows nothing else+ // of. A paused machine offers no new agent, so its reading was never shown; its member's reason must not show it either.+ it('never shows a paused machine\'s measured memory, disk or CPU in its member\'s reason, the answer or the record', async () => {+ const pool = { ...healthy(), paused: true }; Object.assign(pool.observation.resources, { memoryUsedBytes: 26e9, cpuPercent: 92 })+ const { answer, s } = await runPool(pool, true, { heavy: ['build'] })+ expect(answer).toMatchObject({ ok: true, pick: { kind: 'member', notes: expect.arrayContaining([+ 'Machine fit: Short of free memory for a heavy build: it needs 8 GB memory and 30 GB disk free, so equally strong candidates that have it rank first. Its CPU is busy.']) } })+ for (const text of [JSON.stringify(answer), JSON.stringify(recorded(s).command.decision)]) {+ for (const measured of ['6.0 GB', '200.0 GB', '92%', '6 GB', '200 GB']) expect(text).not.toContain(measured)+ }+ })it('reads an old OpenCode contribution as its installed Claude observation', async () => {const pool = healthy()pool.engines = ['opencode']diff --git a/cli/src/superTabs/routeCommand.ts b/cli/src/superTabs/routeCommand.tsindex 294b3a9b3..013a029bf 100644--- a/cli/src/superTabs/routeCommand.ts+++ b/cli/src/superTabs/routeCommand.ts@@ -384,7 +384,8 @@ export async function routeTask(input: { tabId: string; conversationId: string;// instructions takes no roleName (it came with them, phase 2).: `Start with: start OPERATION_ID ${JSON.stringify({ conversationId: input.conversationId, name: 'NAME', ...(instructions ? { roleName: 'ROLE' } : {}),cwd: text(machines.get(verdict.pick.machineId)?.pool?.cwd) ?? assessment.needs.cwd ?? '/absolute/repo/on/that/machine',- worktree: true, requirements: startRequirements(assessment.needs), machineId: verdict.pick.machineId, engine: verdict.pick.engine,+ worktree: true, requirements: startRequirements(assessment.needs), ...(assessment.needs.heavy ? { heavy: assessment.needs.heavy } : {}),+ machineId: verdict.pick.machineId, engine: verdict.pick.engine,// A local model is named by the grid alone: no subscription model or effort goes with it....(verdict.pick.gridModel ? { gridModel: verdict.pick.gridModel, gridName: verdict.pick.gridName } : { model: verdict.pick.model, effort: verdict.pick.effort }),...(typeof routeDecisionId === 'string' ? { routeDecisionId } : {}) })}, then assign the started agent${decision ? ' with the same routeDecisionId' : ''}. `@@ -507,6 +508,14 @@ export function offlineModels(state: Json, now: number = Date.now()): Array<{ tireturn out}+/** What a machine reached directly has, from its capacity read. Its disk is the task folder's, or with none named the disk the+ * read was asked about (`/`), which still says whether heavy work fits there; whether it has the folder only when one was named. */+function loadOf(resources: Json, agents: number | null, cwd: string | undefined): NonNullable<Probe['load']> {+ return { agents, freeMemoryBytes: finite(resources.memoryTotalBytes) && finite(resources.memoryUsedBytes) ? resources.memoryTotalBytes - resources.memoryUsedBytes : null,+ hasFolder: cwd ? finite(resources.projectDiskFreeBytes) : null, freeDiskBytes: finite(resources.projectDiskFreeBytes) ? resources.projectDiskFreeBytes : null,+ cpuPercent: finite(resources.cpuPercent) ? resources.cpuPercent : null }+}+async function probeMachine(machineId: string, { name: machineName, status, account, pool, folded, unready = READY, stalled: stuck = false }: { name: string; status: string; account: boolean; pool?: Json; folded?: boolean; unready?: Unready; stalled?: boolean },members: Json[], allModels: CatalogModel[], catalog: Catalog, a: Assessment, where: Where, open: typeof openDaemon): Promise<Probe[]> {const listedEngines = Array.isArray(pool?.engines) ? pool.engines.filter((engine): engine is string => typeof engine === 'string') : []@@ -557,17 +566,20 @@ async function probeMachine(machineId: string, { name: machineName, status, acco...(needs.devices.length ? ['Required devices have not been reported.'] : []),...unready.all]const pushNote = unready.push ? [unready.push] : []+ // What the machine has, for new agents and members alike: heavy work runs on the machine whoever does it (machineFit.ts).+ const load: Probe['load'] = { agents: Array.isArray(observed.runningHarnessIds) ? observed.runningHarnessIds.length : null,+ freeMemoryBytes: finite(resources.memoryTotalBytes) && finite(resources.memoryUsedBytes) ? resources.memoryTotalBytes - resources.memoryUsedBytes : null,+ hasFolder: finite(resources.projectDiskFreeBytes), freeDiskBytes: finite(resources.projectDiskFreeBytes) ? resources.projectDiskFreeBytes : null,+ cpuPercent: finite(resources.cpuPercent) ? resources.cpuPercent : null }return [...members.map(m => {const engine = String(object(m.configuration).engine), allowance = quota(engine)const running = Array.isArray(observed.runningHarnessIds) ? observed.runningHarnessIds.includes(m.harnessId) : nullreturn { ...memberProbe(m, fresh ? [...memberRefusals(running, needs.tools, needs.devices, tools, object(observed.devices), object(observed.toolProbeErrors)),...teammates(m.contributorId)] : [OFFLINE],- allowance, null, fresh && running === null, [...pushNote, ...usedUp(allowance)]) }+ allowance, null, fresh && running === null, [...pushNote, ...usedUp(allowance)]), ...(fresh ? { load } : {}) }}),...models.map(m => ({ ...newProbe(m, [...newReasons, ...(unready.engines[m.engine] ? [unready.engines[m.engine]!] : [])], quota(m.engine), fresh && quota(m.engine).known,- { agents: Array.isArray(observed.runningHarnessIds) ? observed.runningHarnessIds.length : null,- freeMemoryBytes: finite(resources.memoryTotalBytes) && finite(resources.memoryUsedBytes) ? resources.memoryTotalBytes - resources.memoryUsedBytes : null,- hasFolder: finite(resources.projectDiskFreeBytes) }, [...pushNote, ...(stuck ? [STALLED] : []), ...usedUp(quota(m.engine))]) }))]+ load, [...pushNote, ...(stuck ? [STALLED] : []), ...usedUp(quota(m.engine))]) }))]}// The account says this machine is off, so nothing there can run or be asked.if (account && status === 'offline') return [...members.map(m => memberProbe(m, [OFFLINE])), ...offline()]@@ -595,15 +607,14 @@ async function probeMachine(machineId: string, { name: machineName, status, accoconst refusals = memberRefusals(live.has(String(m.harnessId)), needs.tools, needs.devices,object(capacity.tools), object(capacity.devices), object(capacity.toolProbeErrors))const frame = frames.find(f => f.id === m.harnessId)- probes.push(memberProbe(m, refusals, allowance, frame ? frameOf(frame) : null, false, usedUp(allowance)))+ probes.push({ ...memberProbe(m, refusals, allowance, frame ? frameOf(frame) : null, false, usedUp(allowance)),+ load: loadOf(object(capacity.resources), Array.isArray(listed.agents) ? frames.length : null, a.needs.cwd) })}for (const m of models) {const inspected = byEngine.get(m.engine)!const resources = object(inspected.capacity.resources)// The capacity probe already measured the task's folder (its disk), so the answer is reused, not asked again.- const load = { agents: Array.isArray(listed.agents) ? frames.length : null,- freeMemoryBytes: finite(resources.memoryTotalBytes) && finite(resources.memoryUsedBytes) ? resources.memoryTotalBytes - resources.memoryUsedBytes : null,- hasFolder: a.needs.cwd ? finite(resources.projectDiskFreeBytes) : null }+ const load = loadOf(resources, Array.isArray(listed.agents) ? frames.length : null, a.needs.cwd)// A machine listed only because an agent runs there may never have cloned the project. When its capacity read succeeded but// could not measure the named folder's disk, a missing folder is the likely cause; a failed or unsupported read says nothing.const noFolder = !!a.needs.cwd && machineId !== where.machineId && object(inspected.capacity).ok === true && !finite(resources.projectDiskFreeBytes)diff --git a/cli/src/superTabs/routePlugins.ts b/cli/src/superTabs/routePlugins.tsindex c234ab45c..94d454fa9 100644--- a/cli/src/superTabs/routePlugins.ts+++ b/cli/src/superTabs/routePlugins.ts@@ -7,6 +7,7 @@ import { MEASURED_MAKER } from './routeMeasured.js'import type { ScopedRequest } from './start.js'import { CHEAP_FIRST_MAKERS } from './routeCheapFirst.js'import { windowPullMaker } from './windowPull.js'+import { MACHINE_FIT_MAKER } from './machineFit.js'type Json = Record<string, unknown>@@ -31,6 +32,8 @@ export const ROUTE_PLUGIN_MAKERS: readonly PluginMaker[] = [// Piece 3: measured cost per shipped change and first-review pass rate, per kind of work.MEASURED_MAKER,windowPullMaker(),+ // Piece 5: machine fit for heavy work, and the CI jobs limit.+ MACHINE_FIT_MAKER,]/** As long as the route's other context reads wait (wire.ts within): a maker's read is context too, never worth holding thediff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.tsindex 85ab5ed69..19ff29a03 100644--- a/cli/src/superTabs/start.spec.ts+++ b/cli/src/superTabs/start.spec.ts@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'import { join } from 'node:path'import { existsSync } from 'node:fs'import { homedir } from 'node:os'-import { BUDDY_SESSION_ENGINE, inspectCapacity, MODEL_REPORT_WAIT_MS, startAgent } from './start.js'+import { BUDDY_SESSION_ENGINE, HEAVY_NOT_RECORDED, HEAVY_REFUSED, inspectCapacity, MODEL_REPORT_WAIT_MS, startAgent } from './start.js'import { buildEngineCommandArgv } from '../lib/engineLaunch.js'import { SuperTabHostError } from './wire.js'const teamDaemon = vi.hoisted(() => ({ value: false, relayed: true, offered: null as null | { slugs: string[]; listed: string[] } }))@@ -125,6 +125,57 @@ describe('Swarm permission mode', () => {expect(f.request.mock.calls.some(c => c[0] === 'agent_create')).toBe(false)})+ // Scholes's goals, piece 5: a heavy start says so in its own field, which a server from before it refuses in its body check.+ describe('a start that declares heavy work', () => {+ const submitted = (f: ReturnType<typeof fixture>) => f.scoped.mock.calls.map(c => c[0].command as Record<string, any> | undefined)+ .filter(c => c?.type === 'agent.start').map(c => c!.request as Record<string, unknown>)+ const heavyStart = (f: ReturnType<typeof fixture>, answer: (request: Record<string, any>) => unknown) => {+ const scoped = f.scoped.getMockImplementation()!+ Object.assign(f.start, { poolGeneration: 'pool' })+ f.scoped.mockImplementation(async payload => {+ const command = payload.command as Record<string, any> | undefined+ if (command?.type !== 'agent.start') return scoped(payload)+ return (answer(command.request) ?? scoped(payload)) as Record<string, unknown>+ })+ return startAgent({ action: 'start', tabId: 'tab', operationId: 'op-heavy', request: { ...f.start.request, heavy: ['build'] } }, f.scoped, where, f.open, noPause)+ }+ it('sends the field to a server that takes it, once', async () => {+ const f = fixture()+ const result = await heavyStart(f, () => undefined)+ expect(result).toMatchObject({ ok: true, queued: true, startId: 'start' })+ expect(result).not.toHaveProperty('heavyWarning')+ expect(submitted(f)).toEqual([expect.objectContaining({ heavy: ['build'], permissionMode: 'full' })])+ })+ it('sends the start once more without it when an older server refuses that field, and says routes will not count it', async () => {+ const f = fixture()+ const result = await heavyStart(f, request => request.heavy ? { error: 'VALIDATION_ERROR', detail: HEAVY_REFUSED } : undefined)+ expect(result).toMatchObject({ ok: true, queued: true, startId: 'start', heavyWarning: HEAVY_NOT_RECORDED })+ const sent = submitted(f)+ expect(sent).toHaveLength(2)+ expect(sent[1]).not.toHaveProperty('heavy')+ expect(sent[1]).toEqual({ ...sent[0], heavy: undefined, permissionMode: 'full' } as never)+ expect(new Set(f.scoped.mock.calls.filter(c => (c[0].command as { type?: string } | undefined)?.type === 'agent.start').map(c => c[0].operationId))).toEqual(new Set(['op-heavy']))+ })+ it('never sends it again on a timeout or any other refusal, which may have started an agent', async () => {+ for (const answer of [{ error: 'VALIDATION_ERROR', detail: 'command.request.name: Too big' }, { error: 'VALIDATION_ERROR', detail: 'command.request: Unrecognized key: "other"' },+ { error: 'MACHINE_OFFLINE', detail: 'Wait for a fresh reading from the contributed machine.' }, { error: 'BACKEND_TIMEOUT', detail: 'timeout' }]) {+ const f = fixture()+ await expect(heavyStart(f, () => answer)).rejects.toThrow()+ expect(submitted(f)).toHaveLength(1)+ }+ const f = fixture()+ await expect(heavyStart(f, () => { throw new Error('socket closed') })).rejects.toThrow('socket closed')+ expect(submitted(f)).toHaveLength(1)+ // A start that declares no heavy work is never sent again for that refusal either.+ const plain = fixture(), scoped = plain.scoped.getMockImplementation()!+ Object.assign(plain.start, { poolGeneration: 'pool' })+ plain.scoped.mockImplementation(async payload => (payload.command as { type?: string } | undefined)?.type === 'agent.start'+ ? { error: 'VALIDATION_ERROR', detail: HEAVY_REFUSED } : scoped(payload))+ await expect(startAgent({ action: 'start', tabId: 'tab', operationId: 'op', request: plain.start.request }, plain.scoped, where, plain.open, noPause)).rejects.toThrow()+ expect(submitted(plain)).toHaveLength(1)+ })+ })+it('recovers the same legacy start after its accepted reply is lost', async () => {const f = fixture(), scoped = f.scoped.getMockImplementation()!Object.assign(f.start, { poolGeneration: 'pool' })diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.tsindex 97ce1c38f..061a8fb5d 100644--- a/cli/src/superTabs/start.ts+++ b/cli/src/superTabs/start.ts@@ -175,24 +175,38 @@ async function watchQueued(queued: Json, scoped: ScopedRequest, pause: (ms: numbreturn queued}+/** How a backend from before `heavy` (backend superTabs/commands.ts startRequestSchema) refuses it, word for word. */+export const HEAVY_REFUSED = 'command.request: Unrecognized key: "heavy"'+export const HEAVY_NOT_RECORDED = 'This server cannot record that the start runs heavy work, so routes in the next minutes will not count it on its machine. Update the Harness server.'+async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open: typeof openDaemon): Promise<Json> {let startId = input.startIdlet routed: unknown- let permissionWarning: string | undefined+ let permissionWarning: string | undefined, heavyWarning: string | undefinedif (input.action === 'start') {// The routing decision belongs to the command, not to the machine-side request.const { routeDecisionId, overrideReason, ...request } = object(input.request)routed = routeDecisionIdconst submit = (request: Json) => scoped({ action: 'command', operationId: input.operationId,command: { type: 'agent.start', request, ...(routeDecisionId ? { routeDecisionId } : {}), ...(overrideReason ? { overrideReason } : {}) } })- let reply = await submit({ ...request, permissionMode: 'full' })+ let sent = request+ let reply = await submit({ ...sent, permissionMode: 'full' })+ // A backend from before heavy work was recorded refuses that field in its body check, before it records anything: that+ // refusal alone sends the start again without it. A timeout or any other refusal may have started an agent, so it never+ // does (Lead, 10-31).+ if (reply.error === 'VALIDATION_ERROR' && reply.detail === HEAVY_REFUSED && sent.heavy !== undefined) {+ const { heavy: _heavy, ...plain } = sent+ sent = plain+ heavyWarning = HEAVY_NOT_RECORDED+ reply = await submit({ ...sent, permissionMode: 'full' })+ }// Older backends refused this field before recording a start. A recorded// legacy retry may instead report a hash mismatch after its reply was lost:// replay its exact payload with the same operation ID to recover that receipt.// Other refusals and uncertain replies never authorize another intent.if (reply.error === 'OPERATION_REUSED' || (reply.error === 'OUTSIDE_CONTRIBUTION' && typeof reply.detail === 'string' &&reply.detail.endsWith('Refused: permissionMode (it runs with its own default account settings, so leave it out).'))) {- const { permissionMode: _mode, ...legacyRequest } = request+ const { permissionMode: _mode, ...legacyRequest } = sentif (reply.error === 'OUTSIDE_CONTRIBUTION') {permissionWarning = "This backend cannot request full permissions. Older machine hosts run the agent with the machine's default. Update Harness on the backend and machine."}@@ -214,15 +228,15 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:return { error: 'SWARM_ENGINE', startId, detail }}if (start.harnessId && (!start.poolGeneration || start.poolSettled)) return { ok: true, startId, machineId: request.machineId, harnessId: start.harnessId,- ...(permissionWarning ? { permissionWarning } : {}) }+ ...(permissionWarning ? { permissionWarning } : {}), ...(heavyWarning ? { heavyWarning } : {}) }// Contributed capacity is executed by its owner. A collaborator receives no// machine credentials and cannot issue arbitrary commands to that computer.// Its machine reports it preparing (backend liveness.ts): the backend waits up to 15 minutes, and so should the Lead.if (start.poolGeneration && input.hostDispatch !== true) return start.preparing === true- ? { ok: true, queued: true, preparing: true, startId, machineId: request.machineId, ...(permissionWarning ? { permissionWarning } : {}),+ ? { ok: true, queued: true, preparing: true, startId, machineId: request.machineId, ...(permissionWarning ? { permissionWarning } : {}), ...(heavyWarning ? { heavyWarning } : {}),detail: 'Its machine is still preparing it (fetching the project, checking its worktree out); that can take up to 15 minutes. Resume this start ID to read its receipt; do not start another.' }: { ok: true, queued: true, startId, machineId: request.machineId,- ...(permissionWarning ? { permissionWarning } : {}),+ ...(permissionWarning ? { permissionWarning } : {}), ...(heavyWarning ? { heavyWarning } : {}),detail: 'Queued on the contributed machine. Resume this start ID to read its receipt.' }const target = await open(where, request.machineId)/** What the agent runs now, and its frame, as the frame says; null when the frame cannot say. */@@ -536,6 +550,6 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:engineVersion: text(last.frame.engineVersion)?.slice(0, 160) ?? null } : nullreturn { ok: true, startId, machineId: request.machineId, harnessId: nativeId, ...object(joined.result),...(settledConfiguration ? { configuration: settledConfiguration } : {}),- ...(permissionWarning ? { permissionWarning } : {}), ...(modelWarning ? { modelWarning } : {}) }+ ...(permissionWarning ? { permissionWarning } : {}), ...(heavyWarning ? { heavyWarning } : {}), ...(modelWarning ? { modelWarning } : {}) }} finally { target.close() }}diff --git a/cli/vitest.super-tabs.config.ts b/cli/vitest.super-tabs.config.tsindex b69f82b8b..5ea365918 100644--- a/cli/vitest.super-tabs.config.ts+++ b/cli/vitest.super-tabs.config.ts@@ -8,7 +8,7 @@ import base from './vitest.config.js'const IN_CORE = ['adoption', 'agents', 'attention', 'cards', 'deliveries', 'launch', 'role', 'teamApps', 'teamPurge', 'terminal'].map(name => `src/superTabs/inCore/${name}.ts`)const FILES = ['src/superTabs/route.ts', 'src/superTabs/routeCommand.ts', 'src/superTabs/routePlugins.ts', 'src/superTabs/shortCommand.ts', ...IN_CORE,// The routing plug-ins (routePlugins.ts), one line each.- 'src/superTabs/routeCheapFirst.ts', 'src/superTabs/routeMeasured.ts', 'src/superTabs/windowPull.ts',+ 'src/superTabs/routeCheapFirst.ts', 'src/superTabs/routeMeasured.ts', 'src/superTabs/windowPull.ts', 'src/superTabs/machineFit.ts',]export default defineConfig({test: {