fix(growth): 二次审计修复 — 6项 CRITICAL/HIGH/MEDIUM 全部修复
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
CRITICAL-1/2: json_utils 花括号匹配改为括号平衡算法 - 处理字符串字面量中的花括号和转义引号 - 新增 5 个测试(平衡匹配、字符串内花括号、转义引号、extract_string_array) HIGH-4: EvolutionMiddleware 只取第一个事件(remove(0)),不丢弃后续 HIGH-5: EvolutionMiddleware 先 read() 判空再 write(),减少锁竞争 HIGH-7: from_experience_store 使用传入 store 的 viking 实例(不再忽略参数) - ExperienceStore 新增 viking() getter MEDIUM-9: skill_generator + workflow_composer JSON 数组解析去重 - 新增 json_utils::extract_string_array() 共享函数 MEDIUM-14: EvolutionMiddleware 注入文本去除多余缩进空格 测试: zclaw-growth 133 tests, zclaw-runtime 87 tests, workspace 0 failures
This commit is contained in:
@@ -67,32 +67,14 @@ impl SkillGenerator {
|
||||
zclaw_types::ZclawError::ConfigError(format!("Invalid skill JSON: {}", e))
|
||||
})?;
|
||||
|
||||
let triggers: Vec<String> = raw["triggers"]
|
||||
.as_array()
|
||||
.map(|a: &Vec<serde_json::Value>| {
|
||||
a.iter()
|
||||
.filter_map(|v: &serde_json::Value| v.as_str().map(String::from))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let tools: Vec<String> = raw["tools"]
|
||||
.as_array()
|
||||
.map(|a: &Vec<serde_json::Value>| {
|
||||
a.iter()
|
||||
.filter_map(|v: &serde_json::Value| v.as_str().map(String::from))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(SkillCandidate {
|
||||
name: raw["name"]
|
||||
.as_str()
|
||||
.unwrap_or("未命名技能")
|
||||
.to_string(),
|
||||
description: raw["description"].as_str().unwrap_or("").to_string(),
|
||||
triggers,
|
||||
tools,
|
||||
triggers: crate::json_utils::extract_string_array(&raw, "triggers"),
|
||||
tools: crate::json_utils::extract_string_array(&raw, "tools"),
|
||||
body_markdown: raw["body_markdown"].as_str().unwrap_or("").to_string(),
|
||||
source_pattern: pattern.pain_pattern.clone(),
|
||||
confidence: raw["confidence"].as_f64().unwrap_or(0.5) as f32,
|
||||
|
||||
Reference in New Issue
Block a user