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 GitHub: each task names whom its pull requests are for (its requester), not the project owner (#2492)

0xken15905738b8d6eb
diff --git a/backend/integration/superTabGithub.test.ts b/backend/integration/superTabGithub.test.ts
index f6b69bbc0..4c167cc2c 100644
--- a/backend/integration/superTabGithub.test.ts
+++ b/backend/integration/superTabGithub.test.ts
@@ -93,6 +93,16 @@ async function fresh(options: { github?: boolean; approveAll?: boolean; signIn?:
}
type Env = Awaited<ReturnType<typeof fresh>>
+/** [person] joins the owner's Swarm [tab] as a collaborator. */
+async function invited(env: Env, tab: string, person: AuthUser) {
+ const invitation = await env.run(tab, { type: 'invite.create', email: person.email, role: 'collaborator', conversationId: 'lead' } as Command)
+ await env.run(tab, { type: 'invite.accept', inviteId: invitation.result.inviteId as string } as Command, person)
+}
+/** The owner's account without an email for this test, as an account can be: the owner's email is the token's gate. */
+async function ownerWithoutEmail() {
+ await db.user.update({ where: { id: owner.sub }, data: { email: '' } })
+ onTestFinished(async () => { await db.user.update({ where: { id: owner.sub }, data: { email: owner.email } }) })
+}
/** The team account switched on for this test, in the Swarms of [owners] or everyone's. */
function teamAccounts(owners = '') {
vi.stubEnv('SWARM_TEAM_ACCOUNT_REQUIRED', '1')
@@ -138,6 +148,33 @@ describe('the GitHub token endpoint', () => {
expect(read.json().data.githubApp).toBe(true)
})
+ // Security reviews 1 and 2 of #2492: who asked for a group changes no token. The owner's email is the gate and the commits
+ // name the owner, as on main; only each task's message names its requester (projects.ts requestedByLine).
+ it('gives the token and owner trailers whoever asked, and refuses it when the owner has no email, though the requester has one', async () => {
+ const env = await fresh()
+ const tab = (await env.store.create(owner, randomUUID(), 'Pilot')).id
+ await env.run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'owner-mac', harnessId: randomUUID(), name: 'Lead',
+ configuration: config, lead: true, project: { cwd: '/work/app', repositoryUrl: 'https://github.com/example/app.git' } } as Command)
+ await invited(env, tab, host)
+ const group = String((await env.run(tab, { type: 'conversation.create', title: 'Add search', brief: 'Add a search field', checks: [],
+ requesterId: host.sub } as Command)).result.conversationId)
+ const worker = String((await env.run(tab, { type: 'agent.add', conversationId: group, machineId: 'owner-mac', harnessId: randomUUID(),
+ name: 'Builder', configuration: config, lead: false } as Command)).result.agentId)
+ await env.run(tab, { type: 'work.assign', conversationId: group, agentId: worker } as Command)
+ const given = await ask(env, tab, worker, 'owner-mac', owner)
+ expect(given.statusCode, given.body).toBe(200)
+ expect(given.json().data).toMatchObject({ requestedBy: { name: 'Olive Owner', email: owner.email },
+ pullRequestLine: `Requested by Olive Owner (${owner.email}) through Harness.` })
+ expect(given.json().data.trailers[0]).toBe(`Co-authored-by: Olive Owner <${owner.email}>`)
+ expect(given.body).not.toContain(host.email)
+ await ownerWithoutEmail()
+ const refused = await ask(env, tab, worker, 'owner-mac', owner)
+ expect(refused.statusCode, refused.body).toBe(404)
+ // Refused as on main (here before the owner's own check, as this owner's account no longer matches): no token, whoever asked.
+ expect(refused.json().error.code).toBe('NOT_FOUND')
+ expect(env.github.calls.filter(c => c.path.endsWith('/access_tokens'))).toHaveLength(1)
+ })
+
// A Harness Team account has no git identity of its own (PR #1934, 2026-10-28): its commits are the app's bot account's.
it('names the app\'s bot account as who a Harness Team account\'s commits are by', async () => {
const env = await fresh()
@@ -243,7 +280,8 @@ describe('a queued start\'s preparation token', () => {
projectDiskFreeBytes: 120e9, deviceType: 'Laptop', chip: 'Fixture CPU', os: 'macOS', gpuPercent: null }, quotas: [], tools: { git: true },
runningHarnessIds: [], stoppedHarnessIds: [] }
/** The owner's project on github.com, with a start queued on [machineId], a machine its owner [contributor] added to the Swarm. */
- async function queued(env: Env, machineId = 'gh-pool', contributor = host, repositoryUrl: string | null = 'https://github.com/example/app.git') {
+ async function queued(env: Env, machineId = 'gh-pool', contributor = host, repositoryUrl: string | null = 'https://github.com/example/app.git',
+ requester?: AuthUser) {
const tab = (await env.store.create(owner, randomUUID(), 'Pool')).id
await env.run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'owner-mac', harnessId: randomUUID(), name: 'Lead',
configuration: config, lead: true, project: { cwd: '/work/app', repositoryUrl } } as Command)
@@ -269,7 +307,10 @@ describe('a queued start\'s preparation token', () => {
const pool = (await poolRows(env.store, team, machineId)).find(p => p.tabId === tab)!
await env.store.observeMachine(team, tab, machineId, { generation: pool.machine.generation, ...observed, privacy: { mode: 'dedicated' } })
}
- const startId = String((await env.run(tab, { type: 'agent.start', request: { conversationId: 'lead', machineId, engine: 'codex', name: 'Builder',
+ // A group [requester] asked for, its start's conversation; else the Lead's. The contributor joined above.
+ const conversationId = requester ? String((await env.run(tab, { type: 'conversation.create', title: 'Add search', brief: 'Add a search field',
+ checks: [], requesterId: requester.sub } as Command)).result.conversationId) : 'lead'
+ const startId = String((await env.run(tab, { type: 'agent.start', request: { conversationId, machineId, engine: 'codex', name: 'Builder',
cwd: '/swarm-root/lead', permissionMode: 'full', worktree: true, requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } } } as Command)).result.startId)
return { tab, startId }
}
@@ -454,6 +495,20 @@ describe('a queued start\'s preparation token', () => {
expect(none.json().error).toMatchObject({ code: 'GITHUB_APPROVAL_NOT_CONFIGURED' })
})
+ // Security reviews 1 and 2 of #2492: a start's preparation names the owner whoever asked, as on main, and an owner without an
+ // email answers it empty, which fails the start on its host (cli/src/superTabs/projectFolder.ts).
+ it('names the owner for a start whoever asked for its group, and nobody when the owner has no email', async () => {
+ const env = await fresh()
+ const { tab, startId } = await queued(env, 'gh-pool', host, undefined, host)
+ const response = await prepare(env, tab, startId)
+ expect(response.statusCode, response.body).toBe(200)
+ expect(response.json().data).toMatchObject({ github: true, repository: 'example/app', requestedBy: { name: 'Olive Owner', email: owner.email } })
+ await ownerWithoutEmail()
+ const empty = await prepare(env, tab, startId)
+ expect(empty.statusCode, empty.body).toBe(200)
+ expect(empty.json().data.requestedBy).toEqual({ name: 'Olive Owner', email: '' })
+ })
+
it('answers no token for the machine owner\'s own project, unless its host asks for one anyway', async () => {
const env = await fresh()
const { tab, startId } = await queued(env, 'owner-pool', owner)
diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.ts
index fcd530767..7a703758f 100644
--- a/backend/src/superTabs/commands.test.ts
+++ b/backend/src/superTabs/commands.test.ts
@@ -90,7 +90,9 @@ describe('five-part tasks', () => {
const f = fixture(), group = f.group(), worker = f.add('worker', 'owner', group)
f.run(commandSchema.parse({ type: 'work.define', conversationId: group, task, checks }))
const delivery = f.run({ type: 'work.assign', conversationId: group, agentId: worker }).messages[0]!
- expect(delivery.text).toBe(`${brief}\n\nAcceptance checks:\n- Reconnect preserves edits`)
+ // The worker runs on another person's machine (host-owner's): the task names whom its pull requests are for (projects.ts
+ // requestedByLine, security review 2 of #2492).
+ expect(delivery.text).toBe(`${brief}\n\nAcceptance checks:\n- Reconnect preserves edits\n\nStart each pull request body with: Requested by [email protected] through Harness.`)
expect(delivery.recipients).toEqual([worker])
})
@@ -4112,12 +4114,12 @@ describe('checks are information', () => {
f.run(commandSchema.parse({ type: 'work.define', conversationId: group, brief: 'Fix the install docs.', checks: [] }), f.leadActor)
f.run({ type: 'conversation.agent', conversationId: group, agentId: f.worker, present: true, lead: false }, f.leadActor)
const assigned = f.run({ type: 'work.assign', conversationId: group, agentId: f.worker })
- expect(assigned.messages.find(m => m.recipients.includes(f.worker))!.text).toBe('Fix the install docs.')
+ expect(assigned.messages.find(m => m.recipients.includes(f.worker))!.text).toBe('Fix the install docs.\n\nStart each pull request body with: Requested by [email protected] through Harness.')
// A task with no brief at all is assigned too: its title is what its agent reads.
const bare = f.run({ type: 'conversation.create', title: 'Look into the flaky test', brief: '', checks: [] }, f.leadActor).result.conversationId as string
const other = f.add('other', 'owner', bare)
expect(f.run({ type: 'work.assign', conversationId: bare, agentId: other }).messages.find(m => m.recipients.includes(other))!.text)
- .toBe('Look into the flaky test')
+ .toBe('Look into the flaky test\n\nStart each pull request body with: Requested by [email protected] through Harness.')
})
it('keeps a failed check as a finding', () => {
diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.ts
index c4cf8a3a7..ae231b797 100644
--- a/backend/src/superTabs/commands.ts
+++ b/backend/src/superTabs/commands.ts
@@ -34,7 +34,7 @@ import { shipNotice, shippedAt } from './ship.js'
import { assignedNotice, tellBuddies } from './buddyNews.js'
import { bindPullRequestCards, bindTaskCard, pullRequestCard, recordCardMerged } from './cards.js'
import { avatarChoice, setAgentAvatar, setMemberAvatar, setStatus, statusSchema, type AvatarUpload } from './profile.js'
-import { BUILT_IN_ROLE_DEFAULTS, agentProjectId, audienceOf, canReadProject, deleteProject, isConfidential, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectAgent, projectMembers, projectOf, projectsOf, readAgent, readConversation, readProject, sameProject, sharedWithLeads, withRoleDefaults, type SwarmProject, PROJECT_STATUS_MAX } from './projects.js'
+import { BUILT_IN_ROLE_DEFAULTS, agentProjectId, audienceOf, canReadProject, deleteProject, isConfidential, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectAgent, projectMembers, projectOf, projectsOf, readAgent, readConversation, readProject, requestedByLine, sameProject, sharedWithLeads, withRoleDefaults, type SwarmProject, PROJECT_STATUS_MAX } from './projects.js'
import { BUDDY_SESSION_CAPABILITY, chatOwner, endSessionEntry, entryProject, liveSessions, mainBuddyOf, MAX_BUDDY_SESSIONS, MAX_SESSION_WAITING, requireChatOwner, SESSION_ENDED_KIND, sessionAgentsOf, sessionOf, setSessions, type SessionEndReason } from './buddySessions.js'
import { BUDDY_REQUIREMENTS, buddyChatId, buddyReady, chosenBuddyName, isBuddy, isBuddyChat, isSwarmBuddy, isSwarmBuddyChat, MAX_PROPOSAL_ASKS, MAX_PROPOSAL_ATTACHMENTS, openBuddyChat, openSwarmBuddyChat, PM_LINE_KIND, PROPOSAL_ASK_MS, proposalText, renameBuddy, requireBuddyCommand, swarmBuddyChatId } from './buddies.js'
import { BUDDY_OWN_MACHINE_REFUSAL, CODEX_BUDDY_REFUSAL } from './buddyContract.js'
@@ -2722,9 +2722,12 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma
d => started(d) ? d.final! : { kind: 'member', agentId: worker.id, machineId: worker.machineId }, command.overrideReason, operationId)
if (override) routeNote = { decisionId: decision.id, text: instead(`assigned ${worker.name}`) }
}
- // The brief (a task with none: its title), and its acceptance checks when it has some: checks are information.
+ // The brief (a task with none: its title), and its acceptance checks when it has some: checks are information. Then
+ // whom this task's pull requests are for, from its own requester (projects.ts requestedByLine).
+ const requestedBy = requestedByLine(state, home, group, worker)
message(group.id, [group.brief || group.title,
- ...group.checks.length ? [`Acceptance checks:\n${group.checks.map(c => `- ${c.description}`).join('\n')}`] : []].join('\n\n'), [worker.id], null, SYSTEM_ROW)
+ ...group.checks.length ? [`Acceptance checks:\n${group.checks.map(c => `- ${c.description}`).join('\n')}`] : [],
+ ...requestedBy ? [requestedBy] : []].join('\n\n'), [worker.id], null, SYSTEM_ROW)
const news = assignedNotice(state, group, sender, operationId)
if (news) effects.messages.push(news)
if (routeNote) effects.messages.push({ id: stableId(operationId, 'route-override'), conversationId: group.id, author: sender,
diff --git a/backend/src/superTabs/projects.test.ts b/backend/src/superTabs/projects.test.ts
index d6fb0c1aa..e41a5fe94 100644
--- a/backend/src/superTabs/projects.test.ts
+++ b/backend/src/superTabs/projects.test.ts
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto'
import { describe, expect, it } from 'vitest'
import { applyCommand, commandSchema, type Command, type CommandContext } from './commands.js'
import { agentOnly, createSuperTab, SuperTabError, visibleState, type Actor, type MessageDraft } from './model.js'
-import { canReadAgent, canWatchAgent, markConfidential, projectOf, projectsOf, readConversation, skillModeOf, skillSetOf, watchersLost } from './projects.js'
+import { canReadAgent, canWatchAgent, markConfidential, projectOf, projectsOf, readConversation, skillModeOf, skillSetOf, watchersLost, workRequesterId, requestedByLine } from './projects.js'
import { mayDrive } from './terminal.js'
const owner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }
@@ -547,3 +547,73 @@ describe('whether a commit narrows who may watch a terminal', () => {
expect(narrowed()).toBe(false)
})
})
+
+// 11-01: agents on Tony's Mac opened Tony's pull requests as Ken's, the project's owner (#2486, #2488, #2491).
+describe('whom a group\'s work is for', () => {
+ it('is its requester while they can read its project, else the project\'s owner', () => {
+ const f = setup(), p = f.project('private')
+ f.run({ type: 'project.sharing', projectId: p.projectId, visibility: 'private', memberIds: ['peer'] })
+ const asked = String(f.run({ type: 'conversation.create', projectId: p.projectId, title: 'Asked', brief: '', checks: [], requesterId: 'peer' }).conversationId)
+ const plain = String(f.run({ type: 'conversation.create', projectId: p.projectId, title: 'Plain', brief: '', checks: [] }).conversationId)
+ const group = (id: string) => f.state.conversations.find(c => c.id === id)!
+ const project = () => projectOf(f.state, p.projectId)
+ expect(workRequesterId(f.state, project(), group(asked))).toBe('peer')
+ expect(workRequesterId(f.state, project(), group(plain))).toBe('owner')
+ expect(workRequesterId(f.state, project(), undefined)).toBe('owner')
+ // A group of another project never names its requester for this one.
+ expect(workRequesterId(f.state, projectOf(f.state, 'lead'), group(asked))).toBe('owner')
+ // No email on their row, or no longer in the Swarm: the owner.
+ const peer = f.state.people.find(p => p.id === 'peer')!
+ peer.email = ''
+ expect(workRequesterId(f.state, project(), group(asked))).toBe('owner')
+ peer.email = '[email protected]'
+ // Removed and invited again (a new generation): the old membership no longer reads the project.
+ peer.generation = 'second'
+ expect(workRequesterId(f.state, project(), group(asked))).toBe('owner')
+ peer.generation = 'first'
+ f.run({ type: 'project.sharing', projectId: p.projectId, visibility: 'private', memberIds: [] })
+ expect(workRequesterId(f.state, project(), group(asked))).toBe('owner')
+ f.run({ type: 'member.remove', userId: 'peer' })
+ f.run({ type: 'project.sharing', projectId: p.projectId, visibility: 'public', memberIds: [] })
+ expect(workRequesterId(f.state, project(), group(asked))).toBe('owner')
+ })
+})
+
+// Security review 2 of #2492: the line comes with each task, from that task's requester, never once at the agent's start.
+describe('whom a task\'s pull requests are for', () => {
+ const line = (email: string) => `Start each pull request body with: Requested by ${email} through Harness.`
+ it('ends each task\'s message with its own requester, for an Engineer reused across two people\'s tasks', () => {
+ const f = setup()
+ f.state.people.push({ id: 'third', email: '[email protected]', role: 'collaborator', generation: 'first' })
+ f.add('lead', 'lead-harness')
+ const worker = f.add('lead', 'worker-harness', false)
+ expect(f.state.agents.find(a => a.id === worker)!.machineOwnerId).toBe('host')
+ const ask = (requesterId: string) => String(f.run({ type: 'conversation.create', title: requesterId, brief: `Work for ${requesterId}`,
+ checks: [{ description: 'Done', independent: false }], requesterId }).conversationId)
+ const first = ask('peer'), second = ask('third')
+ const assigned = (group: string) => {
+ f.run({ type: 'work.assign', conversationId: group, agentId: worker })
+ return f.messages.find(m => m.conversationId === group && m.recipients?.includes(worker))!.text
+ }
+ expect(assigned(first)).toBe(`Work for peer\n\nAcceptance checks:\n- Done\n\n${line('[email protected]')}`)
+ f.run({ type: 'work.cancel', conversationId: first, assignmentId: f.state.conversations.find(c => c.id === first)!.assignment!.id, reason: 'Next one' })
+ const text = assigned(second)
+ expect(text.endsWith(line('[email protected]'))).toBe(true)
+ expect(text).not.toContain('[email protected]')
+ })
+
+ it('is the owner\'s for a group nobody asked for, and absent on the owner\'s own machine and for a review', () => {
+ const f = setup()
+ const worker = f.add('lead', 'worker-harness', false)
+ const plain = String(f.run({ type: 'conversation.create', title: 'Plain', brief: '', checks: [] }).conversationId)
+ const review = String(f.run({ type: 'conversation.create', title: 'Review', brief: '', checks: [], reviewOf: plain }).conversationId)
+ const group = (id: string) => f.state.conversations.find(c => c.id === id)!
+ const project = projectOf(f.state, 'lead'), agentOf = (owner: string) => ({ ...f.state.agents.find(a => a.id === worker)!, machineOwnerId: owner })
+ expect(requestedByLine(f.state, project, group(plain), agentOf('host'))).toBe(line('[email protected]'))
+ expect(requestedByLine(f.state, project, group(plain), agentOf('owner'))).toBeNull()
+ expect(requestedByLine(f.state, project, group(review), agentOf('host'))).toBeNull()
+ // An owner with no email on their row: no line, as the start gave none.
+ f.state.people.find(p => p.id === 'owner')!.email = ''
+ expect(requestedByLine(f.state, project, group(plain), agentOf('host'))).toBeNull()
+ })
+})
diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.ts
index 27540f1c7..54bae306d 100644
--- a/backend/src/superTabs/projects.ts
+++ b/backend/src/superTabs/projects.ts
@@ -146,6 +146,27 @@ export function canReadProject(state: SuperTabState, actor: Actor, project: Swar
project.members.some(p => p.id === member.id && p.generation === member.generation))
}
+/** Whom a group's work is for, as its pull requests say (`requestedByLine`): the person who asked for it (`requesterId`) while
+ * they can still read its project, else the project's owner. Until 11-01 it was always the owner, and agents on Tony's Mac
+ * opened Tony's pull requests as Ken's (#2486, #2488, #2491). It names a person only: the GitHub App's token, who gets one
+ * and its commit trailers (store.ts githubAssignment, githubStart) never depend on it. */
+export function workRequesterId(state: SuperTabState, project: SwarmProject, group: Conversation | undefined): string {
+ const id = group && (group.projectId ?? 'lead') === project.id ? group.requesterId : undefined
+ const member = id ? state.people.find(p => p.id === id) : undefined
+ return member?.email && canReadProject(state, { kind: 'person', userId: member.id, email: member.email }, project) ? member.id : project.ownerId
+}
+
+/** The line a task's message ends with, telling its Engineer whom the task's pull requests are for. It comes with each
+ * task, from that task's requester, so a reused Engineer never names the one before; the start prompt names nobody
+ * (security review 2 of #2492). Given where the start prompt gave it before: another person's project work, where the
+ * project's owner is not the machine's (cli/src/superTabs/start.ts `githubPromptLine`). A review opens no pull request.
+ * The email is the Swarm row's, which the Swarm's members already see. */
+export function requestedByLine(state: SuperTabState, project: SwarmProject, group: Conversation, worker: Agent): string | null {
+ if (group.reviewOf || project.ownerId === worker.machineOwnerId) return null
+ const email = state.people.find(p => p.id === workRequesterId(state, project, group))?.email
+ return email ? `Start each pull request body with: Requested by ${email} through Harness.` : null
+}
+
export function readProject(state: SuperTabState, actor: Actor, projectId: string): SwarmProject {
author(state, actor)
const project = projectOf(state, projectId)
diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.ts
index 19ff29a03..a0dff292a 100644
--- a/cli/src/superTabs/start.spec.ts
+++ b/cli/src/superTabs/start.spec.ts
@@ -1118,10 +1118,13 @@ describe('Swarm starts for another person\'s project', () => {
return f.request.mock.calls.find(c => c[0] === 'agent_create')![1]!
}
- it('wires the Harness GitHub App and says whom the work is for when the project\'s owner is not the machine\'s', async () => {
+ it('wires the Harness GitHub App, naming nobody, when the project\'s owner is not the machine\'s', async () => {
const payload = await started({ state, githubApp: true })
expect(payload).toMatchObject({ swarmRole: 'dev', swarmSkillMode: 'default', swarmGitHub: true })
- expect(String(payload.prompt)).toMatch(/not this computer's own GitHub login\. Start each pull request body with: Requested by owner@example\.com through Harness\.$/)
+ expect(String(payload.prompt)).toMatch(/not this computer's own GitHub login\. Each task's message ends with the line to start its pull request bodies with\.$/)
+ // Whom the work is for comes with each task (backend projects.ts requestedByLine): the start names nobody, so an agent reused
+ // for another person's task never names the one before (security review 2 of #2492).
+ expect(String(payload.prompt)).not.toMatch(/Requested by|@example\.com/)
})
it('reads a Swarm from before projects as its owner\'s', async () => {
@@ -1138,7 +1141,8 @@ describe('Swarm starts for another person\'s project', () => {
}
const payload = await hosted({ requester: '[email protected]' })
expect(payload).toMatchObject({ swarmRole: 'dev', swarmGitHub: true })
- expect(String(payload.prompt)).toContain('Requested by [email protected] through Harness.')
+ expect(String(payload.prompt)).toContain('Each task\'s message ends with the line to start its pull request bodies with.')
+ expect(String(payload.prompt)).not.toMatch(/Requested by|olive/)
for (const github of [undefined, null, {}, { requester: '' }]) expect(await hosted(github)).not.toHaveProperty('swarmGitHub')
})
diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.ts
index be4e84aa3..072bf3e9e 100644
--- a/cli/src/superTabs/start.ts
+++ b/cli/src/superTabs/start.ts
@@ -155,9 +155,11 @@ export async function projectFacts(scoped: ScopedRequest, conversationId: unknow
return { mode, github }
}
-/** What an agent doing another person's project work is told about git, gh and its pull requests. */
-export const githubPromptLine = (requester: string) => `git and gh here use a Harness GitHub App token for this project's repository while you `
- + `have a task, not this computer's own GitHub login. Start each pull request body with: Requested by ${requester} through Harness.`
+/** What an agent doing another person's project work is told about git and gh. It names nobody: each task's message says
+ * whom that task's pull requests are for (backend projects.ts `requestedByLine`), so an agent reused for another person's
+ * task never names the one before (security review 2 of #2492). */
+export const githubPromptLine = () => `git and gh here use a Harness GitHub App token for this project's repository while you `
+ + `have a task, not this computer's own GitHub login. Each task's message ends with the line to start its pull request bodies with.`
/** Whether the machine launches `engine` with a model of its own for that session (lib/launchModel.ts). A daemon from
* before the flags does not name the field, and agent_create would silently drop a model it does not know. */
@@ -406,7 +408,7 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:
: buddySessionPrompt(String(input.tabId), String(request.conversationId), session, mode)
: home ? swarmBuddyPrompt(String(input.tabId), String(request.conversationId), home, mode)
: buddyPrompt(String(input.tabId), String(request.conversationId), mode))
- : `${lead ? leadPrompt(String(input.tabId), String(request.conversationId), roleName) : workerPrompt(String(input.tabId), String(request.conversationId), roleName)}${github ? ` ${githubPromptLine(github.requester)}` : ''}`,
+ : `${lead ? leadPrompt(String(input.tabId), String(request.conversationId), roleName) : workerPrompt(String(input.tabId), String(request.conversationId), roleName)}${github ? ` ${githubPromptLine()}` : ''}`,
...(homeFolder ? { cwd: homeFolder } : request.worktree ? { projectSource: 'worktree', gitSource: request.cwd, branchName: `super-tab/${startId}`,
// No branch named: the repository's default branch, fetched, not the host checkout's old HEAD.
...(request.branchRef ? { branchRef: request.branchRef } : { branchBase: 'default' }) } : { cwd: request.cwd }),
diff --git a/docs/swarm-github-app.md b/docs/swarm-github-app.md
index 6ccceef5a..e5a25a0a3 100644
--- a/docs/swarm-github-app.md
+++ b/docs/swarm-github-app.md
@@ -227,9 +227,14 @@ The `prepare-commit-msg` hook runs even with `--no-verify`. Two things leave a c
without trailers: plumbing such as `git commit-tree`, and a command that sets its own
`-c core.hooksPath`.
-The agent is told to start each pull request body with `Requested by <owner's email>
-through Harness.` The token response also carries `pullRequestLine` with the owner's
-name. This line depends on the agent following its instructions. Harness does not
+Each task's message ends with `Start each pull request body with: Requested by <email>
+through Harness.`, naming the person whose ask the task is: its group's requester while
+they can still read the project, otherwise the project's owner (`requestedByLine` in
+`backend/src/superTabs/projects.ts`). It comes with every task, so an agent reused for
+another person's task names that person; the start prompt names nobody. It is given
+for another person's project (its owner is not the machine's), not for a review. Who asked
+changes no token and no trailer: the token response's `pullRequestLine` and the
+co-author still name the project's owner, so members' emails do not enter git history. This line depends on the agent following its instructions. Harness does not
assign the pull request, because it does not know the person's GitHub login.
## The token endpoint