АРЧ АП11 - Выделить route policy adapter для архитектуры assistant runtime

This commit is contained in:
2026-04-15 23:10:46 +03:00
parent 1d95ed9b60
commit 9d5928125d
6 changed files with 207 additions and 16 deletions
@@ -63,6 +63,16 @@ describe("assistant address orchestration runtime adapter", () => {
expect(output.orchestrationDecision.runAddressLane).toBe(true);
expect(output.livingModeDecision.mode).toBe("deep_analysis");
expect(output.addressRuntimeMeta.toolGateDecision).toBe("run_address_lane");
expect(output.addressRuntimeMeta.routePolicyContract).toEqual(
expect.objectContaining({
schema_version: "assistant_route_policy_runtime_v1",
policy_owner: "assistantRoutePolicyRuntimeAdapter",
living_mode: "deep_analysis",
tool_gate_decision: "run_address_lane",
has_followup_context: true,
has_orchestration_contract: true
})
);
expect(output.addressRuntimeMeta.dialogContinuationContract).toEqual({
schema_version: "address_dialog_continuation_contract_v2"
});
@@ -0,0 +1,63 @@
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
});
});
});