from __future__ import annotations

from dataclasses import dataclass, field
from typing import Any


@dataclass(frozen=True)
class StepContext:
    run_id: str
    step_run_id: str
    step_key: str
    biz_dt: str
    date_snapshot: dict[str, Any]
    config_snapshot: dict[str, Any]
    input_snapshot: dict[str, Any] = field(default_factory=dict)


@dataclass(frozen=True)
class StepResult:
    success: bool
    payload: dict[str, Any]
    error_code: str | None = None
    error_message: str | None = None
    exit_code: int | None = None
    log_uri: str | None = None
    timed_out: bool = False

    def to_dict(self) -> dict[str, Any]:
        return {
            "success": self.success,
            "payload": self.payload,
            "error_code": self.error_code,
            "error_message": self.error_message,
            "exit_code": self.exit_code,
            "log_uri": self.log_uri,
            "timed_out": self.timed_out,
        }
