refactor enrichment to tmdb-only and fix review findings

This commit is contained in:
windyboy
2026-02-10 08:29:31 +08:00
parent 53aaeeaedf
commit f0c951ad7f
8 changed files with 187 additions and 127 deletions
+50
View File
@@ -218,6 +218,56 @@
- Add developer note for test import convention: always import from package root (`vlm`), not `src.vlm`.
### Execution checklist (single pass)
## Enrichment 增量评审报告(2026-02-10
### 评审范围
- 文件:`src/vlm/enrichment.py`
- 关注点:刷新一致性、配置可观测性、命名输出质量
### 总体评分(修复后)
- 当前得分:**92 / 100**
- 评分依据:
- 正确性(40 分):37/40(refresh 无命中不再残留旧字段)
- 健壮性(30 分):27/30(未知 provider 已 fail-fast
- 输出质量(20 分):18/20display title 去重)
- 可维护性(10 分):10/10(TMDB-only,分支复杂度降低)
### 问题明细与修复状态
#### 1) P1 - 刷新失败时未清理陈旧富化字段(**fixed**)
- 修复位置:`src/vlm/enrichment.py:378`
- 修复内容:
- `_apply_payload` 从“仅写入非 None”改为“payload 含 key 即覆盖”,支持将字段显式清空为 `None`
- 验证:
- `tests/test_enrichment.py:187` 覆盖 refresh 后无匹配场景,断言旧 `canonical_id/title_zh/title_en/reputation_*` 被清空,`enrichment_confidence == 0.0`
#### 2) P2 - 未识别 provider 被静默忽略(**fixed**
- 修复位置:
- `src/vlm/enrichment.py:157`
- `src/vlm/config.py:271`
- 修复内容:
- `_build_providers` 对未知 provider 直接抛 `ValueError`fail-fast)。
- 配置校验新增白名单,仅允许 `tmdb`
- 同步重构为 TMDB-only,移除 enrich 主流程中的 Douban 分支。
- 验证:
- `tests/test_enrichment.py:176` 覆盖未知 provider 报错。
- `tests/test_config.py:447` 覆盖配置校验拒绝不支持 provider。
#### 3) P2 - display_title fallback 可能重复标题(**fixed**
- 修复位置:`src/vlm/enrichment.py:423`
- 修复内容:
- `_build_display_title` 增加同值去重逻辑;`title_zh/title_en` 回退同值时只保留一个。
- 验证:
- `tests/test_enrichment.py:260` 断言双空回退时输出单标题而非重复标题。
### 结果
1. 三项问题均已修复并有测试覆盖。
2. enrich 已切换为 TMDB-only,配置和文档已同步。
3. 全量测试通过:`uv run --with pytest --with hypothesis pytest -q` -> `411 passed`
### 修复后目标分
- 达成:**92 / 100**。
1. Apply Phase 1, run focused + full tests.
2. Apply Phase 2, add timezone tests, run focused + full tests.
3. Apply Phase 3, run scanner tests + full tests.