feat: vendor upstream Skills and add the GCP provider bundle
Increment 2 of .scratch/solution-architect-agent/spec.md. - Vendor google-cloud-solution-architecture and the six google-cloud-waf-* Skills from google/skills@81a31a6, unmodified, with LICENSE, SHA256SUMS and VENDOR.md; add scripts/sync-vendored-skills.sh to re-sync at a pinned sha. - app/agent_skills.py: discover Skills and validate SKILL.md frontmatter against the Agent Skills specification. - app/providers.py + providers/gcp.yaml: load and validate a Cloud provider bundle (Skills, output template, per-role models, tool tiers, remote MCP servers). MCP allowlists stay empty until the read-only review in increment 6. - Settings CLOUD_PROVIDER and MCP_ENABLE_PREVIEW. - 35 new tests; full suite 65 passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
163
tests/test_providers.py
Normal file
163
tests/test_providers.py
Normal file
@@ -0,0 +1,163 @@
|
||||
"""Cloud provider bundle loading and validation."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from app.providers import ProviderConfigError, load_provider
|
||||
|
||||
REPO_ROOT = Path(__file__).parents[1]
|
||||
|
||||
|
||||
def test_gcp_bundle_loads_vendored_skills_and_template():
|
||||
bundle = load_provider("gcp")
|
||||
|
||||
assert bundle.name == "gcp"
|
||||
assert "google-cloud-solution-architecture" in bundle.skills
|
||||
assert {name for name in bundle.skills if name.startswith("google-cloud-waf-")} == {
|
||||
"google-cloud-waf-security",
|
||||
"google-cloud-waf-reliability",
|
||||
"google-cloud-waf-cost-optimization",
|
||||
"google-cloud-waf-operational-excellence",
|
||||
"google-cloud-waf-performance-optimization",
|
||||
"google-cloud-waf-sustainability",
|
||||
}
|
||||
assert bundle.output_template == (
|
||||
REPO_ROOT
|
||||
/ "skills/vendor/google/google-cloud-solution-architecture/assets/output-template.md"
|
||||
)
|
||||
assert bundle.models.default
|
||||
|
||||
|
||||
def test_gcp_bundle_mcp_servers_are_tiered_and_referenced_consistently():
|
||||
bundle = load_provider("gcp")
|
||||
|
||||
general = {
|
||||
server.id for server in bundle.mcp_servers.values() if server.tier == "general"
|
||||
}
|
||||
assert general == {"developer_knowledge"}
|
||||
assert all(
|
||||
server.url.startswith("https://") for server in bundle.mcp_servers.values()
|
||||
)
|
||||
for role, server_ids in bundle.role_mcp_servers.items():
|
||||
assert set(server_ids) <= set(bundle.mcp_servers), role
|
||||
|
||||
|
||||
def test_role_mcp_servers_can_exclude_preview_servers():
|
||||
bundle = load_provider("gcp")
|
||||
|
||||
with_preview = {s.id for s in bundle.mcp_servers_for_role("requirements-analyst")}
|
||||
without_preview = {
|
||||
s.id
|
||||
for s in bundle.mcp_servers_for_role(
|
||||
"requirements-analyst", include_preview=False
|
||||
)
|
||||
}
|
||||
|
||||
assert "asset_inventory" in with_preview
|
||||
assert "asset_inventory" not in without_preview
|
||||
assert bundle.mcp_servers_for_role("no-such-role") == ()
|
||||
|
||||
|
||||
def test_model_for_role_falls_back_to_default():
|
||||
bundle = load_provider("gcp")
|
||||
|
||||
assert bundle.models.for_role("no-such-role") == bundle.models.default
|
||||
|
||||
|
||||
def test_unknown_provider_is_rejected(tmp_path):
|
||||
(tmp_path / "providers").mkdir()
|
||||
|
||||
with pytest.raises(ProviderConfigError, match="aws"):
|
||||
load_provider("aws", root=tmp_path)
|
||||
|
||||
|
||||
def minimal_bundle(tmp_path: Path, **overrides) -> dict:
|
||||
skill_dir = tmp_path / "skills" / "alpha"
|
||||
skill_dir.mkdir(parents=True)
|
||||
(skill_dir / "SKILL.md").write_text(
|
||||
"---\nname: alpha\ndescription: d\n---\n", encoding="utf-8"
|
||||
)
|
||||
(tmp_path / "template.md").write_text("# Template\n", encoding="utf-8")
|
||||
config = {
|
||||
"name": "test",
|
||||
"skills_dirs": ["skills"],
|
||||
"output_template": "template.md",
|
||||
"models": {"default": "gemini/test-model"},
|
||||
"tools": {"general": ["mermaid_check"], "cloud_read": []},
|
||||
"mcp_auth": {"kind": "google_adc"},
|
||||
"mcp_servers": {
|
||||
"docs": {"url": "https://example.com/mcp", "tier": "general", "allow": []}
|
||||
},
|
||||
"role_mcp_servers": {"describer": ["docs"]},
|
||||
}
|
||||
config.update(overrides)
|
||||
return config
|
||||
|
||||
|
||||
def write_bundle(tmp_path: Path, config: dict) -> None:
|
||||
(tmp_path / "providers").mkdir(exist_ok=True)
|
||||
(tmp_path / "providers" / "test.yaml").write_text(
|
||||
yaml.safe_dump(config), encoding="utf-8"
|
||||
)
|
||||
|
||||
|
||||
def test_minimal_bundle_loads(tmp_path):
|
||||
write_bundle(tmp_path, minimal_bundle(tmp_path))
|
||||
|
||||
bundle = load_provider("test", root=tmp_path)
|
||||
|
||||
assert list(bundle.skills) == ["alpha"]
|
||||
assert bundle.mcp_servers["docs"].allow == ()
|
||||
assert bundle.mcp_servers["docs"].preview is False
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("override", "message"),
|
||||
[
|
||||
({"name": "other"}, "name"),
|
||||
({"skills_dirs": ["missing"]}, "skills_dirs"),
|
||||
({"output_template": "missing.md"}, "output_template"),
|
||||
({"models": {}}, "models.default"),
|
||||
({"tools": {"mutating": ["terraform_apply"]}}, "tier"),
|
||||
(
|
||||
{
|
||||
"mcp_servers": {
|
||||
"docs": {
|
||||
"url": "http://example.com/mcp",
|
||||
"tier": "general",
|
||||
"allow": [],
|
||||
}
|
||||
}
|
||||
},
|
||||
"https",
|
||||
),
|
||||
(
|
||||
{
|
||||
"mcp_servers": {
|
||||
"docs": {
|
||||
"url": "https://example.com/mcp",
|
||||
"tier": "write",
|
||||
"allow": [],
|
||||
}
|
||||
}
|
||||
},
|
||||
"tier",
|
||||
),
|
||||
(
|
||||
{
|
||||
"mcp_servers": {
|
||||
"docs": {"url": "https://example.com/mcp", "tier": "general"}
|
||||
}
|
||||
},
|
||||
"allow",
|
||||
),
|
||||
({"role_mcp_servers": {"describer": ["missing"]}}, "missing"),
|
||||
],
|
||||
)
|
||||
def test_invalid_bundles_are_rejected(tmp_path, override, message):
|
||||
write_bundle(tmp_path, minimal_bundle(tmp_path, **override))
|
||||
|
||||
with pytest.raises(ProviderConfigError, match=message):
|
||||
load_provider("test", root=tmp_path)
|
||||
Reference in New Issue
Block a user