feat: add plugin loader infrastructure

Implement plugin loading and validation:
- loader.py: discover, import, validate plugins
- validate PLUGIN_MANIFEST, MODEL_REQUIREMENTS, create_engine
- validate api_version compatibility (major must match)
- validate capabilities (reject unknown)
- diagnostic messages for all error cases
- no partial registration after error

Test plugins:
- fake_plugin: minimal valid plugin for testing
- missing_manifest: no PLUGIN_MANIFEST
- invalid_api_version: major version mismatch
- invalid_capabilities: unknown capabilities
- missing_create_engine: no create_engine function
- import_error: raises ImportError during import
- missing_model_requirements: no MODEL_REQUIREMENTS

39 new tests covering all loader functionality.
This commit is contained in:
Artem Akymenko
2026-07-12 16:20:05 +03:00
parent 0f568120f4
commit 6eda8516cc
9 changed files with 1025 additions and 0 deletions
@@ -0,0 +1,29 @@
"""Invalid plugin: incompatible api_version (major version mismatch)."""
from __future__ import annotations
from pathlib import Path
from typing import Any
from abogen.tts_plugin.manifest import PluginManifest
from abogen.tts_plugin.types import EngineConfig
# api_version "2.0" has major version 2, but host expects major version 1
PLUGIN_MANIFEST = PluginManifest(
id="invalid_api_version",
name="Invalid API Version Plugin",
version="1.0.0",
api_version="2.0", # Major version mismatch!
description="Plugin with incompatible api_version",
author="Test Author",
)
MODEL_REQUIREMENTS: list[Any] = []
def create_engine(
context: Any,
model_path: Path | None,
config: EngineConfig,
) -> Any:
raise NotImplementedError("This plugin is invalid")