from __future__ import annotations

from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import Any


class SessionStatus(str, Enum):
    RUNNING = "running"
    COMPLETED = "completed"
    FAILED = "failed"
    ROLLED_BACK = "rolled_back"


@dataclass(slots=True)
class SessionRecord:
    session_id: str
    created_at: datetime
    status: SessionStatus
    context: dict[str, Any] = field(default_factory=dict)
    completed_at: datetime | None = None
    error: str | None = None
    undo_count: int = 0
