@furongjun1999/dsh-memory 0.9.22 → 0.9.23

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 (103) hide show
  1. package/CHANGELOG.en.md +404 -0
  2. package/CHANGELOG.md +45 -0
  3. package/README.en.md +240 -0
  4. package/README.md +3 -1
  5. package/docs/README.md +2 -0
  6. package/docs/en/README.md +190 -0
  7. package/docs/en/TRANSLATION.md +78 -0
  8. package/docs/en/TRANSLATION_MANIFEST.json +170 -0
  9. package/docs/en/TRANSLATION_REPORT.md +11 -0
  10. package/docs/en/dev/README.md +10 -0
  11. package/docs/en/dev/coding-testing.md +72 -0
  12. package/docs/en/dev/switch-matrix.md +10 -0
  13. package/docs/en/glossary.md +97 -0
  14. package/docs/en/harnesses/claude.md +100 -0
  15. package/docs/en/harnesses/codebuddy.md +93 -0
  16. package/docs/en/harnesses/codex.md +88 -0
  17. package/docs/en/harnesses/dsh.md +84 -0
  18. package/docs/en/harnesses/zcode.md +42 -0
  19. package/docs/en/mdcg/ccg.md +32 -0
  20. package/docs/en/mdcg/generated-docs.md +20 -0
  21. package/docs/en/mdcg/guardrail-charter.md +170 -0
  22. package/docs/en/mdcg/mcp-tool-names.md +43 -0
  23. package/docs/en/mdcg/multi-harness.md +43 -0
  24. package/docs/en/mdcg/recall-metadata.md +30 -0
  25. package/docs/en/mdcg/world-model-endpoint.md +379 -0
  26. package/docs/en/mdcg/write-aliases.md +130 -0
  27. package/docs/en/ops/README.md +11 -0
  28. package/docs/en/ops/environment-known-issues.md +244 -0
  29. package/docs/en/ops/install.md +72 -0
  30. package/docs/en/ops/operations-troubleshooting.md +86 -0
  31. package/docs/en/ops/permissions-review.md +79 -0
  32. package/docs/en/ops/release-governance.md +49 -0
  33. package/docs/en/ops/tool-name-migration.md +30 -0
  34. package/docs/en/ops/ui-install-troubleshooting.md +53 -0
  35. package/docs/en/standards/ai-coding-standard-checklist.md +71 -0
  36. package/docs/en/standards/ai-coding-standard-lingshu.md +47 -0
  37. package/docs/en/standards/ai-coding-standard.md +185 -0
  38. package/docs/en/ui/minimal.md +62 -0
  39. package/docs/mdcg/cogmap_ops.md +15 -15
  40. package/lib/hooks.d.ts +22 -0
  41. package/lib/hooks.js +124 -32
  42. package/lib/index.js +19 -3
  43. package/lib/lib/console_web.mjs +30 -3
  44. package/lib/lib/hook_audit.d.ts +3 -2
  45. package/lib/lib/hook_audit.js +14 -4
  46. package/lib/lib/mdcg_client.d.ts +5 -2
  47. package/lib/lib/mdcg_client.js +8 -4
  48. package/lib/lib/prompt_safety.d.ts +24 -0
  49. package/lib/lib/prompt_safety.js +77 -1
  50. package/lib/lib/token_store.js +5 -2
  51. package/lib/tools.js +5 -3
  52. package/md_cg/fsutil.py +80 -25
  53. package/md_cg/mcp_server.py +5761 -5557
  54. package/md_cg/mdcg.py +570 -73
  55. package/md_cg/mdcos.py +36 -11
  56. package/md_cg/nodefile.py +147 -23
  57. package/md_cg/op_table.py +14 -4
  58. package/md_cg/reconcile.py +9 -11
  59. package/md_cg/rollback.py +16 -1
  60. package/md_cg/scrub.py +94 -14
  61. package/md_cg/security.py +4 -2
  62. package/md_cg/test_cond_term_fold.py +183 -0
  63. package/md_cg/test_cond_terms_colon.py +348 -0
  64. package/md_cg/test_generation_guard.py +63 -42
  65. package/md_cg/test_issue362_neg_condition.py +44 -7
  66. package/md_cg/test_issue39_utf8_stdio.py +3 -3
  67. package/md_cg/test_issue444_scrub_evidence_plaintext.py +14 -8
  68. package/md_cg/test_issue677_flush_batch_io.py +139 -0
  69. package/md_cg/test_issue677_info_fast.py +82 -0
  70. package/md_cg/test_issue677_remember_dedupe.py +106 -0
  71. package/md_cg/test_issue712_tokens_sessions_read.py +199 -0
  72. package/md_cg/test_issue722_strict_conditions.py +96 -0
  73. package/md_cg/test_issue730_narrowing_audit.py +121 -0
  74. package/md_cg/test_issue733_verify_override.py +193 -0
  75. package/md_cg/test_issue733_verify_override_and_overwrite_inherit.py +315 -0
  76. package/md_cg/test_issue740_filelock_fd_leak.py +218 -0
  77. package/md_cg/test_issue741_content_hash_same_source.py +158 -0
  78. package/md_cg/test_issue747_slot_contradiction.py +125 -0
  79. package/md_cg/test_issue754_nested_root_guard.py +197 -0
  80. package/md_cg/test_issue757_index_hash_compare.py +85 -0
  81. package/md_cg/test_issue758_disk_hash_single.py +67 -0
  82. package/md_cg/test_issue759_twophase_hash.py +67 -0
  83. package/md_cg/test_n204_n205_n226_n227_n228_n229_exit_gates.py +545 -542
  84. package/md_cg/test_n209_verify_write_face_gates.py +5 -2
  85. package/md_cg/test_neg_condition_hits.py +336 -333
  86. package/md_cg/test_scrub_source_line_false_positive.py +64 -0
  87. package/md_cg/test_twophase.py +286 -286
  88. package/md_cg/tokens.py +55 -7
  89. package/md_cg/twophase.py +15 -6
  90. package/md_cg/writepipe.py +35 -3
  91. package/package.json +137 -134
  92. package/scripts/workspace_index.py +2 -0
  93. package/src/hooks.ts +139 -33
  94. package/src/index.ts +19 -3
  95. package/src/lib/console_web.mjs +30 -3
  96. package/src/lib/hook_audit.ts +15 -5
  97. package/src/lib/mdcg_client.ts +8 -4
  98. package/src/lib/prompt_safety.ts +73 -1
  99. package/src/lib/token_store.ts +5 -2
  100. package/src/tools.ts +5 -3
  101. package/ui/minimal/integrity.json +2 -2
  102. package/ui/minimal/payload/lib/lib/console_web.mjs +30 -3
  103. package/ui/minimal/payload/src/lib/console_web.mjs +30 -3
