mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(orchestration): name the re-pair when a closed link refuses a send
This commit is contained in:
@@ -407,6 +407,22 @@ describe('what the coordinating Orca owes a paired server', () => {
|
||||
expect(getRemoteRunLink(db, link.conversation_id)?.state).toBe('closed')
|
||||
expect(owed().stop_owed).toBe(0)
|
||||
})
|
||||
it('names the re-pair, not a reset, when another path closed the link while a send waited', async () => {
|
||||
startedOnB()
|
||||
oweRemoteDispatchStop(db, 'ctx_b1', 'intent_1')
|
||||
let release!: () => void
|
||||
beforeSend = () => new Promise<void>((resolve) => (release = resolve))
|
||||
const pending = sendOwedRemoteStop(runtime, owed())
|
||||
await vi.waitFor(() => expect(release).toBeDefined())
|
||||
server = { ...server, peerFingerprint: 'host_b_new' }
|
||||
openRemoteRunLink(db, run.id, server)
|
||||
release()
|
||||
await expect(pending).rejects.toMatchObject({
|
||||
code: 'remote_link_closed',
|
||||
message: `The pairing with devB was re-made, so it no longer runs Run ${run.id}'s workers. No effects were applied.`
|
||||
})
|
||||
expect(sent).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('S4 orphan lookup', () => {
|
||||
|
||||
@@ -53,11 +53,14 @@ export async function callRemoteOwnedServer(
|
||||
)
|
||||
}
|
||||
if (!current || !call.whileLink.includes(current.state)) {
|
||||
throw new OrchestrationError(
|
||||
'remote_link_closed',
|
||||
`Run ${link.run_id} was reset on this Orca, so nothing more goes to ${server.name} for it. No effects were applied.`,
|
||||
{ effectsApplied: false }
|
||||
)
|
||||
// Only a re-made pairing closes a link; a reset leaves it owing a cancel.
|
||||
const why =
|
||||
current?.state === 'closed'
|
||||
? `The pairing with ${server.name} was re-made, so it no longer runs Run ${link.run_id}'s workers.`
|
||||
: `Run ${link.run_id} was reset on this Orca, so nothing more goes to ${server.name} for it.`
|
||||
throw new OrchestrationError('remote_link_closed', `${why} No effects were applied.`, {
|
||||
effectsApplied: false
|
||||
})
|
||||
}
|
||||
}
|
||||
requireLink()
|
||||
|
||||
Reference in New Issue
Block a user