from __future__ import annotations

from dataclasses import dataclass, field

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_v2.workflow_runtime.models import (
    AccumulatedPageDraft,
    AnalyticsMeta,
    RequirementTaskContext,
    RequirementUnit,
    RuleDocument,
)


@dataclass(slots=True)
class DocUpdateFromFeatureV2Context:
    runtime: RuntimeExecutionContext
    route: V2RouteResult
    rag_session_id: str
    source_ref: str = ""
    source_kind: str = ""
    project_root: str = ""
    source_content: str = ""
    analytics_meta: AnalyticsMeta = field(default_factory=AnalyticsMeta)
    requirements: list[RequirementUnit] = field(default_factory=list)
    rules: list[RuleDocument] = field(default_factory=list)
    docs_catalog_rows: list[dict] = field(default_factory=list)
    requirement_tasks: list[RequirementTaskContext] = field(default_factory=list)
    accumulated_pages: list[AccumulatedPageDraft] = 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
