@furongjun1999/dsh-memory 0.9.7 → 0.9.9
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 +150 -662
- package/codebuddy/CODEBUDDY.md +337 -204
- package/docs/README.md +21 -0
- package/docs/discipline/harnesses.yaml +11 -3
- package/docs/discipline/templates/compact.txt.tmpl +20 -18
- package/docs/discipline/templates/full.md.tmpl +63 -61
- package/docs/discipline/templates/rules.mdc.tmpl +5 -3
- package/docs/discipline/templates/skill.md.tmpl +25 -23
- package/docs/discipline/templates/spec.txt.tmpl +1 -1
- package/docs/discipline/templates/zcode-user.md.tmpl +1 -1
- 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
- package/dsh/cordis.yml.example +2 -2
- package/lib/hooks.d.ts +11 -1
- package/lib/hooks.js +59 -4
- package/lib/index.d.ts +1 -1
- package/lib/index.js +11 -5
- package/lib/init.js +28 -4
- package/lib/lib/hook_audit.d.ts +3 -0
- package/lib/lib/hook_audit.js +63 -0
- package/md_cg/autonomy.py +1 -1
- package/md_cg/config_registry.py +329 -329
- package/md_cg/config_registry_bulk.py +483 -482
- package/md_cg/config_render.py +27 -0
- package/md_cg/config_validate.py +456 -455
- package/md_cg/conflict_surface.py +127 -0
- package/md_cg/mcp_server.py +5324 -5227
- package/md_cg/mdcg.py +12 -1
- package/md_cg/mdcos.py +7159 -7108
- package/md_cg/pooling.py +487 -485
- package/md_cg/qmd_llm.py +334 -334
- package/md_cg/reach.py +10 -4
- package/md_cg/sleep.py +2 -2
- package/md_cg/sustain.py +13 -4
- package/md_cg/test_auto_defaults.py +463 -463
- package/md_cg/test_autonomy_emotion.py +328 -328
- package/md_cg/test_bm25_default.py +56 -0
- package/md_cg/test_c3_transient_read_negative.py +7 -3
- package/md_cg/test_conflict_surface.py +75 -0
- package/md_cg/test_conflict_value_untrusted.py +63 -0
- package/md_cg/test_exact_text_cache.py +194 -191
- package/md_cg/test_heartbeat_ledger.py +563 -557
- package/md_cg/test_hotcache_tool.py +121 -0
- package/md_cg/test_issue274_read_node_id_none.py +364 -341
- package/md_cg/test_issue561_pending_review.py +89 -5
- package/md_cg/test_issue578_service_info_gate.py +264 -0
- package/md_cg/test_n184_keys_concurrent_provision.py +1 -1
- package/md_cg/test_p3_legacy_closure.py +441 -438
- package/md_cg/test_p43_pooling.py +419 -412
- package/md_cg/test_reach.py +5 -1
- package/md_cg/test_reach_exits.py +54 -0
- package/md_cg/test_reach_single_char.py +74 -0
- package/md_cg/test_read_scope_b27.py +2 -2
- package/md_cg/test_search_bm25_default.py +60 -0
- package/md_cg/test_security_audit_v21.py +249 -249
- package/md_cg/test_sleep_p1.py +1032 -1032
- package/md_cg/test_sustain_bad_stamp.py +178 -0
- package/md_cg/test_untrusted_audit.py +55 -0
- package/md_cg/test_untrusted_classifier.py +42 -0
- package/md_cg/test_untrusted_enforcement.py +66 -0
- package/md_cg/untrusted.py +45 -0
- package/md_cg/untrusted_audit.py +87 -0
- package/md_cg/value_conflict.py +71 -0
- package/package.json +7 -7
- package/src/hooks.ts +986 -932
- package/src/index.ts +20 -14
- package/src/init.ts +21 -4
- package/src/lib/hook_audit.ts +334 -282
- package/zcode/AGENTS.md +337 -204
package/md_cg/reach.py
CHANGED
|
@@ -391,14 +391,13 @@ def _disk_fresh(idx: ReachIndex, cg) -> bool:
|
|
|
391
391
|
return bool(idx.built_fingerprint) and idx.built_fingerprint == _fingerprint(cg)
|
|
392
392
|
|
|
393
393
|
|
|
394
|
-
# 生效条件:仅当 enabled() 为真、
|
|
394
|
+
# 生效条件:仅当 enabled() 为真、_index_with_meta(cg) 返回的 idx 非 None 且 idx.hash_complete 为真、由 qb/terms/q 生成的 token 集非空、按 entries 过滤后的 got 非空、且未索引/新写入节点数不超过 _FRESH_MAX 时返回 (got, meta);否则按守卫失败原因返回 (None, {"reach": off/index_unavailable/hash_incomplete/no_tokens/empty_converge/fresh_overflow})。# 单字符 term 不再整段跳过(issue #611):改用「含该字的 bigram」并集做超集收敛,保召回。
|
|
395
395
|
def narrow(cg, entries, terms, qb, context=None, hops: int = 1, q: str = ""):
|
|
396
396
|
meta = {"reach": "on"}
|
|
397
397
|
if not enabled():
|
|
398
398
|
return None, {"reach": "off"}
|
|
399
|
-
terms =
|
|
400
|
-
|
|
401
|
-
return None, {"reach": "short_term"} # 单字符 term 的 bigram 无法覆盖子串语义
|
|
399
|
+
terms = [t for t in (terms or []) if t]
|
|
400
|
+
_single = [t for t in terms if len(t) < 2]
|
|
402
401
|
idx, _fail = _index_with_meta(cg)
|
|
403
402
|
if idx is None:
|
|
404
403
|
return None, dict({"reach": "index_unavailable"}, **_fail)
|
|
@@ -417,6 +416,13 @@ def narrow(cg, entries, terms, qb, context=None, hops: int = 1, q: str = ""):
|
|
|
417
416
|
toks |= bg((q or "").lower())
|
|
418
417
|
for t in terms:
|
|
419
418
|
toks |= bg(t)
|
|
419
|
+
# 单字符 term:任何含该字的文档必含「包含该字的某个 bigram」(长度 >=2 时成立),
|
|
420
|
+
# 故把倒排里所有含该字的 bigram 的 postings 并入 token 集 —— 仍是超集口径,不丢召回。
|
|
421
|
+
if _single:
|
|
422
|
+
_chars = set(_single)
|
|
423
|
+
for b in list(idx.post.keys()):
|
|
424
|
+
if any(c in b for c in _chars):
|
|
425
|
+
toks.add(b)
|
|
420
426
|
toks |= bg((t or "").lower())
|
|
421
427
|
# 与文档侧 ne() 口径对齐(terms 此前只做小写)——同样是超集方向,宁多读不漏召回
|
|
422
428
|
toks |= bg(_ne(t or ""))
|
package/md_cg/sleep.py
CHANGED
|
@@ -120,7 +120,7 @@ SLEEP_ENV_DEFAULTS = {
|
|
|
120
120
|
"merge": "auto", # 合并策略 auto / ask / never
|
|
121
121
|
"gitdir": "", # git 目录(空 → state_root()/sleep/lib.git)
|
|
122
122
|
"shadow": "", # 影子工作树(空 → state_root()/sleep/shadow)
|
|
123
|
-
"scrub_apply": "
|
|
123
|
+
"scrub_apply": "1", # 第④步去污染**实改**闸(默认开:真实落盘;置 0 退回只盘点)
|
|
124
124
|
}
|
|
125
125
|
#: 各键的 env 名(**唯一的字面量落点**)。
|
|
126
126
|
SLEEP_ENV_KEYS = {
|
|
@@ -191,7 +191,7 @@ def sleep_merge_mode(environ=None) -> str:
|
|
|
191
191
|
|
|
192
192
|
# 生效条件:sleep_env("scrub_apply") 取值不属于 SLEEP_OFF_VALUES 时为真(缺省 "0" → 假)。
|
|
193
193
|
def sleep_scrub_apply(environ=None) -> bool:
|
|
194
|
-
"""第④步去污染**实改**闸 `MDCG_SLEEP_SCRUB_APPLY
|
|
194
|
+
"""第④步去污染**实改**闸 `MDCG_SLEEP_SCRUB_APPLY`(缺省开;置 0 退回只盘点)。"""
|
|
195
195
|
return sleep_env("scrub_apply", environ) not in SLEEP_OFF_VALUES
|
|
196
196
|
|
|
197
197
|
|
package/md_cg/sustain.py
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
早已具备,缺的是**驱动源**:没人周期性问「现在有多少该固化 / 该重算的候选」。
|
|
29
29
|
`evolution_candidates()` 以**索引快照**为口径做只读盘点(零读节点文件、零写盘、
|
|
30
30
|
确定性),并挂到常驻循环的 `_tick_evolve()` 上。纪律与 self-heal 一致且更严:
|
|
31
|
-
· 巡检恒只读,`auto_evolve=False
|
|
31
|
+
· 巡检恒只读,`auto_evolve=False` 时**只记账不动库**(默认已改为 True,见 AUTO_DEFAULTS);
|
|
32
32
|
· 自愈只放行**确定性且可回滚**的动作(重要性重算,有 rollback);
|
|
33
33
|
· 依赖 LLM 的固化**永不自动跑**——巡检报出候选数,交人工另批。
|
|
34
34
|
|
|
@@ -97,8 +97,8 @@ TICK_STALE_MIN_S = 1800.0
|
|
|
97
97
|
# ——该动作确定性、永不删除节点、可逆可审计(见 `_tick_tidy` 说明),op 路径的
|
|
98
98
|
# `False` 是唯一错位项。**opt-out:`MDCG_AUTO_TIDY=0`(env 路径)/显式传
|
|
99
99
|
# `auto_tidy=false`(op 路径——显式入参仍优先于本表)。**
|
|
100
|
-
AUTO_DEFAULTS = {"auto_heal": True, "auto_scrub":
|
|
101
|
-
"auto_evolve":
|
|
100
|
+
AUTO_DEFAULTS = {"auto_heal": True, "auto_scrub": True,
|
|
101
|
+
"auto_evolve": True, "auto_tidy": True}
|
|
102
102
|
#: 各 `auto_*` 的 env 覆盖键(env 路径入口照此读;即各档的 opt-out 名)。
|
|
103
103
|
AUTO_ENVS = {"auto_heal": "MDCG_SUSTAIN_AUTOHEAL",
|
|
104
104
|
"auto_scrub": "MDCG_AUTO_SCRUB",
|
|
@@ -192,7 +192,16 @@ def read_stamp(name: str, d: str = None):
|
|
|
192
192
|
return None
|
|
193
193
|
if not isinstance(rec, dict):
|
|
194
194
|
return None
|
|
195
|
-
|
|
195
|
+
# 契约(本函数文档串「不存在 / 损坏 → None」):`ts` 非数值也算损坏。
|
|
196
|
+
# 修前 `float(rec.get("ts") or 0)` 只挡了假值(None/0/""),`ts="abc"` 这类
|
|
197
|
+
# **合法 JSON 里的非法值**会抛 ValueError 穿出本函数;而 peers() 在循环里
|
|
198
|
+
# 直接调本函数、无 try —— 一个坏戳会让**整个 peers() 失败**,同目录下所有
|
|
199
|
+
# 健康节点的状态一并丢失(实测:4 戳含 1 坏 → peers() 抛错;删坏戳 → 恢复 3 条)。
|
|
200
|
+
try:
|
|
201
|
+
ts = float(rec.get("ts") or 0)
|
|
202
|
+
except (TypeError, ValueError):
|
|
203
|
+
return None
|
|
204
|
+
rec["age"] = max(0.0, time.time() - ts)
|
|
196
205
|
return rec
|
|
197
206
|
|
|
198
207
|
|