diff --git a/README.md b/README.md index c0e8e24b..dd10741a 100644 --- a/README.md +++ b/README.md @@ -252,8 +252,8 @@ See [Development and Deployment](docs/DEPLOYMENT.md) for Docker, Compose, Ollama - [Mnemon Memory Harness](docs/framework/HARNESS.md) — skill-first memory harness design and installation guideline - [Harness Install Guide](docs/framework/INSTALL.md) — agent-facing installation contract - [Memory Guideline](docs/framework/GUIDELINE.md) — recall/writeback judgment policy -- [Self-Evolution Harness Design](docs/design/SELF_EVOLUTION_HARNESS.md) — consolidated v0.2 architecture for install, memory loop, skill evolution, and risk control -- [Agent Systems Research](docs/research/agent-systems/README.md) — condensed source index for memory and self-evolution research +- [Self-Evolution Harness Design](docs/design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md) — consolidated v0.2 architecture for install, memory loop, skill evolution, and risk control +- [Agent Systems Research](docs/design/self-evolution-harness/research/agent-systems/README.md) — condensed source index for memory and self-evolution research - [Design & Architecture](docs/DESIGN.md) — current engine architecture, algorithms, integration design - [Usage & Reference](docs/USAGE.md) — CLI commands, embedding support, architecture overview - [Architecture Diagrams](docs/diagrams/) — system architecture, pipelines, lifecycle management diff --git a/docs/DESIGN.md b/docs/DESIGN.md index ef50df3f..feea24f0 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -6,7 +6,7 @@ Mnemon is a persistent memory system designed for LLM agents. It adopts the **LLM-Supervised** pattern: the host LLM acts as external orchestrator of a standalone memory binary through symbolic CLI interfaces, while the binary handles deterministic storage, graph indexing, and lifecycle management. Memory is organized as a four-graph knowledge structure with temporal, entity, causal, and semantic edges. Implemented as a single Go binary + SQLite, with no external API dependencies. -This document describes the current Mnemon binary and engine architecture. The broader memory harness doctrine lives in [Mnemon Memory Harness](framework/HARNESS.md), with installable runtime artifacts in [INSTALL.md](framework/INSTALL.md) and [GUIDELINE.md](framework/GUIDELINE.md). The v0.2 self-evolution architecture is consolidated in [Self-Evolution Harness Design](design/SELF_EVOLUTION_HARNESS.md). +This document describes the current Mnemon binary and engine architecture. The broader memory harness doctrine lives in [Mnemon Memory Harness](framework/HARNESS.md), with installable runtime artifacts in [INSTALL.md](framework/INSTALL.md) and [GUIDELINE.md](framework/GUIDELINE.md). The v0.2 self-evolution architecture is consolidated in [Self-Evolution Harness Design](design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md). --- @@ -40,7 +40,7 @@ Effective Importance (EI) decay formula, immunity rules, auto-pruning, GC comman Markdown-installable runtime integration: `SKILL.md`, `INSTALL.md`, `GUIDELINE.md`, the four hook phases (Prime, Remind, Nudge, Compact), agent-led memory decisions, optional setup automation, and lightweight markdown self-evolution. -### [Self-Evolution Harness](design/SELF_EVOLUTION_HARNESS.md) +### [Self-Evolution Harness](design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md) The v0.2 architecture for agent-agnostic installation, canonical `.mnemon` filesystem, memory consolidation loop, skill evolution, optional maintenance runner, and proposal-first risk control. diff --git a/docs/design/SELF_EVOLUTION_HARNESS.md b/docs/design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md similarity index 98% rename from docs/design/SELF_EVOLUTION_HARNESS.md rename to docs/design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md index f7429f5a..23e9aa78 100644 --- a/docs/design/SELF_EVOLUTION_HARNESS.md +++ b/docs/design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md @@ -2,7 +2,7 @@ 本文档是 Mnemon self-evolution harness 的唯一核心设计入口。它替代此前分散在 `docs/design/self-evolution-harness/` 下的多份分篇设计,并把研究材料浓缩为架构决策所需的摘要。 -交互式架构展示保留在 [architecture-site.html](self-evolution-harness/architecture-site.html)。Issue 入口见 [#10](https://github.com/mnemon-dev/mnemon/issues/10),初始设计 PR 见 [#9](https://github.com/mnemon-dev/mnemon/pull/9)。 +交互式架构展示保留在 [architecture-site.html](architecture-site.html)。Memory loop MVP 的设计文档见 [memory-loop/README.zh.md](memory-loop/README.zh.md),双语可视化页面见 [memory-loop/site/index.html](memory-loop/site/index.html)。Issue 入口见 [#10](https://github.com/mnemon-dev/mnemon/issues/10),初始设计 PR 见 [#9](https://github.com/mnemon-dev/mnemon/pull/9)。 ## 1. 背景与决策 @@ -1196,7 +1196,7 @@ Cross-system conclusions: 5. Background maintenance needs provenance, reports, backups, and hard write boundaries. 6. Host-specific adapters should be convenience scripts, not the core architecture. -Source provenance is kept in [Agent Systems Research](../research/agent-systems/README.md). Detailed per-system notes were intentionally folded into this synthesis to keep the architecture maintainable. +Source provenance is kept in [Agent Systems Research](research/agent-systems/README.md). Detailed per-system notes were intentionally folded into this synthesis to keep the architecture maintainable. ## 18. 成功标准 Success Criteria diff --git a/docs/design/self-evolution-harness/architecture-site.html b/docs/design/self-evolution-harness/architecture-site.html index b3afe23f..6481f3f1 100644 --- a/docs/design/self-evolution-harness/architecture-site.html +++ b/docs/design/self-evolution-harness/architecture-site.html @@ -3,7 +3,7 @@ - + Mnemon Self-Evolution Harness Architecture - - -
-
-
-

