Open-World: добавить debt staleness risk proxy в бизнес-обзор
This commit is contained in:
@@ -510,6 +510,9 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
|
||||
families.push("возрастной сигнал открытых расчетов");
|
||||
}
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
families.push("staleness risk proxy открытых расчетов");
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
families.push("складской срез на дату");
|
||||
}
|
||||
@@ -526,7 +529,13 @@ function headlineFor(mode: AssistantMcpDiscoveryAnswerMode, pilot: AssistantMcpD
|
||||
if (!overview.debt_position) {
|
||||
unknownFamilies.push("долговой срез");
|
||||
}
|
||||
unknownFamilies.push(overview.debt_open_settlement_quality ? "due-date просрочка" : "качество открытых расчетов");
|
||||
unknownFamilies.push(
|
||||
overview.debt_staleness_risk_proxy
|
||||
? "договорные сроки оплаты/due-date просрочка"
|
||||
: overview.debt_open_settlement_quality
|
||||
? "due-date просрочка"
|
||||
: "качество открытых расчетов"
|
||||
);
|
||||
unknownFamilies.push(businessOverviewInventoryUnknownLabel(overview));
|
||||
return `По данным 1С собран ограниченный бизнес-обзор: ${families.join(", ")} подтверждены найденными строками; ${unknownFamilies.join(", ")} остаются отдельными непроверенными областями.`;
|
||||
}
|
||||
@@ -719,6 +728,7 @@ function buildMustNotClaim(pilot: AssistantMcpDiscoveryPilotExecutionContract):
|
||||
claims.push("Do not claim debt quality, VAT position, inventory health, or company health unless those contours were separately checked.");
|
||||
claims.push("Do not present a debt-position snapshot as debt aging, overdue debt, or credit-quality analysis.");
|
||||
claims.push("Do not present open-settlement concentration as contractual due-date aging or confirmed overdue debt.");
|
||||
claims.push("Do not present business overview debt staleness risk proxy as confirmed overdue debt, contractual delinquency, credit risk, or due-date aging.");
|
||||
claims.push("Do not present an inventory snapshot or purchase-date aging signal as turnover, obsolescence, liquidation value, or full inventory health.");
|
||||
claims.push("Do not present business overview inventory turnover proxy as full inventory liquidity, FIFO turnover, obsolescence analysis, or liquidation value.");
|
||||
claims.push("Do not present business overview inventory staleness risk proxy as confirmed obsolete stock, reserve, write-off, or liquidation value.");
|
||||
@@ -1059,6 +1069,21 @@ function inventoryStalenessRiskBandRu(
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
|
||||
function debtStalenessRiskBandRu(
|
||||
riskBand: NonNullable<BusinessOverview["debt_staleness_risk_proxy"]>["risk_band"]
|
||||
): string {
|
||||
if (riskBand === "high") {
|
||||
return "высокая зона внимания";
|
||||
}
|
||||
if (riskBand === "elevated") {
|
||||
return "повышенная зона внимания";
|
||||
}
|
||||
if (riskBand === "watch") {
|
||||
return "зона наблюдения";
|
||||
}
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
|
||||
function derivedBusinessOverviewConfirmedLines(pilot: AssistantMcpDiscoveryPilotExecutionContract): string[] {
|
||||
const overview = pilot.derived_business_overview;
|
||||
if (!overview) {
|
||||
@@ -1133,6 +1158,13 @@ function derivedBusinessOverviewConfirmedLines(pilot: AssistantMcpDiscoveryPilot
|
||||
);
|
||||
}
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
const proxy = overview.debt_staleness_risk_proxy;
|
||||
const counterpartyText = proxy.top_contract_counterparty ? ` / ${proxy.top_contract_counterparty}` : "";
|
||||
lines.push(
|
||||
`Staleness risk proxy открытых расчетов на ${proxy.as_of_date}: самый старый договорный сигнал ${proxy.oldest_contract_start_date}, возраст ${proxy.max_contract_age_days} дн.; старейший крупный договор ${proxy.top_contract}${counterpartyText} держит ${proxy.top_contract_amount_human_ru} (${proxy.top_contract_share_pct}% брутто открытых остатков); оценка ${debtStalenessRiskBandRu(proxy.risk_band)}. Это не подтвержденная просрочка, не кредитный риск и не due-date aging.`
|
||||
);
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
const leader = overview.inventory_position.top_items[0];
|
||||
const leaderText = leader
|
||||
@@ -1228,6 +1260,11 @@ function businessOverviewRiskSynthesisLine(overview: BusinessOverview): string |
|
||||
if (overview.debt_open_settlement_quality?.age_signal?.max_age_days !== null && overview.debt_open_settlement_quality?.age_signal?.max_age_days !== undefined) {
|
||||
signals.push(`самый старый договорный возрастной сигнал ${overview.debt_open_settlement_quality.age_signal.max_age_days} дн.`);
|
||||
}
|
||||
if (overview.debt_staleness_risk_proxy) {
|
||||
signals.push(
|
||||
`staleness risk proxy открытых расчетов: ${debtStalenessRiskBandRu(overview.debt_staleness_risk_proxy.risk_band)}, возраст ${overview.debt_staleness_risk_proxy.max_contract_age_days} дн., концентрация старейшего крупного договора ${overview.debt_staleness_risk_proxy.top_contract_share_pct}%`
|
||||
);
|
||||
}
|
||||
if (overview.inventory_position) {
|
||||
signals.push(`складской остаток на дату ${overview.inventory_position.total_amount_human_ru}`);
|
||||
if (overview.inventory_position.aging_signal?.max_age_days !== null && overview.inventory_position.aging_signal?.max_age_days !== undefined) {
|
||||
@@ -1257,6 +1294,7 @@ function businessOverviewExecutiveVerdictLine(overview: BusinessOverview): strin
|
||||
overview.trading_margin_proxy ||
|
||||
overview.debt_position ||
|
||||
overview.debt_open_settlement_quality ||
|
||||
overview.debt_staleness_risk_proxy ||
|
||||
overview.inventory_position ||
|
||||
overview.inventory_turnover_proxy ||
|
||||
overview.inventory_staleness_risk_proxy
|
||||
@@ -1355,6 +1393,9 @@ export function buildAssistantMcpDiscoveryAnswerDraft(
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_debt_age_signal");
|
||||
}
|
||||
}
|
||||
if (pilot.derived_business_overview?.debt_staleness_risk_proxy) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_debt_staleness_risk_proxy");
|
||||
}
|
||||
if (pilot.derived_business_overview?.inventory_position) {
|
||||
pushReason(reasonCodes, "answer_contains_business_overview_inventory_position");
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@ export interface AssistantMcpDiscoveryDerivedBusinessOverview {
|
||||
trading_margin_proxy: AssistantMcpDiscoveryDerivedBusinessOverviewTradingMarginProxy | null;
|
||||
debt_position: AssistantMcpDiscoveryDerivedBusinessOverviewDebtPosition | null;
|
||||
debt_open_settlement_quality: AssistantMcpDiscoveryDerivedBusinessOverviewDebtOpenSettlementQuality | null;
|
||||
debt_staleness_risk_proxy: AssistantMcpDiscoveryDerivedBusinessOverviewDebtStalenessRiskProxy | null;
|
||||
inventory_position: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryPosition | null;
|
||||
inventory_turnover_proxy: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryTurnoverProxy | null;
|
||||
inventory_staleness_risk_proxy: AssistantMcpDiscoveryDerivedBusinessOverviewInventoryStalenessRiskProxy | null;
|
||||
@@ -277,6 +278,21 @@ export interface AssistantMcpDiscoveryDerivedBusinessOverviewDebtOpenSettlementQ
|
||||
inference_basis: "open_contracts_confirmed_1c_balance_rows";
|
||||
}
|
||||
|
||||
export interface AssistantMcpDiscoveryDerivedBusinessOverviewDebtStalenessRiskProxy {
|
||||
as_of_date: string;
|
||||
gross_open_amount: number;
|
||||
gross_open_amount_human_ru: string;
|
||||
oldest_contract_start_date: string;
|
||||
max_contract_age_days: number;
|
||||
top_contract: string;
|
||||
top_contract_counterparty: string | null;
|
||||
top_contract_amount: number;
|
||||
top_contract_amount_human_ru: string;
|
||||
top_contract_share_pct: number;
|
||||
risk_band: "lower_visible_risk" | "watch" | "elevated" | "high";
|
||||
inference_basis: "contract_date_age_and_open_balance_concentration_confirmed_1c_rows";
|
||||
}
|
||||
|
||||
export interface AssistantMcpDiscoveryBusinessOverviewInventoryItemBucket {
|
||||
item: string;
|
||||
rows_with_amount: number;
|
||||
@@ -3111,6 +3127,74 @@ function deriveBusinessOverviewDebtOpenSettlementQuality(input: {
|
||||
};
|
||||
}
|
||||
|
||||
function debtStalenessRiskBand(input: {
|
||||
maxContractAgeDays: number;
|
||||
topContractSharePct: number;
|
||||
}): AssistantMcpDiscoveryDerivedBusinessOverviewDebtStalenessRiskProxy["risk_band"] {
|
||||
if (input.maxContractAgeDays >= 365 && input.topContractSharePct >= 50) {
|
||||
return "high";
|
||||
}
|
||||
if (input.maxContractAgeDays >= 365 || input.topContractSharePct >= 50) {
|
||||
return "elevated";
|
||||
}
|
||||
if (input.maxContractAgeDays >= 180 || input.topContractSharePct >= 35) {
|
||||
return "watch";
|
||||
}
|
||||
return "lower_visible_risk";
|
||||
}
|
||||
|
||||
function deriveBusinessOverviewDebtStalenessRiskProxy(
|
||||
quality: AssistantMcpDiscoveryDerivedBusinessOverviewDebtOpenSettlementQuality | null
|
||||
): AssistantMcpDiscoveryDerivedBusinessOverviewDebtStalenessRiskProxy | null {
|
||||
const ageSignal = quality?.age_signal;
|
||||
const topAgedContract = ageSignal?.top_aged_contracts[0];
|
||||
const topContractSharePct = topAgedContract?.share_of_gross_open_amount_pct;
|
||||
if (
|
||||
!quality ||
|
||||
!ageSignal?.oldest_start_date ||
|
||||
ageSignal.max_age_days === null ||
|
||||
ageSignal.max_age_days === undefined ||
|
||||
!topAgedContract ||
|
||||
topContractSharePct === null ||
|
||||
topContractSharePct === undefined
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
as_of_date: quality.as_of_date,
|
||||
gross_open_amount: quality.gross_open_amount,
|
||||
gross_open_amount_human_ru: quality.gross_open_amount_human_ru,
|
||||
oldest_contract_start_date: ageSignal.oldest_start_date,
|
||||
max_contract_age_days: ageSignal.max_age_days,
|
||||
top_contract: topAgedContract.contract,
|
||||
top_contract_counterparty: topAgedContract.counterparty,
|
||||
top_contract_amount: topAgedContract.total_amount,
|
||||
top_contract_amount_human_ru: topAgedContract.total_amount_human_ru,
|
||||
top_contract_share_pct: topContractSharePct,
|
||||
risk_band: debtStalenessRiskBand({
|
||||
maxContractAgeDays: ageSignal.max_age_days,
|
||||
topContractSharePct
|
||||
}),
|
||||
inference_basis: "contract_date_age_and_open_balance_concentration_confirmed_1c_rows"
|
||||
};
|
||||
}
|
||||
|
||||
function debtStalenessRiskBandRu(
|
||||
riskBand: AssistantMcpDiscoveryDerivedBusinessOverviewDebtStalenessRiskProxy["risk_band"]
|
||||
): string {
|
||||
if (riskBand === "high") {
|
||||
return "высокая зона внимания";
|
||||
}
|
||||
if (riskBand === "elevated") {
|
||||
return "повышенная зона внимания";
|
||||
}
|
||||
if (riskBand === "watch") {
|
||||
return "зона наблюдения";
|
||||
}
|
||||
return "низкий видимый риск";
|
||||
}
|
||||
|
||||
function daysBetweenIsoDates(leftIsoDate: string, rightIsoDate: string): number | null {
|
||||
const leftMatch = leftIsoDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
const rightMatch = rightIsoDate.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
||||
@@ -3362,6 +3446,7 @@ function deriveBusinessOverview(input: {
|
||||
openContractsResult: input.openContractsResult,
|
||||
debtAsOfDate: input.debtAsOfDate
|
||||
});
|
||||
const debtStalenessRiskProxy = deriveBusinessOverviewDebtStalenessRiskProxy(debtOpenSettlementQuality);
|
||||
const inventoryPosition = deriveBusinessOverviewInventoryPosition({
|
||||
inventoryOnHandResult: input.inventoryOnHandResult,
|
||||
inventoryAgingResult: input.inventoryAgingResult,
|
||||
@@ -3383,6 +3468,7 @@ function deriveBusinessOverview(input: {
|
||||
Boolean(tradingMarginProxy),
|
||||
Boolean(debtPosition),
|
||||
Boolean(debtOpenSettlementQuality),
|
||||
Boolean(debtStalenessRiskProxy),
|
||||
Boolean(inventoryPosition),
|
||||
Boolean(inventoryTurnoverProxy),
|
||||
Boolean(inventoryStalenessRiskProxy)
|
||||
@@ -3406,6 +3492,7 @@ function deriveBusinessOverview(input: {
|
||||
trading_margin_proxy: tradingMarginProxy,
|
||||
debt_position: debtPosition,
|
||||
debt_open_settlement_quality: debtOpenSettlementQuality,
|
||||
debt_staleness_risk_proxy: debtStalenessRiskProxy,
|
||||
inventory_position: inventoryPosition,
|
||||
inventory_turnover_proxy: inventoryTurnoverProxy,
|
||||
inventory_staleness_risk_proxy: inventoryStalenessRiskProxy,
|
||||
@@ -3565,6 +3652,13 @@ function buildBusinessOverviewConfirmedFacts(derived: AssistantMcpDiscoveryDeriv
|
||||
);
|
||||
}
|
||||
}
|
||||
if (derived.debt_staleness_risk_proxy) {
|
||||
const proxy = derived.debt_staleness_risk_proxy;
|
||||
const counterpartyText = proxy.top_contract_counterparty ? ` / ${proxy.top_contract_counterparty}` : "";
|
||||
facts.push(
|
||||
`Staleness risk proxy открытых расчетов на ${proxy.as_of_date}: самый старый договорный сигнал ${proxy.oldest_contract_start_date}, возраст ${proxy.max_contract_age_days} дн.; старейший крупный договор ${proxy.top_contract}${counterpartyText} держит ${proxy.top_contract_amount_human_ru} (${proxy.top_contract_share_pct}% брутто открытых остатков); оценка ${debtStalenessRiskBandRu(proxy.risk_band)}. Это не подтвержденная просрочка, не кредитный риск и не due-date aging.`
|
||||
);
|
||||
}
|
||||
if (derived.inventory_position) {
|
||||
const leader = derived.inventory_position.top_items[0];
|
||||
const leaderText = leader
|
||||
@@ -4737,6 +4831,9 @@ export async function executeAssistantMcpDiscoveryPilot(
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_debt_age_signal_from_contract_dates");
|
||||
}
|
||||
}
|
||||
if (derivedBusinessOverview.debt_staleness_risk_proxy) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_debt_staleness_risk_proxy_from_confirmed_rows");
|
||||
}
|
||||
if (derivedBusinessOverview.inventory_position) {
|
||||
pushReason(reasonCodes, "pilot_derived_business_overview_inventory_position_from_confirmed_rows");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user