fix: files manually
Some checks failed
quality-gates / verify (push) Failing after 7s

This commit is contained in:
2026-09-01 17:21:58 +01:00
parent 56c9eaa459
commit d8a4b6b3c1
36 changed files with 656 additions and 216 deletions

View File

@@ -0,0 +1,6 @@
from .discovery_node import discovery_node
from .validation_node import validation_node
from .generation_node import generation_node
from .deployment_node import deployment_node
__all__ = ["discovery_node", "validation_node", "generation_node", "deployment_node"]

View 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",
}

View File

@@ -0,0 +1,25 @@
from __future__ import annotations
from typing import Any
from ..states.ingestion_state import IngestionState
def discovery_node(state: IngestionState) -> dict[str, Any]:
"""Discovery Phase: Check existing capabilities and resources non-blockingly."""
request = state.get("request")
source = request.source if request else "unknown"
locator = request.locator if request else "unknown"
# Non-blocking check for existing ingestion resources
existing_resources = {
"source": source,
"locator": locator,
"previously_ingested": False,
"connector_available": source in {"github", "sharepoint"},
}
return {
"existing_resources": existing_resources,
"current_step": "discovery",
"next_step": "validation",
}

View File

@@ -0,0 +1,33 @@
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",
}

View File

@@ -0,0 +1,41 @@
from __future__ import annotations
from typing import Any
from ..states.ingestion_state import IngestionState
def validation_node(state: IngestionState, allowed_sources: set[str] | None = None) -> dict[str, Any]:
"""Validation Phase: Validate request input and fail fast on malformed requests."""
request = state.get("request")
allowed = allowed_sources or {"github", "sharepoint"}
errors: list[str] = []
if not request:
errors.append("missing ingestion request")
else:
if not request.source or not request.source.strip():
errors.append("missing request source")
elif request.source not in allowed:
errors.append(f"unsupported source '{request.source}'")
if not request.locator or not request.locator.strip():
errors.append("missing request locator")
if errors:
error_records = list(state.get("errors", []))
for err in errors:
error_records.append({"step": "validation", "message": err, "recoverable": False})
return {
"validation_errors": errors,
"errors": error_records,
"has_errors": True,
"current_step": "validation",
"next_step": "END",
}
return {
"validation_errors": [],
"current_step": "validation",
"next_step": "generation",
}