ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 3.1 - Добавлен строгий контракт семантического извлечения (валидность, качество, reason-codes, рекомендация применять canonical). Подключен semantic guard в predecompose/runtime: мягкое отклонение плохого canonical: отдельный safe-кейс для сырого полезного raw-фрагмента; fallback теперь выигрывает только когда это оправдано. Подключty semantic arbitration в tool-gate

This commit is contained in:
2026-04-11 16:45:43 +03:00
parent 66402439dc
commit a7ccc92a9c
18 changed files with 750 additions and 26 deletions
+17
View File
@@ -2349,6 +2349,23 @@ Plan (Stage 3):
- Coverage critic threshold before final answer.
- Reason-code taxonomy normalized.
Implemented in current pass (Stage 3.1 kick-off):
1. Added strict semantic extraction contract for address predecompose:
- `address_semantic_extraction_contract_v1` built from `source_message + canonical_message + predecompose contract`.
- Captures: extraction snapshot, guard hints, quality, validity, apply-canonical recommendation, reason codes.
2. Added semantic guard integration in predecompose runtime:
- New rejection path for low-value/unsafe canonical rewrites (`normalized_fragment_rejected_semantic_guard`).
- Fallback preference updated: deterministic fallback can win over LLM canonical when semantic contract rejects rewrite.
3. Added semantic arbitration integration in tool-gate:
- `resolveAddressToolGateDecision(...)` now honors `apply_canonical_recommended`.
- New skip reason: `llm_predecompose_semantic_guard_rejected`.
4. Extended runtime/debug observability:
- semantic contract propagated through address tool-gate, deep debug payload, and living chat debug payload.
- orchestration contract now includes semantic guard fields (`semantic_contract_valid`, `semantic_apply_canonical_recommended`, `semantic_reason_codes`).
5. Added focused regression tests:
- `assistantSemanticExtractionContract.test.ts` (new)
- Existing router/chat regressions revalidated (`assistantLivingRouter.test.ts`, `assistantLivingChatMode.test.ts`).
Acceptance (Stage 3):
1. LLM outputs strictly validated schema for extraction/decomposition (no free-form).
2. Deterministic guards can block or downgrade answers when evidence insufficient.