Validate registered route smoke cases
This commit is contained in:
@@ -814,12 +814,13 @@ The script does not import ComfyUI. It parses the repo and prints:
|
|||||||
`composition_pools` reference;
|
`composition_pools` reference;
|
||||||
- item template validation so `{placeholder}` names resolve to `item_axes`.
|
- item template validation so `{placeholder}` names resolve to `item_axes`.
|
||||||
- route documentation validation so critical route modules are listed in this
|
- route documentation validation so critical route modules are listed in this
|
||||||
map and the architecture plan, and covered by their expected smoke cases.
|
map and the architecture plan, and registered in `SMOKE_CASES` by their
|
||||||
|
expected smoke cases.
|
||||||
|
|
||||||
Use its output to spot doc drift after adding a new node or pool. If a new node
|
Use its output to spot doc drift after adding a new node or pool. If a new node
|
||||||
or pool appears there but not in this map, update the relevant route table. The
|
or pool appears there but not in this map, update the relevant route table. The
|
||||||
script exits nonzero when JSON pool references, item template axes, critical
|
script exits nonzero when JSON pool references, item template axes, critical
|
||||||
route docs, or critical route smoke coverage do not resolve.
|
route docs, or critical route smoke registrations do not resolve.
|
||||||
|
|
||||||
## Behavioral Smoke Helper
|
## Behavioral Smoke Helper
|
||||||
|
|
||||||
|
|||||||
@@ -311,14 +311,43 @@ def _json_reference_errors(paths: list[Path]) -> list[tuple[str, str, str]]:
|
|||||||
return errors
|
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]]:
|
def _routing_doc_errors() -> list[tuple[str, str, str]]:
|
||||||
docs = {
|
docs = {
|
||||||
"docs/prompt-pool-routing-map.md": ROOT / "docs" / "prompt-pool-routing-map.md",
|
"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",
|
"docs/prompt-architecture-improvement-plan.md": ROOT / "docs" / "prompt-architecture-improvement-plan.md",
|
||||||
}
|
}
|
||||||
smoke_path = ROOT / "tools" / "prompt_smoke.py"
|
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]] = []
|
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:
|
for module_name, smoke_case in CRITICAL_ROUTE_MODULES:
|
||||||
if not (ROOT / module_name).exists():
|
if not (ROOT / module_name).exists():
|
||||||
errors.append((module_name, "module", "critical route module is missing"))
|
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 ""
|
doc_text = doc_path.read_text(encoding="utf-8") if doc_path.exists() else ""
|
||||||
if module_name not in doc_text:
|
if module_name not in doc_text:
|
||||||
errors.append((module_name, doc_name, "critical route module is not documented"))
|
errors.append((module_name, doc_name, "critical route module is not documented"))
|
||||||
if smoke_case and smoke_case not in smoke_text:
|
if smoke_case and smoke_case not in smoke_cases:
|
||||||
errors.append((module_name, "tools/prompt_smoke.py", f"missing smoke case: {smoke_case}"))
|
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")
|
route_map_text = docs["docs/prompt-pool-routing-map.md"].read_text(encoding="utf-8")
|
||||||
for snippet in ENTRY_ROUTE_SNIPPETS:
|
for snippet in ENTRY_ROUTE_SNIPPETS:
|
||||||
|
|||||||
Reference in New Issue
Block a user