code review
This commit is contained in:
@@ -51,17 +51,46 @@ class ConnectionService:
|
||||
next_ids = {connection.id for connection in config.connections}
|
||||
previous_ids = set(self.connections.connections)
|
||||
for connection_id in previous_ids - next_ids:
|
||||
previous = self.connections.connections[connection_id]
|
||||
# This is the low-level config reconciliation path. ConnectionRegistry
|
||||
# and SourceCatalogService do not yet expose paired unregister methods,
|
||||
# so this method owns direct mutation plus the observable events.
|
||||
del self.connections.connections[connection_id]
|
||||
source_catalog.capability_sources.pop(connection_id, None)
|
||||
self.events.record_kind(
|
||||
"connection_removed",
|
||||
connection_id=connection_id,
|
||||
payload={"server": previous.server, "account": previous.account},
|
||||
)
|
||||
|
||||
for connection in config.connections:
|
||||
self._validate_connection_id(connection.id)
|
||||
previous = self.connections.connections.get(connection.id)
|
||||
self.connections.register(connection)
|
||||
source = source_catalog.capability_sources.get(connection.id)
|
||||
if source is None:
|
||||
source_catalog.hydrate_connection_source_from_snapshot(connection)
|
||||
else:
|
||||
source.enabled = connection.enabled
|
||||
if previous is None:
|
||||
self.events.record_kind(
|
||||
"connection_registered",
|
||||
connection_id=connection.id,
|
||||
payload={
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
},
|
||||
)
|
||||
elif previous != connection:
|
||||
self.events.record_kind(
|
||||
"connection_updated",
|
||||
connection_id=connection.id,
|
||||
payload={
|
||||
"server": connection.server,
|
||||
"account": connection.account,
|
||||
"enabled": connection.enabled,
|
||||
},
|
||||
)
|
||||
|
||||
def _source_catalog(self) -> SourceCatalogService:
|
||||
if self.source_catalog is None:
|
||||
|
||||
@@ -15,6 +15,7 @@ from wf_api.operation_context import (
|
||||
)
|
||||
from .core import WfMcpService
|
||||
from .events import BrokerEventRecorder
|
||||
from .source_catalog import SourceCatalogService
|
||||
from .workflow_runtime import WorkflowRuntimeService
|
||||
|
||||
|
||||
@@ -43,16 +44,16 @@ class WfMcpWorkflowEventRecorder(WorkflowEventRecorder):
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class WfMcpWorkflowSpecProvider(WorkflowSpecProvider):
|
||||
"""Adapter-owned spec provider backed by WfMcpService."""
|
||||
"""Adapter-owned spec provider backed by SourceCatalogService."""
|
||||
|
||||
service: WfMcpService
|
||||
source_catalog: SourceCatalogService
|
||||
|
||||
@property
|
||||
def capability_sources(self):
|
||||
return self.service.source_catalog.capability_sources
|
||||
return self.source_catalog.capability_sources
|
||||
|
||||
def get_qualified_spec(self, qualified_name: str) -> NodeSpec[Any, Any]:
|
||||
return self.service.source_catalog.get_qualified_spec(qualified_name)
|
||||
return self.source_catalog.get_qualified_spec(qualified_name)
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
@@ -120,7 +121,7 @@ class WfMcpWorkflowLiveSourceChecker(WorkflowLiveSourceChecker):
|
||||
|
||||
def context_from_service(service: WfMcpService) -> WorkflowOperationContext:
|
||||
"""Adapt the current MCP service stack into a protocol-neutral context."""
|
||||
specs = WfMcpWorkflowSpecProvider(service)
|
||||
specs = WfMcpWorkflowSpecProvider(service.source_catalog)
|
||||
return WorkflowOperationContext(
|
||||
artifact_store=service.artifact_store,
|
||||
draft_workspace_store=service.draft_workspace_store,
|
||||
|
||||
@@ -58,10 +58,10 @@ class WorkflowRuntimeService:
|
||||
|
||||
nodes = []
|
||||
for node in plan.nodes:
|
||||
payload = node.model_dump(by_alias=True)
|
||||
node_payload = node.model_dump(by_alias=True)
|
||||
if isinstance(node, NodeUse):
|
||||
payload["node"] = bindings.get(node.node, node.node)
|
||||
nodes.append(payload)
|
||||
node_payload["node"] = bindings.get(node.node, node.node)
|
||||
nodes.append(node_payload)
|
||||
|
||||
payload = {
|
||||
"name": plan.name,
|
||||
|
||||
Reference in New Issue
Block a user