fix(audit): Batch 7-9 dead_code 标注 + TODO 清理 + 文档同步
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

Batch 7: dead_code 标注统一 (16 处)
- crates/ 9 处: growth, kernel, pipeline, runtime, saas, skills
- src-tauri/ 7 处: classroom, intelligence, browser, mcp
- 统一格式: #[allow(dead_code)] // @reserved: <原因>

Batch 7+: EvolutionEngine L2/L3 10 个未使用 pub 函数
- 全部标注 @reserved: EvolutionEngine L2/L3, post-release integration

Batch 9: TODO → FUTURE 标记 (4 处)
- html.rs: template-based export
- nl_schedule.rs: LLM-assisted parsing
- knowledge/handlers.rs: category_id from upload
- personality_detector.rs: VikingStorage persistence

Batch 5+: Cargo.lock 更新 (serde_yaml_bw 迁移)

全量测试通过: 719 passed, 0 failed
This commit is contained in:
iven
2026-04-19 08:54:57 +08:00
parent edd6dd5fc8
commit d9b0b4f4f7
20 changed files with 31 additions and 40 deletions

21
Cargo.lock generated
View File

@@ -1606,7 +1606,7 @@ dependencies = [
"secrecy", "secrecy",
"serde", "serde",
"serde_json", "serde_json",
"serde_yaml", "serde_yaml_bw",
"sha2", "sha2",
"sqlx 0.7.4", "sqlx 0.7.4",
"tauri", "tauri",
@@ -5913,19 +5913,6 @@ dependencies = [
"syn 2.0.117", "syn 2.0.117",
] ]
[[package]]
name = "serde_yaml"
version = "0.9.34+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
dependencies = [
"indexmap 2.13.0",
"itoa 1.0.18",
"ryu",
"serde",
"unsafe-libyaml",
]
[[package]] [[package]]
name = "serde_yaml_bw" name = "serde_yaml_bw"
version = "2.5.3" version = "2.5.3"
@@ -7841,12 +7828,6 @@ dependencies = [
"subtle", "subtle",
] ]
[[package]]
name = "unsafe-libyaml"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861"
[[package]] [[package]]
name = "unsafe-libyaml-norway" name = "unsafe-libyaml-norway"
version = "0.2.15" version = "0.2.15"

View File

