ARCH: добавить entry point MCP discovery
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { runAssistantMcpDiscoveryRuntimeEntryPoint } from "../src/services/assistantMcpDiscoveryRuntimeEntryPoint";
|
||||
|
||||
function buildDeps(rows: Array<Record<string, unknown>>, error: string | null = null) {
|
||||
return {
|
||||
executeAddressMcpQuery: vi.fn(async () => ({
|
||||
fetched_rows: rows.length,
|
||||
matched_rows: error ? 0 : rows.length,
|
||||
raw_rows: rows,
|
||||
rows: error ? [] : rows,
|
||||
error
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
describe("assistant MCP discovery runtime entry point", () => {
|
||||
it("runs the bridge for discovery-eligible lifecycle turn context", async () => {
|
||||
const result = await runAssistantMcpDiscoveryRuntimeEntryPoint({
|
||||
userMessage: "Сколько лет мы работаем с Группа СВК?",
|
||||
predecomposeContract: {
|
||||
entities: { counterparty: "Группа СВК" },
|
||||
period: {}
|
||||
},
|
||||
deps: buildDeps([{ Период: "2020-01-15T00:00:00", Регистратор: "CP_CUSTOMER_ACTIVITY_FIRST" }])
|
||||
});
|
||||
|
||||
expect(result.entry_status).toBe("bridge_executed");
|
||||
expect(result.hot_runtime_wired).toBe(false);
|
||||
expect(result.discovery_attempted).toBe(true);
|
||||
expect(result.turn_input.semantic_data_need).toBe("counterparty lifecycle evidence");
|
||||
expect(result.bridge?.bridge_status).toBe("answer_draft_ready");
|
||||
expect(result.bridge?.answer_draft.answer_mode).toBe("confirmed_with_bounded_inference");
|
||||
expect(result.reason_codes).toContain("runtime_entry_point_bridge_executed");
|
||||
});
|
||||
|
||||
it("skips supported exact turns before any discovery execution", async () => {
|
||||
const deps = buildDeps([]);
|
||||
const result = await runAssistantMcpDiscoveryRuntimeEntryPoint({
|
||||
assistantTurnMeaning: {
|
||||
asked_domain_family: "counterparty",
|
||||
asked_action_family: "list_documents",
|
||||
explicit_intent_candidate: "list_documents_by_counterparty",
|
||||
explicit_entity_candidates: [{ value: "SVK" }]
|
||||
},
|
||||
deps
|
||||
});
|
||||
|
||||
expect(result.entry_status).toBe("skipped_not_applicable");
|
||||
expect(result.discovery_attempted).toBe(false);
|
||||
expect(result.bridge).toBeNull();
|
||||
expect(deps.executeAddressMcpQuery).not.toHaveBeenCalled();
|
||||
expect(result.reason_codes).toContain("runtime_entry_point_skipped_supported_exact_turn");
|
||||
});
|
||||
|
||||
it("passes unsupported-but-understood value turns into bridge with normalized entity scope", async () => {
|
||||
const result = await runAssistantMcpDiscoveryRuntimeEntryPoint({
|
||||
assistantTurnMeaning: {
|
||||
asked_domain_family: "counterparty",
|
||||
asked_action_family: "counterparty_value_or_turnover",
|
||||
unsupported_but_understood_family: "counterparty_value_or_turnover",
|
||||
explicit_entity_candidates: [{ value: "SVK" }]
|
||||
},
|
||||
predecomposeContract: {
|
||||
entities: { counterparty: "Группа СВК" },
|
||||
period: { period_from: "2020-01-01", period_to: "2020-12-31" }
|
||||
},
|
||||
deps: buildDeps([])
|
||||
});
|
||||
|
||||
expect(result.entry_status).toBe("bridge_executed");
|
||||
expect(result.turn_input.turn_meaning_ref?.explicit_entity_candidates).toEqual(["SVK", "Группа СВК"]);
|
||||
expect(result.bridge?.bridge_status).toBe("unsupported");
|
||||
expect(result.bridge?.hot_runtime_wired).toBe(false);
|
||||
expect(result.reason_codes).toContain("mcp_discovery_unsupported_but_understood_turn");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user