Implement robust orchestration primitives and connected-server workers (#9925)

This commit is contained in:
OrcaWin
2026-07-27 12:31:37 -07:00
committed by GitHub
parent 8b154d686c
commit cd05f2ff93
127 changed files with 23196 additions and 887 deletions
+32 -1
View File
@@ -241,6 +241,35 @@ describe('sendRemoteRuntimeRequest', () => {
})
})
it('sends orchestration authentication fields in the admitted encrypted request', async () => {
let receivedRequest: Record<string, unknown> | null = null
const server = await createOneShotServer({
onRequest: (request) => {
receivedRequest = request
}
})
await sendRemoteRuntimeRequest(
server.pairing,
'orchestration.federationControl',
{ dispatch: 'ctx_1' },
1000,
{
orchestrationCapability: 'capability',
orchestrationContractVersion: 1,
orchestrationRequestId: 'mutation_1'
}
)
expect(receivedRequest).toMatchObject({
method: 'orchestration.federationControl',
params: { dispatch: 'ctx_1' },
orchestrationCapability: 'capability',
orchestrationContractVersion: 1,
orchestrationRequestId: 'mutation_1'
})
})
it('detaches one-shot socket listeners after a successful response', async () => {
const offSpy = vi.spyOn(WebSocketClient.prototype, 'off')
try {
@@ -387,6 +416,7 @@ async function createClosingServer(
async function createOneShotServer(
options: {
response?: (requestId: string) => unknown
onRequest?: (request: Record<string, unknown>) => void
} = {}
): Promise<{ pairing: PairingOffer }> {
const serverKeyPair = generateKeyPair()
@@ -422,7 +452,8 @@ async function createOneShotServer(
return
}
const request = JSON.parse(plaintext) as { id: string }
const request = JSON.parse(plaintext) as { id: string } & Record<string, unknown>
options.onRequest?.(request)
const key = sharedKey
const keepalive = setInterval(() => {
sendEncrypted(ws, key, { _keepalive: true })