refactor: Align vocabulary — component → program / deployment
Canonical terms (see docs/registry.md glossary): - program: any catalog entry (tool/daemon/frontend) — the software - service / job: how a program is deployed (systemd .service / .timer) - deployment: umbrella for the unified service+job+program view Changes: - core: ServiceSpec/JobSpec component: → program: (component accepted as back-compat validation_alias); DeployedComponent → Deployment. - api: ComponentSummary/Detail → DeploymentSummary/Detail; GET /components → /deployments; GatewayRoute.component → program; GatewayInfo .component_count → deployment_count; ServiceActionResponse/action keys component → program. - app: matching type renames, /components → /deployments hook, route /component/:name → /deployment/:name, GatewayRoute.program. - docs: component-registry.md → registry.md (+ canonical glossary); CLAUDE.md endpoint list refreshed (drop removed /tools, add typed program/service/job + config routes). Tests: core 92, cli 24, api 52 green; app build clean; ruff clean.
This commit is contained in:
@@ -10,7 +10,7 @@ from fastapi.testclient import TestClient
|
||||
import castle_api.config as api_config
|
||||
from castle_api.main import app
|
||||
from castle_core.registry import (
|
||||
DeployedComponent,
|
||||
Deployment,
|
||||
NodeConfig,
|
||||
NodeRegistry,
|
||||
save_registry,
|
||||
@@ -50,7 +50,7 @@ def castle_root(tmp_path: Path) -> Generator[Path, None, None]:
|
||||
},
|
||||
"services": {
|
||||
"test-svc": {
|
||||
"component": "test-svc-comp",
|
||||
"program": "test-svc-comp",
|
||||
"description": "Test service",
|
||||
"run": {
|
||||
"runner": "python",
|
||||
@@ -92,7 +92,7 @@ def registry_path(tmp_path: Path, castle_root: Path) -> Generator[Path, None, No
|
||||
gateway_port=9000,
|
||||
),
|
||||
deployed={
|
||||
"test-svc": DeployedComponent(
|
||||
"test-svc": Deployment(
|
||||
runner="python",
|
||||
run_cmd=["uv", "run", "test-svc"],
|
||||
env={
|
||||
|
||||
@@ -18,7 +18,7 @@ class TestComponents:
|
||||
|
||||
def test_list_components(self, client: TestClient) -> None:
|
||||
"""Returns all registered components."""
|
||||
response = client.get("/components")
|
||||
response = client.get("/deployments")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
names = [c["id"] for c in data]
|
||||
@@ -27,7 +27,7 @@ class TestComponents:
|
||||
|
||||
def test_service_has_port(self, client: TestClient) -> None:
|
||||
"""Service component includes port info."""
|
||||
response = client.get("/components")
|
||||
response = client.get("/deployments")
|
||||
data = response.json()
|
||||
svc = next(c for c in data if c["id"] == "test-svc")
|
||||
assert svc["port"] == 19000
|
||||
@@ -38,7 +38,7 @@ class TestComponents:
|
||||
|
||||
def test_tool_has_no_port(self, client: TestClient) -> None:
|
||||
"""Tool component has no port."""
|
||||
response = client.get("/components")
|
||||
response = client.get("/deployments")
|
||||
data = response.json()
|
||||
tool = next(c for c in data if c["id"] == "test-tool")
|
||||
assert tool["port"] is None
|
||||
@@ -46,19 +46,19 @@ class TestComponents:
|
||||
|
||||
def test_job_has_schedule(self, client: TestClient) -> None:
|
||||
"""Job component has schedule."""
|
||||
response = client.get("/components")
|
||||
response = client.get("/deployments")
|
||||
data = response.json()
|
||||
job = next(c for c in data if c["id"] == "test-job")
|
||||
assert job["behavior"] == "tool"
|
||||
assert job["schedule"] == "0 2 * * *"
|
||||
|
||||
|
||||
class TestComponentDetail:
|
||||
class TestDeploymentDetail:
|
||||
"""Component detail endpoint tests."""
|
||||
|
||||
def test_get_component(self, client: TestClient) -> None:
|
||||
"""Returns detailed info for a component."""
|
||||
response = client.get("/components/test-svc")
|
||||
response = client.get("/deployments/test-svc")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["id"] == "test-svc"
|
||||
@@ -67,7 +67,7 @@ class TestComponentDetail:
|
||||
|
||||
def test_not_found(self, client: TestClient) -> None:
|
||||
"""Returns 404 for unknown component."""
|
||||
response = client.get("/components/nonexistent")
|
||||
response = client.get("/deployments/nonexistent")
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ class TestGateway:
|
||||
assert data["port"] == 9000
|
||||
assert data["hostname"] == "test-node"
|
||||
# Registry has 1 deployed component (test-svc)
|
||||
assert data["component_count"] == 1
|
||||
assert data["deployment_count"] == 1
|
||||
assert data["service_count"] == 1
|
||||
assert data["managed_count"] == 1
|
||||
|
||||
@@ -258,7 +258,7 @@ class TestGateway:
|
||||
route = routes[0]
|
||||
assert route["path"] == "/test-svc"
|
||||
assert route["target_port"] == 19000
|
||||
assert route["component"] == "test-svc"
|
||||
assert route["program"] == "test-svc"
|
||||
assert route["node"] == "test-node"
|
||||
|
||||
def test_gateway_routes_sorted(self, client: TestClient) -> None:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import time
|
||||
|
||||
from castle_core.registry import DeployedComponent, NodeConfig, NodeRegistry
|
||||
from castle_core.registry import Deployment, NodeConfig, NodeRegistry
|
||||
|
||||
from castle_api.mesh import STALE_TTL_SECONDS, MeshStateManager, RemoteNode
|
||||
|
||||
@@ -96,7 +96,7 @@ class TestMeshStateManager:
|
||||
mgr.update_node("devbox", _make_registry("devbox"))
|
||||
new_reg = _make_registry(
|
||||
"devbox",
|
||||
{"svc": DeployedComponent(runner="python", run_cmd=["svc"])},
|
||||
{"svc": Deployment(runner="python", run_cmd=["svc"])},
|
||||
)
|
||||
mgr.update_node("devbox", new_reg)
|
||||
node = mgr.get_node("devbox")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import json
|
||||
|
||||
from castle_core.registry import DeployedComponent, NodeConfig, NodeRegistry
|
||||
from castle_core.registry import Deployment, NodeConfig, NodeRegistry
|
||||
|
||||
from castle_api.mqtt_client import _json_to_registry, _registry_to_json
|
||||
|
||||
@@ -11,7 +11,7 @@ def _make_registry() -> NodeRegistry:
|
||||
return NodeRegistry(
|
||||
node=NodeConfig(hostname="tower", castle_root="/data/repos/castle", gateway_port=9000),
|
||||
deployed={
|
||||
"my-svc": DeployedComponent(
|
||||
"my-svc": Deployment(
|
||||
runner="python",
|
||||
run_cmd=["uv", "run", "my-svc"],
|
||||
env={"PORT": "9001", "SECRET_KEY": "super-secret"},
|
||||
@@ -23,7 +23,7 @@ def _make_registry() -> NodeRegistry:
|
||||
proxy_path="/my-svc",
|
||||
managed=True,
|
||||
),
|
||||
"my-job": DeployedComponent(
|
||||
"my-job": Deployment(
|
||||
runner="command",
|
||||
run_cmd=["my-job"],
|
||||
behavior="tool",
|
||||
@@ -75,7 +75,7 @@ class TestRegistrySerialization:
|
||||
reg = NodeRegistry(
|
||||
node=NodeConfig(hostname="minimal"),
|
||||
deployed={
|
||||
"bare": DeployedComponent(runner="command", run_cmd=["bare"]),
|
||||
"bare": Deployment(runner="command", run_cmd=["bare"]),
|
||||
},
|
||||
)
|
||||
restored = _json_to_registry(_registry_to_json(reg))
|
||||
|
||||
@@ -4,7 +4,7 @@ from pathlib import Path
|
||||
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from castle_core.registry import DeployedComponent, NodeConfig, NodeRegistry
|
||||
from castle_core.registry import Deployment, NodeConfig, NodeRegistry
|
||||
|
||||
from castle_api.mesh import MeshStateManager
|
||||
|
||||
@@ -41,7 +41,7 @@ class TestNodesList:
|
||||
remote_reg = NodeRegistry(
|
||||
node=NodeConfig(hostname="devbox", gateway_port=9000),
|
||||
deployed={
|
||||
"remote-svc": DeployedComponent(
|
||||
"remote-svc": Deployment(
|
||||
runner="python",
|
||||
run_cmd=["svc"],
|
||||
port=9050,
|
||||
|
||||
Reference in New Issue
Block a user