🧠 Memory Never Forget v3.2
Two orthogonal dimensions working together:
| Dimension | Framework | Purpose |
|---|
| Temporal (how long) | Atkinson-Shiffrin 3-stage model | Decay management — what to keep vs. prune |
| Content (what kind) |
4-type taxonomy (Claude Code) | Classification — where to store for retrieval |
How It Works: The Memory Flow
CODEBLOCK0
In one sentence: Memory is first filtered by time (when to save, when to let decay), then transformed by Dream into classified content (where to store, how to retrieve).
Dimension 1: Temporal Layering (Atkinson-Shiffrin)
| Stage | Human Equivalent | Implementation | TTL | Action |
|---|
| Sensory | ~0.25 sec perception | Current input context | Instant | Filter immediately — what deserves attention? |
| Short-term |
Recent 10 turns | Model context window | 10 turns | Pass through working filters |
|
Working | Recent ~7 days |
memory/YYYY-MM-DD.md daily logs | 7 days | Extract signal → promote to long-term or let decay |
|
Long-term | Permanent |
MEMORY.md (index) + classified files | Permanent | Periodic review, prune when stale |
The memory flow:
Input → Sensory (filter) → Short-term (hold) → Working (consolidate) → Long-term (index)
↕
Daily Dream review
(promote or prune)
Dimension 2: Content Classification (4 Types)
| Type | Directory | Content | Example |
|---|
| user | INLINECODE2 | User profile (role, preferences, knowledge, goals) | "User is a data analyst, prefers concise replies" |
| feedback |
memory/feedback/ | Lessons (corrections, confirmations, style) | "Don't use Markdown tables, use lists" |
|
project |
memory/project/ | Project state (work, decisions, reasoning) | "Project X adopted Y because it reduces cost" |
|
reference |
memory/reference/ | External resources (links, tools, locations) | "Project docs are in /docs/api/" |
How the two dimensions interact:
- - Working layer (
memory/*.md daily logs) captures raw signal without classification - Long-term layer stores classified memories (4 types), each with indexed content
- Dream consolidation moves Working → Long-term (classify + promote) OR prunes (decay)
What to Save / What NOT to Save
✅ Save
- - User's role, preferences, responsibilities, knowledge
- User corrections ("not like that", "should be this way")
- User confirmations ("yes exactly", "perfect, keep that")
- Project decisions and the reasoning (not just what, but why)
- New tools, links, resources
- External system locations and their purpose
❌ Don't Save
- - ❌ Code patterns, architecture, file paths (derivable from codebase)
- ❌ Git history (
git log is the authoritative source) - ❌ Debugging solutions (the fix is in the code; commit messages have context)
- ❌ Anything already documented elsewhere
- ❌ Ephemeral task state (write to
todos.md instead) - ❌ Raw conversation content
⚠️ Even if the user explicitly asks — if asked to save a PR list or activity summary, ask what was surprising or non-obvious about it — that's the part worth keeping.
MEMORY.md = Long-Term Index Only
MEMORY.md is the index of long-term memories only, never content. Format:
CODEBLOCK2
Example:
## User Memory
- [user-profile](user/profile.md) — user role and preferences
## Feedback Memory
- [no-tables](feedback/no-tables.md) — prefer lists over markdown tables
## Project Memory
- [model-switch](project/model-decision.md) — why project switched model
## Reference
- [project-docs](reference/docs-path.md) — where project docs live
Memory File Format
Every classified memory file must have frontmatter:
CODEBLOCK4
Memory Drift Caveat
Memories can become stale. Rules:
- 1. Verify first: When referencing a file, function, or path — check it still exists
- Trust current state: If memory conflicts with current observation, trust what you see now
- Update or delete: When a memory is outdated, fix or remove it immediately
- Absolute dates: Convert relative dates ("yesterday", "last week") to absolute dates
"The memory says X exists" ≠ "X exists now"
Directory Structure
CODEBLOCK5
Retrieval Flow (by question type)
Memory Questions ("what happened before", "what did we talk about")
→
memory_search across MEMORY.md + memory/*.md
→ If not found in memory layer → proactively search daily logs (working memory)
Knowledge Questions ("look this up", "check that file")
- 1. Find index in MEMORY.md first
- Read detailed content from classified file or knowledge layer
Temporal Questions ("what did I do last Tuesday")
→ Go directly to daily logs (working memory):
memory/YYYY-MM-DD.md
Feedback Rules
- - Record failures AND successes: only saving corrections makes you overly cautious
- Corrections are easy to notice; confirmations are quieter — watch for them
- Always include why to judge edge cases later
Project Rules
- - Project memories decay fast, so why helps future-you judge if the memory is still load-bearing
- Always convert relative dates to absolute dates
Memory → Knowledge Sublimation (升华)
Not all mature memories should decay. Some evolve into knowledge.
When to Sublimate
| Trigger | Detection Signal | Result |
|---|
| Project complete | All tasks marked done, 3+ related project memories | Merge into INLINECODE11 |
| Feedback patterns |
3+ related feedback entries (e.g., all about reply style) | Merge into
knowledge/user-work-style-guide.md |
|
User depth | User memory accumulates role, preferences, habits over time | Expand to
knowledge/user-playbook.md |
|
Periodic review | Dream detects high density of related memories in one category | Suggest: "Found 5 related feedback entries → merge into knowledge?" |
Sublimation vs Pruning
| Decision | Criteria | Action |
|---|
| Prune (forget) | No longer relevant, isolated, no connections | Remove from MEMORY.md index |
| Sublimate (promote) |
Still relevant, mature, interconnected, frequently referenced | Create detailed document in
knowledge/ |
Sublimation Flow
CODEBLOCK6
Sublimation Rules
- - Always preserve original memories (they are first-hand records)
- Create the knowledge document in INLINECODE15
- Update MEMORY.md to point to the knowledge document
- Log the sublimation (when and why)
- After sublimation, update the knowledge document going forward (not the individual memories)
Dream Consolidation (Periodic, Automated)
Triggered daily via cron. Acts as the Working → Long-term promotion + Sublimation detection gateway.
Phases
- 1. Orient — browse existing memory files and index
- Gather — scan working memory (daily logs) for new signal
- Consolidate — promote to classified long-term (4 types), merge, deduplicate
- Prune — remove outdated entries, update index, let daily logs decay naturally
- ★ Sublimate — detect maturation patterns and promote memory → knowledge
Rules
- - Merge new signal into existing files, not near-duplicates
- Relative dates → absolute dates
- Delete contradicted facts
- Keep MEMORY.md under 5KB
- Remove stale pointers
- Shorten overly long index entries (<150 chars each)
Session Lifecycle (Atkinson-Shiffrin in Practice)
Session Start
CODEBLOCK7
During Conversation
CODEBLOCK8
Session End
- Summarize → write to memory/today.md (working memory)
- Identify items for long-term → update classified files
- Update MEMORY.md index
- Mark items for Dream review (decay candidates)
Workspace Structure
CODEBLOCK10
Example Interactions
User provides important info:
User: "I'm a data analyst, mostly working with Python"
→ Working: log in today's daily log
→ Long-term: save to
memory/user/user-profile.md, update MEMORY.md index
User corrects you:
User: "Don't use Markdown tables, use lists"
→ Working: log in today's daily log
→ Long-term: save to
memory/feedback/no-tables.md, update MEMORY.md index
Project decision:
Decision: approach A over B because lower cost
→ Working: log decision context
→ Long-term: save to
memory/project/decision.md with reasoning
Looking up a past date:
User: "What did we do last Tuesday?"
→ Working memory: read
memory/YYYY-MM-DD.md for that date
References
- - Atkinson-Shiffrin model (1968): Sensory → Short-term → Long-term memory stages
- Claude Code
memoryTypes.ts — 4-type taxonomy - Claude Code
extractMemories.ts — auto-extraction system - Claude Code
autoDream.ts — background consolidation system
Version: v3.2 | Updated: 2026-04-07 | Merges Atkinson-Shiffrin temporal layering with Claude Code 4-type taxonomy + Memory Sublimation System
🧠 永不遗忘记忆 v3.2
两个正交维度协同工作:
| 维度 | 框架 | 目的 |
|---|
| 时间维度(持续多久) | 阿特金森-谢夫林三阶段模型 | 衰减管理——保留什么 vs. 修剪什么 |
| 内容维度(什么类型) |
4类分类法(Claude Code) | 分类——存储在哪里以便检索 |
工作原理:记忆流
新信息
│
▼
┌─────────────────────────┐
│ 感觉记忆 │ ~0.25秒 — 即时过滤器
│ (当前上下文) │ 什么值得关注?
└────────┬────────────────┘
│ 值得记住
▼
┌─────────────────────────┐
│ 短时记忆 │ ~10轮对话 — 上下文窗口
│ (对话) │ 通过工作过滤器
└────────┬────────────────┘
│ 存活下来
▼
┌─────────────────────────┐
│ 工作记忆 │ ~7天 — 每日日志
│ (memory/YYYY-MM-DD.md)│ 原始信号,未分类
└────────┬────────────────┘
│
┌────▼────┐ 每天12:30
│ DREAM │ 网关:
│ │ 1. 扫描近期每日日志
│ ⚙️ │ 2. 识别长期信号
│ ⚙️ │ 3. ★ 分类为4种类型 ← 时间维度 → 内容维度
│ ⚙️ │ 4. 写入分类文件
│ ⚙️ │ 5. 更新MEMORY.md索引
│ │ 6. 让旧日志自然衰减
└────┬────┘
│ 被提升
▼
┌─────────────────────────┐
│ 长期记忆 │ 永久 — 已分类
│ (4种类型 + 索引) │ 用户 / 反馈 / 项目 / 参考
└─────────────────────────┘
一句话概括: 记忆首先按时间过滤(何时保存,何时让之衰减),然后通过Dream转化为分类内容(存储在哪里,如何检索)。
维度1:时间分层(阿特金森-谢夫林模型)
| 阶段 | 人类类比 | 实现方式 | 生存时间 | 操作 |
|---|
| 感觉 | ~0.25秒感知 | 当前输入上下文 | 即时 | 立即过滤——什么值得关注? |
| 短时 |
最近10轮对话 | 模型上下文窗口 | 10轮对话 | 通过工作过滤器 |
|
工作 | 最近~7天 | memory/YYYY-MM-DD.md 每日日志 | 7天 | 提取信号→提升至长期或让之衰减 |
|
长期 | 永久 | MEMORY.md(索引)+ 分类文件 | 永久 | 定期审查,过时时修剪 |
记忆流:
输入 → 感觉(过滤)→ 短时(保持)→ 工作(巩固)→ 长期(索引)
↕
每日Dream审查
(提升或修剪)
维度2:内容分类(4种类型)
| 类型 | 目录 | 内容 | 示例 |
|---|
| 用户 | memory/user/ | 用户画像(角色、偏好、知识、目标) | 用户是数据分析师,偏好简洁回复 |
| 反馈 |
memory/feedback/ | 经验教训(纠正、确认、风格) | 不要使用Markdown表格,使用列表 |
|
项目 | memory/project/ | 项目状态(工作、决策、推理) | 项目X采用Y方案,因为能降低成本 |
|
参考 | memory/reference/ | 外部资源(链接、工具、位置) | 项目文档在 /docs/api/ 中 |
两个维度如何交互:
- - 工作层(memory/*.md 每日日志)捕获未分类的原始信号
- 长期层存储已分类的记忆(4种类型),每种都有索引内容
- Dream巩固将工作层→长期层(分类+提升)或修剪(衰减)
保存什么 / 不保存什么
✅ 保存
- - 用户的角色、偏好、职责、知识
- 用户的纠正(不是那样、应该是这样)
- 用户的确认(是的,完全正确、完美,保持这样)
- 项目决策及其推理(不仅是什么,还有为什么)
- 新工具、链接、资源
- 外部系统位置及其用途
❌ 不保存
- - ❌ 代码模式、架构、文件路径(可从代码库推导)
- ❌ Git历史(git log 是权威来源)
- ❌ 调试解决方案(修复在代码中;提交消息有上下文)
- ❌ 已在其他地方记录的任何内容
- ❌ 临时任务状态(改为写入 todos.md)
- ❌ 原始对话内容
⚠️ 即使用户明确要求——如果被要求保存PR列表或活动摘要,询问其中有什么令人惊讶或非显而易见的内容——那才是值得保留的部分。
MEMORY.md = 仅长期索引
MEMORY.md 是仅长期记忆的索引,从不包含内容。格式:
示例:
markdown
用户记忆
反馈记忆
- - 禁用表格 — 偏好列表而非Markdown表格
项目记忆
参考
记忆文件格式
每个分类的记忆文件必须有前置元数据:
yaml
名称: 记忆名称
描述: 一行描述(用于判断相关性)
类型: user|feedback|project|reference
创建日期: YYYY-MM-DD
规则 / 事实
(内容)
原因
(理由 / 动机)
如何应用
(何时以及如何使用此记忆)
记忆漂移警告
记忆可能变得过时。规则:
- 1. 先验证:引用文件、函数或路径时——检查它是否仍然存在
- 信任当前状态:如果记忆与当前观察冲突,相信你现在看到的
- 更新或删除:当记忆过时时,立即修复或删除
- 绝对日期:将相对日期(昨天、上周)转换为绝对日期
记忆说X存在 ≠ X现在存在
目录结构
memory/
├── memory-types.md ← 本文件
├── user/ ← 长期用户记忆
├── feedback/ ← 长期反馈
├── project/ ← 长期项目记忆
├── reference/ ← 长期参考
└── 2026-XX-XX.md ← 工作记忆(每日日志,7天生存期)
检索流程(按问题类型)
记忆问题(之前发生了什么、我们讨论过什么)
→ 跨 MEMORY.md + memory/*.md 进行 memory_search
→ 如果在记忆层未找到→主动搜索每日日志(工作记忆)
知识问题(查一下这个、检查那个文件)
- 1. 先在MEMORY.md中找到索引
- 从分类文件或知识层读取详细内容
时间问题(我上周二做了什么)
→ 直接访问每日日志(工作记忆):memory/YYYY-MM-DD.md
反馈规则
- - 记录失败和成功:只保存纠正会让你变得过于谨慎
- 纠正很容易注意到;确认则更安静——要留意它们
- 始终包含原因以便后续判断边缘情况
项目规则
- - 项目记忆衰减很快,所以原因能帮助未来的你判断记忆是否仍然有效
- 始终将相对日期转换为绝对日期
记忆→知识升华
并非所有成熟的记忆都应该衰减。有些会演变为知识。
何时升华
| 触发条件 | 检测信号 | 结果 |
|---|
| 项目完成 | 所有任务标记完成,3+条相关项目记忆 | 合并到 knowledge/project-postmortem.md |
| 反馈模式 |
3+条相关反馈条目(例如,都关于回复风格) | 合并到 knowledge/user-work-style-guide.md |
|
用户深度 | 用户记忆随时间积累角色、偏好、习惯 | 扩展为 knowledge/user-playbook.md |
|
定期