fix: address rpc and mcp review followups

This commit is contained in:
lda
2026-06-08 22:53:34 +07:00 Verified
parent 44407e8de2
commit 7043866259
29 changed files with 272 additions and 95 deletions
+9 -9
View File
@@ -3,32 +3,32 @@ from __future__ import annotations
from collections.abc import Mapping
from typing import Any
from .base import RpcCaller
class RpcAdminClientMixin:
"""JSON-RPC implementation of read-only admin/config surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_connections(self) -> dict[str, Any]:
async def list_connections(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.admin.connections.list", {})
async def get_connection_statuses(self) -> dict[str, Any]:
async def get_connection_statuses(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.admin.connection_statuses.list", {})
async def list_events(self) -> dict[str, Any]:
async def list_events(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.admin.events.list", {})
async def list_auth_records(self) -> dict[str, Any]:
async def list_auth_records(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.admin.auth.list", {})
async def inspect_auth_record(self, auth_ref: str) -> dict[str, Any]:
async def inspect_auth_record(self: RpcCaller, auth_ref: str) -> dict[str, Any]:
return await self._call(
"workflow.admin.auth.inspect",
{"auth_ref": auth_ref},
)
async def save_auth_record(
self,
self: RpcCaller,
*,
auth_ref: str,
scheme: str,
@@ -45,7 +45,7 @@ class RpcAdminClientMixin:
},
)
async def delete_auth_record(self, auth_ref: str) -> dict[str, Any]:
async def delete_auth_record(self: RpcCaller, auth_ref: str) -> dict[str, Any]:
return await self._call(
"workflow.admin.auth.delete",
{"auth_ref": auth_ref},
@@ -2,14 +2,14 @@ from __future__ import annotations
from typing import Any, Literal
from .base import RpcCaller
class RpcArtifactClientMixin:
"""JSON-RPC implementation of workflow artifact surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_artifacts(
self,
self: RpcCaller,
*,
query: str | None = None,
kind: Literal["workflow", "wrapper"] | None = None,
@@ -27,12 +27,14 @@ class RpcArtifactClientMixin:
)
async def inspect_artifact(
self, *, artifact_id: str, version: int
self: RpcCaller, *, artifact_id: str, version: int
) -> dict[str, Any]:
return await self._call(
"workflow.artifacts.inspect",
{"artifact_id": artifact_id, "version": version},
)
async def save_artifact(self, artifact: dict[str, Any]) -> dict[str, Any]:
async def save_artifact(
self: RpcCaller, artifact: dict[str, Any]
) -> dict[str, Any]:
return await self._call("workflow.artifacts.save", {"artifact": artifact})
+7 -1
View File
@@ -1,12 +1,18 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import Any
from typing import Any, Protocol
from uuid import uuid4
import httpx
class RpcCaller(Protocol):
"""Transport primitive required by domain RPC client mixins."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
@dataclass(slots=True)
class RpcClientTransport:
"""Shared JSON-RPC request plumbing for workflow RPC client mixins.
@@ -2,14 +2,14 @@ from __future__ import annotations
from typing import Any
from .base import RpcCaller
class RpcCapabilityClientMixin:
"""JSON-RPC implementation of workflow capability surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_capabilities(
self,
self: RpcCaller,
*,
query: str | None = None,
source_id: str | None = None,
@@ -26,14 +26,16 @@ class RpcCapabilityClientMixin:
},
)
async def inspect_capability(self, *, qualified_name: str) -> dict[str, Any]:
async def inspect_capability(
self: RpcCaller, *, qualified_name: str
) -> dict[str, Any]:
return await self._call(
"workflow.capabilities.inspect",
{"qualified_name": qualified_name},
)
async def call_capability(
self,
self: RpcCaller,
*,
qualified_name: str,
payload: dict[str, Any],
@@ -2,33 +2,39 @@ from __future__ import annotations
from typing import Any
from .base import RpcCaller
class RpcDeploymentClientMixin:
"""JSON-RPC implementation of workflow deployment surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_deployments(self) -> dict[str, Any]:
async def list_deployments(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.deployments.list", {})
async def inspect_deployment(self, *, deployment_id: str) -> dict[str, Any]:
async def inspect_deployment(
self: RpcCaller, *, deployment_id: str
) -> dict[str, Any]:
return await self._call(
"workflow.deployments.inspect",
{"deployment_id": deployment_id},
)
async def validate_deployment(
self, *, deployment_id: str, live_check: bool = False
self: RpcCaller, *, deployment_id: str, live_check: bool = False
) -> dict[str, Any]:
return await self._call(
"workflow.deployments.validate",
{"deployment_id": deployment_id, "live_check": live_check},
)
async def save_deployment(self, deployment: dict[str, Any]) -> dict[str, Any]:
async def save_deployment(
self: RpcCaller, deployment: dict[str, Any]
) -> dict[str, Any]:
return await self._call("workflow.deployments.save", {"deployment": deployment})
async def delete_deployment(self, *, deployment_id: str) -> dict[str, Any]:
async def delete_deployment(
self: RpcCaller, *, deployment_id: str
) -> dict[str, Any]:
return await self._call(
"workflow.deployments.delete",
{"deployment_id": deployment_id},
+9 -9
View File
@@ -3,17 +3,17 @@ from __future__ import annotations
from collections.abc import Sequence
from typing import Any, Literal
from .base import RpcCaller
class RpcDraftClientMixin:
"""JSON-RPC implementation of workflow draft workspace surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_draft_workspaces(self) -> dict[str, Any]:
async def list_draft_workspaces(self: RpcCaller) -> dict[str, Any]:
return await self._call("workflow.draft_workspaces.list", {})
async def get_draft_workspace(
self,
self: RpcCaller,
*,
workspace_id: str,
include_draft: bool = False,
@@ -24,7 +24,7 @@ class RpcDraftClientMixin:
)
async def create_draft_workspace_from_capability(
self,
self: RpcCaller,
*,
workspace_id: str,
capability_name: str,
@@ -58,7 +58,7 @@ class RpcDraftClientMixin:
)
async def patch_draft_workspace(
self,
self: RpcCaller,
*,
workspace_id: str,
revision: int,
@@ -70,7 +70,7 @@ class RpcDraftClientMixin:
)
async def validate_draft_workspace(
self,
self: RpcCaller,
*,
workspace_id: str,
) -> dict[str, Any]:
@@ -80,7 +80,7 @@ class RpcDraftClientMixin:
)
async def create_artifact_from_workspace(
self,
self: RpcCaller,
*,
workspace_id: str,
artifact_id: str,
@@ -110,7 +110,7 @@ class RpcDraftClientMixin:
)
async def create_wrapper_from_workspace(
self,
self: RpcCaller,
*,
workspace_id: str,
artifact_id: str,
+6 -6
View File
@@ -4,14 +4,14 @@ from typing import Any
from wf_api.runs import TraceRangeLike
from .base import RpcCaller
class RpcRunClientMixin:
"""JSON-RPC implementation of workflow run lifecycle surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def run_deployment(
self,
self: RpcCaller,
*,
deployment_id: str,
workflow_input: dict[str, Any],
@@ -27,7 +27,7 @@ class RpcRunClientMixin:
)
async def resume_run(
self,
self: RpcCaller,
*,
run_id: str,
resume_payload: dict[str, Any],
@@ -44,11 +44,11 @@ class RpcRunClientMixin:
},
)
async def inspect_run(self, *, run_id: str) -> dict[str, Any]:
async def inspect_run(self: RpcCaller, *, run_id: str) -> dict[str, Any]:
return await self._call("workflow.runs.inspect", {"run_id": run_id})
async def read_run_trace(
self,
self: RpcCaller,
*,
run_id: str,
trace_range: TraceRangeLike,
@@ -2,14 +2,14 @@ from __future__ import annotations
from typing import Any
from .base import RpcCaller
class RpcSourceRegistryClientMixin:
"""JSON-RPC implementation of source registry surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_registry_entries(
self,
self: RpcCaller,
*,
cursor: str | None = None,
limit: int = 50,
@@ -20,7 +20,7 @@ class RpcSourceRegistryClientMixin:
)
async def inspect_registry_entry(
self,
self: RpcCaller,
*,
source_id: str,
) -> dict[str, Any]:
@@ -30,7 +30,7 @@ class RpcSourceRegistryClientMixin:
)
async def add_registry_entry(
self,
self: RpcCaller,
*,
entry: dict[str, Any],
) -> dict[str, Any]:
@@ -40,7 +40,7 @@ class RpcSourceRegistryClientMixin:
)
async def update_registry_entry(
self,
self: RpcCaller,
*,
source_id: str,
patch: dict[str, Any],
@@ -51,7 +51,7 @@ class RpcSourceRegistryClientMixin:
)
async def enable_registry_entry(
self,
self: RpcCaller,
*,
source_id: str,
) -> dict[str, Any]:
@@ -61,7 +61,7 @@ class RpcSourceRegistryClientMixin:
)
async def disable_registry_entry(
self,
self: RpcCaller,
*,
source_id: str,
) -> dict[str, Any]:
@@ -71,7 +71,7 @@ class RpcSourceRegistryClientMixin:
)
async def remove_registry_entry(
self,
self: RpcCaller,
*,
source_id: str,
) -> dict[str, Any]:
@@ -80,7 +80,7 @@ class RpcSourceRegistryClientMixin:
{"source_id": source_id},
)
async def apply_registry_changes(self) -> dict[str, Any]:
async def apply_registry_changes(self: RpcCaller) -> dict[str, Any]:
return await self._call(
"workflow.admin.source_registry.apply",
{},
+4 -4
View File
@@ -2,14 +2,14 @@ from __future__ import annotations
from typing import Any
from .base import RpcCaller
class RpcSourceAdminClientMixin:
"""JSON-RPC implementation of read-only source admin surface methods."""
async def _call(self, method: str, params: dict[str, Any]) -> dict[str, Any]: ...
async def list_sources(
self,
self: RpcCaller,
*,
cursor: str | None = None,
limit: int = 50,
@@ -22,7 +22,7 @@ class RpcSourceAdminClientMixin:
},
)
async def inspect_source(self, *, source_id: str) -> dict[str, Any]:
async def inspect_source(self: RpcCaller, *, source_id: str) -> dict[str, Any]:
return await self._call(
"workflow.sources.inspect",
{"source_id": source_id},
@@ -26,11 +26,12 @@ def _require_source_registry_admin(
) -> WorkflowSourceRegistrySurface:
admin = server.source_registry_admin
if admin is None:
verb = "are" if operation in {"reads", "mutations"} else "is"
raise WorkflowRpcError(
data={
"code": "source_registry_unavailable",
"message": (
f"source registry admin {operation} are not available "
f"source registry admin {operation} {verb} not available "
"for this server"
),
}