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
Let each project choose Simple or Full process (#3427)
harness-for-autonomous[bot]2ec19629680e
diff --git a/backend/integration/superTabMigration.test.ts b/backend/integration/superTabMigration.test.tsindex a9f79aa73..4131c9dc7 100644--- a/backend/integration/superTabMigration.test.ts+++ b/backend/integration/superTabMigration.test.ts@@ -16,6 +16,8 @@ import { stateDifference } from '../src/superTabs/migration/verify.js'import { visibleState, type Author, type SuperTabState } from '../src/superTabs/model.js'import { setLegacyProgress, writeLegacySwarm, type LegacyMessage } from '../scripts/swarm-parts/legacy.js'import { NOW, richSwarm } from '../src/superTabs/read/fixture.test-support.js'+import { seedProjectProcesses } from '../src/superTabs/migration/projectProcesses.js'+import { profiled, reads } from './plans.test-support.js'// A fresh loopback replica set, created here. This suite never reads DATABASE_URL or an existing database.let replica: MongoMemoryReplSet@@ -60,6 +62,53 @@ async function legacySwarm(edit: (state: SuperTabState, s: ReturnType<typeof ric}const partCount = (tabId: string) => db.swarmHead.count({ where: { tabId } })+describe('seeding project processes', () => {+ const tabId = 'c51479bd73b59e58176ad9e4', id = `${tabId}:head`+ async function head() {+ const data = { ...richSwarm().state, id: tabId, projects: ['harness', 'lamp', 'scout', 'harness-gtm', 'other'].map(name => ({+ id: `seed-${name}`, name, ownerId: 'owner', leadConversationId: `chat-${name}`, visibility: 'public', members: [], updateMinutes: 5,+ })) }+ await db.swarmHead.upsert({ where: { id }, create: { id, tabId, key: 'head', version: 3, changedAt: new Date(NOW), ordinal: 0,+ groupCounter: 100, visibilityEpoch: 2, sequenceBase: 50, data: data as never },+ update: { data: data as never, version: 3, deleted: false } })+ return db.swarmHead.findUniqueOrThrow({ where: { id } })+ }++ it('previews without writing, reads only the indexed head, then fills it once with its counters intact', async () => {+ const before = await head()+ const entries = await profiled(db, async () => {+ expect(await seedProjectProcesses(db, { apply: false })).toMatchObject({ applied: false, held: [], changed: [+ { projectId: 'seed-harness', process: 'full' }, { projectId: 'seed-lamp', process: 'full' },+ { projectId: 'seed-scout', process: 'simple' }, { projectId: 'seed-harness-gtm', process: 'simple' },+ ] })+ })+ const queried = reads(entries, 'SwarmHead', ['_id'])+ expect(queried.length).toBeGreaterThan(0)+ for (const query of queried) {+ expect(query.planSummary).toMatch(/IXSCAN|IDHACK|EXPRESS_IXSCAN/)+ expect(query.docsExamined).toBeLessThanOrEqual(1)+ }+ expect(entries.some(e => /\.(SwarmGroup|SwarmAgent|SwarmMember)$/.test(e.ns))).toBe(false)+ expect(await db.swarmHead.findUniqueOrThrow({ where: { id } })).toEqual(before)+ expect(await seedProjectProcesses(db, { apply: true })).toMatchObject({ applied: true, held: [] })+ const after = await db.swarmHead.findUniqueOrThrow({ where: { id } })+ expect(after).toMatchObject({ version: 4, groupCounter: 100, visibilityEpoch: 2, sequenceBase: 50,+ data: { projects: expect.arrayContaining([expect.objectContaining({ id: 'seed-scout', process: 'simple' })]) } })+ expect(await seedProjectProcesses(db, { apply: true })).toMatchObject({ applied: false, changed: [] })+ expect(await db.swarmHead.findUniqueOrThrow({ where: { id } })).toEqual(after)+ })++ it('writes nothing when a seed target is missing, and refuses a deleted head', async () => {+ const before = await head(), data = before.data as unknown as SuperTabState+ data.projects = data.projects!.filter(p => p.name !== 'lamp')+ await db.swarmHead.update({ where: { id }, data: { data: data as never } })+ expect(await seedProjectProcesses(db, { apply: true })).toMatchObject({ applied: false, changed: [], held: [{ name: 'lamp', reason: 'missing' }] })+ expect((await db.swarmHead.findUniqueOrThrow({ where: { id } })).version).toBe(3)+ await db.swarmHead.update({ where: { id }, data: { deleted: true } })+ await expect(seedProjectProcesses(db, { apply: true })).rejects.toMatchObject({ code: 'PROCESS_SEED_UNAVAILABLE' })+ })+})+describe('migrating one Swarm to parts (design 6.1.2)', () => {it('splits a legacy Swarm into parts that reassemble into its state, fences the row and keeps the old state', async () => {const { s, tabId, state } = await legacySwarm()diff --git a/backend/integration/superTabReviewSteps.test.ts b/backend/integration/superTabReviewSteps.test.tsindex 8d8569ef3..77040adca 100644--- a/backend/integration/superTabReviewSteps.test.ts+++ b/backend/integration/superTabReviewSteps.test.ts@@ -72,6 +72,15 @@ const stepsIn = async (tab: string, task: string) => (await db.swarmGroup.findMa.filter(group => group.reviewOf === task)describe('a Ready through the store', () => {+ it('does not read review files or open steps for a task switched to Simple', async () => {+ const pullRequestFiles = vi.fn(async (_repository: string | null, urls: string[]) => ({ urls, head: 'abc1234', files: ['desktop/lib/a.dart'] }))+ const { tab, execute, task, dev, assignment } = await swarm({ pullRequestFiles })+ await execute({ type: 'project.process', projectId: 'lead', process: 'simple' })+ await execute({ type: 'work.status', conversationId: task, assignmentId: assignment, status: 'review', result: `Ready: ${REPO}/pull/7` }, host, dev)+ expect(pullRequestFiles).not.toHaveBeenCalled()+ expect(await stepsIn(tab, task)).toEqual([])+ })+it('reads the pull request\'s files and opens two security reviews for a sign-in change', async () => {const pullRequestFiles = vi.fn(async (_repository: string | null, urls: string[]) => ({ urls, head: 'abc1234', files: ['backend/src/routes/auth.ts'] }))const { tab, execute, task, dev, reviewers, assignment } = await swarm({ pullRequestFiles })diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex 085cf5c08..add38900b 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -50,6 +50,7 @@ import { DELETED_SWARM_COMMANDS, isPersonalSwarm, notThere, SWARM_DELETE_GRACE_Mimport { ABANDONED, askedModel, coordinatorCopy, failureNotice, failureRecipients, MACHINE_MOVED, MACHINE_REMOVED, publicReason } from './startFailure.js'import { noteStartFailed, noteStartSucceeded, resumeEngine } from './engineHealth.js'import { reviewCapacityNotice } from './reviewCapacity.js'+import { processOf, taskProcess, type ProjectProcess } from './process.js'import { digestStartsAfter, knownTimeZone } from './digest.js'import { credentialResult, redactCredentials, type CredentialKind } from './credentials.js'import { dirtyGroups, reportGroups, summarize } from './projectUpdates.js'@@ -244,7 +245,8 @@ export const commandSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('tab.tidy'), enabled: z.boolean(), askedIn: askedInSchema.optional() }).strict(),z.object({ type: z.literal('rule.set'), projectId: id.optional(), rule: ruleSchema, text: ruleTextSchema, askedIn: askedInSchema.optional() }).strict(),z.object({ type: z.literal('rule.remove'), projectId: id.optional(), ruleId: id, askedIn: askedInSchema.optional() }).strict(),- z.object({ type: z.literal('project.create'), name: title, visibility: z.enum(['public', 'private']), brief: z.string().trim().max(8000).default('') }).strict(),+ z.object({ type: z.literal('project.create'), name: title, visibility: z.enum(['public', 'private']), brief: z.string().trim().max(8000).default(''), process: z.enum(['simple', 'full']).optional() }).strict(),+ z.object({ type: z.literal('project.process'), projectId: id, process: z.enum(['simple', 'full']) }).strict(),z.object({ type: z.literal('project.rename'), projectId: id, name: title }).strict(),z.object({ type: z.literal('project.delete'), projectId: id }).strict(),// A closed tab's project in the person's own Personal Swarm (task #3929, desktop personal_projects.dart): deleted when none of@@ -916,7 +918,9 @@ export function authorizeCommandAccess(state: SuperTabState, actor: Actor, comma}}// A project nobody owns is the Swarm owner's to delete though they read nothing of it: its delete checks that (deletableProject).- if ('projectId' in command && command.projectId && command.type !== 'project.delete') readProject(state, actor, command.projectId)+ // The Swarm owner may choose even a private project's process, but gains no access to its conversations or reads.+ const processOwner = command.type === 'project.process' && actor.kind === 'person' && actor.userId === state.ownerId+ if ('projectId' in command && command.projectId && command.type !== 'project.delete' && !processOwner) readProject(state, actor, command.projectId)if ('agentId' in command) readAgent(state, actor, command.agentId)if (command.type === 'agent.start') readConversation(state, actor, command.request.conversationId)if ((command.type === 'rule.set' || command.type === 'rule.remove' || command.type === 'project.skills' || command.type === 'tab.tidy'@@ -1750,7 +1754,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,/** Records [me]'s own machine [machineId], prepared by the app ([setup]), as Buddy-only (machines.ts buddyOnly): its host* then reads the Swarm, starts the Buddy and reports it, and nothing else of the Swarm runs there or reads it. *//** A new project of [ownerId]'s named [name], with its Lead chat: project.create's, and + New agent's for a PM (task #4116). */- const createProject = (ownerId: string, name: string, visibility: 'public' | 'private', brief: string): SwarmProject => {+ const createProject = (ownerId: string, name: string, visibility: 'public' | 'private', brief: string, process: ProjectProcess): SwarmProject => {const projects = mutableProjects(state)if (projects.length >= 100) fail('PROJECTS_FULL', 'A swarm can have up to 100 projects.')const leadConversationId = `project-${operationId}`@@ -1759,7 +1763,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,const onBase = projects.some(p => (p.instructionsBase ?? 0) >= BASE_VERSION)const first = onBase ? { instructionsRevision: 1, instructionsHash: instructionsHash(BASE_DOCUMENT), instructionsBase: BASE_VERSION } : FIRST_INSTRUCTIONSconst project: SwarmProject = { id: operationId, name, ownerId, ownerGeneration: person(state, ownerId).generation, leadConversationId,- visibility, members: [], updateMinutes: 5, skillMode: 'default', ...first }+ visibility, members: [], updateMinutes: 5, skillMode: 'default', process, ...first }projects.push(project)effects.instructions = { projectId: operationId, revision: 1, hash: first.instructionsHash, text: onBase ? BASE_DOCUMENT : INSTRUCTIONS_TEMPLATE,summary: FIRST_SUMMARY, writtenBy: { kind: 'person', id: ownerId }, askedBy: ownerId, at: context.now }@@ -2113,7 +2117,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,case 'project.create': {if (actor.kind !== 'person') fail('HUMAN_REQUIRED', 'A person creates a project and chooses its lead.', 403)if (state.paused) fail('PAUSED', 'New work is paused in this swarm.')- const project = createProject(actor.userId, command.name, command.visibility, command.brief)+ const project = createProject(actor.userId, command.name, command.visibility, command.brief, command.process ?? 'full')result.projectId = project.idresult.conversationId = project.leadConversationIdbreak@@ -2225,6 +2229,17 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,manageProject(state, actor, command.projectId)ignored()break+ case 'project.process': {+ const project = projectOf(state, command.projectId)+ if (actor.kind !== 'person' || (actor.userId !== state.ownerId && !ownsProject(state, actor.userId, project))) {+ fail('PROJECT_OWNER_REQUIRED', 'Only the project owner or Swarm owner can change its process.', 403)+ }+ mutableProjects(state)+ const target = projectOf(state, command.projectId)+ if (processOf(target) === 'simple' && command.process === 'full') target.simpleThrough = nextConversationNumber(state) - 1+ target.process = command.process+ break+ }case 'project.rename': {const project = manageProject(state, actor, command.projectId)project.name = command.name@@ -2846,6 +2861,9 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,requireTaskApproval(reviewed)// One level: a step's own work is a task's step, never a task with steps of its own (task steps design).if (command.step && isStep(reviewed)) fail('STEP_OF_STEP', 'A step belongs to a task, not to another step.', 400)+ if (taskProcess(project, reviewed) === 'simple') {+ fail('SIMPLE_PROCESS', 'Simple tasks finish when their agent marks them done; they have no process steps.', 409)+ }// Never doubled (task #3602: #3561 got its server's Security reviews and Test, then its Engineer's review, review and// test): the task's own Engineer is refused a step when one of the same name is open, or the server opened one of that// kind, while its work is open. Its own second step of a kind under another name ("Security review 2") still opens. The@@ -2894,7 +2912,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,}state.conversations.push({ id: operationId, ...(state.projects ? { projectId: project.id } : {}),// A task lists its steps from its start (#3394): only a task from before lists none, which its PR watch looks up once.- ...(!command.reviewOf && !command.audience ? { stepIds: [] } : {}),+ ...(!command.reviewOf && !command.audience ? { stepIds: [], ...(processOf(project) === 'simple' ? { process: 'simple' as const } : {}) } : {}),number, title: command.title, leadId, agentIds: [...leadId ? [leadId] : [], ...creator],archived: false, brief, ...(brief ? { briefAt: context.now } : {}), ...(command.task ? { task: command.task } : {}), ...(command.reviewOf ? { reviewOf: command.reviewOf } : {}),// A step keeps its task's mark (teamWritten.ts, audit H2). Opening a task writes none of its code (#3304).@@ -3651,7 +3669,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,?? fail('MACHINE_NOT_LISTED', 'Add this computer to the Swarm first.', 403)if (command.kind === 'pm') {const projectName = command.projectName ?? fail('PROJECT_NAME_REQUIRED', 'Name the project its PM starts.', 400)- const project = createProject(me.id, projectName, 'public', '')+ const project = createProject(me.id, projectName, 'public', '', 'full')const asked = leadEffort(withRoleDefaults({ engine: command.engine, ...(command.model ? { model: command.model } : {}),...(command.repositoryUrl ? { repositoryUrl: command.repositoryUrl } : {}) }, BUILT_IN_ROLE_DEFAULTS.lead), coordinatorNameOf(project))const start = placeLead(state, project, me, pool.machineId, asked, operationId, context)@@ -4775,7 +4793,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,// The server opens a task's review steps when its pull request's files were read (openReviewSteps, below); when// they were not, the agent whose work is ready opens and assigns them (project instructions, phase 4). When no machine the project may use can start either engine, or soon none// will, the project's coordinator hears it once, in its chat (reviewCapacity.ts).- const short = command.status === 'review' && !group.reviewOf ? reviewCapacityNotice(state, group, context.now, (machineId, contributorId) =>+ const short = command.status === 'review' && !group.reviewOf && taskProcess(groupProject(state, group), group) === 'full' ? reviewCapacityNotice(state, group, context.now, (machineId, contributorId) =>!teamWorkCheck(state, machineId, contributorId, groupProject(state, group))) : null// A row of its own beside the command's, as the ship notice is: written as the Engineer who handed over. A server notice,// the coordinator's alone (model.ts NOTICE_READERS), untagged, since people cannot read it; with no coordinator in the@@ -4791,7 +4809,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,}}// A task's Ready hands it over: the server opens its review steps from the files it changes (task #3401).- if (command.status === 'review' && !isStep(group) && context.pullRequestFiles) openReviewSteps(group, context.pullRequestFiles)+ if (command.status === 'review' && !isStep(group) && context.pullRequestFiles && taskProcess(groupProject(state, group), group) === 'full') openReviewSteps(group, context.pullRequestFiles)if (actor.kind === 'agent') renewOwnTask(state, group, actor.agentId, context.now)// The time it waited for its review never counts, whoever moved it on.if (waited && activeWork(group) && !waitingForReview(assignment)) restartQuietTime(assignment, context.now)diff --git a/backend/src/superTabs/migration/projectProcesses.test.ts b/backend/src/superTabs/migration/projectProcesses.test.tsnew file mode 100644index 000000000..c2dfea21b--- /dev/null+++ b/backend/src/superTabs/migration/projectProcesses.test.ts@@ -0,0 +1,56 @@+import { describe, expect, it } from 'vitest'+import type { SwarmProject } from '../projects.js'+import { processSeedPlan } from './projectProcesses.js'++const TAB = 'c51479bd73b59e58176ad9e4'+const project = (name: string, extra: Partial<SwarmProject> = {}): SwarmProject => ({ id: `id-${name}`, name, ownerId: 'owner',+ leadConversationId: `chat-${name}`, visibility: 'public', members: [], updateMinutes: 5, ...extra })+const projects = () => ['harness', 'lamp', 'scout', 'harness-gtm', 'other'].map(name => project(name))++describe('the one-time process seed for the requesting Swarm', () => {+ it('seeds the four named projects and leaves every other project as it was', () => {+ const before = projects(), plan = processSeedPlan(TAB, before)+ expect(plan.held).toEqual([])+ expect(plan.changed).toEqual([+ { projectId: 'id-harness', process: 'full' }, { projectId: 'id-lamp', process: 'full' },+ { projectId: 'id-scout', process: 'simple' }, { projectId: 'id-harness-gtm', process: 'simple' },+ ])+ expect(plan.projects.map(p => [p.name, p.process])).toEqual([+ ['harness', 'full'], ['lamp', 'full'], ['scout', 'simple'], ['harness-gtm', 'simple'], ['other', undefined],+ ])+ expect(before).toEqual(projects())+ })++ it('never seeds a similarly named project in another Swarm', () => {+ const before = projects()+ expect(processSeedPlan('another-swarm', before)).toMatchObject({ projects: before, changed: [], held: [] })+ })++ it('preserves an owner’s saved choice and becomes a no-op on a second run', () => {+ const before = projects()+ before[2]!.process = 'full'+ const first = processSeedPlan(TAB, before)+ expect(first.projects.find(p => p.name === 'scout')!.process).toBe('full')+ expect(first.changed.map(c => c.projectId)).not.toContain('id-scout')+ expect(processSeedPlan(TAB, first.projects)).toMatchObject({ changed: [], held: [], projects: first.projects })+ })++ it.each(['missing', 'ambiguous'])('refuses the entire seed when a target is %s', problem => {+ const before = projects()+ if (problem === 'missing') before.splice(1, 1)+ else before.push(project('lamp', { id: 'another-lamp' }))+ const plan = processSeedPlan(TAB, before)+ expect(plan.changed).toEqual([])+ expect(plan.projects).toEqual(before)+ expect(plan.held).toEqual([{ name: 'lamp', reason: problem }])+ })++ it('preserves open release history and settings when filling a preset', () => {+ const before = projects()+ before[2]!.releases = { pending: [{ groupId: 'task', url: 'https://github.com/acme/app/pull/1', mergedAt: 1 }],+ steps: { cli: { groupId: 'release', at: 1 } } }+ before[2]!.simpleThrough = 10+ const plan = processSeedPlan(TAB, before)+ expect(plan.projects[2]).toEqual({ ...before[2], process: 'simple' })+ })+})diff --git a/backend/src/superTabs/migration/projectProcesses.ts b/backend/src/superTabs/migration/projectProcesses.tsnew file mode 100644index 000000000..a5ffe17b5--- /dev/null+++ b/backend/src/superTabs/migration/projectProcesses.ts@@ -0,0 +1,57 @@+/**+ * Task #3896: seed only the four projects named by Dee in autonomous.ai. Run explicitly after the backend deploy;+ * never on reads or in the worker. A dry run resolves their ids; missing or ambiguous names refuse the entire seed.+ * An owner's saved choice wins. Only the existing head is read and written, guarded by its version, with no task scan.+ */+import type { Prisma, PrismaClient } from '@prisma/client'+import type { SwarmProject } from '../projects.js'+import type { ProjectProcess } from '../process.js'+import { clock, guardedWrite, type HeadData } from '../parts/index.js'+import { swarmTransaction } from '../cache.js'+import { fail } from '../model.js'++const TAB = 'c51479bd73b59e58176ad9e4'+const SEEDS: ReadonlyArray<{ name: string; process: ProjectProcess }> = [+ { name: 'harness', process: 'full' }, { name: 'lamp', process: 'full' },+ { name: 'scout', process: 'simple' }, { name: 'harness-gtm', process: 'simple' },+]+interface SeedPlan {+ projects: SwarmProject[]+ changed: Array<{ projectId: string; process: ProjectProcess }>+ held: Array<{ name: string; reason: 'missing' | 'ambiguous' }>+}++/** Plans on a copy, never by a name outside the Swarm that asked, never overwriting an owner's setting. */+export function processSeedPlan(tabId: string, projects: SwarmProject[]): SeedPlan {+ const plan: SeedPlan = { projects: structuredClone(projects), changed: [], held: [] }+ if (tabId !== TAB) return plan+ const targets = SEEDS.map(seed => ({ ...seed, matches: plan.projects.filter(project => project.name === seed.name) }))+ for (const target of targets) if (target.matches.length !== 1) {+ plan.held.push({ name: target.name, reason: target.matches.length ? 'ambiguous' : 'missing' })+ }+ if (plan.held.length) return plan+ for (const { process, matches } of targets) {+ const project = matches[0]!+ if (project.process !== undefined) continue+ project.process = process+ plan.changed.push({ projectId: project.id, process })+ }+ return plan+}++/** Primary-key lookup of one head, and at most one guarded write. A concurrent setting change retries at the caller. */+export async function seedProjectProcesses(db: PrismaClient, opts: { apply: boolean }) {+ const seed = async (tx: Prisma.TransactionClient) => {+ const head = await tx.swarmHead.findUnique({ where: { id: `${TAB}:head` }, select: {+ version: true, deleted: true, data: true, groupCounter: true, visibilityEpoch: true, sequenceBase: true,+ } })+ const data = head?.data as HeadData | undefined+ if (!head || head.deleted || !data?.projects || data.deletion) fail('PROCESS_SEED_UNAVAILABLE', 'The requesting Swarm has no live project head.', 409)+ const plan = processSeedPlan(TAB, data.projects)+ const applied = opts.apply && !plan.held.length && plan.changed.length > 0+ if (applied) await guardedWrite(tx, TAB, { op: 'update', kind: 'head', key: 'head', seen: head.version,+ data: { ...data, projects: plan.projects }, head: { groupCounter: head.groupCounter, visibilityEpoch: head.visibilityEpoch, sequenceBase: head.sequenceBase } }, clock.next())+ return { tabId: TAB, applied, changed: plan.changed, held: plan.held }+ }+ return opts.apply ? swarmTransaction(db, seed, { maxWait: 5_000, timeout: 10_000 }) : seed(db as unknown as Prisma.TransactionClient)+}diff --git a/backend/src/superTabs/migration/seedProjectProcesses.ts b/backend/src/superTabs/migration/seedProjectProcesses.tsnew file mode 100644index 000000000..5f1dd7a16--- /dev/null+++ b/backend/src/superTabs/migration/seedProjectProcesses.ts@@ -0,0 +1,28 @@+/** Explicit operator entry point, dry-run by default. Production application needs the release owner's authorization.+ * From backend/: node --import tsx src/superTabs/migration/seedProjectProcesses.ts [--apply]+ * DATABASE_URL is supplied by the operator's environment; never print it. */+import { parseArgs } from 'node:util'+import { PrismaClient } from '@prisma/client'+import { seedProjectProcesses } from './projectProcesses.js'+import { SuperTabError } from '../model.js'++let apply = false+try {+ const { values } = parseArgs({ options: { apply: { type: 'boolean' } }, strict: true, allowPositionals: false })+ apply = !!values.apply+ if (!process.env.DATABASE_URL) throw new Error('missing database')+} catch {+ console.error('Supply DATABASE_URL in the environment. Usage: node --import tsx src/superTabs/migration/seedProjectProcesses.ts [--apply]')+ process.exit(2)+}+const db = new PrismaClient()+try {+ const report = await seedProjectProcesses(db, { apply })+ console.log(JSON.stringify(report, null, 2))+ if (report.held.length) process.exitCode = 1+} catch (error) {+ console.error(error instanceof SuperTabError ? `${error.code}: ${error.message}` : 'PROCESS_SEED_FAILED: database write failed; no seed changes were committed. Read the dry run before trying again.')+ process.exitCode = 1+} finally {+ await db.$disconnect()+}diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 53b3cbd35..d949ad5d8 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -11,6 +11,7 @@ import { downSince, expireRemovals, startPreparing } from './machines.js'import { publicReason, readsRawReason } from './startFailure.js'import { FIRST_INSTRUCTIONS } from './instructions.js'import { visibleAccess } from './machineAccess.js'+import { processOf, projectColumns } from './process.js'import { agentProjectId, agentSetRole, canReadAgent, canReadGroup, canReadProject, groupProject, ledProject, ownerlessProjects, ownsProject, placeRules, projectsOf, sharedWithLeads, skillSetOf, type ProjectVisibility, type SwarmProject } from './projects.js'export type Role = 'owner' | 'collaborator' | 'viewer'@@ -413,6 +414,8 @@ export interface Conversation {archived: booleanbrief: stringtask?: WorkTask+ /** The process when this task was opened; a Simple task stays Simple if the project returns to Full (#3896). */+ process?: import('./process.js').ProjectProcess/** A review group names the group whose work it reviews; only a Reviewer is assigned it, and a Reviewer nothing else. */reviewOf?: string/** A Harness Team agent was assigned to build this task, or GitHub shows the app's bot pushed to its branch: its code runs@@ -1083,9 +1086,13 @@ export function leadsRemoved(): never { fail('LEADS_CONVERSATION_REMOVED', LEADS* numbers are never reassigned; the store serializes concurrent additions. */export function numberConversations(state: SuperTabState): void {let next = nextConversationNumber(state)- const leads = new Set(projectsOf(state).map(p => p.leadConversationId))+ const projects = projectsOf(state), leads = new Set(projects.map(p => p.leadConversationId))for (const group of state.conversations) {- if (!leads.has(group.id) && !isLeads(group) && group.number == null) state.groupCounter = group.number = next+++ if (!leads.has(group.id) && !isLeads(group) && group.number == null) {+ // An unnumbered dormant task predates a Simple→Full switch. Giving it a number now must not make it new work.+ if (!group.kind && !group.audience && !group.reviewOf && projects.some(p => p.id === (group.projectId ?? 'lead') && p.simpleThrough !== undefined)) group.process = 'simple'+ state.groupCounter = group.number = next+++ }}}/** The store by parts keeps the highest number ever given (`groupCounter`): a dormant group is not loaded, and its@@ -1260,7 +1267,10 @@ export function visibleState(state: SuperTabState, actor: Actor, now = Date.now(// One index for every project: the loop sets only workDecision, which the index does not hold.const workers = workerIndex(visible)for (const project of projectsOf(visible)) for (const target of awaitingWorkers(visible, project.id, workers)) target.workDecision = 'awaiting'- for (const project of visible.projects ?? []) project.skillSet = skillSetOf(project)+ for (const project of visible.projects ?? []) {+ project.skillSet = skillSetOf(project)+ Object.assign(project, { process: processOf(project), columns: projectColumns(project) })+ }// An uploaded avatar's stored key stays on the server; readers get a link with each parts read (avatarLinks.ts).// Each person as the Swarm names them (usernames.ts), their default included.const names = swarmUsernames(state)diff --git a/backend/src/superTabs/parts/light.test.ts b/backend/src/superTabs/parts/light.test.tsindex ade5d0313..9d8884b83 100644--- a/backend/src/superTabs/parts/light.test.ts+++ b/backend/src/superTabs/parts/light.test.ts@@ -69,6 +69,7 @@ const conversation: Required<Conversation> = {paused: { by: 'person:owner', at: 1, reason: 'Wait' },pin: { agentId: 'a', why: 'ci', at: 1 },priority: 'P0',+ process: 'full',projectId: 'p',proposal: { version: 1, text: 'Words', goal: 'Goal', why: 'Why', doneWhen: 'Done', evidence: ['Evidence'], priority: 'P2', createdAt: 0, senders: [], questions: [] },proposals: [],diff --git a/backend/src/superTabs/parts/light.ts b/backend/src/superTabs/parts/light.tsindex bf2db34dc..a96e0a952 100644--- a/backend/src/superTabs/parts/light.ts+++ b/backend/src/superTabs/parts/light.ts@@ -96,6 +96,7 @@ export const GROUP_FIELDS = {'paused','pin','priority',+ 'process','proposals','pullRequestChecks','pullRequestEvents',diff --git a/backend/src/superTabs/parts/touches.ts b/backend/src/superTabs/parts/touches.tsindex 1f4fd3bf0..f65daf159 100644--- a/backend/src/superTabs/parts/touches.ts+++ b/backend/src/superTabs/parts/touches.ts@@ -165,6 +165,10 @@ export function touchesFor(command: Command, actor: Actor, before: SuperTabStatecase 'conversation.unlink':leadCheck(projectOfGroup(command.conversationId)?.id)break+ case 'work.status':+ // Ready decides whether to open steps from the project's preset; a concurrent switch must make it retry.+ if (command.status === 'review') head()+ break// Whether an agent may change a priority is whether it is still its project's PM (commands.ts coordinatorOrPerson).case 'work.priority':case 'work.lane':diff --git a/backend/src/superTabs/process.test.ts b/backend/src/superTabs/process.test.tsnew file mode 100644index 000000000..86bb49291--- /dev/null+++ b/backend/src/superTabs/process.test.ts@@ -0,0 +1,255 @@+import { describe, expect, it } from 'vitest'+import { applyCommand, commandSchema, type CommandContext } from './commands.js'+import { createSuperTab, visibleState, type Actor } from './model.js'+import { projectsOf } from './projects.js'+import { readerView } from './read/views.js'+import { reassemble, split } from './parts/index.js'+import { stepsOf } from './steps.js'+import { touchesFor } from './parts/touches.js'++const owner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }+const peer: Actor = { kind: 'person', userId: 'peer', email: '[email protected]' }+const other: Actor = { kind: 'person', userId: 'other', email: '[email protected]' }+const configuration = { engine: 'claude', model: 'opus', effort: 'high', contextWindow: null, engineVersion: null }+const fullColumns = [+ { id: 'proposals', title: 'Proposal' }, { id: 'nextUp', title: 'Next up' }, { id: 'working', title: 'Working' },+ { id: 'done', title: 'Done' }, { id: 'merged', title: 'Merged' }, { id: 'shipped', title: 'Shipped' },+]+// Simple uses the Board's own column ids (Desktop task_groups.dart SuperTabTaskColumn) under its own titles.+const simpleColumns = [{ id: 'nextUp', title: 'To do' }, { id: 'working', title: 'Doing' }, { id: 'done', title: 'Done' }]++function fixture() {+ let state = createSuperTab('swarm', 'Team', { id: 'owner', email: '[email protected]' }, 'test'), sequence = 0+ state.people.push({ id: 'peer', email: '[email protected]', role: 'collaborator', generation: 'first' },+ { id: 'other', email: '[email protected]', role: 'collaborator', generation: 'first' })+ const run = (input: unknown, actor = owner, context: Partial<CommandContext> = {}) => {+ const command = commandSchema.parse(input)+ const effects = applyCommand(state, actor, command, { now: 1000, operationId: `op-${++sequence}`,+ contribution: { machineOwnerId: 'host', contributorId: 'owner' }, ...context })+ state = effects.state+ return effects+ }+ const create = (process?: string, actor = peer, visibility = 'public') => run({ type: 'project.create', name: 'Work', visibility,+ ...(process ? { process } : {}) }, actor).result.projectId as string+ const set = (projectId: string, process: string, actor = peer) => run({ type: 'project.process', projectId, process }, actor)+ const project = (id: string) => projectsOf(state).find(p => p.id === id)!+ const view = (actor = owner) => readerView(split(state, { tabId: state.id, version: sequence, now: 1000 }), actor, 1000, { teamMachines: [] })+ const as = (agentId: string): Actor => ({ kind: 'agent', agentId, machineOwnerId: 'host' })+ const add = (projectId: string) => run({ type: 'agent.add', conversationId: project(projectId).leadConversationId,+ machineId: 'machine', harnessId: 'pm', name: 'PM', configuration, lead: true }, peer).result.agentId as string+ const group = (id: string) => state.conversations.find(c => c.id === id)!+ const task = (projectId: string) => {+ const id = run({ type: 'conversation.create', projectId, title: 'Work', brief: 'Finish the work', checks: [] }, peer).result.conversationId as string+ const worker = run({ type: 'agent.add', conversationId: id, machineId: 'machine', harnessId: `worker-${sequence}`, name: `Worker${sequence}`,+ configuration, lead: false }, peer).result.agentId as string+ run({ type: 'work.assign', conversationId: id, agentId: worker }, peer)+ const status = (status: string, files?: string[]) => run({ type: 'work.status', conversationId: id,+ assignmentId: group(id).assignment!.id, status, result: status === 'review' ? 'https://github.com/acme/app/pull/1' : 'Finished' }, as(worker),+ files ? { pullRequestFiles: { urls: ['https://github.com/acme/app/pull/1'], head: 'a'.repeat(40), files } } : {})+ return { id, worker, status }+ }+ const reload = () => { state = reassemble(split(state, { tabId: state.id, version: sequence, now: 1000 })) }+ return { run, create, set, project, view, as, add, task, group, reload, get state() { return state } }+}++describe('project process settings and board columns', () => {+ it('defaults old projects and old creation commands to Full and six board columns', () => {+ const f = fixture(), created = f.create()+ expect(f.project(created)).toMatchObject({ process: 'full' })+ expect(f.view().parts.head.data.projects).toEqual(expect.arrayContaining([+ expect.objectContaining({ id: 'lead', process: 'full', columns: fullColumns }),+ expect.objectContaining({ id: created, process: 'full', columns: fullColumns }),+ ]))+ })++ it('creates Simple explicitly and returns its three columns on parts and legacy reads', () => {+ const f = fixture(), id = f.create('simple')+ expect(f.project(id)).toMatchObject({ process: 'simple' })+ expect(f.view().parts.head.data.projects).toContainEqual(expect.objectContaining({ id, process: 'simple', columns: simpleColumns }))+ expect(visibleState(f.state, peer).projects).toContainEqual(expect.objectContaining({ id, process: 'simple', columns: simpleColumns }))+ })++ it('lets the current project owner change only the named project', () => {+ const f = fixture(), id = f.create(), untouched = f.create()+ f.set(id, 'simple')+ expect(f.project(id)).toMatchObject({ process: 'simple' })+ expect(f.project(untouched)).toMatchObject({ process: 'full' })+ f.set(id, 'full')+ expect(f.view(peer).parts.head.data.projects).toContainEqual(expect.objectContaining({ id, process: 'full', columns: fullColumns }))+ })++ it('lets the Swarm owner change a public project owned by someone else', () => {+ const f = fixture(), id = f.create()+ f.set(id, 'simple', owner)+ expect(f.project(id)).toMatchObject({ process: 'simple' })+ })++ it('lets the Swarm owner change a private preset without granting access to its data', () => {+ const f = fixture(), id = f.create(undefined, peer, 'private')+ f.set(id, 'simple', owner)+ expect(f.project(id)).toMatchObject({ process: 'simple' })+ expect(f.view(owner).parts.head.data.projects?.some(p => p.id === id)).toBe(false)+ expect(visibleState(f.state, owner).projects?.some(p => p.id === id)).toBe(false)+ })++ it('refuses another member even when the project is public', () => {+ const f = fixture(), id = f.create()+ expect(() => f.set(id, 'simple', other)).toThrow(expect.objectContaining({ code: 'PROJECT_OWNER_REQUIRED' }))+ expect(f.project(id)).toMatchObject({ process: 'full' })+ })++ it('refuses the PM agent even when it runs for the Swarm owner', () => {+ const f = fixture(), id = f.create(), pm = f.add(id)+ expect(() => f.set(id, 'simple', f.as(pm))).toThrow(expect.objectContaining({ code: 'PROJECT_OWNER_REQUIRED' }))+ expect(f.project(id)).toMatchObject({ process: 'full' })+ })++ it('does not restore an old project owner’s authority when they rejoin', () => {+ const f = fixture(), id = f.create()+ f.state.people.find(p => p.id === 'peer')!.generation = 'rejoined'+ expect(() => f.set(id, 'simple')).toThrow(expect.objectContaining({ code: 'PROJECT_OWNER_REQUIRED' }))+ })++ it('keeps private process metadata out of other members’ board reads', () => {+ const f = fixture(), id = f.create('simple', peer, 'private')+ const view = f.view(other)+ expect(view.parts.head.data.projects?.some(p => p.id === id)).toBe(false)+ expect(JSON.stringify(view.derived)).not.toContain(id)+ expect(() => f.set(id, 'full', other)).toThrow(expect.objectContaining({ code: 'NOT_FOUND' }))+ })++ it('changes a legacy project through the same settings command', () => {+ const f = fixture()+ f.set('lead', 'simple', owner)+ expect(f.project('lead')).toMatchObject({ process: 'simple' })+ expect(f.view().parts.head.data.projects).toContainEqual(expect.objectContaining({ id: 'lead', columns: simpleColumns }))+ })++ it('rejects custom columns and unknown presets instead of silently choosing one', () => {+ expect(commandSchema.safeParse({ type: 'project.create', name: 'Work', visibility: 'public', process: 'custom' }).success).toBe(false)+ expect(commandSchema.safeParse({ type: 'project.process', projectId: 'lead', process: 'simple', columns: [] }).success).toBe(false)+ expect(commandSchema.safeParse({ type: 'project.process', projectId: 'lead', process: 'custom' }).success).toBe(false)+ })+})++describe('Simple task lifecycle', () => {+ it.each([['docs/a.md'], ['backend/src/routes/auth.ts'], ['desktop/lib/a.dart']])('opens no automatic steps for %s', file => {+ const f = fixture(), project = f.create('simple'), task = f.task(project)+ task.status('review', [file])+ expect(stepsOf(f.state, task.id)).toEqual([])+ })++ it('finishes a Simple task directly and exposes Done without any merge or pull request', () => {+ const f = fixture(), project = f.create('simple'), task = f.task(project)+ expect(f.group(task.id).assignment?.status).toBe('working')+ task.status('done')+ const read = f.view(peer).parts.groups.find(p => p.key === task.id)!.data+ expect(read).toMatchObject({ process: 'simple', assignment: { status: 'done' } })+ expect(read.releasing).toBeUndefined()+ expect(read.pullRequestUrls ?? []).toEqual([])+ expect(stepsOf(f.state, task.id)).toEqual([])+ })++ it('keeps Full review and test automation unchanged', () => {+ const f = fixture(), project = f.create('full'), task = f.task(project)+ task.status('review', ['backend/src/routes/auth.ts', 'desktop/lib/a.dart'])+ expect(stepsOf(f.state, task.id).map(s => s.step)).toEqual(['Security review 1', 'Security review 2', 'Test'])+ })++ it.each(['Review', 'Test', 'Merge', 'Release'])('refuses a new explicit %s step for Simple work', step => {+ const f = fixture(), project = f.create('simple'), task = f.task(project)+ expect(() => f.run({ type: 'conversation.create', projectId: project, title: step, brief: 'Check the work', reviewOf: task.id, step, checks: [] }, peer))+ .toThrow(expect.objectContaining({ code: 'SIMPLE_PROCESS' }))+ expect(stepsOf(f.state, task.id)).toEqual([])+ })++ it('also refuses an older client’s linked review without an explicit step name', () => {+ const f = fixture(), project = f.create('simple'), task = f.task(project)+ expect(() => f.run({ type: 'conversation.create', projectId: project, title: 'Review', brief: 'Read it', reviewOf: task.id, checks: [] }, peer))+ .toThrow(expect.objectContaining({ code: 'SIMPLE_PROCESS' }))+ })++ it('keeps earlier Simple tasks Simple when switching to Full, including dormant records', () => {+ const f = fixture(), project = f.create('simple'), old = f.task(project)+ const dormant = structuredClone(f.group(old.id))+ f.state.conversations = f.state.conversations.filter(g => g.id !== old.id)+ f.set(project, 'full')+ f.state.conversations.push(dormant)+ f.reload()+ old.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, old.id)).toEqual([])+ const fresh = f.task(project)+ fresh.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, fresh.id).map(s => s.step)).toEqual(['Review', 'Test'])+ })++ it('does not change open steps or their evidence when switching Full to Simple', () => {+ const f = fixture(), project = f.create('full'), task = f.task(project)+ task.status('review', ['desktop/lib/a.dart'])+ const before = structuredClone(stepsOf(f.state, task.id))+ f.set(project, 'simple')+ expect(stepsOf(f.state, task.id)).toEqual(before)+ })++ it('simplifies existing Full tasks immediately without changing their stored history', () => {+ const f = fixture(), project = f.create('full'), old = f.task(project)+ const before = structuredClone(f.group(old.id))+ f.set(project, 'simple')+ expect(f.group(old.id)).toEqual(before)+ old.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, old.id)).toEqual([])+ })++ it('preserves dormant legacy tasks when switching back to Full without loading them', () => {+ const f = fixture(), project = f.create('full'), old = f.task(project)+ delete (f.group(old.id) as { process?: string }).process+ const dormant = structuredClone(f.group(old.id))+ f.state.conversations = f.state.conversations.filter(g => g.id !== old.id)+ f.set(project, 'simple')+ f.set(project, 'full')+ f.state.conversations.push(dormant)+ f.reload()+ old.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, old.id)).toEqual([])+ const fresh = f.task(project)+ fresh.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, fresh.id).map(s => s.step)).toEqual(['Review', 'Test'])+ })++ it('keeps an unnumbered dormant task Simple when its first later command gives it a number', () => {+ const f = fixture(), project = f.create('full'), old = f.task(project)+ const dormant = structuredClone(f.group(old.id))+ delete dormant.number+ delete (dormant as { process?: string }).process+ f.state.conversations = f.state.conversations.filter(g => g.id !== old.id)+ f.set(project, 'simple'); f.set(project, 'full')+ f.state.conversations.push(dormant)+ old.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, old.id)).toEqual([])+ })++ it('keeps the old tasks Simple across repeated switches, and a repeated Full save does not change newer work', () => {+ const f = fixture(), project = f.create('full'), first = f.task(project)+ f.set(project, 'simple'); f.set(project, 'full')+ const second = f.task(project)+ f.set(project, 'simple'); f.set(project, 'full')+ const newest = f.task(project)+ f.set(project, 'full')+ f.reload()+ for (const task of [first, second]) {+ task.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, task.id)).toEqual([])+ }+ newest.status('review', ['desktop/lib/a.dart'])+ expect(stepsOf(f.state, newest.id).map(s => s.step)).toEqual(['Review', 'Test'])+ })++ it('guards a Ready decision against a concurrent process change', () => {+ const f = fixture(), project = f.create('simple'), task = f.task(project)+ const before = structuredClone(f.state)+ const command = commandSchema.parse({ type: 'work.status', conversationId: task.id, assignmentId: f.group(task.id).assignment!.id,+ status: 'review', result: 'Ready' })+ const effects = f.run(command, f.as(task.worker))+ expect(touchesFor(command, f.as(task.worker), before, effects)).toContainEqual({ kind: 'head', key: 'head' })+ })+})diff --git a/backend/src/superTabs/process.ts b/backend/src/superTabs/process.tsnew file mode 100644index 000000000..1cb326712--- /dev/null+++ b/backend/src/superTabs/process.ts@@ -0,0 +1,24 @@+import type { SwarmProject } from './projects.js'+import type { Conversation } from './model.js'++export type ProjectProcess = 'simple' | 'full'+export interface BoardColumn { id: string; title: string }++/** One column vocabulary, the Board's (Desktop task_groups.dart SuperTabTaskColumn, #3381); Simple shows three of its columns+ * under its own titles. To do also holds what Full shows in Proposal, Done what Full shows in Merged and Shipped. No status+ * is added: personal Tasks' proposal and rejected (Swarm v3) are approval states on the card, not columns. */+const COLUMNS: Record<ProjectProcess, readonly BoardColumn[]> = {+ simple: [{ id: 'nextUp', title: 'To do' }, { id: 'working', title: 'Doing' }, { id: 'done', title: 'Done' }],+ full: [{ id: 'proposals', title: 'Proposal' }, { id: 'nextUp', title: 'Next up' }, { id: 'working', title: 'Working' },+ { id: 'done', title: 'Done' }, { id: 'merged', title: 'Merged' }, { id: 'shipped', title: 'Shipped' }],+}++/** Projects from before presets keep the Full process until their owner chooses. */+export const processOf = (project: SwarmProject): ProjectProcess => project.process ?? 'full'+export const projectColumns = (project: SwarmProject): readonly BoardColumn[] => COLUMNS[processOf(project)]++/** Simple simplifies existing tasks. Returning to Full keeps those tasks Simple, even if they were dormant during the+ * switch. An unnumbered legacy task predates the switch; new tasks always receive a number from the head counter. */+export const taskProcess = (project: SwarmProject, task: Pick<Conversation, 'process' | 'number'>): ProjectProcess =>+ processOf(project) === 'simple' || task.process === 'simple'+ || (project.simpleThrough !== undefined && (task.number ?? 0) <= project.simpleThrough) ? 'simple' : 'full'diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.tsindex 1ff0fc72b..c8d7e37ef 100644--- a/backend/src/superTabs/projects.ts+++ b/backend/src/superTabs/projects.ts@@ -44,6 +44,11 @@ export interface SwarmProject {visibility: ProjectVisibilitymembers: Array<{ id: string; generation: string }>updateMinutes: 1 | 5 | 15 | 30+ /** The project's board and work process; absent on older projects, which keep Full (task #3896). */+ process?: import('./process.js').ProjectProcess+ /** Tasks up to this number stay Simple after returning to Full. One watermark covers dormant tasks and repeated+ * switches without loading or rewriting any task history; absent until the first Simple→Full switch (#3896). */+ simpleThrough?: number/** The morning digest (digest.ts): its local time ("08:00") and zone, and the local date and time of the last one sent.* On by default: a project without one gets the default on its coordinator's next poll, unless a person turned it off. */digest?: { time: string; timeZone: string; lastOn?: string; lastAt?: number }diff --git a/backend/src/superTabs/read/contract.ts b/backend/src/superTabs/read/contract.tsindex 9013959e2..d3ab9a2f4 100644--- a/backend/src/superTabs/read/contract.ts+++ b/backend/src/superTabs/read/contract.ts@@ -25,12 +25,16 @@ export type GroupChange = LivePart<GroupView> | Tombstone | DormantStub/** The head as a reader sees it: no sharing, overlap alerts, retired number or parked groups; projects, rules and* invitations filtered (invitations only for the Swarm owner). `autoJoin`: people at the owner's domain join by themselves* (autoJoin.ts), from the sharing the head holds; who declined is never sent. */-export type HeadView = Pick<SuperTabState, 'version' | 'id' | 'name' | 'project' | 'projects' | 'leadsConversationId' | 'ownerId'+export type HeadView = Pick<SuperTabState, 'version' | 'id' | 'name' | 'project' | 'leadsConversationId' | 'ownerId'| 'environment' | 'routingPolicy' | 'rules' | 'paused' | 'invitations' | 'localModels' | 'workspaceId' | 'workspaceVisibility' | 'buddies' | 'removedMachines'| 'autoJoin'> & {/** How many Buddies each person may have (task #3818): always sent, 5 unless the Swarm's owner set another. An older backend* sends none, so an app offers several Buddies only where this is present. */buddyCap: number+ /** Fixed columns for the chosen preset (task #3896); an older server omits both, meaning Full. */+ projects?: Array<import('../projects.js').SwarmProject & {+ process: import('../process.js').ProjectProcess; columns: readonly import('../process.js').BoardColumn[]+ }>}/** A member's avatar says only `{ kind: 'upload' }` for an upload: its link comes signed in `derived.avatars`. */export type MemberView = Omit<Person, 'avatar'> & { avatar?: import('../profile.js').AvatarView }diff --git a/backend/src/superTabs/releases.test.ts b/backend/src/superTabs/releases.test.tsindex 99455bb0c..e8b4d2c22 100644--- a/backend/src/superTabs/releases.test.ts+++ b/backend/src/superTabs/releases.test.ts@@ -147,6 +147,13 @@ describe('shipping', () => {describe('notePendingRelease', () => {const project = () => ({ id: 'p1' }) as SwarmProject+ it('does not schedule a release for a Simple task after its project switches to Full', () => {+ const p = project(), group = { id: 'simple', process: 'simple' } as Conversation+ notePendingRelease(p, group, 'https://github.com/o/r/pull/1', vn(10))+ expect(p.releases).toBeUndefined()+ expect(group.releasing).toBeUndefined()+ })+it('marks the task releasing, its parts not known yet', () => {const p = project(), group = { id: 'a' } as ConversationnotePendingRelease(p, group, 'https://github.com/o/r/pull/1', vn(10))@@ -205,6 +212,38 @@ describe('settleReleases', () => {const webRelease = { tag: 'v1.3.98_web', sha: 'w1', at: T - 5 * MINUTE, carries: [key12] }const noFacts = { resolved: [], releases: {} }+ it('opens no new release step after switching a project to Simple, preserving its existing ledger', () => {+ const state = swarm([entry({ groupId: 'g12' })])+ Object.assign(state.projects![0]!, { process: 'simple' })+ const outcome = settleReleases(state, 'p1', noFacts, T)+ expect(outcome.opened).toBeNull()+ expect(ledgerOf(state).pending).toHaveLength(1)+ expect(state.conversations.map(c => c.id)).toEqual(['lead-p1', 'g12', 'g13'])+ })++ it('still records a verified release for an existing step after switching to Simple', () => {+ const state = swarm([entry({ groupId: 'g12' })], { steps: { desktop: { groupId: 'step', at: T - 10 * MINUTE } } })+ state.conversations.push({ ...task(14), id: 'step' })+ Object.assign(state.projects![0]!, { process: 'simple' })+ const outcome = settleReleases(state, 'p1', { resolved: [], releases: { desktop: desktopRelease() } }, T)+ expect(outcome.shipped).toContain('g12')+ expect(outcome.opened).toBeNull()+ expect(state.conversations.some(c => c.id === 'step')).toBe(true)+ })++ it('does not reopen releases for old Simple work when the project returns to Full', () => {+ const state = swarm([entry({ groupId: 'g12' })])+ Object.assign(state.projects![0]!, { process: 'full', simpleThrough: 20 })+ expect(settleReleases(state, 'p1', noFacts, T).opened).toBeNull()+ expect(ledgerOf(state).pending).toHaveLength(1)+ state.conversations.push(task(21))+ ledgerOf(state).pending.push(entry({ groupId: 'g21', components: ['cli'] }))+ const opened = settleReleases(state, 'p1', noFacts, T).opened+ expect(opened).not.toBeNull()+ expect(state.conversations.find(c => c.id === opened)!.brief).toContain('Release CLI')+ expect(state.conversations.find(c => c.id === opened)!.brief).not.toContain('Desktop')+ })+it('records when each component may next release, and changes nothing when that has not changed (task #3827)', () => {const state = swarm([entry({ groupId: 'g12', mergedAt: vn(8), components: ['desktop', 'backend'] })])settleReleases(state, 'p1', noFacts, vn(8, 30))diff --git a/backend/src/superTabs/releases.ts b/backend/src/superTabs/releases.tsindex 935d8788e..11a46deea 100644--- a/backend/src/superTabs/releases.ts+++ b/backend/src/superTabs/releases.ts@@ -12,6 +12,7 @@ import { localNow } from './digest.js'import { activeWork, nextConversationNumber, stableId, type Agent, type Conversation, type MessageDraft, type SuperTabState } from './model.js'import { agentProjectId, projectsOf, type SwarmProject } from './projects.js'import { SEED_RULES, type ProjectRules } from './policy.js'+import { processOf, taskProcess } from './process.js'/** The release window, pace and backend pause: the project rules record's own (policy.ts, task #3393), which people edit* without a release. The store reads each project's record when it settles (store.ts settleReleases). */@@ -149,7 +150,8 @@ export const shipped = (entry: PendingRelease): boolean => !!entry.components &&/** Puts [group]'s merge of [url] at [mergedAt] on [project]'s release list, in the merge record's own write. The same merge* recorded again adds nothing; a later merge of the same task waits on its own. Returns the entries the cap pushed out. */-export function notePendingRelease(project: SwarmProject, group: Pick<Conversation, 'id' | 'releasing'>, url: string, mergedAt: number): PendingRelease[] {+export function notePendingRelease(project: SwarmProject, group: Pick<Conversation, 'id' | 'releasing' | 'process' | 'number'>, url: string, mergedAt: number): PendingRelease[] {+ if (taskProcess(project, group) === 'simple') return []const ledger = project.releases ??= { pending: [] }if (ledger.pending.some(e => e.groupId === group.id && e.url === url)) return []// Releasing from its merge on; its parts are known once the worker reads its pull request's files.@@ -309,12 +311,16 @@ export function settleReleases(state: SuperTabState, projectId: string, facts: R}if (JSON.stringify(ledger.nextAt) !== JSON.stringify(nextAt)) ledger.nextAt = nextAt- const due = RELEASE_COMPONENTS.filter(c => releaseDue(ledger, c.id, now, rules))- if (!due.length || state.paused) return outcome+ // A return to Full applies to new work only. Keep the old pending history for verified releases, but open no new+ // release step for a task the switch made Simple. The ledger is bounded by PENDING_MAX.+ const tasks = new Map(state.conversations.map(group => [group.id, group]))+ const scheduled = { ...ledger, pending: ledger.pending.filter(entry => taskProcess(project, tasks.get(entry.groupId) ?? {}) === 'full') }+ const due = RELEASE_COMPONENTS.filter(c => releaseDue(scheduled, c.id, now, rules))+ if (!due.length || state.paused || processOf(project) === 'simple') return outcomeconst id = stableId('release-step', state.id, projectId, due.map(c => c.id).join(','), String(now))if (state.conversations.some(c => c.id === id)) return outcomeconst integrator = integratorOf(state, projectId)- const waiting = [...new Set(due.flatMap(c => waitingFor(ledger, c.id).map(e => e.groupId)))].map(groupId => named(state, groupId))+ const waiting = [...new Set(due.flatMap(c => waitingFor(scheduled, c.id).map(e => e.groupId)))].map(groupId => named(state, groupId))const names = joined(due.map(c => c.name)), window = rules.releaseWindowconst brief = [`Release ${names}: ${waiting.length} merged ${waiting.length === 1 ? 'task waits' : 'tasks wait'} for it (${waiting.join('; ')}).`,`Release between ${window.start} and ${window.end} (${window.timeZone}), applying the merged pull requests' rollout notes first, and verify each release is live.`,diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex f1b6ac280..d2024510b 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -54,6 +54,7 @@ import { recordReload } from './retryStats.js'import { buddyChatId, isSwarmBuddyChat, shownBefore, swarmBuddyChatId, type ChosenBuddyName } from './buddies.js'import { cleanPullRequestLinks } from './cards.js'import { accountOf, wordsOf, buddyInstructionsProject, canReadAgent, canReadGroup, groupRepositoryUrl, canWatchAgent, groupProject, ledProject, onTeamAccount, ownerAccount, ownsProject, admitPerson, projectOf, projectsOf, agentProjectId, readConversation, readProject, skillModeOf, startProject, type ProjectVisibility, sessionKey, GITHUB_SEEN, type GitHubSeen, type RepositoryCreation, repositoryCreator, type SwarmProject } from './projects.js'+import { taskProcess } from './process.js'import { bindSession, makeProjectPrivate } from './sessionScope.js'import { SESSION_ENDED_KIND, sessionContext, sessionReadsRow, type ContextRow } from './buddySessions.js'import { DELETED_TEXT, type MessageChangeTarget } from './messageEdits.js'@@ -1799,7 +1800,7 @@ export class SuperTabStore {facts = await transaction(this.db, async tx => {const { state } = await this.factsLoad(tx, user, tabId, command)const group = state.conversations.find(c => c.id === asked.conversationId)- if (!group || group.reviewOf) return null+ if (!group || group.reviewOf || taskProcess(groupProject(state, group), group) === 'simple') return nullconst repositoryUrl = groupProject(state, group).repository?.repositoryUrl ?? nullconst urls = [...group.pullRequestUrls ?? [], ...[typeof asked.result === 'string' ? asked.result : '', group.brief].flatMap(text => text ? pullRequestsIn(text, repositoryUrl) : [])]diff --git a/docs/plans/2026-11-06-project-process-presets-plan.md b/docs/plans/2026-11-06-project-process-presets-plan.mdnew file mode 100644index 000000000..4cf3f0954--- /dev/null+++ b/docs/plans/2026-11-06-project-process-presets-plan.md@@ -0,0 +1,100 @@+# Project process presets implementation plan++> Implement task by task, test first, with a failing-test commit before each implementation commit and one independent pull-request review, following this project's Engineer instructions.++**Goal:** Let a project choose Simple or Full, keeping existing history and making Simple work finish without review, test, merge or release requirements.++**Architecture:** Keep the process beside the project in the existing head part; missing values mean Full. The command reducer enforces who changes it, and the board read publishes the preset's fixed columns. Task creation and automated steps use one shared process rule, including preservation of old Simple tasks after switching to Full. A single task-number watermark on the project preserves old tasks across repeated switches without loading or rewriting them.++**Tech Stack:** TypeScript, Zod, Vitest, existing MongoDB Swarm parts and version guards. No dependencies or collections.++**Spec:** Harness task #3896, conversation `e39be2ce9fc6e4dad2f0d9a7`: Simple has To do / Doing / Done; Full has Proposal / Next up / Working / Done / Merged / Shipped. Backend only; Desktop is separate. The implementation follows the brief’s asymmetric switch rule: Full→Simple simplifies existing tasks without changing open steps; Simple→Full affects only new tasks. The seed is restricted to the requesting Swarm and resolves exactly one existing project of each requested name; missing or ambiguous names refuse the entire seed. Its dry run reports the exact identities before application.++## Global Constraints++- Default Full; old commands and clients continue to work. No custom columns.+- Only the project owner and the Swarm owner (the existing top authority) change the process; agents and other members cannot.+- Never delete or rewrite open steps or task history. Simple→Full applies to new tasks only.+- Seed harness/lamp Full and scout/harness-gtm Simple only for the intended existing projects; never by an unscoped global name match.+- Own `backend/src/superTabs/`; no CLI or Desktop changes and no production writes in this task.+- Affected tests locally; backend unit and Super Tab integration suites in automatic PR CI. PM owns merge.++## Design (docs/feature-design-rules.md)++1. **Growth:** A bounded enum on each of at most 100 projects, with bounded task process metadata if needed. Created with its project/task, replaced on a setting change, retained through finish/loss/cancel/archive, deleted by the existing project/Swarm purge. Rejoining a person does not restore their ownership. No event list grows on switching.+2. **Concurrency:** Settings change the existing head version and guard the actor's membership. Task creation already advances the head's task-number counter. Ready and release creation must guard the head when their process decision depends on it; concurrent changes retry from fresh state. No all-task update.+3. **Read cost:** Read the already loaded head, at most 100 projects, and the named task. Fixed columns live only in read output, not storage. Parts readers receive the changed head; no task-history scan, added database query or index. Private project metadata stays filtered by `canReadProject`.+4. **Scale:** Constant metadata per project/task, no new fan-out. Measure reducer/read time on the same fixture before and after and report payload growth at 100 projects. Existing part latency/bytes measures reveal growth first.+5. **Compatibility:** Backend ships first. `project.create.process` is optional; the new `project.process` command is additive. Existing CLI and Desktop clients ignore new JSON fields and keep their existing board labels until the Desktop task ships. Work status values stay unchanged; no new enum reaches old clients. Parts reads expose fixed columns in the head; old full-state reads receive the same process defaults. New clients treat missing process/columns as Full and handle an old server's unsupported settings command visibly.+6. **Migration and rollback:** No mass migration or production write. An explicit seed helper will accept only unique exact names in Swarm c51479bd73b59e58176ad9e4, report their ids, and leave any owner's saved choice alone. Missing metadata remains Full. A rollback ignores new fields and resumes Full automation; existing steps and work remain readable. Seed application belongs to the authorized release, with its targets and dry-run evidence recorded before application. No production backup is available to this task; tests use legacy and dormant record fixtures.+7. **Audience:** Settings require the named person's current ownership (including membership generation) or Swarm ownership. Process metadata follows project visibility on full reads, parts and feeds. Changing a setting grants no chat access. No content, secret or private project data is added to notifications, agent prompts, logs, shares or other Swarms.+8. **Identity:** Commands use the authenticated person, never an agent's contributor or machine owner's identity. Missing identity is refused by existing author checks. No process start or subscription behavior changes.+9. **Failure:** Bad preset, unauthorized change and new forbidden steps return named command refusals. Existing operation receipts keep retries idempotent. A failed write leaves project/task data unchanged. Old steps can finish normally after a switch.+10. **Platforms:** Linux backend, locally tested on macOS; unchanged command protocol works for CLI on macOS/Linux/Windows and Desktop/web/phone. No UI or OS process code changes here.++## Review Focus++- Owner leave/rejoin and agents acting on behalf of an owner must not grant setting authority (Task 1).+- A private project's preset must not leak through board metadata (Task 1).+- Existing and dormant Simple tasks must stay Simple after a switch to Full, including repeated switches (Task 2).+- An old client sending Ready or explicitly opening a step must not reintroduce Simple review/test requirements; open Full steps survive (Task 2).+- Seeds must not overwrite an owner's choice or similarly named projects in another Swarm (Task 3).++## Task 1: Project settings and board contract++**Files:** `backend/src/superTabs/projects.ts`, `commands.ts`, `read/contract.ts`, `read/views.ts`, `model.ts`; new `process.ts` and `process.test.ts`.++**Interfaces:** `ProjectProcess = 'simple' | 'full'`; `project.create` gains optional `process`; `project.process {projectId, process}` changes the preset. `processOf(project)` supplies the Full default. `projectColumns(project)` returns fixed `{id, title}` columns. Head projects expose `process` and `columns`.++- [x] Commit command/read tests: creation default and explicit Simple; owner and Swarm owner can change; other people/agents and stale owners cannot; invalid values fail; three/six columns and private filtering.+- [x] Run `npm test -- src/superTabs/process.test.ts` and record red.+- [x] Implement the additive setting, authority and board read contract; announce the contract to the PM for Desktop coordination.+- [x] Run the new tests plus `projects.test.ts`, `read/views.test.ts` and typecheck; commit and push.++## Task 2: Task process and step lifecycle++**Files:** `process.ts`, `process.test.ts`, `model.ts`, `commands.ts`, `parts/touches.ts`, `parts/touches.test.ts`, `releases.ts`, `releases.test.ts`; `store.ts` only if its pre-read must skip Simple review work.++**Interfaces:** One `taskProcess(project, task)` rule used by every step producer; additive task metadata preserves Simple semantics when the project returns to Full. Existing `work.status done` remains the completion command, requiring no merge. Settings never mutate existing step records.++- [x] Preserve existing tasks with a task-number watermark when switching Simple→Full; follow the brief’s asymmetric rule while the optional clarification remains unanswered.+- [x] Commit tests for Simple Ready opening no review/test steps, manual step refusal, Doing→Done without a merge, unchanged Full steps, preserved open steps, old Simple tasks after switching and reloading, and no new Simple release steps.+- [x] Run the affected tests and record red.+- [x] Implement the shared lifecycle rule and necessary concurrency guards.+- [x] Run process, reviewSteps, release and touch tests; measure the changed hot path; commit and push.++## Task 3: Bounded seeds and handoff++**Files:** New `backend/src/superTabs/migration/projectProcesses.ts` and test, plus this plan.++**Interfaces:** A dry-run seed operation reads the requesting Swarm’s head by its primary key, resolves the four unique exact names, fills only absent process choices, reports the ids and changes no task or step history. Missing or duplicate names refuse all changes. An explicit apply uses the existing guarded-head write protocol; the release operator applies it only after the backend deploy and production authorization.++- [x] Commit tests that select only the four intended names within the requesting Swarm, refuse missing/ambiguous targets, set the requested presets, preserve saved choices and do nothing on a second run.+- [x] Run and record red; implement the bounded seed helper; run and record green.+- [x] Document authorized release application and rollback, final command/read examples, platforms, red/green and timing evidence in the PR.+- [ ] Mark the stable head Ready and record its acceptance evidence; let automatic CI and independent review finish before handing it back.++## Settings and read contract++Creation accepts `{"type":"project.create","name":"Scout","visibility":"public","process":"simple"}`; omission keeps Full. Settings accepts `{"type":"project.process","projectId":"PROJECT","process":"simple"}`. The Swarm owner can set a private project’s preset without gaining read access to it. Parts head projects and the legacy status read include `process` and `columns` (`[{id,title}]`): Full ids `proposals`, `nextUp`, `working`, `done`, `merged`, `shipped` (the Board's columns, #3381); Simple uses three of the same ids under its own titles: `nextUp` "To do" (also holding proposals), `working` "Doing", `done` "Done" (also merged and shipped work). The Desktop follow-up defaults missing fields to Full. No change to assignment status values. A task's effective process is Simple when the project is Simple, the task carries `process: "simple"`, or the task's number is at most the project's optional `simpleThrough` watermark. Otherwise it is Full. Missing task numbers predate the watermark; new tasks always have numbers. Desktop must use this rule after a project returns to Full, so old Simple tasks keep their completion behavior. Full task metadata is omitted to avoid copying the default on every read.++Task 1 evidence: test-only commit `e890f351a`, 10 failed / 1 passed before implementation; afterward 81 passed across process, projects and read/views, with backend typecheck clean.++Task 2 initial evidence: corrected test-only commit `832dde613` has 11 failed / 17 passed in process and light projection; release regressions have 2 failed / 30 passed at `c393fb7b2`. The initial implementation passes 86 tests across process, reviewSteps, releases, touches and light, with backend typecheck clean. Repeated-switch coverage follows before the watermark implementation.+++## Final validation and rollout++- Settings: `e890f351a` red (10 failed / 1 passed), `9504e5f53` green (81 tests).+- Lifecycle: `832dde613` red (11 failed / 17 passed); release tests at `c393fb7b2` red (2 failed / 30 passed); `e5e2439da` green (86 tests).+- Repeated/dormant switching: `a87a86c26` red (3 failed / 23 passed), `c26f95b7f` green (159 tests).+- Legacy steps, unnumbered dormant tasks and pending releases: `d84f76048` red (3 failed / 58 passed), `e2d1d4711` green (536 tests).+- Seed: `08ecd61dc` could not load its absent implementation; `27ffc09fe` integration red (2 failed / 17 unrelated tests skipped). `342e4522f` green: 6 unit tests and 2 integration tests, including indexed head-only reads, preview, guarded apply, repeat no-op, refusal and counters.+- Review file reads: `eeaf45145` red (1 failed / 4 unrelated tests skipped), `910796e87` green (all 5 integration tests). Final affected unit selection: 604 passed in 10 files; typecheck clean. Removing redundant Full task metadata then passed the 455 affected process/command tests and typecheck again.+- Full backend and Super Tab integration suites are automatic PR CI, not additional local full runs.++Performance on macOS, 100 projects / 1,000 tasks: initial serial measurements showed a small increase. A CPU profile placed task-data copying first (1,581 ms sampled), followed by group projection (994 ms). Omitting the redundant Full task value removes that additional copying. The final same-process comparison alternates before/after order for 60 batches of 25 operations, after 100 warmups, against main `3c0408237`: Ready median 1.104→1.109 ms; reader median 3.008→2.921 ms. Batch-mean p95 remains noisy: Ready 1.760→2.558 ms, reader 3.165→3.309 ms. These synthetic CPU measurements do not establish end-to-end production p95. The head read at the 100-project cap grows 28,571→51,871 bytes (+233 bytes/project for the requested process and columns); stored columns add zero bytes. There is no added request-path database query. The seed's index test examines at most one head document and no group, agent or member collection.++Rollout: deploy the backend first. An authorized release operator runs `node --import tsx src/superTabs/migration/seedProjectProcesses.ts` from `backend/` with the release database environment, reviews the four resolved target ids, then uses `--apply`. No production application was performed here. A missing or duplicate name refuses every change; saved choices win. On a concurrent version conflict, rerun preview before apply. Every other project defaults Full without migration. Roll back the backend to resume Full automation, retaining all history and the additive metadata. Owner settings can subsequently switch the four choices; do not overwrite saved owner choices with the seed. The read-only production environment is absent on this machine, so production row counts/size and a restored-production migration check remain release validation, not claimed local evidence.++Timing: assigned 2026-11-06 10:54:59 UTC; plan/draft first, implementation and targeted validation interleaved through 11:42 UTC. Final unit selection 4.56 s; review-store integration 20.29 s. Review, automatic CI, merge and seed publication are separate remaining stages and will be recorded on the task/PR when completed.