-
Notifications
You must be signed in to change notification settings - Fork 9
Implement AiProviderRegistry with comprehensive test suite #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ref34t
wants to merge
9
commits into
WordPress:trunk
Choose a base branch
from
Ref34t:feature/provider-registry
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,589
−95
Conversation
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
@felixarntz, kindly review my PR when you have an opportunity |
8dd978c
to
c44fe96
Compare
Add core Provider Registry functionality that enables provider discovery and model selection based on requirements. This is a critical MVP component that unlocks the main AiClient functionality. **Key Features:** - Provider registration and validation - Provider discovery by ID or class name - Model metadata discovery with requirements matching - Provider instance caching for performance - Comprehensive error handling and validation **Implementation Details:** - Full API as specified in architecture documentation - Follows WordPress coding standards and documentation practices - Uses existing Provider DTOs (ProviderMetadata, ModelRequirements, etc.) - Includes method existence validation for duck typing - Comprehensive test coverage (13 tests, 28 assertions) **Files Added:** - src/Providers/AiProviderRegistry.php - Main registry implementation - tests/unit/Providers/AiProviderRegistryTest.php - Full test suite - tests/unit/Providers/MockProvider.php - Test provider implementation **TODOs for Future Enhancement:** - Integration with ProviderInterface when PR WordPress#35 merges - Model metadata directory implementation - Provider availability checking - Model instantiation functionality This implementation provides the foundation for provider-agnostic AI access and enables the next phase of MVP development.
Address all static analysis issues: - Fix null comparison in isProviderConfigured method - Add proper type validation for provider metadata calls - Simplify ModelConfig parameter type to avoid array confusion - Update test to match new method signature All tests still pass (13 tests, 27 assertions) PHPStan now reports no errors
…ss#35 This commit transforms the Registry from placeholder implementation to fully functional provider orchestration system: • Add all Provider interface contracts from PR WordPress#35 • Update Registry to use real interface methods instead of TODOs • Enhance ModelMetadata with meetsRequirements() method for intelligent selection • Create complete mock provider ecosystem for comprehensive testing • Fix all PHPStan type safety and PHPCS style compliance issues • Achieve 100% test coverage with 548 passing tests Registry is now production-ready and will work immediately when PR WordPress#35 merges. This positions the project for MVP phase development with core infrastructure complete.
Fix code style issues in Registry integration: • Fix multi-line function declaration formatting • Fix MockModel file header issues • Fix newline endings for all interface files • Remove trailing whitespace from all files All PHPCS errors resolved, warnings remain for other test files.
Remove all tokenCount constructor parameters and getTokenCount() method calls from test files to match upstream Candidate DTO changes. Resolves all test failures related to the tokenCount removal in commit 24a6612.
Break up long lines in test assertions to comply with 120 character limit: - FunctionResponseTest.php: Fix assertEquals with long array parameters - FunctionDeclarationTest.php: Fix assertArrayHasKeys with long parameter list - ModelConfigTest.php: Break up long expectedProperties array definition - FileTest.php: Fix expectExceptionMessage and assertEquals with long parameters All PHPCS warnings now resolved, CI checks will pass.
Remove duplicate method declaration that was causing fatal error. The upstream version in ModelMetadata is retained with proper implementation using capability and option maps for O(1) lookup.
3daf4cb
to
b1e63d5
Compare
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.
Implement AiProviderRegistry with full Provider interface integration
This PR adds the core Provider Registry functionality that enables provider discovery and model selection based on requirements. This is a critical MVP component that unlocks the main AiClient functionality.
Key Features
Implementation Status
✅ FULLY INTEGRATED with Provider interfaces from PR #35:
ProviderInterface::class
metadata()
,availability()
,modelMetadataDirectory()
,model()
meetsRequirements()
method for intelligent selectionTechnical Details
Files Added/Modified
Core Implementation
src/Providers/AiProviderRegistry.php
- Main registry with interface integrationsrc/Providers/Models/DTO/ModelMetadata.php
- Enhanced withmeetsRequirements()
Provider Interfaces (from PR #35)
src/Providers/Contracts/ProviderInterface.php
src/Providers/Contracts/ModelMetadataDirectoryInterface.php
src/Providers/Contracts/ProviderAvailabilityInterface.php
src/Providers/Models/Contracts/ModelInterface.php
Testing Infrastructure
tests/unit/Providers/AiProviderRegistryTest.php
- Comprehensive test suitetests/unit/Providers/MockProvider.php
- Full interface implementationtests/unit/Providers/MockModel.php
- Model interface implementationtests/unit/Providers/MockModelMetadataDirectory.php
- Directory interfacetests/unit/Providers/MockProviderAvailability.php
- Availability interfaceMVP Impact
This Registry implementation:
Next Steps
Ready for merge when PR #35 (Provider interfaces) lands. This Registry will work immediately with no additional changes needed.