Summary
Add a service-based analytics API to the RL module that enables both Drush commands and other Drupal modules (like ai_content_strategy) to access experiment performance data, insights, and recommendations.
Motivation
Currently, analyzing RL experiment data requires direct database queries. This makes it difficult for:
- AI tools (like Claude Code) to provide experiment insights via Drush
- Other Drupal modules to integrate with RL data
- Automation of experiment analysis and reporting
Proposed Solution
1. Service Layer (RlAnalyzer)
Create a service implementing RlAnalyzerInterface with methods:
listExperiments() - All experiments with summary stats
getStatus($experimentId) - Detailed experiment status
getPerformance($experimentId, $options) - Arm performance with human-readable labels
getTrends($experimentId, $options) - Historical data
export($experimentId) - Full JSON export
2. Drush Commands
Thin CLI wrappers around the service:
rl:list - List all experiments
rl:status <experiment> - Experiment status
rl:performance <experiment> - Arm performance
rl:trends <experiment> - Historical trends
rl:export <experiment> - Full data export
Key Features
- Human-readable labels - Resolve entity IDs to titles/names
- Pre-computed insights - vs_average, confidence levels, trends
- JSON output - Structured data for AI consumption
- Self-documenting - Rich help text for AI discoverability
Technical Approach
Following Drupal core patterns (like StateInterface/State):
- Interface defines API contract
- Service contains all business logic
- Drush commands are thin wrappers
- Other modules inject service via DI
Tasks
Summary
Add a service-based analytics API to the RL module that enables both Drush commands and other Drupal modules (like
ai_content_strategy) to access experiment performance data, insights, and recommendations.Motivation
Currently, analyzing RL experiment data requires direct database queries. This makes it difficult for:
Proposed Solution
1. Service Layer (
RlAnalyzer)Create a service implementing
RlAnalyzerInterfacewith methods:listExperiments()- All experiments with summary statsgetStatus($experimentId)- Detailed experiment statusgetPerformance($experimentId, $options)- Arm performance with human-readable labelsgetTrends($experimentId, $options)- Historical dataexport($experimentId)- Full JSON export2. Drush Commands
Thin CLI wrappers around the service:
rl:list- List all experimentsrl:status <experiment>- Experiment statusrl:performance <experiment>- Arm performancerl:trends <experiment>- Historical trendsrl:export <experiment>- Full data exportKey Features
Technical Approach
Following Drupal core patterns (like
StateInterface/State):Tasks
RlAnalyzerInterfaceRlAnalyzerservicerl.services.ymlRlCommandsDrush class