mindforge-memory 6.5.12__tar.gz → 6.6.3__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 (156) hide show
  1. {mindforge_memory-6.5.12/mindforge_memory.egg-info → mindforge_memory-6.6.3}/PKG-INFO +11 -9
  2. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/README.md +10 -8
  3. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/api/server.py +48 -5
  4. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/cli/main.py +37 -0
  5. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/encryption.py +186 -29
  6. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/indexer.py +186 -54
  7. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/mindforge.py +405 -11
  8. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/query.py +398 -55
  9. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/storage.py +267 -91
  10. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/version.py +2 -2
  11. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/daemon/server.py +47 -4
  12. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/mcp/server.py +120 -56
  13. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/context_window.py +28 -6
  14. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/knowledge_graph.py +73 -65
  15. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/memory_compressor.py +20 -2
  16. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3/mindforge_memory.egg-info}/PKG-INFO +11 -9
  17. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge_memory.egg-info/SOURCES.txt +8 -0
  18. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v547_fixes.py +5 -2
  19. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v568_fixes.py +1 -1
  20. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v571_fixes.py +29 -5
  21. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v575_release_consistency.py +2 -2
  22. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v612_fixes.py +2 -2
  23. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v643_fixes.py +1 -1
  24. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v645_fixes.py +1 -1
  25. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v646_fixes.py +1 -1
  26. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v649_fixes.py +2 -2
  27. mindforge_memory-6.6.3/tests/test_v660_pending_guard.py +163 -0
  28. mindforge_memory-6.6.3/tests/test_v661_fixes.py +332 -0
  29. mindforge_memory-6.6.3/tests/test_v661_llm_judge.py +120 -0
  30. mindforge_memory-6.6.3/tests/test_v662_crypto.py +454 -0
  31. mindforge_memory-6.6.3/tests/test_v662_iface.py +429 -0
  32. mindforge_memory-6.6.3/tests/test_v662_search.py +370 -0
  33. mindforge_memory-6.6.3/tests/test_v662_stability.py +456 -0
  34. mindforge_memory-6.6.3/tests/test_v663_fixes.py +494 -0
  35. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/LICENSE +0 -0
  36. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/MindForge.py +0 -0
  37. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/__init__.py +0 -0
  38. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/__init__.py +0 -0
  39. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/claude_adapter.py +0 -0
  40. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/crewai_memory.py +0 -0
  41. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/generic_api.py +0 -0
  42. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/langgraph_store.py +0 -0
  43. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/adapters/openclaw_adapter.py +0 -0
  44. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/api/__init__.py +0 -0
  45. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/cli/__init__.py +0 -0
  46. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/__init__.py +0 -0
  47. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/embedding.py +0 -0
  48. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/paths.py +0 -0
  49. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/core/types.py +0 -0
  50. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/daemon/__init__.py +0 -0
  51. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/mcp/__init__.py +0 -0
  52. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/__init__.py +0 -0
  53. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/categorizer.py +0 -0
  54. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/conflict_detector.py +0 -0
  55. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/connectors.py +0 -0
  56. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/event_bus.py +0 -0
  57. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/evolution.py +0 -0
  58. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/experience.py +0 -0
  59. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/federated.py +0 -0
  60. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/federated_acl.py +0 -0
  61. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/follow_up.py +0 -0
  62. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/hybrid_search.py +0 -0
  63. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/importer.py +0 -0
  64. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/integrator.py +0 -0
  65. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/intent_router.py +0 -0
  66. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/memory_decay.py +0 -0
  67. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/memory_passport.py +0 -0
  68. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/multi_agent.py +0 -0
  69. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/multimodal.py +0 -0
  70. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/outcome_learning.py +0 -0
  71. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/personality.py +0 -0
  72. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/principled_forgetting.py +0 -0
  73. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/privacy.py +0 -0
  74. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/recall.py +0 -0
  75. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/session_focus.py +0 -0
  76. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/share_conflict.py +0 -0
  77. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/skill_extractor.py +0 -0
  78. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/skill_pack.py +0 -0
  79. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/timeline_viz.py +0 -0
  80. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge/modules/v6.py +0 -0
  81. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge_memory.egg-info/dependency_links.txt +0 -0
  82. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge_memory.egg-info/entry_points.txt +0 -0
  83. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge_memory.egg-info/requires.txt +0 -0
  84. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/mindforge_memory.egg-info/top_level.txt +0 -0
  85. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/pyproject.toml +0 -0
  86. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/setup.cfg +0 -0
  87. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/setup.py +0 -0
  88. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_core.py +0 -0
  89. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_security_hardening.py +0 -0
  90. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_trash_hard_delete.py +0 -0
  91. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v546_features.py +0 -0
  92. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v548_features.py +0 -0
  93. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v550_features.py +0 -0
  94. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v552_features.py +0 -0
  95. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v554_features.py +0 -0
  96. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v556_features.py +0 -0
  97. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v557_banner_insight_wal.py +0 -0
  98. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v557_security_fixes.py +0 -0
  99. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v557_webhook_sig_export.py +0 -0
  100. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v558_audit_fixes.py +0 -0
  101. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v558_features.py +0 -0
  102. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v560_decay_gc.py +0 -0
  103. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v560_kdf_versioning.py +0 -0
  104. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v560_module_coverage.py +0 -0
  105. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v561_security.py +0 -0
  106. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v562_p2_fixes.py +0 -0
  107. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v563_entry_coverage.py +0 -0
  108. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v563_perf_fixes.py +0 -0
  109. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v565_security.py +0 -0
  110. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v566_encrypted_search.py +0 -0
  111. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v567_security_fixes.py +0 -0
  112. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v569_fts_sync.py +0 -0
  113. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v570_coverage_expansion.py +0 -0
  114. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v570_drama_and_utils.py +0 -0
  115. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v570_encrypted_fallback.py +0 -0
  116. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v572_security.py +0 -0
  117. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v573_encrypted_export.py +0 -0
  118. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v573_security.py +0 -0
  119. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v576_bitemporal.py +0 -0
  120. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v576_gdpr.py +0 -0
  121. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v577_agent_governance.py +0 -0
  122. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v578_embedding.py +0 -0
  123. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v579_graph.py +0 -0
  124. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v580_experience.py +0 -0
  125. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v5812_bugfixes.py +0 -0
  126. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v583_security.py +0 -0
  127. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v584_adapters.py +0 -0
  128. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v585_benchmark.py +0 -0
  129. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v586_federated_mcp.py +0 -0
  130. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v590_features.py +0 -0
  131. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v592_features.py +0 -0
  132. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v593_features.py +0 -0
  133. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v595_features.py +0 -0
  134. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v600_forgetting_followup.py +0 -0
  135. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v600_import_timeline.py +0 -0
  136. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v600_multi_agent_formal.py +0 -0
  137. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v600_outcome_passport.py +0 -0
  138. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v600_skillpack_evolution.py +0 -0
  139. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v611_fixes.py +0 -0
  140. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v612_cascade_fixes.py +0 -0
  141. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v613_integrity.py +0 -0
  142. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v620_growth_governance.py +0 -0
  143. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v630_search_explain.py +0 -0
  144. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v631_scrypt.py +0 -0
  145. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v632_explain_interfaces.py +0 -0
  146. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v635_features.py +0 -0
  147. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v635_integration.py +0 -0
  148. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v636_fixes.py +0 -0
  149. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v648_fixes.py +0 -0
  150. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v652_context_expansion.py +0 -0
  151. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v654_search_multi.py +0 -0
  152. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v655_temporal_norm.py +0 -0
  153. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v656_security.py +0 -0
  154. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v657_six_path.py +0 -0
  155. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/tests/test_v65_features.py +0 -0
  156. {mindforge_memory-6.5.12 → mindforge_memory-6.6.3}/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.12
