from typing import Any from kab_ingestion.models import IngestionResult, SourceDocument from .governance import review def publish_document(document: SourceDocument, cms: Any | None, enabled: bool, require_approval: bool) -> IngestionResult: decision = review(document, require_approval) if not decision.approved: return IngestionResult(document, False, "rejected", decision.reason) if not enabled or cms is None: return IngestionResult(document, True, "validated", "publication disabled") return IngestionResult(document, True, "published", published_url=str(cms.publish(document)))