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.

Swarm: until team accounts can be made, a machine without one takes teammates' work as before (#1701)

Deeccb696876b89
diff --git a/backend/integration/superTabTeam.test.ts b/backend/integration/superTabTeam.test.ts
index 24f5b26bd..feb9fd8cf 100644
--- a/backend/integration/superTabTeam.test.ts
+++ b/backend/integration/superTabTeam.test.ts
@@ -274,6 +274,9 @@ describe('a team session speaking in a Swarm', () => {
// Teammates' work runs only on Team machines (Task 3): the owner's project on the person's machines needs the person's
// Harness Team account with its privacy check passed. The person's own projects run on the person's machines as before.
describe('a teammate\'s work and the machines that take it', () => {
+ // With the rule required everywhere, as it will be once team accounts can be made (machines.ts teamAccountRequired).
+ beforeAll(() => { process.env.SWARM_TEAM_ACCOUNT_REQUIRED = '1' })
+ afterAll(() => { delete process.env.SWARM_TEAM_ACCOUNT_REQUIRED })
/** The person's personal MacBook, contributed for every project, reporting from the person's own sign-in. */
async function personalMac(f: Awaited<ReturnType<typeof fixture>>) {
await run(f.tab, { type: 'machine.contribute', machineId: 'personal-mac', name: 'MacBook Pro', cwd: '/work', scope: 'swarm', engines: ['codex'], maxAgents: 2 }, person)
diff --git a/backend/src/superTabs/machines.ts b/backend/src/superTabs/machines.ts
index 6c61c03ae..ccfa75a63 100644
--- a/backend/src/superTabs/machines.ts
+++ b/backend/src/superTabs/machines.ts
@@ -95,6 +95,7 @@ export const MACHINE_FRESH_MS = 45_000
// work. It would run as that machine's owner, with their files, logins and subscriptions, so it is admitted only on a
// Team machine — the Mac's Harness Team account, or a machine used only for agents — that shows its privacy now.
// Everything else refuses it and says why; a person's own projects on their own machines are unchanged.
+// Until that is required everywhere (teamAccountRequired), it holds only on machines that have a team account.
/** How long a passed privacy check counts, from when this server first received it. The team account checks again
* every 5 minutes (cli/src/team/privacy.ts PRIVACY_RECHECK_MS) and reports within a 15-second beat, so a healthy
@@ -129,10 +130,20 @@ const PRIVACY_ITEMS: Record<string, string> = {
}
const ONLY_OWN = 'so it runs only its owner\'s projects'
+/**
+ * Whether a teammate's work needs a Harness Team account on every machine (`SWARM_TEAM_ACCOUNT_REQUIRED=1`). Until the
+ * CLI that makes team accounts is released, it does not: a machine without one takes a teammate's work as it did before
+ * team accounts, while a machine with one already follows the rule. Read on every call, so a test can set it.
+ */
+export function teamAccountRequired(): boolean {
+ return process.env.SWARM_TEAM_ACCOUNT_REQUIRED === '1'
+}
+
/** Why this contributed machine may not run a teammate's project now, or null when it may. `teamRow`: its account row
* says it is signed in as a team account (`Machine.sessionKind`), read by the store. */
export function teamWorkRefusal(pool: ContributedMachine, now: number, teamRow = false): TeamWorkRefusal | null {
const reading = pool.observation, name = pool.name
+ if (!teamRow && reading?.sessionKind !== 'team' && !teamAccountRequired()) return null
if (!reading || now - reading.receivedAt > MACHINE_FRESH_MS) {
return { code: 'MACHINE_OFFLINE', reason: `${name} is offline, so it cannot show that its Harness Team account is private.` }
}
@@ -162,7 +173,11 @@ export function teamWorkCheck(state: SuperTabState, machineId: string, contribut
teamMachines: readonly string[] = []): TeamWorkRefusal | null {
if (project.ownerId === contributorId) return null
const pool = state.machines?.find(m => m.machineId === machineId)
- if (!pool) return { code: 'TEAM_ACCOUNT_REQUIRED', reason: `This machine is not a Team machine of this Swarm, ${ONLY_OWN}.` }
+ if (!pool) {
+ // Off the Machines list nothing reports a team account (store.ts teamMachines), so this is the switch alone.
+ if (!teamAccountRequired()) return null
+ return { code: 'TEAM_ACCOUNT_REQUIRED', reason: `This machine is not a Team machine of this Swarm, ${ONLY_OWN}.` }
+ }
return teamWorkRefusal(pool, now, teamMachines.includes(machineId))
}
diff --git a/backend/src/superTabs/teamRouting.test.ts b/backend/src/superTabs/teamRouting.test.ts
index 5fc544ae3..d7ca8f827 100644
--- a/backend/src/superTabs/teamRouting.test.ts
+++ b/backend/src/superTabs/teamRouting.test.ts
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
import { applyCommand, type Command, type CommandContext } from './commands.js'
import { admitMachineStart, machineObservationSchema, observedPrivacy, PRIVACY_FRESH_MS, teamWorkRefusal, type ContributedMachine, type MachinePrivacy } from './machines.js'
import { createSuperTab, SuperTabError, visibleState, type Actor, type AgentConfiguration, type AgentStart, type SuperTabState } from './model.js'
@@ -7,6 +7,11 @@ import type { RouteDecision } from './routeRecord.js'
// Teammates' work runs only on Team machines (docs/plans/2026-10-24-swarm-team-account.md, Task 3): a start or an
// assignment for a project whose owner did not contribute the machine needs a Harness Team account whose privacy check
// passed, or a machine used only for agents. A person's own projects on their own machine are unchanged.
+//
+// Everything below runs with the rule required everywhere (SWARM_TEAM_ACCOUNT_REQUIRED=1), except the last block: until
+// then, a machine without a team account takes a teammate's work as it did before.
+beforeEach(() => { process.env.SWARM_TEAM_ACCOUNT_REQUIRED = '1' })
+afterEach(() => { delete process.env.SWARM_TEAM_ACCOUNT_REQUIRED })
const NOW = 50_000_000
const MINUTE = 60_000
@@ -327,3 +332,40 @@ describe('agents already working on a personal machine', () => {
expect(refusal(() => f.run({ type: 'work.assign', conversationId: group, agentId: old }))?.code).toBe('TEAM_ACCOUNT_REQUIRED')
})
})
+
+describe('until a team account is required everywhere', () => {
+ beforeEach(() => { delete process.env.SWARM_TEAM_ACCOUNT_REQUIRED })
+ const pool = (observation?: Reading) => ({ machineId: 'mac', name: 'MacBook Pro', contributorId: 'mate', membershipGeneration: 'g', generation: 'g1',
+ cwd: '/swarm', engines: ['codex'], maxAgents: 2, paused: false, ...(observation ? { observation } : {}) }) as ContributedMachine
+
+ it('a machine without a team account takes a teammate\'s project as before, online or not', () => {
+ expect(teamWorkRefusal(pool(reading('computer')), NOW)).toBeNull()
+ expect(teamWorkRefusal(pool(reading('computer', undefined, NOW - 60 * MINUTE)), NOW)).toBeNull()
+ expect(teamWorkRefusal(pool(), NOW)).toBeNull()
+ })
+
+ it('a machine with one already follows the rule, by its reading or its account row', () => {
+ expect(teamWorkRefusal(pool(reading('team', FAILED)), NOW)?.code).toBe('PRIVACY_CHECK_FAILED')
+ expect(teamWorkRefusal(pool(reading('team', PASSED, NOW, NOW - 20 * MINUTE)), NOW)?.code).toBe('PRIVACY_CHECK_STALE')
+ expect(teamWorkRefusal(pool(reading('computer')), NOW, true)?.code).toBe('PRIVACY_UNCHECKED')
+ expect(teamWorkRefusal(pool(reading('team', PASSED)), NOW)).toBeNull()
+ })
+
+ it('starts, assignments and Reviewers on a personal machine or off the Machines list are admitted as before', () => {
+ const f = swarm(), group = f.group()
+ f.run({ type: 'agent.start', request: f.request(group, 'mate-mac') }, owner, f.pooled('mate-mac'))
+ f.run({ type: 'agent.start', request: { ...f.request(group, 'mate-laptop'), cwd: '/work' } }, mate, { contribution: { machineOwnerId: 'mate', contributorId: 'mate' } })
+ expect(f.state.starts).toHaveLength(2)
+ const personal = f.member('personal', 'mate-mac', 'mate')
+ f.run({ type: 'work.assign', conversationId: group, agentId: personal })
+ expect(f.state.conversations.find(c => c.id === group)!.assignment).toMatchObject({ agentId: personal, status: 'working' })
+ const reviewer = f.member('reviewer', 'mate-mac', 'mate', 'lead', { role: 'reviewer' })
+ f.run({ type: 'conversation.agent', conversationId: f.group(), agentId: reviewer, present: true, lead: false })
+ })
+
+ it('a Team machine whose check fails still refuses it', () => {
+ const f = swarm(), group = f.group()
+ f.machine('mate-team').observation = reading('team', FAILED)
+ expect(refusal(() => f.run({ type: 'agent.start', request: f.request(group, 'mate-team') }, owner, f.pooled('mate-team')))?.code).toBe('PRIVACY_CHECK_FAILED')
+ })
+})
diff --git a/docs/plans/2026-10-24-swarm-team-account.md b/docs/plans/2026-10-24-swarm-team-account.md
index 8d2a375fb..cad68363d 100644
--- a/docs/plans/2026-10-24-swarm-team-account.md
+++ b/docs/plans/2026-10-24-swarm-team-account.md
@@ -83,6 +83,7 @@ How it works (`backend/src/superTabs/machines.ts`, `teamWorkCheck`):
- **Enforced** in `admitMachineStart` (on `agent.start` and again on `agent.startDispatch`), on starts off the Machines list, `work.assign`, `conversation.agent` adding a Reviewer, `route.record` and `route.override`. A queued start whose Team machine refuses it for good (no team account, no check, failing check) fails with that reason when its host tries to launch it; one waiting on a stale check keeps waiting.
- **Routing.** The tab read gives each machine `teamWork`: `{ allowed: true }`, or `{ allowed: false, code, reason }`. The CLI's route leaves those machines out for a teammate's project and lists the reason in `excluded[]`. The backend does the same with any candidate an older CLI still sends, and refuses a pick there ("… Route again.").
- **Migration.** Nothing is stopped. Agents already running on personal machines keep their current task, its reports, messages and their sessions. New starts, new assignments and new Reviewer groups for another person's project follow the rule. A personal machine contributed with scope "swarm" now serves only its owner's projects. So does a machine contributed before projects (no scope) by someone other than the Swarm's owner: the Swarm's first project is the owner's.
+- **Switch.** The backend shipped (1.3.28) before the CLI that makes team accounts. So the rule is held to every machine only with `SWARM_TEAM_ACCOUNT_REQUIRED=1` (`machines.ts` `teamAccountRequired`). Until then, a machine without a team account takes a teammate's work as it did before, and a machine with one already follows the rule. Turn it on with the CLI and Desktop release that makes team accounts.
## Task 4: Harness GitHub App (backend, CLI)