Архитектура: централизовать 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
@@ -13,6 +13,8 @@ import {
resolveAddressDebugCarryoverFilters,
resolveAddressDebugAnchorContext,
resolveDisplayedEntityFollowupRetarget,
resolveFollowupTargetIntent,
resolveInventoryFollowupPivotFlags,
resolveAssistantOrganizationAuthority
} from "./assistantContinuityPolicy";
@@ -773,36 +775,21 @@ export function createAssistantTransitionPolicy(deps) {
sourceIntentHint,
deps.toNonEmptyString
);
const rootContextOnlyPivot = Boolean(
(deps.isInventorySelectedObjectIntent(sourceIntentHint) || currentFrameKind === "inventory_drilldown") &&
deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage) &&
!inventoryPurchaseDateVatBridge
const { rootScopedPivot, explicitInventorySameDatePivot } = resolveInventoryFollowupPivotFlags(
inventoryRootFrame,
sourceIntentHint,
currentFrameKind,
deps.hasForeignAccountingPivotOverInventoryMessage(userMessage, alternateMessage),
inventoryPurchaseDateVatBridge,
hasInventoryRootTemporalFollowupPrimary,
hasInventoryRootTemporalFollowupAlternate,
hasInventoryRootRestatementPrimary,
hasInventoryRootRestatementAlternate,
hasExplicitInventorySameDatePivotPrimary,
hasExplicitInventorySameDatePivotAlternate,
deps.isInventorySelectedObjectIntent,
deps.isInventoryRootFrameIntent
);
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;
if (rootScopedPivot) {
previousIntent = null;
previousAnchorType = null;
@@ -899,19 +886,17 @@ export function createAssistantTransitionPolicy(deps) {
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 = resolveFollowupTargetIntent(
inventoryPurchaseDateVatBridge,
selectedObjectRetargetIntent,
explicitIntent,
sourceIntent,
followupSelectionMode,
deps.toNonEmptyString(inventoryRootFrame?.intent),
displayedEntityTargetIntent,
previousIntent,
explicitInventorySameDatePivot
);
return {
followupContext: {
previous_intent: previousIntent ?? undefined,