This commit is contained in:
41
app/nodes/deployment_node.py
Normal file
41
app/nodes/deployment_node.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from kab_ingestion.models import IngestionResult
|
||||
from ..publication import publish_document
|
||||
from ..states.ingestion_state import IngestionState
|
||||
from ..validation import validate_document
|
||||
|
||||
|
||||
def deployment_node(
|
||||
state: IngestionState,
|
||||
cms: Any = None,
|
||||
publish_enabled: bool = False,
|
||||
require_governance_approval: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
"""Deployment Phase: Review governance, enforce tenant ACL isolation, and publish documents."""
|
||||
documents = state.get("fetched_documents", [])
|
||||
results: list[IngestionResult] = []
|
||||
|
||||
for doc in documents:
|
||||
report = validate_document(doc)
|
||||
if not report.valid:
|
||||
results.append(IngestionResult(doc, False, "invalid", "; ".join(report.errors)))
|
||||
continue
|
||||
res = publish_document(doc, cms, publish_enabled, require_governance_approval)
|
||||
results.append(res)
|
||||
|
||||
accepted_count = sum(1 for r in results if r.accepted)
|
||||
final_output = {
|
||||
"total": len(results),
|
||||
"accepted": accepted_count,
|
||||
"results": results,
|
||||
"status": "completed" if not state.get("has_errors") else "completed_with_errors",
|
||||
}
|
||||
|
||||
return {
|
||||
"published_results": results,
|
||||
"final_output": final_output,
|
||||
"current_step": "deployment",
|
||||
"next_step": "END",
|
||||
}
|
||||
Reference in New Issue
Block a user