Skip to content

feat: v3.0.0 - Semantic Memory Layer + Conflict Detection#99

Merged
SonicBotMan merged 1 commit into
masterfrom
feature/v3.0.0-semantic-memory
Mar 17, 2026
Merged

feat: v3.0.0 - Semantic Memory Layer + Conflict Detection#99
SonicBotMan merged 1 commit into
masterfrom
feature/v3.0.0-semantic-memory

Conversation

@SonicBotMan

Copy link
Copy Markdown
Owner

v3.0.0 - 语义记忆层 + 矛盾检测

Feature 3: Semantic Memory Layer

目标: 独立于 DAG 的稳定知识库,存储从对话中提炼的持久性事实

核心功能:

  1. notes 表存储语义记忆
  2. LLM 提取语义知识(决策、偏好、约束、事实)
  3. 上下文组装时注入 notes(始终在头部)
  4. 去重机制(相同内容不重复插入)

文件: src/semantic_memory.py

关键方法:

  • extract_and_store(): 从对话中提取 notes
  • get_active_notes(): 获取生效的 notes
  • format_for_context(): 格式化为上下文注入

Feature 4: Conflict Detection & Reconsolidation

目标: 检测新消息与已有 notes 的矛盾,自动更新知识库

核心功能:

  1. NLI 模型检测矛盾(优先)或规则降级(备选)
  2. 矛盾发生时标记旧 note 为 superseded_by
  3. 创建新 note 反映最新信息
  4. 保留完整溯源链(不删除旧 note)

文件: src/pipeline/conflict_detector.py

关键方法:

  • detect(): 检测矛盾
  • reconcile(): 执行记忆重巩固

Integration

修改文件: src/incremental_compressor.py

改动点:

  1. 添加 llm_client 参数
  2. 初始化 SemanticMemory 和 ConflictDetector
  3. 压缩后触发 note 提取
  4. 新消息触发矛盾检测

Tests

文件: tests/test_v300.py

测试用例 (4/4 通过):

  1. ✅ test_notes_extraction
  2. ✅ test_notes_injection
  3. ✅ test_conflict_api
  4. ✅ test_notes_dedup

Acceptance Criteria (from Issue #97)

  • notes 提取并存储
  • notes 注入上下文
  • 矛盾检测 API
  • 记忆重巩固机制

Version


🧠 认知科学驱动: 基于 EM-LLM、HiMem 等研究论文设计

Feature 3: Semantic Memory Layer
- 创建 src/semantic_memory.py
- notes 表存储持久性语义知识
- extract_and_store() 从对话中提取 notes
- get_active_notes() 获取生效的 notes
- format_for_context() 格式化为上下文注入

Feature 4: Conflict Detection & Reconsolidation
- 创建 src/pipeline/conflict_detector.py
- NLI 模型检测矛盾(可选)
- 规则降级检测(零依赖)
- reconcile() 执行记忆重巩固

Integration:
- incremental_compressor.py 集成语义记忆
- 添加 llm_client 参数
- 压缩后触发 note 提取
- 新消息触发矛盾检测

Tests: 4/4 passed
- test_notes_extraction
- test_notes_injection
- test_conflict_api
- test_notes_dedup

Version: v3.0.0-alpha
@SonicBotMan SonicBotMan merged commit 7fa1ef1 into master Mar 17, 2026
2 checks passed
SonicBotMan added a commit that referenced this pull request Mar 17, 2026
Feature 3: Semantic Memory Layer
- 创建 src/semantic_memory.py
- notes 表存储持久性语义知识
- extract_and_store() 从对话中提取 notes
- get_active_notes() 获取生效的 notes
- format_for_context() 格式化为上下文注入

Feature 4: Conflict Detection & Reconsolidation
- 创建 src/pipeline/conflict_detector.py
- NLI 模型检测矛盾(可选)
- 规则降级检测(零依赖)
- reconcile() 执行记忆重巩固

Integration:
- incremental_compressor.py 集成语义记忆
- 添加 llm_client 参数
- 压缩后触发 note 提取
- 新消息触发矛盾检测

Tests: 4/4 passed
- test_notes_extraction
- test_notes_injection
- test_conflict_api
- test_notes_dedup

Version: v3.0.0-alpha

Co-authored-by: SonicBotMan <sonicman0261@users.noreply.github.com>
@SonicBotMan SonicBotMan deleted the feature/v3.0.0-semantic-memory branch June 12, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant