ARCH: сохранять metadata ambiguity через clarification follow-up

This commit is contained in:
2026-04-22 10:05:03 +03:00
parent 40cf71d118
commit 007369a78a
9 changed files with 179 additions and 39 deletions
@@ -595,6 +595,7 @@ describe("assistant MCP discovery turn input adapter", () => {
asked_domain_family: "metadata",
asked_action_family: "resolve_next_lane",
explicit_entity_candidates: ["SVK"],
metadata_ambiguity_entity_sets: ["Документ", "РегистрНакопления"],
explicit_date_scope: "2020",
unsupported_but_understood_family: "metadata_lane_choice_clarification",
stale_replay_forbidden: true
@@ -1227,6 +1227,61 @@ describe("assistantTransitionPolicy", () => {
"РегистрНакопления"
]);
});
it("preserves metadata ambiguity choice sets through a clarification assistant turn", () => {
const policy = buildPolicy({
findLastAddressAssistantItem: () => ({
text: "уточните: по документам или по движениям?",
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: {
asked_domain_family: "metadata",
asked_action_family: "resolve_next_lane",
explicit_entity_candidates: ["SVK"],
metadata_ambiguity_entity_sets: ["Документ", "РегистрНакопления"],
explicit_date_scope: "2020",
unsupported_but_understood_family: "metadata_lane_choice_clarification"
}
},
bridge: {
bridge_status: "needs_clarification",
business_fact_answer_allowed: false,
pilot: {
pilot_scope: "metadata_inspection_v1"
},
answer_draft: {
answer_mode: "needs_clarification"
}
}
}
}
}),
hasAddressFollowupContextSignal: () => true,
hasReferentialPointer: () => false,
resolveAddressIntent: () => ({ intent: "unknown" }),
resolveAddressIntentFamily: () => null,
resolveAssistantTurnMeaning: () => null
});
const carryover = policy.resolveAddressFollowupCarryoverContext(
"по движениям",
[{ kind: "assistant", text: "уточните: по документам или по движениям?" }],
"по движениям",
{ predecomposeContract: { intent: "unknown" } },
null
);
expect(carryover?.followupContext?.previous_discovery_pilot_scope).toBe("metadata_inspection_v1");
expect(carryover?.followupContext?.previous_discovery_metadata_ambiguity_detected).toBe(true);
expect(carryover?.followupContext?.previous_discovery_metadata_ambiguity_entity_sets).toEqual([
"Документ",
"РегистрНакопления"
]);
});
it("switches to VAT tax-period intent while preserving carried period filters", () => {
const policy = buildPolicy({
findLastAddressAssistantItem: () => ({