ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 3.1 - Добавлен строгий контракт семантического извлечения (валидность, качество, reason-codes, рекомендация применять canonical). Подключен semantic guard в predecompose/runtime: мягкое отклонение плохого canonical: отдельный safe-кейс для сырого полезного raw-фрагмента; fallback теперь выигрывает только когда это оправдано. Подключty semantic arbitration в tool-gate
This commit is contained in:
@@ -104,6 +104,7 @@ function normalizeLlmPreDecomposeMeta(value: unknown): AddressLlmPreDecomposeMet
|
||||
const addressRetryAuditRaw = toRecordObject(source.addressRetryAudit);
|
||||
const predecomposeContractRaw = toRecordObject(source.predecomposeContract);
|
||||
const predecomposePeriodRaw = toRecordObject(predecomposeContractRaw?.period);
|
||||
const semanticExtractionContractRaw = toRecordObject(source.semanticExtractionContract);
|
||||
|
||||
const normalized: AddressLlmPreDecomposeMetaLogInput = {};
|
||||
|
||||
@@ -170,6 +171,27 @@ function normalizeLlmPreDecomposeMeta(value: unknown): AddressLlmPreDecomposeMet
|
||||
}
|
||||
}
|
||||
|
||||
if (semanticExtractionContractRaw) {
|
||||
const valid = toNullableBoolean(semanticExtractionContractRaw.valid);
|
||||
const quality = toNullableString(semanticExtractionContractRaw.quality);
|
||||
const applyCanonicalRecommended = toNullableBoolean(
|
||||
semanticExtractionContractRaw.apply_canonical_recommended
|
||||
);
|
||||
const reasonCodes = Array.isArray(semanticExtractionContractRaw.reason_codes)
|
||||
? semanticExtractionContractRaw.reason_codes
|
||||
.map((item) => toNullableString(item))
|
||||
.filter((item): item is string => Boolean(item))
|
||||
: [];
|
||||
if (valid !== undefined || quality || applyCanonicalRecommended !== undefined || reasonCodes.length > 0) {
|
||||
normalized.semanticExtractionContract = {
|
||||
valid: valid ?? null,
|
||||
quality,
|
||||
apply_canonical_recommended: applyCanonicalRecommended ?? null,
|
||||
reason_codes: reasonCodes
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const hasUsefulField = Object.values(normalized).some((item) => item !== undefined && item !== null);
|
||||
return hasUsefulField ? normalized : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user