feat: Phase 2 plugin architecture with entry point discovery#115
Draft
ChristopherJHart wants to merge 5 commits into
Draft
feat: Phase 2 plugin architecture with entry point discovery#115ChristopherJHart wants to merge 5 commits into
ChristopherJHart wants to merge 5 commits into
Conversation
Adds a clean internal boundary between the core framework and plugin implementations, enabling third-party plugins via Python entry points while keeping built-in plugins automatically active by default. New modules: - huginn.plugin_registry: Central PluginRegistry with entry point discovery for brokers, inventory, reporters, and hooks - huginn.hooks: HookPlugin protocol, HookEvent enum, HookDispatcher with influencing event semantics (SKIP/CONTINUE signals) - huginn.reporting.protocol: ReporterPlugin protocol definition Key changes: - Built-in brokers (SSH, HTTP, NETCONF), FileInventoryPlugin, and HTMLReporterPlugin registered as entry points in pyproject.toml - RuntimeBroker accepts optional PluginRegistry for broker resolution, with backward-compatible fallback to direct instantiation - Runner iterates reporter plugins instead of hardcoding HTML reporter - Inventory plugin spec parsing delegates to registry for third-party plugin discovery - CLI reads [tool.huginn.plugins] from pyproject.toml to configure plugin filtering and per-plugin options - normalize_broker_key passes through unknown protocol strings to support future third-party broker types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Format hooks.py and plugin_registry.py with ruff - Add return type annotations to test helpers - Remove tomli fallback (Python 3.11+ always has tomllib) - Add PluginRegistry to TYPE_CHECKING import in cli.py - Widen broker type annotations from set[BrokerType] to set[str] throughout runner.py and runtime_broker.py to match the new string-based routing - Remove .value accesses on broker keys (already strings via StrEnum) - Extract _persist_and_report() from run_test_plan to reduce cyclomatic complexity below xenon threshold Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move all plugin-related imports from inside functions to module-level imports. No circular dependencies exist between these modules, so lazy imports were unnecessary. - runtime_broker.py: move SSHBroker, HTTPBroker, NETCONFBroker, and PluginRegistry to top-level imports - cli.py: move tomllib, InjectPlan, PluginConfig, PluginRegistry to module level - inventory_plugins.py: move PluginRegistry and PluginResolutionError to module level - runner.py: move PluginRegistry to module level Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Python 3.11+ supports all modern typing syntax natively. The only forward reference needed (RuntimeBrokerClient -> RuntimeBroker) is handled with a quoted string annotation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…istry.py No forward references exist in this module. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PluginRegistrywith entry point discovery (importlib.metadata) for all four plugin types: brokers, inventory, reporters, and hookspyproject.tomlHookPluginprotocol with influencing event semantics (hooks can request SKIP at select lifecycle points)ReporterPluginprotocol enabling multiple simultaneous reporters or zero-reporter configurationRuntimeBrokerregistry-driven while maintaining full backward compatibility with existing test injection patterns[tool.huginn.plugins]from projectpyproject.tomlfor plugin configurationThis is Phase 2 of the plugin architecture roadmap: clean internal separation within the same repository, with the ability for third-party plugins to be installed and wired in via standard Python entry points.
Test plan
pytest tests/)importlib.metadata.entry_points(group='huginn.brokers')returns{ssh, http, netconf}[tool.huginn.plugins]produces identical behavior🤖 AI Generation Metadata
🤖 Generated with Claude Code