ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.562.60 Deep-turn attempt input builder \ Deep-turn analysis-attempt input builder \ Deep-turn response-runtime input builder:
This commit is contained in:
parent
c849eb5f5b
commit
6c9b94ef34
|
|
@ -1689,7 +1689,69 @@ Validation:
|
||||||
- `assistantWave10SettlementCorrectiveRegression.test.ts`
|
- `assistantWave10SettlementCorrectiveRegression.test.ts`
|
||||||
- `assistantLivingChatMode.test.ts`
|
- `assistantLivingChatMode.test.ts`
|
||||||
|
|
||||||
Status: **In progress (Phase 2.1 + 2.2 + 2.3 + 2.4 + 2.5 + 2.6 + 2.7 + 2.8 + 2.9 + 2.10 + 2.11 + 2.12 + 2.13 + 2.14 + 2.15 + 2.16 + 2.17 + 2.18 + 2.19 + 2.20 + 2.21 + 2.22 + 2.23 + 2.24 + 2.25 + 2.26 + 2.27 + 2.28 + 2.29 + 2.30 + 2.31 + 2.32 + 2.33 + 2.34 + 2.35 + 2.36 + 2.37 + 2.38 + 2.39 + 2.40 + 2.41 + 2.42 + 2.43 + 2.44 + 2.45 + 2.46 + 2.47 + 2.48 + 2.49 + 2.50 + 2.51 + 2.52 + 2.53 + 2.54 + 2.55 completed)**
|
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`
|
||||||
|
|
||||||
|
Status: **In progress (Phase 2.1 + 2.2 + 2.3 + 2.4 + 2.5 + 2.6 + 2.7 + 2.8 + 2.9 + 2.10 + 2.11 + 2.12 + 2.13 + 2.14 + 2.15 + 2.16 + 2.17 + 2.18 + 2.19 + 2.20 + 2.21 + 2.22 + 2.23 + 2.24 + 2.25 + 2.26 + 2.27 + 2.28 + 2.29 + 2.30 + 2.31 + 2.32 + 2.33 + 2.34 + 2.35 + 2.36 + 2.37 + 2.38 + 2.39 + 2.40 + 2.41 + 2.42 + 2.43 + 2.44 + 2.45 + 2.46 + 2.47 + 2.48 + 2.49 + 2.50 + 2.51 + 2.52 + 2.53 + 2.54 + 2.55 + 2.56 + 2.57 + 2.58 + 2.59 + 2.60 completed)**
|
||||||
|
|
||||||
## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards)
|
## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards)
|
||||||
|
|
||||||
|
|
|
||||||
116
llm_normalizer/backend/dist/services/assistantDeepTurnAnalysisAttemptInputBuilder.js
vendored
Normal file
116
llm_normalizer/backend/dist/services/assistantDeepTurnAnalysisAttemptInputBuilder.js
vendored
Normal file
|
|
@ -0,0 +1,116 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.buildAssistantDeepTurnContextRuntimeInput = buildAssistantDeepTurnContextRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnExecutionPlanRuntimeInput = buildAssistantDeepTurnExecutionPlanRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnRetrievalRuntimeInput = buildAssistantDeepTurnRetrievalRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnGuardRuntimeInput = buildAssistantDeepTurnGuardRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnGroundingRuntimeInput = buildAssistantDeepTurnGroundingRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnCompositionRuntimeInput = buildAssistantDeepTurnCompositionRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnAnalysisRuntimeInput = buildAssistantDeepTurnAnalysisRuntimeInput;
|
||||||
|
const companyAnchorResolver_1 = require("./companyAnchorResolver");
|
||||||
|
const assistantRuntimeGuards_1 = require("./assistantRuntimeGuards");
|
||||||
|
const assistantClaimBoundEvidence_1 = require("./assistantClaimBoundEvidence");
|
||||||
|
function buildAssistantDeepTurnContextRuntimeInput(input) {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
routeSummary: input.routeSummary,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupUsage: input.followupUsage,
|
||||||
|
resolveCompanyAnchors: companyAnchorResolver_1.resolveCompanyAnchors,
|
||||||
|
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
||||||
|
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
||||||
|
resolveTemporalGuard: assistantRuntimeGuards_1.resolveTemporalGuard,
|
||||||
|
resolveDomainPolarityGuard: assistantRuntimeGuards_1.resolveDomainPolarityGuard,
|
||||||
|
resolveClaimBoundAnchors: assistantClaimBoundEvidence_1.resolveClaimBoundAnchors,
|
||||||
|
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnExecutionPlanRuntimeInput(input, runtime) {
|
||||||
|
return {
|
||||||
|
routeSummary: runtime.resolvedRouteSummary,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
claimType: runtime.claimAnchorAudit.claim_type,
|
||||||
|
temporalGuard: runtime.temporalGuard,
|
||||||
|
domainPolarityGuardInitial: runtime.domainPolarityGuardInitial,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
toExecutionPlan: input.toExecutionPlan,
|
||||||
|
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
||||||
|
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
||||||
|
applyTemporalHintToExecutionPlan: assistantRuntimeGuards_1.applyTemporalHintToExecutionPlan,
|
||||||
|
applyPolarityHintToExecutionPlan: assistantRuntimeGuards_1.applyPolarityHintToExecutionPlan
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnRetrievalRuntimeInput(input, runtime) {
|
||||||
|
return {
|
||||||
|
executionPlan: runtime.executionPlan,
|
||||||
|
liveTemporalHint: runtime.liveTemporalHint,
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason,
|
||||||
|
buildSkippedResult: input.buildSkippedResult
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnGuardRuntimeInput(runtime) {
|
||||||
|
return {
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
domainPolarityGuardInitial: runtime.domainPolarityGuardInitial,
|
||||||
|
claimAnchorAudit: runtime.claimAnchorAudit,
|
||||||
|
temporalGuard: runtime.temporalGuard,
|
||||||
|
focusDomainForGuards: runtime.focusDomainForGuards,
|
||||||
|
companyAnchors: runtime.companyAnchors,
|
||||||
|
userMessage: runtime.userMessage
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnGroundingRuntimeInput(input, runtime) {
|
||||||
|
return {
|
||||||
|
claimType: runtime.claimType,
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
rbpPlanAudit: runtime.rbpPlanAudit,
|
||||||
|
faPlanAudit: runtime.faPlanAudit,
|
||||||
|
routeSummary: runtime.routeSummary,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
requirementExtraction: runtime.requirementExtraction,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
evaluateCoverage: input.evaluateCoverage,
|
||||||
|
checkGrounding: input.checkGrounding,
|
||||||
|
temporalGuard: runtime.temporalGuard,
|
||||||
|
polarityAudit: runtime.polarityAudit,
|
||||||
|
evidenceAudit: runtime.evidenceAudit,
|
||||||
|
claimAnchorAudit: runtime.claimAnchorAudit,
|
||||||
|
targetedEvidenceHitRate: runtime.targetedEvidenceHitRate,
|
||||||
|
businessScopeResolved: runtime.businessScopeResolved,
|
||||||
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
||||||
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnCompositionRuntimeInput(input, runtime) {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
routeSummary: runtime.resolvedRouteSummary,
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
requirements: runtime.requirements,
|
||||||
|
coverageReport: runtime.coverageReport,
|
||||||
|
groundingCheck: runtime.groundingCheck,
|
||||||
|
followupUsage: input.followupUsage,
|
||||||
|
investigationState: input.investigationState,
|
||||||
|
companyAnchors: runtime.companyAnchors,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnAnalysisRuntimeInput(input) {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
runContextRuntime: () => input.runDeepTurnContextRuntimeSafe(buildAssistantDeepTurnContextRuntimeInput(input)),
|
||||||
|
runExecutionPlanRuntime: (runtime) => input.runDeepTurnPlanRuntimeSafe(buildAssistantDeepTurnExecutionPlanRuntimeInput(input, runtime)),
|
||||||
|
runRetrievalRuntime: (runtime) => input.runDeepTurnRetrievalRuntimeSafe(buildAssistantDeepTurnRetrievalRuntimeInput(input, runtime)),
|
||||||
|
runGuardRuntime: (runtime) => input.runDeepTurnGuardRuntimeSafe(buildAssistantDeepTurnGuardRuntimeInput(runtime)),
|
||||||
|
runGroundingRuntime: (runtime) => input.runDeepTurnGroundingRuntimeSafe(buildAssistantDeepTurnGroundingRuntimeInput(input, runtime)),
|
||||||
|
runCompositionRuntime: (runtime) => input.runDeepTurnCompositionRuntimeSafe(buildAssistantDeepTurnCompositionRuntimeInput(input, runtime))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.runAssistantDeepTurnAnalysisAttemptRuntime = runAssistantDeepTurnAnalysisAttemptRuntime;
|
exports.runAssistantDeepTurnAnalysisAttemptRuntime = runAssistantDeepTurnAnalysisAttemptRuntime;
|
||||||
const companyAnchorResolver_1 = require("./companyAnchorResolver");
|
|
||||||
const assistantRuntimeGuards_1 = require("./assistantRuntimeGuards");
|
|
||||||
const assistantClaimBoundEvidence_1 = require("./assistantClaimBoundEvidence");
|
|
||||||
const assistantDeepTurnAnalysisRuntimeAdapter_1 = require("./assistantDeepTurnAnalysisRuntimeAdapter");
|
const assistantDeepTurnAnalysisRuntimeAdapter_1 = require("./assistantDeepTurnAnalysisRuntimeAdapter");
|
||||||
const assistantDeepTurnContextRuntimeAdapter_1 = require("./assistantDeepTurnContextRuntimeAdapter");
|
const assistantDeepTurnContextRuntimeAdapter_1 = require("./assistantDeepTurnContextRuntimeAdapter");
|
||||||
const assistantDeepTurnPlanRuntimeAdapter_1 = require("./assistantDeepTurnPlanRuntimeAdapter");
|
const assistantDeepTurnPlanRuntimeAdapter_1 = require("./assistantDeepTurnPlanRuntimeAdapter");
|
||||||
|
|
@ -11,6 +8,7 @@ const assistantDeepTurnRetrievalRuntimeAdapter_1 = require("./assistantDeepTurnR
|
||||||
const assistantDeepTurnGuardRuntimeAdapter_1 = require("./assistantDeepTurnGuardRuntimeAdapter");
|
const assistantDeepTurnGuardRuntimeAdapter_1 = require("./assistantDeepTurnGuardRuntimeAdapter");
|
||||||
const assistantDeepTurnGroundingRuntimeAdapter_1 = require("./assistantDeepTurnGroundingRuntimeAdapter");
|
const assistantDeepTurnGroundingRuntimeAdapter_1 = require("./assistantDeepTurnGroundingRuntimeAdapter");
|
||||||
const assistantDeepTurnCompositionRuntimeAdapter_1 = require("./assistantDeepTurnCompositionRuntimeAdapter");
|
const assistantDeepTurnCompositionRuntimeAdapter_1 = require("./assistantDeepTurnCompositionRuntimeAdapter");
|
||||||
|
const assistantDeepTurnAnalysisAttemptInputBuilder_1 = require("./assistantDeepTurnAnalysisAttemptInputBuilder");
|
||||||
async function runAssistantDeepTurnAnalysisAttemptRuntime(input) {
|
async function runAssistantDeepTurnAnalysisAttemptRuntime(input) {
|
||||||
const runDeepTurnAnalysisRuntimeSafe = input.runDeepTurnAnalysisRuntime ?? assistantDeepTurnAnalysisRuntimeAdapter_1.runAssistantDeepTurnAnalysisRuntime;
|
const runDeepTurnAnalysisRuntimeSafe = input.runDeepTurnAnalysisRuntime ?? assistantDeepTurnAnalysisRuntimeAdapter_1.runAssistantDeepTurnAnalysisRuntime;
|
||||||
const runDeepTurnContextRuntimeSafe = input.runDeepTurnContextRuntime ?? assistantDeepTurnContextRuntimeAdapter_1.buildAssistantDeepTurnRuntimeContext;
|
const runDeepTurnContextRuntimeSafe = input.runDeepTurnContextRuntime ?? assistantDeepTurnContextRuntimeAdapter_1.buildAssistantDeepTurnRuntimeContext;
|
||||||
|
|
@ -19,88 +17,13 @@ async function runAssistantDeepTurnAnalysisAttemptRuntime(input) {
|
||||||
const runDeepTurnGuardRuntimeSafe = input.runDeepTurnGuardRuntime ?? assistantDeepTurnGuardRuntimeAdapter_1.applyAssistantDeepTurnRetrievalGuards;
|
const runDeepTurnGuardRuntimeSafe = input.runDeepTurnGuardRuntime ?? assistantDeepTurnGuardRuntimeAdapter_1.applyAssistantDeepTurnRetrievalGuards;
|
||||||
const runDeepTurnGroundingRuntimeSafe = input.runDeepTurnGroundingRuntime ?? assistantDeepTurnGroundingRuntimeAdapter_1.runAssistantDeepTurnGroundingRuntime;
|
const runDeepTurnGroundingRuntimeSafe = input.runDeepTurnGroundingRuntime ?? assistantDeepTurnGroundingRuntimeAdapter_1.runAssistantDeepTurnGroundingRuntime;
|
||||||
const runDeepTurnCompositionRuntimeSafe = input.runDeepTurnCompositionRuntime ?? assistantDeepTurnCompositionRuntimeAdapter_1.buildAssistantDeepTurnComposition;
|
const runDeepTurnCompositionRuntimeSafe = input.runDeepTurnCompositionRuntime ?? assistantDeepTurnCompositionRuntimeAdapter_1.buildAssistantDeepTurnComposition;
|
||||||
return runDeepTurnAnalysisRuntimeSafe({
|
return runDeepTurnAnalysisRuntimeSafe((0, assistantDeepTurnAnalysisAttemptInputBuilder_1.buildAssistantDeepTurnAnalysisRuntimeInput)({
|
||||||
userMessage: input.userMessage,
|
...input,
|
||||||
runContextRuntime: () => runDeepTurnContextRuntimeSafe({
|
runDeepTurnContextRuntimeSafe,
|
||||||
userMessage: input.userMessage,
|
runDeepTurnPlanRuntimeSafe,
|
||||||
normalizedPayload: input.normalizedPayload,
|
runDeepTurnRetrievalRuntimeSafe,
|
||||||
routeSummary: input.routeSummary,
|
runDeepTurnGuardRuntimeSafe,
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
runDeepTurnGroundingRuntimeSafe,
|
||||||
followupUsage: input.followupUsage,
|
runDeepTurnCompositionRuntimeSafe
|
||||||
resolveCompanyAnchors: companyAnchorResolver_1.resolveCompanyAnchors,
|
}));
|
||||||
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
|
||||||
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
|
||||||
resolveTemporalGuard: assistantRuntimeGuards_1.resolveTemporalGuard,
|
|
||||||
resolveDomainPolarityGuard: assistantRuntimeGuards_1.resolveDomainPolarityGuard,
|
|
||||||
resolveClaimBoundAnchors: assistantClaimBoundEvidence_1.resolveClaimBoundAnchors,
|
|
||||||
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext
|
|
||||||
}),
|
|
||||||
runExecutionPlanRuntime: ({ resolvedRouteSummary, claimAnchorAudit, temporalGuard, domainPolarityGuardInitial }) => runDeepTurnPlanRuntimeSafe({
|
|
||||||
routeSummary: resolvedRouteSummary,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
claimType: claimAnchorAudit.claim_type,
|
|
||||||
temporalGuard,
|
|
||||||
domainPolarityGuardInitial,
|
|
||||||
extractRequirements: input.extractRequirements,
|
|
||||||
toExecutionPlan: input.toExecutionPlan,
|
|
||||||
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
|
||||||
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
|
||||||
applyTemporalHintToExecutionPlan: assistantRuntimeGuards_1.applyTemporalHintToExecutionPlan,
|
|
||||||
applyPolarityHintToExecutionPlan: assistantRuntimeGuards_1.applyPolarityHintToExecutionPlan
|
|
||||||
}),
|
|
||||||
runRetrievalRuntime: ({ executionPlan, liveTemporalHint }) => runDeepTurnRetrievalRuntimeSafe({
|
|
||||||
executionPlan: executionPlan,
|
|
||||||
liveTemporalHint,
|
|
||||||
executeRouteRuntime: input.executeRouteRuntime,
|
|
||||||
mapNoRouteReason: input.mapNoRouteReason,
|
|
||||||
buildSkippedResult: input.buildSkippedResult
|
|
||||||
}),
|
|
||||||
runGuardRuntime: ({ retrievalResults, domainPolarityGuardInitial, claimAnchorAudit, temporalGuard, focusDomainForGuards, companyAnchors, userMessage: runtimeUserMessage }) => runDeepTurnGuardRuntimeSafe({
|
|
||||||
retrievalResults,
|
|
||||||
domainPolarityGuardInitial: domainPolarityGuardInitial,
|
|
||||||
claimAnchorAudit: claimAnchorAudit,
|
|
||||||
temporalGuard: temporalGuard,
|
|
||||||
focusDomainForGuards: focusDomainForGuards,
|
|
||||||
companyAnchors: companyAnchors,
|
|
||||||
userMessage: runtimeUserMessage
|
|
||||||
}),
|
|
||||||
runGroundingRuntime: ({ claimType, retrievalResults, rbpPlanAudit, faPlanAudit, routeSummary, requirementExtraction, temporalGuard, polarityAudit, evidenceAudit, claimAnchorAudit, targetedEvidenceHitRate, businessScopeResolved }) => runDeepTurnGroundingRuntimeSafe({
|
|
||||||
claimType,
|
|
||||||
retrievalResults,
|
|
||||||
rbpPlanAudit,
|
|
||||||
faPlanAudit,
|
|
||||||
routeSummary,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
requirementExtraction: requirementExtraction,
|
|
||||||
extractRequirements: input.extractRequirements,
|
|
||||||
evaluateCoverage: input.evaluateCoverage,
|
|
||||||
checkGrounding: input.checkGrounding,
|
|
||||||
temporalGuard,
|
|
||||||
polarityAudit,
|
|
||||||
evidenceAudit,
|
|
||||||
claimAnchorAudit,
|
|
||||||
targetedEvidenceHitRate,
|
|
||||||
businessScopeResolved,
|
|
||||||
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
|
||||||
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit
|
|
||||||
}),
|
|
||||||
runCompositionRuntime: ({ resolvedRouteSummary, retrievalResults, requirements, coverageReport, groundingCheck, companyAnchors }) => runDeepTurnCompositionRuntimeSafe({
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
routeSummary: resolvedRouteSummary,
|
|
||||||
retrievalResults,
|
|
||||||
requirements,
|
|
||||||
coverageReport,
|
|
||||||
groundingCheck,
|
|
||||||
followupUsage: input.followupUsage,
|
|
||||||
investigationState: input.investigationState,
|
|
||||||
companyAnchors,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
|
||||||
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
|
||||||
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
|
||||||
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
80
llm_normalizer/backend/dist/services/assistantDeepTurnAttemptInputBuilder.js
vendored
Normal file
80
llm_normalizer/backend/dist/services/assistantDeepTurnAttemptInputBuilder.js
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.buildAssistantDeepTurnNormalizationRuntimeInput = buildAssistantDeepTurnNormalizationRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnAnalysisAttemptRuntimeInput = buildAssistantDeepTurnAnalysisAttemptRuntimeInput;
|
||||||
|
exports.buildAssistantDeepTurnResponseAttemptRuntimeInput = buildAssistantDeepTurnResponseAttemptRuntimeInput;
|
||||||
|
function buildAssistantDeepTurnNormalizationRuntimeInput(input) {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
payload: input.payload,
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureStateFollowupBindingV1: input.featureStateFollowupBindingV1,
|
||||||
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
|
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
||||||
|
normalize: input.normalize
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnAnalysisAttemptRuntimeInput(input) {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalizedPayload: input.normalizationRuntime.normalized.normalized,
|
||||||
|
routeSummary: input.normalizationRuntime.normalized.route_hint_summary,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupUsage: input.normalizationRuntime.followupBinding.usage,
|
||||||
|
investigationState: input.sessionInvestigationState,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
||||||
|
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
||||||
|
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
toExecutionPlan: input.toExecutionPlan,
|
||||||
|
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
||||||
|
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason,
|
||||||
|
buildSkippedResult: input.buildSkippedResult,
|
||||||
|
evaluateCoverage: input.evaluateCoverage,
|
||||||
|
checkGrounding: input.checkGrounding,
|
||||||
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
||||||
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
||||||
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function buildAssistantDeepTurnResponseAttemptRuntimeInput(input) {
|
||||||
|
return {
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureContractsV11: input.featureContractsV11,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
sessionId: input.sessionId,
|
||||||
|
questionId: input.questionId,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalized: {
|
||||||
|
trace_id: input.normalizationRuntime.normalized.trace_id,
|
||||||
|
prompt_version: input.normalizationRuntime.normalized.prompt_version,
|
||||||
|
schema_version: input.normalizationRuntime.normalized.schema_version,
|
||||||
|
normalized: input.normalizationRuntime.normalized.normalized
|
||||||
|
},
|
||||||
|
normalizedQuestion: input.normalizationRuntime.followupBinding.normalizedQuestion,
|
||||||
|
deepTurnAnalysisRuntime: input.deepTurnAnalysisRuntime,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupStateUsage: input.normalizationRuntime.followupBinding.usage,
|
||||||
|
followupApplied: Boolean(input.normalizationRuntime.followupBinding.usage?.applied),
|
||||||
|
previousInvestigationState: input.sessionInvestigationState,
|
||||||
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
extractExecutionState: input.extractExecutionState,
|
||||||
|
sanitizeReply: input.sanitizeReply,
|
||||||
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
|
messageIdFactory: input.messageIdFactory,
|
||||||
|
appendItem: input.appendItem,
|
||||||
|
getSession: input.getSession,
|
||||||
|
persistSession: input.persistSession,
|
||||||
|
cloneConversation: input.cloneConversation,
|
||||||
|
logEvent: input.logEvent,
|
||||||
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -4,11 +4,12 @@ exports.runAssistantDeepTurnAttemptRuntime = runAssistantDeepTurnAttemptRuntime;
|
||||||
const assistantDeepTurnNormalizationRuntimeAdapter_1 = require("./assistantDeepTurnNormalizationRuntimeAdapter");
|
const assistantDeepTurnNormalizationRuntimeAdapter_1 = require("./assistantDeepTurnNormalizationRuntimeAdapter");
|
||||||
const assistantDeepTurnAnalysisAttemptRuntimeAdapter_1 = require("./assistantDeepTurnAnalysisAttemptRuntimeAdapter");
|
const assistantDeepTurnAnalysisAttemptRuntimeAdapter_1 = require("./assistantDeepTurnAnalysisAttemptRuntimeAdapter");
|
||||||
const assistantDeepTurnResponseAttemptRuntimeAdapter_1 = require("./assistantDeepTurnResponseAttemptRuntimeAdapter");
|
const assistantDeepTurnResponseAttemptRuntimeAdapter_1 = require("./assistantDeepTurnResponseAttemptRuntimeAdapter");
|
||||||
|
const assistantDeepTurnAttemptInputBuilder_1 = require("./assistantDeepTurnAttemptInputBuilder");
|
||||||
async function runAssistantDeepTurnAttemptRuntime(input) {
|
async function runAssistantDeepTurnAttemptRuntime(input) {
|
||||||
const runDeepTurnNormalizationRuntimeSafe = input.runDeepTurnNormalizationRuntime ?? assistantDeepTurnNormalizationRuntimeAdapter_1.buildAssistantDeepTurnNormalizationRuntime;
|
const runDeepTurnNormalizationRuntimeSafe = input.runDeepTurnNormalizationRuntime ?? assistantDeepTurnNormalizationRuntimeAdapter_1.buildAssistantDeepTurnNormalizationRuntime;
|
||||||
const runDeepTurnAnalysisAttemptRuntimeSafe = input.runDeepTurnAnalysisAttemptRuntime ?? assistantDeepTurnAnalysisAttemptRuntimeAdapter_1.runAssistantDeepTurnAnalysisAttemptRuntime;
|
const runDeepTurnAnalysisAttemptRuntimeSafe = input.runDeepTurnAnalysisAttemptRuntime ?? assistantDeepTurnAnalysisAttemptRuntimeAdapter_1.runAssistantDeepTurnAnalysisAttemptRuntime;
|
||||||
const runDeepTurnResponseAttemptRuntimeSafe = input.runDeepTurnResponseAttemptRuntime ?? assistantDeepTurnResponseAttemptRuntimeAdapter_1.runAssistantDeepTurnResponseAttemptRuntime;
|
const runDeepTurnResponseAttemptRuntimeSafe = input.runDeepTurnResponseAttemptRuntime ?? assistantDeepTurnResponseAttemptRuntimeAdapter_1.runAssistantDeepTurnResponseAttemptRuntime;
|
||||||
const normalizationRuntime = await runDeepTurnNormalizationRuntimeSafe({
|
const normalizationRuntime = await runDeepTurnNormalizationRuntimeSafe((0, assistantDeepTurnAttemptInputBuilder_1.buildAssistantDeepTurnNormalizationRuntimeInput)({
|
||||||
userMessage: input.userMessage,
|
userMessage: input.userMessage,
|
||||||
payload: input.payload,
|
payload: input.payload,
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
|
@ -16,16 +17,11 @@ async function runAssistantDeepTurnAttemptRuntime(input) {
|
||||||
sessionInvestigationState: input.sessionInvestigationState,
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
||||||
normalize: input.normalize
|
normalize: input.normalize
|
||||||
});
|
}));
|
||||||
const followupBinding = normalizationRuntime.followupBinding;
|
const deepTurnAnalysisRuntime = await runDeepTurnAnalysisAttemptRuntimeSafe((0, assistantDeepTurnAttemptInputBuilder_1.buildAssistantDeepTurnAnalysisAttemptRuntimeInput)({
|
||||||
const normalized = normalizationRuntime.normalized;
|
|
||||||
const deepTurnAnalysisRuntime = await runDeepTurnAnalysisAttemptRuntimeSafe({
|
|
||||||
userMessage: input.userMessage,
|
userMessage: input.userMessage,
|
||||||
normalizedPayload: normalized.normalized,
|
|
||||||
routeSummary: normalized.route_hint_summary,
|
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
followupUsage: followupBinding.usage,
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
investigationState: input.sessionInvestigationState,
|
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
|
@ -43,27 +39,18 @@ async function runAssistantDeepTurnAttemptRuntime(input) {
|
||||||
checkGrounding: input.checkGrounding,
|
checkGrounding: input.checkGrounding,
|
||||||
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
||||||
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
||||||
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor,
|
||||||
});
|
normalizationRuntime
|
||||||
const deepTurnResponseRuntime = runDeepTurnResponseAttemptRuntimeSafe({
|
}));
|
||||||
|
const deepTurnResponseRuntime = runDeepTurnResponseAttemptRuntimeSafe((0, assistantDeepTurnAttemptInputBuilder_1.buildAssistantDeepTurnResponseAttemptRuntimeInput)({
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
featureContractsV11: input.featureContractsV11,
|
featureContractsV11: input.featureContractsV11,
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
sessionId: input.sessionId,
|
sessionId: input.sessionId,
|
||||||
questionId: input.questionId,
|
questionId: input.questionId,
|
||||||
userMessage: input.userMessage,
|
userMessage: input.userMessage,
|
||||||
normalized: {
|
|
||||||
trace_id: normalized.trace_id,
|
|
||||||
prompt_version: normalized.prompt_version,
|
|
||||||
schema_version: normalized.schema_version,
|
|
||||||
normalized: normalized.normalized
|
|
||||||
},
|
|
||||||
normalizedQuestion: followupBinding.normalizedQuestion,
|
|
||||||
deepTurnAnalysisRuntime,
|
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
followupStateUsage: followupBinding.usage,
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
followupApplied: Boolean(followupBinding.usage?.applied),
|
|
||||||
previousInvestigationState: input.sessionInvestigationState,
|
|
||||||
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
buildDebugRoutes: input.buildDebugRoutes,
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
|
@ -77,8 +64,10 @@ async function runAssistantDeepTurnAttemptRuntime(input) {
|
||||||
cloneConversation: input.cloneConversation,
|
cloneConversation: input.cloneConversation,
|
||||||
logEvent: input.logEvent,
|
logEvent: input.logEvent,
|
||||||
runPackagingRuntime: input.runPackagingRuntime,
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn,
|
||||||
});
|
normalizationRuntime,
|
||||||
|
deepTurnAnalysisRuntime
|
||||||
|
}));
|
||||||
return {
|
return {
|
||||||
response: deepTurnResponseRuntime.response,
|
response: deepTurnResponseRuntime.response,
|
||||||
debug: deepTurnResponseRuntime.debug,
|
debug: deepTurnResponseRuntime.debug,
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.runAssistantDeepTurnResponseAttemptRuntime = runAssistantDeepTurnResponseAttemptRuntime;
|
exports.runAssistantDeepTurnResponseAttemptRuntime = runAssistantDeepTurnResponseAttemptRuntime;
|
||||||
const assistantDeepTurnResponseRuntimeAdapter_1 = require("./assistantDeepTurnResponseRuntimeAdapter");
|
const assistantDeepTurnResponseRuntimeAdapter_1 = require("./assistantDeepTurnResponseRuntimeAdapter");
|
||||||
|
const assistantDeepTurnResponseRuntimeInputBuilder_1 = require("./assistantDeepTurnResponseRuntimeInputBuilder");
|
||||||
function runAssistantDeepTurnResponseAttemptRuntime(input) {
|
function runAssistantDeepTurnResponseAttemptRuntime(input) {
|
||||||
const runDeepTurnResponseRuntimeSafe = input.runDeepTurnResponseRuntime ?? assistantDeepTurnResponseRuntimeAdapter_1.runAssistantDeepTurnResponseRuntime;
|
const runDeepTurnResponseRuntimeSafe = input.runDeepTurnResponseRuntime ?? assistantDeepTurnResponseRuntimeAdapter_1.runAssistantDeepTurnResponseRuntime;
|
||||||
const analysis = input.deepTurnAnalysisRuntime;
|
const responseRuntime = runDeepTurnResponseRuntimeSafe((0, assistantDeepTurnResponseRuntimeInputBuilder_1.buildAssistantDeepTurnResponseRuntimeInput)({
|
||||||
const responseRuntime = runDeepTurnResponseRuntimeSafe({
|
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
featureContractsV11: input.featureContractsV11,
|
featureContractsV11: input.featureContractsV11,
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
|
@ -14,31 +14,11 @@ function runAssistantDeepTurnResponseAttemptRuntime(input) {
|
||||||
userMessage: input.userMessage,
|
userMessage: input.userMessage,
|
||||||
normalized: input.normalized,
|
normalized: input.normalized,
|
||||||
normalizedQuestion: input.normalizedQuestion,
|
normalizedQuestion: input.normalizedQuestion,
|
||||||
routeSummary: analysis.resolvedRouteSummary,
|
deepTurnAnalysisRuntime: input.deepTurnAnalysisRuntime,
|
||||||
executionPlan: analysis.executionPlan,
|
|
||||||
requirementExtractionRequirements: analysis.requirementExtraction.requirements,
|
|
||||||
coverageEvaluationRequirements: analysis.coverageEvaluation.requirements,
|
|
||||||
coverageReport: analysis.coverageEvaluation.coverage,
|
|
||||||
groundingCheck: analysis.groundingCheck,
|
|
||||||
retrievalCalls: analysis.retrievalCalls,
|
|
||||||
retrievalResultsRaw: analysis.retrievalResultsRaw,
|
|
||||||
retrievalResults: analysis.retrievalResults,
|
|
||||||
questionTypeClass: analysis.questionTypeClass,
|
|
||||||
companyAnchors: analysis.companyAnchors,
|
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
businessScopeResolution: analysis.businessScopeResolution,
|
|
||||||
temporalGuard: analysis.temporalGuard,
|
|
||||||
polarityAudit: analysis.polarityGuardResult.audit,
|
|
||||||
claimAnchorAudit: analysis.claimAnchorAudit,
|
|
||||||
targetedEvidenceAudit: analysis.targetedEvidenceResult.audit,
|
|
||||||
evidenceAdmissibilityGateAudit: analysis.evidenceGateResult.audit,
|
|
||||||
rbpLiveRouteAudit: analysis.rbpLiveRouteAudit,
|
|
||||||
faLiveRouteAudit: analysis.faLiveRouteAudit,
|
|
||||||
groundedAnswerEligibilityGuard: analysis.groundedAnswerEligibilityGuard,
|
|
||||||
followupStateUsage: input.followupStateUsage,
|
followupStateUsage: input.followupStateUsage,
|
||||||
followupApplied: input.followupApplied,
|
followupApplied: input.followupApplied,
|
||||||
composition: analysis.composition,
|
previousInvestigationState: input.previousInvestigationState,
|
||||||
previousInvestigationState: input.previousInvestigationState ?? null,
|
|
||||||
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
buildDebugRoutes: input.buildDebugRoutes,
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
|
@ -53,7 +33,7 @@ function runAssistantDeepTurnResponseAttemptRuntime(input) {
|
||||||
logEvent: input.logEvent,
|
logEvent: input.logEvent,
|
||||||
runPackagingRuntime: input.runPackagingRuntime,
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
});
|
}));
|
||||||
return {
|
return {
|
||||||
response: responseRuntime.response,
|
response: responseRuntime.response,
|
||||||
debug: responseRuntime.debug
|
debug: responseRuntime.debug
|
||||||
|
|
|
||||||
55
llm_normalizer/backend/dist/services/assistantDeepTurnResponseRuntimeInputBuilder.js
vendored
Normal file
55
llm_normalizer/backend/dist/services/assistantDeepTurnResponseRuntimeInputBuilder.js
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.buildAssistantDeepTurnResponseRuntimeInput = buildAssistantDeepTurnResponseRuntimeInput;
|
||||||
|
function buildAssistantDeepTurnResponseRuntimeInput(input) {
|
||||||
|
const analysis = input.deepTurnAnalysisRuntime;
|
||||||
|
return {
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureContractsV11: input.featureContractsV11,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
sessionId: input.sessionId,
|
||||||
|
questionId: input.questionId,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalized: input.normalized,
|
||||||
|
normalizedQuestion: input.normalizedQuestion,
|
||||||
|
routeSummary: analysis.resolvedRouteSummary,
|
||||||
|
executionPlan: analysis.executionPlan,
|
||||||
|
requirementExtractionRequirements: analysis.requirementExtraction.requirements,
|
||||||
|
coverageEvaluationRequirements: analysis.coverageEvaluation.requirements,
|
||||||
|
coverageReport: analysis.coverageEvaluation.coverage,
|
||||||
|
groundingCheck: analysis.groundingCheck,
|
||||||
|
retrievalCalls: analysis.retrievalCalls,
|
||||||
|
retrievalResultsRaw: analysis.retrievalResultsRaw,
|
||||||
|
retrievalResults: analysis.retrievalResults,
|
||||||
|
questionTypeClass: analysis.questionTypeClass,
|
||||||
|
companyAnchors: analysis.companyAnchors,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
businessScopeResolution: analysis.businessScopeResolution,
|
||||||
|
temporalGuard: analysis.temporalGuard,
|
||||||
|
polarityAudit: analysis.polarityGuardResult.audit,
|
||||||
|
claimAnchorAudit: analysis.claimAnchorAudit,
|
||||||
|
targetedEvidenceAudit: analysis.targetedEvidenceResult.audit,
|
||||||
|
evidenceAdmissibilityGateAudit: analysis.evidenceGateResult.audit,
|
||||||
|
rbpLiveRouteAudit: analysis.rbpLiveRouteAudit,
|
||||||
|
faLiveRouteAudit: analysis.faLiveRouteAudit,
|
||||||
|
groundedAnswerEligibilityGuard: analysis.groundedAnswerEligibilityGuard,
|
||||||
|
followupStateUsage: input.followupStateUsage,
|
||||||
|
followupApplied: input.followupApplied,
|
||||||
|
composition: analysis.composition,
|
||||||
|
previousInvestigationState: input.previousInvestigationState ?? null,
|
||||||
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
extractExecutionState: input.extractExecutionState,
|
||||||
|
sanitizeReply: input.sanitizeReply,
|
||||||
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
|
messageIdFactory: input.messageIdFactory,
|
||||||
|
appendItem: input.appendItem,
|
||||||
|
getSession: input.getSession,
|
||||||
|
persistSession: input.persistSession,
|
||||||
|
cloneConversation: input.cloneConversation,
|
||||||
|
logEvent: input.logEvent,
|
||||||
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,207 @@
|
||||||
|
import { resolveCompanyAnchors } from "./companyAnchorResolver";
|
||||||
|
import {
|
||||||
|
applyPolarityHintToExecutionPlan,
|
||||||
|
applyTemporalHintToExecutionPlan,
|
||||||
|
resolveDomainPolarityGuard,
|
||||||
|
resolveTemporalGuard
|
||||||
|
} from "./assistantRuntimeGuards";
|
||||||
|
import { resolveClaimBoundAnchors } from "./assistantClaimBoundEvidence";
|
||||||
|
import type { RunAssistantDeepTurnAnalysisRuntimeInput } from "./assistantDeepTurnAnalysisRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
BuildAssistantDeepTurnRuntimeContextInput,
|
||||||
|
BuildAssistantDeepTurnRuntimeContextOutput
|
||||||
|
} from "./assistantDeepTurnContextRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
BuildAssistantDeepTurnExecutionPlanInput,
|
||||||
|
BuildAssistantDeepTurnExecutionPlanOutput,
|
||||||
|
AssistantRequirementExtractionLike
|
||||||
|
} from "./assistantDeepTurnPlanRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
AssistantDeepTurnRetrievalExecutionInput,
|
||||||
|
AssistantDeepTurnRetrievalExecutionOutput
|
||||||
|
} from "./assistantDeepTurnRetrievalRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
AssistantDeepTurnRetrievalGuardPipelineInput,
|
||||||
|
AssistantDeepTurnRetrievalGuardPipelineOutput
|
||||||
|
} from "./assistantDeepTurnGuardRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
AssistantDeepTurnGroundingRuntimeInput,
|
||||||
|
AssistantDeepTurnGroundingRuntimeOutput
|
||||||
|
} from "./assistantDeepTurnGroundingRuntimeAdapter";
|
||||||
|
import type {
|
||||||
|
BuildAssistantDeepTurnCompositionInput,
|
||||||
|
AssistantDeepTurnCompositionOutput
|
||||||
|
} from "./assistantDeepTurnCompositionRuntimeAdapter";
|
||||||
|
import type { AssistantExecutionPlanItem } from "./assistantQueryPlanning";
|
||||||
|
import type { RunAssistantDeepTurnAnalysisAttemptRuntimeInput } from "./assistantDeepTurnAnalysisAttemptRuntimeAdapter";
|
||||||
|
|
||||||
|
type ExecutionPlanRuntimeArgs = Parameters<RunAssistantDeepTurnAnalysisRuntimeInput["runExecutionPlanRuntime"]>[0];
|
||||||
|
type RetrievalRuntimeArgs = Parameters<RunAssistantDeepTurnAnalysisRuntimeInput["runRetrievalRuntime"]>[0];
|
||||||
|
type GuardRuntimeArgs = Parameters<RunAssistantDeepTurnAnalysisRuntimeInput["runGuardRuntime"]>[0];
|
||||||
|
type GroundingRuntimeArgs = Parameters<RunAssistantDeepTurnAnalysisRuntimeInput["runGroundingRuntime"]>[0];
|
||||||
|
type CompositionRuntimeArgs = Parameters<RunAssistantDeepTurnAnalysisRuntimeInput["runCompositionRuntime"]>[0];
|
||||||
|
|
||||||
|
export interface BuildAssistantDeepTurnAnalysisRuntimeInputInput
|
||||||
|
extends RunAssistantDeepTurnAnalysisAttemptRuntimeInput {
|
||||||
|
runDeepTurnContextRuntimeSafe: (
|
||||||
|
input: BuildAssistantDeepTurnRuntimeContextInput
|
||||||
|
) => BuildAssistantDeepTurnRuntimeContextOutput;
|
||||||
|
runDeepTurnPlanRuntimeSafe: (
|
||||||
|
input: BuildAssistantDeepTurnExecutionPlanInput
|
||||||
|
) => BuildAssistantDeepTurnExecutionPlanOutput;
|
||||||
|
runDeepTurnRetrievalRuntimeSafe: (
|
||||||
|
input: AssistantDeepTurnRetrievalExecutionInput
|
||||||
|
) => Promise<AssistantDeepTurnRetrievalExecutionOutput>;
|
||||||
|
runDeepTurnGuardRuntimeSafe: (
|
||||||
|
input: AssistantDeepTurnRetrievalGuardPipelineInput
|
||||||
|
) => AssistantDeepTurnRetrievalGuardPipelineOutput;
|
||||||
|
runDeepTurnGroundingRuntimeSafe: (
|
||||||
|
input: AssistantDeepTurnGroundingRuntimeInput
|
||||||
|
) => AssistantDeepTurnGroundingRuntimeOutput;
|
||||||
|
runDeepTurnCompositionRuntimeSafe: (
|
||||||
|
input: BuildAssistantDeepTurnCompositionInput
|
||||||
|
) => AssistantDeepTurnCompositionOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnContextRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput
|
||||||
|
): BuildAssistantDeepTurnRuntimeContextInput {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
routeSummary: input.routeSummary,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupUsage: input.followupUsage,
|
||||||
|
resolveCompanyAnchors,
|
||||||
|
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
||||||
|
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
||||||
|
resolveTemporalGuard: resolveTemporalGuard as any,
|
||||||
|
resolveDomainPolarityGuard: resolveDomainPolarityGuard as any,
|
||||||
|
resolveClaimBoundAnchors: resolveClaimBoundAnchors as any,
|
||||||
|
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnExecutionPlanRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput,
|
||||||
|
runtime: ExecutionPlanRuntimeArgs
|
||||||
|
): BuildAssistantDeepTurnExecutionPlanInput {
|
||||||
|
return {
|
||||||
|
routeSummary: runtime.resolvedRouteSummary,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
claimType: runtime.claimAnchorAudit.claim_type,
|
||||||
|
temporalGuard: runtime.temporalGuard,
|
||||||
|
domainPolarityGuardInitial: runtime.domainPolarityGuardInitial,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
toExecutionPlan: input.toExecutionPlan,
|
||||||
|
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
||||||
|
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
||||||
|
applyTemporalHintToExecutionPlan: applyTemporalHintToExecutionPlan as any,
|
||||||
|
applyPolarityHintToExecutionPlan: applyPolarityHintToExecutionPlan as any
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnRetrievalRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput,
|
||||||
|
runtime: RetrievalRuntimeArgs
|
||||||
|
): AssistantDeepTurnRetrievalExecutionInput {
|
||||||
|
return {
|
||||||
|
executionPlan: runtime.executionPlan as AssistantExecutionPlanItem[],
|
||||||
|
liveTemporalHint: runtime.liveTemporalHint,
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason,
|
||||||
|
buildSkippedResult: input.buildSkippedResult
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnGuardRuntimeInput(
|
||||||
|
runtime: GuardRuntimeArgs
|
||||||
|
): AssistantDeepTurnRetrievalGuardPipelineInput {
|
||||||
|
return {
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
domainPolarityGuardInitial: runtime.domainPolarityGuardInitial as any,
|
||||||
|
claimAnchorAudit: runtime.claimAnchorAudit as any,
|
||||||
|
temporalGuard: runtime.temporalGuard as any,
|
||||||
|
focusDomainForGuards: runtime.focusDomainForGuards as any,
|
||||||
|
companyAnchors: runtime.companyAnchors as any,
|
||||||
|
userMessage: runtime.userMessage
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnGroundingRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput,
|
||||||
|
runtime: GroundingRuntimeArgs
|
||||||
|
): AssistantDeepTurnGroundingRuntimeInput {
|
||||||
|
return {
|
||||||
|
claimType: runtime.claimType,
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
rbpPlanAudit: runtime.rbpPlanAudit,
|
||||||
|
faPlanAudit: runtime.faPlanAudit,
|
||||||
|
routeSummary: runtime.routeSummary,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
requirementExtraction: runtime.requirementExtraction as AssistantRequirementExtractionLike,
|
||||||
|
extractRequirements: input.extractRequirements as any,
|
||||||
|
evaluateCoverage: input.evaluateCoverage as any,
|
||||||
|
checkGrounding: input.checkGrounding as any,
|
||||||
|
temporalGuard: runtime.temporalGuard,
|
||||||
|
polarityAudit: runtime.polarityAudit,
|
||||||
|
evidenceAudit: runtime.evidenceAudit,
|
||||||
|
claimAnchorAudit: runtime.claimAnchorAudit,
|
||||||
|
targetedEvidenceHitRate: runtime.targetedEvidenceHitRate,
|
||||||
|
businessScopeResolved: runtime.businessScopeResolved,
|
||||||
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit as any,
|
||||||
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit as any
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnCompositionRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput,
|
||||||
|
runtime: CompositionRuntimeArgs
|
||||||
|
): BuildAssistantDeepTurnCompositionInput {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
routeSummary: runtime.resolvedRouteSummary,
|
||||||
|
retrievalResults: runtime.retrievalResults,
|
||||||
|
requirements: runtime.requirements,
|
||||||
|
coverageReport: runtime.coverageReport,
|
||||||
|
groundingCheck: runtime.groundingCheck,
|
||||||
|
followupUsage: input.followupUsage,
|
||||||
|
investigationState: input.investigationState,
|
||||||
|
companyAnchors: runtime.companyAnchors,
|
||||||
|
normalizedPayload: input.normalizedPayload,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnAnalysisRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisRuntimeInputInput
|
||||||
|
): RunAssistantDeepTurnAnalysisRuntimeInput {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
runContextRuntime: () =>
|
||||||
|
input.runDeepTurnContextRuntimeSafe(buildAssistantDeepTurnContextRuntimeInput(input)) as any,
|
||||||
|
runExecutionPlanRuntime: (runtime) =>
|
||||||
|
input.runDeepTurnPlanRuntimeSafe(
|
||||||
|
buildAssistantDeepTurnExecutionPlanRuntimeInput(input, runtime)
|
||||||
|
) as any,
|
||||||
|
runRetrievalRuntime: (runtime) =>
|
||||||
|
input.runDeepTurnRetrievalRuntimeSafe(
|
||||||
|
buildAssistantDeepTurnRetrievalRuntimeInput(input, runtime)
|
||||||
|
) as any,
|
||||||
|
runGuardRuntime: (runtime) =>
|
||||||
|
input.runDeepTurnGuardRuntimeSafe(buildAssistantDeepTurnGuardRuntimeInput(runtime) as any),
|
||||||
|
runGroundingRuntime: (runtime) =>
|
||||||
|
input.runDeepTurnGroundingRuntimeSafe(
|
||||||
|
buildAssistantDeepTurnGroundingRuntimeInput(input, runtime)
|
||||||
|
) as any,
|
||||||
|
runCompositionRuntime: (runtime) =>
|
||||||
|
input.runDeepTurnCompositionRuntimeSafe(
|
||||||
|
buildAssistantDeepTurnCompositionRuntimeInput(input, runtime)
|
||||||
|
) as any
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,3 @@
|
||||||
import { resolveCompanyAnchors } from "./companyAnchorResolver";
|
|
||||||
import {
|
|
||||||
applyPolarityHintToExecutionPlan,
|
|
||||||
applyTemporalHintToExecutionPlan,
|
|
||||||
resolveDomainPolarityGuard,
|
|
||||||
resolveTemporalGuard
|
|
||||||
} from "./assistantRuntimeGuards";
|
|
||||||
import { resolveClaimBoundAnchors } from "./assistantClaimBoundEvidence";
|
|
||||||
import {
|
import {
|
||||||
runAssistantDeepTurnAnalysisRuntime,
|
runAssistantDeepTurnAnalysisRuntime,
|
||||||
type RunAssistantDeepTurnAnalysisRuntimeInput,
|
type RunAssistantDeepTurnAnalysisRuntimeInput,
|
||||||
|
|
@ -43,8 +35,7 @@ import {
|
||||||
} from "./assistantDeepTurnCompositionRuntimeAdapter";
|
} from "./assistantDeepTurnCompositionRuntimeAdapter";
|
||||||
import type { NormalizeResponsePayload, RouteHintSummary } from "../types/normalizer";
|
import type { NormalizeResponsePayload, RouteHintSummary } from "../types/normalizer";
|
||||||
import type { InvestigationStateWithProblemUnits } from "../types/stage2ProblemUnits";
|
import type { InvestigationStateWithProblemUnits } from "../types/stage2ProblemUnits";
|
||||||
import type { AssistantExecutionPlanItem } from "./assistantQueryPlanning";
|
import { buildAssistantDeepTurnAnalysisRuntimeInput } from "./assistantDeepTurnAnalysisAttemptInputBuilder";
|
||||||
import type { AssistantRequirementExtractionLike } from "./assistantDeepTurnPlanRuntimeAdapter";
|
|
||||||
|
|
||||||
interface RuntimeAnalysisContextLike {
|
interface RuntimeAnalysisContextLike {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
|
|
@ -117,127 +108,15 @@ export async function runAssistantDeepTurnAnalysisAttemptRuntime(
|
||||||
const runDeepTurnCompositionRuntimeSafe =
|
const runDeepTurnCompositionRuntimeSafe =
|
||||||
input.runDeepTurnCompositionRuntime ?? buildAssistantDeepTurnComposition;
|
input.runDeepTurnCompositionRuntime ?? buildAssistantDeepTurnComposition;
|
||||||
|
|
||||||
return runDeepTurnAnalysisRuntimeSafe({
|
return runDeepTurnAnalysisRuntimeSafe(
|
||||||
userMessage: input.userMessage,
|
buildAssistantDeepTurnAnalysisRuntimeInput({
|
||||||
runContextRuntime: () =>
|
...input,
|
||||||
runDeepTurnContextRuntimeSafe({
|
runDeepTurnContextRuntimeSafe,
|
||||||
userMessage: input.userMessage,
|
runDeepTurnPlanRuntimeSafe,
|
||||||
normalizedPayload: input.normalizedPayload,
|
runDeepTurnRetrievalRuntimeSafe,
|
||||||
routeSummary: input.routeSummary,
|
runDeepTurnGuardRuntimeSafe,
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
runDeepTurnGroundingRuntimeSafe,
|
||||||
followupUsage: input.followupUsage,
|
runDeepTurnCompositionRuntimeSafe
|
||||||
resolveCompanyAnchors,
|
})
|
||||||
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
);
|
||||||
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
|
||||||
resolveTemporalGuard: resolveTemporalGuard as any,
|
|
||||||
resolveDomainPolarityGuard: resolveDomainPolarityGuard as any,
|
|
||||||
resolveClaimBoundAnchors: resolveClaimBoundAnchors as any,
|
|
||||||
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext
|
|
||||||
}) as any,
|
|
||||||
runExecutionPlanRuntime: ({
|
|
||||||
resolvedRouteSummary,
|
|
||||||
claimAnchorAudit,
|
|
||||||
temporalGuard,
|
|
||||||
domainPolarityGuardInitial
|
|
||||||
}) =>
|
|
||||||
runDeepTurnPlanRuntimeSafe({
|
|
||||||
routeSummary: resolvedRouteSummary,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
claimType: claimAnchorAudit.claim_type,
|
|
||||||
temporalGuard,
|
|
||||||
domainPolarityGuardInitial,
|
|
||||||
extractRequirements: input.extractRequirements,
|
|
||||||
toExecutionPlan: input.toExecutionPlan,
|
|
||||||
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
|
||||||
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
|
||||||
applyTemporalHintToExecutionPlan: applyTemporalHintToExecutionPlan as any,
|
|
||||||
applyPolarityHintToExecutionPlan: applyPolarityHintToExecutionPlan as any
|
|
||||||
}) as any,
|
|
||||||
runRetrievalRuntime: ({ executionPlan, liveTemporalHint }) =>
|
|
||||||
runDeepTurnRetrievalRuntimeSafe({
|
|
||||||
executionPlan: executionPlan as AssistantExecutionPlanItem[],
|
|
||||||
liveTemporalHint,
|
|
||||||
executeRouteRuntime: input.executeRouteRuntime,
|
|
||||||
mapNoRouteReason: input.mapNoRouteReason,
|
|
||||||
buildSkippedResult: input.buildSkippedResult
|
|
||||||
}) as any,
|
|
||||||
runGuardRuntime: ({
|
|
||||||
retrievalResults,
|
|
||||||
domainPolarityGuardInitial,
|
|
||||||
claimAnchorAudit,
|
|
||||||
temporalGuard,
|
|
||||||
focusDomainForGuards,
|
|
||||||
companyAnchors,
|
|
||||||
userMessage: runtimeUserMessage
|
|
||||||
}) =>
|
|
||||||
runDeepTurnGuardRuntimeSafe({
|
|
||||||
retrievalResults,
|
|
||||||
domainPolarityGuardInitial: domainPolarityGuardInitial as any,
|
|
||||||
claimAnchorAudit: claimAnchorAudit as any,
|
|
||||||
temporalGuard: temporalGuard as any,
|
|
||||||
focusDomainForGuards: focusDomainForGuards as any,
|
|
||||||
companyAnchors: companyAnchors as any,
|
|
||||||
userMessage: runtimeUserMessage
|
|
||||||
} as any),
|
|
||||||
runGroundingRuntime: ({
|
|
||||||
claimType,
|
|
||||||
retrievalResults,
|
|
||||||
rbpPlanAudit,
|
|
||||||
faPlanAudit,
|
|
||||||
routeSummary,
|
|
||||||
requirementExtraction,
|
|
||||||
temporalGuard,
|
|
||||||
polarityAudit,
|
|
||||||
evidenceAudit,
|
|
||||||
claimAnchorAudit,
|
|
||||||
targetedEvidenceHitRate,
|
|
||||||
businessScopeResolved
|
|
||||||
}) =>
|
|
||||||
runDeepTurnGroundingRuntimeSafe({
|
|
||||||
claimType,
|
|
||||||
retrievalResults,
|
|
||||||
rbpPlanAudit,
|
|
||||||
faPlanAudit,
|
|
||||||
routeSummary,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
requirementExtraction: requirementExtraction as AssistantRequirementExtractionLike,
|
|
||||||
extractRequirements: input.extractRequirements as any,
|
|
||||||
evaluateCoverage: input.evaluateCoverage as any,
|
|
||||||
checkGrounding: input.checkGrounding as any,
|
|
||||||
temporalGuard,
|
|
||||||
polarityAudit,
|
|
||||||
evidenceAudit,
|
|
||||||
claimAnchorAudit,
|
|
||||||
targetedEvidenceHitRate,
|
|
||||||
businessScopeResolved,
|
|
||||||
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit as any,
|
|
||||||
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit as any
|
|
||||||
} as any),
|
|
||||||
runCompositionRuntime: ({
|
|
||||||
resolvedRouteSummary,
|
|
||||||
retrievalResults,
|
|
||||||
requirements,
|
|
||||||
coverageReport,
|
|
||||||
groundingCheck,
|
|
||||||
companyAnchors
|
|
||||||
}) =>
|
|
||||||
runDeepTurnCompositionRuntimeSafe({
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
routeSummary: resolvedRouteSummary,
|
|
||||||
retrievalResults,
|
|
||||||
requirements,
|
|
||||||
coverageReport,
|
|
||||||
groundingCheck,
|
|
||||||
followupUsage: input.followupUsage,
|
|
||||||
investigationState: input.investigationState,
|
|
||||||
companyAnchors,
|
|
||||||
normalizedPayload: input.normalizedPayload,
|
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
|
||||||
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
|
||||||
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
|
||||||
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
|
||||||
}) as any
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,156 @@
|
||||||
|
import type {
|
||||||
|
BuildAssistantDeepTurnNormalizationRuntimeInput,
|
||||||
|
BuildAssistantDeepTurnNormalizationRuntimeOutput
|
||||||
|
} from "./assistantDeepTurnNormalizationRuntimeAdapter";
|
||||||
|
import type { RunAssistantDeepTurnAnalysisAttemptRuntimeInput } from "./assistantDeepTurnAnalysisAttemptRuntimeAdapter";
|
||||||
|
import type { RunAssistantDeepTurnAnalysisRuntimeOutput } from "./assistantDeepTurnAnalysisRuntimeAdapter";
|
||||||
|
import type { RunAssistantDeepTurnResponseAttemptRuntimeInput } from "./assistantDeepTurnResponseAttemptRuntimeAdapter";
|
||||||
|
|
||||||
|
export interface BuildAssistantDeepTurnNormalizationRuntimeInputInput {
|
||||||
|
userMessage: string;
|
||||||
|
payload: BuildAssistantDeepTurnNormalizationRuntimeInput["payload"];
|
||||||
|
featureInvestigationStateV1: boolean;
|
||||||
|
featureStateFollowupBindingV1: boolean;
|
||||||
|
sessionInvestigationState: BuildAssistantDeepTurnNormalizationRuntimeInput["sessionInvestigationState"];
|
||||||
|
buildFollowupStateBinding: BuildAssistantDeepTurnNormalizationRuntimeInput["buildFollowupStateBinding"];
|
||||||
|
normalize: BuildAssistantDeepTurnNormalizationRuntimeInput["normalize"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnNormalizationRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnNormalizationRuntimeInputInput
|
||||||
|
): BuildAssistantDeepTurnNormalizationRuntimeInput {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
payload: input.payload,
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureStateFollowupBindingV1: input.featureStateFollowupBindingV1,
|
||||||
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
|
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
||||||
|
normalize: input.normalize
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BuildAssistantDeepTurnAnalysisAttemptRuntimeInputInput {
|
||||||
|
userMessage: string;
|
||||||
|
runtimeAnalysisContext: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["runtimeAnalysisContext"];
|
||||||
|
sessionInvestigationState: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["investigationState"];
|
||||||
|
featureAnswerPolicyV11: boolean;
|
||||||
|
featureProblemCentricAnswerV1: boolean;
|
||||||
|
featureLifecycleAnswerV1: boolean;
|
||||||
|
resolveBusinessScopeAlignment: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["resolveBusinessScopeAlignment"];
|
||||||
|
inferP0DomainFromMessage: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["inferP0DomainFromMessage"];
|
||||||
|
resolveBusinessScopeFromLiveContext:
|
||||||
|
RunAssistantDeepTurnAnalysisAttemptRuntimeInput["resolveBusinessScopeFromLiveContext"];
|
||||||
|
extractRequirements: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["extractRequirements"];
|
||||||
|
toExecutionPlan: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["toExecutionPlan"];
|
||||||
|
enforceRbpLiveRoutePlan: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["enforceRbpLiveRoutePlan"];
|
||||||
|
enforceFaLiveRoutePlan: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["enforceFaLiveRoutePlan"];
|
||||||
|
executeRouteRuntime: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["executeRouteRuntime"];
|
||||||
|
mapNoRouteReason: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["mapNoRouteReason"];
|
||||||
|
buildSkippedResult: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["buildSkippedResult"];
|
||||||
|
evaluateCoverage: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["evaluateCoverage"];
|
||||||
|
checkGrounding: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["checkGrounding"];
|
||||||
|
collectRbpLiveRouteAudit: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["collectRbpLiveRouteAudit"];
|
||||||
|
collectFaLiveRouteAudit: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["collectFaLiveRouteAudit"];
|
||||||
|
hasExplicitPeriodAnchor: RunAssistantDeepTurnAnalysisAttemptRuntimeInput["hasExplicitPeriodAnchor"];
|
||||||
|
normalizationRuntime: BuildAssistantDeepTurnNormalizationRuntimeOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnAnalysisAttemptRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnAnalysisAttemptRuntimeInputInput
|
||||||
|
): RunAssistantDeepTurnAnalysisAttemptRuntimeInput {
|
||||||
|
return {
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalizedPayload: input.normalizationRuntime.normalized.normalized,
|
||||||
|
routeSummary: input.normalizationRuntime.normalized.route_hint_summary,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupUsage: input.normalizationRuntime.followupBinding.usage,
|
||||||
|
investigationState: input.sessionInvestigationState,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
||||||
|
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
||||||
|
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
toExecutionPlan: input.toExecutionPlan,
|
||||||
|
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
||||||
|
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason,
|
||||||
|
buildSkippedResult: input.buildSkippedResult,
|
||||||
|
evaluateCoverage: input.evaluateCoverage,
|
||||||
|
checkGrounding: input.checkGrounding,
|
||||||
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
||||||
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
||||||
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BuildAssistantDeepTurnResponseAttemptRuntimeInputInput<ResponseType = unknown> {
|
||||||
|
featureInvestigationStateV1: boolean;
|
||||||
|
featureContractsV11: boolean;
|
||||||
|
featureAnswerPolicyV11: boolean;
|
||||||
|
sessionId: string;
|
||||||
|
questionId: string;
|
||||||
|
userMessage: string;
|
||||||
|
runtimeAnalysisContext: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["runtimeAnalysisContext"];
|
||||||
|
sessionInvestigationState: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["previousInvestigationState"];
|
||||||
|
addressRuntimeMetaForDeep: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["addressRuntimeMetaForDeep"];
|
||||||
|
extractDroppedIntentSegments: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["extractDroppedIntentSegments"];
|
||||||
|
buildDebugRoutes: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["buildDebugRoutes"];
|
||||||
|
extractExecutionState: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["extractExecutionState"];
|
||||||
|
sanitizeReply: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["sanitizeReply"];
|
||||||
|
persistInvestigationState: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["persistInvestigationState"];
|
||||||
|
messageIdFactory: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["messageIdFactory"];
|
||||||
|
appendItem: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["appendItem"];
|
||||||
|
getSession: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["getSession"];
|
||||||
|
persistSession: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["persistSession"];
|
||||||
|
cloneConversation: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["cloneConversation"];
|
||||||
|
logEvent: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["logEvent"];
|
||||||
|
runPackagingRuntime?: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["runPackagingRuntime"];
|
||||||
|
runFinalizeDeepTurn?: RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType>["runFinalizeDeepTurn"];
|
||||||
|
normalizationRuntime: BuildAssistantDeepTurnNormalizationRuntimeOutput;
|
||||||
|
deepTurnAnalysisRuntime: RunAssistantDeepTurnAnalysisRuntimeOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType = unknown>(
|
||||||
|
input: BuildAssistantDeepTurnResponseAttemptRuntimeInputInput<ResponseType>
|
||||||
|
): RunAssistantDeepTurnResponseAttemptRuntimeInput<ResponseType> {
|
||||||
|
return {
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureContractsV11: input.featureContractsV11,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
sessionId: input.sessionId,
|
||||||
|
questionId: input.questionId,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalized: {
|
||||||
|
trace_id: input.normalizationRuntime.normalized.trace_id,
|
||||||
|
prompt_version: input.normalizationRuntime.normalized.prompt_version,
|
||||||
|
schema_version: input.normalizationRuntime.normalized.schema_version,
|
||||||
|
normalized: input.normalizationRuntime.normalized.normalized
|
||||||
|
},
|
||||||
|
normalizedQuestion: input.normalizationRuntime.followupBinding.normalizedQuestion,
|
||||||
|
deepTurnAnalysisRuntime: input.deepTurnAnalysisRuntime,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
followupStateUsage: input.normalizationRuntime.followupBinding.usage,
|
||||||
|
followupApplied: Boolean(
|
||||||
|
(input.normalizationRuntime.followupBinding.usage as { applied?: unknown } | null)?.applied
|
||||||
|
),
|
||||||
|
previousInvestigationState: input.sessionInvestigationState,
|
||||||
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
extractExecutionState: input.extractExecutionState,
|
||||||
|
sanitizeReply: input.sanitizeReply,
|
||||||
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
|
messageIdFactory: input.messageIdFactory,
|
||||||
|
appendItem: input.appendItem,
|
||||||
|
getSession: input.getSession,
|
||||||
|
persistSession: input.persistSession,
|
||||||
|
cloneConversation: input.cloneConversation,
|
||||||
|
logEvent: input.logEvent,
|
||||||
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,11 @@ import {
|
||||||
type RunAssistantDeepTurnResponseAttemptRuntimeInput
|
type RunAssistantDeepTurnResponseAttemptRuntimeInput
|
||||||
} from "./assistantDeepTurnResponseAttemptRuntimeAdapter";
|
} from "./assistantDeepTurnResponseAttemptRuntimeAdapter";
|
||||||
import type { RunAssistantDeepTurnAnalysisRuntimeOutput } from "./assistantDeepTurnAnalysisRuntimeAdapter";
|
import type { RunAssistantDeepTurnAnalysisRuntimeOutput } from "./assistantDeepTurnAnalysisRuntimeAdapter";
|
||||||
|
import {
|
||||||
|
buildAssistantDeepTurnAnalysisAttemptRuntimeInput,
|
||||||
|
buildAssistantDeepTurnNormalizationRuntimeInput,
|
||||||
|
buildAssistantDeepTurnResponseAttemptRuntimeInput
|
||||||
|
} from "./assistantDeepTurnAttemptInputBuilder";
|
||||||
|
|
||||||
export interface RunAssistantDeepTurnAttemptRuntimeInput<ResponseType = AssistantMessageResponsePayload> {
|
export interface RunAssistantDeepTurnAttemptRuntimeInput<ResponseType = AssistantMessageResponsePayload> {
|
||||||
sessionId: string;
|
sessionId: string;
|
||||||
|
|
@ -90,80 +95,73 @@ export async function runAssistantDeepTurnAttemptRuntime<ResponseType = Assistan
|
||||||
const runDeepTurnResponseAttemptRuntimeSafe =
|
const runDeepTurnResponseAttemptRuntimeSafe =
|
||||||
input.runDeepTurnResponseAttemptRuntime ?? runAssistantDeepTurnResponseAttemptRuntime;
|
input.runDeepTurnResponseAttemptRuntime ?? runAssistantDeepTurnResponseAttemptRuntime;
|
||||||
|
|
||||||
const normalizationRuntime = await runDeepTurnNormalizationRuntimeSafe({
|
const normalizationRuntime = await runDeepTurnNormalizationRuntimeSafe(
|
||||||
userMessage: input.userMessage,
|
buildAssistantDeepTurnNormalizationRuntimeInput({
|
||||||
payload: input.payload,
|
userMessage: input.userMessage,
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
payload: input.payload,
|
||||||
featureStateFollowupBindingV1: input.featureStateFollowupBindingV1,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
sessionInvestigationState: input.sessionInvestigationState,
|
featureStateFollowupBindingV1: input.featureStateFollowupBindingV1,
|
||||||
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
normalize: input.normalize
|
buildFollowupStateBinding: input.buildFollowupStateBinding,
|
||||||
});
|
normalize: input.normalize
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const followupBinding = normalizationRuntime.followupBinding;
|
const deepTurnAnalysisRuntime = await runDeepTurnAnalysisAttemptRuntimeSafe(
|
||||||
const normalized = normalizationRuntime.normalized;
|
buildAssistantDeepTurnAnalysisAttemptRuntimeInput({
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
||||||
|
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
||||||
|
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
||||||
|
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
||||||
|
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext,
|
||||||
|
extractRequirements: input.extractRequirements,
|
||||||
|
toExecutionPlan: input.toExecutionPlan,
|
||||||
|
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
||||||
|
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason,
|
||||||
|
buildSkippedResult: input.buildSkippedResult,
|
||||||
|
evaluateCoverage: input.evaluateCoverage,
|
||||||
|
checkGrounding: input.checkGrounding,
|
||||||
|
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
||||||
|
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
||||||
|
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor,
|
||||||
|
normalizationRuntime
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
const deepTurnAnalysisRuntime = await runDeepTurnAnalysisAttemptRuntimeSafe({
|
const deepTurnResponseRuntime = runDeepTurnResponseAttemptRuntimeSafe(
|
||||||
userMessage: input.userMessage,
|
buildAssistantDeepTurnResponseAttemptRuntimeInput({
|
||||||
normalizedPayload: normalized.normalized,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
routeSummary: normalized.route_hint_summary,
|
featureContractsV11: input.featureContractsV11,
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
followupUsage: followupBinding.usage,
|
sessionId: input.sessionId,
|
||||||
investigationState: input.sessionInvestigationState,
|
questionId: input.questionId,
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
userMessage: input.userMessage,
|
||||||
featureProblemCentricAnswerV1: input.featureProblemCentricAnswerV1,
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
featureLifecycleAnswerV1: input.featureLifecycleAnswerV1,
|
sessionInvestigationState: input.sessionInvestigationState,
|
||||||
resolveBusinessScopeAlignment: input.resolveBusinessScopeAlignment,
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
inferP0DomainFromMessage: input.inferP0DomainFromMessage,
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
resolveBusinessScopeFromLiveContext: input.resolveBusinessScopeFromLiveContext,
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
extractRequirements: input.extractRequirements,
|
extractExecutionState: input.extractExecutionState,
|
||||||
toExecutionPlan: input.toExecutionPlan,
|
sanitizeReply: input.sanitizeReply,
|
||||||
enforceRbpLiveRoutePlan: input.enforceRbpLiveRoutePlan,
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
enforceFaLiveRoutePlan: input.enforceFaLiveRoutePlan,
|
messageIdFactory: input.messageIdFactory,
|
||||||
executeRouteRuntime: input.executeRouteRuntime,
|
appendItem: input.appendItem,
|
||||||
mapNoRouteReason: input.mapNoRouteReason,
|
getSession: input.getSession,
|
||||||
buildSkippedResult: input.buildSkippedResult,
|
persistSession: input.persistSession,
|
||||||
evaluateCoverage: input.evaluateCoverage,
|
cloneConversation: input.cloneConversation,
|
||||||
checkGrounding: input.checkGrounding,
|
logEvent: input.logEvent,
|
||||||
collectRbpLiveRouteAudit: input.collectRbpLiveRouteAudit,
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
collectFaLiveRouteAudit: input.collectFaLiveRouteAudit,
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn,
|
||||||
hasExplicitPeriodAnchor: input.hasExplicitPeriodAnchor
|
normalizationRuntime,
|
||||||
});
|
deepTurnAnalysisRuntime
|
||||||
|
})
|
||||||
const deepTurnResponseRuntime = runDeepTurnResponseAttemptRuntimeSafe({
|
);
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
|
||||||
featureContractsV11: input.featureContractsV11,
|
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
|
||||||
sessionId: input.sessionId,
|
|
||||||
questionId: input.questionId,
|
|
||||||
userMessage: input.userMessage,
|
|
||||||
normalized: {
|
|
||||||
trace_id: normalized.trace_id,
|
|
||||||
prompt_version: normalized.prompt_version,
|
|
||||||
schema_version: normalized.schema_version,
|
|
||||||
normalized: normalized.normalized
|
|
||||||
},
|
|
||||||
normalizedQuestion: followupBinding.normalizedQuestion,
|
|
||||||
deepTurnAnalysisRuntime,
|
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
|
||||||
followupStateUsage: followupBinding.usage,
|
|
||||||
followupApplied: Boolean((followupBinding.usage as { applied?: unknown } | null)?.applied),
|
|
||||||
previousInvestigationState: input.sessionInvestigationState,
|
|
||||||
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
|
||||||
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
|
||||||
buildDebugRoutes: input.buildDebugRoutes,
|
|
||||||
extractExecutionState: input.extractExecutionState,
|
|
||||||
sanitizeReply: input.sanitizeReply,
|
|
||||||
persistInvestigationState: input.persistInvestigationState,
|
|
||||||
messageIdFactory: input.messageIdFactory,
|
|
||||||
appendItem: input.appendItem,
|
|
||||||
getSession: input.getSession,
|
|
||||||
persistSession: input.persistSession,
|
|
||||||
cloneConversation: input.cloneConversation,
|
|
||||||
logEvent: input.logEvent,
|
|
||||||
runPackagingRuntime: input.runPackagingRuntime,
|
|
||||||
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
response: deepTurnResponseRuntime.response,
|
response: deepTurnResponseRuntime.response,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {
|
||||||
type RunAssistantDeepTurnResponseRuntimeInput,
|
type RunAssistantDeepTurnResponseRuntimeInput,
|
||||||
type RunAssistantDeepTurnResponseRuntimeOutput
|
type RunAssistantDeepTurnResponseRuntimeOutput
|
||||||
} from "./assistantDeepTurnResponseRuntimeAdapter";
|
} from "./assistantDeepTurnResponseRuntimeAdapter";
|
||||||
|
import { buildAssistantDeepTurnResponseRuntimeInput } from "./assistantDeepTurnResponseRuntimeInputBuilder";
|
||||||
|
|
||||||
export interface RunAssistantDeepTurnResponseAttemptRuntimeInput<
|
export interface RunAssistantDeepTurnResponseAttemptRuntimeInput<
|
||||||
ResponseType = AssistantMessageResponsePayload
|
ResponseType = AssistantMessageResponsePayload
|
||||||
|
|
@ -58,56 +59,37 @@ export function runAssistantDeepTurnResponseAttemptRuntime<
|
||||||
} {
|
} {
|
||||||
const runDeepTurnResponseRuntimeSafe =
|
const runDeepTurnResponseRuntimeSafe =
|
||||||
input.runDeepTurnResponseRuntime ?? runAssistantDeepTurnResponseRuntime;
|
input.runDeepTurnResponseRuntime ?? runAssistantDeepTurnResponseRuntime;
|
||||||
const analysis = input.deepTurnAnalysisRuntime;
|
const responseRuntime = runDeepTurnResponseRuntimeSafe(
|
||||||
const responseRuntime = runDeepTurnResponseRuntimeSafe({
|
buildAssistantDeepTurnResponseRuntimeInput({
|
||||||
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
featureContractsV11: input.featureContractsV11,
|
featureContractsV11: input.featureContractsV11,
|
||||||
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
sessionId: input.sessionId,
|
sessionId: input.sessionId,
|
||||||
questionId: input.questionId,
|
questionId: input.questionId,
|
||||||
userMessage: input.userMessage,
|
userMessage: input.userMessage,
|
||||||
normalized: input.normalized,
|
normalized: input.normalized,
|
||||||
normalizedQuestion: input.normalizedQuestion,
|
normalizedQuestion: input.normalizedQuestion,
|
||||||
routeSummary: analysis.resolvedRouteSummary,
|
deepTurnAnalysisRuntime: input.deepTurnAnalysisRuntime,
|
||||||
executionPlan: analysis.executionPlan,
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
requirementExtractionRequirements: analysis.requirementExtraction.requirements,
|
followupStateUsage: input.followupStateUsage,
|
||||||
coverageEvaluationRequirements: analysis.coverageEvaluation.requirements,
|
followupApplied: input.followupApplied,
|
||||||
coverageReport: analysis.coverageEvaluation.coverage,
|
previousInvestigationState: input.previousInvestigationState,
|
||||||
groundingCheck: analysis.groundingCheck,
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
retrievalCalls: analysis.retrievalCalls,
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
retrievalResultsRaw: analysis.retrievalResultsRaw,
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
retrievalResults: analysis.retrievalResults,
|
extractExecutionState: input.extractExecutionState,
|
||||||
questionTypeClass: analysis.questionTypeClass,
|
sanitizeReply: input.sanitizeReply,
|
||||||
companyAnchors: analysis.companyAnchors,
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
messageIdFactory: input.messageIdFactory,
|
||||||
businessScopeResolution: analysis.businessScopeResolution,
|
appendItem: input.appendItem,
|
||||||
temporalGuard: analysis.temporalGuard,
|
getSession: input.getSession,
|
||||||
polarityAudit: analysis.polarityGuardResult.audit,
|
persistSession: input.persistSession,
|
||||||
claimAnchorAudit: analysis.claimAnchorAudit,
|
cloneConversation: input.cloneConversation,
|
||||||
targetedEvidenceAudit: analysis.targetedEvidenceResult.audit,
|
logEvent: input.logEvent,
|
||||||
evidenceAdmissibilityGateAudit: analysis.evidenceGateResult.audit,
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
rbpLiveRouteAudit: analysis.rbpLiveRouteAudit,
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
faLiveRouteAudit: analysis.faLiveRouteAudit,
|
})
|
||||||
groundedAnswerEligibilityGuard: analysis.groundedAnswerEligibilityGuard,
|
);
|
||||||
followupStateUsage: input.followupStateUsage,
|
|
||||||
followupApplied: input.followupApplied,
|
|
||||||
composition: analysis.composition as any,
|
|
||||||
previousInvestigationState: input.previousInvestigationState ?? null,
|
|
||||||
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
|
||||||
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
|
||||||
buildDebugRoutes: input.buildDebugRoutes,
|
|
||||||
extractExecutionState: input.extractExecutionState,
|
|
||||||
sanitizeReply: input.sanitizeReply,
|
|
||||||
persistInvestigationState: input.persistInvestigationState,
|
|
||||||
messageIdFactory: input.messageIdFactory,
|
|
||||||
appendItem: input.appendItem,
|
|
||||||
getSession: input.getSession,
|
|
||||||
persistSession: input.persistSession,
|
|
||||||
cloneConversation: input.cloneConversation,
|
|
||||||
logEvent: input.logEvent,
|
|
||||||
runPackagingRuntime: input.runPackagingRuntime,
|
|
||||||
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
response: responseRuntime.response as ResponseType,
|
response: responseRuntime.response as ResponseType,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
import type { RunAssistantDeepTurnAnalysisRuntimeOutput } from "./assistantDeepTurnAnalysisRuntimeAdapter";
|
||||||
|
import type { RunAssistantDeepTurnResponseRuntimeInput } from "./assistantDeepTurnResponseRuntimeAdapter";
|
||||||
|
|
||||||
|
export interface BuildAssistantDeepTurnResponseRuntimeInputInput {
|
||||||
|
featureInvestigationStateV1: boolean;
|
||||||
|
featureContractsV11: boolean;
|
||||||
|
featureAnswerPolicyV11: boolean;
|
||||||
|
sessionId: string;
|
||||||
|
questionId: string;
|
||||||
|
userMessage: string;
|
||||||
|
normalized: RunAssistantDeepTurnResponseRuntimeInput["normalized"];
|
||||||
|
normalizedQuestion: string;
|
||||||
|
deepTurnAnalysisRuntime: RunAssistantDeepTurnAnalysisRuntimeOutput;
|
||||||
|
runtimeAnalysisContext: RunAssistantDeepTurnResponseRuntimeInput["runtimeAnalysisContext"];
|
||||||
|
followupStateUsage: RunAssistantDeepTurnResponseRuntimeInput["followupStateUsage"];
|
||||||
|
followupApplied: boolean;
|
||||||
|
previousInvestigationState: RunAssistantDeepTurnResponseRuntimeInput["previousInvestigationState"];
|
||||||
|
addressRuntimeMetaForDeep: RunAssistantDeepTurnResponseRuntimeInput["addressRuntimeMetaForDeep"];
|
||||||
|
extractDroppedIntentSegments: RunAssistantDeepTurnResponseRuntimeInput["extractDroppedIntentSegments"];
|
||||||
|
buildDebugRoutes: RunAssistantDeepTurnResponseRuntimeInput["buildDebugRoutes"];
|
||||||
|
extractExecutionState: RunAssistantDeepTurnResponseRuntimeInput["extractExecutionState"];
|
||||||
|
sanitizeReply: RunAssistantDeepTurnResponseRuntimeInput["sanitizeReply"];
|
||||||
|
persistInvestigationState: RunAssistantDeepTurnResponseRuntimeInput["persistInvestigationState"];
|
||||||
|
messageIdFactory: RunAssistantDeepTurnResponseRuntimeInput["messageIdFactory"];
|
||||||
|
appendItem: RunAssistantDeepTurnResponseRuntimeInput["appendItem"];
|
||||||
|
getSession: RunAssistantDeepTurnResponseRuntimeInput["getSession"];
|
||||||
|
persistSession: RunAssistantDeepTurnResponseRuntimeInput["persistSession"];
|
||||||
|
cloneConversation: RunAssistantDeepTurnResponseRuntimeInput["cloneConversation"];
|
||||||
|
logEvent: RunAssistantDeepTurnResponseRuntimeInput["logEvent"];
|
||||||
|
runPackagingRuntime?: RunAssistantDeepTurnResponseRuntimeInput["runPackagingRuntime"];
|
||||||
|
runFinalizeDeepTurn?: RunAssistantDeepTurnResponseRuntimeInput["runFinalizeDeepTurn"];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildAssistantDeepTurnResponseRuntimeInput(
|
||||||
|
input: BuildAssistantDeepTurnResponseRuntimeInputInput
|
||||||
|
): RunAssistantDeepTurnResponseRuntimeInput {
|
||||||
|
const analysis = input.deepTurnAnalysisRuntime;
|
||||||
|
return {
|
||||||
|
featureInvestigationStateV1: input.featureInvestigationStateV1,
|
||||||
|
featureContractsV11: input.featureContractsV11,
|
||||||
|
featureAnswerPolicyV11: input.featureAnswerPolicyV11,
|
||||||
|
sessionId: input.sessionId,
|
||||||
|
questionId: input.questionId,
|
||||||
|
userMessage: input.userMessage,
|
||||||
|
normalized: input.normalized,
|
||||||
|
normalizedQuestion: input.normalizedQuestion,
|
||||||
|
routeSummary: analysis.resolvedRouteSummary,
|
||||||
|
executionPlan: analysis.executionPlan,
|
||||||
|
requirementExtractionRequirements: analysis.requirementExtraction.requirements,
|
||||||
|
coverageEvaluationRequirements: analysis.coverageEvaluation.requirements,
|
||||||
|
coverageReport: analysis.coverageEvaluation.coverage,
|
||||||
|
groundingCheck: analysis.groundingCheck,
|
||||||
|
retrievalCalls: analysis.retrievalCalls,
|
||||||
|
retrievalResultsRaw: analysis.retrievalResultsRaw,
|
||||||
|
retrievalResults: analysis.retrievalResults,
|
||||||
|
questionTypeClass: analysis.questionTypeClass,
|
||||||
|
companyAnchors: analysis.companyAnchors,
|
||||||
|
runtimeAnalysisContext: input.runtimeAnalysisContext,
|
||||||
|
businessScopeResolution: analysis.businessScopeResolution,
|
||||||
|
temporalGuard: analysis.temporalGuard,
|
||||||
|
polarityAudit: analysis.polarityGuardResult.audit,
|
||||||
|
claimAnchorAudit: analysis.claimAnchorAudit,
|
||||||
|
targetedEvidenceAudit: analysis.targetedEvidenceResult.audit,
|
||||||
|
evidenceAdmissibilityGateAudit: analysis.evidenceGateResult.audit,
|
||||||
|
rbpLiveRouteAudit: analysis.rbpLiveRouteAudit,
|
||||||
|
faLiveRouteAudit: analysis.faLiveRouteAudit,
|
||||||
|
groundedAnswerEligibilityGuard: analysis.groundedAnswerEligibilityGuard,
|
||||||
|
followupStateUsage: input.followupStateUsage,
|
||||||
|
followupApplied: input.followupApplied,
|
||||||
|
composition: analysis.composition as any,
|
||||||
|
previousInvestigationState: input.previousInvestigationState ?? null,
|
||||||
|
addressRuntimeMetaForDeep: input.addressRuntimeMetaForDeep,
|
||||||
|
extractDroppedIntentSegments: input.extractDroppedIntentSegments,
|
||||||
|
buildDebugRoutes: input.buildDebugRoutes,
|
||||||
|
extractExecutionState: input.extractExecutionState,
|
||||||
|
sanitizeReply: input.sanitizeReply,
|
||||||
|
persistInvestigationState: input.persistInvestigationState,
|
||||||
|
messageIdFactory: input.messageIdFactory,
|
||||||
|
appendItem: input.appendItem,
|
||||||
|
getSession: input.getSession,
|
||||||
|
persistSession: input.persistSession,
|
||||||
|
cloneConversation: input.cloneConversation,
|
||||||
|
logEvent: input.logEvent,
|
||||||
|
runPackagingRuntime: input.runPackagingRuntime,
|
||||||
|
runFinalizeDeepTurn: input.runFinalizeDeepTurn
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import { buildAssistantDeepTurnAnalysisRuntimeInput } from "../src/services/assistantDeepTurnAnalysisAttemptInputBuilder";
|
||||||
|
|
||||||
|
function buildInput(overrides: Record<string, unknown> = {}) {
|
||||||
|
return {
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
normalizedPayload: { fragments: [] },
|
||||||
|
routeSummary: { mode: "deterministic_v2", decisions: [] },
|
||||||
|
runtimeAnalysisContext: {
|
||||||
|
active: true,
|
||||||
|
as_of_date: "2020-07-31",
|
||||||
|
period_from: null,
|
||||||
|
period_to: null,
|
||||||
|
source: "analysis_context"
|
||||||
|
},
|
||||||
|
followupUsage: { applied: true },
|
||||||
|
investigationState: { session_id: "asst-1" },
|
||||||
|
featureAnswerPolicyV11: true,
|
||||||
|
featureProblemCentricAnswerV1: true,
|
||||||
|
featureLifecycleAnswerV1: true,
|
||||||
|
resolveBusinessScopeAlignment: vi.fn(() => ({ route_summary_resolved: { mode: "deterministic_v2", decisions: [] } })),
|
||||||
|
inferP0DomainFromMessage: vi.fn(() => "settlements_60_62"),
|
||||||
|
resolveBusinessScopeFromLiveContext: vi.fn(({ current }) => current),
|
||||||
|
extractRequirements: vi.fn(() => ({ requirements: [{ id: "R1" }], byFragment: new Map([["F1", ["R1"]]]) })),
|
||||||
|
toExecutionPlan: vi.fn(() => [{ fragment_id: "F1", requirement_ids: ["R1"], route: "store_canonical", should_execute: true }]),
|
||||||
|
enforceRbpLiveRoutePlan: vi.fn(({ executionPlan }) => ({ executionPlan, audit: { rbp: true } })),
|
||||||
|
enforceFaLiveRoutePlan: vi.fn(({ executionPlan }) => ({ executionPlan, audit: { fa: true } })),
|
||||||
|
executeRouteRuntime: vi.fn(async () => ({})),
|
||||||
|
mapNoRouteReason: vi.fn(() => "skipped"),
|
||||||
|
buildSkippedResult: vi.fn(() => ({ status: "skipped" })),
|
||||||
|
evaluateCoverage: vi.fn(() => ({ requirements: [{ id: "R1" }], coverage: {} })),
|
||||||
|
checkGrounding: vi.fn(() => ({ status: "grounded", reasons: [] })),
|
||||||
|
collectRbpLiveRouteAudit: vi.fn(() => ({ routed: 1 })),
|
||||||
|
collectFaLiveRouteAudit: vi.fn(() => ({ routed: 1 })),
|
||||||
|
hasExplicitPeriodAnchor: vi.fn(() => false),
|
||||||
|
runDeepTurnContextRuntimeSafe: vi.fn(() => ({ context: true })),
|
||||||
|
runDeepTurnPlanRuntimeSafe: vi.fn(() => ({ plan: true })),
|
||||||
|
runDeepTurnRetrievalRuntimeSafe: vi.fn(async () => ({ retrieval: true })),
|
||||||
|
runDeepTurnGuardRuntimeSafe: vi.fn(() => ({ guard: true })),
|
||||||
|
runDeepTurnGroundingRuntimeSafe: vi.fn(() => ({ grounding: true })),
|
||||||
|
runDeepTurnCompositionRuntimeSafe: vi.fn(() => ({ composition: true })),
|
||||||
|
...overrides
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("assistant deep turn analysis attempt input builder", () => {
|
||||||
|
it("builds analysis runtime callbacks and delegates stage payload mapping", async () => {
|
||||||
|
const input = buildInput();
|
||||||
|
const runtimeInput = buildAssistantDeepTurnAnalysisRuntimeInput(input);
|
||||||
|
|
||||||
|
runtimeInput.runContextRuntime();
|
||||||
|
runtimeInput.runExecutionPlanRuntime({
|
||||||
|
resolvedRouteSummary: { mode: "deterministic_v2", decisions: [] } as any,
|
||||||
|
claimAnchorAudit: { claim_type: "prove_settlement_closure_state" } as any,
|
||||||
|
temporalGuard: { primary_period_window: {} },
|
||||||
|
domainPolarityGuardInitial: { polarity: "supplier_payable" }
|
||||||
|
});
|
||||||
|
await runtimeInput.runRetrievalRuntime({
|
||||||
|
executionPlan: [{ fragment_id: "F1", route: "store_canonical" }],
|
||||||
|
liveTemporalHint: { as_of_date: "2020-07-31", period_from: null, period_to: null, source: "analysis_context" }
|
||||||
|
} as any);
|
||||||
|
runtimeInput.runGuardRuntime({
|
||||||
|
retrievalResults: [],
|
||||||
|
domainPolarityGuardInitial: { polarity: "supplier_payable" },
|
||||||
|
claimAnchorAudit: { claim_type: "prove_settlement_closure_state" },
|
||||||
|
temporalGuard: { primary_period_window: {} },
|
||||||
|
focusDomainForGuards: "settlements_60_62",
|
||||||
|
companyAnchors: { accounts: ["60.01"] },
|
||||||
|
userMessage: "runtime-user-message"
|
||||||
|
} as any);
|
||||||
|
runtimeInput.runGroundingRuntime({
|
||||||
|
claimType: "prove_settlement_closure_state",
|
||||||
|
retrievalResults: [],
|
||||||
|
rbpPlanAudit: { rbp: true },
|
||||||
|
faPlanAudit: { fa: true },
|
||||||
|
routeSummary: { mode: "deterministic_v2", decisions: [] },
|
||||||
|
requirementExtraction: { requirements: [{ id: "R1" }], byFragment: new Map([["F1", ["R1"]]]) },
|
||||||
|
temporalGuard: { primary_period_window: {} },
|
||||||
|
polarityAudit: { polarity: "supplier_payable" },
|
||||||
|
evidenceAudit: { admissible_evidence_count: 1 },
|
||||||
|
claimAnchorAudit: { claim_type: "prove_settlement_closure_state" },
|
||||||
|
targetedEvidenceHitRate: 1,
|
||||||
|
businessScopeResolved: ["company_specific_accounting"]
|
||||||
|
} as any);
|
||||||
|
runtimeInput.runCompositionRuntime({
|
||||||
|
resolvedRouteSummary: { mode: "deterministic_v2", decisions: [] },
|
||||||
|
retrievalResults: [],
|
||||||
|
requirements: [{ id: "R1" }],
|
||||||
|
coverageReport: { requirements_total: 1, requirements_covered: 1 },
|
||||||
|
groundingCheck: { status: "grounded", reasons: [] },
|
||||||
|
companyAnchors: { accounts: ["60.01"] }
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
expect(input.runDeepTurnContextRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
runtimeAnalysisContext: expect.objectContaining({ as_of_date: "2020-07-31" }),
|
||||||
|
resolveCompanyAnchors: expect.any(Function)
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(input.runDeepTurnPlanRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
claimType: "prove_settlement_closure_state",
|
||||||
|
userMessage: "why debt not closed"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(input.runDeepTurnRetrievalRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
executeRouteRuntime: input.executeRouteRuntime,
|
||||||
|
mapNoRouteReason: input.mapNoRouteReason
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(input.runDeepTurnGuardRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
userMessage: "runtime-user-message",
|
||||||
|
focusDomainForGuards: "settlements_60_62"
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(input.runDeepTurnGroundingRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
normalizedPayload: { fragments: [] },
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
targetedEvidenceHitRate: 1
|
||||||
|
})
|
||||||
|
);
|
||||||
|
expect(input.runDeepTurnCompositionRuntimeSafe).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
featureAnswerPolicyV11: true,
|
||||||
|
featureProblemCentricAnswerV1: true,
|
||||||
|
featureLifecycleAnswerV1: true
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import {
|
||||||
|
buildAssistantDeepTurnAnalysisAttemptRuntimeInput,
|
||||||
|
buildAssistantDeepTurnNormalizationRuntimeInput,
|
||||||
|
buildAssistantDeepTurnResponseAttemptRuntimeInput
|
||||||
|
} from "../src/services/assistantDeepTurnAttemptInputBuilder";
|
||||||
|
|
||||||
|
function buildNormalizationRuntime(overrides: Record<string, unknown> = {}) {
|
||||||
|
return {
|
||||||
|
followupBinding: {
|
||||||
|
normalizedQuestion: "normalized-question",
|
||||||
|
mergedContext: {},
|
||||||
|
usage: { applied: true }
|
||||||
|
},
|
||||||
|
normalizePayload: {
|
||||||
|
userQuestion: "normalized-question"
|
||||||
|
},
|
||||||
|
normalized: {
|
||||||
|
trace_id: "trace-1",
|
||||||
|
prompt_version: "normalizer_v2_0_2",
|
||||||
|
schema_version: "normalized_query_v2_0_2",
|
||||||
|
normalized: { fragments: [] },
|
||||||
|
route_hint_summary: { mode: "deterministic_v2", decisions: [] }
|
||||||
|
},
|
||||||
|
...overrides
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("assistant deep turn attempt input builder", () => {
|
||||||
|
it("builds normalization runtime input from turn fields", () => {
|
||||||
|
const normalize = vi.fn(async () => ({}));
|
||||||
|
const runtimeInput = buildAssistantDeepTurnNormalizationRuntimeInput({
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
payload: { llmProvider: "openai", context: {} } as any,
|
||||||
|
featureInvestigationStateV1: true,
|
||||||
|
featureStateFollowupBindingV1: true,
|
||||||
|
sessionInvestigationState: { session_id: "asst-1" },
|
||||||
|
buildFollowupStateBinding: vi.fn(() => ({
|
||||||
|
normalizedQuestion: "normalized",
|
||||||
|
mergedContext: {},
|
||||||
|
usage: null
|
||||||
|
})),
|
||||||
|
normalize
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(runtimeInput.userMessage).toBe("why debt not closed");
|
||||||
|
expect(runtimeInput.normalize).toBe(normalize);
|
||||||
|
expect(runtimeInput.featureInvestigationStateV1).toBe(true);
|
||||||
|
expect(runtimeInput.featureStateFollowupBindingV1).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("builds analysis and response attempt inputs from normalization runtime", () => {
|
||||||
|
const normalizationRuntime = buildNormalizationRuntime();
|
||||||
|
const deepTurnAnalysisRuntime = {
|
||||||
|
composition: { reply_type: "partial_coverage" }
|
||||||
|
} as any;
|
||||||
|
|
||||||
|
const analysisInput = buildAssistantDeepTurnAnalysisAttemptRuntimeInput({
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
runtimeAnalysisContext: { active: true, as_of_date: "2020-07-31", period_from: null, period_to: null, source: "analysis_context" },
|
||||||
|
sessionInvestigationState: { session_id: "asst-1" } as any,
|
||||||
|
featureAnswerPolicyV11: true,
|
||||||
|
featureProblemCentricAnswerV1: true,
|
||||||
|
featureLifecycleAnswerV1: true,
|
||||||
|
resolveBusinessScopeAlignment: vi.fn(),
|
||||||
|
inferP0DomainFromMessage: vi.fn(),
|
||||||
|
resolveBusinessScopeFromLiveContext: vi.fn(),
|
||||||
|
extractRequirements: vi.fn(),
|
||||||
|
toExecutionPlan: vi.fn(),
|
||||||
|
enforceRbpLiveRoutePlan: vi.fn(),
|
||||||
|
enforceFaLiveRoutePlan: vi.fn(),
|
||||||
|
executeRouteRuntime: vi.fn(),
|
||||||
|
mapNoRouteReason: vi.fn(),
|
||||||
|
buildSkippedResult: vi.fn(),
|
||||||
|
evaluateCoverage: vi.fn(),
|
||||||
|
checkGrounding: vi.fn(),
|
||||||
|
collectRbpLiveRouteAudit: vi.fn(),
|
||||||
|
collectFaLiveRouteAudit: vi.fn(),
|
||||||
|
hasExplicitPeriodAnchor: vi.fn(),
|
||||||
|
normalizationRuntime
|
||||||
|
});
|
||||||
|
const responseInput = buildAssistantDeepTurnResponseAttemptRuntimeInput({
|
||||||
|
featureInvestigationStateV1: true,
|
||||||
|
featureContractsV11: true,
|
||||||
|
featureAnswerPolicyV11: true,
|
||||||
|
sessionId: "asst-1",
|
||||||
|
questionId: "msg-q1",
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
runtimeAnalysisContext: { as_of_date: "2020-07-31" } as any,
|
||||||
|
sessionInvestigationState: { session_id: "asst-1" } as any,
|
||||||
|
addressRuntimeMetaForDeep: null,
|
||||||
|
extractDroppedIntentSegments: vi.fn(() => []),
|
||||||
|
buildDebugRoutes: vi.fn(() => []),
|
||||||
|
extractExecutionState: vi.fn(() => []),
|
||||||
|
sanitizeReply: vi.fn((value: string) => value),
|
||||||
|
persistInvestigationState: vi.fn(),
|
||||||
|
messageIdFactory: vi.fn(() => "msg-a1"),
|
||||||
|
appendItem: vi.fn(),
|
||||||
|
getSession: vi.fn(),
|
||||||
|
persistSession: vi.fn(),
|
||||||
|
cloneConversation: vi.fn((items: unknown[]) => items),
|
||||||
|
logEvent: vi.fn(),
|
||||||
|
normalizationRuntime,
|
||||||
|
deepTurnAnalysisRuntime
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(analysisInput.normalizedPayload).toEqual({ fragments: [] });
|
||||||
|
expect(analysisInput.routeSummary).toEqual({ mode: "deterministic_v2", decisions: [] });
|
||||||
|
expect(analysisInput.followupUsage).toEqual({ applied: true });
|
||||||
|
expect(responseInput.normalizedQuestion).toBe("normalized-question");
|
||||||
|
expect(responseInput.normalized.trace_id).toBe("trace-1");
|
||||||
|
expect(responseInput.followupApplied).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
import { describe, expect, it, vi } from "vitest";
|
||||||
|
import { buildAssistantDeepTurnResponseRuntimeInput } from "../src/services/assistantDeepTurnResponseRuntimeInputBuilder";
|
||||||
|
|
||||||
|
function buildDeepRuntime() {
|
||||||
|
return {
|
||||||
|
companyAnchors: { accounts: ["60.01"] },
|
||||||
|
temporalGuard: { primary_period_window: { from: "2020-07-01", to: "2020-07-31" } },
|
||||||
|
claimAnchorAudit: { claim_type: "prove_settlement_closure_state" },
|
||||||
|
businessScopeResolution: { business_scope_resolved: ["company_specific_accounting"] },
|
||||||
|
resolvedRouteSummary: { mode: "deterministic_v2", decisions: [] as any[] },
|
||||||
|
requirementExtraction: {
|
||||||
|
requirements: [{ id: "R1" }],
|
||||||
|
byFragment: new Map<string, string[]>([["F1", ["R1"]]])
|
||||||
|
},
|
||||||
|
executionPlan: [{ fragment_id: "F1", route: "store_canonical" }],
|
||||||
|
retrievalCalls: [{ fragment_id: "F1", route: "store_canonical" }],
|
||||||
|
retrievalResultsRaw: [{ fragment_id: "F1", route: "store_canonical", raw_result: {} }],
|
||||||
|
retrievalResults: [{ fragment_id: "F1", requirement_ids: ["R1"] }],
|
||||||
|
polarityGuardResult: { audit: { polarity: "supplier_payable" } },
|
||||||
|
targetedEvidenceResult: { audit: { targeted_evidence_hit_rate: 1 } },
|
||||||
|
evidenceGateResult: { audit: { admissible_evidence_count: 2 } },
|
||||||
|
rbpLiveRouteAudit: { routed: 1 },
|
||||||
|
faLiveRouteAudit: { routed: 1 },
|
||||||
|
coverageEvaluation: {
|
||||||
|
requirements: [{ id: "R1" }],
|
||||||
|
coverage: { requirements_total: 1, requirements_covered: 1 }
|
||||||
|
},
|
||||||
|
groundedAnswerEligibilityGuard: { eligible: true },
|
||||||
|
groundingCheck: { status: "grounded", reasons: [] },
|
||||||
|
questionTypeClass: "causal_trace",
|
||||||
|
composition: { reply_type: "factual_with_explanation", assistant_reply: "ok" }
|
||||||
|
} as any;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe("assistant deep turn response runtime input builder", () => {
|
||||||
|
it("maps analysis runtime into response runtime contract", () => {
|
||||||
|
const runtimeInput = buildAssistantDeepTurnResponseRuntimeInput({
|
||||||
|
featureInvestigationStateV1: true,
|
||||||
|
featureContractsV11: true,
|
||||||
|
featureAnswerPolicyV11: true,
|
||||||
|
sessionId: "asst-1",
|
||||||
|
questionId: "msg-q1",
|
||||||
|
userMessage: "why debt not closed",
|
||||||
|
normalized: {
|
||||||
|
trace_id: "trace-1",
|
||||||
|
prompt_version: "normalizer_v2_0_2",
|
||||||
|
schema_version: "normalized_query_v2_0_2",
|
||||||
|
normalized: { fragments: [] }
|
||||||
|
},
|
||||||
|
normalizedQuestion: "normalized-question",
|
||||||
|
deepTurnAnalysisRuntime: buildDeepRuntime(),
|
||||||
|
runtimeAnalysisContext: { as_of_date: "2020-07-31" },
|
||||||
|
followupStateUsage: { applied: true },
|
||||||
|
followupApplied: true,
|
||||||
|
previousInvestigationState: null,
|
||||||
|
addressRuntimeMetaForDeep: null,
|
||||||
|
extractDroppedIntentSegments: vi.fn(() => []),
|
||||||
|
buildDebugRoutes: vi.fn(() => []),
|
||||||
|
extractExecutionState: vi.fn(() => []),
|
||||||
|
sanitizeReply: vi.fn((value: string) => value),
|
||||||
|
persistInvestigationState: vi.fn(),
|
||||||
|
messageIdFactory: vi.fn(() => "msg-a1"),
|
||||||
|
appendItem: vi.fn(),
|
||||||
|
getSession: vi.fn(),
|
||||||
|
persistSession: vi.fn(),
|
||||||
|
cloneConversation: vi.fn((items: unknown[]) => items),
|
||||||
|
logEvent: vi.fn()
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(runtimeInput.routeSummary).toEqual({ mode: "deterministic_v2", decisions: [] });
|
||||||
|
expect(runtimeInput.requirementExtractionRequirements).toEqual([{ id: "R1" }]);
|
||||||
|
expect(runtimeInput.coverageEvaluationRequirements).toEqual([{ id: "R1" }]);
|
||||||
|
expect(runtimeInput.questionTypeClass).toBe("causal_trace");
|
||||||
|
expect(runtimeInput.polarityAudit).toEqual({ polarity: "supplier_payable" });
|
||||||
|
expect(runtimeInput.targetedEvidenceAudit).toEqual({ targeted_evidence_hit_rate: 1 });
|
||||||
|
expect(runtimeInput.evidenceAdmissibilityGateAudit).toEqual({ admissible_evidence_count: 2 });
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue