"""Registry: Meta-Scores (Phase 0b) — Ziel-Fortschritt und Datenqualität."""

from placeholder_registry import (
    PlaceholderMetadata,
    MissingValuePolicy,
    OutputType,
    PlaceholderType,
    register_placeholder,
)
from ._evidence import tag_standard_evidence

CAT = "Scores (Phase 0b)"
MVP = lambda reason, disp: MissingValuePolicy(
    available=False, value_raw=None, missing_reason=reason, legacy_display=disp
)


def register_phase_0b_meta_scores():
    for key, dl_fn, desc, unit in [
        (
            "goal_progress_score",
            "calculate_goal_progress_score",
            "Aggregierter Ziel-Fortschritt 0–100",
            "0–100",
        ),
        (
            "data_quality_score",
            "calculate_data_quality_score",
            "Datenqualitäts-Score 0–100",
            "0–100",
        ),
    ]:
        m = PlaceholderMetadata(
            key=key,
            category=CAT,
            description=desc,
            resolver_module="backend/placeholder_resolver.py",
            resolver_function="_safe_int",
            data_layer_module="backend/data_layer/scores.py",
            data_layer_function=dl_fn,
            source_tables=["goals", "weight_log", "nutrition_log", "activity_log", "profiles"],
            semantic_contract=f"scores.{dl_fn} (siehe Data Layer).",
            business_meaning="Meta-KPI für Prompt-Gewichtung",
            unit=unit,
            time_window="composite",
            output_type=OutputType.NUMERIC,
            placeholder_type=PlaceholderType.SCORE,
            format_hint="Ganzzahl als String",
            example_output="72",
            minimum_data_requirements="Abhängig von Score-Implementierung",
            quality_filter_policy=None,
            confidence_logic="Wie calculate_* in scores.py",
            missing_value_policy=MVP("insufficient_data", "nicht verfügbar"),
            known_limitations="Bei dünnen Daten weniger aussagekräftig",
            layer_1_decision=f"scores.{dl_fn}",
            layer_2a_decision="_safe_int",
            layer_2b_reuse_possible=True,
            architecture_alignment="Phase 0b",
            issue_53_alignment="Layer 1",
            evidence={},
        )
        tag_standard_evidence(m)
        register_placeholder(m)


register_phase_0b_meta_scores()
