Архитектура: централизовать root-frame-aware carryover filters в continuity policy и transition glue
This commit is contained in:
@@ -208,6 +208,42 @@ export function resolveAddressDebugContextFacts(
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveAddressDebugCarryoverFilters(
|
||||
debug: Record<string, unknown> | null,
|
||||
toNonEmptyString: (value: unknown) => string | null = fallbackToNonEmptyString
|
||||
): Record<string, unknown> {
|
||||
const extractedFilters = readAddressDebugFilters(debug);
|
||||
const nextFilters = extractedFilters ? { ...extractedFilters } : {};
|
||||
const inventoryRootFrame = buildInventoryRootFrameFromAddressDebug(debug, toNonEmptyString);
|
||||
const rootFilters =
|
||||
inventoryRootFrame?.filters && typeof inventoryRootFrame.filters === "object"
|
||||
? inventoryRootFrame.filters
|
||||
: null;
|
||||
if (rootFilters) {
|
||||
const organization = toNonEmptyString(rootFilters.organization);
|
||||
const warehouse = toNonEmptyString(rootFilters.warehouse);
|
||||
const asOfDate = toNonEmptyString(rootFilters.as_of_date);
|
||||
const periodFrom = toNonEmptyString(rootFilters.period_from);
|
||||
const periodTo = toNonEmptyString(rootFilters.period_to);
|
||||
if (organization) {
|
||||
nextFilters.organization = organization;
|
||||
}
|
||||
if (warehouse) {
|
||||
nextFilters.warehouse = warehouse;
|
||||
}
|
||||
if (asOfDate) {
|
||||
nextFilters.as_of_date = asOfDate;
|
||||
}
|
||||
if (periodFrom) {
|
||||
nextFilters.period_from = periodFrom;
|
||||
}
|
||||
if (periodTo) {
|
||||
nextFilters.period_to = periodTo;
|
||||
}
|
||||
}
|
||||
return nextFilters;
|
||||
}
|
||||
|
||||
export function buildInventoryRootFrameFromAddressDebug(
|
||||
debug: Record<string, unknown> | null,
|
||||
toNonEmptyString: (value: unknown) => string | null = fallbackToNonEmptyString
|
||||
|
||||
@@ -4,6 +4,7 @@ import {
|
||||
readAddressDebugFilters,
|
||||
readAddressDebugItem,
|
||||
readAddressDebugTemporalScope,
|
||||
resolveAddressDebugCarryoverFilters,
|
||||
resolveAddressDebugAnchorContext,
|
||||
resolveAssistantOrganizationAuthority
|
||||
} from "./assistantContinuityPolicy";
|
||||
@@ -773,9 +774,7 @@ export function createAssistantTransitionPolicy(deps) {
|
||||
: null;
|
||||
let resolvedCounterpartyFromDisplay = false;
|
||||
let displayedEntityTargetIntent = null;
|
||||
const previousFiltersRaw = previousAddressDebug.extracted_filters;
|
||||
let previousFilters =
|
||||
previousFiltersRaw && typeof previousFiltersRaw === "object" ? { ...previousFiltersRaw } : {};
|
||||
let previousFilters = resolveAddressDebugCarryoverFilters(previousAddressDebug, deps.toNonEmptyString);
|
||||
const shouldBackfillHistoricalPartyAnchors =
|
||||
sourceIntentHint === "list_contracts_by_counterparty" ||
|
||||
sourceIntentHint === "list_documents_by_counterparty" ||
|
||||
|
||||
Reference in New Issue
Block a user