mindforge-memory 6.5.4__tar.gz → 6.5.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {mindforge_memory-6.5.4/mindforge_memory.egg-info → mindforge_memory-6.5.6}/PKG-INFO +14 -11
  2. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/README.md +13 -10
  3. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/api/server.py +35 -3
  4. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/encryption.py +33 -3
  5. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/mindforge.py +21 -1
  6. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/query.py +94 -2
  7. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/storage.py +12 -3
  8. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/version.py +2 -2
  9. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/mcp/server.py +70 -0
  10. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/memory_compressor.py +13 -24
  11. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6/mindforge_memory.egg-info}/PKG-INFO +14 -11
  12. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge_memory.egg-info/SOURCES.txt +2 -0
  13. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v568_fixes.py +1 -1
  14. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v575_release_consistency.py +2 -2
  15. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v576_bitemporal.py +1 -1
  16. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v577_agent_governance.py +1 -1
  17. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v579_graph.py +1 -1
  18. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v580_experience.py +1 -1
  19. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v611_fixes.py +3 -3
  20. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v612_fixes.py +3 -3
  21. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v635_integration.py +17 -5
  22. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v643_fixes.py +1 -1
  23. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v645_fixes.py +2 -2
  24. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v646_fixes.py +1 -1
  25. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v649_fixes.py +2 -2
  26. mindforge_memory-6.5.6/tests/test_v655_temporal_norm.py +97 -0
  27. mindforge_memory-6.5.6/tests/test_v656_security.py +170 -0
  28. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/LICENSE +0 -0
  29. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/MindForge.py +0 -0
  30. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/__init__.py +0 -0
  31. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/__init__.py +0 -0
  32. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/claude_adapter.py +0 -0
  33. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/crewai_memory.py +0 -0
  34. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/generic_api.py +0 -0
  35. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/langgraph_store.py +0 -0
  36. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/adapters/openclaw_adapter.py +0 -0
  37. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/api/__init__.py +0 -0
  38. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/cli/__init__.py +0 -0
  39. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/cli/main.py +0 -0
  40. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/__init__.py +0 -0
  41. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/embedding.py +0 -0
  42. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/indexer.py +0 -0
  43. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/paths.py +0 -0
  44. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/core/types.py +0 -0
  45. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/daemon/__init__.py +0 -0
  46. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/daemon/server.py +0 -0
  47. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/mcp/__init__.py +0 -0
  48. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/__init__.py +0 -0
  49. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/categorizer.py +0 -0
  50. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/conflict_detector.py +0 -0
  51. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/connectors.py +0 -0
  52. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/context_window.py +0 -0
  53. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/event_bus.py +0 -0
  54. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/evolution.py +0 -0
  55. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/experience.py +0 -0
  56. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/federated.py +0 -0
  57. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/federated_acl.py +0 -0
  58. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/follow_up.py +0 -0
  59. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/hybrid_search.py +0 -0
  60. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/importer.py +0 -0
  61. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/integrator.py +0 -0
  62. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/intent_router.py +0 -0
  63. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/knowledge_graph.py +0 -0
  64. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/memory_decay.py +0 -0
  65. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/memory_passport.py +0 -0
  66. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/multi_agent.py +0 -0
  67. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/multimodal.py +0 -0
  68. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/outcome_learning.py +0 -0
  69. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/personality.py +0 -0
  70. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/principled_forgetting.py +0 -0
  71. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/privacy.py +0 -0
  72. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/recall.py +0 -0
  73. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/session_focus.py +0 -0
  74. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/share_conflict.py +0 -0
  75. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/skill_extractor.py +0 -0
  76. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/skill_pack.py +0 -0
  77. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/timeline_viz.py +0 -0
  78. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge/modules/v6.py +0 -0
  79. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge_memory.egg-info/dependency_links.txt +0 -0
  80. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge_memory.egg-info/entry_points.txt +0 -0
  81. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge_memory.egg-info/requires.txt +0 -0
  82. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/mindforge_memory.egg-info/top_level.txt +0 -0
  83. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/pyproject.toml +0 -0
  84. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/setup.cfg +0 -0
  85. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/setup.py +0 -0
  86. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_core.py +0 -0
  87. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_security_hardening.py +0 -0
  88. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_trash_hard_delete.py +0 -0
  89. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v546_features.py +0 -0
  90. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v547_fixes.py +0 -0
  91. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v548_features.py +0 -0
  92. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v550_features.py +0 -0
  93. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v552_features.py +0 -0
  94. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v554_features.py +0 -0
  95. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v556_features.py +0 -0
  96. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v557_banner_insight_wal.py +0 -0
  97. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v557_security_fixes.py +0 -0
  98. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v557_webhook_sig_export.py +0 -0
  99. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v558_audit_fixes.py +0 -0
  100. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v558_features.py +0 -0
  101. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v560_decay_gc.py +0 -0
  102. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v560_kdf_versioning.py +0 -0
  103. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v560_module_coverage.py +0 -0
  104. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v561_security.py +0 -0
  105. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v562_p2_fixes.py +0 -0
  106. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v563_entry_coverage.py +0 -0
  107. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v563_perf_fixes.py +0 -0
  108. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v565_security.py +0 -0
  109. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v566_encrypted_search.py +0 -0
  110. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v567_security_fixes.py +0 -0
  111. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v569_fts_sync.py +0 -0
  112. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v570_coverage_expansion.py +0 -0
  113. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v570_drama_and_utils.py +0 -0
  114. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v570_encrypted_fallback.py +0 -0
  115. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v571_fixes.py +0 -0
  116. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v572_security.py +0 -0
  117. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v573_encrypted_export.py +0 -0
  118. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v573_security.py +0 -0
  119. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v576_gdpr.py +0 -0
  120. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v578_embedding.py +0 -0
  121. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v5812_bugfixes.py +0 -0
  122. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v583_security.py +0 -0
  123. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v584_adapters.py +0 -0
  124. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v585_benchmark.py +0 -0
  125. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v586_federated_mcp.py +0 -0
  126. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v590_features.py +0 -0
  127. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v592_features.py +0 -0
  128. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v593_features.py +0 -0
  129. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v595_features.py +0 -0
  130. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v600_forgetting_followup.py +0 -0
  131. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v600_import_timeline.py +0 -0
  132. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v600_multi_agent_formal.py +0 -0
  133. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v600_outcome_passport.py +0 -0
  134. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v600_skillpack_evolution.py +0 -0
  135. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v612_cascade_fixes.py +0 -0
  136. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v613_integrity.py +0 -0
  137. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v620_growth_governance.py +0 -0
  138. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v630_search_explain.py +0 -0
  139. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v631_scrypt.py +0 -0
  140. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v632_explain_interfaces.py +0 -0
  141. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v635_features.py +0 -0
  142. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v636_fixes.py +0 -0
  143. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v648_fixes.py +0 -0
  144. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v652_context_expansion.py +0 -0
  145. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v654_search_multi.py +0 -0
  146. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v65_features.py +0 -0
  147. {mindforge_memory-6.5.4 → mindforge_memory-6.5.6}/tests/test_v6_ports.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mindforge-memory
