decomposer: fix validation failure for Migrate the kab_ingestion domain models, ports, GitHub SCM connector, and SharePoint CMS connector into the repository's app/ package.; Wire the migrated ingestion components into the agent application entry point, card, settings, triggers, governance, publication, and validation layers.; Populate every remaining placeholder file with working application, package, test, dependency, and Kubernetes content.; Verify the migrated agent and completed repository end to end.
Some checks failed
quality-gates / verify (push) Failing after 7s
Some checks failed
quality-gates / verify (push) Failing after 7s
This commit is contained in:
50
app/agent.py
50
app/agent.py
@@ -1,16 +1,40 @@
|
||||
from .card import CARD
|
||||
from .settings import Settings
|
||||
from .connectors.github import GitHubConnector
|
||||
from .connectors.sharepoint import SharePointConnector
|
||||
from .routes import ingest_route
|
||||
from .triggers import register_triggers
|
||||
from .governance import authorize
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from .card import AGENT_CARD, AgentCard
|
||||
from .kab_ingestion.connectors.github import GitHubSCMConnector
|
||||
from .kab_ingestion.connectors.sharepoint import SharePointCMSConnector
|
||||
from .kab_ingestion.domain.models import IngestionRequest, IngestionResult
|
||||
from .publication import publish_document
|
||||
from .settings import Settings, get_settings
|
||||
from .validation import validate_document
|
||||
|
||||
def create_agent_app(settings: Settings | None = None) -> dict:
|
||||
config = settings or Settings.from_env()
|
||||
source, publisher = GitHubConnector(config.github_token), SharePointConnector(config.sharepoint_site_url)
|
||||
app = {"card": CARD, "settings": config, "routes": {"/ingest": lambda payload: ingest_route(payload, source)}, "triggers": {}, "governance": authorize, "publication": lambda doc: publish_document(doc, publisher, config), "validation": validate_document}
|
||||
register_triggers(app, app["routes"]["/ingest"])
|
||||
return app
|
||||
|
||||
@dataclass
|
||||
class IngestionService:
|
||||
settings: Settings
|
||||
scm: Any
|
||||
cms: Any = None
|
||||
|
||||
def ingest(self, request: IngestionRequest) -> list[IngestionResult]:
|
||||
if request.source not in self.settings.allowed_sources:
|
||||
return []
|
||||
results = []
|
||||
for document in self.scm.fetch(request):
|
||||
report = validate_document(document)
|
||||
if not report.valid:
|
||||
from .kab_ingestion.domain.models import IngestionResult
|
||||
results.append(IngestionResult(document, False, "invalid", "; ".join(report.errors)))
|
||||
continue
|
||||
results.append(publish_document(document, self.cms, self.settings.publish_enabled, self.settings.require_governance_approval))
|
||||
return results
|
||||
|
||||
|
||||
def create_agent_app(settings: Settings | None = None) -> dict[str, Any]:
|
||||
config = settings or get_settings()
|
||||
scm = GitHubSCMConnector(config.github_token, config.github_api_base)
|
||||
cms = SharePointCMSConnector(config.sharepoint_site_url, config.sharepoint_access_token) if config.sharepoint_site_url and config.sharepoint_access_token else None
|
||||
service = IngestionService(config, scm, cms)
|
||||
return {"card": AGENT_CARD, "service": service, "routes": {"/health": "health", "/card": "card", "/ingest": "ingest"}, "triggers": {"github": "github_trigger"}}
|
||||
|
||||
Reference in New Issue
Block a user