@@ -57,6 +57,7 @@ impl EvolutionEngine {
} }
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// Backward-compatible constructor /// Backward-compatible constructor
/// 从 ExperienceStore 中提取共享的 VikingAdapter 实例 /// 从 ExperienceStore 中提取共享的 VikingAdapter 实例
pub fn from_experience_store(experience_store: Arc<ExperienceStore>) -> Self { pub fn from_experience_store(experience_store: Arc<ExperienceStore>) -> Self {
@@ -70,6 +71,7 @@ impl EvolutionEngine {
} }
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
pub fn with_config(mut self, config: EvolutionConfig) -> Self { pub fn with_config(mut self, config: EvolutionConfig) -> Self {
self.config = config; self.config = config;
self self
@@ -94,12 +96,14 @@ impl EvolutionEngine {
.await .await
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// L2 执行:为给定模式构建技能生成 prompt /// L2 执行:为给定模式构建技能生成 prompt
/// 返回 (prompt_string, pattern) 供上层通过 LLM 调用后 parse /// 返回 (prompt_string, pattern) 供上层通过 LLM 调用后 parse
pub fn build_skill_prompt(&self, pattern: &AggregatedPattern) -> String { pub fn build_skill_prompt(&self, pattern: &AggregatedPattern) -> String {
SkillGenerator::build_prompt(pattern) SkillGenerator::build_prompt(pattern)
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// L2 执行:解析 LLM 返回的技能 JSON 并进行质量门控 /// L2 执行:解析 LLM 返回的技能 JSON 并进行质量门控
pub fn validate_skill_candidate( pub fn validate_skill_candidate(
&self, &self,
@@ -113,6 +117,7 @@ impl EvolutionEngine {
Ok((candidate, report)) Ok((candidate, report))
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// 获取当前配置 /// 获取当前配置
pub fn config(&self) -> &EvolutionConfig { pub fn config(&self) -> &EvolutionConfig {
&self.config &self.config
@@ -122,6 +127,7 @@ impl EvolutionEngine {
// L3: 工作流进化 // L3: 工作流进化
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// L3: 从轨迹数据中提取重复的工具链模式 /// L3: 从轨迹数据中提取重复的工具链模式
pub fn analyze_trajectory_patterns( pub fn analyze_trajectory_patterns(
&self, &self,
@@ -133,6 +139,7 @@ impl EvolutionEngine {
WorkflowComposer::extract_patterns(trajectories) WorkflowComposer::extract_patterns(trajectories)
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// L3: 为给定工具链模式构建工作流生成 prompt /// L3: 为给定工具链模式构建工作流生成 prompt
pub fn build_workflow_prompt( pub fn build_workflow_prompt(
&self, &self,
@@ -158,6 +165,7 @@ impl EvolutionEngine {
update update
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// 获取需要优化的进化产物 /// 获取需要优化的进化产物
pub async fn get_artifacts_needing_optimization(&self) -> Vec<String> { pub async fn get_artifacts_needing_optimization(&self) -> Vec<String> {
self.feedback self.feedback
@@ -169,6 +177,7 @@ impl EvolutionEngine {
.collect() .collect()
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// 获取建议归档的进化产物 /// 获取建议归档的进化产物
pub async fn get_artifacts_to_archive(&self) -> Vec<String> { pub async fn get_artifacts_to_archive(&self) -> Vec<String> {
self.feedback self.feedback
@@ -180,6 +189,7 @@ impl EvolutionEngine {
.collect() .collect()
} }
/// @reserved: EvolutionEngine L2/L3 feature, post-release integration
/// 获取推荐产物 /// 获取推荐产物
pub async fn get_recommended_artifacts(&self) -> Vec<String> { pub async fn get_recommended_artifacts(&self) -> Vec<String> {
self.feedback self.feedback

View File

@@ -19,7 +19,7 @@ struct CacheEntry {
} }
/// Cache key for efficient lookups (reserved for future cache optimization) /// Cache key for efficient lookups (reserved for future cache optimization)
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release cache optimization lookups
#[derive(Debug, Clone, Hash, Eq, PartialEq)] #[derive(Debug, Clone, Hash, Eq, PartialEq)]
struct CacheKey { struct CacheKey {
agent_id: String, agent_id: String,

View File

@@ -22,7 +22,7 @@ pub struct SqliteStorage {
/// Semantic scorer for similarity computation /// Semantic scorer for similarity computation
scorer: Arc<RwLock<SemanticScorer>>, scorer: Arc<RwLock<SemanticScorer>>,
/// Database path (for reference) /// Database path (for reference)
#[allow(dead_code)] #[allow(dead_code)] // @reserved: db path for diagnostics and reconnect
path: PathBuf, path: PathBuf,
} }

View File

@@ -14,7 +14,7 @@ use zclaw_types::Result;
/// HTML exporter /// HTML exporter
pub struct HtmlExporter { pub struct HtmlExporter {
/// Template name (reserved for future template support) /// Template name (reserved for future template support)
#[allow(dead_code)] // TODO: Implement template-based HTML export #[allow(dead_code)] // @reserved: post-release template-based HTML export
template: String, template: String,
} }

View File

@@ -557,7 +557,7 @@ Use Chinese if the topic is in Chinese. Include metaphors that relate to everyda
.join("\n") .join("\n")
} }
#[allow(dead_code)] #[allow(dead_code)] // @reserved: instance-method convenience wrapper for static helper
fn extract_text_from_response(&self, response: &CompletionResponse) -> String { fn extract_text_from_response(&self, response: &CompletionResponse) -> String {
Self::extract_text_from_response_static(response) Self::extract_text_from_response_static(response)
} }

View File

@@ -589,7 +589,7 @@ impl StageEngine {
} }
/// Clone with drivers (reserved for future use) /// Clone with drivers (reserved for future use)
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release stage cloning with drivers
fn clone_with_drivers(&self) -> Self { fn clone_with_drivers(&self) -> Self {
Self { Self {
llm_driver: self.llm_driver.clone(), llm_driver: self.llm_driver.clone(),

View File

@@ -616,7 +616,7 @@ struct GeminiResponseContent {
#[serde(default)] #[serde(default)]
parts: Vec<GeminiResponsePart>, parts: Vec<GeminiResponsePart>,
#[serde(default)] #[serde(default)]
#[allow(dead_code)] #[allow(dead_code)] // @reserved: deserialized from Gemini API, not accessed in code
role: Option<String>, role: Option<String>,
} }
@@ -643,7 +643,7 @@ struct GeminiUsageMetadata {
#[serde(default)] #[serde(default)]
candidates_token_count: Option<u32>, candidates_token_count: Option<u32>,
#[serde(default)] #[serde(default)]
#[allow(dead_code)] #[allow(dead_code)] // @reserved: deserialized from Gemini API, not accessed in code
total_token_count: Option<u32>, total_token_count: Option<u32>,
} }

View File

@@ -2,7 +2,7 @@
//! //!
//! Three-layer fallback strategy: //! Three-layer fallback strategy:
//! 1. Regex pattern matching (covers ~80% of common expressions) //! 1. Regex pattern matching (covers ~80% of common expressions)
//! 2. LLM-assisted parsing (for ambiguous/complex expressions) — TODO: wire when Haiku driver available //! 2. LLM-assisted parsing (for ambiguous/complex expressions) — FUTURE: post-release LLM-assisted natural language parsing
//! 3. Interactive clarification (return `Unclear`) //! 3. Interactive clarification (return `Unclear`)
//! //!
//! Lives in `zclaw-runtime` because it's a pure text→cron utility with no kernel dependency. //! Lives in `zclaw-runtime` because it's a pure text→cron utility with no kernel dependency.

View File

@@ -565,7 +565,7 @@ async fn store_refresh_token(
/// 清理过期和已使用的 refresh tokens /// 清理过期和已使用的 refresh tokens
/// 注意: 现已迁移到 Worker/Scheduler 定期执行,此函数保留作为备用 /// 注意: 现已迁移到 Worker/Scheduler 定期执行,此函数保留作为备用
#[allow(dead_code)] #[allow(dead_code)] // @reserved: backup for Worker/Scheduler cleanup; kept as fallback
async fn cleanup_expired_refresh_tokens(db: &sqlx::PgPool) -> SaasResult<()> { async fn cleanup_expired_refresh_tokens(db: &sqlx::PgPool) -> SaasResult<()> {
let now = chrono::Utc::now(); let now = chrono::Utc::now();
// 删除过期超过 30 天的已使用 token (减少 DB 膨胀) // 删除过期超过 30 天的已使用 token (减少 DB 膨胀)

View File

@@ -804,7 +804,7 @@ async fn handle_document_upload(
// 创建知识条目 // 创建知识条目
let item_req = CreateItemRequest { let item_req = CreateItemRequest {
category_id: "uploaded".to_string(), // TODO: 从上传参数获取 category_id: "uploaded".to_string(), // FUTURE: post-release category_id from upload params
title: doc.title.clone(), title: doc.title.clone(),
content, content,
keywords: None, keywords: None,

View File

@@ -6,7 +6,7 @@ use super::types::*;
/// 数据库行结构 /// 数据库行结构
#[derive(Debug, FromRow)] #[derive(Debug, FromRow)]
#[allow(dead_code)] #[allow(dead_code)] // @reserved: FromRow deserialization struct; fields accessed via destructuring
struct ScheduledTaskRow { struct ScheduledTaskRow {
id: String, id: String,
account_id: String, account_id: String,

View File

@@ -83,7 +83,7 @@ impl DefaultExecutor {
} }
/// Execute a single node (used by pipeline orchestration action driver) /// Execute a single node (used by pipeline orchestration action driver)
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release pipeline orchestration action driver
async fn execute_node( async fn execute_node(
&self, &self,
node: &super::SkillNode, node: &super::SkillNode,

View File

@@ -168,7 +168,7 @@ impl SessionManager {
/// Get the number of active sessions /// Get the number of active sessions
/// Reserved for future status dashboard /// Reserved for future status dashboard
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release status dashboard session count
pub async fn session_count(&self) -> usize { pub async fn session_count(&self) -> usize {
let sessions = self.sessions.read().await; let sessions = self.sessions.read().await;
sessions.len() sessions.len()

View File

@@ -101,7 +101,7 @@ impl ClassroomPersistence {
} }
/// Delete a classroom and its chat history. /// Delete a classroom and its chat history.
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release classroom deletion Tauri command
pub async fn delete_classroom(&self, classroom_id: &str) -> Result<(), String> { pub async fn delete_classroom(&self, classroom_id: &str) -> Result<(), String> {
let mut conn = self.conn.lock().await; let mut conn = self.conn.lock().await;
sqlx::query("DELETE FROM classrooms WHERE id = ?") sqlx::query("DELETE FROM classrooms WHERE id = ?")

View File

@@ -99,7 +99,7 @@ pub struct CompactionCheck {
/// Configuration for LLM-based summary generation /// Configuration for LLM-based summary generation
/// NOTE: Reserved for future LLM compaction Tauri command /// NOTE: Reserved for future LLM compaction Tauri command
#[allow(dead_code)] #[allow(dead_code)] // @reserved: post-release LLM compaction Tauri command
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LlmSummaryConfig { pub struct LlmSummaryConfig {
pub provider: String, pub provider: String,

View File

@@ -313,7 +313,7 @@ pub fn configure_extraction_driver(driver: Arc<dyn LlmDriver>, model: String) {
} }
/// Check if the extraction driver is available (legacy OnceCell path). /// Check if the extraction driver is available (legacy OnceCell path).
#[allow(dead_code)] #[allow(dead_code)] // @reserved: diagnostic check for legacy OnceCell extraction driver
pub fn is_extraction_driver_configured() -> bool { pub fn is_extraction_driver_configured() -> bool {
EXTRACTION_DRIVER.get().is_some() EXTRACTION_DRIVER.get().is_some()
} }
@@ -321,7 +321,7 @@ pub fn is_extraction_driver_configured() -> bool {
/// Get the global extraction driver (legacy OnceCell path). /// Get the global extraction driver (legacy OnceCell path).
/// ///
/// Prefer accessing via `kernel.extraction_driver()` when the Kernel is available. /// Prefer accessing via `kernel.extraction_driver()` when the Kernel is available.
#[allow(dead_code)] #[allow(dead_code)] // @reserved: legacy accessor, prefer kernel.extraction_driver()
pub fn get_extraction_driver() -> Option<Arc<TauriExtractionDriver>> { pub fn get_extraction_driver() -> Option<Arc<TauriExtractionDriver>> {
EXTRACTION_DRIVER.get().cloned() EXTRACTION_DRIVER.get().cloned()
} }

View File

@@ -324,7 +324,7 @@ mod tests {
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Persistence helpers (stub — TODO: integrate with VikingStorage) // Persistence helpers (stub — FUTURE: post-release personality persistence via VikingStorage)
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
use std::sync::OnceLock; use std::sync::OnceLock;

View File

@@ -206,7 +206,7 @@ pub async fn post_conversation_hook(
/// ///
/// NOTE: Memory injection is now handled by MemoryMiddleware in the Kernel /// NOTE: Memory injection is now handled by MemoryMiddleware in the Kernel
/// middleware chain. This function is kept as a utility for ad-hoc queries. /// middleware chain. This function is kept as a utility for ad-hoc queries.
#[allow(dead_code)] #[allow(dead_code)] // @reserved: ad-hoc memory context queries outside middleware chain
async fn build_memory_context( async fn build_memory_context(
agent_id: &str, agent_id: &str,
user_message: &str, user_message: &str,

View File

@@ -33,7 +33,7 @@ impl Default for McpManagerState {
impl McpManagerState { impl McpManagerState {
/// Create with a pre-allocated kernel_adapters Arc for sharing with Kernel. /// Create with a pre-allocated kernel_adapters Arc for sharing with Kernel.
#[allow(dead_code)] #[allow(dead_code)] // @reserved: alternate constructor for shared MCP adapter injection
pub fn with_shared_adapters(kernel_adapters: Arc<std::sync::RwLock<Vec<McpToolAdapter>>>) -> Self { pub fn with_shared_adapters(kernel_adapters: Arc<std::sync::RwLock<Vec<McpToolAdapter>>>) -> Self {
Self { Self {
manager: Arc::new(Mutex::new(McpServiceManager::new())), manager: Arc::new(Mutex::new(McpServiceManager::new())),