Validate registered route smoke cases

This commit is contained in:
2026-06-27 12:36:59 +02:00
parent 05c84c6b83
commit 3599a334be
2 changed files with 35 additions and 5 deletions
+32 -3
View File
@@ -311,14 +311,43 @@ def _json_reference_errors(paths: list[Path]) -> list[tuple[str, str, str]]:
return errors
def _smoke_case_names(path: Path) -> set[str]:
if not path.exists():
return set()
tree = ast.parse(path.read_text(encoding="utf-8"))
for node in tree.body:
value: ast.AST | None = None
if isinstance(node, ast.AnnAssign) and isinstance(node.target, ast.Name) and node.target.id == "SMOKE_CASES":
value = node.value
elif isinstance(node, ast.Assign) and any(
isinstance(target, ast.Name) and target.id == "SMOKE_CASES" for target in node.targets
):
value = node.value
if value is None:
continue
if not isinstance(value, (ast.List, ast.Tuple)):
return set()
names: set[str] = set()
for item in value.elts:
if not isinstance(item, (ast.List, ast.Tuple)) or not item.elts:
continue
first = item.elts[0]
if isinstance(first, ast.Constant) and isinstance(first.value, str):
names.add(first.value)
return names
return set()
def _routing_doc_errors() -> list[tuple[str, str, str]]:
docs = {
"docs/prompt-pool-routing-map.md": ROOT / "docs" / "prompt-pool-routing-map.md",
"docs/prompt-architecture-improvement-plan.md": ROOT / "docs" / "prompt-architecture-improvement-plan.md",
}
smoke_path = ROOT / "tools" / "prompt_smoke.py"
smoke_text = smoke_path.read_text(encoding="utf-8") if smoke_path.exists() else ""
smoke_cases = _smoke_case_names(smoke_path)
errors: list[tuple[str, str, str]] = []
if not smoke_cases:
errors.append(("tools/prompt_smoke.py", "SMOKE_CASES", "no registered smoke cases found"))
for module_name, smoke_case in CRITICAL_ROUTE_MODULES:
if not (ROOT / module_name).exists():
errors.append((module_name, "module", "critical route module is missing"))
@@ -326,8 +355,8 @@ def _routing_doc_errors() -> list[tuple[str, str, str]]:
doc_text = doc_path.read_text(encoding="utf-8") if doc_path.exists() else ""
if module_name not in doc_text:
errors.append((module_name, doc_name, "critical route module is not documented"))
if smoke_case and smoke_case not in smoke_text:
errors.append((module_name, "tools/prompt_smoke.py", f"missing smoke case: {smoke_case}"))
if smoke_case and smoke_case not in smoke_cases:
errors.append((module_name, "tools/prompt_smoke.py", f"missing registered smoke case: {smoke_case}"))
route_map_text = docs["docs/prompt-pool-routing-map.md"].read_text(encoding="utf-8")
for snippet in ENTRY_ROUTE_SNIPPETS: