core: add orchestration and service definitions
This commit is contained in:
27
tests/test_orchestration.py
Normal file
27
tests/test_orchestration.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from afs.orchestration import Orchestrator, TaskRequest
|
||||
from afs.schema import AgentConfig, OrchestratorConfig
|
||||
|
||||
|
||||
def test_orchestrator_disabled_returns_note() -> None:
|
||||
config = OrchestratorConfig(enabled=False)
|
||||
orchestrator = Orchestrator(config=config)
|
||||
plan = orchestrator.plan(TaskRequest(summary="Test"))
|
||||
assert not plan.agents
|
||||
assert "orchestrator disabled" in plan.notes
|
||||
|
||||
|
||||
def test_orchestrator_matches_tags() -> None:
|
||||
config = OrchestratorConfig(
|
||||
enabled=True,
|
||||
max_agents=2,
|
||||
default_agents=[
|
||||
AgentConfig(name="planner", role="planner", tags=["plan"]),
|
||||
AgentConfig(name="builder", role="coder", tags=["build"]),
|
||||
],
|
||||
)
|
||||
orchestrator = Orchestrator(config=config)
|
||||
plan = orchestrator.plan(TaskRequest(summary="Build", tags=["build"]))
|
||||
assert len(plan.agents) == 1
|
||||
assert plan.agents[0].name == "builder"
|
||||
28
tests/test_services.py
Normal file
28
tests/test_services.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from afs.schema import AFSConfig, ServiceConfig, ServicesConfig
|
||||
from afs.services.manager import ServiceManager
|
||||
|
||||
|
||||
def test_service_manager_lists_builtins() -> None:
|
||||
manager = ServiceManager(config=AFSConfig(), platform_name="linux")
|
||||
names = [definition.name for definition in manager.list_definitions()]
|
||||
assert "orchestrator" in names
|
||||
|
||||
|
||||
def test_service_config_can_disable_service() -> None:
|
||||
services = ServicesConfig(
|
||||
enabled=True,
|
||||
services={
|
||||
"orchestrator": ServiceConfig(name="orchestrator", enabled=False),
|
||||
},
|
||||
)
|
||||
manager = ServiceManager(config=AFSConfig(services=services), platform_name="linux")
|
||||
names = [definition.name for definition in manager.list_definitions()]
|
||||
assert "orchestrator" not in names
|
||||
|
||||
|
||||
def test_service_render_contains_execstart() -> None:
|
||||
manager = ServiceManager(config=AFSConfig(), platform_name="linux")
|
||||
unit = manager.render_unit("orchestrator")
|
||||
assert "ExecStart=" in unit
|
||||
Reference in New Issue
Block a user