Files
dsh_ai1net_server/docs/规则与载体/验收_规则载体压缩_20260924.py
T
admin c1b5e4d966 chore(工作区): 全量入库 + 补齐 .gitignore(以工作区为准)
- 变更规模:新增 514 / 修改 62 / 重命名 155 / 删除 4(归档重组与文档轮次)
- .gitignore 修:`归档/**/db-cwd归一-备份-*/` —— 原规则写绝对层级(归档/db-cwd归一-…),
  目录搬进 归档/配置与备份/ 后**静默失效**,43 MB 的 DB 备份又变成未跟踪
- .gitignore 补:嵌套 git 内部数据(归档/内嵌git-20261008/、归档/skills-git-旧线-20261007/dotgit-原样移出/)
- .gitignore 补:运行态与部署副本(.workbuddy/collab/、.workbuddy/tools/、.workbuddy/.load-pending、.workbuddy/tmp-*)
- .gitignore 补:备份件(*.bak-*)
- 未跟踪文件从 2190 降到 890(其余为 归档/ 归档件与 .workbuddy/memory/ 知识文件,按口径入库)
2026-10-10 23:13:22 +08:00

60 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""规则载体压缩 · 端到端验收(2026-09-24)"""
import io, re, sys
WS = "E:/ProgramData/AIProject/ai1net-dsh-server"
MAIN = WS + "/CODEBUDDY.md"
REF = WS + "/docs/规则与载体/规则详解_红线与实证_20260924.md"
BAK = WS + "/归档/规则A-备份-20260924/CODEBUDDY.md.before-compress"
def rd(p):
return io.open(p, encoding="utf-8").read()
main, ref, bak = rd(MAIN), rd(REF), rd(BAK)
LIMIT = 8000
print("== 1. 体积 ==")
print(" 压缩前 =%6d 字符" % len(bak))
print(" 压缩后 =%6d 字符 (线=%d, 占比 %.0f%%)" % (len(main), LIMIT, 100.0*LIMIT/len(main)))
print(" 削减 =%6d 字符 (-%.0f%%)" % (len(bak)-len(main), 100.0*(len(bak)-len(main))/len(bak)))
print(" 目标 <=%d : %s" % (LIMIT, "达标" if len(main) <= LIMIT else "未达标(差 %d)" % (len(main)-LIMIT)))
print("== 2. 标题注入 ==")
offs = [(m.start(), m.group(0)) for m in re.finditer(r"(?m)^#{1,3} .+$", main)]
inline = [o for o, t in offs if o < LIMIT]
print(" 总标题 =%2d 线内 =%2d %s" % (len(offs), len(inline), "12/12 达标" if len(inline)==len(offs) else "未达标"))
for o, t in offs:
print(" %s %6d %s" % ("OK " if o < LIMIT else "OUT", o, t[:44]))
print("== 3. 红线 11 条可寻址 ==")
sec3 = main[main.index("## 3. 红线 R1"): main.index("## 4. 提交边界")]
ok = 0
for i in range(1, 12):
tag = "**R%d**" % i
if tag in sec3:
ok += 1
else:
print(" !! 缺失 %s" % tag)
print(" 主文件 §3 内 R1-R11 判据行 = %d/11" % ok)
print(" 解释段落点 R7-边界/R8/R9/R10/R11 在 §B: %s"
% ("齐全" if all(("B-1" in ref or i==1) and ("### B-%d" % n) in ref
for n in [1,2,3,4,5]) else "缺"))
print("== 4. 指针悬空检查 ==")
ref_secs = set(re.findall(r"(?m)^## (§[A-Z]\S*)", ref))
print(" 【详】实有章节: %s" % " ".join(sorted(ref_secs)))
want = ["§A","§B","§C","§D","§E","§F","§G","§H"]
# 主文件里指向【详】的章节号(含「详 X」「§B-1…§B-5」两种写法)
used = set(re.findall(r"【详】(§[A-Z])", main)) | set(re.findall(r"详 ([A-Z]\d)", main))
bad = [s for s in want if s not in ref_secs]
print(" A-H 全在: %s" % ("是" if not bad else "缺 %s" % bad))
print(" 主文件显式指向的章节: %s" % " ".join(sorted(used)))
print("== 5. 完好性 ==")
for k in ["R11", "R9", "R10", "分层判定标准", "动作前必须执行的三条",
"preflight-lock.sh", "state.py", "_ANCHOR_SEGS", "dshs-worker"]:
print(" %-26s 主文件 %s" % (k, "有" if k in main else "无"))
print(" 回滚点存在: %s (%d 字符)" % ("是" if bak else "否", len(bak)))
print(" 主文件与回滚点字符差 = %d" % (len(bak)-len(main)))