HEL-898: preserve director three-fix rework verbatim on b0dcb17
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -164,22 +164,41 @@ describe('page guards against bad frames (adversarial, hand-built)', () => {
|
||||
expect(r.view().her).toMatchObject({ speech: 'speech_A', state: 'done', turnId: 'gate-turn-1' });
|
||||
});
|
||||
|
||||
it('DOCUMENTED GAP: after 64+ later closures a retired speech falls out of the window and a duplicate start with a fresh seq re-enters', async () => {
|
||||
it('a retired speech stays retired for the whole call, however many speeches closed after it (was: re-entered after 64)', async () => {
|
||||
const r = await connected(), room = r.transport.rooms[0];
|
||||
const frames = load('adversarial-gates');
|
||||
// Up to the end of the 66 squeeze speeches: speech_A is long closed (and by now pushed
|
||||
// out of the 64-entry window); nothing of it is on the page.
|
||||
// Up to the end of the 66 squeeze speeches: speech_A is long closed; nothing of it is on the page.
|
||||
const dupStart = frames.filter(f => f.kind === 'turn_start' && f.speech_id === 'speech_A').at(-1)!;
|
||||
play(room, frames.filter(f => f.seq < dupStart.seq));
|
||||
expect(r.view().her).toBeNull();
|
||||
expect(dupStart.seq).toBeGreaterThan(140);
|
||||
// The current worker never re-emits a speech id (each SDK speech gets a fresh id and
|
||||
// interim.begin runs once per stream), so this needs a misbehaving/second source —
|
||||
// but if it happens, the page DOES re-open the long-retired speech...
|
||||
// The current worker never re-emits a speech id (each SDK speech gets a fresh id and interim.begin runs once
|
||||
// per stream), so this needs a misbehaving/second source — a low-cost guard, not a fix of a worker fault.
|
||||
// Its fresh seqs pass the sequence gate; the retired speech id does not.
|
||||
const views = r.views.length;
|
||||
play(room, frames.filter(f => f.seq >= dupStart.seq));
|
||||
expect(r.view().her).toMatchObject({ speech: 'speech_A', state: 'done', turnId: 'gate-turn-1' });
|
||||
// ...whose replayed line stands as her words again.
|
||||
expect(r.view().her?.text).toBe('被挤出后的重放终稿');
|
||||
expect(r.view().her).toBeNull();
|
||||
expect(r.views.slice(views).some(v => v.her || v.phase !== 'listening')).toBe(false);
|
||||
// The seq gate is still strict on its own: nothing at or below the high-water mark gets in.
|
||||
const high = frames.at(-1)!.seq;
|
||||
room.on.subtitle({ v: 2, seq: high, kind: 'turn_start', role: 'assistant', text: '', speech_id: 'speech_new' });
|
||||
expect(r.view().her).toBeNull();
|
||||
room.on.subtitle({ v: 2, seq: high + 1, kind: 'turn_start', role: 'assistant', text: '', speech_id: 'speech_new' });
|
||||
expect(r.view().her).toEqual({ speech: 'speech_new', text: '', state: 'open' });
|
||||
});
|
||||
it('the retired set is per call: a new call starts clean, and an old call\'s retired ids never leak or block', async () => {
|
||||
const r = await connected(), room = r.transport.rooms[0];
|
||||
play(room, load('adversarial-gates'));
|
||||
await r.c.end();
|
||||
await r.c.start(); const next = r.transport.rooms[1]; next.on.agentJoined();
|
||||
// A new worker job: its own sequence from 1. A speech id the old call retired is not this call's business.
|
||||
next.on.subtitle({ v: 2, seq: 1, kind: 'turn_start', role: 'assistant', text: '', speech_id: 'speech_A' });
|
||||
next.on.subtitle({ v: 2, seq: 2, kind: 'assistant_interim', role: 'assistant', text: '新的一通。', speech_id: 'speech_A' });
|
||||
expect(r.view().her).toEqual({ speech: 'speech_A', text: '新的一通。', state: 'open' });
|
||||
// The old room, however late, moves nothing.
|
||||
room.on.subtitle({ v: 2, seq: 9999, kind: 'turn_cancel', role: 'assistant', text: '', speech_id: 'speech_A' });
|
||||
expect(r.view().her?.state).toBe('open');
|
||||
await r.c.end();
|
||||
});
|
||||
|
||||
it('your interim leaves her open line to the server\'s cancel; your final closes it at once', async () => {
|
||||
|
||||
Reference in New Issue
Block a user