WP-0001 complete: v1.1.0 lazy registry and install performance
Some checks failed
ci / test (3.12) (push) Has been cancelled
ci / test (3.10) (push) Has been cancelled

Lazy-load agent registry (frontmatter index, parse on demand), copy
agents by path during install, fix Makefile template tab lint issue,
add registry performance tests, bump to 1.1.0, document CLI reinstall
after pull.
This commit is contained in:
2026-06-16 02:06:43 +02:00
parent 80c60ebd7a
commit 22ee93e125
10 changed files with 227 additions and 138 deletions

View File

@@ -53,9 +53,9 @@ description: Second test agent
registry = AgentRegistry(tmp_path)
assert len(registry._agents) == 2
assert "agent-one" in registry._agents
assert "agent-two" in registry._agents
assert registry.agent_names() == ["agent-one", "agent-two"]
assert registry.get_agent("agent-one") is not None
assert registry.get_agent("agent-two") is not None
def test_agent_registry_get_agent(tmp_path):

View File

@@ -0,0 +1,79 @@
"""Registry lazy-loading performance tests (WP-0001 T06)."""
from __future__ import annotations
from pathlib import Path
from unittest.mock import patch
import pytest
from kaizen_agentic.installer import AgentInstaller, InstallationConfig
from kaizen_agentic.registry import AgentDefinition, AgentRegistry
def _write_agent(path: Path, name: str) -> None:
path.write_text(
f"""---
name: {name}
description: Agent {name}
category: testing
---
# {name}
""",
encoding="utf-8",
)
@pytest.fixture
def large_registry(tmp_path: Path) -> AgentRegistry:
agents_dir = tmp_path / "agents"
agents_dir.mkdir()
for index in range(15):
_write_agent(agents_dir / f"agent-agent-{index}.md", f"agent-{index}")
_write_agent(agents_dir / "agent-tdd-workflow.md", "tdd-workflow")
return AgentRegistry(agents_dir)
def test_registry_indexes_without_full_parse(large_registry: AgentRegistry):
assert len(large_registry.agent_names()) == 16
assert large_registry._agents == {}
def test_get_agent_loads_only_requested_agent(large_registry: AgentRegistry):
with patch.object(
AgentDefinition,
"from_file",
wraps=AgentDefinition.from_file,
) as mock_from_file:
agent = large_registry.get_agent("tdd-workflow")
assert agent is not None
assert agent.name == "tdd-workflow"
assert mock_from_file.call_count == 1
def test_install_single_agent_parses_minimal_subset(
large_registry: AgentRegistry, tmp_path: Path
):
installer = AgentInstaller(large_registry)
project_dir = tmp_path / "project"
with patch.object(
AgentDefinition,
"from_file",
wraps=AgentDefinition.from_file,
) as mock_from_file:
results = installer.install_agents(
["tdd-workflow"],
InstallationConfig(
target_dir=project_dir,
create_backup=False,
update_docs=False,
),
)
assert results["tdd-workflow"] == "INSTALLED"
assert (project_dir / "agents" / "agent-tdd-workflow.md").exists()
# resolve_dependencies loads only the target agent, not the full fleet
assert mock_from_file.call_count == 1