diff --git a/extensions/voice-call/src/manager/events.test.ts b/extensions/voice-call/src/manager/events.test.ts index d4af5da72c0e..070f74be0448 100644 --- a/extensions/voice-call/src/manager/events.test.ts +++ b/extensions/voice-call/src/manager/events.test.ts @@ -15,8 +15,9 @@ import type { AnswerCallInput, HangupCallInput, NormalizedEvent } from "../types import type { CallManagerContext } from "./context.js"; import { processEvent } from "./events.js"; import { speakInitialMessage } from "./outbound.js"; -import { MAX_CALL_REPLAY_KEYS, MAX_MANAGER_REPLAY_KEYS } from "./replay-keys.js"; +import { MAX_CALL_REPLAY_KEYS } from "./replay-keys.js"; +const MANAGER_REPLAY_KEY_LIMIT = 10_000; const logSpy = vi.hoisted(() => { const logEntries: string[] = []; return { @@ -775,7 +776,7 @@ describe("processEvent (functional)", () => { it("bounds committed replay keys in both manager and persisted call owners", () => { const now = Date.now(); const managerKeys = Array.from( - { length: MAX_MANAGER_REPLAY_KEYS }, + { length: MANAGER_REPLAY_KEY_LIMIT }, (_, index) => `manager-${index}`, ); const callKeys = Array.from({ length: MAX_CALL_REPLAY_KEYS }, (_, index) => `call-${index}`); @@ -806,7 +807,7 @@ describe("processEvent (functional)", () => { const call = ctx.activeCalls.get("call-bounded"); expect(result).toEqual({ kind: "processed" }); - expect(ctx.processedEventIds.size).toBe(MAX_MANAGER_REPLAY_KEYS); + expect(ctx.processedEventIds.size).toBe(MANAGER_REPLAY_KEY_LIMIT); expect(ctx.processedEventIds.has("manager-0")).toBe(false); expect(ctx.processedEventIds.has("evt-bounded-new")).toBe(true); expect(call?.processedEventIds).toHaveLength(MAX_CALL_REPLAY_KEYS); @@ -827,7 +828,7 @@ describe("processEvent (functional)", () => { it("bounds rejected provider calls while retaining hangup-once behavior", () => { const rejectedProviderCallIds = new Map( Array.from( - { length: MAX_MANAGER_REPLAY_KEYS }, + { length: MANAGER_REPLAY_KEY_LIMIT }, (_, index) => [`provider-${index}`, Symbol(`provider-${index}`)] as const, ), ); @@ -851,7 +852,7 @@ describe("processEvent (functional)", () => { }), ); - expect(ctx.rejectedProviderCallIds.size).toBe(MAX_MANAGER_REPLAY_KEYS); + expect(ctx.rejectedProviderCallIds.size).toBe(MANAGER_REPLAY_KEY_LIMIT); expect(ctx.rejectedProviderCallIds.has("provider-0")).toBe(false); expect(ctx.rejectedProviderCallIds.has("provider-new")).toBe(true); expect(hangupCalls).toHaveLength(1); diff --git a/extensions/voice-call/src/manager/replay-keys.ts b/extensions/voice-call/src/manager/replay-keys.ts index f820beab1348..93ad5a9ce87f 100644 --- a/extensions/voice-call/src/manager/replay-keys.ts +++ b/extensions/voice-call/src/manager/replay-keys.ts @@ -1,7 +1,7 @@ // Voice Call manager helpers own bounded webhook replay identity. /** Match the existing voice-call webhook replay-cache cardinality. */ -export const MAX_MANAGER_REPLAY_KEYS = 10_000; +const MAX_MANAGER_REPLAY_KEYS = 10_000; /** Keep typical provider replay IDs near one raw persisted-record chunk. */ export const MAX_CALL_REPLAY_KEYS = 500; diff --git a/extensions/voice-call/src/manager/store.test.ts b/extensions/voice-call/src/manager/store.test.ts index a1676d08e1cb..203fe0c87d7b 100644 --- a/extensions/voice-call/src/manager/store.test.ts +++ b/extensions/voice-call/src/manager/store.test.ts @@ -14,7 +14,7 @@ import { } from "../manager.test-harness.js"; import { setVoiceCallStateRuntime } from "../runtime-state.js"; import { CallRecordSchema } from "../types.js"; -import { MAX_CALL_REPLAY_KEYS, MAX_MANAGER_REPLAY_KEYS } from "./replay-keys.js"; +import { MAX_CALL_REPLAY_KEYS } from "./replay-keys.js"; import { findCallMatchesInStore, getCallHistoryFromStore, @@ -22,6 +22,8 @@ import { persistCallRecord, } from "./store.js"; +const MANAGER_REPLAY_KEY_LIMIT = 10_000; + function installStateRuntime(): void { setVoiceCallStateRuntime({ state: { @@ -191,7 +193,7 @@ describe("voice-call call record store", () => { ); for ( let callIndex = 0; - callIndex < MAX_MANAGER_REPLAY_KEYS / MAX_CALL_REPLAY_KEYS; + callIndex < MANAGER_REPLAY_KEY_LIMIT / MAX_CALL_REPLAY_KEYS; callIndex++ ) { persistCallRecord( @@ -221,7 +223,7 @@ describe("voice-call call record store", () => { const restored = loadActiveCallsFromStore(storePath); - expect(restored.processedEventIds.size).toBe(MAX_MANAGER_REPLAY_KEYS); + expect(restored.processedEventIds.size).toBe(MANAGER_REPLAY_KEY_LIMIT); expect(restored.processedEventIds.has("evt-latest-old")).toBe(true); expect(restored.processedEventIds.has("evt-latest-new")).toBe(true); expect(restored.processedEventIds.has("evt-fill-0-0")).toBe(false);