3
- Version: 6.5.4
3
+ Version: 6.5.6
4
4
  Summary: AI Agent 终身记忆系统 - 四层记忆架构 · 知识图谱 · 多模态支持
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/opok-ops/MindForge
@@ -36,11 +36,11 @@ Dynamic: license-file
36
36
 
37
37
  MindForge gives AI agents a persistent, structured long-term memory: a four-tier lifecycle model, knowledge graphs, hybrid retrieval, end-to-end encryption, and MCP / CLI / REST interfaces. All data stays on your machine.
38
38
 
39
- > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.5.4: no team, no funding, 1,272 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
39
+ > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.5.6: no team, no funding, 1,272 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
40
40
 
41
41
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
42
42
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
43
- [![Version](https://img.shields.io/badge/version-6.5.4-green.svg)](https://github.com/opok-ops/MindForge/releases)
43
+ [![Version](https://img.shields.io/badge/version-6.5.6-green.svg)](https://github.com/opok-ops/MindForge/releases)
44
44
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
45
45
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
46
46
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -62,7 +62,7 @@ Key design decisions:
62
62
  - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
63
63
  - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
64
64
  - **Encryption by default.** AES-256-GCM at rest with PBKDF2 key derivation; encrypted backups you can export and trust.
65
- - **Open interfaces.** MCP server (87 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
65
+ - **Open interfaces.** MCP server (90 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
66
66
 
67
67
  ## Quick Start
68
68
 
@@ -72,7 +72,7 @@ Install from source, then start writing and reading memories in minutes:
72
72
  git clone https://github.com/opok-ops/MindForge.git
73
73
  cd MindForge
74
74
  pip install -e . # zero ML deps: 3-path retrieval (TF-IDF + FTS5 + fuzzy)
75
- pip install -e ".[embedding]" # + vector path → full 6-way hybrid search
75
+ pip install -e ".[embedding]" # + vector path → full 4-way hybrid retrieval
76
76
  ```
77
77
 
78
78
  > Without the `embedding` extra, MindForge runs in zero-dependency mode — fully functional, but paraphrased queries may go unrecalled (no semantic path). With it, a small sentence-transformers model downloads on first vector search.
@@ -106,12 +106,15 @@ MindForge stats
106
106
  - **Ten-million-character library, millisecond-class across all query types (v6.4.9)**: pathological 218→**0.4ms** (−99.8%), mixed 143→**3.0ms** (−98%), rare 6.8ms, combined 17.8ms (100k full-pipeline, clean environment). The last bottleneck — FTS5 high-frequency-phrase bm25 scoring — is now pruned query-side via trigram-df pre-check (df upper bound = min trigram df, pruned at 5% corpus size, symmetric to the TF-IDF max_df design; df served from an in-process cache — fts5vocab is a streaming virtual table, per-term probes scan it fully).
107
107
  - **Index-blindness fix (v6.4.8)**: TF-IDF vocabulary was locked to the first 5 documents since v6.4.6 — incremental adds indexed as empty vectors (TF-IDF effectively half-dead; previous numbers carried by FTS5/fuzzy). Fixed with incremental vocabulary growth; all pipeline numbers above are now *true full-pipeline* measurements.
108
108
  - Retrieval quality (fixed-seed, `benchmarks/quality_bench.py`, 2k entries): needle Recall@1 = 1.0, MRR = 1.0, topic Recall@1 = 1.0, noise false-recall = 0.
109
- - Full LLM-judged benchmarks (LoCoMo / LongMemEval) — interface ready, not yet run (requires external LLM API key).
109
+ - **LoCoMo full-suite, LLM-judged (v6.5.6, 2026-11-13)**: 1,986 questions across all 10 conversations — **51.5% accuracy (≥9/10 judge score)**, 2.13× over the 24.2% pre-assembly baseline; cross-validated by two independent judges (DeepSeek 51.5% / Kimi K3.1 52.72%, Δ1.2pt); excluding the adversarial "should-refuse" bucket, **43.05%** (663/1540). Per-bucket: adversarial 93.9%, single-hop 57.8%, multi-hop 25.2%, temporal 9.6%, open-domain 10.4% — temporal evidence recall and two-hop chain retrieval are the named v6.6 targets. Data: `benchmarks/results/`, judge pipeline in `benchmarks/`.
110
+ - LongMemEval — interface ready, not yet run (requires external LLM API key).
110
111
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
111
112
 
112
113
  ## What's New
113
114
 
114
- v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in the last two days), guarded by **1,273 tests** (1,272 passing, 1 environment-skipped).
115
+ v6.1.3 – v6.5.6 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
116
+
117
+ - **v6.5.6 — security fix pack from dual-judge external review** (2026-11-14). Qwen4-Max (Doubao) and Kimi K3.1 independently reviewed the codebase; their overlapping findings became this release. (1) **GDPR erasure completed**: `gdpr_erase_all` now cascades to 17 tables — added `knowledge_graph` entities, `memory_snapshots`, `memory_templates`, and the four drama_* creation-content tables that previously survived erasure (the "right to be forgotten" had a real gap). (2) **Legacy key-file verification fixed**: v5.5-era key files (no `verify_blob`) previously accepted *any* password during `rekey` — a wrong old password could rewrite the key file and orphan all data. Rekey now probe-decrypts a real ciphertext from the store; empty stores fall back to the old behavior. (3) **KDF cost floor**: `KDFParams.from_dict` rejects tampered parameters (PBKDF2 < 60k, scrypt N < 4096) that would downgrade brute-force cost — key files and ciphertext headers are attacker-visible input. (4) **Compression × encryption unblocked**: `compress_memories` previously raised `SecurityError` on encrypted stores, making the two flagship features mutually exclusive by default. Compression now hydrates its TF-IDF index via the same in-memory decryption path as `fuzzy_search` (`_plaintext_for_index`) — plaintext never touches disk or FTS5. (5) **Interface matrix completed**: REST gains `/api/gdpr/report`, `/api/gdpr/export`, `/api/gdpr/erase` (confirm=true required), `/api/compress`, `/api/compressions`; MCP gains `gdpr_report`, `gdpr_erase` (confirm required), `memory_compress` — 87→90 tools, all three interfaces now expose the full governance surface. (6) **Honesty fixes**: README previously claimed "six-way hybrid search"; the actual retrieval count is four (vector/FTS5/TF-IDF/fuzzy) — wording corrected, and the cross-encoder/heuristic distinction is now explicit. LoCoMo full-suite results (51.5%, dual-judge) added to the benchmarks section. 7+ new contract tests (`tests/test_v656_security.py`).
115
118
 
116
119
  - **v6.4.9 — ten-million-char library at millisecond latency: FTS5 high-frequency-phrase scoring pruned** (2026-11-11). The last honest bottleneck from v6.4.8's ledger. Root cause (30k per-path timing): under the trigram tokenizer, corpus-wide phrases (template data's "陈述性记忆") match every row — bm25 full-match scoring cost 50.5ms/query, the dominant remainder of 100k mixed latency. Fix, query-side df pre-pruning symmetric to TF-IDF max_df: a phrase's df upper bound = min df of its trigrams (phrase matches ⊆ every trigram's row set); prune at 5% of corpus size; keep the lowest-ub phrase if all pruned. df is served from an in-process cache keyed by `max(rowid)` (add/update invalidate; hard-delete leaves df slightly stale = prunes more conservatively) — **two real pitfalls found en route: fts5vocab is a *streaming virtual table* — per-term probes AND `IN` batches trigger full scans (combined regressed 17→45ms before the cache)**. Plus: FTS5 path skipped on pathological fallback (no discriminating signal). Clean-environment 100k re-bench: pathological 122→**0.4ms** (−99.7%), mixed 134.9→**3.0ms** (−98%), all query types millisecond-class at ~10M chars. AI-flavored comment cleanup (essay-style docstrings → engineer-speak, info preserved). 5 new guards.
117
120
 
@@ -131,7 +134,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
131
134
  - **v6.3.0 — Retrieval explainability** (`search --explain`). Hybrid search used to be a black box: you saw the ranking, not the reasoning. Every result can now carry its full score breakdown — per-path scores (TF-IDF / FTS5 / fuzzy / vector), the winning path, and text+vector fusion weights when both hit. Debug why a memory ranked first — or why another was never recalled at all. Zero overhead when disabled.
132
135
  - **v6.2.0 — Growth governance & reproducible benchmarks.** Audit logs get a brake: search-audit debouncing (one row per unique query per 60 s, compliance events never sampled or pruned), `audit-prune` for trimming, and a 7th doctor check that flags runaway growth. Also ships `benchmarks/repro_benchmark.py` — the methodology that killed the "encrypted writes are faster" benchmark artifact: same-N alternating rounds, P50/P95 latency over 50 samples per query type, 8-thread concurrency runs, orphan-repair verification.
133
136
  - **v6.1.3 — Self-healing data integrity.** GDPR erasure now removes derived data too — embeddings, notes, review schedules, evolution history, and graph relations (five tables previously survived "the right to be forgotten"). `doctor` gained orphan detection with one-command repair (`--fix`): dangling graph references, orphaned versions, and stray embeddings left behind by older cascade deletes are found and cleaned, with `dry_run` for impact assessment.
134
- - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (87 MCP tools total).
137
+ - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (90 MCP tools total).
135
138
 
136
139
  ## Features
137
140
 
@@ -144,7 +147,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
144
147
 
145
148
  **Retrieval**
146
149
 
147
- - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
150
+ - **Four-way hybrid retrieval** — vector, FTS5, TF-IDF, and fuzzy recall fused into a single ranked result set (RRF fusion, per-path score breakdown via `search --explain`). Query expansion (ctxdate temporal normalization + context windowing) operates at the evidence-assembly layer; reranking uses hand-tuned heuristic features, not a neural cross-encoder. *(v6.5.6 wording fix: previously overstated as "six-way" — honest count is four retrieval paths.)*
148
151
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
149
152
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
150
153
 
@@ -176,7 +179,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
176
179
 
177
180
  **Integration**
178
181
 
179
- - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
182
+ - **MCP server** — 90 tools, drop into Claude Code, OpenClaw, or any MCP client.
180
183
  - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
181
184
  - **REST API** — standard HTTP endpoints for non-Python applications.
182
185
  - **CLI** — 200+ commands with bash / zsh / fish completion.
@@ -188,7 +191,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
188
191
 
189
192
  ```
190
193
  ┌──────────────────────────────────────────────────────┐
191
- │ MindForge v6.5.4 │
194
+ │ MindForge v6.5.6 │
192
195
  │ Cognitive Layer Personality · KnowledgeGraph │
193
196
  │ MemoryEvolution · FederatedMemory │
194
197
  ├──────────────────────────────────────────────────────┤
@@ -6,11 +6,11 @@
6
6
 
7
7
  MindForge gives AI agents a persistent, structured long-term memory: a four-tier lifecycle model, knowledge graphs, hybrid retrieval, end-to-end encryption, and MCP / CLI / REST interfaces. All data stays on your machine.
8
8
 
9
- > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.5.4: no team, no funding, 1,272 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
9
+ > **The story** — one developer, seven months, from v1.0 (March 2026) to v6.5.6: no team, no funding, 1,272 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
10
10
 
11
11
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
12
12
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
13
- [![Version](https://img.shields.io/badge/version-6.5.4-green.svg)](https://github.com/opok-ops/MindForge/releases)
13
+ [![Version](https://img.shields.io/badge/version-6.5.6-green.svg)](https://github.com/opok-ops/MindForge/releases)
14
14
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
15
15
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
16
16
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -32,7 +32,7 @@ Key design decisions:
32
32
  - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
33
33
  - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
34
34
  - **Encryption by default.** AES-256-GCM at rest with PBKDF2 key derivation; encrypted backups you can export and trust.
35
- - **Open interfaces.** MCP server (87 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
35
+ - **Open interfaces.** MCP server (90 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
36
36
 
37
37
  ## Quick Start
38
38
 
@@ -42,7 +42,7 @@ Install from source, then start writing and reading memories in minutes:
42
42
  git clone https://github.com/opok-ops/MindForge.git
43
43
  cd MindForge
44
44
  pip install -e . # zero ML deps: 3-path retrieval (TF-IDF + FTS5 + fuzzy)
45
- pip install -e ".[embedding]" # + vector path → full 6-way hybrid search
45
+ pip install -e ".[embedding]" # + vector path → full 4-way hybrid retrieval
46
46
  ```
47
47
 
48
48
  > Without the `embedding` extra, MindForge runs in zero-dependency mode — fully functional, but paraphrased queries may go unrecalled (no semantic path). With it, a small sentence-transformers model downloads on first vector search.
@@ -76,12 +76,15 @@ MindForge stats
76
76
  - **Ten-million-character library, millisecond-class across all query types (v6.4.9)**: pathological 218→**0.4ms** (−99.8%), mixed 143→**3.0ms** (−98%), rare 6.8ms, combined 17.8ms (100k full-pipeline, clean environment). The last bottleneck — FTS5 high-frequency-phrase bm25 scoring — is now pruned query-side via trigram-df pre-check (df upper bound = min trigram df, pruned at 5% corpus size, symmetric to the TF-IDF max_df design; df served from an in-process cache — fts5vocab is a streaming virtual table, per-term probes scan it fully).
77
77
  - **Index-blindness fix (v6.4.8)**: TF-IDF vocabulary was locked to the first 5 documents since v6.4.6 — incremental adds indexed as empty vectors (TF-IDF effectively half-dead; previous numbers carried by FTS5/fuzzy). Fixed with incremental vocabulary growth; all pipeline numbers above are now *true full-pipeline* measurements.
78
78
  - Retrieval quality (fixed-seed, `benchmarks/quality_bench.py`, 2k entries): needle Recall@1 = 1.0, MRR = 1.0, topic Recall@1 = 1.0, noise false-recall = 0.
79
- - Full LLM-judged benchmarks (LoCoMo / LongMemEval) — interface ready, not yet run (requires external LLM API key).
79
+ - **LoCoMo full-suite, LLM-judged (v6.5.6, 2026-11-13)**: 1,986 questions across all 10 conversations — **51.5% accuracy (≥9/10 judge score)**, 2.13× over the 24.2% pre-assembly baseline; cross-validated by two independent judges (DeepSeek 51.5% / Kimi K3.1 52.72%, Δ1.2pt); excluding the adversarial "should-refuse" bucket, **43.05%** (663/1540). Per-bucket: adversarial 93.9%, single-hop 57.8%, multi-hop 25.2%, temporal 9.6%, open-domain 10.4% — temporal evidence recall and two-hop chain retrieval are the named v6.6 targets. Data: `benchmarks/results/`, judge pipeline in `benchmarks/`.
80
+ - LongMemEval — interface ready, not yet run (requires external LLM API key).
80
81
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
81
82
 
82
83
  ## What's New
83
84
 
84
- v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in the last two days), guarded by **1,273 tests** (1,272 passing, 1 environment-skipped).
85
+ v6.1.3 – v6.5.6 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
86
+
87
+ - **v6.5.6 — security fix pack from dual-judge external review** (2026-11-14). Qwen4-Max (Doubao) and Kimi K3.1 independently reviewed the codebase; their overlapping findings became this release. (1) **GDPR erasure completed**: `gdpr_erase_all` now cascades to 17 tables — added `knowledge_graph` entities, `memory_snapshots`, `memory_templates`, and the four drama_* creation-content tables that previously survived erasure (the "right to be forgotten" had a real gap). (2) **Legacy key-file verification fixed**: v5.5-era key files (no `verify_blob`) previously accepted *any* password during `rekey` — a wrong old password could rewrite the key file and orphan all data. Rekey now probe-decrypts a real ciphertext from the store; empty stores fall back to the old behavior. (3) **KDF cost floor**: `KDFParams.from_dict` rejects tampered parameters (PBKDF2 < 60k, scrypt N < 4096) that would downgrade brute-force cost — key files and ciphertext headers are attacker-visible input. (4) **Compression × encryption unblocked**: `compress_memories` previously raised `SecurityError` on encrypted stores, making the two flagship features mutually exclusive by default. Compression now hydrates its TF-IDF index via the same in-memory decryption path as `fuzzy_search` (`_plaintext_for_index`) — plaintext never touches disk or FTS5. (5) **Interface matrix completed**: REST gains `/api/gdpr/report`, `/api/gdpr/export`, `/api/gdpr/erase` (confirm=true required), `/api/compress`, `/api/compressions`; MCP gains `gdpr_report`, `gdpr_erase` (confirm required), `memory_compress` — 87→90 tools, all three interfaces now expose the full governance surface. (6) **Honesty fixes**: README previously claimed "six-way hybrid search"; the actual retrieval count is four (vector/FTS5/TF-IDF/fuzzy) — wording corrected, and the cross-encoder/heuristic distinction is now explicit. LoCoMo full-suite results (51.5%, dual-judge) added to the benchmarks section. 7+ new contract tests (`tests/test_v656_security.py`).
85
88
 
86
89
  - **v6.4.9 — ten-million-char library at millisecond latency: FTS5 high-frequency-phrase scoring pruned** (2026-11-11). The last honest bottleneck from v6.4.8's ledger. Root cause (30k per-path timing): under the trigram tokenizer, corpus-wide phrases (template data's "陈述性记忆") match every row — bm25 full-match scoring cost 50.5ms/query, the dominant remainder of 100k mixed latency. Fix, query-side df pre-pruning symmetric to TF-IDF max_df: a phrase's df upper bound = min df of its trigrams (phrase matches ⊆ every trigram's row set); prune at 5% of corpus size; keep the lowest-ub phrase if all pruned. df is served from an in-process cache keyed by `max(rowid)` (add/update invalidate; hard-delete leaves df slightly stale = prunes more conservatively) — **two real pitfalls found en route: fts5vocab is a *streaming virtual table* — per-term probes AND `IN` batches trigger full scans (combined regressed 17→45ms before the cache)**. Plus: FTS5 path skipped on pathological fallback (no discriminating signal). Clean-environment 100k re-bench: pathological 122→**0.4ms** (−99.7%), mixed 134.9→**3.0ms** (−98%), all query types millisecond-class at ~10M chars. AI-flavored comment cleanup (essay-style docstrings → engineer-speak, info preserved). 5 new guards.
87
90
 
@@ -101,7 +104,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
101
104
  - **v6.3.0 — Retrieval explainability** (`search --explain`). Hybrid search used to be a black box: you saw the ranking, not the reasoning. Every result can now carry its full score breakdown — per-path scores (TF-IDF / FTS5 / fuzzy / vector), the winning path, and text+vector fusion weights when both hit. Debug why a memory ranked first — or why another was never recalled at all. Zero overhead when disabled.
102
105
  - **v6.2.0 — Growth governance & reproducible benchmarks.** Audit logs get a brake: search-audit debouncing (one row per unique query per 60 s, compliance events never sampled or pruned), `audit-prune` for trimming, and a 7th doctor check that flags runaway growth. Also ships `benchmarks/repro_benchmark.py` — the methodology that killed the "encrypted writes are faster" benchmark artifact: same-N alternating rounds, P50/P95 latency over 50 samples per query type, 8-thread concurrency runs, orphan-repair verification.
103
106
  - **v6.1.3 — Self-healing data integrity.** GDPR erasure now removes derived data too — embeddings, notes, review schedules, evolution history, and graph relations (five tables previously survived "the right to be forgotten"). `doctor` gained orphan detection with one-command repair (`--fix`): dangling graph references, orphaned versions, and stray embeddings left behind by older cascade deletes are found and cleaned, with `dry_run` for impact assessment.
104
- - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (87 MCP tools total).
107
+ - **v6.1.1 — Follow-up closed loop.** Memories don't just wait to be queried — they nudge. Follow-up items can now trigger proactive reminders when their time comes (90 MCP tools total).
105
108
 
106
109
  ## Features
107
110
 
@@ -114,7 +117,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
114
117
 
115
118
  **Retrieval**
116
119
 
117
- - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
120
+ - **Four-way hybrid retrieval** — vector, FTS5, TF-IDF, and fuzzy recall fused into a single ranked result set (RRF fusion, per-path score breakdown via `search --explain`). Query expansion (ctxdate temporal normalization + context windowing) operates at the evidence-assembly layer; reranking uses hand-tuned heuristic features, not a neural cross-encoder. *(v6.5.6 wording fix: previously overstated as "six-way" — honest count is four retrieval paths.)*
118
121
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
119
122
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
120
123
 
@@ -146,7 +149,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
146
149
 
147
150
  **Integration**
148
151
 
149
- - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
152
+ - **MCP server** — 90 tools, drop into Claude Code, OpenClaw, or any MCP client.
150
153
  - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
151
154
  - **REST API** — standard HTTP endpoints for non-Python applications.
152
155
  - **CLI** — 200+ commands with bash / zsh / fish completion.
@@ -158,7 +161,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
158
161
 
159
162
  ```
160
163
  ┌──────────────────────────────────────────────────────┐
161
- │ MindForge v6.5.4 │
164
+ │ MindForge v6.5.6 │
162
165
  │ Cognitive Layer Personality · KnowledgeGraph │
163
166
  │ MemoryEvolution · FederatedMemory │
164
167
  ├──────────────────────────────────────────────────────┤
@@ -13,11 +13,12 @@ MindForge REST API Server
13
13
  读 100 req/60s/IP、写 30、批量导入 10(_check_rate_limit(write/heavy));
14
14
  认证:除 /api/health 与 / 外均需 _check_auth。
15
15
 
16
- **本表是摘选,不是权威清单。** 当前实现的分发点共 **60** 个
17
- (按方法:GET 37 / POST 21 / PUT 1 / DELETE 1,口径见
16
+ **本表是摘选,不是权威清单。** 当前实现的分发点共 **65** 个
17
+ (按方法:GET 39 / POST 24 / PUT 1 / DELETE 1,v6.5.6 起;口径见
18
18
  `scripts/check_docs_consistency.py` 第 [8] 组——它直接解析 `do_*` 方法体,
19
19
  数字漂移会被 CI 拦下)。此前这里写着「路由表」却只列了 24 条,
20
- 读代码的人据此估算接口规模,会低估一半以上。
20
+ 读代码的人据此估算接口规模,会低估一半以上。v6.5.6 起 65 个
21
+ (GDPR 报告/导出/擦除 + 压缩 2 条)。
21
22
 
22
23
  Method Path 说明 分发位置
23
24
  ------ ---------------------- ------------------------ --------------
@@ -821,6 +822,12 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
821
822
  }
822
823
  )
823
824
 
825
+ elif path == "/api/gdpr/report":
826
+ # v6.5.6:GDPR 合规报告(数据地图)
827
+ self._send_json(self.mindforge.gdpr_report())
828
+ elif path == "/api/compressions":
829
+ # v6.5.6:压缩簇列表
830
+ self._send_json({"clusters": self.mindforge.list_compressions()})
824
831
  elif path == "/api/valid-at":
825
832
  # v5.7.6 新增:Bi-temporal as-of 查询(事实有效时间)
826
833
  ts_raw = qs.get("ts", [None])[0]
@@ -1084,6 +1091,31 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
1084
1091
  entry.to_dict() if hasattr(entry, "to_dict") else vars(entry), 201
1085
1092
  )
1086
1093
 
1094
+ elif path == "/api/gdpr/export":
1095
+ # v6.5.6:REST 对齐 CLI 的被遗忘权三件套(报告/导出/擦除)
1096
+ data = self.mindforge.gdpr_export_all()
1097
+ self._send_json({"count": len(data.get("memories", [])),
1098
+ "exported_at": data.get("exported_at")})
1099
+ elif path == "/api/gdpr/erase":
1100
+ confirm = body.get("confirm", False)
1101
+ if confirm is not True:
1102
+ self._send_json(
1103
+ {"error": "irreversible operation: pass confirm=true"},
1104
+ 400)
1105
+ return
1106
+ res = self.mindforge.gdpr_erase_all(
1107
+ backup=bool(body.get("backup", True)),
1108
+ actor=body.get("actor", "rest_gdpr_erase"))
1109
+ self._send_json({"status": "erased", "deleted": res.get("deleted"),
1110
+ "backup": res.get("backup")})
1111
+ elif path == "/api/compress":
1112
+ # v6.5.6:REST 对齐记忆压缩入口
1113
+ res = self.mindforge.compress_memories(
1114
+ threshold=float(body.get("threshold", 0.75)),
1115
+ dry_run=bool(body.get("dry_run", False)),
1116
+ categories=body.get("categories"),
1117
+ min_cluster_size=int(body.get("min_cluster_size", 3)))
1118
+ self._send_json(res)
1087
1119
  elif path == "/api/agent/forget":
1088
1120
  mid = body.get("id", "")
1089
1121
  if not isinstance(mid, str) or not mid:
@@ -11,7 +11,7 @@ import json
11
11
  import base64
12
12
  import threading # v5.4.7 修复 H-4:全局引擎初始化线程安全
13
13
  from pathlib import Path
14
- from typing import Optional, Tuple
14
+ from typing import Optional, Tuple, Callable
15
15
  from dataclasses import dataclass
16
16
 
17
17
  # 懒加载 cryptography:避免 CLI 启动时导入耗时(低配电脑 300ms+)
@@ -48,6 +48,8 @@ PBKDF2_ITERATIONS_LEGACY = 60_000
48
48
  SCRYPT_N_CURRENT = 65_536
49
49
  SCRYPT_R_CURRENT = 8
50
50
  SCRYPT_P_CURRENT = 1
51
+ # v6.5.6:KDF 成本下限(防降级攻击,见 KDFParams.from_dict)
52
+ _KDF_MIN_SCRYPT_N = 4096
51
53
 
52
54
  # 密钥文件格式版本(v6.3 = scrypt 默认;5.6 = PBKDF2 版本化;更早 = legacy)
53
55
  KEY_FILE_VERSION = "6.3"
@@ -100,6 +102,20 @@ class KDFParams:
100
102
  """
101
103
  algorithm = data.get("algorithm", KDF_ALGORITHM_LEGACY)
102
104
  iterations = int(data.get("iterations", PBKDF2_ITERATIONS_LEGACY))
105
+ # v6.5.6 安全修复:KDF 成本下限(防降级攻击)——密钥文件/密文头
106
+ # 是外部可篡改输入,攻击者把参数改小(如 iterations=100 或
107
+ # scrypt n=1024)可使暴力破解成本骤降。from_dict 是唯一入口,
108
+ # 此处强制下限:PBKDF2 ≥ 60k(legacy 下限)、scrypt n ≥ 4096。
109
+ # 真实历史数据全部满足(60k/600k/2^16),不影响兼容读取。
110
+ if algorithm == KDF_ALGORITHM_CURRENT:
111
+ if int(data.get("n", iterations)) < _KDF_MIN_SCRYPT_N:
112
+ raise SecurityError(
113
+ f"KDF 参数低于安全下限(scrypt n={data.get('n')} < "
114
+ f"{_KDF_MIN_SCRYPT_N}),疑似降级攻击,已拒绝")
115
+ elif iterations < PBKDF2_ITERATIONS_LEGACY:
116
+ raise SecurityError(
117
+ f"KDF 参数低于安全下限(PBKDF2 iterations={iterations} < "
118
+ f"{PBKDF2_ITERATIONS_LEGACY}),疑似降级攻击,已拒绝")
103
119
  if algorithm == KDF_ALGORITHM_CURRENT:
104
120
  # scrypt:iterations 承载 N(信息性);实际派生用 n/r/p
105
121
  n = int(data.get("n", iterations))
@@ -388,14 +404,28 @@ def _write_key_file(key_path: Path, salt: bytes, kdf_params: KDFParams,
388
404
  pass # icacls 失败不阻断流程
389
405
 
390
406
 
391
- def _verify_key_password(engine: EncryptionEngine, key_data: dict) -> bool:
407
+ def _verify_key_password(engine: EncryptionEngine, key_data: dict,
408
+ probe_decrypt: Optional[Callable[[EncryptionEngine], bool]] = None) -> bool:
392
409
  """使用验证令牌检查密码是否正确
393
410
 
394
411
  v5.6.0: 新密钥文件包含 verify_blob 字段。旧文件没有则跳过验证
395
412
  (向后兼容,避免老用户升级后被锁)。
413
+ v6.5.6 安全修复:legacy 密钥文件(无 verify_blob)在调用方提供
414
+ probe_decrypt 时进行试探解密验证——此前恒放行意味着 rekey 路径
415
+ 用错误旧密码也能把密钥文件重写成新密码(数据仍可用旧密钥解开,
416
+ 但新密钥从此对不上数据,构成可用性攻击面 + 双判官独立评审
417
+ (Qwen4-Max / Kimi K3.1)重叠指出的校验缺口)。
418
+ probe_decrypt 回调负责从库中取一条真实密文让 engine 试解;
419
+ 返回 True/False。无回调(None)时维持旧行为放行(调用方
420
+ 无验证材料,如空库)。
396
421
  """
397
422
  if "verify_blob" not in key_data:
398
- return True # legacy 密钥文件,无法验证,放行
423
+ if probe_decrypt is not None:
424
+ try:
425
+ return bool(probe_decrypt(engine))
426
+ except Exception:
427
+ return False
428
+ return True # legacy 且无验证材料:放行(旧行为)
399
429
 
400
430
  try:
401
431
  blob = EncryptedBlob.from_dict(key_data["verify_blob"])
@@ -442,7 +442,27 @@ class MindForge:
442
442
  old_password, old_salt,
443
443
  kdf_params=verify_params,
444
444
  )
445
- if not _verify_key_password(verify_engine, key_data):
445
+ # v6.5.6:legacy 文件(无 verify_blob)接 probe 试探解密——
446
+ # 从库中取一条真实密文让旧密码引擎试解;空库无材料时退回放行。
447
+ def _probe(eng):
448
+ try:
449
+ rows = self._storage._get_conn().execute(
450
+ "SELECT * FROM memories WHERE encrypted=1 LIMIT 1"
451
+ ).fetchall()
452
+ if not rows:
453
+ return True # 无验证材料(空库):不因缺材料拒真
454
+ from mindforge.core.encryption import EncryptedBlob
455
+ e = self._storage._row_to_entry(rows[0])
456
+ blob = EncryptedBlob(
457
+ ciphertext=e.ciphertext, nonce=e.nonce, salt=e.salt,
458
+ kdf_params=getattr(e, "kdf_params", None) or eng.kdf_params)
459
+ eng.decrypt(blob)
460
+ return True # 试解成功即密码正确
461
+ except Exception:
462
+ return False # 试解失败 = 旧密码错误
463
+
464
+ if not _verify_key_password(verify_engine, key_data,
465
+ probe_decrypt=_probe):
446
466
  raise SecurityError("旧密码错误")
447
467
 
448
468
  # v6.3.1: 默认升级到 scrypt(64 MiB 内存墙);显式传 new_iterations
@@ -4,6 +4,7 @@ MindForge 查询引擎
4
4
  """
5
5
 
6
6
  import logging
7
+ import re
7
8
  from dataclasses import dataclass, field
8
9
  from typing import List, Optional, Dict, Any, Tuple
9
10
  from .storage import StorageEngine, MemoryEntry
@@ -64,6 +65,85 @@ class RecallResult:
64
65
  approximate: bool = False
65
66
 
66
67
 
68
+ # v6.5.5:相对时间词归一化表(窗口扩展时就地换算为绝对日期)。
69
+ # 锚定来源:轮次 tags 携带 "ctxdate:YYYY-MM-DD"(可选协议位)。
70
+ # 缺 ctxdate 时原样返回(降级安全)。纯规则零 LLM。
71
+ _TEMPORAL_RULES = [
72
+ ("today", 0), ("tonight", 0), ("this morning", 0),
73
+ ("this afternoon", 0), ("this evening", 0), ("right now", 0),
74
+ ("yesterday", -1), ("yesterday morning", -1), ("last night", -1),
75
+ ("tomorrow", 1), ("tomorrow morning", 1),
76
+ ("last week", -7), ("next week", 7), ("last weekend", -7),
77
+ ("next weekend", 7), ("last month", -30), ("next month", 30),
78
+ ("last year", -365), ("next year", 365),
79
+ ]
80
+ _N_REL = re.compile(
81
+ r"(\b\d+\s+(?:day|week|month|year)s?\s+ago\b"
82
+ r"|\bin\s+\d+\s+(?:day|week|month|year)s?\b"
83
+ r"|[两二三四五六七八九十0-9]+\s*(?:天|周|月|年)(?:之)?\s*[前后以])", re.IGNORECASE)
84
+ _CN_NUM = {"两": 2, "二": 2, "三": 3, "四": 4, "五": 5, "六": 6,
85
+ "七": 7, "八": 8, "九": 9, "十": 10}
86
+ _REL_DUR = {"day": 1, "week": 7, "month": 30, "year": 365,
87
+ "天": 1, "周": 7, "月": 30, "年": 365}
88
+
89
+
90
+ def _normalize_temporal(text: str, anchor: Optional[str]) -> str:
91
+ """把 text 中的相对时间词换算为 [绝对日期±N] 标注(v6.5.5)
92
+
93
+ anchor 为该轮所属日期(YYYY-MM-DD);None 时原样返回。
94
+ """
95
+ if not anchor or not text:
96
+ return text
97
+ try:
98
+ from datetime import datetime, timedelta
99
+ base = datetime.strptime(anchor, "%Y-%m-%d")
100
+ except Exception:
101
+ return text
102
+
103
+ def fmt(d):
104
+ return d.strftime("%Y-%m-%d")
105
+
106
+ out = text
107
+ # 显式「N 天/周/月 前(后)」
108
+ def rel_repl(m):
109
+ s = m.group(0).lower()
110
+ import re as _r
111
+ cn = _r.search(r"([两二三四五六七八九十]+)", s)
112
+ if cn:
113
+ # 中文数字(十以内单字;十X=10+X、X十=X*10 简化处理)
114
+ t = cn.group(1)
115
+ if len(t) == 1:
116
+ n = _CN_NUM.get(t, 1)
117
+ else:
118
+ n = 10 + _CN_NUM.get(t[1], 0) if t[0] == "十" else _CN_NUM.get(t[0], 1) * 10 + _CN_NUM.get(t[1], 0)
119
+ else:
120
+ num = _r.search(r"(\d+)", s)
121
+ if not num:
122
+ return m.group(0)
123
+ n = int(num.group(1))
124
+ unit = None
125
+ for k in _REL_DUR:
126
+ if k in s:
127
+ unit = k
128
+ break
129
+ if unit is None:
130
+ return m.group(0)
131
+ delta = n * _REL_DUR[unit]
132
+ if "前" in s or "ago" in s:
133
+ d = base - timedelta(days=delta)
134
+ else:
135
+ d = base + timedelta(days=delta)
136
+ return f"[{fmt(d)}]"
137
+
138
+ out = _N_REL.sub(rel_repl, out)
139
+ # 固定短语表(倒序替换避免子串误伤:先长后短)
140
+ for phrase, delta_days in sorted(_TEMPORAL_RULES, key=lambda x: -len(x[0])):
141
+ pat = re.compile(r"\b" + re.escape(phrase) + r"\b", re.IGNORECASE)
142
+ d = base + timedelta(days=delta_days)
143
+ out = pat.sub(f"[{fmt(d)}]", out)
144
+ return out
145
+
146
+
67
147
  # v5.5.5 P1 新增:中文技术同义词词典(50+ 组)
68
148
  # 用于查询扩展,提升中文检索召回率
69
149
  _CHINESE_SYNONYMS: Dict[str, List[str]] = {
@@ -524,11 +604,15 @@ class QueryEngine:
524
604
  approximate=approximate,
525
605
  )
526
606
 
607
+
527
608
  def _expand_chunk_context(self, chunks: List[MemoryChunk],
528
609
  radius: int) -> None:
529
610
  """按 ctxgrp/ctxseq 坐标 tags 填充 context_expansion(v6.5.2)
530
611
 
531
- 坐标协议:入库 tags 携带 "ctxgrp:<组id>" 与 "ctxseq:<序号>"。
612
+ 坐标协议:入库 tags 携带 "ctxgrp:<组id>" 与 "ctxseq:<序号>";
613
+ v6.5.5 起可选 "ctxdate:YYYY-MM-DD"(轮次日期锚)——携带时邻居
614
+ 文本中的相对时间词(yesterday/两周前…)就地归一化为绝对日期,
615
+ temporal 类问题的证据自包含时间戳。
532
616
  无坐标或组内邻居缺失时该 chunk 字段保持 None(降级安全)。
533
617
  窗口 = [seq-radius, seq+radius](含命中轮),升序输出。
534
618
  """
@@ -565,7 +649,15 @@ class QueryEngine:
565
649
  if e_seq is None:
566
650
  continue
567
651
  if abs(e_seq - seq) <= radius:
568
- neighbours.append((e_seq, e.content))
652
+ # v6.5.5:邻居轮时间归一化(ctxdate 存在时)
653
+ e_date = None
654
+ for t in (e.tags or []):
655
+ if t.startswith("ctxdate:"):
656
+ e_date = t[8:]
657
+ break
658
+ content = (_normalize_temporal(e.content, e_date)
659
+ if e_date else e.content)
660
+ neighbours.append((e_seq, content))
569
661
  if neighbours:
570
662
  neighbours.sort(key=lambda x: x[0])
571
663
  chunk.context_expansion = neighbours
@@ -2415,9 +2415,11 @@ class StorageEngine:
2415
2415
  key_file: Optional[str] = None) -> Dict[str, Any]:
2416
2416
  """删除权(被遗忘权)实现(v5.7.6 新增)
2417
2417
 
2418
- 先自动创建完整备份(数据库 + 密钥文件),再永久删除
2419
- memory_links / memory_versions / audit_log / archived_memories /
2420
- memories / memory_fts,并清空缓存与访问计数挂账。
2418
+ 先自动创建完整备份(数据库 + 密钥文件),再永久删除全部
2419
+ 含个人数据的表(v6.5.6 补齐:knowledge_graph 实体、
2420
+ memory_snapshots 快照、memory_templates、drama_* 剧作创作
2421
+ 内容——此前遗留实体表残留,被遗忘权不完整),并清空缓存
2422
+ 与访问计数挂账。
2421
2423
  返回各表删除计数与备份路径。不可逆,调用方必须先提示确认。
2422
2424
  """
2423
2425
  backup_path = ""
@@ -2444,9 +2446,16 @@ class StorageEngine:
2444
2446
  # graph_relations(含 memory_ids 指向被删记忆的引用)。
2445
2447
  # 这些表留下孤儿行不仅占空间,更构成「名义上已行使删除权、
2446
2448
  # 实际数据仍残留」的合规缺口。
2449
+ # v6.5.6:补齐 knowledge_graph(实体含从记忆抽取的个人数据)、
2450
+ # memory_snapshots(历史内容快照)、memory_templates、
2451
+ # drama_series/scenes/characters/lines(剧作创作内容)——
2452
+ # 双判官独立评审(Qwen4-Max / Kimi K3.1)重叠指出的级联残留。
2447
2453
  for table in ("memory_links", "memory_versions", "memory_notes",
2448
2454
  "review_schedules", "memory_evolutions",
2449
2455
  "memory_embeddings", "graph_relations",
2456
+ "knowledge_graph", "memory_snapshots",
2457
+ "memory_templates", "drama_series", "drama_scenes",
2458
+ "drama_characters", "drama_lines",
2450
2459
  "audit_log", "archived_memories", "memories"):
2451
2460
  try:
2452
2461
  deleted[table] = int(conn.execute(f"DELETE FROM {table}").rowcount)
@@ -20,10 +20,10 @@ core/mindforge.py、cli/main.py、mcp/server.py),每处都带一份硬编码
20
20
  from typing import Tuple
21
21
 
22
22
  #: 当前发布版本(唯一真值)
23
- __version__: str = "6.5.4"
23
+ __version__: str = "6.5.6"
24
24
 
25
25
  #: 结构化版本元组,便于比较(如 `VERSION_INFO >= (6, 1, 0)`)
26
- VERSION_INFO: Tuple[int, int, int] = (6, 5, 4)
26
+ VERSION_INFO: Tuple[int, int, int] = (6, 5, 6)
27
27
 
28
28
  #: 下一个大版本的目标版本号(供 v6 端口预留引用)
29
29
  NEXT_MAJOR_TARGET: str = "7.0.0"
@@ -812,6 +812,37 @@ TOOL_SCHEMAS: List[Dict[str, Any]] = [
812
812
  }
813
813
  },
814
814
  },
815
+ {
816
+ "name": "gdpr_report",
817
+ "description": "GDPR 合规报告:数据地图与各表行数统计(v6.5.6 对齐 CLI/REST)。",
818
+ "inputSchema": {"type": "object", "required": [], "properties": {}},
819
+ },
820
+ {
821
+ "name": "gdpr_erase",
822
+ "description": "行使被遗忘权:永久删除全部个人数据(含知识图谱实体/快照/剧作内容,不可逆)。必须显式传 confirm=true。",
823
+ "inputSchema": {
824
+ "type": "object",
825
+ "required": ["confirm"],
826
+ "properties": {
827
+ "confirm": {"type": "boolean",
828
+ "description": "必须为 true 才执行(不可逆删除)"},
829
+ "backup": {"type": "boolean", "description": "删除前自动备份,默认 true"}
830
+ }
831
+ },
832
+ },
833
+ {
834
+ "name": "memory_compress",
835
+ "description": "记忆压缩:聚类相似记忆生成摘要(v6.5.6 起支持加密库,明文仅驻内存)。dry_run 只报告不写入。",
836
+ "inputSchema": {
837
+ "type": "object", "required": [],
838
+ "properties": {
839
+ "threshold": {"type": "number", "description": "相似度阈值 0-1,默认 0.75"},
840
+ "dry_run": {"type": "boolean", "description": "只报告将压缩的簇"},
841
+ "categories": {"type": "array", "items": {"type": "string"}},
842
+ "min_cluster_size": {"type": "integer", "description": "最小簇大小,默认 3"}
843
+ }
844
+ },
845
+ },
815
846
  {
816
847
  "name": "skill_pack_export",
817
848
  "description": "功能 3:导出可分享技能包(v6.0.0)。",
@@ -1755,6 +1786,42 @@ def h_timeline_viz(mf, args):
1755
1786
  return {"ok": False, "error": _safe_error_msg(e)}
1756
1787
 
1757
1788
 
1789
+ def h_gdpr_report(mf, _args):
1790
+ try:
1791
+ return {"ok": True, **mf.gdpr_report()}
1792
+ except Exception as e:
1793
+ return {"ok": False, "error": _safe_error_msg(e)}
1794
+
1795
+
1796
+ def h_gdpr_erase(mf, args):
1797
+ if args.get("confirm") is not True:
1798
+ return {"ok": False,
1799
+ "error": "被遗忘权操作不可逆:必须显式传 confirm=true"}
1800
+ try:
1801
+ res = mf.gdpr_erase_all(
1802
+ backup=bool(args.get("backup", True)),
1803
+ actor="mcp_gdpr_erase")
1804
+ return {"ok": True, "status": "erased", **res}
1805
+ except Exception as e:
1806
+ return {"ok": False, "error": _safe_error_msg(e)}
1807
+
1808
+
1809
+ def h_memory_compress(mf, args):
1810
+ try:
1811
+ kwargs = {}
1812
+ if "threshold" in args:
1813
+ kwargs["threshold"] = float(args["threshold"])
1814
+ if "dry_run" in args:
1815
+ kwargs["dry_run"] = bool(args["dry_run"])
1816
+ if "categories" in args:
1817
+ kwargs["categories"] = args["categories"]
1818
+ if "min_cluster_size" in args:
1819
+ kwargs["min_cluster_size"] = int(args["min_cluster_size"])
1820
+ return {"ok": True, **mf.compress_memories(**kwargs)}
1821
+ except Exception as e:
1822
+ return {"ok": False, "error": _safe_error_msg(e)}
1823
+
1824
+
1758
1825
  def h_skill_pack_export(mf, _args):
1759
1826
  try:
1760
1827
  return {"ok": True, **mf.skill_pack_export()}
@@ -2273,6 +2340,9 @@ HANDLERS: Dict[str, Any] = {
2273
2340
  # v6.0.0 功能 1-8
2274
2341
  "chat_import": h_chat_import,
2275
2342
  "timeline_viz": h_timeline_viz,
2343
+ "gdpr_report": h_gdpr_report,
2344
+ "gdpr_erase": h_gdpr_erase,
2345
+ "memory_compress": h_memory_compress,
2276
2346
  "skill_pack_export": h_skill_pack_export,
2277
2347
  "skill_pack_import": h_skill_pack_import,
2278
2348
  "memory_evolve": h_memory_evolve,