from __future__ import annotations from typing import Any from ..states.ingestion_state import IngestionState def generation_node(state: IngestionState, scm: Any = None) -> dict[str, Any]: """Generation Phase: Fetch and normalize documents from source connector.""" request = state.get("request") if not request or not scm: return { "fetched_documents": [], "current_step": "generation", "next_step": "deployment", } try: documents = list(scm.fetch(request)) return { "fetched_documents": documents, "current_step": "generation", "next_step": "deployment", } except Exception as exc: error_records = list(state.get("errors", [])) error_records.append({"step": "generation", "message": str(exc), "recoverable": True}) return { "fetched_documents": [], "errors": error_records, "has_errors": True, "current_step": "generation", "next_step": "END", }