Post-F: укрепить VAT, даты остатков и SVK follow-up
This commit is contained in:
@@ -23,4 +23,25 @@ describe("address filter extractor regressions", () => {
|
||||
expect(extracted.extracted_filters.counterparty).toBe("\u0441\u0432\u043a");
|
||||
expect(extracted.warnings).toContain("counterparty_anchor_derived_from_revenue_phrase");
|
||||
});
|
||||
|
||||
it("drops document and movement service words as low-quality counterparty anchors", () => {
|
||||
const documentNoise = extractAddressFilters(
|
||||
"документы по контрагенту документам",
|
||||
"list_documents_by_counterparty"
|
||||
);
|
||||
const movementNoise = extractAddressFilters(
|
||||
"Проверить движение по счетам или документам",
|
||||
"list_documents_by_counterparty"
|
||||
);
|
||||
const explicitCheckNoise = extractAddressFilters(
|
||||
"документы по контрагенту Проверить",
|
||||
"list_documents_by_counterparty"
|
||||
);
|
||||
|
||||
expect(documentNoise.extracted_filters.counterparty).toBeUndefined();
|
||||
expect(documentNoise.warnings).toContain("counterparty_anchor_dropped_low_quality");
|
||||
expect(movementNoise.extracted_filters.counterparty).toBeUndefined();
|
||||
expect(explicitCheckNoise.extracted_filters.counterparty).toBeUndefined();
|
||||
expect(explicitCheckNoise.warnings).toContain("counterparty_anchor_dropped_low_quality");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -144,6 +144,31 @@ describe("address follow-up temporal regressions", () => {
|
||||
expect(result?.baseReasons).toContain("period_to_from_followup_context");
|
||||
});
|
||||
|
||||
it("does not inherit stale inventory as-of date over an explicit fresh snapshot date", () => {
|
||||
const result = runAddressDecomposeStage(
|
||||
"Покажи складской срез Альтернативы Плюс на 2026-04-16: что есть в остатках, какие самые заметные позиции, и что это говорит о бизнесе.",
|
||||
{
|
||||
previous_intent: "inventory_on_hand_as_of_date",
|
||||
target_intent: "inventory_on_hand_as_of_date",
|
||||
previous_filters: {
|
||||
organization: "ООО Альтернатива Плюс",
|
||||
period_from: "2020-01-01",
|
||||
period_to: "2020-12-31",
|
||||
as_of_date: "2020-12-31"
|
||||
},
|
||||
previous_anchor_type: "organization",
|
||||
previous_anchor_value: "ООО Альтернатива Плюс"
|
||||
}
|
||||
);
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result?.intent.intent).toBe("inventory_on_hand_as_of_date");
|
||||
expect(result?.filters.extracted_filters.as_of_date).toBe("2026-04-16");
|
||||
expect(result?.filters.extracted_filters.period_from).toBe("2026-04-01");
|
||||
expect(result?.filters.extracted_filters.period_to).toBe("2026-04-30");
|
||||
expect(result?.baseReasons).not.toContain("as_of_date_from_open_items_followup_context");
|
||||
});
|
||||
|
||||
it("retargets inventory purchase-date VAT bridge into confirmed VAT period with inherited purchase month", () => {
|
||||
const result = runAddressDecomposeStage("ндс можешь прикинуть на дату покупки рабочей станции?", {
|
||||
previous_intent: "inventory_purchase_provenance_for_item",
|
||||
@@ -240,4 +265,30 @@ describe("address follow-up temporal regressions", () => {
|
||||
expect(result?.filters.extracted_filters.period_from).toBeUndefined();
|
||||
expect(result?.filters.extracted_filters.period_to).toBeUndefined();
|
||||
});
|
||||
|
||||
it("replaces document and movement service-word anchors from counterparty follow-up context", () => {
|
||||
const followupContext = {
|
||||
previous_intent: "customer_revenue_and_payments" as const,
|
||||
target_intent: "list_documents_by_counterparty" as const,
|
||||
previous_filters: {
|
||||
organization: "ООО Альтернатива Плюс",
|
||||
counterparty: "Группа СВК",
|
||||
period_from: "2020-01-01",
|
||||
period_to: "2020-12-31"
|
||||
},
|
||||
previous_anchor_type: "counterparty" as const,
|
||||
previous_anchor_value: "Группа СВК",
|
||||
resolved_counterparty_from_display: true
|
||||
};
|
||||
|
||||
const documents = runAddressDecomposeStage("документы по контрагенту документам", followupContext);
|
||||
const movements = runAddressDecomposeStage("Проверить движение по счетам или документам", followupContext);
|
||||
|
||||
expect(documents?.intent.intent).toBe("list_documents_by_counterparty");
|
||||
expect(documents?.filters.extracted_filters.counterparty).toBe("Группа СВК");
|
||||
expect(documents?.baseReasons).toContain("counterparty_from_followup_context");
|
||||
expect(movements?.intent.intent).toBe("list_documents_by_counterparty");
|
||||
expect(movements?.filters.extracted_filters.counterparty).toBe("Группа СВК");
|
||||
expect(movements?.baseReasons).toContain("counterparty_from_followup_context");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -28,6 +28,15 @@ describe("vat payable confirmed as-of route", () => {
|
||||
expect(result.reasons).toContain("vat_liability_colloquial_bridge_signal_detected");
|
||||
});
|
||||
|
||||
it("keeps VAT period-inspection wording out of inventory snapshot arbitration", () => {
|
||||
const result = resolveAddressIntent(
|
||||
"Что с НДС за 2020 год по Альтернативе Плюс: какая позиция видна, на чем она основана и чего не хватает для налогового вывода?"
|
||||
);
|
||||
|
||||
expect(result.intent).toBe("vat_liability_confirmed_for_tax_period");
|
||||
expect(result.reasons).toContain("vat_period_inspection_bridge_signal_detected");
|
||||
});
|
||||
|
||||
it("keeps VAT forecast intent when explicit forecast wording is used", () => {
|
||||
const result = resolveAddressIntent("мож прикинусь плиз скока ндс надо заплатить на 15 марта 2020 года");
|
||||
expect(result.intent).toBe("vat_payable_forecast");
|
||||
|
||||
@@ -133,6 +133,36 @@ describe("assistant MCP discovery turn input adapter", () => {
|
||||
expect(result.reason_codes).not.toContain("mcp_discovery_payout_signal_detected");
|
||||
});
|
||||
|
||||
it("extracts compact scoped counterparty from net follow-up wording when LLM entities are empty", () => {
|
||||
const orgName = "ООО Альтернатива Плюс";
|
||||
const result = buildAssistantMcpDiscoveryTurnInput({
|
||||
userMessage: "А какое нетто по СВК: сколько получили минус сколько заплатили?",
|
||||
followupContext: {
|
||||
previous_discovery_pilot_scope: "counterparty_value_flow_query_movements_v1",
|
||||
previous_filters: {
|
||||
organization: orgName,
|
||||
period_from: "2020-01-01",
|
||||
period_to: "2020-12-31"
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
expect(result.adapter_status).toBe("ready");
|
||||
expect(result.should_run_discovery).toBe(true);
|
||||
expect(result.semantic_data_need).toBe("counterparty value-flow evidence");
|
||||
expect(result.turn_meaning_ref).toMatchObject({
|
||||
asked_domain_family: "counterparty_value",
|
||||
asked_action_family: "net_value_flow",
|
||||
explicit_entity_candidates: ["СВК"],
|
||||
explicit_organization_scope: orgName,
|
||||
explicit_date_scope: "2020",
|
||||
unsupported_but_understood_family: "counterparty_bidirectional_value_flow_or_netting",
|
||||
stale_replay_forbidden: true
|
||||
});
|
||||
expect(result.reason_codes).toContain("mcp_discovery_counterparty_from_raw_scope");
|
||||
expect(result.reason_codes).toContain("mcp_discovery_bidirectional_value_flow_signal_detected");
|
||||
});
|
||||
|
||||
it("overrides a supported exact current-turn payout route when the question asks for a payment amount", () => {
|
||||
const result = buildAssistantMcpDiscoveryTurnInput({
|
||||
userMessage:
|
||||
|
||||
Reference in New Issue
Block a user