mindforge-memory 6.5.5__tar.gz → 6.5.7__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 (148) hide show
  1. {mindforge_memory-6.5.5/mindforge_memory.egg-info → mindforge_memory-6.5.7}/PKG-INFO +16 -11
  2. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/README.md +15 -10
  3. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/api/server.py +35 -3
  4. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/encryption.py +41 -5
  5. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/mindforge.py +35 -3
  6. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/query.py +305 -0
  7. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/storage.py +110 -29
  8. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/types.py +5 -2
  9. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/version.py +2 -2
  10. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/mcp/server.py +70 -0
  11. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/knowledge_graph.py +84 -3
  12. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/memory_compressor.py +13 -24
  13. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7/mindforge_memory.egg-info}/PKG-INFO +16 -11
  14. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge_memory.egg-info/SOURCES.txt +2 -0
  15. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v568_fixes.py +1 -1
  16. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v575_release_consistency.py +2 -2
  17. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v576_bitemporal.py +1 -1
  18. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v577_agent_governance.py +1 -1
  19. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v579_graph.py +23 -10
  20. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v580_experience.py +1 -1
  21. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v611_fixes.py +3 -3
  22. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v612_fixes.py +3 -3
  23. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v635_integration.py +17 -5
  24. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v643_fixes.py +1 -1
  25. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v645_fixes.py +2 -2
  26. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v646_fixes.py +1 -1
  27. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v649_fixes.py +2 -2
  28. mindforge_memory-6.5.7/tests/test_v656_security.py +170 -0
  29. mindforge_memory-6.5.7/tests/test_v657_six_path.py +184 -0
  30. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/LICENSE +0 -0
  31. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/MindForge.py +0 -0
  32. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/__init__.py +0 -0
  33. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/__init__.py +0 -0
  34. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/claude_adapter.py +0 -0
  35. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/crewai_memory.py +0 -0
  36. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/generic_api.py +0 -0
  37. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/langgraph_store.py +0 -0
  38. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/adapters/openclaw_adapter.py +0 -0
  39. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/api/__init__.py +0 -0
  40. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/cli/__init__.py +0 -0
  41. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/cli/main.py +0 -0
  42. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/__init__.py +0 -0
  43. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/embedding.py +0 -0
  44. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/indexer.py +0 -0
  45. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/core/paths.py +0 -0
  46. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/daemon/__init__.py +0 -0
  47. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/daemon/server.py +0 -0
  48. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/mcp/__init__.py +0 -0
  49. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/__init__.py +0 -0
  50. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/categorizer.py +0 -0
  51. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/conflict_detector.py +0 -0
  52. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/connectors.py +0 -0
  53. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/context_window.py +0 -0
  54. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/event_bus.py +0 -0
  55. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/evolution.py +0 -0
  56. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/experience.py +0 -0
  57. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/federated.py +0 -0
  58. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/federated_acl.py +0 -0
  59. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/follow_up.py +0 -0
  60. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/hybrid_search.py +0 -0
  61. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/importer.py +0 -0
  62. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/integrator.py +0 -0
  63. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/intent_router.py +0 -0
  64. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/memory_decay.py +0 -0
  65. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/memory_passport.py +0 -0
  66. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/multi_agent.py +0 -0
  67. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/multimodal.py +0 -0
  68. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/outcome_learning.py +0 -0
  69. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/personality.py +0 -0
  70. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/principled_forgetting.py +0 -0
  71. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/privacy.py +0 -0
  72. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/recall.py +0 -0
  73. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/session_focus.py +0 -0
  74. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/share_conflict.py +0 -0
  75. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/skill_extractor.py +0 -0
  76. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/skill_pack.py +0 -0
  77. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/timeline_viz.py +0 -0
  78. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge/modules/v6.py +0 -0
  79. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge_memory.egg-info/dependency_links.txt +0 -0
  80. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge_memory.egg-info/entry_points.txt +0 -0
  81. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge_memory.egg-info/requires.txt +0 -0
  82. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/mindforge_memory.egg-info/top_level.txt +0 -0
  83. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/pyproject.toml +0 -0
  84. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/setup.cfg +0 -0
  85. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/setup.py +0 -0
  86. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_core.py +0 -0
  87. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_security_hardening.py +0 -0
  88. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_trash_hard_delete.py +0 -0
  89. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v546_features.py +0 -0
  90. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v547_fixes.py +0 -0
  91. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v548_features.py +0 -0
  92. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v550_features.py +0 -0
  93. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v552_features.py +0 -0
  94. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v554_features.py +0 -0
  95. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v556_features.py +0 -0
  96. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v557_banner_insight_wal.py +0 -0
  97. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v557_security_fixes.py +0 -0
  98. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v557_webhook_sig_export.py +0 -0
  99. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v558_audit_fixes.py +0 -0
  100. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v558_features.py +0 -0
  101. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v560_decay_gc.py +0 -0
  102. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v560_kdf_versioning.py +0 -0
  103. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v560_module_coverage.py +0 -0
  104. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v561_security.py +0 -0
  105. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v562_p2_fixes.py +0 -0
  106. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v563_entry_coverage.py +0 -0
  107. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v563_perf_fixes.py +0 -0
  108. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v565_security.py +0 -0
  109. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v566_encrypted_search.py +0 -0
  110. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v567_security_fixes.py +0 -0
  111. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v569_fts_sync.py +0 -0
  112. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v570_coverage_expansion.py +0 -0
  113. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v570_drama_and_utils.py +0 -0
  114. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v570_encrypted_fallback.py +0 -0
  115. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v571_fixes.py +0 -0
  116. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v572_security.py +0 -0
  117. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v573_encrypted_export.py +0 -0
  118. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v573_security.py +0 -0
  119. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v576_gdpr.py +0 -0
  120. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v578_embedding.py +0 -0
  121. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v5812_bugfixes.py +0 -0
  122. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v583_security.py +0 -0
  123. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v584_adapters.py +0 -0
  124. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v585_benchmark.py +0 -0
  125. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v586_federated_mcp.py +0 -0
  126. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v590_features.py +0 -0
  127. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v592_features.py +0 -0
  128. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v593_features.py +0 -0
  129. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v595_features.py +0 -0
  130. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v600_forgetting_followup.py +0 -0
  131. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v600_import_timeline.py +0 -0
  132. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v600_multi_agent_formal.py +0 -0
  133. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v600_outcome_passport.py +0 -0
  134. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v600_skillpack_evolution.py +0 -0
  135. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v612_cascade_fixes.py +0 -0
  136. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v613_integrity.py +0 -0
  137. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v620_growth_governance.py +0 -0
  138. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v630_search_explain.py +0 -0
  139. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v631_scrypt.py +0 -0
  140. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v632_explain_interfaces.py +0 -0
  141. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v635_features.py +0 -0
  142. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v636_fixes.py +0 -0
  143. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v648_fixes.py +0 -0
  144. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v652_context_expansion.py +0 -0
  145. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v654_search_multi.py +0 -0
  146. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v655_temporal_norm.py +0 -0
  147. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/tests/test_v65_features.py +0 -0
  148. {mindforge_memory-6.5.5 → mindforge_memory-6.5.7}/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.5
