v4OnlineModelFallback.test.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { describe, expect, it } from "vitest";
  2. import { isOnlineModelFallbackAuthoritative } from "@/v4/composer/onlineModelFallback.js";
  3. const transition = {
  4. from: { provider: "provider-a", model: "model-a" },
  5. to: { provider: "provider-b", model: "model-b" },
  6. };
  7. describe("isOnlineModelFallbackAuthoritative", () => {
  8. it("accepts only the target session projection matching the fallback destination", () => {
  9. expect(
  10. isOnlineModelFallbackAuthoritative({
  11. targetSessionId: "session-b",
  12. current: {
  13. sessionId: "session-b",
  14. config: { provider: "provider-b", model: "model-b", thought: "high" },
  15. },
  16. transition,
  17. hasPendingExplicitIntent: false,
  18. }),
  19. ).toBe(true);
  20. });
  21. it("rejects stale sessions and explicit user intents", () => {
  22. const current = {
  23. sessionId: "session-a",
  24. config: { provider: "provider-b", model: "model-b", thought: "high" },
  25. };
  26. expect(
  27. isOnlineModelFallbackAuthoritative({
  28. targetSessionId: "session-b",
  29. current,
  30. transition,
  31. hasPendingExplicitIntent: false,
  32. }),
  33. ).toBe(false);
  34. expect(
  35. isOnlineModelFallbackAuthoritative({
  36. targetSessionId: "session-a",
  37. current,
  38. transition,
  39. hasPendingExplicitIntent: true,
  40. }),
  41. ).toBe(false);
  42. });
  43. });