fix(qa): 修 3 个 QA MEDIUM——规则/档位路由校验收紧

- 规则 GET 不存在 project → 404(原返误导性空 200,掩盖坏 id):list_rules 加
  项目存在校验(仿 C1/H2)。
- 规则 content 纯空白 → 422(原 strip 前校验 min_length,空白行入库成垃圾):
  改 StringConstraints(strip_whitespace=True, min_length=1)。
- 档位路由 tier 限定 writer/analyst/light(Tier Literal)→ 未知档位 422
  (原接受任意字符串)。

回归测试:test_generation(GET rules 404)/ test_rules(空白 content 422)/
test_settings_providers(未知 tier 422)。门禁绿:ruff/format/mypy(210)/pytest。
This commit is contained in:
Yaojia Wang
2026-06-24 17:51:02 +02:00
parent 7a40c7fbb5
commit 3868f80502
6 changed files with 49 additions and 5 deletions

View File

@@ -378,8 +378,11 @@ async def list_world_entities(
async def list_rules(
project_id: uuid.UUID,
repo: RulesReadRepoDep,
project_repo: ProjectRepoDep,
) -> RuleListResponse:
"""规则列表(按读侧顺序)。规则页用。"""
"""规则列表(按读侧顺序)。规则页用。项目不存在 → 404QA MEDIUM此前返误导性空 200"""
if await project_repo.get(STUB_OWNER_ID, project_id) is None:
raise AppError(ErrorCode.NOT_FOUND, f"project not found: {project_id}")
rules = await repo.all_for_project(project_id)
return RuleListResponse(rules=[RuleView(level=r.level, content=r.content) for r in rules])