ADR-034: Plugin Architecture Implementation
Status
Implementation Status: Complete (October 2-4, 2025)
Original Decision: Accepted (June 3, 2025)
Context
The June 3, 2025 architectural decision established plugin architecture from day one, but it was only partially implemented. Currently, GitHub integration is hardcoded rather than pluggable. With spatial intelligence patterns already in our MCP integrations and the need for Notion, Slack, and future PM tool integrations, implementing the plugin architecture is critical for extensibility.
Implementation Context (October 2025)
During GREAT-3A/3B/3C/3D work (October 2-4, 2025), we chose a Wrapper/Adapter Pattern to implement plugins without requiring major refactoring:
- Business logic remains in integration routers (
*_integration_router.py)
- Plugins are thin adapters implementing
PiperPlugin interface (~111 lines each)
- This provides plugin benefits (discovery, lifecycle, config control) without rewriting existing integrations
- Preserves spatial intelligence already implemented in routers
This pragmatic approach allowed us to:
- Add plugin capabilities to 4 existing integrations (GitHub, Slack, Notion, Calendar)
- Maintain backward compatibility (zero breaking changes)
- Complete implementation in 3 days instead of estimated 4 weeks
- Achieve exceptional performance (0.041μs overhead)
Decision
We will implement a plugin architecture where all external integrations (GitHub, Notion, Slack, Calendar, etc.) are pluggable components implementing a common interface. The architecture will be domain-driven, with PM concepts defining the interface rather than tool-specific features.
Implementation Choice: Wrapper/Adapter Pattern
Decision (October 2025): Use thin plugin wrappers that delegate to existing integration routers.
Rationale:
- Integration routers already contain validated business logic
- Spatial intelligence already implemented and tested
- Rewriting to “pure plugins” would risk regressions
- Wrapper pattern provides plugin benefits with minimal risk
- Can migrate to pure plugins incrementally if needed
Plugin Architecture Principles
- Domain-first: PM concepts (WorkItem, TeamMember) drive the interface
- Tool-agnostic: No tool-specific logic in core
- Event-driven: Every plugin interaction emits learnable events
- Capability-based: Plugins declare their capabilities
- Spatial-aware: Leverage MCP spatial intelligence patterns (see ADR-038)
Core Components
Core System (web/app.py)
↓
Plugin Registry (services/plugins/plugin_registry.py)
↓
Plugin Interface (services/plugins/plugin_interface.py - PiperPlugin)
↓
Individual Plugins (services/integrations/*/‹name›_plugin.py)
↓ (delegates to)
Integration Routers (services/integrations/*/‹name›_integration_router.py)
↓ (uses)
Config Services (services/integrations/*/config_service.py)
Implementation Timeline
GREAT-3A: Foundation (October 2, 2025)
Duration: 1 day
GitHub Issue: Part of plugin architecture epic
Achievements:
- Created
PiperPlugin interface with 8 core methods
- Created
PluginRegistry with discovery, loading, lifecycle management
- Implemented 4 operational plugins: GitHub, Slack, Notion, Calendar
- Established two-file pattern:
*_plugin.py + *_integration_router.py
- Added semantic versioning to all plugins (1.0.0)
- 48/48 tests passing with comprehensive coverage
GREAT-3B: Dynamic Loading (October 3, 2025)
Duration: 1 day
GitHub Issue: Part of plugin architecture epic
Achievements:
- Implemented config-controlled plugin loading via
PIPER.user.md
- Added auto-discovery via
importlib introspection
- Created plugin lifecycle management (initialize/shutdown)
- Implemented graceful degradation for unconfigured plugins
- Maintained 100% backward compatibility
- 57/57 tests passing (added lifecycle tests)
GREAT-3C: Documentation & Enhancement (October 4, 2025)
Duration: 0.5 day
GitHub Issue: Part of plugin architecture epic
Achievements:
- Created comprehensive developer guide (497 lines)
- Documented Pattern-031: Plugin Wrapper (189 lines)
- Created demo plugin as copy-paste template (380 lines, 9/9 tests)
- Added versioning policy and quick reference
- Created 3 Mermaid diagrams (system, pattern, data flow)
- Complete documentation ecosystem with cross-references
GREAT-3D: Validation (October 4, 2025)
Duration: 0.5 day
GitHub Issue: Part of plugin architecture epic
Achievements:
- Contract testing: 92/92 tests validating all plugins comply with interface
- Performance testing: All 4 metrics exceeded targets (120× to 909× better)
- ADR documentation: Updated ADR-034 with implementation record
- Created benchmark suite for regression detection
Total Implementation: 3 days (October 2-4, 2025) vs estimated 4 weeks
Architecture Details
Two-File Pattern
Each integration consists of:
- Plugin File (
services/integrations/<name>/<name>_plugin.py, ~111 lines)
- Implements
PiperPlugin interface
- Delegates to integration router
- Provides metadata, lifecycle hooks
- Auto-registers via module import
- Router File (
services/integrations/<name>/<name>_integration_router.py)
- Contains business logic
- Manages integration-specific operations
- Provides FastAPI routes
- May include spatial intelligence
Auto-Registration
Plugins auto-register when their module is imported:
# In plugin file
from services.plugins import get_plugin_registry
registry = get_plugin_registry()
registry.register_plugin("github", GitHubPlugin())
No manual registration needed - just import the plugin module.
Configuration in PIPER.user.md
Plugins are enabled/disabled via YAML blocks:
```plugins
enabled:
- github
- slack
- notion
- calendar
disabled:
- demo
Config-driven loading allows:
- Runtime plugin control without code changes
- Graceful degradation for unconfigured integrations
- Easy testing with different plugin combinations
### Lifecycle Management
Plugins support async initialization and shutdown:
```python
# Startup
await registry.initialize_all()
# Shutdown
await registry.shutdown_all()
All lifecycle methods are idempotent (can be called multiple times safely).
Performance validation (October 4, 2025) via benchmark suite:
| Metric |
Target |
Actual |
Result |
Margin |
| Plugin Overhead |
< 0.05 ms |
0.000041 ms |
✅ PASS |
120× better |
| Startup Time |
< 2000 ms |
295.23 ms |
✅ PASS |
6.8× faster |
| Memory/Plugin |
< 50 MB |
9.08 MB |
✅ PASS |
5.5× better |
| Concurrency |
< 100 ms |
0.11 ms |
✅ PASS |
909× faster |
Key Insights:
- Wrapper pattern is essentially free (0.041μs overhead)
- Startup dominated by config parsing (295ms of 295ms total)
- Memory efficient (9MB per plugin average)
- Fully concurrent-safe (0.11ms for 4 concurrent health checks)
Benchmark Suite: scripts/benchmarks/ for regression detection
Consequences
Positive (Realized)
- ✅ Vendor independence: Not locked to any PM tool ecosystem
- ✅ Infinite extensibility: New tools added without core changes (demo plugin validates)
- ✅ Learning amplification: Every plugin feeds the learning system
- ✅ Cross-tool intelligence: Spatial queries across all plugins (via ADR-038 patterns)
- ✅ Market differentiation: Works with any PM stack
- ✅ Zero performance overhead: 0.041μs wrapper cost is negligible
- ✅ Config-based control: Enable/disable plugins without code changes
- ✅ Backward compatible: Zero breaking changes to existing integrations
Negative (Mitigated)
- ⚠️ Abstraction complexity: Mitigated by comprehensive developer guide
- ⚠️ Feature parity challenges: Addressed by capability-based interface
- ⚠️ Testing burden: Automated via contract tests (92/92 tests, auto-parametrized)
- ⚠️ Initial overhead: Reduced from 4 weeks to 3 days via wrapper pattern
- ⚠️ API stability requirement: Validated via contract tests across all plugins
Trade-offs
- Two files per integration (router + plugin): Acceptable overhead for clean separation
- Not “pure” plugins: Business logic in routers, not plugins - pragmatic choice
- Config in PIPER.user.md: Non-standard but works well with existing patterns
Migration Path
If we need to move to “pure plugins” (all logic in plugin, no routers):
- Incremental migration: Move one integration at a time
- Interface compatibility:
PiperPlugin interface stays the same
- Router becomes internal: Router logic moves into plugin implementation
- No user impact: Plugin consumer code unchanged
- Spatial preserved: Spatial adapters move with plugin logic
Current Assessment: Migration not needed. Wrapper pattern performs exceptionally well.
- ADR-038: Spatial Intelligence Patterns - Plugins leverage these patterns for spatial capabilities
- ADR-013: MCP Spatial Integration Pattern - Superseded by ADR-038, but Calendar plugin uses MCP delegation
- ADR-010: Configuration Patterns - Plugin config follows PIPER.user.md YAML pattern
References
Documentation
- Developer Guide:
docs/guides/plugin-development-guide.md (497 lines)
- Pattern Documentation:
docs/internal/architecture/current/patterns/pattern-031-plugin-wrapper.md (189 lines)
- Demo Plugin:
services/integrations/demo/ (380 lines, complete template)
- Versioning Policy:
docs/guides/plugin-versioning-policy.md (202 lines)
- Quick Reference:
docs/guides/plugin-quick-reference.md (85 lines)
Implementation
- Plugin Interface:
services/plugins/plugin_interface.py (154 lines)
- Plugin Registry:
services/plugins/plugin_registry.py (458 lines)
- Example Plugins:
services/integrations/{github,slack,notion,calendar}/
Testing
- Contract Tests:
tests/plugins/contract/ (92/92 tests passing)
- Performance Tests:
tests/plugins/performance/ (12/12 tests passing)
- Benchmark Suite:
scripts/benchmarks/ (4 benchmark scripts)
Original Vision
- Original decision: June 3, 2025 (Clean slate, plugin from day one)
- Implementation: October 2-4, 2025 (GREAT-3A/3B/3C/3D)
- Related issues: Multiple integration requests across tracks
Success Metrics
Target Metrics (from original decision)
- Plugin development time: <1 week per plugin
- Cross-plugin query success rate: High
- Learning events generated per plugin: Measurable
- User satisfaction with multi-tool support: Positive
Achieved Metrics (October 2025)
- ✅ Plugin development time: Demo plugin created in <1 hour (from template)
- ✅ Interface compliance: 92/92 contract tests passing across all plugins
- ✅ Performance: All metrics 5× to 1,220× better than targets
- ✅ Spatial integration: All plugins support spatial patterns (ADR-038)
- ✅ Documentation: Complete developer guide with copy-paste template
- ✅ Test coverage: Automated contract tests for all future plugins
Verification (October 13, 2025)
Documentation Metrics Verification
Serena MCP Symbolic Analysis confirmed all core claims with corrections to documentation sizes:
| Document |
Original Claim |
Verified Actual |
Status |
Notes |
| ADR-034 size |
281 lines |
280 lines |
⚠️ CORRECTED |
Off by 1 line |
| API Reference |
685 lines |
902 lines |
⚠️ CORRECTED |
+32% larger than claimed |
| Developer Guide |
800+ lines |
523 lines |
⚠️ CORRECTED |
Actually smaller than claimed |
| Contract tests |
92 tests |
92 tests |
✅ ACCURATE |
23 methods × 4 plugins |
| Plugin wrappers |
4 wrappers |
4 wrappers |
✅ ACCURATE |
GitHub, Slack, Notion, Calendar |
Verification Method: Direct file measurement via Serena MCP + bash wc -l + pytest test collection
Implementation Status
- Plugin Architecture: ✅ Complete (October 2-4, 2025)
- File size: 280 lines (corrected from original claim of 281 lines)
- Contract tests: 92 test executions (23 test methods × 4 plugins) - VERIFIED
- Plugin wrappers: 4 operational plugins confirmed - VERIFIED
- Performance overhead: 0.000041ms per request (documented in benchmarks)
Evidence
- Completion report:
dev/2025/10/04/GREAT-3-EPIC-COMPLETE.md (updated with verified metrics)
- Contract tests:
tests/plugins/contract/ (4 test files, 23 test methods, auto-parametrized across 4 plugins)
- Plugin wrappers:
services/integrations/github/github_plugin.py - ✅ Operational
services/integrations/slack/slack_plugin.py - ✅ Operational
services/integrations/notion/notion_plugin.py - ✅ Operational
services/integrations/calendar/calendar_plugin.py - ✅ Operational
- Benchmark suite:
scripts/benchmarks/ (performance validation)
- Developer documentation:
- API Reference:
docs/public/api-reference/api/plugin-api-reference.md (902 lines verified)
- Developer Guide:
docs/guides/plugin-development-guide.md (523 lines verified)
- Pattern documentation:
docs/internal/architecture/current/patterns/pattern-031-plugin-wrapper.md
Verification Notes
Documentation size discrepancies were found and corrected in the GREAT-3 completion report. The plugin architecture implementation itself is sound and all functional claims are accurate. Documentation counts were updated to reflect actual measured file sizes as of October 13, 2025.
Evidence package: dev/2025/10/13/proof-3-great-3-evidence.md