fix(audit): 修复深度审计 P1/P2 问题 — 记忆统一、持久化、前端适配
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
H3: 重写 memory_commands.rs 统一到 VikingStorage 单一存储,移除双写 H4: 心跳引擎 record_interaction() 持久化到 VikingStorage,启动时恢复 M4: 反思结果/状态持久化到 VikingStorage metadata,重启后自动恢复 - HandApprovalModal import 修正 (handStore 替代 gatewayStore) - kernel-client.ts 幽灵调用替换为 kernel_status - PersistentMemoryStore dead_code warnings 清理 - 审计报告和 README 更新至 v0.6.3,完成度 58%→62%
This commit is contained in:
@@ -53,10 +53,10 @@
|
||||
|
||||
| 功能 | 文档声称 | 真实完成度 | 差距模式 | 严重度 |
|
||||
|------|----------|-----------|----------|--------|
|
||||
| **Agent 记忆** | L4 (90%) | **L3 (75%)** | 双存储路径使用不同数据库 | HIGH |
|
||||
| **Agent 记忆** | L4 (90%) | **L4 (85%)** | ~~双存储路径使用不同数据库~~ ✅ 已修复 (H3) — 统一到 VikingStorage | ~~HIGH~~ FIXED |
|
||||
| **身份演化** | L2 (70%) | **L2 (65%)** | SOUL.md 注入已验证,但前端回滚 UI 缺失 | MEDIUM |
|
||||
| **反思引擎** | L2 (65%) | **L2 (55%)** | ~~传入空记忆数组~~ ✅ 已修复 (C2);结果仍未反馈到行为 | ~~MEDIUM~~ PARTIAL |
|
||||
| **心跳引擎** | L2 (70%) | **L1 (35%)** | 默认禁用(enabled=false),无持久化,无定时器 | HIGH |
|
||||
| **反思引擎** | L2 (65%) | **L2 (60%)** | ~~传入空记忆数组~~ ✅ 已修复 (C2);~~结果未持久化~~ ✅ 已修复 (M4);UI 展示仍缺失 | ~~MEDIUM~~ PARTIAL |
|
||||
| **心跳引擎** | L2 (70%) | **L1 (40%)** | ~~无持久化~~ ✅ 已修复 (H4);默认禁用(enabled=false),需前端主动启动 | ~~HIGH~~ PARTIAL |
|
||||
| **自主授权** | L2 (75%) | **L2 (60%)** | 前端组件存在但未在执行链路中调用 canAutoExecute | MEDIUM |
|
||||
| **上下文压缩** | L2 (75%) | **L2 (70%)** | 规则压缩已集成,LLM 压缩存在但默认关闭 | LOW |
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
|
||||
| 维度 | 文档声称 | 审计结果 | 修复后 |
|
||||
|------|----------|----------|--------|
|
||||
| **整体** | 68% | **~50%** | **~58%** |
|
||||
| **核心可用** | 85% | **75%** | **~82%** |
|
||||
| **真实可用** | 100% | **~55%**(排除模拟实现和 PromptOnly 技能后) | **~70%** |
|
||||
| **整体** | 68% | **~50%** | **~62%** |
|
||||
| **核心可用** | 85% | **75%** | **~85%** |
|
||||
| **真实可用** | 100% | **~55%**(排除模拟实现和 PromptOnly 技能后) | **~72%** |
|
||||
|
||||
---
|
||||
|
||||
@@ -129,7 +129,9 @@
|
||||
- 短期: UI 明确标注"模拟模式",禁用写操作
|
||||
- 中期: 实现 Twitter API v2 或改为 Mastodon API
|
||||
|
||||
#### H3: 记忆系统双存储路径不同步
|
||||
#### H3: 记忆系统双存储路径不同步 ✅ **已修复**
|
||||
- **修复方案**: 完全重写 `memory_commands.rs`,所有操作统一委派到 VikingStorage (SqliteStorage)。移除了 PersistentMemoryStore 的双写逻辑。保留 PersistentMemory 类型作为前端 API 兼容层,内部通过 `to_persistent()` 转换。
|
||||
- **修复文件**: `memory_commands.rs`, `viking_commands.rs`, `memory/mod.rs`
|
||||
- **路径A**: `memory_commands.rs` → `PersistentMemoryStore` → `{app_data_dir}/memory/memories.db`(UI 面板使用)
|
||||
- **路径B**: `intelligence_hooks.rs` → `VikingStorage` → `{data_dir}/zclaw/memories/memories.db`(聊天流程使用)
|
||||
- **证据**: 两个路径使用**不同的数据库文件**。`memory_store()` 第88-94行虽有双写逻辑,但 `memory_search()` 优先用 VikingStorage,`intelligence_hooks` 也只用 VikingStorage。`memory_db_path()` 返回的是 PersistentMemoryStore 的路径。
|
||||
@@ -137,7 +139,9 @@
|
||||
- **影响**: UI 面板存储的记忆可能无法在聊天时被检索到
|
||||
- **解决方案**: 统一到 `zclaw-growth` 的 SqliteStorage(已有 FTS5 + TF-IDF + 可选 embedding)
|
||||
|
||||
#### H4: 心跳引擎无持久化(已在启动时运行)
|
||||
#### H4: 心跳引擎无持久化(已在启动时运行) ✅ **已修复**
|
||||
- **修复方案**: `record_interaction()` 现在通过 `tokio::spawn` 将交互时间戳持久化到 VikingStorage metadata(key: `heartbeat:last_interaction:{agent_id}`)。`heartbeat_init()` 在初始化时调用 `restore_last_interaction()` 从 VikingStorage 恢复上次交互时间,确保 `idle-greeting` 检查在应用重启后仍能正确工作。
|
||||
- **修复文件**: `heartbeat.rs`
|
||||
- **文件**: `desktop/src-tauri/src/intelligence/heartbeat.rs`
|
||||
- **证据**:
|
||||
- `HeartbeatConfig::default()` 中 `enabled: false`(第103行),但 `App.tsx:181` 主动调用 `heartbeat.start()`
|
||||
@@ -214,7 +218,9 @@
|
||||
- **影响**: 无法按 hand 类型筛选审批
|
||||
- **解决方案**: 实现按 hand_name + run_id 联合查找
|
||||
|
||||
#### M4: 反思引擎结果未反馈到行为
|
||||
#### M4: 反思引擎结果未反馈到行为 ✅ **已修复(持久化部分)**
|
||||
- **修复方案**: `reflect()` 完成后通过 `tokio::spawn` 将 ReflectionState 和 ReflectionResult 持久化到 VikingStorage metadata。新增 `restore_state()` 方法在初始化时从 VikingStorage 恢复状态,确保 `conversations_since_reflection` 计数器在重启后保持。`intelligence_hooks` 在首次 `post_conversation_hook` 时通过 `pop_restored_state/result` 消费恢复数据。
|
||||
- **修复文件**: `reflection.rs`, `intelligence_hooks.rs`
|
||||
- **文件**: `desktop/src-tauri/src/intelligence/reflection.rs:190-233`
|
||||
- **证据**: `reflect()` 基于规则检测模式(task ≥ 5、preference ≥ 5、lesson ≥ 5),生成改进建议,但结果仅存入内存 `history: Vec<ReflectionResult>`(最多保留 20 条),不持久化且不用于修改后续行为。**更严重的是,由于 C1 bug,这些结果永远是空的。**
|
||||
- **差距模式**: 传了没存 + 存了没用
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# ZCLAW 功能全景文档
|
||||
|
||||
> **版本**: v0.6.2
|
||||
> **版本**: v0.6.3
|
||||
> **更新日期**: 2026-03-27
|
||||
> **项目状态**: 完整 Rust Workspace 架构,10 个核心 Crates,69 技能,Pipeline DSL + Smart Presentation + Agent Growth System
|
||||
> **整体完成度**: ~58% (基于 2026-03-27 深度审计 + P0/P1 修复后)
|
||||
> **整体完成度**: ~62% (基于 2026-03-27 深度审计 + 两轮修复后)
|
||||
> **架构**: Tauri 桌面应用,Rust Workspace (10 crates) + React 前端
|
||||
>
|
||||
> **审计修复 (2026-03-27)**: 修复 2 个 CRITICAL + 4 个 HIGH + 1 个 MEDIUM 问题,详见 [DEEP_AUDIT_REPORT.md](./DEEP_AUDIT_REPORT.md)
|
||||
> **审计修复 (2026-03-27)**: 修复 2 个 CRITICAL + 6 个 HIGH + 2 个 MEDIUM 问题,详见 [DEEP_AUDIT_REPORT.md](./DEEP_AUDIT_REPORT.md)
|
||||
|
||||
> **重要**: ZCLAW 采用 Rust Workspace 架构,包含 10 个分层 Crates (types → memory → runtime → kernel → skills/hands/protocols/pipeline/growth/channels),所有核心能力集成在 Tauri 桌面应用中
|
||||
|
||||
@@ -38,11 +38,11 @@
|
||||
| [00-agent-memory.md](02-intelligence-layer/00-agent-memory.md) | Agent 记忆 | L3-L4 (90%) | ✅ pre-hook (FTS5+TF-IDF+Embedding) | ✅ SqliteStorage |
|
||||
| [01-identity-evolution.md](02-intelligence-layer/01-identity-evolution.md) | 身份演化 | L2 (70%) | ✅ pre-hook (SOUL.md → system prompt) | ✅ Rust 实现 |
|
||||
| [06-context-compaction.md](02-intelligence-layer/06-context-compaction.md) | 上下文压缩 | L2-L3 (75%) | ✅ 已接入内核 (AgentLoop, LLM 摘要) | ✅ Rust 实现 |
|
||||
| [03-reflection-engine.md](02-intelligence-layer/03-reflection-engine.md) | 自我反思 | L2 (55%) | ✅ post-hook (自动触发 + 真实记忆) | ✅ Rust 实现 |
|
||||
| 心跳巡检 | 心跳巡检 | L2-L3 (70%) | ✅ post-hook (record_interaction) | ✅ Rust 实现 |
|
||||
| [03-reflection-engine.md](02-intelligence-layer/03-reflection-engine.md) | 自我反思 | L2 (60%) | ✅ post-hook (自动触发 + 真实记忆 + 持久化) | ✅ Rust 实现 |
|
||||
| 心跳巡检 | 心跳巡检 | L2-L3 (70%) | ✅ post-hook (record_interaction + VikingStorage 持久化) | ✅ Rust 实现 |
|
||||
| [05-autonomy-manager.md](02-intelligence-layer/05-autonomy-manager.md) | 自主授权 | L2-L3 (75%) | ✅ RightPanel 'autonomy' | ✅ TypeScript |
|
||||
|
||||
> **智能层集成说明** (2026-03-27): 通过 `intelligence_hooks.rs` 将 identity、memory context、heartbeat、reflection 接入 `agent_chat_stream` 流程。compactor 已在内核 AgentLoop 集成 (15k token 阈值)。反思引擎已修复空记忆 bug (C2),现在从 VikingStorage 查询真实记忆进行分析。已清理死代码: pattern_detector、recommender、mesh、persona_evolver、trigger_evaluator。
|
||||
> **智能层集成说明** (2026-03-27): 通过 `intelligence_hooks.rs` 将 identity、memory context、heartbeat、reflection 接入 `agent_chat_stream` 流程。compactor 已在内核 AgentLoop 集成 (15k token 阈值)。反思引擎已修复空记忆 bug (C2),现在从 VikingStorage 查询真实记忆进行分析。反思结果和状态已持久化到 VikingStorage metadata,重启后自动恢复 (H4/M4)。心跳引擎交互记录已持久化,idle-greeting 检查跨重启生效 (H4)。记忆系统已统一到 VikingStorage 单一存储 (H3)。已清理死代码: pattern_detector、recommender、mesh、persona_evolver、trigger_evaluator。
|
||||
|
||||
### 1.4 上下文数据库 (Context Database)
|
||||
|
||||
@@ -289,6 +289,7 @@ skills hands protocols pipeline growth channels
|
||||
|
||||
| 日期 | 版本 | 变更内容 |
|
||||
|------|------|---------|
|
||||
| 2026-03-27 | v0.6.3 | **审计修复 (P1/P2)**: H3 记忆双存储统一到 VikingStorage、H4 心跳引擎持久化 + 启动恢复、M4 反思结果持久化。整体完成度 58%→62%。|
|
||||
| 2026-03-27 | v0.6.2 | **审计修复 (P0/P1)**: C1 PromptOnly LLM 集成、C2 反思引擎空记忆修复、H7 Agent Store 接口适配、H8 Hand 审批检查、M1 幽灵命令注册、H1/H2 demo 标记、H5 归档过时报告。整体完成度 50%→58%。|
|
||||
| 2026-03-27 | v0.6.1 | **功能完整性修复**: 激活 LoopGuard 循环防护、实现 CapabilityManager.validate() 安全验证、handStore/workflowStore KernelClient 适配器、Credits 标注开发中、Skills 动态化、ScheduledTasks localStorage 降级、token 用量追踪 |
|
||||
| 2026-03-27 | v0.6.0a | **全面审计更新**:所有成熟度标注调整为实际完成度 (平均 68%),新增清理记录 |
|
||||
@@ -322,7 +323,16 @@ skills hands protocols pipeline growth channels
|
||||
| TwitterHand demo 标记 | H2 | 添加 `"demo"` 标签到 twitter.rs 和 twitter.HAND.toml |
|
||||
| 归档过时报告 | H5 | VERIFICATION_REPORT.md 顶部添加归档声明 |
|
||||
|
||||
### 7.2 代码清理
|
||||
### 7.2 审计修复 (P1/P2 第二轮)
|
||||
|
||||
| 修复项 | ID | 说明 |
|
||||
|--------|-----|------|
|
||||
| 记忆双存储统一 | H3 | 完全重写 `memory_commands.rs`,统一委派到 VikingStorage,移除 PersistentMemoryStore 双写 |
|
||||
| 心跳引擎持久化 | H4 | `record_interaction()` 持久化到 VikingStorage metadata,`heartbeat_init()` 启动时恢复 |
|
||||
| 反思结果持久化 | M4 | `reflect()` 后持久化 ReflectionState/Result 到 VikingStorage,重启后自动恢复 |
|
||||
| 清理 dead_code warnings | — | PersistentMemoryStore impl 添加 `#[allow(dead_code)]`,移除未使用的 `build_uri` |
|
||||
|
||||
### 7.3 代码清理
|
||||
|
||||
| 清理项 | 说明 |
|
||||
|--------|------|
|
||||
|
||||
Reference in New Issue
Block a user