ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.2 - Усилена оркестрацию в deep/address гейте и follow-up binding в assistantService.ts. Починен кейс UTF-8 follow-up refinement (теперь followup_state_usage.applied=true в нужном сценарии). Убраны регрессии по assistantLivingRouter и stage3 lifecycle probe. Корректное поведение для llm canonical candidate (чтобы не уезжало в clarification_required там, где должен быть address factual).

This commit is contained in:
2026-04-11 14:56:14 +03:00
parent 19f5f19d8e
commit b5bd4fd737
46 changed files with 2471 additions and 370 deletions
@@ -49,14 +49,7 @@ const KNOWN_GUARD_DOMAINS = [
"fixed_asset_amortization"
] as const;
function toRecordObject(value: unknown): Record<string, unknown> | null {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return null;
}
return value as Record<string, unknown>;
}
function toStringArray(value: unknown): string[] {
function toStringArray(value: string[] | null | undefined): string[] {
if (!Array.isArray(value)) {
return [];
}
@@ -65,11 +58,11 @@ function toStringArray(value: unknown): string[] {
.filter((item) => item.length > 0);
}
function toCompanyAnchorSet(value: unknown): CompanyAnchorSet | null {
const source = toRecordObject(value);
if (!source) {
function toCompanyAnchorSet(value: Partial<CompanyAnchorSet> | null | undefined): CompanyAnchorSet | null {
if (!value || typeof value !== "object" || Array.isArray(value)) {
return null;
}
const source: Partial<CompanyAnchorSet> = value;
return {
contract_numbers: toStringArray(source.contract_numbers),
document_numbers: toStringArray(source.document_numbers),
@@ -82,14 +75,13 @@ function toCompanyAnchorSet(value: unknown): CompanyAnchorSet | null {
};
}
function toClaimBoundPrimaryPeriod(value: unknown): ClaimBoundPrimaryPeriod {
const source = toRecordObject(value);
if (!source) {
function toClaimBoundPrimaryPeriod(value: ClaimBoundPrimaryPeriod | null | undefined): ClaimBoundPrimaryPeriod {
if (!value || typeof value !== "object") {
return null;
}
const from = typeof source.from === "string" ? source.from.trim() : "";
const to = typeof source.to === "string" ? source.to.trim() : "";
const granularity = source.granularity === "day" || source.granularity === "month" ? source.granularity : null;
const from = typeof value.from === "string" ? value.from.trim() : "";
const to = typeof value.to === "string" ? value.to.trim() : "";
const granularity = value.granularity === "day" || value.granularity === "month" ? value.granularity : null;
if (!from || !to || !granularity) {
return null;
}
@@ -101,7 +93,7 @@ function toClaimBoundPrimaryPeriod(value: unknown): ClaimBoundPrimaryPeriod {
}
function normalizeFocusDomainForGuards(
value: unknown
value: string | null | undefined
): AssistantDeepTurnRetrievalGuardPipelineInput["focusDomainForGuards"] {
const normalized = typeof value === "string" ? value.trim() : "";
if (!normalized) {