@furongjun1999/dsh-memory 0.9.8 → 0.9.10

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 (57) hide show
  1. package/README.md +1 -1
  2. package/codebuddy/CODEBUDDY.md +4 -0
  3. package/docs/README.md +3 -0
  4. package/docs//350/247/204/350/214/203/AI/347/274/226/347/250/213/351/200/232/347/224/250/350/247/204/350/214/203.md +4 -0
  5. package/dsh/cordis.yml.example +2 -2
  6. package/lib/hooks.d.ts +11 -1
  7. package/lib/hooks.js +58 -3
  8. package/lib/index.d.ts +1 -1
  9. package/lib/index.js +2 -2
  10. package/lib/init.js +11 -2
  11. package/lib/lib/hook_audit.d.ts +3 -0
  12. package/lib/lib/hook_audit.js +37 -0
  13. package/md_cg/autonomy.py +1 -1
  14. package/md_cg/config_registry.py +329 -329
  15. package/md_cg/config_registry_bulk.py +2 -0
  16. package/md_cg/config_render.py +27 -0
  17. package/md_cg/config_validate.py +10 -8
  18. package/md_cg/conflict_surface.py +127 -0
  19. package/md_cg/mcp_server.py +105 -8
  20. package/md_cg/mdcg.py +60 -2
  21. package/md_cg/mdcos.py +61 -6
  22. package/md_cg/pooling.py +487 -485
  23. package/md_cg/qmd_llm.py +334 -334
  24. package/md_cg/reach.py +10 -4
  25. package/md_cg/sleep.py +2 -2
  26. package/md_cg/sustain.py +3 -3
  27. package/md_cg/test_auto_defaults.py +463 -463
  28. package/md_cg/test_autonomy_emotion.py +328 -328
  29. package/md_cg/test_bm25_default.py +56 -0
  30. package/md_cg/test_c3_transient_read_negative.py +797 -793
  31. package/md_cg/test_conflict_surface.py +75 -0
  32. package/md_cg/test_conflict_value_untrusted.py +63 -0
  33. package/md_cg/test_exact_text_cache.py +3 -0
  34. package/md_cg/test_hotcache_tool.py +121 -0
  35. package/md_cg/test_index_snapshot_fastpath.py +72 -0
  36. package/md_cg/test_issue274_read_node_id_none.py +29 -6
  37. package/md_cg/test_issue561_pending_review.py +89 -5
  38. package/md_cg/test_issue578_service_info_gate.py +264 -0
  39. package/md_cg/test_p3_legacy_closure.py +5 -2
  40. package/md_cg/test_p43_pooling.py +419 -412
  41. package/md_cg/test_reach.py +5 -1
  42. package/md_cg/test_reach_exits.py +54 -0
  43. package/md_cg/test_reach_single_char.py +74 -0
  44. package/md_cg/test_search_bm25_default.py +60 -0
  45. package/md_cg/test_sleep_p1.py +1032 -1032
  46. package/md_cg/test_untrusted_audit.py +55 -0
  47. package/md_cg/test_untrusted_classifier.py +42 -0
  48. package/md_cg/test_untrusted_enforcement.py +66 -0
  49. package/md_cg/untrusted.py +45 -0
  50. package/md_cg/untrusted_audit.py +87 -0
  51. package/md_cg/value_conflict.py +71 -0
  52. package/package.json +7 -7
  53. package/src/hooks.ts +986 -932
  54. package/src/index.ts +2 -2
  55. package/src/init.ts +7 -2
  56. package/src/lib/hook_audit.ts +32 -0
  57. package/zcode/AGENTS.md +4 -0
@@ -0,0 +1,56 @@
1
+ # -*- coding: utf-8 -*-
2
+ """BM25 默认开 + 能力降级守卫。
3
+
4
+ B1 前提:search_rrf 只存在于 MdCGOS/MdCGSecure,纯 MdCG 没有(guard 的由来)
5
+ B2 检索面:mdcg_search 未传 bm25 时走 BM25 路且不报错(MdCGSecure 上)
6
+ B3 降级:cg 无 search_rrf 时不得抛 AttributeError(用最小伪造对象验证同一判据表达式)
7
+ B4 recall 面仍 opt-in:mdcg_recall 未传 bm25 时正常返回(不因默认改词法而崩)
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import tempfile
12
+
13
+ from .mdcg import MdCG
14
+ from .mdcos import MdCGSecure, MdCGOS
15
+ from .mcp_server import call_tool
16
+
17
+
18
+ def main():
19
+ ok = 0
20
+ bad = 0
21
+
22
+ def chk(cond, label):
23
+ nonlocal ok, bad
24
+ if cond:
25
+ ok += 1
26
+ print(" PASS", label)
27
+ else:
28
+ bad += 1
29
+ print(" FAIL", label)
30
+
31
+ chk(hasattr(MdCGOS, "search_rrf") and hasattr(MdCGSecure, "search_rrf"), "B1 MdCGOS/MdCGSecure 有 search_rrf")
32
+ chk(not hasattr(MdCG, "search_rrf"), "B1b 纯 MdCG 没有 search_rrf(guard 前提成立)")
33
+
34
+ class NoRrf:
35
+ def search(self, *a, **kw):
36
+ return ([], {})
37
+
38
+ fake = NoRrf()
39
+ chk(not hasattr(fake, "search_rrf"), "B3 无该能力的对象可被 hasattr 判出(表达式不抛错)")
40
+
41
+ root = tempfile.mkdtemp(prefix="bm25_def_")
42
+ cg = MdCGSecure(root)
43
+ cg.add("m1", "生产环境 连接池 32 个", layer="knowledge")
44
+ out = call_tool(cg, "mdcg_search", {"query": "连接池", "k": 5})
45
+ chk(isinstance(out, dict) and "results" in out, "B2 mdcg_search 缺省(BM25 开)可正常返回")
46
+
47
+ out2 = call_tool(cg, "mdcg_recall", {"query": "连接池", "k": 5})
48
+ chk(isinstance(out2, (dict, list)), "B4 mdcg_recall 缺省仍可用(recall 面 opt-in)")
49
+
50
+ print("=" * 60)
51
+ print("BM25 默认开守卫:%d 通过 / %d 失败" % (ok, bad))
52
+ return 0 if bad == 0 else 1
53
+
54
+
55
+ if __name__ == "__main__":
56
+ raise SystemExit(main())