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
Swarm reviews start with the task's review focus, and two-review tasks open both by themselves (#2382)
0xken156b91c310533b
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex 21b5055b8..a98131dcf 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -2239,6 +2239,55 @@ describe('Super Tabs on a real Mongo replica set', () => {}})+ // Nightly reflection 10-30: reviews the Swarm opened started without the Lead's focus, and second security reviews needed+ // hand-built holder groups. The plan is stored on the task, reaches both reviews, and holds done until both passed.+ it('opens both reviews of a task wanting two on different Reviewers, each with its focus, and holds done until both pass', async () => {+ const tab = (await store.create(owner, randomUUID(), 'Pilot')).id+ const lead = String((await run(tab, { type: 'agent.add', conversationId: 'lead', machineId: 'test-host', harnessId: randomUUID(), name: 'Lead',+ configuration: config, lead: true, project: { cwd: '/fixture/repo', repositoryUrl: 'https://github.com/example/project' } } as Command)).result.agentId)+ // A focus at its limit, saved, read back and saved again.+ const focus = 'Check that a queued edit is never replayed twice after reconnect. '.repeat(40).slice(0, 2000).trim()+ const task = { goal: 'Save edits offline.', changes: 'Queue edits.', constraints: 'No data loss.', owns: ['app/offline'], review: { focus, reviews: 2 as const } }+ const checks = [{ description: 'Independent review', independent: true }]+ const group = String((await run(tab, { type: 'conversation.create', title: 'Offline', task, checks })).result.conversationId)+ const readBack = (await store.read(owner, tab)).state.conversations.find(c => c.id === group)!.task!+ expect(readBack.review).toEqual({ focus, reviews: 2 })+ await run(tab, { type: 'work.define', conversationId: group, task: readBack, checks })+ const reviewers: string[] = []+ for (let i = 0; i < 2; i++) {+ const { startId } = await routedStart(tab, lead, 'reviewer')+ reviewers.push(String((await run(tab, { type: 'agent.started', startId, harnessId: randomUUID(), configuration: { ...config, model: 'gpt-6.1-sol' } }, host, lead)).result.agentId))+ }+ const worker = String((await run(tab, { type: 'agent.add', conversationId: group, machineId: 'test-host', harnessId: randomUUID(),+ name: 'Builder', configuration: { ...config, model: 'gpt-6.1-sol' }, lead: false })).result.agentId)+ const built = String((await run(tab, { type: 'work.assign', conversationId: group, agentId: worker })).result.assignmentId)+ await run(tab, { type: 'work.status', conversationId: group, assignmentId: built, status: 'review', result: 'Ready at abc123. https://github.com/example/project/pull/9' }, host, worker)++ const reviews = (await storedState(tab)).conversations.filter(c => c.reviewOf === group)+ expect(reviews.map(r => r.title)).toEqual(['Review: Offline', 'Second review: Offline'])+ expect(reviews.map(r => r.assignment?.agentId).sort()).toEqual([...reviewers].sort())+ for (const review of reviews) expect(review.brief.startsWith(`Review focus:\n${focus}\n\n`)).toBe(true)+ // The review groups read only the work they review: its own reviews are all the Swarm opened.+ expect((await storedState(tab)).conversations.filter(c => c.reviewOf && c.reviewOf !== group)).toEqual([])++ const independent = (await storedState(tab)).conversations.find(c => c.id === group)!.checks[0]!.id+ // Each Reviewer gives its review's own verdict and passes the work, as swarm-review does.+ const pass = async (reviewer: string) => {+ const review = reviews.find(r => r.assignment?.agentId === reviewer)!+ await run(tab, { type: 'work.check', conversationId: review.id, assignmentId: review.assignment!.id, checkId: review.checks[0]!.id, passed: true, evidence: 'Ready: yes at abc123.' }, host, reviewer)+ await run(tab, { type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at abc123.' }, host, reviewer)+ }+ const done = () => run(tab, { type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, host, worker)+ await pass(reviewers[0]!)+ await expect(done()).rejects.toMatchObject({ code: 'REVIEWS_PENDING' })+ await pass(reviewers[1]!)+ expect((await storedState(tab)).conversations.find(c => c.id === group)!.assignment).toMatchObject({ handoffs: 1,+ verdicts: reviewers.map(r => ({ by: `agent:${r}`, passed: true, handoff: 1, review: reviews.find(x => x.assignment?.agentId === r)!.id })) })+ expect(reviews.map(r => r.reviewStamp)).toEqual([{ assignmentId: built, handoff: 1 }, { assignmentId: built, handoff: 1 }])+ await done()+ expect((await storedState(tab)).conversations.find(c => c.id === group)!.assignment!.status).toBe('done')+ })+it('releases a started agent\'s route hold when the host stops it before assignment', async () => {const { tab, lead } = await fixture()const { routeDecisionId, startId } = await routedStart(tab, lead, 'reviewer')diff --git a/backend/src/superTabs/autoReview.ts b/backend/src/superTabs/autoReview.tsindex f0185e6fd..187528d89 100644--- a/backend/src/superTabs/autoReview.ts+++ b/backend/src/superTabs/autoReview.ts@@ -1,6 +1,6 @@import { githubRepository } from '../github/repository.js'import { agentDisplayName } from './agentNames.js'-import { activeWork, agentRole, forRecipients, nextConversationNumber, renderWorkTask, stableId, type Agent, type Author, type Conversation, type MessageDraft, type SuperTabState } from './model.js'+import { activeWork, agentRole, finishWorker, forRecipients, nextConversationNumber, renderWorkTask, reviewsWanted, stableId, type Agent, type Author, type Conversation, type MessageDraft, type ReviewStamp, type SuperTabState } from './model.js'import { agentProjectId, groupProject, skillSetOf } from './projects.js'import { recordAsked, recordRun } from './leaderboard/record.js'import { renewLease } from './liveness.js'@@ -36,10 +36,98 @@ const verdictGiven = (group: Conversation): boolean => group.checks.some(c => c.const verdictMissing = (group: Conversation): boolean =>!!group.reviewOf && group.assignment?.status !== 'cancelled' && !verdictGiven(group)-/** A review of [group] that is still open: not archived, not cancelled and with no verdict yet. A second review, by itself- * or by hand, waits until it closes (commands.ts conversation.create). */-export const openReviewOf = (state: SuperTabState, group: Conversation): Conversation | undefined =>- state.conversations.find(c => c.reviewOf === group.id && !c.archived && verdictMissing(c))+/** The hand-over of [group]'s work a review opened now reviews: only for a task wanting two reviews, whose done counts+ * passes per hand-over (model.ts reviewsPassed). */+export function reviewStampOf(group: Conversation): ReviewStamp | undefined {+ return reviewsWanted(group.task) > 1 && group.assignment ? { assignmentId: group.assignment.id, handoff: group.assignment.handoffs ?? 0 } : undefined+}+const sameStamp = (a: ReviewStamp | undefined, b: ReviewStamp | undefined) => !!a && !!b && a.assignmentId === b.assignmentId && a.handoff === b.handoff++/** The review of [build] that [agentId] holds, its newest: the one its verdicts on [build]'s independent checks come through. */+export const reviewHeldBy = (state: SuperTabState, build: Conversation, agentId: string): Conversation | undefined =>+ state.conversations.filter(c => c.reviewOf === build.id && c.assignment?.agentId === agentId).sort((a, b) => (b.number ?? 0) - (a.number ?? 0))[0]++/** A verdict that opens by saying it passes: at the start of the text, after an optional "Verdict:". Reviewers often pass+ * their review's own check only to say a verdict was given, whatever it was, so the words decide, and only the opening ones:+ * swarm-review opens with "No finding on <rev>" or "Hold — <rev>" (reviews 4 and 5 of #2382: "Not ready", "Request changes"+ * and "Blocked" read as passes, then a Hold reporting "300 passed" or "CI passed" did). */+const PASS = /^\s*(verdict\s*:\s*)?(no findings?|pass|ready\s*:\s*yes|approved?|approves)\b/i+/** The Harness orchestration Reviewer's opening ("Meets the brief: yes, quality: yes, then Ready: yes — revision <rev>"):+ * "Ready: yes" anywhere in the opening line passes too (review 6 of #2382). "Passed"/"passes" never do: they report runs. */+const READY_YES = /\bready\s*:\s*yes\b/i+/** Words in its opening line that take a pass back ("Pass — with fixes", "Ready: yes, but blocked", "quality: no"). */+const NOT_PASS = /\b(hold|holds|held|not ready|ready\s*:\s*(no|with fixes)|with fixes|request(s|ed)? changes|changes (needed|requested)|block(ed|s|ing|er)?|not pass(ed)?|did not|fail(s|ed)?|(brief|quality)\s*:\s*no)\b/i+/** How a review's verdict reads as a pass, for a refused done to say. */+export const PASS_HINT = 'A review\'s verdict passes when it opens with No finding or Pass.'+/** Whether [verdict] is a pass: it opens with a pass, or its opening line says Ready: yes, and that line takes nothing back;+ * anything else is not yet. */+export function passVerdict(verdict: string): boolean {+ const opening = verdict.trimStart().split('\n')[0]!+ return (PASS.test(verdict) || READY_YES.test(opening)) && !NOT_PASS.test(opening)+}+/** Whether [review] gave a pass verdict: its own check passed, and its verdict opens with a pass. */+export const reviewPassed = (review: Conversation): boolean => review.checks.some(c => c.passedBy && c.evidence && passVerdict(c.evidence))++/** The hand-over a pass on [build] through [review] counts for: the review's own, once the review gave a pass verdict, while+ * it still reviews [build]'s current attempt and was not closed; else -1, never counted. A pass on the work given while+ * [review] was open counts once that review passes; its Hold clears it (commands.ts work.check). A late pass on head 1 was+ * carried to head 2 when the Reviewer held head 2 (reviews of #2382). */+export function verdictHandoff(build: Conversation, review: Conversation): number {+ const stamp = review.reviewStamp+ return stamp && stamp.assignmentId === build.assignment?.id && review.assignment?.status !== 'cancelled' && reviewPassed(review) ? stamp.handoff : -1+}++/** The Reviewers whose review of [build]'s last hand-over is open or given but whose pass on the work does not count yet:+ * who must still pass it, as a refused done says. */+export function reviewersToPass(state: SuperTabState, build: Conversation): string[] {+ const stamp = reviewStampOf(build), verdicts = build.assignment?.verdicts ?? []+ if (!stamp) return []+ return state.conversations.filter(c => c.reviewOf === build.id && sameStamp(c.reviewStamp, stamp) && c.assignment && c.assignment.status !== 'cancelled')+ .map(c => state.agents.find(a => a.id === c.assignment!.agentId))+ .filter((a): a is Agent => !!a && !verdicts.some(v => v.by === `agent:${a.id}` && v.passed && v.handoff === stamp.handoff))+ .map(a => a.displayName ?? a.name)+}++/**+ * Closes [group]'s open reviews left on an earlier hand-over when its Engineer hands over a new head, so each of the two+ * reviews its task wants opens again for this one (review of #2382: a Reviewer still on head 1 passed, and it counted for+ * head 2). One with a Reviewer is cancelled and its Reviewer told; one nobody took yet just moves to this hand-over.+ */+export function supersedeReviews(state: SuperTabState, group: Conversation, operationId: string, author: Author): MessageDraft[] {+ const stamp = reviewStampOf(group)+ if (!stamp) return []+ const messages: MessageDraft[] = []+ for (const review of openReviewsOf(state, group).filter(r => !sameStamp(r.reviewStamp, stamp))) {+ if (!review.assignment) { review.reviewStamp = stamp; continue }+ const reviewer = review.assignment.agentId, ended = !activeWork(review)+ review.assignment.status = 'cancelled'+ review.assignment.result = `#${group.number} handed over a new revision.`+ if (!ended) finishWorker(state, reviewer, review)+ messages.push({ id: stableId(operationId, 'auto-review', 'superseded', review.id), conversationId: review.id, author, replyTo: null,+ recipients: ended ? [] : [reviewer], source: forRecipients({ kind: 'auto-review', reviewOf: group.id }),+ text: `#${group.number} handed over a new revision, so this review is closed and its verdict no longer counts. A new review opens for the new revision. Stop working on this one.` })+ }+ return messages+}++/** Whether the Swarm opens reviews for [group] by itself: not while paused, nor on Custom skills without a reviewer role+ * (commands.ts requireCustomRole). */+export function opensReviews(state: SuperTabState, group: Conversation): boolean {+ const project = groupProject(state, group)+ return !state.paused && !(skillSetOf(project) === 'custom' && !project.roles?.some(r => r.kind === 'reviewer'))+}++/** The reviews of [group] still open: not archived, not cancelled and with no verdict yet, oldest first. */+export const openReviewsOf = (state: SuperTabState, group: Conversation): Conversation[] =>+ state.conversations.filter(c => c.reviewOf === group.id && !c.archived && verdictMissing(c))++/** A review of [group] that is still open while it has every review its task wants: another one, by itself or by hand, waits+ * until one closes (commands.ts conversation.create). A task wanting two independent reviews has room for a second one+ * beside the first, so the Lead needs no holder group for it (nightly reflection 10-30). */+export const fullReviewOf = (state: SuperTabState, group: Conversation): Conversation | undefined => {+ const open = openReviewsOf(state, group)+ return open.length >= reviewsWanted(group.task) ? open[0] : undefined+}/** A review that may not be archived, by hand or by itself: no verdict, not cancelled, and the work it reviews still going.* Once that work is done or cancelled the review is moot. A review with no Reviewer has no assignment to cancel, so that@@ -69,25 +157,32 @@ function unable(state: SuperTabState, agent: Agent, now: number): boolean {* tier are common and an idle Codex Reviewer out of quota came first), or (`mayWork`) not allowed to take this work: on its* machine, by the owner's rules (#610 review), or as the review rule (rules.ts reviewRefusal) has it.*/-function pickReviewer(state: SuperTabState, group: Conversation, engineer: Agent | undefined, earlier: Conversation | undefined,- mayWork: (agent: Agent) => boolean, strength: (agent: Agent) => number, now: number): Agent | null {+function pickReviewer(state: SuperTabState, group: Conversation, engineer: Agent | undefined, earlier: readonly string[],+ taken: ReadonlySet<string>, mayWork: (agent: Agent) => boolean, strength: (agent: Agent) => number, now: number): Agent | null {const projectId = groupProject(state, group).id- const candidates = state.agents.filter(a => a.id !== engineer?.id && agentRole(a) === 'reviewer' && agentProjectId(state, a) === projectId &&+ // `taken`: the Reviewers of its other open reviews, and of one just opened beside this one: two reviews never share one.+ const candidates = state.agents.filter(a => a.id !== engineer?.id && !taken.has(a.id) && agentRole(a) === 'reviewer' && agentProjectId(state, a) === projectId &&a.workDecision !== 'stop' && !a.lostTask && !downSince(state, a, now) && !unable(state, a, now) && free(state, a) && mayWork(a))- const previous = candidates.find(a => a.id === earlier?.assignment?.agentId)+ const previous = earlier.map(id => candidates.find(a => a.id === id)).find(a => a)// Strongest first; at equal strength the roster's order stands (sort is stable).return previous ?? [...candidates].sort((a, b) => strength(b) - strength(a))[0] ?? null}-function briefOf(group: Conversation, handoff: string, pullRequest: string, earlier: Conversation | undefined): string {+/** [lane] of [lanes]: which of a task's independent reviews this is, when it wants more than one. */+function briefOf(group: Conversation, handoff: string, pullRequest: string, earlier: Conversation | undefined, lane: { index: number; of: number }): string {const task = group.taskconst privacy = PRIVACY.test([task ? renderWorkTask(task) : group.brief, handoff].join('\n'))const kept = handoff.length > HANDOFF_CHARS ? `${handoff.slice(0, HANDOFF_CHARS)}… (the rest is in #${group.number})` : handoff+ // The focus leads the brief, so it is not repeated in the task below it.+ const focus = task?.review?.focus+ const work = task ? renderWorkTask({ ...task, review: undefined }) : group.briefreturn [...privacy ? ['Privacy first: this work touches sharing, access or confidentiality. Check who can see or reach what before anything else.'] : [],+ ...focus ? [`Review focus:\n${focus}`] : [],`Give an independent verdict on the Engineer's revision of #${group.number} ${group.title}. Read only; do not change the code.`,+ ...lane.of > 1 ? [`Independent review ${lane.index + 1} of ${lane.of}: another Reviewer reviews this work separately. Reach your own verdict without reading theirs.`] : [],...earlier ? [`Delta review: #${earlier.number} reviewed the earlier head. Review only the changes since.`] : [],- `The reviewed work:\n${task ? renderWorkTask(task) : group.brief}`,+ `The reviewed work:\n${work}`,`Its acceptance checks:\n${group.checks.map(c => `- ${c.description}`).join('\n')}`,`The Engineer's handoff:\n${kept}`,`Pull request: ${pullRequest}`,@@ -95,56 +190,76 @@ function briefOf(group: Conversation, handoff: string, pullRequest: string, earl].join('\n\n')}-export interface OpenedReview { review: Conversation; reviewer: Agent | null; messages: MessageDraft[] }+/** Who writes the Swarm's own review rows in [group]: its project's Lead, or [fallback] in a group with no Lead. */+export function swarmAuthor(state: SuperTabState, group: Conversation, fallback: Author): Author {+ const lead = state.agents.find(a => a.id === group.leadId)+ return lead ? { kind: 'agent', id: lead.id, name: lead.name, displayName: agentDisplayName(state.agents, lead.id), membershipGeneration: lead.membershipGeneration } : fallback+}++export interface OpenedReview { reviews: { review: Conversation; reviewer: Agent | null }[]; messages: MessageDraft[] }/**- * Opens [group]'s review after its Engineer marked it ready with [handoff], which links [pullRequest]: a "Review: <title>"- * group reviewing it, assigned to a free Reviewer that also joins [group] so it can pass the independent check, and one- * line to the Lead, who can cancel it. With no free Reviewer the review waits, and the line asks the Lead to start one.- * Its rows are the Swarm's own: written as the project's Lead with an auto-review source, as its lost-task and failed-start- * notices are (liveness.ts), never as the Engineer (#610 review); [engineer] writes them only in a group with no Lead.+ * Opens [group]'s reviews after its Engineer marked it ready with [handoff], which links [pullRequest]: as many as its task+ * wants beyond those still open (one, or two for a task wanting two independent reviews). Each is a "Review: <title>" group+ * (the second "Second review: <title>") reviewing it, assigned to a free Reviewer that also joins [group] so it can pass the+ * independent check, never the Reviewer of another open review of it, and one line to the Lead, who can cancel it. With no+ * free Reviewer a review waits, and the line asks the Lead to start one. Its rows are the Swarm's own: written as the+ * project's Lead with an auto-review source, as its lost-task and failed-start notices are (liveness.ts), never as the+ * Engineer (#610 review); [engineer] writes them only in a group with no Lead.*/export function openReview(state: SuperTabState, group: Conversation, handoff: string, pullRequest: string,context: { operationId: string; now: number; engineer: Author; mayWork: (agent: Agent) => boolean; strength: (agent: Agent) => number }): OpenedReview | null {- const project = groupProject(state, group)- // On Custom skills without a reviewer role there are no review groups (commands.ts requireCustomRole).- if (state.paused || (skillSetOf(project) === 'custom' && !project.roles?.some(r => r.kind === 'reviewer'))) return null- // Only a review that gave its verdict reviewed the earlier head: one cancelled before it reviewed nothing (#610 review).- const earlier = state.conversations.filter(c => c.reviewOf === group.id && c.assignment && verdictGiven(c)).sort((a, b) => (b.number ?? 0) - (a.number ?? 0))[0]+ if (!opensReviews(state, group)) return null+ const open = openReviewsOf(state, group), wanted = reviewsWanted(group.task)+ if (open.length >= wanted) return null+ // Only a review that gave its verdict reviewed an earlier head: one cancelled before it reviewed nothing (#610 review).+ const verdicts = state.conversations.filter(c => c.reviewOf === group.id && c.assignment && verdictGiven(c)).sort((a, b) => (b.number ?? 0) - (a.number ?? 0))+ // The Reviewers of the latest heads, one per review the task wants, newest first: each review goes back to one of them.+ const earlier = [...new Set(verdicts.map(c => c.assignment!.agentId))].slice(0, wanted)+ const taken = new Set(open.flatMap(c => c.assignment ? [c.assignment.agentId] : []))const engineer = state.agents.find(a => a.id === group.assignment?.agentId)- const reviewer = pickReviewer(state, group, engineer, earlier, context.mayWork, context.strength, context.now)- const id = stableId(context.operationId, 'auto-review')- const number = nextConversationNumber(state)- state.groupCounter = number- const brief = briefOf(group, handoff, pullRequest, earlier)const leadId = group.leadId- const lead = state.agents.find(a => a.id === leadId)- const author: Author = lead ? { kind: 'agent', id: lead.id, name: lead.name, displayName: agentDisplayName(state.agents, lead.id),- membershipGeneration: lead.membershipGeneration } : context.engineer- const review: Conversation = { id, ...(group.projectId ? { projectId: group.projectId } : {}), number, title: `Review: ${group.title}`.slice(0, 160),- leadId, agentIds: leadId ? [leadId] : [], archived: false, brief, reviewOf: group.id, assignment: null, lastMessageSequence: 0,- checks: [{ description: VERDICT_CHECK, independent: false, id: stableId(id, '0'), evidence: null, passedBy: null }] }- state.conversations.push(review)- recordAsked(review, group.requesterId, context.now)- const row = (key: string, text: string, recipients: string[], source: Record<string, unknown> = { kind: 'auto-review', reviewOf: group.id }): MessageDraft =>- ({ id: stableId(context.operationId, 'auto-review', key), conversationId: id, author, text, replyTo: null, recipients, source })- const messages = [row('brief', brief, [])]- if (reviewer) {- review.agentIds.push(reviewer.id)- if (!group.agentIds.includes(reviewer.id)) group.agentIds.push(reviewer.id)- delete reviewer.workDecision- delete reviewer.releaseId- review.assignment = { id: stableId(id, 'assignment'), agentId: reviewer.id, status: 'working', configuration: structuredClone(reviewer.configuration),- execution: { machineId: reviewer.machineId, harnessId: reviewer.harnessId, machineOwnerId: reviewer.machineOwnerId }, result: null }- renewLease(review.assignment, context.now)- recordRun(state, review, review.assignment, reviewer, context.now)- messages.push(row('assign', `${brief}\n\nAcceptance checks:\n- ${VERDICT_CHECK}`, [reviewer.id]))+ const author = swarmAuthor(state, group, context.engineer)+ const stamp = reviewStampOf(group)+ const opened: OpenedReview = { reviews: [], messages: [] }+ for (let index = open.length; index < wanted; index++) {+ // The first keeps the ids a one-review task always had, so a retried write finds the same rows.+ const lane = index === open.length ? [] : [String(index + 1)]+ const reviewer = pickReviewer(state, group, engineer, earlier, taken, context.mayWork, context.strength, context.now)+ if (reviewer) taken.add(reviewer.id)+ const previous = (reviewer && earlier.includes(reviewer.id) && verdicts.find(c => c.assignment!.agentId === reviewer.id)) || verdicts[0]+ const id = stableId(context.operationId, 'auto-review', ...lane)+ const number = nextConversationNumber(state)+ state.groupCounter = number+ const brief = briefOf(group, handoff, pullRequest, previous, { index, of: wanted })+ const review: Conversation = { id, ...(group.projectId ? { projectId: group.projectId } : {}), number,+ title: `${index ? 'Second review' : 'Review'}: ${group.title}`.slice(0, 160),+ leadId, agentIds: leadId ? [leadId] : [], archived: false, brief, reviewOf: group.id, ...(stamp ? { reviewStamp: stamp } : {}), assignment: null, lastMessageSequence: 0,+ checks: [{ description: VERDICT_CHECK, independent: false, id: stableId(id, '0'), evidence: null, passedBy: null }] }+ state.conversations.push(review)+ recordAsked(review, group.requesterId, context.now)+ const row = (key: string, text: string, recipients: string[], source: Record<string, unknown> = { kind: 'auto-review', reviewOf: group.id }): MessageDraft =>+ ({ id: stableId(context.operationId, 'auto-review', key, ...lane), conversationId: id, author, text, replyTo: null, recipients, source })+ opened.messages.push(row('brief', brief, []))+ if (reviewer) {+ review.agentIds.push(reviewer.id)+ if (!group.agentIds.includes(reviewer.id)) group.agentIds.push(reviewer.id)+ delete reviewer.workDecision+ delete reviewer.releaseId+ review.assignment = { id: stableId(id, 'assignment'), agentId: reviewer.id, status: 'working', configuration: structuredClone(reviewer.configuration),+ execution: { machineId: reviewer.machineId, harnessId: reviewer.harnessId, machineOwnerId: reviewer.machineOwnerId }, result: null }+ renewLease(review.assignment, context.now)+ recordRun(state, review, review.assignment, reviewer, context.now)+ opened.messages.push(row('assign', `${brief}\n\nAcceptance checks:\n- ${VERDICT_CHECK}`, [reviewer.id]))+ }+ const name = reviewer && (reviewer.displayName ?? reviewer.name)+ const which = wanted > 1 ? ` (independent review ${index + 1} of ${wanted})` : ''+ if (leadId) opened.messages.push(row('lead', reviewer+ ? `Review opened by itself for #${group.number}${which}: ${name} reviews it. Cancel it here if it is not needed.`+ : `Review opened by itself for #${group.number}${which}, but no Reviewer is free. Route it and start one.`, [leadId],+ // The Lead's wake, its alone (review of #2225): people read the review's brief and its status.+ forRecipients({ kind: 'auto-review', reviewOf: group.id })))+ opened.reviews.push({ review, reviewer })}- const name = reviewer && (reviewer.displayName ?? reviewer.name)- if (leadId) messages.push(row('lead', reviewer- ? `Review opened by itself for #${group.number}: ${name} reviews it. Cancel it here if it is not needed.`- : `Review opened by itself for #${group.number}, but no Reviewer is free. Route it and start one.`, [leadId],- // The Lead's wake, its alone (review of #2225): people read the review's brief and its status.- forRecipients({ kind: 'auto-review', reviewOf: group.id })))- return { review, reviewer, messages }+ return opened}diff --git a/backend/src/superTabs/commands.test.ts b/backend/src/superTabs/commands.test.tsindex 21ca71636..9cb0c50d5 100644--- a/backend/src/superTabs/commands.test.ts+++ b/backend/src/superTabs/commands.test.ts@@ -3,7 +3,7 @@ import { applyCommand, commandSchema, PAIR_CHAIN_LIMIT, swarmGridName, withoutCrimport { CREDENTIAL_MARKER, type CredentialKind } from './credentials.js'import { sweepLiveness } from './liveness.js'import { hostLocalGrid, machineSlots, removalPreview, swarmGridRow } from './machines.js'-import { activeWork, agentOnly, agentRole, createSuperTab, visibleState, type Actor, type AgentConfiguration } from './model.js'+import { activeWork, agentOnly, agentRole, createSuperTab, visibleState, type Actor, type AgentConfiguration, type Conversation, type ReviewPlan } from './model.js'import type { RouteDecision } from './routeRecord.js'import { startFinished } from './parts/write.js'import { agentTarget, broken } from './rules.js'@@ -68,6 +68,24 @@ describe('five-part tasks', () => {expect(f.state.conversations[1]).toMatchObject({ task, brief })})+ it('renders a review plan under "Review:" and refuses an empty, too long or third-review plan', () => {+ const f = fixture()+ const review = { focus: ' Check revoked access first. ', reviews: 2 }+ const group = f.run(commandSchema.parse({ type: 'conversation.create', title: 'Drafts', task: { ...task, review }, checks })).result.conversationId as string+ expect(f.state.conversations.find(c => c.id === group)).toMatchObject({ task: { ...task, review: { focus: 'Check revoked access first.', reviews: 2 } },+ brief: `${brief}\n\nReview:\nCheck revoked access first.\nTwo independent reviews, each by a different Reviewer.` })+ f.run(commandSchema.parse({ type: 'work.define', conversationId: group, task: { ...task, review: { reviews: 2 } }, checks }))+ expect(f.state.conversations.find(c => c.id === group)!.brief).toBe(`${brief}\n\nReview:\nTwo independent reviews, each by a different Reviewer.`)+ f.run(commandSchema.parse({ type: 'work.define', conversationId: group, task: { ...task, review: { focus: 'Lifecycle.', reviews: 1 } }, checks }))+ expect(f.state.conversations.find(c => c.id === group)!.brief).toBe(`${brief}\n\nReview:\nLifecycle.`)+ for (const bad of [{}, { focus: '' }, { focus: 'x'.repeat(2001) }, { reviews: 3 }, { reviews: 0 }, { focus: 'x', reviewers: 2 }]) {+ for (const type of ['conversation.create', 'work.define']) {+ expect([bad, commandSchema.safeParse({ type, title: 'Drafts', conversationId: group, task: { ...task, review: bad }, checks }).success]).toEqual([bad, false])+ }+ }+ expect(commandSchema.safeParse({ type: 'conversation.create', title: 'Drafts', task: { ...task, review: { focus: 'x'.repeat(2000) } }, checks }).success).toBe(true)+ })+it('delivers all five parts from the stored rendered brief', () => {const f = fixture(), group = f.group(), worker = f.add('worker', 'owner', group)f.run(commandSchema.parse({ type: 'work.define', conversationId: group, task, checks }))@@ -1705,9 +1723,12 @@ describe('Reviewer role', () => {describe('a review the Swarm opens by itself', () => {const pr = 'https://github.com/example/project/pull/42'/** reviewed() with the project's repository, the Builder working, and a second Reviewer `fresh` that is not in the group. */- function ready(engine: 'claude' | 'codex' = 'claude') {+ function ready(engine: 'claude' | 'codex' = 'claude', review?: ReviewPlan) {const setup = reviewed()const { f, leadActor, group, builder } = setup+ // The Lead's review plan, set as a person or Lead sets any task (model.ts ReviewPlan).+ if (review) f.run(commandSchema.parse({ type: 'work.define', conversationId: group, task: { ...offlineTask, review },+ checks: [{ description: 'Reconnect preserves the edits.', independent: true }] }))f.state.projects![0]!.repository = { machineId: 'host', cwd: '/repo', repositoryUrl: 'https://github.com/Example/project.git' }const startId = f.run({ type: 'agent.start', request: request('lead', { role: 'reviewer', engine, name: 'Second reviewer' }), ...via } as Command, leadActor,{ contribution, ...decisionIn('lead') }).result.startId as string@@ -1720,6 +1741,316 @@ describe('Reviewer role', () => {const reviews = () => f.state.conversations.filter(c => c.reviewOf === group)return { ...setup, fresh, built, builderActor, markReady, reviews }}+ const offlineTask = { goal: 'Save edits while offline.', changes: 'Queue edits locally.', constraints: 'No data loss.', owns: ['app/offline'] }+ const focus = 'Most likely wrong: a queued edit replayed twice after reconnect, and a stale sync result landing on a new session.'+ /** [reviewer] gives [review]'s verdict as swarm-review does: passes the review's own check, then the work's independent one. */+ function verdict(f: ReturnType<typeof fixture>, review: Conversation, group: string, built: string, reviewer: string, passed: boolean) {+ const actor: Actor = { kind: 'agent', agentId: reviewer, machineOwnerId: 'target-owner' }+ f.run({ type: 'work.check', conversationId: review.id, assignmentId: review.assignment!.id, checkId: review.checks[0]!.id, passed: true,+ evidence: `Ready: ${passed ? 'yes' : 'with fixes'} at d4e5f6.` }, actor)+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent.id, passed, evidence: `${passed ? 'Pass' : 'Fail'} at d4e5f6.` }, actor)+ f.run({ type: 'work.status', conversationId: review.id, assignmentId: review.assignment!.id, status: 'done', result: 'Verdict given.' }, actor)+ }++ // Nightly reflection 10-30: the Lead hand-sent a focus to 20+ reviews the Swarm opened itself, and built holder groups+ // for second security reviews.+ describe('with the task\'s review plan', () => {+ it('starts the first review and its re-check with the focus, after the privacy line and before the delta line', () => {+ const { f, group, built, builderActor, reviewer, markReady, reviews } = ready('claude', { focus })+ const effects = markReady(`Ready. Readers without access lose the queue. ${pr}`)+ const first = reviews()[0]!+ expect(first.brief.split('\n\n').slice(0, 3)).toEqual([expect.stringMatching(/^Privacy first:/), `Review focus:\n${focus}`,+ expect.stringMatching(/^Give an independent verdict/)])+ // Said once: the reviewed work below it leaves the plan out.+ expect(first.brief.split(focus)).toHaveLength(2)+ expect(effects.messages.find(m => m.conversationId === first.id && m.recipients.includes(reviewer))!.text).toContain(`Review focus:\n${focus}`)+ verdict(f, first, group, built, reviewer, false)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ markReady(`Fixed, head 778899. ${pr}`)+ const recheck = reviews().find(c => c.id !== first.id)!+ expect(recheck.assignment!.agentId).toBe(reviewer)+ expect(recheck.brief.split('\n\n').slice(0, 3)).toEqual([`Review focus:\n${focus}`, expect.stringMatching(/^Give an independent verdict/),+ `Delta review: #${first.number} reviewed the earlier head. Review only the changes since.`])+ })++ it('opens two reviews at once on two different Reviewers for a task wanting two, each told it is one of two', () => {+ const { f, lead, group, reviewer, fresh, markReady, reviews } = ready('claude', { focus, reviews: 2 })+ expect(f.state.conversations.find(c => c.id === group)!.brief).toContain(`Review:\n${focus}\nTwo independent reviews, each by a different Reviewer.`)+ const effects = markReady(`Ready. ${pr}`)+ expect(reviews().map(r => r.title)).toEqual(['Review: Offline editing', 'Second review: Offline editing'])+ expect(new Set(reviews().map(r => r.assignment!.agentId))).toEqual(new Set([reviewer, fresh]))+ expect(reviews().map(r => r.brief.includes(`Independent review ${reviews().indexOf(r) + 1} of 2`))).toEqual([true, true])+ expect(reviews().every(r => r.brief.startsWith(`Review focus:\n${focus}`))).toBe(true)+ expect(f.state.conversations.find(c => c.id === group)!.agentIds).toEqual(expect.arrayContaining([reviewer, fresh]))+ expect(effects.messages.filter(m => m.recipients.includes(lead) && m.conversationId !== group).map(m => m.text.replace(/: .* reviews it/, ': X reviews it')))+ .toEqual(['Review opened by itself for #1 (independent review 1 of 2): X reviews it. Cancel it here if it is not needed.',+ 'Review opened by itself for #1 (independent review 2 of 2): X reviews it. Cancel it here if it is not needed.'])+ // Every row id is its own.+ const ids = effects.messages.map(m => m.id)+ expect(new Set(ids).size).toBe(ids.length)+ // A new head closes both, as neither reviewed it, and opens both again for it, on different Reviewers.+ const firstRound = reviews().map(r => r.id)+ markReady(`Ready, head 2. ${pr}`)+ expect(reviews().filter(r => firstRound.includes(r.id)).map(r => r.assignment!.status)).toEqual(['cancelled', 'cancelled'])+ const secondRound = reviews().filter(r => !firstRound.includes(r.id))+ expect(secondRound.map(r => r.reviewStamp!.handoff)).toEqual([2, 2])+ expect(new Set(secondRound.map(r => r.assignment!.agentId))).toEqual(new Set([reviewer, fresh]))+ })++ it('never gives both reviews to one Reviewer: with one free, the second waits for the Lead', () => {+ const { f, lead, leadActor, fresh, reviewer, markReady, reviews } = ready('claude', { reviews: 2 })+ f.run({ type: 'agent.release', agentId: fresh, decision: 'stop' }, leadActor)+ const effects = markReady(`Ready. ${pr}`)+ expect(reviews().map(r => r.assignment?.agentId ?? null)).toEqual([reviewer, null])+ expect(effects.messages.filter(m => m.conversationId === reviews()[1]!.id && m.recipients.includes(lead)).map(m => m.text))+ .toEqual(['Review opened by itself for #1 (independent review 2 of 2), but no Reviewer is free. Route it and start one.'])+ })++ // Review of #2382: A still on head 1 passed after head 2 was handed over, and it counted for head 2.+ it('counts a pass only through a review of the head handed over last, so a pass on an earlier head never completes it', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ const done = () => f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ markReady(`Ready, head 1. ${pr}`)+ const [onA, onB] = reviews()+ const a = onA!.assignment!.agentId, b = onB!.assignment!.agentId+ const aActor: Actor = { kind: 'agent', agentId: a, machineOwnerId: 'target-owner' }+ // B finds a problem in head 1; A is still reviewing it.+ verdict(f, onB!, group, built, b, false)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ const handover = markReady(`Fixed, head 2. ${pr}`)+ // A's review of head 1 is closed and A is told; both reviews open again for head 2.+ expect(f.state.conversations.find(c => c.id === onA!.id)!.assignment!.status).toBe('cancelled')+ expect(handover.messages.filter(m => m.conversationId === onA!.id && m.recipients.includes(a)).map(m => m.text))+ .toEqual(['#1 handed over a new revision, so this review is closed and its verdict no longer counts. A new review opens for the new revision. Stop working on this one.'])+ const head2 = reviews().filter(r => r.id !== onA!.id && r.id !== onB!.id)+ expect(head2.map(r => r.reviewStamp!.handoff)).toEqual([2, 2])+ expect(new Set(head2.map(r => r.assignment!.agentId))).toEqual(new Set([a, b]))+ // A, still on head 1, can no longer give the closed review's verdict, and its pass on the work does not count.+ expect(() => f.run({ type: 'work.check', conversationId: onA!.id, assignmentId: onA!.assignment!.id, checkId: onA!.checks[0]!.id, passed: true,+ evidence: 'Ready: yes at head 1.' }, aActor)).toThrow()+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 1.' }, aActor)+ verdict(f, head2.find(r => r.assignment!.agentId === b)!, group, built, b, true)+ const aAgent = f.state.agents.find(x => x.id === a)!+ expect(done).toThrow(`Still to pass it at this revision, after their review's pass verdict: ${aAgent.displayName ?? aAgent.name}.`)+ // Only A's own review of head 2 completes it.+ verdict(f, head2.find(r => r.assignment!.agentId === a)!, group, built, a, true)+ done()+ expect(f.state.conversations.find(c => c.id === group)!.assignment!.status).toBe('done')+ })++ // Review 3 of #2382 (Kai): both Reviewers passed the work, then recorded their reviews' pass verdicts, and done was refused.+ it('keeps a pass on the work given before its review\'s own pass verdict for the same head, and clears it on a Hold, naming who must pass again', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ const done = () => f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ markReady(`Ready. ${pr}`)+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ const actorOf = (review: Conversation): Actor => ({ kind: 'agent', agentId: review.assignment!.agentId, machineOwnerId: 'target-owner' })+ const nameOf = (review: Conversation) => { const a = f.state.agents.find(x => x.id === review.assignment!.agentId)!; return a.displayName ?? a.name }+ const [one, two] = reviews()+ for (const review of [one!, two!]) f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 1.' }, actorOf(review))+ // Passed the work, but no review verdict yet: both are named.+ expect(done).toThrow(`Still to pass it at this revision, after their review's pass verdict: ${nameOf(one!)}, ${nameOf(two!)}.`)+ // One holds in its review's own check, though it passed that check: its pass on the work is cleared.+ f.run({ type: 'work.check', conversationId: two!.id, assignmentId: two!.assignment!.id, checkId: two!.checks[0]!.id, passed: true, evidence: 'Ready: with fixes at head 1.' }, actorOf(two!))+ f.run({ type: 'work.check', conversationId: one!.id, assignmentId: one!.assignment!.id, checkId: one!.checks[0]!.id, passed: true, evidence: 'Ready: yes at head 1.' }, actorOf(one!))+ expect(done).toThrow(`Still to pass it at this revision, after their review's pass verdict: ${nameOf(two!)}.`)+ // Its review passes on a second look: the earlier pass on the work stays cleared until it passes the work again.+ f.run({ type: 'work.check', conversationId: two!.id, assignmentId: two!.assignment!.id, checkId: two!.checks[0]!.id, passed: true, evidence: 'Ready: yes at head 1.' }, actorOf(two!))+ expect(done).toThrow(nameOf(two!))+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 1.' }, actorOf(two!))+ done()+ })++ // Review 4 of #2382 (Kai): verdicts outside the short Hold list read as passes, so done went through with one real pass.+ it.each([['Not ready at head 2: P1 replay on reconnect.'], ['Request changes at head 2: P1 replay on reconnect.'], ['Blocked at head 2: one P1.'],+ ['Looked at head 2; see the findings below.'],+ // Review 5 (Kai): Holds that report test runs or name approval words read as passes when pass words matched anywhere.+ ['Two findings at d4e5f6: P1 in the sweep. Ran specs: 300 passed.'], ['P1 at d4e5f6: the token leaks. 120 tests passed.'],+ ['Needs work at d4e5f6: P1. CI passed.'], ['Cannot approve d4e5f6: P1.'], ['Not approved: P1.'], ['Rejected at d4e5f6. Unit suite passes.'],+ ['Pass — with fixes at d4e5f6: P2 in the sweep.'],+ // Review 6 (Kai): "Passed"/"passes" report runs, not a verdict; an orchestration opening that holds back is not a pass.+ ['Passed typecheck at d4e5f6; P1 below.'], ['Passes the unit suite at d4e5f6, but P1 below.'],+ ['Meets the brief: yes, quality: no. Ready: with fixes — revision d4e5f6.'], ['Meets the brief: no, quality: yes. Ready: yes — revision d4e5f6.']])('refuses done when a review passes its check with %j, naming its Reviewer', (wording) => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready. ${pr}`)+ const [one, two] = reviews()+ verdict(f, one!, group, built, one!.assignment!.agentId, true)+ const actor: Actor = { kind: 'agent', agentId: two!.assignment!.agentId, machineOwnerId: 'target-owner' }+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 2.' }, actor)+ f.run({ type: 'work.check', conversationId: two!.id, assignmentId: two!.assignment!.id, checkId: two!.checks[0]!.id, passed: true, evidence: wording }, actor)+ const name = f.state.agents.find(a => a.id === two!.assignment!.agentId)!+ expect(() => f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor))+ .toThrow(`Still to pass it at this revision, after their review's pass verdict: ${name.displayName ?? name.name}. A review's verdict passes when it opens with No finding or Pass.`)+ })++ it.each([['No finding at head 2.'], ['Pass at head 2.'], ['Ready: yes at head 2.'], ['Approve at head 2.'], ['Pass — d4e5f6, every check rerun.'],+ ['Verdict: No finding on d4e5f6.'], ['No finding on d4e5f6.\nRan specs: 300 passed, 0 failed.'],+ // Review 6 (Kai): the Harness orchestration Reviewer's opening, a pass with minor notes.+ ['Meets the brief: yes, quality: yes. Ready: yes — revision d4e5f6. Two minor notes below.']])('counts a review whose verdict says %j as a pass', (wording) => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready. ${pr}`)+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ for (const review of reviews()) {+ const actor: Actor = { kind: 'agent', agentId: review.assignment!.agentId, machineOwnerId: 'target-owner' }+ f.run({ type: 'work.check', conversationId: review.id, assignmentId: review.assignment!.id, checkId: review.checks[0]!.id, passed: true, evidence: wording }, actor)+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 2.' }, actor)+ }+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ expect(f.state.conversations.find(c => c.id === group)!.assignment!.status).toBe('done')+ })++ it('counts both passes when each Reviewer passes the work first and then records its review\'s pass verdict', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready. ${pr}`)+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ for (const review of reviews()) {+ const actor: Actor = { kind: 'agent', agentId: review.assignment!.agentId, machineOwnerId: 'target-owner' }+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 1.' }, actor)+ f.run({ type: 'work.check', conversationId: review.id, assignmentId: review.assignment!.id, checkId: review.checks[0]!.id, passed: true, evidence: 'Ready: yes at head 1.' }, actor)+ }+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ expect(f.state.conversations.find(c => c.id === group)!.assignment!.status).toBe('done')+ })++ // Review 2 of #2382 (Kai): A's late pass on head 1 was carried to head 2 when A held head 2's review.+ it.each([['a failed check', false, 'Hold: replay on reconnect at head 2.'], ['a passed check naming a Hold', true, 'Hold at head 2.']] as const)(+ 'refuses done when a Reviewer late-passes head 1 and then holds head 2 with %s, though the other passes head 2', (_, held, evidence) => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready, head 1. ${pr}`)+ const [onA, onB] = reviews()+ const a = onA!.assignment!.agentId, b = onB!.assignment!.agentId+ const aActor: Actor = { kind: 'agent', agentId: a, machineOwnerId: 'target-owner' }+ verdict(f, onB!, group, built, b, false)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ markReady(`Fixed, head 2. ${pr}`)+ const head2 = reviews().filter(r => r.id !== onA!.id && r.id !== onB!.id)+ const aHead2 = head2.find(r => r.assignment!.agentId === a)!+ // A, still on head 1, passes the work late, then holds its review of head 2.+ const independent = f.state.conversations.find(c => c.id === group)!.checks.find(c => c.independent)!.id+ f.run({ type: 'work.check', conversationId: group, assignmentId: built, checkId: independent, passed: true, evidence: 'Pass at head 1.' }, aActor)+ f.run({ type: 'work.check', conversationId: aHead2.id, assignmentId: aHead2.assignment!.id, checkId: aHead2.checks[0]!.id, passed: held, evidence }, aActor)+ verdict(f, head2.find(r => r.assignment!.agentId === b)!, group, built, b, true)+ expect(() => f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor))+ .toThrow('This task wants 2 independent reviews')+ })++ it('closes a review whose Reviewer stopped before its verdict when a new head comes, and opens both again on different Reviewers', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready. ${pr}`)+ const [first, second] = reviews()+ f.run({ type: 'work.status', conversationId: second!.id, assignmentId: second!.assignment!.id, status: 'stopped', result: null }, owner, { confirmedStopped: true })+ verdict(f, first!, group, built, first!.assignment!.agentId, false)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ const handover = markReady(`Fixed, head 2. ${pr}`)+ expect(f.state.conversations.find(c => c.id === second!.id)!.assignment!.status).toBe('cancelled')+ // Its Reviewer had already stopped: nobody is told to stop again.+ expect(handover.messages.filter(m => m.conversationId === second!.id).map(m => m.recipients)).toEqual([[]])+ const added = reviews().filter(r => r.id !== first!.id && r.id !== second!.id)+ expect(added).toHaveLength(2)+ expect(new Set(added.map(r => r.assignment!.agentId)).size).toBe(2)+ })++ it('moves a review nobody took yet to the new head instead of closing it', () => {+ const { f, leadActor, reviewer, fresh, markReady, reviews } = ready('claude', { reviews: 2 })+ for (const id of [reviewer, fresh]) f.run({ type: 'agent.release', agentId: id, decision: 'stop' }, leadActor)+ markReady(`Ready. ${pr}`)+ expect(reviews().map(r => [r.assignment, r.reviewStamp!.handoff])).toEqual([[null, 1], [null, 1]])+ markReady(`Ready, head 2. ${pr}`)+ expect(reviews().map(r => [r.assignment, r.reviewStamp!.handoff])).toEqual([[null, 2], [null, 2]])+ })++ it('gives each re-check back to its own earlier Reviewer, never both to one', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ markReady(`Ready. ${pr}`)+ const firstRound = reviews().map(r => [r.id, r.assignment!.agentId] as const)+ for (const r of reviews()) verdict(f, r, group, built, r.assignment!.agentId, false)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ markReady(`Fixed, head 2. ${pr}`)+ const recheck = reviews().filter(r => !firstRound.some(([id]) => id === r.id))+ expect(recheck).toHaveLength(2)+ expect(new Set(recheck.map(r => r.assignment!.agentId))).toEqual(new Set(firstRound.map(([, a]) => a)))+ for (const r of recheck) {+ const own = firstRound.find(([, a]) => a === r.assignment!.agentId)!+ expect(r.brief).toContain(`Delta review: #${f.state.conversations.find(c => c.id === own[0])!.number} reviewed the earlier head.`)+ }+ })++ it('lets the Lead open the second review by hand beside the first, with no holder group, and refuses a third', () => {+ const { f, leadActor, group, reviewer, fresh, markReady, reviews } = ready('claude', { reviews: 2 })+ f.run({ type: 'agent.release', agentId: fresh, decision: 'stop' }, leadActor)+ f.run({ type: 'agent.release', agentId: reviewer, decision: 'stop' }, leadActor)+ const create = () => f.run({ type: 'conversation.create', title: 'Review: by hand', brief: 'Review it.', reviewOf: group,+ checks: [{ description: 'Verdict', independent: false }] }, leadActor)+ create()+ expect(reviews()).toHaveLength(1)+ // The Engineer's hand-over opens the one still missing, not a third.+ markReady(`Ready. ${pr}`)+ expect(reviews()).toHaveLength(2)+ expect(create).toThrow('already reviews this work and has no verdict yet')+ expect(reviews()).toHaveLength(2)+ })++ it('is done only once two different Reviewers passed at the head handed over last', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready('claude', { reviews: 2 })+ const done = () => f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ markReady(`Ready. ${pr}`)+ const [first, second] = reviews()+ verdict(f, first!, group, built, first!.assignment!.agentId, true)+ // The work's independent check now reads passed, but only one Reviewer said so.+ expect(done).toThrow('This task wants 2 independent reviews')+ // The second Reviewer finds a problem: still not done, whatever the first said.+ verdict(f, second!, group, built, second!.assignment!.agentId, false)+ expect(done).toThrow('Completion needs a result and evidence for every acceptance check.')+ // A new head: the first Reviewer's pass was for the earlier one.+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'working', result: null }, builderActor)+ markReady(`Fixed, head 2. ${pr}`)+ const [lane2] = reviews().filter(r => r.id !== first!.id && r.id !== second!.id)+ verdict(f, lane2!, group, built, lane2!.assignment!.agentId, true)+ expect(done).toThrow('This task wants 2 independent reviews')+ const [lane1] = reviews().filter(r => ![first!.id, second!.id, lane2!.id].includes(r.id))+ verdict(f, lane1!, group, built, lane1!.assignment!.agentId, true)+ expect(lane1!.assignment!.agentId).not.toBe(lane2!.assignment!.agentId)+ done()+ expect(f.state.conversations.find(c => c.id === group)!.assignment!.status).toBe('done')+ })++ it('never takes another project\'s Reviewer for the second review, and refuses a review of another project\'s work without its title', () => {+ const { f, lead, leadActor, fresh, reviewer, markReady, reviews } = ready('claude', { reviews: 2 })+ const other = f.run({ type: 'project.create', name: 'Other', visibility: 'public', brief: '' }).result+ const outsider = f.add('other-reviewer', 'owner', other.conversationId as string)+ Object.assign(f.state.agents.find(a => a.id === outsider)!, { role: 'reviewer', configuration: { ...config, engine: 'claude', model: 'claude-opus-4-7' } })+ f.run({ type: 'agent.release', agentId: fresh, decision: 'stop' }, leadActor)+ markReady(`Ready. ${pr}`)+ expect(reviews().map(r => r.assignment?.agentId ?? null)).toEqual([reviewer, null])+ expect(f.state.conversations.filter(c => c.agentIds.includes(outsider)).map(c => c.id)).toEqual([other.conversationId])+ // A two-review task of the other project: a review of it from this project is refused, naming nothing of it.+ const theirs = f.run({ type: 'conversation.create', projectId: other.projectId as string, title: 'Secret payroll export',+ task: { ...offlineTask, review: { reviews: 2 } }, checks: [{ description: 'Review', independent: true }] }).result.conversationId as string+ let refusal = ''+ try { f.run({ type: 'conversation.create', title: 'Review: theirs', brief: 'Review it.', reviewOf: theirs, checks: [{ description: 'Verdict', independent: false }] }, leadActor) }+ catch (error) { refusal = (error as Error).message }+ expect(refusal).not.toBe('')+ expect(refusal).not.toContain('Secret payroll')+ expect(f.state.conversations.filter(c => c.reviewOf === theirs)).toEqual([])+ expect(lead).toBeTruthy()+ })++ it('keeps a task with no plan as today: one review, no focus line, done on its checks', () => {+ const { f, group, built, builderActor, markReady, reviews } = ready()+ markReady(`Ready. ${pr}`)+ expect(reviews()).toHaveLength(1)+ expect(reviews()[0]!.brief).not.toContain('Review focus')+ expect(reviews()[0]!.brief).not.toContain('Independent review')+ expect(reviews()[0]!.title).toBe('Review: Offline editing')+ verdict(f, reviews()[0]!, group, built, reviews()[0]!.assignment!.agentId, true)+ f.run({ type: 'work.status', conversationId: group, assignmentId: built, status: 'done', result: 'Merged.' }, builderActor)+ expect(f.state.conversations.find(c => c.id === group)!.assignment).not.toHaveProperty('verdicts')+ expect(f.state.conversations.find(c => c.id === group)!.assignment).not.toHaveProperty('handoffs')+ })+ })// Overnight 2026-10-30 reviews waited hours with every Codex Reviewer out of quota, and nobody was told. Since any strong// engine reviews (Ken, 2026-10-30), the chat hears only when no machine can start one of any engine.diff --git a/backend/src/superTabs/commands.ts b/backend/src/superTabs/commands.tsindex f1f38223e..f3c8d366b 100644--- a/backend/src/superTabs/commands.ts+++ b/backend/src/superTabs/commands.ts@@ -4,7 +4,7 @@ import { keepUsernames, setUsername, swarmUsernames } from './usernames.js'import { z } from 'zod'import { tokensByModelSchema } from './costs/tokens.js'import {- activeWork, actorKey, agent, agentRole, appendPullRequestUrls, author, conversation, crossProjectActive, fail, isLeads, person, stableId, syncLeads, numberConversations, nextConversationNumber, renderWorkTask,+ activeWork, actorKey, agent, agentRole, appendPullRequestUrls, author, conversation, crossProjectActive, fail, isLeads, person, stableId, syncLeads, numberConversations, nextConversationNumber, renderWorkTask, reviewsPassed, reviewsWanted,finishWorker, requireWorkerDecisions, reviewing, seenMachineIds, swarmGridName, visibleState, AGENT_ONLY, STATUS_LABELS, forRecipients,type Actor, type AgentConfiguration, type AgentStart, type AgentStartRequest, type BuddySessionEntry, type WorkTask, type Agent, type Author, type CommandEffects, type Conversation, type SuperTabState,} from './model.js'@@ -32,7 +32,7 @@ import { react, reactionSchema, type ReactionTarget } from './reactions.js'import { shipNotice, shippedAt } from './ship.js'import { assignedNotice, tellBuddies } from './buddyNews.js'import { bindPullRequestCards, bindTaskCard, pullRequestCard, recordCardMerged } from './cards.js'-import { openReview, openReviewOf, projectPullRequest, verdictPending } from './autoReview.js'+import { fullReviewOf, openReview, opensReviews, PASS_HINT, projectPullRequest, reviewersToPass, reviewHeldBy, reviewStampOf, supersedeReviews, swarmAuthor, verdictHandoff, verdictPending } from './autoReview.js'import { carryOver, cheapAttempt, GRID_START_FAILED, REVIEW_FAILED, stepUp, stepUpRefusal } from './stepUp.js'import { avatarChoice, setAgentAvatar, setMemberAvatar, setStatus, statusSchema, type AvatarUpload } from './profile.js'import { agentKind, agentProjectId, audienceOf, agentSetRole, canReadProject, deleteProject, isConfidential, markConfidential, onTeamAccount, requireSingleRegistration, groupProject, inviteLanding, ledProject, manageProject, MAX_ROLES, mutableProjects, placeRules, projectMembers, projectOf, projectRules, projectsOf, readAgent, readConversation, readProject, roleDefaults, roleVersion, sameProject, sharedWithLeads, SKILL_SET_NAMES, skillSetOf, withRoleDefaults, type ProjectRole, type RoleDefaults, type RoleKind, type SwarmProject } from './projects.js'@@ -92,6 +92,8 @@ export const startRequestSchema = z.object({maxCpuPercent: z.number().min(0).max(100), tools: z.array(z.string().regex(/^[A-Za-z0-9_.+-]{1,80}$/)).max(20),devices: z.array(path).max(20), quotaRequired: z.boolean() }).strict(),}).strict()+/** The reviewers' verdicts an attempt keeps for a task wanting two reviews: the latest of each, the most recent ones. */+const MAX_VERDICTS = 8const check = z.object({ description: z.string().trim().min(1).max(1000), independent: z.boolean() }).strict()const task = z.object({goal: z.string().trim().min(1).max(8000), changes: z.string().trim().min(1).max(8000),@@ -99,6 +101,9 @@ const task = z.object({/** model.ts TaskRequirement; `unseenMachines` is only ever read back, never set. */requires: z.object({ machines: z.array(id).min(1).max(20).optional(), devices: z.array(path).min(1).max(20).optional() }).strict().refine(r => r.machines || r.devices, 'Require at least one machine or device.').optional(),+ /** model.ts ReviewPlan: what every review the Swarm opens for it checks first, and 2 for two independent reviews. */+ review: z.object({ focus: z.string().trim().min(1).max(2000).optional(), reviews: z.union([z.literal(1), z.literal(2)]).optional() }).strict()+ .refine(r => r.focus !== undefined || r.reviews !== undefined, 'Give the review a focus or a number of reviews.').optional(),}).strict()export const commandSchema = z.discriminatedUnion('type', [@@ -256,10 +261,10 @@ const WORDS: Partial<Record<Command['type'], readonly string[]>> = {'agent.start': ['request.name', 'overrideReason'],'agent.startFailed': ['error'],'agent.startSettled': ['warning'],- 'conversation.create': ['title', 'brief', 'task.goal', 'task.changes', 'task.constraints', 'task.owns[]', 'checks[].description'],+ 'conversation.create': ['title', 'brief', 'task.goal', 'task.changes', 'task.constraints', 'task.owns[]', 'task.review.focus', 'checks[].description'],'conversation.rename': ['title'],'buddy.rename': ['name'],- 'work.define': ['brief', 'task.goal', 'task.changes', 'task.constraints', 'task.owns[]', 'checks[].description'],+ 'work.define': ['brief', 'task.goal', 'task.changes', 'task.constraints', 'task.owns[]', 'task.review.focus', 'checks[].description'],'work.assign': ['overrideReason'],'work.status': ['result'],'work.cancel': ['reason'],@@ -1451,16 +1456,19 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commafail('REVIEW_TARGET', 'A review group reviews one build group of the same project.', 400)}requireCustomRole(project, 'reviewer')- // One open review at a time: a Lead on the skill text from before #610 would otherwise open one beside the Swarm's.- const pending = openReviewOf(state, reviewed)+ // One open review at a time, or two for a task wanting two independent reviews: a Lead on the skill text from before+ // #610 would otherwise open one beside the Swarm's.+ const pending = fullReviewOf(state, reviewed)if (pending) fail('REVIEW_OPEN', `#${pending.number} ${pending.title} already reviews this work and has no verdict yet. Cancel it first, or wait for its verdict.`)}+ // A review by hand of a task wanting two reviews reviews its current hand-over, as one the Swarm opens does.+ const reviewStamp = command.reviewOf ? reviewStampOf(conversation(state, command.reviewOf)) : undefinedconst requesterId = command.requesterId ? requester(state, project, command.requesterId) : actor.kind === 'person' ? actor.userId : undefinedconst number = nextConversationNumber(state)state.groupCounter = numberstate.conversations.push({ id: operationId, ...(state.projects ? { projectId: project.id } : {}),number, title: command.title, leadId, agentIds: leadId ? [leadId] : [],- archived: false, brief, ...(command.task ? { task: command.task } : {}), ...(command.reviewOf ? { reviewOf: command.reviewOf } : {}),+ archived: false, brief, ...(command.task ? { task: command.task } : {}), ...(command.reviewOf ? { reviewOf: command.reviewOf } : {}), ...(reviewStamp ? { reviewStamp } : {}),assignment: null, lastMessageSequence: 0,checks: command.checks.map((c, i) => ({ ...c, id: stableId(operationId, String(i)), evidence: null, passedBy: null })),})@@ -2419,6 +2427,11 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaif (command.status === 'done' && (!command.result || !group.checks.every(c => c.passedBy && c.evidence))) {fail('CHECKS_PENDING', 'Completion needs a result and evidence for every acceptance check.')}+ if (command.status === 'done' && !reviewsPassed(assignment, reviewsWanted(group.task))) {+ const missing = reviewersToPass(state, group)+ fail('REVIEWS_PENDING', `This task wants ${reviewsWanted(group.task)} independent reviews: it is done once that many different Reviewers pass its independent check at the revision handed over last.${+ missing.length ? ` Still to pass it at this revision, after their review's pass verdict: ${missing.join(', ')}. ${PASS_HINT}` : ''}`)+ }let asked: string | undefinedif (command.ask) {if (command.status !== 'needs_human' || !command.result || actor.kind !== 'agent') {@@ -2436,6 +2449,10 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma}const changed = assignment.status !== command.status || assignment.result !== command.result || !!command.ask, previous = assignment.statusconst waited = waitingForReview(assignment)+ // Each hand-over of a task wanting two reviews is a new head: verdicts on an earlier one no longer count toward done.+ if (changed && command.status === 'review' && actor.kind === 'agent' && actor.agentId === assignment.agentId && reviewsWanted(group.task) > 1) {+ assignment.handoffs = (assignment.handoffs ?? 0) + 1+ }assignment.status = command.statusassignment.result = command.result// A new status is a new hand-off, or the end of one: a review's earlier findings are answered.@@ -2458,8 +2475,11 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Commaconst asked = !command.ask ? '' : effects.result.notAsked ? `\n\n${effects.result.notAsked}` : `\n\nAsked ${person(state, command.ask.personId).email}.`message(group.id, `${label}${command.result ? `\n\n${command.result}` : ''}${asked}`, [...(tellLead ? [lead] : []), ...reviewers], null, SYSTEM_ROW)// The Engineer's own Ready for review with a pull request of the project opens its review (autoReview.ts).- const pullRequest = command.status === 'review' && actor.kind === 'agent' && actor.agentId === assignment.agentId && !group.reviewOf- && !group.audience && !openReviewOf(state, group) ? projectPullRequest(state, group, command.result) : null+ const handedOver = command.status === 'review' && actor.kind === 'agent' && actor.agentId === assignment.agentId && !group.reviewOf+ && !group.audience ? projectPullRequest(state, group, command.result) : null+ // A new head of a task wanting two reviews closes the reviews left on an earlier one, so both open again for it.+ if (handedOver && opensReviews(state, group)) effects.messages.push(...supersedeReviews(state, group, operationId, swarmAuthor(state, group, sender)))+ const pullRequest = handedOver && !fullReviewOf(state, group) ? handedOver : nullconst opened = pullRequest && openReview(state, group, command.result!, pullRequest, { operationId, now: context.now, engineer: sender,// The owner's hard rules hold as for work.assign; the reviewed task's own requirement is its Engineer's, not its Reviewer's.mayWork: a => !teamWorkCheck(state, a.machineId, a.contributorId, groupProject(state, group), context.now, context.teamMachines, context.otherWorkspaceMachines)@@ -2564,6 +2584,27 @@ export function applyCommand(original: SuperTabState, actor: Actor, input: Comma}check.evidence = command.evidencecheck.passedBy = command.passed ? actorKey(actor) : null+ // Two reviews pass one independent check in turn: each reviewer's own verdict is kept beside it, at most one each.+ // A Reviewer's counts through the review it holds, for that review's hand-over once it gave its own verdict; a person's or+ // the Lead's for the hand-over they judged (review of #2382).+ if (check.independent && !group.reviewOf && reviewsWanted(group.task) > 1) {+ const by = actorKey(actor), assignment = group.assignment+ const review = actor.kind === 'agent' ? reviewHeldBy(state, group, actor.agentId) : undefined+ assignment.verdicts = [...(assignment.verdicts ?? []).filter(v => v.by !== by),+ { by, passed: command.passed, handoff: review ? verdictHandoff(group, review) : assignment.handoffs ?? 0, ...(review ? { review: review.id } : {}) }]+ .slice(-MAX_VERDICTS)+ }+ // A review's own verdict settles its Reviewer's pass on the work: a pass verdict keeps a pass given while this review was+ // open (the same head), in either order; a Hold, or a pass given through an earlier review, is cleared (review 3 of #2382).+ const build = group.reviewOf ? state.conversations.find(c => c.id === group.reviewOf) : undefined+ const held = group.assignment && `agent:${group.assignment.agentId}`+ if (build?.assignment?.verdicts) for (const v of build.assignment.verdicts) {+ if (v.review !== group.id && v.by !== held) continue+ const kept = v.review === group.id && v.passed ? verdictHandoff(build, group) : -1+ // Cleared is gone: a later pass verdict of the same review does not bring it back.+ if (kept < 0) v.passed = false+ v.handoff = kept+ }const run = group.ledger?.runs?.find(r => r.assignmentId === group.assignment!.id), reviewed = run?.firstReview// Before the review's first verdict is kept: a check's verdict counts once per attempt.if (actor.kind === 'agent') recordVerdict(state, group, check, agent(state, actor.agentId), context.now)diff --git a/backend/src/superTabs/model.ts b/backend/src/superTabs/model.tsindex 2336be2ec..e8cf40c27 100644--- a/backend/src/superTabs/model.ts+++ b/backend/src/superTabs/model.ts@@ -184,17 +184,42 @@ export interface Assignment {/** When a review last found problems in its hand-off: the hand-off no longer pauses its quiet time (liveness.ts* waitingForReview). Its next status clears it. */reviewFoundAt?: number+ /** A task wanting two independent reviews only (Lead, 10-30: done once both passed at the same head): how many times its+ * agent handed it over for review in this attempt, each a new head, and each reviewer's latest verdict on its independent+ * checks with the hand-over it judged. */+ handoffs?: number+ verdicts?: ReviewVerdict[]/** Why and when it was lost (status `lost`); after a usage limit whose screen gave a reset time, when its own agent may* take it back (work.resume) unless it was handed on first. */lost?: { reason: string; at: number; resumeAt?: string }}+/** One reviewer's (actorKey) latest verdict on a task's independent checks. `handoff`: the hand-over it counts for: a+ * person's or the Lead's at the hand-over they judged, a Reviewer's only once its [review] for that hand-over gave its own+ * verdict (autoReview.ts verdictHandoff), else -1, which never counts (review of #2382: a pass on an earlier head counted+ * for the next one). */+export interface ReviewVerdict { by: string; passed: boolean; handoff: number; review?: string }+/** Whether [assignment] has passing verdicts from [wanted] different reviewers at its latest hand-over. One review needs none+ * of this: its checks say it. */+export const reviewsPassed = (assignment: Assignment, wanted: number): boolean => wanted < 2 ||+ (assignment.verdicts ?? []).filter(v => v.passed && v.handoff === (assignment.handoffs ?? 0)).length >= wanted+/** The hand-over of a task wanting two reviews that a review of it was opened for: its attempt, and which hand-over. */+export interface ReviewStamp { assignmentId: string; handoff: number }export interface WorkTask {goal: stringchanges: stringconstraints: stringowns: string[]requires?: TaskRequirement+ /** What its reviews check first, and how many independent reviews it needs (autoReview.ts). Absent: one review, no focus. */+ review?: ReviewPlan}+/** The Lead's review plan for a task (nightly reflection 10-30: the Lead hand-sent a focus to 20+ reviews that day, and+ * built holder groups for second security reviews). `focus` leads every review the Swarm opens for it; `reviews: 2` opens+ * two, each by a different Reviewer. */+export interface ReviewPlan { focus?: string; reviews?: 1 | 2 }++/** How many independent reviews [task] needs: 2 only when its review plan says so. */+export const reviewsWanted = (task: WorkTask | undefined): number => task?.review?.reviews === 2 ? 2 : 1/** Where a task can be done at all (2026-10-27: a task to check a device plugged into one person's Mac was routed to another* machine by policy order). `machines`: it runs only there, or on a Mac's Harness Team account of one of them. `devices`:* full paths every start for it asks its machine to check (cli superTabs/capacity.ts). Never in the rendered brief, since@@ -214,8 +239,11 @@ export function withSeenRequirement<T extends Pick<Conversation, 'task'>>(group:unseenMachines: (requires.unseenMachines ?? 0) + requires.machines.length - machines.length } } }}+export const TWO_REVIEWS = 'Two independent reviews, each by a different Reviewer.'export function renderWorkTask(task: WorkTask): string {+ const review = [...task.review?.focus ? [task.review.focus] : [], ...reviewsWanted(task) === 2 ? [TWO_REVIEWS] : []]return `Goal:\n${task.goal}\n\nChanges:\n${task.changes}\n\nConstraints:\n${task.constraints}\n\nOwns:\n${task.owns.map(area => `- ${area}`).join('\n')}`+ + (review.length ? `\n\nReview:\n${review.join('\n')}` : '')}export interface Conversation {@@ -233,6 +261,8 @@ export interface Conversation {task?: WorkTask/** A review group names the group whose work it reviews; only a Reviewer is assigned it, and a Reviewer nothing else. */reviewOf?: string+ /** A review of a task wanting two reviews: the hand-over it reviews. A later hand-over closes it and opens a new one. */+ reviewStamp?: ReviewStampchecks: Check[]assignment: Assignment | nulllastMessageSequence: numberdiff --git a/backend/src/superTabs/parts/light.test.ts b/backend/src/superTabs/parts/light.test.tsindex 211273dae..8ae78ecd4 100644--- a/backend/src/superTabs/parts/light.test.ts+++ b/backend/src/superTabs/parts/light.test.ts@@ -9,11 +9,11 @@ import { FINISHED, GROUP_FIELDS } from './light.js'const assignment: Required<Assignment> = {id: 'w', agentId: 'a', status: 'working', configuration: { engine: 'codex', model: null, effort: null, contextWindow: null, engineVersion: null },execution: { machineId: 'm', harnessId: 'h', machineOwnerId: 'o' }, result: null, recordingProgress: { at: 1, revision: 1 }, leaseUntil: 1, progressAt: 1, askedOf: 'p', reviewFoundAt: 1,- lost: { reason: 'r', at: 1 },+ handoffs: 1, verdicts: [{ by: 'agent:r', passed: true, handoff: 1, review: 'g' }], lost: { reason: 'r', at: 1 },}const conversation: Required<Conversation> = {id: 'g', kind: 'leads', projectId: 'p', number: 1, title: 't', leadId: null, agentIds: [], archived: false, brief: '',- task: { goal: '', changes: '', constraints: '', owns: [] }, reviewOf: 'r', checks: [], assignment, lastMessageSequence: 0, lastMainSequence: 0, pullRequestUrls: [], cards: {},+ task: { goal: '', changes: '', constraints: '', owns: [] }, reviewOf: 'r', reviewStamp: { assignmentId: 'w', handoff: 1 }, checks: [], assignment, lastMessageSequence: 0, lastMainSequence: 0, pullRequestUrls: [], cards: {},messageSeq: 0, reportSeq: 0, dormant: false, lastActivityAt: '', audience: { people: [] }, lostAttempt: { id: 'w', agentId: 'a' }, reactionSeq: 0,requesterId: 'p', ledger: {}, proposals: [], buddyName: 'Sparky', buddySessions: [], liveness: { state: 'quiet', why: 'silent', since: 1 }, leadAction: { kind: 'post', at: 1 },stepUp: { attempt: 2, floor: 2, reason: 'r', at: 1, carry: '' },diff --git a/backend/src/superTabs/parts/light.ts b/backend/src/superTabs/parts/light.tsindex 3bee331dd..93a24dd37 100644--- a/backend/src/superTabs/parts/light.ts+++ b/backend/src/superTabs/parts/light.ts@@ -27,8 +27,9 @@ export const GROUP_FIELDS = {always: ['id', 'kind', 'projectId', 'leadId', 'agentIds', 'archived', 'audience', 'dormant', 'assignment.id', 'assignment.agentId', 'assignment.status','assignment.lost'],whenRunning: ['title', 'task.owns', 'assignment.execution', 'assignment.result'],- unread: ['number', 'brief', 'reviewOf', 'checks', 'lastMessageSequence', 'lastMainSequence', 'pullRequestUrls', 'cards', 'messageSeq', 'reportSeq', 'lastActivityAt', 'lostAttempt', 'requesterId', 'ledger', 'reactionSeq', 'proposals', 'buddyName', 'buddySessions', 'liveness', 'leadAction', 'stepUp',- 'assignment.configuration', 'assignment.recordingProgress', 'assignment.leaseUntil', 'assignment.progressAt', 'assignment.askedOf', 'assignment.reviewFoundAt'],+ unread: ['number', 'brief', 'reviewOf', 'reviewStamp', 'checks', 'lastMessageSequence', 'lastMainSequence', 'pullRequestUrls', 'cards', 'messageSeq', 'reportSeq', 'lastActivityAt', 'lostAttempt', 'requesterId', 'ledger', 'reactionSeq', 'proposals', 'buddyName', 'buddySessions', 'liveness', 'leadAction', 'stepUp',+ 'assignment.configuration', 'assignment.recordingProgress', 'assignment.leaseUntil', 'assignment.progressAt', 'assignment.askedOf', 'assignment.reviewFoundAt',+ 'assignment.handoffs', 'assignment.verdicts'],} as constconst LIGHT_GROUP = {_id: 0, key: 1, version: 1, changedAt: 1, ordinal: 1, dormant: 1,diff --git a/backend/src/superTabs/parts/touches.test.ts b/backend/src/superTabs/parts/touches.test.tsindex 169f47ce6..9cbe9da3b 100644--- a/backend/src/superTabs/parts/touches.test.ts+++ b/backend/src/superTabs/parts/touches.test.ts@@ -70,6 +70,23 @@ describe('the parts a command touches (design section 1.2, column T)', () => {expect(has(again.touches, 'agent', reviewer) || has(again.touches, 'head', 'head')).toBe(false)})+ it('makes a task wanting two reviews meet on both Reviewers it takes in one write', () => {+ const f = swarm(), a = f.group('A')+ const add = (harnessId: string) => {+ const id = f.run({ type: 'agent.add', conversationId: 'lead', machineId: 'host', harnessId, name: harnessId, configuration: { ...config, engine: config.engine === 'claude' ? 'codex' : 'claude', model: config.engine === 'claude' ? 'default' : 'opus' }, lead: false },+ owner, { contribution: { machineOwnerId: 'host-owner', contributorId: 'owner' } }).effects.result.agentId as string+ f.state.agents.find(x => x.id === id)!.role = 'reviewer'+ return id+ }+ const first = add('reviewer-1'), second = add('reviewer-2')+ f.state.conversations.find(c => c.id === a.id)!.task = { goal: 'G', changes: 'C', constraints: 'K', owns: ['x'], review: { reviews: 2 } }+ f.state.projects![0]!.repository = { machineId: 'host', cwd: '/repo', repositoryUrl: 'https://github.com/example/project' }+ const ready = f.run({ type: 'work.status', conversationId: a.id, assignmentId: a.assignmentId, status: 'review',+ result: 'Ready. https://github.com/example/project/pull/7' }, f.agentActor(a.worker))+ expect(ready.effects.state.conversations.filter(c => c.reviewOf === a.id).map(c => c.assignment!.agentId).sort()).toEqual([first, second].sort())+ expect([has(ready.touches, 'agent', first), has(ready.touches, 'agent', second), has(ready.touches, 'head', 'head')]).toEqual([true, true, true])+ })+it('makes finishing work and the Lead\'s next start or assignment meet on the project\'s progress part', () => {const f = swarm(), a = f.group('A')f.run({ type: 'work.check', conversationId: a.id, assignmentId: a.assignmentId, checkId: f.state.conversations.find(c => c.id === a.id)!.checks[0]!.id,diff --git a/backend/src/superTabs/parts/touches.ts b/backend/src/superTabs/parts/touches.tsindex f2dfcbc86..ce02e8a57 100644--- a/backend/src/superTabs/parts/touches.ts+++ b/backend/src/superTabs/parts/touches.ts@@ -181,11 +181,12 @@ export function touchesFor(command: Command, actor: Actor, before: SuperTabStateif (command.status === 'review') {// A review the Swarm opened by itself (autoReview.ts) reads whether its Reviewer is free and numbers the new group,// as conversation.create and work.assign do: two opened at once meet on that Reviewer and on the head.- const opened = effects.state.conversations.find(c => c.reviewOf === command.conversationId && !before.conversations.some(b => b.id === c.id))- if (opened) {+ // A task wanting two independent reviews opens two in one write, each with its own Reviewer.+ const opened = effects.state.conversations.filter(c => c.reviewOf === command.conversationId && !before.conversations.some(b => b.id === c.id))+ if (opened.length) {head()group(leadGroupOf(projectOfGroup(command.conversationId)?.id))- agent(opened.assignment?.agentId)+ for (const review of opened) agent(review.assignment?.agentId)progress(projectOfGroup(command.conversationId)?.id)}}diff --git a/cli/src/lib/swarmSkills.spec.ts b/cli/src/lib/swarmSkills.spec.tsindex aa81623fe..e27b9f020 100644--- a/cli/src/lib/swarmSkills.spec.ts+++ b/cli/src/lib/swarmSkills.spec.ts@@ -155,6 +155,8 @@ describe('built-in Swarm skills', () => {const reactionsBefore = (role: 'lead' | 'dev' | 'review') => `\n${reactions(role).trimEnd()}\n`// The Builder's 👀 replaces its "say that you took it" line, in both modes.const took = '- React 👀 to the message that assigned it and mark it working; your first post is your plan or a first result, never that you took it.\n'+ // The task's review plan (nightly reflection 10-30): a new bullet right after each Lead's review line, nothing replaced.+ const reviewPlan = '- Put what every review must check first (the most-likely-wrong list, the privacy edges) in the task\'s review focus when you create or define it, and ask for two reviews when the work needs two independent ones: every review the Swarm opens for it, re-checks too, starts with that focus, two open at once on different Reviewers with no holder group, and the task is done only once both pass at the revision handed over last.\n'const reactionTake: Array<['orchestration' | 'default', 'dev', string, string]> = [['orchestration', 'dev', took, '- Say in the group chat that you took it and what your first step is; mark it working.\n'],['default', 'dev', took, '- Say in the group that you took it and what you will do first; mark it working.\n'],@@ -171,7 +173,7 @@ describe('built-in Swarm skills', () => {})// By role too: the Builder's and the Reviewer's tool-check line is the same, and only the Builder's replaced an approved one.const approved = (text: string, mode: 'orchestration' | 'default', role: 'lead' | 'dev' | 'review') =>- [...autoReview, ...failFast, ...stallWake, ...reactionTake].filter(([m, r]) => m === mode && r === role).reduce((t, [, , line, before]) => t.replace(line, before), text)+ [...autoReview, ...failFast, ...stallWake, ...reactionTake].filter(([m, r]) => m === mode && r === role).reduce((t, [, , line, before]) => t.replace(line, before), role === 'lead' ? text.replace(reviewPlan, '') : text)it('tells each Lead to act within minutes on the Swarm\'s stall wake-up, in place of the 6-hour rule, and no other role', () => {for (const [mode, , line, before] of stallWake) {expect(readFileSync(prepareSwarmSkill(fixture(), { role: 'lead', key: 'session', mode }).file, 'utf8').split(line), mode).toHaveLength(2)@@ -182,6 +184,16 @@ describe('built-in Swarm skills', () => {}}})+ it('tells each Lead, once and right after its review line, to put the review focus and two reviews on the task, and no other role', () => {+ for (const mode of ['orchestration', 'default'] as const) {+ for (const role of ['lead', 'dev', 'review'] as const) {+ const text = readFileSync(prepareSwarmSkill(fixture(), { role, key: 'session', mode }).file, 'utf8')+ expect(text.split(reviewPlan), `${mode} ${role}`).toHaveLength(role === 'lead' ? 2 : 1)+ const reviewLine = autoReview.find(([m, r]) => m === mode && r === 'lead')![2].replace(/\n?$/, '\n')+ if (role === 'lead') expect(text, mode).toContain(`${reviewLine}${reviewPlan}`)+ }+ }+ })it('tells each Lead the Swarm opens reviews by itself, and each Builder to hand off with a pull request link', () => {for (const [mode, role, line, before] of autoReview) {const text = readFileSync(prepareSwarmSkill(fixture(), { role, key: 'session', mode }).file, 'utf8')diff --git a/cli/src/lib/swarmSkills.ts b/cli/src/lib/swarmSkills.tsindex 002dcbecc..fbed22f4d 100644--- a/cli/src/lib/swarmSkills.ts+++ b/cli/src/lib/swarmSkills.ts@@ -131,6 +131,7 @@ For large work, post the group plan and get the owner's ok before assigning; onc- Independent review is required when risk or difficulty is medium or higher, when the work touches security, data, defaults or a release, or when the result will be merged. Also bring in a Reviewer when a Builder is stuck, before a large refactor, or after a hard bug fix.- Read the Builder's doubts first; settle any doubt about correctness or scope before the review starts.- When a Builder marks ready for review with a pull request of the project's repository, the Swarm opens "Review: <group>" by itself: its brief holds the goal, constraints, owned code, checks, the Builder's handoff and the pull request, privacy first when the work touches sharing or access. A free Reviewer gets it (the one that reviewed the earlier head, for a re-review) and joins the Builder's group to pass the independent check. You get one line there; cancel the review if it is not needed, and post what its brief lacks (the spec's constraints copied verbatim, the most-likely-wrong list). When the line says no Reviewer is free, route the review group, start a Reviewer (on any engine, with a model at least as strong as the Builder's), assign it and add it to the Builder's group. Work marked ready without a pull request link gets the same group from you, by hand. A review with no verdict stays open while the work it reviews goes on.+- Put what every review must check first (the most-likely-wrong list, the privacy edges) in the task's review focus when you create or define it, and ask for two reviews when the work needs two independent ones: every review the Swarm opens for it, re-checks too, starts with that focus, two open at once on different Reviewers with no holder group, and the task is done only once both pass at the revision handed over last.- Never tell a Reviewer what not to flag or how to grade it.- Do not review the diff yourself: same blind spots, and it burns the context you need to coordinate.- Re-grade each finding by what a user gets if it ships, not by its label or by the spec's silence. Critical findings are fixed now, Important ones before you accept, Minor ones recorded for later.@@ -448,6 +449,7 @@ Keep each Builder's list a few tasks deep; do the easy, self-contained parts fir## 5. Review and accept- Work that will be merged, or carries medium risk or more, gets a Reviewer. When its Builder marks ready for review with a pull request link, the Swarm opens "Review: <group>", assigns a free Reviewer and tells you in one line; cancel it there if it is not needed. When no Reviewer is free, route it, start one, assign it and add it to the Builder's group. Without a pull request link, create the review group yourself the same way.+- Put what every review must check first (the most-likely-wrong list, the privacy edges) in the task's review focus when you create or define it, and ask for two reviews when the work needs two independent ones: every review the Swarm opens for it, re-checks too, starts with that focus, two open at once on different Reviewers with no holder group, and the task is done only once both pass at the revision handed over last.- Findings go back to the Builder; you rule on disagreements.- Accept only when the reviewed revision is the handed-off revision, its checks have evidence, and CI is green on it.- Close the task saying what was and was not delivered.diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.tsindex ad0cf43f9..0343b57f3 100644--- a/cli/src/superTabs/service.spec.ts+++ b/cli/src/superTabs/service.spec.ts@@ -114,6 +114,22 @@ describe('five-part task commands', () => {expect(t.call).toHaveBeenLastCalledWith('POST', '/api/super-tabs/tab/commands', { operationId: 'task-op', asAgentId: t.agentId, command: { ...base, brief, checks } })})}+ it('renders a task\'s review plan into its brief as the backend does', async () => {+ const t = setup()+ const review = { focus: ' Check revoked access first. ', reviews: 2 }+ expect(await send(t, { type: 'conversation.create', title: 'Drafts', task: { ...task, review }, checks })).toMatchObject({ ok: true })+ expect(t.call).toHaveBeenLastCalledWith('POST', '/api/super-tabs/tab/commands', { operationId: 'task-op', asAgentId: t.agentId,+ command: { type: 'conversation.create', title: 'Drafts', task: { ...task, review }, checks,+ brief: `${brief}\n\nReview:\nCheck revoked access first.\nTwo independent reviews, each by a different Reviewer.` } })+ })+ it('tells the Lead an older server takes no review plan, and sends nothing more', async () => {+ const t = setup(), original = t.call.getMockImplementation()!+ t.call.mockImplementation(async (...args) => args[0] === 'POST'+ ? { status: 400, body: { success: false, error: { code: 'VALIDATION_ERROR', message: 'command.task: Unrecognized key: "review"' } } } as never : original(...args))+ expect(await send(t, { type: 'work.define', conversationId: 'group', task: { ...task, review: { reviews: 2 } }, checks }))+ .toMatchObject({ error: 'REVIEW_PLAN_UNSUPPORTED', detail: expect.stringContaining('review focus in its constraints') })+ expect(t.call.mock.calls.filter(c => c[0] === 'POST')).toHaveLength(1)+ })it('preserves other errors and never repeats a failed compatibility retry', async () => {for (const [status, code, message, count] of [[403, 'FORBIDDEN', 'Unrecognized key: "task"', 1], [400, 'VALIDATION_ERROR', 'Invalid title', 1],diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.tsindex 0f30a92a7..84e6aadc9 100644--- a/cli/src/superTabs/service.ts+++ b/cli/src/superTabs/service.ts@@ -44,7 +44,7 @@ const POST_HELP = `${POST_ABOUT} TEXT is one argument: when it holds quotes, orconst BUDDY_POST_HELP = `${POST_ABOUT} TEXT is one argument, the message itself in quotes: 'your message', or "it's done" when it holds an apostrophe. A Buddy never passes - for TEXT: its message is checked for secrets, so one read from stdin is refused and nothing is posted.`/** What the command entry says after how its JSON is passed, the same for everyone. */const COMMAND_ABOUT = 'send one of the commands below.'-const COMMAND_RULES = 'Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model. A model on the Swarm\'s grid builds only low-risk work of kind docs, tests or fixtures, unless a person asks for a local model or names one, and ranks first there unless the owner set noGridFirst (at medium difficulty a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid, at the top tier as every build, at most twice) and tells you: route it again, and the route and the server keep to the new floor.'+const COMMAND_RULES = 'Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model. A model on the Swarm\'s grid builds only low-risk work of kind docs, tests or fixtures, unless a person asks for a local model or names one, and ranks first there unless the owner set noGridFirst (at medium difficulty a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid, at the top tier as every build, at most twice) and tells you: route it again, and the route and the server keep to the new floor. A task\'s optional review (conversation.create or work.define) leads every review the Swarm opens for it, the first and each re-check, with its focus; reviews 2 opens two at once, each on a different Reviewer, so no holder group is needed, and the task is done only once both pass its independent check at the revision handed over last: a Reviewer\'s pass counts once its own review of that revision passed (a Hold clears it), and a person\'s or the Lead\'s pass counts for the revision current when they give it. Leave review out for one review as before.'/** A Buddy's guard refuses `command` itself and every JSON read from stdin, so its help never offers - and stdin there either* (a Buddy that follows a stdin form is refused and tries again, #2360); it quotes the JSON, as its usage hints do. */const BUDDY_COMMAND_HELP = `command OPERATION_ID JSON: ${COMMAND_ABOUT} The JSON is one argument, in single quotes: command OPERATION_ID '{...}' (an apostrophe inside it as \\u0027). ${COMMAND_RULES}`@@ -92,7 +92,8 @@ const HELP = {{ type: 'project.digest', projectId: 'PROJECT', time: '08:00', timeZone: 'Asia/Ho_Chi_Minh' },{ type: 'tab.tidy', enabled: false, askedIn: { conversationId: 'GROUP', messageId: 'OWNER_MESSAGE' } },{ type: 'message.send', conversationId: 'GROUP', text: 'A message addressed to an agent', replyTo: null, recipientIds: ['AGENT'] },- { type: 'conversation.create', title: 'Outcome', task: { goal: 'An independently assignable result', changes: 'What changes', constraints: 'What must stay true', owns: ['Paths or code areas'] }, checks: [{ description: 'Observable acceptance evidence', independent: false }] },+ { type: 'conversation.create', title: 'Outcome', task: { goal: 'An independently assignable result', changes: 'What changes', constraints: 'What must stay true', owns: ['Paths or code areas'],+ review: { focus: 'Optional: what every review of it checks first, such as the most-likely-wrong list (up to 2,000 characters)', reviews: 2 } }, checks: [{ description: 'Observable acceptance evidence', independent: false }] },{ type: 'conversation.create', title: 'Review: Outcome', reviewOf: 'GROUP', task: { goal: 'An independent verdict on the Builder\'s revision', changes: 'None: read only', constraints: 'The reviewed group\'s constraints', owns: ['The reviewed group\'s owned code, read only'] }, checks: [{ description: 'Verdict with the reviewed revision', independent: false }] },{ type: 'conversation.agent', conversationId: 'GROUP', agentId: 'AGENT', present: true, lead: false },{ type: 'work.define', conversationId: 'GROUP', task: { goal: 'What to deliver', changes: 'What changes', constraints: 'What must stay true', owns: ['Paths or code areas'] }, checks: [{ description: 'Observable acceptance evidence', independent: false }] },@@ -186,7 +187,11 @@ function taskCommand(command: Record<string, unknown>): Record<string, unknown>if ([trimmed.goal, trimmed.changes, trimmed.constraints].some(part => part.length > 8000) || trimmed.owns.length > 40 || trimmed.owns.some(area => area.length > 4096)) {throw new SuperTabHostError('INVALID_TASK', 'Task sections may have up to 8,000 characters; owns needs 1–40 paths or areas of up to 4,096 characters each.', 400)}+ // The review plan renders as the backend's (superTabs/model.ts renderWorkTask); the backend checks its fields.+ const review = object(task.review), focus = typeof review.focus === 'string' ? review.focus.trim() : ''+ const plan = [...focus ? [focus] : [], ...review.reviews === 2 ? ['Two independent reviews, each by a different Reviewer.'] : []]const brief = `Goal:\n${trimmed.goal}\n\nChanges:\n${trimmed.changes}\n\nConstraints:\n${trimmed.constraints}\n\nOwns:\n${trimmed.owns.map(area => `- ${area}`).join('\n')}`+ + (plan.length ? `\n\nReview:\n${plan.join('\n')}` : '')const limit = command.type === 'conversation.create' ? 8000 : 32_000if (brief.length > limit) throw new SuperTabHostError('INVALID_TASK', `Keep the rendered task within ${limit.toLocaleString('en-US')} characters.`, 400)return { ...command, task: trimmed, brief }@@ -647,6 +652,11 @@ export function superTabService(core: CoreApi, options: SuperTabServiceOptions =&& /Unrecognized (?:key: "mentions"|key\(s\) in object: 'mentions')/.test(error.message)) {return { error: 'MENTIONS_UNSUPPORTED', detail: 'This Swarm\'s server does not support tagging people yet.' }}+ // A backend from before review plans: the Lead sends the task without one, its focus in the constraints.+ if (object(command.task).review !== undefined && error instanceof SuperTabHostError && error.status === 400 && error.code === 'VALIDATION_ERROR'+ && /Unrecognized (?:key: "review"|key\(s\) in object: 'review')/.test(error.message)) {+ return { error: 'REVIEW_PLAN_UNSUPPORTED', detail: 'This Swarm\'s server does not take a task\'s review plan yet. Send the task without it and put the review focus in its constraints.' }+ }if (!['conversation.create', 'work.define'].includes(String(command.type)) || !command.task || !(error instanceof SuperTabHostError)) throw errorconst oldSchema = error.status === 400 && error.code === 'VALIDATION_ERROR'&& /^(?:command: )?Unrecognized (?:key: "task"|key\(s\) in object: 'task')$/.test(error.message)diff --git a/desktop/lib/super_tabs/roles_editor.dart b/desktop/lib/super_tabs/roles_editor.dartindex c8ff579aa..4905715d6 100644--- a/desktop/lib/super_tabs/roles_editor.dart+++ b/desktop/lib/super_tabs/roles_editor.dart@@ -72,6 +72,7 @@ Keep each Builder's list a few tasks deep; do the easy, self-contained parts fir## 5. Review and accept- Work that will be merged, or carries medium risk or more, gets a Reviewer. When its Builder marks ready for review with a pull request link, the Swarm opens "Review: <group>", assigns a free Reviewer and tells you in one line; cancel it there if it is not needed. When no Reviewer is free, route it, start one, assign it and add it to the Builder's group. Without a pull request link, create the review group yourself the same way.+- Put what every review must check first (the most-likely-wrong list, the privacy edges) in the task's review focus when you create or define it, and ask for two reviews when the work needs two independent ones: every review the Swarm opens for it, re-checks too, starts with that focus, two open at once on different Reviewers with no holder group, and the task is done only once both pass at the revision handed over last.- Findings go back to the Builder; you rule on disagreements.- Accept only when the reviewed revision is the handed-off revision, its checks have evidence, and CI is green on it.- Close the task saying what was and was not delivered.