fix(orchestration): bind legacy escalation dispatch

This commit is contained in:
Jinwoo-H
2026-08-17 00:58:34 -04:00
parent 4468dc1f1b
commit 6af880e4b8
2 changed files with 20 additions and 2 deletions
@@ -1,6 +1,7 @@
import { createHash } from 'node:crypto'
import { afterEach, describe, expect, it, vi } from 'vitest'
import type Database from '../../sqlite/sync-database'
import { applyEscalationToDispatch } from '../orchestration/coordinator-escalation-triage'
import {
cleanupLegacyCompatibilityDispatcherHarnesses,
COORDINATOR_HANDLE,
@@ -51,7 +52,10 @@ describe('legacy compatibility through RpcDispatcher', () => {
harness.dispatcher,
request(
'orchestration.send',
escalationParams(harness),
{
...escalationParams(harness),
payload: JSON.stringify({ taskId: harness.taskId })
},
evidence('worker', valid),
`${transport}-${valid}`
),
@@ -75,6 +79,15 @@ describe('legacy compatibility through RpcDispatcher', () => {
legacyCompatibility: { replayed: false }
}
})
const message = (response as { result: { message: { id: string; payload: string } } }).result
.message
expect(JSON.parse(message.payload)).toMatchObject({
taskId: harness.taskId,
dispatchId: harness.dispatchId
})
applyEscalationToDispatch(harness.db, harness.db.getMessageById(message.id)!, () => {})
expect(harness.db.getTask(harness.taskId)?.status).toBe('ready')
expect(harness.db.getDispatchContextById(harness.dispatchId)?.status).toBe('failed')
expect(counts(harness.db)).toEqual({
...before,
messages: before.messages + 1,
@@ -2,6 +2,7 @@ import type { RpcRequest } from './core'
import type { OrcaRuntimeService } from '../orca-runtime'
import type { MessageType } from '../orchestration/db'
import { OrchestrationError } from '../orchestration/orchestration-error'
import { bindCoordinatorMutationPayload } from '../orchestration/dispatch-message-binding'
import type { LegacyCompatibilityAuthority } from './orchestration-legacy-authority'
import {
inferLegacyWorkerOutcome,
@@ -89,7 +90,11 @@ export async function handleLegacyLifecycleSend(args: {
body: params.body,
type: params.type as MessageType,
priority: params.priority,
payload: params.payload
payload: bindCoordinatorMutationPayload(
params.type as MessageType,
params.payload,
dispatch.id
)
},
lifecycle:
params.type === 'heartbeat'