feat: comprehensive AI Sorting overhaul with entity-agnostic support and human-readable experiment names #11
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
Fixes #10, Fixes #12, Fixes #13
This PR implements a comprehensive overhaul of AI Sorting, transforming it from a node-only module into a universal, entity-agnostic machine learning solution with proper cold start handling, human-readable experiment names, and production-ready code quality.
Problems Solved
Changes Made
Universal Entity Support (#12)
base_fieldinstead of hardcodednid_entity,_object, and field-based entity access patternsComplete Cold Start Solution (#10)
JavaScript Modernization (#13)
ai-sorting-turns.jsandai-sorting-rewards.jsinto singleai-sorting-tracking.jsnids/nidUrlMaptoentityIds/entityUrlMapHuman-Readable Experiment Names Integration
view_id:display_idformat for clear identificationCode Quality & Cleanup
ExperimentResolver,TotalTrialsService, andAiSortingExperimentDecoratorExperimentRegistrationServiceonlyai_sorting.permissions.ymlTechnical Implementation
Universal Entity Query
Fail-Hard Error Handling
Entity-Agnostic Views Integration
Benefits
✅ Universal compatibility - Works with any Drupal entity type
✅ Proper cold start - New items get appropriate exploration scores
✅ User-friendly reporting - Readable experiment names in admin interface
✅ Reduced complexity - Single JavaScript file, streamlined codebase
✅ Better debugging - Clear error messages instead of silent failures
✅ Production ready - Clean code following Drupal standards
✅ Performance optimized - Consolidated assets, efficient database queries
✅ Future-proof architecture - Extensible design for new entity types
Use Cases Now Supported
Testing
✅ Verified with nodes, users, taxonomy terms, and media entities
✅ Cold start handling confirmed across all entity types
✅ Human-readable experiment names displaying correctly in reports
✅ JavaScript tracking working for both turns and rewards
✅ Drupal coding standards compliance verified
✅ No breaking changes for existing node-based experiments
Compatibility
Related Issues & PRs
This comprehensive overhaul transforms AI Sorting from a limited node-only tool into a universal machine learning platform that works with any Drupal content while providing the production-ready code quality and user experience expected in modern Drupal modules.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com