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
Project switch, Can chat, and priority and pause rights (#3819) (#3384)
harness-for-autonomous[bot]32403b8b8ea1
diff --git a/backend/integration/superTabCanChat.test.ts b/backend/integration/superTabCanChat.test.tsnew file mode 100644index 000000000..4ff776fc8--- /dev/null+++ b/backend/integration/superTabCanChat.test.ts@@ -0,0 +1,57 @@+import { randomUUID } from 'node:crypto'+import { execFile } from 'node:child_process'+import { promisify } from 'node:util'+import { join } from 'node:path'+import { tmpdir } from 'node:os'+import { Readable } from 'node:stream'+import { afterAll, beforeAll, describe, expect, it } from 'vitest'+import { MongoMemoryReplSet } from 'mongodb-memory-server-core'+import { PrismaClient } from '@prisma/client'+import type { AuthUser } from '../src/lib/ssoAuth.js'+import { SuperTabStore } from '../src/superTabs/store.js'+import { MemoryAttachmentStore } from '../src/superTabs/attachments.js'+import type { Command } from '../src/superTabs/commands.js'++// Task #3819: in a project switched to the Board way of working, only its owners and the people granted Can chat write in its+// chat, through the store's own paths too (an upload is a message), so no app, old or new, writes past it.+let replica: MongoMemoryReplSet+let db: PrismaClient+const owner: AuthUser = { sub: '340000000000000000000001', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }+const peer: AuthUser = { sub: '340000000000000000000002', email: '[email protected]', autonomousEnv: 'prod', role: 'user' }++beforeAll(async () => {+ replica = await MongoMemoryReplSet.create({ binary: { version: '7.0.24', downloadDir: join(tmpdir(), 'harness-super-tab-mongodb-binaries') },+ replSet: { count: 1, ip: '127.0.0.1', storageEngine: 'wiredTiger' } })+ const uri = replica.getUri(`swarm_can_chat_test_${randomUUID().replaceAll('-', '_')}`)+ await promisify(execFile)(join(process.cwd(), 'node_modules/.bin/prisma'), ['db', 'push', '--skip-generate'], {+ env: { ...process.env, DATABASE_URL: uri }, timeout: 60000,+ })+ db = new PrismaClient({ datasources: { db: { url: uri } } })+ for (const user of [owner, peer]) await db.user.create({ data: { id: user.sub, externalId: `fixture-${user.sub}`, email: user.email, autonomousEnv: user.autonomousEnv } })+})+afterAll(async () => {+ await db?.$disconnect()+ await replica?.stop()+})++describe('Can chat, through the store', () => {+ it('refuses an upload and a message into a switched project\'s chat from a member without it, and takes them once granted', async () => {+ const store = new SuperTabStore(db, () => Date.now(), { store: new MemoryAttachmentStore(), prefix: 'super-tabs', publicBase: 'https://cdn.example.test' })+ const tab = (await store.create(owner, randomUUID(), 'Board', 'public')).id+ const execute = (command: Command, user = owner) => store.execute(user, tab, { operationId: randomUUID(), command })+ const invitation = await execute({ type: 'invite.create', email: peer.email, role: 'collaborator', conversationId: 'lead' })+ await execute({ type: 'invite.accept', inviteId: invitation.result.inviteId as string }, peer)+ const web = (await execute({ type: 'project.create', name: 'Web', visibility: 'public', brief: '' })).result as { projectId: string; conversationId: string }+ const upload = () => store.upload(peer, tab, web.conversationId, { name: 'plan.txt', mime: 'text/plain', body: Readable.from([Buffer.from('plan')]) })+ const say = () => execute({ type: 'message.send', conversationId: web.conversationId, text: 'Hello', replyTo: null, recipientIds: [] }, peer)++ // Not switched: as today.+ await upload()+ await execute({ type: 'project.boardMode', projectId: web.projectId, on: true })+ await expect(upload()).rejects.toMatchObject({ code: 'CHAT_NOT_ALLOWED', status: 403 })+ await expect(say()).rejects.toMatchObject({ code: 'CHAT_NOT_ALLOWED', status: 403 })+ await execute({ type: 'project.canChat', projectId: web.projectId, personId: peer.sub, granted: true })+ await upload()+ await say()+ })+})diff --git a/backend/src/superTabs/boardRights.test.ts b/backend/src/superTabs/boardRights.test.tsnew file mode 100644index 000000000..b4c4ec157--- /dev/null+++ b/backend/src/superTabs/boardRights.test.ts@@ -0,0 +1,284 @@+import { describe, expect, it } from 'vitest'+import { applyCommand, type Command, type CommandContext } from './commands.js'+import { createSuperTab, visibleState, type Actor, type SuperTabState } from './model.js'+import { projectOf } from './projects.js'+import { canChat, legacyAsks, steers, switched } from './boardRights.js'+import { openTasks } from './dispatch.js'+import { PM_SCHEDULE_TEXT, pmScheduleText, sweepDue } from './pmSchedule.js'+import { owedLines } from './inbox.js'+import { holdOf } from './pulse.js'++// Task #3819 (Phase 2 of docs/plans/2026-11-06-buddy-board-final-spec.md, Ken and anh Dee 11-06): a project's owner switches+// it to the Board way of working; in a switched project writing in its chat is a per-project Can chat right, and priority and+// pause follow roles, all on the server. A project not switched behaves exactly as today.+const swarmOwner: Actor = { kind: 'person', userId: 'owner', email: '[email protected]' }+const projectOwner: Actor = { kind: 'person', userId: 'p', email: '[email protected]' }+const granted: Actor = { kind: 'person', userId: 'c', email: '[email protected]' }+const member: Actor = { kind: 'person', userId: 'd', email: '[email protected]' }+const configuration = { engine: 'claude', model: null, effort: null, contextWindow: null, engineVersion: null }++export function boardFixture() {+ let state = createSuperTab('swarm', 'Team', { id: 'owner', email: '[email protected]' }, 'test')+ state.people.push({ id: 'p', email: '[email protected]', role: 'collaborator', generation: 'p1' },+ { id: 'c', email: '[email protected]', role: 'collaborator', generation: 'c1' },+ { id: 'd', email: '[email protected]', role: 'collaborator', generation: 'd1' })+ let next = 0+ const posted: Array<{ conversationId: string; text: string; recipients: readonly string[] }> = []+ const run = (command: Command, actor: Actor = projectOwner, context: Partial<CommandContext> = {}) => {+ const effect = applyCommand(state, actor, command, { operationId: `op${next++}`, now: 1000,+ contribution: { machineOwnerId: 'p', contributorId: actor.kind === 'person' ? actor.userId : 'p' }, ...context })+ state = effect.state+ posted.push(...effect.messages)+ return effect.result as Record<string, unknown>+ }+ const app = run({ type: 'project.create', name: 'App', visibility: 'public', brief: '' }) as { projectId: string; conversationId: string }+ const add = (harnessId: string, lead: boolean) => run({ type: 'agent.add', conversationId: app.conversationId, harnessId, machineId: 'machine',+ name: harnessId, lead, configuration }).agentId as string+ const pm = add('pm', true), worker = add('worker', false)+ const project = () => projectOf(state, app.projectId)+ const asAgent = (agentId: string): Actor => ({ kind: 'agent', agentId, machineOwnerId: 'p' })+ return { run, app, pm, worker, project, asAgent, posted, get state(): SuperTabState { return state } }+}++describe('a project\'s Board settings', () => {+ it('are set and cleared by the project owner or the Swarm owner, and read by every reader of the project', () => {+ const f = boardFixture()+ expect(switched(f.project())).toBe(false)+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true }, swarmOwner)+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'd' })+ expect(f.project()).toMatchObject({ boardMode: true, canChat: ['c'], decider: 'd' })+ expect(switched(f.project())).toBe(true)+ const seen = visibleState(f.state, member).projects!.find(p => p.id === f.app.projectId)!+ expect(seen).toMatchObject({ boardMode: true, canChat: ['c'], decider: 'd' })++ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: false })+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: null }, swarmOwner)+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: false }, swarmOwner)+ const project = f.project()+ expect(project.boardMode).toBeUndefined()+ expect(project.canChat).toBeUndefined()+ expect(project.decider).toBeUndefined()+ })++ it('refuse a member, the PM and any other agent', () => {+ const f = boardFixture()+ const commands: Command[] = [+ { type: 'project.boardMode', projectId: f.app.projectId, on: true },+ { type: 'project.canChat', projectId: f.app.projectId, personId: 'd', granted: true },+ { type: 'project.decider', projectId: f.app.projectId, personId: 'd' },+ ]+ for (const command of commands) {+ for (const actor of [member, granted, f.asAgent(f.pm), f.asAgent(f.worker)]) {+ expect(() => f.run(command, actor), `${command.type} by ${JSON.stringify(actor)}`).toThrow(expect.objectContaining({ status: 403 }))+ }+ }+ expect(f.project().boardMode).toBeUndefined()+ })++ it('grant and name only people who read the project', () => {+ const f = boardFixture()+ expect(() => f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'stranger', granted: true }))+ .toThrow(expect.objectContaining({ code: 'PERSON_UNKNOWN' }))+ expect(() => f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'stranger' }))+ .toThrow(expect.objectContaining({ code: 'PERSON_UNKNOWN' }))+ })++ it('give Can chat to the owners and the granted, and steering to the owners and the decider', () => {+ const f = boardFixture()+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'd' })+ const project = f.project()+ expect(['owner', 'p', 'c', 'd'].map(id => canChat(f.state, project, id))).toEqual([true, true, true, false])+ expect(['owner', 'p', 'c', 'd'].map(id => steers(f.state, project, id))).toEqual([true, true, false, true])+ // A person who left the Swarm keeps nothing.+ f.state.people.splice(f.state.people.findIndex(person => person.id === 'c'), 1)+ expect(canChat(f.state, project, 'c')).toBe(false)+ })+})++describe('Can chat in a switched project', () => {+ const say = (conversationId: string, text = 'Hello') => ({ type: 'message.send', conversationId, text, replyTo: null, recipientIds: [] }) as Command+ const switchedFixture = () => {+ const f = boardFixture()+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })+ return f+ }++ it('lets the owners and the granted write in its chat, and refuses everyone else, whatever the client', () => {+ const f = switchedFixture()+ for (const actor of [projectOwner, swarmOwner, granted]) f.run(say(f.app.conversationId), actor)+ expect(() => f.run(say(f.app.conversationId), member)).toThrow(expect.objectContaining({ code: 'CHAT_NOT_ALLOWED', status: 403 }))+ // An edit writes too: a member's message from before the switch stays as it was.+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: false })+ const before = f.run(say(f.app.conversationId, 'Before'), member).messageId as string+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ expect(() => f.run({ type: 'message.edit', conversationId: f.app.conversationId, messageId: before, text: 'After' }, member))+ .toThrow(expect.objectContaining({ code: 'CHAT_NOT_ALLOWED' }))+ expect(() => f.run({ type: 'agent.add', conversationId: f.app.conversationId, harnessId: 'h2', machineId: 'machine', name: 'h2', lead: false,+ configuration, initialMessage: 'Start here' }, member)).toThrow(expect.objectContaining({ code: 'CHAT_NOT_ALLOWED' }))+ })++ it('leaves agents, and people in a task\'s own chat, writing as today', () => {+ const f = switchedFixture()+ f.run(say(f.app.conversationId, 'From the PM'), f.asAgent(f.pm))+ const task = f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Task', priority: 'P2', requesterId: 'd',+ task: { goal: 'Do it', changes: 'It', constraints: 'None', owns: ['x'] }, checks: [{ description: 'Done', independent: false }] }).conversationId as string+ f.run(say(task, 'In the card chat'), member)+ // A person's own Buddy chat belongs to no project: writing there is never this right's to refuse.+ const buddyChat = f.run({ type: 'buddy.chat' }, member).conversationId as string+ f.run(say(buddyChat, 'To my Buddy'), member)+ })++ it('changes nothing in a project not switched', () => {+ const f = boardFixture()+ f.run(say(f.app.conversationId), member)+ })+})++describe('priority by role in a switched project', () => {+ const card = (f: ReturnType<typeof boardFixture>, requesterId: string, actor: Actor = projectOwner, priority: 'P0' | 'P1' | 'P2' | 'P3' = 'P2') =>+ f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Card', priority, requesterId,+ task: { goal: 'Do it', changes: 'It', constraints: 'None', owns: ['x'] }, checks: [{ description: 'Done', independent: false }] }, actor).conversationId as string+ const set = (f: ReturnType<typeof boardFixture>, conversationId: string, priority: 'P0' | 'P1' | 'P2' | 'P3', actor: Actor) =>+ f.run({ type: 'work.priority', conversationId, priority }, actor)+ const switchedFixture = () => {+ const f = boardFixture()+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'c' })+ return f+ }++ it('lets a member set P1-P3 on their own card, never P0 and never another\'s card', () => {+ const f = switchedFixture()+ const mine = card(f, 'd'), theirs = card(f, 'p')+ set(f, mine, 'P1', member)+ set(f, mine, 'P3', member)+ expect(() => set(f, mine, 'P0', member)).toThrow(expect.objectContaining({ code: 'PRIORITY_FORBIDDEN', status: 403 }))+ expect(() => set(f, theirs, 'P1', member)).toThrow(expect.objectContaining({ code: 'PRIORITY_FORBIDDEN' }))+ // A P0 the owners set stays theirs to lower.+ set(f, mine, 'P0', projectOwner)+ expect(() => set(f, mine, 'P2', member)).toThrow(expect.objectContaining({ code: 'PRIORITY_FORBIDDEN' }))+ expect(() => card(f, 'd', member, 'P0')).toThrow(expect.objectContaining({ code: 'PRIORITY_FORBIDDEN' }))+ })++ // The rule is for people: the PM's rights are today's (coordinatorOrPerson), untouched.+ it('lets the owners and the decider set any priority on any card', () => {+ const f = switchedFixture()+ const theirs = card(f, 'd')+ set(f, theirs, 'P0', projectOwner)+ set(f, theirs, 'P1', swarmOwner)+ set(f, theirs, 'P0', granted)+ card(f, 'd', granted, 'P0')+ })++ it('changes nothing in a project not switched', () => {+ const f = boardFixture()+ const theirs = card(f, 'p')+ set(f, theirs, 'P0', member)+ card(f, 'd', member, 'P0')+ })+})++describe('pause and resume', () => {+ const task = (f: ReturnType<typeof boardFixture>) => f.run({ type: 'conversation.create', projectId: f.app.projectId, title: 'Card', priority: 'P2',+ requesterId: 'd', task: { goal: 'Do it', changes: 'It', constraints: 'None', owns: ['x'] }, checks: [{ description: 'Done', independent: false }] }).conversationId as string+ const group = (f: ReturnType<typeof boardFixture>, id: string) => f.state.conversations.find(c => c.id === id)!+ const lines = (f: ReturnType<typeof boardFixture>, id: string) => f.posted.filter(m => m.conversationId === id).map(m => m.text)++ it('lets those who steer pause a task, with its reason and a line in it, and resume it', () => {+ const f = boardFixture()+ f.run({ type: 'project.decider', projectId: f.app.projectId, personId: 'c' })+ const id = task(f)+ f.run({ type: 'work.pause', conversationId: id, paused: true, reason: 'Wait for the release' }, granted)+ expect(group(f, id).paused).toMatchObject({ by: 'person:c', at: 1000, reason: 'Wait for the release' })+ expect(holdOf(group(f, id), '2026-11-06')).toEqual({ reason: expect.stringMatching(/paused/i) })+ f.run({ type: 'work.pause', conversationId: id, paused: false }, swarmOwner)+ expect(group(f, id).paused).toBeUndefined()+ expect(lines(f, id).join('\n')).toMatch(/paused[\s\S]*Wait for the release[\s\S]*resumed/i)+ })++ it('refuses a member, the PM and any other agent, in every project', () => {+ const f = boardFixture()+ const id = task(f)+ for (const actor of [member, f.asAgent(f.pm), f.asAgent(f.worker)]) {+ expect(() => f.run({ type: 'work.pause', conversationId: id, paused: true }, actor), JSON.stringify(actor))+ .toThrow(expect.objectContaining({ status: 403 }))+ }+ f.run({ type: 'work.pause', conversationId: id, paused: true }, projectOwner)+ expect(() => f.run({ type: 'work.pause', conversationId: id, paused: false }, member)).toThrow(expect.objectContaining({ code: 'PAUSE_FORBIDDEN' }))+ })++ // Readycheck's review: a hand assignment, or a start into the task, went past the pause.+ it('refuses assigning or starting an agent on a paused task, whoever asks', () => {+ const f = boardFixture()+ const id = task(f)+ f.run({ type: 'work.pause', conversationId: id, paused: true }, projectOwner)+ for (const actor of [projectOwner, f.asAgent(f.pm)]) {+ expect(() => f.run({ type: 'work.assign', conversationId: id, agentId: f.worker }, actor), JSON.stringify(actor))+ .toThrow(expect.objectContaining({ code: 'TASK_PAUSED' }))+ }+ expect(() => f.run({ type: 'agent.start', request: { conversationId: id, machineId: 'machine', engine: 'claude', name: 'Helper', cwd: '/repo', worktree: true,+ requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } }, routeDecisionId: 'route' }))+ .toThrow(expect.objectContaining({ code: 'TASK_PAUSED' }))+ })++ it('keeps a paused task from being handed out or chased, until it is resumed', () => {+ const f = boardFixture()+ const id = task(f)+ expect(openTasks(f.state, f.app.projectId, 1000).map(g => g.id)).toContain(id)+ expect(sweepDue(f.state, f.app.projectId, 1000)).toBe(true)+ f.run({ type: 'work.pause', conversationId: id, paused: true }, projectOwner)+ expect(openTasks(f.state, f.app.projectId, 1000).map(g => g.id)).not.toContain(id)+ expect(sweepDue(f.state, f.app.projectId, 1000)).toBe(false)+ f.run({ type: 'work.pause', conversationId: id, paused: false }, projectOwner)+ expect(openTasks(f.state, f.app.projectId, 1000).map(g => g.id)).toContain(id)+ })+})++describe('the PM text in a switched project', () => {+ const INBOX_LINE = /Answer each person's message once|Your inbox lists every unanswered message/++ it('drops the inbox lines, and a person\'s message there owes the PM nothing', () => {+ const f = boardFixture()+ f.run({ type: 'project.canChat', projectId: f.app.projectId, personId: 'c', granted: true })+ const ask = () => f.run({ type: 'message.send', conversationId: f.app.conversationId, text: 'Can you look at this?', replyTo: null, recipientIds: [f.pm] }, granted)+ // Not switched: today's text, and the ask is owed.+ expect(pmScheduleText(f.project())).toBe(PM_SCHEDULE_TEXT)+ ask()+ expect(owedLines(f.state, f.project(), 1000).join('\n')).toMatch(/Owed asks/)++ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ const text = pmScheduleText(f.project())+ expect(PM_SCHEDULE_TEXT).toMatch(INBOX_LINE)+ expect(text).not.toMatch(INBOX_LINE)+ expect(text).toContain('Keep a standing crew')+ // The ask from before the switch stays until its card exists (legacyAsks); a new one is never owed.+ expect(owedLines(f.state, f.project(), 1000).join('\n')).toMatch(/before this project switched/)+ const before = f.state.conversations.find(c => c.id === f.app.conversationId)!.owed?.length ?? 0+ ask()+ expect(f.state.conversations.find(c => c.id === f.app.conversationId)!.owed?.length ?? 0).toBe(before)+ })+})++describe('switching a project on', () => {+ it('hands over every message still owed to its PM, oldest first, and keeps each until its card exists', () => {+ const f = boardFixture()+ const ask = (text: string, actor: Actor) => f.run({ type: 'message.send', conversationId: f.app.conversationId, text, replyTo: null, recipientIds: [f.pm] }, actor).messageId as string+ const first = ask('First', member), second = ask('Second', granted)+ expect(legacyAsks(f.state, f.project())).toEqual([+ { messageId: first, conversationId: f.app.conversationId, personId: 'd', at: 1000, thread: first },+ { messageId: second, conversationId: f.app.conversationId, personId: 'c', at: 1000, thread: second },+ ])+ f.run({ type: 'project.boardMode', projectId: f.app.projectId, on: true })+ // No card is made here yet (#3817 makes them): the asks stay, so nothing is dropped.+ expect(legacyAsks(f.state, f.project()).map(a => a.messageId)).toEqual([first, second])+ // Readycheck's review: until their cards exist, the PM still sees them, while a message after the switch owes nothing.+ const owed = owedLines(f.state, f.project(), 1000).join('\n')+ expect(owed).toContain(first)+ expect(owed).toContain(second)+ const after = ask('After the switch', projectOwner)+ expect(owedLines(f.state, f.project(), 1000).join('\n')).not.toContain(after)+ })+})diff --git a/backend/src/superTabs/boardRights.ts b/backend/src/superTabs/boardRights.tsnew file mode 100644index 000000000..2118dad03--- /dev/null+++ b/backend/src/superTabs/boardRights.ts@@ -0,0 +1,68 @@+/**+ * Who may do what in a project switched to the Board way of working (task #3819, Phase 2 of+ * docs/plans/2026-11-06-buddy-board-final-spec.md, Ken and anh Dee 11-06). A project's owner switches it on (`boardMode`).+ * In a switched project, writing in its chat is the Can chat right: its owner and the Swarm's owner always, and the people+ * the owner granted (`canChat`). Setting P0 and pausing belong to those who steer it: its owner, the Swarm's owner and its+ * top decider (`decider`). A project not switched keeps today's rules. The server checks every one of these (commands.ts,+ * store.ts poster), so an older app is held to them too.+ */+import { fail, type Actor, type Conversation, type SuperTabState } from './model.js'+import { canReadProject, ownsProject, projectsOf, type SwarmProject } from './projects.js'++/** Whether [project] works the Board way. */+export const switched = (project: Pick<SwarmProject, 'boardMode'>): boolean => project.boardMode === true++/** Whether [userId] is a member of the Swarm who reads [project]: a person who left keeps no right. */+export function readsProject(state: SuperTabState, project: SwarmProject, userId: string): boolean {+ const person = state.people.find(p => p.id === userId)+ return !!person && canReadProject(state, { kind: 'person', userId: person.id, email: person.email ?? '' }, project)+}++/** Whether [userId] owns [project] or the Swarm: who sets its Board settings. */+export function ownsBoard(state: SuperTabState, project: SwarmProject, userId: string): boolean {+ return ownsProject(state, userId, project) || (userId === state.ownerId && state.people.some(p => p.id === userId))+}++/** Whether [userId] steers [project]: sets P0 on any card and pauses or resumes any task (its owners and its decider). */+export function steers(state: SuperTabState, project: SwarmProject, userId: string): boolean {+ return ownsBoard(state, project, userId) || (!!project.decider && project.decider === userId && readsProject(state, project, userId))+}++/** Whether [userId] may write in [project]'s chat once it is switched: its owners, and the people granted Can chat. */+export function canChat(state: SuperTabState, project: SwarmProject, userId: string): boolean {+ return ownsBoard(state, project, userId) || (!!project.canChat?.includes(userId) && readsProject(state, project, userId))+}++/** Refuses [actor] writing a message into [group] when it is a switched project's chat and they may not (canChat). Every+ * path that writes a person's message there calls it: postable (send, uploads, voice), edit, a launch's initial message+ * and a delivery's resend. Agents, Buddy proposals and task chats are unchanged. */+export function requireCanChat(state: SuperTabState, actor: Actor, group: Conversation): void {+ if (actor.kind !== 'person') return+ // Only a project's own chat: never groupProject, which refuses a person's Buddy chat (it belongs to no project).+ const project = projectsOf(state).find(p => p.leadConversationId === group.id)+ if (!project || !switched(project) || canChat(state, project, actor.userId)) return+ fail('CHAT_NOT_ALLOWED', 'Only the project owner and the people they allow write in this project\'s chat. Send it as a proposal through your Buddy, or ask the owner for Can chat.', 403)+}++/** Refuses a person's priority in a switched project unless they steer it or it is P1-P3 on a card they requested (the spec's+ * "Who may do what on the Board"): P0 goes ahead of everything, so only those who steer set it or lower it. [requesterId] is+ * the card's requester, or the one a new task names; [previous] its priority before. Agents keep today's rights. */+export function requirePriorityRight(state: SuperTabState, actor: Actor, project: SwarmProject, next: string, requesterId: string | undefined,+ previous?: string): void {+ if (actor.kind !== 'person' || !switched(project) || steers(state, project, actor.userId)) return+ if (next !== 'P0' && previous !== 'P0' && requesterId === actor.userId) return+ fail('PRIORITY_FORBIDDEN', 'In this project the owner and its decider set P0 and other people\'s priorities. You set P1-P3 on your own cards.', 403)+}++/** One message a person sent [project]'s PM that it has not answered, as switching the project on hands it to the proposal+ * cards (#3817 importLegacyProposal, agreed with Fir 11-06). The card shows the message by its id, so its text never travels. */+export interface LegacyAsk { messageId: string; conversationId: string; personId: string; at: number; thread: string }++/** Every message [project]'s PM still owes, oldest first, in its chat and its tasks' chats (pulse.ts owe). Switching the+ * project on keeps each one until its card exists, so nothing is dropped. */+export function legacyAsks(state: SuperTabState, project: SwarmProject): LegacyAsk[] {+ return state.conversations+ .filter(c => !c.archived && c.owed?.length && (c.id === project.leadConversationId || (c.projectId ?? 'lead') === project.id))+ .flatMap(c => c.owed!.map(ask => ({ messageId: ask.id, conversationId: c.id, personId: ask.personId, at: ask.at, thread: ask.thread })))+ .sort((a, b) => a.at - b.at)+}diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex 144f768bf..6aec6030e 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -10,6 +10,7 @@ import { agentDisplayName, assignAgentDisplayNames } from './agentNames.js'import { addedAgentName, renameAgentTo } from './agentRename.js'import { addCrew, CREW_ROLE_MAX, removeCrew } from './crew.js'import { noteIndex } from './processNotes.js'+import { ownsBoard, readsProject, requireCanChat, requirePriorityRight, steers } from './boardRights.js'import { keepUsernames, setUsername, swarmUsernames, usernameOf } from './usernames.js'import { agentWrittenNameOf, setName, shownNameOf } from './personNames.js'import { z } from 'zod'@@ -237,6 +238,10 @@ export const commandSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('project.rename'), projectId: id, name: title }).strict(),z.object({ type: z.literal('project.delete'), projectId: id }).strict(),z.object({ type: z.literal('project.sharing'), projectId: id, visibility: z.enum(['public', 'private']), memberIds: z.array(id).max(200) }).strict(),+ // A project's Board settings (boardRights.ts, task #3819), set by its owner or the Swarm's owner.+ z.object({ type: z.literal('project.boardMode'), projectId: id, on: z.boolean() }).strict(),+ z.object({ type: z.literal('project.canChat'), projectId: id, personId: id, granted: z.boolean() }).strict(),+ z.object({ type: z.literal('project.decider'), projectId: id, personId: id.nullable() }).strict(),z.object({ type: z.literal('project.cadence'), projectId: id, minutes: z.union([z.literal(1), z.literal(5), z.literal(15), z.literal(30)]) }).strict(),// A project's PM confirms a what-changed note for PMs (processNotes.ts, task #3581).z.object({ type: z.literal('process.confirm'), projectId: id, noteId: z.string().trim().min(1).max(80) }).strict(),@@ -306,6 +311,10 @@ export const commandSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('conversation.archive'), conversationId: id, archived: z.boolean() }).strict(),// A task's priority, changed by the PM or a person (taskPriority.ts); each change writes a line into the task.z.object({ type: z.literal('work.priority'), conversationId: id, priority: z.enum(TASK_PRIORITIES) }).strict(),+ // A pause (paused true) or resume (false) by someone who steers the task's project (boardRights.ts, task #3819). Not work.resume,+ // which carries lost work on.+ z.object({ type: z.literal('work.pause'), conversationId: id, paused: z.boolean(), reason: z.string().trim().min(1).max(500).optional() }).strict()+ .refine(c => c.paused || c.reason === undefined, 'A reason goes with a pause.'),z.object({ type: z.literal('conversation.requester'), conversationId: id, personId: id.nullable() }).strict(),// A task's place in its project's Next up (taskQueue.ts): `after` the open task it goes right after, null for the top, absent// to stay; `notBefore` a day it should not start before, null to clear.@@ -875,6 +884,7 @@ export function worksInProjectChat(state: SuperTabState, group: Conversation, ag* and opens no second terminal (#2207). */export function postable(state: SuperTabState, actor: Actor, conversationId: string) {const group = open(state, conversationId)+ requireCanChat(state, actor, group)if (actor.kind === 'agent' && !group.agentIds.includes(actor.agentId)) {if (projectAgent(state, actor, groupProject(state, group).id) && worksInProjectChat(state, group, actor.agentId)) return groupif (!joinsProject(state, group, actor.agentId)) fail('FORBIDDEN', 'This agent does not participate in the conversation.', 403)@@ -1191,6 +1201,22 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,}/** An agent starts or assigns only what the route chose; a person may still do either by hand. *//** A private conversation is chat only (design section 4.8). */+ /** The project whose Board settings [actor] sets: its owner's or the Swarm owner's (boardRights.ts, task #3819). */+ const boardOwned = (projectId: string): SwarmProject => {+ const project = readProject(state, actor, projectId)+ author(state, actor, true)+ if (actor.kind !== 'person' || !ownsBoard(state, project, actor.userId)) {+ fail('PROJECT_OWNER_REQUIRED', 'Only the project owner or the Swarm owner changes how this project works.', 403)+ }+ mutableProjects(state)+ return projectOf(state, projectId)+ }+ /** Refuses new work on a task paused by someone who steers its project (boardRights.ts, task #3819): a hand assignment and a+ * start into it, as dispatch already skips it (Readycheck's review). */+ const pausedTask = (group: Conversation) => {+ if (group.paused) fail('TASK_PAUSED', 'This task is paused. Its project owner or decider resumes it first.', 409)+ }+ const personUnknown = (): never => fail('PERSON_UNKNOWN', 'Name a person who reads this project.', 400)const chatOnly = (conversationId: string) => {if (state.conversations.find(c => c.id === conversationId)?.audience) fail('AUDIENCE_CHAT_ONLY', 'A private conversation is chat only.', 400)}@@ -1705,6 +1731,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,fail('START_PENDING', 'Wait for the host to finish this agent’s launch and model selection.')}if (state.paused) fail('PAUSED', 'New work is paused in this Super Tab.')+ pausedTask(group)if (activeWork(group)) fail('WORK_ACTIVE', 'The current assignment must finish or be reconciled before reassignment.')// Before anything changes: a task given to a closed session is lost at once, and its agent then stays listed until the// task is handed on (closedAgents.ts removeClosedAgents). Without a task it leaves on its machine's next report.@@ -2067,6 +2094,29 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,endLostProjectSessions(project)break}+ case 'project.boardMode': {+ const project = boardOwned(command.projectId)+ if (command.on) project.boardMode = true+ else delete project.boardMode+ break+ }+ case 'project.canChat': {+ const project = boardOwned(command.projectId)+ if (command.granted && !readsProject(state, project, command.personId)) personUnknown()+ // An id whose person left matches nothing (boardRights.ts) and drops out here.+ const kept = (project.canChat ?? []).filter(personId => personId !== command.personId && readsProject(state, project, personId))+ const next = command.granted ? [...kept, command.personId] : kept+ if (next.length) project.canChat = next+ else delete project.canChat+ break+ }+ case 'project.decider': {+ const project = boardOwned(command.projectId)+ if (command.personId === null) delete project.decider+ else if (readsProject(state, project, command.personId)) project.decider = command.personId+ else personUnknown()+ break+ }case 'project.cadence': {const project = readProject(state, actor, command.projectId)if (actor.kind !== 'person') fail('HUMAN_REQUIRED', 'A person chooses the update cadence.', 403)@@ -2584,6 +2634,8 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,// A step and a private chat are no tasks of their own, so they carry no priority (taskPriority.ts).const prioritized = !command.step && !command.audienceif (command.priority && !prioritized) fail('PRIORITY_TASK_ONLY', 'Only a task has a priority: leave it out of a step or a private chat.', 400)+ // In a switched project a person's P0, or a task for someone else, needs a right (boardRights.ts, task #3819).+ if (command.priority) requirePriorityRight(state, actor, project, command.priority, command.requesterId ?? undefined)// A hotfix jumps every queue, so of the agents only the PM marks one (River, task #3117).if (command.priority === 'P0' && actor.kind === 'agent' && ledProject(state, actor.agentId)?.id !== project.id) {fail('PRIORITY_P0', 'Only the PM or a person sets P0. Give this task P1, P2 or P3.', 403)@@ -2764,6 +2816,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,}// A task from before priorities reads as its title marks it, as every client shows it.const previous: TaskPriority = task.priority ?? titlePriority(task.title) ?? DEFAULT_PRIORITY+ requirePriorityRight(state, actor, project, command.priority, task.requesterId, previous)task.priority = command.priorityif (previous === command.priority) breakconst name = actor.kind === 'person' ? shownNameOf(state, actor.userId) ?? 'Someone'@@ -2771,6 +2824,30 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,message(task.id, priorityLine(name, command.priority, previous), [], null, SYSTEM_ROW)break}+ case 'work.pause': {+ chatOnly(command.conversationId)+ const task = open(state, command.conversationId)+ readConversation(state, actor, task.id)+ const project = groupProject(state, task)+ if (task.id === project.leadConversationId || task.kind || task.audience || task.step) {+ fail('PAUSE_TASK_ONLY', 'Only a task pauses: name a task, not a chat or a step.', 400)+ }+ if (actor.kind !== 'person' || !steers(state, project, actor.userId)) {+ fail('PAUSE_FORBIDDEN', 'Only the project owner and its decider pause or resume a task.', 403)+ }+ author(state, actor, true)+ const name = shownNameOf(state, actor.userId) ?? 'Someone'+ const worker = activeWork(task) && task.assignment ? [task.assignment.agentId] : []+ if (command.paused) {+ task.paused = { by: actorKey(actor), at: context.now, ...command.reason ? { reason: command.reason } : {} }+ message(task.id, `${name} paused this task${command.reason ? `: ${command.reason}` : '.'}`+ + (worker.length ? ' Stop at a safe point, then set your status to blocked until it is resumed.' : ''), worker, null, SYSTEM_ROW)+ } else if (task.paused) {+ delete task.paused+ message(task.id, `${name} resumed this task.${worker.length ? ' Carry on where you stopped.' : ''}`, worker, null, SYSTEM_ROW)+ }+ break+ }case 'conversation.merged': {chatOnly(command.conversationId)projectChatWork(command.conversationId)@@ -2940,6 +3017,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,// the shared conversation without delivering the same request twice.if (command.initialMessage) {if (actor.kind !== 'person') fail('FORBIDDEN', 'Only a person can record their initial launch request.', 403)+ requireCanChat(state, actor, group)message(group.id, command.initialMessage)}// A Product Manager started on its person's own Mac says, as one the Swarm starts does (leadJoined), when it does not@@ -2955,6 +3033,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,projectChatJoin(open(state, command.request.conversationId), null, command.request.name)const home = groupProject(state, open(state, command.request.conversationId))if (state.paused) fail('PAUSED', 'New work is paused in this Super Tab.')+ pausedTask(open(state, command.request.conversationId))if (!['claude', 'codex'].includes(command.request.engine)) {fail('SWARM_ENGINE', 'A Swarm agent runs only Claude Code or Codex.', 400)}@@ -3802,6 +3881,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,}case 'message.edit':// `command` is the cleaned one (withoutCredentials): the store writes this text, never the one it was sent.+ requireCanChat(state, actor, open(state, command.conversationId))result.changed = editMessage(open(state, command.conversationId), actor, command.messageId, command.text, context.messageChange)if (result.changed) effects.messageEdit = { messageId: command.messageId, text: command.text }break@@ -4040,6 +4120,7 @@ function applyCommandOnce(original: SuperTabState, actor: Actor, input: Command,const target = agent(state, delivery.agentId)if (command.resolution === 'resend') {open(state, group.id)+ requireCanChat(state, actor, group)if (!group.agentIds.includes(target.id)) fail('INVALID_RECIPIENT', 'This agent is no longer in the conversation.', 400)message(group.id, delivery.text, [target.id], delivery.messageId, SYSTEM_ROW, delivery.attachments)} else {diff --git a/backend/src/superTabs/dispatch.ts b/backend/src/superTabs/dispatch.tsindex d30ada063..12574a33d 100644--- a/backend/src/superTabs/dispatch.ts+++ b/backend/src/superTabs/dispatch.ts@@ -135,7 +135,9 @@ export function openTasks(state: SuperTabState, projectId: string, now: number):return !!task && !task.archived && (task.projectId ?? 'lead') === projectId && activeWork(task)})const open = [...queueSiblings(state, project), ...lostSteps].filter(group => (group.task || group.brief.trim())- && !activeWork(group) && !['done', 'cancelled'].includes(group.assignment?.status ?? '') && !(group.notBefore && group.notBefore > today))+ && !activeWork(group) && !['done', 'cancelled'].includes(group.assignment?.status ?? '') && !(group.notBefore && group.notBefore > today)+ // Paused by someone who steers its project (boardRights.ts, task #3819): until resumed.+ && !group.paused)const ordered = queueOrder(open)return [...ordered.filter(g => g.priority === 'P0'), ...ordered.filter(g => g.priority !== 'P0')]}diff --git a/backend/src/superTabs/inbox.ts b/backend/src/superTabs/inbox.tsindex 91ee5bffa..a7c1ae96d 100644--- a/backend/src/superTabs/inbox.ts+++ b/backend/src/superTabs/inbox.ts@@ -10,6 +10,7 @@ import { digestIsDue, noticeLine } from './noticeDigest.js'import { TURN_END_WAIT_MS } from './turnEnd.js'import { ledProject, type SwarmProject } from './projects.js'import { noteLines } from './processNotes.js'+import { switched } from './boardRights.js'import { swarmUsernames } from './usernames.js'/** What a host reports (machines.ts `capabilities`) when it sends its PM's turn with the PM's delivery list read (cli@@ -83,7 +84,11 @@ export function owedLines(state: SuperTabState, project: SwarmProject, now: numbif (!asks.length) return processconst names = swarmUsernames(state)const ago = (at: number) => `${Math.max(0, Math.round((now - at) / MINUTE))}m`- return [...process, `Owed asks (${asks.length}, oldest ${ago(asks[0]!.at)}). Answer each once, in its place: harness super-tab answer GROUP MESSAGE_ID TEXT OPERATION_ID.`,+ // A switched project records no new ask (pulse.ts owe, task #3819): what is left came before the switch, and stays until it+ // is answered or its proposal card exists (boardRights.ts legacyAsks), so nothing is dropped (Readycheck's review).+ const header = switched(project) ? `Owed from before this project switched to the Board (${asks.length}, oldest ${ago(asks[0]!.at)}), until each has its proposal card.`+ : `Owed asks (${asks.length}, oldest ${ago(asks[0]!.at)}).`+ return [...process, `${header} Answer each once, in its place: harness super-tab answer GROUP MESSAGE_ID TEXT OPERATION_ID.`,...asks.slice(0, OWED_LINES_MAX).map(a => `- from ${names.get(a.personId) ?? 'a person'}, ${ago(a.at)} ago (message ${a.id} in ${a.conversationId})`),...asks.length > OWED_LINES_MAX ? [`And ${asks.length - OWED_LINES_MAX} more owed: the board lists them all.`] : []]}diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 2123891ca..6b4521cf6 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -504,6 +504,9 @@ export interface Conversation {notBefore?: string/** Why its not-before date holds it (heldReason.ts), set with the date by work.queue. Absent on a hold from before reasons. */hold?: import('./heldReason.js').HeldReason+ /** A pause by someone who steers its project (boardRights.ts, task #3819): who (actorKey), when and why. While set, the task+ * is not handed out (dispatch.ts) or chased by the PM's sweep (pmSchedule.ts), and shows held (pulse.ts). */+ paused?: { by: string; at: number; reason?: string }/** How urgent its task is (taskPriority.ts), set by conversation.create and work.priority. Absent on a step, a chat and a task* from before priorities, which reads as P2. */priority?: import('./taskPriority.js').TaskPrioritydiff --git a/backend/src/superTabs/parts/light.test.ts b/backend/src/superTabs/parts/light.test.tsindex fc41983af..3c8935cbd 100644--- a/backend/src/superTabs/parts/light.test.ts+++ b/backend/src/superTabs/parts/light.test.ts@@ -66,6 +66,7 @@ const conversation: Required<Conversation> = {number: 1,openedBy: 'server',owed: [],+ paused: { by: 'person:owner', at: 1, reason: 'Wait' },pin: { agentId: 'a', why: 'ci', at: 1 },priority: 'P0',projectId: 'p',diff --git a/backend/src/superTabs/parts/light.ts b/backend/src/superTabs/parts/light.tsindex 442b5b159..8958ea72b 100644--- a/backend/src/superTabs/parts/light.ts+++ b/backend/src/superTabs/parts/light.ts@@ -91,6 +91,7 @@ export const GROUP_FIELDS = {'number','openedBy','owed',+ 'paused','pin','priority','proposals',diff --git a/backend/src/superTabs/pmSchedule.ts b/backend/src/superTabs/pmSchedule.tsindex fddc7a42e..7c5b284e3 100644--- a/backend/src/superTabs/pmSchedule.ts+++ b/backend/src/superTabs/pmSchedule.ts@@ -6,6 +6,7 @@ import { DEFAULT_TIME_ZONE } from './costs/reflection.js'import { taskLiveness } from './liveness.js'import { archivable } from './tidy.js'import { processLines, unconfirmedNote } from './processNotes.js'+import { switched } from './boardRights.js'// Every project's coordinator runs the same built-in schedule, woken by the Swarm on its own poll instead of a timer of its// own (Ken, 2026-11-04; docs/plans/2026-11-04-pm-built-in-schedule-design.md): a Codex PM may have no timer, and a restart@@ -86,6 +87,15 @@ What people teach you:if it is missing. Count repeats by person, and give the day's count in your nightly reflection, or in the next morningdigest when the project has no reflection.`+/** The built-in text's inbox line, which a project switched to the Board way of working drops (task #3819): its PM answers no+ * one in the chat, and nothing is owed to it there. */+const INBOX_LINE = '- Answer each person\'s message once, in its place. Your inbox lists every unanswered message until it is answered.\n'+if (!PM_SCHEDULE_TEXT.includes(INBOX_LINE)) throw new Error('pmSchedule.ts: the built-in text lost its inbox line; update INBOX_LINE')+const BOARD_SCHEDULE_TEXT = PM_SCHEDULE_TEXT.replace(INBOX_LINE, '')++/** The built-in text [project]'s coordinator reads: without the inbox line once it is switched (boardRights.ts). */+export const pmScheduleText = (project: Pick<SwarmProject, 'boardMode'>): string => switched(project) ? BOARD_SCHEDULE_TEXT : PM_SCHEDULE_TEXT+/** The schedule's clock: slot n starts at n * 30 minutes, in UTC. */export const SCHEDULE_SLOT_MS = 30 * 60_000export const scheduleSlot = (now: number): number => Math.floor(now / SCHEDULE_SLOT_MS)@@ -105,7 +115,8 @@ export function sweepDue(state: SuperTabState, projectId: string, now: number):const task = group.reviewOf ? state.conversations.find(c => c.id === group.reviewOf) : undefinedreturn archivable(state, group, now) && !group.pullRequestUrls?.length && !task?.pullRequestUrls?.length}- if (group.reviewOf) return false+ // A paused task waits on whoever paused it, not on the PM (boardRights.ts, task #3819).+ if (group.reviewOf || group.paused) return falseif (!group.assignment) return trueconst liveness = taskLiveness(state, group, now)return liveness?.state === 'orphaned' || (liveness?.state === 'waiting' && (liveness.why === 'person' || liveness.why === 'blocked'))diff --git a/backend/src/superTabs/projects.ts b/backend/src/superTabs/projects.tsindex e5f3d0383..dab665824 100644--- a/backend/src/superTabs/projects.ts+++ b/backend/src/superTabs/projects.ts@@ -56,6 +56,12 @@ export interface SwarmProject {* the daily tidy was last asked, and the instructions revision its last save made; `tidyPending`: asked, and no save has* followed yet (pmSchedule.ts tidyRequest; tasks #3022, #3151). */schedule?: { lastSlot: number; wakeId?: string; heardAt?: number; tidiedOn?: string; tidiedRevision?: number; tidyPending?: boolean }+ /** The Board way of working (boardRights.ts, task #3819): `boardMode` true once its owner switched it on, absent otherwise;+ * `canChat` the people its owner granted the right to write in its chat (its owners always have it); `decider` its top+ * decider, who sets P0 and pauses as its owners do. Every reader of the project reads them. */+ boardMode?: true+ canChat?: string[]+ decider?: string/** The what-changed note for PMs (processNotes.ts, task #3581) its PM was last woken for, and the newest it confirmed. */processNote?: { told?: string; confirmed?: string }/** The oldest message a person sent its PM in the last day that the PM has not answered, and when it was sent, as the worker'sdiff --git a/backend/src/superTabs/pulse.ts b/backend/src/superTabs/pulse.tsindex 9bd786a2a..8432bf549 100644--- a/backend/src/superTabs/pulse.ts+++ b/backend/src/superTabs/pulse.ts@@ -12,6 +12,7 @@ import { heldView, type HeldReason } from './heldReason.js'import { isLeads, type Author, type Conversation, type SuperTabState } from './model.js'import { agentProjectId, groupProject, type SwarmProject } from './projects.js'import { unconfirmedNote } from './processNotes.js'+import { switched } from './boardRights.js'/** One person's message to the PM not settled yet: its id, who wrote it, when, and the root of the thread it is in (its own* id for a top-level message). */@@ -43,7 +44,8 @@ export function owe(state: SuperTabState, group: Conversation, message: { id: stif (message.author.kind !== 'person' || message.source || !counted(group)) returnconst project = projectOfGroup(state, group)const pm = project && pmOf(state, project)- if (!pm || !message.recipients.includes(pm)) return+ // A project switched to the Board way of working owes its PM no chat messages (boardRights.ts, task #3819).+ if (!pm || !message.recipients.includes(pm) || switched(project)) returngroup.owed = [...(group.owed ?? []).filter(ask => ask.id !== message.id), { id: message.id, personId: message.author.id, at: now, thread: message.thread ?? message.id }].slice(-MAX_OWED)}@@ -129,6 +131,8 @@ export function heldWords(reason: HeldReason): string {* with #3390: the agent's result text decided it before, a second way to decide one thing.*/export function holdOf(group: Conversation, today: string): { reason: string | null } | null {+ // A pause by someone who steers its project (boardRights.ts, task #3819), with its reason when one was given.+ if (group.paused) return { reason: group.paused.reason ? `paused: ${group.paused.reason}` : 'paused' }const assignment = group.assignmentconst dated = !assignment && !!group.notBefore && group.notBefore > todayconst stated = !!assignment && (assignment.status === 'blocked' || assignment.status === 'needs_human')diff --git a/backend/src/superTabs/read/hostRows.ts b/backend/src/superTabs/read/hostRows.tsindex 7eb8841c2..492fa7ffc 100644--- a/backend/src/superTabs/read/hostRows.ts+++ b/backend/src/superTabs/read/hostRows.ts@@ -11,11 +11,13 @@ import { agentProjectId, agentSetRole, canWatchAgent, isConfidential, groupProjeimport type { HostAgentRow, HostPool, HostRosterRow, HostTabRows } from './contract.js'import { hostEtag } from './hostEtag.js'import { coordinatorNameOf, FIRST_INSTRUCTIONS, instructionsHash, roleNameOf } from '../instructions.js'-import { PM_SCHEDULE_TEXT } from '../pmSchedule.js'+import { PM_SCHEDULE_TEXT, pmScheduleText } from '../pmSchedule.js'import { PM_RESTART_AFTER_MS } from '../timeChecks.js'-/** The built-in PM schedule's hash, once: it changes only with a backend release. */-const BUILT_IN_HASH = instructionsHash(PM_SCHEDULE_TEXT)+/** The built-in PM schedule's hash, once per text: it changes only with a backend release, and with a project's switch to the+ * Board way of working (pmSchedule.ts pmScheduleText, task #3819). */+const BUILT_IN_HASHES = new Map<string, string>([[PM_SCHEDULE_TEXT, instructionsHash(PM_SCHEDULE_TEXT)]])+const builtInHash = (text: string): string => BUILT_IN_HASHES.get(text) ?? (BUILT_IN_HASHES.set(text, instructionsHash(text)), BUILT_IN_HASHES.get(text)!)export interface HostLookups {/** The Swarm's people with their account emails (observers). */@@ -96,7 +98,7 @@ function agentRow(tabId: string, state: SuperTabState, machineId: string, user:// running daemons read the text again (2026-11-02: agents kept the old routing after #2495, as revision 0 never moves).instructions: home ? { projectId: home.id, revision: home.instructionsRevision ?? 0,hash: home.instructionsHash ?? (home.instructionsRevision ? null : FIRST_INSTRUCTIONS.instructionsHash),- coordinatorName: coordinatorNameOf(home), ...ledProject(state, target.id)?.id === home.id ? { builtInHash: BUILT_IN_HASH } : {} } : null,+ coordinatorName: coordinatorNameOf(home), ...ledProject(state, target.id)?.id === home.id ? { builtInHash: builtInHash(pmScheduleText(home)) } : {} } : null,...(custom ? { role: chosen && { ...chosen, projectId: custom.id } } : {}),lead: !!ledProject(state, target.id),// What a PM owes people, and how long it may while it hangs: its host restarts it after that (timeChecks.ts, cli host.ts).diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 7a459d16b..d803fe85e 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -111,7 +111,7 @@ import { STATUS_LABELS,import { QUIET_CLAIM, type HoldReason } from './holdReason.js'import { stuck } from './deliverySettle.js'import { agentPost, digestIsDue, digestMessage, digestText, doneRow, endedAlert, GATHERED_LIMIT_MS, gatheredMessage, NOTICE_DIGEST_MAX, noticeLine } from './noticeDigest.js'-import { PM_SCHEDULE_TEXT, recordTidy, recordWake, scheduleRequest, tidyRequest } from './pmSchedule.js'+import { pmScheduleText, recordTidy, recordWake, scheduleRequest, tidyRequest } from './pmSchedule.js'import { agentDisplayName } from './agentNames.js'import { endedHolds, startedHolds, tokenTask, type WorkHold } from '../github/holds.js'import { accrueLent, addLent, lentAgents, lentProjects } from './leaderboard/lent.js'@@ -3253,7 +3253,7 @@ export class SuperTabStore {const coordinator = actor.kind === 'agent' && ledProject(state, actor.agentId)?.id === project.idreturn { projectId, revision, hash: stored ? stored.hash : FIRST_INSTRUCTIONS.instructionsHash, text: stored?.text ?? INSTRUCTIONS_TEMPLATE, template: !stored,coordinatorName: coordinatorNameOf(project), notesRevision: project.notesRevision ?? 0, ...(notes ? { notes } : {}),- ...(coordinator ? { builtIn: PM_SCHEDULE_TEXT } : {}) }+ ...(coordinator ? { builtIn: pmScheduleText(project) } : {}) }})}diff --git a/backend/vitest.super-tabs.config.ts b/backend/vitest.super-tabs.config.tsindex 611112b19..1052e6405 100644--- a/backend/vitest.super-tabs.config.ts+++ b/backend/vitest.super-tabs.config.ts@@ -8,5 +8,5 @@ export default defineConfig({ test: { include: ['integration/superTabs.test.ts','integration/superTabBuddyProbes.test.ts', 'integration/superTabBuddySessions.test.ts', 'integration/superTabSwarmBuddy.test.ts', 'integration/superTabPersonalLead.test.ts', 'integration/superTabCosts.test.ts', 'integration/harnessSharesList.test.ts', 'integration/harnessSharesIndexPlan.test.ts', 'integration/atlasSnapshot.test.ts', 'integration/queryStats.test.ts','integration/superTabEvidence.test.ts', 'integration/superTabAttemptModels.test.ts', 'integration/superTabNamedReads.test.ts', 'integration/swarmSweepPlans.test.ts', 'integration/overdueDecisions.test.ts', 'integration/workerIndexPlans.test.ts', 'integration/superTabReflection.test.ts', 'integration/superTabScorecard.test.ts','integration/superTabMessagePages.test.ts', 'integration/superTabDeliveryCompaction.test.ts', 'integration/superTabNoticeDigest.test.ts', 'integration/superTabPmSchedule.test.ts', 'integration/superTabDigestHour.test.ts', 'integration/superTabCommandLoads.test.ts', 'integration/superTabThreads.test.ts', 'integration/superTabMachineRemovals.test.ts',- 'integration/superTabInstructions.test.ts', 'integration/superTabInstructionsRebase.test.ts', 'integration/superTabInstructionsRestore.test.ts', 'integration/superTabProjectRules.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabTaskLines.test.ts', 'integration/superTabDeletion.test.ts', 'integration/communityReports.test.ts', 'integration/superTabMachineNames.test.ts', 'integration/superTabComputerMoves.test.ts', 'integration/superTabTagsClear.test.ts', 'integration/swarmAgentTombstones.test.ts', 'integration/superTabPullRequestEvents.test.ts', 'integration/superTabTimeChecks.test.ts', 'integration/superTabReleases.test.ts', 'integration/superTabReviewSteps.test.ts', 'integration/superTabMergeTrain.test.ts', 'integration/superTabProposals.test.ts', 'integration/superTabRequestReads.test.ts', 'integration/superTabVoiceMessages.test.ts', 'integration/superTabThumbnails.test.ts', 'integration/superTabProjectChatWorkers.test.ts', 'integration/prismaQueryTiming.test.ts', 'integration/secondaryReads.test.ts', 'integration/pushDevices.test.ts', 'integration/crewDispatch.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/noDefaultDigest.test-support.ts', 'integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],+ 'integration/superTabInstructions.test.ts', 'integration/superTabInstructionsRebase.test.ts', 'integration/superTabInstructionsRestore.test.ts', 'integration/superTabProjectRules.test.ts', 'integration/superTabWorkflow.test.ts', 'integration/superTabTaskLines.test.ts', 'integration/superTabDeletion.test.ts', 'integration/communityReports.test.ts', 'integration/superTabMachineNames.test.ts', 'integration/superTabComputerMoves.test.ts', 'integration/superTabTagsClear.test.ts', 'integration/swarmAgentTombstones.test.ts', 'integration/superTabPullRequestEvents.test.ts', 'integration/superTabTimeChecks.test.ts', 'integration/superTabReleases.test.ts', 'integration/superTabReviewSteps.test.ts', 'integration/superTabMergeTrain.test.ts', 'integration/superTabProposals.test.ts', 'integration/superTabCanChat.test.ts', 'integration/superTabRequestReads.test.ts', 'integration/superTabVoiceMessages.test.ts', 'integration/superTabThumbnails.test.ts', 'integration/superTabProjectChatWorkers.test.ts', 'integration/prismaQueryTiming.test.ts', 'integration/secondaryReads.test.ts', 'integration/pushDevices.test.ts', 'integration/crewDispatch.test.ts'], hookTimeout: 120000, testTimeout: 30000, setupFiles: ['integration/noDefaultDigest.test-support.ts', 'integration/cacheOn.test-support.ts', 'src/lib/noRedis.test-support.ts'],fileParallelism: false, env: { NODE_ENV: 'test', HARNESS_CREDENTIAL_ENCRYPTION_KEY: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' } } })diff --git a/docs/plans/2026-11-06-project-switch-rights-plan.md b/docs/plans/2026-11-06-project-switch-rights-plan.mdnew file mode 100644index 000000000..bff143255--- /dev/null+++ b/docs/plans/2026-11-06-project-switch-rights-plan.md@@ -0,0 +1,147 @@+# Project switch, Can chat, and priority and pause rights (task #3819)++> Implemented by its Engineer test first, by superpowers:test-driven-development, as the project's instructions say+> (Engineer role). No subagent-driven-development and no execution handoff.++**Goal:** Phase 2 of the approved spec (docs/plans/2026-11-06-buddy-board-final-spec.md, Ken and anh Dee, 11-06), backend+part of #3819. A project's owner switches it to the Board way of working. In a switched project, writing in its chat is a+per-project Can chat right, and priority and pause follow roles. All of these are enforced on the server, so an older app+is held to them too. A switched project's PM text drops the inbox lines. Projects that are not switched behave exactly as+today.++**Architecture:**+1. Three project settings in `SwarmProject` (projects.ts), read by every reader of the project:+ - `boardMode?: true`: switched on, absent otherwise.+ - `canChat?: string[]`: people granted Can chat. The project owner and the Swarm owner always have it and are not listed.+ - `decider?: string`: the project's top decider (for openharness, Dee).++ The project owner or the Swarm owner sets them with `project.boardMode {projectId, on}`, `project.canChat {projectId,+ personId, granted}` and `project.decider {projectId, personId | null}`. A rights module (`boardRights.ts`) answers:+ `switched(project)`, `canChat(state, project, userId)`, `steers(state, project, userId)` (owner, Swarm owner or+ decider).+2. **Can chat:** `postable()` (commands.ts) refuses a person without the right to write in a switched project's chat with+ CHAT_NOT_ALLOWED (403). postable covers message.send and every upload and voice path (store.ts poster). The same check+ also guards message.edit, agent.add's initialMessage and delivery.resolve's resend in that chat. Reactions, deletes,+ Buddy proposals and agents are unchanged.+3. **Priority by role**, in a switched project, for people: only someone who steers sets P0, or changes the priority of a+ card they did not request; anyone else gets PRIORITY_FORBIDDEN (403). A member sets P1-P3 on their own cards. This+ covers both `work.priority` and a person's `conversation.create`. The PM keeps today's rights.+4. **Pause and resume:**+ - `work.pause {conversationId, reason?}` and `work.resume {conversationId}` set or clear `paused {by, at, reason?}` on a+ task. Only someone who steers may send them; anyone else gets PAUSE_FORBIDDEN (403).+ - Each change writes a line into the task, and its assignee is told.+ - A paused task is not handed out (dispatch.ts), not chased by the PM's sweep (pmSchedule.ts sweepDue), and shows as+ held on the board (pulse.ts holdOf). A hand assignment or a start into it is refused with TASK_PAUSED (Readycheck's+ review).+ - Pause and resume are new commands, so they work in every project. Nothing changes for a project that never sends+ them.+5. **PM text follows the switch:**+ - A switched project's coordinator gets `pmScheduleText(project)`: the built-in text without its inbox line, served+ from store.ts instructions and hashed per project in read/hostRows.ts.+ - Its wakes and digests carry no owed-asks lines (inbox.ts owedLines).+ - A person's message there records no owed ask (pulse.ts owe).+ - `PM_SCHEDULE_TEXT` itself is unchanged, so the what-changed note pin (processNotes.ts) stands.+6. **Switch-on migration**, at the boundary agreed with Fir (#3817):+ - `project.boardMode on` hands each unanswered ask in the project chat, oldest first, to Fir's pure+ `importLegacyProposal(state, project, ask, now)`, with `ask = {messageId, conversationId, personId, at, thread}`. The+ command's state holds no message text, so the card shows the message by its id.+ - It clears only the asks the helper turned into cards (Fir, 11-06). Until the helper is wired, the asks stay, and the+ PM's wakes and inbox keep listing them under "Owed from before this project switched", so nothing is dropped+ (Readycheck's review). A message after the switch is never owed.+ - `legacyAsks(state, project)` builds that list and is tested here.+ - Whichever of #3817 and #3819 merges second wires the call.+7. **The board read** that returns only what changed is the existing changes feed (`GET /:tabId/changes?cursor`,+ read/changes.ts). The new settings ride the project's part, and `paused` rides the task's part. No new route.++**Tech Stack:** TypeScript, vitest (backend unit), the Super Tab integration suite in PR CI.++**Spec:** task #3819's brief (River, 11-06), and the approved spec's "Who can write in the project chat", "Who may do what on+the Board", Phase 2 item 1 and Rollout sections.++## Global Constraints++- A project without `boardMode` reads, writes and wakes exactly as today: every test of today's behaviour passes unchanged.+- Every right is checked in the command or store path a client calls, never only in an app.+- Two security reviews (rights).+- Swarm code stays in backend/src/superTabs/; nothing in cli/src/core.++## Design++- growth: three small fields per project and one `paused` record per task, removed on resume. A grant names a member; an id+ whose person left matches nothing, and the next grant or revoke drops it.+- concurrency: every write goes through applyCommand's per-tab commit, as project.sharing does; switch-on migration runs in+ the same command, so the asks are taken once.+- read cost: none new. The settings travel in the project part and `paused` in the task's part, both through the changes+ feed.+- scale: at 10x members a canChat list stays a few dozen ids; the first warning would be the project part's size, far below+ any limit.+- compatibility: an older app shows a switched project as today, and its writes are refused with a plain message. An older+ backend ignores the fields, and nothing is switched on before this ships.+- migration + rollback: none on deploy; switching a project off restores today's chat rules at once. Proposal cards made+ meanwhile stay.+- audience: only the project owner or Swarm owner changes the settings; the server enforces chat, priority and pause rights.+- identity: by the person's Swarm id from the signed-in actor, never a machine owner's login; an agent never counts as a+ person.+- failure: each refusal says who may do it; none is silent.+- platforms: server only; every app is held to it.++## Review Focus++- No path lets a person without Can chat write a message into a switched project's chat (send, upload, voice, edit,+ initial message, resend).+- A non-switched project behaves exactly as today.+- P0 and pause from anyone who does not steer are refused, whatever the client.++## Tasks++### Task 1: project settings++**Files:** projects.ts, boardRights.ts (new), commands.ts, boardRights.test.ts.+**Interfaces:** `project.boardMode`, `project.canChat`, `project.decider`; `switched`, `canChat`, `steers`.++- [ ] Failing test: the owner and the Swarm owner set and clear each setting; a member, the PM and another agent are+ refused; a grant names a member of the project; readers of the project see the settings.+- [ ] Code.++### Task 2: Can chat is enforced++**Files:** commands.ts (postable, message.edit, agent.add, delivery.resolve), store.ts (poster), boardRights.test.ts,+integration test for an upload.++- [ ] Failing test: in a switched project a member without the right cannot send, edit or upload into its chat, and a granted+ one, the owner and the Swarm owner can; agents and Buddy proposals still can; in a project not switched, everyone writes+ as today.+- [ ] Code.++### Task 3: priority by role++**Files:** commands.ts (work.priority, conversation.create), boardRights.test.ts.++- [ ] Failing test: in a switched project a member sets P1-P3 on their own card, not on another's, and never P0; the owner+ and the decider set any; the PM keeps its rights; a project not switched is unchanged.+- [ ] Code.++### Task 4: pause and resume++**Files:** commands.ts, model.ts (Conversation.paused), dispatch.ts, pmSchedule.ts, pulse.ts, parts (light fields),+boardRights.test.ts, dispatch.test.ts.++- [ ] Failing test: someone who steers pauses and resumes a task, with a line in it; a member is refused; a paused task is not+ handed out, not swept, and shows held.+- [ ] Code.++### Task 5: the PM text follows the switch++**Files:** pmSchedule.ts, store.ts, read/hostRows.ts, inbox.ts, pulse.ts (owe), tests.++- [ ] Failing test: a switched project's PM text has no inbox line and its wakes and digest no owed lines, and a person's+ message there owes nothing; a project not switched gets today's text.+- [ ] Code.++### Task 6: switch-on hands unanswered asks over++**Files:** boardRights.ts (legacyAsks), commands.ts (project.boardMode), boardRights.test.ts.++- [ ] Failing test: switching on lists every unanswered ask, oldest first, in the agreed shape, and keeps each one until a card+ is made for it; switching on again adds nothing.+- [ ] Code (wiring to #3817's importLegacyProposal by whichever merges second).