Skip to content

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

test(super-tabs): the super-tab coverage gate passes on main again (#2380)

harness-for-autonomous[bot]812fa6f1738e
diff --git a/cli/src/superTabs/inCore/adoption.spec.ts b/cli/src/superTabs/inCore/adoption.spec.ts
index e9fa19f12..ff5770a1e 100644
--- a/cli/src/superTabs/inCore/adoption.spec.ts
+++ b/cli/src/superTabs/inCore/adoption.spec.ts
@@ -168,6 +168,11 @@ describe('old Swarm role adoption', () => {
expect(t.role).toHaveBeenCalledOnce()
expect(t.wait).not.toHaveBeenCalled()
})
+ it('reads and writes nothing for a relaunch already cancelled', async () => {
+ const t = setup(row({ startedBy: 'agent' })); t.cancel()
+ expect(await t.adopt.lookup!(t.saved, t.current)).toBeNull()
+ expect(t.role).not.toHaveBeenCalled()
+ })
it('answers null when the relaunch is cancelled or the session rebound while it reads', async () => {
const cancelled = setup(); cancelled.role.mockImplementation(async () => { cancelled.cancel(); return { role: 'buddy' as const } })
expect(await cancelled.adopt.lookup!(cancelled.saved, cancelled.current)).toBeNull()
@@ -177,9 +182,15 @@ describe('old Swarm role adoption', () => {
})
it('gives the row as it is for a session in no Swarm, one already tagged, or the person\'s own outside the roster', async () => {
const none = setup(); none.role.mockResolvedValue(null)
- expect(await none.adopt.lookup!(none.saved, none.current)).toMatchObject({ row: none.saved })
+ const noneLooked = await none.adopt.lookup!(none.saved, none.current)
+ expect(noneLooked).toMatchObject({ row: none.saved })
const tagged = setup(row({ swarmSkill: { role: 'buddy', key: 'old-session' } }))
- expect(await tagged.adopt.lookup!(tagged.saved, tagged.current)).toMatchObject({ row: tagged.saved })
+ const taggedLooked = await tagged.adopt.lookup!(tagged.saved, tagged.current)
+ expect(taggedLooked).toMatchObject({ row: tagged.saved })
+ // The caller commits whatever it was given: for these rows that writes nothing.
+ for (const looked of [noneLooked, taggedLooked]) { if (!looked || looked === 'unavailable') throw new Error('expected a row'); looked.commit() }
+ expect(none.saved.swarmSkill).toBeUndefined()
+ expect(tagged.saved.swarmSkill).toEqual({ role: 'buddy', key: 'old-session' })
const own = setup()
const adopt = createSwarmSkillAdoption({ role: own.role, authority: () => () => true, save: vi.fn(), candidate: () => false })
expect(await adopt.lookup!(own.saved, own.current)).toMatchObject({ row: own.saved })
@@ -226,6 +237,26 @@ describe('old Swarm role adoption', () => {
expect(await t.adopt(t.saved, t.current)).toBeNull()
expect(t.saved.swarmSkill).toBeUndefined()
})
+ it('holds for two real seconds before reading again, and says so on the console, when the core gives it no wait or log', async () => {
+ vi.useFakeTimers()
+ const said = vi.spyOn(console, 'log').mockImplementation(() => {})
+ try {
+ const t = setup(row({ startedBy: 'agent' })); t.role.mockResolvedValueOnce(undefined)
+ const adopt = createSwarmSkillAdoption({ role: t.role, authority: () => () => true, save: vi.fn(), candidate: () => true })
+ let done = false
+ const adopting = adopt(t.saved, t.current).then(row => { done = true; return row })
+ await vi.advanceTimersByTimeAsync(1_999)
+ expect(done).toBe(false)
+ expect(t.role).toHaveBeenCalledOnce()
+ expect(said).toHaveBeenCalledWith('[swarm] old-sess held · its Swarm role could not be read; it opens once a read answers')
+ await vi.advanceTimersByTimeAsync(1)
+ expect(await adopting).toMatchObject({ swarmSkill: { role: 'lead', key: 'old-session' } })
+ expect(t.role).toHaveBeenCalledTimes(2)
+ } finally {
+ said.mockRestore()
+ vi.useRealTimers()
+ }
+ })
it('does not read or write for an already-cancelled operation', async () => {
const t = setup(); t.cancel()
expect(await t.adopt(t.saved, t.current)).toBeNull()
diff --git a/cli/src/superTabs/route.spec.ts b/cli/src/superTabs/route.spec.ts
index 205db4852..8bf0920ec 100644
--- a/cli/src/superTabs/route.spec.ts
+++ b/cli/src/superTabs/route.spec.ts
@@ -727,6 +727,10 @@ describe('local models on the Swarm\'s grid', () => {
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.' }] })
+ // A row for an engine this CLI does not know yet (a newer server's) is named by the server's own word for it.
+ const newer = { ...policy, models: [...policy.models, { engine: 'gemini' as never, model: 'pro', effort: 'high', quality: 3, cost: 3, enabled: false }] }
+ expect(choose([], newer, { ...simple, model: 'pro' }, NOW)).toEqual({ error: 'NO_CANDIDATE',
+ excluded: [{ title: 'Named model', reason: 'The routing table turns gemini pro 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')
diff --git a/cli/src/superTabs/routeCommand.spec.ts b/cli/src/superTabs/routeCommand.spec.ts
index a99e82375..3a61a941a 100644
--- a/cli/src/superTabs/routeCommand.spec.ts
+++ b/cli/src/superTabs/routeCommand.spec.ts
@@ -284,6 +284,12 @@ describe('routeTask', () => {
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, policy: floorPolicy }), where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'member', agentId: 'a1' } })
+ // An assignment that names no agent is held by what it ran on, and keeps no Reviewer out as its Builder.
+ Object.assign(t.state.conversations[2]!, { assignment: { id: 'b', status: 'review', configuration: { engine: 'codex' } } })
+ const unnamed = scoped({ tab: t, policy: floorPolicy })
+ expect(await routeTask(input, unnamed, where as never, opener(), () => 'op')).toMatchObject({ ok: true, pick: { kind: 'new', engine: 'claude', model: 'opus' } })
+ expect(recorded(unnamed).command.decision).toMatchObject({ floor: 3, belowFloor: false })
+ expect(JSON.stringify(recorded(unnamed).command.decision)).not.toContain('never reviews work it built')
})
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)
@@ -1111,6 +1117,14 @@ describe('routing contributed capacity', () => {
expect(reasons(out.answer)[0]!.reason).toContain('Claude Code is suspended on this machine: its last 2 starts there failed.')
pool.suspendedEngines = { codex: 'Codex is suspended on this machine: its last 2 starts there failed.' }
expect((await runPool(pool, false, {}, project)).answer.ok).toBe(true)
+ // The machine's own reading says more, and goes first: what its owner can fix there, not the count of failed starts.
+ // An engine this CLI does not run, or a reason that is not words, is not read.
+ const unsigned = swarm(undefined, [{ engine: 'claude', installed: true, signedIn: false }])
+ unsigned.suspendedEngines = { claude: 'Claude Code is suspended on this machine: its last 2 starts there failed.', gemini: 'Suspended.', codex: 2 }
+ const both = await runPool(unsigned, false, {}, project)
+ expect(both.answer).toMatchObject({ error: 'NO_CANDIDATE' })
+ expect(reasons(both.answer)[0]!.reason).toContain('not signed in to a subscription')
+ expect(JSON.stringify(reasons(both.answer))).not.toMatch(/suspended|Suspended/)
})
it('still offers a local model on a machine whose engine is signed out, since the grid needs no subscription', async () => {