ARCH: продолжить metadata continuity для MCP discovery
This commit is contained in:
@@ -209,6 +209,39 @@ describe("assistant MCP discovery response candidate", () => {
|
||||
expect(candidate.reply_text).not.toContain("broad probe hit the row limit");
|
||||
});
|
||||
|
||||
it("localizes metadata evidence without leaking raw MCP wording", () => {
|
||||
const candidate = buildAssistantMcpDiscoveryResponseCandidate(
|
||||
entryPoint({
|
||||
bridge: {
|
||||
bridge_status: "answer_draft_ready",
|
||||
user_facing_response_allowed: true,
|
||||
business_fact_answer_allowed: true,
|
||||
requires_user_clarification: false,
|
||||
answer_draft: {
|
||||
answer_mode: "confirmed_with_bounded_inference",
|
||||
headline: "По данным 1С найдена подтвержденная metadata-поверхность.",
|
||||
confirmed_lines: [
|
||||
'Confirmed 1C metadata surface for scope "НДС": 7 rows and 3 matching objects',
|
||||
"Available metadata object sets: accumulation_register, document",
|
||||
"Available metadata fields/sections: amount, vat_rate, organization"
|
||||
],
|
||||
inference_lines: [],
|
||||
unknown_lines: ['No matching 1C metadata objects were confirmed for scope "Прибыль"'],
|
||||
limitation_lines: ["Detailed metadata fields were not returned by this MCP metadata probe"],
|
||||
next_step_line: null
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
expect(candidate.reply_text).toContain('В 1С подтверждена metadata-поверхность по области "НДС"');
|
||||
expect(candidate.reply_text).toContain("Доступные типы metadata-объектов");
|
||||
expect(candidate.reply_text).toContain("Доступные metadata-поля/секции");
|
||||
expect(candidate.reply_text).toContain('В 1С не подтверждены metadata-объекты по области "Прибыль"');
|
||||
expect(candidate.reply_text).toContain("Эта MCP-проверка metadata не вернула детальный список полей");
|
||||
expect(candidate.reply_text).not.toContain("Confirmed 1C metadata surface");
|
||||
});
|
||||
|
||||
it("returns not applicable when discovery was skipped for an exact supported route", () => {
|
||||
const candidate = buildAssistantMcpDiscoveryResponseCandidate({
|
||||
schema_version: "assistant_mcp_discovery_runtime_entry_point_v1",
|
||||
|
||||
@@ -203,6 +203,34 @@ describe("assistant MCP discovery turn input adapter", () => {
|
||||
expect(result.reason_codes).toContain("mcp_discovery_date_scope_from_followup_context");
|
||||
});
|
||||
|
||||
it("seeds short metadata follow-up from prior metadata discovery context", () => {
|
||||
const result = buildAssistantMcpDiscoveryTurnInput({
|
||||
userMessage: "а по регистрам?",
|
||||
followupContext: {
|
||||
previous_discovery_pilot_scope: "metadata_inspection_v1",
|
||||
previous_filters: {
|
||||
counterparty: "НДС"
|
||||
},
|
||||
previous_anchor_type: "counterparty",
|
||||
previous_anchor_value: "НДС"
|
||||
}
|
||||
});
|
||||
|
||||
expect(result.adapter_status).toBe("ready");
|
||||
expect(result.should_run_discovery).toBe(true);
|
||||
expect(result.source_signal).toBe("followup_context");
|
||||
expect(result.semantic_data_need).toBe("1C metadata evidence");
|
||||
expect(result.turn_meaning_ref).toMatchObject({
|
||||
asked_domain_family: "metadata",
|
||||
asked_action_family: "inspect_registers",
|
||||
explicit_entity_candidates: ["НДС"],
|
||||
unsupported_but_understood_family: "1c_metadata_surface",
|
||||
stale_replay_forbidden: true
|
||||
});
|
||||
expect(result.reason_codes).toContain("mcp_discovery_metadata_seeded_from_followup_context");
|
||||
expect(result.reason_codes).toContain("mcp_discovery_counterparty_from_followup_context");
|
||||
});
|
||||
|
||||
it("switches the checked year on a short payout follow-up while keeping prior discovery counterparty", () => {
|
||||
const result = buildAssistantMcpDiscoveryTurnInput({
|
||||
userMessage: "а теперь за 2021?",
|
||||
|
||||
@@ -386,6 +386,64 @@ describe("assistantMemoryRecapPolicy", () => {
|
||||
expect(reply).toContain("43 763 351,53 руб.");
|
||||
});
|
||||
|
||||
it("builds deterministic recap summary from grounded MCP metadata discovery context", () => {
|
||||
const sessionItems = [
|
||||
{
|
||||
role: "assistant",
|
||||
debug: {
|
||||
execution_lane: "living_chat",
|
||||
mcp_discovery_response_applied: true,
|
||||
assistant_mcp_discovery_entry_point_v1: {
|
||||
schema_version: "assistant_mcp_discovery_runtime_entry_point_v1",
|
||||
entry_status: "bridge_executed",
|
||||
turn_input: {
|
||||
turn_meaning_ref: {
|
||||
explicit_entity_candidates: ["НДС"]
|
||||
}
|
||||
},
|
||||
bridge: {
|
||||
bridge_status: "answer_draft_ready",
|
||||
business_fact_answer_allowed: true,
|
||||
answer_draft: {
|
||||
answer_mode: "confirmed_with_bounded_inference"
|
||||
},
|
||||
pilot: {
|
||||
pilot_scope: "metadata_inspection_v1",
|
||||
derived_metadata_surface: {
|
||||
metadata_scope: "НДС",
|
||||
matched_rows: 7,
|
||||
matched_objects: ["РегистрНакопления.НДСПокупок"],
|
||||
available_entity_sets: ["accumulation_register", "document"],
|
||||
available_fields: ["amount", "vat_rate", "organization"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
const context = resolveAssistantLivingChatMemoryContext({
|
||||
modeDecisionReason: "memory_recap_followup_detected",
|
||||
sessionItems
|
||||
});
|
||||
|
||||
const reply = buildAddressMemoryRecapReply({
|
||||
organization: null,
|
||||
addressDebug: context.lastMemoryAddressDebug,
|
||||
sessionItems,
|
||||
toNonEmptyString: (value: unknown) => {
|
||||
const text = String(value ?? "").trim();
|
||||
return text.length > 0 ? text : null;
|
||||
}
|
||||
});
|
||||
|
||||
expect(context.contextualMemoryRecapFollowup).toBe(true);
|
||||
expect(reply).toContain("НДС");
|
||||
expect(reply).toContain("metadata-поверхность 1С");
|
||||
expect(reply).toContain("amount");
|
||||
expect(reply).toContain("accumulation_register");
|
||||
});
|
||||
|
||||
it("builds deterministic broad business evaluation summary from recent grounded organization facts", () => {
|
||||
const sessionItems = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user