ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.30: вынос ветки tool_gate_skip + chat fallback из assistantService в отдельный runtime-адаптер, чтобы в сервисе остался только orchestration flow.

This commit is contained in:
2026-04-10 20:52:04 +03:00
parent 3531f7ddfe
commit 353cbc1763
16 changed files with 1706 additions and 405 deletions
+103 -1
View File
@@ -996,7 +996,109 @@ Validation:
- `assistantLivingRouter.test.ts`
- `assistantWave10SettlementCorrectiveRegression.test.ts`
Status: **In progress (Phase 2.1 + 2.2 + 2.3 + 2.4 + 2.5 + 2.6 + 2.7 + 2.8 + 2.9 + 2.10 + 2.11 + 2.12 + 2.13 + 2.14 + 2.15 + 2.16 + 2.17 + 2.18 + 2.19 + 2.20 + 2.21 + 2.22 + 2.23 + 2.24 + 2.25 + 2.26 + 2.27 + 2.28 + 2.29 completed)**
Implemented in current pass (Phase 2.30):
1. Extracted address tool-gate skip branch from `assistantService` into dedicated runtime adapter:
- `assistantAddressToolGateRuntimeAdapter.ts`
- introduced:
- `runAssistantAddressToolGateRuntime(...)`
2. Centralized tool-gate skip/runtime sequence (behavior-preserving):
- deterministic early noop when `runAddressLane=true`;
- structured `assistant_address_tool_gate_skip` logging payload projection;
- conditional living-chat fallback invocation when mode is `chat`.
3. Rewired `assistantService` to consume tool-gate runtime adapter output and preserve existing early-return contract for handled chat fallback.
4. Added focused unit tests:
- `assistantAddressToolGateRuntimeAdapter.test.ts`
Validation:
1. `npm run build` passed.
2. Targeted living/address followup pack passed:
- `assistantAddressToolGateRuntimeAdapter.test.ts`
- `assistantAddressOrchestrationRuntimeAdapter.test.ts`
- `assistantAddressLaneRuntimeAdapter.test.ts`
- `assistantAddressFollowupContext.test.ts`
- `assistantLivingChatMode.test.ts`
- `assistantLivingRouter.test.ts`
- `assistantWave10SettlementCorrectiveRegression.test.ts`
Implemented in current pass (Phase 2.31):
1. Extracted deep-lane followup binding + normalize bootstrap block from `assistantService` into dedicated runtime adapter:
- `assistantDeepTurnNormalizationRuntimeAdapter.ts`
- introduced:
- `buildAssistantDeepTurnNormalizationRuntime(...)`
2. Centralized deep normalization bootstrap sequence (behavior-preserving):
- followup state binding projection when feature flags are enabled;
- deterministic fallback to raw user question when followup binding is disabled/unavailable;
- normalize request payload assembly and normalizer invocation.
3. Rewired `assistantService` deep-lane bootstrap to consume normalization runtime adapter output.
4. Added focused unit tests:
- `assistantDeepTurnNormalizationRuntimeAdapter.test.ts`
Validation:
1. `npm run build` passed.
2. Targeted living/address/deep followup pack passed:
- `assistantDeepTurnNormalizationRuntimeAdapter.test.ts`
- `assistantAddressToolGateRuntimeAdapter.test.ts`
- `assistantAddressOrchestrationRuntimeAdapter.test.ts`
- `assistantAddressLaneRuntimeAdapter.test.ts`
- `assistantAddressFollowupContext.test.ts`
- `assistantLivingChatMode.test.ts`
- `assistantLivingRouter.test.ts`
- `assistantWave10SettlementCorrectiveRegression.test.ts`
Implemented in current pass (Phase 2.32):
1. Extracted deep-lane context/plan/retrieval/guard/grounding/composition orchestration block from `assistantService` into dedicated runtime adapter:
- `assistantDeepTurnAnalysisRuntimeAdapter.ts`
- introduced:
- `runAssistantDeepTurnAnalysisRuntime(...)`
2. Centralized deep analysis sequence wiring (behavior-preserving):
- runtime context stage output propagation;
- execution-plan, retrieval, guard and grounding stage chaining;
- composition stage input projection from grounded retrieval output.
3. Rewired `assistantService` deep-lane middle pipeline to consume analysis runtime adapter output while preserving existing packaging/finalization contracts.
4. Added focused unit tests:
- `assistantDeepTurnAnalysisRuntimeAdapter.test.ts`
Validation:
1. `npm run build` passed.
2. Targeted living/address/deep followup pack passed:
- `assistantDeepTurnAnalysisRuntimeAdapter.test.ts`
- `assistantDeepTurnNormalizationRuntimeAdapter.test.ts`
- `assistantAddressToolGateRuntimeAdapter.test.ts`
- `assistantAddressOrchestrationRuntimeAdapter.test.ts`
- `assistantAddressLaneRuntimeAdapter.test.ts`
- `assistantAddressFollowupContext.test.ts`
- `assistantLivingChatMode.test.ts`
- `assistantLivingRouter.test.ts`
- `assistantWave10SettlementCorrectiveRegression.test.ts`
Implemented in current pass (Phase 2.33):
1. Extracted deep-lane response tail (packaging + finalize) from `assistantService` into dedicated runtime adapter:
- `assistantDeepTurnResponseRuntimeAdapter.ts`
- introduced:
- `runAssistantDeepTurnResponseRuntime(...)`
2. Centralized deep response-tail sequence (behavior-preserving):
- packaging runtime invocation with full debug/contract payload projection;
- deep finalization invocation with packaged reply/debug artifacts;
- single response projection back to caller.
3. Rewired `assistantService` deep-lane tail to consume response runtime adapter output.
4. Added focused unit tests:
- `assistantDeepTurnResponseRuntimeAdapter.test.ts`
Validation:
1. `npm run build` passed.
2. Targeted living/address/deep followup pack passed:
- `assistantDeepTurnResponseRuntimeAdapter.test.ts`
- `assistantDeepTurnAnalysisRuntimeAdapter.test.ts`
- `assistantDeepTurnNormalizationRuntimeAdapter.test.ts`
- `assistantAddressToolGateRuntimeAdapter.test.ts`
- `assistantAddressOrchestrationRuntimeAdapter.test.ts`
- `assistantAddressLaneRuntimeAdapter.test.ts`
- `assistantAddressFollowupContext.test.ts`
- `assistantLivingChatMode.test.ts`
- `assistantLivingRouter.test.ts`
- `assistantWave10SettlementCorrectiveRegression.test.ts`
Status: **In progress (Phase 2.1 + 2.2 + 2.3 + 2.4 + 2.5 + 2.6 + 2.7 + 2.8 + 2.9 + 2.10 + 2.11 + 2.12 + 2.13 + 2.14 + 2.15 + 2.16 + 2.17 + 2.18 + 2.19 + 2.20 + 2.21 + 2.22 + 2.23 + 2.24 + 2.25 + 2.26 + 2.27 + 2.28 + 2.29 + 2.30 + 2.31 + 2.32 + 2.33 completed)**
## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards)