Enrich formatter route trace metadata

This commit is contained in:
2026-06-27 19:46:13 +02:00
parent 3c7ccbb711
commit 307ffdba3b
8 changed files with 117 additions and 6 deletions
+4
View File
@@ -106,6 +106,10 @@ AUDIT_DOC_SNIPPETS: tuple[tuple[str, str], ...] = (
"docs/prompt-pool-routing-map.md",
"pair pose rerolls changing hardcore action metadata",
),
(
"docs/prompt-pool-routing-map.md",
"formatter route traces exposing selected row metadata",
),
)
PROMPT_ROW_READ_SCAN_GLOBS: tuple[str, ...] = (
+37 -3
View File
@@ -518,11 +518,44 @@ def _trace_dict(formatter_name: str, payload: dict[str, Any]) -> tuple[dict[str,
return trace, ""
def _formatter_trace_metadata_issues(name: str, trace: dict[str, Any], row: dict[str, Any] | None) -> list[str]:
if not isinstance(row, dict):
return []
issues: list[str] = []
expected_fields = {
"metadata_category": row.get("main_category") or row.get("category"),
"metadata_subcategory": row.get("subcategory"),
"action_family": row.get("action_family"),
"position_family": row.get("position_family"),
"position_key": row.get("position_key"),
"scene_profile": row.get("scene_camera_profile_key"),
}
for key, expected in expected_fields.items():
if expected in (None, "", []):
continue
if trace.get(key) != expected:
issues.append(f"{name}: trace_{key}_mismatch:{trace.get(key)} != {expected}")
expected_position_keys = [str(value) for value in (row.get("position_keys") or []) if str(value or "").strip()]
if expected_position_keys:
trace_position_keys = [str(value) for value in (trace.get("position_keys") or [])]
for key in expected_position_keys:
if key not in trace_position_keys:
issues.append(f"{name}: trace_missing_position_key:{key}")
expected_pov_labels = [str(value) for value in (row.get("pov_character_labels") or []) if str(value or "").strip()]
if expected_pov_labels:
trace_pov_labels = [str(value) for value in (trace.get("pov_labels") or [])]
for label in expected_pov_labels:
if label not in trace_pov_labels:
issues.append(f"{name}: trace_missing_pov_label:{label}")
return issues
def _formatter_trace_issues(
name: str,
formats: dict[str, Any],
*,
target: str,
row: dict[str, Any] | None = None,
) -> list[str]:
expected_formatters = {
"krea": "krea2",
@@ -554,14 +587,15 @@ def _formatter_trace_issues(
if formatter_name in ("krea", "sdxl"):
if branch != "insta_of_pair":
issues.append(f"{name}.{formatter_name}: trace_pair_branch_mismatch:{branch}")
if trace.get("selected_side") != target:
issues.append(f"{name}.{formatter_name}: trace_selected_side_mismatch:{trace.get('selected_side')} != {target}")
elif "metadata(insta_of_pair)" not in method:
issues.append(f"{name}.{formatter_name}: trace_caption_pair_method_mismatch:{method}")
if trace.get("selected_side") != target:
issues.append(f"{name}.{formatter_name}: trace_selected_side_mismatch:{trace.get('selected_side')} != {target}")
elif formatter_name == "krea" and not branch.startswith("metadata("):
issues.append(f"{name}.{formatter_name}: trace_krea_metadata_branch_mismatch:{branch}")
elif formatter_name in ("sdxl", "caption") and branch != "metadata":
issues.append(f"{name}.{formatter_name}: trace_metadata_branch_mismatch:{branch}")
issues.extend(_formatter_trace_metadata_issues(f"{name}.{formatter_name}", trace, row))
return issues
@@ -602,7 +636,7 @@ def _formatter_issues(
):
if "metadata" not in str(method or ""):
issues.append(f"{name}.{formatter_name}: not_metadata_route:{method}")
issues.extend(_formatter_trace_issues(name, formats, target=target))
issues.extend(_formatter_trace_issues(name, formats, target=target, row=row))
for label, value in (
(f"{name}.krea_negative", krea.get("negative_prompt")),