File size: 867 Bytes
77da5ce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from core.life_state import LifeMetrics
VALID_METRIC_PATHS = tuple(sorted(LifeMetrics().flatten().keys()))
LEGACY_METRIC_ALIASES = {
"physical_health.exercise_routine": "physical_health.fitness",
}
def normalize_metric_path(path: str) -> str:
"""Map legacy or malformed metric names onto the current LifeMetrics schema."""
if not isinstance(path, str):
return ""
path = path.strip()
return LEGACY_METRIC_ALIASES.get(path, path)
def is_valid_metric_path(path: str) -> bool:
return normalize_metric_path(path) in VALID_METRIC_PATHS
def format_valid_metrics() -> str:
grouped = {}
for path in VALID_METRIC_PATHS:
domain, metric = path.split(".", 1)
grouped.setdefault(domain, []).append(metric)
return "\n".join(
f"{domain}: {', '.join(metrics)}" for domain, metrics in grouped.items()
)
|