Conversation
…and production cleanup - Enhanced rl.php endpoint with symlink support using SCRIPT_FILENAME fallback - Thompson sampling tie-breaker to ensure unique scores - Cold start initialization: getThompsonScores() now accepts arm IDs to initialize - Security improvements with regex input validation - Complete debug cleanup removing all debug logging - Code optimization with simplified logic The cold start fix allows getThompsonScores() to accept an array of arm IDs that should be initialized with zero stats if they don't exist in the database. This ensures the RL module always returns scores, even for completely new experiments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
dd51762 to
f1ba127
Compare
- Add experiment_name field to rl_experiment_registry table - Update ExperimentRegistryInterface to support optional experiment name - Update ExperimentRegistry to store experiment names when provided - Update ReportsController to display experiment names instead of UUIDs - Add database update hook rl_update_8002 for field addition Fixes issue where experiments showed SHA1 hashes instead of readable names in reports interface. AI Sorting module can now pass "view:display" format names that will be properly displayed to users. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Use nullable parameter syntax (?string instead of string = NULL) - Remove trailing whitespace 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix recordTurns() to increment total_turns by 1 per page view - Previously was incrementing by number of arms shown - Each arm still gets individual turn tracking - 1 page view = 1 total turn (regardless of arms count) - Also update existing incorrect totals based on arm data In multi-armed bandit context, 1 turn = 1 decision opportunity, not 1 per item displayed. This fixes the overview reports showing 0 total turns while individual experiments showed correct data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Change recordTurns() to increment total_turns by arm count - Each arm turn represents one opportunity/exposure - Total turns = sum of all individual arm turns across all arms - If 10 arms shown on page, total_turns increases by 10 - Update existing totals to match sum of arm turns This fixes the overview reports to correctly show the sum of all arm exposures rather than just counting page views. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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
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.
Summary
Fixes #7, Fixes #9, Fixes #10, Fixes #11
This PR implements a comprehensive overhaul of the RL module, introducing human-readable experiment names, complete cold start handling, total turns calculation fixes, enhanced symlink support, and production-ready code quality improvements.
Problems Solved
Changes Made
Human-Readable Experiment Names (#10)
experiment_namefield torl_experiment_registrytableExperimentRegistryInterface::register()now accepts optional experiment namesrl_update_8002()adds field to existing installationsTotal Turns Calculation Fix (#11)
Complete Cold Start Solution
getThompsonScores()now acceptsrequested_armsparameterThompson Sampling Improvements (#9)
Enhanced rl.php Endpoint (#7)
$_SERVER['SCRIPT_FILENAME']fallbackFILTER_SANITIZE_STRINGusageProduction Code Quality (#7)
Technical Implementation
Human-Readable Names Storage (#10)
Enhanced Cold Start Logic
Corrected Total Turns Calculation (#11)
Thompson Sampling with Tie-Breaker (#9)
Database Schema Changes
New Field Added (#10)
rl_experiment_registry.experiment_name(VARCHAR 255, nullable)Update Hook
rl_update_8002()safely adds field to existing installationsdrush updbData Correction (#11)
Benefits
✅ User-friendly reporting - Experiment names show as "content_recent:default" instead of SHA1 hashes (#10)
✅ Accurate statistics - Total turns display correctly as sum of all arm exposures (#11)
✅ Proper cold start - New content gets appropriate exploration scores for fair exposure
✅ Universal compatibility - Works with standard and symlinked Drupal installations (#7)
✅ Production ready - Clean code without debug statements or verbose logging (#7)
✅ Performance optimized - Efficient database operations and streamlined endpoint
✅ Developer friendly - Clear error messages and comprehensive documentation
✅ Statistically sound - Proper multi-armed bandit implementation with exploration guarantees (#9)
Reporting Improvements
Before (#10, #11):
After:
Testing
✅ Human-readable experiment names displaying correctly in admin reports (#10)
✅ Total turns calculation verified with multiple arm configurations (#11)
✅ Cold start behavior confirmed for new experiments and new arms
✅ Symlink compatibility tested in development environments (#7)
✅ Thompson sampling randomization verified during cold start conditions (#9)
✅ Database update hook tested on existing installations
✅ Drupal coding standards compliance verified
✅ Backward compatibility confirmed with existing experiment data
Compatibility
Related Issues & PRs
This comprehensive overhaul transforms the RL module into a production-ready, statistically sound machine learning platform with proper cold start handling, accurate reporting, and user-friendly administration interfaces that work reliably across all Drupal installation scenarios.
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com