@ankh-studio/ai-enablement 1.0.0
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 +243 -0
- package/dist/analyzers/tech-stack-analyzer.d.ts +63 -0
- package/dist/analyzers/tech-stack-analyzer.d.ts.map +1 -0
- package/dist/analyzers/tech-stack-analyzer.js +401 -0
- package/dist/analyzers/tech-stack-analyzer.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +347 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/collectors/evidence-collector.d.ts +57 -0
- package/dist/collectors/evidence-collector.d.ts.map +1 -0
- package/dist/collectors/evidence-collector.js +386 -0
- package/dist/collectors/evidence-collector.js.map +1 -0
- package/dist/core/assessment-engine.d.ts +76 -0
- package/dist/core/assessment-engine.d.ts.map +1 -0
- package/dist/core/assessment-engine.js +310 -0
- package/dist/core/assessment-engine.js.map +1 -0
- package/dist/generators/adr-generator.d.ts +35 -0
- package/dist/generators/adr-generator.d.ts.map +1 -0
- package/dist/generators/adr-generator.js +339 -0
- package/dist/generators/adr-generator.js.map +1 -0
- package/dist/generators-backup-phase-2/adr-generator.d.ts +31 -0
- package/dist/generators-backup-phase-2/adr-generator.d.ts.map +1 -0
- package/dist/generators-backup-phase-2/adr-generator.js +309 -0
- package/dist/generators-backup-phase-2/adr-generator.js.map +1 -0
- package/dist/llm/coalescer.d.ts +45 -0
- package/dist/llm/coalescer.d.ts.map +1 -0
- package/dist/llm/coalescer.js +258 -0
- package/dist/llm/coalescer.js.map +1 -0
- package/dist/llm/copilot-client.d.ts +53 -0
- package/dist/llm/copilot-client.d.ts.map +1 -0
- package/dist/llm/copilot-client.js +198 -0
- package/dist/llm/copilot-client.js.map +1 -0
- package/dist/llm/prompt-templates.d.ts +24 -0
- package/dist/llm/prompt-templates.d.ts.map +1 -0
- package/dist/llm/prompt-templates.js +255 -0
- package/dist/llm/prompt-templates.js.map +1 -0
- package/dist/llm/response-processor.d.ts +50 -0
- package/dist/llm/response-processor.d.ts.map +1 -0
- package/dist/llm/response-processor.js +321 -0
- package/dist/llm/response-processor.js.map +1 -0
- package/dist/llm/structured-types.d.ts +184 -0
- package/dist/llm/structured-types.d.ts.map +1 -0
- package/dist/llm/structured-types.js +61 -0
- package/dist/llm/structured-types.js.map +1 -0
- package/dist/llm/validation.d.ts +57 -0
- package/dist/llm/validation.d.ts.map +1 -0
- package/dist/llm/validation.js +273 -0
- package/dist/llm/validation.js.map +1 -0
- package/dist/llm-backup-phase-1/coalescer.d.ts +40 -0
- package/dist/llm-backup-phase-1/coalescer.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/coalescer.js +209 -0
- package/dist/llm-backup-phase-1/coalescer.js.map +1 -0
- package/dist/llm-backup-phase-1/copilot-client.d.ts +53 -0
- package/dist/llm-backup-phase-1/copilot-client.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/copilot-client.js +198 -0
- package/dist/llm-backup-phase-1/copilot-client.js.map +1 -0
- package/dist/llm-backup-phase-1/prompt-templates.d.ts +23 -0
- package/dist/llm-backup-phase-1/prompt-templates.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/prompt-templates.js +197 -0
- package/dist/llm-backup-phase-1/prompt-templates.js.map +1 -0
- package/dist/llm-backup-phase-1/response-processor.d.ts +44 -0
- package/dist/llm-backup-phase-1/response-processor.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/response-processor.js +200 -0
- package/dist/llm-backup-phase-1/response-processor.js.map +1 -0
- package/dist/llm-backup-phase-1/validation.d.ts +57 -0
- package/dist/llm-backup-phase-1/validation.d.ts.map +1 -0
- package/dist/llm-backup-phase-1/validation.js +273 -0
- package/dist/llm-backup-phase-1/validation.js.map +1 -0
- package/dist/personas/base-persona.d.ts +28 -0
- package/dist/personas/base-persona.d.ts.map +1 -0
- package/dist/personas/base-persona.js +140 -0
- package/dist/personas/base-persona.js.map +1 -0
- package/dist/personas/consultant-persona.d.ts +25 -0
- package/dist/personas/consultant-persona.d.ts.map +1 -0
- package/dist/personas/consultant-persona.js +288 -0
- package/dist/personas/consultant-persona.js.map +1 -0
- package/dist/personas/persona-factory.d.ts +17 -0
- package/dist/personas/persona-factory.d.ts.map +1 -0
- package/dist/personas/persona-factory.js +53 -0
- package/dist/personas/persona-factory.js.map +1 -0
- package/dist/personas/research-backed-consultant.d.ts +12 -0
- package/dist/personas/research-backed-consultant.d.ts.map +1 -0
- package/dist/personas/research-backed-consultant.js +100 -0
- package/dist/personas/research-backed-consultant.js.map +1 -0
- package/dist/personas-backup-phase-1/base-persona.d.ts +28 -0
- package/dist/personas-backup-phase-1/base-persona.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/base-persona.js +140 -0
- package/dist/personas-backup-phase-1/base-persona.js.map +1 -0
- package/dist/personas-backup-phase-1/consultant-persona.d.ts +24 -0
- package/dist/personas-backup-phase-1/consultant-persona.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/consultant-persona.js +197 -0
- package/dist/personas-backup-phase-1/consultant-persona.js.map +1 -0
- package/dist/personas-backup-phase-1/persona-factory.d.ts +17 -0
- package/dist/personas-backup-phase-1/persona-factory.d.ts.map +1 -0
- package/dist/personas-backup-phase-1/persona-factory.js +53 -0
- package/dist/personas-backup-phase-1/persona-factory.js.map +1 -0
- package/dist/scanners/copilot-feature-scanner.d.ts +55 -0
- package/dist/scanners/copilot-feature-scanner.d.ts.map +1 -0
- package/dist/scanners/copilot-feature-scanner.js +259 -0
- package/dist/scanners/copilot-feature-scanner.js.map +1 -0
- package/dist/scorers/readiness-scorer.d.ts +42 -0
- package/dist/scorers/readiness-scorer.d.ts.map +1 -0
- package/dist/scorers/readiness-scorer.js +279 -0
- package/dist/scorers/readiness-scorer.js.map +1 -0
- package/dist/types/persona.d.ts +69 -0
- package/dist/types/persona.d.ts.map +1 -0
- package/dist/types/persona.js +9 -0
- package/dist/types/persona.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Evidence-Based Validation Layer
|
|
4
|
+
*
|
|
5
|
+
* Ensures LLM responses remain grounded in deterministic findings
|
|
6
|
+
* and prevents hallucination while maintaining adversarial value
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.EvidenceValidator = void 0;
|
|
10
|
+
class EvidenceValidator {
|
|
11
|
+
constructor(config = {}) {
|
|
12
|
+
this.config = {
|
|
13
|
+
evidenceThreshold: 0.8,
|
|
14
|
+
confidenceThreshold: 0.7,
|
|
15
|
+
maxNewInsights: 2,
|
|
16
|
+
requireEvidenceGrounding: true,
|
|
17
|
+
...config,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
validateLLMResponse(parsedResponse, deterministicInsights) {
|
|
21
|
+
const issues = [];
|
|
22
|
+
const metrics = this.calculateMetrics(parsedResponse, deterministicInsights);
|
|
23
|
+
// Validate evidence grounding
|
|
24
|
+
if (this.config.requireEvidenceGrounding) {
|
|
25
|
+
const evidenceIssues = this.validateEvidenceGrounding(parsedResponse, deterministicInsights);
|
|
26
|
+
issues.push(...evidenceIssues);
|
|
27
|
+
}
|
|
28
|
+
// Validate confidence levels
|
|
29
|
+
const confidenceIssues = this.validateConfidenceLevels(parsedResponse, deterministicInsights);
|
|
30
|
+
issues.push(...confidenceIssues);
|
|
31
|
+
// Validate priority alignment
|
|
32
|
+
const priorityIssues = this.validatePriorityAlignment(parsedResponse, deterministicInsights);
|
|
33
|
+
issues.push(...priorityIssues);
|
|
34
|
+
// Check for hallucination
|
|
35
|
+
const hallucinationIssues = this.detectHallucination(parsedResponse, deterministicInsights);
|
|
36
|
+
issues.push(...hallucinationIssues);
|
|
37
|
+
// Validate new insights
|
|
38
|
+
const newInsightIssues = this.validateNewInsights(parsedResponse, deterministicInsights);
|
|
39
|
+
issues.push(...newInsightIssues);
|
|
40
|
+
const score = this.calculateValidationScore(metrics, issues);
|
|
41
|
+
const isValid = score >= this.config.confidenceThreshold;
|
|
42
|
+
const recommendations = this.generateRecommendations(issues, metrics);
|
|
43
|
+
return {
|
|
44
|
+
isValid,
|
|
45
|
+
score,
|
|
46
|
+
issues,
|
|
47
|
+
metrics,
|
|
48
|
+
recommendations,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
validateEvidenceGrounding(parsedResponse, deterministicInsights) {
|
|
52
|
+
const issues = [];
|
|
53
|
+
const deterministicEvidence = new Set(deterministicInsights.flatMap(insight => insight.evidence));
|
|
54
|
+
// Check each enhanced insight for evidence grounding
|
|
55
|
+
parsedResponse.enhancedInsights.forEach((insightText, index) => {
|
|
56
|
+
const insightEvidence = this.extractEvidenceFromText(insightText);
|
|
57
|
+
const hasDeterministicEvidence = insightEvidence.some(evidence => deterministicEvidence.has(evidence));
|
|
58
|
+
if (!hasDeterministicEvidence && deterministicEvidence.size > 0) {
|
|
59
|
+
issues.push({
|
|
60
|
+
type: "evidence_drift",
|
|
61
|
+
severity: "medium",
|
|
62
|
+
description: `Enhanced insight ${index + 1} introduces evidence not present in deterministic analysis`,
|
|
63
|
+
affectedInsights: [`insight-${index}`],
|
|
64
|
+
suggestion: "Ensure all enhanced insights reference existing deterministic evidence",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return issues;
|
|
69
|
+
}
|
|
70
|
+
validateConfidenceLevels(parsedResponse, deterministicInsights) {
|
|
71
|
+
const issues = [];
|
|
72
|
+
const deterministicAvgConfidence = deterministicInsights.reduce((sum, insight) => sum + insight.confidence, 0) /
|
|
73
|
+
deterministicInsights.length;
|
|
74
|
+
// Parse confidence from assessment if available
|
|
75
|
+
const llmConfidence = this.parseConfidenceFromAssessment(parsedResponse.confidenceAssessment);
|
|
76
|
+
if (llmConfidence > deterministicAvgConfidence + 20) {
|
|
77
|
+
issues.push({
|
|
78
|
+
type: "confidence_inflation",
|
|
79
|
+
severity: "medium",
|
|
80
|
+
description: "LLM confidence appears significantly inflated compared to deterministic analysis",
|
|
81
|
+
affectedInsights: ["all"],
|
|
82
|
+
suggestion: "Review confidence scoring and ensure it's grounded in evidence quality",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return issues;
|
|
86
|
+
}
|
|
87
|
+
validatePriorityAlignment(parsedResponse, deterministicInsights) {
|
|
88
|
+
const issues = [];
|
|
89
|
+
// This is a simplified check - in practice, we'd need to parse priorities from enhanced insights
|
|
90
|
+
const priorityShifts = this.countPriorityShifts(parsedResponse.enhancedInsights);
|
|
91
|
+
if (priorityShifts > deterministicInsights.length * 0.3) {
|
|
92
|
+
issues.push({
|
|
93
|
+
type: "priority_mismatch",
|
|
94
|
+
severity: "low",
|
|
95
|
+
description: "Significant priority changes detected in enhanced insights",
|
|
96
|
+
affectedInsights: ["multiple"],
|
|
97
|
+
suggestion: "Ensure priority changes are justified by additional evidence",
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return issues;
|
|
101
|
+
}
|
|
102
|
+
detectHallucination(parsedResponse, deterministicInsights) {
|
|
103
|
+
const issues = [];
|
|
104
|
+
// Check for claims that contradict deterministic findings
|
|
105
|
+
const contradictions = this.findContradictions(parsedResponse.enhancedInsights, deterministicInsights);
|
|
106
|
+
contradictions.forEach((contradiction, index) => {
|
|
107
|
+
issues.push({
|
|
108
|
+
type: "hallucination",
|
|
109
|
+
severity: "high",
|
|
110
|
+
description: `Enhanced insight contradicts deterministic finding: ${contradiction}`,
|
|
111
|
+
affectedInsights: [`insight-${index}`],
|
|
112
|
+
suggestion: "Review enhanced insight for accuracy and evidence grounding",
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
return issues;
|
|
116
|
+
}
|
|
117
|
+
validateNewInsights(parsedResponse, deterministicInsights) {
|
|
118
|
+
const issues = [];
|
|
119
|
+
const newInsightCount = Math.max(0, parsedResponse.enhancedInsights.length - deterministicInsights.length);
|
|
120
|
+
if (newInsightCount > this.config.maxNewInsights) {
|
|
121
|
+
issues.push({
|
|
122
|
+
type: "hallucination",
|
|
123
|
+
severity: "medium",
|
|
124
|
+
description: `Too many new insights created (${newInsightCount} vs max ${this.config.maxNewInsights})`,
|
|
125
|
+
affectedInsights: ["new-insights"],
|
|
126
|
+
suggestion: "Limit new insights to those strongly supported by existing evidence",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return issues;
|
|
130
|
+
}
|
|
131
|
+
calculateMetrics(parsedResponse, deterministicInsights) {
|
|
132
|
+
const evidenceOverlap = this.calculateEvidenceOverlap(parsedResponse.enhancedInsights, deterministicInsights);
|
|
133
|
+
const confidenceInflation = this.calculateConfidenceInflation(parsedResponse.confidenceAssessment, deterministicInsights);
|
|
134
|
+
const priorityAlignment = this.calculatePriorityAlignment();
|
|
135
|
+
const newInsightCount = Math.max(0, parsedResponse.enhancedInsights.length - deterministicInsights.length);
|
|
136
|
+
const hallucinationRisk = this.calculateHallucinationRisk(parsedResponse, deterministicInsights);
|
|
137
|
+
return {
|
|
138
|
+
evidenceOverlap,
|
|
139
|
+
confidenceInflation,
|
|
140
|
+
priorityAlignment,
|
|
141
|
+
newInsightCount,
|
|
142
|
+
hallucinationRisk,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
calculateEvidenceOverlap(enhancedInsights, deterministicInsights) {
|
|
146
|
+
const deterministicEvidence = new Set(deterministicInsights.flatMap(insight => insight.evidence));
|
|
147
|
+
if (deterministicEvidence.size === 0)
|
|
148
|
+
return 1.0;
|
|
149
|
+
let overlappingEvidence = 0;
|
|
150
|
+
enhancedInsights.forEach(insight => {
|
|
151
|
+
const insightEvidence = this.extractEvidenceFromText(insight);
|
|
152
|
+
const overlap = insightEvidence.filter(evidence => deterministicEvidence.has(evidence)).length;
|
|
153
|
+
overlappingEvidence += overlap;
|
|
154
|
+
});
|
|
155
|
+
return overlappingEvidence / (deterministicEvidence.size * enhancedInsights.length);
|
|
156
|
+
}
|
|
157
|
+
calculateConfidenceInflation(confidenceAssessment, deterministicInsights) {
|
|
158
|
+
const deterministicAvg = deterministicInsights.reduce((sum, insight) => sum + insight.confidence, 0) /
|
|
159
|
+
deterministicInsights.length;
|
|
160
|
+
const llmConfidence = this.parseConfidenceFromAssessment(confidenceAssessment);
|
|
161
|
+
return Math.max(0, (llmConfidence - deterministicAvg) / 100);
|
|
162
|
+
}
|
|
163
|
+
calculatePriorityAlignment() {
|
|
164
|
+
// Simplified calculation - in practice would parse actual priorities
|
|
165
|
+
return 0.8; // Placeholder
|
|
166
|
+
}
|
|
167
|
+
calculateHallucinationRisk(parsedResponse, deterministicInsights) {
|
|
168
|
+
let riskScore = 0;
|
|
169
|
+
// Risk factors
|
|
170
|
+
if (parsedResponse.enhancedInsights.length > deterministicInsights.length * 1.5) {
|
|
171
|
+
riskScore += 0.3;
|
|
172
|
+
}
|
|
173
|
+
if (parsedResponse.adversarialChallenges.length === 0) {
|
|
174
|
+
riskScore += 0.2;
|
|
175
|
+
}
|
|
176
|
+
const contradictions = this.findContradictions(parsedResponse.enhancedInsights, deterministicInsights);
|
|
177
|
+
riskScore += contradictions.length * 0.2;
|
|
178
|
+
return Math.min(1, riskScore);
|
|
179
|
+
}
|
|
180
|
+
calculateValidationScore(metrics, issues) {
|
|
181
|
+
let score = 1.0;
|
|
182
|
+
// Deduct points for each issue based on severity
|
|
183
|
+
issues.forEach(issue => {
|
|
184
|
+
switch (issue.severity) {
|
|
185
|
+
case "critical":
|
|
186
|
+
score -= 0.4;
|
|
187
|
+
break;
|
|
188
|
+
case "high":
|
|
189
|
+
score -= 0.3;
|
|
190
|
+
break;
|
|
191
|
+
case "medium":
|
|
192
|
+
score -= 0.2;
|
|
193
|
+
break;
|
|
194
|
+
case "low":
|
|
195
|
+
score -= 0.1;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
// Factor in metrics
|
|
200
|
+
score *= metrics.evidenceOverlap;
|
|
201
|
+
score *= (1 - metrics.hallucinationRisk);
|
|
202
|
+
score *= (1 - metrics.confidenceInflation);
|
|
203
|
+
return Math.max(0, Math.min(1, score));
|
|
204
|
+
}
|
|
205
|
+
generateRecommendations(issues, metrics) {
|
|
206
|
+
const recommendations = [];
|
|
207
|
+
if (metrics.evidenceOverlap < this.config.evidenceThreshold) {
|
|
208
|
+
recommendations.push("Improve evidence grounding by referencing more deterministic findings");
|
|
209
|
+
}
|
|
210
|
+
if (metrics.confidenceInflation > 0.2) {
|
|
211
|
+
recommendations.push("Review confidence scoring to ensure it reflects evidence quality");
|
|
212
|
+
}
|
|
213
|
+
if (metrics.hallucinationRisk > 0.3) {
|
|
214
|
+
recommendations.push("Reduce hallucination risk by limiting new insights and improving adversarial challenges");
|
|
215
|
+
}
|
|
216
|
+
issues.forEach(issue => {
|
|
217
|
+
if (!recommendations.includes(issue.suggestion)) {
|
|
218
|
+
recommendations.push(issue.suggestion);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return recommendations;
|
|
222
|
+
}
|
|
223
|
+
// Helper methods
|
|
224
|
+
extractEvidenceFromText(text) {
|
|
225
|
+
// Simple extraction - in practice would be more sophisticated
|
|
226
|
+
const evidencePatterns = [
|
|
227
|
+
/evidence[:\s]+([^\n]+)/gi,
|
|
228
|
+
/data[:\s]+([^\n]+)/gi,
|
|
229
|
+
/analysis[:\s]+([^\n]+)/gi,
|
|
230
|
+
];
|
|
231
|
+
const evidence = [];
|
|
232
|
+
evidencePatterns.forEach(pattern => {
|
|
233
|
+
const matches = text.match(pattern);
|
|
234
|
+
if (matches) {
|
|
235
|
+
evidence.push(...matches.map(m => m.trim()));
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
return evidence;
|
|
239
|
+
}
|
|
240
|
+
parseConfidenceFromAssessment(assessment) {
|
|
241
|
+
const confidencePatterns = [
|
|
242
|
+
/(\d+)%/gi,
|
|
243
|
+
/confidence[:\s]+(\d+)/gi,
|
|
244
|
+
/(\d+)\s*percent/gi,
|
|
245
|
+
];
|
|
246
|
+
for (const pattern of confidencePatterns) {
|
|
247
|
+
const match = assessment.match(pattern);
|
|
248
|
+
if (match && match[1]) {
|
|
249
|
+
return parseInt(match[1], 10);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return 75; // Default confidence
|
|
253
|
+
}
|
|
254
|
+
countPriorityShifts(enhancedInsights) {
|
|
255
|
+
// Simplified count - in practice would parse actual priorities
|
|
256
|
+
return Math.floor(enhancedInsights.length * 0.1);
|
|
257
|
+
}
|
|
258
|
+
findContradictions(enhancedInsights, deterministicInsights) {
|
|
259
|
+
const contradictions = [];
|
|
260
|
+
// Simple contradiction detection - in practice would be more sophisticated
|
|
261
|
+
deterministicInsights.forEach(deterministic => {
|
|
262
|
+
enhancedInsights.forEach(enhanced => {
|
|
263
|
+
if (enhanced.toLowerCase().includes("not") &&
|
|
264
|
+
deterministic.description.toLowerCase().includes(enhanced.replace(/\s+not\s+/gi, " ").trim())) {
|
|
265
|
+
contradictions.push(`${deterministic.title} vs enhanced insight`);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
return contradictions;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.EvidenceValidator = EvidenceValidator;
|
|
273
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/llm/validation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoCH,MAAa,iBAAiB;IAG5B,YAAY,SAAoC,EAAE;QAChD,IAAI,CAAC,MAAM,GAAG;YACZ,iBAAiB,EAAE,GAAG;YACtB,mBAAmB,EAAE,GAAG;YACxB,cAAc,EAAE,CAAC;YACjB,wBAAwB,EAAE,IAAI;YAC9B,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,mBAAmB,CACjB,cAAiC,EACjC,qBAAuC;QAEvC,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,MAAM,O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AAC,CAAC;gBACpE,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAlaD,8CAkaC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Coalescer - Adversarial Fuzzy Comprehension
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates LLM-based coalescing of deterministic analysis results
|
|
5
|
+
* with adversarial validation to challenge and enhance insights
|
|
6
|
+
*/
|
|
7
|
+
import { PersonaContext, PersonaInsight } from "../types/persona";
|
|
8
|
+
import { CopilotClient } from "./copilot-client";
|
|
9
|
+
export interface CoalescingConfig {
|
|
10
|
+
enableAdversarialValidation: boolean;
|
|
11
|
+
confidenceThreshold: number;
|
|
12
|
+
maxTokens: number;
|
|
13
|
+
temperature: number;
|
|
14
|
+
}
|
|
15
|
+
export interface CoalescingResult {
|
|
16
|
+
enhancedInsights: PersonaInsight[];
|
|
17
|
+
adversarialChallenges: string[];
|
|
18
|
+
confidenceScore: number;
|
|
19
|
+
processingTime: number;
|
|
20
|
+
tokensUsed: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class LLMCoalescer {
|
|
23
|
+
private copilotClient;
|
|
24
|
+
private config;
|
|
25
|
+
constructor(copilotClient: CopilotClient, config?: Partial<CoalescingConfig>);
|
|
26
|
+
coalescePersonaInsights(deterministicInsights: PersonaInsight[], context: PersonaContext, personaType: string): Promise<CoalescingResult>;
|
|
27
|
+
private buildCoalescingPrompt;
|
|
28
|
+
private processLLMResponse;
|
|
29
|
+
private performAdversarialValidation;
|
|
30
|
+
private calculateEvidenceOverlap;
|
|
31
|
+
private calculateConfidenceInflation;
|
|
32
|
+
private calculatePriorityShifts;
|
|
33
|
+
private calculateConfidenceScore;
|
|
34
|
+
healthCheck(): Promise<boolean>;
|
|
35
|
+
getMetrics(): {
|
|
36
|
+
config: CoalescingConfig;
|
|
37
|
+
copilotMetrics: any;
|
|
38
|
+
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gB,CAAC;QACzB,cAAc,EAAE,GAAG,CAAC;KACrB;CAMF"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LLM Coalescer - Adversarial Fuzzy Comprehension
|
|
4
|
+
*
|
|
5
|
+
* Orchestrates LLM-based coalescing of deterministic analysis results
|
|
6
|
+
* with adversarial validation to challenge and enhance insights
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.LLMCoalescer = void 0;
|
|
10
|
+
class LLMCoalescer {
|
|
11
|
+
constructor(copilotClient, config = {}) {
|
|
12
|
+
this.copilotClient = copilotClient;
|
|
13
|
+
this.config = {
|
|
14
|
+
enableAdversarialValidation: true,
|
|
15
|
+
confidenceThreshold: 0.7,
|
|
16
|
+
maxTokens: 500,
|
|
17
|
+
temperature: 0.3,
|
|
18
|
+
...config,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async coalescePersonaInsights(deterministicInsights, context, personaType) {
|
|
22
|
+
const startTime = Date.now();
|
|
23
|
+
try {
|
|
24
|
+
console.log(`🧠 Coalescing ${personaType} insights with adversarial validation...`);
|
|
25
|
+
// Step 1: Generate coalescing prompt with adversarial elements
|
|
26
|
+
const prompt = this.buildCoalescingPrompt(deterministicInsights, context, personaType);
|
|
27
|
+
// Step 2: Get LLM response
|
|
28
|
+
const llmResponse = await this.copilotClient.analyze({
|
|
29
|
+
prompt,
|
|
30
|
+
context,
|
|
31
|
+
maxTokens: this.config.maxTokens,
|
|
32
|
+
temperature: this.config.temperature,
|
|
33
|
+
});
|
|
34
|
+
// Step 3: Process LLM response and extract enhanced insights
|
|
35
|
+
const enhancedInsights = this.processLLMResponse(llmResponse.content, deterministicInsights);
|
|
36
|
+
// Step 4: Adversarial validation
|
|
37
|
+
const adversarialChallenges = this.config.enableAdversarialValidation
|
|
38
|
+
? this.performAdversarialValidation(enhancedInsights, deterministicInsights, context)
|
|
39
|
+
: [];
|
|
40
|
+
// Step 5: Calculate confidence score
|
|
41
|
+
const confidenceScore = this.calculateConfidenceScore(enhancedInsights, adversarialChallenges, llmResponse.confidence);
|
|
42
|
+
const processingTime = Date.now() - startTime;
|
|
43
|
+
return {
|
|
44
|
+
enhancedInsights,
|
|
45
|
+
adversarialChallenges,
|
|
46
|
+
confidenceScore,
|
|
47
|
+
processingTime,
|
|
48
|
+
tokensUsed: llmResponse.tokensUsed,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
console.error("❌ LLM coalescing failed:", error);
|
|
53
|
+
// Fallback to deterministic insights
|
|
54
|
+
return {
|
|
55
|
+
enhancedInsights: deterministicInsights,
|
|
56
|
+
adversarialChallenges: [],
|
|
57
|
+
confidenceScore: 0.5,
|
|
58
|
+
processingTime: Date.now() - startTime,
|
|
59
|
+
tokensUsed: 0,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
buildCoalescingPrompt(insights, context, personaType) {
|
|
64
|
+
const insightsText = insights
|
|
65
|
+
.map((insight, index) => `${index + 1}. ${insight.title} (${insight.priority}): ${insight.description}`)
|
|
66
|
+
.join("\n");
|
|
67
|
+
const scoresText = `
|
|
68
|
+
Repository Readiness: ${context.scores.repoReadiness}/100
|
|
69
|
+
Team Readiness: ${context.scores.teamReadiness}/100
|
|
70
|
+
Organization Readiness: ${context.scores.orgReadiness}/100
|
|
71
|
+
Overall Maturity: ${context.scores.overallMaturity}/8
|
|
72
|
+
`.trim();
|
|
73
|
+
return `As a ${personaType} AI expert, perform adversarial analysis on these deterministic insights:
|
|
74
|
+
|
|
75
|
+
DETERMINISTIC INSIGHTS:
|
|
76
|
+
${insightsText}
|
|
77
|
+
|
|
78
|
+
ASSESSMENT SCORES:
|
|
79
|
+
${scoresText}
|
|
80
|
+
|
|
81
|
+
ADVERSARIAL ANALYSIS TASK:
|
|
82
|
+
1. Challenge these insights - what might be missing or incorrect?
|
|
83
|
+
2. Identify hidden patterns or connections between insights
|
|
84
|
+
3. Question the confidence levels and priorities
|
|
85
|
+
4. Suggest alternative interpretations of the evidence
|
|
86
|
+
5. Highlight potential risks not captured in the deterministic analysis
|
|
87
|
+
|
|
88
|
+
RESPONSE FORMAT:
|
|
89
|
+
Provide your analysis in this exact format:
|
|
90
|
+
|
|
91
|
+
ENHANCED_INSIGHTS:
|
|
92
|
+
- [Enhanced insight 1 with adversarial perspective]
|
|
93
|
+
- [Enhanced insight 2 with additional evidence]
|
|
94
|
+
- [Enhanced insight 3 with risk identification]
|
|
95
|
+
|
|
96
|
+
ADVERSARIAL_CHALLENGES:
|
|
97
|
+
- [Challenge to deterministic finding 1]
|
|
98
|
+
- [Challenge to deterministic finding 2]
|
|
99
|
+
- [Question about evidence or methodology]
|
|
100
|
+
|
|
101
|
+
CONFIDENCE_ASSESSMENT:
|
|
102
|
+
[Overall confidence in the enhanced analysis and key uncertainties]
|
|
103
|
+
|
|
104
|
+
Focus on being constructively critical while maintaining evidence-based reasoning. Do not hallucinate - base all challenges on the provided evidence.`;
|
|
105
|
+
}
|
|
106
|
+
processLLMResponse(llmContent, deterministicInsights) {
|
|
107
|
+
const enhancedInsights = [];
|
|
108
|
+
try {
|
|
109
|
+
// Parse enhanced insights section
|
|
110
|
+
const enhancedSection = llmContent.match(/ENHANCED_INSIGHTS:\s*\n([\s\S]*?)(?=\n\n|\n[A-Z_]+:|$)/);
|
|
111
|
+
if (enhancedSection && enhancedSection[1]) {
|
|
112
|
+
const insightLines = enhancedSection[1]
|
|
113
|
+
.split("\n")
|
|
114
|
+
.filter(line => line.trim().startsWith("-"))
|
|
115
|
+
.map(line => line.replace(/^-\s*/, "").trim());
|
|
116
|
+
insightLines.forEach((insightText, index) => {
|
|
117
|
+
if (index < deterministicInsights.length && deterministicInsights[index]) {
|
|
118
|
+
const original = deterministicInsights[index];
|
|
119
|
+
enhancedInsights.push({
|
|
120
|
+
...original,
|
|
121
|
+
description: insightText,
|
|
122
|
+
confidence: Math.min(original.confidence + 10, 100), // Boost confidence slightly
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.warn("⚠️ Failed to parse LLM response, using deterministic insights");
|
|
130
|
+
return deterministicInsights;
|
|
131
|
+
}
|
|
132
|
+
return enhancedInsights.length > 0 ? enhancedInsights : deterministicInsights;
|
|
133
|
+
}
|
|
134
|
+
performAdversarialValidation(enhancedInsights, deterministicInsights, context) {
|
|
135
|
+
const challenges = [];
|
|
136
|
+
// Challenge 1: Evidence consistency
|
|
137
|
+
const evidenceOverlap = this.calculateEvidenceOverlap(enhancedInsights, deterministicInsights);
|
|
138
|
+
if (evidenceOverlap < 0.8) {
|
|
139
|
+
challenges.push("Enhanced insights introduce evidence not present in deterministic analysis - potential hallucination risk");
|
|
140
|
+
}
|
|
141
|
+
// Challenge 2: Confidence inflation
|
|
142
|
+
const confidenceInflation = this.calculateConfidenceInflation(enhancedInsights, deterministicInsights);
|
|
143
|
+
if (confidenceInflation > 0.2) {
|
|
144
|
+
challenges.push("LLM may be overconfident - confidence scores appear inflated without additional evidence");
|
|
145
|
+
}
|
|
146
|
+
// Challenge 3: Priority consistency
|
|
147
|
+
const priorityShifts = this.calculatePriorityShifts(enhancedInsights, deterministicInsights);
|
|
148
|
+
if (priorityShifts > 0.3) {
|
|
149
|
+
challenges.push("Significant priority changes detected - verify if LLM interpretation is justified by evidence");
|
|
150
|
+
}
|
|
151
|
+
// Challenge 4: Contextual relevance
|
|
152
|
+
if (context.scores.orgReadiness < 30 && enhancedInsights.some(i => i.category === "strategy")) {
|
|
153
|
+
challenges.push("Strategic insights may be premature given low organizational readiness");
|
|
154
|
+
}
|
|
155
|
+
return challenges;
|
|
156
|
+
}
|
|
157
|
+
calculateEvidenceOverlap(enhanced, deterministic) {
|
|
158
|
+
const enhancedEvidence = new Set(enhanced.flatMap(i => i.evidence));
|
|
159
|
+
const deterministicEvidence = new Set(deterministic.flatMap(i => i.evidence));
|
|
160
|
+
if (deterministicEvidence.size === 0)
|
|
161
|
+
return 0;
|
|
162
|
+
const intersection = new Set([...enhancedEvidence].filter(x => deterministicEvidence.has(x)));
|
|
163
|
+
return intersection.size / deterministicEvidence.size;
|
|
164
|
+
}
|
|
165
|
+
calculateConfidenceInflation(enhanced, deterministic) {
|
|
166
|
+
const enhancedAvg = enhanced.reduce((sum, i) => sum + i.confidence, 0) / enhanced.length;
|
|
167
|
+
const deterministicAvg = deterministic.reduce((sum, i) => sum + i.confidence, 0) / deterministic.length;
|
|
168
|
+
return (enhancedAvg - deterministicAvg) / 100;
|
|
169
|
+
}
|
|
170
|
+
calculatePriorityShifts(enhanced, deterministic) {
|
|
171
|
+
const priorityOrder = { critical: 4, high: 3, medium: 2, low: 1 };
|
|
172
|
+
let shifts = 0;
|
|
173
|
+
for (let i = 0; i < Math.min(enhanced.length, deterministic.length); i++) {
|
|
174
|
+
const enhancedPriority = priorityOrder[enhanced[i]?.priority || 'medium'];
|
|
175
|
+
const deterministicPriority = priorityOrder[deterministic[i]?.priority || 'medium'];
|
|
176
|
+
if (enhancedPriority !== deterministicPriority) {
|
|
177
|
+
shifts++;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return deterministic.length > 0 ? shifts / deterministic.length : 0;
|
|
181
|
+
}
|
|
182
|
+
calculateConfidenceScore(enhancedInsights, adversarialChallenges, llmConfidence) {
|
|
183
|
+
let score = llmConfidence;
|
|
184
|
+
// Reduce confidence based on adversarial challenges
|
|
185
|
+
score -= adversarialChallenges.length * 0.1;
|
|
186
|
+
// Boost confidence if enhanced insights are well-structured
|
|
187
|
+
if (enhancedInsights.every(i => i.confidence >= 70)) {
|
|
188
|
+
score += 0.1;
|
|
189
|
+
}
|
|
190
|
+
return Math.max(0, Math.min(1, score));
|
|
191
|
+
}
|
|
192
|
+
async healthCheck() {
|
|
193
|
+
try {
|
|
194
|
+
return await this.copilotClient.healthCheck();
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.error("❌ LLM coalescer health check failed:", error);
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
getMetrics() {
|
|
202
|
+
return {
|
|
203
|
+
config: this.config,
|
|
204
|
+
copilotMetrics: this.copilotClient.getMetrics(),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.LLMCoalescer = LLMCoalescer;
|
|
209
|
+
//# sourceMappingURL=coalescer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coalescer.js","sourceRoot":"","sources":["../../src/llm-backup-phase-1/coalescer.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAoBH,MAAa,YAAY;IAIvB,YACE,aAA4B,EAC5B,SAAoC,EAAE;QAEtC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG;YACZ,2BAA2B,EAAE,IAAI;YACjC,mBAAmB,EAAE,GAAG;YACxB,SAAS,EAAE,GAAG;YACd,WAAW,EAAE,GAAG;YAChB,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,uBAAuB,CAC3B,qBAAuC,EACvC,OAAuB,EACvB,WAAmB;QAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,iBAAiB,WAAW,0CAA0C,CAAC,CAAC;YAEpF,+DAA+D;YAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,qBAAqB,CACvC,qBAAqB,EACrB,OAAO,EACP,WAAW,CACZ,CAAC;YAEF,2BAA2B;YAC3B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;gBACnD,MAAM;gBACN,OAAO;gBACP,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;gBAChC,WAAW,EAAE,IAA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CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;QAChD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,sCAAsC,EAAE,KAAK,CAAC,CAAC;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,UAAU;QAIR,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE;SAChD,CAAC;IACJ,CAAC;CACF;AA/QD,oCA+QC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot SDK Client for LLM Coalescing
|
|
3
|
+
*
|
|
4
|
+
* Provides integration with GitHub Copilot SDK for adversarial
|
|
5
|
+
* fuzzy comprehension of deterministic analysis results
|
|
6
|
+
*/
|
|
7
|
+
export interface CopilotConfig {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
timeoutMs?: number;
|
|
11
|
+
maxRetries?: number;
|
|
12
|
+
clientName?: string;
|
|
13
|
+
reasoningEffort?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CopilotRequest {
|
|
16
|
+
prompt: string;
|
|
17
|
+
context?: any;
|
|
18
|
+
maxTokens?: number;
|
|
19
|
+
temperature?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface CopilotResponse {
|
|
22
|
+
content: string;
|
|
23
|
+
tokensUsed: number;
|
|
24
|
+
confidence: number;
|
|
25
|
+
processingTime: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ClientMetrics {
|
|
28
|
+
isInitialized: boolean;
|
|
29
|
+
config: Omit<CopilotConfig, 'apiKey'>;
|
|
30
|
+
requestCount: number;
|
|
31
|
+
failureCount: number;
|
|
32
|
+
fallbackCount: number;
|
|
33
|
+
averageLatency: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class CopilotClient {
|
|
36
|
+
private config;
|
|
37
|
+
private isInitialized;
|
|
38
|
+
private sdkClient;
|
|
39
|
+
private metrics;
|
|
40
|
+
constructor(config: CopilotConfig);
|
|
41
|
+
initialize(): Promise<void>;
|
|
42
|
+
analyze(request: CopilotRequest): Promise<CopilotResponse>;
|
|
43
|
+
private getSystemMessage;
|
|
44
|
+
private updateAverageLatency;
|
|
45
|
+
private extractContent;
|
|
46
|
+
private estimateTokens;
|
|
47
|
+
private calculateConfidence;
|
|
48
|
+
private getFallbackResponse;
|
|
49
|
+
healthCheck(): Promise<boolean>;
|
|
50
|
+
getMetrics(): ClientMetrics;
|
|
51
|
+
shutdown(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=copilot-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-client.d.ts","sourceRoot":"","sources":["../../src/llm-backup-phase-1/copilot-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IA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