audit trail details

This commit is contained in:
overcuriousity
2025-08-17 15:45:40 +02:00
parent dd26d45a21
commit 5c3c308225
3 changed files with 448 additions and 168 deletions

View File

@@ -656,17 +656,25 @@ class AIPipeline {
this.addToContextHistory(context, `${isWorkflow ? 'Szenario' : 'Problem'}-Analyse: ${result.content.slice(0, 200)}...`);
const confidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 50, max: 300 },
'scenario-analysis'
);
auditService.addAIDecision(
'contextual-analysis',
prompt,
result.content,
80,
`Generated ${isWorkflow ? 'scenario' : 'problem'} analysis for user query`,
confidence,
`Analysierte ${isWorkflow ? 'Szenario' : 'Problem'} basierend auf Nutzereingabe: "${context.userQuery.slice(0, 100)}..." - Identifizierte Kernaspekte und Herausforderungen für forensische Untersuchung`,
taskStart,
{
microTaskType: 'scenario-analysis',
analysisType: isWorkflow ? 'scenario' : 'problem',
contentLength: result.content.length,
decisionBasis: 'ai-analysis',
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);
@@ -687,18 +695,26 @@ class AIPipeline {
context.investigationApproach = result.content;
this.addToContextHistory(context, `${isWorkflow ? 'Untersuchungs' : 'Lösungs'}ansatz: ${result.content.slice(0, 200)}...`);
const confidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 50, max: 300 },
'investigation-approach'
);
auditService.addAIDecision(
'contextual-analysis',
prompt,
result.content,
75,
`Generated ${isWorkflow ? 'investigation' : 'solution'} approach`,
confidence,
`Entwickelte ${isWorkflow ? 'Untersuchungs' : 'Lösungs'}ansatz unter Berücksichtigung der Szenario-Analyse - Strukturierte Herangehensweise für forensische Methodik`,
taskStart,
{
microTaskType: 'investigation-approach',
approachType: isWorkflow ? 'investigation' : 'solution',
contentLength: result.content.length,
contextHistoryLength: context.contextHistory.length,
decisionBasis: 'ai-analysis',
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);
@@ -719,16 +735,24 @@ class AIPipeline {
context.criticalConsiderations = result.content;
this.addToContextHistory(context, `Kritische Überlegungen: ${result.content.slice(0, 200)}...`);
const confidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 40, max: 250 },
'critical-considerations'
);
auditService.addAIDecision(
'contextual-analysis',
prompt,
result.content,
70,
'Generated critical considerations and constraints',
confidence,
'Identifizierte kritische Überlegungen für forensische Untersuchung - Berücksichtigung von Beweissicherung, Chain of Custody und methodischen Herausforderungen',
taskStart,
{
microTaskType: 'critical-considerations',
contentLength: result.content.length,
decisionBasis: 'ai-analysis',
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);
@@ -771,12 +795,22 @@ class AIPipeline {
}
}, 'evaluation', priority, evaluation.detailed_explanation, moderatedTaskRelevance, evaluation.limitations);
// Calculate confidence based on response quality and task relevance
const responseConfidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 200, max: 800 },
'tool-evaluation'
);
// Use the higher of response quality confidence or moderated task relevance
const finalConfidence = Math.max(responseConfidence, moderatedTaskRelevance);
auditService.addAIDecision(
'tool-evaluation',
prompt,
result.content,
moderatedTaskRelevance,
`Evaluated tool ${tool.name} for ${context.mode} mode`,
finalConfidence,
`Bewertete Tool "${tool.name}" (Rang ${rank}) - Analysierte Eignung für spezifische Aufgabenstellung mit Fokus auf praktische Anwendbarkeit und methodische Integration`,
taskStart,
{
microTaskType: 'tool-evaluation',
@@ -785,10 +819,14 @@ class AIPipeline {
rank,
originalTaskRelevance,
moderatedTaskRelevance,
responseConfidence,
finalConfidence,
moderationApplied: originalTaskRelevance !== moderatedTaskRelevance,
evaluationParsed: !!evaluation.detailed_explanation,
prosCount: evaluation.pros?.length || 0,
limitationsCount: evaluation.limitations?.length || 0,
decisionBasis: 'ai-analysis',
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);
@@ -826,24 +864,39 @@ class AIPipeline {
relevance: sel.relevance
}));
const responseConfidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 100, max: 500 },
'background-knowledge'
);
const selectionBonus = context.backgroundKnowledge.length > 0 ? 15 : 0;
const finalConfidence = Math.min(95, responseConfidence + selectionBonus);
auditService.addEntry(
'knowledge-synthesis',
'concept-selection',
{
availableConcepts: availableConcepts.map(c => c.name),
selectedToolsContext: selectedToolNames
selectedToolsContext: selectedToolNames,
selectionCriteria: 'methodische Fundierung'
},
{
selectedConcepts: context.backgroundKnowledge.map(bk => bk.concept.name),
selectionReasonings: context.backgroundKnowledge.map(bk => bk.relevance)
},
context.backgroundKnowledge.length > 0 ? 75 : 50,
finalConfidence,
taskStart,
{
microTaskType: 'background-knowledge',
availableConceptsCount: availableConcepts.length,
selectedConceptsCount: context.backgroundKnowledge.length,
selectionRatio: context.backgroundKnowledge.length / availableConcepts.length,
responseConfidence,
selectionBonus,
decisionBasis: 'ai-analysis',
reasoning: `Wählte ${context.backgroundKnowledge.length} von ${availableConcepts.length} verfügbaren Konzepten für methodische Fundierung der Empfehlungen`,
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);
@@ -862,18 +915,31 @@ class AIPipeline {
const result = await this.callMicroTaskAI(prompt, context, 350, 'final-recommendations');
if (result.success) {
const confidence = auditService.calculateAIResponseConfidence(
result.content,
{ min: 60, max: 250 },
'final-recommendations'
);
const contextBonus = selectedToolNames.length >= 3 ? 10 : 0;
const finalConfidence = Math.min(95, confidence + contextBonus);
auditService.addAIDecision(
'synthesis',
prompt,
result.content,
85,
`Generated final ${context.mode} recommendations`,
finalConfidence,
`Generierte abschließende ${context.mode}-Empfehlungen basierend auf ausgewählten ${selectedToolNames.length} Tools - Synthese aller Analyseschritte zu kohärenter Handlungsempfehlung`,
taskStart,
{
microTaskType: 'final-recommendations',
mode: context.mode,
selectedToolsCount: selectedToolNames.length,
contentLength: result.content.length,
responseConfidence: confidence,
contextBonus,
decisionBasis: 'ai-analysis',
aiModel: aiService.getConfig().model,
...result.aiUsage
}
);