@@ -0,0 +1,67 @@
1
+ # -*- coding: utf-8 -*-
2
+ """issue #759:twophase 指纹与索引条目同源(不再先剥尾换行再哈希)。"""
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ import shutil
7
+ import sys
8
+ import tempfile
9
+
10
+ sys.stdout.reconfigure(encoding="utf-8", errors="replace")
11
+ _REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
12
+ sys.path.insert(0, _REPO)
13
+
14
+ from md_cg import nodefile, twophase # noqa: E402
15
+ from md_cg.mdcg import MdCG # noqa: E402
16
+
17
+ FAILS = []
18
+
19
+
20
+ def ok(cond, name, detail=""):
21
+ if cond:
22
+ print(" PASS " + name)
23
+ else:
24
+ print(" FAIL " + name + " " + str(detail)[:300])
25
+ FAILS.append(name)
26
+
27
+
28
+ BODY = ("# 功能名:x\n# 生效条件:y\n# 子功能:z\n# 执行:e\n"
29
+ "# 验证方式:test\n# 不适用条件:无\n\n正文")
30
+
31
+
32
+ def main():
33
+ print("=" * 68)
34
+ print("issue #759 · twophase 指纹与索引同源")
35
+ print("=" * 68)
36
+ tmp = tempfile.mkdtemp(prefix="iss759_")
37
+ try:
38
+ cg = MdCG(os.path.join(tmp, "r"), autoflush=1)
39
+ # A1:常盘形态(无尾换行入参)——begin 指纹 == 索引条目口径
40
+ tok = twophase.begin(cg, "n759a", BODY)
41
+ ok(tok.get("content_hash") == nodefile.content_hash(BODY),
42
+ "A1 begin 指纹 == content_hash(正文)(与索引同函数)", tok.get("content_hash"))
43
+ # A2:≥2 尾换行——不再被剥掉(旧口径会剥成 1 个尾换行,产生第二个指纹)
44
+ tok2 = twophase.begin(cg, "n759b", BODY + "\n\n")
45
+ ok(tok2.get("content_hash") == nodefile.content_hash(BODY + "\n\n"),
46
+ "A2 ≥2 尾换行指纹不被剥(旧行为会算成 1 个尾换行)")
47
+ ok(tok2.get("content_hash") != nodefile.content_hash(BODY + "\n"),
48
+ "A2b 与 1 尾换行形态不同值(同节点不再有两个指纹)")
49
+ # A3:落盘后判 judge 为 committed(同源自洽)
50
+ cg.add("n759a", BODY, layer="knowledge")
51
+ # intent 记录里 id 字段名与 _judge 读取口径不同(按 node_id 落账),这里直接按判定契约构造。
52
+ st, why = twophase._judge(cg, {"id": "n759a", "content_hash": tok["content_hash"]})
53
+ ok(st == twophase.STATUS_COMMITTED, "A3 begin→add→judge = committed", (st, why))
54
+ # A4(复核要求):**legacy intent 放行**——旧 begin 存的是 content_hash(_norm(x))。
55
+ ok(twophase._judge(cg, {"id": "n759a", "content_hash": nodefile.content_hash(twophase._norm(BODY))})[0]
56
+ == twophase.STATUS_COMMITTED,
57
+ "A4 legacy 口径 intent 仍判 committed(兼容分支不是死代码)")
58
+ cg.close()
59
+ finally:
60
+ shutil.rmtree(tmp, ignore_errors=True)
61
+ print()
62
+ print("issue #759:%d 项失败" % len(FAILS) if FAILS else "issue #759:全部通过")
63
+ return 1 if FAILS else 0
64
+
65
+
66
+ if __name__ == "__main__":
67
+ sys.exit(main())