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
No Sonnet in the default table, grid builds only low-risk docs/tests/fixtures, Codex Astra xhigh row (#2314)
0xken15d48e2cba5c9b
diff --git a/backend/src/superTabs/buddyMachines.test.ts b/backend/src/superTabs/buddyMachines.test.tsindex 03ee7e9f1..52fb83fdf 100644--- a/backend/src/superTabs/buddyMachines.test.ts+++ b/backend/src/superTabs/buddyMachines.test.ts@@ -4,6 +4,7 @@import { describe, expect, it } from 'vitest'import { applyCommand, type Command, type CommandContext } from './commands.js'import { createSuperTab, visibleState, type Actor } from './model.js'+import { DEFAULT_ROUTING_POLICY } from './routingPolicy.js'import { servedLocalModels, type ContributedMachine } from './machines.js'import { buddyChatId } from './buddies.js'import { LEAD_CAPABILITY } from './leadStart.js'@@ -25,12 +26,15 @@ const setupOf = { name: 'Peer Laptop', cwd: '/home/peer/harness-swarm', engines:const own = (userId: string) => ({ machineOwnerId: userId, contributorId: userId, hostGrant: null })/** A Swarm of two public projects, each with its Lead on the owner's Swarm machine, and peer, who has added no machine. */+/** The default table, with Claude launched on its own model (these fixtures' agents) at the top tier so they build. */+const FIXTURE_POLICY = { ...DEFAULT_ROUTING_POLICY, models: [...DEFAULT_ROUTING_POLICY.models,+ { engine: 'claude' as const, model: 'default', effort: 'default', quality: 3, cost: 3, enabled: true }] }function setup() {let state = createSuperTab('swarm', 'Team', { id: 'owner', email: owner.email }, 'test')state.people.push({ id: 'peer', email: peer.email, role: 'collaborator', generation: 'first' })let next = 0const run = (command: Command, actor: Actor = owner, context: Partial<CommandContext> = {}) => {- const effects = applyCommand(state, actor, command, { operationId: `op${next++}`, now: 1000,+ const effects = applyCommand(state, actor, command, { operationId: `op${next++}`, now: 1000, routingPolicy: FIXTURE_POLICY,contribution: own(actor.kind === 'person' ? actor.userId : 'owner'), ...context })state = effects.statereturn effectsdiff --git a/backend/src/superTabs/buildRules.test.ts b/backend/src/superTabs/buildRules.test.tsnew file mode 100644index 000000000..ce536177a--- /dev/null+++ b/backend/src/superTabs/buildRules.test.ts@@ -0,0 +1,46 @@+import { describe, expect, it } from 'vitest'+import { DEFAULT_ROUTING_POLICY as policy } from './routingPolicy.js'+import { buildRefusal, cheapKind, gridBuilds, GRID_BUILDS, startTarget } from './rules.js'++// Ken and Dee, 2026-10-30: Builders run on Opus high or Astra xhigh. A build needs a model rated 3, on the server as in the+// CLI's route; a grid model builds only low-risk docs, tests or fixtures; a model a person named builds whatever its rating.+// Review of #2314: an existing Sonnet agent still got builds, low-difficulty fixes went to Haiku, and saved tables keep Sonnet on.+describe('who may build', () => {+ const on = (engine: string, model: string, effort = 'high') => startTarget({ machineId: 'm', engine, model, effort })+ const grid = { ...on('claude', 'default', 'default'), gridModel: 'moonshotai/kimi-k3' }+ const work = (patch: Record<string, unknown> = {}) => ({ risk: 'low', kind: 'docs', ...patch })++ it('takes the top tier: Opus, Astra at xhigh, Sol and Codex on its own model', () => {+ for (const target of [on('claude', 'opus'), on('codex', 'gpt-6-astra', 'xhigh'), on('codex', 'gpt-6.1-sol'), on('codex', 'default', 'default')]) {+ expect(buildRefusal(policy, target, work({ kind: 'fix' }))).toBeNull()+ }+ })++ it('refuses Sonnet, Haiku and a model the policy does not name, Sonnet even with its row turned off', () => {+ expect(policy.models.find(m => m.model === 'sonnet')!.enabled).toBe(false)+ expect(buildRefusal(policy, on('claude', 'sonnet'), work({ kind: 'fix' })))+ .toBe('A build needs a model rated 3, and Claude sonnet is 2. Builders run at the top tier unless a person names the model.')+ expect(buildRefusal(policy, on('claude', 'claude-haiku-5-5'), work({ kind: 'fix' }))).toContain('Claude claude-haiku-5-5 is 1.')+ expect(buildRefusal(policy, on('codex', 'gpt-7-unknown'), undefined)).toContain('Codex gpt-7-unknown is 1.')+ })++ it('lets a model a person named build, whatever its rating', () => {+ expect(buildRefusal(policy, on('claude', 'sonnet'), work({ kind: 'fix', model: 'sonnet' }))).toBeNull()+ })++ it('lets a grid model build only low-risk docs, tests or fixtures, singular or plural, or what a person asked for', () => {+ for (const kind of ['docs', 'doc', 'tests', 'test', 'fixtures', 'fixture']) expect(buildRefusal(policy, grid, work({ kind }))).toBeNull()+ for (const kind of ['fix', 'copy', 'refactor', 'ui', undefined]) expect(buildRefusal(policy, grid, work({ kind }))).toBe(GRID_BUILDS)+ expect(buildRefusal(policy, grid, work({ risk: 'medium' }))).toBe(GRID_BUILDS)+ // With no route decision to read, a grid build is refused.+ expect(buildRefusal(policy, grid, undefined)).toBe(GRID_BUILDS)+ expect(buildRefusal(policy, grid, work({ kind: 'ui', local: true }))).toBeNull()+ expect(buildRefusal(policy, grid, work({ kind: 'ui', model: 'kimi k3' }))).toBeNull()+ })++ it('reads the kinds as the CLI does', () => {+ expect(['docs', 'doc', 'tests', 'test', 'fixtures', 'fixture'].every(cheapKind)).toBe(true)+ expect(['fix', 'copy', 'documentation', 'testing', '', undefined].some(cheapKind)).toBe(false)+ expect(gridBuilds(undefined)).toBe(false)+ })+})diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.tsindex a56cc9453..8934c2b58 100644--- a/backend/src/superTabs/commands.test.ts+++ b/backend/src/superTabs/commands.test.ts@@ -12,11 +12,16 @@ import { DEFAULT_ROUTING_POLICY, effectivePolicy } from './routingPolicy.js'const owner: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'owner', email: '[email protected]' }const peer: Extract<Actor, { kind: 'person' }> = { kind: 'person', userId: 'peer', email: '[email protected]' }const config: AgentConfiguration = { engine: 'codex', model: 'test-model', effort: 'high', contextWindow: 200000, engineVersion: 'fixture' }+/** The default table, with the fixtures' own stand-in models (Codex `test-model`, Claude launched on its own model) rated at+ * the top tier, so a test about something else builds on them (rules.ts buildRefusal). Tests of the floor name real models. */+const FIXTURE_POLICY = { ...DEFAULT_ROUTING_POLICY, models: [...DEFAULT_ROUTING_POLICY.models,+ { engine: 'codex' as const, model: 'test-model', effort: 'high', quality: 3, cost: 2, enabled: true },+ { engine: 'claude' as const, model: 'default', effort: 'default', quality: 3, cost: 3, enabled: true }] }function fixture() {let state = createSuperTab('tab', 'Pilot', { id: 'owner', email: owner.email }, 'prod')let sequence = 0const run = (command: Command, actor: Actor = owner, context: Partial<CommandContext> = {}) => {- const effects = applyCommand(state, actor, command, { now: 1000, operationId: `op-${++sequence}`, ...context })+ const effects = applyCommand(state, actor, command, { now: 1000, operationId: `op-${++sequence}`, routingPolicy: FIXTURE_POLICY, ...context })state = effects.statereturn effects}@@ -638,11 +643,13 @@ describe('tab.routingPolicy', () => {expect(() => commandSchema.parse({ type: 'tab.routingPolicy', policy: { quotaReserve: 99 } })).toThrow()expect(() => f.run({ type: 'tab.routingPolicy', policy: { quotaReserve: 99 } } as never)).toThrow()})- it('refuses a second row for a built-in model', () => {+ it('counts a second row for a built-in model against the 40 (reviews of #2271 and #2314)', () => {const sol = DEFAULT_ROUTING_POLICY.models.find(m => m.model === 'gpt-6.1-sol')!- expect(() => commandSchema.parse({ type: 'tab.routingPolicy', policy: { models: [sol, { ...sol, enabled: false }] } }))- .toThrow('Only one row for codex gpt-6.1-sol.')- expect(commandSchema.parse({ type: 'tab.routingPolicy', policy: { models: [sol] } })).toBeTruthy()+ const own = Array.from({ length: 40 }, (_, i) => ({ engine: 'claude' as const, model: `model-${i}`, effort: 'high', quality: 2, cost: 2, enabled: true }))+ expect(() => commandSchema.parse({ type: 'tab.routingPolicy', policy: { models: [...own, sol, { ...sol, enabled: false }] } }))+ .toThrow('At most 40 rows of your own.')+ expect(commandSchema.parse({ type: 'tab.routingPolicy', policy: { models: [sol, { ...sol, enabled: false }] } })).toBeTruthy()+ expect(commandSchema.parse({ type: 'tab.routingPolicy', policy: { models: [...own, sol] } })).toBeTruthy()})})@@ -685,7 +692,7 @@ const record = (patch: Record<string, unknown> = {}) => ({ assessment: { difficupick: 'c0', via: 'jev', p: 0.82, belowFloor: false, why: 'Highest quality within quota.', ...patch })/** What an agent passes to start or assign: a routing decision of `conversationId`. Its pick differs from the call, so it carries a reason. */const via = { routeDecisionId: 'd1', overrideReason: 'Test.' }-const decisionIn = (conversationId = 'lead') => ({ routeDecision: { id: 'd1', conversationId, record: record(), final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision })+const decisionIn = (conversationId = 'lead', patch: Record<string, unknown> = {}) => ({ routeDecision: { id: 'd1', conversationId, record: record(patch), final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision })/** The base fixture plus a coordinating Lead and a worker, both on one host. */function routed() {const f = fixture()@@ -775,16 +782,17 @@ describe('agent bookkeeping in the chats people read', () => {expect(routing('lead').map(shown)).toEqual([false])expect(routing(group).map(shown)).toEqual([true])// The Lead choosing otherwise than its route, on a start or an assignment.- const request = { conversationId: 'lead', machineId: 'machine', engine: 'claude', model: 'sonnet', effort: 'high', name: 'Builder', cwd: '/repo', worktree: false,+ const request = { conversationId: 'lead', machineId: 'machine', engine: 'claude', model: 'opus', effort: 'xhigh', name: 'Builder', cwd: '/repo', worktree: false,requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }- const started = f.run({ type: 'agent.start', request, routeDecisionId: 'd1', overrideReason: 'Sonnet is enough here.' }, f.leadActor, { routeDecision: open(), contribution: f.contribution })+ const started = f.run({ type: 'agent.start', request, routeDecisionId: 'd1', overrideReason: 'Xhigh is needed here.' }, f.leadActor, { routeDecision: open(), contribution: f.contribution })expect(started.messages.filter(m => m.text.startsWith('Lead started')).map(shown)).toEqual([false])f.define(group)const assigned = f.run({ type: 'work.assign', conversationId: group, agentId: f.worker, routeDecisionId: 'd1', overrideReason: 'It knows the code.' }, f.leadActor,{ routeDecision: open({ conversationId: group }) })expect(assigned.messages.filter(m => m.text.startsWith('Lead assigned')).map(shown)).toEqual([true])// A person's choice is theirs to read wherever it is written.- const decision = { id: 'd2', conversationId: 'lead', record: record(), final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision+ const codex = record({ candidates: [candidate('c0'), candidate('c1', { engine: 'codex', model: 'gpt-6.1-sol', effort: 'high' })] })+ const decision = { id: 'd2', conversationId: 'lead', record: codex, final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecisionexpect(f.run({ type: 'route.override', decisionId: 'd2', candidateId: 'c1', reason: 'Quota.' }, undefined, { routeDecision: decision }).messages.map(shown)).toEqual([true])})@@ -865,7 +873,8 @@ describe('route.record and route.override', () => {})it('lets a writer change an open decision with a reason and tells the lead', () => {const f = routed()- const decision = { id: 'd1', conversationId: 'lead', record: record(), final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision+ const codex = record({ candidates: [candidate('c0'), candidate('c1', { engine: 'codex', model: 'gpt-6.1-sol', effort: 'high' })] })+ const decision = { id: 'd1', conversationId: 'lead', record: codex, final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecisionconst effects = f.run({ type: 'route.override', decisionId: 'd1', candidateId: 'c1', reason: 'Opus quota is needed elsewhere.' }, undefined, { routeDecision: decision })expect(effects.routeDecisions).toEqual([{ op: 'override', id: 'd1', override: expect.objectContaining({ by: 'person', candidateId: 'c1', reason: 'Opus quota is needed elsewhere.' }) }])expect(effects.messages[0]!.recipients).toEqual([f.lead])@@ -966,13 +975,13 @@ describe('decisions linked to work', () => {it('needs a reason when a start differs from the pick, and tells the group about it', () => {const f = routed()- const request = { conversationId: 'lead', machineId: 'machine', engine: 'claude', model: 'sonnet', effort: 'high', name: 'Builder', cwd: '/repo', worktree: false,+ const request = { conversationId: 'lead', machineId: 'machine', engine: 'claude', model: 'opus', effort: 'xhigh', name: 'Builder', cwd: '/repo', worktree: false,requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }const start = (extra: Record<string, unknown> = {}) => f.run({ type: 'agent.start', request, routeDecisionId: 'd1', ...extra } as Command, f.leadActor, { routeDecision: open(), contribution: f.contribution })expect(() => start()).toThrow(expect.objectContaining({ code: 'OVERRIDE_REASON_REQUIRED' }))- const effects = start({ overrideReason: 'Sonnet is enough here.' })- expect(effects.routeDecisions[0]).toMatchObject({ op: 'final', override: { by: 'lead', reason: 'Sonnet is enough here.' } })- expect(effects.messages[0]).toMatchObject({ text: 'Lead started Builder instead of Title c0. Reason: Sonnet is enough here.',+ const effects = start({ overrideReason: 'Xhigh is needed here.' })+ expect(effects.routeDecisions[0]).toMatchObject({ op: 'final', override: { by: 'lead', reason: 'Xhigh is needed here.' } })+ expect(effects.messages[0]).toMatchObject({ text: 'Lead started Builder instead of Title c0. Reason: Xhigh is needed here.',source: { kind: 'route-override', decisionId: 'd1', by: 'lead' } })})@@ -1371,7 +1380,7 @@ describe('Reviewer role', () => {// Never the Builder itself.expect(() => route({ kind: 'member', agentId: builder, machineId: 'host' })).toThrow('A review group is assigned only to a Reviewer.')// A model the policy does not name is rated 1.- expect(() => route({ model: 'default', effort: 'default' })).toThrow('Claude default is 1.')+ expect(() => route({ model: 'mystery', effort: 'default' })).toThrow('Claude mystery is 1.')// A person assigning a grid Reviewer by hand is told.f.state.agents.find(a => a.id === reviewer)!.gridModel = 'qwen3'const byHand = f.run({ type: 'work.assign', conversationId: review, agentId: reviewer })@@ -1408,7 +1417,7 @@ describe('Reviewer role', () => {expect(route({}, { why: 'same-engine review: no Reviewer of another engine has quota. First by the owner\'s rules and the policy order.' }).routeDecisions[0]).toMatchObject({ record: { why: 'First by the owner\'s rules and the policy order.' } })codexBox()- expect(() => route({ model: 'default', effort: 'default' })).toThrow('Claude default is 1.')+ expect(() => route({ model: 'mystery', effort: 'default' })).toThrow('Claude mystery is 1.')expect(() => route({ model: 'default', effort: 'default', gridModel: 'moonshotai/kimi-k3', gridName: 'swarm-g' })).toThrow('never runs on a model served on the Swarm\'s grid')// The Reviewer's brief starts with the brief itself, assigned by hand too.codexBox()@@ -2066,11 +2075,11 @@ describe('the owner\'s rules', () => {expect(startBy(f, f.leadActor).result.startId).toBeTruthy()f.run(set({ kind: 'forbidModel', model: 'OPUS' }, 'No Opus.'))expect(() => startBy(f, f.leadActor)).toThrow('The owner\'s rule "No Opus." rules out Claude opus. Route again.')- expect(startBy(f, f.leadActor, { model: 'sonnet' }).result.startId).toBeTruthy()+ expect(startBy(f, f.leadActor, { model: 'default' }).result.startId).toBeTruthy()f.run(set({ kind: 'minEffort', engine: 'claude', effort: 'high' }, 'High effort.'))expect(() => startBy(f, f.leadActor, { model: 'sonnet', effort: 'medium' })).toThrow('rules out Claude at medium effort')expect(() => startBy(f, f.leadActor, { model: 'sonnet', effort: undefined })).toThrow('rules out Claude at an unnamed effort')- expect(startBy(f, f.leadActor, { model: 'sonnet', effort: 'max' }).result.startId).toBeTruthy()+ expect(startBy(f, f.leadActor, { model: 'default', effort: 'max' }).result.startId).toBeTruthy()f.run(set({ kind: 'machines', machineIds: ['elsewhere'] }, 'Only elsewhere.'))expect(() => startBy(f, f.leadActor, { model: 'sonnet' })).toThrow('The owner\'s rule "Only elsewhere." rules out this machine (it allows only elsewhere).')})@@ -2258,11 +2267,12 @@ describe('the owner\'s rules in a Swarm of projects', () => {it('applies a project\'s rules only to that project\'s groups', () => {// 2026-10-23: one project's rules (three machines, no Haiku, high effort) refused every other project's Lead.const f = projects(), app = projectIdOf(f, f.app)- f.run(forbid(app, 'sonnet')); f.run(forbid(app, 'test-model'))+ f.run(forbid(app, 'gpt-6.1-sol')); f.run(forbid(app, 'test-model'))expect(f.state.rules!.map(r => r.projectId)).toEqual([app, app])- const route = (conversationId: string, actor: Actor) => f.run({ type: 'route.record', conversationId, decision: record({ pick: 'c1' }) } as Command, actor, {})+ const sol = record({ candidates: [candidate('c0'), candidate('c1', { engine: 'codex', model: 'gpt-6.1-sol', effort: 'high' })], pick: 'c1' })+ const route = (conversationId: string, actor: Actor) => f.run({ type: 'route.record', conversationId, decision: sol } as Command, actor, {})expect(route(f.site, f.siteLead).result.routeDecisionId).toBeTruthy()- expect(() => route(f.app, f.lead)).toThrow('The owner\'s rule "No sonnet." rules out Claude sonnet.')+ expect(() => route(f.app, f.lead)).toThrow('The owner\'s rule "No gpt-6.1-sol." rules out Codex gpt-6.1-sol.')const siteWorker = f.add('site-worker', 'owner', f.site)const assign = (conversationId: string, agentId: string) => {f.run({ type: 'work.define', conversationId, brief: 'Build it.', checks: [{ description: 'Tests pass.', independent: false }] })@@ -3211,7 +3221,8 @@ describe('the Local models add-on', () => {const grid = f.run({ type: 'localModels.set', enabled: true }).result.grid as stringserved(f, grid)const local = candidate('c0', { machineId: 'host', model: 'default', effort: 'default', quality: 1, cost: 1, gridModel: 'qwen3-30b', gridName: grid })- const decision = { routeDecision: { id: 'd1', conversationId: 'lead', record: record({ candidates: [local, candidate('c1')], pick: 'c0' }),+ const docs = { difficulty: 'low', risk: 'low', why: 'Fix the docs.', kind: 'docs' }+ const decision = { routeDecision: { id: 'd1', conversationId: 'lead', record: record({ assessment: docs, candidates: [local, candidate('c1')], pick: 'c0' }),final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision }const actor: Actor = { kind: 'agent', agentId: lead, machineOwnerId: 'host-owner' }const effects = f.run({ type: 'agent.start', request: start(grid), routeDecisionId: 'd1' }, actor, { ...grant, ...decision })@@ -3657,6 +3668,84 @@ describe('agent.stopRefused', () => {// Ken, 2026-10-29: simple work runs on a grid model first, and a failed first review or a grid host that never starts the// agent steps it up a tier (Sonnet, then Opus), at most twice per group.+// Ken and Dee, 2026-10-30: Builders run on Opus high or Astra xhigh. Review of #2314: an existing Sonnet agent still got builds,+// low-difficulty fixes went to Haiku, saved tables keep Sonnet on, and older CLIs still send other work to grid models.+describe('a build at the top tier', () => {+ const sonnetWorker = (f: ReturnType<typeof routed>) => {+ Object.assign(f.state.agents.find(a => a.id === f.worker)!, { configuration: { ...config, engine: 'claude', model: 'claude-sonnet-4-5', effort: 'medium' } })+ return f.worker+ }++ it('refuses an agent\'s assignment of an existing Sonnet agent to a build, and lets a person through with a warning', () => {+ const f = routed(), group = f.group()+ f.define(group)+ const worker = sonnetWorker(f)+ expect(() => f.run({ type: 'work.assign', conversationId: group, agentId: worker, ...via }, f.leadActor, decisionIn(group)))+ .toThrow('A build needs a model rated 3, and Claude claude-sonnet-4-5 is 2. Builders run at the top tier unless a person names the model. Route again.')+ const byHand = f.run({ type: 'work.assign', conversationId: group, agentId: worker })+ expect(byHand.result.warnings).toEqual(['A build needs a model rated 3, and Claude claude-sonnet-4-5 is 2. Builders run at the top tier unless a person names the model.'])+ })++ it('lets a Sonnet agent build when the route says a person named it, and keeps that on the decision', () => {+ const f = routed(), group = f.group()+ f.define(group)+ const worker = sonnetWorker(f)+ const named = record({ assessment: { difficulty: 'medium', risk: 'low', why: 'Ken asked for Sonnet.', model: 'sonnet' },+ candidates: [candidate('c0', { kind: 'member', agentId: worker, machineId: 'host', model: 'sonnet', quality: 2 })], pick: 'c0' })+ const routedOnce = f.run({ type: 'route.record', conversationId: group, decision: named } as Command, f.leadActor)+ expect(routedOnce.routeDecisions[0]).toMatchObject({ op: 'create', record: { assessment: { model: 'sonnet' } } })+ const decision = { routeDecision: { id: 'd1', conversationId: group, record: named, final: null, override: null, assignmentId: null, outcome: null } as unknown as RouteDecision }+ expect(f.run({ type: 'work.assign', conversationId: group, agentId: worker, routeDecisionId: 'd1' }, f.leadActor, decision).result.warnings).toBeUndefined()+ })++ it('refuses an agent\'s grid pick for anything but low-risk docs, tests or fixtures, as an older CLI may send it', () => {+ const f = routed(), group = f.group()+ const grid = (assessment: Record<string, unknown>) => f.run({ type: 'route.record', conversationId: group, decision: record({ assessment: { difficulty: 'low', risk: 'low', why: 'Small.', ...assessment },+ candidates: [candidate('c0', { model: 'default', effort: 'default', quality: 2, cost: 1, gridModel: 'moonshotai/kimi-k3', gridName: 'swarm-g' })], pick: 'c0' }) } as Command, f.leadActor)+ expect(() => grid({ kind: 'fix' })).toThrow('A model on the Swarm\'s grid builds only low-risk docs, tests or fixtures')+ expect(() => grid({})).toThrow('builds only low-risk docs, tests or fixtures')+ expect(() => grid({ kind: 'docs', risk: 'medium' })).toThrow('builds only low-risk docs, tests or fixtures')+ expect(grid({ kind: 'test' }).result.routeDecisionId).toBeTruthy()+ expect(grid({ kind: 'ui', local: true }).routeDecisions[0]).toMatchObject({ record: { assessment: { local: true } } })+ })++ it('holds a Reviewer it starts to the review rule, not a Builder\'s', () => {+ const f = routed()+ const request = { conversationId: 'lead', machineId: 'machine', engine: 'claude', model: 'sonnet', effort: 'medium', name: 'Reviewer', role: 'reviewer', cwd: '/repo', worktree: true,+ requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }+ expect(f.run({ type: 'agent.start', request, ...via } as Command, f.leadActor, { contribution: f.contribution, ...decisionIn() }).result.startId).toBeTruthy()+ expect(() => f.run({ type: 'agent.start', request: { ...request, role: undefined, name: 'Builder' }, ...via } as Command, f.leadActor,+ { contribution: f.contribution, ...decisionIn() })).toThrow('A build needs a model rated 3, and Claude sonnet is 2.')+ })+})++// Re-review of #2313: the server keeps no list of a review's past Builders, so only a Reviewer or a person passes its checks.+describe('the checks of a review', () => {+ it('are passed only by a Reviewer or a person, never another agent in the review group', () => {+ const f = routed(), group = f.group()+ f.define(group)+ f.run({ type: 'work.assign', conversationId: group, agentId: f.worker })+ const review = f.run({ type: 'conversation.create', title: 'Review', brief: 'Review it.', reviewOf: group, checks: [{ description: 'Verdict', independent: false }] },+ f.leadActor).result.conversationId as string+ // An earlier Builder of reassigned work, still in the Swarm: a Builder, not the reviewed group's current one.+ const earlier = f.add('earlier')+ const reviewer = f.add('reviewer')+ f.state.agents.find(a => a.id === reviewer)!.role = 'reviewer'+ f.run({ type: 'conversation.agent', conversationId: review, agentId: earlier, present: true, lead: false }, f.leadActor)+ f.run({ type: 'work.assign', conversationId: review, agentId: reviewer })+ const g = () => f.state.conversations.find(c => c.id === review)!+ const check = (actor: Actor, passed = true) => f.run({ type: 'work.check', conversationId: review, assignmentId: g().assignment!.id, checkId: g().checks[0]!.id,+ passed, evidence: 'Looks fine.' } as Command, actor)+ expect(() => check({ kind: 'agent', agentId: earlier, machineOwnerId: 'host-owner' })).toThrow('Only a Reviewer or a person passes a review\'s checks.')+ expect(() => check(f.leadActor)).toThrow('Only a Reviewer or a person passes a review\'s checks.')+ expect(g().checks[0]!.passedBy).toBeNull()+ check({ kind: 'agent', agentId: reviewer, machineOwnerId: 'host-owner' })+ expect(g().checks[0]!.passedBy).toBeTruthy()+ check(owner, false)+ expect(g().checks[0]!.passedBy).toBeNull()+ })+})+describe('stepping up from a cheap model', () => {const pr = 'https://github.com/example/project/pull/41'function cheap() {@@ -3708,7 +3797,9 @@ describe('stepping up from a cheap model', () => {expect(() => route({ model: 'default', effort: 'default', quality: 2, gridModel: 'deepseek/deepseek-v4.1', gridName: 'swarm-g' })).toThrow('This task stepped up from a cheaper model: it runs on no model on the grid and nothing below quality 2. Route again.')expect(() => route({ model: 'haiku', effort: 'auto', quality: 1 })).toThrow('nothing below quality 2')- expect(route({ model: 'sonnet', effort: 'medium', quality: 2 }).routeDecisions[0]).toMatchObject({ op: 'create', record: { stepUp: { attempt: 2, reason: 'Its first review said Ready no.' } } })+ // A build runs at the top tier (Ken and Dee, 2026-10-30), stepped up or not; a person may still assign Sonnet by hand.+ expect(() => route({ model: 'sonnet', effort: 'medium', quality: 2 })).toThrow('A build needs a model rated 3, and Claude sonnet is 2.')+ expect(route({ model: 'opus', effort: 'high', quality: 3 }).routeDecisions[0]).toMatchObject({ op: 'create', record: { stepUp: { attempt: 2, reason: 'Its first review said Ready no.' } } })const sonnet = builder('sonnet', 'claude-sonnet-4-5')const second = assign(sonnet)expect(second.brief).toContain(`Carry-over from attempt 1:\n${g().stepUp!.carry}`)@@ -3795,8 +3886,10 @@ describe('an engine that cannot run on a contributed machine', () => {const fail = (startId: string) => f.run({ type: 'agent.startFailed', startId, error: 'Codex could not launch.' }, owner).messages[0]!const request = (extra: Record<string, unknown> = {}) => ({ conversationId: 'lead', machineId: 'mac', engine: 'codex', name: 'Builder', cwd: '/repo',worktree: true, requirements: { memoryBytes: 1, diskBytes: 1, maxCpuPercent: 100, tools: ['git'], devices: [], quotaRequired: false }, ...extra })+ // A grid start is routed as docs work, which a grid model may build (rules.ts buildRefusal).const begin = (extra: Record<string, unknown> = {}) => f.run({ type: 'agent.start', request: request(extra), ...via } as Command, leadActor,- { contribution: { machineOwnerId: 'owner', contributorId: 'owner' }, ...decisionIn('lead') })+ { contribution: { machineOwnerId: 'owner', contributorId: 'owner' },+ ...decisionIn('lead', extra.gridModel ? { assessment: { difficulty: 'low', risk: 'low', why: 'Docs.', kind: 'docs' } } : {}) })return { f, lead, fail, begin, start }}diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex 5f874d560..b908d87cf 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -11,7 +11,7 @@ import {import { jobKindOf } from './evidence/jobKind.js'import { routeRecordSchema, routeTitle, startedAs, type RouteCandidate, type RouteDecision, type RouteFinal, type RouteOverride } from './routeRecord.js'import { DEFAULT_ROUTING_POLICY, routingOverrideSaveSchema, type RoutingPolicy } from './routingPolicy.js'-import { agentQuality, agentTarget, askedInSchema, broken, MAX_RULES, reviewRefusal, RULE_MESSAGE_MS, ruleSchema, ruleTextSchema, startTarget, unmet, type RunTarget } from './rules.js'+import { agentQuality, agentTarget, askedInSchema, broken, buildRefusal, MAX_RULES, reviewRefusal, RULE_MESSAGE_MS, ruleSchema, ruleTextSchema, startTarget, unmet, type RunTarget } from './rules.js'import { MAX_ATTACHMENTS, type Attachment } from './attachments.js'import { checkMentions, MAX_MENTIONS, namedIn, saysName, textTags, withTags, type MentionTarget } from './mentions.js'import { answerDecision, askDecisions, checkAsker, decisionChoices, decisionQuestion, MAX_OPEN_DECISIONS, MAX_QUESTIONS, type DecisionTarget } from './decisions.js'@@ -707,6 +707,9 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaconst mayRun = (conversationId: string, requirement: boolean) => (target: RunTarget, contributorId: string) =>!broken(groupRules(conversationId), target, machineName, macOf) && (!requirement || !unmet(conversation(state, conversationId).task?.requires, target, macOf))&& !teamWorkCheck(state, target.machineId, contributorId, groupProject(state, conversation(state, conversationId)), context.now, context.teamMachines, context.otherWorkspaceMachines)+ /** What the route decision this command carries or names says of [conversationId]'s work (rules.ts RoutedWork). */+ const routedWork = (conversationId: string) => command.type === 'route.record' && command.conversationId === conversationId ? command.decision.assessment+ : context.routeDecision?.conversationId === conversationId ? context.routeDecision.record.assessment : undefined/** [builds]: the target would do the group's work, so a step up's floor holds too (stepUp.ts). [reviews]: it would review* the group's work, so the review rule holds (rules.ts reviewRefusal); merely joining a review group is not reviewing. */const refusal = (target: RunTarget, conversationId: string, builds = true, reviews = true): { code: string; why: string } | null => {@@ -717,7 +720,10 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaconst review = reviews ? reviewRefusal(state, conversation(state, conversationId).reviewOf, target, policy) : nullif (review) return { code: 'REVIEW_REFUSED', why: review }const stepped = builds ? stepUpRefusal(conversation(state, conversationId), target, policy) : null- return stepped ? { code: 'STEPPED_UP', why: stepped } : null+ if (stepped) return { code: 'STEPPED_UP', why: stepped }+ // A build at the top tier, or on the grid only for the work it may take (rules.ts buildRefusal).+ const build = builds && !conversation(state, conversationId).reviewOf ? buildRefusal(policy, target, routedWork(conversationId)) : null+ return build ? { code: 'BUILD_REFUSED', why: build } : null}const ruled = (target: RunTarget, conversationId: string, done: string, personChose = false, builds = true, reviews = true) => {const refused = refusal(target, conversationId, builds, reviews)@@ -1551,7 +1557,8 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commabookkeeping(r.conversationId, { kind: 'route-override', decisionId: decision.id, by: 'lead' }))personChose = !override && decision.override?.by === 'person'}- ruled(startTarget(request), request.conversationId, `${who} started ${request.name}`, personChose)+ // A Reviewer started is held to the review rule where it reviews, not to a Builder's (rules.ts buildRefusal).+ ruled(startTarget(request), request.conversationId, `${who} started ${request.name}`, personChose, request.role !== 'reviewer')break}case 'buddy.propose': {@@ -1677,7 +1684,7 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commafail('SWARM_ENGINE', 'A Swarm agent runs only Claude Code or Codex.', 400)}// A start recorded before a rule was added is not launched past it, unless a person asked for it by hand.- const why = actor.kind === 'agent' && !(start.routeDecisionId && context.routeDecision?.override?.by === 'person') && refusal(startTarget(start.request), start.request.conversationId)+ const why = actor.kind === 'agent' && !(start.routeDecisionId && context.routeDecision?.override?.by === 'person') && refusal(startTarget(start.request), start.request.conversationId, start.request.role !== 'reviewer')if (why) fail(why.code, `${why.why} This start was not launched. Route again.`, 403)requireWorkerDecisions(state, actor, open(state, start.request.conversationId))const grant = context.contribution ?? fail('HOST_REQUIRED', 'The original machine grant is unavailable.', 403)@@ -2361,6 +2368,11 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaif (group.reviewOf && actor.kind === 'agent' && actor.agentId === state.conversations.find(c => c.id === group.reviewOf)?.assignment?.agentId) {fail('INDEPENDENT_REVIEW', 'The Builder of the reviewed work does not give its review\'s verdict.')}+ // A review's checks are its Reviewer's or a person's: the server keeps no list of the reviewed work's past Builders, so any+ // other agent in the review group, an earlier Builder of reassigned work among them, is refused (re-review of #2313).+ if (group.reviewOf && actor.kind === 'agent' && agentRole(agent(state, actor.agentId)) !== 'reviewer') {+ fail('INDEPENDENT_REVIEW', 'Only a Reviewer or a person passes a review\'s checks.')+ }check.evidence = command.evidencecheck.passedBy = command.passed ? actorKey(actor) : nullconst run = group.ledger?.runs?.find(r => r.assignmentId === group.assignment!.id), reviewed = run?.firstReviewdiff --git a/backend/src/superTabs/costs/cost.test.ts b/backend/src/superTabs/costs/cost.test.tsindex c848ae05f..8e39319bd 100644--- a/backend/src/superTabs/costs/cost.test.ts+++ b/backend/src/superTabs/costs/cost.test.ts@@ -34,6 +34,11 @@ describe('an attempt’s cost', () => {expect(cost).toMatchObject({ spend: 0, priced: 'list' })})+ it('prices GPT-6-Astra at OpenAI\'s list rate, five times Sol\'s', () => {+ // 1M input $10, 1M output $50, 1M cache reads $1, 1M cache writes $12.50 (30-minute rate).+ expect(attemptCost(run({ billing: 'api', end: { 'gpt-6-astra': tokens(1e6, 1e6, 1e6, 1e6) } }), true)).toEqual({ apiCost: 73.5, spend: 73.5, priced: 'list' })+ })+it('is money spent when the attempt paid per token', () => {expect(attemptCost(run({ billing: 'api', end: { 'gpt-6.1-sol': tokens(1e6, 1e6, 1e6) } }), true)).toEqual({ apiCost: 12.1, spend: 12.1, priced: 'list' })})diff --git a/backend/src/superTabs/costs/prices.ts b/backend/src/superTabs/costs/prices.tsindex 4e94a958c..8c4be01e3 100644--- a/backend/src/superTabs/costs/prices.ts+++ b/backend/src/superTabs/costs/prices.ts@@ -5,7 +5,8 @@** - Cache writes are the 5-minute rate: transcripts do not say which cache a write went to, so 1-hour writes count low.* - Claude Haiku 5.5 is left out on purpose: its rate doubles past 100,000 prompt tokens, which the counts cannot tell.- * - gpt-6.1-sol is its rate up to 272K input tokens; longer prompts cost more.+ * - gpt-6.1-sol and gpt-6-astra are their rates up to 272K input tokens; longer prompts cost more. Their cache writes are the+ * 30-minute rate.* - Grid models are priced at OpenRouter's rates, which is how the Swarm reaches them (Lead, 2026-10-29). DeepSeek's* off-peak hours are half this rate, so its cost is an upper bound.*/@@ -29,6 +30,7 @@ export const PRICES: readonly ModelPrice[] = [{ model: 'claude-opus-5-5', input: 4, output: 20, cacheRead: 0.2, cacheWrite: 5, source: ANTHROPIC, checked: '2026-10-29' },{ model: 'claude-sonnet-5-5', input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5, source: ANTHROPIC, checked: '2026-10-29' },{ model: 'gpt-6.1-sol', input: 2, output: 10, cacheRead: 0.1, cacheWrite: 2.5, source: OPENAI, checked: '2026-10-29' },+ { model: 'gpt-6-astra', input: 10, output: 50, cacheRead: 1, cacheWrite: 12.5, source: OPENAI, checked: '2026-10-30' },{ model: 'moonshotai/kimi-k3', input: 0.192, output: 20, cacheRead: 0.182, cacheWrite: 0, source: OPENROUTER, checked: '2026-10-29' },{ model: 'deepseek/deepseek-v4.1-flash-1017', input: 0.3, output: 1.2, cacheRead: 0.006, cacheWrite: 0, source: OPENROUTER, checked: '2026-10-29' },]diff --git a/backend/src/superTabs/routeRecord.ts b/backend/src/superTabs/routeRecord.tsindex 2bb811416..66ddf6a55 100644--- a/backend/src/superTabs/routeRecord.ts+++ b/backend/src/superTabs/routeRecord.ts@@ -41,7 +41,10 @@ export const routeRecordSchema = z.object({assessment: z.object({ difficulty: level, risk: level, why: z.string().trim().min(1).max(300),size: z.enum(['small', 'medium', 'large']).optional(),/** The job's kind the Lead gave (`ui`, `docs`; `review` for a review), what attempts are compared by (costs/read.ts). */- kind: z.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional() }).strict(),+ kind: z.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),+ /** A person asked for a local model, or named one (cli superTabs/route.ts Assessment): what lets a grid model, or a model+ * rated below 3, build (rules.ts buildRefusal). */+ local: z.literal(true).optional(), model: z.string().trim().min(1).max(200).optional() }).strict(),candidates: z.array(routeCandidateSchema).min(1).max(12),excluded: z.array(z.object({ title: z.string().trim().min(1).max(160), reason: z.string().trim().min(1).max(500) }).strict()).max(200),floor: z.number().int().min(1).max(3),diff --git a/backend/src/superTabs/routingPolicy.test.ts b/backend/src/superTabs/routingPolicy.test.tsindex 3fbf0d2a6..c602899e6 100644--- a/backend/src/superTabs/routingPolicy.test.ts+++ b/backend/src/superTabs/routingPolicy.test.ts@@ -1,6 +1,7 @@import { describe, expect, it } from 'vitest'import { DEFAULT_ROUTING_POLICY, effectivePolicy, gridQuality, priorFor, routingOverrideSaveSchema, routingOverrideSchema, routingPolicySaveSchema, routingPolicySchema } from './routingPolicy.js'import type { PriorsTable } from './benchmarkPriors/priors.js'+import { startTarget, targetQuality } from './rules.js'describe('routing policy', () => {it('ships a valid default that needs no setup', () => {@@ -15,6 +16,24 @@ describe('routing policy', () => {expect(DEFAULT_ROUTING_POLICY.models).toContainEqual({ engine: 'claude', model: 'opus', effort: 'xhigh', quality: 3, cost: 4, enabled: true })})+ // Ken, 2026-10-30: no Sonnet Builders. Only the default table changes; an owner's own table is theirs (Lead's ruling).+ it('turns Sonnet off in the default table, and keeps an owner\'s saved Sonnet row and a tab override\'s as they are', () => {+ const sonnet = (models: Array<{ engine: string; model: string; enabled: boolean }>) => models.filter(m => m.engine === 'claude' && m.model === 'sonnet')+ expect(sonnet(DEFAULT_ROUTING_POLICY.models)).toEqual([expect.objectContaining({ effort: 'medium', quality: 2, enabled: false })])+ // Haiku too (review of #2314): an older CLI on the new server picked it for easy work the server refuses, on every route.+ expect(DEFAULT_ROUTING_POLICY.models.filter(m => m.model === 'haiku')).toEqual([expect.objectContaining({ quality: 1, enabled: false })])+ // What an older CLI's route can still pick from the default table builds: every row it may pick is rated 3.+ expect(DEFAULT_ROUTING_POLICY.models.filter(m => m.enabled).every(m => m.quality === 3)).toBe(true)+ expect(sonnet(effectivePolicy(null, null).policy.models).map(m => m.enabled)).toEqual([false])+ // An owner who saved the table before keeps Sonnet on; it is their row.+ const saved = { ...DEFAULT_ROUTING_POLICY, models: DEFAULT_ROUTING_POLICY.models.map(m => m.model === 'sonnet' ? { ...m, enabled: true } : m) }+ const read = effectivePolicy(saved, null)+ expect(read.warnings).toEqual([])+ expect(sonnet(read.policy.models).map(m => m.enabled)).toEqual([true])+ expect(read.policy.models.filter(m => m.model !== 'sonnet')).toEqual(saved.models.filter(m => m.model !== 'sonnet'))+ // A tab override's own models win over the default too.+ expect(sonnet(effectivePolicy(null, { models: saved.models }).policy.models).map(m => m.enabled)).toEqual([true])+ })it('uses the default when the account has none, and merges a tab override field by field', () => {expect(effectivePolicy(null, null)).toEqual({ policy: DEFAULT_ROUTING_POLICY, warnings: [], overridden: [] })const account = { ...DEFAULT_ROUTING_POLICY, quotaReserve: 20, notes: 'Frontend prefers Claude.' }@@ -29,7 +48,7 @@ describe('routing policy', () => {// Review of #2271: rows added on read must not push an owner's full policy past what saving accepts.const owner = Array.from({ length: 40 }, (_, i) => ({ engine: 'claude' as const, model: `model-${i}`, effort: 'high', quality: 2, cost: 2, enabled: true }))const read = effectivePolicy({ ...DEFAULT_ROUTING_POLICY, models: owner }, null).policy- expect(read.models).toHaveLength(41)+ expect(read.models).toHaveLength(42)expect(read.models.slice(0, 40)).toEqual(owner)const saved = routingPolicySchema.parse({ ...read, notes: 'Edited.' })expect(saved.models).toEqual(read.models)@@ -46,6 +65,35 @@ describe('routing policy', () => {// The owner's own version of a built-in row takes its place, not one of their 40.expect(parses([...own(40), { ...sol, enabled: false }])).toBe(true)expect(parses([...own(41), sol])).toBe(false)+ // Both built-in rows ride free of the 40, Astra's as Sol's.+ const astra = DEFAULT_ROUTING_POLICY.models.find(m => m.model === 'gpt-6-astra')!+ expect(parses([...own(40), sol, astra])).toBe(true)+ expect(parses([...own(40), sol, { ...astra, quality: 2 }])).toBe(true)+ expect(routingPolicySaveSchema.safeParse({ ...DEFAULT_ROUTING_POLICY, models: [...own(40), sol, astra] }).success).toBe(true)+ expect(routingPolicySaveSchema.safeParse({ ...DEFAULT_ROUTING_POLICY, models: [...own(40), sol, astra, astra] }).success).toBe(false)+ })++ // Lead's ruling, 10-30: the owners' standing decision is that Builders run on Opus high or Astra xhigh; with no row Astra rated+ // 1 and was never picked.+ it('ships Codex GPT-6-Astra at xhigh as a strong built-in row, dearer than Opus, and keeps an owner\'s own Astra row', () => {+ const astra = DEFAULT_ROUTING_POLICY.models.find(m => m.model === 'gpt-6-astra')!+ expect(astra).toEqual({ engine: 'codex', model: 'gpt-6-astra', effort: 'xhigh', quality: 3, cost: 5, enabled: true })+ const opusCosts = DEFAULT_ROUTING_POLICY.models.filter(m => m.model === 'opus').map(m => m.cost)+ expect(astra.cost).toBeGreaterThan(Math.max(...opusCosts))+ // A policy saved before the row reads it.+ const before = { ...DEFAULT_ROUTING_POLICY, models: DEFAULT_ROUTING_POLICY.models.filter(m => m.model !== 'gpt-6-astra') }+ expect(effectivePolicy(before, null).policy.models.filter(m => m.model === 'gpt-6-astra')).toEqual([astra])+ // An owner's own Astra row wins over the built-in one, on or off, and is never doubled (review of #2271).+ const owned = { ...before, models: [...before.models, { ...astra, effort: 'high', quality: 2, cost: 9, enabled: false }] }+ expect(effectivePolicy(owned, null).policy.models.filter(m => m.model === 'gpt-6-astra')).toEqual([{ ...astra, effort: 'high', quality: 2, cost: 9, enabled: false }])+ })++ it('rates a start or agent on Astra at the top tier on the server, as the CLI\'s route does (cli route.ts rateFor)', () => {+ const on = (effort: string) => targetQuality(DEFAULT_ROUTING_POLICY, startTarget({ machineId: 'm', engine: 'codex', model: 'gpt-6-astra', effort }))+ expect(on('xhigh')).toBe(3)+ expect(on('high')).toBe(3)+ const before = { ...DEFAULT_ROUTING_POLICY, models: DEFAULT_ROUTING_POLICY.models.filter(m => m.model !== 'gpt-6-astra') }+ expect(targetQuality(before, startTarget({ machineId: 'm', engine: 'codex', model: 'gpt-6-astra', effort: 'xhigh' }))).toBe(1)})describe('a built-in row added on read (review of #2271 at 1d9499646)', () => {@@ -78,17 +126,23 @@ describe('routing policy', () => {})})- it('refuses saving a second row for a built-in model, and still reads an old policy saved with one', () => {- const own = Array.from({ length: 39 }, (_, i) => ({ engine: 'claude' as const, model: `model-${i}`, effort: 'high', quality: 2, cost: 2, enabled: true }))+ it('counts a second row for a built-in model against the 40 when saving, and still reads an old policy saved with one', () => {+ // Review of #2271: a second copy never rides free. Review of #2314: an owner with two Astra rows (two efforts, from before+ // Astra was built in) must still save.+ const own = (n: number) => Array.from({ length: n }, (_, i) => ({ engine: 'claude' as const, model: `model-${i}`, effort: 'high', quality: 2, cost: 2, enabled: true }))const sol = DEFAULT_ROUTING_POLICY.models.find(m => m.model === 'gpt-6.1-sol')!- const twice = { ...DEFAULT_ROUTING_POLICY, models: [...own, sol, { ...sol, enabled: false }] }+ const astra = DEFAULT_ROUTING_POLICY.models.find(m => m.model === 'gpt-6-astra')!+ const saves = (models: unknown[]) => routingPolicySaveSchema.safeParse({ ...DEFAULT_ROUTING_POLICY, models }).success+ expect(saves([...own(10), sol, astra, { ...astra, effort: 'high', quality: 2 }])).toBe(true)+ expect(saves([...own(39), sol, astra, { ...astra, effort: 'high' }])).toBe(true)+ const twice = { ...DEFAULT_ROUTING_POLICY, models: [...own(40), sol, { ...sol, enabled: false }] }const refused = routingPolicySaveSchema.safeParse(twice)expect(refused.success).toBe(false)- expect(refused.error?.issues.map(i => i.message)).toEqual(['Only one row for codex gpt-6.1-sol.'])+ expect(refused.error?.issues.map(i => i.message)).toEqual(['At most 40 rows of your own.'])expect(routingOverrideSaveSchema.safeParse({ models: twice.models }).success).toBe(false)- expect(routingPolicySaveSchema.safeParse({ ...twice, models: [...own, sol] }).success).toBe(true)- // Saved before this check: still read as saved, never as unreadable.- expect(effectivePolicy(twice, null)).toEqual({ policy: twice, warnings: [], overridden: [] })+ expect(saves([...own(40), sol, astra])).toBe(true)+ // Saved before this count: still read as saved, never as unreadable; the Astra row joins it, off with Codex off.+ expect(effectivePolicy(twice, null)).toEqual({ policy: { ...twice, models: [...twice.models, { ...astra, enabled: false }] }, warnings: [], overridden: [] })})it('falls back to the default with a warning for a corrupt account policy or override', () => {diff --git a/backend/src/superTabs/routingPolicy.ts b/backend/src/superTabs/routingPolicy.tsindex c18dc34fc..0cbf44dca 100644--- a/backend/src/superTabs/routingPolicy.ts+++ b/backend/src/superTabs/routingPolicy.ts@@ -7,9 +7,13 @@ import { JOB_KINDS, priorLevel, type JobKind, type PriorsTable } from './benchma/** Built-in rows added after owners could save a policy, so saved policies read them too (effectivePolicy). Codex's own default* model, named: GPT-6.1 Sol scores 58.18 on Terminal-Bench 4.0 in Codex (benchmarkPriors/data.ts) and costs Sonnet's API rate- * (costs/prices.ts). A start or Reviewer that names it is rated by this row, not as an unknown slug (Lead, 10-30). */+ * (costs/prices.ts). A start or Reviewer that names it is rated by this row, not as an unknown slug (Lead, 10-30).+ * GPT-6-Astra at xhigh: the owners' standing decision is that Builders run on Opus high or Astra xhigh, which without a row+ * rated it 1, so routing never picked it (Lead's ruling, 10-30). Its API rate is five times Sol's and 2.5 times Opus's+ * (costs/prices.ts), so it costs 5, after Opus at xhigh (4): at equal strength routing keeps choosing Opus high first. */const ADDED_ROWS = [{ engine: 'codex', model: 'gpt-6.1-sol', effort: 'high', quality: 3, cost: 2, enabled: true },+ { engine: 'codex', model: 'gpt-6-astra', effort: 'xhigh', quality: 3, cost: 5, enabled: true },] as const satisfies ReadonlyArray<Record<string, unknown>>/** An owner keeps exactly up to 40 rows of their own. A built-in row added on read, or the owner's own version of one (the same* engine and model), never counts against that, or a full policy could no longer be saved once read (reviews of #2271). */@@ -45,12 +49,12 @@ const fields = {}export const routingPolicySchema = z.object({ version: z.literal(1), ...fields }).strict()export const routingOverrideSchema = z.object(fields).partial().strict()-/** What a save accepts: also one row at most per built-in model, so a second copy never rides free of the 40 (review of #2271).- * Only saves check it: a policy saved before it still reads as saved, never as unreadable. */-const saved = { ...fields, models: models.superRefine((rows, ctx) => {- for (const added of ADDED_ROWS) if (rows.filter(row => same(row, added)).length > 1)- ctx.addIssue({ code: 'custom', message: `Only one row for ${added.engine} ${added.model}.` })-}) }+/** What a save accepts: the first row for each built-in model rides free, and every further copy counts against the 40, so a+ * second copy never rides free (review of #2271), yet an owner with two rows of a model that became built-in, such as+ * Astra at two efforts, still saves (review of #2314). Only saves count them: a policy saved before still reads as saved. */+const extraCopies = (rows: ReadonlyArray<Named>) => ADDED_ROWS.reduce((n, added) => n + Math.max(0, rows.filter(row => same(row, added)).length - 1), 0)+const saved = { ...fields, models: models.refine(rows => rows.filter(row => !builtIn(row)).length + extraCopies(rows) <= OWN_MODEL_ROWS,+ `At most ${OWN_MODEL_ROWS} rows of your own.`) }export const routingPolicySaveSchema = z.object({ version: z.literal(1), ...saved }).strict()export const routingOverrideSaveSchema = z.object(saved).partial().strict()export type RoutingPolicy = z.infer<typeof routingPolicySchema>@@ -67,8 +71,12 @@ export const DEFAULT_ROUTING_POLICY: RoutingPolicy = {{ engine: 'codex', model: 'default', effort: 'default', quality: 3, cost: 2, enabled: true },// Next to `default` so the form lists Codex's rows together. List order ranks nothing: the CLI route breaks ties by title....ADDED_ROWS,- { engine: 'claude', model: 'sonnet', effort: 'medium', quality: 2, cost: 2, enabled: true },- { engine: 'claude', model: 'haiku', effort: 'auto', quality: 1, cost: 1, enabled: true },+ // Off since 2026-10-30 (Ken: no Sonnet Builders). Kept as a row so an owner can turn it back on; an owner's saved table keeps+ // its own Sonnet row as it is, and a forbidModel rule rules Sonnet out there.+ { engine: 'claude', model: 'sonnet', effort: 'medium', quality: 2, cost: 2, enabled: false },+ // Off since 2026-10-30 too (review of #2314): a build needs 3, and an older CLI on the new server picked Haiku for easy work+ // that the server then refused, again on every route. With it off, an older CLI picks a model rated 3.+ { engine: 'claude', model: 'haiku', effort: 'auto', quality: 1, cost: 1, enabled: false },],floor: { low: 1, medium: 2, high: 3 },quotaReserve: 10,diff --git a/backend/src/superTabs/rules.ts b/backend/src/superTabs/rules.tsindex c9aabb3c9..4dbddf223 100644--- a/backend/src/superTabs/rules.ts+++ b/backend/src/superTabs/rules.ts@@ -130,6 +130,27 @@ export const targetQuality = (policy: RoutingPolicy, t: RunTarget) => policyQualexport const agentQuality = (state: SuperTabState, policy: RoutingPolicy, worker: Agent): number =>worker.gridModel ? gridQuality(policy, worker.gridModel, state.starts?.find(s => s.harnessId === worker.harnessId && s.request.machineId === worker.machineId)?.request.gridName ?? ''): targetQuality(policy, agentTarget(state, worker))+/** What a route decision says of the work it routed (routeRecord.ts assessment): enough to tell a build a grid model may take. */+export interface RoutedWork { risk: string; kind?: string; local?: true; model?: string }+/** The kinds of build a model on the Swarm's grid takes at low risk (Ken, 2026-10-30), singular or plural (review of #2314):+ * docs, tests and fixtures. The CLI's route reads the same (cli superTabs/route.ts cheapKind). */+export const cheapKind = (kind: string | undefined) => ['doc', 'test', 'fixture'].includes((kind ?? '').replace(/s$/, ''))+/** Whether a grid model may build [work]: low-risk docs, tests or fixtures, or a person asked for a local model or named one. */+export const gridBuilds = (work: RoutedWork | undefined) => !!work && (!!work.local || !!work.model || (work.risk === 'low' && cheapKind(work.kind)))+/** Why [target] may not build: Builders run at the top tier (Ken and Dee, 2026-10-30: Opus high or Astra xhigh), so a model+ * the policy rates below 3, Sonnet and Haiku among them, builds only when a person named it; a grid model only what+ * [gridBuilds] allows (review of #2314: an older CLI still sent other work to the grid). [work] is the linked route+ * decision's; with none, a grid model is refused and a named model is not known. The CLI's route judges the same (cli+ * superTabs/route.ts buildRefusals). */+export function buildRefusal(policy: RoutingPolicy, target: RunTarget, work: RoutedWork | undefined): string | null {+ if (target.gridModel) return gridBuilds(work) ? null : GRID_BUILDS+ if (work?.model) return null+ const quality = targetQuality(policy, target)+ return quality >= 3 ? null : `A build needs a model rated 3, and ${ENGINE[target.engine] ?? target.engine} ${target.model ?? 'default'} is ${quality}. `+ + 'Builders run at the top tier unless a person names the model.'+}+export const GRID_BUILDS = 'A model on the Swarm\'s grid builds only low-risk docs, tests or fixtures, unless a person asks for a local model or names one.'+/** Whether a new Reviewer may run [target] for [contributorId]'s machine: its owner's rules, the task's machine and team* access, as the command judges them (reviewCapacity.ts). */export type MayRun = (target: RunTarget, contributorId: string) => booleandiff --git a/backend/src/superTabs/stepUp.ts b/backend/src/superTabs/stepUp.tsindex 1d1a7373e..1698eee03 100644--- a/backend/src/superTabs/stepUp.ts+++ b/backend/src/superTabs/stepUp.ts@@ -1,13 +1,15 @@/** Cheap first, step up on failure (Ken, 2026-10-29). Simple work runs on a model served on the Swarm's grid first (cli* superTabs/route.ts softOf); when that attempt's first review says Ready no, or its grid host never starts its agent, the- * group steps up a tier: no grid and quality 2 (Sonnet), then quality 3 (Opus), at most twice. The server records the step,+ * group steps up a tier: no grid and quality 2, then quality 3, at most twice. Since 2026-10-30 a build needs quality 3 anyway+ * (rules.ts buildRefusal), so the first step takes the top tier too. The server records the step,* closes the failed attempt and wakes the Lead; the Lead's route and start run the next attempt, since only its machine can* probe the others (autoReview.ts, the same ruling for Reviewers). */import { activeWork, finishWorker, type Conversation, type SuperTabState } from './model.js'import { policyQuality, targetQuality, type RunTarget } from './rules.js'import type { RoutingPolicy } from './routingPolicy.js'-/** Grid, then Sonnet, then Opus; after that it is the Lead's decision (Lead, 2026-10-29). */+/** Grid, then a stronger model, then the top tier; after that it is the Lead's decision (Lead, 2026-10-29). Builds run at the+ * top tier since 2026-10-30, so in practice grid, then the top tier. */export const MAX_STEP_UPS = 2/** What of the failed attempt a brief keeps: conversation.create takes briefs up to 8,000 characters. */const CARRY_CHARS = 2000diff --git a/cli/src/superTabs/route.spec.ts b/cli/src/superTabs/route.spec.tsindex 02bc0d4c6..76f513782 100644--- a/cli/src/superTabs/route.spec.ts+++ b/cli/src/superTabs/route.spec.ts@@ -1,6 +1,6 @@// cli/src/superTabs/route.spec.tsimport { describe, expect, it } from 'vitest'-import { API_BUILDERS, LOCAL_NONE, breaks, choose, gridQuality, reviewRefusals, decide, floorFor, parseAssessment, quotaOf2, rateFor, recordOf, repoMatch, repositoryKey, type Assessment, type Commitment, type MemberFrame, type Policy, type Probe, type SwarmRule, type TaskFolder } from './route.js'+import { API_BUILDERS, buildRefusals, cheapKind, GRID_BUILDS, LOCAL_NONE, breaks, choose, gridQuality, reviewRefusals, decide, floorFor, parseAssessment, quotaOf2, rateFor, recordOf, repoMatch, repositoryKey, type Assessment, type Commitment, type MemberFrame, type Policy, type Probe, type SwarmRule, type TaskFolder } from './route.js'const object = (v: unknown) => v as Record<string, unknown>@@ -65,6 +65,15 @@ describe('quota and rates', () => {expect(rateFor(policy, 'codex', 'default', 'default')).toEqual({ quality: 3, cost: 2 })expect(rateFor(policy, 'claude', 'claude-opus-4-7', 'high', true)).toEqual({ quality: 3, cost: 3 })})+ // Lead's ruling, 10-30: Builders run on Opus high or Astra xhigh; the server's table now names Astra (backend+ // superTabs/routingPolicy.ts ADDED_ROWS), and the route rates it by that row as the server does (rules.ts policyQuality).+ it('rates Codex GPT-6-Astra by the server\'s Astra row, at xhigh or any other effort, and 1 from a server without it', () => {+ const astra = { engine: 'codex' as const, model: 'gpt-6-astra', effort: 'xhigh', quality: 3, cost: 5, enabled: true }+ const served = { ...policy, models: [...policy.models, astra] }+ expect(rateFor(served, 'codex', 'gpt-6-astra', 'xhigh')).toEqual({ quality: 3, cost: 5 })+ expect(rateFor(served, 'codex', 'gpt-6-astra', 'high')).toEqual({ quality: 3, cost: 5 })+ expect(rateFor(policy, 'codex', 'gpt-6-astra', 'xhigh')).toEqual({ quality: 1, cost: 1 })+ })it('rates a Codex model by its own row in the server\'s policy, and an unnamed slug 1', () => {const served = { ...policy, models: [...policy.models, { engine: 'codex' as const, model: 'gpt-6.1-sol', effort: 'high', quality: 3, cost: 2, enabled: true }] }expect(rateFor(served, 'codex', 'gpt-6.1-sol', 'xhigh')).toEqual({ quality: 3, cost: 2 })@@ -564,20 +573,20 @@ describe('local models on the Swarm\'s grid', () => {expect(parseAssessment({ difficulty: 'low', risk: 'low', why: 'x', local: 'yes' })).toContain('local')})it('fits a local model on no subscription, names it as local and records where it is served', () => {- const r = ok(choose([local()], policy, a({ difficulty: 'low' }), NOW))+ const r = ok(choose([local()], policy, a({ difficulty: 'low', kind: 'docs' }), NOW))expect(r.shown[0]).toMatchObject({ title: 'New agent · Claude on Qwen 3 (local) · remote-1', fit: { status: 'fits', account: 'local:swarm-0123456789ab:qwen3' } })expect(r.shown[0]!.label).toContain('Claude on Qwen 3 (local)')expect((recordOf(r, decide(r), a(), policy) as { candidates: unknown[] }).candidates[0]).toMatchObject({ gridModel: 'qwen3', gridName: 'swarm-0123456789ab' })// Without a name or a label: the model stands for both, and nothing about the grid is recorded without a grid.- const bare = ok(choose([local({ gridName: undefined, gridLabel: undefined })], policy, a({ difficulty: 'low' }), NOW))+ const bare = ok(choose([local({ gridName: undefined, gridLabel: undefined })], policy, a({ difficulty: 'low', kind: 'docs' }), NOW))expect(bare.shown[0]).toMatchObject({ title: 'New agent · Claude on qwen3 (local) · remote-1', fit: { account: 'local::qwen3' } })expect((recordOf(bare, decide(bare), a(), policy) as { candidates: unknown[] }).candidates[0]).not.toHaveProperty('gridModel')})it('keeps a local model under the floor of a harder task, and keeps it beside a subscription row of the same name', () => {- const r = ok(choose([probe(), local()], policy, a(), NOW))+ const r = ok(choose([probe(), local()], policy, a({ kind: 'docs' }), NOW))expect(r.shown.map(s => s.gridModel)).toEqual([undefined])// Same machine, engine, model and effort as a subscription `default` row: both stay, being different models.- const both = ok(choose([probe({ model: 'default', effort: 'default', quality: 1, cost: 1, quota: windows([80, 3 * H], [90, 5 * D]) }), local()], policy, a({ difficulty: 'low' }), NOW))+ const both = ok(choose([probe({ model: 'default', effort: 'default', quality: 1, cost: 1, quota: windows([80, 3 * H], [90, 5 * D]) }), local()], policy, a({ difficulty: 'low', kind: 'docs' }), NOW))expect(both.shown).toHaveLength(2)})it('considers only local models when a person asked for one, whatever the floor, and says when none is served', () => {@@ -597,7 +606,7 @@ describe('local models on the Swarm\'s grid', () => {expect(r.belowFloor).toBe(false)// A subscription model by name, and the engine's name counts as one of its words.expect(ok(choose([opus, api], policy, a({ model: 'Claude Opus' }), NOW)).shown.map(s => s.model)).toEqual(['opus'])- expect(ok(choose([older], policy, a({ difficulty: 'low' }), NOW)).shown[0]!.title).toContain('(shared)')+ expect(ok(choose([older], policy, a({ difficulty: 'low', kind: 'docs' }), NOW)).shown[0]!.title).toContain('(shared)')expect(choose([opus], policy, a({ model: 'gpt 9' }), NOW)).toEqual({ error: 'NO_CANDIDATE',excluded: [{ title: 'Named model', reason: 'No candidate runs "gpt 9". Share it with the Swarm (Your models), or check its name.' }] })expect(parseAssessment({ difficulty: 'low', risk: 'low', why: 'x', model: ' deepseek 4.1 flash ' })).toMatchObject({ model: 'deepseek 4.1 flash' })@@ -632,20 +641,20 @@ describe('local models on the Swarm\'s grid', () => {})describe('first for simple work (roadmap, Dec: about 30% of work on cheaper models)', () => {- const simple = a({ difficulty: 'low', risk: 'low', size: 'small' })+ const simple = a({ difficulty: 'low', risk: 'low', size: 'small', kind: 'docs' })// Opus on an account whose 5-hour window resets in 20 minutes costs nothing in effect, so it ranked above a free model.const expiring = probe({ machineName: 'mac', model: 'opus', effort: 'high', quality: 3, cost: 3, quota: windows([60, 20 * M], [60, 2 * D]) })const haiku = probe({ machineName: 'mac', model: 'haiku', effort: 'auto', quality: 1, cost: 1, quota: windows([90, 4 * H], [80, 5 * D]) })const idle = probe({ kind: 'member', agentId: 'a1', name: 'Idle', model: 'sonnet', quota: windows([90, 4 * H], [80, 5 * D]) })const grid = local({ machineName: 'mac' })const firstOf = (r: ReturnType<typeof choose>) => ok(r).shown[0]!.gridModel ?? ok(r).shown[0]!.model- it('ranks a model on the Swarm\'s grid first for low-difficulty, low-risk work', () => {+ it('ranks a model on the Swarm\'s grid first for low-difficulty, low-risk docs', () => {expect(firstOf(choose([expiring, haiku, grid], policy, simple, NOW))).toBe('qwen3')expect(firstOf(choose([idle, grid], policy, simple, NOW, [], [{ rule: { kind: 'preferIdle' }, text: 'Idle first.' }]))).toBe('qwen3')})- it('ranks a strong grid model first for medium docs, copy, tests, fixtures, a specified fix or a mechanical refactor (Ken, 2026-10-29)', () => {+ it('ranks a strong grid model first for medium docs, tests and fixtures (Ken, 2026-10-30)', () => {const kimi = local({ machineName: 'mac', quality: 2, gridModel: 'moonshotai/kimi-k3', gridLabel: 'Kimi K3' })- for (const kind of ['docs', 'copy', 'tests', 'fixtures', 'fix', 'refactor']) {+ for (const kind of ['docs', 'tests', 'fixtures']) {expect(firstOf(choose([expiring, kimi], policy, { ...simple, difficulty: 'medium', kind }, NOW))).toBe('moonshotai/kimi-k3')}// A small model stays under the medium floor, and other kinds keep the policy order.@@ -654,6 +663,35 @@ describe('local models on the Swarm\'s grid', () => {expect(firstOf(choose([expiring, kimi], policy, { ...simple, difficulty: 'medium', kind: 'docs', risk: 'medium' }, NOW))).toBe('opus')expect(firstOf(choose([expiring, kimi], policy, { ...simple, difficulty: 'high', kind: 'docs' }, NOW))).toBe('opus')})+ // Ken, 2026-10-30: cheaper shared models only for low-risk docs, tests and fixtures; they had also built copy, fixes,+ // refactors and any low-difficulty work. Ken and Dee, the same day: a build needs a model rated 3.+ it('builds only on the top tier, a grid model on low-risk docs, tests or fixtures, or what a person asked for', () => {+ const kimi = local({ machineName: 'mac', quality: 2, gridModel: 'moonshotai/kimi-k3', gridLabel: 'Kimi K3' })+ for (const kind of ['docs', 'doc', 'tests', 'test', 'fixtures', 'fixture']) expect(buildRefusals(kimi, { ...simple, kind })).toEqual([])+ for (const assessment of [{ ...simple, kind: undefined }, ...['copy', 'fix', 'refactor', 'ui'].map(kind => ({ ...simple, kind })),+ { ...simple, difficulty: 'medium' as const, kind: 'fix' }, { ...simple, risk: 'medium' as const }]) {+ expect(buildRefusals(kimi, assessment)).toEqual([GRID_BUILDS])+ }+ expect(buildRefusals(kimi, { ...simple, kind: 'ui', local: true })).toEqual([])+ expect(buildRefusals(kimi, { ...simple, kind: 'ui', model: 'kimi k3' })).toEqual([])+ // Sonnet, Haiku and an unnamed model build nothing unless a person named them; the top tier builds anything.+ expect(buildRefusals(idle, { ...simple, kind: 'fix' })).toEqual(['A build needs a model rated 3, and Claude sonnet is 2. Builders run at the top tier unless a person names the model.'])+ expect(buildRefusals(haiku, simple)).toEqual(['A build needs a model rated 3, and Claude haiku is 1. Builders run at the top tier unless a person names the model.'])+ expect(buildRefusals(idle, { ...simple, model: 'sonnet' })).toEqual([])+ expect(buildRefusals(expiring, { ...simple, kind: 'ui', risk: 'high' })).toEqual([])+ // A review is judged apart (reviewRefusals).+ expect(buildRefusals(kimi, { ...simple, kind: 'review' })).toEqual([])+ expect(['documentation', 'testing', ''].some(cheapKind)).toBe(false)+ })+ it('ranks a grid model first for singular kinds too', () => {+ const kimi = local({ machineName: 'mac', quality: 2, gridModel: 'moonshotai/kimi-k3', gridLabel: 'Kimi K3' })+ expect(firstOf(choose([expiring, kimi], policy, { ...simple, difficulty: 'medium', kind: 'test' }, NOW))).toBe('moonshotai/kimi-k3')+ })+ it('says a model a person names is off in the routing table, rather than to share it', () => {+ const off = { ...policy, models: policy.models.map(m => m.model === 'sonnet' ? { ...m, enabled: false } : m) }+ expect(choose([], off, { ...simple, model: 'sonnet' }, NOW)).toEqual({ error: 'NO_CANDIDATE',+ excluded: [{ title: 'Named model', reason: 'The routing table turns Claude sonnet off. Turn its row on to use it.' }] })+ })it('keeps the policy order for anything harder, riskier or a review', () => {expect(firstOf(choose([expiring, haiku, grid], policy, { ...simple, risk: 'medium' }, NOW))).toBe('opus')expect(firstOf(choose([expiring, haiku, grid], policy, { ...simple, difficulty: 'medium' }, NOW))).toBe('opus')diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.tsindex 4dedcd7d1..743225512 100644--- a/cli/src/superTabs/route.ts+++ b/cli/src/superTabs/route.ts@@ -123,18 +123,32 @@ export function liftEffort(rules: SwarmRule[], engine: string, effort: string):/** The soft rules for this task: the engine preferred for its kind (a rule for the kind before one for every task),* whether idle agents come first, and whether a model on the Swarm's grid comes first. */interface Soft { engine: string | null; idle: boolean; grid: boolean }-/** Kinds of build a quality-2 grid model takes first at medium difficulty: docs, copy, tests, fixtures, a small specified fix,- * a mechanical refactor. */-export const CHEAP_KINDS = ['docs', 'copy', 'tests', 'fixtures', 'fix', 'refactor']+/** The only kinds of build a model on the Swarm's grid takes, and then only at low risk (Ken, 2026-10-30; it had taken docs,+ * copy, tests, fixtures, fixes and refactors since 10-29, and any low-difficulty work before). A failed first review still+ * steps it up (backend superTabs/stepUp.ts). */+export const CHEAP_KINDS = ['docs', 'tests', 'fixtures']+/** Whether [kind] is one of [CHEAP_KINDS], singular or plural (review of #2314; backend superTabs/rules.ts cheapKind). */+export const cheapKind = (kind: string | undefined) => ['doc', 'test', 'fixture'].includes((kind ?? '').replace(/s$/, ''))+/** Why [p] may not build the task [a] (Ken and Dee, 2026-10-30: Builders run on Opus high or Astra xhigh): a model rated+ * below 3, Sonnet and Haiku among them, unless a person named it; a model on the Swarm's grid on anything but low-risk docs,+ * tests or fixtures, unless a person asked for a local model or named one. Reviews are judged apart ([reviewRefusals]). The+ * server judges the same (backend superTabs/rules.ts buildRefusal). */+export function buildRefusals(p: Probe, a: Assessment): string[] {+ if (a.kind === 'review') return []+ if (p.gridModel) return gridBuilds(a) ? [] : [GRID_BUILDS]+ return a.model || p.quality >= 3 ? [] : [`A build needs a model rated 3, and ${ENGINE[p.engine]} ${p.model} is ${p.quality}. Builders run at the top tier unless a person names the model.`]+}+/** Whether a model on the Swarm's grid may build [a] ([buildRefusals]). */+export const gridBuilds = (a: Assessment) => !!a.local || !!a.model || (a.risk === 'low' && cheapKind(a.kind))+export const GRID_BUILDS = 'A model on the Swarm\'s grid builds only low-risk docs, tests or fixtures, unless a person asks for a local model or names one.'function softOf(rules: SwarmRule[], a: Assessment): Soft {const prefer = rules.flatMap(({ rule }) => rule.kind === 'preferEngine' ? [rule] : [])const engine = (prefer.find(r => a.kind && r.taskKind === a.kind) ?? prefer.find(r => r.taskKind === null))?.engine ?? null- // Simple work goes to the free models first (roadmap, Dec: about 30% of work on cheaper models without lower quality).+ // The work a grid model may build goes to it first (roadmap, Dec: about 30% of work on cheaper models without lower quality).// A grid model counts as cost 1 like Haiku, so an expiring 5-hour window or an idle member ranked above it and it was- // rarely picked. Reviews keep the other model family, and the owner can opt out.- // Since 2026-10-29 (Ken) also medium work of a kind a strong grid model does well, which steps up when it fails (backend- // superTabs/stepUp.ts); the floor still keeps a small model off it.- const simple = a.difficulty === 'low' || (a.difficulty === 'medium' && CHEAP_KINDS.includes(a.kind ?? ''))+ // rarely picked. Reviews never run on one, and the owner can opt out. It steps up when it fails (backend+ // superTabs/stepUp.ts); the floor still keeps a small model off medium work.+ const simple = (a.difficulty === 'low' || a.difficulty === 'medium') && cheapKind(a.kind)const grid = simple && a.risk === 'low' && a.kind !== 'review' && !rules.some(r => r.rule.kind === 'noGridFirst')return { engine, idle: rules.some(r => r.rule.kind === 'preferIdle'), grid }}@@ -265,6 +279,8 @@ function runsNamed(p: Probe, named: string): boolean {return words(named).every(w => name.includes(w))}const NAMED_NONE = (named: string) => `No candidate runs "${named}". Share it with the Swarm (Your models), or check its name.`+const NAMED_OFF = (row: { engine: string; model: string }) =>+ `The routing table turns ${ENGINE[row.engine as keyof typeof ENGINE] ?? row.engine} ${row.model} off. Turn its row on to use it.`/** How many Builders may run on one API model a member shares: the share answers four requests at once* (cli/src/lib/swarmApiShares.ts CONCURRENCY), unlike a local engine, which answers one conversation at a time. */@@ -435,7 +451,11 @@ export function choose(probes: Probe[], policy: Policy, a: Assessment, now: numbconst heldNamed = named ? held.filter(m => words(named).every(w => words(`${m.model} ${m.label}`).join('').includes(w))) : []if (named && !probes.length) {if (heldNamed.length) excluded.push(...heldNamed.map(m => ({ title: 'Named model', reason: heldReason(m) })))- else excluded.push({ title: 'Named model', reason: NAMED_NONE(named) })+ // A model the routing table turns off is not one to share (review of #2314: Sonnet, off since 2026-10-30).+ else {+ const off = policy.models.find(m => !m.enabled && runsNamed({ engine: m.engine, model: m.model } as Probe, named))+ excluded.push({ title: 'Named model', reason: off ? NAMED_OFF(off) : NAMED_NONE(named) })+ }} else if (a.local && !probes.length) {if (held.length) excluded.push(...held.map(m => ({ title: 'Local models', reason: heldReason(m) })))else excluded.push({ title: 'Local models', reason: LOCAL_NONE })@@ -476,7 +496,9 @@ export type RecordShape = 'current' | 'unkinded' | 'v1'export function recordOf(choice: Choice, verdict: Verdict, a: Assessment, policy: Policy, shape: RecordShape = 'current'): Record<string, unknown> {const v1 = shape === 'v1'return {- assessment: { difficulty: a.difficulty, risk: a.risk, why: a.why, ...(v1 ? {} : { size: a.size }), ...(shape === 'current' && a.kind ? { kind: a.kind } : {}) },+ // A person's local or named model goes with it, so the server lets that model build (backend superTabs/rules.ts buildRefusal).+ assessment: { difficulty: a.difficulty, risk: a.risk, why: a.why, ...(v1 ? {} : { size: a.size }), ...(shape === 'current' && a.kind ? { kind: a.kind } : {}),+ ...(shape === 'current' && a.local ? { local: true } : {}), ...(shape === 'current' && a.model ? { model: a.model } : {}) },candidates: choice.shown.map(s => ({ id: s.id, kind: s.kind, ...(s.agentId ? { agentId: s.agentId } : {}), machineId: s.machineId,engine: s.engine, model: s.model, effort: s.effort, quality: s.quality, cost: s.cost, title: s.title, label: s.label, ...(v1 ? {} : { fit: s.fit }),...(s.gridModel && s.gridName ? { gridModel: s.gridModel, gridName: s.gridName } : {}) })),diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.tsindex 1100f6dbe..bcf7322f5 100644--- a/cli/src/superTabs/routeCommand.spec.ts+++ b/cli/src/superTabs/routeCommand.spec.ts@@ -8,11 +8,15 @@ import type { describeScmProject } from '../scm/scmProjects.js'import { admission, quotaOf, RELAYED_QUOTA } from './capacity.js'import type { Assessment, Policy, Probe } from './route.js'+// Sonnet rated 3, as an owner who wants Sonnet Builders rates it (a build needs 3: route.ts buildRefusals), so the member these+// specs probe can build; the specs of the floor itself use a table of their own ([floorPolicy]).const policy = { version: 1, floor: { low: 1, medium: 2, high: 3 }, quotaReserve: 10, notes: '', models: [{ engine: 'claude', model: 'opus', effort: 'high', quality: 3, cost: 3, enabled: true },- { engine: 'claude', model: 'sonnet', effort: 'medium', quality: 2, cost: 2, enabled: true },+ { engine: 'claude', model: 'sonnet', effort: 'medium', quality: 3, cost: 2, enabled: true },{ engine: 'codex', model: 'default', effort: 'default', quality: 3, cost: 2, enabled: false },] }+/** The table with Sonnet at its real rating, 2, for the specs of strength and floors. */+const floorPolicy = { ...policy, models: policy.models.map(m => m.model === 'sonnet' ? { ...m, quality: 2 } : m) }const agents = [{ id: 'a1', name: 'Multiply', machineId: 'm1', harnessId: 'h1', configuration: { engine: 'claude', model: 'sonnet', effort: 'medium' } },{ id: 'lead', name: 'Lead', machineId: 'm1', harnessId: 'hl', configuration: { engine: 'claude', model: 'opus', effort: 'high' } },@@ -47,9 +51,9 @@ async function withBlocked(os: string, body: () => Promise<void>) {blocked.push(os)try { await body() } finally { blocked.splice(blocked.indexOf(os), 1) }}-function scoped(answers: { record?: Answer; tab?: unknown; context?: Answer; history?: Answer; historyHangs?: boolean; recordThrows?: boolean } = {}) {+function scoped(answers: { record?: Answer; tab?: unknown; context?: Answer; history?: Answer; historyHangs?: boolean; recordThrows?: boolean; policy?: typeof policy } = {}) {return vi.fn(async (payload: Record<string, any>): Promise<Record<string, unknown>> => {- if (payload.action === 'routeContext') return answers.context ?? { ok: true, value: { agentId: 'lead', tab: answers.tab ?? tab(), policy: { policy, warnings: ['w'] }, machines: [{ machineId: 'm1', name: 'remote-1' }, { machineId: 'm2', name: 'mac' }] } }+ if (payload.action === 'routeContext') return answers.context ?? { ok: true, value: { agentId: 'lead', tab: answers.tab ?? tab(), policy: { policy: answers.policy ?? policy, warnings: ['w'] }, machines: [{ machineId: 'm1', name: 'remote-1' }, { machineId: 'm2', name: 'mac' }] } }if (payload.action === 'routeHistory') return answers.historyHangs ? new Promise(() => {}) : answers.history ?? { ok: true, value: { decisions: [], attempts: [] } }if (payload.action === 'command') {if (answers.recordThrows) throw new Error('socket closed')@@ -256,7 +260,7 @@ describe('routeTask', () => {assignment: { id: 'b', agentId: 'gone', status: 'review', configuration: { engine: 'claude', model: 'opus', effort: 'high' } } } as never)Object.assign(t.state.conversations[1]!, { reviewOf: 'g0' })// Codex is on in the policy and signed in with quota, so a Codex Reviewer could start too.- const both = { ...policy, models: policy.models.map(m => ({ ...m, enabled: true })) }+ const both = { ...floorPolicy, models: floorPolicy.models.map(m => ({ ...m, enabled: true })) }const context = { ok: true, value: { agentId: 'lead', tab: t, policy: { policy: both, warnings: [] }, machines: [{ machineId: 'm1', name: 'remote-1' }] } }const s = scoped({ context })const result = await routeTask(input, s, where as never, opener(id => daemon(id, { agents: id === 'm1' ? ['h1'] : [],@@ -273,13 +277,13 @@ describe('routeTask', () => {assignment: { id: 'b', agentId: 'gone', status: 'review', configuration: { engine: 'codex' } } } as never)Object.assign(t.state.conversations[1]!, { reviewOf: 'g0' })// The idle Sonnet Reviewer is cheaper, but the Builder ran Codex's top tier.- const s = scoped({ tab: t })+ const s = scoped({ tab: t, policy: floorPolicy })expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', engine: 'claude', model: 'opus' } })expect(recorded(s).command.decision).toMatchObject({ floor: 3, belowFloor: false })// A Builder on a grid model of quality 2: the Sonnet Reviewer will do.t.state.agents.push({ id: 'b1', name: 'Kimi', machineId: 'm1', harnessId: 'hb', configuration: { engine: 'codex', model: 'default', effort: 'default' }, gridModel: 'moonshotai/kimi-k3' } as never)Object.assign(t.state.conversations[2]!, { assignment: { id: 'b', agentId: 'b1', status: 'review' } })- expect(await routeTask(input, scoped({ tab: t }), where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'member', agentId: 'a1' } })+ expect(await routeTask(input, scoped({ tab: t, policy: floorPolicy }), where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'member', agentId: 'a1' } })})it('rates a Builder launched on its engine\'s own model by that engine\'s default row, whatever slug it reports (review of #2274)', async () => {const t = tab(); t.state.agents = agents.map(a => a.id === 'a1' ? { ...a, role: 'reviewer' } : a)@@ -289,7 +293,7 @@ describe('routeTask', () => {t.state.conversations.push({ id: 'g0', title: 'Built', leadId: 'lead', agentIds: ['lead'], archived: false, brief: '', checks: [],assignment: { id: 'b', agentId: 'b2', status: 'review' } } as never)Object.assign(t.state.conversations[1]!, { reviewOf: 'g0' })- const s = scoped({ tab: t })+ const s = scoped({ tab: t, policy: floorPolicy })expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', engine: 'claude', model: 'opus' } })expect(recorded(s).command.decision).toMatchObject({ floor: 3, belowFloor: false })})@@ -302,7 +306,7 @@ describe('routeTask', () => {observation: { receivedAt: Date.now(), resources: { memoryTotalBytes: 32e9, memoryUsedBytes: 2e9, projectDiskFreeBytes: 200e9 }, tools: { git: true }, runningHarnessIds: [],quotas: engines.map(engine => ({ engine, known: true, windows: [{ name: '5-hour', usedPercent: 20, resetsAt: Date.now() + 3600000 },{ name: 'weekly', usedPercent: engine === 'codex' ? weekly.usedPercent : 10, resetsAt: Date.now() + (engine === 'codex' ? weekly.resetsIn : 5 * DAY) }] })) } })- const both = { ...policy, models: policy.models.map(m => ({ ...m, enabled: true })) }+ const both = { ...floorPolicy, models: floorPolicy.models.map(m => ({ ...m, enabled: true })) }const routeWith = async (codexBox: Record<string, unknown>, rules: unknown[] = []) => {const t = tab(); t.state.agents = [agents[1]] as nevert.state.conversations.push({ id: 'g0', title: 'Built', leadId: 'lead', agentIds: ['lead'], archived: false, brief: '', checks: [],@@ -333,12 +337,23 @@ describe('routeTask', () => {expect((await routeWith(pool('m2', ['codex']), prefer('codex'))).result).toMatchObject({ ok: true, pick: { engine: 'codex', machineId: 'm2' } })})})+ // Ken and Dee, 2026-10-30: Builders run on Opus high or Astra xhigh. Review of #2314: an idle Sonnet member still got builds.+ it('passes over an idle Sonnet member for a build, says why, and tells the server when a person named the model', async () => {+ const s = scoped({ policy: floorPolicy })+ expect(await routeTask(input, s, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', model: 'opus' } })+ expect(recorded(s).command.decision.excluded).toEqual(expect.arrayContaining([{ title: 'Multiply · Claude sonnet medium · remote-1',+ reason: 'A build needs a model rated 3, and Claude sonnet is 2. Builders run at the top tier unless a person names the model.' }]))+ const named = scoped({ policy: floorPolicy })+ expect(await routeTask({ ...input, assessment: { ...input.assessment, model: 'sonnet' } }, named, where as never, opener(), () => 'op'))+ .toMatchObject({ ok: true, pick: { kind: 'member', agentId: 'a1' } })+ expect(recorded(named).command.decision.assessment).toMatchObject({ model: 'sonnet' })+ })it('tells the Lead how to assign a member or start a new agent with the decision', async () => {const member = await routeTask(input, scoped(), where as never, opener(), () => 'op')// Cheapest first: the member on sonnet.expect(member).toMatchObject({ pick: { kind: 'member', agentId: 'a1' } })expect(member.next).toContain('"type":"work.assign","conversationId":"g1","agentId":"a1","routeDecisionId":"d1"')- const fresh = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high' } }, scoped(), where as never, opener(), () => 'op')+ const fresh = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high' } }, scoped({ policy: floorPolicy }), where as never, opener(), () => 'op')expect(fresh).toMatchObject({ pick: { kind: 'new', engine: 'claude', model: 'opus', effort: 'high' } })expect(fresh.next).toContain('"engine":"claude","model":"opus","effort":"high","routeDecisionId":"d1"')// Without a branch the agent starts from the default one, and the hint says how to choose another.@@ -351,7 +366,7 @@ describe('routeTask', () => {machineId: 'm2', engine: 'claude', model: 'opus', effort: 'high', routeDecisionId: 'd1' })// The task's own repository, when the assessment named one, and no decision when none was recorded.const placed = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high', needs: { cwd: '/repo/api' } } },- scoped({ record: { error: 'BACKEND_UNAVAILABLE' } }), where as never, opener(), () => 'op')+ scoped({ record: { error: 'BACKEND_UNAVAILABLE' }, policy: floorPolicy }), where as never, opener(), () => 'op')expect(JSON.parse(/start OPERATION_ID (\{.*\}), then/.exec(placed.next as string)![1]!)).toMatchObject({ cwd: '/repo/api' })expect(placed.next).not.toContain('routeDecisionId')})@@ -376,7 +391,7 @@ describe('routeTask', () => {: request(type, payload, ms))return d})- const result = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high' } }, scoped(), where as never, make, () => 'op')+ const result = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high' } }, scoped({ policy: floorPolicy }), where as never, make, () => 'op')expect(result).toMatchObject({ ok: true, pick: { kind: 'new' } })})it('warns when the account\'s machines could not be read, and still offers the Lead\'s own machine', async () => {@@ -500,8 +515,10 @@ describe('routeTask', () => {})it('names a member that has no name, model or effort of its own, and leaves the decision blank when it is unrecorded', async () => {const plain = tab(); plain.state.agents = [{ id: 'a1', machineId: 'm1', harnessId: 'h1', configuration: { engine: 'claude' } }, agents[1]] as never- const options = { tab: plain, record: { error: 'BACKEND_UNAVAILABLE' } }- const easy = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low' } }, scoped(options), where as never, opener())+ // A member launched on Claude's own model builds where the table rates that model 3; with no row it is rated 1 and does not.+ const options = { tab: plain, record: { error: 'BACKEND_UNAVAILABLE' }, policy: floorPolicy }+ const rated = { ...options, policy: { ...floorPolicy, models: [...floorPolicy.models, { engine: 'claude', model: 'default', effort: 'default', quality: 3, cost: 1, enabled: true }] } }+ const easy = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low' } }, scoped(rated), where as never, opener())expect(easy).toMatchObject({ unrecorded: true, pick: { kind: 'member', title: 'Member · Claude default default · remote-1' } })expect(easy.next).not.toContain('routeDecisionId')const hard = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'high' } }, scoped(options), where as never, opener())@@ -575,13 +592,17 @@ describe('routeTask', () => {// Codex hand was launched on the engine's own model, which it reports by its slug; Mini hand was launched on a model the// policy does not name (review of #2137).Object.assign(working.state, { starts: [{ harnessId: 'h4', request: { model: 'default' } }, { harnessId: 'h5', request: { model: 'gpt-5.5-mini' } }] })- const s = scoped({ tab: working })+ const s = scoped({ tab: working, policy: floorPolicy })const open = opener(id => daemon(id, { agents: id === 'm1' ? ['h1', 'h3', 'h4', 'h5'] : [], usage: { providers: [] }, engines: [{ engine: 'claude', installed: true, signedIn: true }, { engine: 'codex', installed: true, signedIn: true }] }))// Low work, so a model rated 1 is shown too.await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low' } }, s, where as never, open)const rated = Object.fromEntries((recorded(s).command.decision.candidates as Array<{ title: string; quality: number; cost: number }>).filter(c => /hand/.test(c.title)).map(c => [c.title.split(' · ')[0], [c.quality, c.cost]]))- expect(rated).toEqual({ 'Opus hand': [3, 3], 'Sonnet hand': [2, 2], 'Codex hand': [3, 2], 'Mini hand': [1, 1] })+ expect(rated).toEqual({ 'Opus hand': [3, 3], 'Codex hand': [3, 2] })+ // Below the top tier they build nothing, and say how they are rated (a build needs 3: route.ts buildRefusals).+ const below = Object.fromEntries((recorded(s).command.decision.excluded as Array<{ title: string; reason: string }>)+ .filter(e => /hand/.test(e.title)).map(e => [e.title.split(' · ')[0], / is (\d)\. /.exec(e.reason)?.[1]]))+ expect(below).toEqual({ 'Sonnet hand': '2', 'Mini hand': '1' })})it('counts the quota open picks hold on the same account, and tells the Lead when nobody is expected to cover the task', async () => {const pick = { conversationId: 'g1', title: 'Pick', outcome: null, assignmentId: 'as1', createdAt: new Date().toISOString(), final: { kind: 'new', engine: 'claude', model: 'opus' } }@@ -941,14 +962,14 @@ describe('routing contributed capacity', () => {observation: { receivedAt: Date.now(), resources: { memoryTotalBytes: 32e9, memoryUsedBytes: 2e9, projectDiskFreeBytes: 200e9 },tools: { git: true }, runningHarnessIds: ['h1'], quotas: [{ engine: 'claude', known: true, windows: [{ name: '5-hour', usedPercent: 20, resetsAt: Date.now() + 3600000 }] }] } })async function runPool(pool: Record<string, any>, members = false, needs: Record<string, unknown> = {}, project?: Record<string, unknown>,- more: { state?: Record<string, unknown>; tab?: Record<string, unknown>; review?: boolean } = {}) {+ more: { state?: Record<string, unknown>; tab?: Record<string, unknown>; review?: boolean; kind?: string } = {}) {const groups = conversations()if (project) Object.assign(groups[1]!, { projectId: project.id })if (more.review) Object.assign(groups[1]!, { reviewOf: 'g0' })const crew = members ? agents.map(a => more.review && a.id === 'a1' ? { ...a, role: 'reviewer' } : a) : [agents[1]]const s = scoped({ context: { ok: true, value: { agentId: 'lead', tab: { ...more.tab, state: { id: 'tab', agents: crew, conversations: groups, machines: [pool], ...(project ? { projects: [project] } : {}), ...more.state } }, policy: { policy, warnings: [] }, machines: [] } } })const open = opener()- const answer = await routeTask({ ...input, assessment: { ...input.assessment, needs } }, s, where, open)+ const answer = await routeTask({ ...input, assessment: { ...input.assessment, needs, ...(more.kind ? { kind: more.kind } : {}) } }, s, where, open)expect(open).not.toHaveBeenCalled()return { answer, s }}@@ -1093,7 +1114,7 @@ describe('routing contributed capacity', () => {it('still offers a local model on a machine whose engine is signed out, since the grid needs no subscription', async () => {const grid = 'swarm-0123456789ab', pool = swarm(undefined, [{ engine: 'claude', installed: true, signedIn: false }])pool.observation.localModels = [{ grid, model: 'qwen3' }]- const { answer, s } = await runPool(pool, false, {}, project, { state: { localModels: { grid, enabled: true } } })+ const { answer, s } = await runPool(pool, false, {}, project, { state: { localModels: { grid, enabled: true } }, kind: 'tests' })expect(answer).toMatchObject({ ok: true, pick: { gridModel: 'qwen3' } })expect(recorded(s).command.decision.excluded).toEqual(expect.arrayContaining([expect.objectContaining({ reason: expect.stringContaining('not signed in') })]))})@@ -1256,7 +1277,7 @@ describe('routing contributed capacity', () => {const subscription = healthy(), reading = { usedPercent: 20, resetsAt: Date.now() + 5 * 86_400_000 }Object.assign(subscription, { engines: ['claude', 'codex'] })subscription.observation.quotas = ['claude', 'codex'].map(engine => ({ engine, known: true, windows: [{ ...reading, name: '5-hour' }, { ...reading, name: 'weekly' }] }))- const enabled = { ...policy, models: policy.models.map(m => ({ ...m, enabled: true })) }+ const enabled = { ...floorPolicy, models: floorPolicy.models.map(m => ({ ...m, enabled: true })) }const s = scoped({ context: { ok: true, value: { agentId: 'lead', tab: { state: { id: 'tab', agents: [agents[1]], conversations: conversations(), machines: [subscription, keyed('m2'), keyed('m3')] } },policy: { policy: enabled, warnings: [] }, machines: [] } } })const answer = await routeTask(input, s, where, opener())@@ -1521,7 +1542,7 @@ describe('local models on the Swarm\'s grid', () => {{ grid: GRID, model: 'deepseek/deepseek-v4.1', kind: 'api' }, { grid: GRID, model: 'starting', starting: true }, { grid: 7, model: 'odd' }] } },{ machineId: 'old', observation: { receivedAt: 'never', localModels: [{ grid: GRID, model: 'unnamed-host' }] } }] })const s = scoped({ tab: t })- const result = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low' } }, s, where as never, opener(), () => 'op')+ const result = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low', kind: 'docs' } }, s, where as never, opener(), () => 'op')const excluded = recorded(s).command.decision.excluded as Array<{ title: string; reason: string }>expect(excluded.filter(e => /offline/.test(e.reason))).toEqual([{ title: 'Kimi K3', reason: 'Its host 2x 4090 Rig is offline, so a Builder on it would never start.' },@@ -1543,7 +1564,7 @@ describe('local models on the Swarm\'s grid', () => {const t = tab(); Object.assign(t.state, { localModels: { grid: GRID, enabled: true },machines: [{ machineId: 'm1', observation: { receivedAt: Date.now(), localModels: [{ grid: GRID, model: 'moonshotai/kimi-k3', kind: 'api' }] } }] })Object.assign(t.state.conversations[1]!, { stepUp: { attempt: 3, floor: 3, reason: 'Its first review said Ready no.', at: 1, carry: '' } })- const s = scoped({ tab: t })+ const s = scoped({ tab: t, policy: floorPolicy })const result = await routeTask({ ...input, assessment: { ...input.assessment, difficulty: 'low', kind: 'docs' } }, s, where as never, opener(), () => 'op')expect(result).toMatchObject({ ok: true, pick: { model: 'opus' } })const why = 'This task stepped up from a cheaper model: it runs on no model on the grid and nothing below quality 3.'diff --git a/cli/src/superTabs/routeCommand.ts b/cli/src/superTabs/routeCommand.tsindex 97bb1b0b3..7a42999a0 100644--- a/cli/src/superTabs/routeCommand.ts+++ b/cli/src/superTabs/routeCommand.ts@@ -7,7 +7,7 @@ import { openDaemon, type Daemon, type Where } from '../agentClient/daemon.js'import { RELAYED_QUOTA, requiredToolReason, startRequirements } from './capacity.js'import { inspectCapacity, type ScopedRequest } from './start.js'import { ENDED_WORK, object, within } from './wire.js'-import { accountOf, API_BUILDERS, choose, decide, gridQuality, parseAssessment, quotaOf2, rateFor, recordOf, repoMatch, repositoryKey, reviewRefusals, stepUpRefusals, type Assessment, type Reviewed, type RecordShape, type Commitment, type Excluded, type HeldModel, type MemberFrame, type Policy, type Probe, type SwarmRule, type TaskFolder } from './route.js'+import { accountOf, API_BUILDERS, buildRefusals, gridBuilds, choose, decide, gridQuality, parseAssessment, quotaOf2, rateFor, recordOf, repoMatch, repositoryKey, reviewRefusals, stepUpRefusals, type Assessment, type Reviewed, type RecordShape, type Commitment, type Excluded, type HeldModel, type MemberFrame, type Policy, type Probe, type SwarmRule, type TaskFolder } from './route.js'import { stat } from 'node:fs/promises'import { describeScmProject } from '../scm/scmProjects.js'@@ -324,7 +324,7 @@ export async function routeTask(input: { tabId: string; conversationId: string;const step = finite(object(group.stepUp).floor) ? { floor: object(group.stepUp).floor as number } : nullfor (const [i, p] of probes.entries()) {const refusals = [...(outside(p.machineId) ? [ELSEWHERE] : []), ...(p.kind === 'member' && !checked(p.agentId) ? [UNCHECKED_DEVICE] : []),- ...(review ? reviewRefusals(p, builder) : []), ...stepUpRefusals(p, step)]+ ...(review ? reviewRefusals(p, builder) : buildRefusals(p, assessment)), ...stepUpRefusals(p, step)]if (refusals.length) probes[i] = { ...p, refusals: [...p.refusals, ...refusals] }}// Picks started or assigned and still at work hold part of their account's quota; the log, and so this, is per Swarm.@@ -487,7 +487,7 @@ export function localProbes(state: Json, policy: Policy, probes: Probe[], a: Ass* 2026-10-29). Only where [localProbes] would offer them. */export function offlineModels(state: Json, policy: Policy, a: Assessment, review: boolean, now: number = Date.now()): Array<{ title: string; reason: string }> {const addOn = object(state.localModels)- if (addOn.enabled !== true || typeof addOn.grid !== 'string' || review || (policy.localModels?.enabled === false && !a.local)) return []+ if (addOn.enabled !== true || typeof addOn.grid !== 'string' || review || !gridBuilds(a) || (policy.localModels?.enabled === false && !a.local)) return []const served = servedModels(state, addOn.grid, now), out: Array<{ title: string; reason: string }> = []for (const machine of list(state.machines)) {const observed = object(machine.observation)diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.tsindex b92741428..7ea9451ce 100644--- a/cli/src/superTabs/service.spec.ts+++ b/cli/src/superTabs/service.spec.ts@@ -747,10 +747,12 @@ it('says a server from before rules does not support them, and passes a malformeexpect(await send({ type: 'rule.set', rule: { kind: 'minEffort', effort: 'huge' }, text: 'x' })).not.toMatchObject({ error: 'RULES_UNSUPPORTED' })})-it('tells the Lead that simple work ranks grid models first, and how the owner opts out', async () => {+it('tells the Lead which builds a grid model takes and ranks first, and how the owner opts out', async () => {const help = (await setup().ask({ action: 'help' }, owner)).help as { commands: unknown[]; command: string }expect(help.commands).toContainEqual(expect.objectContaining({ type: 'rule.set', rule: { kind: 'noGridFirst' } }))- expect(help.command).toContain('ranks models on the Swarm\'s grid first unless the owner set noGridFirst')+ expect(help.command).toContain('builds only low-risk work of kind docs, tests or fixtures')+ expect(help.command).toContain('ranks first there unless the owner set noGridFirst')+ expect(help.command).toContain('A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model.')})it('documents finished worker decisions and explains an older backend without release support', async () => {diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.tsindex 1e066e68e..7e2dc20f5 100644--- a/cli/src/superTabs/service.ts+++ b/cli/src/superTabs/service.ts@@ -73,7 +73,7 @@ const HELP = {capacity: 'capacity MACHINE_ID JSON: inspect machine, engine and quota headroom. JSON uses the start request fields below. Unknown allowances are not reported as free tokens.',startRequest: { conversationId: 'GROUP', machineId: 'MACHINE', engine: 'codex', name: 'Builder', cwd: '/absolute/repo/on/that/machine', worktree: true, branchRef: 'refs/remotes/origin/BASE_BRANCH', requirements: START_REQUIREMENTS,model: 'opus', effort: 'high', routeDecisionId: 'DECISION' },- command: 'command OPERATION_ID JSON: send one of the commands below. The JSON is one argument: when it holds quotes, put - in its place and send it on stdin (command OPERATION_ID - <<\'JSON\' … JSON). Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. Low-risk work that is not a review ranks models on the Swarm\'s grid first unless the owner set noGridFirst: low-difficulty work, and medium work of kind docs, copy, tests, fixtures, fix or refactor (a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid and quality 2, then quality 3, at most twice) and tells you: route it again, and the route and the server keep to the new floor.',+ command: 'command OPERATION_ID JSON: send one of the commands below. The JSON is one argument: when it holds quotes, put - in its place and send it on stdin (command OPERATION_ID - <<\'JSON\' … JSON). Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model. A model on the Swarm\'s grid builds only low-risk work of kind docs, tests or fixtures, unless a person asks for a local model or names one, and ranks first there unless the owner set noGridFirst (at medium difficulty a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid, at the top tier as every build, at most twice) and tells you: route it again, and the route and the server keep to the new floor.',commands: [{ type: 'project.report', projectId: 'PROJECT', through: { GROUP: 214031 }, text: 'What changed, what is blocked, and what comes next. Use null when nothing merits repeating.' },{ type: 'project.repository', projectId: 'PROJECT', repositoryUrl: 'https://github.com/OWNER/REPOSITORY' },diff --git a/docs/swarms.md b/docs/swarms.mdindex 7e036a78d..fab92146f 100644--- a/docs/swarms.md+++ b/docs/swarms.md@@ -415,22 +415,50 @@ orders the rest by the owner's soft rules and the routing policy (strength,quota fit, effective cost).**Grid models.** A model served on the Swarm's grid counts as strong as the-policy says. Kimi K3 and DeepSeek v4.1 are rated 2, Sonnet's tier; every other+policy says. Kimi K3 and DeepSeek v4.1 are rated 2; every othergrid or local model takes the policy's local quality (1). An owner can changeboth, and add rows of their own, in the policy's local models (`models`: a nameand a quality, first match first). A model whose host is offline is left outwith that reason, so no Builder is sent to a machine that cannot start it.-**Cheap first.** Low-risk work that is not a review ranks a grid model first:-low-difficulty work, and medium work of kind `docs`, `copy`, `tests`,-`fixtures`, `fix` or `refactor`. The floor still keeps a small model off medium-work. An owner opts out with the `noGridFirst` rule.+**Builds at the top tier.** A build needs a model the table rates 3 (Ken and+Dee, 2026-10-30: Builders run on Opus high or Astra xhigh), on the server and+in the route alike, so Sonnet (2), Haiku (1) and any model the table does not+name build nothing. Two exceptions: a model a person named, and a grid model+for low-risk docs, tests or fixtures (below). The server refuses an agent's+start, assignment or pick otherwise, and lets a person through with a warning.+An owner who wants Sonnet Builders rates Sonnet 3 in their table. A Claude agent+that reports no model is rated 1, since Claude Code's own default depends on+the account and can be Sonnet; a person's own start without a model therefore+posts a warning.++**No Haiku by default.** Haiku's row is off too (review of #2314): an older CLI+on a newer server picked it for easy work that the server refuses, on every+route. With it off, every row the default table offers is rated 3.++**Cheap first.** A grid model builds only low-risk work of kind `docs`,+`tests` or `fixtures`, singular or plural (Ken, 2026-10-30), and ranks first+there. Any other build leaves it out with that reason, unless a person asks for+a local model or names one; the route decision records that, and the server+refuses a grid start or assignment whose decision does not allow it. The floor+still keeps a small model off medium work. An owner opts out of ranking it+first with the `noGridFirst` rule.++**No Sonnet by default.** The default routing table turns Claude Sonnet off+(Ken, 2026-10-30: no Sonnet Builders). With its row off, the route also starts+no new Sonnet Reviewer, and a role whose default is Sonnet starts on its+engine's own model instead, telling the group why. A person who names Sonnet+is told the table turns it off. An owner's saved table keeps its own Sonnet row+as it is; an owner who wants none there sets a `forbidModel` rule. Codex GPT-6-Astra at+`xhigh` is a built-in row (quality 3, cost 5: its API rate is 2.5 times+Opus's), added on read like GPT-6.1 Sol's, so Builders can run on Opus high or+Astra xhigh as the owners decided; an owner's own Astra row wins over it.**Stepping up.** When a grid attempt's first review says Ready no, or its gridhost never starts the agent (the start fails or misses its window), the Swarmsteps the task up: it closes the attempt, tells its Builder to stop, and wakes-the Lead to route it again. The next attempt runs on no grid model and nothing-below quality 2 (Sonnet), and after a second failure nothing below 3 (Opus). A+the Lead to route it again. The next attempt runs on no grid model and, as+every build, at the top tier (quality 3). Atask steps up at most twice; after that the Lead decides. The route and theserver both keep to the new floor. The next attempt's brief carries the pullrequest, the last result and the review's findings, and the step (attempt