ARCH: связать metadata grounding с document MCP lane

This commit is contained in:
2026-04-21 23:01:12 +03:00
parent 6d9c1568c3
commit 7ef788fa50
18 changed files with 706 additions and 54 deletions
@@ -155,6 +155,14 @@ function readAssistantMcpDiscoveryBridge(
return toRecordObject(readAssistantMcpDiscoveryEntry(debug)?.bridge);
}
function readAssistantMcpDiscoveryDerivedMetadataSurface(
debug: Record<string, unknown> | null
): Record<string, unknown> | null {
const bridge = readAssistantMcpDiscoveryBridge(debug);
const pilot = toRecordObject(bridge?.pilot);
return toRecordObject(pilot?.derived_metadata_surface);
}
export function readAssistantMcpDiscoveryPilotScope(
debug: Record<string, unknown> | null,
toNonEmptyString: (value: unknown) => string | null = fallbackToNonEmptyString
@@ -164,6 +172,26 @@ export function readAssistantMcpDiscoveryPilotScope(
return toNonEmptyString(pilot?.pilot_scope);
}
export function readAssistantMcpDiscoveryMetadataRouteFamily(
debug: Record<string, unknown> | null,
toNonEmptyString: (value: unknown) => string | null = fallbackToNonEmptyString
): string | null {
return toNonEmptyString(readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.downstream_route_family);
}
export function readAssistantMcpDiscoveryMetadataSelectedEntitySet(
debug: Record<string, unknown> | null,
toNonEmptyString: (value: unknown) => string | null = fallbackToNonEmptyString
): string | null {
return toNonEmptyString(readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.selected_entity_set);
}
export function readAssistantMcpDiscoveryMetadataAmbiguityDetected(
debug: Record<string, unknown> | null
): boolean {
return readAssistantMcpDiscoveryDerivedMetadataSurface(debug)?.ambiguity_detected === true;
}
function mapAssistantMcpDiscoveryPilotScopeToAddressIntent(
pilotScope: string | null,
actionFamily: string | null
@@ -171,6 +199,9 @@ function mapAssistantMcpDiscoveryPilotScopeToAddressIntent(
if (pilotScope === "counterparty_lifecycle_query_documents_v1") {
return "counterparty_activity_lifecycle";
}
if (pilotScope === "counterparty_document_evidence_query_documents_v1") {
return "list_documents_by_counterparty";
}
if (pilotScope === "counterparty_supplier_payout_query_movements_v1") {
return "supplier_payouts_profile";
}
@@ -97,6 +97,10 @@ function isValueFlowPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): b
);
}
function isDocumentPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): boolean {
return pilot.pilot_scope === "counterparty_document_evidence_query_documents_v1";
}
function isMetadataPilot(pilot: AssistantMcpDiscoveryPilotExecutionContract): boolean {
return pilot.pilot_scope === "metadata_inspection_v1";
}
@@ -147,6 +151,9 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
}
return "По данным 1С найдены строки денежных движений; сумму можно называть только в рамках проверенного периода и найденных строк.";
}
if (isDocumentPilot(pilot) && mode === "confirmed_with_bounded_inference") {
return "По данным 1С найдены строки документов; ответ ограничен проверенным периодом и найденными строками.";
}
if (mode === "confirmed_with_bounded_inference") {
return "По данным 1С есть подтвержденная активность; длительность можно оценивать только как вывод из этих строк.";
}
@@ -198,6 +205,10 @@ function buildMustNotClaim(pilot: AssistantMcpDiscoveryPilotExecutionContract):
claims.push("Do not claim full all-time turnover unless the checked period and coverage prove it.");
claims.push("Do not present a derived sum as a legal/accounting final total outside the checked 1C rows.");
}
if (isDocumentPilot(pilot)) {
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 (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_document_evidence_query_documents_v1"
| "counterparty_lifecycle_query_documents_v1"
| "counterparty_value_flow_query_movements_v1"
| "counterparty_supplier_payout_query_movements_v1"
@@ -291,6 +292,18 @@ function isLifecyclePilotEligible(planner: AssistantMcpDiscoveryPlannerContract)
);
}
function isDocumentEvidencePilotEligible(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 combined = `${domain} ${action} ${unsupported}`;
return (
planner.proposed_primitives.includes("query_documents") &&
(combined.includes("document") || combined.includes("list_documents"))
);
}
function isValueFlowPilotEligible(planner: AssistantMcpDiscoveryPlannerContract): boolean {
const meaning = planner.discovery_plan.turn_meaning_ref;
const domain = String(meaning?.asked_domain_family ?? "").toLowerCase();
@@ -641,6 +654,16 @@ function summarizeLifecycleRows(result: AddressMcpQueryExecutorResult): string |
return `${result.fetched_rows} MCP document rows fetched, ${result.matched_rows} matched lifecycle scope`;
}
function summarizeDocumentRows(result: AddressMcpQueryExecutorResult): string | null {
if (result.error) {
return null;
}
if (result.fetched_rows <= 0) {
return "0 MCP document rows fetched";
}
return `${result.fetched_rows} MCP document rows fetched, ${result.matched_rows} matched document scope`;
}
function summarizeValueFlowRows(result: AssistantMcpDiscoveryCoverageAwareQueryResult): string | null {
if (result.error) {
return null;
@@ -1310,6 +1333,17 @@ function buildLifecycleConfirmedFacts(result: AddressMcpQueryExecutorResult, cou
];
}
function buildDocumentConfirmedFacts(result: AddressMcpQueryExecutorResult, counterparty: string | null): string[] {
if (result.error || result.matched_rows <= 0) {
return [];
}
return [
counterparty
? `1C document rows were found for counterparty ${counterparty}`
: "1C document rows were found for the requested scope"
];
}
function buildValueFlowConfirmedFacts(
result: AssistantMcpDiscoveryCoverageAwareQueryResult,
counterparty: string | null,
@@ -1357,6 +1391,13 @@ function buildLifecycleInferredFacts(result: AddressMcpQueryExecutorResult): str
return ["Business activity duration may be inferred from first and latest confirmed 1C activity rows"];
}
function buildDocumentInferredFacts(result: AddressMcpQueryExecutorResult): string[] {
if (result.error || result.fetched_rows <= 0) {
return [];
}
return ["Counterparty document evidence is limited to confirmed 1C document rows in the checked scope"];
}
function buildValueFlowInferredFacts(derived: AssistantMcpDiscoveryDerivedValueFlow | null): string[] {
if (!derived) {
return [];
@@ -1400,6 +1441,14 @@ function buildLifecycleUnknownFacts(): string[] {
return ["Legal registration date is not proven by this MCP discovery pilot"];
}
function buildDocumentUnknownFacts(periodScope: string | null): string[] {
return [
periodScope
? "Full document history outside the checked period is not proven by this MCP discovery pilot"
: "Full document history is not proven without an explicit checked period"
];
}
function buildValueFlowUnknownFacts(
periodScope: string | null,
direction: AssistantMcpDiscoveryDerivedValueFlow["value_flow_direction"],
@@ -1465,6 +1514,9 @@ function pilotScopeForPlanner(planner: AssistantMcpDiscoveryPlannerContract): As
if (isValueFlowPilotEligible(planner)) {
return valueFlowPilotProfile(planner).scope;
}
if (isDocumentEvidencePilotEligible(planner)) {
return "counterparty_document_evidence_query_documents_v1";
}
return "counterparty_lifecycle_query_documents_v1";
}
@@ -1533,10 +1585,11 @@ export async function executeAssistantMcpDiscoveryPilot(
}
const metadataPilotEligible = isMetadataPilotEligible(planner);
const documentPilotEligible = isDocumentEvidencePilotEligible(planner);
const lifecyclePilotEligible = isLifecyclePilotEligible(planner);
const valueFlowPilotEligible = isValueFlowPilotEligible(planner);
if (!metadataPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
if (!metadataPilotEligible && !documentPilotEligible && !lifecyclePilotEligible && !valueFlowPilotEligible) {
pushReason(reasonCodes, "pilot_scope_unsupported_for_live_execution");
for (const step of dryRun.execution_steps) {
skippedPrimitives.push(step.primitive_id);
@@ -1631,6 +1684,89 @@ export async function executeAssistantMcpDiscoveryPilot(
};
}
if (documentPilotEligible) {
let queryResult: AddressMcpQueryExecutorResult | null = null;
const filters = buildLifecycleFilters(planner);
const selection = selectAddressRecipe("list_documents_by_counterparty", filters);
if (!selection.selected_recipe) {
pushReason(reasonCodes, "pilot_document_recipe_not_available");
const evidence = buildEmptyEvidence(planner, dryRun, probeResults, "Document-evidence recipe is not available");
return {
schema_version: ASSISTANT_MCP_DISCOVERY_PILOT_EXECUTOR_SCHEMA_VERSION,
policy_owner: "assistantMcpDiscoveryPilotExecutor",
pilot_status: "unsupported",
pilot_scope: "counterparty_document_evidence_query_documents_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: ["Document-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_documents") {
skippedPrimitives.push(step.primitive_id);
probeResults.push(skippedProbeResult(step, "pilot_only_executes_query_documents"));
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_documents_mcp_error");
} else {
pushReason(reasonCodes, "pilot_query_documents_mcp_executed");
}
}
const sourceRowsSummary = queryResult ? summarizeDocumentRows(queryResult) : null;
const evidence = resolveAssistantMcpDiscoveryEvidence({
plan: planner.discovery_plan,
probeResults,
confirmedFacts: queryResult ? buildDocumentConfirmedFacts(queryResult, counterparty) : [],
inferredFacts: queryResult ? buildDocumentInferredFacts(queryResult) : [],
unknownFacts: buildDocumentUnknownFacts(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_document_evidence_query_documents_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);
@@ -105,6 +105,13 @@ function localizeLine(value: string): string {
if (/^1C value-flow rows were found for the requested counterparty scope$/i.test(value)) {
return "В 1С найдены строки денежных движений по запрошенному контрагентскому контуру.";
}
const documentRowsMatch = value.match(/^1C document rows were found for counterparty\s+(.+)$/i);
if (documentRowsMatch) {
return `В 1С найдены строки документов по контрагенту ${documentRowsMatch[1]}.`;
}
if (/^1C document 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]}.`;
@@ -131,6 +138,9 @@ function localizeLine(value: string): string {
if (/^Business activity duration may be inferred from first and latest confirmed 1C activity rows$/i.test(value)) {
return "Длительность деловой активности можно оценивать только как вывод по первой и последней подтвержденной строке активности в 1С.";
}
if (/^Counterparty document evidence is limited to confirmed 1C document 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С.";
}
@@ -210,6 +220,12 @@ function localizeLine(value: string): string {
if (/^Full all-time turnover is not proven without an explicit checked period$/i.test(value)) {
return "Полный оборот за все время без явно проверенного периода не подтвержден.";
}
if (/^Full document history outside the checked period is not proven by this MCP discovery pilot$/i.test(value)) {
return "Полный исторический срез документов вне проверенного периода этим поиском не подтвержден.";
}
if (/^Full document 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 "Полный объем исходящих платежей вне проверенного периода этим поиском не подтвержден.";
}
@@ -248,6 +248,9 @@ function collectFollowupDiscoverySeed(followupContext: Record<string, unknown> |
discoveryEntity: string | null;
organization: string | null;
dateScope: string | null;
metadataRouteFamily: string | null;
metadataSelectedEntitySet: string | null;
metadataAmbiguityDetected: boolean;
} {
const previousFilters = toRecordObject(followupContext?.previous_filters);
const rootFilters = toRecordObject(followupContext?.root_filters);
@@ -282,7 +285,10 @@ function collectFollowupDiscoverySeed(followupContext: Record<string, unknown> |
counterparty,
discoveryEntity: discoveryEntities[0] ?? null,
organization,
dateScope
dateScope,
metadataRouteFamily: toNonEmptyString(followupContext?.previous_discovery_metadata_route_family),
metadataSelectedEntitySet: toNonEmptyString(followupContext?.previous_discovery_metadata_selected_entity_set),
metadataAmbiguityDetected: followupContext?.previous_discovery_metadata_ambiguity_detected === true
};
}
@@ -338,6 +344,12 @@ function hasMetadataObjectHint(text: string): boolean {
);
}
function hasDocumentEvidenceFollowupSignal(text: string): boolean {
return /(?:\u043f\u043e\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u0430\u043c|\u044b)?|\u0434\u0430\u0432\u0430\u0439\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|\u0438\u0449\u0438\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|\u043f\u043e\u043a\u0430\u0436\u0438\s+\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442(?:\u044b)?|document(?:s)?\s+(?:then|next)?|(?:then|next)\s+documents?|go\s+to\s+documents?)/iu.test(
text
);
}
function metadataActionFromRawText(text: string): string {
if (/(?:\u043f\u043e\u043b(?:\u0435|\u044f)|field)/iu.test(text)) {
return "inspect_fields";
@@ -465,9 +477,32 @@ export function buildAssistantMcpDiscoveryTurnInput(
!rawValueFlowSignal &&
hasMetadataObjectHint(rawText)
);
const seededDomain = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.domain : null;
const seededAction = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.action : null;
const seededUnsupported = followupDiscoverySeedApplicable || metadataFollowupSeedApplicable ? followupSeed.unsupported : null;
const metadataGroundedDocumentFollowupApplicable = Boolean(
followupSeed.pilotScope === "metadata_inspection_v1" &&
followupSeed.metadataRouteFamily === "document_evidence" &&
!followupSeed.metadataAmbiguityDetected &&
followupSeed.counterparty &&
!rawLifecycleSignal &&
!rawValueFlowSignal &&
hasDocumentEvidenceFollowupSignal(rawText)
);
const effectiveMetadataFollowupSeedApplicable =
metadataFollowupSeedApplicable && !metadataGroundedDocumentFollowupApplicable;
const seededDomain = metadataGroundedDocumentFollowupApplicable
? "documents"
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
? followupSeed.domain
: null;
const seededAction = metadataGroundedDocumentFollowupApplicable
? "list_documents"
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
? followupSeed.action
: null;
const seededUnsupported = metadataGroundedDocumentFollowupApplicable
? "document_evidence"
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
? followupSeed.unsupported
: null;
const lifecycleSignal =
rawLifecycleSignal || seededDomain === "counterparty_lifecycle";
const bidirectionalValueFlowSignal =
@@ -485,7 +520,7 @@ export function buildAssistantMcpDiscoveryTurnInput(
unsupported: unsupported ?? seededUnsupported,
lifecycleSignal,
valueFlowSignal,
metadataSignal: rawMetadataSignal || metadataFollowupSeedApplicable
metadataSignal: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
});
const entityCandidates = collectEntityCandidates(assistantTurnMeaning?.explicit_entity_candidates);
pushUnique(entityCandidates, predecomposeEntities.counterparty);
@@ -509,7 +544,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
? "counterparty_lifecycle"
: valueFlowSignal
? "counterparty_value"
: rawMetadataSignal || metadataFollowupSeedApplicable
: metadataGroundedDocumentFollowupApplicable
? "documents"
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
? "metadata"
: rawDomain ?? seededDomain,
asked_action_family: lifecycleSignal
@@ -520,7 +557,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
: payoutSignal
? "payout"
: rawAction ?? seededAction ?? "turnover"
: rawMetadataSignal || metadataFollowupSeedApplicable
: metadataGroundedDocumentFollowupApplicable
? "list_documents"
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
? metadataActionFromRawText(rawText) ?? seededAction
: rawAction ?? seededAction,
asked_aggregation_axis: monthlyAggregationSignal ? "month" : rawAggregationAxis,
@@ -537,7 +576,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
: payoutSignal
? "counterparty_payouts_or_outflow"
: seededUnsupported ?? "counterparty_value_or_turnover"
: rawMetadataSignal || metadataFollowupSeedApplicable
: metadataGroundedDocumentFollowupApplicable
? "document_evidence"
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
? "1c_metadata_surface"
: followupDiscoverySeedApplicable
? seededUnsupported
@@ -547,8 +588,9 @@ export function buildAssistantMcpDiscoveryTurnInput(
unsupported ||
lifecycleSignal ||
valueFlowSignal ||
metadataGroundedDocumentFollowupApplicable ||
rawMetadataSignal ||
metadataFollowupSeedApplicable ||
effectiveMetadataFollowupSeedApplicable ||
followupDiscoverySeedApplicable
)
};
@@ -583,15 +625,20 @@ export function buildAssistantMcpDiscoveryTurnInput(
unsupported: unsupported ?? seededUnsupported,
lifecycleSignal,
valueFlowSignal,
metadataSignal: rawMetadataSignal || metadataFollowupSeedApplicable,
metadataSignal: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable,
semanticDataNeed,
explicitIntentCandidate,
followupDiscoverySeedApplicable: followupDiscoverySeedApplicable || metadataFollowupSeedApplicable
followupDiscoverySeedApplicable:
followupDiscoverySeedApplicable ||
effectiveMetadataFollowupSeedApplicable ||
metadataGroundedDocumentFollowupApplicable
});
const hasTurnMeaning = Object.keys(cleanTurnMeaning).length > 0;
const sourceSignal: AssistantMcpDiscoveryTurnInputSource = assistantTurnMeaning
? "assistant_turn_meaning"
: followupDiscoverySeedApplicable || metadataFollowupSeedApplicable
: followupDiscoverySeedApplicable || effectiveMetadataFollowupSeedApplicable
? "followup_context"
: metadataGroundedDocumentFollowupApplicable
? "followup_context"
: predecomposeContract
? "predecompose_contract"
@@ -599,7 +646,7 @@ export function buildAssistantMcpDiscoveryTurnInput(
? "raw_text"
: valueFlowSignal
? "raw_text"
: rawMetadataSignal || metadataFollowupSeedApplicable
: rawMetadataSignal || effectiveMetadataFollowupSeedApplicable
? "raw_text"
: "none";
@@ -624,9 +671,12 @@ export function buildAssistantMcpDiscoveryTurnInput(
if (followupDiscoverySeedApplicable) {
pushReason(reasonCodes, "mcp_discovery_seeded_from_followup_context");
}
if (metadataFollowupSeedApplicable) {
if (effectiveMetadataFollowupSeedApplicable) {
pushReason(reasonCodes, "mcp_discovery_metadata_seeded_from_followup_context");
}
if (metadataGroundedDocumentFollowupApplicable) {
pushReason(reasonCodes, "mcp_discovery_metadata_grounded_document_followup");
}
if (unsupported) {
pushReason(reasonCodes, "mcp_discovery_unsupported_but_understood_turn");
}
@@ -10,6 +10,9 @@ import {
readAddressDebugIntent,
readAddressDebugFilters,
readAddressDebugItem,
readAssistantMcpDiscoveryMetadataAmbiguityDetected,
readAssistantMcpDiscoveryMetadataRouteFamily,
readAssistantMcpDiscoveryMetadataSelectedEntitySet,
readAddressDebugTemporalScope,
readAssistantMcpDiscoveryPilotScope,
resolveOrganizationClarificationContinuation,
@@ -607,6 +610,17 @@ export function createAssistantTransitionPolicy(deps) {
}
const sourceIntent = readAddressDebugIntent(carryoverSourceDebug, deps.toNonEmptyString);
const sourceDiscoveryPilotScope = readAssistantMcpDiscoveryPilotScope(carryoverSourceDebug, deps.toNonEmptyString);
const sourceDiscoveryMetadataRouteFamily = readAssistantMcpDiscoveryMetadataRouteFamily(
carryoverSourceDebug,
deps.toNonEmptyString
);
const sourceDiscoveryMetadataSelectedEntitySet = readAssistantMcpDiscoveryMetadataSelectedEntitySet(
carryoverSourceDebug,
deps.toNonEmptyString
);
const sourceDiscoveryMetadataAmbiguityDetected = readAssistantMcpDiscoveryMetadataAmbiguityDetected(
carryoverSourceDebug
);
const llmExplicitIntent = deps.toNonEmptyString(llmPreDecomposeMeta?.predecomposeContract?.intent);
const llmSelectedObjectScopeDetected =
llmPreDecomposeMeta?.predecomposeContract?.semantics?.selected_object_scope_detected === true;
@@ -939,6 +953,9 @@ export function createAssistantTransitionPolicy(deps) {
previous_anchor_type: previousAnchorType ?? undefined,
previous_anchor_value: previousAnchor,
previous_discovery_pilot_scope: sourceDiscoveryPilotScope ?? undefined,
previous_discovery_metadata_route_family: sourceDiscoveryMetadataRouteFamily ?? undefined,
previous_discovery_metadata_selected_entity_set: sourceDiscoveryMetadataSelectedEntitySet ?? undefined,
previous_discovery_metadata_ambiguity_detected: sourceDiscoveryMetadataAmbiguityDetected || undefined,
resolved_counterparty_from_display: resolvedCounterpartyFromDisplay || undefined,
root_context_only: rootScopedPivot || undefined,
root_intent: shouldAttachInventoryRootFrame ? inventoryRootFrame?.intent ?? undefined : undefined,