Memory Loop MVP

-

第一版只实现一个清晰的记忆闭环:HostAgent 通过 hook 获得时机,通过 Markdown guide 做判断,通过 memory_get / memory_set / dreaming subagent 调用具体协议,最终在 MEMORY.md 与 Mnemon 之间完成在线读写和离线巩固。

-
- -
-
- -
-
-
-

System Components

-

这里先说明哪些东西是系统主体,哪些只是安装、触发、协议或维护资产。

-
- -
-
-
Three Core Parts
-
-
- HostAgent -

宿主 Agent 的核心引擎。它运行任务、接收 hook 注入,并根据 GUIDE.md 判断是否加载 skill 或启动 subagent。

-
-
- MEMORY.md -

工作记忆主体。Prime 直接把它加入 system prompt;memory_set.md 负责在线维护它。

-
-
- Mnemon -

长期记忆主体。mnemon binary 通过 brew 安装;memory_get.md 和 dreaming subagent 通过协议调用它。

-
-
-
- -
-
Maintained Assets
-
-
- Guide + setup -

GUIDE.md 说明何时读写记忆;Claude Code setup scripts 负责把 hook、skill、subagent 挂载到宿主。

-
-
- Four hooks -

Prime、Remind、Nudge、Compact 只负责触发时机,不承载记忆协议。

-
-
- Two skills -

memory_get.md 绑定 Mnemon recall;memory_set.md 绑定 MEMORY.md 编辑规则。

-
-
- One subagent -

dreaming subagent 负责维护任务:巩固、压缩、丢弃和长期写入。

-
-
-
-
-
- -
-
- Guide 只定义判断 -

GUIDE.md 只回答“何时读记忆、何时写记忆、什么值得保留”,不直接绑定 MEMORY.md 或 Mnemon。

-
-
- Skill 绑定协议 -

memory_get.md 负责把“读记忆”落到 Mnemon recall;memory_set.md 通过 MNEMON_MEMORY_LOOP_DIR 定位并 patch MEMORY.md。

-
-
- Dreaming 做巩固 -

Dreaming 不是普通 hook。它是被 spawn 的维护 subagent,先写 Mnemon,再整理 MEMORY.md。

-
-
- -
-
-