3
+ Version: 6.6.3
4
4
  Summary: AI Agent 终身记忆系统 - 四层记忆架构 · 知识图谱 · 多模态支持
5
5
  License: MIT
6
6
  Project-URL: Homepage, https://github.com/opok-ops/MindForge
@@ -36,13 +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.12: no team, no funding, 1,305 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.6.3: no team, no funding, 1,435 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
40
40
  >
41
- > *Timeline note (v6.5.12):* "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.
41
+ > *Timeline note (v6.6.0):* "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.
42
42
 
43
43
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
44
44
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
45
- [![Version](https://img.shields.io/badge/version-6.5.12-green.svg)](https://github.com/opok-ops/MindForge/releases)
45
+ [![Version](https://img.shields.io/badge/version-6.6.3-green.svg)](https://github.com/opok-ops/MindForge/releases)
46
46
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
47
47
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
48
48
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -108,15 +108,17 @@ MindForge stats
108
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).
109
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.
110
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.
111
- - **LoCoMo full-suite, LLM-judged (v6.5.12, 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/`.
111
+ - **LoCoMo full-suite, LLM-judged (v6.6.0, 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
112
  - LongMemEval — interface ready, not yet run (requires external LLM API key).
113
113
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
114
114
 
115
115
  ## What's New
116
116
 
117
- v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
117
+ v6.1.3 – v6.6.3 shipped in two weeks (2026-11-01 → 11-17), guarded by **1,400+ tests**.
118
118
 
119
- - **v6.5.12 — 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`).
119
+ - **v6.6.3 — ultimate bug-fix pack + retrieval enhancement for the named v6.6 targets** (2026-11-17). Three externally-found must-fix stability bugs closed (daemon dies on any invalid-UTF-8 input line — strict→replace decoding; REST double HTTP response after 413; lone-surrogate crash in the encrypted write path), plus rekey race honest-error and daemon error-dict forwarding. Temporal parsing overhauled: year-month queries (2024年5月 / 2024-05) no longer parse to None (full-month window now), English month-name dates (17 July 2023 / May 2023) parsed and matched on the evidence side, N-quantity windows actually multiply (two weeks ago had a 2-day window since v6.5.7), weekday expressions (last Wednesday / 上周三) resolved precisely, and Chinese phrases now flow through assembly-layer normalization. New retrieval layer (zero LLM, all rule-based): `search_chain` (hop1 evidence → entity extraction → hop2, the structural fix behind the multi-hop 25.2% bucket), path-aware graph retrieval (A-B shortest-path bridge evidence at 0.65), `decompose_two_hop` rule split, and `search_broad` open-domain entry. 36 new contract tests (`tests/test_v663_fixes.py`); full suite 1,477 green. LoCoMo re-judge pending an external API key.
120
+
121
+ - **v6.6.0 — 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`).
120
122
 
121
123
  - **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.
122
124
 
@@ -149,7 +151,7 @@ v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,3
149
151
 
150
152
  **Retrieval**
151
153
 
152
- - **Six-way hybrid retrieval (real, as of v6.5.12)** — 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.12) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.5.12). 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.
154
+ - **Six-way hybrid retrieval (real, as of v6.6.0)** — 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.6.0) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.6.0). 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.
153
155
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
154
156
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
155
157
 
@@ -193,7 +195,7 @@ v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,3
193
195
 
194
196
  ```
195
197
  ┌──────────────────────────────────────────────────────┐
196
- │ MindForge v6.5.12 │
198
+ │ MindForge v6.6.3 │
197
199
  │ Cognitive Layer Personality · KnowledgeGraph │
198
200
  │ MemoryEvolution · FederatedMemory │
199
201
  ├──────────────────────────────────────────────────────┤
@@ -6,13 +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.12: no team, no funding, 1,305 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.6.3: no team, no funding, 1,435 passing tests. [Read the journey →](https://opok-ops.github.io/MindForge/#developer)
10
10
  >
11
- > *Timeline note (v6.5.12):* "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.
11
+ > *Timeline note (v6.6.0):* "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.
12
12
 
13
13
  [![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
14
14
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
15
- [![Version](https://img.shields.io/badge/version-6.5.12-green.svg)](https://github.com/opok-ops/MindForge/releases)
15
+ [![Version](https://img.shields.io/badge/version-6.6.3-green.svg)](https://github.com/opok-ops/MindForge/releases)
16
16
  [![Stars](https://img.shields.io/github/stars/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/stargazers)
17
17
  [![Forks](https://img.shields.io/github/forks/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/forks)
18
18
  [![Open Issues](https://img.shields.io/github/issues/opok-ops/MindForge.svg)](https://github.com/opok-ops/MindForge/issues)
@@ -78,15 +78,17 @@ MindForge stats
78
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).
79
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.
80
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.
81
- - **LoCoMo full-suite, LLM-judged (v6.5.12, 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/`.
81
+ - **LoCoMo full-suite, LLM-judged (v6.6.0, 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
82
  - LongMemEval — interface ready, not yet run (requires external LLM API key).
83
83
  - TF-IDF degraded mode process memory at 100k: ~700 MB. Index LRU cap: 100,000 docs (MINDFORGE_INDEX_MAX_DOCS).
84
84
 
85
85
  ## What's New
86
86
 
87
- v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,300+ tests**.
87
+ v6.1.3 – v6.6.3 shipped in two weeks (2026-11-01 → 11-17), guarded by **1,400+ tests**.
88
88
 
89
- - **v6.5.12 — 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`).
89
+ - **v6.6.3 — ultimate bug-fix pack + retrieval enhancement for the named v6.6 targets** (2026-11-17). Three externally-found must-fix stability bugs closed (daemon dies on any invalid-UTF-8 input line — strict→replace decoding; REST double HTTP response after 413; lone-surrogate crash in the encrypted write path), plus rekey race honest-error and daemon error-dict forwarding. Temporal parsing overhauled: year-month queries (2024年5月 / 2024-05) no longer parse to None (full-month window now), English month-name dates (17 July 2023 / May 2023) parsed and matched on the evidence side, N-quantity windows actually multiply (two weeks ago had a 2-day window since v6.5.7), weekday expressions (last Wednesday / 上周三) resolved precisely, and Chinese phrases now flow through assembly-layer normalization. New retrieval layer (zero LLM, all rule-based): `search_chain` (hop1 evidence → entity extraction → hop2, the structural fix behind the multi-hop 25.2% bucket), path-aware graph retrieval (A-B shortest-path bridge evidence at 0.65), `decompose_two_hop` rule split, and `search_broad` open-domain entry. 36 new contract tests (`tests/test_v663_fixes.py`); full suite 1,477 green. LoCoMo re-judge pending an external API key.
90
+
91
+ - **v6.6.0 — 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`).
90
92
 
91
93
  - **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.
92
94
 
@@ -119,7 +121,7 @@ v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,3
119
121
 
120
122
  **Retrieval**
121
123
 
122
- - **Six-way hybrid retrieval (real, as of v6.5.12)** — 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.12) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.5.12). 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.
124
+ - **Six-way hybrid retrieval (real, as of v6.6.0)** — 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.6.0) and **knowledge-graph adjacency** (entity match → 2-hop relation walk → memory back-references; v6.6.0). 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.
123
125
  - **Knowledge graph** — automatic entity and relation extraction, path finding, and associative recall.
124
126
  - **Weighted recall** — multi-factor scoring (coverage, importance, access frequency, time decay) instead of similarity alone.
125
127
 
@@ -163,7 +165,7 @@ v6.1.3 – v6.5.12 shipped in two weeks (2026-11-01 → 11-14), guarded by **1,3
163
165
 
164
166
  ```
165
167
  ┌──────────────────────────────────────────────────────┐
166
- │ MindForge v6.5.12 │
168
+ │ MindForge v6.6.3 │
167
169
  │ Cognitive Layer Personality · KnowledgeGraph │
168
170
  │ MemoryEvolution · FederatedMemory │
169
171
  ├──────────────────────────────────────────────────────┤
@@ -109,6 +109,8 @@ class _RateLimiter:
109
109
  self.max_requests = max_requests
110
110
  self.window = window_seconds
111
111
  self._requests = defaultdict(list)
112
+ # v6.6.2(F9):每 IP 最近一次请求时间,逐出按「最久未活跃」排序
113
+ self._last_seen = {}
112
114
  self._lock = threading.Lock()
113
115
 
114
116
  def check(self, client_ip: str) -> bool:
@@ -120,21 +122,36 @@ class _RateLimiter:
120
122
  """
121
123
  now = time.time()
122
124
  with self._lock:
125
+ self._last_seen[client_ip] = now
126
+ # v6.6.2(F9):仅当该 IP 此前已被跟踪且历史全部过期时才清
127
+ # last_seen——新访客首次 check 时 times 也为空,不能误删刚写入
128
+ # 的时间戳,否则逐出排序会把新 IP 当成「最久未活动」。
129
+ was_tracked = client_ip in self._requests
123
130
  times = [t for t in self._requests[client_ip] if now - t < self.window]
124
131
  # 过滤后为空 → 该 IP 历史已过期,删除空键避免常驻
125
132
  if not times:
126
133
  self._requests.pop(client_ip, None)
134
+ if was_tracked:
135
+ self._last_seen.pop(client_ip, None)
127
136
  else:
128
137
  self._requests[client_ip] = times
129
138
  if len(times) >= self.max_requests:
130
139
  return False
131
140
  times.append(now)
132
141
  self._requests[client_ip] = times
133
- # IP 总数上限:丢弃最久未活动的键
142
+ # IP 总数上限:丢弃最久未活动的键。
143
+ # v6.6.2(F9)修复:此前按 dict 插入序弹出前 N 个键——更新计数
144
+ # 不会改变已有键的位置,长期活跃的旧 IP 反而先被逐出,且逐出即
145
+ # 计数清零构成 fail-open。现按 last_seen 逐出真正最久未活动者,
146
+ # 两个字典同步删除。
134
147
  if len(self._requests) > self._MAX_TRACKED_IPS:
135
148
  excess = len(self._requests) - self._MAX_TRACKED_IPS
136
- for stale_ip in list(self._requests.keys())[:excess]:
149
+ stale_ips = sorted(
150
+ self._requests, key=lambda ip: self._last_seen.get(ip, 0.0)
151
+ )[:excess]
152
+ for stale_ip in stale_ips:
137
153
  self._requests.pop(stale_ip, None)
154
+ self._last_seen.pop(stale_ip, None)
138
155
  return True
139
156
 
140
157
 
@@ -427,6 +444,12 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
427
444
  self.end_headers()
428
445
  self.wfile.write(body)
429
446
 
447
+ # v6.6.3(M2):_read_body 的「已自行发送响应」哨兵——此前 413 分支
448
+ # 与 body 非法分支共用 None 返回值,调用方无法区分,对超限请求连发
449
+ # 413 + 400 两个完整 HTTP 响应;keep-alive 客户端/反向代理会把第二
450
+ # 个响应错配到下一个请求,静默丢请求。
451
+ _BODY_RESPONSE_SENT = object()
452
+
430
453
  def _read_body(self):
431
454
  # v5.6.2 安全修复:Content-Length 非数值时返回 None,不抛异常
432
455
  try:
@@ -463,7 +486,8 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
463
486
  },
464
487
  413,
465
488
  )
466
- return None
489
+ # v6.6.3(M2):已回 413,返回哨兵,调用方不再补发 400。
490
+ return self._BODY_RESPONSE_SENT
467
491
  if content_length < 0:
468
492
  return None
469
493
  raw = self.rfile.read(content_length)
@@ -1045,6 +1069,10 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
1045
1069
 
1046
1070
  try:
1047
1071
  body = self._read_body()
1072
+ # v6.6.3(M2):超限分支已在 _read_body 内回 413,此处直接返回,
1073
+ # 不再对同一连接补发第二个响应。
1074
+ if body is self._BODY_RESPONSE_SENT:
1075
+ return
1048
1076
  if body is None:
1049
1077
  self._send_json({"error": "Invalid JSON body"}, 400)
1050
1078
  return
@@ -1110,11 +1138,23 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
1110
1138
  "backup": res.get("backup")})
1111
1139
  elif path == "/api/compress":
1112
1140
  # v6.5.6:REST 对齐记忆压缩入口
1141
+ # v6.6.2(F7)修复:threshold/min_cluster_size 类型非法时回
1142
+ # 400——此前 ValueError 直接落入 do_POST 顶层 except 回 500,
1143
+ # 与同文件其他端点的 400 口径不一致,错误日志也无上下文。
1144
+ try:
1145
+ threshold = float(body.get("threshold", 0.75))
1146
+ min_cluster_size = int(body.get("min_cluster_size", 3))
1147
+ except (TypeError, ValueError):
1148
+ self._send_json(
1149
+ {"error": "'threshold' must be a number and "
1150
+ "'min_cluster_size' must be an integer"},
1151
+ 400)
1152
+ return
1113
1153
  res = self.mindforge.compress_memories(
1114
- threshold=float(body.get("threshold", 0.75)),
1154
+ threshold=threshold,
1115
1155
  dry_run=bool(body.get("dry_run", False)),
1116
1156
  categories=body.get("categories"),
1117
- min_cluster_size=int(body.get("min_cluster_size", 3)))
1157
+ min_cluster_size=min_cluster_size)
1118
1158
  self._send_json(res)
1119
1159
  elif path == "/api/agent/forget":
1120
1160
  mid = body.get("id", "")
@@ -1403,6 +1443,9 @@ class MindForgeAPIHandler(BaseHTTPRequestHandler):
1403
1443
 
1404
1444
  try:
1405
1445
  body = self._read_body()
1446
+ # v6.6.3(M2):同 do_POST——413 已在 _read_body 内回过。
1447
+ if body is self._BODY_RESPONSE_SENT:
1448
+ return
1406
1449
  if body is None:
1407
1450
  self._send_json({"error": "Invalid JSON body"}, 400)
1408
1451
  return
@@ -1375,6 +1375,26 @@ def cmd_daemon(args):
1375
1375
  """
1376
1376
  from mindforge.daemon.server import run_daemon
1377
1377
 
1378
+ # v6.6.2(F3)修复:加密库 fail-closed。key_file 存在即视为加密库
1379
+ # (判定与 _get_memory 一致),而 daemon 主循环不支持密码解锁;此前
1380
+ # 静默以 encrypted=False 打开加密库——查询全部走明文列返回空结果,
1381
+ # 表现为「数据丢失」且无任何报错,若此时 add 还会产生明文/混杂数据。
1382
+ key_file_path = Path(args.key_file) if args.key_file else None
1383
+ if key_file_path and key_file_path.exists():
1384
+ print(c(
1385
+ f"❌ 检测到密钥文件({args.key_file}):该库为加密库,daemon 模式暂不支持密码解锁。",
1386
+ "red",
1387
+ ))
1388
+ print(c(
1389
+ " 为避免静默以明文模式打开加密库(查询空结果/混杂数据),已拒绝启动。",
1390
+ "yellow",
1391
+ ))
1392
+ print(c(
1393
+ " 请改用其他子命令(会提示输入密码),或去掉 --key-file 指向明文库。",
1394
+ "yellow",
1395
+ ))
1396
+ return 1
1397
+
1378
1398
  return run_daemon(
1379
1399
  db_path=args.db_path,
1380
1400
  key_file=args.key_file,
@@ -3611,6 +3631,15 @@ def main(argv=None):
3611
3631
  _stream.reconfigure(encoding="utf-8")
3612
3632
  except (ValueError, AttributeError, OSError):
3613
3633
  pass
3634
+ # v6.6.2(F3 附带):stdin 同样强制 UTF-8 解码——daemon 子命令把
3635
+ # stdin 转交给行式 JSON 主循环,cp936/cp1252 控制台会把 UTF-8 行读成乱码。
3636
+ # v6.6.3(M1):errors strict → replace,与 daemon/server.py 同药——strict
3637
+ # 下坏字节行在迭代解码处抛 UnicodeDecodeError 逃出主循环、杀死进程。
3638
+ try:
3639
+ if hasattr(sys.stdin, "reconfigure"):
3640
+ sys.stdin.reconfigure(encoding="utf-8", errors="replace")
3641
+ except (ValueError, AttributeError, OSError):
3642
+ pass
3614
3643
  parser = argparse.ArgumentParser(
3615
3644
  prog="mindforge",
3616
3645
  description=f"MindForge v{__version__} - AI Agent 终身记忆系统",
@@ -7558,6 +7587,14 @@ def cmd_import_chat(args):
7558
7587
  """功能 1:一键导入记忆(ChatGPT/Claude 导出,v6.0.0)"""
7559
7588
  cm = _get_memory(args)
7560
7589
  path = args.input
7590
+ # v6.6.2(F10)修复:接入 _safe_import_path 统一校验(存在性/允许扩展名/
7591
+ # 100MB 上限),与其他 6 处导入命令口径一致;此前直接 open 任意路径。
7592
+ try:
7593
+ path = _safe_import_path(path)
7594
+ except (ValueError, OSError) as e:
7595
+ print(c(f"❌ 导入路径校验失败: {e}", "red"))
7596
+ cm.close()
7597
+ return 1
7561
7598
  # v6.1.2:导入前先按体积护栏拦截。importer 的模块文档自 v6.0.0 起就承诺
7562
7599
  # 「MAX_EXPORT_SIZE = 200MB 超大导出直接拒绝」,但该常量从未被引用,
7563
7600
  # 几百 MB 的导出文件会直接被 json.load 整份读进内存。