from __future__ import annotations

from app.agents.schemas.learning import LearningDecision, SessionRetrospective


def build_learning_audit_entry(retrospective: SessionRetrospective) -> dict[str, object]:
    decision = retrospective.learning_decision
    return {
        "retrospective_id": retrospective.retrospective_id,
        "decision": decision.decision if isinstance(decision, LearningDecision) else None,
        "explanation": decision.explanation if isinstance(decision, LearningDecision) else None,
        "signal_count": len(retrospective.learning_signals),
        "pattern_count": len(retrospective.pattern_candidates),
        "skill_candidate_count": len(retrospective.skill_candidates),
        "outcome": retrospective.outcome,
    }
