feat: add seconds-based time window support for Thompson Sampling#3
Closed
feat: add seconds-based time window support for Thompson Sampling#3
Conversation
Implements comprehensive admin interface for managing RL experiments with granular permission control and proper separation of concerns. **New Features:** - Added CRUD forms for creating, editing, and deleting experiments - Granular permissions: 'administer rl experiments' and 'view rl reports' - Admin operations (Edit/Delete) shown conditionally based on permissions - Add experiment button for users with admin permissions **Changes:** - Updated permissions.yml with more specific, secure permission names - Added 3 new routes: add, edit, delete experiment forms - Enhanced ReportsController with permission-based operations column - Created ExperimentForm for create/update operations with validation - Created ExperimentDeleteForm with confirmation and cascade delete **Security:** - Restricted 'administer rl experiments' permission with 'restrict access: true' - Separated read-only 'view rl reports' from admin permissions - Form validation prevents UUID conflicts and ensures data integrity - Transaction-based delete with proper error handling and rollback **UX Improvements:** - Operations column shows View | Edit | Delete for admins, View-only for others - Primary action button styling for "Add experiment" - Clear confirmation dialog for destructive delete operations - Proper cancel links and redirects maintain workflow continuity 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Move Operations column to first position for better UX - Rename "Module" column to "Ownership" for clearer semantics - Operations are now the first thing users see in each row 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add getAllArmsDataWithWindow() method to storage interface and implementation - Add getThompsonScoresWithWindow() method to manager interface and implementation - Implement time-based filtering using seconds for technical precision - Add optimized composite indexes for time window query performance - Add covering index on rl_arm_data for optimal SELECT performance - Maintain backward compatibility with existing getAllArmsData() method - Support filtering arms by activity timestamp (updated column) BREAKING CHANGE: New database indexes require fresh installation or manual index updates Addresses sliding time window functionality for non-stationary content optimization. Enables content marketers to focus recommendations on recently active content. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
9 tasks
Contributor
Author
|
Closing this PR to create a clean one without extraneous commits from outdated base branch. New PR: [Will be created momentarily] |
Contributor
Author
|
✅ New clean PR created: #4 This PR was closed and recreated to remove extraneous commits that were showing due to an outdated base branch. The new PR contains only the time window implementation changes. |
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
Implements sliding time window functionality for Thompson Sampling to support non-stationary content optimization. Enables content marketers to focus AI recommendations on recently active content while maintaining backward compatibility.
Implementation Details
New Storage Methods
getAllArmsDataWithWindow($experiment_uuid, $time_window_seconds)- Filters arms by activity timestampgetAllArmsData()methodNew Manager Methods
getThompsonScoresWithWindow($experiment_uuid, $time_window_seconds)- Thompson Sampling with time filteringgetThompsonScores()now uses new method internallyDatabase Optimizations
rl_experiment_totals(experiment_uuid, updated)rl_arm_data(experiment_uuid, updated, arm_id, turns, rewards, created)Technical Benefits
Database Schema Changes
BREAKING CHANGE: Requires fresh installation or manual index updates
New indexes replace old separate indexes:
rl_experiment_totals:experiment_uuid+updated→experiment_updated(experiment_uuid, updated)rl_arm_data:experiment_uuid+updated→covering_time_window(experiment_uuid, updated, arm_id, turns, rewards, created)Testing Performed
Use Cases Enabled
Content Types Benefiting:
Content Types Unchanged:
Related Issues & PRs
Resolves: #2
Paired with: dxpr/ai_sorting#6 (UI integration)
Related: dxpr/ai_sorting#5 (UI issue)
Deployment Notes
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com