Архитектура: централизовать inventory pivot flags и carryover target intent в continuity policy

This commit is contained in:
2026-04-19 12:53:15 +03:00
parent 15662cfe4f
commit d1ad8e2c1b
6 changed files with 207 additions and 76 deletions
@@ -11,6 +11,8 @@ exports.resolveAddressDebugContextFacts = resolveAddressDebugContextFacts;
exports.resolveAddressDebugCarryoverFilters = resolveAddressDebugCarryoverFilters;
exports.hydrateInventoryRootFrameState = hydrateInventoryRootFrameState;
exports.buildRootScopedCarryoverFilters = buildRootScopedCarryoverFilters;
exports.resolveInventoryFollowupPivotFlags = resolveInventoryFollowupPivotFlags;
exports.resolveFollowupTargetIntent = resolveFollowupTargetIntent;
exports.shouldUseNavigationTemporalCarryover = shouldUseNavigationTemporalCarryover;
exports.applyTemporalCarryoverFilters = applyTemporalCarryoverFilters;
exports.applyOrganizationCarryoverFilters = applyOrganizationCarryoverFilters;
@@ -241,6 +243,49 @@ function buildRootScopedCarryoverFilters(previousFilters, inventoryRootFrame, to
}
return nextFilters;
}
function resolveInventoryFollowupPivotFlags(inventoryRootFrame, sourceIntentHint, currentFrameKind, hasForeignAccountingPivotMessage, inventoryPurchaseDateVatBridge, hasInventoryRootTemporalFollowupPrimary, hasInventoryRootTemporalFollowupAlternate, hasInventoryRootRestatementPrimary, hasInventoryRootRestatementAlternate, hasExplicitInventorySameDatePivotPrimary, hasExplicitInventorySameDatePivotAlternate, isInventorySelectedObjectIntent, isInventoryRootFrameIntent) {
const rootContextOnlyPivot = Boolean((isInventorySelectedObjectIntent(sourceIntentHint) || currentFrameKind === "inventory_drilldown") &&
hasForeignAccountingPivotMessage &&
!inventoryPurchaseDateVatBridge);
const inventoryRootTemporalPivot = Boolean(inventoryRootFrame &&
(isInventorySelectedObjectIntent(sourceIntentHint) ||
isInventoryRootFrameIntent(sourceIntentHint) ||
currentFrameKind === "inventory_drilldown" ||
currentFrameKind === "inventory_root") &&
(hasInventoryRootTemporalFollowupPrimary || hasInventoryRootTemporalFollowupAlternate) &&
!hasForeignAccountingPivotMessage);
const inventoryRootRestatementPivot = Boolean(inventoryRootFrame &&
(isInventorySelectedObjectIntent(sourceIntentHint) ||
isInventoryRootFrameIntent(sourceIntentHint) ||
currentFrameKind === "inventory_drilldown" ||
currentFrameKind === "inventory_root" ||
currentFrameKind === "generic") &&
(hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) &&
!hasForeignAccountingPivotMessage);
const explicitInventorySameDatePivot = Boolean(!inventoryRootFrame &&
(hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) &&
!hasForeignAccountingPivotMessage);
return {
rootScopedPivot: rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot,
explicitInventorySameDatePivot
};
}
function resolveFollowupTargetIntent(inventoryPurchaseDateVatBridge, selectedObjectRetargetIntent, explicitIntent, sourceIntent, followupSelectionMode, inventoryRootFrameIntent, displayedEntityTargetIntent, previousIntent, explicitInventorySameDatePivot) {
if (inventoryPurchaseDateVatBridge) {
return "vat_liability_confirmed_for_tax_period";
}
if (selectedObjectRetargetIntent &&
(explicitIntent === null || explicitIntent === "inventory_on_hand_as_of_date" || explicitIntent === sourceIntent)) {
return selectedObjectRetargetIntent;
}
if (followupSelectionMode === "carry_root_context") {
return inventoryRootFrameIntent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
}
if (explicitInventorySameDatePivot) {
return "inventory_on_hand_as_of_date";
}
return displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
}
function shouldUseNavigationTemporalCarryover(sourceIntentHint) {
const normalizedIntent = fallbackToNonEmptyString(sourceIntentHint);
return (normalizedIntent === "inventory_on_hand_as_of_date" ||
@@ -591,28 +591,7 @@ function createAssistantTransitionPolicy(deps) {
}
}
previousFilters = (0, assistantContinuityPolicy_1.applyTemporalCarryoverFilters)(previousFilters, navigationDateScope, continuityTemporalScope, sourceIntentHint, deps.toNonEmptyString);
const rootContextOnlyPivot = Boolean((deps.isInventorySelectedObjectIntent(sourceIntentHint) || currentFrameKind === "inventory_drilldown") &&
deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage) &&
!inventoryPurchaseDateVatBridge);
const inventoryRootTemporalPivot = Boolean(inventoryRootFrame &&
(deps.isInventorySelectedObjectIntent(sourceIntentHint) ||
deps.isInventoryRootFrameIntent(sourceIntentHint) ||
currentFrameKind === "inventory_drilldown" ||
currentFrameKind === "inventory_root") &&
(hasInventoryRootTemporalFollowupPrimary || hasInventoryRootTemporalFollowupAlternate) &&
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage));
const inventoryRootRestatementPivot = Boolean(inventoryRootFrame &&
(deps.isInventorySelectedObjectIntent(sourceIntentHint) ||
deps.isInventoryRootFrameIntent(sourceIntentHint) ||
currentFrameKind === "inventory_drilldown" ||
currentFrameKind === "inventory_root" ||
currentFrameKind === "generic") &&
(hasInventoryRootRestatementPrimary || hasInventoryRootRestatementAlternate) &&
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage));
const explicitInventorySameDatePivot = Boolean(!inventoryRootFrame &&
(hasExplicitInventorySameDatePivotPrimary || hasExplicitInventorySameDatePivotAlternate) &&
!deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage));
const rootScopedPivot = rootContextOnlyPivot || inventoryRootTemporalPivot || inventoryRootRestatementPivot;
const { rootScopedPivot, explicitInventorySameDatePivot } = (0, assistantContinuityPolicy_1.resolveInventoryFollowupPivotFlags)(inventoryRootFrame, sourceIntentHint, currentFrameKind, deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage), inventoryPurchaseDateVatBridge, hasInventoryRootTemporalFollowupPrimary, hasInventoryRootTemporalFollowupAlternate, hasInventoryRootRestatementPrimary, hasInventoryRootRestatementAlternate, hasExplicitInventorySameDatePivotPrimary, hasExplicitInventorySameDatePivotAlternate, deps.isInventorySelectedObjectIntent, deps.isInventoryRootFrameIntent);
if (rootScopedPivot) {
previousIntent = null;
previousAnchorType = null;
@@ -679,18 +658,7 @@ function createAssistantTransitionPolicy(deps) {
hasInventoryRootRestatementAlternate ||
hasSelectedObjectInventorySignalPrimary ||
hasSelectedObjectInventorySignalAlternate));
const carryoverTargetIntent = inventoryPurchaseDateVatBridge
? "vat_liability_confirmed_for_tax_period"
: selectedObjectRetargetIntent &&
(explicitIntent === null ||
explicitIntent === "inventory_on_hand_as_of_date" ||
explicitIntent === sourceIntent)
? selectedObjectRetargetIntent
: followupSelectionMode === "carry_root_context"
? inventoryRootFrame?.intent ?? displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined
: explicitInventorySameDatePivot
? "inventory_on_hand_as_of_date"
: displayedEntityTargetIntent ?? explicitIntent ?? previousIntent ?? undefined;
const carryoverTargetIntent = (0, assistantContinuityPolicy_1.resolveFollowupTargetIntent)(inventoryPurchaseDateVatBridge, selectedObjectRetargetIntent, explicitIntent, sourceIntent, followupSelectionMode, deps.toNonEmptyString(inventoryRootFrame?.intent), displayedEntityTargetIntent, previousIntent, explicitInventorySameDatePivot);
return {
followupContext: {
previous_intent: previousIntent ?? undefined,