mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 08:03:37 +00:00
fix(orchestration): neutralize rejected control messages
This commit is contained in:
@@ -3737,7 +3737,10 @@ export class OrchestrationDb {
|
||||
reason: string
|
||||
): MessageRow | undefined {
|
||||
const message = this.getMessageById(messageId)
|
||||
if (!message || (message.type !== 'worker_done' && message.type !== 'heartbeat')) {
|
||||
if (
|
||||
!message ||
|
||||
!['worker_done', 'heartbeat', 'escalation', 'decision_gate'].includes(message.type)
|
||||
) {
|
||||
return message
|
||||
}
|
||||
|
||||
@@ -3748,7 +3751,8 @@ export class OrchestrationDb {
|
||||
this.db
|
||||
.prepare(
|
||||
`UPDATE messages
|
||||
SET priority = 'high', subject = ?, body = ?, payload = ?
|
||||
SET type = CASE WHEN type IN ('escalation', 'decision_gate') THEN 'status' ELSE type END,
|
||||
priority = 'high', subject = ?, body = ?, payload = ?
|
||||
WHERE id = ?`
|
||||
)
|
||||
.run(`Rejected ${message.type}: ${message.subject}`, body, payload, messageId)
|
||||
|
||||
@@ -279,7 +279,10 @@ describe('orchestration RPC methods', () => {
|
||||
taskId: task.id,
|
||||
...(type === 'decision_gate' ? { question: 'Proceed?' } : {})
|
||||
})
|
||||
})) as { lifecycle: { action: string; code: string } }
|
||||
})) as {
|
||||
lifecycle: { action: string; code: string }
|
||||
message: { type: string }
|
||||
}
|
||||
|
||||
expect(rejected.lifecycle).toMatchObject({
|
||||
action: 'rejected',
|
||||
@@ -288,6 +291,21 @@ describe('orchestration RPC methods', () => {
|
||||
expect(db.getTask(task.id)?.status).toBe('dispatched')
|
||||
expect(db.getDispatchContextById(dispatch.id)?.status).toBe('dispatched')
|
||||
expect(db.listGates({ taskId: task.id })).toHaveLength(0)
|
||||
expect(rejected.message.type).toBe('status')
|
||||
|
||||
vi.mocked(runtime.getTerminalProcessIncarnation).mockReturnValue(
|
||||
'runtime_test:term_worker:1'
|
||||
)
|
||||
const accepted = (await call('orchestration.send', {
|
||||
from: 'term_worker',
|
||||
subject: `${type} by assignee`,
|
||||
type,
|
||||
payload: JSON.stringify({
|
||||
taskId: task.id,
|
||||
...(type === 'decision_gate' ? { question: 'Proceed?' } : {})
|
||||
})
|
||||
})) as { message: { type: string } }
|
||||
expect(accepted.message.type).toBe(type)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user