mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
* docs: design SSH relay PTY backpressure * fix(ssh): bound relay frame decoding * fix(relay): bound PTY output publication * fix(ssh): bound PTY model admission * fix(ssh): settle closed model admissions * feat(ssh): negotiate bounded PTY consumer sessions * fix(ssh): fence exit on renderer settlement * feat(ssh): track PTY source credit end to end * fix(ssh): recover bounded PTY output across reconnect * feat(ssh): complete relay PTY output backpressure * fix(ssh): close final PTY source credit races * docs(ssh): record final backpressure validation * feat(ssh): complete relay PTY source-credit lifecycle * test(ssh): complete provider notification fixture * fix(ssh): preserve terminal source credit across rotation * fix(ssh): fail closed on recovery cancellation * fix(ssh): prioritize mux control writes after drain * fix(ssh): retire canceled relay restore deliveries * fix(ssh): order exit cancellation cleanup * fix(ssh): gate provisional source activation * test(ssh): register mux drain-priority coverage * fix(ssh): type stale owner recovery mismatches * fix(ssh): close projection replacement races * fix(relay): contain streaming edge failures * fix(ssh): secure relay endpoint credentials * docs(ssh): reconcile final backpressure lifecycle * fix(ssh): bound main IPC output lifecycle * fix(ssh): close recovery ownership gaps * docs(ssh): record exact artifact validation * fix(ssh): reject reclaimed snapshot replacements * fix(ssh): fence model admission across reconnect * fix(ssh): contain migration failure per PTY * docs(ssh): record final exact-head validation * test(ssh): align deploy fixtures with credential publication * feat(ssh): add per-target bounded output setting * fix(ssh): close source recovery review gaps * fix(ssh): latch source credit environment override * feat(ssh): make PTY source credit the default * docs(ssh): record always-on relay validation * docs(ssh): bind validation to current main * test(ssh): grant source credit in IPC fixture * test(ssh): grant source credit in fake relay --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
87 lines
2.5 KiB
TypeScript
87 lines
2.5 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import type { PtySourceCreditAckBatch } from '../../shared/pty-source-credit-contract'
|
|
import { SshPtyOutputIntake } from './ssh-pty-output-intake'
|
|
import {
|
|
installSshPtySourceAckPublisher,
|
|
publishSshPtySourceAck
|
|
} from './ssh-pty-output-intake-registry'
|
|
|
|
afterEach(() => vi.useRealTimers())
|
|
|
|
describe('SSH PTY intake to relay ACK contract', () => {
|
|
it('publishes one cumulative relay-ID ACK only after model and desktop settlement', async () => {
|
|
vi.useFakeTimers()
|
|
const batches: PtySourceCreditAckBatch[] = []
|
|
const cleanup = installSshPtySourceAckPublisher(7, (batch, onSettled) => {
|
|
batches.push(batch)
|
|
onSettled({ ok: true })
|
|
})
|
|
let sequence = 0
|
|
const intake = new SshPtyOutputIntake({
|
|
getModelSequence: () => sequence,
|
|
acceptModel: (event) => {
|
|
sequence += event.rawLength
|
|
return { sequence, completion: Promise.resolve() }
|
|
},
|
|
project: () => {},
|
|
prepareExit: () => {},
|
|
finalizeExit: () => {},
|
|
publishSourceAck: publishSshPtySourceAck
|
|
})
|
|
|
|
try {
|
|
const receipt = await intake.acceptData({
|
|
id: 'ssh:target@@relay-pty-1',
|
|
data: 'data',
|
|
providerGeneration: 7,
|
|
ptyIncarnation: 'incarnation-1',
|
|
rawLength: 4,
|
|
transformed: false,
|
|
source: {
|
|
relayPtyId: 'relay-pty-1',
|
|
spanId: 'token-1:0:4',
|
|
clientGeneration: 2,
|
|
ownerGeneration: 3,
|
|
deliveryToken: 'token-1',
|
|
sourceStartSu: 0,
|
|
sourceEndSu: 4
|
|
}
|
|
})
|
|
await vi.advanceTimersByTimeAsync(8)
|
|
expect(batches).toHaveLength(0)
|
|
|
|
const projectionId = receipt.projection.identity.projectionSemanticsId
|
|
intake.publishProjectionPrefix([projectionId], 4, 4)
|
|
intake.settleProjectionPrefix('ssh:target@@relay-pty-1', 4)
|
|
await vi.advanceTimersByTimeAsync(8)
|
|
|
|
expect(batches).toEqual([
|
|
{
|
|
acknowledgements: [
|
|
{
|
|
id: 'relay-pty-1',
|
|
clientGeneration: 2,
|
|
ownerGeneration: 3,
|
|
deliveryToken: 'token-1',
|
|
creditedEndSu: 4
|
|
}
|
|
]
|
|
}
|
|
])
|
|
await intake.acceptExit({
|
|
id: 'ssh:target@@relay-pty-1',
|
|
code: 0,
|
|
providerGeneration: 7,
|
|
ptyIncarnation: 'incarnation-1'
|
|
})
|
|
expect(intake.getDebugSnapshot().source).toEqual({
|
|
openedTokens: 0,
|
|
ptyIdentities: 0
|
|
})
|
|
} finally {
|
|
intake.dispose()
|
|
cleanup()
|
|
}
|
|
})
|
|
})
|