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)