ARCH: связать metadata grounding с movement lane и reusable follow-up
This commit is contained in:
@@ -202,6 +202,9 @@ function mapAssistantMcpDiscoveryPilotScopeToAddressIntent(
|
||||
if (pilotScope === "counterparty_document_evidence_query_documents_v1") {
|
||||
return "list_documents_by_counterparty";
|
||||
}
|
||||
if (pilotScope === "counterparty_movement_evidence_query_movements_v1") {
|
||||
return "bank_operations_by_counterparty";
|
||||
}
|
||||
if (pilotScope === "counterparty_supplier_payout_query_movements_v1") {
|
||||
return "supplier_payouts_profile";
|
||||
}
|
||||
|
||||
@@ -101,6 +101,10 @@ function isDocumentPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): bo
|
||||
return pilot.pilot_scope === "counterparty_document_evidence_query_documents_v1";
|
||||
}
|
||||
|
||||
function isMovementPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): boolean {
|
||||
return pilot.pilot_scope === "counterparty_movement_evidence_query_movements_v1";
|
||||
}
|
||||
|
||||
function isMetadataPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): boolean {
|
||||
return pilot.pilot_scope === "metadata_inspection_v1";
|
||||
}
|
||||
@@ -124,6 +128,9 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
|
||||
const askedMonthlyBreakdown =
|
||||
pilot.derived_bidirectional_value_flow?.aggregation_axis === "month" ||
|
||||
pilot.derived_value_flow?.aggregation_axis === "month";
|
||||
if (isMovementPilot(pilot) && mode === "confirmed_with_bounded_inference") {
|
||||
return "По данным 1С найдены строки движений; ответ ограничен проверенным периодом и найденными строками.";
|
||||
}
|
||||
if (pilot.derived_metadata_surface && mode === "confirmed_with_bounded_inference") {
|
||||
if (pilot.derived_metadata_surface.ambiguity_detected) {
|
||||
return "По метаданным 1С найдены конкурирующие schema-поверхности; перед следующим шагом нужно удержать неоднозначность явно.";
|
||||
@@ -209,6 +216,10 @@ function buildMustNotClaim(pilot: AssistantMcpDiscoveryPilotExecutionContract):
|
||||
claims.push("Do not claim full document history outside the checked period.");
|
||||
claims.push("Do not present the confirmed document rows as a complete document universe.");
|
||||
}
|
||||
if (isMovementPilot(pilot)) {
|
||||
claims.push("Do not claim full movement history outside the checked period.");
|
||||
claims.push("Do not present the confirmed movement rows as a complete movement universe.");
|
||||
}
|
||||
if (isMetadataPilot(pilot)) {
|
||||
claims.push("Do not present metadata surface as confirmed business data rows.");
|
||||
claims.push("Do not claim a document/register exists outside the checked metadata probe results.");
|
||||
|
||||
@@ -149,6 +149,7 @@ interface AssistantMcpDiscoveryCoverageAwareQueryExecution {
|
||||
|
||||
export type AssistantMcpDiscoveryPilotScope =
|
||||
| "metadata_inspection_v1"
|
||||
| "counterparty_movement_evidence_query_movements_v1"
|
||||
| "counterparty_document_evidence_query_documents_v1"
|
||||
| "counterparty_lifecycle_query_documents_v1"
|
||||
| "counterparty_value_flow_query_movements_v1"
|
||||
@@ -304,6 +305,23 @@ function isDocumentEvidencePilotEligible(planner: AssistantMcpDiscoveryPlannerCo
|
||||
);
|
||||
}
|
||||
|
||||
function isMovementEvidencePilotEligible(planner: AssistantMcpDiscoveryPlannerContract): boolean {
|
||||
const meaning = planner.discovery_plan.turn_meaning_ref;
|
||||
const domain = String(meaning?.asked_domain_family ?? "").toLowerCase();
|
||||
const action = String(meaning?.asked_action_family ?? "").toLowerCase();
|
||||
const unsupported = String(meaning?.unsupported_but_understood_family ?? "").toLowerCase();
|
||||
const semanticNeed = String(planner.semantic_data_need ?? "").toLowerCase();
|
||||
const combined = `${domain} ${action} ${unsupported} ${semanticNeed}`;
|
||||
return (
|
||||
planner.proposed_primitives.includes("query_movements") &&
|
||||
(combined.includes("movement") ||
|
||||
combined.includes("movements") ||
|
||||
combined.includes("bank_operations") ||
|
||||
combined.includes("movement_evidence") ||
|
||||
combined.includes("list_movements"))
|
||||
);
|
||||
}
|
||||
|
||||
function isValueFlowPilotEligible(planner: AssistantMcpDiscoveryPlannerContract): boolean {
|
||||
const meaning = planner.discovery_plan.turn_meaning_ref;
|
||||
const domain = String(meaning?.asked_domain_family ?? "").toLowerCase();
|
||||
@@ -664,6 +682,16 @@ function summarizeDocumentRows(result: AddressMcpQueryExecutorResult): string |
|
||||
return `${result.fetched_rows} MCP document rows fetched, ${result.matched_rows} matched document scope`;
|
||||
}
|
||||
|
||||
function summarizeMovementRows(result: AddressMcpQueryExecutorResult): string | null {
|
||||
if (result.error) {
|
||||
return null;
|
||||
}
|
||||
if (result.fetched_rows <= 0) {
|
||||
return "0 MCP movement rows fetched";
|
||||
}
|
||||
return `${result.fetched_rows} MCP movement rows fetched, ${result.matched_rows} matched movement scope`;
|
||||
}
|
||||
|
||||
function summarizeValueFlowRows(result: AssistantMcpDiscoveryCoverageAwareQueryResult): string | null {
|
||||
if (result.error) {
|
||||
return null;
|
||||
@@ -1344,6 +1372,17 @@ function buildDocumentConfirmedFacts(result: AddressMcpQueryExecutorResult, coun
|
||||
];
|
||||
}
|
||||
|
||||
function buildMovementConfirmedFacts(result: AddressMcpQueryExecutorResult, counterparty: string | null): string[] {
|
||||
if (result.error || result.matched_rows <= 0) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
counterparty
|
||||
? `1C movement rows were found for counterparty ${counterparty}`
|
||||
: "1C movement rows were found for the requested scope"
|
||||
];
|
||||
}
|
||||
|
||||
function buildValueFlowConfirmedFacts(
|
||||
result: AssistantMcpDiscoveryCoverageAwareQueryResult,
|
||||
counterparty: string | null,
|
||||
@@ -1398,6 +1437,13 @@ function buildDocumentInferredFacts(result: AddressMcpQueryExecutorResult): stri
|
||||
return ["Counterparty document evidence is limited to confirmed 1C document rows in the checked scope"];
|
||||
}
|
||||
|
||||
function buildMovementInferredFacts(result: AddressMcpQueryExecutorResult): string[] {
|
||||
if (result.error || result.fetched_rows <= 0) {
|
||||
return [];
|
||||
}
|
||||
return ["Counterparty movement evidence is limited to confirmed 1C movement rows in the checked scope"];
|
||||
}
|
||||
|
||||
function buildValueFlowInferredFacts(derived: AssistantMcpDiscoveryDerivedValueFlow | null): string[] {
|
||||
if (!derived) {
|
||||
return [];
|
||||
@@ -1449,6 +1495,14 @@ function buildDocumentUnknownFacts(periodScope: string | null): string[] {
|
||||
];
|
||||
}
|
||||
|
||||
function buildMovementUnknownFacts(periodScope: string | null): string[] {
|
||||
return [
|
||||
periodScope
|
||||
? "Full movement history outside the checked period is not proven by this MCP discovery pilot"
|
||||
: "Full movement history is not proven without an explicit checked period"
|
||||
];
|
||||
}
|
||||
|
||||
function buildValueFlowUnknownFacts(
|
||||
periodScope: string | null,
|
||||
direction: AssistantMcpDiscoveryDerivedValueFlow["value_flow_direction"],
|
||||
@@ -1511,6 +1565,9 @@ function pilotScopeForPlanner(planner: AssistantMcpDiscoveryPlannerContract): As
|
||||
if (isMetadataPilotEligible(planner)) {
|
||||
return "metadata_inspection_v1";
|
||||
}
|
||||
if (isMovementEvidencePilotEligible(planner)) {
|
||||
return "counterparty_movement_evidence_query_movements_v1";
|
||||
}
|
||||
if (isValueFlowPilotEligible(planner)) {
|
||||
return valueFlowPilotProfile(planner).scope;
|
||||
}
|
||||
@@ -1586,10 +1643,11 @@ export async function executeAssistantMcpDiscoveryPilot(
|
||||
|
||||
const metadataPilotEligible = isMetadataPilotEligible(planner);
|
||||
const documentPilotEligible = isDocumentEvidencePilotEligible(planner);
|
||||
const movementPilotEligible = isMovementEvidencePilotEligible(planner);
|
||||
const lifecyclePilotEligible = isLifecyclePilotEligible(planner);
|
||||
const valueFlowPilotEligible = isValueFlowPilotEligible(planner);
|
||||
|
||||
if (!metadataPilotEligible && !documentPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
|
||||
if (!metadataPilotEligible && !documentPilotEligible && !movementPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
|
||||
pushReason(reasonCodes, "pilot_scope_unsupported_for_live_execution");
|
||||
for (const step of dryRun.execution_steps) {
|
||||
skippedPrimitives.push(step.primitive_id);
|
||||
@@ -1767,6 +1825,89 @@ export async function executeAssistantMcpDiscoveryPilot(
|
||||
};
|
||||
}
|
||||
|
||||
if (movementPilotEligible) {
|
||||
let queryResult: AddressMcpQueryExecutorResult | null = null;
|
||||
const filters = buildValueFlowFilters(planner);
|
||||
const selection = selectAddressRecipe("bank_operations_by_counterparty", filters);
|
||||
if (!selection.selected_recipe) {
|
||||
pushReason(reasonCodes, "pilot_movement_recipe_not_available");
|
||||
const evidence = buildEmptyEvidence(planner, dryRun, probeResults, "Movement-evidence recipe is not available");
|
||||
return {
|
||||
schema_version: ASSISTANT_MCP_DISCOVERY_PILOT_EXECUTOR_SCHEMA_VERSION,
|
||||
policy_owner: "assistantMcpDiscoveryPilotExecutor",
|
||||
pilot_status: "unsupported",
|
||||
pilot_scope: "counterparty_movement_evidence_query_movements_v1",
|
||||
dry_run: dryRun,
|
||||
mcp_execution_performed: false,
|
||||
executed_primitives: executedPrimitives,
|
||||
skipped_primitives: skippedPrimitives,
|
||||
probe_results: probeResults,
|
||||
evidence,
|
||||
source_rows_summary: null,
|
||||
derived_metadata_surface: null,
|
||||
derived_activity_period: null,
|
||||
derived_value_flow: null,
|
||||
derived_bidirectional_value_flow: null,
|
||||
query_limitations: ["Movement-evidence recipe is not available"],
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
|
||||
const recipePlan = buildAddressRecipePlan(selection.selected_recipe, filters);
|
||||
for (const step of dryRun.execution_steps) {
|
||||
if (step.primitive_id !== "query_movements") {
|
||||
skippedPrimitives.push(step.primitive_id);
|
||||
probeResults.push(skippedProbeResult(step, "pilot_only_executes_query_movements"));
|
||||
continue;
|
||||
}
|
||||
queryResult = await runtimeDeps.executeAddressMcpQuery({
|
||||
query: recipePlan.query,
|
||||
limit: recipePlan.limit,
|
||||
account_scope: recipePlan.account_scope
|
||||
});
|
||||
executedPrimitives.push(step.primitive_id);
|
||||
probeResults.push(queryResultToProbeResult(step.primitive_id, queryResult));
|
||||
if (queryResult.error) {
|
||||
pushUnique(queryLimitations, queryResult.error);
|
||||
pushReason(reasonCodes, "pilot_query_movements_mcp_error");
|
||||
} else {
|
||||
pushReason(reasonCodes, "pilot_query_movements_mcp_executed");
|
||||
}
|
||||
}
|
||||
|
||||
const sourceRowsSummary = queryResult ? summarizeMovementRows(queryResult) : null;
|
||||
const evidence = resolveAssistantMcpDiscoveryEvidence({
|
||||
plan: planner.discovery_plan,
|
||||
probeResults,
|
||||
confirmedFacts: queryResult ? buildMovementConfirmedFacts(queryResult, counterparty) : [],
|
||||
inferredFacts: queryResult ? buildMovementInferredFacts(queryResult) : [],
|
||||
unknownFacts: buildMovementUnknownFacts(dateScope),
|
||||
sourceRowsSummary,
|
||||
queryLimitations,
|
||||
recommendedNextProbe: "explain_evidence_basis"
|
||||
});
|
||||
|
||||
return {
|
||||
schema_version: ASSISTANT_MCP_DISCOVERY_PILOT_EXECUTOR_SCHEMA_VERSION,
|
||||
policy_owner: "assistantMcpDiscoveryPilotExecutor",
|
||||
pilot_status: "executed",
|
||||
pilot_scope: "counterparty_movement_evidence_query_movements_v1",
|
||||
dry_run: dryRun,
|
||||
mcp_execution_performed: executedPrimitives.length > 0,
|
||||
executed_primitives: executedPrimitives,
|
||||
skipped_primitives: skippedPrimitives,
|
||||
probe_results: probeResults,
|
||||
evidence,
|
||||
source_rows_summary: sourceRowsSummary,
|
||||
derived_metadata_surface: null,
|
||||
derived_activity_period: null,
|
||||
derived_value_flow: null,
|
||||
derived_bidirectional_value_flow: null,
|
||||
query_limitations: queryLimitations,
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
|
||||
if (valueFlowPilotEligible) {
|
||||
let queryResult: AssistantMcpDiscoveryCoverageAwareQueryResult | null = null;
|
||||
const filters = buildValueFlowFilters(planner);
|
||||
|
||||
@@ -170,6 +170,16 @@ function recipeFor(input: AssistantMcpDiscoveryPlannerInput): PlannerRecipe {
|
||||
};
|
||||
}
|
||||
|
||||
if (includesAny(combined, ["movement", "movements", "bank_operations", "movement_evidence", "list_movements"])) {
|
||||
pushUnique(axes, "coverage_target");
|
||||
return {
|
||||
semanticDataNeed: "movement evidence",
|
||||
primitives: ["resolve_entity_reference", "query_movements", "probe_coverage"],
|
||||
axes,
|
||||
reason: "planner_selected_movement_recipe"
|
||||
};
|
||||
}
|
||||
|
||||
if (includesAny(combined, ["document", "documents"])) {
|
||||
pushUnique(axes, "coverage_target");
|
||||
return {
|
||||
|
||||
@@ -112,6 +112,13 @@ function localizeLine(value: string): string {
|
||||
if (/^1C document rows were found for the requested scope$/i.test(value)) {
|
||||
return "В 1С найдены строки документов по запрошенному контуру.";
|
||||
}
|
||||
const movementRowsMatch = value.match(/^1C movement rows were found for counterparty\s+(.+)$/i);
|
||||
if (movementRowsMatch) {
|
||||
return `В 1С найдены строки движений по контрагенту ${movementRowsMatch[1]}.`;
|
||||
}
|
||||
if (/^1C movement rows were found for the requested scope$/i.test(value)) {
|
||||
return "В 1С найдены строки движений по запрошенному контуру.";
|
||||
}
|
||||
const supplierPayoutMatch = value.match(/^1C supplier-payout rows were found for counterparty\s+(.+)$/i);
|
||||
if (supplierPayoutMatch) {
|
||||
return `В 1С найдены строки исходящих платежей/списаний по контрагенту ${supplierPayoutMatch[1]}.`;
|
||||
@@ -141,6 +148,9 @@ function localizeLine(value: string): string {
|
||||
if (/^Counterparty document evidence is limited to confirmed 1C document rows in the checked scope$/i.test(value)) {
|
||||
return "Срез документов ограничен только подтвержденными строками документов в проверенном окне.";
|
||||
}
|
||||
if (/^Counterparty movement evidence is limited to confirmed 1C movement rows in the checked scope$/i.test(value)) {
|
||||
return "Срез движений ограничен только подтвержденными строками движений в проверенном окне.";
|
||||
}
|
||||
if (/^Counterparty value-flow total was calculated from confirmed 1C movement rows$/i.test(value)) {
|
||||
return "Сумма рассчитана только по подтвержденным строкам денежных движений в 1С.";
|
||||
}
|
||||
@@ -226,6 +236,12 @@ function localizeLine(value: string): string {
|
||||
if (/^Full document history is not proven without an explicit checked period$/i.test(value)) {
|
||||
return "Полный срез документов без явно проверенного периода не подтвержден.";
|
||||
}
|
||||
if (/^Full movement history outside the checked period is not proven by this MCP discovery pilot$/i.test(value)) {
|
||||
return "Полный исторический срез движений вне проверенного периода этим поиском не подтвержден.";
|
||||
}
|
||||
if (/^Full movement history is not proven without an explicit checked period$/i.test(value)) {
|
||||
return "Полный срез движений без явно проверенного периода не подтвержден.";
|
||||
}
|
||||
if (/^Full supplier-payout amount outside the checked period is not proven by this MCP discovery pilot$/i.test(value)) {
|
||||
return "Полный объем исходящих платежей вне проверенного периода этим поиском не подтвержден.";
|
||||
}
|
||||
|
||||
@@ -169,6 +169,13 @@ function mapPilotScopeToFollowupMeaning(
|
||||
unsupported: "counterparty_lifecycle"
|
||||
};
|
||||
}
|
||||
if (pilotScope === "counterparty_movement_evidence_query_movements_v1") {
|
||||
return {
|
||||
domain: "movements",
|
||||
action: "list_movements",
|
||||
unsupported: "movement_evidence"
|
||||
};
|
||||
}
|
||||
if (pilotScope === "counterparty_supplier_payout_query_movements_v1") {
|
||||
return {
|
||||
domain: "counterparty_value",
|
||||
@@ -232,6 +239,13 @@ function mapAddressIntentToFollowupMeaning(
|
||||
unsupported: "counterparty_value_or_turnover"
|
||||
};
|
||||
}
|
||||
if (intent === "bank_operations_by_counterparty") {
|
||||
return {
|
||||
domain: "movements",
|
||||
action: "list_movements",
|
||||
unsupported: "movement_evidence"
|
||||
};
|
||||
}
|
||||
return {
|
||||
domain: null,
|
||||
action: null,
|
||||
@@ -350,6 +364,18 @@ function hasDocumentEvidenceFollowupSignal(text: string): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
function hasMovementEvidenceFollowupSignal(text: string): boolean {
|
||||
return /(?:\u043f\u043e\s+\u0434\u0432\u0438\u0436\u0435\u043d(?:\u0438\u044f\u043c|\u0438\u044f)?|\u0434\u0430\u0432\u0430\u0439\s+\u0434\u0432\u0438\u0436\u0435\u043d(?:\u0438\u044f|\u0438\u0435)|\u0438\u0449\u0438\s+\u0434\u0432\u0438\u0436\u0435\u043d(?:\u0438\u044f|\u0438\u0435)|\u043f\u043e\u043a\u0430\u0436\u0438\s+\u0434\u0432\u0438\u0436\u0435\u043d(?:\u0438\u044f|\u0438\u0435)|\u0431\u0430\u043d\u043a\u043e\u0432\u0441\u043a(?:\u0438\u0435|\u0438\u0439)\s+\u0434\u0432\u0438\u0436\u0435\u043d(?:\u0438\u044f|\u0438\u0435)|movement(?:s)?\s+(?:then|next)?|(?:then|next)\s+movements?|go\s+to\s+movements?)/iu.test(
|
||||
text
|
||||
);
|
||||
}
|
||||
|
||||
function hasMetadataDownstreamContinuationSignal(text: string): boolean {
|
||||
return /(?:\u0434\u0430\u0432\u0430\u0439\s+\u0434\u0430\u043b\u044c\u0448\u0435|\u0438\u0434(?:\u0435|\u0451)\u043c\s+\u0434\u0430\u043b\u044c\u0448\u0435|\u043f\u043e\u0448\u043b(?:\u0438|\u0451\u043c)\s+\u0434\u0430\u043b\u044c\u0448\u0435|\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0439|\u0438\u0449\u0438\s+\u0434\u0430\u043b\u044c\u0448\u0435|\u0438\u0449\u0438\s+\u0434\u0430\u043d\u043d\u044b\u0435|\u043f\u043e\u043a\u0430\u0436\u0438\s+\u0434\u0430\u043d\u043d\u044b\u0435|\u043f\u043e\u043a\u0430\u0436\u0438\s+\u0441\u0442\u0440\u043e\u043a\u0438|\u0433\u043b\u0443\u0431\u0436\u0435|\u0447\u0442\u043e\s+\u0434\u0430\u043b\u044c\u0448\u0435|continue|go\s+ahead|go\s+deeper|look\s+deeper|drill\s+down|show\s+(?:data|rows))/iu.test(
|
||||
text
|
||||
);
|
||||
}
|
||||
|
||||
function metadataActionFromRawText(text: string): string {
|
||||
if (/(?:\u043f\u043e\u043b(?:\u0435|\u044f)|field)/iu.test(text)) {
|
||||
return "inspect_fields";
|
||||
@@ -404,6 +430,9 @@ function semanticNeedFor(input: {
|
||||
if (input.valueFlowSignal || /(?:turnover|revenue|payment|payout|value|net|netting|balance|cashflow)/iu.test(combined)) {
|
||||
return "counterparty value-flow evidence";
|
||||
}
|
||||
if (/(?:movement|movements|bank_operations|movement_evidence|list_movements)/iu.test(combined)) {
|
||||
return "movement evidence";
|
||||
}
|
||||
if (/(?:document|documents|list_documents)/iu.test(combined)) {
|
||||
return "document evidence";
|
||||
}
|
||||
@@ -486,20 +515,56 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
!rawValueFlowSignal &&
|
||||
hasDocumentEvidenceFollowupSignal(rawText)
|
||||
);
|
||||
const metadataGroundedMovementFollowupApplicable = Boolean(
|
||||
followupSeed.pilotScope === "metadata_inspection_v1" &&
|
||||
followupSeed.metadataRouteFamily === "movement_evidence" &&
|
||||
!followupSeed.metadataAmbiguityDetected &&
|
||||
followupSeed.counterparty &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
hasMovementEvidenceFollowupSignal(rawText)
|
||||
);
|
||||
const metadataGroundedLaneContinuationApplicable = Boolean(
|
||||
followupSeed.pilotScope === "metadata_inspection_v1" &&
|
||||
(followupSeed.metadataRouteFamily === "document_evidence" ||
|
||||
followupSeed.metadataRouteFamily === "movement_evidence") &&
|
||||
!followupSeed.metadataAmbiguityDetected &&
|
||||
followupSeed.counterparty &&
|
||||
!rawLifecycleSignal &&
|
||||
!rawValueFlowSignal &&
|
||||
!rawMetadataSignal &&
|
||||
!hasDocumentEvidenceFollowupSignal(rawText) &&
|
||||
!hasMovementEvidenceFollowupSignal(rawText) &&
|
||||
hasMetadataDownstreamContinuationSignal(rawText)
|
||||
);
|
||||
const metadataGroundedDocumentLaneApplicable =
|
||||
metadataGroundedDocumentFollowupApplicable ||
|
||||
(metadataGroundedLaneContinuationApplicable && followupSeed.metadataRouteFamily === "document_evidence");
|
||||
const metadataGroundedMovementLaneApplicable =
|
||||
metadataGroundedMovementFollowupApplicable ||
|
||||
(metadataGroundedLaneContinuationApplicable && followupSeed.metadataRouteFamily === "movement_evidence");
|
||||
const effectiveMetadataFollowupSeedApplicable =
|
||||
metadataFollowupSeedApplicable && !metadataGroundedDocumentFollowupApplicable;
|
||||
const seededDomain = metadataGroundedDocumentFollowupApplicable
|
||||
metadataFollowupSeedApplicable &&
|
||||
!metadataGroundedDocumentLaneApplicable &&
|
||||
!metadataGroundedMovementLaneApplicable;
|
||||
const seededDomain = metadataGroundedDocumentLaneApplicable
|
||||
? "documents"
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "movements"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.domain
|
||||
: null;
|
||||
const seededAction = metadataGroundedDocumentFollowupApplicable
|
||||
const seededAction = metadataGroundedDocumentLaneApplicable
|
||||
? "list_documents"
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "list_movements"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.action
|
||||
: null;
|
||||
const seededUnsupported = metadataGroundedDocumentFollowupApplicable
|
||||
const seededUnsupported = metadataGroundedDocumentLaneApplicable
|
||||
? "document_evidence"
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "movement_evidence"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? followupSeed.unsupported
|
||||
: null;
|
||||
@@ -543,9 +608,11 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
lifecycleSignal
|
||||
? "counterparty_lifecycle"
|
||||
: valueFlowSignal
|
||||
? "counterparty_value"
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
? "documents"
|
||||
? "counterparty_value"
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "movements"
|
||||
: metadataGroundedDocumentLaneApplicable
|
||||
? "documents"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? "metadata"
|
||||
: rawDomain ?? seededDomain,
|
||||
@@ -557,7 +624,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
: payoutSignal
|
||||
? "payout"
|
||||
: rawAction ?? seededAction ?? "turnover"
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "list_movements"
|
||||
: metadataGroundedDocumentLaneApplicable
|
||||
? "list_documents"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? metadataActionFromRawText(rawText) ?? seededAction
|
||||
@@ -576,7 +645,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
: payoutSignal
|
||||
? "counterparty_payouts_or_outflow"
|
||||
: seededUnsupported ?? "counterparty_value_or_turnover"
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "movement_evidence"
|
||||
: metadataGroundedDocumentLaneApplicable
|
||||
? "document_evidence"
|
||||
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
|
||||
? "1c_metadata_surface"
|
||||
@@ -588,7 +659,8 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
unsupported ||
|
||||
lifecycleSignal ||
|
||||
valueFlowSignal ||
|
||||
metadataGroundedDocumentFollowupApplicable ||
|
||||
metadataGroundedMovementLaneApplicable ||
|
||||
metadataGroundedDocumentLaneApplicable ||
|
||||
rawMetadataSignal ||
|
||||
effectiveMetadataFollowupSeedApplicable ||
|
||||
followupDiscoverySeedApplicable
|
||||
@@ -631,14 +703,17 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
followupDiscoverySeedApplicable:
|
||||
followupDiscoverySeedApplicable ||
|
||||
effectiveMetadataFollowupSeedApplicable ||
|
||||
metadataGroundedDocumentFollowupApplicable
|
||||
metadataGroundedMovementLaneApplicable ||
|
||||
metadataGroundedDocumentLaneApplicable
|
||||
});
|
||||
const hasTurnMeaning = Object.keys(cleanTurnMeaning).length > 0;
|
||||
const sourceSignal: AssistantMcpDiscoveryTurnInputSource = assistantTurnMeaning
|
||||
? "assistant_turn_meaning"
|
||||
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
|
||||
? "followup_context"
|
||||
: metadataGroundedDocumentFollowupApplicable
|
||||
: metadataGroundedMovementLaneApplicable
|
||||
? "followup_context"
|
||||
: metadataGroundedDocumentLaneApplicable
|
||||
? "followup_context"
|
||||
: predecomposeContract
|
||||
? "predecompose_contract"
|
||||
@@ -677,6 +752,12 @@ export function buildAssistantMcpDiscoveryTurnInput(
|
||||
if (metadataGroundedDocumentFollowupApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_metadata_grounded_document_followup");
|
||||
}
|
||||
if (metadataGroundedMovementFollowupApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_metadata_grounded_movement_followup");
|
||||
}
|
||||
if (metadataGroundedLaneContinuationApplicable) {
|
||||
pushReason(reasonCodes, "mcp_discovery_metadata_grounded_lane_continuation");
|
||||
}
|
||||
if (unsupported) {
|
||||
pushReason(reasonCodes, "mcp_discovery_unsupported_but_understood_turn");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user