fix: butler audit critical fixes — pain detection, proposal trigger, URI + data flow
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

5 fixes from focused audit:
- Connect analyze_for_pain_signals() to post_conversation_hook (pain points now auto-created)
- Add "generate solution" button in InsightsSection for high-confidence pain points (>=0.7)
- Fix Memory URI mismatch: viking://agents/ → viking://agent/ (singular)
- Remove duplicate .then() chain in useButlerInsights (was destructuring undefined)
- Update stale director.rs doc comment (multi-agent now enabled by default)
This commit is contained in:
iven
2026-04-07 10:23:54 +08:00
parent 58703492e1
commit a5b887051d
6 changed files with 69 additions and 12 deletions

View File

@@ -78,6 +78,37 @@ pub async fn post_conversation_hook(
}
}
// Step 1.6: Detect pain signals from user message
if !_user_message.is_empty() {
let messages = vec![zclaw_types::Message::user(_user_message)];
if let Some(analysis) = crate::intelligence::pain_aggregator::analyze_for_pain_signals(&messages) {
let severity_str = match analysis.severity {
crate::intelligence::pain_aggregator::PainSeverity::High => "high",
crate::intelligence::pain_aggregator::PainSeverity::Medium => "medium",
crate::intelligence::pain_aggregator::PainSeverity::Low => "low",
};
match crate::intelligence::pain_aggregator::butler_record_pain_point(
agent_id.to_string(),
"default_user".to_string(),
analysis.summary,
analysis.category,
severity_str.to_string(),
_user_message.to_string(),
analysis.evidence,
).await {
Ok(pain) => {
debug!(
"[intelligence_hooks] Pain point recorded: {} (confidence: {:.2}, count: {})",
pain.summary, pain.confidence, pain.occurrence_count
);
}
Err(e) => {
warn!("[intelligence_hooks] Failed to record pain point: {}", e);
}
}
}
}
// Step 2: Record conversation for reflection
let mut engine = reflection_state.lock().await;