import { describe, expect, it, vi } from "vitest"; import { runAssistantRoutePolicyRuntime } from "../src/services/assistantRoutePolicyRuntimeAdapter"; describe("assistant route policy runtime adapter", () => { it("delegates to the current orchestration decision function and emits a route policy contract", () => { const resolveAssistantOrchestrationDecision = vi.fn(() => ({ runAddressLane: true, livingMode: "address_data", livingReason: "address_lane_triggered", toolGateDecision: "run_address_lane", toolGateReason: "followup_context_detected", orchestrationContract: { schema_version: "assistant_orchestration_contract_v1" } })); const followupContext = { previous_intent: "inventory_on_hand_as_of_date" }; const output = runAssistantRoutePolicyRuntime({ rawUserMessage: "кто это поставил нам", effectiveAddressUserMessage: "кто это поставил нам", followupContext, llmPreDecomposeMeta: { attempted: true }, sessionItems: [{ role: "assistant" }], sessionOrganizationScope: { selectedOrganization: "ООО Ромашка" }, useMock: false, resolveAssistantOrchestrationDecision }); expect(resolveAssistantOrchestrationDecision).toHaveBeenCalledWith({ rawUserMessage: "кто это поставил нам", effectiveAddressUserMessage: "кто это поставил нам", followupContext, llmPreDecomposeMeta: { attempted: true }, sessionItems: [{ role: "assistant" }], sessionOrganizationScope: { selectedOrganization: "ООО Ромашка" }, useMock: false }); expect(output.orchestrationDecision.runAddressLane).toBe(true); expect(output.livingModeDecision).toEqual({ mode: "address_data", reason: "address_lane_triggered" }); expect(output.routePolicyContract).toEqual({ schema_version: "assistant_route_policy_runtime_v1", policy_owner: "assistantRoutePolicyRuntimeAdapter", decision_source: "resolveAssistantOrchestrationDecision", living_mode: "address_data", living_reason: "address_lane_triggered", tool_gate_decision: "run_address_lane", tool_gate_reason: "followup_context_detected", has_followup_context: true, has_orchestration_contract: true }); }); });