fix(growth): AUD-11 反馈信任度启动集成 + AUD-12 日志格式优化
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

AUD-11: FeedbackCollector 内部 lazy-load 机制
- save() 首次调用自动从持久化存储加载信任度记录
- load() 使用 or_insert 策略,不覆盖内存中较新记录
- GrowthIntegration.initialize() 保留为可选优化入口
- 移除无法在 &self 中间件中使用的 ensure_feedback_loaded

AUD-12: 日志格式优化
- ProfileSignals 新增 signal_count() 方法
- extractor.rs 使用 signal_count() 替代 has_any_signal() as usize
This commit is contained in:
iven
2026-04-19 00:15:50 +08:00
parent 0fd78ac321
commit 72b3206a6b
4 changed files with 61 additions and 4 deletions

View File

@@ -116,6 +116,34 @@ impl GrowthIntegration {
self.config.enabled
}
/// 启动时初始化:从持久化存储恢复进化引擎的信任度记录
///
/// **注意**FeedbackCollector 内部已实现 lazy-load首次 save() 时自动加载),
/// 所以此方法为可选优化 — 提前加载可避免首次反馈提交时的延迟。
/// 在中间件持有 GrowthIntegration 的场景中,由于 `&self` 限制无法调用此方法,
/// lazy-load 机制会兜底处理。
pub async fn initialize(&mut self) -> Result<()> {
if let Some(ref mut engine) = self.evolution_engine {
match engine.load_feedback().await {
Ok(count) => {
if count > 0 {
tracing::info!(
"[GrowthIntegration] Loaded {} trust records from storage",
count
);
}
}
Err(e) => {
tracing::warn!(
"[GrowthIntegration] Failed to load trust records: {}",
e
);
}
}
}
Ok(())
}
/// Enable or disable auto extraction
pub fn set_auto_extract(&mut self, auto_extract: bool) {
self.config.auto_extract = auto_extract;