feat: type source registry results

This commit is contained in:
lda
2026-08-01 09:02:56 +07:00 Verified
parent fbcd3a61a5
commit 18b9002d17
9 changed files with 398 additions and 96 deletions
@@ -169,6 +169,121 @@ def test_openrpc_exposes_typed_source_diagnosis_result(
assert diagnosed["additionalProperties"] is True
def test_openrpc_exposes_typed_source_registry_read_results(
openrpc_document: dict[str, Any],
) -> None:
_assert_result_component(
openrpc_document,
method_name="workflow.admin.source_registry.list",
component_name="ListRegistryEntriesResult",
properties={"entries", "next_cursor", "total"},
)
_assert_result_component(
openrpc_document,
method_name="workflow.admin.source_registry.inspect",
component_name="InspectRegistryEntryResult",
properties={"entry", "shadowed_by_config", "config_ownership", "mutable"},
)
schemas = openrpc_document["components"]["schemas"]
assert schemas["ListRegistryEntriesResult"]["properties"]["entries"]["items"] == {
"$ref": "#/components/schemas/RegistryEntrySummaryPayload"
}
assert schemas["InspectRegistryEntryResult"]["properties"]["entry"] == {
"$ref": "#/components/schemas/RegistryEntryPayload"
}
assert schemas["RegistryEntryPayload"]["additionalProperties"] is True
assert set(schemas["ListRegistryEntriesResult"]["required"]) == {
"entries",
"next_cursor",
"total",
}
assert set(schemas["RegistryEntrySummaryPayload"]["required"]) == {
"id",
"kind",
"enabled",
"provider",
"account",
"profile",
"transport_kind",
"auth_ref",
"shadowed_by_config",
"config_ownership",
"mutable",
}
assert set(schemas["InspectRegistryEntryResult"]["required"]) == {
"entry",
"shadowed_by_config",
"config_ownership",
"mutable",
}
@pytest.mark.parametrize(
"method_name",
[
"workflow.admin.source_registry.add",
"workflow.admin.source_registry.update",
"workflow.admin.source_registry.enable",
"workflow.admin.source_registry.disable",
],
)
def test_openrpc_exposes_typed_source_registry_mutation_result(
openrpc_document: dict[str, Any],
method_name: str,
) -> None:
_assert_result_component(
openrpc_document,
method_name=method_name,
component_name="RegistryEntryMutationResult",
properties={"entry", "shadowed_by_config"},
)
mutation = openrpc_document["components"]["schemas"]["RegistryEntryMutationResult"]
assert set(mutation["required"]) == {"entry", "shadowed_by_config"}
assert mutation["properties"]["entry"] == {
"$ref": "#/components/schemas/RegistryEntryPayload"
}
def test_openrpc_exposes_typed_source_registry_remove_and_apply_results(
openrpc_document: dict[str, Any],
) -> None:
_assert_result_component(
openrpc_document,
method_name="workflow.admin.source_registry.remove",
component_name="RemoveRegistryEntryResult",
properties={"removed", "source_id"},
)
_assert_result_component(
openrpc_document,
method_name="workflow.admin.source_registry.apply",
component_name="ApplyRegistryChangesResult",
properties={
"applied",
"registered",
"updated",
"removed",
"connection_count",
"registry_entry_count",
},
)
schemas = openrpc_document["components"]["schemas"]
assert set(schemas["RemoveRegistryEntryResult"]["required"]) == {
"removed",
"source_id",
}
assert set(schemas["ApplyRegistryChangesResult"]["required"]) == {
"applied",
"registered",
"updated",
"removed",
"connection_count",
"registry_entry_count",
}
assert schemas["ApplyRegistryChangesResult"]["properties"]["auth_diagnostics"][
"items"
] == {"$ref": "#/components/schemas/DependencyDiagnosticPayload"}
@pytest.mark.parametrize(
("method_name", "component_name", "properties"),
[
@@ -22,6 +22,7 @@ class FakeRegistryEntry:
transport: dict[str, str] | None = None
auth_ref: str | None = "github.work"
metadata: dict[str, object] | None = None
provider_options: dict[str, object] | None = None
class FakeRegistryProvider:
@@ -31,6 +32,7 @@ class FakeRegistryProvider:
id="github.work",
transport={"kind": "stdio", "command": "npx"},
metadata={},
provider_options={"region": "work"},
)
]
@@ -152,6 +154,8 @@ async def test_rpc_source_registry_methods_return_registry_payloads(tmp_path) ->
assert listed["result"]["entries"][0]["id"] == "github.work"
assert listed["result"]["entries"][0]["shadowed_by_config"] is True
assert inspected["result"]["entry"]["transport"]["kind"] == "stdio"
assert inspected["result"]["entry"]["transport"]["command"] == "npx"
assert inspected["result"]["entry"]["provider_options"] == {"region": "work"}
assert inspected["result"]["shadowed_by_config"] is True
@@ -246,12 +250,22 @@ async def test_rpc_source_registry_add_returns_entry(tmp_path) -> None:
payload = await _rpc(
client,
"workflow.admin.source_registry.add",
{"entry": {"id": "new.mcp", "kind": "mcp", "enabled": True}},
{
"entry": {
"id": "new.mcp",
"kind": "mcp",
"enabled": True,
"transport": {"kind": "stdio", "command": "custom-runner"},
"provider_options": {"region": "local"},
}
},
)
assert "result" in payload
assert payload["result"]["entry"]["id"] == "new.mcp"
assert payload["result"]["entry"]["kind"] == "mcp"
assert payload["result"]["entry"]["transport"]["command"] == "custom-runner"
assert payload["result"]["entry"]["provider_options"] == {"region": "local"}
async def test_rpc_source_registry_update_returns_entry(tmp_path) -> None:
@@ -476,6 +490,16 @@ async def test_rpc_source_registry_apply_returns_summary(tmp_path) -> None:
"removed": [],
"connection_count": 1,
"registry_entry_count": 1,
"auth_diagnostics": [
{
"severity": "error",
"code": "auth_not_found",
"logical_ref": "",
"bound_source": "demo.new",
"message": "Missing auth record.",
"repair_hint": "Save the referenced auth record.",
}
],
}
server = replace(
build_local_static_workflow_server(tmp_path / "store"),
@@ -494,6 +518,7 @@ async def test_rpc_source_registry_apply_returns_summary(tmp_path) -> None:
assert payload["result"]["applied"] is True
assert payload["result"]["registered"] == ["demo.new"]
assert payload["result"]["auth_diagnostics"][0]["code"] == "auth_not_found"
admin.apply_registry_changes.assert_awaited_once()