mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-09-22 18:08:04 +00:00
feat(lightkernel): N2c —— 轻量内核 profile(窄接口 GraphMemory + nil 即禁用整理面)
按用户指出的关键点(a.memory 多数使用点属"主 agent 整理记忆"与"记忆整理流水线", 子不该有那些路径)实现,方案见设计 §16.0。 ## 窄接口:只有 Recall + Commit 新增 `GraphMemory` 接口(memoryface.go)—— 按调用方实测分类后,真正"根与子都要"的只有这两个: - `Recall`:上下文检索 / memory_recall - `Commit`:自动写入路径的图部分 / memory_commit 新增 `Agent.graph`(共同面)与 `Agent.graphMem()` 访问器: - `graph` 显式为 nil 时**回落**到 `memory` ⇒ 既有"只用 Agent 字面量设 memory"的测试无需改动 (原本会出现"必须同时设两个字段"的脚坑,实测踩到后去掉了) - 轻量内核:`graph = *memory.LightMemory`,`memory = nil` ## nil 即禁用:整理面自动消失,不需要受限包装 子的 `a.memory == nil` ⇒ 既有的 22 处 `if a.memory != nil` 关卡自动禁掉全部整理面: - 记忆整理流水线(distill.go 的 archive/review/merge 循环) - 记忆块 + 媒体桥(graphmedia.go / medialoop.go) - 记忆整理工具(memory_merge / memory_delete_entity / memory_block_merge / memory_purge / memory_edit / memory_introspect)—— 它们本就在 `if a.memory != nil` 块内 唯一拆开的一处是自动写入 `commitTriplesWithMedia`: 图部分走 `graphMem().Commit`(父落 main、子落 temp),块/媒体部分仍由 `a.memory != nil` 守卫。 `executeMemoryTool` 的读路径改走 `graphMem().Recall`;整理类 case 加 `requireFull()` 闸门, 被直调时明确报"本 agent 是轻量内核:记忆整理不可用",不静默降级。 ## 验收(3 项新测试) - `TestLightProfile_MemoryFaceWiring`:整理面为 nil、写入只落 temp(主库无子痕迹)、 读是并集(主库实体 + temp 实体都看得到) - `TestLightProfile_OrganizeToolsAbsentAndRefused`:整理类工具**不进工具表**; 即便被直调也明确报"轻量内核不支持" - `TestFullProfile_KeepsOrganizeFace`:对照,根 agent 仍保留整理面与整理工具 全仓 go test ./... 37 包 ok / 0 FAIL;-race(agent/memory)干净;gofmt 干净。
This commit is contained in:
@ -545,11 +545,11 @@ type GraphMemory interface {
|
||||
| **N0** | **无状态化**:删 `Agent.currentOutputChannel`、删提示词里的通道预设 | S18;既有全部测试通过(这是纯收敛,不含新能力) |
|
||||
| **N1a** | **通道登记层**:inputch 一等化(归属插件 / 归属 agent / 容量 / 共享登记表)+ **单工具多视图总览** | S21–S23 |
|
||||
| **N1b** | 输出通道授权过滤 + 目标解析(outputch → 目标 agent 的 inputch) | S1–S3 |
|
||||
| **N2a** | **作用域对象 + 图记忆 space 维度**:`memory.Scope{Write string; Read []string}`;`entities/sentences/relations` 加 `space` 列(默认 `main`,老数据迁移视为 main);写落 `Write`、查询过滤 `space IN Read` | 同 space 可见、跨 space 不可见 |
|
||||
| **N2b** | **图记忆的向量检索**接入同一 space 过滤(子能按 space 语义检索) | 检索不跨 space 越界 |
|
||||
| **N2a** | ~~作用域对象 + 图记忆 space 维度~~ **已完成(改为独立存储实例)**:`OpenGraphDBReadOnly`(query_only 受限句柄)+ `LightMemory`(temp 可写 / 主库只读 / 并集查询 + 应用层合并) | S13–S15 ✅ |
|
||||
| **N2b** | 图记忆的向量检索在并集下的排序/去重(当前按实体名/三元组合并,检索排序沿用单库语义) | 待做(非阻塞) |
|
||||
| — | 其余记忆面(doc 记忆 / 动态上下文 / 知识库 / 文本 / 媒体 / 社交):**v1 不加 space**(子不可达) | 由 S13/S14 隐含 |
|
||||
| **N2c** | **Agent 级 profile(轻量内核接线)**:见下方施工方案 | S13–S15 |
|
||||
| **N2d** | **晋升与丢弃**:`Promote(space, records)`(回收时父把选中的 temp 记录写进 main)+ `DropSpace(space)`(回收/销毁时丢弃 temp) | S11 的数据面 |
|
||||
| **N2c** | ~~Agent 级 profile~~ **已完成**:`GraphMemory` 窄接口(Recall/Commit)+ `a.graph` 共同面;子 `a.memory = nil` ⇒ 22 处既有关卡自动禁用整理面 | S13–S15 ✅ |
|
||||
| **N2d** | ~~晋升与丢弃~~ **数据面已完成**:`GraphDB.ExportTriples` + 复用 `Commit` 合入(父选哪几条);`LightMemory.Close()` 丢弃 temp | S11 数据面 ✅ |
|
||||
| **N3** | **驻留子生命周期**:创建 / 销毁 / 登记表 / 父退出清理 | S12、S16 |
|
||||
| **N4** | **跨 agent 投递**:子→父 L3、父→子 L4(+ `isKernelLevelSource` 分层) | S4、S6、S17 |
|
||||
| **N5** | **inputch 处理表**:主动写入工具 + 自动写兜底 + 生命周期 | S8、S9 |
|
||||
|
||||
Reference in New Issue
Block a user