feat(gateway): add interrupt preemption telemetry and requester notice
This commit is contained in:
@@ -49,6 +49,7 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
registerBuiltinCommands(commandRegistry);
|
||||
const mockAuditLogger = {
|
||||
userAction: vi.fn(),
|
||||
queuePreempt: vi.fn(),
|
||||
};
|
||||
|
||||
const handlers = createAgentHandlers({
|
||||
@@ -364,6 +365,16 @@ describe('createAgentHandlers command fast-path', () => {
|
||||
});
|
||||
|
||||
describe('createAgentHandlers queue policy resolution', () => {
|
||||
const mockAuditLogger = {
|
||||
userAction: vi.fn(),
|
||||
queuePreempt: vi.fn(),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
initAuditLogger(mockAuditLogger as any);
|
||||
});
|
||||
|
||||
it('passes resolved per-request queue policy into lane enqueue', async () => {
|
||||
const mockAgent = {
|
||||
process: vi.fn(async () => 'ok'),
|
||||
@@ -554,6 +565,15 @@ describe('createAgentHandlers queue policy resolution', () => {
|
||||
|
||||
expect(sessionBridge.cancelSession).toHaveBeenCalledWith('ws:s1');
|
||||
expect(sessionBridge.cancel).not.toHaveBeenCalled();
|
||||
expect((sent[0] as GatewayEvent).event).toBe('done');
|
||||
expect(mockAuditLogger.queuePreempt).toHaveBeenCalledWith(expect.objectContaining({
|
||||
session_id: 'ws:s1',
|
||||
lane_id: 'ws:s1',
|
||||
request_id: '7',
|
||||
mode: 'interrupt',
|
||||
cancelled_active_run: true,
|
||||
}));
|
||||
expect((sent[0] as GatewayEvent).event).toBe('content');
|
||||
expect(((sent[0] as GatewayEvent).data as { text: string }).text).toContain('Interrupt mode');
|
||||
expect((sent[1] as GatewayEvent).event).toBe('done');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user