@uns-kit/assistant-workflow 2.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -0
- package/dist/clarification-policy.d.ts +64 -0
- package/dist/clarification-policy.d.ts.map +1 -0
- package/dist/clarification-policy.js +174 -0
- package/dist/clarification-policy.js.map +1 -0
- package/dist/decision.d.ts +37 -0
- package/dist/decision.d.ts.map +1 -0
- package/dist/decision.js +100 -0
- package/dist/decision.js.map +1 -0
- package/dist/definition-catalog-replay.d.ts +25 -0
- package/dist/definition-catalog-replay.d.ts.map +1 -0
- package/dist/definition-catalog-replay.js +54 -0
- package/dist/definition-catalog-replay.js.map +1 -0
- package/dist/definition-catalog.d.ts +45 -0
- package/dist/definition-catalog.d.ts.map +1 -0
- package/dist/definition-catalog.js +97 -0
- package/dist/definition-catalog.js.map +1 -0
- package/dist/definition-diagnostics.d.ts +17 -0
- package/dist/definition-diagnostics.d.ts.map +1 -0
- package/dist/definition-diagnostics.js +353 -0
- package/dist/definition-diagnostics.js.map +1 -0
- package/dist/definition-diff.d.ts +51 -0
- package/dist/definition-diff.d.ts.map +1 -0
- package/dist/definition-diff.js +172 -0
- package/dist/definition-diff.js.map +1 -0
- package/dist/definition-json.d.ts +53 -0
- package/dist/definition-json.d.ts.map +1 -0
- package/dist/definition-json.js +186 -0
- package/dist/definition-json.js.map +1 -0
- package/dist/definition-manifest.d.ts +41 -0
- package/dist/definition-manifest.d.ts.map +1 -0
- package/dist/definition-manifest.js +119 -0
- package/dist/definition-manifest.js.map +1 -0
- package/dist/definition-package-execution-json.d.ts +64 -0
- package/dist/definition-package-execution-json.d.ts.map +1 -0
- package/dist/definition-package-execution-json.js +245 -0
- package/dist/definition-package-execution-json.js.map +1 -0
- package/dist/definition-package-execution-replay.d.ts +14 -0
- package/dist/definition-package-execution-replay.d.ts.map +1 -0
- package/dist/definition-package-execution-replay.js +47 -0
- package/dist/definition-package-execution-replay.js.map +1 -0
- package/dist/definition-package-executor.d.ts +52 -0
- package/dist/definition-package-executor.d.ts.map +1 -0
- package/dist/definition-package-executor.js +70 -0
- package/dist/definition-package-executor.js.map +1 -0
- package/dist/definition-package-loader.d.ts +36 -0
- package/dist/definition-package-loader.d.ts.map +1 -0
- package/dist/definition-package-loader.js +56 -0
- package/dist/definition-package-loader.js.map +1 -0
- package/dist/definition-package-replay.d.ts +28 -0
- package/dist/definition-package-replay.d.ts.map +1 -0
- package/dist/definition-package-replay.js +74 -0
- package/dist/definition-package-replay.js.map +1 -0
- package/dist/definition-package-resolver.d.ts +31 -0
- package/dist/definition-package-resolver.d.ts.map +1 -0
- package/dist/definition-package-resolver.js +60 -0
- package/dist/definition-package-resolver.js.map +1 -0
- package/dist/definition-package-review.d.ts +29 -0
- package/dist/definition-package-review.d.ts.map +1 -0
- package/dist/definition-package-review.js +74 -0
- package/dist/definition-package-review.js.map +1 -0
- package/dist/definition-package-run-report.d.ts +25 -0
- package/dist/definition-package-run-report.d.ts.map +1 -0
- package/dist/definition-package-run-report.js +37 -0
- package/dist/definition-package-run-report.js.map +1 -0
- package/dist/definition-package-run.d.ts +20 -0
- package/dist/definition-package-run.d.ts.map +1 -0
- package/dist/definition-package-run.js +41 -0
- package/dist/definition-package-run.js.map +1 -0
- package/dist/definition-package-selection.d.ts +29 -0
- package/dist/definition-package-selection.d.ts.map +1 -0
- package/dist/definition-package-selection.js +68 -0
- package/dist/definition-package-selection.js.map +1 -0
- package/dist/definition-package-smoke.d.ts +74 -0
- package/dist/definition-package-smoke.d.ts.map +1 -0
- package/dist/definition-package-smoke.js +184 -0
- package/dist/definition-package-smoke.js.map +1 -0
- package/dist/definition-package.d.ts +36 -0
- package/dist/definition-package.d.ts.map +1 -0
- package/dist/definition-package.js +114 -0
- package/dist/definition-package.js.map +1 -0
- package/dist/definition-tuning-approval.d.ts +39 -0
- package/dist/definition-tuning-approval.d.ts.map +1 -0
- package/dist/definition-tuning-approval.js +207 -0
- package/dist/definition-tuning-approval.js.map +1 -0
- package/dist/definition-tuning-json.d.ts +58 -0
- package/dist/definition-tuning-json.d.ts.map +1 -0
- package/dist/definition-tuning-json.js +276 -0
- package/dist/definition-tuning-json.js.map +1 -0
- package/dist/definition-tuning-promotion.d.ts +120 -0
- package/dist/definition-tuning-promotion.d.ts.map +1 -0
- package/dist/definition-tuning-promotion.js +460 -0
- package/dist/definition-tuning-promotion.js.map +1 -0
- package/dist/definition-tuning-replay.d.ts +14 -0
- package/dist/definition-tuning-replay.d.ts.map +1 -0
- package/dist/definition-tuning-replay.js +50 -0
- package/dist/definition-tuning-replay.js.map +1 -0
- package/dist/definition-tuning-review-artifact.d.ts +56 -0
- package/dist/definition-tuning-review-artifact.d.ts.map +1 -0
- package/dist/definition-tuning-review-artifact.js +302 -0
- package/dist/definition-tuning-review-artifact.js.map +1 -0
- package/dist/definition-tuning-review.d.ts +59 -0
- package/dist/definition-tuning-review.d.ts.map +1 -0
- package/dist/definition-tuning-review.js +213 -0
- package/dist/definition-tuning-review.js.map +1 -0
- package/dist/definition-tuning-source-patch.d.ts +43 -0
- package/dist/definition-tuning-source-patch.d.ts.map +1 -0
- package/dist/definition-tuning-source-patch.js +214 -0
- package/dist/definition-tuning-source-patch.js.map +1 -0
- package/dist/definition-tuning.d.ts +73 -0
- package/dist/definition-tuning.d.ts.map +1 -0
- package/dist/definition-tuning.js +426 -0
- package/dist/definition-tuning.js.map +1 -0
- package/dist/definition.d.ts +189 -0
- package/dist/definition.d.ts.map +1 -0
- package/dist/definition.js +494 -0
- package/dist/definition.js.map +1 -0
- package/dist/direct-route-invocation.d.ts +132 -0
- package/dist/direct-route-invocation.d.ts.map +1 -0
- package/dist/direct-route-invocation.js +325 -0
- package/dist/direct-route-invocation.js.map +1 -0
- package/dist/direct-route-policy.d.ts +25 -0
- package/dist/direct-route-policy.d.ts.map +1 -0
- package/dist/direct-route-policy.js +106 -0
- package/dist/direct-route-policy.js.map +1 -0
- package/dist/eval-case.d.ts +85 -0
- package/dist/eval-case.d.ts.map +1 -0
- package/dist/eval-case.js +366 -0
- package/dist/eval-case.js.map +1 -0
- package/dist/eval-replay.d.ts +18 -0
- package/dist/eval-replay.d.ts.map +1 -0
- package/dist/eval-replay.js +41 -0
- package/dist/eval-replay.js.map +1 -0
- package/dist/eval-result.d.ts +46 -0
- package/dist/eval-result.d.ts.map +1 -0
- package/dist/eval-result.js +183 -0
- package/dist/eval-result.js.map +1 -0
- package/dist/eval-runner.d.ts +30 -0
- package/dist/eval-runner.d.ts.map +1 -0
- package/dist/eval-runner.js +57 -0
- package/dist/eval-runner.js.map +1 -0
- package/dist/eval-suite.d.ts +43 -0
- package/dist/eval-suite.d.ts.map +1 -0
- package/dist/eval-suite.js +101 -0
- package/dist/eval-suite.js.map +1 -0
- package/dist/execution-plan.d.ts +43 -0
- package/dist/execution-plan.d.ts.map +1 -0
- package/dist/execution-plan.js +187 -0
- package/dist/execution-plan.js.map +1 -0
- package/dist/hosted-tool-policy.d.ts +70 -0
- package/dist/hosted-tool-policy.d.ts.map +1 -0
- package/dist/hosted-tool-policy.js +228 -0
- package/dist/hosted-tool-policy.js.map +1 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/memory-policy.d.ts +55 -0
- package/dist/memory-policy.d.ts.map +1 -0
- package/dist/memory-policy.js +187 -0
- package/dist/memory-policy.js.map +1 -0
- package/dist/memory-updates.d.ts +39 -0
- package/dist/memory-updates.d.ts.map +1 -0
- package/dist/memory-updates.js +110 -0
- package/dist/memory-updates.js.map +1 -0
- package/dist/outcome-trace.d.ts +79 -0
- package/dist/outcome-trace.d.ts.map +1 -0
- package/dist/outcome-trace.js +117 -0
- package/dist/outcome-trace.js.map +1 -0
- package/dist/outcome.d.ts +97 -0
- package/dist/outcome.d.ts.map +1 -0
- package/dist/outcome.js +160 -0
- package/dist/outcome.js.map +1 -0
- package/dist/planner-compiler.d.ts +14 -0
- package/dist/planner-compiler.d.ts.map +1 -0
- package/dist/planner-compiler.js +26 -0
- package/dist/planner-compiler.js.map +1 -0
- package/dist/planning.d.ts +36 -0
- package/dist/planning.d.ts.map +1 -0
- package/dist/planning.js +141 -0
- package/dist/planning.js.map +1 -0
- package/dist/policy-resolution.d.ts +10 -0
- package/dist/policy-resolution.d.ts.map +1 -0
- package/dist/policy-resolution.js +30 -0
- package/dist/policy-resolution.js.map +1 -0
- package/dist/run-evaluation.d.ts +29 -0
- package/dist/run-evaluation.d.ts.map +1 -0
- package/dist/run-evaluation.js +128 -0
- package/dist/run-evaluation.js.map +1 -0
- package/dist/run-parity.d.ts +24 -0
- package/dist/run-parity.d.ts.map +1 -0
- package/dist/run-parity.js +36 -0
- package/dist/run-parity.js.map +1 -0
- package/dist/run-report-batch.d.ts +150 -0
- package/dist/run-report-batch.d.ts.map +1 -0
- package/dist/run-report-batch.js +391 -0
- package/dist/run-report-batch.js.map +1 -0
- package/dist/run-report-json.d.ts +76 -0
- package/dist/run-report-json.d.ts.map +1 -0
- package/dist/run-report-json.js +451 -0
- package/dist/run-report-json.js.map +1 -0
- package/dist/run-report.d.ts +22 -0
- package/dist/run-report.d.ts.map +1 -0
- package/dist/run-report.js +46 -0
- package/dist/run-report.js.map +1 -0
- package/dist/run.d.ts +20 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +36 -0
- package/dist/run.js.map +1 -0
- package/dist/tool-bindings.d.ts +42 -0
- package/dist/tool-bindings.d.ts.map +1 -0
- package/dist/tool-bindings.js +124 -0
- package/dist/tool-bindings.js.map +1 -0
- package/dist/tool-capabilities.d.ts +37 -0
- package/dist/tool-capabilities.d.ts.map +1 -0
- package/dist/tool-capabilities.js +91 -0
- package/dist/tool-capabilities.js.map +1 -0
- package/dist/tool-executor.d.ts +63 -0
- package/dist/tool-executor.d.ts.map +1 -0
- package/dist/tool-executor.js +176 -0
- package/dist/tool-executor.js.map +1 -0
- package/dist/tool-fixtures.d.ts +18 -0
- package/dist/tool-fixtures.d.ts.map +1 -0
- package/dist/tool-fixtures.js +52 -0
- package/dist/tool-fixtures.js.map +1 -0
- package/dist/tool-invocations.d.ts +31 -0
- package/dist/tool-invocations.d.ts.map +1 -0
- package/dist/tool-invocations.js +79 -0
- package/dist/tool-invocations.js.map +1 -0
- package/dist/tool-provider-executors.d.ts +43 -0
- package/dist/tool-provider-executors.d.ts.map +1 -0
- package/dist/tool-provider-executors.js +59 -0
- package/dist/tool-provider-executors.js.map +1 -0
- package/dist/tool-result-cache.d.ts +37 -0
- package/dist/tool-result-cache.d.ts.map +1 -0
- package/dist/tool-result-cache.js +173 -0
- package/dist/tool-result-cache.js.map +1 -0
- package/dist/tool-results.d.ts +41 -0
- package/dist/tool-results.d.ts.map +1 -0
- package/dist/tool-results.js +137 -0
- package/dist/tool-results.js.map +1 -0
- package/dist/tool-runtime.d.ts +46 -0
- package/dist/tool-runtime.d.ts.map +1 -0
- package/dist/tool-runtime.js +163 -0
- package/dist/tool-runtime.js.map +1 -0
- package/dist/tool-selection-evaluation.d.ts +214 -0
- package/dist/tool-selection-evaluation.d.ts.map +1 -0
- package/dist/tool-selection-evaluation.js +773 -0
- package/dist/tool-selection-evaluation.js.map +1 -0
- package/dist/tool-selection-json.d.ts +71 -0
- package/dist/tool-selection-json.d.ts.map +1 -0
- package/dist/tool-selection-json.js +284 -0
- package/dist/tool-selection-json.js.map +1 -0
- package/dist/tool-selection-policy.d.ts +81 -0
- package/dist/tool-selection-policy.d.ts.map +1 -0
- package/dist/tool-selection-policy.js +376 -0
- package/dist/tool-selection-policy.js.map +1 -0
- package/dist/tool-selection-replay.d.ts +26 -0
- package/dist/tool-selection-replay.d.ts.map +1 -0
- package/dist/tool-selection-replay.js +88 -0
- package/dist/tool-selection-replay.js.map +1 -0
- package/dist/tool-selection-rules.d.ts +46 -0
- package/dist/tool-selection-rules.d.ts.map +1 -0
- package/dist/tool-selection-rules.js +183 -0
- package/dist/tool-selection-rules.js.map +1 -0
- package/dist/tool-selection-trace-export.d.ts +37 -0
- package/dist/tool-selection-trace-export.d.ts.map +1 -0
- package/dist/tool-selection-trace-export.js +324 -0
- package/dist/tool-selection-trace-export.js.map +1 -0
- package/dist/trace-events.d.ts +14 -0
- package/dist/trace-events.d.ts.map +1 -0
- package/dist/trace-events.js +65 -0
- package/dist/trace-events.js.map +1 -0
- package/dist/trace-payload.d.ts +24 -0
- package/dist/trace-payload.d.ts.map +1 -0
- package/dist/trace-payload.js +113 -0
- package/dist/trace-payload.js.map +1 -0
- package/dist/trace-replay.d.ts +276 -0
- package/dist/trace-replay.d.ts.map +1 -0
- package/dist/trace-replay.js +685 -0
- package/dist/trace-replay.js.map +1 -0
- package/dist/trace-report.d.ts +320 -0
- package/dist/trace-report.d.ts.map +1 -0
- package/dist/trace-report.js +1394 -0
- package/dist/trace-report.js.map +1 -0
- package/dist/trace-stages.d.ts +70 -0
- package/dist/trace-stages.d.ts.map +1 -0
- package/dist/trace-stages.js +103 -0
- package/dist/trace-stages.js.map +1 -0
- package/dist/value-readers.d.ts +20 -0
- package/dist/value-readers.d.ts.map +1 -0
- package/dist/value-readers.js +82 -0
- package/dist/value-readers.js.map +1 -0
- package/package.json +341 -0
|
@@ -0,0 +1,773 @@
|
|
|
1
|
+
import { buildAssistantWorkflowToolSelectionSegmentKey } from "./tool-selection-policy.js";
|
|
2
|
+
import { readAssistantWorkflowNumber as readNumber, readAssistantWorkflowString as readString, readAssistantWorkflowStringArray, } from "./value-readers.js";
|
|
3
|
+
export function evaluateAssistantWorkflowToolSelectionDecision(decision) {
|
|
4
|
+
const signals = collectAssistantWorkflowToolSelectionEvaluationSignals(decision);
|
|
5
|
+
const workflowSelectionCandidateToolNames = readStringArray(decision.comparisonPayload?.["workflowSelectionCandidateTools"]);
|
|
6
|
+
const workflowSelectionActiveProfileIds = readStringArray(decision.comparisonPayload?.["workflowSelectionActiveProfileIds"]);
|
|
7
|
+
const workflowSelectionProfileToolNames = readStringArray(decision.comparisonPayload?.["workflowSelectionProfileTools"]);
|
|
8
|
+
const intentId = readString(decision.comparisonPayload?.["intent"]);
|
|
9
|
+
const workflowAuthorityIntentIds = readStringArray(decision.comparisonPayload?.["workflowAuthorityIntentIds"]);
|
|
10
|
+
const workflowAuthoritySegmentKeys = readStringArray(decision.comparisonPayload?.["workflowAuthoritySegmentKeys"]);
|
|
11
|
+
const workflowAuthoritySegmentKey = readString(decision.comparisonPayload?.["workflowAuthoritySegmentKey"]) ??
|
|
12
|
+
buildAssistantWorkflowToolSelectionSegmentKey({
|
|
13
|
+
intentId,
|
|
14
|
+
hop: readNumber(decision.comparisonPayload?.["hop"]),
|
|
15
|
+
selectedReason: readString(decision.comparisonPayload?.["selectedReason"]),
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
intentId,
|
|
19
|
+
hop: readNumber(decision.comparisonPayload?.["hop"]),
|
|
20
|
+
selectedReason: readString(decision.comparisonPayload?.["selectedReason"]),
|
|
21
|
+
authoritySource: decision.authority.source,
|
|
22
|
+
authorityReason: decision.authority.reason,
|
|
23
|
+
workflowStatus: decision.authority.workflowStatus,
|
|
24
|
+
workflowAuthorityEnabled: intentId && workflowAuthorityIntentIds.length > 0
|
|
25
|
+
? workflowAuthorityIntentIds.includes(intentId)
|
|
26
|
+
: null,
|
|
27
|
+
workflowAuthoritySegmentKey,
|
|
28
|
+
workflowAuthoritySegmentEnabled: workflowAuthoritySegmentKeys.length > 0
|
|
29
|
+
? workflowAuthoritySegmentKeys.includes(workflowAuthoritySegmentKey)
|
|
30
|
+
: null,
|
|
31
|
+
effectiveReason: decision.effectiveReason,
|
|
32
|
+
selectedToolCount: decision.authority.selectedToolNames.length,
|
|
33
|
+
effectiveToolCount: decision.effectiveToolNames.length,
|
|
34
|
+
workflowSuggestedToolCount: decision.authority.workflowSuggestedToolNames.length,
|
|
35
|
+
workflowSelectionCandidateToolCount: workflowSelectionCandidateToolNames.length,
|
|
36
|
+
workflowSelectionActiveProfileIds,
|
|
37
|
+
workflowSelectionProfileToolNames: workflowSelectionProfileToolNames,
|
|
38
|
+
workflowSelectionProfileToolCount: workflowSelectionProfileToolNames.length,
|
|
39
|
+
signalCount: signals.length,
|
|
40
|
+
warningCount: signals.filter((signal) => signal.severity === "warning").length,
|
|
41
|
+
signals,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function collectAssistantWorkflowToolSelectionEvaluationSignals(decision) {
|
|
45
|
+
const signals = [];
|
|
46
|
+
const missingCandidateTools = readStringArray(decision.comparisonPayload?.["missingWorkflowSelectionCandidateTools"]);
|
|
47
|
+
const selectedOutsideCandidate = readStringArray(decision.comparisonPayload?.["selectedOutsideWorkflowSelectionCandidate"]);
|
|
48
|
+
const selectedOutsideSuggestions = readStringArray(decision.comparisonPayload?.["selectedOutsideWorkflowSuggestions"]);
|
|
49
|
+
const excludedOptionalTools = readStringArray(decision.comparisonPayload?.["workflowSelectionExcludedOptionalTools"]);
|
|
50
|
+
const selectedPolicyExcludedOptionalTools = selectedOutsideCandidate.filter((toolName) => excludedOptionalTools.includes(toolName));
|
|
51
|
+
if (decision.authority.source === "legacy-pruner") {
|
|
52
|
+
signals.push({
|
|
53
|
+
name: "legacy_authority",
|
|
54
|
+
severity: "info",
|
|
55
|
+
detail: decision.authority.reason,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (decision.authority.reason === "workflow_unavailable") {
|
|
59
|
+
signals.push({
|
|
60
|
+
name: "workflow_unavailable",
|
|
61
|
+
severity: "warning",
|
|
62
|
+
detail: "tool selection ran without a workflow comparison payload",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (decision.authority.reason === "workflow_authority_not_enabled") {
|
|
66
|
+
signals.push({
|
|
67
|
+
name: "workflow_authority_not_enabled",
|
|
68
|
+
severity: "info",
|
|
69
|
+
detail: readString(decision.comparisonPayload?.["intent"]),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (decision.authority.reason === "workflow_blocked") {
|
|
73
|
+
signals.push({
|
|
74
|
+
name: "workflow_blocked",
|
|
75
|
+
severity: "warning",
|
|
76
|
+
detail: decision.authority.workflowStatus,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (decision.authority.reason === "workflow_differs") {
|
|
80
|
+
signals.push({
|
|
81
|
+
name: "workflow_differs",
|
|
82
|
+
severity: "info",
|
|
83
|
+
detail: summarizeDifference(missingCandidateTools, selectedOutsideCandidate),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (missingCandidateTools.length > 0) {
|
|
87
|
+
signals.push({
|
|
88
|
+
name: "workflow_candidate_not_selected",
|
|
89
|
+
severity: "warning",
|
|
90
|
+
detail: missingCandidateTools.join(", "),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (selectedOutsideCandidate.length > 0) {
|
|
94
|
+
signals.push({
|
|
95
|
+
name: "selected_outside_workflow_candidate",
|
|
96
|
+
severity: "info",
|
|
97
|
+
detail: selectedOutsideCandidate.join(", "),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (selectedOutsideSuggestions.length > 0) {
|
|
101
|
+
signals.push({
|
|
102
|
+
name: "selected_outside_workflow_suggestions",
|
|
103
|
+
severity: "info",
|
|
104
|
+
detail: selectedOutsideSuggestions.join(", "),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (selectedPolicyExcludedOptionalTools.length > 0) {
|
|
108
|
+
signals.push({
|
|
109
|
+
name: "selected_policy_excluded_optional_tool",
|
|
110
|
+
severity: "info",
|
|
111
|
+
detail: selectedPolicyExcludedOptionalTools.join(", "),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return signals;
|
|
115
|
+
}
|
|
116
|
+
export function buildAssistantWorkflowToolSelectionEvaluationBatch(decisions, options = {}) {
|
|
117
|
+
const allRows = decisions.map(evaluateAssistantWorkflowToolSelectionDecision);
|
|
118
|
+
const rows = options.onlyInteresting === true ? allRows.filter(isInterestingRow) : allRows;
|
|
119
|
+
const intentReadiness = buildIntentReadiness(rows);
|
|
120
|
+
const segmentReadiness = buildSegmentReadiness(rows);
|
|
121
|
+
return {
|
|
122
|
+
generatedAt: new Date().toISOString(),
|
|
123
|
+
sourceDecisionCount: decisions.length,
|
|
124
|
+
rowCount: rows.length,
|
|
125
|
+
interestingRowCount: rows.filter(isInterestingRow).length,
|
|
126
|
+
warningRowCount: rows.filter((row) => row.warningCount > 0).length,
|
|
127
|
+
intentCounts: buildStringCounts(rows.map((row) => row.intentId ?? "unknown")),
|
|
128
|
+
intentReadiness,
|
|
129
|
+
segmentReadiness,
|
|
130
|
+
readinessSummary: buildReadinessSummary(intentReadiness, segmentReadiness),
|
|
131
|
+
authoritySourceCounts: buildStringCounts(rows.map((row) => row.authoritySource)),
|
|
132
|
+
authorityReasonCounts: buildStringCounts(rows.map((row) => row.authorityReason)),
|
|
133
|
+
workflowStatusCounts: buildStringCounts(rows.map((row) => row.workflowStatus ?? "none")),
|
|
134
|
+
effectiveReasonCounts: buildStringCounts(rows.map((row) => row.effectiveReason ?? "none")),
|
|
135
|
+
workflowSelectionProfileCounts: buildStringCounts(rows.flatMap((row) => row.workflowSelectionActiveProfileIds)),
|
|
136
|
+
workflowSelectionProfileToolCounts: buildStringCounts(rows.flatMap((row) => row.workflowSelectionProfileToolNames)),
|
|
137
|
+
signalCounts: buildSignalCounts(rows.flatMap((row) => row.signals)),
|
|
138
|
+
rows,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export function buildAssistantWorkflowToolSelectionEvaluationTracePayload(evaluation) {
|
|
142
|
+
return {
|
|
143
|
+
authoritySource: evaluation.authoritySource,
|
|
144
|
+
authorityReason: evaluation.authorityReason,
|
|
145
|
+
workflowStatus: evaluation.workflowStatus,
|
|
146
|
+
intentId: evaluation.intentId,
|
|
147
|
+
hop: evaluation.hop,
|
|
148
|
+
selectedReason: evaluation.selectedReason,
|
|
149
|
+
workflowAuthorityEnabled: evaluation.workflowAuthorityEnabled,
|
|
150
|
+
workflowAuthoritySegmentKey: evaluation.workflowAuthoritySegmentKey,
|
|
151
|
+
workflowAuthoritySegmentEnabled: evaluation.workflowAuthoritySegmentEnabled,
|
|
152
|
+
effectiveReason: evaluation.effectiveReason,
|
|
153
|
+
selectedToolCount: evaluation.selectedToolCount,
|
|
154
|
+
effectiveToolCount: evaluation.effectiveToolCount,
|
|
155
|
+
workflowSuggestedToolCount: evaluation.workflowSuggestedToolCount,
|
|
156
|
+
workflowSelectionCandidateToolCount: evaluation.workflowSelectionCandidateToolCount,
|
|
157
|
+
workflowSelectionActiveProfileIds: evaluation.workflowSelectionActiveProfileIds,
|
|
158
|
+
workflowSelectionProfileToolNames: evaluation.workflowSelectionProfileToolNames,
|
|
159
|
+
workflowSelectionProfileToolCount: evaluation.workflowSelectionProfileToolCount,
|
|
160
|
+
signalCount: evaluation.signalCount,
|
|
161
|
+
warningCount: evaluation.warningCount,
|
|
162
|
+
signals: evaluation.signals.map((signal) => ({
|
|
163
|
+
name: signal.name,
|
|
164
|
+
severity: signal.severity,
|
|
165
|
+
detail: signal.detail,
|
|
166
|
+
})),
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export function buildAssistantWorkflowToolSelectionEvaluationBatchTracePayload(batch) {
|
|
170
|
+
return {
|
|
171
|
+
generatedAt: batch.generatedAt,
|
|
172
|
+
sourceDecisionCount: batch.sourceDecisionCount,
|
|
173
|
+
rowCount: batch.rowCount,
|
|
174
|
+
interestingRowCount: batch.interestingRowCount,
|
|
175
|
+
warningRowCount: batch.warningRowCount,
|
|
176
|
+
intentCounts: batch.intentCounts,
|
|
177
|
+
readinessSummary: {
|
|
178
|
+
readyIntentCount: batch.readinessSummary.readyIntentCount,
|
|
179
|
+
confirmedIntentCount: batch.readinessSummary.confirmedIntentCount,
|
|
180
|
+
readySegmentCount: batch.readinessSummary.readySegmentCount,
|
|
181
|
+
confirmedSegmentCount: batch.readinessSummary.confirmedSegmentCount,
|
|
182
|
+
warningIntentCount: batch.readinessSummary.warningIntentCount,
|
|
183
|
+
warningSegmentCount: batch.readinessSummary.warningSegmentCount,
|
|
184
|
+
},
|
|
185
|
+
intentReadiness: batch.intentReadiness.map((intent) => ({
|
|
186
|
+
intentId: intent.intentId,
|
|
187
|
+
decisionCount: intent.decisionCount,
|
|
188
|
+
workflowAuthorityCount: intent.workflowAuthorityCount,
|
|
189
|
+
shadowEquivalentCount: intent.shadowEquivalentCount,
|
|
190
|
+
workflowDiffersCount: intent.workflowDiffersCount,
|
|
191
|
+
workflowBlockedCount: intent.workflowBlockedCount,
|
|
192
|
+
workflowUnavailableCount: intent.workflowUnavailableCount,
|
|
193
|
+
warningCount: intent.warningCount,
|
|
194
|
+
workflowAuthorityConfirmed: intent.workflowAuthorityConfirmed,
|
|
195
|
+
readyForWorkflowAuthority: intent.readyForWorkflowAuthority,
|
|
196
|
+
})),
|
|
197
|
+
segmentReadiness: batch.segmentReadiness.map((segment) => ({
|
|
198
|
+
segmentKey: segment.segmentKey,
|
|
199
|
+
intentId: segment.intentId,
|
|
200
|
+
hop: segment.hop,
|
|
201
|
+
selectedReason: segment.selectedReason,
|
|
202
|
+
decisionCount: segment.decisionCount,
|
|
203
|
+
workflowAuthorityCount: segment.workflowAuthorityCount,
|
|
204
|
+
shadowEquivalentCount: segment.shadowEquivalentCount,
|
|
205
|
+
workflowDiffersCount: segment.workflowDiffersCount,
|
|
206
|
+
workflowBlockedCount: segment.workflowBlockedCount,
|
|
207
|
+
workflowUnavailableCount: segment.workflowUnavailableCount,
|
|
208
|
+
warningCount: segment.warningCount,
|
|
209
|
+
workflowAuthorityConfirmed: segment.workflowAuthorityConfirmed,
|
|
210
|
+
readyForWorkflowAuthority: segment.readyForWorkflowAuthority,
|
|
211
|
+
})),
|
|
212
|
+
authoritySourceCounts: batch.authoritySourceCounts,
|
|
213
|
+
authorityReasonCounts: batch.authorityReasonCounts,
|
|
214
|
+
workflowStatusCounts: batch.workflowStatusCounts,
|
|
215
|
+
effectiveReasonCounts: batch.effectiveReasonCounts,
|
|
216
|
+
workflowSelectionProfileCounts: batch.workflowSelectionProfileCounts,
|
|
217
|
+
workflowSelectionProfileToolCounts: batch.workflowSelectionProfileToolCounts,
|
|
218
|
+
signalCounts: batch.signalCounts,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export function buildAssistantWorkflowToolSelectionMigrationReport(batch, options = {}) {
|
|
222
|
+
const minDecisionCount = normalizeMinDecisionCount(options.minDecisionCount);
|
|
223
|
+
const intentCandidates = batch.intentReadiness.map((readiness) => buildMigrationCandidate("intent", readiness, minDecisionCount));
|
|
224
|
+
const segmentCandidates = batch.segmentReadiness.map((readiness) => buildMigrationCandidate("segment", readiness, minDecisionCount));
|
|
225
|
+
const readyIntentCandidates = intentCandidates.filter((candidate) => candidate.status === "ready_for_workflow_authority");
|
|
226
|
+
const readySegmentCandidates = segmentCandidates.filter((candidate) => candidate.status === "ready_for_workflow_authority");
|
|
227
|
+
const confirmedIntentCandidates = intentCandidates.filter((candidate) => candidate.status === "workflow_authority_confirmed");
|
|
228
|
+
const confirmedSegmentCandidates = segmentCandidates.filter((candidate) => candidate.status === "workflow_authority_confirmed");
|
|
229
|
+
const reviewCandidates = [...intentCandidates, ...segmentCandidates].filter((candidate) => candidate.status === "needs_review");
|
|
230
|
+
return {
|
|
231
|
+
generatedAt: batch.generatedAt,
|
|
232
|
+
minDecisionCount,
|
|
233
|
+
sourceDecisionCount: batch.sourceDecisionCount,
|
|
234
|
+
rowCount: batch.rowCount,
|
|
235
|
+
suggestedAuthorityIntentIds: uniqueStrings(readyIntentCandidates.map((candidate) => candidate.intentId)),
|
|
236
|
+
suggestedAuthoritySegmentKeys: uniqueStrings(readySegmentCandidates.map((candidate) => candidate.segmentKey ?? "")),
|
|
237
|
+
candidateCount: intentCandidates.length + segmentCandidates.length,
|
|
238
|
+
readyIntentCandidates,
|
|
239
|
+
readySegmentCandidates,
|
|
240
|
+
confirmedIntentCandidates,
|
|
241
|
+
confirmedSegmentCandidates,
|
|
242
|
+
reviewCandidates,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
export function buildAssistantWorkflowToolSelectionMigrationReportTracePayload(report) {
|
|
246
|
+
return {
|
|
247
|
+
generatedAt: report.generatedAt,
|
|
248
|
+
minDecisionCount: report.minDecisionCount,
|
|
249
|
+
sourceDecisionCount: report.sourceDecisionCount,
|
|
250
|
+
rowCount: report.rowCount,
|
|
251
|
+
suggestedAuthorityIntentIds: report.suggestedAuthorityIntentIds,
|
|
252
|
+
suggestedAuthoritySegmentKeys: report.suggestedAuthoritySegmentKeys,
|
|
253
|
+
candidateCount: report.candidateCount,
|
|
254
|
+
readyIntentCandidates: report.readyIntentCandidates.map(toMigrationCandidateTracePayload),
|
|
255
|
+
readySegmentCandidates: report.readySegmentCandidates.map(toMigrationCandidateTracePayload),
|
|
256
|
+
confirmedIntentCandidates: report.confirmedIntentCandidates.map(toMigrationCandidateTracePayload),
|
|
257
|
+
confirmedSegmentCandidates: report.confirmedSegmentCandidates.map(toMigrationCandidateTracePayload),
|
|
258
|
+
reviewCandidates: report.reviewCandidates.map(toMigrationCandidateTracePayload),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export function buildAssistantWorkflowToolSelectionAuthorityAllowListProposal(report, options = {}) {
|
|
262
|
+
const currentAuthorityIntentIds = uniqueStrings(options.currentAuthorityIntentIds ?? []);
|
|
263
|
+
const currentAuthoritySegmentKeys = uniqueStrings(options.currentAuthoritySegmentKeys ?? []);
|
|
264
|
+
const suggestedAuthorityIntentIds = uniqueStrings(report.suggestedAuthorityIntentIds);
|
|
265
|
+
const suggestedAuthoritySegmentKeys = uniqueStrings(report.suggestedAuthoritySegmentKeys);
|
|
266
|
+
const addIntentIds = suggestedAuthorityIntentIds.filter((intentId) => !currentAuthorityIntentIds.includes(intentId));
|
|
267
|
+
const addSegmentKeys = suggestedAuthoritySegmentKeys.filter((segmentKey) => !currentAuthoritySegmentKeys.includes(segmentKey));
|
|
268
|
+
const keepIntentIds = currentAuthorityIntentIds;
|
|
269
|
+
const keepSegmentKeys = currentAuthoritySegmentKeys;
|
|
270
|
+
const proposedAuthorityIntentIds = uniqueStrings([...keepIntentIds, ...addIntentIds]);
|
|
271
|
+
const proposedAuthoritySegmentKeys = uniqueStrings([...keepSegmentKeys, ...addSegmentKeys]);
|
|
272
|
+
const reviewIntentIds = uniqueStrings(report.reviewCandidates
|
|
273
|
+
.filter((candidate) => candidate.kind === "intent")
|
|
274
|
+
.map((candidate) => candidate.intentId));
|
|
275
|
+
const reviewSegmentKeys = uniqueStrings(report.reviewCandidates
|
|
276
|
+
.filter((candidate) => candidate.kind === "segment")
|
|
277
|
+
.map((candidate) => candidate.segmentKey ?? ""));
|
|
278
|
+
const currentIntentIdsWithReviewEvidence = currentAuthorityIntentIds.filter((intentId) => reviewIntentIds.includes(intentId));
|
|
279
|
+
const currentSegmentKeysWithReviewEvidence = currentAuthoritySegmentKeys.filter((segmentKey) => reviewSegmentKeys.includes(segmentKey));
|
|
280
|
+
return {
|
|
281
|
+
generatedAt: report.generatedAt,
|
|
282
|
+
minDecisionCount: report.minDecisionCount,
|
|
283
|
+
sourceDecisionCount: report.sourceDecisionCount,
|
|
284
|
+
rowCount: report.rowCount,
|
|
285
|
+
currentAuthorityIntentIds,
|
|
286
|
+
currentAuthoritySegmentKeys,
|
|
287
|
+
suggestedAuthorityIntentIds,
|
|
288
|
+
suggestedAuthoritySegmentKeys,
|
|
289
|
+
addIntentIds,
|
|
290
|
+
addSegmentKeys,
|
|
291
|
+
keepIntentIds,
|
|
292
|
+
keepSegmentKeys,
|
|
293
|
+
proposedAuthorityIntentIds,
|
|
294
|
+
proposedAuthoritySegmentKeys,
|
|
295
|
+
readyIntentCandidateCount: report.readyIntentCandidates.length,
|
|
296
|
+
readySegmentCandidateCount: report.readySegmentCandidates.length,
|
|
297
|
+
confirmedIntentCandidateCount: report.confirmedIntentCandidates.length,
|
|
298
|
+
confirmedSegmentCandidateCount: report.confirmedSegmentCandidates.length,
|
|
299
|
+
reviewIntentCandidateCount: report.reviewCandidates.filter((candidate) => candidate.kind === "intent").length,
|
|
300
|
+
reviewSegmentCandidateCount: report.reviewCandidates.filter((candidate) => candidate.kind === "segment").length,
|
|
301
|
+
reviewIntentIds,
|
|
302
|
+
reviewSegmentKeys,
|
|
303
|
+
currentIntentIdsWithReviewEvidence,
|
|
304
|
+
currentSegmentKeysWithReviewEvidence,
|
|
305
|
+
canApplyAdditions: addIntentIds.length > 0 || addSegmentKeys.length > 0,
|
|
306
|
+
rationale: buildAuthorityAllowListProposalRationale({
|
|
307
|
+
addIntentIds,
|
|
308
|
+
addSegmentKeys,
|
|
309
|
+
currentAuthorityIntentIds,
|
|
310
|
+
currentAuthoritySegmentKeys,
|
|
311
|
+
currentIntentIdsWithReviewEvidence,
|
|
312
|
+
currentSegmentKeysWithReviewEvidence,
|
|
313
|
+
report,
|
|
314
|
+
reviewIntentIds,
|
|
315
|
+
reviewSegmentKeys,
|
|
316
|
+
}),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
export function buildAssistantWorkflowToolSelectionAuthorityAllowListProposalTracePayload(proposal) {
|
|
320
|
+
return {
|
|
321
|
+
generatedAt: proposal.generatedAt,
|
|
322
|
+
minDecisionCount: proposal.minDecisionCount,
|
|
323
|
+
sourceDecisionCount: proposal.sourceDecisionCount,
|
|
324
|
+
rowCount: proposal.rowCount,
|
|
325
|
+
currentAuthorityIntentIds: proposal.currentAuthorityIntentIds,
|
|
326
|
+
currentAuthoritySegmentKeys: proposal.currentAuthoritySegmentKeys,
|
|
327
|
+
suggestedAuthorityIntentIds: proposal.suggestedAuthorityIntentIds,
|
|
328
|
+
suggestedAuthoritySegmentKeys: proposal.suggestedAuthoritySegmentKeys,
|
|
329
|
+
addIntentIds: proposal.addIntentIds,
|
|
330
|
+
addSegmentKeys: proposal.addSegmentKeys,
|
|
331
|
+
keepIntentIds: proposal.keepIntentIds,
|
|
332
|
+
keepSegmentKeys: proposal.keepSegmentKeys,
|
|
333
|
+
proposedAuthorityIntentIds: proposal.proposedAuthorityIntentIds,
|
|
334
|
+
proposedAuthoritySegmentKeys: proposal.proposedAuthoritySegmentKeys,
|
|
335
|
+
readyIntentCandidateCount: proposal.readyIntentCandidateCount,
|
|
336
|
+
readySegmentCandidateCount: proposal.readySegmentCandidateCount,
|
|
337
|
+
confirmedIntentCandidateCount: proposal.confirmedIntentCandidateCount,
|
|
338
|
+
confirmedSegmentCandidateCount: proposal.confirmedSegmentCandidateCount,
|
|
339
|
+
reviewIntentCandidateCount: proposal.reviewIntentCandidateCount,
|
|
340
|
+
reviewSegmentCandidateCount: proposal.reviewSegmentCandidateCount,
|
|
341
|
+
reviewIntentIds: proposal.reviewIntentIds,
|
|
342
|
+
reviewSegmentKeys: proposal.reviewSegmentKeys,
|
|
343
|
+
currentIntentIdsWithReviewEvidence: proposal.currentIntentIdsWithReviewEvidence,
|
|
344
|
+
currentSegmentKeysWithReviewEvidence: proposal.currentSegmentKeysWithReviewEvidence,
|
|
345
|
+
canApplyAdditions: proposal.canApplyAdditions,
|
|
346
|
+
rationale: proposal.rationale,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
export function buildAssistantWorkflowToolSelectionMigrationReviewArtifact(input, options = {}) {
|
|
350
|
+
const patchTargets = uniqueStrings(options.patchTargets ?? []);
|
|
351
|
+
const requiredTestIds = uniqueStrings(options.requiredTestIds ?? []);
|
|
352
|
+
const status = input.proposal.canApplyAdditions
|
|
353
|
+
? "ready_for_runtime_change"
|
|
354
|
+
: "no_runtime_change";
|
|
355
|
+
return {
|
|
356
|
+
generatedAt: input.proposal.generatedAt,
|
|
357
|
+
title: readString(options.title) ?? "Assistant workflow tool-selection migration review",
|
|
358
|
+
status,
|
|
359
|
+
recommendedAction: status === "ready_for_runtime_change"
|
|
360
|
+
? "apply_authority_allow_list_update"
|
|
361
|
+
: "keep_current_authority",
|
|
362
|
+
minDecisionCount: input.proposal.minDecisionCount,
|
|
363
|
+
sourceDecisionCount: input.proposal.sourceDecisionCount,
|
|
364
|
+
rowCount: input.proposal.rowCount,
|
|
365
|
+
patchTargets,
|
|
366
|
+
requiredTestIds,
|
|
367
|
+
runtimeChange: {
|
|
368
|
+
addIntentIds: input.proposal.addIntentIds,
|
|
369
|
+
addSegmentKeys: input.proposal.addSegmentKeys,
|
|
370
|
+
keepIntentIds: input.proposal.keepIntentIds,
|
|
371
|
+
keepSegmentKeys: input.proposal.keepSegmentKeys,
|
|
372
|
+
proposedAuthorityIntentIds: input.proposal.proposedAuthorityIntentIds,
|
|
373
|
+
proposedAuthoritySegmentKeys: input.proposal.proposedAuthoritySegmentKeys,
|
|
374
|
+
},
|
|
375
|
+
evidence: {
|
|
376
|
+
readyIntentCandidateKeys: input.report.readyIntentCandidates.map((candidate) => candidate.key),
|
|
377
|
+
readySegmentCandidateKeys: input.report.readySegmentCandidates.map((candidate) => candidate.key),
|
|
378
|
+
confirmedIntentCandidateKeys: input.report.confirmedIntentCandidates.map((candidate) => candidate.key),
|
|
379
|
+
confirmedSegmentCandidateKeys: input.report.confirmedSegmentCandidates.map((candidate) => candidate.key),
|
|
380
|
+
},
|
|
381
|
+
review: {
|
|
382
|
+
reviewIntentIds: input.proposal.reviewIntentIds,
|
|
383
|
+
reviewSegmentKeys: input.proposal.reviewSegmentKeys,
|
|
384
|
+
currentIntentIdsWithReviewEvidence: input.proposal.currentIntentIdsWithReviewEvidence,
|
|
385
|
+
currentSegmentKeysWithReviewEvidence: input.proposal.currentSegmentKeysWithReviewEvidence,
|
|
386
|
+
blockerCount: input.report.reviewCandidates.length,
|
|
387
|
+
blockers: input.report.reviewCandidates,
|
|
388
|
+
},
|
|
389
|
+
rationale: buildMigrationReviewArtifactRationale(input.proposal, status),
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
export function buildAssistantWorkflowToolSelectionMigrationReviewArtifactTracePayload(artifact) {
|
|
393
|
+
return {
|
|
394
|
+
generatedAt: artifact.generatedAt,
|
|
395
|
+
title: artifact.title,
|
|
396
|
+
status: artifact.status,
|
|
397
|
+
recommendedAction: artifact.recommendedAction,
|
|
398
|
+
minDecisionCount: artifact.minDecisionCount,
|
|
399
|
+
sourceDecisionCount: artifact.sourceDecisionCount,
|
|
400
|
+
rowCount: artifact.rowCount,
|
|
401
|
+
patchTargets: artifact.patchTargets,
|
|
402
|
+
requiredTestIds: artifact.requiredTestIds,
|
|
403
|
+
runtimeChange: {
|
|
404
|
+
addIntentIds: artifact.runtimeChange.addIntentIds,
|
|
405
|
+
addSegmentKeys: artifact.runtimeChange.addSegmentKeys,
|
|
406
|
+
keepIntentIds: artifact.runtimeChange.keepIntentIds,
|
|
407
|
+
keepSegmentKeys: artifact.runtimeChange.keepSegmentKeys,
|
|
408
|
+
proposedAuthorityIntentIds: artifact.runtimeChange.proposedAuthorityIntentIds,
|
|
409
|
+
proposedAuthoritySegmentKeys: artifact.runtimeChange.proposedAuthoritySegmentKeys,
|
|
410
|
+
},
|
|
411
|
+
evidence: {
|
|
412
|
+
readyIntentCandidateKeys: artifact.evidence.readyIntentCandidateKeys,
|
|
413
|
+
readySegmentCandidateKeys: artifact.evidence.readySegmentCandidateKeys,
|
|
414
|
+
confirmedIntentCandidateKeys: artifact.evidence.confirmedIntentCandidateKeys,
|
|
415
|
+
confirmedSegmentCandidateKeys: artifact.evidence.confirmedSegmentCandidateKeys,
|
|
416
|
+
},
|
|
417
|
+
review: {
|
|
418
|
+
reviewIntentIds: artifact.review.reviewIntentIds,
|
|
419
|
+
reviewSegmentKeys: artifact.review.reviewSegmentKeys,
|
|
420
|
+
currentIntentIdsWithReviewEvidence: artifact.review.currentIntentIdsWithReviewEvidence,
|
|
421
|
+
currentSegmentKeysWithReviewEvidence: artifact.review.currentSegmentKeysWithReviewEvidence,
|
|
422
|
+
blockerCount: artifact.review.blockerCount,
|
|
423
|
+
blockers: artifact.review.blockers.map(toMigrationCandidateTracePayload),
|
|
424
|
+
},
|
|
425
|
+
rationale: artifact.rationale,
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function buildReadinessSummary(intentReadiness, segmentReadiness) {
|
|
429
|
+
return {
|
|
430
|
+
readyIntentCount: intentReadiness.filter((intent) => intent.readyForWorkflowAuthority).length,
|
|
431
|
+
confirmedIntentCount: intentReadiness.filter((intent) => intent.workflowAuthorityConfirmed).length,
|
|
432
|
+
readySegmentCount: segmentReadiness.filter((segment) => segment.readyForWorkflowAuthority).length,
|
|
433
|
+
confirmedSegmentCount: segmentReadiness.filter((segment) => segment.workflowAuthorityConfirmed).length,
|
|
434
|
+
warningIntentCount: intentReadiness.filter((intent) => intent.warningCount > 0).length,
|
|
435
|
+
warningSegmentCount: segmentReadiness.filter((segment) => segment.warningCount > 0).length,
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function buildMigrationCandidate(kind, readiness, minDecisionCount) {
|
|
439
|
+
const isSegment = isSegmentReadiness(readiness);
|
|
440
|
+
const key = isSegment ? readiness.segmentKey : readiness.intentId;
|
|
441
|
+
const blockingReasons = collectMigrationBlockingReasons(readiness, minDecisionCount);
|
|
442
|
+
const status = blockingReasons.length > 0
|
|
443
|
+
? "needs_review"
|
|
444
|
+
: readiness.workflowAuthorityConfirmed
|
|
445
|
+
? "workflow_authority_confirmed"
|
|
446
|
+
: readiness.readyForWorkflowAuthority
|
|
447
|
+
? "ready_for_workflow_authority"
|
|
448
|
+
: "needs_review";
|
|
449
|
+
const recommendedAction = buildMigrationRecommendedAction(kind, status);
|
|
450
|
+
return {
|
|
451
|
+
kind,
|
|
452
|
+
key,
|
|
453
|
+
intentId: readiness.intentId,
|
|
454
|
+
segmentKey: isSegment ? readiness.segmentKey : null,
|
|
455
|
+
hop: isSegment ? readiness.hop : null,
|
|
456
|
+
selectedReason: isSegment ? readiness.selectedReason : null,
|
|
457
|
+
decisionCount: readiness.decisionCount,
|
|
458
|
+
workflowAuthorityCount: readiness.workflowAuthorityCount,
|
|
459
|
+
shadowEquivalentCount: readiness.shadowEquivalentCount,
|
|
460
|
+
workflowDiffersCount: readiness.workflowDiffersCount,
|
|
461
|
+
workflowBlockedCount: readiness.workflowBlockedCount,
|
|
462
|
+
workflowUnavailableCount: readiness.workflowUnavailableCount,
|
|
463
|
+
warningCount: readiness.warningCount,
|
|
464
|
+
status,
|
|
465
|
+
recommendedAction,
|
|
466
|
+
blockingReasons,
|
|
467
|
+
rationale: buildMigrationRationale(kind, status, readiness, blockingReasons, minDecisionCount),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function collectMigrationBlockingReasons(readiness, minDecisionCount) {
|
|
471
|
+
const reasons = [];
|
|
472
|
+
if (readiness.intentId === "unknown")
|
|
473
|
+
reasons.push("unknown_intent");
|
|
474
|
+
if (readiness.decisionCount < minDecisionCount)
|
|
475
|
+
reasons.push("insufficient_decisions");
|
|
476
|
+
if (readiness.warningCount > 0)
|
|
477
|
+
reasons.push("warnings_present");
|
|
478
|
+
if (readiness.workflowDiffersCount > 0)
|
|
479
|
+
reasons.push("workflow_differs");
|
|
480
|
+
if (readiness.workflowBlockedCount > 0)
|
|
481
|
+
reasons.push("workflow_blocked");
|
|
482
|
+
if (readiness.workflowUnavailableCount > 0)
|
|
483
|
+
reasons.push("workflow_unavailable");
|
|
484
|
+
if (readiness.workflowAuthorityCount > 0 &&
|
|
485
|
+
readiness.shadowEquivalentCount > 0 &&
|
|
486
|
+
readiness.workflowDiffersCount === 0 &&
|
|
487
|
+
readiness.workflowBlockedCount === 0 &&
|
|
488
|
+
readiness.workflowUnavailableCount === 0) {
|
|
489
|
+
reasons.push("mixed_authority_evidence");
|
|
490
|
+
}
|
|
491
|
+
if (readiness.workflowAuthorityCount === 0 &&
|
|
492
|
+
readiness.shadowEquivalentCount === 0 &&
|
|
493
|
+
readiness.workflowDiffersCount === 0 &&
|
|
494
|
+
readiness.workflowBlockedCount === 0 &&
|
|
495
|
+
readiness.workflowUnavailableCount === 0) {
|
|
496
|
+
reasons.push("no_workflow_equivalence_evidence");
|
|
497
|
+
}
|
|
498
|
+
return reasons;
|
|
499
|
+
}
|
|
500
|
+
function buildMigrationRecommendedAction(kind, status) {
|
|
501
|
+
if (status === "workflow_authority_confirmed")
|
|
502
|
+
return "keep_runtime_authority";
|
|
503
|
+
if (status === "ready_for_workflow_authority") {
|
|
504
|
+
return kind === "intent"
|
|
505
|
+
? "add_intent_to_authority_allow_list"
|
|
506
|
+
: "review_segment_before_authority_change";
|
|
507
|
+
}
|
|
508
|
+
return "review_blockers_before_migration";
|
|
509
|
+
}
|
|
510
|
+
function buildMigrationRationale(kind, status, readiness, blockingReasons, minDecisionCount) {
|
|
511
|
+
const scope = kind === "intent" ? `intent ${readiness.intentId}` : `segment ${getReadinessKey(readiness)}`;
|
|
512
|
+
if (status === "workflow_authority_confirmed") {
|
|
513
|
+
return `${scope} is already workflow-owned across ${readiness.decisionCount} decision(s) without warnings.`;
|
|
514
|
+
}
|
|
515
|
+
if (status === "ready_for_workflow_authority") {
|
|
516
|
+
return `${scope} has ${readiness.shadowEquivalentCount} shadow-equivalent decision(s), no warnings, and meets minDecisionCount=${minDecisionCount}.`;
|
|
517
|
+
}
|
|
518
|
+
return `${scope} is not ready for runtime migration: ${blockingReasons.join(", ") || "unknown_reason"}.`;
|
|
519
|
+
}
|
|
520
|
+
function getReadinessKey(readiness) {
|
|
521
|
+
return isSegmentReadiness(readiness) ? readiness.segmentKey : readiness.intentId;
|
|
522
|
+
}
|
|
523
|
+
function isSegmentReadiness(readiness) {
|
|
524
|
+
return "segmentKey" in readiness;
|
|
525
|
+
}
|
|
526
|
+
function toMigrationCandidateTracePayload(candidate) {
|
|
527
|
+
return {
|
|
528
|
+
kind: candidate.kind,
|
|
529
|
+
key: candidate.key,
|
|
530
|
+
intentId: candidate.intentId,
|
|
531
|
+
segmentKey: candidate.segmentKey,
|
|
532
|
+
hop: candidate.hop,
|
|
533
|
+
selectedReason: candidate.selectedReason,
|
|
534
|
+
decisionCount: candidate.decisionCount,
|
|
535
|
+
workflowAuthorityCount: candidate.workflowAuthorityCount,
|
|
536
|
+
shadowEquivalentCount: candidate.shadowEquivalentCount,
|
|
537
|
+
workflowDiffersCount: candidate.workflowDiffersCount,
|
|
538
|
+
workflowBlockedCount: candidate.workflowBlockedCount,
|
|
539
|
+
workflowUnavailableCount: candidate.workflowUnavailableCount,
|
|
540
|
+
warningCount: candidate.warningCount,
|
|
541
|
+
status: candidate.status,
|
|
542
|
+
recommendedAction: candidate.recommendedAction,
|
|
543
|
+
blockingReasons: candidate.blockingReasons,
|
|
544
|
+
rationale: candidate.rationale,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function buildAuthorityAllowListProposalRationale(input) {
|
|
548
|
+
const rationale = [];
|
|
549
|
+
if (input.addIntentIds.length > 0) {
|
|
550
|
+
rationale.push(`Add ${input.addIntentIds.join(", ")} to workflow authority after ${input.report.minDecisionCount} matching decision(s) with no blockers.`);
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
rationale.push("No new intent-level workflow authority additions are ready.");
|
|
554
|
+
}
|
|
555
|
+
if (input.addSegmentKeys.length > 0) {
|
|
556
|
+
rationale.push(`Add segment authority for ${input.addSegmentKeys.join(", ")} after ${input.report.minDecisionCount} matching decision(s) with no blockers.`);
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
rationale.push("No new segment-level workflow authority additions are ready.");
|
|
560
|
+
}
|
|
561
|
+
if (input.currentAuthorityIntentIds.length > 0) {
|
|
562
|
+
rationale.push(`Keep existing workflow authority intents: ${input.currentAuthorityIntentIds.join(", ")}.`);
|
|
563
|
+
}
|
|
564
|
+
if (input.currentAuthoritySegmentKeys.length > 0) {
|
|
565
|
+
rationale.push(`Keep existing workflow authority segments: ${input.currentAuthoritySegmentKeys.join(", ")}.`);
|
|
566
|
+
}
|
|
567
|
+
if (input.currentIntentIdsWithReviewEvidence.length > 0) {
|
|
568
|
+
rationale.push(`Review existing authority evidence for: ${input.currentIntentIdsWithReviewEvidence.join(", ")}.`);
|
|
569
|
+
}
|
|
570
|
+
if (input.currentSegmentKeysWithReviewEvidence.length > 0) {
|
|
571
|
+
rationale.push(`Review existing segment authority evidence for: ${input.currentSegmentKeysWithReviewEvidence.join(", ")}.`);
|
|
572
|
+
}
|
|
573
|
+
if (input.reviewIntentIds.length > 0) {
|
|
574
|
+
rationale.push(`Review blocked intent candidates before migration: ${input.reviewIntentIds.join(", ")}.`);
|
|
575
|
+
}
|
|
576
|
+
if (input.reviewSegmentKeys.length > 0) {
|
|
577
|
+
rationale.push(`Review blocked segment candidates before migration: ${input.reviewSegmentKeys.join(", ")}.`);
|
|
578
|
+
}
|
|
579
|
+
return rationale;
|
|
580
|
+
}
|
|
581
|
+
function buildMigrationReviewArtifactRationale(proposal, status) {
|
|
582
|
+
if (status === "ready_for_runtime_change") {
|
|
583
|
+
return [
|
|
584
|
+
"Migration proposal has ready allow-list additions.",
|
|
585
|
+
...proposal.rationale,
|
|
586
|
+
];
|
|
587
|
+
}
|
|
588
|
+
return [
|
|
589
|
+
"Migration proposal does not require a runtime allow-list change.",
|
|
590
|
+
...proposal.rationale,
|
|
591
|
+
];
|
|
592
|
+
}
|
|
593
|
+
function normalizeMinDecisionCount(value) {
|
|
594
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : 1;
|
|
595
|
+
}
|
|
596
|
+
function isInterestingRow(row) {
|
|
597
|
+
return row.authoritySource !== "workflow";
|
|
598
|
+
}
|
|
599
|
+
function summarizeDifference(missingCandidateTools, selectedOutsideCandidate) {
|
|
600
|
+
const parts = [
|
|
601
|
+
missingCandidateTools.length > 0 ? `missing=${missingCandidateTools.join(",")}` : "",
|
|
602
|
+
selectedOutsideCandidate.length > 0 ? `outside=${selectedOutsideCandidate.join(",")}` : "",
|
|
603
|
+
].filter((part) => part.length > 0);
|
|
604
|
+
return parts.length ? parts.join("; ") : null;
|
|
605
|
+
}
|
|
606
|
+
function buildIntentReadiness(rows) {
|
|
607
|
+
const byIntent = new Map();
|
|
608
|
+
for (const row of rows) {
|
|
609
|
+
const intentId = row.intentId ?? "unknown";
|
|
610
|
+
const current = byIntent.get(intentId) ?? [];
|
|
611
|
+
current.push(row);
|
|
612
|
+
byIntent.set(intentId, current);
|
|
613
|
+
}
|
|
614
|
+
return [...byIntent.entries()]
|
|
615
|
+
.map(([intentId, intentRows]) => {
|
|
616
|
+
const workflowAuthorityCount = intentRows.filter((row) => row.authoritySource === "workflow").length;
|
|
617
|
+
const shadowEquivalentCount = intentRows.filter((row) => row.authorityReason === "workflow_authority_not_enabled").length;
|
|
618
|
+
const workflowDiffersCount = intentRows.filter((row) => row.authorityReason === "workflow_differs").length;
|
|
619
|
+
const workflowBlockedCount = intentRows.filter((row) => row.authorityReason === "workflow_blocked").length;
|
|
620
|
+
const workflowUnavailableCount = intentRows.filter((row) => row.authorityReason === "workflow_unavailable").length;
|
|
621
|
+
const warningCount = intentRows.reduce((total, row) => total + row.warningCount, 0);
|
|
622
|
+
return {
|
|
623
|
+
intentId,
|
|
624
|
+
decisionCount: intentRows.length,
|
|
625
|
+
workflowAuthorityCount,
|
|
626
|
+
shadowEquivalentCount,
|
|
627
|
+
workflowDiffersCount,
|
|
628
|
+
workflowBlockedCount,
|
|
629
|
+
workflowUnavailableCount,
|
|
630
|
+
warningCount,
|
|
631
|
+
workflowAuthorityConfirmed: (intentId !== "unknown" &&
|
|
632
|
+
workflowAuthorityCount > 0 &&
|
|
633
|
+
shadowEquivalentCount === 0 &&
|
|
634
|
+
workflowDiffersCount === 0 &&
|
|
635
|
+
workflowBlockedCount === 0 &&
|
|
636
|
+
workflowUnavailableCount === 0 &&
|
|
637
|
+
warningCount === 0),
|
|
638
|
+
readyForWorkflowAuthority: (intentId !== "unknown" &&
|
|
639
|
+
workflowAuthorityCount === 0 &&
|
|
640
|
+
shadowEquivalentCount > 0 &&
|
|
641
|
+
workflowDiffersCount === 0 &&
|
|
642
|
+
workflowBlockedCount === 0 &&
|
|
643
|
+
workflowUnavailableCount === 0 &&
|
|
644
|
+
warningCount === 0),
|
|
645
|
+
};
|
|
646
|
+
})
|
|
647
|
+
.sort((left, right) => {
|
|
648
|
+
if (left.readyForWorkflowAuthority !== right.readyForWorkflowAuthority) {
|
|
649
|
+
return left.readyForWorkflowAuthority ? -1 : 1;
|
|
650
|
+
}
|
|
651
|
+
if (left.workflowAuthorityConfirmed !== right.workflowAuthorityConfirmed) {
|
|
652
|
+
return left.workflowAuthorityConfirmed ? -1 : 1;
|
|
653
|
+
}
|
|
654
|
+
if (right.shadowEquivalentCount !== left.shadowEquivalentCount) {
|
|
655
|
+
return right.shadowEquivalentCount - left.shadowEquivalentCount;
|
|
656
|
+
}
|
|
657
|
+
if (right.decisionCount !== left.decisionCount)
|
|
658
|
+
return right.decisionCount - left.decisionCount;
|
|
659
|
+
return left.intentId.localeCompare(right.intentId);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
function buildSegmentReadiness(rows) {
|
|
663
|
+
const bySegment = new Map();
|
|
664
|
+
for (const row of rows) {
|
|
665
|
+
const segmentKey = buildSegmentKey(row);
|
|
666
|
+
const current = bySegment.get(segmentKey) ?? [];
|
|
667
|
+
current.push(row);
|
|
668
|
+
bySegment.set(segmentKey, current);
|
|
669
|
+
}
|
|
670
|
+
return [...bySegment.entries()]
|
|
671
|
+
.map(([segmentKey, segmentRows]) => {
|
|
672
|
+
const [base] = segmentRows;
|
|
673
|
+
const intentReadiness = buildIntentReadiness(segmentRows)[0] ?? {
|
|
674
|
+
intentId: base?.intentId ?? "unknown",
|
|
675
|
+
decisionCount: 0,
|
|
676
|
+
workflowAuthorityCount: 0,
|
|
677
|
+
shadowEquivalentCount: 0,
|
|
678
|
+
workflowDiffersCount: 0,
|
|
679
|
+
workflowBlockedCount: 0,
|
|
680
|
+
workflowUnavailableCount: 0,
|
|
681
|
+
warningCount: 0,
|
|
682
|
+
workflowAuthorityConfirmed: false,
|
|
683
|
+
readyForWorkflowAuthority: false,
|
|
684
|
+
};
|
|
685
|
+
return {
|
|
686
|
+
...intentReadiness,
|
|
687
|
+
segmentKey,
|
|
688
|
+
hop: base?.hop ?? null,
|
|
689
|
+
selectedReason: base?.selectedReason ?? null,
|
|
690
|
+
};
|
|
691
|
+
})
|
|
692
|
+
.sort((left, right) => {
|
|
693
|
+
if (left.readyForWorkflowAuthority !== right.readyForWorkflowAuthority) {
|
|
694
|
+
return left.readyForWorkflowAuthority ? -1 : 1;
|
|
695
|
+
}
|
|
696
|
+
if (left.workflowAuthorityConfirmed !== right.workflowAuthorityConfirmed) {
|
|
697
|
+
return left.workflowAuthorityConfirmed ? -1 : 1;
|
|
698
|
+
}
|
|
699
|
+
if (right.shadowEquivalentCount !== left.shadowEquivalentCount) {
|
|
700
|
+
return right.shadowEquivalentCount - left.shadowEquivalentCount;
|
|
701
|
+
}
|
|
702
|
+
if (right.decisionCount !== left.decisionCount)
|
|
703
|
+
return right.decisionCount - left.decisionCount;
|
|
704
|
+
return left.segmentKey.localeCompare(right.segmentKey);
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
function buildSegmentKey(row) {
|
|
708
|
+
return buildAssistantWorkflowToolSelectionSegmentKey({
|
|
709
|
+
intentId: row.intentId,
|
|
710
|
+
hop: row.hop,
|
|
711
|
+
selectedReason: row.selectedReason,
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
function buildStringCounts(values) {
|
|
715
|
+
const counts = new Map();
|
|
716
|
+
for (const value of values) {
|
|
717
|
+
if (!value.length)
|
|
718
|
+
continue;
|
|
719
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
720
|
+
}
|
|
721
|
+
return [...counts.entries()]
|
|
722
|
+
.map(([key, count]) => ({ key, count }))
|
|
723
|
+
.sort((left, right) => {
|
|
724
|
+
if (right.count !== left.count)
|
|
725
|
+
return right.count - left.count;
|
|
726
|
+
return left.key.localeCompare(right.key);
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
function uniqueStrings(values) {
|
|
730
|
+
const out = [];
|
|
731
|
+
const seen = new Set();
|
|
732
|
+
for (const value of values) {
|
|
733
|
+
const trimmed = value.trim();
|
|
734
|
+
if (!trimmed.length || seen.has(trimmed))
|
|
735
|
+
continue;
|
|
736
|
+
seen.add(trimmed);
|
|
737
|
+
out.push(trimmed);
|
|
738
|
+
}
|
|
739
|
+
return out;
|
|
740
|
+
}
|
|
741
|
+
function buildSignalCounts(signals) {
|
|
742
|
+
const counts = new Map();
|
|
743
|
+
for (const signal of signals) {
|
|
744
|
+
const current = counts.get(signal.name);
|
|
745
|
+
if (current) {
|
|
746
|
+
current.count += 1;
|
|
747
|
+
if (signal.severity === "warning")
|
|
748
|
+
current.severity = "warning";
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
counts.set(signal.name, {
|
|
752
|
+
name: signal.name,
|
|
753
|
+
severity: signal.severity,
|
|
754
|
+
count: 1,
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
return [...counts.values()].sort((left, right) => {
|
|
758
|
+
if (right.count !== left.count)
|
|
759
|
+
return right.count - left.count;
|
|
760
|
+
if (left.severity !== right.severity)
|
|
761
|
+
return left.severity === "warning" ? -1 : 1;
|
|
762
|
+
return left.name.localeCompare(right.name);
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
function readStringArray(value) {
|
|
766
|
+
return readAssistantWorkflowStringArray(value, {
|
|
767
|
+
trim: false,
|
|
768
|
+
allowEmpty: true,
|
|
769
|
+
unique: false,
|
|
770
|
+
requireAllStrings: true,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
//# sourceMappingURL=tool-selection-evaluation.js.map
|