feat(growth,kernel,runtime): Embedding 接通 + 自学习自动化 — A线+B线 6 项实现
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
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
A线 Embedding 接通: - A1: MemoryRetriever.set_embedding_client() + GrowthIntegration.configure_embedding() + Kernel.set_embedding_client() + viking_configure_embedding 传播到 Kernel - A2: Skill 路由替换 new_tf_idf_only() 为 EmbeddingAdapter + LlmSkillFallback B线 自学习自动化: - B1: evolution_bridge.rs — candidate_to_manifest() (PromptOnly, disabled by default) - B2: Kernel::generate_and_register_skill() 全链路 (LLM→parse→QualityGate→manifest→persist) - B3: EvolutionMiddleware 双模式 (auto_mode 跳过注入, 留给 kernel 自动处理) - B4: QualityGate 加固 (body ≥100字符 + 必须含标题 + 置信度上限 1.0) 验证: 934 tests PASS, 0 failures
This commit is contained in:
@@ -148,6 +148,18 @@ impl GrowthIntegration {
|
||||
self.config.auto_extract = auto_extract;
|
||||
}
|
||||
|
||||
/// Configure embedding client for memory retrieval.
|
||||
///
|
||||
/// Propagates the embedding client to the MemoryRetriever's SemanticScorer,
|
||||
/// enabling embedding-based similarity in addition to TF-IDF.
|
||||
/// Safe to call from non-async contexts.
|
||||
pub fn configure_embedding(
|
||||
&self,
|
||||
client: Arc<dyn zclaw_growth::retrieval::semantic::EmbeddingClient>,
|
||||
) {
|
||||
self.retriever.set_embedding_client(client);
|
||||
}
|
||||
|
||||
/// Set the user profile store for incremental profile updates
|
||||
pub fn with_profile_store(mut self, store: Arc<UserProfileStore>) -> Self {
|
||||
self.profile_store = Some(store);
|
||||
|
||||
@@ -19,18 +19,35 @@ pub struct PendingEvolution {
|
||||
}
|
||||
|
||||
/// 进化引擎中间件
|
||||
/// 检查是否有待确认的进化事件,注入确认提示到 system prompt
|
||||
/// 检查是否有待确认的进化事件,根据模式:
|
||||
/// - suggest 模式(默认): 注入确认提示到 system prompt
|
||||
/// - auto 模式: 不注入,仅排队等待 kernel 自动处理
|
||||
pub struct EvolutionMiddleware {
|
||||
pending: Arc<RwLock<Vec<PendingEvolution>>>,
|
||||
auto_mode: bool,
|
||||
}
|
||||
|
||||
impl EvolutionMiddleware {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
pending: Arc::new(RwLock::new(Vec::new())),
|
||||
auto_mode: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create with auto mode enabled
|
||||
pub fn new_auto() -> Self {
|
||||
Self {
|
||||
pending: Arc::new(RwLock::new(Vec::new())),
|
||||
auto_mode: true,
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if auto mode is enabled
|
||||
pub fn is_auto_mode(&self) -> bool {
|
||||
self.auto_mode
|
||||
}
|
||||
|
||||
/// 添加一个待确认的进化事件
|
||||
pub async fn add_pending(&self, evolution: PendingEvolution) {
|
||||
self.pending.write().await.push(evolution);
|
||||
@@ -73,7 +90,12 @@ impl AgentMiddleware for EvolutionMiddleware {
|
||||
return Ok(MiddlewareDecision::Continue);
|
||||
}
|
||||
|
||||
// 只移除第一个事件,保留后续事件留待下次注入
|
||||
// Auto mode: don't inject into prompt, leave for kernel to process
|
||||
if self.auto_mode {
|
||||
return Ok(MiddlewareDecision::Continue);
|
||||
}
|
||||
|
||||
// Suggest mode: 只移除第一个事件,保留后续事件留待下次注入
|
||||
let to_inject = {
|
||||
let mut pending = self.pending.write().await;
|
||||
if pending.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user