-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
This issue consolidates production-ready improvements including enhanced symlink compatibility, security hardening, and debug cleanup across the RL module.
Changes Made
- Enhanced
rl.phpendpoint with symlink support: Added fallback path detection using$_SERVER['SCRIPT_FILENAME']for symlinked module development setups - Security improvements: Input validation for experiment UUIDs and arm IDs using regex patterns
- Thompson sampling tie-breaker: Added micro-randomization to prevent identical scores
- Debug cleanup: Removed all debug logging statements from production code
- Code optimization: Simplified conditional logic and removed verbose comments
Technical Details
rl.php Endpoint Enhancement
- Primary path detection:
chdir('../../../')for standard installations - Fallback detection: Uses
$_SERVER['SCRIPT_FILENAME']when symlinks are present - Input sanitization: Regex validation for security (
/^[a-zA-Z0-9]+$/for UUIDs) - Error handling: Proper HTTP status codes (400, 500) with descriptive messages
Thompson Sampling Improvements
- Added tie-breaker mechanism:
$base_score + $tie_breakerwhere tie-breaker =mt_rand(1, 999) / 1000000 - Ensures unique scores even when beta distributions return identical values
- Maintains statistical properties while preventing deterministic ordering
Production Cleanup
- Removed debug statements from
ExperimentDataStorage.phpandExperimentManager.php - Simplified time window logic to ternary operators
- Removed verbose code comments, keeping only essential documentation
- Code passes Drupal coding standards
Testing
- Symlink compatibility verified with development setups
- Path detection fallback tested with both standard and symlinked installations
- Thompson sampling randomization confirmed working
- All Drupal coding standards checks pass
Compatibility
- Drupal 10/11 compatible
- Works with both standard and symlinked module installations
- Backward compatible with existing experiment data
- No database schema changes required
Pull Request: #8
Related to AI Sorting module cold start fix: dxpr/ai_sorting#10
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
No labels