NODEDC_1C/llm_normalizer/backend/tests/assistantRoutePolicyRuntime...

64 lines
2.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
});
});
});