@furongjun1999/dsh-memory 0.7.1 → 0.7.3
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 +58 -48
- package/codebuddy/CODEBUDDY.md +9 -9
- package/docs/README.md +148 -144
- package/docs/discipline/harnesses.yaml +16 -8
- package/docs/discipline/templates/zcode-user.md.tmpl +49 -0
- package/docs/eval/AGI/344/270/203/347/273/264/350/257/204/345/210/206/346/212/245/345/221/212_/345/205/255/345/256/266/350/256/260/345/277/206/347/263/273/347/273/237/345/220/214/345/260/272/345/256/236/346/265/213_v3.1.md +340 -0
- package/docs/eval/N225_/347/264/242/345/274/225/346/227/245/345/277/227/351/235/236/345/257/271/350/261/241/350/243/205/350/275/275/351/235/242/347/261/273/345/236/213/351/227/270_v1.0.md +2 -2
- package/docs/eval/cons200_/345/206/262/347/252/201/346/243/200/346/265/213/351/200/211/351/235/242_/345/256/236/346/226/275/350/256/260/345/275/225_v1.0.md +1 -1
- package/docs/eval/cons200_/345/206/262/347/252/201/346/243/200/346/265/213/351/200/211/351/235/242_/345/256/236/346/226/275/350/256/260/345/275/225_v1.1.md +1 -1
- package/docs/eval/issue43_/351/273/230/350/256/244/347/255/226/347/225/245/344/270/216/351/224/256/347/261/273/345/236/213/351/227/270_v1.1.md +1 -1
- package/docs/eval/issue43_/351/273/230/350/256/244/347/255/226/347/225/245/345/212/240/350/275/275/344/270/216/345/207/255/346/215/256/346/230/216/346/226/207/351/230/237/345/210/227_v1.0.md +2 -2
- package/docs/eval/issue50_/345/205/203/346/225/260/346/215/256/351/200/217/344/274/240/344/270/216/345/205/234/345/272/225_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +5 -5
- package/docs/eval/issue50_/345/215/212/351/207/215/345/244/215/345/276/205/345/256/232/345/244/215/346/240/270_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +9 -9
- package/docs/eval/issue50_/345/276/205/345/256/232/345/244/215/346/240/270/345/205/245/351/230/237_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +4 -4
- package/docs/eval/issue50_/351/207/215/350/246/201/345/272/246/345/220/214/346/272/220/344/270/216/344/277/235/346/212/244/350/257/255/344/271/211_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +1 -1
- package/docs/eval/issue51_/344/270/200/351/224/256/345/256/211/350/243/205/345/244/261/350/264/245_/345/275/222/345/261/236/345/210/244/345/256/232_v1.0.md +1 -1
- package/docs/eval/issue52_/346/235/241/344/273/266/345/205/210/350/241/214/344/270/216/346/210/252/346/226/255/345/217/257/350/247/202/346/265/213_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +3 -3
- package/docs/eval//344/270/211/346/241/243/350/207/252/346/262/273_/346/255/245/351/252/244/342/221/242/345/217/230/346/233/264/345/215/225/344/270/216/345/233/236/346/273/232/345/216/237/350/257/255_/350/220/275/347/240/201/350/256/260/345/275/225_v1.0.md +3 -3
- package/docs/eval//344/270/211/346/241/243/350/207/252/346/262/273_/346/255/245/351/252/244/342/221/243/345/207/206/345/205/245/350/257/273/346/225/260_/350/220/275/347/240/201/350/256/260/345/275/225_v1.0.md +7 -7
- package/docs/eval//344/274/230/345/214/226/347/254/254/344/270/200/346/211/271_/346/216/245/347/272/277/344/270/216/347/255/211/344/273/267/345/217/230/346/215/242_v1.0.md +2 -2
- package/docs/eval//344/274/230/345/214/226/347/254/254/344/270/211/346/211/271_/351/227/250/347/246/201/350/275/254/346/255/243/344/270/216/350/260/203/345/272/246/346/255/242/350/241/200/344/270/216/351/227/250/346/216/247/346/224/266/345/217/243_v1.0.md +1 -1
- package/docs/eval//344/274/230/345/214/226/347/254/254/344/272/214/346/211/271_/344/276/235/350/265/226/351/200/217/344/274/240/344/270/216/345/257/271/346/213/215/345/217/243/345/276/204/344/270/216/350/264/237/347/274/223/345/255/230_v1.0.md +7 -7
- package/docs/eval//345/207/272/350/264/247/351/235/242/345/206/222/347/203/237_/350/277/233/350/264/247/351/227/250/347/246/201_v1.0.md +10 -10
- package/docs/eval//345/217/221/345/270/20307_/345/244/226/351/203/250/346/212/245/345/221/212/345/233/233/346/211/271/344/277/256/345/244/215/344/270/216/346/217/222/344/273/266/351/235/242/345/212/240/345/233/272_v1.0.md +4 -0
- package/docs/eval//345/217/221/345/270/20308_/350/207/252/350/277/255/344/273/243/344/270/216/347/235/241/347/234/240_/345/233/276/346/243/200/347/264/242/350/267/257/344/270/216/346/235/203/351/207/215_v1.0.md +1 -1
- package/docs/eval//345/217/221/345/270/20309_/346/243/200/347/264/242/351/235/242/344/270/211/346/211/271/346/224/266/345/217/243_v1.0.md +1 -1
- package/docs/eval//345/217/221/345/270/20310_/350/257/273/351/235/242/346/215/237/345/235/217UTF8/345/256/266/346/227/217/346/224/266/345/217/243_v1.0.md +71 -0
- package/docs/eval//345/217/221/345/270/20311_/345/244/226/346/212/245/345/205/255/350/277/236/344/277/256/344/270/216/344/270/226/347/225/214/346/250/241/345/236/213/345/272/225/345/272/247_v1.0.md +91 -0
- package/docs/eval//345/275/222/344/270/200/345/261/202/347/274/272/347/234/201/347/277/273/345/205/263_/344/277/256/345/244/215/350/256/260/345/275/225_v1.0.md +2 -2
- package/docs/eval//347/224/250/346/210/267/350/243/201/345/206/263/345/244/204/347/275/256_/347/254/254/344/270/200/346/211/271_v1.0.md +195 -0
- package/docs/eval//347/224/250/346/210/267/350/243/201/345/206/263/345/244/204/347/275/256_/347/254/254/344/272/214/346/211/271B6_/346/234/254/346/234/272/350/267/257/345/276/204/347/233/270/345/257/271/345/214/226_v1.0.md +78 -0
- package/docs/eval//347/253/257/345/210/260/347/253/257LoCoMoQA/345/220/214/345/217/243/345/276/204/345/257/271/347/205/247_v1.0.md +1 -1
- package/docs/eval//347/253/257/345/210/260/347/253/257/345/271/262/346/211/260/346/261/240/350/257/204/346/265/213_/347/241/256/345/256/232/346/200/247/350/243/201/345/206/263vsLLM_judge_v1.1.md +3 -3
- package/docs/eval//347/254/2543/345/261/202stg/347/273/223/346/236/204/347/264/242/345/274/225_/345/256/236/346/226/275/350/256/260/345/275/225_v1.0.md +1 -1
- package/docs/eval//347/274/226/347/240/201/351/235/242/345/211/215/347/275/256_/345/205/245/345/217/243/350/207/252/344/277/235/350/257/201UTF8/344/270/216/346/226/207/346/234/254open/345/256/210/345/215/253_v1.0.md +1 -1
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v26.md +196 -0
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v27.md +259 -0
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v28.md +217 -0
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v29.md +270 -0
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v30.md +231 -0
- package/docs/eval//347/274/272/351/231/267/346/214/226/346/216/230_/350/207/252/344/270/273/350/277/255/344/273/243_v31.md +281 -0
- package/docs/hive//345/256/211/345/205/250/345/256/241/350/256/241/345/256/236/351/224/232_v0.1.md +1 -1
- package/docs/hive//350/234/202/345/267/242M6_ingest/345/256/236/346/226/275/350/256/241/345/210/222_v0.1.md +1 -1
- package/docs/hive//350/234/202/345/267/242/345/217/214/345/256/236/344/276/213/344/272/222/351/252/214_/350/256/276/350/256/241/345/256/232/347/250/277.md +1 -1
- package/docs/hive//350/234/202/345/267/242/350/256/276/350/256/241_/347/220/206/350/256/272/345/257/271/351/275/220_v0.1.md +17 -17
- package/docs/hive//350/234/202/345/267/242/350/277/255/344/273/243_/345/256/217/350/247/202/344/270/216/347/276/244/344/275/223/350/260/203/345/272/246_v0.1.md +1 -1
- package/docs/mdcg/README/350/257/246/347/273/206/347/211/210_v0.4.10.md +2 -2
- package/docs/mdcg//345/212/237/350/203/275/350/260/203/347/224/250/346/230/240/345/260/204/350/241/250_v0.1.md +42 -41
- package/docs/mdcg//345/217/221/345/270/203/351/227/250/347/246/201/351/223/276_v0.1.md +29 -8
- package/docs/mdcg//347/235/241/347/234/240/345/221/250/346/234/237_/350/277/220/347/273/264/345/211/215/346/217/220/344/270/216/347/273/264/346/212/244/346/214/207/345/215/227_v1.0.md +71 -1
- package/docs/plans//345/205/250/344/270/255/346/226/207/347/274/226/347/240/201/344/270/216/350/234/202/345/267/242/344/273/273/345/212/241/346/240/207/350/257/206/345/245/221/347/272/246_v2.0.md +1 -1
- package/docs/plans//345/244/232/344/270/273/344/275/223/344/270/226/347/225/214/346/250/241/345/236/213_/345/257/271/351/275/220/350/257/204/344/274/260/344/270/216/350/220/275/345/234/260/350/256/276/350/256/241_v0.1.md +141 -0
- package/docs/plans//347/235/241/347/234/240/344/270/216/350/207/252/350/277/255/344/273/243_/345/212/237/350/203/275/344/274/230/345/214/226/350/256/276/350/256/241_v0.4.md +2 -2
- package/docs/plans//350/257/255/344/271/211/346/227/266/347/251/272/345/233/276/350/241/245/345/205/250_/344/270/226/347/225/214/346/250/241/345/236/213/345/212/237/350/203/275/347/253/257_/350/256/276/350/256/241_v0.1.md +107 -0
- 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 +9 -8
- package/docs//347/247/244_/350/256/260/345/277/206/347/263/273/347/273/237/350/257/204/346/265/213/350/247/204/350/214/203_v2.1.md +225 -0
- package/dsh/cordis-patch-profile-web.example.yml +2 -2
- package/lib/bridge.js +9 -0
- package/lib/hooks.d.ts +8 -1
- package/lib/hooks.js +94 -32
- package/lib/lib/hook_audit.d.ts +55 -0
- package/lib/lib/hook_audit.js +208 -0
- package/lib/lib/mutual.js +5 -1
- package/lib/lib/roleplay_web.js +17 -2
- package/md_cg/auditview.py +248 -0
- package/md_cg/bench6_arms.py +10 -6
- package/md_cg/bench_e2e_judge.py +4 -2
- package/md_cg/branches.py +29 -3
- package/md_cg/census.py +2 -1
- package/md_cg/consistency.py +38 -13
- package/md_cg/datapath.py +38 -11
- package/md_cg/forgetting.py +15 -2
- package/md_cg/freshness.py +32 -11
- package/md_cg/ghostref.py +130 -0
- package/md_cg/judgment_manifest.py +7 -0
- package/md_cg/mcp_server.py +58 -1
- package/md_cg/mdcg.py +4923 -4764
- package/md_cg/mdcos.py +40 -15
- package/md_cg/mreview/locate.py +1 -1
- package/md_cg/nodefile.py +77 -13
- package/md_cg/readcache.py +29 -4
- package/md_cg/rollback.py +12 -3
- package/md_cg/routing.py +10 -1
- package/md_cg/selfreport.py +12 -3
- package/md_cg/sleep.py +129 -13
- package/md_cg/sources.py +1 -1
- package/md_cg/state_events.py +131 -0
- package/md_cg/sustain.py +1436 -1436
- package/md_cg/test_auditview.py +277 -0
- package/md_cg/test_autonomy_modes.py +2 -1
- package/md_cg/test_boot_openblas_guard.py +197 -0
- package/md_cg/test_ccg_form_parity.py +95 -4
- package/md_cg/test_cons200_scan_selection.py +4 -2
- package/md_cg/test_corrupt_utf8_read_surfaces.py +451 -0
- package/md_cg/test_datapath_device_name.py +62 -3
- package/md_cg/test_generation_guard.py +20 -11
- package/md_cg/test_ghostref.py +182 -0
- package/md_cg/test_health_corrupt_utf8.py +37 -0
- package/md_cg/test_index_crossprocess_reload.py +39 -24
- package/md_cg/test_interop.py +1 -1
- package/md_cg/test_issue52_scan_condition_first.py +1 -1
- package/md_cg/test_issue53_cipher_health_hash.py +385 -0
- package/md_cg/test_lock.py +16 -7
- package/md_cg/test_m3_h9_semantic_guard.py +1 -1
- package/md_cg/test_n230_dirty_replay.py +375 -375
- package/md_cg/test_n238_body_text_parity.py +156 -0
- package/md_cg/test_n276_probe_hoist.py +199 -0
- package/md_cg/test_p4_freshness.py +95 -1
- package/md_cg/test_policy_required_ccg.py +3 -1
- package/md_cg/test_readcache_prodpath.py +66 -0
- package/md_cg/test_sleep.py +58 -1
- package/md_cg/test_sleep_p1.py +218 -2
- package/md_cg/test_state_events.py +178 -0
- package/md_cg/test_time_core_lint.py +8 -1
- package/md_cg/test_writepipe.py +8 -5
- package/md_cg/tokens.py +11 -2
- package/md_cg/writepipe.py +76 -0
- package/package.json +2 -2
- package/skills/plugin.json +1 -1
- package/src/bridge.ts +9 -0
- package/src/hooks.ts +576 -517
- package/src/lib/hook_audit.ts +243 -0
- package/src/lib/mutual.ts +5 -1
- package/src/lib/roleplay_web.ts +17 -2
- package/zcode/AGENTS.md +9 -9
package/md_cg/mdcos.py
CHANGED
|
@@ -977,7 +977,9 @@ class MdCGOS(MdCG):
|
|
|
977
977
|
# 语义资格(MDCG_SEMANTIC=1):fm.semantic 节点无条件入池
|
|
978
978
|
hits = [d for d in docs
|
|
979
979
|
if self._like(d[2], d[1], terms,
|
|
980
|
-
index_key_hits(d[0], terms, q)
|
|
980
|
+
index_key_hits(d[0], terms, q),
|
|
981
|
+
entry=d[0],
|
|
982
|
+
positive_body=self._positive_body)
|
|
981
983
|
or (semantic_on() and d[1].get("semantic"))]
|
|
982
984
|
out = try_stage(hits, TIER_BUCKET_LIKE)
|
|
983
985
|
if out:
|
|
@@ -1004,7 +1006,9 @@ class MdCGOS(MdCG):
|
|
|
1004
1006
|
_dif = set(_rstat.get("reach_diffused_paths") or ())
|
|
1005
1007
|
hits_r = [d for d in docs_r
|
|
1006
1008
|
if self._like(d[2], d[1], terms,
|
|
1007
|
-
index_key_hits(d[0], terms, q)
|
|
1009
|
+
index_key_hits(d[0], terms, q),
|
|
1010
|
+
entry=d[0],
|
|
1011
|
+
positive_body=self._positive_body)
|
|
1008
1012
|
or (semantic_on() and d[1].get("semantic"))
|
|
1009
1013
|
or d[0].get("path") in _dif] # 图扩散补召回:无词面命中也放行进打分
|
|
1010
1014
|
stat["pre_cap"] = len(hits_r) # 与 T2 同序:截断**前**的候选数
|
|
@@ -1038,7 +1042,9 @@ class MdCGOS(MdCG):
|
|
|
1038
1042
|
# 语义资格(MDCG_SEMANTIC=1):fm.semantic 节点无条件入池
|
|
1039
1043
|
hits = [d for d in docs_all
|
|
1040
1044
|
if self._like(d[2], d[1], terms,
|
|
1041
|
-
index_key_hits(d[0], terms, q)
|
|
1045
|
+
index_key_hits(d[0], terms, q),
|
|
1046
|
+
entry=d[0],
|
|
1047
|
+
positive_body=self._positive_body)
|
|
1042
1048
|
or (semantic_on() and d[1].get("semantic"))]
|
|
1043
1049
|
stat["pre_cap"] = len(hits)
|
|
1044
1050
|
stat["cap"] = GLOBAL_CAP
|
|
@@ -1088,7 +1094,9 @@ class MdCGOS(MdCG):
|
|
|
1088
1094
|
# 语义摘要=检索面(设想核心),否则摘要层只在 LIKE 全空时生效
|
|
1089
1095
|
hits = [d for d in docs
|
|
1090
1096
|
if self._like(d[2], d[1], terms,
|
|
1091
|
-
index_key_hits(d[0], terms, query)
|
|
1097
|
+
index_key_hits(d[0], terms, query),
|
|
1098
|
+
entry=d[0],
|
|
1099
|
+
positive_body=self._positive_body)
|
|
1092
1100
|
or (semantic_on() and d[1].get("semantic"))]
|
|
1093
1101
|
if not hits:
|
|
1094
1102
|
# 兜底池(LIKE 全空 = 无相关度信号):截断依据=importance/created_at
|
|
@@ -1346,8 +1354,10 @@ class MdCGOS(MdCG):
|
|
|
1346
1354
|
out = []
|
|
1347
1355
|
for e, fm, c in self._read_many(entries, stat):
|
|
1348
1356
|
tags = " ".join(str(t) for t in (fm.get("tags") or []))
|
|
1349
|
-
# 负条件行不作召回键(反例命中应由 judge 走 REJECT
|
|
1350
|
-
|
|
1357
|
+
# 负条件行不作召回键(反例命中应由 judge 走 REJECT,不该召回节点)。
|
|
1358
|
+
# N273:走 `_positive_body` 钩子(readcache 启用时 path 键控缓存
|
|
1359
|
+
# 版)——与 `_like` 侧同一条派生物缓存口径,不再是第二处直调。
|
|
1360
|
+
cov = _weighted_coverage(tw, f"{self._positive_body(e, c)} {tags}")
|
|
1351
1361
|
if cov <= 0.0:
|
|
1352
1362
|
continue
|
|
1353
1363
|
e_dom = routing.route_key(None, e.get("tags"))
|
|
@@ -3005,7 +3015,7 @@ class MdCGOS(MdCG):
|
|
|
3005
3015
|
def is_tombstoned(self, node_id: str):
|
|
3006
3016
|
return any(r.get("id") == node_id for r in read_jsonl(self.deletions_log))
|
|
3007
3017
|
|
|
3008
|
-
# 生效条件:当 node_id 传入时,若 deletions_log 中存在该 id 且 force=False 返回 tombstoned 拒绝;否则检查 trash_dir/{node_id}.md,os.path.exists 为 False 返回 not_in_trash
|
|
3018
|
+
# 生效条件:当 node_id 传入时,若 deletions_log 中存在该 id 且 force=False 返回 tombstoned 拒绝;否则检查 trash_dir/{node_id}.md,os.path.exists 为 False 返回 not_in_trash;文件含坏字节(非 UTF-8)无法解析时返回 error=corrupt 且 trash 源原样保留(不删不移);可打开则读取并以 add(override=True) + trash frontmatter 元数据全量透传(显式形参逐项传,其余键经 **extra 回写;lifecycle_state 仅在 active→该态合法迁移时透传)恢复、移除 trash 源、audit,返回 ok True/id/forced=bool(force);
|
|
3009
3019
|
def restore(self, node_id: str, force: bool = False):
|
|
3010
3020
|
"""恢复:若在删除清单中且未 force → 拒绝(恢复时删除检查)。"""
|
|
3011
3021
|
tomb = [r for r in read_jsonl(self.deletions_log) if r.get("id") == node_id]
|
|
@@ -3015,8 +3025,14 @@ class MdCGOS(MdCG):
|
|
|
3015
3025
|
src = os.path.join(self.trash_dir, f"{node_id}.md")
|
|
3016
3026
|
if not os.path.exists(src):
|
|
3017
3027
|
return {"ok": False, "error": "not_in_trash"}
|
|
3018
|
-
|
|
3019
|
-
|
|
3028
|
+
try:
|
|
3029
|
+
with open(src, encoding="utf-8") as f:
|
|
3030
|
+
fm, content = nodefile.loads(f.read())
|
|
3031
|
+
except UnicodeDecodeError:
|
|
3032
|
+
# trash 源损坏:返回结构化失败,源文件原样保留(不删不移)
|
|
3033
|
+
return {"ok": False, "error": "corrupt",
|
|
3034
|
+
"reason": "trash 文件非 UTF-8(损坏),恢复中止;"
|
|
3035
|
+
"源文件原样保留"}
|
|
3020
3036
|
layer = fm.get("layer", "knowledge")
|
|
3021
3037
|
# 恢复 = 原样放回:add 是**全量重建 fm**,只传个位数字段会把 edges/
|
|
3022
3038
|
# depends_on/验证态/生命周期/created_at/语义摘要/证据计数等元数据永久
|
|
@@ -4410,9 +4426,15 @@ class MdCGOS(MdCG):
|
|
|
4410
4426
|
def check_consistency(self, content, layer=None, condition_space=None,
|
|
4411
4427
|
non_applicable_conditions=None, tags=None,
|
|
4412
4428
|
exclude=None, limit=consistency.MAX_SCAN,
|
|
4413
|
-
depth=consistency.MAX_DEPTH, auto_flywheel=False
|
|
4429
|
+
depth=consistency.MAX_DEPTH, auto_flywheel=False,
|
|
4430
|
+
log_write=True):
|
|
4414
4431
|
"""不落盘地预检一条待写内容是否与既有节点/纪律冲突(三级决策)。
|
|
4415
4432
|
|
|
4433
|
+
log_write(路线 C,2026-10-05,透传 consistency.check 同名参数):
|
|
4434
|
+
缺省 True=原行为(落 `_consistency.jsonl` 台账);**只读消费面**
|
|
4435
|
+
(auditview 证据审计)传 False——判定照常返回、台账不写(「不落盘
|
|
4436
|
+
预检」承诺的补全:既有 log 是无条件写,只读面消费会变成隐式写)。
|
|
4437
|
+
|
|
4416
4438
|
对齐《智能的公理化基石》§十一(情绪=信息差二阶变化,独立不参与信任)、
|
|
4417
4439
|
条件论「反题」(预测与事实冲突)、:273(递归受深度/节点/循环/增益门槛约束)。
|
|
4418
4440
|
|
|
@@ -4430,7 +4452,7 @@ class MdCGOS(MdCG):
|
|
|
4430
4452
|
if not _is_null_condition(x)],
|
|
4431
4453
|
tags=tags,
|
|
4432
4454
|
exclude=exclude, limit=limit, depth=depth,
|
|
4433
|
-
auto_flywheel=auto_flywheel)
|
|
4455
|
+
auto_flywheel=auto_flywheel, log_write=log_write)
|
|
4434
4456
|
|
|
4435
4457
|
# 生效条件:当 limit 传入时,以 limit(默认 100)调用 consistency.history 并返回其结果;本函数不改变 limit;
|
|
4436
4458
|
def consistency_history(self, limit=100):
|
|
@@ -5097,8 +5119,8 @@ class MdCGSecure(MdCGOS):
|
|
|
5097
5119
|
def _neg_coverage(self, terms):
|
|
5098
5120
|
return [e for e in super()._neg_coverage(terms) if self._readable(e)]
|
|
5099
5121
|
|
|
5100
|
-
# 生效条件:node_id 在 self.index["nodes"] 中存在且 self._readable(e) 为假时返回 None,否则转 super().get(node_id);索引缺该条目时**先做代际探活重载再判可见性**(N196:索引缺条目 ≡ 本进程陈旧,不得据以跳过读隔离),重载后仍无条目才回落 super().get 的 not_found 语义;super().get 返回真值节点后用**同一次读取所得的 frontmatter**(sensitivity/session)再判一次可见性,为假即返回 None(N213:命中陈旧条目的路径不得以旧快照当判据、以新盘面当正文);
|
|
5101
|
-
def get(self, node_id: str):
|
|
5122
|
+
# 生效条件:probe 为真(缺省,行为与改动前逐位一致)时,索引缺该条目才做代际探活重载(N196)且 super().get 照旧探活;probe=False 时两处探活一并跳过(N276:调用方已在本批读之前探过一次,批量循环内的逐节点读不再各自重探);其余判据与 probe 无关:node_id 在 self.index["nodes"] 中存在且 self._readable(e) 为假时返回 None,否则转 super().get(node_id, probe=probe);索引缺该条目时**先做代际探活重载再判可见性**(N196:索引缺条目 ≡ 本进程陈旧,不得据以跳过读隔离),重载后仍无条目才回落 super().get 的 not_found 语义;super().get 返回真值节点后用**同一次读取所得的 frontmatter**(sensitivity/session)再判一次可见性,为假即返回 None(N213:命中陈旧条目的路径不得以旧快照当判据、以新盘面当正文);
|
|
5123
|
+
def get(self, node_id: str, probe: bool = True):
|
|
5102
5124
|
e = self.index["nodes"].get(node_id)
|
|
5103
5125
|
if e is None:
|
|
5104
5126
|
# N196(2026-09-28):索引缺条目**不**等于「节点不存在」——本进程
|
|
@@ -5108,11 +5130,14 @@ class MdCGSecure(MdCGOS):
|
|
|
5108
5130
|
# 第二次读才归 None,因为那时条目已随重载进入索引)。先探活重载
|
|
5109
5131
|
# 再判可见性;真不存在时 e 仍为 None,super().get 照旧返回 None。
|
|
5110
5132
|
# 成本只在**未命中**路径(一次 stat),命中路径零变化。
|
|
5111
|
-
|
|
5133
|
+
# N276:probe=False(批内单探针)时本探活同跳——语义窗口见
|
|
5134
|
+
# forgetting.redundancy 同注(本批读期间他进程写入不探知)。
|
|
5135
|
+
if probe:
|
|
5136
|
+
self._maybe_reload_index()
|
|
5112
5137
|
e = self.index["nodes"].get(node_id)
|
|
5113
5138
|
if e is not None and not self._readable(e):
|
|
5114
5139
|
return None # 读隔离:不可见即不存在
|
|
5115
|
-
node = super().get(node_id)
|
|
5140
|
+
node = super().get(node_id, probe=probe)
|
|
5116
5141
|
if node is None:
|
|
5117
5142
|
return None
|
|
5118
5143
|
# N213(2026-09-28):命中陈旧条目的路径此前**零探活**——可见性判据取自
|
package/md_cg/mreview/locate.py
CHANGED
|
@@ -312,7 +312,7 @@ def load_node(node_id, root, *, index=None) -> dict:
|
|
|
312
312
|
try:
|
|
313
313
|
with open(fp, encoding="utf-8") as f:
|
|
314
314
|
text = f.read()
|
|
315
|
-
except OSError:
|
|
315
|
+
except (OSError, UnicodeDecodeError):
|
|
316
316
|
return {"node_id": node_id, "meta": dict(meta), "fm": {}, "content": None,
|
|
317
317
|
"text": None, "path": fp}
|
|
318
318
|
fm, content = NF.loads(text)
|
package/md_cg/nodefile.py
CHANGED
|
@@ -123,6 +123,22 @@ REPRODUCIBLE_BASIS = ("compiler", "test", "measurement", "formal_proof", "data")
|
|
|
123
123
|
#: 来源一致性档:文科断言可用(来源表述一致即可)
|
|
124
124
|
CONSISTENCY_BASIS = ("textbook", "public_kb")
|
|
125
125
|
|
|
126
|
+
# ---- 多主体世界模型对齐(2026-10-05):检验强度字段真源 ----------------------------
|
|
127
|
+
# 「检验强度」分级(过程追踪过程 tracing 方法,见对齐评估 v0.1 §2 L1):一条断言
|
|
128
|
+
# 的**证据能带走多少裁决权重**——hoop(必要证据:不满足即证伪)/ smoking_gun
|
|
129
|
+
# (决定性:单独即可确立)/ doubly_decisive(同时排除竞争假设)。与
|
|
130
|
+
# `verification_basis`(来源**类型**)正交:一个说「凭什么类别的证据」,一个说
|
|
131
|
+
# 「证据的裁决力有多强」。缺省 None=未声明(**不落 fm 键**,存量零迁移、读取侧
|
|
132
|
+
# `.get()` 回落);显式传入时校验闭集(与 VERIFICATION_BASIS 同风格)。
|
|
133
|
+
CHECK_STRENGTHS = ("hoop", "smoking_gun", "doubly_decisive")
|
|
134
|
+
CHECK_STRENGTH_FIELD = "check_strength"
|
|
135
|
+
|
|
136
|
+
#: 幽灵引用标记字段(A2,多主体世界模型对齐 v0.1 §2 L1「转引不得升级」):
|
|
137
|
+
#: 写入链检测到的**无可解析出处**的回指短语清单(短语层),落 fm 供后续
|
|
138
|
+
#: 裁决/检索看见。**正文属性**:每次写入按当次检测重算、不继承(与
|
|
139
|
+
#: check_strength 的声明继承语义相反——正文变了检测就该变)。
|
|
140
|
+
UNCERTAIN_REFS_FIELD = "uncertain_refs"
|
|
141
|
+
|
|
126
142
|
# ---- 裁定 D(2026-09-19):可验证记忆单元的**字段名真源** --------------------------
|
|
127
143
|
# 「子功能」的契约角色是**依赖 dependency**(见 CCG_CONTRACT_ROLES),其落字段即
|
|
128
144
|
# `depends_on`——名字与角色对齐(不叫 sub_features,避免同一概念两种写法)。
|
|
@@ -386,6 +402,48 @@ def ccg_mark_present(content: str, mark: str) -> bool:
|
|
|
386
402
|
return False
|
|
387
403
|
|
|
388
404
|
|
|
405
|
+
# 生效条件:content 为真时逐行扫描——命中 marks 中任一要素的 CCG 标题行(判据单点 _ccg_heading_rest,`^#\s*<要素>` 冒号可有可无)即整段剥除:行内带值(`# 生效条件:v`/前缀式)只剥该行,裸标题连同其后首个非空、非标题行(该字段的值行,取值口径同 ccg_field_value)一并剥除;其余原行原样保留(含缩进)以 "\n" 连接返回;content 假值按空串返回。
|
|
406
|
+
def _strip_ccg_segments(content, marks=CCG_MARKS):
|
|
407
|
+
"""剥除 CCG 声明**整段字段**后的文本——剥除算法单点。
|
|
408
|
+
|
|
409
|
+
单点动因(N238 同族):六要素允许无冒号形态(`# 不适用条件` + 换行 + 值行),
|
|
410
|
+
**值行才是内容本体**;只剥标题行会把该字段的正文留在正文里——同一条内容写成
|
|
411
|
+
带冒号时剥净、写成无冒号时残留,两种写法给出两种结论(该缺陷在
|
|
412
|
+
`consistency._body_text` 已按 N238 收口,本函数把**剥除算法本身**也收成一份,
|
|
413
|
+
防下游再各写一份循环而漂移)。调用方:`positive_body`(只剥不适用条件)与
|
|
414
|
+
`consistency._body_text`(剥全部六要素)。
|
|
415
|
+
|
|
416
|
+
判据一律走单点(`_ccg_heading_rest`,与写入闸门 data/policy.json 同一行语义):
|
|
417
|
+
缩进标题与二级标题不构成「已声明」,与 `ccg_mark_present` 同边界。
|
|
418
|
+
"""
|
|
419
|
+
lines = (content or "").split("\n")
|
|
420
|
+
out = []
|
|
421
|
+
i, n = 0, len(lines)
|
|
422
|
+
while i < n:
|
|
423
|
+
rest = None
|
|
424
|
+
for mark in marks:
|
|
425
|
+
rest = _ccg_heading_rest(lines[i], mark)
|
|
426
|
+
if rest is not None:
|
|
427
|
+
break
|
|
428
|
+
if rest is None:
|
|
429
|
+
out.append(lines[i])
|
|
430
|
+
i += 1
|
|
431
|
+
continue
|
|
432
|
+
i += 1
|
|
433
|
+
if rest.strip():
|
|
434
|
+
continue # 行内已带值(冒号式 `# 字段:v` / 前缀式)→ 只剥该行
|
|
435
|
+
while i < n: # 裸标题:其后首个非空、非标题行是值行,同剥
|
|
436
|
+
t = lines[i].strip()
|
|
437
|
+
if not t:
|
|
438
|
+
i += 1
|
|
439
|
+
continue
|
|
440
|
+
if t.startswith("#"):
|
|
441
|
+
break # 下一个标题 ⇒ 本字段值为空,不消费
|
|
442
|
+
i += 1
|
|
443
|
+
break
|
|
444
|
+
return "\n".join(out)
|
|
445
|
+
|
|
446
|
+
|
|
389
447
|
# 生效条件:content 中出现 "# {mark}:" 或 "# {mark}:"(中/英文冒号)或仅 "# {mark}" 标题行即把该 mark 计入 present 与 required_present;complete 为 required_present 覆盖全部 CCG_REQUIRED、all_present 为 present 覆盖全部 CCG_MARKS,ratio = len(required_present)/len(CCG_REQUIRED),四键连同两个清单一起返回。
|
|
390
448
|
def ccg_completeness(content: str) -> dict:
|
|
391
449
|
"""CCG 要素齐全度——白箱可审计性的量化指标。
|
|
@@ -441,39 +499,45 @@ def is_placeholder_text(value) -> bool:
|
|
|
441
499
|
return any(m in s for m in PLACEHOLDER_MARKERS)
|
|
442
500
|
|
|
443
501
|
|
|
444
|
-
# 生效条件:content
|
|
502
|
+
# 生效条件:content 中存在 NEG_FIELD("不适用条件")的 CCG 标题行(判据单点 ccg_mark_present,`^#\s*不适用条件`,冒号可有可无,与写入闸门同一行语义)时返回 True,否则 False。
|
|
445
503
|
def has_non_applicable(content: str) -> bool:
|
|
446
504
|
"""是否声明了不适用条件——REJECT 路径成立的必要条件。
|
|
447
505
|
|
|
448
506
|
没有不适用条件的节点在白箱下不能 REJECT(无法证明「不适用」),
|
|
449
507
|
只能 ACCEPT 或 BLINDSPOT。这是第 1 篇第 10 章从 28%→88% 的关键。
|
|
508
|
+
|
|
509
|
+
A3(N238 同族残面):判据单点 = `ccg_mark_present`——本函数原先只认
|
|
510
|
+
「`# 不适用条件:`/`# 不适用条件:`」两种**带冒号**的字面量,无冒号形态
|
|
511
|
+
(`# 不适用条件` + 换行 + 值行)被判成「没声明」:同一条正文写不写冒号
|
|
512
|
+
给出两种结论,而「冒号可有可无」已由单点定案(test_ccg_form_parity ①-⑦)。
|
|
513
|
+
消费面:索引条目 `has_neg_conditions`(mdcg `_entry` / rebuild / `_stage`),
|
|
514
|
+
进而 `export`/`insight`/`sustain`/`predict` 的统计与边界读数。
|
|
450
515
|
"""
|
|
451
|
-
return
|
|
516
|
+
return ccg_mark_present(content, NEG_FIELD)
|
|
452
517
|
|
|
453
518
|
|
|
454
519
|
#: 负条件字段名——它是**反例声明**,不是召回键
|
|
455
520
|
NEG_FIELD = "不适用条件"
|
|
456
521
|
|
|
457
522
|
|
|
458
|
-
# 生效条件:content 为 None 时按 ""
|
|
523
|
+
# 生效条件:content 为 None 时按 "" 处理;逐行剥除 NEG_FIELD 的整段 CCG 声明(剥除算法单点 _strip_ccg_segments——行内带值只剥该行,裸标题连同其后首个非空、非标题的值行一并剥除),其余行原样保留(含原缩进),返回保留行的 "\n".join。
|
|
459
524
|
def positive_body(content: str) -> str:
|
|
460
|
-
"""剥离 `#
|
|
525
|
+
"""剥离 `# 不适用条件` 声明段后的正文——负条件不作召回键。
|
|
461
526
|
|
|
462
527
|
不适用条件声明的是「什么时候**不**适用」,其触发词是反例。一旦把它当召回
|
|
463
528
|
键,查询命中反例时节点反而被召回——**恰好在它不该适用的地方被召回**,属实
|
|
464
529
|
质性错误。反例的正确去向是 `judge_qualification` 的 REJECT 路径(读
|
|
465
530
|
`frontmatter.non_applicable_conditions`),而不是召回。
|
|
466
531
|
|
|
467
|
-
只剥离真正的 CCG
|
|
468
|
-
|
|
532
|
+
只剥离真正的 CCG 行(判据单点 `_ccg_heading_rest`:`# <字段>` 标题前缀、
|
|
533
|
+
冒号可有可无),避免误伤正文里恰好以「不适用条件」开头的普通句子。
|
|
534
|
+
|
|
535
|
+
A3(N238 同族残面):剥的必须是**整段字段**——无冒号形态(`# 不适用条件` +
|
|
536
|
+
换行 + 值行)原先只剥标题行,值行(内容本体)残留 ⇒ 反例词面照样进召回键
|
|
537
|
+
(`MdCG._like` 实测命中),与带冒号写法的行为相反。剥除算法收在单点
|
|
538
|
+
`_strip_ccg_segments`(与 `consistency._body_text` 共用一份循环)。
|
|
469
539
|
"""
|
|
470
|
-
|
|
471
|
-
for ln in (content or "").split("\n"):
|
|
472
|
-
s = ln.strip()
|
|
473
|
-
if s.startswith("#") and s.lstrip("#").strip().startswith(NEG_FIELD):
|
|
474
|
-
continue
|
|
475
|
-
keep.append(ln)
|
|
476
|
-
return "\n".join(keep)
|
|
540
|
+
return _strip_ccg_segments(content, (NEG_FIELD,))
|
|
477
541
|
|
|
478
542
|
|
|
479
543
|
# ---- 条件空间 → 生效条件声明 -------------------------------------------------
|
package/md_cg/readcache.py
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
2. 缓存**解析产物** `(fm, content)`(benchmark 版只缓存原文,parse 仍逐次),
|
|
26
26
|
**并缓存文档侧检索派生物** `_doc_norm_bigrams`(归一化 bigram——批次 21
|
|
27
27
|
实测本机热点 88% 在此而非 I/O:内容不变则派生物不变,随读缓存常驻;
|
|
28
|
-
Rust `load_docs` 预计算 stripped/db_len
|
|
28
|
+
Rust `load_docs` 预计算 stripped/db_len 同款理论)与 `_positive_body`
|
|
29
|
+
(剥除不适用条件后的召回键正文——N273,8000 池实测 ~102ms/查询,
|
|
30
|
+
与 bigram 同一 path 键控 + 脏集失效口径,两者恒同步);
|
|
29
31
|
3. 进程内一致性边界(与 MdStore 相同的诚实边界):跨进程/外部直接改写
|
|
30
32
|
md 文件不保证可见——认知图的多进程形态(每智能体一进程)各持快照。
|
|
31
33
|
4. **读失败不固化(C-3 / FI-M02 / N134,2026-09-29)**:只接纳「成功」与
|
|
@@ -67,7 +69,7 @@ def direct_read(cg, entry):
|
|
|
67
69
|
return fn(entry)
|
|
68
70
|
|
|
69
71
|
|
|
70
|
-
# 生效条件:cg 提供 _read_status(MdCG/MdCGSecure 恒有)时按其**三态标签**包装:第三元素为 None(成功 / 终态真缺)者照脏集精确失效口径入缓存,第三元素非 None(瞬时读失败,fsutil.READ_FAIL_TRANSIENT)者**一律不入缓存**(C-3:不得把可重试的读失败以「新鲜」身份固化);cg 无 _read_status(非 MdCG 载体)时回落包装 cg._read,且空结果一律不接纳(无判别面时的保守侧:宁可重读,不可固化可能是瞬时的缺失);cg._doc_norm_bigrams 存在时同款包装其派生物(_score 热点:文档侧归一化 bigram 只依赖 content
|
|
72
|
+
# 生效条件:cg 提供 _read_status(MdCG/MdCGSecure 恒有)时按其**三态标签**包装:第三元素为 None(成功 / 终态真缺)者照脏集精确失效口径入缓存,第三元素非 None(瞬时读失败,fsutil.READ_FAIL_TRANSIENT)者**一律不入缓存**(C-3:不得把可重试的读失败以「新鲜」身份固化);cg 无 _read_status(非 MdCG 载体)时回落包装 cg._read,且空结果一律不接纳(无判别面时的保守侧:宁可重读,不可固化可能是瞬时的缺失);cg._doc_norm_bigrams 存在时同款包装其派生物(_score 热点:文档侧归一化 bigram 只依赖 content,随读缓存一并常驻);cg._positive_body 存在时同款包装其派生物(_like 热点:剥除不适用条件后的正文只依赖 content,N273 与前者同一 path 键控 + 脏集失效口径);包装后 cg._read 与 cg._doc_norm_bigrams/cg._positive_body 走缓存、cg._read_cache/_norm_bigrams_cache/_positive_body_cache 为缓存字典、cg._read_uncached 为**穿透缓存的原始二态 _read**(direct_read 的真源,返回形状与 install 前逐位一致);返回缓存字典。
|
|
71
73
|
def install(cg):
|
|
72
74
|
"""把 `cg._read`(与派生物钩子)包成**脏集精确失效**的常驻缓存。
|
|
73
75
|
|
|
@@ -189,14 +191,37 @@ def install(cg):
|
|
|
189
191
|
|
|
190
192
|
cg._doc_norm_bigrams = _cached_nb
|
|
191
193
|
cg._norm_bigrams_cache = nb_cache
|
|
194
|
+
|
|
195
|
+
# N273(第 32 轮性能面):`_positive_body` 派生物同款缓存层——同 `entry`
|
|
196
|
+
# path 键、同 `_fresh` 脏集判据、同装载/失效时机(与 `_doc_norm_bigrams`
|
|
197
|
+
# 一字不差的同形结构,故两者命中率与失效行为恒同步)。修前 `_like` 每
|
|
198
|
+
# 查询对每个候选节点直调 `nodefile.positive_body`(逐行扫 CCG 声明段),
|
|
199
|
+
# 8000 池实测每次查询 ~102ms(占热态查询 ~47%)——它却是与 bigram 同
|
|
200
|
+
# 性质的纯函数(只依赖 content),缓存不对称在此收口。
|
|
201
|
+
pb_cache = {}
|
|
202
|
+
if hasattr(cg, "_positive_body"):
|
|
203
|
+
orig_pb = cg._positive_body
|
|
204
|
+
|
|
205
|
+
def _cached_pb(entry, content):
|
|
206
|
+
p = entry["path"]
|
|
207
|
+
gen = getattr(cg._dirty, "write_gen", len(cg._dirty))
|
|
208
|
+
hit = pb_cache.get(p)
|
|
209
|
+
if hit is not None and _fresh(p, hit):
|
|
210
|
+
return hit[1]
|
|
211
|
+
val = orig_pb(entry, content)
|
|
212
|
+
pb_cache[p] = (gen, val)
|
|
213
|
+
return val
|
|
214
|
+
|
|
215
|
+
cg._positive_body = _cached_pb
|
|
216
|
+
cg._positive_body_cache = pb_cache
|
|
192
217
|
return cache
|
|
193
218
|
|
|
194
219
|
|
|
195
|
-
# 生效条件:cg._read_cache 与 cg.
|
|
220
|
+
# 生效条件:cg._read_cache、cg._norm_bigrams_cache 与 cg._positive_body_cache 均清空(写侧显式兜底;哨兵之外的强制手段),返回清空的条目总数;无缓存时返回 0。
|
|
196
221
|
def clear(cg) -> int:
|
|
197
222
|
"""强制清空(外部批量改写文件后可手动调;正常写路径无需——哨兵自动失效)。"""
|
|
198
223
|
n = 0
|
|
199
|
-
for attr in ("_read_cache", "_norm_bigrams_cache"):
|
|
224
|
+
for attr in ("_read_cache", "_norm_bigrams_cache", "_positive_body_cache"):
|
|
200
225
|
c = getattr(cg, attr, None)
|
|
201
226
|
if c:
|
|
202
227
|
n += len(c)
|
package/md_cg/rollback.py
CHANGED
|
@@ -155,7 +155,7 @@ def collect_impact(cg, node_id):
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
# 生效条件:rel 指向的文件不存在时抛 RollbackError(code="preimage_missing");存在则读取并以 cg._open_content(node_id, fm, raw) 对称解封,返回 (fm, content)——content 为 None(无密钥/身份不符)时抛 RollbackError(code="preimage_unreadable")
|
|
158
|
+
# 生效条件:rel 指向的文件不存在时抛 RollbackError(code="preimage_missing");存在则读取并以 cg._open_content(node_id, fm, raw) 对称解封,返回 (fm, content)——content 为 None(无密钥/身份不符)时抛 RollbackError(code="preimage_unreadable");文件含坏字节(非 UTF-8)无法解析时同样抛 RollbackError(code="preimage_unreadable")(fail-closed,不裸抛 UnicodeDecodeError);
|
|
159
159
|
def read_preimage(cg, node_id, rel):
|
|
160
160
|
"""读执行时点前像文件(**与 snapshot_preimage 对称**:写走 _write_node 封装、
|
|
161
161
|
读走 _open_content 解封)——返回 (fm, content)。
|
|
@@ -163,14 +163,23 @@ def read_preimage(cg, node_id, rel):
|
|
|
163
163
|
注意:快照文件以节点文件同款 nodefile 序列化落盘;加密库中其内容为密封
|
|
164
164
|
形态,必须经解封钩子读,直接 nodefile.loads 会把密文当明文再次封装
|
|
165
165
|
(双重封装)。非加密库两钩子恒等(探针实测逐字节一致)。
|
|
166
|
+
|
|
167
|
+
文件含坏字节(非 UTF-8)无法解析时抛 RollbackError(code="preimage_unreadable")
|
|
168
|
+
——fail-closed,不裸抛 UnicodeDecodeError。
|
|
166
169
|
"""
|
|
167
170
|
p = os.path.join(cg.root, str(rel).replace("/", os.sep))
|
|
168
171
|
if not os.path.isfile(p):
|
|
169
172
|
raise RollbackError("preimage_missing",
|
|
170
173
|
"前像文件不存在:%s——变更单可能未执行(无前像)"
|
|
171
174
|
"或快照被移走;fail-closed 不猜一个前像。" % rel)
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
try:
|
|
176
|
+
with open(p, encoding="utf-8") as f:
|
|
177
|
+
fm, raw = nodefile.loads(f.read())
|
|
178
|
+
except UnicodeDecodeError as exc:
|
|
179
|
+
# 坏字节/非 UTF-8:fail-closed——绝不让 UnicodeDecodeError 裸抛逃逸
|
|
180
|
+
raise RollbackError("preimage_unreadable",
|
|
181
|
+
"前像文件坏字节 / 非 UTF-8 无法解析:%s(%s)——"
|
|
182
|
+
"fail-closed 不回滚。" % (rel, exc))
|
|
174
183
|
content = cg._open_content(node_id, fm, raw)
|
|
175
184
|
if content is None:
|
|
176
185
|
raise RollbackError("preimage_unreadable",
|
package/md_cg/routing.py
CHANGED
|
@@ -314,7 +314,7 @@ def bucket_health(counts: dict, total_nodes: int = None) -> dict:
|
|
|
314
314
|
# 巨桶/期望扫描两条在 nb==1 时只是同一事实的两种写法,合并为一条如实读数。
|
|
315
315
|
# expected_scan 的**数值**仍在返回 dict 里(下游读的是数:test_p0 :92、
|
|
316
316
|
# bench_axis_domain :159),只有文案不再把「未分区」说成「巨桶退化」。
|
|
317
|
-
problems.append(f"
|
|
317
|
+
problems.append(f"单桶:仅 1 个分桶({n} 个已分桶节点同桶),"
|
|
318
318
|
"条件路由本就不可用(从未分区,非分区退化)")
|
|
319
319
|
elif expected_scan > 0.30:
|
|
320
320
|
problems.append(f"路由无效:期望扫描 {expected_scan:.1%}(接近全量)")
|
|
@@ -417,5 +417,14 @@ def classify_text(text, limit: int = 400):
|
|
|
417
417
|
|
|
418
418
|
返回 None 表示「无有效域信号」——此时**不写** big_domain 字段,
|
|
419
419
|
该节点留在 ORPHAN/兜底池(S1 收敛时必须能被兜底召回,见契约 §3 S1 不变量)。
|
|
420
|
+
|
|
421
|
+
issue #53-A:密文(`<!-- mdcg-enc:v1:…`)恒无域信号——无密钥的读面会把
|
|
422
|
+
密文**原样**交到这里,base64 噪声会碰巧命中词表(实测唯一命中形态=「经济」:
|
|
423
|
+
词表里唯一的拉丁词 GDP 被 base64 三连子串撞上),且假标签会被 backfill 的
|
|
424
|
+
already 幂等分支永久固化。判据收在此**唯一致敏点**:节点侧全部调用方
|
|
425
|
+
(add 写入面、backfill 回填面)自动同覆盖,无需各自设防。
|
|
420
426
|
"""
|
|
427
|
+
from . import crypto # 延迟导入:routing 是底层模块,避免加载序耦合
|
|
428
|
+
if crypto.is_encrypted(text):
|
|
429
|
+
return None
|
|
421
430
|
return big_domain_classify(domain_terms(text, limit))
|
package/md_cg/selfreport.py
CHANGED
|
@@ -126,10 +126,19 @@ def read_all() -> dict:
|
|
|
126
126
|
return out
|
|
127
127
|
|
|
128
128
|
|
|
129
|
-
# 生效条件:pids 为可迭代的 pid 集合(通常是「当前进程表中仍在的 md_cg
|
|
130
|
-
def purge(pids) -> int:
|
|
131
|
-
"""清掉不属于「仍在的进程」的自报文件(防目录随重启次数膨胀)。
|
|
129
|
+
# 生效条件:pids 为可迭代的 pid 集合(通常是「当前进程表中仍在的 md_cg 进程」),allow_empty 为破坏性动作的显式开关;keep 非空时删除自报目录中 pid 不在该集合内的 *.json 与遗留 *.tmp 并返回删除条数;keep 为**空集**且 allow_empty=False(默认)时一律不删并返回 0——空集既可能是「在役进程真的全部退出」也可能是「探测失败/未经校验」,两者不可分,故清空须显式开启;目录不存在或删除失败逐项吞掉,不抛。
|
|
130
|
+
def purge(pids, *, allow_empty: bool = False) -> int:
|
|
131
|
+
"""清掉不属于「仍在的进程」的自报文件(防目录随重启次数膨胀)。
|
|
132
|
+
|
|
133
|
+
N255(2026-10-05):keep 为空集时**默认不删任何东西**(fail-closed)——空集既可能来自
|
|
134
|
+
「在役进程确已全部退出」,也可能来自**一次失败/未经校验的探测**。后者在本仓实证过:
|
|
135
|
+
`scripts/mdcg_stale_servers.py` 的 scan() 尾部曾无条件调用 `purge([])`(探测失败 →
|
|
136
|
+
pids 为空),把自报目录下全部 *.json 一次删光(沙盒 3 件预置全灭)。确要清空时,由
|
|
137
|
+
**探测已成功**的调用方显式传 `allow_empty=True`(见该脚本的 purge_reports())。
|
|
138
|
+
"""
|
|
132
139
|
keep = {int(p) for p in (pids or ())}
|
|
140
|
+
if not keep and not allow_empty:
|
|
141
|
+
return 0
|
|
133
142
|
n = 0
|
|
134
143
|
try:
|
|
135
144
|
names = os.listdir(SELF_REPORT_DIR)
|