from __future__ import annotations

from dataclasses import dataclass, field

from app.core.agent.processes.v2.workflows.doc_update_from_feature.doc_rules_pipeline.models import DocRulesBundle
from app.core.agent.runtime.execution_context import RuntimeExecutionContext
from app.core.agent.utils.process_v2.models import V2RouteResult
from app.schemas.changeset import ChangeItem
from app.core.agent.processes.v2.workflows.doc_update_from_feature.workflow_runtime.models import (
    AnalyticsMeta,
    FeatureRequirementUnit,
    PlannedChange,
)


@dataclass(slots=True)
class DocUpdateFromFeatureContext:
    runtime: RuntimeExecutionContext
    route: V2RouteResult
    rag_session_id: str
    source_ref: str = ""
    source_kind: str = ""
    project_root: str = ""
    feature_content: str = ""
    analytics_meta: AnalyticsMeta = field(default_factory=AnalyticsMeta)
    units: list[FeatureRequirementUnit] = field(default_factory=list)
    docs_catalog_rows: list[dict] = field(default_factory=list)
    doc_rules_enabled: bool = True
    doc_rules_bundle: DocRulesBundle | None = None
    planned_changes: list[PlannedChange] = field(default_factory=list)
    changeset: list[ChangeItem] = field(default_factory=list)
    apply_changeset: bool = False
    issues: list[str] = field(default_factory=list)
    answer: str = ""
    answer_generated_payload: dict[str, object] | None = None
