fix(orchestration): keep a paired server's worker list when one Dispatch is from an earlier pairing

The server's fleet snapshot refused the whole batch when one requested
Dispatch was not this home's (for example, one started before the home
re-paired), so the home showed every worker on that server as
host_unavailable. Now only that Dispatch reads as unverifiable.
This commit is contained in:
Jinwoo-H
2026-11-09 00:52:12 -05:00
parent 345ffb56d2
commit e357add5ec
2 changed files with 37 additions and 1 deletions
@@ -28,7 +28,14 @@ export const ORCHESTRATION_FEDERATION_CONTROL_METHODS = [
params: FederationFleetSnapshotParams,
handler: async (params, { runtime, authenticatedCallerFingerprint }) => {
const items = await mapWithConcurrency(params.dispatchIds, 16, async (dispatchId) => {
requireHomeAttachment(runtime, dispatchId, authenticatedCallerFingerprint)
const attachment = runtime.getOrchestrationDb().getRemoteDispatchAttachment(dispatchId)
// A Dispatch this home no longer holds here, such as one from an earlier pairing, must not hide the rest.
if (!attachment || attachment.home_peer_fingerprint !== authenticatedCallerFingerprint) {
return {
dispatchId,
observation: { status: 'unverifiable' as const, exactWorker: false }
}
}
const observation = await observeRemoteAttachmentLiveness(runtime, dispatchId)
const db = runtime.getOrchestrationDb()
const autoReleaseAt = db.getLiveWorkerTerminalAutoReleaseAt(dispatchId)
@@ -234,6 +234,35 @@ describe('federation host liveness verdicts', () => {
})
})
it('still reports its own workers when one requested Dispatch belongs to an earlier pairing', async () => {
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: observation reads only these terminal fields.
vi.spyOn(runtime, 'showTerminal').mockResolvedValue({
handle: HANDLE,
worktreeId: 'repo::remote-worktree',
connected: true,
status: 'running'
} as never)
vi.spyOn(runtime, 'getTerminalLivenessVerdict').mockReturnValue(null)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: observation reads only the host scope.
vi.spyOn(runtime, 'getOrchestrationDispatchAuthority').mockReturnValue({
hostScope: { kind: 'local', hostId: 'local' }
} as never)
await expect(
call('orchestration.federationFleetSnapshot', {
dispatchIds: ['ctx_from_an_earlier_pairing', DISPATCH_ID]
})
).resolves.toMatchObject({
items: [
{
dispatchId: 'ctx_from_an_earlier_pairing',
observation: { status: 'unverifiable', exactWorker: false }
},
{ dispatchId: DISPATCH_ID, observation: { status: 'live', exactWorker: true } }
]
})
})
it('keeps a disconnected verdict-less pane unverifiable rather than exited', async () => {
vi.spyOn(runtime, 'getTerminalLivenessVerdict').mockReturnValue(null)
vi.spyOn(runtime, 'getOrchestrationDispatchAuthority').mockReturnValue(null)