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
fix(route): a build leaves out a member in another repository, whatever its name (#2377)
harness-for-autonomous[bot]972b5bece343
diff --git a/cli/src/superTabs/route.spec.ts b/cli/src/superTabs/route.spec.tsindex 76f513782..205db4852 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, 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'+import { API_BUILDERS, buildRefusals, cheapKind, ELSEWHERE, 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>@@ -120,15 +120,49 @@ describe('choose', () => {], policy, a(), NOW)if ('error' in r) throw new Error('unexpected')expect(r.belowFloor).toBe(false)- // A member in another repository saves no start, so it ranks as a new agent would.+ // A member in another repository would build in that repository's worktree, so a build leaves it out.expect(r.shown.map(s => s.title)).toEqual(['New agent · Claude sonnet medium · mac','Multiply · Claude sonnet medium · remote-1',- 'Elsewhere · Claude sonnet medium · remote-1','New agent · Claude sonnet medium · remote-1','New agent · Claude opus high · remote-1',])- expect(r.shown.map(s => s.id)).toEqual(['c0', 'c1', 'c2', 'c3', 'c4'])+ expect(r.shown.map(s => s.id)).toEqual(['c0', 'c1', 'c2', 'c3'])+ expect(r.excluded).toContainEqual({ title: 'Elsewhere · Claude sonnet medium · remote-1', reason: ELSEWHERE, machine: 'remote-1' })+ })+ // Diego, 10-30: a member in another repository tied a new agent and the title decided, so Ada took the task in her own+ // repository's worktree and Zed did not. Review of #2377: ranking it after a new agent was not enough, since the owner's+ // reuse rule and quota room both come before placement.+ it('leaves a member in another repository out of a build whatever its name or rank; one in the repository wins; an unknown one ranks as before', () => {+ const route = (member: Partial<Probe>, task: Partial<Assessment> = {}, rules: SwarmRule[] = [], others = [probe()]) =>+ ok(choose([...others, probe({ kind: 'member', agentId: 'a1', activity: 'idle', ...member })], policy, a(task), NOW, [], rules))+ const order = (member: Partial<Probe>, task: Partial<Assessment> = {}, rules: SwarmRule[] = []) => route(member, task, rules).shown.map(s => s.kind)+ expect(order({ name: 'Ada', repo: 'different' })).toEqual(['new'])+ expect(order({ name: 'Zed', repo: 'different' })).toEqual(['new'])+ expect(route({ name: 'Ada', repo: 'different' }).excluded).toEqual([{ title: 'Ada · Claude sonnet medium · remote-1', reason: ELSEWHERE, machine: 'remote-1' }])+ expect(order({ name: 'Ada', repo: 'same' })).toEqual(['member', 'new'])+ expect(order({ name: 'Zed', repo: 'same' })).toEqual(['member', 'new'])+ // No folder named: nothing to be in or out of, so a member saves a start as before.+ expect(order({ name: 'Zed' })).toEqual(['member', 'new'])+ // A repository that could not be told keeps its rank beside a new agent: the title still decides between them.+ expect(order({ name: 'Ada', repo: 'unknown' })).toEqual(['member', 'new'])+ expect(order({ name: 'Zed', repo: 'unknown' })).toEqual(['new', 'member'])+ // Nothing that ranks before placement brings it back: cheaper, the owner's reuse-idle-agents rule, or more quota room+ // than the machine that can start a new agent (its own machine at its agent limit).+ expect(order({ name: 'Zed', repo: 'different', cost: 1 })).toEqual(['new'])+ const reuse: SwarmRule[] = [{ rule: { kind: 'preferIdle' }, text: 'Reuse idle agents first.' }]+ expect(order({ name: 'Zed', repo: 'different' }, {}, reuse)).toEqual(['new'])+ expect(order({ name: 'Zed', repo: 'same' }, {}, reuse)).toEqual(['member', 'new'])+ const roomy = windows([90, 3 * H], [90, 5 * D], 'A'), tight = windows([40, 3 * H], [60, 5 * D], 'B')+ const full = [probe({ quota: roomy, refusals: ['This machine runs as many agents as its owner allows.'] }), probe({ machineId: 'm2', machineName: 'mac', quota: tight })]+ expect(route({ name: 'Ada', repo: 'different', quota: roomy }, {}, [], full).shown.map(s => s.title)).toEqual(['New agent · Claude sonnet medium · mac'])+ expect(route({ name: 'Ada', repo: 'same', quota: roomy }, {}, [], full).shown[0]!.title).toBe('Ada · Claude sonnet medium · remote-1')+ // Only members in another repository: none is offered, and the Lead is told why.+ expect(choose([probe({ kind: 'member', agentId: 'a1', name: 'Ada', activity: 'idle', repo: 'different' })], policy, a(), NOW))+ .toEqual({ error: 'NO_CANDIDATE', excluded: [{ title: 'Ada · Claude sonnet medium · remote-1', reason: ELSEWHERE, machine: 'remote-1' }] })+ // A review reads the pull request and needs no worktree: its Reviewer in another repository is kept, after a new agent.+ expect(order({ name: 'Ada', repo: 'different' }, { kind: 'review' })).toEqual(['new', 'member'])+ expect(order({ name: 'Ada', repo: 'same' }, { kind: 'review' })).toEqual(['member', 'new'])})it('marks belowFloor when nobody meets it, and shows those that fit before the unknown and the short', () => {const r = ok(choose([probe({ quality: 1 }), probe({ quality: 1, machineName: 'mac', quota: windows([90, null], [90, null]) })], policy, a({ difficulty: 'high' }), NOW))@@ -410,7 +444,9 @@ describe('candidate labels', () => {expect(label).toContain('api, branch feat/auth')expect(label).toContain('last active 2h ago')expect(label).toContain('earlier here: API done')- expect(members({ repo: 'different' }).shown.find(s => s.kind === 'member')!.label).toContain('different repo')+ // Only a review offers one in another repository: a build leaves it out (ELSEWHERE).+ expect(ok(choose([probe({ kind: 'member', agentId: 'a1', name: 'Multiply', activity: 'idle', frame: frame(), repo: 'different' })], policy, a({ kind: 'review' }), now))+ .shown[0]!.label).toContain('different repo')expect(members({ repo: 'unknown' }).shown.find(s => s.kind === 'member')!.label).toContain('repo unknown')expect(members({ repo: undefined }).shown.find(s => s.kind === 'member')!.label).not.toMatch(/repo/)})diff --git a/cli/src/superTabs/route.ts b/cli/src/superTabs/route.tsindex 743225512..8f6ca8c7d 100644--- a/cli/src/superTabs/route.ts+++ b/cli/src/superTabs/route.ts@@ -355,6 +355,7 @@ export function accountOf(p: Probe): string {const AVOIDED = 'Its account lost this task before (a model that kept failing, a limit or a stall), and another account is free.'const AVOIDED_ONLY = 'Every candidate runs on the account that lost this task before; check it is answering before you assign.'+export const ELSEWHERE = 'It works in another repository, so it would build this in that repository\'s worktree. A new agent starts in this one.'/** How the probe's account would carry a task of this size (phase 1 §2–3). */function sizeUp(p: Probe, policy: Policy, a: Assessment, now: number, open: Commitment[]): Sized {@@ -402,9 +403,12 @@ export const LOCAL_NONE = 'No local model is being served on this Swarm\'s grid./** The fixed order: the owner's preferred engine, a model on the Swarm's grid for simple work, an idle member before a new* agent and a less busy machine first when the owner prefers idle agents; then the policy order: cheaper in effect,* stronger, a model that runs on a machine before one reached through a shared API or another grid, more room on the- * tightest window, an idle member in the task's repository before a new agent, then by title. */+ * tightest window, an idle member in the task's repository before a new agent and one in another repository after it, then by+ * title. */function compare(x: Probe & Sized, y: Probe & Sized, soft: Soft): number {- const placed = (p: Probe) => p.kind === 'member' && (p.repo ?? 'same') === 'same' ? 0 : 1+ // A member in another repository ranked as a new agent did, so its name sorting before "New agent" decided whether it took+ // the task (Diego, 2026-10-30). A build leaves it out (choose); a review, which needs no worktree, ranks it after a new agent.+ const placed = (p: Probe) => p.kind !== 'member' ? 1 : p.repo === 'different' ? 2 : p.repo === 'unknown' ? 1 : 0const preferred = (p: Probe) => soft.engine && p.engine !== soft.engine ? 1 : 0const subscription = (p: Probe) => soft.grid && !p.gridModel ? 1 : 0const fresh = (p: Probe) => soft.idle && p.kind === 'new' ? 1 : 0@@ -445,6 +449,11 @@ export function choose(probes: Probe[], policy: Policy, a: Assessment, now: numbconst raised = probes.map(p => lifted(rules, p)), key = (p: Probe) => `${p.kind}\0${p.machineId}\0${p.engine}\0${p.model}\0${p.effort}\0${p.gridModel ?? ''}`const ruled = raised.filter((p, i) => p === probes[i] || !raised.some((q, j) => j !== i && key(q) === key(p) && (q === probes[j] || j < i))).map(p => { const why = breaks(rules, p); return why ? { ...p, refusals: [...p.refusals, why] } : p })+ // A member builds in its own worktree, so one in another repository would build there (Diego, 2026-10-30). Ranking it+ // after a new agent was not enough: the owner's reuse rule and quota room both rank before placement (review of #2377).+ // Both checkouts are compared as host and path (repoMatch), so the same repository over SSH and HTTPS is not "different".+ // A review reads the pull request and needs no worktree, so it keeps its Reviewer; an unknown repository says nothing.+ .map(p => a.kind !== 'review' && p.kind === 'member' && p.repo === 'different' ? { ...p, refusals: [...p.refusals, ELSEWHERE] } : p)const excluded: Excluded[] = ruled.filter(p => p.refusals.length).map(p => ({ title: titleOf(p), reason: p.refusals.join(' '), machine: p.machineName }))const viable = ruled.filter(p => !p.refusals.length)// Nothing offered: a model that is served but taken says who has it, rather than reading as unshared.diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.tsindex bcf7322f5..a99e82375 100644--- a/cli/src/superTabs/routeCommand.spec.ts+++ b/cli/src/superTabs/routeCommand.spec.ts@@ -6,7 +6,7 @@ import { join } from 'node:path'import { heldLocalModels, localProbes, NO_SWARM_AGENTS_ON, offlineModels, routeTask, STALL_RETRY_MS, stalled } from './routeCommand.js'import type { describeScmProject } from '../scm/scmProjects.js'import { admission, quotaOf, RELAYED_QUOTA } from './capacity.js'-import type { Assessment, Policy, Probe } from './route.js'+import { ELSEWHERE, type Assessment, type Policy, type 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]).@@ -788,7 +788,9 @@ describe('what the route log says about each candidate', () => {const other = frame({ project: git({ name: 'web', remote: 'github.com/acme/web', root: '/w/web', cwd: '/w/web' }) })const s = scoped(world())await routeTask(withCwd, s, where as never, opener(id => daemon(id, { agents: id === 'm1' ? ['h1'] : [], frames: { h1: other } })), () => 'op', describeGit())- expect(memberLabel(s)).toContain('different repo')+ // A build leaves it out, with why (Diego, 2026-10-30): it would build in the other repository's worktree.+ expect(labels(s).some(l => l.startsWith('Member Multiply'))).toBe(false)+ expect(recorded(s).command.decision.excluded).toContainEqual({ title: 'Multiply · Claude sonnet medium · remote-1', reason: ELSEWHERE })const t = scoped(world())await routeTask(withCwd, t, where as never, opener(id => daemon(id, { agents: id === 'm1' ? ['h1'] : [] })), () => 'op', describeGit())expect(memberLabel(t)).toContain('repo unknown · last active unknown')