feat(provenance): URI 统一 + resolver + 强验证(T12 架构审查整改)

- T12 (OV3, P1): 新建 src/genesis/parsers/resolver.py
  - parse_source_uri: 解析 file.xlsx#Sheet!CellRef → SourceRef(格式非法 raise URIError)
  - provenance_to_uri: Provenance 还原 URI(与 build_source_uri 互逆)
  - resolve_source_uri: StructuredSource 内定位真实 CellValue
  - validate_source_uris: 批量强验证 → ValidationResult(resolved/unresolved)
    格式错误或源中不存在一律 unresolved(防 QA#8 编造 URI 作弊)
- URI 唯一生成入口 build_source_uri(provenance.py),无散落不一致
- 新增 test_resolver.py(13 用例);同步 design.md §9.2 + §6.8 第五步
- TDD: RED(模块缺失)→ GREEN(聚焦 10 passed)→ 全量 231 passed / 100.00%(1191 stmts/298 br)
This commit is contained in:
lhl
2026-08-12 22:35:56 +08:00
parent 6a54580ca4
commit 69aec7716c
4 changed files with 270 additions and 1 deletions
+11 -1
View File
@@ -897,7 +897,8 @@ style_map:
│ │
│ ⑤ 校验输出: │
│ 内容块结构校验(schema 校验)→ 失败则重试 │
│ source_uris 存在性校验(引用的 URI 必须在输入中存在)
│ source_uris 存在性校验(引用的 URI 必须在输入中定位,
│ T12 resolver.validate_source_uris → unresolved 非空即失败)│
│ │
│ ⑥ 渲染: │
│ 产出 chapter_html → 前端实时预览 │
@@ -1374,6 +1375,15 @@ DB设计 生成过程中发生错误
例: "要件定義.xlsx#機能一覧!C3"
```
> **T12 机制化(OV3)**:URI 的解析/存在性验证已落地为 `src/genesis/parsers/resolver.py`
> - `parse_source_uri(uri)`:解析为 SourceRef(格式非法 → `URIError`
> - `provenance_to_uri(prov)`:从 Provenance 还原 URI(与 build 互逆)
> - `resolve_source_uri(uri, source)`:在 StructuredSource 内定位真实单元格
> - `validate_source_uris(uris, source)` → ValidationResult(resolved, unresolved)
>
> 该机制支撑 design.md §6.8 第五步「source_uris 存在性校验」——QA 校验时
> 所有引用的 URI 必须能在输入源中定位,否则落入 unresolved(防 QA#8 编造 URI 作弊)。
### 9.3 Provenance Chain
```