# 1CLLMARCH Fact Check And Stabilization Plan Updated at: 2026-04-11 Source baseline: `docs/TECH/1CLLMARCH.md` ## 1. Purpose This document fixes the current factual state of the codebase against `1CLLMARCH` and records a production-focused stabilization plan that preserves: 1. existing MCP routes; 2. manual routing and guard logic; 3. GUI manual markup + autorun operational loop. ## 2. Executive Reality Check Current state is **not MVP** and also **not stable production**. It is an advanced prototype with strong observability and eval tooling, but with architectural coupling and quality bottlenecks. Approximate readiness against target architecture: **55/100**. ## 3. Verified Facts (Code + Runtime) 1. Strong engineering layers already exist: - requirement extraction, coverage, grounding checks; - rich debug payload and session trace; - investigation state/followup continuity; - manual annotation schema and post-analysis queues; - async eval run + live history APIs. 2. Main production blockers: - orchestration monolith and coupling in `assistantService.ts`; - deterministic/template-heavy final answer construction; - large lexical heuristic surface for intent routing; - temporal policy inconsistency (date handling differs by lane/path); - hidden fallback behavior around historical snapshot assumptions. 3. Quality metrics from latest Stage1 runs confirm weak user value: - low retrieval differentiation; - high generic explanation rate; - low accountant actionability; - zero mechanism specificity. ## 4. Gap Vs `1CLLMARCH` ### 4.1 Already aligned (partially or strongly) 1. Structured normalization contracts and validator loops. 2. Coverage and grounding artifacts (with different naming than target). 3. Conversation state persistence. 4. Operational diagnostics and report generation. ### 4.2 Not aligned enough for stable prod 1. Role separation (Interpreter/Planner/Critic/Answer) is incomplete and strongly coupled. 2. Final user answer quality is constrained by deterministic template synthesis. 3. Unified contract for analysis date/time scope is missing across all lanes. 4. Result classes from target (`FULLY_ANSWERED`, `BLOCKED_BY_*`, etc.) are not normalized as one contract. 5. Reason-code taxonomy exists but is fragmented across modules. ## 5. Stabilization Plan (No Route Breakage) ## Stage 1 (P0): Unified Analysis Context + Temporal Hardening Goal: 1. Introduce unified `analysis_context` contract. 2. Propagate it through eval -> assistant -> runtime lanes. 3. Remove hidden hardcoded period fallback in live MCP plan generation. 4. Keep backward compatibility (`period_hint` still supported). Acceptance: 1. If analysis date is set, runtime uses it explicitly in both deep/address paths. 2. If analysis date is absent, runtime no longer silently injects fixed historical date in live-plan fallback. 3. Existing APIs and manual workflows remain operational. Implemented in current pass: 1. Added unified `analysis_context` contract to request context (`as_of_date`, `period_from`, `period_to`, `snapshot_mode`, `source`). 2. Added compatibility bridge: legacy `period_hint` is still accepted and normalized into `analysis_context`. 3. Propagated analysis context through eval flows into assistant runtime. 4. Applied analysis context in temporal guard with explicit precedence over implicit snapshot lock. 5. Removed hidden hardcoded live-plan fallback period by switching to: - explicit analysis period/date when provided; - query-derived period when present; - generic live probe when period is absent. Validation: 1. `npm run build` passed. 2. Targeted runtime tests passed: - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Status: **Completed** ## Stage 2 (P1): Orchestrator Decomposition (Behavior-Preserving Refactor) Goal: 1. Split monolith into explicit modules: - QueryFrame builder - Execution planner - Evidence assembler - Coverage critic - Answer package builder 2. Preserve current behavior under compatibility adapter. Acceptance: 1. No MCP route regressions. 2. Existing tests and autorun loop remain green. Implemented in current pass (Phase 2.1): 1. Added new orchestration contract module: - `assistant_query_frame_v1` - `assistant_execution_plan_v1` - `assistant_evidence_bundle_v1` - `assistant_coverage_contract_v1` - outcome classifier (`FULLY_ANSWERED`, `PARTIALLY_ANSWERED`, `BLOCKED_*`, `MISROUTED`, `FAILED_TO_BIND_ENTITIES`) 2. Integrated contracts into deep-lane runtime without route/answer behavior changes: - debug payload now includes `assistant_outcome_class_v1`; - debug payload and event logs now include `assistant_orchestration_contracts_v1`. 3. Added unit regression tests: - `assistantOrchestrationContracts.test.ts` Validation: 1. `npm run build` passed. 2. Targeted tests passed: - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.2): 1. Added runtime orchestration adapter for the deep lane: - `assistantOrchestrationRuntimeAdapter.ts` - unified pipeline call for `requirements -> coverage -> grounding` with stable interfaces. 2. Integrated adapter into `assistantService` main deep-lane flow (behavior-preserving): - existing extraction/coverage/grounding logic preserved; - execution now routed through one orchestration boundary. 3. Added adapter unit tests: - `assistantOrchestrationRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted tests passed: - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.3): 1. Extracted answer package builder (`answer_structure_v11`) from `assistantService` into dedicated module: - `assistantAnswerPackageBuilder.ts` 2. Rewired deep-lane answer structure assembly to use the new module without contract changes. 3. Added focused unit tests for answer package behavior: - `assistantAnswerPackageBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 test pack passed: - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.4): 1. Extracted coverage/grounding pipeline into dedicated module: - `assistantCoverageGrounding.ts` - moved requirement extraction, coverage resolution, and grounding checks under one reusable boundary. 2. Rewired `assistantService` to use extracted coverage/grounding module via compatibility wrappers (behavior-preserving). 3. Added focused regression tests: - `assistantCoverageGrounding.test.ts` 4. Stabilized deterministic Stage 2 regression environment for followup continuity checks: - fixed accidental false-positive token in grounding test fixture; - fixed env isolation in `assistantWave10SettlementCorrectiveRegression.test.ts` by explicitly controlling `FEATURE_ASSISTANT_ADDRESS_QUERY_V1`. Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.5): 1. Extracted query-planning helpers from `assistantService` into dedicated module: - `assistantQueryPlanning.ts` - moved `fragmentTextById`, execution-plan builder, and debug-routes builder under one reusable boundary. 2. Rewired `assistantService` to use extracted query-planning module (behavior-preserving wrapper integration). 3. Added focused unit tests for query-planning behavior: - `assistantQueryPlanning.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.6): 1. Extracted evidence-bundle assembly from `assistantService` into dedicated module: - `assistantEvidenceBundleAssembler.ts` - centralized: - `assistant_evidence_bundle_v1` contract assembly; - debug `retrieval_status` projection from normalized retrieval results. 2. Rewired `assistantService` to use assembler output for both: - `assistant_orchestration_contracts_v1.evidence_bundle`; - debug payload `retrieval_status`. 3. Added focused unit tests: - `assistantEvidenceBundleAssembler.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantEvidenceBundleAssembler.test.ts` - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.7): 1. Extracted deep-lane debug payload assembly from `assistantService` into dedicated module: - `assistantDebugPayloadAssembler.ts` 2. Rewired `assistantService` to build `debug` via assembler (behavior-preserving): - keeps all existing fields, guard audits, orchestration contracts and optional sections. 3. Added focused unit tests: - `assistantDebugPayloadAssembler.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantDebugPayloadAssembler.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.8): 1. Extracted deep-lane processed log payload assembly from `assistantService` into dedicated module: - `assistantMessageLogAssembler.ts` 2. Rewired `assistantService` to build `assistant_message_processed.details` via assembler (behavior-preserving). 3. Added focused unit tests: - `assistantMessageLogAssembler.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantMessageLogAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.9): 1. Extracted orchestration-contract bundle assembly from `assistantService` into dedicated module: - `assistantContractsBundleAssembler.ts` 2. Rewired `assistantService` to consume bundled contracts/outcome class from assembler (behavior-preserving): - `query_frame`, `execution_plan`, `evidence_bundle`, `coverage`, `outcome_class`. 3. Added focused unit tests: - `assistantContractsBundleAssembler.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantContractsBundleAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.10): 1. Extracted deep response envelope assembly from `assistantService` into dedicated module: - `assistantDeepResponseAssembler.ts` - centralized: - safe final assistant text cleanup (debug tail stripping); - `answer_structure_v11` selection/building policy; - assistant conversation item construction. 2. Rewired `assistantService` to consume deep response assembler (behavior-preserving). 3. Added focused unit tests: - `assistantDeepResponseAssembler.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 + safety regressions passed: - `assistantDeepResponseAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantQueryPlanning.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantOrchestrationContracts.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.11): 1. Added top-level deep turn packager to compose extracted Stage 2 modules behind one boundary: - `assistantDeepTurnPackaging.ts` - centralizes orchestration of: - evidence bundle assembly; - contracts/outcome class assembly; - deep answer artifacts; - debug payload; - assistant conversation item; - processed log details. 2. Rewired deep-lane `assistantService` flow to use `assembleAssistantDeepTurnPackaging(...)` (behavior-preserving): - replaced duplicated per-artifact assembly block with single orchestrator call; - preserved investigation-state update and existing response/event contract. 3. Added focused unit test: - `assistantDeepTurnPackaging.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.12): 1. Extracted deep-turn input normalization/defaulting from `assistantService` into dedicated module: - `assistantDeepTurnInputBuilder.ts` - centralized normalization of: - `followupStateUsage` default (`null` when absent); - composition defaults (`problem_*` fields, `answer_structure_v11`); - `problem_unit_ids_used` array normalization. 2. Rewired `assistantService` to build deep-turn input via: - `buildAssistantDeepTurnPackagingInput(...)` - followed by existing `assembleAssistantDeepTurnPackaging(...)` call (behavior-preserving). 3. Added focused unit tests: - `assistantDeepTurnInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.13): 1. Extracted investigation-state update/persist runtime block from `assistantService` into dedicated adapter: - `assistantInvestigationStateRuntimeAdapter.ts` - introduced: - `buildAssistantInvestigationStateSnapshot(...)` - `persistAssistantInvestigationStateSnapshot(...)` 2. Rewired `assistantService` to consume new adapter (behavior-preserving): - same `investigation_state` snapshot semantics; - same `FEATURE_ASSISTANT_INVESTIGATION_STATE_V1` gating; - same session persistence call path. 3. Added focused unit tests: - `assistantInvestigationStateRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.14): 1. Extracted deep-lane assistant post-turn commit/persist/log block from `assistantService` into dedicated adapter: - `assistantTurnCommitRuntimeAdapter.ts` - introduced: - `commitAssistantTurnAndLog(...)` 2. Rewired `assistantService` deep-lane to use new adapter (behavior-preserving): - same append-to-session semantics; - same session persistence behavior when session exists; - same `assistant_message_processed` log envelope and event type. 3. Added focused unit tests: - `assistantTurnCommitRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.15): 1. Extracted deep-lane pre-packaging context assembly from `assistantService` into dedicated module: - `assistantDeepTurnPrePackagingContext.ts` - centralized: - dropped intent segments extraction; - analysis context projection for contracts; - debug route projection; - resolved execution state projection; - safe assistant reply base sanitization. 2. Rewired `assistantService` deep-lane to consume `buildAssistantDeepTurnPrePackagingContext(...)` (behavior-preserving). 3. Added focused unit tests: - `assistantDeepTurnPrePackagingContext.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.16): 1. Extracted deep-lane success response envelope assembly from `assistantService` into dedicated builder: - `assistantDeepTurnResponseBuilder.ts` - introduced: - `buildAssistantDeepTurnSuccessResponse(...)` 2. Rewired `assistantService` deep-lane to return response via new builder (behavior-preserving). 3. Added focused unit tests: - `assistantDeepTurnResponseBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.17): 1. Extracted deep-lane composition assembly from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnCompositionRuntimeAdapter.ts` - introduced: - `buildAssistantDeepTurnComposition(...)` 2. Centralized composition-time derivations (behavior-preserving): - `focusDomainHint` from followup usage + investigation state; - `questionTypeClass` via `resolveQuestionType(...)`; - period presence signals from company anchors/normalization payload; - downstream `composeAssistantAnswer(...)` call wiring. 3. Rewired `assistantService` deep-lane to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.18): 1. Extracted deep-lane guard runtime pipeline from `assistantService` into dedicated adapter: - `assistantDeepTurnGuardRuntimeAdapter.ts` - introduced: - `applyAssistantDeepTurnRetrievalGuards(...)` - `applyAssistantDeepTurnGroundingEligibility(...)` 2. Centralized and isolated runtime sequence (behavior-preserving): - polarity guard on retrieval results; - targeted evidence acquisition; - evidence admissibility gate; - grounded-answer eligibility evaluation + grounding status overlay. 3. Rewired `assistantService` deep-lane to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnGuardRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.19): 1. Extracted deep-lane retrieval execution loop from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnRetrievalRuntimeAdapter.ts` - introduced: - `executeAssistantDeepTurnRetrievalPlan(...)` 2. Centralized retrieval runtime behavior (behavior-preserving): - skipped/no-route call record generation; - sequential route execution with temporal hint propagation; - raw result capture; - failed-route fallback normalization with stable error envelope. 3. Rewired `assistantService` deep-lane to consume retrieval adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.20): 1. Extracted deep-lane execution-plan assembly/enforcement from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnPlanRuntimeAdapter.ts` - introduced: - `buildAssistantDeepTurnExecutionPlan(...)` 2. Centralized planning runtime sequence (behavior-preserving): - requirement extraction by fragment; - execution plan build from route summary; - RBP route-plan enforcement; - FA route-plan enforcement; - temporal hint overlay; - polarity hint overlay. 3. Rewired `assistantService` deep-lane to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnPlanRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPlanRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.21): 1. Extracted deep-lane pre-guard runtime context assembly from `assistantService` into dedicated adapter: - `assistantDeepTurnContextRuntimeAdapter.ts` - introduced: - `buildAssistantDeepTurnRuntimeContext(...)` 2. Centralized context runtime sequence (behavior-preserving): - company anchors resolution; - initial business-scope alignment; - P0 domain inference + domain whitelist gating for guard focus; - temporal guard resolution with runtime analysis context; - domain polarity guard resolution; - claim-bound anchors resolution; - live business-scope resolution with followup flag; - normalized live temporal hint projection. 3. Rewired `assistantService` deep-lane to consume context adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnContextRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPlanRuntimeAdapter.test.ts` - `assistantDeepTurnContextRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.22): 1. Extracted deep-lane post-retrieval grounding runtime orchestration from `assistantService` into dedicated adapter: - `assistantDeepTurnGroundingRuntimeAdapter.ts` - introduced: - `runAssistantDeepTurnGroundingRuntime(...)` 2. Centralized grounding/runtime sequence (behavior-preserving): - RBP live-route audit projection; - FA live-route audit projection; - coverage+grounding pipeline execution; - grounded-answer eligibility overlay on base grounding check. 3. Rewired `assistantService` deep-lane to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPlanRuntimeAdapter.test.ts` - `assistantDeepTurnContextRuntimeAdapter.test.ts` - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.23): 1. Extracted deep-lane packaging orchestration block from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnPackagingRuntimeAdapter.ts` - introduced: - `runAssistantDeepTurnPackagingRuntime(...)` 2. Centralized packaging/runtime sequence (behavior-preserving): - pre-packaging context assembly; - investigation-state snapshot build/persist; - deep-turn packaging input assembly; - deep-turn packaging output projection (`safeAssistantReply`, debug payload, assistant item, processed log details). 3. Rewired `assistantService` deep-lane to consume packaging runtime adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPlanRuntimeAdapter.test.ts` - `assistantDeepTurnContextRuntimeAdapter.test.ts` - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.24): 1. Extracted deep-lane finalization/response tail from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnFinalizeRuntimeAdapter.ts` - introduced: - `finalizeAssistantDeepTurn(...)` 2. Centralized finalization runtime sequence (behavior-preserving): - assistant turn commit + processed-event logging; - deep-turn API success response assembly from committed conversation state. 3. Rewired `assistantService` deep-lane to consume finalization adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantDeepTurnFinalizeRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 assembler/adapter pack passed: - `assistantOrchestrationContracts.test.ts` - `assistantOrchestrationRuntimeAdapter.test.ts` - `assistantAnswerPackageBuilder.test.ts` - `assistantCoverageGrounding.test.ts` - `assistantQueryPlanning.test.ts` - `assistantEvidenceBundleAssembler.test.ts` - `assistantDebugPayloadAssembler.test.ts` - `assistantMessageLogAssembler.test.ts` - `assistantContractsBundleAssembler.test.ts` - `assistantDeepResponseAssembler.test.ts` - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnInputBuilder.test.ts` - `assistantInvestigationStateRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` - `assistantDeepTurnPrePackagingContext.test.ts` - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnGuardRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPlanRuntimeAdapter.test.ts` - `assistantDeepTurnContextRuntimeAdapter.test.ts` - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantDeepTurnFinalizeRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.25): 1. Extracted address-lane finalization/response tail from `assistantService` into dedicated runtime adapter: - `assistantAddressTurnFinalizeRuntimeAdapter.ts` - introduced: - `finalizeAssistantAddressTurn(...)` 2. Centralized address finalization runtime sequence (behavior-preserving): - assistant item creation for address lane; - structured `assistant_message_address` processed-event payload build; - turn commit/persist/log via shared commit runtime adapter; - API success response assembly from committed conversation state. 3. Rewired `assistantService` address-lane finalize path to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantAddressTurnFinalizeRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted Stage 2 adapter/finalization pack passed: - `assistantAddressTurnFinalizeRuntimeAdapter.test.ts` - `assistantDeepTurnFinalizeRuntimeAdapter.test.ts` - `assistantTurnCommitRuntimeAdapter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.26): 1. Extracted living-chat finalization/response tail from `assistantService` into dedicated runtime adapter: - `assistantLivingChatTurnFinalizeRuntimeAdapter.ts` - introduced: - `finalizeAssistantLivingChatTurn(...)` 2. Centralized living-chat finalization runtime sequence (behavior-preserving): - assistant item creation for chat lane; - structured `assistant_message_chat` processed-event payload build; - turn commit/persist/log via shared commit runtime adapter; - API success response assembly from committed conversation state. 3. Rewired `assistantService` `tryHandleLivingChat(...)` finalize path to consume adapter output (behavior-preserving). 4. Added focused unit tests: - `assistantLivingChatTurnFinalizeRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep finalize pack passed: - `assistantLivingChatTurnFinalizeRuntimeAdapter.test.ts` - `assistantAddressTurnFinalizeRuntimeAdapter.test.ts` - `assistantDeepTurnFinalizeRuntimeAdapter.test.ts` - `assistantLivingChatMode.test.ts` - `assistantLivingRouter.test.ts` 3. Additional safety regressions passed: - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantMcpRuntimeBridge.test.ts` - `assistantAddressFollowupContext.test.ts` Implemented in current pass (Phase 2.27): 1. Extracted living-chat runtime orchestration branch from `assistantService` into dedicated runtime adapter: - `assistantLivingChatRuntimeAdapter.ts` - introduced: - `runAssistantLivingChatRuntime(...)` 2. Centralized living-chat runtime branch sequence (behavior-preserving): - deterministic capability + safety refusal branch; - deterministic data-scope contract branch (with live probe projection); - deterministic organization-boundary and scope-selection branches; - deterministic operational-boundary and capability-contract branches; - LLM chat branch with script-guard + grounding-guard post-processing. 3. Rewired `assistantService` `tryHandleLivingChat(...)` to consume runtime adapter output and keep existing chat finalization adapter path unchanged. 4. Added focused unit tests: - `assistantLivingChatRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/chat followup pack passed: - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantLivingChatMode.test.ts` - `assistantLivingRouter.test.ts` - `assistantAddressFollowupContext.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.28): 1. Extracted address-lane retry orchestration branch from `assistantService` into dedicated runtime adapter: - `assistantAddressLaneRuntimeAdapter.ts` - introduced: - `runAssistantAddressLaneRuntime(...)` 2. Centralized address retry/runtime branch sequence (behavior-preserving): - contextual-first execution when followup context is preferred; - primary execution without followup context; - optional contextual fallback when context exists but is not preferred; - retry with raw user message for retryable limited results; - deterministic fallback to pending limited result when retry does not improve outcome. 3. Rewired `assistantService` address lane execution path to consume retry adapter output and preserve existing address finalization contract. 4. Added focused unit tests: - `assistantAddressLaneRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address followup pack passed: - `assistantAddressLaneRuntimeAdapter.test.ts` - `assistantAddressFollowupContext.test.ts` - `assistantLivingChatMode.test.ts` - `assistantLivingRouter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.29): 1. Extracted address orchestration bootstrap block from `assistantService` into dedicated runtime adapter: - `assistantAddressOrchestrationRuntimeAdapter.ts` - introduced: - `buildAssistantAddressOrchestrationRuntime(...)` 2. Centralized address orchestration bootstrap sequence (behavior-preserving): - LLM predecompose stage or deterministic fallback contract when feature is disabled; - effective address input message resolution; - followup carryover context resolution; - orchestration/tool-gate decision resolution; - dialog continuation contract projection into runtime meta; - living mode decision projection for chat fallback. 3. Rewired `assistantService` address pre-lane bootstrap path to consume orchestration runtime adapter output. 4. Added focused unit tests: - `assistantAddressOrchestrationRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address followup pack passed: - `assistantAddressOrchestrationRuntimeAdapter.test.ts` - `assistantAddressLaneRuntimeAdapter.test.ts` - `assistantAddressFollowupContext.test.ts` - `assistantLivingChatMode.test.ts` - `assistantLivingRouter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` 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` Implemented in current pass (Phase 2.34): 1. Extracted top-level address branch orchestration from `assistantService` into dedicated runtime adapter: - `assistantAddressRuntimeAdapter.ts` - introduced: - `runAssistantAddressRuntime(...)` 2. Centralized full address-branch control flow (behavior-preserving): - address bootstrap orchestration stage; - tool-gate skip/chat fallback stage; - lane execution/retry stage with analysis-date hint propagation; - address finalize stage projection with retry audit merge. 3. Rewired `assistantService` address branch to a single runtime adapter invocation and preserved `addressRuntimeMetaForDeep` propagation contract. 4. Added focused unit tests: - `assistantAddressRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressRuntimeAdapter.test.ts` - `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` Implemented in current pass (Phase 2.35): 1. Extracted address-lane response-tail (debug enrichment + finalize projection) from `assistantService` into dedicated runtime adapter: - `assistantAddressLaneResponseRuntimeAdapter.ts` - introduced: - `runAssistantAddressLaneResponseRuntime(...)` 2. Centralized address response-tail sequence (behavior-preserving): - reply sanitization and structured address debug payload assembly; - followup-offer projection + known/active organization debug enrichment; - address turn finalization through existing finalize adapter contract. 3. Rewired `assistantService` `finalizeAddressLaneResponse(...)` closure to consume response runtime adapter output. 4. Added focused unit tests: - `assistantAddressLaneResponseRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `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` Implemented in current pass (Phase 2.36): 1. Extracted living-chat handler branch (`tryHandleLivingChat`) from `assistantService` into dedicated runtime adapter: - `assistantLivingChatHandlerRuntimeAdapter.ts` - introduced: - `tryHandleAssistantLivingChatRuntime(...)` 2. Centralized living-chat handler sequence (behavior-preserving): - living-chat runtime invocation (deterministic/LLM guard chain); - chat finalization invocation for `assistant_message_chat` response path; - warn-log fallback path for runtime failures. 3. Rewired `assistantService` `tryHandleLivingChat(...)` closure to consume handler runtime adapter output. 4. Added focused unit tests: - `assistantLivingChatHandlerRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `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` Implemented in current pass (Phase 2.37): 1. Extracted living-chat LLM call/build block from `assistantService` into dedicated runtime adapter: - `assistantLivingChatLlmRuntimeAdapter.ts` - introduced: - `runAssistantLivingChatLlmRuntime(...)` 2. Centralized living LLM execution sequence (behavior-preserving): - context window assembly from session history; - canon excerpt loading and prompt composition; - model/token selection with guard clamp; - output sanitization with stable fallback. 3. Rewired `assistantService` `tryHandleLivingChat(...)` closure to consume the new LLM runtime adapter. 4. Added focused unit tests: - `assistantLivingChatLlmRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.38): 1. Internalized living-chat prompt/context builders into `assistantLivingChatLlmRuntimeAdapter`: - removed external builder dependencies from runtime input contract; - centralized compacting + clipping + context/prompt projection directly in adapter. 2. Simplified `assistantService` living LLM call wiring: - removed `buildLivingChatContextWindow` / `buildLivingChatPrompt` injection from `executeLlmChat`. 3. Updated focused tests for adapter-owned prompt assembly: - `assistantLivingChatLlmRuntimeAdapter.test.ts` now verifies context carryover and user-message prompt shape. 4. Applied cleanup inside `assistantService` after the wiring simplification: - removed dead local living prompt/context helper functions. Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.39): 1. Extracted user-turn bootstrap sequence from `assistantService` into dedicated runtime adapter: - `assistantUserTurnBootstrapRuntimeAdapter.ts` - introduced: - `runAssistantUserTurnBootstrapRuntime(...)` 2. Centralized user-turn bootstrap flow (behavior-preserving): - session ensure + user message normalization/repair; - user item append + session persistence; - runtime analysis context projection. 3. Rewired `assistantService.handleMessage(...)` to consume bootstrap runtime output and preserve downstream `questionId` contract usage. 4. Added focused unit tests: - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.40): 1. Extracted address-lane attempt bridge (`runAddressLaneAttempt`) from `assistantService` into dedicated runtime adapter: - `assistantAddressLaneAttemptRuntimeAdapter.ts` - introduced: - `runAssistantAddressLaneAttemptRuntime(...)` 2. Centralized address-lane attempt handoff logic (behavior-preserving): - organization-scoped followup context merge; - fallback to plain lane attempt when scoped context is unavailable; - strict propagation of analysis-date hint into `addressQueryService.tryHandle(...)`. 3. Rewired `assistantService` to consume lane-attempt runtime adapter. 4. Added focused unit tests: - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.41): 1. Extracted living-chat attempt bridge (`tryHandleLivingChat`) from `assistantService` into dedicated runtime adapter: - `assistantLivingChatAttemptRuntimeAdapter.ts` - introduced: - `runAssistantLivingChatAttemptRuntime(...)` 2. Centralized living-chat attempt handoff logic (behavior-preserving): - delegated handler invocation (`tryHandleAssistantLivingChatRuntime(...)`); - delegated LLM call bridge (`runAssistantLivingChatLlmRuntime(...)`) behind unified `executeLlmChat` contract; - preserved all guard, scope and session finalization hooks. 3. Rewired `assistantService` to consume living-chat attempt runtime adapter. 4. Added focused unit tests: - `assistantLivingChatAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.42): 1. Extracted address-lane response attempt bridge (`finalizeAddressLaneResponse`) from `assistantService` into dedicated runtime adapter: - `assistantAddressLaneResponseAttemptRuntimeAdapter.ts` - introduced: - `runAssistantAddressLaneResponseAttemptRuntime(...)` 2. Centralized address-lane response handoff logic (behavior-preserving): - delegated response runtime invocation (`runAssistantAddressLaneResponseRuntime(...)`); - preserved followup-offer/debug payload and session finalization contract wiring. 3. Rewired `assistantService` to consume address-lane response attempt runtime adapter. 4. Added focused unit tests: - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.43): 1. Extracted deep-analysis bridge (`deepTurnAnalysisRuntime` wiring) from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.ts` - introduced: - `runAssistantDeepTurnAnalysisAttemptRuntime(...)` 2. Centralized deep-analysis handoff logic (behavior-preserving): - context/plan/retrieval/guard/grounding/composition chain wiring moved behind a single runtime boundary; - preserved feature flags and all existing local helper hooks (`extractRequirements`, route enforcement, coverage/grounding evaluators, audits). 3. Rewired `assistantService` to consume deep-analysis attempt runtime adapter. 4. Added focused unit tests: - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.44): 1. Extracted deep-response bridge (`deepTurnResponseRuntime` wiring) from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnResponseAttemptRuntimeAdapter.ts` - introduced: - `runAssistantDeepTurnResponseAttemptRuntime(...)` 2. Centralized deep-response handoff logic (behavior-preserving): - mapping from deep-analysis runtime output into response/packaging/finalization runtime contract moved behind a single runtime boundary; - preserved existing debug/state persistence hooks and session finalization callbacks. 3. Rewired `assistantService` to consume deep-response attempt runtime adapter. 4. Added focused unit tests: - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.45): 1. Extracted full deep-turn chain (`normalization -> analysis -> response`) from `assistantService` into dedicated runtime adapter: - `assistantDeepTurnAttemptRuntimeAdapter.ts` - introduced: - `runAssistantDeepTurnAttemptRuntime(...)` 2. Centralized deep-turn orchestration handoff (behavior-preserving): - unified composition over existing attempt adapters (`Normalization`, `Analysis`, `Response`); - preserved followup binding, runtime context propagation, response finalization hooks and investigation-state persistence callbacks. 3. Rewired `assistantService` to consume a single deep-turn runtime adapter call. 4. Added focused unit tests: - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.46): 1. Activated full address-turn attempt runtime boundary inside `assistantService`: - rewired address handling call-site to `runAssistantAddressAttemptRuntime(...)`; - removed local inline closures for lane-attempt, lane-response, and living-chat handoff wiring from `handleMessage`. 2. Finalized and type-hardened address attempt adapter contract: - `assistantAddressAttemptRuntimeAdapter.ts` - aligned `logEvent` and `messageIdFactory` contract typing to runtime expectations. 3. Added focused unit tests: - `assistantAddressAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.47): 1. Extracted top-level assistant turn orchestration (`bootstrap -> address attempt -> deep attempt`) into dedicated runtime adapter: - `assistantTurnAttemptRuntimeAdapter.ts` - introduced: - `runAssistantTurnAttemptRuntime(...)` 2. Rewired `assistantService.handleMessage` to use single top-level turn runtime boundary (behavior-preserving): - user-turn bootstrap remains delegated to `assistantUserTurnBootstrapRuntime`; - address and deep attempt runtimes remain unchanged, but orchestration/early-return logic moved out of service body. 3. Added focused unit tests: - `assistantTurnAttemptRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.48): 1. Extracted turn-level runtime input assembly from `assistantService` into dedicated builder module: - `assistantTurnRuntimeInputBuilder.ts` - introduced: - `buildAssistantUserTurnBootstrapRuntimeInput(...)` - `buildAssistantAddressAttemptRuntimeInput(...)` - `buildAssistantDeepTurnAttemptRuntimeInput(...)` 2. Rewired `assistantService.handleMessage` to consume builder outputs (behavior-preserving): - moved bulky dependency mapping for bootstrap/address/deep attempts out of service body; - preserved existing runtime adapters and route behavior. 3. Added focused unit tests: - `assistantTurnRuntimeInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.49): 1. Extracted turn runtime dependency factory from `assistantService` into dedicated adapter: - `assistantTurnRuntimeDepsAdapter.ts` - introduced: - `buildAssistantTurnRuntimeDeps(...)` 2. Rewired `assistantService.handleMessage` to construct runtime deps via adapter (behavior-preserving): - service-level wrappers for `sessions`, `sessionLogger`, `normalizerService`, `dataLayer`, `addressQueryService` moved under deps-adapter boundary; - flags/defaults/helpers remain unchanged semantically and are passed as structured groups (`flags`, `defaults`, `helpers`). 3. Added focused unit tests: - `assistantTurnRuntimeDepsAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` Implemented in current pass (Phase 2.50): 1. Extracted organization-scope runtime logic from `assistantService` into dedicated adapter: - `assistantOrganizationScopeRuntimeAdapter.ts` - introduced: - `resolveSessionOrganizationScopeContextRuntime(...)` - `mergeFollowupContextWithOrganizationScopeRuntime(...)` 2. Rewired `assistantService` scope helpers to delegate through the adapter (behavior-preserving): - `resolveSessionOrganizationScopeContext(...)` now uses runtime adapter with existing extraction/scoring/sanitization helpers; - `mergeFollowupContextWithOrganizationScope(...)` now uses runtime adapter while preserving existing normalization/toNonEmpty semantics. 3. Added focused unit tests: - `assistantOrganizationScopeRuntimeAdapter.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantUserTurnBootstrapRuntimeAdapter.test.ts` - `assistantLivingChatLlmRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.51): 1. Extracted living-chat attempt input assembly from `assistantAddressAttemptRuntimeAdapter` into dedicated builder: - `assistantLivingChatAttemptInputBuilder.ts` - introduced: - `buildAssistantLivingChatAttemptRuntimeInput(...)` 2. Rewired `assistantAddressAttemptRuntimeAdapter` to consume the new builder (behavior-preserving): - moved inline living-chat payload mapping (including `traceIdFactory` derivation and scope/meta wiring) behind a single input-builder boundary. 3. Added focused unit tests: - `assistantLivingChatAttemptInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantLivingChatAttemptInputBuilder.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.52 + 2.53 + 2.54 + 2.55): 1. Removed remaining inline address-lane response input assembly from `assistantAddressAttemptRuntimeAdapter`: - rewired `finalizeAddressLaneResponse` to `buildAssistantAddressLaneResponseAttemptRuntimeInput(...)`. 2. Added dedicated lane-attempt input builder and rewired adapter call-site: - `assistantAddressLaneAttemptInputBuilder.ts` - introduced: - `buildAssistantAddressLaneAttemptRuntimeInput(...)` 3. Added dedicated address-runtime input builder and rewired final runtime invocation: - `assistantAddressRuntimeInputBuilder.ts` - introduced: - `buildAssistantAddressRuntimeInput(...)` 4. Added focused builder tests: - `assistantAddressLaneResponseAttemptInputBuilder.test.ts` - `assistantAddressLaneAttemptInputBuilder.test.ts` - `assistantAddressRuntimeInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressLaneResponseAttemptInputBuilder.test.ts` - `assistantAddressLaneAttemptInputBuilder.test.ts` - `assistantAddressRuntimeInputBuilder.test.ts` - `assistantLivingChatAttemptInputBuilder.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.56 + 2.57 + 2.58 + 2.59 + 2.60): 1. Extracted deep-turn attempt input assembly into dedicated builder: - `assistantDeepTurnAttemptInputBuilder.ts` - introduced: - `buildAssistantDeepTurnNormalizationRuntimeInput(...)` - `buildAssistantDeepTurnAnalysisAttemptRuntimeInput(...)` - `buildAssistantDeepTurnResponseAttemptRuntimeInput(...)` 2. Rewired `assistantDeepTurnAttemptRuntimeAdapter` to consume deep-turn attempt builder outputs (behavior-preserving): - removed inline normalization/analysis/response attempt payload mapping from adapter body. 3. Extracted deep-turn response runtime input mapping into dedicated builder: - `assistantDeepTurnResponseRuntimeInputBuilder.ts` - introduced: - `buildAssistantDeepTurnResponseRuntimeInput(...)` 4. Rewired `assistantDeepTurnResponseAttemptRuntimeAdapter` to consume response runtime input builder (behavior-preserving): - moved deep-analysis -> response-runtime field projection behind a single builder boundary. 5. Extracted deep-turn analysis-attempt stage input wiring into dedicated builder: - `assistantDeepTurnAnalysisAttemptInputBuilder.ts` - introduced: - `buildAssistantDeepTurnAnalysisRuntimeInput(...)` - `buildAssistantDeepTurnContextRuntimeInput(...)` - `buildAssistantDeepTurnExecutionPlanRuntimeInput(...)` - `buildAssistantDeepTurnRetrievalRuntimeInput(...)` - `buildAssistantDeepTurnGuardRuntimeInput(...)` - `buildAssistantDeepTurnGroundingRuntimeInput(...)` - `buildAssistantDeepTurnCompositionRuntimeInput(...)` 6. Rewired `assistantDeepTurnAnalysisAttemptRuntimeAdapter` to build `runAssistantDeepTurnAnalysisRuntime(...)` contract via builder (behavior-preserving). 7. Added focused builder tests: - `assistantDeepTurnAttemptInputBuilder.test.ts` - `assistantDeepTurnResponseRuntimeInputBuilder.test.ts` - `assistantDeepTurnAnalysisAttemptInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantDeepTurnAttemptInputBuilder.test.ts` - `assistantDeepTurnResponseRuntimeInputBuilder.test.ts` - `assistantDeepTurnAnalysisAttemptInputBuilder.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptInputBuilder.test.ts` - `assistantAddressLaneAttemptInputBuilder.test.ts` - `assistantAddressLaneResponseAttemptInputBuilder.test.ts` - `assistantAddressRuntimeInputBuilder.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.61 + 2.62 + 2.63 + 2.64): 1. Added dedicated runtime input builder for address lane response runtime: - `assistantAddressLaneResponseRuntimeInputBuilder.ts` - introduced: - `buildAssistantAddressLaneResponseRuntimeInput(...)` 2. Rewired `assistantAddressLaneResponseAttemptRuntimeAdapter` to consume the new builder (behavior-preserving): - removed inline mapping from attempt input to response runtime input. 3. Added dedicated runtime input builders for living-chat attempt orchestration: - `assistantLivingChatAttemptRuntimeInputBuilder.ts` - introduced: - `buildAssistantLivingChatLlmRuntimeInput(...)` - `buildAssistantLivingChatHandlerRuntimeInput(...)` 4. Rewired `assistantLivingChatAttemptRuntimeAdapter` to consume living-chat runtime input builders (behavior-preserving): - `buildExecuteLlmChat(...)` now delegates llm payload assembly via builder; - top-level living-chat handler invocation now uses builder payload. 5. Added focused builder tests: - `assistantAddressLaneResponseRuntimeInputBuilder.test.ts` - `assistantLivingChatAttemptRuntimeInputBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantAddressLaneResponseRuntimeInputBuilder.test.ts` - `assistantLivingChatAttemptRuntimeInputBuilder.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptInputBuilder.test.ts` - `assistantDeepTurnAnalysisAttemptInputBuilder.test.ts` - `assistantDeepTurnResponseRuntimeInputBuilder.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.65 + 2.66 + 2.67 + 2.68): 1. Added dedicated turn-attempt input builder: - `assistantTurnAttemptInputBuilder.ts` - introduced: - `buildAssistantTurnAttemptAddressRuntimeInput(...)` - `buildAssistantTurnAttemptDeepRuntimeInput(...)` 2. Rewired `assistantTurnAttemptRuntimeAdapter` to consume turn-attempt builder outputs (behavior-preserving): - removed inline payload assembly for `runAddressAttemptRuntime(...)` and `runDeepTurnAttemptRuntime(...)`. 3. Added dedicated query-options builder for address lane attempt: - `assistantAddressLaneAttemptQueryOptionsBuilder.ts` - introduced: - `resolveAssistantAddressLaneAttemptFollowupContext(...)` - `buildAssistantAddressLaneAttemptQueryOptions(...)` 4. Rewired `assistantAddressLaneAttemptRuntimeAdapter` to consume query-options builder (behavior-preserving): - moved followup-context extraction and options branching behind builder helpers. 5. Added focused builder tests: - `assistantTurnAttemptInputBuilder.test.ts` - `assistantAddressLaneAttemptQueryOptionsBuilder.test.ts` Validation: 1. `npm run build` passed. 2. Targeted living/address/deep followup pack passed: - `assistantTurnAttemptInputBuilder.test.ts` - `assistantAddressLaneAttemptQueryOptionsBuilder.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptRuntimeAdapter.test.ts` - `assistantAddressLaneAttemptInputBuilder.test.ts` - `assistantAddressLaneResponseRuntimeInputBuilder.test.ts` - `assistantLivingChatAttemptRuntimeInputBuilder.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantAddressRuntimeAdapter.test.ts` - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantLivingChatRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptInputBuilder.test.ts` - `assistantDeepTurnAnalysisAttemptInputBuilder.test.ts` - `assistantDeepTurnResponseRuntimeInputBuilder.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantOrganizationScopeRuntimeAdapter.test.ts` - `assistantWave10SettlementCorrectiveRegression.test.ts` - `assistantLivingChatMode.test.ts` Implemented in current pass (Phase 2.69 + 2.70 + 2.71 + 2.72): 1. Finalized strict deps typing in turn runtime input builder: - `assistantTurnRuntimeInputBuilder.ts` - completed generic `AssistantTurnRuntimeBuilderDeps` wiring through address/deep runtime input contracts; - removed residual weak casts from builder field projection. 2. Hardened turn runtime deps adapter contracts: - `assistantTurnRuntimeDepsAdapter.ts` - typed sessions/normalizer/data-layer/address-query/chat/log inputs directly from `AssistantTurnRuntimeBuilderDeps` contract slices; - removed `unknown`/`any` wrappers from adapter mapping while preserving compatible handler signatures for optional args. 3. Preserved behavior of turn orchestration chain under stricter typing: - bootstrap -> address attempt -> deep attempt flow remains unchanged at runtime. Validation: 1. `npm run build` passed. 2. Targeted turn/deps regression pack passed: - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` - `assistantAddressAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.73 + 2.74 + 2.75 + 2.76): 1. Removed remaining unsafe casts in address->living-chat bridge: - `assistantAddressAttemptRuntimeAdapter.ts` - replaced `mergeKnownOrganizations` dependency type with living-chat compatible contract; - removed `as any` cast for `mergeKnownOrganizations` and removed final object cast to `RunAssistantLivingChatAttemptRuntimeInput`. 2. Added explicit mode-decision normalization before living-chat runtime handoff: - mapped untyped `modeDecision` to typed `{ mode: string | null; reason: string | null }` contract. 3. Preserved behavior of address lane + living-chat fallback under stricter typing: - runtime flow unchanged, only contract hardening. Validation: 1. `npm run build` passed. 2. Targeted address/living/turn regression pack passed: - `assistantAddressAttemptRuntimeAdapter.test.ts` - `assistantLivingChatAttemptRuntimeAdapter.test.ts` - `assistantLivingChatHandlerRuntimeAdapter.test.ts` - `assistantTurnRuntimeInputBuilder.test.ts` - `assistantTurnRuntimeDepsAdapter.test.ts` - `assistantTurnAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.77 + 2.78 + 2.79 + 2.80): 1. Removed unsafe casts from address lane response runtime finalization path: - `assistantAddressLaneResponseRuntimeAdapter.ts` - introduced explicit normalization for: - `replyType` (fallback-safe); - `carryoverMeta` extraction from followup context; - `llmPreDecomposeMeta` sparse contract mapping; - address debug payload handoff into finalize stage. 2. Hardened deep response runtime bridge to packaging stage: - `assistantDeepTurnResponseRuntimeAdapter.ts` - replaced `as any` payload handoff with typed normalizers for: - execution plan; - runtime analysis context; - business scope resolution; - record/audit buckets; - address-runtime meta. 3. Updated deep response runtime input builder to pass typed composition contract directly: - `assistantDeepTurnResponseRuntimeInputBuilder.ts` - removed composition cast in analysis->response mapping. Validation: 1. `npm run build` passed. 2. Targeted response/address/deep pack passed: - `assistantAddressLaneResponseRuntimeAdapter.test.ts` - `assistantAddressLaneResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnResponseRuntimeInputBuilder.test.ts` - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.81 + 2.82 + 2.83 + 2.84): 1. Removed remaining unsafe casts from deep analysis-attempt input builder: - `assistantDeepTurnAnalysisAttemptInputBuilder.ts` - added typed adapters/normalizers for: - temporal/polarity/claim-bound resolver bridges; - focus-domain narrowing for guard pipeline; - company-anchor and primary-period normalization; - runtime callback mapping (`context -> plan -> retrieval -> guard -> grounding -> composition`) without `as any`. 2. Hardened deep analysis runtime contracts: - `assistantDeepTurnAnalysisRuntimeAdapter.ts` - replaced broad unknown execution-plan/guard/grounding signatures with concrete typed contracts (`AssistantExecutionPlanItem`, guard and grounding slices). 3. Hardened deep context contracts for guard chain compatibility: - `assistantDeepTurnContextRuntimeAdapter.ts` - aligned temporal/polarity/claim-bound outputs with concrete audits; - aligned `liveTemporalHint` with retrieval runtime contract. 4. Removed remaining unsafe casts from grounding and composition runtime adapters: - `assistantDeepTurnGroundingRuntimeAdapter.ts` - `assistantDeepTurnCompositionRuntimeAdapter.ts` - replaced generic cast-based defaults with typed defaults and normalized company-anchor handoff into answer composer. Validation: 1. `npm run build` passed. 2. Targeted deep analysis/grounding/composition pack passed: - `assistantDeepTurnAnalysisAttemptInputBuilder.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.85 + 2.86 + 2.87 + 2.88): 1. Removed the final `as any` from backend source deep-turn packaging path: - `assistantDeepTurnPackaging.ts` - switched assistant-item debug handoff to strongly typed payload contract. 2. Hardened debug payload contract at assembly boundary: - `assistantDebugPayloadAssembler.ts` - `buildDeepAnalysisDebugPayload(...)` now returns `AssistantDebugPayload` contract. 3. Propagated typed debug payload through deep-turn runtime chain: - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnResponseRuntimeAdapter.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.ts` - `assistantDeepTurnAttemptRuntimeAdapter.ts` - aligned `debug` field contracts to `AssistantDebugPayload` and fixed generic runtime callback typing so `ResponseType` remains preserved end-to-end. 4. Preserved behavior: - no runtime logic change; only contract tightening for debug payload propagation and generic signature alignment. Validation: 1. `npm run build` passed. 2. Targeted deep packaging/response chain pack passed: - `assistantDeepTurnPackaging.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.89 + 2.90 + 2.91 + 2.92): 1. Hardened deep-turn response envelope contract: - `assistantDeepTurnResponseBuilder.ts` - removed weak `debug` union (`AssistantDebugPayload | Record`); - response builder now accepts and propagates `AssistantDebugPayload` strictly. 2. Hardened deep-turn finalize runtime contract: - `assistantDeepTurnFinalizeRuntimeAdapter.ts` - aligned finalize input to strict `AssistantDebugPayload` for `debug`. 3. Preserved behavior: - no runtime logic changes; only stricter contract enforcement for debug payload type at finalize/response boundary. Validation: 1. `npm run build` passed. 2. Targeted deep finalize/response pack passed: - `assistantDeepTurnResponseBuilder.test.ts` - `assistantDeepTurnFinalizeRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.93 + 2.94 + 2.95 + 2.96): 1. Introduced shared followup-usage contract and helper: - `assistantFollowupUsage.ts` - added: - `AssistantFollowupUsage` - `isAssistantFollowupApplied(...)` 2. Replaced weak `unknown` followup usage contracts across deep-turn chain: - `assistantDeepTurnNormalizationRuntimeAdapter.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.ts` - `assistantDeepTurnContextRuntimeAdapter.ts` - `assistantDeepTurnCompositionRuntimeAdapter.ts` - `assistantDeepTurnAttemptInputBuilder.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.ts` - `assistantDeepTurnInputBuilder.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnPackaging.ts` 3. Removed inline followup casts: - switched `Boolean((... as { applied?: unknown })?.applied)` style checks to shared helper usage. 4. Preserved behavior: - no logic changes, only contract normalization and reuse of a single applied-check helper. Validation: 1. `npm run build` passed. 2. Targeted deep followup chain pack passed: - `assistantDeepTurnNormalizationRuntimeAdapter.test.ts` - `assistantDeepTurnContextRuntimeAdapter.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptInputBuilder.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantDeepTurnPackaging.test.ts` Implemented in current pass (Phase 2.97 + 2.98 + 2.99 + 2.100): 1. Tightened deep-turn response runtime input contracts for analysis context and address meta: - `assistantDeepTurnResponseRuntimeAdapter.ts` - `runtimeAnalysisContext` now typed with explicit fields and optional `snapshot_mode`; - `addressRuntimeMetaForDeep` now typed via packaging contract. 2. Propagated the tightened types through deep response attempt chain: - `assistantDeepTurnResponseAttemptRuntimeAdapter.ts` - `assistantDeepTurnAttemptRuntimeAdapter.ts` 3. Preserved behavior: - no runtime logic changes; only type alignment for response attempt inputs. Validation: 1. `npm run build` passed. 2. Targeted deep response attempt pack passed: - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnAttemptInputBuilder.test.ts` Implemented in current pass (Phase 2.101 + 2.102 + 2.103 + 2.104): 1. Tightened company-anchors and business-scope contracts in deep analysis runtime: - `assistantDeepTurnContextRuntimeAdapter.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.ts` - `companyAnchors` now typed as `CompanyAnchorSet | null`; - `businessScopeResolution` now typed as `AssistantBusinessScopeResolution`. 2. Aligned composition runtime input to accept typed anchors: - `assistantDeepTurnAnalysisRuntimeAdapter.ts` - `runCompositionRuntime` now expects `CompanyAnchorSet | null`. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. `npm run build` passed. 2. Targeted deep analysis pack passed: - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnCompositionRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.105 + 2.106 + 2.107 + 2.108): 1. Hardened raw retrieval normalization without changing output: - `retrievalResultNormalizer.ts` - added `normalizeRawRetrievalResult(...)` to avoid unsafe raw casting; - added `normalizeNumberRecord(...)` to replace `Record` casts for lifecycle distributions. 2. Preserved behavior: - no logic changes; only safer normalization of raw payload shapes. Validation: 1. `npm run build` passed. 2. Targeted retrieval normalization pack passed: - `retrievalResultEvidenceEnrichment.test.ts` - `retrievalProblemUnitDualPayload.test.ts` - `retrievalLifecycleRuntimeRollout.test.ts` - `retrievalGraphRuntimeDualPayload.test.ts` Implemented in current pass (Phase 2.109 + 2.110 + 2.111 + 2.112): 1. Tightened plan-audit and live-route audit typing for deep grounding: - `assistantDeepTurnPlanRuntimeAdapter.ts` - `assistantDeepTurnGroundingRuntimeAdapter.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.ts` - `rbpPlanAudit` / `faPlanAudit` now use `Record | null` contract; - live route audits now typed to `RbpLiveRouteAuditDebug | null` / `FaLiveRouteAuditDebug | null`; - grounded eligibility guard now typed to `GroundedAnswerEligibilityGuardDebug`. 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. `npm run build` passed. 2. Targeted deep grounding pack passed: - `assistantDeepTurnGroundingRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.113 + 2.114 + 2.115 + 2.116): 1. Tightened temporal/polarity guard typing in deep plan runtime: - `assistantDeepTurnPlanRuntimeAdapter.ts` - `temporalGuard` now typed to `TemporalGuardAudit`; - `domainPolarityGuardInitial` now typed to `DomainPolarityGuardAudit`. 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. `npm run build` passed. 2. Targeted deep plan pack passed: - `assistantDeepTurnPlanRuntimeAdapter.test.ts` - `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts` Implemented in current pass (Phase 2.117 + 2.118 + 2.119 + 2.120): 1. Tightened audit typing along deep response/packaging chain: - `assistantDebugPayloadAssembler.ts` - `assistantMessageLogAssembler.ts` - `assistantDeepTurnPackaging.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnInputBuilder.ts` - `assistantDeepTurnResponseRuntimeAdapter.ts` - audit contracts now use concrete types: - `TemporalGuardAudit`, `DomainPolarityGuardAudit`, `ClaimBoundAnchorAudit`, `TargetedEvidenceAcquisitionAudit`, `EvidenceAdmissibilityAudit`, `GroundedAnswerEligibilityAudit`, `RbpLiveRouteAuditDebug | null`, `FaLiveRouteAuditDebug | null`. 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. `npm run build` passed. 2. Targeted deep response/packaging pack passed: - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnResponseAttemptRuntimeAdapter.test.ts` - `assistantDeepTurnPackagingRuntimeAdapter.test.ts` - `assistantDeepTurnPackaging.test.ts` Implemented in current pass (Phase 2.121 + 2.122 + 2.123 + 2.124): 1. Tightened retrieval call/raw types across deep response chain: - `assistantDeepTurnRetrievalRuntimeAdapter.ts` - `assistantDeepTurnResponseRuntimeAdapter.ts` - `assistantDeepTurnPackaging.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnInputBuilder.ts` - `assistantMessageLogAssembler.ts` - `assistantEvidenceBundleAssembler.ts` - `assistantOrchestrationContracts.ts` - introduced `AssistantRetrievalRawResult` and typed `AssistantRetrievalRawResultRecord`; - retrieval calls now use `AssistantRetrievalCallRecord[]` end-to-end. 2. Preserved behavior: - no runtime logic changes; only stronger typing and safe raw normalization. Validation: 1. `npm run build` passed. 2. Targeted deep retrieval/response pack passed: - `assistantDeepTurnResponseRuntimeAdapter.test.ts` - `assistantDeepTurnRetrievalRuntimeAdapter.test.ts` - `assistantDeepTurnPackaging.test.ts` Implemented in current pass (Phase 2.125 + 2.126 + 2.127 + 2.128): 1. Tightened deep turn execution state + fallback metadata typing: - `assistantDeepTurnPrePackagingContext.ts` - `assistantDeepTurnPackaging.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnInputBuilder.ts` - `assistantDeepTurnResponseRuntimeAdapter.ts` - `assistantDeepTurnNormalizationRuntimeAdapter.ts` - added `AssistantExecutionStateRecord` + `AssistantAddressRuntimeMetaForDeep`; - `fallback_type` now `AssistantFallbackType`; - `problem_answer_mode` now `AssistantProblemAnswerMode`; - `problem_unit_ids_used` now `string[]`; - `investigationStateSnapshot` now `InvestigationStateWithProblemUnits | null`. 2. Aligned debug/log payload typing with contracts: - `assistantDebugPayloadAssembler.ts` - `assistantMessageLogAssembler.ts` - `assistantOrchestrationContractsV1` and `outcomeClassV1` now typed; - `answerStructureV11` now typed. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.129 + 2.130 + 2.131 + 2.132): 1. Typified debug route structures end-to-end: - `assistantQueryPlanning.ts` - `assistantDeepTurnPrePackagingContext.ts` - `assistantDeepTurnPackaging.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnInputBuilder.ts` - `assistantDeepTurnResponseRuntimeAdapter.ts` - `assistantDebugPayloadAssembler.ts` - `assistantMessageLogAssembler.ts` - introduced `AssistantDebugRouteRecord` union (legacy vs deterministic debug routes); - `routes` now typed in `AssistantDebugPayload`. 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.133): 1. Tightened deep retrieval runtime input: - `assistantDeepTurnRetrievalRuntimeAdapter.ts` - `executeRouteRuntime` now returns `AssistantRetrievalRawResult` (explicit union). 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.134 + 2.135): 1. Typed live-route plan audit contract: - `assistantDeepTurnPlanRuntimeAdapter.ts` - introduced `AssistantLiveRoutePlanAudit` for plan enforcement audits. 2. Typed deep analysis log payload plumbing: - `assistantMessageLogAssembler.ts` - `assistantDeepTurnPackaging.ts` - `assistantDeepTurnPackagingRuntimeAdapter.ts` - `assistantDeepTurnFinalizeRuntimeAdapter.ts` - introduced `DeepAnalysisLogDetails` alias and used it end-to-end. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.136): 1. Tightened business-scope resolution contract shape: - `assistantDeepTurnContextRuntimeAdapter.ts` - removed index-signature `unknown` on business scope resolution; - `resolveBusinessScopeFromLiveContext` now uses `AssistantBusinessScopeResolution` explicitly. 2. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.137 + 2.138): 1. Tightened company anchor normalization input types: - `assistantDeepTurnCompositionRuntimeAdapter.ts` - `toStringArray` now accepts `string[] | null | undefined`; - company anchor normalization now consumes `Partial`. 2. Narrowed response runtime normalizers: - `assistantDeepTurnResponseRuntimeAdapter.ts` - runtime analysis context and business scope normalizers now take typed inputs. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.139 + 2.140): 1. Tightened analysis attempt builder normalizers: - `assistantDeepTurnAnalysisAttemptInputBuilder.ts` - removed `unknown` from anchor/period helpers; now `Partial` + typed primary period. 2. Narrowed response runtime normalization helpers: - `assistantDeepTurnResponseRuntimeAdapter.ts` - execution plan normalization now consumes typed `AssistantExecutionPlanItem[]`; - helper signatures no longer accept `unknown` where input is already typed. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.141 + 2.142 + 2.143 + 2.144): 1. Tightened attempt input defaults: - `assistantDeepTurnAttemptInputBuilder.ts` - response attempt default type is now `AssistantMessageResponsePayload`. 2. Tightened retrieval raw result typing: - `assistantDeepTurnRetrievalRuntimeAdapter.ts` - introduced `AssistantRetrievalRawResultLike` + list item union. 3. Tightened deep packaging normalization: - `assistantDeepTurnPackaging.ts` - normalized fragments extracted without `Record` cast. 4. Simplified response runtime normalizers: - `assistantDeepTurnResponseRuntimeAdapter.ts` - removed `toRecordObject` casts and normalized from typed inputs. 5. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Implemented in current pass (Phase 2.145 + 2.146): 1. Tightened retrieval raw result field shapes: - `assistantDeepTurnRetrievalRuntimeAdapter.ts` - introduced `AssistantRetrievalFieldValue` / `AssistantRetrievalRecord`; - removed `unknown` from raw result record types. 2. Tightened normalized fragment extraction: - `assistantDeepTurnPackaging.ts` - normalized fragments now typed to `NormalizedQueryV2*` fragments. 3. Preserved behavior: - no runtime logic changes; type alignment only. Validation: 1. Not run in this pass (type-only changes). Status: **Completed (Phase 2.1–2.146)** ### Stage 2 Completion Report (Summary) 1. Orchestration monolith decomposed into explicit modules: - QueryFrame, ExecutionPlan, EvidenceBundle, Coverage/Grounding, Answer package, Debug payload, Log details. 2. Deep lane now uses stable contracts end-to-end: - `assistant_orchestration_contracts_v1`, `assistant_evidence_bundle_v1`, `assistant_coverage_contract_v1`. 3. Audit & trace coverage standardized: - temporal/polarity/claim/evidence guards, live-route audits, followup usage, outcome class. 4. Type hardening complete across deep chain: - normalized payloads, execution plan, retrieval calls/raw, debug routes, runtime meta, investigation state. 5. Behavior preserved throughout refactor (no route/answer regressions by design). ### Stage 2 Closure Audit (2026-04-11) 1. Fixed runtime-critical context loss in `assistantTurnRuntimeDepsAdapter.ts`: - unbound session store/logger/normalizer methods caused `TypeError` at `assistantSessionStore.ensureSession(...)` and mass `500` responses in API tests. 2. Added safe method wrappers in deps adapter: - `ensureSession`, `appendItem`, `getSession`, `persistSession`, `setInvestigationState`, `normalize`. 3. Added regression guard: - `assistantTurnRuntimeDepsAdapter.test.ts` now includes a stateful instance-context test to prevent `this` loss regressions. 4. Validation gates (fact): - `npm run build` passed. - Combined Stage 2 regression validation passed: `37` files / `95` tests (deep-turn adapters/builders/packaging, orchestration contracts/runtime, MCP bridge, followup continuity, wave10 corrective regression). 5. Scope note: - Full backend suite still has red tests in Stage 3/4 probes and long-running acceptance packs; this is tracked under Stage 3 backlog and is not a Stage 2 blocker. ### Stage 2 Remaining Risks (Known) 1. Final answer quality still template-heavy and brittle. 2. Lexical routing pressure remains high (dictionary overfitting risk). 3. Deterministic guards still compensate for weak semantic parsing. ## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards) Goal: 1. Use LLM for semantic extraction/decomposition in strict schema. 2. Keep deterministic guardrails as verifier, not primary “brain”. 3. Reduce dictionary overfitting and false route drifts. Plan (Stage 3): 1. **Schema-first semantic extraction** - Strict JSON schema for: entities, time scope, intent, ambiguity, success criteria. - Hard validation + retry/repair loop. 2. **LLM decomposition with guardrails** - Decomposition produces executable plan candidates. - Deterministic guards validate: domain polarity, temporal window, claim-bound anchors. 3. **Evidence-first reasoning** - LLM only summarizes from evidence bundle, never invents facts. 4. **Context binding** - Carryover only via typed followup state, not free-text memory. 5. **Quality gates** - Coverage critic threshold before final answer. - Reason-code taxonomy normalized. 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. 3. False route drifts and generic responses reduced in regression packs. 4. Manual markup shows increase in “correct/grounded” labels. Status: Planned ## Stage 4 (P2): Human-Centric Answer Layer Goal: 1. Move final user response to contract-driven answer package with: - direct answer; - what was checked; - what was found; - what remains unproven; - best next step. 2. Keep claim-to-evidence binding strict. Status: Planned ## Stage 5 (P3): Quality Loop Driven By GUI Markup Goal: 1. Drive backlog from `manual_case_decision` queues. 2. Build targeted regression packs from real failed comments. 3. Track trend by reason-code clusters. Status: Planned ## 6. Non-Negotiable Constraints 1. Do not break MCP route interfaces. 2. Do not remove manual logic without compatible replacement. 3. Preserve UTF-8 (without BOM) for all source/doc files. 4. Keep manual markup and autorun API contract stable.