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.

v3 flows: a Regular agent's chat, members' computers in the route, a PM in a Team account (#4248) (#3476)

0xken155a0fedbb1124
diff --git a/backend/integration/superTabComputerMoves.test.ts b/backend/integration/superTabComputerMoves.test.ts
index 9f8c74cba..b7e8c2e20 100644
--- a/backend/integration/superTabComputerMoves.test.ts
+++ b/backend/integration/superTabComputerMoves.test.ts
@@ -262,7 +262,9 @@ describe('the cleanup script', () => {
describe("a Mac whose owner's Team account is about to join", () => {
const run = (tab: string, command: Command, as: AuthUser = owner) => store.execute(as, tab, { operationId: randomUUID(), command })
- it('reads joining, not "not set up", until its Team account is listed, from an indexed read of the owners\' Team machines', async () => {
+ // Swarm v3 has no Team accounts (#4248, finding 8 of #4212): the Mac takes teammates' projects through its person's own agents
+ // meanwhile, and the read of the owners' Team machines it still makes stays indexed.
+ it('reads as taking teammates\' projects, from an indexed read of the owners\' Team machines', async () => {
const tab = (await store.create(owner, randomUUID(), 'Joining')).id
const invitation = await run(tab, { type: 'invite.create', email: kelvinUser.email, role: 'collaborator', conversationId: 'lead' })
await run(tab, { type: 'invite.accept', inviteId: invitation.result.inviteId as string }, kelvinUser)
@@ -277,7 +279,7 @@ describe("a Mac whose owner's Team account is about to join", () => {
deviceType: 'Laptop', chip: 'Fixture', os: 'macOS', gpuPercent: null }, quotas: [], tools: {}, runningHarnessIds: [], stoppedHarnessIds: [] })
const teamWork = async () => ((await store.read(kelvinUser, tab)).state.machines!.find(m => m.machineId === 'kelvin-joining') as { teamWork?: { code?: string } })
.teamWork?.code
- expect(await teamWork()).toBe('TEAM_ACCOUNT_JOINING')
+ expect(await teamWork()).toBeUndefined()
const { state } = await store.readLoad(kelvinUser, tab)
const entries = await profiled(db, () => store.joiningTeams(db, state))
const rows = reads(entries, 'machines', ['hostMachineId'])
diff --git a/backend/integration/superTabTeam.test.ts b/backend/integration/superTabTeam.test.ts
index c322afe8f..2c7eb8304 100644
--- a/backend/integration/superTabTeam.test.ts
+++ b/backend/integration/superTabTeam.test.ts
@@ -1366,3 +1366,59 @@ describe('teammates\' work in a machine owner\'s own account', () => {
expect((off as unknown as { teamWork: { ownAccount?: string } }).teamWork.ownAccount).toBeUndefined()
})
})
+
+// Task #4248 (finding 7 of #4212): a PM from before Swarm v3 still running in its person's Harness Team account. Its team sign-in
+// still reaches nothing in a main account, so it neither assigns nor starts there; it is told so in words that say who moves it
+// and how, and that move (Switch PM to its person's own computer, where it starts agents in their own account) works.
+describe('a PM still in a Harness Team account', () => {
+ const capable = (generation: string) => ({ ...reading(generation), capabilities: ['leadStart', 'leadSwitch'] }) as Parameters<SuperTabStore['observeMachine']>[3]
+ /** The fixture, with the person's own Mac reporting and their project's PM on their Team machine, started there by the person as
+ * before Swarm v3 and settled by its team session. */
+ async function teamPm() {
+ const f = await fixture()
+ await run(f.tab, { type: 'machine.contribute', machineId: 'personal-mac', name: 'MacBook Pro', cwd: '/work', scope: 'swarm', engines: ['codex'], maxAgents: 4 }, person)
+ const own = (await poolRows(store, person, 'personal-mac')).find(p => p.tabId === f.tab)!.machine.generation
+ await store.observeMachine(person, f.tab, 'personal-mac', capable(own))
+ await run(f.tab, { type: 'machine.contribute', machineId: 'team-mac', name: 'MacBook Pro · Team', cwd: '/team', scope: 'swarm', engines: ['codex'], maxAgents: 4 }, person)
+ const generation = (await poolRows(store, team, 'team-mac')).find(p => p.tabId === f.tab)!.machine.generation
+ await store.observeMachine(team, f.tab, 'team-mac', capable(generation))
+ const pm = await beforeV3(f.tab, generation, async () => {
+ const startId = String((await asBeforeV3('team-mac', () => run(f.tab, { type: 'lead.start', projectId: f.own, machineId: 'team-mac', engine: 'codex',
+ repositoryUrl: 'https://github.com/example/own' }, person))).result.startId)
+ await hostRun(f.tab, { type: 'agent.startDispatch', startId })
+ const id = String((await hostRun(f.tab, { type: 'agent.started', startId, harnessId: `team-pm-${randomUUID()}`, configuration: config })).result.agentId)
+ await hostRun(f.tab, { type: 'agent.startSettled', startId, warning: null })
+ return id
+ })
+ await store.observeMachine(team, f.tab, 'team-mac', capable(generation))
+ const project = (await store.read(person, f.tab)).state.projects!.find(p => p.id === f.own)!
+ return { ...f, pm, leadChat: project.leadConversationId }
+ }
+ const MOVE = { code: 'PM_IN_TEAM_ACCOUNT', status: 403, message: expect.stringMatching(/Harness Team account.*Switch PM.*own computer/s) }
+
+ it('is refused assigning or starting an agent with how to move it, and keeps coordinating', async () => {
+ const f = await teamPm()
+ await expect(run(f.tab, { type: 'work.assign', conversationId: f.personalGroup, agentId: f.personal }, team, f.pm)).rejects.toMatchObject(MOVE)
+ for (const machineId of ['personal-mac', 'team-mac']) {
+ await expect(run(f.tab, { type: 'agent.start', request: { conversationId: f.personalGroup, machineId, engine: 'codex', name: 'Builder',
+ cwd: machineId === 'team-mac' ? '/team' : `/work/${f.own}`, worktree: false, requirements } }, team, f.pm), machineId).rejects.toMatchObject(MOVE)
+ }
+ // An agent of the Team account that is no PM keeps the plain refusal.
+ await expect(run(f.tab, { type: 'work.assign', conversationId: f.personalGroup, agentId: f.personal }, team, f.builder)).rejects.toMatchObject(LIMITED)
+ // Naming another project's PM, one not on this Team computer, tells it nothing of that project (review of #3476).
+ const other = run(f.tab, { type: 'work.assign', conversationId: f.personalGroup, agentId: f.personal }, team, f.lead)
+ await expect(other).rejects.not.toMatchObject({ code: 'PM_IN_TEAM_ACCOUNT' })
+ await expect(other).rejects.not.toMatchObject({ message: expect.stringContaining('Switch PM') })
+ // Coordinating stays: it posts in its project.
+ await run(f.tab, { type: 'message.send', conversationId: f.leadChat, text: 'The footer task needs a Switch PM before I can assign it.', replyTo: null,
+ recipientIds: [] }, team, f.pm)
+ })
+
+ it('moves to its person\'s own computer with Switch PM, and the crew dispatch says why it waits until then', async () => {
+ const f = await teamPm()
+ expect((await store.dispatchCrew(f.tab)).skipped).toMatchObject({ PM_IN_TEAM_ACCOUNT: 1 })
+ await run(f.tab, { type: 'lead.switch', projectId: f.own, engine: 'codex', profileId: 'default', machineId: 'personal-mac' }, person)
+ expect((await poolRows(store, person, 'personal-mac')).find(p => p.tabId === f.tab)!.leadStarts)
+ .toEqual([expect.objectContaining({ request: expect.objectContaining({ machineId: 'personal-mac', conversationId: f.leadChat }) })])
+ })
+})
diff --git a/backend/integration/superTabV3Flows.test.ts b/backend/integration/superTabV3Flows.test.ts
new file mode 100644
index 000000000..63b47f7ca
--- /dev/null
+++ b/backend/integration/superTabV3Flows.test.ts
@@ -0,0 +1,97 @@
+import { randomUUID } from 'node:crypto'
+import { execFile } from 'node:child_process'
+import { promisify } from 'node:util'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { afterAll, beforeAll, describe, expect, it } from 'vitest'
+import { PrismaClient } from '@prisma/client'
+import { MongoMemoryReplSet } from 'mongodb-memory-server-core'
+import type { AuthUser } from '../src/lib/ssoAuth.js'
+import { SuperTabStore } from '../src/superTabs/store.js'
+import { commandSchema } from '../src/superTabs/commands.js'
+import { SwarmReads } from '../src/superTabs/read/service.js'
+import { HostReads } from '../src/superTabs/read/host.js'
+
+// Task #4248, from the v3 flows audit (#4212): what a member who joined with their own computer meets, through the store.
+let db: PrismaClient, replica: MongoMemoryReplSet
+const owner: AuthUser = { sub: '610000000000000000000001', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const member: AuthUser = { sub: '610000000000000000000002', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }
+const configuration = { engine: 'codex', model: 'fixture', effort: 'high', contextWindow: 200000, engineVersion: 'fixture' }
+
+beforeAll(async () => {
+ replica = await MongoMemoryReplSet.create({ binary: { version: '7.0.24', downloadDir: join(tmpdir(), 'harness-super-tab-mongodb-binaries') },
+ replSet: { count: 1, ip: '127.0.0.1', storageEngine: 'wiredTiger' } })
+ const uri = replica.getUri(`swarm_v3_flows_${randomUUID().replaceAll('-', '_')}`)
+ await promisify(execFile)(join(process.cwd(), 'node_modules/.bin/prisma'), ['db', 'push', '--skip-generate'], {
+ env: { ...process.env, DATABASE_URL: uri }, timeout: 60000,
+ })
+ db = new PrismaClient({ datasources: { db: { url: uri } } })
+ for (const user of [owner, member]) {
+ await db.user.create({ data: { id: user.sub, externalId: `fixture-${user.sub}`, email: user.email, autonomousEnv: 'prod' } })
+ await db.machine.create({ data: { machineId: user.sub, userId: user.sub, apiKey: `fixture-${user.sub}`, managerId: 'fixture', autonomousEnv: 'prod', authMode: 'remote' } })
+ }
+})
+afterAll(async () => { await db?.$disconnect(); await replica?.stop() })
+
+/** The owner's Swarm with the member in it, their computer listed as Desktop's join lists it, and reporting. */
+async function joined() {
+ const store = new SuperTabStore(db, Date.now, null, { readCache: null }), reads = new SwarmReads(store)
+ const tab = (await store.create(owner, randomUUID(), 'Flows', 'public')).id
+ const execute = (command: unknown, user = owner, asAgentId?: string, hostMachineId?: string) =>
+ store.execute(user, tab, { operationId: randomUUID(), command: commandSchema.parse(command) }, asAgentId, hostMachineId)
+ const invite = await execute({ type: 'invite.create', email: member.email, role: 'collaborator', conversationId: 'lead' })
+ await execute({ type: 'invite.accept', inviteId: invite.result.inviteId }, member)
+ // Desktop's join (agent_launcher.dart) lists the computer with teamAccountOnly, as clients from before v3 did too.
+ await execute({ type: 'machine.contribute', machineId: member.sub, name: 'Member computer', cwd: '/fixture', scope: 'swarm', engines: ['codex'],
+ maxAgents: 4, agents: 'memory', teamAccountOnly: true }, member)
+ const running: string[] = []
+ const report = async () => {
+ const own = (await new HostReads(store).changes(member, member.sub, { full: true })).tabs.find(row => row.tabId === tab)
+ if (!own || !('pool' in own) || !own.pool) throw new Error('The member computer has no host pool')
+ await store.observeMachine(member, tab, member.sub, { generation: own.pool.machine.generation, resources: { cpuPercent: 10, memoryTotalBytes: 32e9,
+ memoryUsedBytes: 4e9, diskFreeBytes: 120e9, diskTotalBytes: 500e9, projectDiskFreeBytes: 120e9, deviceType: 'Laptop', chip: 'Fixture', os: 'macOS',
+ gpuPercent: null }, quotas: [], tools: {}, runningHarnessIds: [...running], stoppedHarnessIds: [], capabilities: ['regularAgent'] })
+ }
+ await report()
+ const host = (command: unknown) => execute(command, member, undefined, member.sub)
+ const launch = async (startId: string) => {
+ await host({ type: 'agent.startDispatch', startId })
+ const harnessId = randomUUID(); running.push(harnessId)
+ const id = String((await host({ type: 'agent.started', startId, harnessId, configuration })).result.agentId)
+ await host({ type: 'agent.startSettled', startId, warning: null })
+ await report()
+ return id
+ }
+ return { store, reads, tab, execute, launch }
+}
+
+describe('a Regular agent\'s own chat (#4212 finding 1)', () => {
+ it('is in its person\'s read, opens, takes read marks, and carries messages both ways', async () => {
+ const f = await joined()
+ const made = await f.execute({ type: 'agent.new', kind: 'regular', name: 'Worker', machineId: member.sub, engine: 'codex' }, member)
+ const chat = String(made.result.conversationId), worker = await f.launch(String(made.result.startId))
+
+ expect((await f.store.read(member, f.tab)).state.conversations.map(c => c.id)).toContain(chat)
+ expect(JSON.stringify((await f.reads.firstLoad(member, f.tab)))).toContain(chat)
+ const asked = await f.execute({ type: 'message.send', conversationId: chat, text: 'Fix the footer', replyTo: null, recipientIds: [] }, member)
+ expect((await f.store.deliveries(member, f.tab, worker)).map(row => row.messageId)).toContain(asked.result.messageId)
+ await f.execute({ type: 'message.send', conversationId: chat, text: 'The footer overlaps the menu below 600 px; I am moving it under the links.', replyTo: null, recipientIds: [] }, member, worker)
+ const opened = await f.store.messages(member, f.tab, chat, {})
+ expect(JSON.stringify(opened)).toContain('under the links')
+ await f.reads.markRead(member, f.tab, chat, 2)
+
+ // Still nobody else's: the Swarm's owner neither reads nor opens it.
+ expect((await f.store.read(owner, f.tab)).state.conversations.map(c => c.id)).not.toContain(chat)
+ await expect(f.store.messages(owner, f.tab, chat, {})).rejects.toMatchObject({ code: 'NOT_FOUND' })
+ })
+})
+
+describe('a member\'s computer listed as they joined (#4212 finding 8)', () => {
+ it('reads as taking the owner\'s projects\' work, so the route keeps the member\'s own agents', async () => {
+ const f = await joined()
+ const row = (await f.store.read(owner, f.tab)).state.machines!.find(m => m.machineId === member.sub) as { teamWork?: unknown }
+ expect(row.teamWork).toEqual({ allowed: true })
+ const derived = (await f.reads.firstLoad(owner, f.tab)) as unknown as { derived?: { machines?: Record<string, { teamWork: unknown }> } }
+ expect(derived.derived?.machines?.[member.sub]?.teamWork).toEqual({ allowed: true })
+ })
+})
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index caff8e65b..c46c3ea55 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -4457,8 +4457,9 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,
&& worksInProjectChat(state, group, id) ? id : null
const answered = chatWorker(replyAgent)
const below = !command.replyTo && context.above?.author.kind === 'agent' ? chatWorker(context.above.author.id) : null
- // A Buddy chat has no Lead: its owner talks to its Buddy.
+ // A Buddy chat has no Lead: its owner talks to its Buddy. A Regular agent's chat has none either: its person talks to that agent.
const automatic = actor.kind === 'person' ? (isBuddyChat(group) ? (session?.inSession ? session.to : mainBuddyOf(state, group)?.id ?? null)
+ : isAgentChat(group) ? group.agentIds[0] ?? null
: answered ?? (replyAgent && group.agentIds.includes(replyAgent) ? replyAgent : group.leadId)) : toAssignee
// A person's reply to the agent whose assignment here is done reaches the coordinator too, and the agent still (Ken, #3114):
// his reply under Hawthorn3's "Done" in #3022 reached Hawthorn3 alone, whose work there was over.
diff --git a/backend/src/superTabs/computerMoves.test.ts b/backend/src/superTabs/computerMoves.test.ts
index b77544720..fdeae8de1 100644
--- a/backend/src/superTabs/computerMoves.test.ts
+++ b/backend/src/superTabs/computerMoves.test.ts
@@ -162,8 +162,9 @@ describe('a Mac whose own Harness Team account has not joined the Swarm yet', ()
const f = setup()
const pool = mac(f)
expect(joiningTeamMacs(f.state, [row('kelvin', 'kelvin-mac')])).toEqual(['kelvin-mac'])
- expect(machineTeamWork(f.state, pool, NOW, [], [], ['kelvin-mac'])?.code).toBe('TEAM_ACCOUNT_JOINING')
- expect(machineTeamWork(f.state, pool, NOW, [], [])?.code).toBe('TEAM_ACCOUNT_REQUIRED')
+ // Swarm v3 has no Team accounts (#4248): the Mac takes teammates' projects as itself meanwhile, through its person's own agents.
+ expect(machineTeamWork(f.state, pool, NOW, [], [], ['kelvin-mac'])).toBeNull()
+ expect(machineTeamWork(f.state, pool, NOW, [], [])).toBeNull()
})
it("is not joining with another account's Team account on it, one listed already, or no room for it", () => {
diff --git a/backend/src/superTabs/machines.ts b/backend/src/superTabs/machines.ts
index a0260c70a..6c3ece716 100644
--- a/backend/src/superTabs/machines.ts
+++ b/backend/src/superTabs/machines.ts
@@ -41,9 +41,9 @@ export interface ContributedMachine {
* the host says it cleaned up (machine.cleaned) or REMOVAL_FALLBACK_MS passes. An offline one leaves the list at once and
* its cleanup waits for its host (expireRemovals). No chat hears how it ended (#2742). */
removal?: { id: string; state: 'cleaning'; requestedAt: string }
- /** Added by Desktop as its person joined the Swarm, not lent to teammates by choice: their work runs here only through
- * its Harness Team account whose privacy check passed, whether or not the Swarm requires that everywhere
- * (teamWorkRefusal). Kept when the contribution is saved again; gone with the machine. */
+ /** Added by Desktop as its person joined the Swarm. Swarm v3 has no Team accounts, so it no longer keeps teammates' projects
+ * off it: its person's own agents take any project they read (teamWorkCheck; #4248, finding 8 of #4212). Kept, and kept
+ * when the contribution is saved again, only because Desktop's launch.dart still reads it; gone with the machine. */
teamAccountOnly?: true
/** Its owner's choice whether teammates' work may also run in their own account here (commands.ts machine.ownAccountWork,
* Scholes 11-04): who chose (the owner, whose word it is) and when. `allowed` lets a teammate's start run on this entry,
@@ -357,7 +357,7 @@ export function teamWorkRefusal(pool: ContributedMachine, now: number, teamRow =
// Its owner let teammates' work run in their own account here: their explicit choice wins over the Swarm-wide rule, for
// this machine only (River, 11-04).
if (ownAccountWork(pool)) return null
- if (!teamRow && reading?.sessionKind !== 'team' && !required && !pool.teamAccountOnly) return null
+ if (!teamRow && reading?.sessionKind !== 'team' && !required) return null
if (otherWorkspace) return { code: 'MACHINE_IN_OTHER_WORKSPACE', reason: `The Harness Team account on ${name} also serves another ${WORKSPACE_LABEL}'s Swarms, ${ONLY_OWN} here.` }
if (!reading || now - reading.receivedAt > MACHINE_FRESH_MS) {
// A Mac's team account goes by its Mac's name ("One machine"), and the Mac itself may well be online.
diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.ts
index 5b885e50a..05e3ef5f4 100644
--- a/backend/src/superTabs/projects.ts
+++ b/backend/src/superTabs/projects.ts
@@ -358,9 +358,10 @@ export function readConversation(state: SuperTabState, actor: Actor, conversatio
* (2026-10-26); this is the one place that decides it (design section 4.8). */
export const PRIVATE_VISIBLE_TO_OWNERS = false
-/** A Chat with PM from before Buddies replaced it (Ken, 10-29): a private conversation that is no Buddy chat. Nobody opens
- * one any more, and nobody reads one, the PM and its person included; its rows stay in the database. */
-export const isClosedPmChat = (group: Pick<Conversation, 'kind' | 'audience'>): boolean => !!group.audience && !isBuddyChat(group)
+/** A Chat with PM from before Buddies replaced it (Ken, 10-29): a private conversation that is no Buddy chat and no Regular agent's
+ * chat (#4248: counted as one, a Regular agent's chat was never listed or delivered). Nobody opens one any more, and nobody reads
+ * one, the PM and its person included; its rows stay in the database. */
+export const isClosedPmChat = (group: Pick<Conversation, 'kind' | 'audience'>): boolean => !!group.audience && !isBuddyChat(group) && !isAgentChat(group)
/** Who reads a conversation: nobody the removed Leads conversation (model.ts leadsRemoved); a project conversation's readers; and a Buddy
* chat's owner and Buddy (buddies.ts), the PM never. A closed Chat with PM is nobody's. A Buddy reads what its person
diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.ts
index a694a1316..a8e8dee02 100644
--- a/backend/src/superTabs/store.ts
+++ b/backend/src/superTabs/store.ts
@@ -570,6 +570,13 @@ const machineKey = (environment: string, machineId: string, ownerId: string) =>
export const teamByRecord = (state: SuperTabState, machineId: string): boolean =>
!!state.machines?.find(m => m.machineId === machineId)?.hostMachineId || state.agents.some(a => a.machineId === machineId && onTeamAccount(state, a))
/** A Team account's machine refused to its owner's own sign-in (notTeamMachine). */
+/** A PM from before Swarm v3 still in a Harness Team account, which assigns and starts no agent (store.ts teamCommand, #4248). */
+export const PM_IN_TEAM_ACCOUNT = 'PM_IN_TEAM_ACCOUNT'
+/** What such a PM is told: who moves it, and how (commands.ts lead.switch, which only the project's owner may run). */
+const pmInTeamAccount = (state: SuperTabState, project: SwarmProject): string =>
+ `This ${coordinatorNameOf(project)} runs in a Harness Team account, which assigns and starts no agents now. ${shownNameOf(state, project.ownerId) ?? 'The project\'s owner'} `
+ + 'moves it with Switch PM to their own computer, where it keeps its chat and tasks and starts agents in their own account. Until then it keeps coordinating.'
+
export const TEAM_HOST_ONLY = 'TEAM_HOST_ONLY'
export const TEAM_HOST_ONLY_MESSAGE = 'Only this computer\'s Harness Team account runs its Swarm agents. Its owner\'s own sign-in cannot act for them.'
@@ -826,7 +833,17 @@ export class SuperTabStore {
* or reading another machine's terminal stays refused, whatever account it runs in. Messages and work reports go to the
* Swarm as from any agent. An agent that is gone is left to the command's own answer.
*/
- private teamCommand(state: SuperTabState, team: string, user: AuthUser, command: Command): void {
+ private teamCommand(state: SuperTabState, team: string, user: AuthUser, command: Command, actorId?: string): void {
+ // A PM from before Swarm v3 still in a Team account (#4248, finding 7 of #4212): what it may not do is refused in words that
+ // say who moves it and how, since nothing else tells it; it keeps coordinating meanwhile. Only a PM on this Team computer: the
+ // agent a request names is not checked yet here, and another project's PM would read that project's names (review of #3476).
+ const pm = actorId && ['work.assign', 'conversation.agent', 'agent.start'].includes(command.type)
+ ? state.agents.find(a => a.id === actorId && a.machineId === team) : undefined
+ const led = pm && ledProject(state, pm.id)
+ if (led) {
+ logger.warn('[super-tab] team command refused', { tabId: state.id, command: command.type, teamMachineId: team, code: PM_IN_TEAM_ACCOUNT })
+ fail(PM_IN_TEAM_ACCOUNT, pmInTeamAccount(state, led), 403)
+ }
const refuse = (target?: Agent) => {
// Refusals were counted only from agents saying so in chat (15 lines in 10 days): the log says which command, and
// whether its target was in a Team account, so a workflow the check blocks shows up before people work around it.
@@ -1882,7 +1899,7 @@ export class SuperTabStore {
fail('FORBIDDEN', 'Only the execution host can confirm this removal.', 403)
}
if (hostMachineId && !['agent.startDispatch', 'agent.started', 'agent.startFailed', 'agent.startSettled', 'route.modelResult'].includes(command.type)) fail('FORBIDDEN', 'A host can only settle its queued starts.', 403)
- if (team !== null && !hostMachineId) this.teamCommand(original, team, user, command)
+ if (team !== null && !hostMachineId) this.teamCommand(original, team, user, command, asAgentId)
// A Team account's session is closed by its own team session: the Mac's owner is its machine owner too, and from an
// ordinary sign-in confirmed it, ending its hold with its data still there. A held one is on a Team account by
// definition, whatever the account row says now (review of #2142).
@@ -2623,7 +2640,7 @@ export class SuperTabStore {
}
try {
await this.agentGrant(tx, state, pm)
- if (onTeamAccount(state, pm)) this.teamCommand(state, pm.machineId, user, command)
+ if (onTeamAccount(state, pm)) this.teamCommand(state, pm.machineId, user, command, pm.id)
} catch (error) { return pmRefused(error) }
return { kind: 'agent', agentId, machineOwnerId: pm.machineOwnerId }
}
@@ -2728,6 +2745,13 @@ export class SuperTabStore {
if (periodic && !this.periodicDue(tabId, project.id, rules, now)) continue
this.rememberDispatch(tabId, project.id, now)
if (this.pmWaiting(tabId, state, project, now)) continue
+ const leadId = state.conversations.find(c => c.id === project.leadConversationId)?.leadId
+ const lead = leadId ? state.agents.find(a => a.id === leadId) : undefined
+ // Its PM is still in a Team account, which assigns no agent (teamCommand): counted while work waits, so the pass says why.
+ if (lead && onTeamAccount(state, lead)) {
+ if (openTasks(state, project.id, now).length) skipCode(PM_IN_TEAM_ACCOUNT)
+ continue
+ }
const free = freeCrew(state, project.id, rules, now)
if (!free.length) continue
for (const lane of laneCapacity(state, project.id, rules, now)) {
@@ -2735,8 +2759,6 @@ export class SuperTabStore {
total.waiting += lane.waiting
total.busy += lane.busy
}
- const leadId = state.conversations.find(c => c.id === project.leadConversationId)?.leadId
- const lead = leadId ? state.agents.find(a => a.id === leadId) : undefined
if (!lead) { skipCode('NO_PM'); continue }
// No one's sign-in: the Swarm's environment for its reads, and the PM as the actor (executeOnce asProjectPm).
const user: AuthUser = { sub: lead.machineOwnerId, email: '', autonomousEnv: row.autonomousEnv as AuthUser['autonomousEnv'], role: 'user' }
diff --git a/backend/src/superTabs/teamRouting.test.ts b/backend/src/superTabs/teamRouting.test.ts
index 226966507..129e0ffc7 100644
--- a/backend/src/superTabs/teamRouting.test.ts
+++ b/backend/src/superTabs/teamRouting.test.ts
@@ -542,12 +542,13 @@ describe('a machine added as its person joined', () => {
expect(f.state.starts).toHaveLength(2)
})
- it('says why in its reading, so routing leaves it out of a teammate\'s project', () => {
+ // Swarm v3 has no Team accounts (#4248, finding 8 of #4212): its reading no longer keeps routing off it for a teammate's
+ // project, so the route keeps its person's own agents; the pick itself is held to what its person reads (teamWorkCheck).
+ it('reads as taking teammates\' projects, as a machine contributed by hand does', () => {
const f = swarm()
f.run(joined, mate, contribution)
f.machine('joined-mac').observation = reading('computer')
- expect(machineTeamWork(f.state, f.machine('joined-mac'), NOW, [])?.code).toBe('TEAM_ACCOUNT_REQUIRED')
- // An ordinary machine contributed by hand takes it as before while the rule is not required.
+ expect(machineTeamWork(f.state, f.machine('joined-mac'), NOW, [])).toBeNull()
expect(machineTeamWork(f.state, f.machine('mate-mac'), NOW, [])).toBeNull()
})
diff --git a/backend/vitest.super-tabs.config.ts b/backend/vitest.super-tabs.config.ts
index db7c55889..4c8adec0f 100644
--- a/backend/vitest.super-tabs.config.ts
+++ b/backend/vitest.super-tabs.config.ts
@@ -8,5 +8,5 @@ export default defineConfig({ test: { include: ['integration/superTabProposalCar
'integration/superTabBuddyProbes.test.ts', 'integration/superTabBuddySessions.test.ts', 'integration/superTabSwarmBuddy.test.ts', 'integration/superTabPersonalLead.test.ts', 'integration/superTabCosts.test.ts', 'integration/harnessSharesList.test.ts', 'integration/harnessSharesIndexPlan.test.ts', 'integration/atlasSnapshot.test.ts', 'integration/queryStats.test.ts',
'integration/superTabEvidence.test.ts', 'integration/superTabAttemptModels.test.ts', 'integration/superTabNamedReads.test.ts', 'integration/swarmSweepPlans.test.ts', 'integration/overdueDecisions.test.ts', 'integration/workerIndexPlans.test.ts', 'integration/superTabReflection.test.ts', 'integration/superTabScorecard.test.ts',
'integration/superTabMessagePages.test.ts', 'integration/superTabDeliveryCompaction.test.ts', 'integration/superTabNoticeDigest.test.ts', 'integration/superTabPmSchedule.test.ts', 'integration/superTabDigestHour.test.ts', 'integration/superTabCommandLoads.test.ts', 'integration/superTabCommandReads.test.ts', 'integration/superTabThreads.test.ts', 'integration/superTabMachineRemovals.test.ts',
- 'integration/superTabInstructions.test.ts', 'integration/superTabInstructionsRebase.test.ts', 'integration/superTabInstructionsRestore.test.ts', 'integration/superTabProjectRules.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabTaskLines.test.ts', 'integration/superTabDeletion.test.ts', 'integration/communityReports.test.ts', 'integration/superTabMachineNames.test.ts', 'integration/superTabComputerMoves.test.ts', 'integration/superTabTagsClear.test.ts', 'integration/swarmAgentTombstones.test.ts', 'integration/superTabPullRequestEvents.test.ts', 'integration/superTabTimeChecks.test.ts', 'integration/superTabReleases.test.ts', 'integration/superTabReviewSteps.test.ts', 'integration/superTabMergeTrain.test.ts', 'integration/superTabProposals.test.ts', 'integration/superTabCanChat.test.ts', 'integration/superTabRequestReads.test.ts', 'integration/superTabVoiceMessages.test.ts', 'integration/superTabThumbnails.test.ts', 'integration/superTabProjectChatWorkers.test.ts', 'integration/prismaQueryTiming.test.ts', 'integration/secondaryReads.test.ts', 'integration/pushDevices.test.ts', 'integration/crewDispatch.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/noDefaultDigest.test-support.ts', 'integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],
+ 'integration/superTabInstructions.test.ts', 'integration/superTabInstructionsRebase.test.ts', 'integration/superTabInstructionsRestore.test.ts', 'integration/superTabProjectRules.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabTaskLines.test.ts', 'integration/superTabDeletion.test.ts', 'integration/communityReports.test.ts', 'integration/superTabMachineNames.test.ts', 'integration/superTabComputerMoves.test.ts', 'integration/superTabTagsClear.test.ts', 'integration/swarmAgentTombstones.test.ts', 'integration/superTabPullRequestEvents.test.ts', 'integration/superTabTimeChecks.test.ts', 'integration/superTabReleases.test.ts', 'integration/superTabReviewSteps.test.ts', 'integration/superTabMergeTrain.test.ts', 'integration/superTabProposals.test.ts', 'integration/superTabCanChat.test.ts', 'integration/superTabRequestReads.test.ts', 'integration/superTabVoiceMessages.test.ts', 'integration/superTabThumbnails.test.ts', 'integration/superTabProjectChatWorkers.test.ts', 'integration/prismaQueryTiming.test.ts', 'integration/secondaryReads.test.ts', 'integration/pushDevices.test.ts', 'integration/crewDispatch.test.ts', 'integration/superTabV3Flows.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/noDefaultDigest.test-support.ts', 'integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],
fileParallelism: false, env: { NODE_ENV: 'test', HARNESS_CREDENTIAL_ENCRYPTION_KEY: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' } } })
diff --git a/docs/plans/2026-11-07-v3-flow-bugs-plan.md b/docs/plans/2026-11-07-v3-flow-bugs-plan.md
new file mode 100644
index 000000000..bda7cf42f
--- /dev/null
+++ b/docs/plans/2026-11-07-v3-flow-bugs-plan.md
@@ -0,0 +1,68 @@
+# v3 flow bugs (#1, #7, #8 of the #4212 audit) Implementation Plan
+
+> Written by the writing-plans skill; the Engineer implements it task by task, test first, as the project's instructions say.
+
+**Goal:** A Regular agent's own chat is read and delivered; a member's own agents reach the PM's route for projects they read; a PM still in a Harness Team account gets one clear refusal that says how to move it, and the move works.
+
+**Architecture:** Three backend-only fixes under `backend/src/superTabs/`. The read rule for private chats stops counting agent chats as closed Chat with PM. The machine read stops turning the join's `teamAccountOnly` mark into a Team-account refusal. A team session's refused coordination commands get a named refusal for a PM, and the crew dispatch says why it skips that PM's project. CLI 0.5.63 needs no change: it reads `teamWork` from the backend.
+
+**Tech Stack:** TypeScript, vitest, MongoDB memory replica set (integration tests through `SuperTabStore`).
+
+**Spec:** Task #4248 brief; findings 1, 7 and 8 in task #4212.
+
+## Global Constraints
+
+- Verify each finding first. Test first. Never read or print a secret or login.
+- Owns: `backend/src/superTabs/`, `cli/src/superTabs/` (tests in `backend/integration/`).
+- A real-store test per finding.
+- A team session still reaches nothing in a main account (task #4120, `integration/superTabTeam.test.ts` "still reaches nothing in a main account").
+- Clients from the last 30 days keep working: `machine.contribute` still takes `teamAccountOnly`, and the stored mark stays (Desktop `launch.dart` reads it).
+
+## Review Focus
+
+- A Regular agent's chat after its person leaves and rejoins: still nobody's (the audience generation check stays).
+- A closed Chat with PM from before Buddies: still nobody's.
+- A computer listed on join whose person cannot read the project: still refused at the pick (`teamWorkCheck`), only the per-machine read changes.
+- A Team account's own pool (`hostMachineId`) still reads as refused.
+- A Team-account agent that is not a PM keeps the plain team-session refusal.
+
+---
+
+### Task 1: A Regular agent's own chat is read and delivered (#1)
+
+**Files:**
+- Modify: `backend/src/superTabs/projects.ts` (`isClosedPmChat`)
+- Test: `backend/integration/superTabV3Flows.test.ts` (new)
+
+- [x] **Step 1: Write the failing test** `a Regular agent's own chat is in its person's read, opens, takes read marks, and reaches the agent`: member joins, lists a computer, `agent.new` kind regular, agent started; `store.read(member)` lists the chat; `readConversation` through the store answers; a member message there is delivered to the agent (delivery row exists and the agent claims it); the agent's reply is in the member's read.
+- [x] **Step 2: Run it** `npx vitest run integration/superTabV3Flows.test.ts` — FAIL (chat missing from the read).
+- [x] **Step 3: Implement** `isClosedPmChat(group)`: false for an agent chat (`isAgentChat`).
+- [x] **Step 4: Run it** — PASS. Run `src/superTabs/agentNew.test.ts`, `projects.test.ts`, `decisions.test.ts`.
+- [x] **Step 5: Commit** test, then fix.
+
+### Task 2: A member's computer listed on join reads as taking projects' work (#8)
+
+**Files:**
+- Modify: `backend/src/superTabs/machines.ts` (`teamWorkRefusal`, `teamAccountOnly` comment)
+- Test: `backend/integration/superTabV3Flows.test.ts`; unit tests that pinned the old rule (`ownAccountWork.test.ts`, `teamRouting.test.ts` and others the run names)
+
+- [x] **Step 1: Write the failing test** `a member's computer listed as they joined reads as taking the owner's projects' work`: member contributes with `teamAccountOnly: true` and reports a reading; `store.read(owner).state.machines` row for it has `teamWork: { allowed: true }`; the same through `SwarmReads.firstLoad` derived machines.
+- [x] **Step 2: Run it** — FAIL (`TEAM_ACCOUNT_REQUIRED`).
+- [x] **Step 3: Implement**: drop `pool.teamAccountOnly` from `teamWorkRefusal`'s early return; the mark is kept for older Desktop clients only.
+- [x] **Step 4: Run it** — PASS; update the unit tests that asserted the old refusal.
+- [x] **Step 5: Commit** test, then fix.
+
+### Task 3: A PM in a Team account is told how to move, and the move works (#7)
+
+**Files:**
+- Modify: `backend/src/superTabs/store.ts` (`teamCommand` takes the acting agent; `dispatchCrew` skip)
+- Test: `backend/integration/superTabTeam.test.ts`
+
+**Interfaces:**
+- Produces: refusal code `PM_IN_TEAM_ACCOUNT` (403): "This {PM name} runs in a Harness Team account, which starts and assigns no agents now. {owner} moves it to their own computer with Switch PM; it keeps its chat and tasks, and starts agents there in their own account. Until then it keeps coordinating."
+
+- [x] **Step 1: Write the failing test** `a PM in a Team account is refused assigning or starting with how to move it, and its owner's Switch PM moves it to their own computer`: a PM of the person's project on their Team machine; as the team session, `work.assign` of the person's own agent and `agent.start` on the person's own computer and on the Team machine are refused with `PM_IN_TEAM_ACCOUNT` and the text naming the person and Switch PM; `lead.switch` by the person to their own computer queues a start there; the dispatch pass skips the project with `PM_IN_TEAM_ACCOUNT`.
+- [x] **Step 2: Run it** — FAIL (`TEAM_SESSION_LIMITED` / `TEAM_ACCOUNTS_REMOVED`, no skip code).
+- [x] **Step 3: Implement** in `teamCommand(state, team, user, command, asAgentId?)`: when the actor leads a project, `work.assign`, `conversation.agent` and `agent.start` are refused with `PM_IN_TEAM_ACCOUNT`; other agents keep `TEAM_SESSION_LIMITED`. `dispatchCrew` counts `PM_IN_TEAM_ACCOUNT` for a project whose PM is on a Team account.
+- [x] **Step 4: Run it** — PASS; run the rest of `superTabTeam.test.ts`.
+- [x] **Step 5: Commit** test, then fix.