ADR-0001: Unified Platform Registration Architecture
Status
Accepted
Date
2025-12-08
Context
BenchBox had two parallel systems for platform registration that could drift apart:
-
get_platform_adapter()inbenchbox/platforms/__init__.py- Hardcoded dictionary mapping platform names to adapter classes
- Included alias handling (e.g.,
sqlite3->SQLiteAdapter) - Used by CLI for benchmark execution (
benchbox run)
-
PlatformRegistryinbenchbox/core/platform_registry.py- Dynamic registration via
auto_register_platforms() - Rich metadata (descriptions, categories, capabilities, requirements)
- Used by CLI for platform discovery (
benchbox platforms list)
- Dynamic registration via
This led to bugs where:
- New platforms were added to one system but not the other
- Alias handling was only in
get_platform_adapter() - Installation requirements were duplicated and could diverge
- Platform availability detection was implemented twice
Decision
Make PlatformRegistry the single source of truth for all platform-related information:
- Adapter Registration: All platforms are registered only in
auto_register_platforms() - Alias Resolution: Move alias handling to
PlatformRegistry.resolve_platform_name() - Adapter Lookup:
get_platform_adapter()delegates toPlatformRegistry.get_adapter_class() - Metadata: All platform metadata (requirements, capabilities) lives in
PlatformRegistry
The get_platform_adapter() function remains as a thin wrapper that:
- Handles CLI-specific concerns (driver version resolution, error messages)
- Delegates all platform lookup to PlatformRegistry
Consequences
Positive
- Single registration point: New platforms only need to be added to
auto_register_platforms() - Consistent aliases: Alias resolution works everywhere via
resolve_platform_name() - No drift: Alignment tests prevent future divergence
- Reduced code: ~100 lines of duplicated code removed
- Cleaner architecture: Clear separation between registry (source of truth) and factory (CLI concerns)
Negative
- Additional indirection:
get_platform_adapter()now calls PlatformRegistry methods - Migration required: Any external code directly using the old implementations needs updating
Neutral
- Public API preserved:
get_platform_adapter(),list_available_platforms(), andget_platform_requirements()remain available with same signatures
Implementation
- Added
resolve_platform_name()andget_all_aliases()to PlatformRegistry - Updated
get_adapter_class(),get_platform_info(),get_platform_capabilities()to use alias resolution - Refactored
get_platform_adapter()to delegate adapter lookup to PlatformRegistry - Replaced
list_available_platforms()andget_platform_requirements()with thin wrappers - Added comprehensive alignment tests in
test_platform_registration_alignment.py
How to Add a New Platform
After this change, adding a new platform requires:
- Create the adapter class in
benchbox/platforms/ - Add metadata to
_build_platform_metadata()inplatform_registry.py - Add registration to
auto_register_platforms()inplatform_registry.py
The alignment tests will fail if any of these steps are missed.
References
benchbox/core/platform_registry.py- PlatformRegistry classbenchbox/platforms/__init__.py- get_platform_adapter() and other wrapperstests/unit/core/test_platform_registration_alignment.py- Alignment tests