@furongjun1999/dsh-memory 0.9.13 → 0.9.14
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.
- package/README.md +6 -3
- package/codebuddy/CODEBUDDY.md +8 -3
- package/codebuddy/README.md +92 -92
- package/docs/discipline/templates/zcode-user.md.tmpl +52 -52
- package/docs//345/267/245/344/275/234/347/272/252/345/276/213_/350/256/244/347/237/245/345/233/276/346/235/241/347/233/256_v1.1.json +488 -461
- 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_/347/201/265/346/236/242/351/200/202/351/205/215.md +45 -45
- package/dsh/README.md +82 -82
- package/lib/hooks.js +28 -20
- package/md_cg/conformance_core.py +28 -0
- package/md_cg/consistency.py +9 -2
- package/md_cg/mcp_server.py +86 -9
- package/md_cg/mdcg.py +113 -11
- package/md_cg/mdcos.py +47 -11
- package/md_cg/nodefile.py +39 -1
- package/md_cg/op_table.py +1 -0
- package/md_cg/relations.py +91 -0
- package/md_cg/scrub.py +20 -3
- package/md_cg/test_issue218_postcondition_value_blind.py +4 -2
- package/md_cg/test_issue650_658_f26.py +98 -0
- package/md_cg/test_issue659_r26_batch2.py +74 -0
- package/md_cg/test_issue665_scrub_process_records.py +59 -0
- package/md_cg/test_issue669_ccg_empty_colon.py +69 -0
- package/md_cg/test_issue672_validity_scope.py +47 -0
- package/md_cg/version_anchor.py +160 -0
- package/package.json +2 -2
- package/src/hooks.ts +28 -20
- package/zcode/AGENTS.md +8 -3
- package/zcode/README.md +41 -41
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""R26 清单(issue #659)第二批守卫:min_score 单点 / exclude_doc 类型与超取。
|
|
3
|
+
|
|
4
|
+
覆盖 F26-06(inf 让检索恒空)、F26-12(两处开关判据相反)、F26-14(门槛读数不可见)、
|
|
5
|
+
F26-15(负覆盖尾绕过门槛)、F26-28(字符串 "false" 反向开启)、F26-11(k 截断后过滤吃配额)。
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import tempfile
|
|
11
|
+
|
|
12
|
+
from . import mcp_server
|
|
13
|
+
from .mdcg import parse_min_score
|
|
14
|
+
from .mdcos import MdCGOS
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main():
|
|
18
|
+
ok = bad = 0
|
|
19
|
+
|
|
20
|
+
def chk(cond, label):
|
|
21
|
+
nonlocal ok, bad
|
|
22
|
+
if cond:
|
|
23
|
+
ok += 1
|
|
24
|
+
print(" PASS", label)
|
|
25
|
+
else:
|
|
26
|
+
bad += 1
|
|
27
|
+
print(" FAIL", label)
|
|
28
|
+
|
|
29
|
+
# ---------- F26-06 / F26-12:解析单点 ----------
|
|
30
|
+
chk(parse_min_score("inf", 0.0) == (0.0, "invalid"), "F26-06 inf 判非法并回落默认(不再全量滤空)")
|
|
31
|
+
chk(parse_min_score("-inf", 0.0) == (0.0, "invalid"), "F26-06 -inf 同样判非法")
|
|
32
|
+
chk(parse_min_score("nan", 0.0) == (0.0, "invalid"), "F26-12 nan 判非法(此前静默等同关闭)")
|
|
33
|
+
chk(parse_min_score("0.01", 0.0) == (0.01, "ok"), "F26-06 正常值原样解析")
|
|
34
|
+
chk(parse_min_score(None, -1.0) == (-1.0, "default"), "F26-12 缺省取各自默认(recall 面 -1)")
|
|
35
|
+
|
|
36
|
+
# ---------- F26-28:布尔强制 ----------
|
|
37
|
+
chk(mcp_server._as_flag("false") is False, "F26-28 字符串 false 不再反向开启")
|
|
38
|
+
chk(mcp_server._as_flag("true") is True, "F26-28 字符串 true 判真")
|
|
39
|
+
chk(mcp_server._as_flag(0) is False and mcp_server._as_flag(1) is True, "F26-28 数字按 0/非 0")
|
|
40
|
+
items = [{"id": "doc_1"}, {"id": "mem_1"}]
|
|
41
|
+
kept, dropped = mcp_server.drop_doc_nodes(items, lambda x: x["id"], "false")
|
|
42
|
+
chk(len(kept) == 2 and dropped == 0, "F26-28 传 \"false\" 时不过滤(旧实现会丢掉 doc_1)")
|
|
43
|
+
|
|
44
|
+
# ---------- F26-06 端到端:inf 不再把结果滤空 ----------
|
|
45
|
+
root = tempfile.mkdtemp(prefix="f659_")
|
|
46
|
+
cg = MdCGOS(root)
|
|
47
|
+
cg.add("mem_alpha", "# 功能名:甲\n# 执行:乙", layer="knowledge", tags=["t1"],
|
|
48
|
+
importance=0.6, verification_basis="test")
|
|
49
|
+
cg.flush()
|
|
50
|
+
# 默认读路径是 search_rrf(cg(op=read) bm25=True 走它),故在此验端到端。
|
|
51
|
+
os.environ["MDCG_MIN_SCORE"] = "inf"
|
|
52
|
+
try:
|
|
53
|
+
res, meta = cg.search_rrf("甲", paths=("bm25",), k=5)
|
|
54
|
+
chk(len(res) >= 1, "F26-06 MIN_SCORE=inf 时检索仍有结果(旧实现恒空,实际 %d 条)" % len(res))
|
|
55
|
+
chk(meta.get("min_score_input") == "invalid", "F26-06 非法输入如实记账 min_score_input=invalid")
|
|
56
|
+
finally:
|
|
57
|
+
del os.environ["MDCG_MIN_SCORE"]
|
|
58
|
+
|
|
59
|
+
# ---------- F26-14:门槛读数可观测 ----------
|
|
60
|
+
os.environ["MDCG_MIN_SCORE"] = "0.01"
|
|
61
|
+
try:
|
|
62
|
+
res, meta = cg.search_rrf("甲", paths=("bm25",), k=5)
|
|
63
|
+
chk(meta.get("min_score") == 0.01, "F26-14 生效门槛值透出到 meta(此前写入 stat 无人读)")
|
|
64
|
+
chk("min_score_dropped" in meta, "F26-14 被丢弃条数同样可观测")
|
|
65
|
+
finally:
|
|
66
|
+
del os.environ["MDCG_MIN_SCORE"]
|
|
67
|
+
|
|
68
|
+
print("=" * 56)
|
|
69
|
+
print("R26 第二批守卫:%d 通过 / %d 失败" % (ok, bad))
|
|
70
|
+
return 0 if bad == 0 else 1
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
if __name__ == "__main__":
|
|
74
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""scrub 过程记录误报守卫(issue #665 / #40 残留面)。"""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
|
|
7
|
+
from . import scrub
|
|
8
|
+
from .mdcos import MdCGOS
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
ok = bad = 0
|
|
13
|
+
|
|
14
|
+
def chk(cond, label):
|
|
15
|
+
nonlocal ok, bad
|
|
16
|
+
if cond:
|
|
17
|
+
ok += 1
|
|
18
|
+
print(" PASS", label)
|
|
19
|
+
else:
|
|
20
|
+
bad += 1
|
|
21
|
+
print(" FAIL", label)
|
|
22
|
+
|
|
23
|
+
# 1) _kv_pairs:列表行不抽键;rej 的两个固定字段也不抽
|
|
24
|
+
rev = "\n".join([
|
|
25
|
+
"# 功能名:裁决记录",
|
|
26
|
+
"- 提案:prop_aaa",
|
|
27
|
+
"- 轮次:1 裁决:accept",
|
|
28
|
+
])
|
|
29
|
+
chk(scrub._kv_pairs(rev) == {}, "#665 列表行不抽键(rev 记录零键)")
|
|
30
|
+
rej = "\n".join(["假设:Claude Desktop", "否决原因:V1 未过", "验证:test"])
|
|
31
|
+
chk(scrub._kv_pairs(rej) == {}, "#665 rej 固定字段已在 _SKIP_KEYS")
|
|
32
|
+
|
|
33
|
+
# 2) 真矛盾仍能被抽到(阴性对照:判据非恒假)
|
|
34
|
+
real = "\n".join(["端口:8080", "协议:tcp"])
|
|
35
|
+
chk(scrub._kv_pairs(real) == {"端口": "8080", "协议": "tcp"},
|
|
36
|
+
"#665 普通断言行仍可抽键(判据非恒假)")
|
|
37
|
+
|
|
38
|
+
# 3) audit 端到端:两条 rev 记录不得互判「同键不同值」
|
|
39
|
+
cg = MdCGOS(tempfile.mkdtemp(prefix="f665_"))
|
|
40
|
+
for i, prop in enumerate(("prop_aaa", "prop_bbb")):
|
|
41
|
+
cg.add("rev_x%d_r1" % i, "\n".join([
|
|
42
|
+
"# 功能名:裁决记录 %d" % i,
|
|
43
|
+
"- 提案:" + prop,
|
|
44
|
+
"- 轮次:1 裁决:accept",
|
|
45
|
+
]), layer="contextual", role="tool-output",
|
|
46
|
+
tags=["review"], importance=0.4, verification_basis="test")
|
|
47
|
+
cg.flush()
|
|
48
|
+
res = scrub.audit(cg, min_severity="info")
|
|
49
|
+
kinds = [i["kind"] for i in res.get("issues", [])
|
|
50
|
+
if i["node_id"].startswith("rev_x")]
|
|
51
|
+
chk("contradiction" not in kinds,
|
|
52
|
+
"#665 过程记录不再被判同键不同值(实际 kinds=%s)" % (kinds,))
|
|
53
|
+
print("=" * 56)
|
|
54
|
+
print("scrub 过程记录守卫:%d 通过 / %d 失败" % (ok, bad))
|
|
55
|
+
return 0 if bad == 0 else 1
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
if __name__ == "__main__":
|
|
59
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""issue #669 守卫:CCG 要素行「带冒号空值 + 换行正文」必须在写入闸门被拒。
|
|
3
|
+
|
|
4
|
+
病象:取值面 ccg_field_value 只看冒号后同一行(得空串),剥除面 _strip_ccg_segments
|
|
5
|
+
见冒号算非空只剥标题行 ⇒ 列表项残留进 body ⇒ _ban_hit(body, neg) 命中自身声明残片
|
|
6
|
+
⇒ verdict=REJECT / conflicts.type=self_negation / score=1.0(假「条件自相矛盾」)。
|
|
7
|
+
|
|
8
|
+
本守卫钉住:①坏形态 fail-closed 且给出两种修法;②三种合法形态一律放行;
|
|
9
|
+
③合规单行(含真正不相交的负条件)不再产生 self_negation(阳性对照:真冲突仍 ctor 命中)。
|
|
10
|
+
"""
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import tempfile
|
|
14
|
+
|
|
15
|
+
from .mdcg import MdCG
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main():
|
|
19
|
+
ok = bad = 0
|
|
20
|
+
|
|
21
|
+
def chk(cond, label):
|
|
22
|
+
nonlocal ok, bad
|
|
23
|
+
if cond:
|
|
24
|
+
ok += 1
|
|
25
|
+
print(" PASS", label)
|
|
26
|
+
else:
|
|
27
|
+
bad += 1
|
|
28
|
+
print(" FAIL", label)
|
|
29
|
+
|
|
30
|
+
cg = MdCG(tempfile.mkdtemp(prefix="f669_"))
|
|
31
|
+
|
|
32
|
+
def try_add(cid, content):
|
|
33
|
+
try:
|
|
34
|
+
cg.add(cid, content, layer="knowledge")
|
|
35
|
+
return None
|
|
36
|
+
except ValueError as exc:
|
|
37
|
+
return str(exc)
|
|
38
|
+
|
|
39
|
+
# ---------- ① 坏形态:fail-closed + 两种修法都在文案里 ----------
|
|
40
|
+
msg = try_add("bad1", "# 功能名:甲\n# 不适用条件:\n- 批量\n- 本人出镜")
|
|
41
|
+
chk(msg is not None, "#669 带冒号空值 + 列表 → 写入被拒(fail-closed)")
|
|
42
|
+
chk(msg is not None and "单行" in msg and "non_applicable_conditions" in msg,
|
|
43
|
+
"#669 拒绝文案给出两种修法(单行 / frontmatter 列表)")
|
|
44
|
+
chk(msg is not None and "第 2 行" in msg, "#669 文案点名具体行号")
|
|
45
|
+
|
|
46
|
+
# ---------- ② 合法形态一律放行 ----------
|
|
47
|
+
chk(try_add("good1", "# 功能名:甲\n# 不适用条件:批量;本人出镜") is None,
|
|
48
|
+
"#669 带冒号单行(多项用;分隔)放行")
|
|
49
|
+
chk(try_add("good2", "# 功能名:甲\n# 不适用条件\n批量;本人出镜") is None,
|
|
50
|
+
"#669 裸标题 + 单行值(CCG 文档形态)放行")
|
|
51
|
+
chk(try_add("good3", "# 功能名:甲\n# 不适用条件:\n# 执行:乙") is None,
|
|
52
|
+
"#669 带冒号空值但紧跟下一要素(值为空)放行")
|
|
53
|
+
|
|
54
|
+
# ---------- ③ 合规写法不再假 REJECT ----------
|
|
55
|
+
from .consistency import check
|
|
56
|
+
body = ("# 功能名:甲\n# 生效条件:用户问代码怎么写\n"
|
|
57
|
+
"# 执行:给示例\n# 不适用条件:本人出镜;涉密材料")
|
|
58
|
+
rec = check(cg, content=body, condition_space={"domain": "code"}, layer="knowledge")
|
|
59
|
+
types = [c.get("type") for c in (rec.get("conflicts") or [])]
|
|
60
|
+
chk("self_negation" not in types,
|
|
61
|
+
"#669 合规单行(负条件与自身不相交)不再判 self_negation(实际 %s)" % (types,))
|
|
62
|
+
|
|
63
|
+
print("=" * 56)
|
|
64
|
+
print("issue #669 守卫:%d 通过 / %d 失败" % (ok, bad))
|
|
65
|
+
return 0 if bad == 0 else 1
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""issue #672 守卫:validity 语义与 meta 口径透出(不改变过滤行为)。"""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
|
|
7
|
+
from .mdcos import MdCGOS
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def main():
|
|
11
|
+
ok = bad = 0
|
|
12
|
+
|
|
13
|
+
def chk(cond, label):
|
|
14
|
+
nonlocal ok, bad
|
|
15
|
+
if cond:
|
|
16
|
+
ok += 1
|
|
17
|
+
print(" PASS", label)
|
|
18
|
+
else:
|
|
19
|
+
bad += 1
|
|
20
|
+
print(" FAIL", label)
|
|
21
|
+
|
|
22
|
+
cg = MdCGOS(tempfile.mkdtemp(prefix="f672_"))
|
|
23
|
+
cg.add("expired", "# 功能名:甲过期\n# 执行:乙", layer="knowledge", importance=0.6,
|
|
24
|
+
verification_basis="test", valid_until="2000-01-01")
|
|
25
|
+
cg.add("live", "# 功能名:甲在效\n# 执行:乙", layer="knowledge", importance=0.6,
|
|
26
|
+
verification_basis="test", valid_from="2000-01-01", valid_until="2099-01-01")
|
|
27
|
+
cg.add("future", "# 功能名:甲未生效\n# 执行:乙", layer="knowledge", importance=0.6,
|
|
28
|
+
verification_basis="test", valid_from="2099-01-01")
|
|
29
|
+
cg.flush()
|
|
30
|
+
|
|
31
|
+
res_off, meta_off = cg.search_rrf("甲", paths=("bm25",), k=10)
|
|
32
|
+
res_on, meta_on = cg.search_rrf("甲", paths=("bm25",), k=10, validity=True)
|
|
33
|
+
ids_off = sorted(r[0].get("id") for r in res_off)
|
|
34
|
+
ids_on = sorted(r[0].get("id") for r in res_on)
|
|
35
|
+
|
|
36
|
+
chk(meta_off.get("validity_scope") == "off", "默认(不启用)meta.validity_scope=off")
|
|
37
|
+
chk(meta_on.get("validity_scope") == "expired_only", "启用时 meta.validity_scope=expired_only")
|
|
38
|
+
chk("expired" in ids_off, "未启用:过期节点仍可见(默认不过滤)")
|
|
39
|
+
chk("expired" not in ids_on, "启用:过期节点被排除")
|
|
40
|
+
chk("future" in ids_on, "启用:**未生效节点仍保留**(名字易误读,本守卫钉住语义)")
|
|
41
|
+
chk("live" in ids_on, "启用:生效中节点保留")
|
|
42
|
+
|
|
43
|
+
return 0 if bad == 0 else 1
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""版本锚(version anchor)——I18 的代码落点。
|
|
3
|
+
|
|
4
|
+
为什么需要(issue #6 提案,2026-10-18 采纳):
|
|
5
|
+
I17 规定「任何投影不得自称权威」,那么每个投影必须能回溯到
|
|
6
|
+
「信息 + 条件空间 + 证据链」三元组。**版本锚就是那个回溯入口**——
|
|
7
|
+
缺版本锚的对外材料,读者无法判断它对应哪一版理论、哪一版架构,
|
|
8
|
+
也就无法回溯。这不是排版问题,是可回溯性的前提。
|
|
9
|
+
|
|
10
|
+
三条纪律:
|
|
11
|
+
1. **三元齐全**:理论版本、架构版本、本投影版本,缺一不可记为不完整。
|
|
12
|
+
2. **机器可读**:格式固定,便于校验(conformance / CI 可红)。
|
|
13
|
+
3. **不猜**:解析不到就是缺,不用「看起来像版本号」去**猜**——猜出来的锚比没有更糟。
|
|
14
|
+
|
|
15
|
+
格式(Markdown 引用块内一行,字段用全角竖线分隔):
|
|
16
|
+
|
|
17
|
+
> **版本锚**:理论=智能论 3.4 | 架构=灵枢记忆系统统一架构 v1.2 | 投影=变更说明 v1
|
|
18
|
+
|
|
19
|
+
也接受 YAML 式三行:
|
|
20
|
+
|
|
21
|
+
version_anchor:
|
|
22
|
+
theory: 智能论 3.4
|
|
23
|
+
architecture: 灵枢记忆系统统一架构 v1.2
|
|
24
|
+
projection: 变更说明 v1
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
import re
|
|
28
|
+
|
|
29
|
+
__all__ = ["FIELDS", "parse_anchor", "check_anchor", "ANCHOR_LINE_RE"]
|
|
30
|
+
|
|
31
|
+
#: 三元字段(键名 → 中文别名,都接受)
|
|
32
|
+
FIELDS = ("theory", "architecture", "projection")
|
|
33
|
+
_ALIASES = {
|
|
34
|
+
"theory": ("theory", "理论", "理论版本"),
|
|
35
|
+
"architecture": ("architecture", "架构", "架构版本"),
|
|
36
|
+
"projection": ("projection", "投影", "本投影", "投影版本"),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#: 单行形态: > **版本锚**:理论=… | 架构=… | 投影=…
|
|
40
|
+
ANCHOR_LINE_RE = re.compile(r"版本锚\*\*\s*[::]\s*(.+)$", re.M)
|
|
41
|
+
_KV_RE = re.compile(r"([^==||]+?)\s*[==]\s*([^||]+)")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _canon(name):
|
|
45
|
+
n = str(name or "").strip()
|
|
46
|
+
for key, alts in _ALIASES.items():
|
|
47
|
+
if n in alts:
|
|
48
|
+
return key
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def parse_anchor(text):
|
|
53
|
+
"""从文本中解析版本锚。
|
|
54
|
+
|
|
55
|
+
返回 {"found": bool, "anchor": {field: value}, "missing": [field...]}。
|
|
56
|
+
两种形态都支持;解析不到即 missing,**不做推测性填充**。
|
|
57
|
+
"""
|
|
58
|
+
text = str(text or "")
|
|
59
|
+
anchor = {}
|
|
60
|
+
|
|
61
|
+
m = ANCHOR_LINE_RE.search(text)
|
|
62
|
+
if m:
|
|
63
|
+
for k, v in _KV_RE.findall(m.group(1)):
|
|
64
|
+
key = _canon(k)
|
|
65
|
+
if key and key not in anchor:
|
|
66
|
+
val = v.strip().strip("*_ ")
|
|
67
|
+
if val:
|
|
68
|
+
anchor[key] = val
|
|
69
|
+
|
|
70
|
+
# YAML 式三行形态(仅在上面的单行形态没解析全时补充)
|
|
71
|
+
if len(anchor) < len(FIELDS):
|
|
72
|
+
for key, alts in _ALIASES.items():
|
|
73
|
+
if key in anchor:
|
|
74
|
+
continue
|
|
75
|
+
for alt in alts:
|
|
76
|
+
ym = re.search(r"^\s*" + re.escape(alt) + r"\s*[::]\s*(.+?)\s*$",
|
|
77
|
+
text, re.M)
|
|
78
|
+
if ym and ym.group(1).strip():
|
|
79
|
+
anchor[key] = ym.group(1).strip().strip("\"'*_ ")
|
|
80
|
+
break
|
|
81
|
+
|
|
82
|
+
missing = [f for f in FIELDS if not anchor.get(f)]
|
|
83
|
+
return {"found": bool(anchor), "anchor": anchor, "missing": missing}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
#: 历史材料标记:早于 I18 施行、且作者已难追溯的对外材料。
|
|
87
|
+
#: 它们**不补锚**(推定版本等于造锚),但在检查结果里显式区分于「应补未补」。
|
|
88
|
+
LEGACY_MARK = "legacy_no_anchor"
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def check_anchor(text):
|
|
92
|
+
"""I18 判定:三元齐全才算通过。返回 (ok, detail)。
|
|
93
|
+
|
|
94
|
+
detail["legacy"] 为真表示该材料自带历史标记——不算通过,但也不算待修。
|
|
95
|
+
这两件事必须分开:**「明示未标注」与「忘了标注」责任不同**。
|
|
96
|
+
"""
|
|
97
|
+
rep = parse_anchor(text)
|
|
98
|
+
ok = rep["found"] and not rep["missing"]
|
|
99
|
+
legacy = LEGACY_MARK in str(text or "")
|
|
100
|
+
return ok, {"anchor": rep["anchor"], "missing": rep["missing"],
|
|
101
|
+
"found": rep["found"], "legacy": legacy}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def scan_dir(directory, suffix=".md"):
|
|
105
|
+
"""扫描目录下的对外材料,分类为 ok/legacy/todo。
|
|
106
|
+
|
|
107
|
+
「todo」是应补未补的,需要人决定;「legacy」是明示历史材料,不催。
|
|
108
|
+
"""
|
|
109
|
+
import os
|
|
110
|
+
rows = {"ok": [], "legacy": [], "todo": []}
|
|
111
|
+
d = str(directory)
|
|
112
|
+
if not os.path.isdir(d):
|
|
113
|
+
return {"error": "目录不存在:%s" % d, **rows}
|
|
114
|
+
for name in sorted(os.listdir(d)):
|
|
115
|
+
if not name.endswith(suffix):
|
|
116
|
+
continue
|
|
117
|
+
path = os.path.join(d, name)
|
|
118
|
+
if not os.path.isfile(path):
|
|
119
|
+
continue
|
|
120
|
+
try:
|
|
121
|
+
with open(path, "r", encoding="utf-8", errors="replace") as fh:
|
|
122
|
+
text = fh.read()
|
|
123
|
+
except OSError as exc:
|
|
124
|
+
rows["todo"].append({"file": name, "why": "read_error: %s" % exc})
|
|
125
|
+
continue
|
|
126
|
+
ok, detail = check_anchor(text)
|
|
127
|
+
if ok:
|
|
128
|
+
rows["ok"].append(name)
|
|
129
|
+
elif detail.get("legacy"):
|
|
130
|
+
rows["legacy"].append(name)
|
|
131
|
+
else:
|
|
132
|
+
rows["todo"].append({"file": name, "missing": detail["missing"]})
|
|
133
|
+
return rows
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def main(argv=None):
|
|
137
|
+
import sys
|
|
138
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
139
|
+
try:
|
|
140
|
+
sys.stdout.reconfigure(encoding="utf-8")
|
|
141
|
+
except Exception:
|
|
142
|
+
pass
|
|
143
|
+
if "--check" not in argv:
|
|
144
|
+
print("用法:python -m md_cg.version_anchor --check <目录> [--json]")
|
|
145
|
+
return 2
|
|
146
|
+
d = argv[argv.index("--check") + 1]
|
|
147
|
+
rows = scan_dir(d)
|
|
148
|
+
if "--json" in argv:
|
|
149
|
+
import json as _j
|
|
150
|
+
print(_j.dumps(rows, ensure_ascii=False, indent=1, sort_keys=True))
|
|
151
|
+
else:
|
|
152
|
+
print("ok=%d legacy=%d todo=%d" % (len(rows["ok"]), len(rows["legacy"]),
|
|
153
|
+
len(rows["todo"])))
|
|
154
|
+
for item in rows["todo"]:
|
|
155
|
+
print(" TODO ", item)
|
|
156
|
+
return 0 if not rows["todo"] else 1
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if __name__ == "__main__":
|
|
160
|
+
raise SystemExit(main())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@furongjun1999/dsh-memory",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.14",
|
|
4
4
|
"description": "灵枢(Lingshu·líng shū)DeepSeek Harness 插件:完整大脑——长期记忆/知识飞轮/自我认知/递归反思接入 DSH,对话自动沉淀进 md_cg 认知图(md 文档)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"build": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
92
92
|
"test": "npm run build && node --import tsx --test \"test/*.test.ts\"",
|
|
93
93
|
"prepare": "node -e \"const fs=require('fs');const tsc='node_modules/typescript/bin/tsc';if(fs.existsSync(tsc)){fs.rmSync('lib',{recursive:true,force:true});require('child_process').execFileSync(process.execPath,[tsc,'-p','tsconfig.json'],{stdio:'inherit'})}else if(fs.existsSync('lib/index.js')){console.log('[prepare] 跳过构建:typescript 未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)——需要构建请用 npm install --include=dev')}else{console.error('[prepare] 本安装会得到一个不可用的包(issue #161):包入口 main 指向 lib/index.js,但 lib/ 被 .gitignore 忽略、git 归档里没有它,此处 typescript 又未安装(NODE_ENV=production 或 --omit=dev 会省略 devDependencies)⇒ prepare 无法构建,lib/index.js 不存在。修法:用 npm install --include=dev 安装(带上 devDependencies,让 prepare 能构建),或改用已带构建产物的发布包。');process.exitCode=1}\"",
|
|
94
|
-
"gate": "python scripts/check_unreachable.py && python scripts/check_publish_artifact.py && python scripts/check_publish_smoke.py && python scripts/cogmap_sync.py check && python scripts/link_check.py && python scripts/check_line_anchors.py && python scripts/workspace_index.py --check && python scripts/discipline_nodes.py --init --write --cg-root .tmp/discipline-cg && python scripts/verify_discipline.py --allow-missing --cg-root .tmp/discipline-cg && python scripts/gate_rust_crate_test.py && python scripts/gate_rust_parity.py && python scripts/check_local_paths.py && python scripts/body_e2e_smoke.py",
|
|
94
|
+
"gate": "python scripts/check_unreachable.py && python scripts/check_publish_artifact.py && python scripts/check_publish_smoke.py && python scripts/cogmap_sync.py check && python scripts/link_check.py && python scripts/check_line_anchors.py && python scripts/workspace_index.py --check && python scripts/discipline_nodes.py --init --write --cg-root .tmp/discipline-cg && python scripts/verify_discipline.py --allow-missing --cg-root .tmp/discipline-cg && python scripts/gate_output.py && python scripts/gate_rust_crate_test.py && python scripts/gate_rust_parity.py && python scripts/check_local_paths.py && python scripts/body_e2e_smoke.py",
|
|
95
95
|
"prepublishOnly": "npm run build && npm test && npm run gate"
|
|
96
96
|
},
|
|
97
97
|
"repository": {
|
package/src/hooks.ts
CHANGED
|
@@ -785,12 +785,26 @@ export function installMemoryHooks(ctx: Context, mdcg: MdcgClient | null, opts:
|
|
|
785
785
|
if (!Number.isFinite(n)) return 10
|
|
786
786
|
return Math.max(1, Math.min(100, Math.floor(n)))
|
|
787
787
|
})()
|
|
788
|
-
|
|
788
|
+
{
|
|
789
|
+
// 本 handler **恒定注册**(#657):提醒是独立配置(memory.turnReminder),
|
|
790
|
+
// 关掉自动召回不该让它只写不读;召回部分在内部按 opts.autoRecall 门控。
|
|
789
791
|
const recallLimit = Math.max(1, Math.min(10, opts.autoRecallLimit || 4))
|
|
790
792
|
ctx.on('system-prompt/assemble', async (assembly, _ctx, next) => {
|
|
791
793
|
try {
|
|
792
794
|
// 异步取最近记忆节点(失败静默——不阻塞模型请求)
|
|
793
|
-
|
|
795
|
+
// 会话标识:门控内外都要用(提醒消费 + 自动召回),故先解析。
|
|
796
|
+
const hostCtx = (_ctx as unknown) as { agent?: { session?: unknown } } | undefined
|
|
797
|
+
const sid = sessionIdOf(hostCtx?.agent?.session)
|
|
798
|
+
|| (observedSession ? currentSession() : '')
|
|
799
|
+
// 逢十轮提醒的消费面(#657):不受 autoRecall 门控。
|
|
800
|
+
if (sid) {
|
|
801
|
+
const pending = pendingReminder.get(sid)
|
|
802
|
+
if (pending) {
|
|
803
|
+
pendingReminder.delete(sid)
|
|
804
|
+
assembly.contexts.push({ name: 'lingshu:turn-reminder', text: pending })
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
if (opts.autoRecall && graph.isReady()) {
|
|
794
808
|
// 会话隔离(P45):自动召回只注入**本会话**的记忆,防多会话串台;
|
|
795
809
|
// 取不到会话标识则退回旧行为(不加过滤),不做半吊子猜测。
|
|
796
810
|
// ⚠️ 取值必须**每步稳定**:本块按 v0.4.8 契约每步都 push,内容一旦与上
|
|
@@ -799,14 +813,7 @@ export function installMemoryHooks(ctx: Context, mdcg: MdcgClient | null, opts:
|
|
|
799
813
|
// 退回「最近一次 session/event 的会话」。
|
|
800
814
|
// 想读**所有**会话做了什么:别走自动召回(它会串台),显式调
|
|
801
815
|
// `stg(op=timeline, session="*")`,返回项带 session 归属。
|
|
802
|
-
|
|
803
|
-
// 回落 = **本实例观测门 × 模块单点值**(裁定项 dwfq-7b3a555e-1,见上方
|
|
804
|
-
// observedSession 注释):本实例尚未观测 → 回落 ''(保持「新实例 =
|
|
805
|
-
// 干净状态」,与 test/session-attribution.test.ts ② 的「未观测 → 不加
|
|
806
|
-
// 过滤」相容);已观测 → 取 lib/session_state.ts 的进程级单点值。
|
|
807
|
-
// 真机单实例下两者逐位等价(差异窗口不可达)。
|
|
808
|
-
const sid = sessionIdOf(hostCtx?.agent?.session)
|
|
809
|
-
|| (observedSession ? currentSession() : '')
|
|
816
|
+
// sid 已在门控外解析(提醒消费与召回共用同一份,避免两次口径漂移)。
|
|
810
817
|
// 逢十轮提醒(纪律第 16 条;issue #645 修正):计数挪到 session/event 的真实
|
|
811
818
|
// 用户回合上,这里只消费一次待推文本。旧实现把 assemble 当轮次 + 段内永久重推
|
|
812
819
|
// ⇒ 提醒几乎常驻、agent 反复空转归档;sid 缺失时还回落共用键 __no_sid__,
|
|
@@ -941,6 +948,17 @@ export function installMemoryHooks(ctx: Context, mdcg: MdcgClient | null, opts:
|
|
|
941
948
|
observedSession = true
|
|
942
949
|
}
|
|
943
950
|
const sessionTag = sid ? { session: sid } : { session: UNASSIGNED_SESSION }
|
|
951
|
+
// 逢十轮提醒的**计轮点**(#645/#658):真实用户回合 = 用户消息条数。
|
|
952
|
+
// 位置在 opts.userMessage 之外——那个开关是「消息不自动进知识面」的正当决策,
|
|
953
|
+
// 与「提醒还该不该跑」是两件事;旧实现把计轮塞在它里面,关知识面会连带静默杀死提醒。
|
|
954
|
+
if (event.type === 'user/message' && event.data.source?.kind === 'user'
|
|
955
|
+
&& !isRelayedMessage(event.data.source) && sid && reminderInterval > 0) {
|
|
956
|
+
const n = (userTurns.get(sid) ?? 0) + 1
|
|
957
|
+
userTurns.set(sid, n)
|
|
958
|
+
if (shouldRemindTurn(n, reminderInterval)) {
|
|
959
|
+
pendingReminder.set(sid, escapePromptBraces(formatTurnReminder(n)))
|
|
960
|
+
}
|
|
961
|
+
}
|
|
944
962
|
if (event.type === 'user/message' && opts.userMessage) {
|
|
945
963
|
// 落盘审计(issue #56):source.kind 分布——先于两级判据记录**完整**输入分布
|
|
946
964
|
// (含被滤与放行),「宿主到底给这条消息标了什么 kind」是排障第一问。
|
|
@@ -962,16 +980,6 @@ export function installMemoryHooks(ctx: Context, mdcg: MdcgClient | null, opts:
|
|
|
962
980
|
}
|
|
963
981
|
const text = extractText(event.data.content)
|
|
964
982
|
if (!text) return
|
|
965
|
-
// 逢十轮提醒的**计轮点**(issue #645):真实用户回合 = 用户消息条数。
|
|
966
|
-
// 放在脱敏之前——被脱敏丢弃的消息也是一次真实交互,不应影响计数。
|
|
967
|
-
// 无 sid 不计数、不提醒(旧实现回落共用键 __no_sid__,并行会话会互相污染频率)。
|
|
968
|
-
if (sid && reminderInterval > 0) {
|
|
969
|
-
const n = (userTurns.get(sid) ?? 0) + 1
|
|
970
|
-
userTurns.set(sid, n)
|
|
971
|
-
if (shouldRemindTurn(n, reminderInterval)) {
|
|
972
|
-
pendingReminder.set(sid, escapePromptBraces(formatTurnReminder(n)))
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
983
|
const safe = sanitize(text) // 脱敏:纯凭据消息 → null → 跳过写入
|
|
976
984
|
if (safe === null) { audit.skipped('sanitized', 'user'); return }
|
|
977
985
|
memorize('user', 'user', (g) => g.remember(safe, {
|
package/zcode/AGENTS.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# 工作纪律(工作纪律_认知图条目_v1.1)·
|
|
1
|
+
# 工作纪律(工作纪律_认知图条目_v1.1)· 19 条
|
|
2
2
|
|
|
3
3
|
> 本文件由 `scripts/render_discipline.py` 从真源
|
|
4
4
|
> `docs/工作纪律_认知图条目_v1.1.json` 渲染生成,**请勿手改**;改真源后重跑渲染。
|
|
5
|
-
> 真源指纹(SHA256 前16位):
|
|
5
|
+
> 真源指纹(SHA256 前16位):aea28906043ba9a2
|
|
6
6
|
|
|
7
7
|
## 概述
|
|
8
8
|
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
|
|
205
205
|
**版本**:v1.1 | **状态**:待校准(未对外发布)
|
|
206
206
|
|
|
207
|
-
### 附录:本仓
|
|
207
|
+
### 附录:本仓 19 条纪律(语义 / 触发 / 动作 / 声明出口)
|
|
208
208
|
|
|
209
209
|
1. **1.理论先行**
|
|
210
210
|
- 触发:重要项目|长期任务
|
|
@@ -278,6 +278,10 @@
|
|
|
278
278
|
- 触发:查找工作区文件|需要了解工作区结构|跨目录检索定位|长会话续接/上下文压缩后查找工作区文件
|
|
279
279
|
- 动作:定位工作区文件→先读 WORKSPACE_INDEX.md(仓根)→有则按表中职责/关键入口直接定位→无则先 python scripts/workspace_index.py --write 生成再读→守卫报陈化先重生成→不以重复全盘浏览代替; 新增顶层目录/根级文件须在脚本 DIR_ROLES/ROOT_FILES 登记后重生成; 上下文压缩/长会话续接后, 先 cg route『工作区索引』重建纪律视野(压缩会丢弃未留下执行痕迹的纪律, 只剩被声明过的条目——须主动召回); 压缩/续接后三步=route『工作区索引』→输出声明→回取本会话近10轮窗口重建上下文(cg(op=recent)/session_recall/会话 md 镜像)
|
|
280
280
|
- 声明:按工作纪律第18条: 工作区索引优先——查工作区文件先读 WORKSPACE_INDEX.md(仓根, 管线生成); 无则先跑 scripts/workspace_index.py --write 生成再读, 不以重复全盘浏览代替。 压缩续接后并回取本会话窗口(最近10轮)重建上下文。
|
|
281
|
+
19. **19.输出单元细则(echo三问/D_out/版本锚)**
|
|
282
|
+
- 触发:对外交付|对外材料/公开文档|回答外部提问|发版说明|对外数据集产出
|
|
283
|
+
- 动作:对外交付前→①按三问写 echo 页(<=200 字, 第二问必须指认判据 id/测试名/读数) ②补版本锚三元(理论/架构/本投影) ③跑 python scripts/gate_output.py 判绿 ④附当期 D_out 读数(首次允许很差, 但必须留基线)→任一不满足不得对外; 改口径先改真源再重渲染, 不得手改产物; 材料与实现版本不一致时以版本锚为准, 先修锚再发
|
|
284
|
+
- 声明:按工作纪律第19条: 输出单元细则——对外交付先写 echo 三问页(<=200字, 第二问须指认判据/断言id/读数)、带版本锚三元、跑 gate_output 并留当期 D_out 读数; 缺一不对外, 不做说服率/好感度测量。
|
|
281
285
|
|
|
282
286
|
## 声明出口(`response.direct` 原文 · 未输出即未执行)
|
|
283
287
|
|
|
@@ -301,6 +305,7 @@
|
|
|
301
305
|
| 16 | 按工作纪律第16条: 任务收尾归档——每次任务执行完只提炼核心修改(内容/原因/位置/验证结论)并按 CCG 六要素(功能名/生效条件/子功能/执行/验证方式/不适用条件)成文存入灵枢记忆(text 类六要素缺失会被写入闸门当场拒绝并返回缺失清单——补齐后重写即可, 不必等读回确认才发现), 写入后发起一次读取查询确认写入成功且可检索, 禁写中间过程/试错/调试等无效信息, 与第2条形成「查记忆→执行→写记忆→读回确认」闭环。 |
|
|
302
306
|
| 17 | 按工作纪律第17条: 任务派发统一走蜂巢——任何执行性任务经蜂巢 spawn/submit 执行并留痕(spec/status/result), agent本体只做编排; 宿主自带subagent/team不是等价通道(zcode端的工作流工具为等效蜂巢工具——使用者2026-10-04裁定; 蜂巢功能完全完善之前, zcode端可优先使用zcode工作流处理), 兜底须声明。L1只读判定(产物落点=不改仓库/外部状态)可直跑, 须输出「L1 直跑:<命令> — 风险/频次/可逆性」留痕。 |
|
|
303
307
|
| 18 | 按工作纪律第18条: 工作区索引优先——查工作区文件先读 WORKSPACE_INDEX.md(仓根, 管线生成); 无则先跑 scripts/workspace_index.py --write 生成再读, 不以重复全盘浏览代替。 压缩续接后并回取本会话窗口(最近10轮)重建上下文。 |
|
|
308
|
+
| 19 | 按工作纪律第19条: 输出单元细则——对外交付先写 echo 三问页(<=200字, 第二问须指认判据/断言id/读数)、带版本锚三元、跑 gate_output 并留当期 D_out 读数; 缺一不对外, 不做说服率/好感度测量。 |
|
|
304
309
|
|
|
305
310
|
## 记忆接口速查(`cg` / `stg`)
|
|
306
311
|
|
package/zcode/README.md
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
# ZCode 端 · 灵枢接入配置
|
|
2
|
-
|
|
3
|
-
本目录 = **ZCode harness 专属配置**。ZCode 与 CodeBuddy 同构:在**会话起始读取项目根的 `AGENTS.md`**
|
|
4
|
-
全文注入,因此本端产物同样采用 `full` 变体。
|
|
5
|
-
|
|
6
|
-
## 目录内容
|
|
7
|
-
|
|
8
|
-
| 文件 | 作用 | 性质 |
|
|
9
|
-
|---|---|---|
|
|
10
|
-
| `AGENTS.md` |
|
|
11
|
-
| `README.md` | 本文件(接入说明) | 手写 |
|
|
12
|
-
|
|
13
|
-
## 接入
|
|
14
|
-
|
|
15
|
-
把 `zcode/AGENTS.md` 复制到**你项目的根目录**,新建会话即生效。
|
|
16
|
-
|
|
17
|
-
ZCode 侧的记忆访问复用同一套 MCP 大脑,配置方式与 CodeBuddy 一致
|
|
18
|
-
(见 [`../codebuddy/mcp.json`](../codebuddy/mcp.json) 与 [`../codebuddy/README.md`](../codebuddy/README.md)),
|
|
19
|
-
只需把 `MDCG_ACTOR` 改为 `zcode`。
|
|
20
|
-
|
|
21
|
-
该模板同源含第二条 MCP server `hive`(蜂巢:多智能体并发 + 任务上下文管理),一并合并即可;
|
|
22
|
-
ZCode 与 CodeBuddy 指向同一仓库时**共享同一并发池**。语义与边界见
|
|
23
|
-
[`../hive/README.md`](../hive/README.md) 的「各 harness 注册」。
|
|
24
|
-
|
|
25
|
-
## 与 CodeBuddy 并存
|
|
26
|
-
|
|
27
|
-
两者互不干扰——CodeBuddy 读根目录 `CODEBUDDY.md`,ZCode 读根目录 `AGENTS.md`;
|
|
28
|
-
若项目同时使用两端,各自放入对应文件即可(内容同源,均为真源渲染产物)。
|
|
29
|
-
|
|
30
|
-
## 记忆策略
|
|
31
|
-
|
|
32
|
-
同 CodeBuddy 端:**只记重要内容(核心修改:内容/原因/位置/验证结论)+ 对话记录**,
|
|
33
|
-
其余一律经写入闸门过滤。详见 [`../codebuddy/README.md`](../codebuddy/README.md) 的「记忆策略」一节。
|
|
34
|
-
|
|
35
|
-
## 维护(面向灵枢维护者)
|
|
36
|
-
|
|
37
|
-
- `AGENTS.md` 由 `scripts/render_discipline.py` 从**唯一真源** `docs/工作纪律_认知图条目_v1.1.json`
|
|
38
|
-
渲染生成,矩阵见 `docs/discipline/harnesses.yaml`(`zcode` 槽位)。
|
|
39
|
-
- 改纪律 → 改真源 → `python scripts/render_discipline.py --target zcode --write`
|
|
40
|
-
→ `python scripts/verify_discipline.py --target zcode` 通过 → 提交。
|
|
41
|
-
- **手改本目录的 `AGENTS.md` 会被 `verify_discipline.py` 判为漂移**。
|
|
1
|
+
# ZCode 端 · 灵枢接入配置
|
|
2
|
+
|
|
3
|
+
本目录 = **ZCode harness 专属配置**。ZCode 与 CodeBuddy 同构:在**会话起始读取项目根的 `AGENTS.md`**
|
|
4
|
+
全文注入,因此本端产物同样采用 `full` 变体。
|
|
5
|
+
|
|
6
|
+
## 目录内容
|
|
7
|
+
|
|
8
|
+
| 文件 | 作用 | 性质 |
|
|
9
|
+
|---|---|---|
|
|
10
|
+
| `AGENTS.md` | 19 条工作纪律全文(会话起始注入) | **渲染产物**,勿手改 |
|
|
11
|
+
| `README.md` | 本文件(接入说明) | 手写 |
|
|
12
|
+
|
|
13
|
+
## 接入
|
|
14
|
+
|
|
15
|
+
把 `zcode/AGENTS.md` 复制到**你项目的根目录**,新建会话即生效。
|
|
16
|
+
|
|
17
|
+
ZCode 侧的记忆访问复用同一套 MCP 大脑,配置方式与 CodeBuddy 一致
|
|
18
|
+
(见 [`../codebuddy/mcp.json`](../codebuddy/mcp.json) 与 [`../codebuddy/README.md`](../codebuddy/README.md)),
|
|
19
|
+
只需把 `MDCG_ACTOR` 改为 `zcode`。
|
|
20
|
+
|
|
21
|
+
该模板同源含第二条 MCP server `hive`(蜂巢:多智能体并发 + 任务上下文管理),一并合并即可;
|
|
22
|
+
ZCode 与 CodeBuddy 指向同一仓库时**共享同一并发池**。语义与边界见
|
|
23
|
+
[`../hive/README.md`](../hive/README.md) 的「各 harness 注册」。
|
|
24
|
+
|
|
25
|
+
## 与 CodeBuddy 并存
|
|
26
|
+
|
|
27
|
+
两者互不干扰——CodeBuddy 读根目录 `CODEBUDDY.md`,ZCode 读根目录 `AGENTS.md`;
|
|
28
|
+
若项目同时使用两端,各自放入对应文件即可(内容同源,均为真源渲染产物)。
|
|
29
|
+
|
|
30
|
+
## 记忆策略
|
|
31
|
+
|
|
32
|
+
同 CodeBuddy 端:**只记重要内容(核心修改:内容/原因/位置/验证结论)+ 对话记录**,
|
|
33
|
+
其余一律经写入闸门过滤。详见 [`../codebuddy/README.md`](../codebuddy/README.md) 的「记忆策略」一节。
|
|
34
|
+
|
|
35
|
+
## 维护(面向灵枢维护者)
|
|
36
|
+
|
|
37
|
+
- `AGENTS.md` 由 `scripts/render_discipline.py` 从**唯一真源** `docs/工作纪律_认知图条目_v1.1.json`
|
|
38
|
+
渲染生成,矩阵见 `docs/discipline/harnesses.yaml`(`zcode` 槽位)。
|
|
39
|
+
- 改纪律 → 改真源 → `python scripts/render_discipline.py --target zcode --write`
|
|
40
|
+
→ `python scripts/verify_discipline.py --target zcode` 通过 → 提交。
|
|
41
|
+
- **手改本目录的 `AGENTS.md` 会被 `verify_discipline.py` 判为漂移**。
|