ADR-021: Handler Nomenclature for Plugin Manifest Declarations
Context
Gatekit's plugin system originally used the term "POLICIES" for manifest declarations that map plugin names to their implementation classes. This terminology was inherited from the initial security-focused design where plugins were conceptualized as "security policies."
With the introduction of middleware plugins, this terminology became problematic:
Semantic Inaccuracy: The term "policy" implies rules or governance, which makes sense for security plugins but not for middleware that performs transformations, routing, or other non-policy operations.
Conceptual Confusion: Auditing plugins that simply observe and log are not "policies" in any meaningful sense. They don't enforce anything or make decisions.
Limited Scope: As the plugin architecture expanded to support different plugin types (security, auditing, middleware), the term "policy" became increasingly inappropriate for non-security contexts.
Developer Experience: New plugin developers were confused about why they needed to declare "POLICIES" for plugins that weren't implementing any policies.
Decision
We will rename all references from "POLICIES" to "HANDLERS" throughout the codebase:
- Manifest Declarations: Change
POLICIES = {...}toHANDLERS = {...}in all plugin files - Configuration Fields: Change
policy: "plugin_name"tohandler: "plugin_name"in YAML configurations - Plugin Attributes: Change
plugin.policytoplugin.handlerfor runtime plugin identification - Method Names: Change
_discover_policies()to_discover_handlers()in the plugin manager - Variable Names: Change all
policy_name,available_policiestohandler_name,available_handlers
Consequences
Positive
Semantic Clarity: "Handler" accurately describes what these are - code that handles messages, regardless of plugin type.
Universal Applicability: The term "handler" works equally well for all plugin types:
- Security handlers make security decisions
- Middleware handlers transform or route messages
- Auditing handlers observe and log activity
Improved Developer Experience: Plugin developers immediately understand that they're declaring message handlers, not policies.
Future-Proof: As new plugin types are added, "handler" remains appropriate terminology.
Industry Alignment: "Handler" is widely used in similar contexts (event handlers, request handlers, message handlers).
Negative
Migration Effort: All existing plugins and configurations need to be updated.
Documentation Updates: All documentation references must be changed.
Potential User Confusion: Users with existing configurations will need to update them (mitigated by helpful error messages).
Migration Strategy
Since Gatekit is at v0.1.0 with no backward compatibility requirements, we can make this a clean break. However, we will:
- Provide clear error messages when old "policy" configuration is detected
- Include a migration script for users to update their configurations
- Update all documentation and examples
- Ensure comprehensive testing of the new terminology
Implementation
The implementation includes:
- Comprehensive grep audit to find all uses of "policy" terminology
- Systematic updates to all plugin files, tests, and documentation
- Addition of helpful error messages for old configuration format
- Creation of migration tooling for user configurations
Notes
This change exemplifies Gatekit's commitment to semantic accuracy and developer experience. While "policy" made sense in the initial security-focused context, the evolution to a general-purpose plugin architecture requires terminology that accurately reflects the broader scope of functionality.
The term "handler" was chosen over alternatives like "processor", "plugin", or "implementation" because:
- It's concise and clear
- It accurately describes the function (handling messages)
- It's familiar to developers from other contexts
- It doesn't imply any specific type of processing or decision-making