fix: 数据源审查小修(from_config 类型守卫/PROMPTS_KEYS 消重/契约措辞)

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-10-13 09:05:09 +08:00
parent c7fd533320
commit 1bd341c21a
4 changed files with 22 additions and 8 deletions
+5 -3
View File
@@ -16,10 +16,12 @@ registry 只认本模块的 TenantSource 协议(async load_all / load_tenant),
——旧路径 PromptProvider.from_dir 直读盘、不进快照;对齐后 DB 源(prompts
嵌 config_json)与文件源输出形态一致,registry 不再感知源差异。
错误契约(两源一致,registry 依赖):
错误契约(registry 依赖,加载期显性失败不流入运行期):
- 未知 slug → LookupError(registry_reload 映射为 UnknownTenantError);
- 数据坏(缺版本/坏 JSON/零站点/缺 wall·prompts 组)→ ValueError 带
租户名(加载期显性失败,不流入运行期)。
- DB 源数据坏(缺版本/坏 JSON/非对象/零站点/缺 wall·prompts 组)→
ValueError 带租户名(与版本号);
- 文件源数据坏:坏 JSON/slug 与目录不一致/零站点 → ValueError 带路径,
wall/prompts 文件缺失 → FileNotFoundError 带路径(read_text 原样)。
"""
import json
import pathlib