"""Pipeline context for multi-language processing."""

from dataclasses import dataclass, field
from typing import Any, Literal


@dataclass
class PipelineContext:
    """Context object that flows through language processing pipelines."""

    language_id: str
    source_code: str
    function_name: str
    feature: Literal["testgen", "optimizer", "code_repair"]

    generated_test: str | None = None
    optimized_code: str | None = None
    repaired_code: str | None = None
    test_framework: str | None = None
    metadata: dict[str, Any] = field(default_factory=dict)
    additional_context: dict[str, Any] = field(default_factory=dict)

    def __post_init__(self) -> None:
        if not self.language_id:
            raise ValueError("language_id is required")
        if not self.source_code:
            raise ValueError("source_code is required")
        if not self.function_name:
            raise ValueError("function_name is required")
        if self.feature not in ("testgen", "optimizer", "code_repair"):
            msg = f"Invalid feature '{self.feature}'. Must be one of: testgen, optimizer, code_repair"
            raise ValueError(msg)
