diff --git a/docs/planning/capability-claims.json b/docs/planning/capability-claims.json index 0628d877..60750e0c 100644 --- a/docs/planning/capability-claims.json +++ b/docs/planning/capability-claims.json @@ -16,21 +16,6 @@ "category": "限制项(limitation)", "reason": "533 审计行自述复杂构型失败率上升、CBRA 面预算 64;544 报告真实语料默认 caliber 布尔全红,不伪造绑定" }, - { - "match": "1e-6 精确交付承诺", - "category": "无承诺(no-promise)", - "reason": "生产路径无 1e-6 交付精度承诺,CBRA 明确不承诺 1e-6" - }, - { - "match": "通用 Delaunay 边界面恢复", - "category": "限制项(limitation)", - "reason": "已知失败形态 L-bracket/bug33638 体积误差 1.46%–196%,边界不闭合被拒" - }, - { - "match": "一般自由曲面 tetra", - "category": "限制项(limitation)", - "reason": "仅 prin/star/torus/sphere/cone/box/tube 有限构型;tetra 主能力已由 FEA 网格声明覆盖" - }, { "match": "CAE", "category": "广度项(breadth)", @@ -905,6 +890,91 @@ "kc": [ "KC-Q10" ] + }, + { + "id": "impl-delaunay-boundary-recovery", + "tier": "implemented", + "title": "通用 Delaunay 四面体网格的边界面恢复(面使用次数==1 + 边界 2-流形闭合)", + "statement": "cae::tetrahedral_mesh 的通用 Delaunay 路径在按内外判定删除凸包外体元后,直接用「面使用次数==1」的三角形构造边界面:并集边界天然闭合,不再有旧实现的伪边界面剔除(那一步丢面不补,是边界不闭合的根因);并以确定性微小抖动重试 +「边界面是闭合 2-流形 + 四面体结构合法 + 体积误差≤2%」三重采纳条件修复共面/共球退化产生的 pinched edge。tests/cae/test_fea_mesh.cpp 的 CorpusProbe.LBracketTetraAccepted 断言凹体 L-bracket 由通用 Delaunay 路径接受(边界闭合、体积在容差内),OpenShellIsRejectedWithDiagnostic 断言开放壳仍被明确拒绝;real 语料 L-bracket 闭合体积误差 +0.2889%、plate +0.2509%(1.0.480 现状)。533 审计 §3 L150(🟡/❌,1.0.467 时点)的限制项已由后续 VDE-1241 修复解除,本声明只覆盖闭合水密实体,开放镶嵌壳(bug33638)仍明确拒绝。", + "code": { + "file": "src/cae/fea_mesh.cpp", + "line": 3824, + "text": "只保留内部体元后,其并集边界(面使用次数==1 的三角形)天然闭合,不再", + "symbol": "面使用次数==1 的三角形", + "signature": "并集边界" + }, + "test": { + "target": "test_fea_mesh", + "case": "CorpusProbe.LBracketTetraAccepted" + }, + "evidence": { + "file": "docs/planning/remaining-gaps-2026-11-14.md", + "line": 29, + "text": "通用 Delaunay 边界面恢复" + }, + "audit_533": [ + "通用 Delaunay 边界面恢复" + ], + "kc": [ + "KC-I07" + ] + }, + { + "id": "impl-freeform-tetra-general", + "tier": "implemented", + "title": "一般自由曲面实体的通用 tetra 网格(任意闭合 B-Rep → Delaunay 路径)", + "statement": "tetrahedral_mesh 的结构化快速路径(box/棱柱/星形/环面/球等有限构型)识别失败后,走通用 Delaunay:先按 target_size 弦高三角化任意 B-Rep 表面(含平面与解析曲面片),点集 = 表面采样点 + 内部点,Delaunay 后按射线奇偶内外判定删除外部体元,再执行边界面恢复与体积校验。因此 L-bracket/plate/plate2、带圆柱孔/凸台板(CorpusProbe.PlateWithCylindricalFeaturesAccepted)等一般自由曲面/解析曲面构型被接受。533 审计 §3 L151(🟡,1.0.467 时点)「仅 prin/star/torus/sphere/cone/box/tube」的有限构型限制已随通用路径与边界面恢复解除(real 语料 L-bracket/plate/plate2 general Delaunay accepted,1.0.480 现状)。", + "code": { + "file": "src/cae/fea_mesh.cpp", + "line": 3162, + "text": "tetra_probe(\"[tetra] stage=general-path target_size=%g\\n\", target_size);", + "symbol": "stage=general-path", + "signature": "general-path" + }, + "test": { + "target": "test_fea_mesh", + "case": "CorpusProbe.PlateWithCylindricalFeaturesAccepted" + }, + "evidence": { + "file": "docs/planning/remaining-gaps-2026-11-14.md", + "line": 31, + "text": "一般自由曲面 tetra" + }, + "audit_533": [ + "一般自由曲面 tetra" + ], + "kc": [ + "KC-I07" + ] + }, + { + "id": "unsupported-exactness-1e-6-delivery", + "tier": "unsupported", + "title": "1e-6 逐点精确交付承诺(生产路径不承诺,仅容差内几何正确)", + "statement": "生产布尔/曲面路径不承诺 1e-6 逐点精确交付:brep_difference_exact 的支持域仅「单一解析基元或纯平面刀具」,域外稳定返回 nullopt(诊断 ExactNotApplicable,不再静默 fallback);CBRA 曲面布尔继承 p-curve 拟合残差(报告 537 明示「非 1e-6 精度权威」,面数上限 64);验收口径为体积/几何误差容差 + 结构化失败码(BooleanFailureReason),而非 1e-6 逐点契约。tests/brep/test_boolean_failure_semantics.cpp 的 BooleanFailureSemanticsTest.Telemetry_UncoveredFailuresIsZero 断言域外(环面刀具)exact 失败带非空失败码且不可信结果 100% 有码。533 审计 §3 L116(❌)为显式无承诺行。", + "declaration": { + "file": "docs/reference/537-VDE1.0.471-KCP-Wave4-真实模型闭合-CBRA性能-SSI区域图-中面-互操作-语料修复自验证报告.md", + "line": 77, + "text": "非 1e-6 精度权威", + "symbol": "非 1e-6 精度权威" + }, + "code": { + "file": "include/vde/brep/exactness_audit.h", + "line": 23, + "text": "[[nodiscard]] ExactnessReport validate_exact_trim(", + "symbol": "ExactnessReport validate_exact_trim\\(", + "signature": "validate_exact_trim(" + }, + "test": { + "target": "test_boolean_failure_semantics", + "case": "BooleanFailureSemanticsTest.Telemetry_UncoveredFailuresIsZero" + }, + "audit_533": [ + "1e-6 精确交付承诺" + ], + "kc": [ + "KC-Q10" + ] } ] } diff --git a/docs/planning/wave14/doc-notes.md b/docs/planning/wave14/doc-notes.md new file mode 100644 index 00000000..c440e068 --- /dev/null +++ b/docs/planning/wave14/doc-notes.md @@ -0,0 +1,135 @@ +# W85(P2)文档/治理:能力声明覆盖 35/40 → 38/40 + 报告-计划流清单联动 + 下一波输入结构 + WIP 治理 + signature 漂移候选 + +- 任务卡:task-166(KCP-1.0 Wave 14 / W85 / P2) +- 分支/基线:`feat/kcp14-doc`,基线 `054724f7`(1.0.480,Wave 13 收口) +- 日期:2026-11-21 +- 工作目录:`D:\3_Source\VDE_cp14_doc`(worktree) +- 约束:**引擎源码零改动**(`src/`、`include/`、`tests/` 生产代码未触碰);不 push / 不动版本链 / 不碰主树源码 / 不动其他 worktree;本 worktree 无 build 目录,`--ctest-list` 的 ctest 二次确认与 fast-gate/determinism 未执行(见 §6)。 + +## 1. 交付摘要 + +| 项目 | 结果 | +| --- | --- | +| docs-claims 覆盖 | **35/40 → 38/40**(声明 36 → 39 条;新增 2 条 implemented:L150 通用 Delaunay 边界面恢复、L151 一般自由曲面 tetra;新增 1 条 unsupported:L116 1e-6 精确交付承诺) | +| 剩余 unmapped | **5 → 2 行显式分类**(L113 凹平面体布尔=限制项、L172 CAE=广度项),不伪造绑定 | +| bind() 漂移自愈扩展 | 新增「签名漂移候选」:声明行/自愈命中行 `signature` 不符时,若该 signature 在文件内**唯一出现且在 ±24 行内**,记录候选行 + 旧签名并在错误消息/`--verify-drift`/JSON 中报告(**报告但不自动接受**,见 §4.1) | +| unsupported test 校验 | unsupported 声明若显式带 `test`(负向/契约测试),与 implemented 同口径校验 target/case/注册源文件(新增 `_check_test_binding`) | +| 报告-计划联动 | `check_docs_index.py` 新增 3 组检查(8 checks):报告 §3/§8 的 W## 流清单 ↔ 计划 §9「报告 NNN」行流清单双向一致;报告「Wave N+1 输入」小节结构(编号项 + P0/P1/P2)+ 计划下一 Wave 行;WIP 报告不得落盘后仍声明 WIP / 不得进入 index 最新链(--strict) | +| self-test | `vde_docs_claims.py` 19 → **21 用例**(+signature_drift_candidate 4 场景、+unsupported_test_target);`check_docs_index.py` 3 正例+6 反例 → **3 正例+14 反例**(新增 8 个 W85 反例);`validate_workflows.py` 60 → **61 反例**(+pr-docs-index-no-selftest) | +| 硬门槛 | claims exit 0(PASS,39 claims,0 warnings)、`--verify-drift` PASS(symbol 15 / signature 7 / 候选 0 / 建议 0)、`check_docs_index.py --strict` PASS(8 checks,0 warnings)、`validate_workflows.py --strict` PASS 2/2、`--self-test` PASS、`vde_release.py --check` PASS(14 checks,fail=0 warn=0) | +| 引擎改动 | **0 行**(`git status` 仅 docs/tools 文件) | +| 改动文件 | `tools/vde_docs_claims.py`(1599 → 1777 行)、`docs/planning/capability-claims.json`(910 → 980 行)、`tools/check_docs_index.py`(623 → 873 行)、`tools/ci/validate_workflows.py`(1548 → 1560 行)、`docs/planning/wave14/doc-notes.md`(本文件) | + +## 2. 能力声明覆盖提升(533 §3 矩阵 40 行 → covered 38) + +审计来源:`docs/reference/533-VDE1.0.467-内核能力代码级审计与成熟内核对标报告.md` §3。新增 3 条声明(`docs/planning/capability-claims.json`): + +| # | claim id | tier | 533 行 | 代码绑定(file:line,symbol + signature) | 测试(target.Suite.Case) | 证据文档 | +| --- | --- | --- | --- | --- | --- | --- | +| 1 | impl-delaunay-boundary-recovery | implemented | L150 通用 Delaunay 边界面恢复 🟡/❌ | `src/cae/fea_mesh.cpp:3824`(`面使用次数==1 的三角形`,`并集边界`) | `test_fea_mesh.CorpusProbe.LBracketTetraAccepted` | `docs/planning/remaining-gaps-2026-11-14.md:29`(`通用 Delaunay 边界面恢复`) | +| 2 | impl-freeform-tetra-general | implemented | L151 一般自由曲面 tetra 🟡 | `src/cae/fea_mesh.cpp:3162`(`stage=general-path`,`general-path`) | `test_fea_mesh.CorpusProbe.PlateWithCylindricalFeaturesAccepted` | `docs/planning/remaining-gaps-2026-11-14.md:31`(`一般自由曲面 tetra`) | +| 3 | unsupported-exactness-1e-6-delivery | unsupported | L116 1e-6 精确交付承诺 ❌ | `include/vde/brep/exactness_audit.h:23`(`ExactnessReport validate_exact_trim\(`,`validate_exact_trim(`);declaration 537 报告 L77`非 1e-6 精度权威` | `test_boolean_failure_semantics.BooleanFailureSemanticsTest.Telemetry_UncoveredFailuresIsZero` | 537 报告 §能力边界(同 declaration,明示非 1e-6 精度权威、CBRA 面数上限 64) | + +口径(与 W67/W73/W79 一致,不伪造): + +- 每条 implemented statement 只声明**已实现并有测试断言的最小能力集**,并保留 533 限制描述的时点差异说明:L150 声明边界仅覆盖「闭合水密实体、开放镶嵌壳(bug33638)仍明确拒绝」;L151 声明只覆盖「结构化快速路径失败后走通用 Delaunay + 边界面恢复」后的接受面。 +- **时点差异理由(重要,与 wave11/12/13 doc-notes 的「不可声明」结论不同)**:533 是 **1.0.467 时点**的审计快照,其 L150/L151 限制项描述的是「Delaunay 未做边界面恢复」的旧缺陷;该缺陷已由后续 VDE-1241 修复并在 1.0.471/1.0.480 的代码、测试与 `remaining-gaps-2026-11-14.md` 中留痕,故 W85 改按**当前代码 + 当前测试 + 当前证据**诚实绑定,而不是沿用 533 的旧限制。声明文本内明确写出「533 §3 L150/L151(1.0.467 时点)限制已由 VDE-1241 解除,本声明只覆盖 …」,避免读者误以为 533 行文本被改写。 +- L116 保持 unsupported(无承诺),同时按新扩展校验其负向契约测试(`BooleanFailureSemanticsTest.Telemetry_UncoveredFailuresIsZero` 断言域外 exact 失败带失败码),使 unsupported 声明也有可执行锚点;未把「1e-6 承诺」伪造成 implemented。 +- 命中后从 `unmapped_classification` 移除 L116/L150/L151 三个 match 条目;既有 36 条声明未修改。 + +### 2.1 剩余 2 行 unmapped 的显式分类(`claims.unmapped_classification`) + +| 533 行 | 能力 | 分类 | 说明 | +| --- | --- | --- | --- | +| L113 | 凹平面体布尔、薄壁/大面数布尔 | 限制项(limitation) | 533 自述复杂构型失败率上升、CBRA 面预算 64;544 报告真实语料默认 caliber 布尔全红,本轮无新增真实语料全绿证据,不伪造绑定 | +| L172 | CAE | 广度项(breadth) | 11,759 行广度能力,求解器覆盖窄,无单条可互核绑定;FEA/流体域主能力已分别由 `impl-fea-tetra-mesh`、`impl-midsurface-extract` 等声明覆盖(W79 已移除 CAM 分类并新增 pocket_toolpath 声明) | + +汇总:限制项 1、广度项 1(覆盖 38/40,unmapped 2 行全部有显式分类与理由,`--strict` 通过)。W85 未伪造 L113/L172 的绑定。 + +## 3. 报告-计划联动 / 下一波输入 / WIP 治理(`tools/check_docs_index.py`,5 → 8 checks) + +### 3.1 为什么没有新增 `tools/check_plan_reports.py` + +任务卡允许新增独立脚本;实际实现选择**内置到 `tools/check_docs_index.py`**,因为:① 该检查器已被 `pr-quality.yml` static gate 以 `--strict` 调用(W73 接线),新增检查组自动进 CI,无需新增 CI 资产清单/工作流步骤;② 三组校验共享 `docs/index.md` 最新报告、`docs/reference` 编号报告、计划 §9 的同一批解析结果,独立脚本会造成重复读取与两套「最新报告」口径。`validate_workflows.py` 的 W85 规则负责保证 pr-quality 同时调用其 `--self-test`(见 §3.4)。 + +### 3.2 检查 5:报告 §3/§8 流清单 ↔ 计划 §9「报告 NNN」行(双向) + +- 从 `docs/reference` 最大编号报告 N 的正文提取 W## 标记集合:§3 流标题 `^### 3.x W## ...` + §8 变更清单 `^\*\*W##\*\*:...`; +- 从计划 §9 中**含「报告 NNN」**的交付行提取 `\bW##\b` 集合; +- 两侧集合必须**双向一致**(报告缺/计划缺分别报错),并强制计划行存在; +- 基线实跑:报告 546 = `[W74,W75,W76,W77,W78,W79]`,计划 L490 行 = 同集合 → PASS。 +- 该口径可严格核对且对 Wave 14 完成行(1.0.481 + 报告 547)天然可满足;未采用「报告 §9 输入主题 vs 计划下一 Wave 主题文本匹配」口径,因为基线两侧语义并不严格对应(报告 546 §9 的 6 条输入 vs 计划 L491 的 5 个主题),文本匹配会在基线 FAIL、只能靠模糊启发式,破坏门禁可信度。 + +### 3.3 检查 6:下一 wave 输入结构 + +- 最新报告必须含 `## . Wave N+1 输入` 小节(N+1 由报告标题 Wave N 推导); +- 小节内必须有 ≥1 条编号输入项(`1) ...`),**每条必须带 P0/P1/P2 优先级**(全角/半角括号均可); +- 计划 §9 必须有下一 Wave N+1 行(当前 Wave 14 行「待填 | Wave 14 启动(…)」已存在); +- 基线实跑:报告 546 = `## 9. Wave 14 输入`,6 条输入项全部带(P0)/(P1)/(P2)→ PASS。 + +### 3.4 检查 7:WIP 治理 + `validate_workflows.py` 接线 + +- 已落盘到 `docs/reference` 的编号报告仍被 `--allow-wip-report`/`WIP_REPORT_NUMBERS` 声明为 WIP → **error**(发布后必须移除 WIP 声明); +- WIP 报告进入 `docs/index.md` 最新链:沿用 W73 规则(非 strict 为 warning,`--strict` 一律失败),`details.wip_latest_chain` 记录该号; +- `validate_workflows.py` 新增 W85 规则:pr-quality.yml 的 `tools/check_docs_index.py` 步骤必须同时带 `--self-test`(缺失为 warning,`--strict` 下升级失败),并新增反例 `pr-docs-index-no-selftest`; +- 基线实跑:`validate_workflows.py --strict` PASS 2/2;`--self-test` PASS(3 正例 + 61 反例)。 + +### 3.5 `check_docs_index.py --self-test` 新增 8 个 W85 反例 + +`stream_mismatch`(计划流 W71/W73 vs 报告 W71/W72 → 「流清单不一致」)、`report_stream_missing`(报告无 §3/§8 W-tag → 「未解析到 §3 流标题」)、`next_wave_input_missing`(无「Wave 11 输入」小节)、`next_wave_priority_missing`(输入项缺 P0/P1/P2)、`plan_report_row_missing`(计划行缺「报告 543」)、`plan_next_wave_missing`(计划缺下一 Wave 行)、`wip_report_published_conflict`(543 已落盘仍声明 WIP)、`strict_wip_latest_chain`(WIP 544 进 index 最新链:非 strict 允许、strict 必须退出码 2)。fixture `build()` 增加 `report_streams/plan_streams/report_next_wave/next_wave_priority/plan_next_wave/plan_report` 参数,正例增加联动 details 断言(`report_streams`、`plan_streams`、`next_wave_input_items=2`、`plan_report_row` 含「报告 543」)。 + +## 4. `tools/vde_docs_claims.py` W85 扩展 + +### 4.1 signature 漂移候选(bind() 漂移自愈扩展) + +- 触发点:① 声明行 text 命中但 `signature` 不在该行;② text 失配、symbol 唯一命中(±24 行内)但命中行无 `signature`;③ `--verify-drift` 的 `verify_symbol_bindings()` 发现唯一命中行签名不符。 +- 处理:新增 `_signature_drift_candidate(lines, declared, signature, tolerance)`:signature 在文件内**唯一出现**且与声明行距离 ≤ tolerance 时返回候选行号(否则 None);命中则 `_record_signature_drift(...)` 记录 `{claim,binding,file,declared_line,suggested_line,drift,signature,tolerance}`,并在错误消息后缀「;W85 签名漂移候选 L%d(±%d 行内唯一出现),请核对后更新 claims JSON」。 +- **设计决策:报告候选但不自动接受绑定**。理由:`signature` 是 W79 三重锚定的第三重(防止同名重载/同 symbol 误命中);若签名漂移候选可静默接受,W79 的 `signature_anchor` 反例(同名重载必须失败)语义被破坏,且「函数签名变化」正需要人确认这是同一能力而非同名不同语义。因此候选只出现在错误提示、`--verify-drift` INFO 行与 JSON `verify_drift.signature_suggestions` 中,claims JSON 不被工具改写。 +- `--verify-drift` 汇总行更新为「symbol 绑定 N 个可唯一定位(signature 锚定通过 M 个,签名漂移候选 K 个),建议更新行号 J 个(未写回文件)」;JSON 新增 `verify_drift.signature_suggestions`。 +- 基线实跑:symbol 15 / signature 7 / 候选 0 / 建议 0(现有声明无签名漂移)。 + +### 4.2 unsupported 声明可选 test 校验 + +- 抽出 `_check_test_binding(cid, test, ctest_names, not_built_targets)`(原 implemented 分支逻辑:target 必须在 `tests/**/CMakeLists.txt` 注册、注册源文件存在、case `TEST/TEST_F/TEST_P` 必须落在 target 注册源文件、`--ctest-list` 时校验 `..`)。 +- `check_claim`:implemented 分支改为调用该函数;**unsupported 分支若声明带 `test`**(负向/契约测试)也按同口径校验——本轮新 unsupported 声明 `unsupported-exactness-1e-6-delivery` 即带 `test_boolean_failure_semantics`,其 target 已在 tests/brep/CMakeLists.txt 注册。 +- self-test 新增 `unsupported_test_target` 反例(unsupported + 未注册 target 必须报错;换成已注册 target/case 后不报 test 错误)。 + +### 4.3 self-test 19 → 21 用例 + +新增 `_case_signature_drift_candidate`(4 场景:声明行签名缺失+唯一候选→记录候选并报错含「签名漂移候选」;tolerance=1 超容差→不记录;signature 双侧命中→不记录;`verify_symbol_bindings` 报候选 L4)与 `_case_unsupported_test_target`。全部 21 用例 PASS。 + +## 5. 硬门槛实跑表(2026-11-21,worktree `D:\3_Source\VDE_cp14_doc`) + +| 门槛 | 命令 | 结果 | +| --- | --- | --- | +| docs 三档声明 | `python tools/vde_docs_claims.py` | **PASS**(39 claims,0 warnings,coverage **38/40**,unmapped 2) | +| docs 声明自检 | `python tools/vde_docs_claims.py --self-test` | **PASS**(39 claims + 21 用例) | +| 行号漂移 | `python tools/vde_docs_claims.py --verify-drift` | **PASS**(symbol 15,signature 7,候选 0,建议 0) | +| docs 索引一致性 | `python tools/check_docs_index.py --strict` | **PASS**(8 checks,0 errors,0 warnings;报告流=计划流 W74–W79;下一波输入 6 条) | +| docs 索引自检 | `python tools/check_docs_index.py --self-test` | **PASS**(3 正例 + 14 反例) | +| workflow 校验 | `python tools/ci/validate_workflows.py --strict` | **PASS** 2/2(pr-quality.yml / nightly.yml) | +| workflow 自检 | `python tools/ci/validate_workflows.py --self-test` | **PASS**(3 正例 + 61 反例) | +| release 校验 | `python tools/vde_release.py --check` | **PASS**(checks=14,fail=0,warn=0) | +| 引擎零改动 | `git status --porcelain` | 仅 4 个 docs/tools 文件(+本 notes),`src/`/`include/`/`tests/` 0 改动 | + +证据目录:`D:\3_Source\VDE_drawint\build\kcp14_evidence\doc\`(各命令 stdout/stderr、`docs-claims-result.json`、`docs-index-result.json`、`gates-summary.txt`、`git-status.txt`、`git-diffstat-baseline.txt`)。 + +## 6. 未执行项与局限 + +- 本 worktree 无 build 目录:**未跑** `vde_docs_claims.py --ctest-list` 的 ctest 列表二次确认(新增 test 声明的 ctest 名 `..` 未与 CTestTestfile 交叉核对),也**未跑** fast-gate/determinism/全量回归;上述由 Wave 14 集成(W86/W87)在有 build 的集成 worktree 复核。 +- 报告 547 尚不存在(Wave 14 集成后产出):检查 5/6 当前以 546 为「最新已发布报告」验证,547 落盘后联动校验会自动改绑 547,需报告 §3/§8 W## 与计划 Wave 14 完成行一致、且含「Wave 15 输入」小节(≥1 条、每条带 P0/P1/P2),否则 --strict FAIL。 +- WIP 严格链路的反例是 fixture 级(`strict_wip_latest_chain`);真实仓库当前无 WIP 报告(546 已发布),故只验证规则不验证真实 WIP 发布流程。 +- 533 §3 是 1.0.467 静态快照,覆盖数是「审计行关键词 ↔ 声明关键词」映射,不等于运行时能力保证;L150/L151 的时点差异已在声明文本与 §2 中显式记录,未修改 533/544/546/547 等既有报告。 + +## 7. 剩余 unmapped 与 Wave 15 输入 + +| 533 行 | 能力 | 保持显式分类的理由 | Wave 15 建议 | +| --- | --- | --- | --- | +| L113 | 凹平面体布尔、薄壁/大面数布尔 | CBRA 面预算 64 + 真实语料 caliber 布尔全红(544),无真实语料全绿证据,不伪造 | 先补真实语料布尔全绿证据(含凹平面/薄壁用例)与专门测试 target,再按 implemented 绑定 | +| L172 | CAE | 11,759 行广度能力,求解器覆盖窄;FEA/流体域主能力已被细分声明覆盖,无单条可互核绑定 | 若做,建议按「fluid_domain(`make_external_domain`/`classify_patches`)+ `test_fluid_domain`」单条最小能力绑定,需先确认 target 注册与 docs 证据 | + +W85 向 Wave 15 的输入: +1. 报告 547 落盘时,`check_docs_index.py --strict` 会强制「报告 547 §3/§8 W## 流清单 = 计划 §9 Wave 14 完成行 W## 流清单」且「Wave 15 输入」小节结构合规——W86/W87 集成前先按此准备报告结构,避免集成后返工。 +2. 本 worktree 未跑 ctest 二次确认(无 build),集成 worktree 需补 `--ctest-list` 对新增两条 implemented 声明的 `..` 交叉核对。 +3. 剩余 2 行 unmapped 继续在 `unmapped_classification` 显式分类,不因「凑 40/40」而伪造绑定。 +4. signature 漂移候选仍为「报告不自动接受」口径;若 Wave 15 确需自动修复,须同步放开并重写 `signature_anchor` 反例语义(不建议)。 diff --git a/tools/check_docs_index.py b/tools/check_docs_index.py index 6b930473..513dcead 100644 --- a/tools/check_docs_index.py +++ b/tools/check_docs_index.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -"""docs 索引一致性门禁(KCP-1.0 Wave 11 / W67;W73 增 WIP 窗口)。 +"""docs 索引一致性门禁(KCP-1.0 Wave 11 / W67;W73 增 WIP 窗口;W85 增联动)。 校验项(全部为仓库内可严格核对的静态事实): 1. docs/index.md「最新(X)」版本号与 include/vde/core/version.h 一致, @@ -11,7 +11,15 @@ 当前 wave 从 docs/index.md 最新报告(或 WIP 时回退到最近已发布报告) 的标题(`Wave N`)解析; 4. docs/reference 编号报告在最新窗口(默认最后 30 号)内无缺号, - WIP 白名单 `WIP_REPORT_NUMBERS` 显式列出允许的缺口(默认空)。 + WIP 白名单 `WIP_REPORT_NUMBERS` 显式列出允许的缺口(默认空); + 5. W85 报告-计划流清单联动:最新已发布报告的 §3 流标题与 §8 变更清单中 + 提取的 W## 工作流标记集合,必须与计划 §9 中含「报告 NNN」的交付行内 + W## 集合双向一致(两侧不能各说各话); + 6. W85 下一 wave 输入结构:最新报告必须含「## . Wave N+1 输入」小节, + 至少 1 条编号输入项且每项带 P0/P1/P2 优先级;计划 §9 必须有下一 Wave 行; + 7. W85 WIP 治理:已落盘到 docs/reference 的编号报告不得仍被声明为 WIP + (--allow-wip-report/WIP_REPORT_NUMBERS);WIP 报告不得进入 index 最新链 + (W73 规则:非 strict 仅 warning,--strict 一律失败)。 W73 WIP 窗口规则(版本 bump / 报告在途期间): --allow-wip-report 544,545 声明在途报告号(可重复,或逗号分隔); @@ -351,6 +359,9 @@ def run_checks(root, wip_numbers=None): "最新报告标题未解析到 Wave 编号,跳过计划 §9 " "wave 校验: %r" % latest_report_title) + plan_lines = None + plan_start = None + plan_section = [] plan_path = os.path.join(root, PLAN_MD) if not os.path.isfile(plan_path): errors.append("计划文件不存在: %s" % PLAN_MD.replace(os.sep, "/")) @@ -377,19 +388,148 @@ def run_checks(root, wip_numbers=None): latest_report_title)) else: details["plan_wave_row"] = hit[:160] + # ---- 5. 报告-计划流清单联动(W85)---- + def _stream_sort(tags): + return sorted(tags, key=lambda s: int(s[1:])) + + report_streams = set() + if max_number is not None and max_number in numbered: + link_report_rel = numbered[max_number] + link_report_path = os.path.join(root, link_report_rel) + if os.path.isfile(link_report_path): + for line in read_text(link_report_path).splitlines(): + stripped = line.strip() + match = re.match( + r"^###\s+\d+(?:\.\d+)?\s+W(\d{2,3})\b", stripped) + if not match: + match = re.match(r"^\*\*W(\d{2,3})\*\*", stripped) + if match: + report_streams.add("W%s" % match.group(1)) + plan_streams = set() + plan_report_row = None + if plan_lines is not None and plan_start is not None \ + and max_number is not None: + report_needle = re.compile(r"报告\s*%03d" % max_number) + for line in plan_section: + if report_needle.search(line): + plan_report_row = line.strip() + break + if plan_report_row is None: + errors.append( + "计划 §9 缺少最新已发布报告 %03d 的交付行" + "(应含「报告 %03d」;报告与计划必须联动)" + % (max_number, max_number)) + else: + for match in re.finditer(r"\bW(\d{2,3})\b", plan_report_row): + plan_streams.add("W%s" % match.group(1)) + details["report_number_for_linkage"] = max_number + details["plan_report_row"] = (plan_report_row or "")[:160] + if not report_streams: + errors.append( + "最新已发布报告 %03d 未解析到 §3 流标题/§8 变更清单中的 " + "W## 工作流标记(报告-计划联动失败)" % max_number) + elif plan_report_row is not None and report_streams != plan_streams: + errors.append( + "报告 %03d 与计划 §9 流清单不一致:报告 §3/§8=%s," + "计划行=%s;报告缺 %s,计划缺 %s" + % (max_number, + ",".join(_stream_sort(report_streams)), + ",".join(_stream_sort(plan_streams)) or "无", + ",".join(_stream_sort(report_streams - plan_streams)) + or "无", + ",".join(_stream_sort(plan_streams - report_streams)) + or "无")) + details["report_streams"] = _stream_sort(report_streams) + details["plan_streams"] = _stream_sort(plan_streams) + + # ---- 6. 下一 wave 输入结构(W85)---- + next_wave = current_wave + 1 if current_wave is not None else None + if next_wave is not None: + details["next_wave"] = next_wave + next_input_items = 0 + if latest_report_rel is not None: + next_report_path = os.path.join(root, latest_report_rel) + if os.path.isfile(next_report_path): + heading_re = re.compile( + r"^##\s+\d+\.\s*Wave\s+%d\s*输入" % next_wave) + found_section = False + in_section = False + items = [] + for line in read_text(next_report_path).splitlines(): + stripped = line.strip() + if not in_section: + if heading_re.match(stripped): + in_section = True + found_section = True + continue + if stripped.startswith("## "): + break + item_match = re.match(r"^(\d+)[.)]\s*(.+)$", stripped) + if item_match: + items.append(item_match.group(2)) + next_input_items = len(items) + if not found_section: + errors.append( + "最新报告缺少「## . Wave %d 输入」小节" + "(下一 wave 输入清单必须显式落文档)" % next_wave) + elif not items: + errors.append( + "最新报告「Wave %d 输入」小节没有任何编号输入项" + "(应为 1) ...)" % next_wave) + else: + for index, text in enumerate(items, 1): + if not re.search(r"[((]\s*P[012]\s*[))]", text): + errors.append( + "Wave %d 输入第 %d 条缺少 P0/P1/P2 " + "优先级标记: %r" + % (next_wave, index, text[:80])) + details["next_wave_input_items"] = next_input_items + if plan_lines is not None and plan_start is not None: + next_needle = re.compile( + r"Wave\s*%d(?![0-9])" % next_wave, re.IGNORECASE) + if not any(next_needle.search(line) for line in plan_section): + errors.append( + "计划 §9 缺少下一 Wave %d 行(报告 %s 已在收集下一波输入)" + % (next_wave, + latest_report_rel.replace(os.sep, "/") + if latest_report_rel else "?")) + + # ---- 7. WIP 报告与 index 最新链(W85)---- + wip_violations = [] + if wip: + for number in sorted(wip): + if number in numbered: + errors.append( + "报告 %03d 已落盘到 docs/reference,但仍被声明为 WIP" + "(--allow-wip-report/WIP_REPORT_NUMBERS):" + "发布后必须移除 WIP 声明" % number) + wip_violations.append(number) + if latest_report_number is not None and latest_report_number in wip \ + and latest_report_number not in numbered: + details["wip_latest_chain"] = latest_report_number + details["wip_violations"] = wip_violations + return errors, warnings, details def self_test(): - """内置档期用例:3 个正例 + 6 个反例(版本/链接/计划/缺号/WIP 窗口)。""" + """内置档期用例:3 个正例 + 14 个反例。 + + 覆盖版本/链接/计划/缺号/WIP 窗口(W73)+ 报告-计划流清单联动/ + 下一波输入结构/WIP 治理(W85)。 + """ positives = 0 negatives = 0 failures = [] def build(root, *, version="1.0.477", index_version="1.0.477", report_wave="10", plan_wave="10", gap=None, - drop_link_file=False, wip_link=None): + drop_link_file=False, wip_link=None, + report_streams="W71 / W72", plan_streams="W71 / W72", + report_next_wave=True, next_wave_priority=True, + plan_next_wave=True, plan_report=True): max_number = 543 + next_wave = int(report_wave) + 1 major, minor, patch = version.split(".") _write(root, VERSION_H, "#pragma once\n#define VDE_VERSION_MAJOR %s\n" @@ -404,11 +544,34 @@ def self_test(): skip.add(max_number - 1) numbers = [n for n in range(max_number - GAP_WINDOW + 1, max_number + 1) if n not in skip] + report_tags = re.findall(r"W(\d{2,3})", report_streams) + report_body = ["# %03d — VDE 1.0.477 KCP-1.0 Wave %s 自验证报告" + % (max_number, report_wave), ""] + if report_tags: + report_body.append("## 3. 工作流实现与数据") + report_body.append("") + for offset, tag in enumerate(report_tags, 1): + report_body.append("### 3.%d W%s 测试工作流" % (offset, tag)) + report_body.append("") + report_body.append("## 8. 变更清单") + report_body.append("") + for tag in report_tags: + report_body.append("**W%s**:`src/x.cpp`。" % tag) + report_body.append("") + if report_next_wave: + report_body.append("## 9. Wave %d 输入" % next_wave) + report_body.append("") + if next_wave_priority: + report_body.append("1) **下一波事项甲**(P1):占位。") + report_body.append("2) **下一波事项乙**(P2):占位。") + else: + report_body.append("1) **下一波事项甲**:占位。") + report_body.append("") + report_text = "\n".join(report_body) + "\n" for number in numbers: _write(root, os.path.join( REFERENCE_DIR, "%03d-VDE1.0.477-测试报告.md" % number), - "# %03d — VDE 1.0.477 KCP-1.0 Wave %s 自验证报告\n" - % (number, report_wave)) + report_text) link_numbers = list(range(max_number, max_number - 6, -1)) if wip_link is not None: # W73:index 先引用在途(WIP)报告号,文件尚未落盘。 @@ -422,10 +585,18 @@ def self_test(): _write(root, INDEX_MD, "\n".join(lines) + "\n") plan_lines = ["# 计划", "", "## 9. 第一波执行状态(滚动更新)", "", "| # | 状态 |", "|---|---|"] + plan_tags = re.findall(r"W(\d{2,3})", plan_streams) if plan_wave is not None: + stream_text = " / ".join( + "W%s 工作流" % tag for tag in plan_tags) or "无" + report_suffix = ((" + 报告 %03d" % max_number) + if plan_report else "") plan_lines.append( - "| 10 | **Wave %s 交付与集成完成**(1.0.477 + 报告 543) |" - % plan_wave) + "| 10 | **Wave %s 交付与集成完成**(1.0.477%s):" + "%d 工作流合并(%s),新增测试 0 |" + % (plan_wave, report_suffix, len(plan_tags), stream_text)) + if plan_next_wave: + plan_lines.append("| 待填 | Wave %d 启动(占位) |" % next_wave) plan_lines.extend(["", "## 附录 A", ""]) _write(root, PLAN_MD, "\n".join(plan_lines)) @@ -440,6 +611,12 @@ def self_test(): assert details["reference_max_number"] == 543, details assert details["latest_report_wave"] == 10, details assert details["gap_window"] == [514, 543], details + assert details["report_streams"] == ["W71", "W72"], details + assert details["plan_streams"] == ["W71", "W72"], details + assert "报告 543" in details["plan_report_row"], details + assert details["next_wave"] == 11, details + assert details["next_wave_input_items"] == 2, details + assert details["wip_violations"] == [], details def case_version_mismatch(): with tempfile.TemporaryDirectory() as tmp: @@ -509,6 +686,63 @@ def self_test(): errors, _warnings, _details = run_checks(tmp) assert any("缺号: 530" in e for e in errors), errors + # ---- W85 报告-计划联动 / 下一波输入 / WIP 治理用例 ---- + def case_stream_mismatch(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, plan_streams="W71 / W73") + errors, _warnings, _details = run_checks(tmp) + assert any("流清单不一致" in e for e in errors), errors + + def case_report_stream_missing(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, report_streams="") + errors, _warnings, _details = run_checks(tmp) + assert any("未解析到 §3 流标题" in e for e in errors), errors + + def case_next_wave_input_missing(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, report_next_wave=False) + errors, _warnings, details = run_checks(tmp) + assert any("Wave 11 输入」小节" in e for e in errors), errors + assert details.get("next_wave_input_items") == 0, details + + def case_next_wave_priority_missing(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, next_wave_priority=False) + errors, _warnings, _details = run_checks(tmp) + assert any("缺少 P0/P1/P2 优先级标记" in e for e in errors), errors + + def case_plan_report_row_missing(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, plan_report=False) + errors, _warnings, details = run_checks(tmp) + assert any("缺少最新已发布报告 543 的交付行" in e + for e in errors), errors + assert details.get("report_number_for_linkage") == 543, details + + def case_plan_next_wave_missing(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, plan_next_wave=False) + errors, _warnings, _details = run_checks(tmp) + assert any("缺少下一 Wave 11 行" in e for e in errors), errors + + def case_wip_report_published_conflict(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp) + errors, _warnings, details = run_checks(tmp, wip_numbers={543}) + assert any("仍被声明为 WIP" in e for e in errors), errors + assert details.get("wip_violations") == [543], details + + def case_strict_rejects_wip_latest_chain(): + with tempfile.TemporaryDirectory() as tmp: + build(tmp, version="1.0.478", index_version="1.0.478", + wip_link=544) + # 非 strict + 显式 WIP 声明:允许(warning 不拦截) + assert main(["--root", tmp, "--allow-wip-report", "544"]) == 0 + # strict:WIP 报告进入 index 最新链必须失败(不得静默发布) + assert main(["--root", tmp, "--strict", + "--allow-wip-report", "544"]) == 2 + good_cases = [ ("positive_fixture", case_positive), ("wip_window_accepted", case_wip_window_accepted), @@ -521,6 +755,15 @@ def self_test(): ("number_gap", case_number_gap), ("wip_window_requires_flag", case_wip_window_requires_flag), ("wip_gap_requires_flag", case_wip_gap_requires_flag), + ("stream_mismatch", case_stream_mismatch), + ("report_stream_missing", case_report_stream_missing), + ("next_wave_input_missing", case_next_wave_input_missing), + ("next_wave_priority_missing", case_next_wave_priority_missing), + ("plan_report_row_missing", case_plan_report_row_missing), + ("plan_next_wave_missing", case_plan_next_wave_missing), + ("wip_report_published_conflict", + case_wip_report_published_conflict), + ("strict_wip_latest_chain", case_strict_rejects_wip_latest_chain), ] for name, func in good_cases: try: @@ -599,6 +842,13 @@ def main(argv=None): details.get("reference_max_number"), details.get("latest_report_wave"), details.get("gap_window"))) + if details.get("report_streams") is not None: + print("[docs-index] 报告-计划联动: 报告流=%s 计划流=%s " + "报告行=%s 下一波输入=%s 条" + % (",".join(details.get("report_streams") or []) or "无", + ",".join(details.get("plan_streams") or []) or "无", + (details.get("plan_report_row") or "无")[:60], + details.get("next_wave_input_items"))) for warning in warnings: print(" WARN " + warning) for error in errors: @@ -615,7 +865,7 @@ def main(argv=None): % (len(errors), len(warnings))) return 2 print("[docs-index] PASS (%d checks, 0 errors, %d warnings)" - % (5, len(warnings))) + % (8, len(warnings))) return 0 diff --git a/tools/ci/validate_workflows.py b/tools/ci/validate_workflows.py index 5694aa73..1a7431c7 100644 --- a/tools/ci/validate_workflows.py +++ b/tools/ci/validate_workflows.py @@ -59,6 +59,9 @@ --verify-drift 与 --self-test); - pr-quality.yml static gate 必须调用 tools/check_docs_index.py --strict, 未带 --strict 视为假绿(error); + - (W85)tools/check_docs_index.py 新增「报告-计划流清单联动 / 下一波输入 + 结构 / WIP 治理」三组检查,pr-quality.yml static gate 必须同时调用其 + --self-test(缺失告警,--strict 下升级为失败),防止联动校验自身退化; - PageHeap job 的 run 必须包含 cdb.exe 预检(Windows SDK Debugging Tools, 仓库变量 VDE_CDB_PATH 可覆盖),缺失即失败——避免 PageHeap 在无 cdb 的 runner 上假绿或挂死。 @@ -665,6 +668,11 @@ def validate_doc(data, path): if "--strict" not in text: r.err("%s tools/check_docs_index.py 未使用 --strict" "(W73:docs 索引门禁必须严格模式)" % sw) + if not any("--self-test" in text + for _sw, text in docs_index_steps): + r.warn("pr-quality docs 索引步骤缺少 --self-test" + "(W85:报告-计划联动/下一波输入/WIP 治理自检必须进 CI," + "防止联动校验自身退化)") # ---- W77:Windows runner 首次启用 smoke(环境预检,禁止静默 skip)---- smoke_jobs = [] for job_id, job in jobs.items(): @@ -1244,6 +1252,10 @@ jobs: pr_good.replace("tools/check_docs_index.py --strict", "tools/check_docs_index.py"), "pr-quality.yml", "--strict"), + "pr-docs-index-no-selftest": ( + pr_good.replace( + "python3 tools/check_docs_index.py --self-test", ""), + "pr-quality.yml", "--self-test"), "pageheap-missing-cdb": ( pageheap_base.replace(cdb_preflight, ""), "nightly.yml", "cdb"), diff --git a/tools/vde_docs_claims.py b/tools/vde_docs_claims.py index bca64f01..c5924d0e 100644 --- a/tools/vde_docs_claims.py +++ b/tools/vde_docs_claims.py @@ -171,6 +171,8 @@ class Checker: self.drift_suggestions = [] # W79:三重锚定 signature 通过计数 + 一致性检查缓存 self.signature_verified = 0 + # W85:signature 漂移候选(函数签名改名/移动时报告候选行,不静默接受) + self.signature_drift_suggestions = [] self._registered_cache = None self._version_cache = "unset" self._published_report_cache = "unset" @@ -252,9 +254,18 @@ class Checker: if not require_text or text in line: # W79 三重锚定:声明行还必须包含 signature(防止同名重载误命中) if signature is not None and signature not in line: + candidate = self._signature_drift_candidate( + lines, line_no, signature, tolerance) + hint = "" + if candidate is not None: + self._record_signature_drift( + claim_id, kind, rel, line_no, candidate, signature, + tolerance) + hint = ";W85 签名漂移候选 L%d(±%d 行内唯一出现)," \ + "请核对后更新 claims JSON" % (candidate, tolerance) self.err("%s: %s 声明行 %s:%d 未包含 signature %r" - "(三重锚定失败:text/symbol 命中的行不是声明的签名行)" - % (claim_id, kind, rel, line_no, signature)) + "(三重锚定失败:text/symbol 命中的行不是声明的签名行)%s" + % (claim_id, kind, rel, line_no, signature, hint)) return None if signature is not None: self.signature_verified += 1 @@ -298,9 +309,18 @@ class Checker: tolerance, suggested)) return None if signature is not None and signature not in lines[suggested - 1]: + candidate = self._signature_drift_candidate( + lines, suggested, signature, tolerance) + hint = "" + if candidate is not None: + self._record_signature_drift( + claim_id, kind, rel, line_no, candidate, signature, + tolerance) + hint = ";W85 签名漂移候选 L%d(±%d 行内唯一出现)," \ + "请核对后更新 claims JSON" % (candidate, tolerance) self.err("%s: %s symbol 唯一命中 %s:%d 但该行未包含 signature %r" - "(漂移自愈失败:命中行签名不符)" - % (claim_id, kind, rel, suggested, signature)) + "(漂移自愈失败:命中行签名不符)%s" + % (claim_id, kind, rel, suggested, signature, hint)) return None if signature is not None: self.signature_verified += 1 @@ -354,9 +374,21 @@ class Checker: signature = binding.get("signature") if isinstance(signature, str) and signature: if signature not in lines[hits[0] - 1]: + declared = binding.get("line") + tolerance = binding.get("tolerance", DRIFT_TOLERANCE) + candidate = self._signature_drift_candidate( + lines, declared if isinstance(declared, int) + else hits[0], signature, tolerance) + hint = "" + if candidate is not None: + self._record_signature_drift( + cid, kind, rel, + declared if isinstance(declared, int) + else hits[0], candidate, signature, tolerance) + hint = ";W85 签名漂移候选 L%d" % candidate self.err("%s: %s.symbol 唯一命中 %s:%d 但该行未包含 " - "signature %r(三重锚定失败)" - % (cid, kind, rel, hits[0], signature)) + "signature %r(三重锚定失败)%s" + % (cid, kind, rel, hits[0], signature, hint)) continue self.drift_verified += 1 if isinstance(declared, int) and hits[0] != declared: @@ -384,6 +416,47 @@ class Checker: "tolerance": tolerance, }) + # ---- W85 signature 漂移候选(签名变化时给候选行,不静默接受) ---- + def _signature_drift_candidate(self, lines, declared, signature, tolerance): + """返回 signature 漂移候选行号;候选不唯一/超容差/越界返回 None。 + + W85:函数签名变化(改名/参数增删/移位)时,text 与 symbol 仍能定位到 + 原声明行,但该行已不再包含 signature。此时把「signature 在文件内唯一 + 出现且与声明行漂移在容差内」的行作为候选报告给 --verify-drift, + 由人工更新 claims JSON;bind() 仍按 W79 三重锚定失败(避免把同名重载 + 误当成漂移自愈而静默接受错误绑定)。 + """ + if not isinstance(signature, str) or not signature: + return None + hits = [idx for idx, line in enumerate(lines, 1) if signature in line] + if len(hits) != 1: + return None + suggested = hits[0] + if suggested < 1 or suggested > len(lines): + return None + if not isinstance(declared, int) or abs(suggested - declared) > tolerance: + return None + return suggested + + def _record_signature_drift(self, claim_id, kind, rel, declared, suggested, + signature, tolerance): + """记录一次 signature 漂移候选(W85,不写回 JSON)。""" + key = (claim_id, kind, declared, suggested, signature) + for item in self.signature_drift_suggestions: + if item["_key"] == key: + return + self.signature_drift_suggestions.append({ + "_key": key, + "claim": claim_id, + "binding": kind, + "file": rel.replace("\\", "/"), + "declared_line": declared, + "suggested_line": suggested, + "drift": suggested - declared, + "signature": signature, + "tolerance": tolerance, + }) + def check_evidence(self, claim_id, claim): """已实现声明的可选 `evidence` 绑定:docs/ 下 file:line:text。 @@ -655,6 +728,43 @@ class Checker: } # ---- 单条声明 ---- + def _check_test_binding(self, cid, test, ctest_names, not_built_targets): + """校验 test.target/test.case 与 CMake 注册源文件、可选 ctest 注册名。 + + W85:implemented 与 unsupported(显式声明 test 时)共用同一口径, + 避免「明确不支持」声明借 test 字段指向不存在的测试二进制。 + """ + target = test.get("target") + case = test.get("case") + if not target or not isinstance(target, str): + self.err("%s: test.target 缺失" % cid) + elif not self.test_target_exists(target): + self.err("%s: 测试 target %r 未在 tests/**/CMakeLists.txt 注册" + % (cid, target)) + elif not self.target_registered_sources(target): + self.err("%s: 测试 target %r 已注册但注册源文件不存在" + "(CMake add_vde_test/SRCS 与磁盘文件不一致)" + % (cid, target)) + if not case or not isinstance(case, str): + self.err("%s: test.case 缺失" % cid) + elif not self.test_case_exists(target or "", case): + self.err("%s: 测试 case %r 在 tests/**/*.cpp 中不存在 TEST(...)" + % (cid, case)) + elif target and not self.test_case_in_target(target, case): + self.err("%s: 测试 case %r 不在 target %r 的注册源文件中" + "(默认 .cpp / 显式 SRCS;声明-测试一致性" + "失败:target 与 case 必须来自同一测试二进制)" + % (cid, case, target)) + if ctest_names is not None and target and case: + full = "%s.%s" % (target, case) + if full not in ctest_names: + if target in not_built_targets: + self.warn("%s: target %s 未在当前 build 构建," + "跳过 ctest 注册确认" % (cid, target)) + else: + self.err("%s: ctest --show-only 结果中没有 %r" + % (cid, full)) + def check_claim(self, claim, rows, ctest_names, not_built_targets=None): not_built_targets = not_built_targets or set() if not isinstance(claim, dict): @@ -683,36 +793,8 @@ class Checker: if not isinstance(test, dict): self.err("%s: 已实现声明缺少 test 绑定" % cid) else: - target = test.get("target") - case = test.get("case") - if not target or not isinstance(target, str): - self.err("%s: test.target 缺失" % cid) - elif not self.test_target_exists(target): - self.err("%s: 测试 target %r 未在 tests/**/CMakeLists.txt 注册" - % (cid, target)) - elif not self.target_registered_sources(target): - self.err("%s: 测试 target %r 已注册但注册源文件不存在" - "(CMake add_vde_test/SRCS 与磁盘文件不一致)" - % (cid, target)) - if not case or not isinstance(case, str): - self.err("%s: test.case 缺失" % cid) - elif not self.test_case_exists(target or "", case): - self.err("%s: 测试 case %r 在 tests/**/*.cpp 中不存在 TEST(...)" - % (cid, case)) - elif target and not self.test_case_in_target(target, case): - self.err("%s: 测试 case %r 不在 target %r 的注册源文件中" - "(默认 .cpp / 显式 SRCS;声明-测试一致性" - "失败:target 与 case 必须来自同一测试二进制)" - % (cid, case, target)) - if ctest_names is not None and target and case: - full = "%s.%s" % (target, case) - if full not in ctest_names: - if target in not_built_targets: - self.warn("%s: target %s 未在当前 build 构建," - "跳过 ctest 注册确认" % (cid, target)) - else: - self.err("%s: ctest --show-only 结果中没有 %r" - % (cid, full)) + self._check_test_binding(cid, test, ctest_names, + not_built_targets) if code is None: self.err("%s: 已实现声明必须有可核对的 code 绑定" % cid) self.check_evidence(cid, claim) @@ -746,6 +828,14 @@ class Checker: self.err("%s: declaration 必须位于 docs/ 下: %s" % (cid, decl[0])) if isinstance(claim.get("code"), dict): self.bind(cid, "code", claim["code"]) + # W85:unsupported 若显式声明 test(负向/契约测试),按同一口径校验 + if "test" in claim: + test = claim.get("test") + if not isinstance(test, dict): + self.err("%s: unsupported 声明的 test 必须是对象" % cid) + else: + self._check_test_binding(cid, test, ctest_names, + not_built_targets) self.check_audit_refs(claim, rows) @@ -1344,6 +1434,81 @@ def _case_version_mismatch_evidence(repo): assert any("高于当前版本" in e for e in checker.errors), checker.errors +def _case_signature_drift_candidate(repo): + """W85:函数签名变化 → 报告候选行(仍按三重锚定失败,不静默接受)。 + + 覆盖:候选唯一且在容差内 → 记录 signature_drift_suggestions 并报错; + 超容差/候选不唯一 → 不记录候选;--verify-drift 同样给候选。 + """ + import tempfile + with tempfile.TemporaryDirectory() as tmp: + os.makedirs(os.path.join(tmp, "sub")) + rel = os.path.join("sub", "drift_sig.h") + with open(os.path.join(tmp, rel), "w", encoding="utf-8") as fh: + fh.write("// header\n" + "int expected_symbol(int x);\n" + "// filler\n" + "double expected_symbol(double y);\n") + checker = Checker(tmp) + # 1) 声明行签名缺失 + 签名在容差内唯一出现 → 记录候选但绑定失败 + assert checker.bind("fixture", "code", { + "file": rel, "line": 2, "text": "expected_symbol", + "signature": "double expected_symbol(double y)"}) is None + assert any("签名漂移候选" in e for e in checker.errors), checker.errors + assert checker.signature_drift_suggestions, \ + checker.signature_drift_suggestions + cand = checker.signature_drift_suggestions[-1] + assert cand["suggested_line"] == 4, cand + assert cand["declared_line"] == 2, cand + # 2) 候选超出显式 tolerance → 不记录候选 + checker.errors.clear() + checker.signature_drift_suggestions.clear() + assert checker.bind("fixture", "code", { + "file": rel, "line": 2, "text": "expected_symbol", + "signature": "double expected_symbol(double y)", + "tolerance": 1}) is None + assert not checker.signature_drift_suggestions, \ + checker.signature_drift_suggestions + # 3) 签名在文件内多处出现(候选不唯一)→ 不记录候选 + checker.errors.clear() + checker.signature_drift_suggestions.clear() + assert checker.bind("fixture", "code", { + "file": rel, "line": 1, "text": "// header", + "signature": "expected_symbol"}) is None + assert not checker.signature_drift_suggestions + # 4) --verify-drift 同样报告候选 + checker.errors.clear() + checker.signature_drift_suggestions.clear() + checker.verify_symbol_bindings([{ + "id": "fixture", "code": { + "file": rel, "line": 2, "text": "expected_symbol", + "symbol": r"int expected_symbol\(", + "signature": "double expected_symbol(double y)"}}]) + assert checker.signature_drift_suggestions, \ + checker.signature_drift_suggestions + assert checker.signature_drift_suggestions[-1]["suggested_line"] == 4, \ + checker.signature_drift_suggestions + + +def _case_unsupported_test_target(repo): + """W85:unsupported 声明的 test 也走 target/case 一致性校验。""" + import tempfile + with tempfile.TemporaryDirectory() as tmp: + claim = _claims_fixture(tmp) + claim["tier"] = "unsupported" + claim["test"] = {"target": "test_missing", "case": "SomeSuite.SomeCase"} + claim["declaration"] = {"file": "docs/ev.md", "line": 2, "text": "api"} + checker = Checker(tmp) + checker.check_claim(claim, [], None) + assert any("未在 tests/**/CMakeLists.txt 注册" in e + for e in checker.errors), checker.errors + # 合法 unsupported + test(负向契约测试)不应报 test 相关错误 + checker.errors.clear() + claim["test"] = {"target": "test_b", "case": "SomeSuite.SomeCase"} + checker.check_claim(claim, [], None) + assert not any("test" in e for e in checker.errors), checker.errors + + def _run_self_test_cases(repo): cases = [ ("parse_audit_rows", _case_parse_rows), @@ -1354,6 +1519,8 @@ def _run_self_test_cases(repo): ("unmapped_classification", _case_unmapped_classification), ("evidence_binding", _case_evidence_binding), ("signature_anchor", _case_signature_anchor), + ("signature_drift_candidate", _case_signature_drift_candidate), + ("unsupported_test_target", _case_unsupported_test_target), ("forged_line", _case_forged_line), ("dead_symbol", _case_dead_symbol), ("missing_test_target", _case_missing_test_target), @@ -1543,6 +1710,9 @@ def main(argv=None): "suggestions": [ {k: v for k, v in item.items() if not k.startswith("_")} for item in checker.drift_suggestions], + "signature_suggestions": [ + {k: v for k, v in item.items() if not k.startswith("_")} + for item in checker.signature_drift_suggestions], }, "errors": checker.errors, "warnings": checker.warnings, @@ -1570,10 +1740,18 @@ def main(argv=None): % (item["claim"], item["binding"], item["file"], item["declared_line"], item["suggested_line"], item["tolerance"])) + for item in checker.signature_drift_suggestions: + print(" INFO 签名漂移候选 %s.%s %s:%d -> %d(signature %r 唯一出现且" + "在 ±%d 行内,未自动接受,请核对后更新 claims JSON)" + % (item["claim"], item["binding"], item["file"], + item["declared_line"], item["suggested_line"], + item["signature"], item["tolerance"])) if args.verify_drift: print("[docs-claims] verify-drift: symbol 绑定 %d 个可唯一定位" - "(signature 锚定通过 %d 个),建议更新行号 %d 个(未写回文件)" + "(signature 锚定通过 %d 个,签名漂移候选 %d 个)," + "建议更新行号 %d 个(未写回文件)" % (checker.drift_verified, checker.signature_verified, + len(checker.signature_drift_suggestions), len(checker.drift_suggestions))) for wmsg in checker.warnings: print(" WARN " + wmsg)