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
fix(swarm): contributed starts read their project's skills (no 400 per start); validation, heartbeat and machine_select logs say why (#1999)
0xken1555c55b747e24
diff --git a/backend/integration/superTabs.test.ts b/backend/integration/superTabs.test.tsindex 0d0e7005b..1c2d1c1d3 100644--- a/backend/integration/superTabs.test.ts+++ b/backend/integration/superTabs.test.ts@@ -842,6 +842,34 @@ describe('Super Tabs on a real Mongo replica set', () => {expect(await runs()).toEqual([['moonshotai/kimi-k3', true], ['moonshotai/kimi-k3', true]])})+ it('tells a contributed machine its start\'s project skills, which its host cannot read from the Swarm', async () => {+ // Prod logs 2026-10-28: the host asked for a Swarm status read it may not make (a 400 at every start), then launched+ // every agent on Harness orchestration, whatever its project ran.+ const tab = (await store.create(owner, randomUUID(), 'Skills pool')).id+ const invitation = await run(tab, { type: 'invite.create', email: host.email, role: 'collaborator', conversationId: 'lead' })+ await run(tab, { type: 'invite.accept', inviteId: invitation.result.inviteId as string }, host)+ await db.machine.create({ data: { machineId: 'skills-host', userId: host.sub, apiKey: 'fixture-skills-host', managerId: 'fixture', autonomousEnv: 'prod', authMode: 'remote' } })+ const team = await teamMachine('skills-host')+ await run(tab, { type: 'machine.contribute', machineId: 'skills-host', name: 'Skills laptop', cwd: '/project', engines: ['claude'], maxAgents: 4 }, host)+ const generation = (await poolRows(store, host, 'skills-host'))[0]!.machine.generation+ await store.observeMachine(team.session, tab, 'skills-host', { generation, resources: { cpuPercent: 10, memoryTotalBytes: 32e9, memoryUsedBytes: 4e9,+ diskFreeBytes: 120e9, diskTotalBytes: 500e9, projectDiskFreeBytes: 120e9, deviceType: 'Laptop', chip: 'Fixture CPU', os: 'macOS', gpuPercent: null },+ quotas: [], tools: { git: true }, runningHarnessIds: [], stoppedHarnessIds: [], privacy: team.privacy })+ const start = async () => String((await run(tab, { type: 'agent.start', request: { conversationId: 'lead', machineId: 'skills-host', engine: 'claude',+ name: 'Builder', cwd: '/project', worktree: true,+ requirements: { memoryBytes: 0, diskBytes: 0, maxCpuPercent: 100, tools: [], devices: [], quotaRequired: false } } })).result.startId)+ const skillMode = async (startId: string) => (await store.start(host, tab, startId, undefined, 'skills-host')).skillMode++ expect(await skillMode(await start())).toBe('default')+ await run(tab, { type: 'project.skills', projectId: 'lead', mode: 'orchestration' })+ expect(await skillMode(await start())).toBe('orchestration')+ await run(tab, { type: 'project.roles.create', projectId: 'lead', roles: [{ id: 'lead', name: 'Product Manager', kind: 'lead', text: 'LEAD' },+ { id: 'dev', name: 'Engineer', kind: 'builder', text: 'DEV' }, { id: 'review', name: 'Reviewer', kind: 'reviewer', text: 'REVIEW' }] })+ await run(tab, { type: 'project.skills', projectId: 'lead', mode: 'custom' })+ // A Custom set is the Default skills with the owner's role text, which the agent reads after it joins.+ expect(await skillMode(await start())).toBe('default')+ })+it('contributes project capacity without sharing the computer and fences host execution', async () => {const tab = (await store.create(owner, randomUUID(), 'Machine pool')).idconst invitation = await run(tab, { type: 'invite.create', email: host.email, role: 'collaborator', conversationId: 'lead' })diff --git a/backend/src/errors/AppError.ts b/backend/src/errors/AppError.tsindex f578c429d..c3e5116eb 100644--- a/backend/src/errors/AppError.ts+++ b/backend/src/errors/AppError.ts@@ -18,7 +18,8 @@ export class NotFoundError extends AppError {}export class ValidationError extends AppError {- constructor(message: string) {+ /** `fields`: the names of the fields refused, for the log; never their values. */+ constructor(message: string, readonly fields: string[] = []) {super(message, 400, 'VALIDATION_ERROR')this.name = 'ValidationError'}diff --git a/backend/src/lib/adapterWs.ts b/backend/src/lib/adapterWs.tsindex 3385ccd06..851259178 100644--- a/backend/src/lib/adapterWs.ts+++ b/backend/src/lib/adapterWs.ts@@ -401,7 +401,7 @@ async function attachAdapter(ws: WebSocket, machineId: string, userId: string, c// and counted pongs only, so an adapter that was actively sending application traffic could still// be killed if one pong went missing. `trackSocketLiveness` counts message/ping/pong against a time// deadline instead, which is the same fix already applied to the hub's own sockets.- const releaseLiveness = trackSocketLiveness(ws)+ const releaseLiveness = trackSocketLiveness(ws, 'adapter')onMessage = (raw: RawData, isBinary: boolean): void => {if (isBinary) {diff --git a/backend/src/lib/agentMessagesWs.ts b/backend/src/lib/agentMessagesWs.tsindex f520c62a5..0e1b70395 100644--- a/backend/src/lib/agentMessagesWs.ts+++ b/backend/src/lib/agentMessagesWs.ts@@ -66,7 +66,7 @@ async function attach(ws: WebSocket, userId: string, share: string, machine: strlive.get(key)?.close(4409, 'Replaced by a newer connection')live.set(key, ws)const send = (frame: unknown) => guardedSendJson(ws, frame, 'must')- const disposers: Array<() => void> = [trackSocketLiveness(ws)]+ const disposers: Array<() => void> = [trackSocketLiveness(ws, 'agentMessages')]let closed = falsews.once('close', () => { closed = true; if (live.get(key) === ws) live.delete(key); for (const d of disposers.splice(0)) d() })const keep = (dispose: () => void) => { if (closed) dispose(); else disposers.push(dispose) }diff --git a/backend/src/lib/deviceWs.ts b/backend/src/lib/deviceWs.tsindex 9506dce75..ca9909066 100644--- a/backend/src/lib/deviceWs.ts+++ b/backend/src/lib/deviceWs.ts@@ -390,7 +390,7 @@ function relay(device: WebSocket, opts: RelayOpts): void {// the picker (or short of `device_hello`) it would otherwise never be pinged and a half-open drop would// never be reaped — leaving presence green, the MQTT bridge open and this relay's timers running.// The device pings US every 15s, so it earns a much shorter silence deadline than a browser.- const releaseLiveness = trackSocketLiveness(device, DEVICE_IDLE_DEADLINE_MS)+ const releaseLiveness = trackSocketLiveness(device, 'device', DEVICE_IDLE_DEADLINE_MS)// Multi-attach: the device is a `commander` on ALL the user's machines at once — ONE per-user socket// holding N per-machine commander clients, keyed by machineId. Each machine's node then sees commander>0 and// runs its recap, so a background machine's turn-done can badge the device. `activeMachineId` is the ONEdiff --git a/backend/src/lib/hub.ts b/backend/src/lib/hub.tsindex e884dae0f..b9ae7ef45 100644--- a/backend/src/lib/hub.ts+++ b/backend/src/lib/hub.ts@@ -182,6 +182,11 @@ type Alive = WebSocket & {__hubLastPing?: number__hubDeadlineMs?: number__hubLivenessWired?: boolean+ // For the timeout log only: which endpoint holds it, since when, whether it ever answered and how many pings it has not.+ __hubClient?: string+ __hubSince?: number+ __hubAnswered?: boolean+ __hubUnanswered?: number}// Liveness is a DEADLINE ON SILENCE, not a count of sweeps. Counting tied how fast a dead peer is noticed@@ -204,7 +209,13 @@ export const DEVICE_IDLE_DEADLINE_MS = 35_000function wireLiveness(socket: WebSocket): void {if ((socket as Alive).__hubLivenessWired) return;(socket as Alive).__hubLivenessWired = true- const markAlive = (): void => { (socket as Alive).__hubLastAlive = Date.now() }+ ;(socket as Alive).__hubSince ??= Date.now()+ const markAlive = (): void => {+ const alive = socket as Alive+ alive.__hubLastAlive = Date.now()+ alive.__hubAnswered = true+ alive.__hubUnanswered = 0+ }socket.on('message', markAlive)socket.on('ping', markAlive)socket.on('pong', markAlive)@@ -220,9 +231,10 @@ const trackedSockets = new Set<WebSocket>()/** Keep `socket` in the liveness sweep regardless of hub-client attachment, with an optional custom* silence deadline (the deadline is stored ON the socket, so it still applies once clients attach).- * Returns the release fn. */-export function trackSocketLiveness(socket: WebSocket, deadlineMs?: number): () => void {+ * `client` names its endpoint in the timeout log. Returns the release fn. */+export function trackSocketLiveness(socket: WebSocket, client: string, deadlineMs?: number): () => void {;(socket as Alive).__hubLastAlive ??= Date.now()+ ;(socket as Alive).__hubClient = clientif (deadlineMs != null) (socket as Alive).__hubDeadlineMs = deadlineMswireLiveness(socket)trackedSockets.add(socket)@@ -237,7 +249,11 @@ function pingOrTerminate(ws: Alive, info: Record<string, unknown>): boolean {const deadline = ws.__hubDeadlineMs ?? CLIENT_IDLE_DEADLINE_MSconst idleMs = now - (ws.__hubLastAlive ??= now)if (idleMs >= deadline) {- logger.warn('hub client heartbeat timed out', { ...info, idleMs, deadline })+ // The server pings and the deadline is three pings long, so an idle just past it is the sweep's own 5 s step. What+ // tells a dead peer (a computer that slept) from a client that never answers pings is `answered` and its age+ // (prod logs 2026-10-28: 40–78 every 10 minutes, most named only `tracked`).+ logger.warn('hub client heartbeat timed out', { ...info, ...(ws.__hubClient ? { client: ws.__hubClient } : {}), idleMs, deadline,+ connectedMs: now - (ws.__hubSince ?? now), answered: ws.__hubAnswered === true, unansweredPings: ws.__hubUnanswered ?? 0 })try { ws.terminate() } catch { /* ignore */ }return true}@@ -245,6 +261,7 @@ function pingOrTerminate(ws: Alive, info: Record<string, unknown>): boolean {const pingEvery = Math.max(LIVENESS_TICK_MS, Math.floor(deadline / 3))if (now - (ws.__hubLastPing ?? 0) >= pingEvery) {ws.__hubLastPing = now+ ws.__hubUnanswered = (ws.__hubUnanswered ?? 0) + 1try { ws.ping() } catch { /* ignore */ }}return truediff --git a/backend/src/lib/hubLiveness.test.ts b/backend/src/lib/hubLiveness.test.tsnew file mode 100644index 000000000..20fdfada9--- /dev/null+++ b/backend/src/lib/hubLiveness.test.ts@@ -0,0 +1,46 @@+import { afterAll, describe, expect, it, vi } from 'vitest'+import type { WebSocket } from 'ws'++vi.mock('./bus.js', () => ({+ setAgentClientCount: vi.fn(async () => undefined), setAgentClientCountsBatch: vi.fn(async () => undefined),+ getAgentClientState: vi.fn(async () => ({ totals: { ui: 0, commander: 0, commanderActive: 0 }, commanderJoinGeneration: undefined })),+ bumpCommanderJoinGeneration: vi.fn(async () => 1), publishDown: vi.fn(async () => 1), publishUp: vi.fn(async () => 1),+ publishTerminalDown: vi.fn(async () => 1), subscribeUp: vi.fn(async () => () => undefined), subscribeTerminalUp: vi.fn(async () => () => undefined),+}))+vi.mock('./providerLink.js', () => ({ routeDown: async (_m: string, _d: unknown, fallback: () => Promise<number>) => fallback() }))+vi.mock('../utils/logger.js', () => ({ logger: { warn: vi.fn(), info: vi.fn(), error: vi.fn() } }))++// The sweep's interval starts when the module loads, so the clock is fake before it does.+vi.useFakeTimers()+const { trackSocketLiveness, CLIENT_IDLE_DEADLINE_MS } = await import('./hub.js')+const { logger } = await import('../utils/logger.js')+afterAll(() => { vi.useRealTimers() })++function socket() {+ const listeners = new Map<string, () => void>()+ const ws = { readyState: 1, ping: vi.fn(), terminate: vi.fn(() => { ws.readyState = 3 }),+ on: (event: string, listener: () => void) => { listeners.set(event, listener) } }+ return { ws: ws as unknown as WebSocket, ping: ws.ping, terminate: ws.terminate, hear: (event: string) => listeners.get(event)!() }+}+const timedOut = () => vi.mocked(logger.warn).mock.calls.filter(([message]) => message === 'hub client heartbeat timed out').map(([, info]) => info)++// Prod logs 2026-10-28: 40–78 of these every 10 minutes, most saying only `tracked`, so nobody could tell which clients went+// silent, or whether they ever answered a ping (a client that cannot) or stopped answering (a computer that slept).+describe('a socket that stops answering', () => {+ it('is closed past its deadline, and the log names its client, its age and the pings it left unanswered', async () => {+ vi.mocked(logger.warn).mockClear()+ const answered = socket(), silent = socket()+ trackSocketLiveness(answered.ws, 'web')+ trackSocketLiveness(silent.ws, 'observer')+ await vi.advanceTimersByTimeAsync(30_000)+ answered.hear('pong')+ await vi.advanceTimersByTimeAsync(CLIENT_IDLE_DEADLINE_MS + 5_000)+ expect(silent.terminate).toHaveBeenCalledOnce()+ expect(answered.terminate).toHaveBeenCalledOnce()+ const [observer, web] = timedOut() as Array<Record<string, unknown>>+ // A ping every third of the deadline, at 5, 30 and 55 s: none answered, closed at 75 s. The web client answered the one at+ // 30 s and left those at 55 and 80 s unanswered, closed at 105 s.+ expect(observer).toMatchObject({ kind: 'tracked', client: 'observer', answered: false, unansweredPings: 3, idleMs: 75_000, connectedMs: 75_000 })+ expect(web).toMatchObject({ kind: 'tracked', client: 'web', answered: true, unansweredPings: 2, idleMs: 75_000, connectedMs: 105_000 })+ })+})diff --git a/backend/src/lib/observerWs.ts b/backend/src/lib/observerWs.tsindex ee1c0845b..be7807b7c 100644--- a/backend/src/lib/observerWs.ts+++ b/backend/src/lib/observerWs.ts@@ -41,7 +41,7 @@ export async function attachObserver(ws: WebSocket, user: AuthUser | null,share: { id: string; machineId: string; ownerId: string; superTabId?: string | null }, linkEnv?: AutonomousEnvironment): Promise<void> {const connId = `observer:${randomUUID()}`const send = (frame: unknown) => guardedSendJson(ws, frame, 'must')- const disposers: Array<() => void> = [trackSocketLiveness(ws)]+ const disposers: Array<() => void> = [trackSocketLiveness(ws, 'observer')]let closed = falselet opened = falseconst down = (type: string, payload: unknown) => publishDown(share.machineId, { connId, frame: { type, payload } })diff --git a/backend/src/lib/webWs.ts b/backend/src/lib/webWs.tsindex 521e7a26f..10d2f2ecc 100644--- a/backend/src/lib/webWs.ts+++ b/backend/src/lib/webWs.ts@@ -185,7 +185,7 @@ function attachUserClient(ws: WebSocket, user: AuthUser, surface: 'mobile' | 'we// registry-driven sweep can't see it — it would be killed by LB idle timeouts, or never reaped when// dead. This used to be a second heartbeat loop here, carefully disabled while attached so the two// sweeps couldn't race; the hub now tracks the socket itself, which is one sweep for both states.- const releaseLiveness = trackSocketLiveness(ws)+ const releaseLiveness = trackSocketLiveness(ws, 'web')// ── Live Machines-list feed ──────────────────────────────────────────────────────────────────// Subscribe node_status for EVERY agent the user owns and forward it tagged with the machineId (the@@ -354,11 +354,15 @@ function attachUserClient(ws: WebSocket, user: AuthUser, surface: 'mobile' | 'weif (closed || gen !== selectGen) return // superseded by a newer select// Another account's machine is selected only while it is shared with this one (lib/machineAccess.ts),// with the same rights as the owner's own; its daemon decides again whether to trust this account.+ let shareCheckFailed = falseconst shared = binding && !binding.deletedAt && binding.userId !== user.sub- ? await sharedMachineAccess(user, binding).catch(() => null) : null+ ? await sharedMachineAccess(user, binding).catch(() => { shareCheckFailed = true; return null }) : nullif (closed || gen !== selectGen) returnif (!binding || binding.deletedAt || (binding.userId !== user.sub && !shared)) {- logger.warn('machine_select rejected', { userId: user.sub, machineId })+ // About 45 an hour in prod said nothing more (2026-10-28): a machine removed since, or one no longer shared, is the+ // client's stale list; a failed share check is ours.+ const reason = !binding ? 'unknown' : binding.deletedAt ? 'deleted' : shareCheckFailed ? 'share_check_failed' : 'not_shared'+ logger.warn('machine_select rejected', { userId: user.sub, machineId, reason })send({ type: 'machine_select_error', payload: { machineId: machineId, error: 'NOT_YOUR_MACHINE' } })return}diff --git a/backend/src/lib/webWsOffline.test.ts b/backend/src/lib/webWsOffline.test.tsindex 73b3a4f0c..c4c18e69a 100644--- a/backend/src/lib/webWsOffline.test.ts+++ b/backend/src/lib/webWsOffline.test.ts@@ -7,8 +7,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'// already out there) is refused at once, with how long to wait; a phone or the web viewer still waits attached.const m = vi.hoisted(() => ({auth: vi.fn(), upgrade: vi.fn(), presence: vi.fn(), online: vi.fn(), attach: vi.fn(),- machineFindUnique: vi.fn(),+ machineFindUnique: vi.fn(), shared: vi.fn(), warn: vi.fn(),}))+vi.mock('../utils/logger.js', () => ({ logger: { warn: m.warn, info: vi.fn(), error: vi.fn(), debug: vi.fn() } }))+vi.mock('./machineAccess.js', async original => ({ ...await original<typeof import('./machineAccess.js')>(), sharedMachineAccess: m.shared }))vi.mock('./ssoAuth.js', async original => ({ ...await original<typeof import('./ssoAuth.js')>(), authenticateAccessToken: m.auth }))vi.mock('./wsServer.js', async original => ({ ...await original<typeof import('./wsServer.js')>(), createWss: () => ({ handleUpgrade: m.upgrade }) }))vi.mock('./prisma.js', () => ({@@ -85,3 +87,20 @@ it.each(['mobile', 'web'])('a %s client still attaches to an offline machine andexpect(m.attach).toHaveBeenCalledOnce()expect(ws.sent()).toContainEqual(expect.objectContaining({ type: 'connected', payload: expect.objectContaining({ machineId: 'owner-mac' }) }))})++// Prod logs 2026-10-28: about 45 refused selects an hour, and the log did not say why.+describe('a refused machine select', () => {+ it.each([+ ['unknown', null, null],+ ['deleted', { ...mac, deletedAt: new Date('2026-10-01T00:00:00Z') }, null],+ ['not_shared', { ...mac, userId: 'someone-else' }, null],+ ['share_check_failed', { ...mac, userId: 'someone-else' }, new Error('database down')],+ ])('logs why: %s', async (reason, binding, failure) => {+ m.machineFindUnique.mockResolvedValue(binding)+ if (failure) m.shared.mockRejectedValue(failure)+ else m.shared.mockResolvedValue(null)+ const ws = await selects({}, '&client=web')+ expect(ws.sent()).toContainEqual({ type: 'machine_select_error', payload: { machineId: 'owner-mac', error: 'NOT_YOUR_MACHINE' } })+ expect(m.warn).toHaveBeenCalledWith('machine_select rejected', { userId: 'owner', machineId: 'owner-mac', reason })+ })+})diff --git a/backend/src/middlewares/errorHandler.ts b/backend/src/middlewares/errorHandler.tsindex d058f8f4c..ce5ef80bc 100644--- a/backend/src/middlewares/errorHandler.ts+++ b/backend/src/middlewares/errorHandler.ts@@ -1,5 +1,5 @@import type { FastifyError, FastifyReply, FastifyRequest } from 'fastify'-import { AppError } from '../errors/index.js'+import { AppError, ValidationError } from '../errors/index.js'import { sendError } from '../utils/response.js'import { logger } from '../utils/logger.js'import { SuperTabError } from '../superTabs/model.js'@@ -34,6 +34,7 @@ export async function errorHandler(path: request.url,method: request.method,message: error.message,+ ...(error instanceof ValidationError && error.fields.length ? { fields: error.fields } : {}),})sendError(reply, error.message, error.code || 'APP_ERROR', error.statusCode)returndiff --git a/backend/src/middlewares/validation.test.ts b/backend/src/middlewares/validation.test.tsnew file mode 100644index 000000000..b73623221--- /dev/null+++ b/backend/src/middlewares/validation.test.ts@@ -0,0 +1,44 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import Fastify, { type FastifyInstance } from 'fastify'+import { errorHandler } from './errorHandler.js'+import { validateBody } from './validation.js'+import { operationSchema } from '../superTabs/commands.js'+import { logger } from '../utils/logger.js'++// Prod logs 2026-10-28: a host's start report was refused with 400 VALIDATION_ERROR every few minutes, and the log said only+// "Invalid input", so nobody could tell which field. The log names the fields; their values may be a person's words.+describe('a body refused by its schema', () => {+ let app: FastifyInstance+ beforeEach(async () => {+ app = Fastify()+ app.setErrorHandler(errorHandler)+ app.post('/api/super-tabs/hosts/m1/starts/tab-1/start-1', { preHandler: validateBody(operationSchema) }, async () => ({}))+ await app.ready()+ })+ afterEach(async () => { await app.close(); vi.restoreAllMocks() })++ const refused = async (payload: unknown) => {+ const warn = vi.spyOn(logger, 'warn').mockImplementation(() => {})+ const res = await app.inject({ method: 'POST', url: '/api/super-tabs/hosts/m1/starts/tab-1/start-1', payload: payload as object })+ // Hosts fall back to an older form of a command on exactly this answer (cli superTabs/start.ts), so it stays.+ expect(res.statusCode).toBe(400)+ expect(res.json().error.code).toBe('VALIDATION_ERROR')+ const logged = warn.mock.calls.find(([message]) => message === 'Application error')![1] as Record<string, unknown>+ return { logged, text: JSON.stringify(warn.mock.calls) }+ }++ it('logs the names of the missing fields', async () => {+ expect((await refused({})).logged).toMatchObject({ code: 'VALIDATION_ERROR', fields: ['operationId', 'command'] })+ })++ it('logs nested and unknown field names, never their values', async () => {+ const { logged, text } = await refused({ operationId: 'op-1', command: { type: 'agent.started', startId: 'start-1', harnessId: 'h-1',+ configuration: { engine: 'claude', model: null, effort: null, contextWindow: 0, engineVersion: null }, token: 'SECRET-VALUE' } })+ expect(logged.fields).toEqual(['command.configuration.contextWindow', 'command.token'])+ expect(text).not.toContain('SECRET-VALUE')+ })++ it('names the command type when no command has it', async () => {+ expect((await refused({ operationId: 'op-1', command: { type: 'agent.unknown' } })).logged.fields).toEqual(['command.type'])+ })+})diff --git a/backend/src/middlewares/validation.ts b/backend/src/middlewares/validation.tsindex 494cc2495..080a330b3 100644--- a/backend/src/middlewares/validation.ts+++ b/backend/src/middlewares/validation.ts@@ -2,6 +2,18 @@ import type { FastifyReply, FastifyRequest } from 'fastify'import { z } from 'zod'import { ValidationError } from '../errors/index.js'+/** The fields a request was refused for, by name only: a value may be a person's words or a credential. Zod's own first+ * message ("Invalid input") does not say which field, and a host's start report was refused every few minutes in+ * prod without anyone being able to tell why (2026-10-28). */+export function refusedFields(issues: readonly z.core.$ZodIssue[]): string[] {+ const names = issues.flatMap(issue => {+ const at = issue.path.map(String)+ if (issue.code === 'unrecognized_keys') return issue.keys.map(key => [...at, key].join('.'))+ return [at.join('.') || '(body)']+ })+ return [...new Set(names)].slice(0, 20)+}+/** `named` puts the failing field's path before zod's message, which alone ("expected number, received undefined") does not say which one. */export function validateBody<T extends z.ZodTypeAny>(schema: T, options: { named?: boolean } = {}) {return async (request: FastifyRequest<{ Body: z.infer<T> }>, _reply: FastifyReply): Promise<void> => {@@ -9,7 +21,7 @@ export function validateBody<T extends z.ZodTypeAny>(schema: T, options: { namedif (!result.success) {const issue = result.error.issues[0]const field = options.named && issue?.path.length ? `${issue.path.join('.')}: ` : ''- throw new ValidationError(issue?.message ? `${field}${issue.message}` : 'Invalid request body')+ throw new ValidationError(issue?.message ? `${field}${issue.message}` : 'Invalid request body', refusedFields(result.error.issues))}request.body = result.data as z.infer<T>}@@ -19,7 +31,7 @@ export function validateParams<T extends z.ZodTypeAny>(schema: T) {return async (request: FastifyRequest<{ Params: z.infer<T> }>, _reply: FastifyReply): Promise<void> => {const result = schema.safeParse(request.params)if (!result.success) {- throw new ValidationError(result.error.issues[0]?.message || 'Invalid request parameters')+ throw new ValidationError(result.error.issues[0]?.message || 'Invalid request parameters', refusedFields(result.error.issues))}request.params = result.data as z.infer<T>}@@ -29,7 +41,7 @@ export function validateQuery<T extends z.ZodTypeAny>(schema: T) {return async (request: FastifyRequest<{ Querystring: z.infer<T> }>, _reply: FastifyReply): Promise<void> => {const result = schema.safeParse(request.query)if (!result.success) {- throw new ValidationError(result.error.issues[0]?.message || 'Invalid query parameters')+ throw new ValidationError(result.error.issues[0]?.message || 'Invalid query parameters', refusedFields(result.error.issues))}request.query = result.data as z.infer<T>}diff --git a/backend/src/superTabs/store.ts b/backend/src/superTabs/store.tsindex 144f27822..fe33b89ba 100644--- a/backend/src/superTabs/store.ts+++ b/backend/src/superTabs/store.ts@@ -16,7 +16,7 @@ import { attachmentMime, attachmentName, AttachmentTooLarge, AVATAR_PURPOSE, AVAimport { randomBytes } from 'node:crypto'import type { Readable } from 'node:stream'import { logger } from '../utils/logger.js'-import { canReadAgent, canReadGroup, canWatchAgent, groupProject, ledProject, projectOf, projectsOf, agentProjectId, readConversation, roleVersion, watchingNarrowed, type ProjectVisibility } from './projects.js'+import { canReadAgent, canReadGroup, canWatchAgent, groupProject, ledProject, projectOf, projectsOf, agentProjectId, readConversation, roleVersion, skillModeOf, watchingNarrowed, type ProjectVisibility } from './projects.js'import { bindSession, makeProjectPrivate } from './sessionScope.js'import { confidentialSessions, otherRegistrations, recordConfidential } from './confidential.js'import { answersRequest, dirtyGroups, noteProjectReports, projectUpdateRequest } from './projectUpdates.js'@@ -778,8 +778,11 @@ export class SuperTabStore {if (grant.machineOwnerId !== start.machineOwnerId || (grant.hostGrant ?? null) !== start.hostGrant) {fail('CONTRIBUTION_REVOKED', 'This start belongs to a machine grant that was revoked.', 403)}+ // The skills its agent launches with. A contributed machine's host cannot read the Swarm to learn them (cli+ // superTabs/start.ts): until 2026-10-28 it launched every agent on Harness orchestration, whatever its project ran.+ const read = { ...start, skillMode: skillModeOf(groupProject(state, group)) }// The Lead reads that its machine is still preparing it, and waits instead of starting another (liveness.ts).- return startPreparing(state, start, this.now()) ? { ...start, preparing: true as const } : start+ return startPreparing(state, start, this.now()) ? { ...read, preparing: true as const } : read})}diff --git a/cli/src/superTabs/machines.spec.ts b/cli/src/superTabs/machines.spec.tsindex b46d82d16..e3ed8c83d 100644--- a/cli/src/superTabs/machines.spec.ts+++ b/cli/src/superTabs/machines.spec.ts@@ -148,6 +148,11 @@ describe('contributed machine executor', () => {expect(where).toMatchObject({ machineId: 'host', dataDir: '/isolated-pool-fixture' })await (scoped as (p: unknown) => Promise<unknown>)({ action: 'startStatus' })expect(f.backend).toHaveBeenLastCalledWith(f.core, 'GET', '/api/super-tabs/hosts/host/starts/tab/start', undefined)+ // Any other read went out as an empty start report, which the backend refused with a 400 at every start (prod logs+ // 2026-10-28): the start endpoint takes only this start's commands.+ const sent = f.backend.mock.calls.length+ expect(await (scoped as (p: unknown) => Promise<unknown>)({ action: 'status' })).toMatchObject({ error: 'HOST_UNSUPPORTED' })+ expect(f.backend.mock.calls.length).toBe(sent)expect(f.close).toHaveBeenCalledOnce()await f.machine.tick()expect(f.open).toHaveBeenCalledOnce()diff --git a/cli/src/superTabs/machines.ts b/cli/src/superTabs/machines.tsindex 9f8715ffc..606b769c4 100644--- a/cli/src/superTabs/machines.ts+++ b/cli/src/superTabs/machines.ts@@ -460,9 +460,12 @@ export class ContributedMachines {if (this.stopped) returnif (!identifier(start.id) || ((row.paused || pool.paused) && !start.dispatched)) continueconst path = `/api/super-tabs/hosts/${this.machineId}/starts/${row.tabId}/${start.id}`- const scoped: ScopedRequest = async input => ({ ok: true, value: await this.deps.backend(this.core,- input.action === 'startStatus' ? 'GET' : 'POST', path,- input.action === 'startStatus' ? undefined : { operationId: input.operationId, command: input.command }) })+ // The start endpoint reads this start and takes its commands, nothing else. Any other read went out as an empty+ // command, which the backend refused with a 400 at every start (prod logs 2026-10-28).+ const scoped: ScopedRequest = async input => input.action !== 'startStatus' && input.action !== 'command'+ ? { error: 'HOST_UNSUPPORTED', detail: 'A contributed machine reads only its own starts.' }+ : { ok: true, value: await this.deps.backend(this.core, input.action === 'startStatus' ? 'GET' : 'POST', path,+ input.action === 'startStatus' ? undefined : { operationId: input.operationId, command: input.command }) }try {// The Harness Team account is not private (its owner's home folder opened again, say): a new start is refused// here as well as by routing, and never moved to the owner's account instead.diff --git a/cli/src/superTabs/start.spec.ts b/cli/src/superTabs/start.spec.tsindex 088cb7e9f..b50ba58cb 100644--- a/cli/src/superTabs/start.spec.ts+++ b/cli/src/superTabs/start.spec.ts@@ -272,6 +272,30 @@ describe('the skills of the project the agent joins', () => {])('reads %s as Harness orchestration', async (_name, state) => {expect(await started(state)).toMatchObject({ swarmSkillMode: 'orchestration' })})++ // Prod logs 2026-10-28: a contributed machine's host asked for a Swarm read it may not make (a 400 at every start) and+ // launched every agent on Harness orchestration. Its start read names the project's skills instead.+ const hosted = async (skillMode?: string) => {+ const f = fixture({ state: projects('orchestration') })+ Object.assign(f.start, { poolGeneration: 'pool-1', ...(skillMode ? { skillMode } : {}) })+ expect(await startAgent({ tabId: 'tab', startId: 'start', hostDispatch: true }, f.scoped, where, f.open)).toMatchObject({ ok: true })+ expect(f.scoped.mock.calls.map(c => c[0].action)).not.toContain('status')+ return f.request.mock.calls.find(call => call[0] === 'agent_create')![1]!+ }+ it('starts a contributed machine\'s agent with the skills its start read names, without reading the Swarm', async () => {+ const payload = await hosted('default')+ expect(payload).toMatchObject({ swarmRole: 'dev', swarmSkillMode: 'default' })+ expect(payload.prompt).toContain('Use the swarm-dev skill for this session: the team process; otherwise work your usual way.')+ })+ it('starts a contributed machine\'s agent on Harness orchestration when an older backend\'s start read names no skills', async () => {+ expect(await hosted()).toMatchObject({ swarmRole: 'dev', swarmSkillMode: 'orchestration' })+ })+ it('takes the start read\'s skills for a Lead\'s own start too', async () => {+ const f = fixture({ state: projects('orchestration') })+ Object.assign(f.start, { skillMode: 'default' })+ await startAgent({ action: 'resume', tabId: 'tab', startId: 'start' }, f.scoped, where, f.open)+ expect(f.request.mock.calls.find(call => call[0] === 'agent_create')![1]).toMatchObject({ swarmSkillMode: 'default' })+ })})it('asks for an owner contribution instead of widening a guest machine connection', async () => {diff --git a/cli/src/superTabs/start.ts b/cli/src/superTabs/start.tsindex 5b717cb1a..f8cff6905 100644--- a/cli/src/superTabs/start.ts+++ b/cli/src/superTabs/start.ts@@ -6,7 +6,7 @@ import { admission, memoryShortIn, quotaOf, type Requirements } from './capacityimport { groupSkillMode, identifier, object } from './host.js'import { permissionModeFlags } from '../lib/engineLaunch.js'import type { AgentEngine } from '../engines/types.js'-import { swarmSkillUse, type SwarmSkillMode } from '../lib/swarmSkills.js'+import { isSwarmSkillMode, swarmSkillUse, type SwarmSkillMode } from '../lib/swarmSkills.js'type Json = Record<string, unknown>export type ScopedRequest = (payload: Json) => Promise<Json>@@ -326,11 +326,13 @@ async function startOnce(input: Json, scoped: ScopedRequest, where: Where, open:// Engines without a full mode retain their existing approving launch flags.// The backend starts a Reviewer only on Claude Code or Codex, the engines with built-in Swarm skills.const skilled = ['claude', 'codex'].includes(String(request.engine)), reviewer = request.role === 'reviewer'- const role = reviewer ? 'review' : 'dev', facts = skilled ? await projectFacts(scoped, request.conversationId, start.machineOwnerId) : null// A contributed machine's host cannot read the tab as a Lead does: it asked the backend whose work this is when it// readied the start, and prepared it with the app's token if it is another person's (superTabs/projectFolder.ts).- const hosted = input.hostDispatch === true ? object(input.github) : null- const mode = facts?.mode ?? null+ // Its Swarm read was refused with a 400 at every start until 2026-10-28, and its agents ran Harness orchestration+ // whatever their project's skills: the start read names them, and a backend from before that keeps orchestration.+ const role = reviewer ? 'review' : 'dev', hosted = input.hostDispatch === true ? object(input.github) : null+ const facts = skilled && !hosted ? await projectFacts(scoped, request.conversationId, start.machineOwnerId) : null+ const mode = !skilled ? null : isSwarmSkillMode(start.skillMode) ? start.skillMode : facts?.mode ?? 'orchestration'const github = hosted ? (typeof hosted.requester === 'string' && hosted.requester ? { requester: hosted.requester } : null) : facts?.github ?? nullconst payload: Json = { engine: request.engine, name: request.name, creationId, startedBy: 'agent', bypassPermission: true,...(permissionModeFlags(request.engine as AgentEngine, 'full') ? { permissionMode: 'full' } : {}),