fix: 全面审计修复 — P0 功能缺陷 + P1 代码质量
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

P0 功能修复:
- stats: Admin V2 仪表盘 API 路径修正 (/stats/dashboard → /admin/dashboard)
- mcp: 桌面端 MCP 插件增加 isTauriRuntime() 守卫,避免浏览器模式崩溃
- admin: 侧边栏高亮逻辑修复 (startsWith → 精确匹配+子路径)

P1 代码质量:
- 删除 workflowBuilderStore.ts 死代码 (456行,零引用)
- sqlite.rs 3 处 SQL 静默失败改为 tracing::warn! 日志
- mcp_tool_adapter 2 处 unwrap 改为安全回退
- orchestration_execute 添加 @reserved 标注
- TRUTH.md 测试数字校准 (734→803),Store 数 26→25
This commit is contained in:
iven
2026-04-18 23:57:03 +08:00
parent ab4d06c4d6
commit 0fd78ac321
8 changed files with 27 additions and 473 deletions

View File

@@ -218,11 +218,14 @@ impl SqliteStorage {
let mut hasher = std::collections::hash_map::DefaultHasher::new();
normalized.hash(&mut hasher);
let hash = format!("{:016x}", hasher.finish());
let _ = sqlx::query("UPDATE memories SET content_hash = ? WHERE uri = ?")
if let Err(e) = sqlx::query("UPDATE memories SET content_hash = ? WHERE uri = ?")
.bind(&hash)
.bind(uri)
.execute(&self.pool)
.await;
.await
{
tracing::warn!("[sqlite] content_hash update failed for {}: {}", uri, e);
}
}
tracing::info!(
"[SqliteStorage] Backfilled content_hash for {} existing entries",
@@ -256,9 +259,12 @@ impl SqliteStorage {
if needs_rebuild {
tracing::info!("[SqliteStorage] Rebuilding FTS5 table: unicode61 → trigram for CJK support");
// Drop old FTS5 table
let _ = sqlx::query("DROP TABLE IF EXISTS memories_fts")
if let Err(e) = sqlx::query("DROP TABLE IF EXISTS memories_fts")
.execute(&self.pool)
.await;
.await
{
tracing::warn!("[sqlite] FTS5 table drop failed during rebuild: {}", e);
}
// Recreate with trigram tokenizer
sqlx::query(
r#"
@@ -423,14 +429,17 @@ impl SqliteStorage {
.await;
// Also clean up FTS entries for archived memories
let _ = sqlx::query(
if let Err(e) = sqlx::query(
r#"
DELETE FROM memories_fts
WHERE uri NOT IN (SELECT uri FROM memories)
"#,
)
.execute(&self.pool)
.await;
.await
{
tracing::warn!("[sqlite] FTS cleanup after archive failed: {}", e);
}
let archived = archive_result
.map(|r| r.rows_affected())

View File

@@ -130,7 +130,7 @@ impl McpToolAdapter {
match result.len() {
0 => Ok(Value::Null),
1 => Ok(result.into_iter().next().unwrap()),
1 => Ok(result.into_iter().next().unwrap_or(Value::Null)),
_ => Ok(Value::Array(result)),
}
}
@@ -160,7 +160,7 @@ impl McpServiceManager {
let adapters = McpToolAdapter::from_server(name.clone(), client.clone()).await?;
self.clients.insert(name.clone(), client);
self.adapters.insert(name.clone(), adapters);
Ok(self.adapters.get(&name).unwrap().iter().collect())
Ok(self.adapters.get(&name).map(|v| v.iter().collect()).unwrap_or_default())
}
/// Get all registered tool adapters from all services