From e357add5ec9f5f4ffbee1305e459bbc585270703 Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Mon, 9 Nov 2026 00:52:12 -0500 Subject: [PATCH] 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. --- .../federation/federation-control.ts | 9 +++++- .../federation-liveness-verdict.test.ts | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/main/runtime/rpc/methods/orchestration/federation/federation-control.ts b/src/main/runtime/rpc/methods/orchestration/federation/federation-control.ts index 4fbe9d527ae..aa3430ec5bf 100644 --- a/src/main/runtime/rpc/methods/orchestration/federation/federation-control.ts +++ b/src/main/runtime/rpc/methods/orchestration/federation/federation-control.ts @@ -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) diff --git a/src/main/runtime/rpc/methods/orchestration/federation/federation-liveness-verdict.test.ts b/src/main/runtime/rpc/methods/orchestration/federation/federation-liveness-verdict.test.ts index 65bd9c84da4..20f434ede46 100644 --- a/src/main/runtime/rpc/methods/orchestration/federation/federation-liveness-verdict.test.ts +++ b/src/main/runtime/rpc/methods/orchestration/federation/federation-liveness-verdict.test.ts @@ -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)