ГЛОБАЛЬНЫЙ РЕФАКТОРИНГ АРХИТЕКТУРЫ - Рефакторинг этапов 2.109 - 2.112 - Ужесточение типы plan-аудита и live-route аудита в deep grounding
This commit is contained in:
parent
44eccb3d26
commit
19f5f19d8e
|
|
@ -2043,7 +2043,60 @@ Validation:
|
||||||
- `assistantDeepTurnAttemptRuntimeAdapter.test.ts`
|
- `assistantDeepTurnAttemptRuntimeAdapter.test.ts`
|
||||||
- `assistantDeepTurnAttemptInputBuilder.test.ts`
|
- `assistantDeepTurnAttemptInputBuilder.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 + 2.61 + 2.62 + 2.63 + 2.64 + 2.65 + 2.66 + 2.67 + 2.68 + 2.69 + 2.70 + 2.71 + 2.72 + 2.73 + 2.74 + 2.75 + 2.76 + 2.77 + 2.78 + 2.79 + 2.80 + 2.81 + 2.82 + 2.83 + 2.84 + 2.85 + 2.86 + 2.87 + 2.88 + 2.89 + 2.90 + 2.91 + 2.92 + 2.93 + 2.94 + 2.95 + 2.96 + 2.97 + 2.98 + 2.99 + 2.100 completed)**
|
Implemented in current pass (Phase 2.101 + 2.102 + 2.103 + 2.104):
|
||||||
|
1. Tightened company-anchors and business-scope contracts in deep analysis runtime:
|
||||||
|
- `assistantDeepTurnContextRuntimeAdapter.ts`
|
||||||
|
- `assistantDeepTurnAnalysisRuntimeAdapter.ts`
|
||||||
|
- `companyAnchors` now typed as `CompanyAnchorSet | null`;
|
||||||
|
- `businessScopeResolution` now typed as `AssistantBusinessScopeResolution`.
|
||||||
|
2. Aligned composition runtime input to accept typed anchors:
|
||||||
|
- `assistantDeepTurnAnalysisRuntimeAdapter.ts`
|
||||||
|
- `runCompositionRuntime` now expects `CompanyAnchorSet | null`.
|
||||||
|
3. Preserved behavior:
|
||||||
|
- no runtime logic changes; type alignment only.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
1. `npm run build` passed.
|
||||||
|
2. Targeted deep analysis pack passed:
|
||||||
|
- `assistantDeepTurnAnalysisRuntimeAdapter.test.ts`
|
||||||
|
- `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts`
|
||||||
|
- `assistantDeepTurnCompositionRuntimeAdapter.test.ts`
|
||||||
|
|
||||||
|
Implemented in current pass (Phase 2.105 + 2.106 + 2.107 + 2.108):
|
||||||
|
1. Hardened raw retrieval normalization without changing output:
|
||||||
|
- `retrievalResultNormalizer.ts`
|
||||||
|
- added `normalizeRawRetrievalResult(...)` to avoid unsafe raw casting;
|
||||||
|
- added `normalizeNumberRecord(...)` to replace `Record<string, number>` casts for lifecycle distributions.
|
||||||
|
2. Preserved behavior:
|
||||||
|
- no logic changes; only safer normalization of raw payload shapes.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
1. `npm run build` passed.
|
||||||
|
2. Targeted retrieval normalization pack passed:
|
||||||
|
- `retrievalResultEvidenceEnrichment.test.ts`
|
||||||
|
- `retrievalProblemUnitDualPayload.test.ts`
|
||||||
|
- `retrievalLifecycleRuntimeRollout.test.ts`
|
||||||
|
- `retrievalGraphRuntimeDualPayload.test.ts`
|
||||||
|
|
||||||
|
Implemented in current pass (Phase 2.109 + 2.110 + 2.111 + 2.112):
|
||||||
|
1. Tightened plan-audit and live-route audit typing for deep grounding:
|
||||||
|
- `assistantDeepTurnPlanRuntimeAdapter.ts`
|
||||||
|
- `assistantDeepTurnGroundingRuntimeAdapter.ts`
|
||||||
|
- `assistantDeepTurnAnalysisRuntimeAdapter.ts`
|
||||||
|
- `rbpPlanAudit` / `faPlanAudit` now use `Record<string, unknown> | null` contract;
|
||||||
|
- live route audits now typed to `RbpLiveRouteAuditDebug | null` / `FaLiveRouteAuditDebug | null`;
|
||||||
|
- grounded eligibility guard now typed to `GroundedAnswerEligibilityGuardDebug`.
|
||||||
|
2. Preserved behavior:
|
||||||
|
- no runtime logic changes; type alignment only.
|
||||||
|
|
||||||
|
Validation:
|
||||||
|
1. `npm run build` passed.
|
||||||
|
2. Targeted deep grounding pack passed:
|
||||||
|
- `assistantDeepTurnGroundingRuntimeAdapter.test.ts`
|
||||||
|
- `assistantDeepTurnAnalysisRuntimeAdapter.test.ts`
|
||||||
|
- `assistantDeepTurnAnalysisAttemptRuntimeAdapter.test.ts`
|
||||||
|
|
||||||
|
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 + 2.61 + 2.62 + 2.63 + 2.64 + 2.65 + 2.66 + 2.67 + 2.68 + 2.69 + 2.70 + 2.71 + 2.72 + 2.73 + 2.74 + 2.75 + 2.76 + 2.77 + 2.78 + 2.79 + 2.80 + 2.81 + 2.82 + 2.83 + 2.84 + 2.85 + 2.86 + 2.87 + 2.88 + 2.89 + 2.90 + 2.91 + 2.92 + 2.93 + 2.94 + 2.95 + 2.96 + 2.97 + 2.98 + 2.99 + 2.100 + 2.101 + 2.102 + 2.103 + 2.104 + 2.105 + 2.106 + 2.107 + 2.108 + 2.109 + 2.110 + 2.111 + 2.112 completed)**
|
||||||
|
|
||||||
## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards)
|
## Stage 3 (P2): Hybrid Semantic Layer (LLM + Deterministic Guards)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,26 @@ function toObject(value) {
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
function normalizeRawRetrievalResult(raw) {
|
||||||
|
const source = toObject(raw);
|
||||||
|
if (!source) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: source.status,
|
||||||
|
result_type: source.result_type,
|
||||||
|
items: source.items,
|
||||||
|
summary: source.summary,
|
||||||
|
evidence: source.evidence,
|
||||||
|
why_included: source.why_included,
|
||||||
|
selection_reason: source.selection_reason,
|
||||||
|
risk_factors: source.risk_factors,
|
||||||
|
business_interpretation: source.business_interpretation,
|
||||||
|
confidence: source.confidence,
|
||||||
|
limitations: source.limitations,
|
||||||
|
errors: source.errors
|
||||||
|
};
|
||||||
|
}
|
||||||
function toStringOrNull(value) {
|
function toStringOrNull(value) {
|
||||||
if (typeof value !== "string")
|
if (typeof value !== "string")
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -61,6 +81,19 @@ function normalizeStringArray(value) {
|
||||||
}
|
}
|
||||||
return value.map((item) => String(item));
|
return value.map((item) => String(item));
|
||||||
}
|
}
|
||||||
|
function normalizeNumberRecord(value) {
|
||||||
|
const source = toObject(value);
|
||||||
|
if (!source) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const result = {};
|
||||||
|
for (const [key, entry] of Object.entries(source)) {
|
||||||
|
if (typeof entry === "number" && Number.isFinite(entry)) {
|
||||||
|
result[key] = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
function mergeSummaryWithProblemUnitMeta(summary, input) {
|
function mergeSummaryWithProblemUnitMeta(summary, input) {
|
||||||
return {
|
return {
|
||||||
...summary,
|
...summary,
|
||||||
|
|
@ -391,7 +424,7 @@ function normalizeEvidenceItems(fragmentId, requirementIds, route, value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function normalizeRetrievalResult(fragmentId, requirementIds, route, raw) {
|
function normalizeRetrievalResult(fragmentId, requirementIds, route, raw) {
|
||||||
const rawResult = toObject(raw) ?? {};
|
const rawResult = normalizeRawRetrievalResult(raw);
|
||||||
const items = normalizeObjectArray(rawResult.items);
|
const items = normalizeObjectArray(rawResult.items);
|
||||||
const summary = normalizeSummary(rawResult.summary);
|
const summary = normalizeSummary(rawResult.summary);
|
||||||
const evidence = normalizeEvidenceItems(fragmentId, requirementIds, route, rawResult.evidence);
|
const evidence = normalizeEvidenceItems(fragmentId, requirementIds, route, rawResult.evidence);
|
||||||
|
|
@ -457,8 +490,8 @@ function normalizeRetrievalResult(fragmentId, requirementIds, route, raw) {
|
||||||
severityDistribution: graphBoundSummary.severity_distribution,
|
severityDistribution: graphBoundSummary.severity_distribution,
|
||||||
confidenceDistribution: graphBoundSummary.confidence_distribution,
|
confidenceDistribution: graphBoundSummary.confidence_distribution,
|
||||||
lifecycleEnrichedUnits: graphBoundSummary.lifecycle_enriched_units ?? 0,
|
lifecycleEnrichedUnits: graphBoundSummary.lifecycle_enriched_units ?? 0,
|
||||||
lifecycleDomainDistribution: (graphBoundSummary.lifecycle_domain_distribution ?? {}),
|
lifecycleDomainDistribution: normalizeNumberRecord(graphBoundSummary.lifecycle_domain_distribution),
|
||||||
lifecycleDefectDistribution: (graphBoundSummary.lifecycle_defect_distribution ?? {})
|
lifecycleDefectDistribution: normalizeNumberRecord(graphBoundSummary.lifecycle_defect_distribution)
|
||||||
});
|
});
|
||||||
if (graphBuild) {
|
if (graphBuild) {
|
||||||
enrichedSummary = mergeSummaryWithGraphMeta(enrichedSummary, graphBuild.summary);
|
enrichedSummary = mergeSummaryWithGraphMeta(enrichedSummary, graphBuild.summary);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import type {
|
||||||
AssistantDeepTurnRetrievalGuardPipelineInput,
|
AssistantDeepTurnRetrievalGuardPipelineInput,
|
||||||
AssistantDeepTurnRetrievalGuardPipelineOutput
|
AssistantDeepTurnRetrievalGuardPipelineOutput
|
||||||
} from "./assistantDeepTurnGuardRuntimeAdapter";
|
} from "./assistantDeepTurnGuardRuntimeAdapter";
|
||||||
|
import type { AssistantBusinessScopeResolution } from "./assistantDeepTurnContextRuntimeAdapter";
|
||||||
import type {
|
import type {
|
||||||
AssistantPlanEnforcementAuditLike,
|
AssistantPlanEnforcementAuditLike,
|
||||||
AssistantRequirementExtractionLike
|
AssistantRequirementExtractionLike
|
||||||
|
|
@ -20,17 +21,15 @@ import type {
|
||||||
} from "./assistantDeepTurnGroundingRuntimeAdapter";
|
} from "./assistantDeepTurnGroundingRuntimeAdapter";
|
||||||
import type { AssistantDeepTurnCompositionOutput } from "./assistantDeepTurnCompositionRuntimeAdapter";
|
import type { AssistantDeepTurnCompositionOutput } from "./assistantDeepTurnCompositionRuntimeAdapter";
|
||||||
import type { DomainPolarityGuardAudit, TemporalGuardAudit } from "./assistantRuntimeGuards";
|
import type { DomainPolarityGuardAudit, TemporalGuardAudit } from "./assistantRuntimeGuards";
|
||||||
|
import type { CompanyAnchorSet } from "./companyAnchorResolver";
|
||||||
|
|
||||||
export interface AssistantDeepTurnRuntimeContextLike {
|
export interface AssistantDeepTurnRuntimeContextLike {
|
||||||
companyAnchors: AssistantDeepTurnRetrievalGuardPipelineInput["companyAnchors"];
|
companyAnchors: CompanyAnchorSet | null;
|
||||||
focusDomainForGuards: AssistantDeepTurnRetrievalGuardPipelineInput["focusDomainForGuards"];
|
focusDomainForGuards: AssistantDeepTurnRetrievalGuardPipelineInput["focusDomainForGuards"];
|
||||||
temporalGuard: TemporalGuardAudit;
|
temporalGuard: TemporalGuardAudit;
|
||||||
domainPolarityGuardInitial: DomainPolarityGuardAudit;
|
domainPolarityGuardInitial: DomainPolarityGuardAudit;
|
||||||
claimAnchorAudit: ClaimBoundAnchorAudit;
|
claimAnchorAudit: ClaimBoundAnchorAudit;
|
||||||
businessScopeResolution: {
|
businessScopeResolution: AssistantBusinessScopeResolution;
|
||||||
business_scope_resolved?: string[] | null;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
resolvedRouteSummary: RouteHintSummary | null;
|
resolvedRouteSummary: RouteHintSummary | null;
|
||||||
liveTemporalHint: AssistantLiveTemporalHint | null;
|
liveTemporalHint: AssistantLiveTemporalHint | null;
|
||||||
}
|
}
|
||||||
|
|
@ -65,8 +64,8 @@ export interface RunAssistantDeepTurnAnalysisRuntimeInput {
|
||||||
runGroundingRuntime: (input: {
|
runGroundingRuntime: (input: {
|
||||||
claimType: string;
|
claimType: string;
|
||||||
retrievalResults: UnifiedRetrievalResult[];
|
retrievalResults: UnifiedRetrievalResult[];
|
||||||
rbpPlanAudit: unknown;
|
rbpPlanAudit: AssistantDeepTurnGroundingRuntimeInput["rbpPlanAudit"];
|
||||||
faPlanAudit: unknown;
|
faPlanAudit: AssistantDeepTurnGroundingRuntimeInput["faPlanAudit"];
|
||||||
routeSummary: RouteHintSummary | null;
|
routeSummary: RouteHintSummary | null;
|
||||||
requirementExtraction: AssistantRequirementExtractionLike;
|
requirementExtraction: AssistantRequirementExtractionLike;
|
||||||
temporalGuard: AssistantDeepTurnGroundingRuntimeInput["temporalGuard"];
|
temporalGuard: AssistantDeepTurnGroundingRuntimeInput["temporalGuard"];
|
||||||
|
|
@ -82,13 +81,13 @@ export interface RunAssistantDeepTurnAnalysisRuntimeInput {
|
||||||
requirements: AssistantRequirement[];
|
requirements: AssistantRequirement[];
|
||||||
coverageReport: RequirementCoverageReport;
|
coverageReport: RequirementCoverageReport;
|
||||||
groundingCheck: AnswerGroundingCheck;
|
groundingCheck: AnswerGroundingCheck;
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet | null;
|
||||||
}) => AssistantDeepTurnCompositionOutput;
|
}) => AssistantDeepTurnCompositionOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RunAssistantDeepTurnAnalysisRuntimeOutput {
|
export interface RunAssistantDeepTurnAnalysisRuntimeOutput {
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet | null;
|
||||||
temporalGuard: unknown;
|
temporalGuard: TemporalGuardAudit;
|
||||||
claimAnchorAudit: AssistantDeepTurnRuntimeContextLike["claimAnchorAudit"];
|
claimAnchorAudit: AssistantDeepTurnRuntimeContextLike["claimAnchorAudit"];
|
||||||
businessScopeResolution: AssistantDeepTurnRuntimeContextLike["businessScopeResolution"];
|
businessScopeResolution: AssistantDeepTurnRuntimeContextLike["businessScopeResolution"];
|
||||||
resolvedRouteSummary: RouteHintSummary | null;
|
resolvedRouteSummary: RouteHintSummary | null;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import type { ClaimBoundAnchorAudit } from "./assistantClaimBoundEvidence";
|
||||||
import type { AssistantLiveTemporalHint } from "./assistantDeepTurnRetrievalRuntimeAdapter";
|
import type { AssistantLiveTemporalHint } from "./assistantDeepTurnRetrievalRuntimeAdapter";
|
||||||
import { isAssistantFollowupApplied, type AssistantFollowupUsage } from "./assistantFollowupUsage";
|
import { isAssistantFollowupApplied, type AssistantFollowupUsage } from "./assistantFollowupUsage";
|
||||||
import type { DomainPolarityGuardAudit, TemporalGuardAudit } from "./assistantRuntimeGuards";
|
import type { DomainPolarityGuardAudit, TemporalGuardAudit } from "./assistantRuntimeGuards";
|
||||||
|
import type { CompanyAnchorSet } from "./companyAnchorResolver";
|
||||||
|
|
||||||
const KNOWN_P0_DOMAINS = new Set([
|
const KNOWN_P0_DOMAINS = new Set([
|
||||||
"settlements_60_62",
|
"settlements_60_62",
|
||||||
|
|
@ -37,31 +38,28 @@ export interface BuildAssistantDeepTurnRuntimeContextInput {
|
||||||
source: string | null;
|
source: string | null;
|
||||||
};
|
};
|
||||||
followupUsage: AssistantFollowupUsage | null | undefined;
|
followupUsage: AssistantFollowupUsage | null | undefined;
|
||||||
resolveCompanyAnchors: (userMessage: string) => unknown;
|
resolveCompanyAnchors: (userMessage: string) => CompanyAnchorSet;
|
||||||
resolveBusinessScopeAlignment: (input: {
|
resolveBusinessScopeAlignment: (input: {
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
normalized: NormalizeResponsePayload["normalized"];
|
normalized: NormalizeResponsePayload["normalized"];
|
||||||
routeSummary: RouteHintSummary | null;
|
routeSummary: RouteHintSummary | null;
|
||||||
}) => {
|
}) => AssistantBusinessScopeResolution;
|
||||||
route_summary_resolved: RouteHintSummary | null;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
inferP0DomainFromMessage: (userMessage: string) => string | null;
|
inferP0DomainFromMessage: (userMessage: string) => string | null;
|
||||||
resolveTemporalGuard: (input: {
|
resolveTemporalGuard: (input: {
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
normalized: NormalizeResponsePayload["normalized"];
|
normalized: NormalizeResponsePayload["normalized"];
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
analysisContext: AssistantLiveTemporalHint | null;
|
analysisContext: AssistantLiveTemporalHint | null;
|
||||||
}) => TemporalGuardAudit;
|
}) => TemporalGuardAudit;
|
||||||
resolveDomainPolarityGuard: (input: {
|
resolveDomainPolarityGuard: (input: {
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
focusDomainHint: string | null;
|
focusDomainHint: string | null;
|
||||||
}) => DomainPolarityGuardAudit;
|
}) => DomainPolarityGuardAudit;
|
||||||
resolveClaimBoundAnchors: (input: {
|
resolveClaimBoundAnchors: (input: {
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
focusDomainHint: string | null;
|
focusDomainHint: string | null;
|
||||||
primaryPeriod: unknown;
|
primaryPeriod: unknown;
|
||||||
}) => ClaimBoundAnchorAudit;
|
}) => ClaimBoundAnchorAudit;
|
||||||
|
|
@ -74,29 +72,29 @@ export interface BuildAssistantDeepTurnRuntimeContextInput {
|
||||||
claimType: string;
|
claimType: string;
|
||||||
focusDomainHint: string | null;
|
focusDomainHint: string | null;
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
followupApplied: boolean;
|
followupApplied: boolean;
|
||||||
}) => {
|
}) => AssistantBusinessScopeResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AssistantBusinessScopeResolution {
|
||||||
route_summary_resolved: RouteHintSummary | null;
|
route_summary_resolved: RouteHintSummary | null;
|
||||||
|
business_scope_raw?: string[];
|
||||||
|
business_scope_resolved?: string[];
|
||||||
|
company_grounding_applied?: boolean;
|
||||||
|
scope_resolution_reason?: string[];
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BuildAssistantDeepTurnRuntimeContextOutput {
|
export interface BuildAssistantDeepTurnRuntimeContextOutput {
|
||||||
companyAnchors: unknown;
|
companyAnchors: CompanyAnchorSet;
|
||||||
initialBusinessScopeResolution: {
|
initialBusinessScopeResolution: AssistantBusinessScopeResolution;
|
||||||
route_summary_resolved: RouteHintSummary | null;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
inferredDomainByMessage: string | null;
|
inferredDomainByMessage: string | null;
|
||||||
focusDomainForGuards: string | null;
|
focusDomainForGuards: string | null;
|
||||||
temporalGuard: TemporalGuardAudit;
|
temporalGuard: TemporalGuardAudit;
|
||||||
domainPolarityGuardInitial: DomainPolarityGuardAudit;
|
domainPolarityGuardInitial: DomainPolarityGuardAudit;
|
||||||
claimAnchorAudit: ClaimBoundAnchorAudit;
|
claimAnchorAudit: ClaimBoundAnchorAudit;
|
||||||
businessScopeResolution: {
|
businessScopeResolution: AssistantBusinessScopeResolution;
|
||||||
route_summary_resolved: RouteHintSummary | null;
|
|
||||||
[key: string]: unknown;
|
|
||||||
};
|
|
||||||
resolvedRouteSummary: RouteHintSummary | null;
|
resolvedRouteSummary: RouteHintSummary | null;
|
||||||
liveTemporalHint: AssistantLiveTemporalHint | null;
|
liveTemporalHint: AssistantLiveTemporalHint | null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ import type {
|
||||||
AnswerGroundingCheck,
|
AnswerGroundingCheck,
|
||||||
AssistantRequirement,
|
AssistantRequirement,
|
||||||
RequirementCoverageReport,
|
RequirementCoverageReport,
|
||||||
|
RbpLiveRouteAuditDebug,
|
||||||
|
FaLiveRouteAuditDebug,
|
||||||
|
GroundedAnswerEligibilityGuardDebug,
|
||||||
UnifiedRetrievalResult
|
UnifiedRetrievalResult
|
||||||
} from "../types/assistant";
|
} from "../types/assistant";
|
||||||
import type { NormalizeResponsePayload, RouteHintSummary } from "../types/normalizer";
|
import type { NormalizeResponsePayload, RouteHintSummary } from "../types/normalizer";
|
||||||
|
|
@ -16,8 +19,8 @@ import {
|
||||||
export interface AssistantDeepTurnGroundingRuntimeInput {
|
export interface AssistantDeepTurnGroundingRuntimeInput {
|
||||||
claimType: string;
|
claimType: string;
|
||||||
retrievalResults: UnifiedRetrievalResult[];
|
retrievalResults: UnifiedRetrievalResult[];
|
||||||
rbpPlanAudit: unknown;
|
rbpPlanAudit: RbpLiveRouteAuditDebug["plan_override"];
|
||||||
faPlanAudit: unknown;
|
faPlanAudit: FaLiveRouteAuditDebug["plan_override"];
|
||||||
routeSummary: RouteHintSummary | null;
|
routeSummary: RouteHintSummary | null;
|
||||||
normalizedPayload: NormalizeResponsePayload["normalized"] | null | undefined;
|
normalizedPayload: NormalizeResponsePayload["normalized"] | null | undefined;
|
||||||
userMessage: string;
|
userMessage: string;
|
||||||
|
|
@ -46,13 +49,13 @@ export interface AssistantDeepTurnGroundingRuntimeInput {
|
||||||
collectRbpLiveRouteAudit: (input: {
|
collectRbpLiveRouteAudit: (input: {
|
||||||
claimType: string;
|
claimType: string;
|
||||||
retrievalResults: UnifiedRetrievalResult[];
|
retrievalResults: UnifiedRetrievalResult[];
|
||||||
planAudit: unknown;
|
planAudit: RbpLiveRouteAuditDebug["plan_override"];
|
||||||
}) => unknown;
|
}) => RbpLiveRouteAuditDebug | null;
|
||||||
collectFaLiveRouteAudit: (input: {
|
collectFaLiveRouteAudit: (input: {
|
||||||
claimType: string;
|
claimType: string;
|
||||||
retrievalResults: UnifiedRetrievalResult[];
|
retrievalResults: UnifiedRetrievalResult[];
|
||||||
planAudit: unknown;
|
planAudit: FaLiveRouteAuditDebug["plan_override"];
|
||||||
}) => unknown;
|
}) => FaLiveRouteAuditDebug | null;
|
||||||
runCoverageGroundingPipelineFn?: typeof runAssistantCoverageGroundingPipeline;
|
runCoverageGroundingPipelineFn?: typeof runAssistantCoverageGroundingPipeline;
|
||||||
applyGroundingEligibilityFn?: (
|
applyGroundingEligibilityFn?: (
|
||||||
input: AssistantDeepTurnGroundingEligibilityInput<AnswerGroundingCheck>
|
input: AssistantDeepTurnGroundingEligibilityInput<AnswerGroundingCheck>
|
||||||
|
|
@ -60,11 +63,11 @@ export interface AssistantDeepTurnGroundingRuntimeInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AssistantDeepTurnGroundingRuntimeOutput {
|
export interface AssistantDeepTurnGroundingRuntimeOutput {
|
||||||
rbpLiveRouteAudit: unknown;
|
rbpLiveRouteAudit: RbpLiveRouteAuditDebug | null;
|
||||||
faLiveRouteAudit: unknown;
|
faLiveRouteAudit: FaLiveRouteAuditDebug | null;
|
||||||
coverageEvaluation: AssistantCoverageEvaluationResult;
|
coverageEvaluation: AssistantCoverageEvaluationResult;
|
||||||
groundingCheckBase: AnswerGroundingCheck;
|
groundingCheckBase: AnswerGroundingCheck;
|
||||||
groundedAnswerEligibilityGuard: unknown;
|
groundedAnswerEligibilityGuard: GroundedAnswerEligibilityGuardDebug;
|
||||||
groundingCheck: AnswerGroundingCheck;
|
groundingCheck: AnswerGroundingCheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export interface AssistantRequirementExtractionLike {
|
||||||
|
|
||||||
export interface AssistantPlanEnforcementAuditLike {
|
export interface AssistantPlanEnforcementAuditLike {
|
||||||
executionPlan: AssistantExecutionPlanItem[];
|
executionPlan: AssistantExecutionPlanItem[];
|
||||||
audit: unknown;
|
audit: Record<string, unknown> | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BuildAssistantDeepTurnExecutionPlanInput {
|
export interface BuildAssistantDeepTurnExecutionPlanInput {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,27 @@ function toObject(value: unknown): Record<string, unknown> | null {
|
||||||
return value as Record<string, unknown>;
|
return value as Record<string, unknown>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeRawRetrievalResult(raw: unknown): RawRetrievalResult {
|
||||||
|
const source = toObject(raw);
|
||||||
|
if (!source) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: source.status as string | undefined,
|
||||||
|
result_type: source.result_type as string | undefined,
|
||||||
|
items: source.items,
|
||||||
|
summary: source.summary,
|
||||||
|
evidence: source.evidence,
|
||||||
|
why_included: source.why_included,
|
||||||
|
selection_reason: source.selection_reason,
|
||||||
|
risk_factors: source.risk_factors,
|
||||||
|
business_interpretation: source.business_interpretation,
|
||||||
|
confidence: source.confidence,
|
||||||
|
limitations: source.limitations,
|
||||||
|
errors: source.errors
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function toStringOrNull(value: unknown): string | null {
|
function toStringOrNull(value: unknown): string | null {
|
||||||
if (typeof value !== "string") return null;
|
if (typeof value !== "string") return null;
|
||||||
const trimmed = value.trim();
|
const trimmed = value.trim();
|
||||||
|
|
@ -101,6 +122,20 @@ function normalizeStringArray(value: unknown): string[] {
|
||||||
return value.map((item) => String(item));
|
return value.map((item) => String(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeNumberRecord(value: unknown): Record<string, number> {
|
||||||
|
const source = toObject(value);
|
||||||
|
if (!source) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const result: Record<string, number> = {};
|
||||||
|
for (const [key, entry] of Object.entries(source)) {
|
||||||
|
if (typeof entry === "number" && Number.isFinite(entry)) {
|
||||||
|
result[key] = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function mergeSummaryWithProblemUnitMeta(
|
function mergeSummaryWithProblemUnitMeta(
|
||||||
summary: Record<string, unknown>,
|
summary: Record<string, unknown>,
|
||||||
input: {
|
input: {
|
||||||
|
|
@ -511,7 +546,7 @@ export function normalizeRetrievalResult(
|
||||||
route: string,
|
route: string,
|
||||||
raw: unknown
|
raw: unknown
|
||||||
): UnifiedRetrievalResult {
|
): UnifiedRetrievalResult {
|
||||||
const rawResult = (toObject(raw) as RawRetrievalResult | null) ?? {};
|
const rawResult = normalizeRawRetrievalResult(raw);
|
||||||
const items = normalizeObjectArray(rawResult.items);
|
const items = normalizeObjectArray(rawResult.items);
|
||||||
const summary = normalizeSummary(rawResult.summary);
|
const summary = normalizeSummary(rawResult.summary);
|
||||||
const evidence = normalizeEvidenceItems(fragmentId, requirementIds, route, rawResult.evidence);
|
const evidence = normalizeEvidenceItems(fragmentId, requirementIds, route, rawResult.evidence);
|
||||||
|
|
@ -584,8 +619,8 @@ export function normalizeRetrievalResult(
|
||||||
severityDistribution: graphBoundSummary.severity_distribution,
|
severityDistribution: graphBoundSummary.severity_distribution,
|
||||||
confidenceDistribution: graphBoundSummary.confidence_distribution,
|
confidenceDistribution: graphBoundSummary.confidence_distribution,
|
||||||
lifecycleEnrichedUnits: graphBoundSummary.lifecycle_enriched_units ?? 0,
|
lifecycleEnrichedUnits: graphBoundSummary.lifecycle_enriched_units ?? 0,
|
||||||
lifecycleDomainDistribution: (graphBoundSummary.lifecycle_domain_distribution ?? {}) as Record<string, number>,
|
lifecycleDomainDistribution: normalizeNumberRecord(graphBoundSummary.lifecycle_domain_distribution),
|
||||||
lifecycleDefectDistribution: (graphBoundSummary.lifecycle_defect_distribution ?? {}) as Record<string, number>
|
lifecycleDefectDistribution: normalizeNumberRecord(graphBoundSummary.lifecycle_defect_distribution)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (graphBuild) {
|
if (graphBuild) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue