fix(core): 修复 v0.3.0 审查发现的 6 项警告问题

- InMemoryGraph 的 10 处 lock().unwrap() 改为错误传播,避免 Mutex poison 时 panic
- SubTaskResult 添加 Serialize/Deserialize,支持结果序列化
- dispatch_all 移除多余的 task.clone()
- truncate_total_chars 补充字节切片安全性注释
- SessionManager::children 添加 ponytail 注释标记 O(N) 扫描现状
- SessionMemoryEntry.created_at 添加 i64 类型说明注释
This commit is contained in:
徐涛
2026-07-17 15:59:02 +08:00
parent 9d73f525d0
commit 6676322666
5 changed files with 41 additions and 13 deletions
+3 -1
View File
@@ -124,7 +124,9 @@ fn truncate_total_chars(s: &str, max_chars: usize) -> String {
let dropped: String = s.chars().take(skip).collect();
let mut kept = String::with_capacity(max_chars + 8);
kept.push_str("[... earlier messages truncated ...]\n");
kept.push_str(&s[dropped.len()..]); // 字节切:dropped.len() 字节一定在 char 边界
// 字节切安全dropped 由 s.chars().take(skip).collect() 构建,
// 每个 char 的 UTF-8 字节序列完整保留,故 dropped.len() 恰好是 s 的某个 char 边界字节偏移。
kept.push_str(&s[dropped.len()..]);
kept
}