Runtime Flow

-

点击左侧阶段,只显示当前阶段的数据流,避免所有箭头同时出现。

-
- -
- -
-
-
- -
-
Responsibility Matrix
-
-
-
- - - - diff --git a/docs/design/self-evolution-harness/MEMORY_LOOP_MVP.md b/docs/design/self-evolution-harness/memory-loop/README.md similarity index 97% rename from docs/design/self-evolution-harness/MEMORY_LOOP_MVP.md rename to docs/design/self-evolution-harness/memory-loop/README.md index badf0da9..81d9f7b1 100644 --- a/docs/design/self-evolution-harness/MEMORY_LOOP_MVP.md +++ b/docs/design/self-evolution-harness/memory-loop/README.md @@ -2,9 +2,11 @@ This document describes the first implementation slice of the memory loop. The goal is to keep the harness small: install a few hook prompts and Markdown-based capabilities around an existing host agent, while using Mnemon as the long-term memory backend. -Related visualization: [memory-loop-mvp.html](./memory-loop-mvp.html) +Related visualization: [site/index.html](./site/index.html) -Reference implementation: [harness/memory-loop](../../../harness/memory-loop) +Chinese version: [README.zh.md](./README.zh.md) + +Reference implementation: [harness/memory-loop](../../../../harness/memory-loop) ## Core Model diff --git a/docs/design/self-evolution-harness/memory-loop/README.zh.md b/docs/design/self-evolution-harness/memory-loop/README.zh.md new file mode 100644 index 00000000..cca5d99c --- /dev/null +++ b/docs/design/self-evolution-harness/memory-loop/README.zh.md @@ -0,0 +1,181 @@ +# Memory Loop MVP 设计 + +本文档描述 memory loop 的第一版实现切片。目标是让 harness 保持足够小:围绕已有 HostAgent 安装少量 hook prompt 和 Markdown 能力,同时使用 Mnemon 作为长期记忆后端。 + +交互式展示:[site/index.html](./site/index.html) + +英文版本:[README.md](./README.md) + +参考实现:[harness/memory-loop](../../../../harness/memory-loop) + +## 核心模型 + +MVP 只有三个核心主体: + +| 主体 | 作用 | 边界 | +| --- | --- | --- | +| HostAgent | 宿主 agent runtime。它运行任务、接收 hook 注入,并决定是否加载记忆 skill 或启动 dreaming subagent。 | 不拥有记忆存储协议。 | +| `MEMORY.md` | 工作记忆文件。它很小、直接面向 prompt,并在 Prime 阶段进入 system prompt。 | 由 `memory_set.md` 和 dreaming subagent 维护。 | +| Mnemon | 长期记忆存储和 binary。它独立安装,例如通过 `brew install`。 | 通过 `memory_get.md` 和 dreaming subagent 协议访问。 | + +其他内容都是围绕这三个主体的支撑资产。 + +## 维护资产 + +第一版维护以下资产: + +| 资产 | 类型 | 用途 | +| --- | --- | --- | +| `env.sh` | 配置 | 定义 `MNEMON_MEMORY_LOOP_ENV`、`MNEMON_MEMORY_LOOP_DIR` 和记忆长度阈值。 | +| `GUIDE.md` | 手册 | 描述何时读记忆、何时写记忆、什么信息值得保留。 | +| Claude Code setup scripts | 安装 | 第一条具体安装路径。安装 hooks、skills、subagent 和 memory 文件。 | +| Prime hook | Hook | 将 `MEMORY.md` 和 `GUIDE.md` 注入 system prompt。 | +| Remind hook | Hook | 提醒 HostAgent 判断是否需要读取记忆。 | +| Nudge hook | Hook | 提醒 HostAgent 判断是否需要积累工作记忆。 | +| Compact hook | Hook | 在上下文压缩前提醒 HostAgent 保存重要信息。 | +| `memory_get.md` | Skill | 定义如何从 Mnemon 召回长期记忆。 | +| `memory_set.md` | Skill | 定义如何编辑 `MEMORY.md`。 | +| dreaming subagent spec | Subagent | 定义如何将 `MEMORY.md` 巩固到 Mnemon,并压缩或移除工作记忆条目。 | + +## 策略与实现分离 + +`GUIDE.md` 刻意保持抽象。它描述记忆行为,而不是存储机制。 + +它回答这类问题: + +- 当前是否应该读记忆? +- 当前是否应该写记忆? +- 这条信息是否足够稳定,值得保留? +- 这是长期偏好、项目约定,还是可复用事实? + +它不要求 HostAgent 判断目标是 `MEMORY.md` 还是 Mnemon。这个决定下沉到能力层。可复用能力通过 `MNEMON_MEMORY_LOOP_DIR` 定位运行目录。 + +- `memory_get.md` 将“读记忆”映射为 Mnemon recall。 +- `memory_set.md` 将“写记忆”映射为 `$MNEMON_MEMORY_LOOP_DIR/MEMORY.md` 编辑。 +- dreaming subagent 将“巩固”映射为 Mnemon write 加 `$MNEMON_MEMORY_LOOP_DIR/MEMORY.md` 压缩。 + +这个拆分让 guide 可以跨不同 HostAgent 复用。 + +## 运行流程 + +### Prime + +Prime 是唯一的直接加载路径。 + +输入: + +- `MEMORY.md` +- `GUIDE.md` + +动作: + +- 将二者注入 HostAgent 的 system prompt。 + +边界: + +- Prime 不调用 `memory_get.md`。 +- Prime 不召回 Mnemon。 +- Prime 不写长期记忆。 + +### Remind / Recall + +Remind 创造读记忆机会。 + +流程: + +1. Remind 根据 `GUIDE.md` 提醒 HostAgent 判断是否应该读记忆。 +2. 如果需要,HostAgent 加载 `memory_get.md`。 +3. `memory_get.md` 说明如何调用 Mnemon recall。 +4. Mnemon 返回有界的 recall context 给 HostAgent。 + +边界: + +- 长期记忆不会被全量注入。 +- recall 结果不会自动写回 `MEMORY.md`。 +- `GUIDE.md` 不需要知道 Mnemon 协议细节。 + +### Nudge / Accumulate + +Nudge 创造写工作记忆机会。 + +流程: + +1. Nudge 根据 `GUIDE.md` 提醒 HostAgent 判断是否应该积累记忆。 +2. 如果需要,HostAgent 加载 `memory_set.md`。 +3. `memory_set.md` 说明如何新增、替换或删除 `MEMORY.md` 条目。 + +边界: + +- 在线记忆积累只写 `MEMORY.md`。 +- 它不直接写 Mnemon。 +- 它应避免记录流水账、一次性进度和低置信度观察。 + +### Compact + +Compact 是上下文边界时的 Nudge。 + +流程: + +1. 在上下文压缩前,Compact 提醒 HostAgent 判断是否有重要信息会丢失。 +2. 如果需要,HostAgent 加载 `memory_set.md`。 +3. `memory_set.md` 将必要的最后补丁写入 `MEMORY.md`。 + +边界: + +- Compact 不是 dreaming。 +- Compact 不做全量工作记忆清理。 +- Compact 不直接写长期记忆。 + +### Dreaming + +Dreaming 是维护流程,不是普通在线 hook。 + +流程: + +1. HostAgent 启动专用 dreaming subagent。 +2. subagent 读取完整 `MEMORY.md`。 +3. subagent 按 Mnemon 协议将当前工作记忆写入 Mnemon。 +4. subagent 压缩、整理或移除 `MEMORY.md` 条目。 + +触发时机: + +- `MEMORY.md` 超过 quota。 +- 上下文压缩前。 +- 用户或 HostAgent 主动要求。 + +边界: + +- Dreaming 负责巩固与清理。 +- 它不替代 Remind、Nudge 或 Compact。 +- 它需要保留 prompt-facing 有用性,同时把耐久信息移动到长期记忆。 + +## 第一版范围 + +MVP 包含: + +- 最小 `GUIDE.md`。 +- Claude Code setup scripts,将 Prime、Remind、Nudge、Compact 挂载进 `.claude/settings.json`。 +- `MEMORY.md` 模板。 +- 用于 Mnemon recall 的 `memory_get.md` skill。 +- 用于 `MEMORY.md` 编辑的 `memory_set.md` skill。 +- dreaming subagent spec。 +- 明确假设 Mnemon 作为 binary 和长期存储独立安装。 + +MVP 不包含: + +- 自定义 agent runtime。 +- 复杂 adapter framework。 +- 第二种 working-memory 格式。 +- 普通在线 hook 直接写长期记忆的路径。 + +## 设计原则 + +Harness 应保持 agent-agnostic。它向 HostAgent 提供安装记忆行为所需的材料: + +- 规则手册和安装脚本; +- 用于时机控制的 hooks; +- 用于在线记忆操作的 skills; +- 用于离线巩固的 subagent; +- 用于长期存储的 Mnemon。 + +这让第一版足够可实现,同时保留目标记忆循环:`MEMORY.md` 提供 prompt-facing working memory,Mnemon 提供 durable long-term memory,dreaming 在二者之间移动信息。 diff --git a/docs/design/self-evolution-harness/memory-loop/site/index.html b/docs/design/self-evolution-harness/memory-loop/site/index.html new file mode 100644 index 00000000..7bde77e2 --- /dev/null +++ b/docs/design/self-evolution-harness/memory-loop/site/index.html @@ -0,0 +1,1118 @@ + + + + + + + Mnemon Memory Loop MVP + + + +
+
+
+
+
+ + +
+
+
+
+

