АРЧ - Добавить поддержку агентных смысловых прогонов в автопрогоны и правило AGENT в AGENTS.md
This commit is contained in:
+263
-338
@@ -3430,6 +3430,107 @@ class AddressQueryService {
|
||||
debug: debugPayload
|
||||
};
|
||||
};
|
||||
const buildFactualExecutionResult = (input) => {
|
||||
const resultSemantics = mergeAddressResultSemantics(deriveAddressResultSemantics({
|
||||
intent: intent.intent,
|
||||
selectedRecipe: input.selectedRecipe,
|
||||
filters: input.extractedFilters ?? filters.extracted_filters,
|
||||
semanticFrame: input.semanticFrame ?? semanticFrame,
|
||||
responseType: input.responseType,
|
||||
rowsMatched: input.rowsMatched
|
||||
}), input.responseSemantics);
|
||||
const routeExpectationAudit = input.routeExpectationAudit ??
|
||||
buildRouteExpectationAudit({
|
||||
intent: routeExpectationIntent,
|
||||
selectedRecipe: input.selectedRecipe,
|
||||
requestedResultMode,
|
||||
resultMode: resultSemantics.result_mode
|
||||
});
|
||||
const debugPayload = (0, addressTruthGatePolicy_1.attachAddressTruthGate)({
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: input.extractedFilters ?? filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: input.selectedRecipe,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus(input.mcpCallStatus),
|
||||
account_scope_mode: input.accountScopeMode,
|
||||
account_scope_fallback_applied: input.accountScopeFallbackApplied,
|
||||
anchor_type: input.anchor.anchor_type,
|
||||
anchor_value_raw: input.anchor.anchor_value_raw,
|
||||
anchor_value_resolved: input.anchor.anchor_value_resolved,
|
||||
resolver_confidence: input.anchor.resolver_confidence,
|
||||
ambiguity_count: input.anchor.ambiguity_count,
|
||||
match_failure_stage: input.matchFailureStage,
|
||||
match_failure_reason: input.matchFailureReason,
|
||||
mcp_call_status: input.mcpCallStatus,
|
||||
rows_fetched: input.rowsFetched,
|
||||
raw_rows_received: input.rawRowsReceived,
|
||||
rows_after_account_scope: input.rowsAfterAccountScope,
|
||||
rows_after_recipe_filter: input.rowsAfterRecipeFilter,
|
||||
rows_materialized: input.rowsMaterialized,
|
||||
rows_matched: input.rowsMatched,
|
||||
raw_row_keys_sample: input.rawRowKeysSample,
|
||||
materialization_drop_reason: input.materializationDropReason,
|
||||
account_token_raw: input.accountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: input.accountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: input.accountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: input.accountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: input.accountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: input.runtimeReadiness ?? "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: input.limitedReasonCategory ?? null,
|
||||
response_type: input.responseType,
|
||||
route_expectation_status: routeExpectationAudit.status,
|
||||
route_expectation_reason: routeExpectationAudit.reason,
|
||||
route_expectation_expected_selected_recipes: routeExpectationAudit.expectedSelectedRecipes,
|
||||
route_expectation_expected_requested_result_modes: routeExpectationAudit.expectedRequestedResultModes,
|
||||
route_expectation_expected_result_modes: routeExpectationAudit.expectedResultModes,
|
||||
semantic_frame: input.semanticFrame ?? semanticFrame,
|
||||
...resultSemantics,
|
||||
limitations: input.limitations,
|
||||
reasons: input.reasons,
|
||||
...(input.capabilityAudit
|
||||
? {
|
||||
capability_id: input.capabilityAudit.capabilityId,
|
||||
capability_layer: input.capabilityAudit.layer,
|
||||
capability_route_mode: input.capabilityAudit.routeMode,
|
||||
capability_route_enabled: input.capabilityAudit.enabled,
|
||||
capability_route_reason: input.capabilityAudit.reason
|
||||
}
|
||||
: {}),
|
||||
...(input.shadowRouteAudit
|
||||
? {
|
||||
shadow_route_intent: input.shadowRouteAudit.intent,
|
||||
shadow_route_selected_recipe: input.shadowRouteAudit.selectedRecipe,
|
||||
shadow_route_status: input.shadowRouteAudit.status
|
||||
}
|
||||
: {})
|
||||
}, {
|
||||
intent: intent.intent,
|
||||
filters: input.extractedFilters ?? filters.extracted_filters,
|
||||
semanticFrame: input.semanticFrame ?? semanticFrame,
|
||||
selectedRecipe: input.selectedRecipe,
|
||||
truthGateStatusHint: input.truthGateStatusHint ?? null,
|
||||
rowsMatched: input.rowsMatched,
|
||||
limitedReasonCategory: input.limitedReasonCategory ?? null,
|
||||
runtimeReadiness: input.runtimeReadiness ?? "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limitations: input.limitations,
|
||||
reasons: input.reasons,
|
||||
routeExpectationStatus: routeExpectationAudit.status,
|
||||
routeExpectationReason: routeExpectationAudit.reason,
|
||||
replyType: (0, composeStage_1.inferReplyType)(input.responseType)
|
||||
});
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: input.replyText,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(input.responseType),
|
||||
response_type: input.responseType,
|
||||
debug: debugPayload
|
||||
};
|
||||
};
|
||||
if (organizationWarehouseRecoveryApplied) {
|
||||
if (!baseReasons.includes("organization_scope_live_grounding_recovered_rows")) {
|
||||
baseReasons.push("organization_scope_live_grounding_recovered_rows");
|
||||
@@ -3481,60 +3582,33 @@ class AddressQueryService {
|
||||
const replyPrefix = recoveredBankRows.length > 0
|
||||
? "Документный фильтр в live дал пустой набор; показываю связанные банковские операции по договору."
|
||||
: "Документный фильтр в live дал пустой набор; показываю найденные строки по договорному якорю.";
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: `${replyPrefix}\n${factual.text}`,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(factual.responseType),
|
||||
response_type: factual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: effectiveRecipeId,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus("matched_non_empty"),
|
||||
account_scope_mode: plan.account_scope_mode,
|
||||
account_scope_fallback_applied: accountScopeFallbackApplied,
|
||||
anchor_type: anchor.anchor_type,
|
||||
anchor_value_raw: anchor.anchor_value_raw,
|
||||
anchor_value_resolved: anchor.anchor_value_resolved,
|
||||
resolver_confidence: anchor.resolver_confidence,
|
||||
ambiguity_count: anchor.ambiguity_count,
|
||||
match_failure_stage: "none",
|
||||
match_failure_reason: null,
|
||||
mcp_call_status: "matched_non_empty",
|
||||
rows_fetched: mcp.fetched_rows,
|
||||
raw_rows_received: mcp.raw_rows.length,
|
||||
rows_after_account_scope: normalizedRows.length,
|
||||
rows_after_recipe_filter: filterByAnchors.length,
|
||||
rows_materialized: normalizedRows.length,
|
||||
rows_matched: recoveredRows.length,
|
||||
raw_row_keys_sample: rowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: rowDiagnostics.materializationDropReason,
|
||||
account_token_raw: accountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: accountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: accountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: accountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: accountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: factual.responseType,
|
||||
...mergeAddressResultSemantics(deriveAddressResultSemantics({
|
||||
intent: intent.intent,
|
||||
selectedRecipe: effectiveRecipeId,
|
||||
filters: filters.extracted_filters,
|
||||
semanticFrame,
|
||||
responseType: factual.responseType,
|
||||
rowsMatched: recoveredRows.length
|
||||
}), factual.semantics),
|
||||
limitations: [...filters.warnings, recoveryReason],
|
||||
reasons: withConfirmedBalanceFallbackReason([...baseReasons, recoveryReason], requestedResultMode, factual.semantics)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: `${replyPrefix}\n${factual.text}`,
|
||||
responseType: factual.responseType,
|
||||
responseSemantics: factual.semantics,
|
||||
selectedRecipe: effectiveRecipeId,
|
||||
mcpCallStatus: "matched_non_empty",
|
||||
rowsFetched: mcp.fetched_rows,
|
||||
rawRowsReceived: mcp.raw_rows.length,
|
||||
rowsAfterAccountScope: normalizedRows.length,
|
||||
rowsAfterRecipeFilter: filterByAnchors.length,
|
||||
rowsMaterialized: normalizedRows.length,
|
||||
rowsMatched: recoveredRows.length,
|
||||
rawRowKeysSample: rowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: rowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: plan.account_scope_mode,
|
||||
accountScopeFallbackApplied,
|
||||
accountScopeAudit,
|
||||
anchor,
|
||||
matchFailureStage: "none",
|
||||
matchFailureReason: null,
|
||||
limitations: [...filters.warnings, recoveryReason],
|
||||
reasons: withConfirmedBalanceFallbackReason([...baseReasons, recoveryReason], requestedResultMode, factual.semantics),
|
||||
limitedReasonCategory: "recipe_visibility_gap",
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
semanticFrame
|
||||
});
|
||||
}
|
||||
}
|
||||
if (filteredRows.length === 0 &&
|
||||
@@ -3605,60 +3679,32 @@ class AddressQueryService {
|
||||
const expandedPrefix = `Период сохранен. Глубина live-выборки автоматически расширена до ${expandedPlan.limit} строк.`;
|
||||
const expandedLimitations = [...filters.warnings, "query_limit_auto_expanded_for_anchor_recovery"];
|
||||
const expandedReasons = [...baseReasons, "query_limit_auto_expanded_for_anchor_recovery"];
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: `${expandedPrefix}\n${expandedFactual.text}`,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(expandedFactual.responseType),
|
||||
response_type: expandedFactual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: expandedSelection.selected_recipe.recipe_id,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus(expandedStageStatus),
|
||||
account_scope_mode: expandedPlan.account_scope_mode,
|
||||
account_scope_fallback_applied: expandedAccountScopeFallbackApplied,
|
||||
anchor_type: expandedAnchor.anchor_type,
|
||||
anchor_value_raw: expandedAnchor.anchor_value_raw,
|
||||
anchor_value_resolved: expandedAnchor.anchor_value_resolved,
|
||||
resolver_confidence: expandedAnchor.resolver_confidence,
|
||||
ambiguity_count: expandedAnchor.ambiguity_count,
|
||||
match_failure_stage: "none",
|
||||
match_failure_reason: null,
|
||||
mcp_call_status: expandedStageStatus,
|
||||
rows_fetched: expandedMcp.fetched_rows,
|
||||
raw_rows_received: expandedMcp.raw_rows.length,
|
||||
rows_after_account_scope: expandedNormalizedRows.length,
|
||||
rows_after_recipe_filter: expandedRowsByAnchor.length,
|
||||
rows_materialized: expandedNormalizedRows.length,
|
||||
rows_matched: expandedFilteredRows.length,
|
||||
raw_row_keys_sample: expandedRowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: expandedRowDiagnostics.materializationDropReason,
|
||||
account_token_raw: expandedAccountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: expandedAccountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: expandedAccountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: expandedAccountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: expandedAccountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: expandedFactual.responseType,
|
||||
...mergeAddressResultSemantics(deriveAddressResultSemantics({
|
||||
intent: intent.intent,
|
||||
selectedRecipe: expandedSelection.selected_recipe.recipe_id,
|
||||
filters: filters.extracted_filters,
|
||||
semanticFrame,
|
||||
responseType: expandedFactual.responseType,
|
||||
rowsMatched: expandedFilteredRows.length
|
||||
}), expandedFactual.semantics),
|
||||
limitations: expandedLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(expandedReasons, requestedResultMode, expandedFactual.semantics)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: `${expandedPrefix}\n${expandedFactual.text}`,
|
||||
responseType: expandedFactual.responseType,
|
||||
responseSemantics: expandedFactual.semantics,
|
||||
selectedRecipe: expandedSelection.selected_recipe.recipe_id,
|
||||
mcpCallStatus: expandedStageStatus,
|
||||
rowsFetched: expandedMcp.fetched_rows,
|
||||
rawRowsReceived: expandedMcp.raw_rows.length,
|
||||
rowsAfterAccountScope: expandedNormalizedRows.length,
|
||||
rowsAfterRecipeFilter: expandedRowsByAnchor.length,
|
||||
rowsMaterialized: expandedNormalizedRows.length,
|
||||
rowsMatched: expandedFilteredRows.length,
|
||||
rawRowKeysSample: expandedRowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: expandedRowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: expandedPlan.account_scope_mode,
|
||||
accountScopeFallbackApplied: expandedAccountScopeFallbackApplied,
|
||||
accountScopeAudit: expandedAccountScopeAudit,
|
||||
anchor: expandedAnchor,
|
||||
matchFailureStage: "none",
|
||||
matchFailureReason: null,
|
||||
limitations: expandedLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(expandedReasons, requestedResultMode, expandedFactual.semantics),
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
semanticFrame
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3752,67 +3798,34 @@ class AddressQueryService {
|
||||
requestedResultMode,
|
||||
resultMode: broadenedResultSemantics.result_mode
|
||||
});
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: injectNoticeAfterLeadLine(broadenedFactual.text, broadenedPrefix),
|
||||
reply_type: (0, composeStage_1.inferReplyType)(broadenedFactual.responseType),
|
||||
response_type: broadenedFactual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: broadenedSelection.selected_recipe.recipe_id,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus(broadenedStageStatus),
|
||||
account_scope_mode: broadenedPlan.account_scope_mode,
|
||||
account_scope_fallback_applied: broadenedAccountScopeFallbackApplied,
|
||||
anchor_type: broadenedAnchor.anchor_type,
|
||||
anchor_value_raw: broadenedAnchor.anchor_value_raw,
|
||||
anchor_value_resolved: broadenedAnchor.anchor_value_resolved,
|
||||
resolver_confidence: broadenedAnchor.resolver_confidence,
|
||||
ambiguity_count: broadenedAnchor.ambiguity_count,
|
||||
match_failure_stage: "none",
|
||||
match_failure_reason: null,
|
||||
mcp_call_status: broadenedStageStatus,
|
||||
rows_fetched: broadenedMcp.fetched_rows,
|
||||
raw_rows_received: broadenedMcp.raw_rows.length,
|
||||
rows_after_account_scope: broadenedNormalizedRows.length,
|
||||
rows_after_recipe_filter: broadenedRowsByAnchor.length,
|
||||
rows_materialized: broadenedNormalizedRows.length,
|
||||
rows_matched: broadenedFilteredRows.length,
|
||||
raw_row_keys_sample: broadenedRowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: broadenedRowDiagnostics.materializationDropReason,
|
||||
account_token_raw: broadenedAccountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: broadenedAccountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: broadenedAccountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: broadenedAccountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: broadenedAccountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: broadenedFactual.responseType,
|
||||
capability_id: capabilityAudit.capabilityId,
|
||||
capability_layer: capabilityAudit.layer,
|
||||
capability_route_mode: capabilityAudit.routeMode,
|
||||
capability_route_enabled: capabilityAudit.enabled,
|
||||
capability_route_reason: capabilityAudit.reason,
|
||||
shadow_route_intent: shadowRouteAudit.intent,
|
||||
shadow_route_selected_recipe: shadowRouteAudit.selectedRecipe,
|
||||
shadow_route_status: shadowRouteAudit.status,
|
||||
route_expectation_status: broadenedRouteExpectationAudit.status,
|
||||
route_expectation_reason: broadenedRouteExpectationAudit.reason,
|
||||
route_expectation_expected_selected_recipes: broadenedRouteExpectationAudit.expectedSelectedRecipes,
|
||||
route_expectation_expected_requested_result_modes: broadenedRouteExpectationAudit.expectedRequestedResultModes,
|
||||
route_expectation_expected_result_modes: broadenedRouteExpectationAudit.expectedResultModes,
|
||||
semantic_frame: semanticFrame,
|
||||
...broadenedResultSemantics,
|
||||
limitations: broadenedLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(broadenedReasons, requestedResultMode, broadenedFactual.semantics)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: injectNoticeAfterLeadLine(broadenedFactual.text, broadenedPrefix),
|
||||
responseType: broadenedFactual.responseType,
|
||||
responseSemantics: broadenedFactual.semantics,
|
||||
selectedRecipe: broadenedSelection.selected_recipe.recipe_id,
|
||||
mcpCallStatus: broadenedStageStatus,
|
||||
rowsFetched: broadenedMcp.fetched_rows,
|
||||
rawRowsReceived: broadenedMcp.raw_rows.length,
|
||||
rowsAfterAccountScope: broadenedNormalizedRows.length,
|
||||
rowsAfterRecipeFilter: broadenedRowsByAnchor.length,
|
||||
rowsMaterialized: broadenedNormalizedRows.length,
|
||||
rowsMatched: broadenedFilteredRows.length,
|
||||
rawRowKeysSample: broadenedRowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: broadenedRowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: broadenedPlan.account_scope_mode,
|
||||
accountScopeFallbackApplied: broadenedAccountScopeFallbackApplied,
|
||||
accountScopeAudit: broadenedAccountScopeAudit,
|
||||
anchor: broadenedAnchor,
|
||||
matchFailureStage: "none",
|
||||
matchFailureReason: null,
|
||||
limitations: broadenedLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(broadenedReasons, requestedResultMode, broadenedFactual.semantics),
|
||||
routeExpectationAudit: broadenedRouteExpectationAudit,
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
semanticFrame,
|
||||
truthGateStatusHint: "limited_temporal_or_contextual"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3887,60 +3900,33 @@ class AddressQueryService {
|
||||
: "";
|
||||
const historicalLimitations = [...filters.warnings, "historical_window_sort_recovery_applied"];
|
||||
const historicalReasons = [...baseReasons, "historical_window_sort_recovery_applied"];
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: `${historicalPrefix}\n${historicalFactual.text}${historicalSuggestion}`,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(historicalFactual.responseType),
|
||||
response_type: historicalFactual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: historicalSelection.selected_recipe.recipe_id,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus(historicalStageStatus),
|
||||
account_scope_mode: historicalPlan.account_scope_mode,
|
||||
account_scope_fallback_applied: historicalAccountScopeFallbackApplied,
|
||||
anchor_type: historicalAnchor.anchor_type,
|
||||
anchor_value_raw: historicalAnchor.anchor_value_raw,
|
||||
anchor_value_resolved: historicalAnchor.anchor_value_resolved,
|
||||
resolver_confidence: historicalAnchor.resolver_confidence,
|
||||
ambiguity_count: historicalAnchor.ambiguity_count,
|
||||
match_failure_stage: "none",
|
||||
match_failure_reason: null,
|
||||
mcp_call_status: historicalStageStatus,
|
||||
rows_fetched: historicalMcp.fetched_rows,
|
||||
raw_rows_received: historicalMcp.raw_rows.length,
|
||||
rows_after_account_scope: historicalNormalizedRows.length,
|
||||
rows_after_recipe_filter: historicalRowsByAnchor.length,
|
||||
rows_materialized: historicalNormalizedRows.length,
|
||||
rows_matched: historicalFilteredRows.length,
|
||||
raw_row_keys_sample: historicalRowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: historicalRowDiagnostics.materializationDropReason,
|
||||
account_token_raw: historicalAccountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: historicalAccountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: historicalAccountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: historicalAccountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: historicalAccountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: historicalFactual.responseType,
|
||||
...mergeAddressResultSemantics(deriveAddressResultSemantics({
|
||||
intent: intent.intent,
|
||||
selectedRecipe: historicalSelection.selected_recipe.recipe_id,
|
||||
filters: filters.extracted_filters,
|
||||
semanticFrame,
|
||||
responseType: historicalFactual.responseType,
|
||||
rowsMatched: historicalFilteredRows.length
|
||||
}), historicalFactual.semantics),
|
||||
limitations: historicalLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(historicalReasons, requestedResultMode, historicalFactual.semantics)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: `${historicalPrefix}\n${historicalFactual.text}${historicalSuggestion}`,
|
||||
responseType: historicalFactual.responseType,
|
||||
responseSemantics: historicalFactual.semantics,
|
||||
selectedRecipe: historicalSelection.selected_recipe.recipe_id,
|
||||
mcpCallStatus: historicalStageStatus,
|
||||
rowsFetched: historicalMcp.fetched_rows,
|
||||
rawRowsReceived: historicalMcp.raw_rows.length,
|
||||
rowsAfterAccountScope: historicalNormalizedRows.length,
|
||||
rowsAfterRecipeFilter: historicalRowsByAnchor.length,
|
||||
rowsMaterialized: historicalNormalizedRows.length,
|
||||
rowsMatched: historicalFilteredRows.length,
|
||||
rawRowKeysSample: historicalRowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: historicalRowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: historicalPlan.account_scope_mode,
|
||||
accountScopeFallbackApplied: historicalAccountScopeFallbackApplied,
|
||||
accountScopeAudit: historicalAccountScopeAudit,
|
||||
anchor: historicalAnchor,
|
||||
matchFailureStage: "none",
|
||||
matchFailureReason: null,
|
||||
limitations: historicalLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(historicalReasons, requestedResultMode, historicalFactual.semantics),
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
semanticFrame,
|
||||
truthGateStatusHint: "limited_temporal_or_contextual"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3959,60 +3945,33 @@ class AddressQueryService {
|
||||
: "";
|
||||
const fallbackLimitations = [...filters.warnings, "anchor_not_matched_fallback_rows"];
|
||||
const fallbackReasons = [...baseReasons, "anchor_not_matched_fallback_rows"];
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: `${fallbackPrefix}\n${fallbackFactual.text}${fallbackSuggestion}`,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(fallbackFactual.responseType),
|
||||
response_type: fallbackFactual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: effectiveRecipeId,
|
||||
mcp_call_status_legacy: "matched_non_empty",
|
||||
account_scope_mode: plan.account_scope_mode,
|
||||
account_scope_fallback_applied: accountScopeFallbackApplied,
|
||||
anchor_type: anchor.anchor_type,
|
||||
anchor_value_raw: anchor.anchor_value_raw,
|
||||
anchor_value_resolved: anchor.anchor_value_resolved,
|
||||
resolver_confidence: anchor.resolver_confidence,
|
||||
ambiguity_count: anchor.ambiguity_count,
|
||||
match_failure_stage: matchFailureStage,
|
||||
match_failure_reason: matchFailureReason,
|
||||
mcp_call_status: "matched_non_empty",
|
||||
rows_fetched: mcp.fetched_rows,
|
||||
raw_rows_received: mcp.raw_rows.length,
|
||||
rows_after_account_scope: normalizedRows.length,
|
||||
rows_after_recipe_filter: filterByAnchors.length,
|
||||
rows_materialized: normalizedRows.length,
|
||||
rows_matched: documentBankFallbackRows.length,
|
||||
raw_row_keys_sample: rowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: rowDiagnostics.materializationDropReason,
|
||||
account_token_raw: accountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: accountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: accountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: accountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: accountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: fallbackFactual.responseType,
|
||||
...mergeAddressResultSemantics(deriveAddressResultSemantics({
|
||||
intent: intent.intent,
|
||||
selectedRecipe: effectiveRecipeId,
|
||||
filters: filters.extracted_filters,
|
||||
semanticFrame,
|
||||
responseType: fallbackFactual.responseType,
|
||||
rowsMatched: documentBankFallbackRows.length
|
||||
}), fallbackFactual.semantics),
|
||||
limitations: fallbackLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(fallbackReasons, requestedResultMode, fallbackFactual.semantics)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: `${fallbackPrefix}\n${fallbackFactual.text}${fallbackSuggestion}`,
|
||||
responseType: fallbackFactual.responseType,
|
||||
responseSemantics: fallbackFactual.semantics,
|
||||
selectedRecipe: effectiveRecipeId,
|
||||
mcpCallStatus: "matched_non_empty",
|
||||
rowsFetched: mcp.fetched_rows,
|
||||
rawRowsReceived: mcp.raw_rows.length,
|
||||
rowsAfterAccountScope: normalizedRows.length,
|
||||
rowsAfterRecipeFilter: filterByAnchors.length,
|
||||
rowsMaterialized: normalizedRows.length,
|
||||
rowsMatched: documentBankFallbackRows.length,
|
||||
rawRowKeysSample: rowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: rowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: plan.account_scope_mode,
|
||||
accountScopeFallbackApplied,
|
||||
accountScopeAudit,
|
||||
anchor,
|
||||
matchFailureStage,
|
||||
matchFailureReason,
|
||||
limitations: fallbackLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(fallbackReasons, requestedResultMode, fallbackFactual.semantics),
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
limitedReasonCategory: "recipe_visibility_gap",
|
||||
semanticFrame
|
||||
});
|
||||
}
|
||||
}
|
||||
const allowConfirmedAsOfZeroSnapshot = filteredRows.length === 0 &&
|
||||
@@ -4297,67 +4256,33 @@ class AddressQueryService {
|
||||
const reasonsWithRouteExpectation = finalRouteExpectationAudit.status === "mismatch"
|
||||
? [...baseReasons, `route_expectation_mismatch:${finalRouteExpectationAudit.reason}`]
|
||||
: baseReasons;
|
||||
return {
|
||||
handled: true,
|
||||
reply_text: factual.text,
|
||||
reply_type: (0, composeStage_1.inferReplyType)(factual.responseType),
|
||||
response_type: factual.responseType,
|
||||
debug: {
|
||||
detected_mode: mode.mode,
|
||||
detected_mode_confidence: mode.confidence,
|
||||
query_shape: shape.shape,
|
||||
query_shape_confidence: shape.confidence,
|
||||
detected_intent: intent.intent,
|
||||
detected_intent_confidence: intent.confidence,
|
||||
extracted_filters: filters.extracted_filters,
|
||||
missing_required_filters: [],
|
||||
selected_recipe: effectiveRecipeId,
|
||||
mcp_call_status_legacy: toLegacyMcpStatus(stageStatus),
|
||||
account_scope_mode: plan.account_scope_mode,
|
||||
account_scope_fallback_applied: accountScopeFallbackApplied,
|
||||
anchor_type: anchor.anchor_type,
|
||||
anchor_value_raw: anchor.anchor_value_raw,
|
||||
anchor_value_resolved: anchor.anchor_value_resolved,
|
||||
resolver_confidence: anchor.resolver_confidence,
|
||||
ambiguity_count: anchor.ambiguity_count,
|
||||
match_failure_stage: "none",
|
||||
match_failure_reason: null,
|
||||
mcp_call_status: stageStatus,
|
||||
rows_fetched: mcp.fetched_rows,
|
||||
raw_rows_received: mcp.raw_rows.length,
|
||||
rows_after_account_scope: normalizedRows.length,
|
||||
rows_after_recipe_filter: filterByAnchors.length,
|
||||
rows_materialized: normalizedRows.length,
|
||||
rows_matched: filteredRows.length,
|
||||
raw_row_keys_sample: rowDiagnostics.rawRowKeysSample,
|
||||
materialization_drop_reason: rowDiagnostics.materializationDropReason,
|
||||
account_token_raw: accountScopeAudit.accountTokenRaw,
|
||||
account_token_normalized: accountScopeAudit.accountTokenNormalized,
|
||||
account_scope_fields_checked: accountScopeAudit.accountScopeFieldsChecked,
|
||||
account_scope_match_strategy: accountScopeAudit.accountScopeMatchStrategy,
|
||||
account_scope_drop_reason: accountScopeAudit.accountScopeDropReason,
|
||||
runtime_readiness: "LIVE_QUERYABLE_WITH_LIMITS",
|
||||
limited_reason_category: null,
|
||||
response_type: factual.responseType,
|
||||
capability_id: capabilityAudit.capabilityId,
|
||||
capability_layer: capabilityAudit.layer,
|
||||
capability_route_mode: capabilityAudit.routeMode,
|
||||
capability_route_enabled: capabilityAudit.enabled,
|
||||
capability_route_reason: capabilityAudit.reason,
|
||||
shadow_route_intent: shadowRouteAudit.intent,
|
||||
shadow_route_selected_recipe: shadowRouteAudit.selectedRecipe,
|
||||
shadow_route_status: shadowRouteAudit.status,
|
||||
route_expectation_status: finalRouteExpectationAudit.status,
|
||||
route_expectation_reason: finalRouteExpectationAudit.reason,
|
||||
route_expectation_expected_selected_recipes: finalRouteExpectationAudit.expectedSelectedRecipes,
|
||||
route_expectation_expected_requested_result_modes: finalRouteExpectationAudit.expectedRequestedResultModes,
|
||||
route_expectation_expected_result_modes: finalRouteExpectationAudit.expectedResultModes,
|
||||
semantic_frame: semanticFrame,
|
||||
...factualResultSemantics,
|
||||
limitations: factualLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(reasonsWithRouteExpectation, requestedResultMode, factual.semantics, factualResultSemantics.result_mode)
|
||||
}
|
||||
};
|
||||
return buildFactualExecutionResult({
|
||||
replyText: factual.text,
|
||||
responseType: factual.responseType,
|
||||
responseSemantics: factual.semantics,
|
||||
selectedRecipe: effectiveRecipeId,
|
||||
mcpCallStatus: stageStatus,
|
||||
rowsFetched: mcp.fetched_rows,
|
||||
rawRowsReceived: mcp.raw_rows.length,
|
||||
rowsAfterAccountScope: normalizedRows.length,
|
||||
rowsAfterRecipeFilter: filterByAnchors.length,
|
||||
rowsMaterialized: normalizedRows.length,
|
||||
rowsMatched: filteredRows.length,
|
||||
rawRowKeysSample: rowDiagnostics.rawRowKeysSample,
|
||||
materializationDropReason: rowDiagnostics.materializationDropReason,
|
||||
accountScopeMode: plan.account_scope_mode,
|
||||
accountScopeFallbackApplied,
|
||||
accountScopeAudit,
|
||||
anchor,
|
||||
matchFailureStage: "none",
|
||||
matchFailureReason: null,
|
||||
limitations: factualLimitations,
|
||||
reasons: withConfirmedBalanceFallbackReason(reasonsWithRouteExpectation, requestedResultMode, factual.semantics, factualResultSemantics.result_mode),
|
||||
routeExpectationAudit: finalRouteExpectationAudit,
|
||||
capabilityAudit,
|
||||
shadowRouteAudit,
|
||||
semanticFrame
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.AddressQueryService = AddressQueryService;
|
||||
|
||||
@@ -115,6 +115,9 @@ function hasReusableRootScope(input) {
|
||||
return Boolean(input.semanticFrame && input.semanticFrame.scope_kind !== "none");
|
||||
}
|
||||
function truthGateStatusFrom(input) {
|
||||
if (input.truthGateStatusHint) {
|
||||
return input.truthGateStatusHint;
|
||||
}
|
||||
const missingRequiredFilters = input.missingRequiredFilters ?? [];
|
||||
if (input.routeExpectationStatus === "mismatch") {
|
||||
return "blocked_route_expectation_failure";
|
||||
|
||||
@@ -192,7 +192,7 @@ exports.INVENTORY_CAPABILITY_CONTRACTS = [
|
||||
capability_id: "confirmed_inventory_on_hand_as_of_date",
|
||||
intent_ids: ["inventory_on_hand_as_of_date"],
|
||||
entry_modes: ["root_entry", "root_followup", "clarification_resume"],
|
||||
transitions: ["T1", "T2", "T7"],
|
||||
transitions: ["T1", "T2", "T6", "T7"],
|
||||
requiresFocusObject: false,
|
||||
requiredAnchors: [],
|
||||
resultShape: "item_list_with_quantity_cost_warehouse_organization",
|
||||
|
||||
@@ -18,7 +18,7 @@ function hasInventorySupplierCue(text) {
|
||||
if (/(?:кто\s+(?:был\s+)?продавец|кто\s+нам\s+продал|кто\s+продал\s+нам|(?:^|[\s,.;:!?()\-])(?:продавец|seller)(?=$|[\s,.;:!?()\-]))/iu.test(value)) {
|
||||
return true;
|
||||
}
|
||||
if (/(?:кто\s+(?:(?:это|этот\s+товар|эту\s+позицию)\s+)?(?:нам\s+)?поставил|кто\s+(?:нам\s+)?поставил\s+(?:это|этот\s+товар|эту\s+позицию)|от\s+какого\s+поставщика|у\s+какого\s+поставщика|от\s+кого\s+куплен|у\s+кого\s+купили|у\s+кого\s+куплено|где\s+(?:мы\s+)?купили(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|где\s+(?:мы\s+)?взяли(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|откуда\s+(?:мы\s+)?взяли(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|где\s+куплено|supplier|vendor|поставщик)/iu.test(value)) {
|
||||
if (/(?:кто\s+(?:(?:это|этот\s+товар|эту\s+позицию)\s+)?(?:нам\s+)?поставил|кто\s+(?:нам\s+)?(?:это|этот\s+товар|эту\s+позицию)\s+поставил|кто\s+(?:нам\s+)?поставил\s+(?:это|этот\s+товар|эту\s+позицию)|от\s+какого\s+поставщика|у\s+какого\s+поставщика|от\s+кого\s+куплен|у\s+кого\s+купили|у\s+кого\s+куплено|где\s+(?:мы\s+)?купили(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|где\s+(?:мы\s+)?взяли(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|откуда\s+(?:мы\s+)?взяли(?:\s+(?:это|его|этот\s+товар|эту\s+позицию))?|где\s+куплено|supplier|vendor|поставщик)/iu.test(value)) {
|
||||
return true;
|
||||
}
|
||||
return hasInventoryPurchaseStem(value) && /(?:у\s+кого|от\s+кого|где)/iu.test(value);
|
||||
|
||||
Reference in New Issue
Block a user