架构收窄批补笔(闸件适配): capability_audit.py 判据出处注记正则改双形态——行号锚(路径:行号)与节锚(路径「节名」关键词, 2026-11-07 立)并认; 节锚核验=文件存在+节名首段(「·」前)在档, 行号锚核验照旧; 「节名」与关键词间零空白形态兼容。凭据: 能力审计单跑 红项0(oracle 注记函数 417 全识别, 修前 25 红)
This commit is contained in:
1 parent
28c4645ae2
commit
52b9490e82
1 file changed
+17
-5
@@ -16,7 +16,9 @@ r"""capability_audit.py — 能力清单、覆盖域表与 GDD 纯度机检(
|
||||
对上能力表里的行名;部分/未覆盖行的缺口非空且指待办清单。
|
||||
G 判据出处随测注记(test-conventions §8.3):game/tests/** 与 game/probe/** 内每个验证函数
|
||||
(函数体含 check(/check_quiet(/_problems.append(/push_error( 判定调用,定义行与 _check( 前缀除外)
|
||||
须带 ≥1 条 `# oracle: <design/相对路径>:<行号> <判据一句>` 注记;指针指向存在的设计文档行且不出
|
||||
须带 ≥1 条 `# oracle: <design/相对路径>:<行号> <判据一句>` 注记(或节锚形态
|
||||
`# oracle: <design/相对路径>「节名」<关键词> <判据一句>`,2026-11-07 架构收窄批立,见
|
||||
test-conventions §8.3);指针指向存在的设计文档行/节且不出
|
||||
design/ 全域。扫描面=game/tests/**+game/probe/**(sim/ 不进——测量面直构惯例)。
|
||||
条件闸行豁免(代表用例含「条件闸」字样)不参与 D/E。
|
||||
|
||||
@@ -337,7 +339,7 @@ def check_coverage(cov_tables, names):
|
||||
red(README.relative_to(REPO), 1, "覆盖域表", "%s 未在覆盖域表登记" % doc)
|
||||
|
||||
|
||||
ORACLE_RE = re.compile(r"^#\s*oracle:\s*(\S+\.md):(\d+)\s+\S")
|
||||
ORACLE_RE = re.compile(r"^#\s*oracle:\s*(\S+?\.md)(?::(\d+)|「([^」]+)」)\s*\S")
|
||||
VERDICT_RE = re.compile(r"(?<![_\w])check(?:_quiet)?\(|_problems\.append\(|push_error\(")
|
||||
ORACLE_FUNC_RE = re.compile(r"^(?:static\s+)?func\s+([A-Za-z_]\w*)")
|
||||
|
||||
@@ -388,13 +390,23 @@ def check_oracle_markers():
|
||||
continue
|
||||
marked += 1
|
||||
for m in oks:
|
||||
relp, no = m.group(1), int(m.group(2))
|
||||
relp, no, sec = m.group(1), m.group(2), m.group(3)
|
||||
if not relp.replace("\\", "/").startswith("design/"):
|
||||
red(rel, s0 + 1, "判据出处注记", "%s 指针越出 design/ 全域:%s" % (name, relp))
|
||||
continue
|
||||
tp = REPO / relp
|
||||
if not tp.is_file() or not (1 <= no <= len(read(tp).splitlines())):
|
||||
red(rel, s0 + 1, "判据出处注记", "%s 指针不可核:%s:%d(文件缺失或行号越界)" % (name, relp, no))
|
||||
if not tp.is_file():
|
||||
red(rel, s0 + 1, "判据出处注记", "%s 指针不可核:%s(文件缺失)" % (name, relp))
|
||||
continue
|
||||
if no is not None:
|
||||
if not (1 <= int(no) <= len(read(tp).splitlines())):
|
||||
red(rel, s0 + 1, "判据出处注记", "%s 指针不可核:%s:%d(行号越界)" % (name, relp, int(no)))
|
||||
elif sec is not None:
|
||||
# 节锚(2026-11-07 架构收窄批立,test-conventions §8.3):核验节名首段(「·」前)
|
||||
# 在所指文档中出现——「模块归属·基础层」核「模块归属」节标题在档;关键词不核(随文档措辞漂移由人审兜)
|
||||
head = sec.split("·")[0]
|
||||
if head not in read(tp):
|
||||
red(rel, s0 + 1, "判据出处注记", "%s 节锚不可核:%s「%s」(文档内无该节名首段)" % (name, relp, head))
|
||||
return marked, flagged
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user