+

+
+ +
+
+
+ +
+
+
+

+

+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+

+

+
+
+
+ +
+
+

+

+
+
+ +
+
+
+ +
+
+
+
+
+ + + + diff --git a/docs/research/agent-systems/README.md b/docs/design/self-evolution-harness/research/agent-systems/README.md similarity index 97% rename from docs/research/agent-systems/README.md rename to docs/design/self-evolution-harness/research/agent-systems/README.md index 87c976b9..83300965 100644 --- a/docs/research/agent-systems/README.md +++ b/docs/design/self-evolution-harness/research/agent-systems/README.md @@ -1,6 +1,6 @@ # Agent Systems Research -本目录保留 Mnemon self-evolution harness 设计的来源索引与研究摘要。详细分项目调研已经浓缩进 [Self-Evolution Harness 设计](../../design/SELF_EVOLUTION_HARNESS.md),不再维护多份长研究笔记。 +本目录保留 Mnemon self-evolution harness 设计的来源索引与研究摘要。详细分项目调研已经浓缩进 [Self-Evolution Harness 设计](../../SELF_EVOLUTION_HARNESS.md),不再维护多份长研究笔记。 ## Scope diff --git a/docs/framework/HARNESS.md b/docs/framework/HARNESS.md index 6734176e..31882410 100644 --- a/docs/framework/HARNESS.md +++ b/docs/framework/HARNESS.md @@ -464,7 +464,7 @@ Self-evolution should start as a lightweight markdown loop, not a heavy framework. The full v0.2 architecture is consolidated in -[Self-Evolution Harness Design](../design/SELF_EVOLUTION_HARNESS.md). +[Self-Evolution Harness Design](../design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md). Mnemon should not automatically rewrite runtime behavior. It should help the agent notice repeated experience, preserve evidence, and propose markdown diff --git a/docs/zh/DESIGN.md b/docs/zh/DESIGN.md index 640d86d7..dad21e22 100644 --- a/docs/zh/DESIGN.md +++ b/docs/zh/DESIGN.md @@ -6,7 +6,7 @@ Mnemon 是一个为 LLM agent 设计的持久化记忆系统。它采用 **LLM-Supervised** 模式:宿主 LLM 作为独立记忆 Binary 的外部编排者,通过符号化 CLI 接口交互,而 Binary 负责确定性的存储、图索引和生命周期管理。记忆以四图知识结构组织 — temporal、entity、causal、semantic 四种 edge。以单一 Go binary + SQLite 的形式实现,不依赖任何外部 API。 -本文档描述当前 Mnemon binary 与 engine architecture。更上层的 memory harness doctrine 见 [Mnemon Memory Harness](framework/HARNESS.md),可安装 runtime 资产见 [INSTALL.md](framework/INSTALL.md) 和 [GUIDELINE.md](framework/GUIDELINE.md)。v0.2 自进化架构已收敛到 [Self-Evolution Harness 设计](../design/SELF_EVOLUTION_HARNESS.md)。 +本文档描述当前 Mnemon binary 与 engine architecture。更上层的 memory harness doctrine 见 [Mnemon Memory Harness](framework/HARNESS.md),可安装 runtime 资产见 [INSTALL.md](framework/INSTALL.md) 和 [GUIDELINE.md](framework/GUIDELINE.md)。v0.2 自进化架构已收敛到 [Self-Evolution Harness 设计](../design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md)。 --- @@ -40,7 +40,7 @@ MAGMA 四图模型(temporal、entity、causal、semantic),LLM 注意力与 Markdown 可安装的 runtime 集成:`SKILL.md`、`INSTALL.md`、`GUIDELINE.md`、四个 hook phase(Prime、Remind、Nudge、Compact)、agent 主导的记忆判断、可选 setup 自动化,以及轻量 Markdown 自进化。 -### [Self-Evolution Harness](../design/SELF_EVOLUTION_HARNESS.md) +### [Self-Evolution Harness](../design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md) v0.2 的 agent-agnostic 安装挂载、`.mnemon` canonical filesystem、记忆巩固循环、技能演进、可选维护 runner 与 proposal-first 风控架构。 diff --git a/docs/zh/README.md b/docs/zh/README.md index 308cc2f5..c51fcd8f 100644 --- a/docs/zh/README.md +++ b/docs/zh/README.md @@ -232,8 +232,8 @@ make help # 显示所有目标 - [Mnemon Memory Harness](framework/HARNESS.md) — skill-first memory harness 设计与安装指引 - [Harness 安装指南](framework/INSTALL.md) — 面向 agent 的安装契约 - [Memory Guideline](framework/GUIDELINE.md) — recall/writeback 判断策略 -- [Self-Evolution Harness 设计](../design/SELF_EVOLUTION_HARNESS.md) — v0.2 安装挂载、记忆循环、技能演进与风控架构 -- [Agent Systems Research](../research/agent-systems/README.md) — 记忆与自进化调研的浓缩来源索引 +- [Self-Evolution Harness 设计](../design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md) — v0.2 安装挂载、记忆循环、技能演进与风控架构 +- [Agent Systems Research](../design/self-evolution-harness/research/agent-systems/README.md) — 记忆与自进化调研的浓缩来源索引 - [设计与架构](DESIGN.md) — 当前 engine architecture、核心概念、算法、集成设计 - [用法与参考](USAGE.md) — CLI 命令、嵌入向量支持、架构概览 - [架构图](../diagrams/) — 系统架构、记忆/召回流程、四图模型、生命周期管理 diff --git a/docs/zh/framework/HARNESS.md b/docs/zh/framework/HARNESS.md index 4bb4ebff..1057b320 100644 --- a/docs/zh/framework/HARNESS.md +++ b/docs/zh/framework/HARNESS.md @@ -401,7 +401,7 @@ Harness 失败的表现: 自进化应先从轻量 Markdown loop 开始,而不是先做重型 framework。 -完整 v0.2 架构已收敛到 [Self-Evolution Harness 设计](../../design/SELF_EVOLUTION_HARNESS.md)。 +完整 v0.2 架构已收敛到 [Self-Evolution Harness 设计](../../design/self-evolution-harness/SELF_EVOLUTION_HARNESS.md)。 Mnemon 不应自动改写 runtime 行为。它应帮助 agent 发现重复经验、保存证据,并提出 Markdown 变更候选;这些候选必须由人类或仓库 review 接受后才生效。