3
+ Version: 6.5.7
4
4
  Summary: AI Agent 终身记忆系统 - 四层记忆架构 · 知识图谱 · 多模态支持
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/opok-ops/MindForge
@@ -36,11 +36,13 @@ 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.5: 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.7: no team, no funding, 1,305 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
40
+ >
41
+ > *Timeline note (v6.5.7):* "seven months" counts from project start (2026-03, pre-git prototyping era). Git history begins 2026-07-17 with the v5.7.x repository consolidation — earlier code lived outside this repo. The 416+ commits reflect consolidated history only.
40
42
 
41
43
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
42
44
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
43
- [![Version](https://img.shields.io/badge/version-6.5.5-green.svg)](https://github.com/opok-ops/MindForge/releases)
45
+ [![Version](https://img.shields.io/badge/version-6.5.7-green.svg)](https://github.com/opok-ops/MindForge/releases)
44
46
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
45
47
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
46
48
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -62,7 +64,7 @@ Key design decisions:
62
64
  - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
63
65
  - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
64
66
  - **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.
67
+ - **Open interfaces.** MCP server (90 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
66
68
 
67
69
  ## Quick Start
68
70
 
@@ -72,7 +74,7 @@ Install from source, then start writing and reading memories in minutes:
72
74
  git clone https://github.com/opok-ops/MindForge.git
73
75
  cd MindForge
74
76
  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
77
+ pip install -e ".[embedding]" # + vector path → full 6-way hybrid retrieval
76
78
  ```
77
79
 
78
80
  > 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 +108,15 @@ MindForge stats
106
108
  - **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
109
  - **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
110
  - 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).
111
+ - **LoCoMo full-suite, LLM-judged (v6.5.7, 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/`.
112
+ - LongMemEval — interface ready, not yet run (requires external LLM API key).
110
113
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
111
114
 
112
115
  ## What's New
113
116
 
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).
117
+ v6.1.3 – v6.5.7 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
118
+
119
+ - **v6.5.7 — 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
120
 
116
121
  - **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
122
 
@@ -131,7 +136,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
131
136
  - **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
137
  - **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
138
  - **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).
139
+ - **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
140
 
136
141
  ## Features
137
142
 
@@ -144,7 +149,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
144
149
 
145
150
  **Retrieval**
146
151
 
147
- - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
152
+ - **Six-way hybrid retrieval (real, as of v6.5.7)** — six recall paths fused into one ranked result set: vector, FTS5, TF-IDF, fuzzy (the four core paths, RRF-style max-fusion with per-path score breakdown via `search --explain`), **temporal anchoring** (query absolute dates / anchored relative phrases → windowed SQL recall; v6.5.7) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.5.7). Paths 5-6 run in "blind-spot fill" mode — they only add candidates the four core paths missed, never re-rank existing high-quality hits. Degradation is per-path and safe: encrypted stores skip temporal (ciphertext is not SQL-matchable), empty KG skips graph, missing time anchor degrades to absolute-date-only.
148
153
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
149
154
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
150
155
 
@@ -176,7 +181,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
176
181
 
177
182
  **Integration**
178
183
 
179
- - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
184
+ - **MCP server** — 90 tools, drop into Claude Code, OpenClaw, or any MCP client.
180
185
  - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
181
186
  - **REST API** — standard HTTP endpoints for non-Python applications.
182
187
  - **CLI** — 200+ commands with bash / zsh / fish completion.
@@ -188,7 +193,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
188
193
 
189
194
  ```
190
195
  ┌──────────────────────────────────────────────────────┐
191
- │ MindForge v6.5.5 │
196
+ │ MindForge v6.5.7 │
192
197
  │ Cognitive Layer Personality · KnowledgeGraph │
193
198
  │ MemoryEvolution · FederatedMemory │
194
199
  ├──────────────────────────────────────────────────────┤
@@ -6,11 +6,13 @@
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.5: 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.7: no team, no funding, 1,305 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
10
+ >
11
+ > *Timeline note (v6.5.7):* "seven months" counts from project start (2026-03, pre-git prototyping era). Git history begins 2026-07-17 with the v5.7.x repository consolidation — earlier code lived outside this repo. The 416+ commits reflect consolidated history only.
10
12
 
11
13
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
12
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
13
- [![Version](https://img.shields.io/badge/version-6.5.5-green.svg)](https://github.com/opok-ops/MindForge/releases)
15
+ [![Version](https://img.shields.io/badge/version-6.5.7-green.svg)](https://github.com/opok-ops/MindForge/releases)
14
16
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
15
17
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
16
18
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -32,7 +34,7 @@ Key design decisions:
32
34
  - **Structured memory.** Four tiers (sensory, short-term, long-term, permanent) with promotion and decay driven by the Ebbinghaus forgetting curve.
33
35
  - **Retrieval quality.** Six complementary retrieval paths fused into one ranked result, instead of a single vector index.
34
36
  - **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.
37
+ - **Open interfaces.** MCP server (90 tools), Python SDK, CLI with shell completion, and a REST API for non-Python consumers.
36
38
 
37
39
  ## Quick Start
38
40
 
@@ -42,7 +44,7 @@ Install from source, then start writing and reading memories in minutes:
42
44
  git clone https://github.com/opok-ops/MindForge.git
43
45
  cd MindForge
44
46
  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
47
+ pip install -e ".[embedding]" # + vector path → full 6-way hybrid retrieval
46
48
  ```
47
49
 
48
50
  > 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 +78,15 @@ MindForge stats
76
78
  - **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
79
  - **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
80
  - 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).
81
+ - **LoCoMo full-suite, LLM-judged (v6.5.7, 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/`.
82
+ - LongMemEval — interface ready, not yet run (requires external LLM API key).
80
83
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
81
84
 
82
85
  ## What's New
83
86
 
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).
87
+ v6.1.3 – v6.5.7 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
88
+
89
+ - **v6.5.7 — 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
90
 
86
91
  - **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
92
 
@@ -101,7 +106,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
101
106
  - **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
107
  - **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
108
  - **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).
109
+ - **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
110
 
106
111
  ## Features
107
112
 
@@ -114,7 +119,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
114
119
 
115
120
  **Retrieval**
116
121
 
117
- - **Six-way hybrid search** — vector, FTS5, TF-IDF, fuzzy, query expansion, and cross-encoder reranking fused into a single ranked result set.
122
+ - **Six-way hybrid retrieval (real, as of v6.5.7)** — six recall paths fused into one ranked result set: vector, FTS5, TF-IDF, fuzzy (the four core paths, RRF-style max-fusion with per-path score breakdown via `search --explain`), **temporal anchoring** (query absolute dates / anchored relative phrases → windowed SQL recall; v6.5.7) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.5.7). Paths 5-6 run in "blind-spot fill" mode — they only add candidates the four core paths missed, never re-rank existing high-quality hits. Degradation is per-path and safe: encrypted stores skip temporal (ciphertext is not SQL-matchable), empty KG skips graph, missing time anchor degrades to absolute-date-only.
118
123
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
119
124
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
120
125
 
@@ -146,7 +151,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
146
151
 
147
152
  **Integration**
148
153
 
149
- - **MCP server** — 87 tools, drop into Claude Code, OpenClaw, or any MCP client.
154
+ - **MCP server** — 90 tools, drop into Claude Code, OpenClaw, or any MCP client.
150
155
  - **Federated memory** — P2P sharing between agents with trust levels, ACLs, and conflict resolution.
151
156
  - **REST API** — standard HTTP endpoints for non-Python applications.
152
157
  - **CLI** — 200+ commands with bash / zsh / fish completion.
@@ -158,7 +163,7 @@ v6.1.3 – v6.4.9 shipped in ten days (2026-11-01 → 11-11; four releases in th
158
163
 
159
164
  ```
160
165
  ┌──────────────────────────────────────────────────────┐
161
- │ MindForge v6.5.5 │
166
+ │ MindForge v6.5.7 │
162
167
  │ Cognitive Layer Personality · KnowledgeGraph │
163
168
  │ MemoryEvolution · FederatedMemory │
164
169
  ├──────────────────────────────────────────────────────┤
@@ -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:
@@ -9,9 +9,10 @@ import hashlib
9
9
  import hmac
10
10
  import json
11
11
  import base64
12
+ import logging
12
13
  import threading # v5.4.7 修复 H-4:全局引擎初始化线程安全
13
14
  from pathlib import Path
14
- from typing import Optional, Tuple
15
+ from typing import Optional, Tuple, Callable
15
16
  from dataclasses import dataclass
16
17
 
17
18
  # 懒加载 cryptography:避免 CLI 启动时导入耗时(低配电脑 300ms+)
@@ -48,6 +49,8 @@ PBKDF2_ITERATIONS_LEGACY = 60_000
48
49
  SCRYPT_N_CURRENT = 65_536
49
50
  SCRYPT_R_CURRENT = 8
50
51
  SCRYPT_P_CURRENT = 1
52
+ # v6.5.6:KDF 成本下限(防降级攻击,见 KDFParams.from_dict)
53
+ _KDF_MIN_SCRYPT_N = 4096
51
54
 
52
55
  # 密钥文件格式版本(v6.3 = scrypt 默认;5.6 = PBKDF2 版本化;更早 = legacy)
53
56
  KEY_FILE_VERSION = "6.3"
@@ -100,6 +103,20 @@ class KDFParams:
100
103
  """
101
104
  algorithm = data.get("algorithm", KDF_ALGORITHM_LEGACY)
102
105
  iterations = int(data.get("iterations", PBKDF2_ITERATIONS_LEGACY))
106
+ # v6.5.6 安全修复:KDF 成本下限(防降级攻击)——密钥文件/密文头
107
+ # 是外部可篡改输入,攻击者把参数改小(如 iterations=100 或
108
+ # scrypt n=1024)可使暴力破解成本骤降。from_dict 是唯一入口,
109
+ # 此处强制下限:PBKDF2 ≥ 60k(legacy 下限)、scrypt n ≥ 4096。
110
+ # 真实历史数据全部满足(60k/600k/2^16),不影响兼容读取。
111
+ if algorithm == KDF_ALGORITHM_CURRENT:
112
+ if int(data.get("n", iterations)) < _KDF_MIN_SCRYPT_N:
113
+ raise SecurityError(
114
+ f"KDF 参数低于安全下限(scrypt n={data.get('n')} < "
115
+ f"{_KDF_MIN_SCRYPT_N}),疑似降级攻击,已拒绝")
116
+ elif iterations < PBKDF2_ITERATIONS_LEGACY:
117
+ raise SecurityError(
118
+ f"KDF 参数低于安全下限(PBKDF2 iterations={iterations} < "
119
+ f"{PBKDF2_ITERATIONS_LEGACY}),疑似降级攻击,已拒绝")
103
120
  if algorithm == KDF_ALGORITHM_CURRENT:
104
121
  # scrypt:iterations 承载 N(信息性);实际派生用 n/r/p
105
122
  n = int(data.get("n", iterations))
@@ -384,18 +401,37 @@ def _write_key_file(key_path: Path, salt: bytes, kdf_params: KDFParams,
384
401
  ["icacls", str(key_path), "/inheritance:r", "/grant:r", f"{username}:F"],
385
402
  capture_output=True, timeout=5, check=False
386
403
  )
387
- except Exception:
388
- pass # icacls 失败不阻断流程
404
+ except Exception as _acl_err:
405
+ # v6.5.6:ACL 失败不再静默(评审指出 Windows 密钥文件权限
406
+ # 失败无声 = 用户以为已加固实际继承默认 ACL)。仍不阻断
407
+ # 创建,但显式告警留痕。
408
+ logging.getLogger("core.encryption").warning(
409
+ "Windows 密钥文件 ACL 设置失败(%s)——文件权限为"
410
+ "继承默认值,建议手动 icacls 加固", _acl_err)
389
411
 
390
412
 
391
- def _verify_key_password(engine: EncryptionEngine, key_data: dict) -> bool:
413
+ def _verify_key_password(engine: EncryptionEngine, key_data: dict,
414
+ probe_decrypt: Optional[Callable[[EncryptionEngine], bool]] = None) -> bool:
392
415
  """使用验证令牌检查密码是否正确
393
416
 
394
417
  v5.6.0: 新密钥文件包含 verify_blob 字段。旧文件没有则跳过验证
395
418
  (向后兼容,避免老用户升级后被锁)。
419
+ v6.5.6 安全修复:legacy 密钥文件(无 verify_blob)在调用方提供
420
+ probe_decrypt 时进行试探解密验证——此前恒放行意味着 rekey 路径
421
+ 用错误旧密码也能把密钥文件重写成新密码(数据仍可用旧密钥解开,
422
+ 但新密钥从此对不上数据,构成可用性攻击面 + 双判官独立评审
423
+ (Qwen4-Max / Kimi K3.1)重叠指出的校验缺口)。
424
+ probe_decrypt 回调负责从库中取一条真实密文让 engine 试解;
425
+ 返回 True/False。无回调(None)时维持旧行为放行(调用方
426
+ 无验证材料,如空库)。
396
427
  """
397
428
  if "verify_blob" not in key_data:
398
- return True # legacy 密钥文件,无法验证,放行
429
+ if probe_decrypt is not None:
430
+ try:
431
+ return bool(probe_decrypt(engine))
432
+ except Exception:
433
+ return False
434
+ return True # legacy 且无验证材料:放行(旧行为)
399
435
 
400
436
  try:
401
437
  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
@@ -643,7 +663,10 @@ class MindForge:
643
663
  kg = self._knowledge_graph
644
664
  stats: Dict[str, Any] = {"entities_added": 0, "relations_added": 0, "memory_processed": 0}
645
665
  if memory_id:
646
- entry = self._storage.get_memory(memory_id)
666
+ # v6.5.7:内部管线读取不触发 auto-expire——add 流程的自动
667
+ # 建图会立即 get_memory,若条目带过去 expires_at 会被提前
668
+ # 移入回收站(TTL 语义破坏:list_expired/purge_expired 全空)
669
+ entry = self._storage.get_memory(memory_id, _auto_expire=False)
647
670
  if entry is None:
648
671
  raise ValueError(f"记忆不存在: {memory_id}")
649
672
  if str(getattr(entry, "privacy", "")) in ("PrivacyLevel.STRICT", "STRICT"):
@@ -811,7 +834,8 @@ class MindForge:
811
834
  session_id: str = "",
812
835
  use_embedding: bool = True,
813
836
  explain: bool = False,
814
- expand_context: int = 0):
837
+ expand_context: int = 0,
838
+ time_anchor: Optional[str] = None):
815
839
  """搜索记忆
816
840
 
817
841
  v5.4.5 新增 use_embedding 参数:
@@ -824,6 +848,13 @@ class MindForge:
824
848
  multi-hop 正确率 +27pt 的核心机制产品化)
825
849
  - 0(默认):行为与旧版完全一致
826
850
 
851
+ v6.5.7 新增 time_anchor 参数(六路检索的第 5 路时间锚):
852
+ - ISO 日期("2023-05-06"):query 中的相对时间词(yesterday/
853
+ 两周前)以此为锚换算绝对日期窗口,启用 temporal 召回路;
854
+ 同时 query 中的绝对日期直接成窗
855
+ - None(默认):仅 query 携带绝对日期时启用 temporal 路
856
+ (相对词无锚降级,v6.5.5 同款安全语义)
857
+
827
858
  v6.3.0 新增 explain 参数(检索可解释性):
828
859
  - True:每个返回的 MemoryChunk.score_breakdown 携带各召回路
829
860
  (tfidf/fts5/fuzzy/vector)原始分数、融合明细与最终胜出
@@ -855,6 +886,7 @@ class MindForge:
855
886
  use_embedding=use_embedding,
856
887
  explain=explain,
857
888
  expand_context=expand_context,
889
+ time_anchor=time_anchor,
858
890
  _update_access=False,
859
891
  _record_search=False,
860
892
  )