Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- Desktop: a Room agent can release its own idle ticket claim, returning the ticket to Ready for another seat with its evidence, reviews and worker history kept (#4081, fixes #3452). Thanks to @AIFlowML.

- Web: the development stand-in returns its listed model from `GET /v1/models/{id}` and a 404 `model_not_found` for any other ID, as the engine does (#4091, fixes #4090). Thanks to @AIFlowML.



- Tests: on macOS, threaded host tests no longer hang in Zig's debug stack capture: the test allocator keeps its leak and safety checks but records no allocation stacks there; Linux and custom runners are unchanged (#3855).

- CI: the last four host checks excluded under #2031 return to the aggregate; recording fixtures initialize runner state and affine kernel handles.
Expand Down
1 change: 1 addition & 0 deletions app/electron/agent/room-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function buildPrimer(project: Project, room: Room, seat: Seat, roster: Se
'SHARED BOARD: coordinate through it so you never duplicate a teammate\'s work:',
'ACTION: TOOL list_tickets: see every ticket and who is working on what.',
'ACTION: TOOL claim_ticket {"title":"..."}: claim a ticket BEFORE you start it, so teammates know it is taken.',
'ACTION: TOOL release_ticket {"title":"..."}: return your idle claimed ticket to Ready and keep its evidence.',
'ACTION: TOOL create_ticket {"title":"...","body":"...","priority":"high","risk":"medium","allowedCapabilities":["read"],"requiredEvidence":["files inspected","verification result"],"acceptanceCriteria":["..."]}: add an execution ticket to the board.',
'ACTION: TOOL add_ticket_evidence {"title":"...","kind":"file","summary":"What you found","ref":"src/file.ts"}: attach evidence to a claimed ticket.',
'ACTION: TOOL complete_ticket {"title":"...","evidence":[{"kind":"review","summary":"Reviewed X and found Y"}]}: mark your claimed ticket complete after attaching required evidence.',
Expand Down
90 changes: 88 additions & 2 deletions app/electron/main/host/room-ticket-work-launch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
import assert from 'node:assert/strict'
import os from 'node:os'
import { randomUUID } from 'node:crypto'
import { buildPrimer } from '../../agent/room-protocol'
import { createSubAgentFromLaunch, parentForRoomSeat, startSubAgent } from '../../agent/subagents'
import { createWorkspaceRuntimeIpc } from './workspace-runtime-ipc'

interface HarnessOpts {
startTicketWork: (input: any) => Promise<any>
localOnly?: boolean
beforeWorkspace?: () => void
isTicketStarting?: (id: string) => boolean
onPersistTickets?: (tickets: unknown[]) => void
}

function buildHarness(opts: HarnessOpts) {
Expand Down Expand Up @@ -41,6 +44,7 @@ function buildHarness(opts: HarnessOpts) {
const emittedTickets: any[] = []
const delegated: any[] = []
const remote: any[] = []
const aborters = new Map()
let persistTicketsCalls = 0
let runDeps: any = null
let runDone: Promise<void> | null = null
Expand All @@ -52,6 +56,8 @@ function buildHarness(opts: HarnessOpts) {
auditEvent: async () => {},
auditPreview: (s: string) => s,
roomAborters: new Map(),
aborters,
isTicketStarting: opts.isTicketStarting,
workspaceMutationGuard: { reserveStart: () => ({ addWorkspaceKeys: () => {}, release: () => {} }) },
ensureRoomWorktree: async () => { opts.beforeWorkspace?.(); return os.tmpdir() },
randomUUID, createSubAgentFromLaunch, parentForRoomSeat, startSubAgent,
Expand All @@ -60,7 +66,7 @@ function buildHarness(opts: HarnessOpts) {
return { agent, output: 'Synthetic delegated result' }
},
persistRooms: () => {},
persistTickets: () => { persistTicketsCalls++ },
persistTickets: () => { persistTicketsCalls++; opts.onPersistTickets?.(store.tickets) },
emitRoom: () => {},
emitTicket: (t: any) => emittedTickets.push({ ...t }),
emitJob: () => {},
Expand Down Expand Up @@ -99,7 +105,7 @@ function buildHarness(opts: HarnessOpts) {
})
const api = createWorkspaceRuntimeIpc(ctx as any)
return {
api, store, emittedTickets, remote, delegated,
api, store, emittedTickets, remote, delegated, aborters,
get runDeps() { return runDeps },
get persistTicketsCalls() { return persistTicketsCalls },
// Start the room (which captures the live room tools), then settle the run.
Expand Down Expand Up @@ -213,6 +219,86 @@ async function main() {
assert.equal(workerSources[0]?.reasoningEffort, 'low', 'ticket workers inherit the same Room run capture')
console.log('ok - actual Room delegation forwards independent captured efforts')
}
{
let starting = false
let savedTickets = ''
const first = buildHarness({
startTicketWork: async () => { throw new Error('Release must not start a worker') },
onPersistTickets: (tickets) => { savedTickets = JSON.stringify(tickets) },
})
const parked = first.store.tickets[0]
parked.threadId = 'previous-thread'
parked.evidence = [{ id: 'existing-evidence', summary: 'Prior evidence' }]
parked.execution = { history: ['existing-record'] }
await first.run()
await first.tool('claim_ticket', { id: parked.id }, 'Builder')

const h = buildHarness({
startTicketWork: async () => { throw new Error('Release must not start a worker') },
isTicketStarting: (id) => id === 't1' && starting,
})
const room = h.store.rooms[0]
h.store.tickets = JSON.parse(savedTickets)
room.seats.push({ ...room.seats[0], id: 's2', name: 'Reviewer', role: 'reviewer' })
await h.run()
const ticket = h.store.tickets[0]
const selector = { id: ticket.id }
assert.match(await h.tool('claim_ticket', selector, 'Reviewer'), /Already claimed by Builder/)

async function rejectRelease(expected: RegExp, args: { id?: string; title?: string } = selector, seat = 'Builder') {
const previous = structuredClone(ticket)
const saves = h.persistTicketsCalls
const updates = h.emittedTickets.length
assert.match(await h.tool('release_ticket', args, seat), expected)
assert.deepEqual(ticket, previous, 'a refused release leaves the stored ticket untouched')
assert.equal(h.persistTicketsCalls, saves)
assert.equal(h.emittedTickets.length, updates)
}

await rejectRelease(/Only Builder/, selector, 'Reviewer')
await rejectRelease(/uniquely configured/, selector, 'Removed')
await rejectRelease(/No matching/, { id: 'missing', title: ticket.title })
h.store.tickets.push({ ...ticket, id: 'other', roomId: 'other-room' })
await rejectRelease(/No matching/, { id: 'other' })
assert.equal(h.store.tickets[1].assignee, 'Builder')
room.seats.push({ ...room.seats[0], id: 'conflicting', name: 'builder' })
await rejectRelease(/uniquely configured/)
room.seats.pop()

for (const state of ['queued', 'running']) {
ticket.runState = state
await rejectRelease(/active ticket run/)
}
ticket.runState = null
h.aborters.set(ticket.threadId, {})
await rejectRelease(/active ticket run/)
h.aborters.clear()
starting = true
await rejectRelease(/active ticket run/)
starting = false
ticket.archivedAt = 1
await rejectRelease(/No matching/)
ticket.archivedAt = null
ticket.status = 'completed'
await rejectRelease(/completed/)
ticket.status = 'in_progress'
ticket.updatedAt = 1

const expected = { ...structuredClone(ticket), assignee: null, status: 'ready' }
const saves = h.persistTicketsCalls
const updates = h.emittedTickets.length
assert.match(await h.tool('release_ticket', { title: ticket.title }, 'Builder'), /Released/)
assert.deepEqual(ticket, { ...expected, updatedAt: ticket.updatedAt })
assert.ok(ticket.updatedAt > expected.updatedAt)
assert.equal(h.persistTicketsCalls, saves + 1)
assert.equal(h.emittedTickets.length, updates + 1)
assert.deepEqual(h.emittedTickets.at(-1), ticket)
await rejectRelease(/no claim to release/)
assert.match(await h.tool('claim_ticket', selector, 'Reviewer'), /You claimed/)
assert.equal(ticket.assignee, 'Reviewer')
assert.match(buildPrimer(h.store.projects[0], room, room.seats[0], room.seats), /TOOL release_ticket/)
console.log('ok - only the configured owner can release an idle Room claim without losing its history')
}
console.log('room ticket work launch tests passed')
}

Expand Down
26 changes: 26 additions & 0 deletions app/electron/main/host/room-tools-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createSharedMemory, MEMORY_MAX_BLOCK_CHARS, MEMORY_MAX_BLOCKS, renderSh

import type { WorkspaceRuntimeIpcDeps } from './workspace-runtime-ipc'
import type { RoomWorkerBudget } from '../../agent/types'
import { pickTicketUserPatch, ticketHasActiveRun } from './room-ticket-patch-policy'

export interface RoomToolScope {
reasoningEffort: ReasoningEffortSetting
Expand Down Expand Up @@ -42,6 +43,8 @@ export function createRoomTools(ctx: WorkspaceRuntimeIpcDeps, runtimeScope: Room
emitTicket,
publishRemote,
activeJob,
aborters,
isTicketStarting,
runtimeProvider,
appendRoomSupervisorEvent,
roomTicketConflictBlockers,
Expand Down Expand Up @@ -97,6 +100,29 @@ export function createRoomTools(ctx: WorkspaceRuntimeIpcDeps, runtimeScope: Room
const caps = normalizeTicketCapabilities(tk.allowedCapabilities, ['read']).join(', ')
return `You claimed "${tk.title}". Allowed capabilities: ${caps}. Required evidence: ${required.length ? required.join('; ') : 'none'}.`
},
release_ticket: async (args, seat) => {
const selector = typeof args?.id === 'string' && args.id ? { id: args.id } : args
const { ticket, error } = runtimeScope.resolveTicket(selector)
if (error) return error
const room = runtimeScope.room
if (!ticket || ticket.archivedAt || ticket.roomId !== room.id || ticket.projectId !== room.projectId) {
return 'No matching ticket.'
}
const name = seat.trim().toLowerCase()
const configured = room.seats.filter((candidate) => candidate.name.trim().toLowerCase() === name)
if (configured.length !== 1 || configured[0].name !== seat) return 'The requesting seat is not uniquely configured.'
if (!ticket.assignee) return 'This ticket has no claim to release.'
if (ticket.assignee !== seat) return `Only ${ticket.assignee} can release "${ticket.title}".`
if (ticket.status === 'completed') return 'A completed ticket cannot be released.'
const activeThread = !!ticket.threadId && aborters?.has?.(ticket.threadId)
if (ticketHasActiveRun(ticket, activeThread || !!isTicketStarting?.(ticket.id))) {
return 'Stop the active ticket run before releasing its claim.'
}
Object.assign(ticket, pickTicketUserPatch({ status: 'ready' }), { updatedAt: Date.now() })
persistTickets()
emitTicket(ticket)
return `Released "${ticket.title}" to Ready.`
},
add_ticket_evidence: async (args, seat) => {
const tk = runtimeScope.findTicket(args)
if (!tk) return 'No matching ticket.'
Expand Down
Loading