Skip to main content
Version: Latest

ActionHistory Migration Plan

Executive Summary

The ActionHistory class is currently in a transitional state, supporting both the legacy ActionOptions.Action API and the modern ActionConfig API. This document outlines a comprehensive plan to complete the migration to the modern API while maintaining backward compatibility.

Current State Assessment

Migration Progress

  • ✅ 70% Complete: Infrastructure and dual API support implemented
  • ⚠️ 20% In Progress: Internal methods still using legacy API
  • ❌ 10% Not Started: Deprecation removal and data migration

Key Components Status

ComponentStatusNotes
ActionConfigAdapter✅ CompleteFull type mapping implemented
ActionRecord Dual API✅ CompleteBoth fields with auto-population
Modern API Methods✅ CompleteAll new methods implemented
Deprecation Marking✅ CompleteLegacy methods marked @Deprecated
Test Coverage✅ CompleteComprehensive modern API tests
Internal Method Updates⚠️ PartialSome hardcoded references remain
Data Migration Tools❌ Not StartedNo serialization migration path
Legacy Method Removal❌ Not StartedNo deprecation timeline

Migration Phases

Phase 1: Complete Internal Migration (2-3 weeks)

Goal: Remove all hardcoded ActionOptions.Action references

Tasks:

  1. Update getRandomText() method

    // Current (hardcoded)
    public String getRandomText() {
    ActionRecord snapshot = getRandomSnapshot(ActionOptions.Action.FIND);
    // ...
    }

    // Target (using ActionConfig)
    public String getRandomText() {
    PatternFindOptions findConfig = new PatternFindOptions.Builder().build();
    ActionRecord snapshot = getRandomSnapshot(findConfig);
    // ...
    }
  2. Refactor helper methods

    • Update getFindOrVanishSnapshots() to use ActionConfig parameter
    • Update getSnapshotOfFindType() to use ActionConfig parameter
    • Remove direct ActionOptions.Action enum usage
  3. Update type detection methods

    • Enhance getSnapshotActionType() to prioritize ActionConfig
    • Enhance getSnapshotFindType() to prioritize ActionConfig

Deliverables:

  • All internal methods using ActionConfig
  • No direct ActionOptions.Action references
  • Updated unit tests confirming functionality

Phase 2: Data Migration Infrastructure (3-4 weeks)

Goal: Enable seamless migration of existing data

Tasks:

  1. Create migration utilities

    @Component
    public class ActionHistoryMigrationService {
    public ActionHistory migrate(ActionHistory legacy) {
    // Convert ActionOptions-based snapshots to ActionConfig
    }

    public void migrateDatabase(DataSource dataSource) {
    // Batch migrate persisted records
    }
    }
  2. Implement serialization converters

    • JSON deserializer that auto-converts ActionOptions to ActionConfig
    • Database migration scripts for existing records
    • File-based migration tool for saved states
  3. Add migration validation

    • Checksum verification for migrated data
    • Rollback capability for failed migrations
    • Migration status tracking

Deliverables:

  • ActionHistoryMigrationService implementation
  • Database migration scripts
  • Migration validation framework
  • Documentation for migration process

Phase 3: Gradual Deprecation (2-3 months)

Goal: Transition users to modern API

Tasks:

  1. Enhanced deprecation warnings

    @Deprecated(since = "1.2.0", forRemoval = true)
    @DeprecationWarning(
    message = "This method will be removed in version 2.0.0",
    alternative = "Use getRandomSnapshot(ActionConfig) instead"
    )
    public ActionRecord getRandomSnapshot(ActionOptions.Action action) {
    // Log deprecation usage for metrics
    DeprecationMetrics.log("getRandomSnapshot", "ActionOptions.Action");
    // ...
    }
  2. Usage metrics collection

    • Track deprecated method usage in production
    • Generate deprecation reports
    • Identify high-impact areas
  3. Migration guides and tooling

    • Automated code migration tool
    • IDE plugin for deprecation warnings
    • Comprehensive migration documentation

Deliverables:

  • Deprecation metrics system
  • Automated migration tool
  • Updated documentation
  • User communication plan

Phase 4: Performance Optimization (2-3 weeks)

Goal: Optimize ActionConfigAdapter performance

Tasks:

  1. Caching implementation

    @Component
    public class ActionConfigAdapter {
    private final Map<Class<?>, ActionOptions.Action> typeCache =
    new ConcurrentHashMap<>();

    public ActionOptions.Action getActionType(ActionConfig config) {
    return typeCache.computeIfAbsent(
    config.getClass(),
    this::computeActionType
    );
    }
    }
  2. Lazy initialization

    • Defer ActionOptions creation until needed
    • Use weak references for infrequently used mappings
  3. Performance benchmarking

    • Compare legacy vs modern API performance
    • Identify and optimize hotspots
    • Document performance characteristics

Deliverables:

  • Optimized ActionConfigAdapter
  • Performance benchmark suite
  • Performance documentation

Phase 5: Legacy Removal (Version 2.0.0)

Goal: Remove all deprecated code

Tasks:

  1. Remove deprecated methods

    • Delete all @Deprecated ActionOptions.Action methods
    • Remove ActionOptions field from ActionRecord
    • Clean up ActionConfigAdapter legacy support
  2. Update all dependencies

    • Update Pattern class usage
    • Update UI components
    • Update test suites
  3. Final migration verification

    • Ensure all data migrated
    • Verify no legacy API usage
    • Performance regression testing

Deliverables:

  • Clean codebase without legacy API
  • Updated documentation
  • Migration completion report

Implementation Timeline

PhaseDurationStart DateEnd DateDependencies
Phase 12-3 weeksWeek 1Week 3None
Phase 23-4 weeksWeek 4Week 7Phase 1
Phase 32-3 monthsWeek 8Week 20Phase 2
Phase 42-3 weeksWeek 16Week 19Parallel with Phase 3
Phase 51 weekVersion 2.0Version 2.0All phases

Risk Mitigation

High-Risk Areas

  1. Serialized Data Compatibility

    • Risk: Breaking existing saved states
    • Mitigation: Dual deserialization support for 2 major versions
  2. Performance Degradation

    • Risk: ActionConfigAdapter overhead
    • Mitigation: Caching and optimization in Phase 4
  3. User Adoption

    • Risk: Slow migration to modern API
    • Mitigation: Automated migration tools and extended deprecation period

Rollback Strategy

  1. Feature flags for new functionality
  2. Versioned APIs during transition
  3. Data backup before migration
  4. Phased rollout with monitoring

Success Metrics

Phase 1 Metrics

  • Zero hardcoded ActionOptions.Action references
  • All tests passing with modern API

Phase 2 Metrics

  • 100% of existing data migrateable
  • Migration tool processes 1000+ records/second

Phase 3 Metrics

  • < 5% deprecated API usage after 2 months
  • 90% of users migrated to modern API

Phase 4 Metrics

  • < 10% performance overhead vs legacy API
  • Sub-millisecond ActionConfigAdapter operations

Phase 5 Metrics

  • Zero legacy API code in codebase
  • All dependent modules updated

Developer Migration Guide

For Library Users

Step 1: Update method calls

// Old way (deprecated)
ActionRecord snapshot = history.getRandomSnapshot(ActionOptions.Action.FIND);

// New way (recommended)
PatternFindOptions findConfig = new PatternFindOptions.Builder()
.setStrategy(PatternFindOptions.Strategy.BEST)
.build();
ActionRecord snapshot = history.getRandomSnapshot(findConfig);

Step 2: Update ActionRecord creation

// Old way (deprecated)
ActionRecord record = new ActionRecord.Builder()
.setActionOptions(new ActionOptions.Builder()
.setAction(ActionOptions.Action.CLICK)
.build())
.build();

// New way (recommended)
ActionRecord record = new ActionRecord.Builder()
.setActionConfig(new ClickOptions.Builder()
.setClickType(ClickOptions.Type.LEFT)
.build())
.build();

Step 3: Run migration tool

java -jar brobot-migration-tool.jar \
--source ./src \
--migrate-actionhistory \
--backup ./backup

For Framework Contributors

Understanding the Adapter Pattern

// ActionConfigAdapter handles the translation
public class ActionConfigAdapter {
public ActionOptions.Action getActionType(ActionConfig config) {
// Maps modern config to legacy action type
if (config instanceof PatternFindOptions) return FIND;
if (config instanceof ClickOptions) return CLICK;
// ...
}
}

Testing Both APIs

@Test
public void testDualAPICompatibility() {
// Test legacy API
ActionRecord legacyResult = history.getRandomSnapshot(
ActionOptions.Action.FIND
);

// Test modern API
ActionRecord modernResult = history.getRandomSnapshot(
new PatternFindOptions.Builder().build()
);

// Results should be equivalent
assertEquals(legacyResult.getActionType(), modernResult.getActionType());
}

Communication Plan

Version 1.2.0 (Phase 1-2 Complete)

  • Release notes highlighting new ActionConfig API
  • Migration guide publication
  • Deprecation warnings added

Version 1.3.0 (Phase 3 Start)

  • Enhanced deprecation warnings
  • Migration tool availability
  • Community workshops

Version 1.5.0 (Phase 3 End)

  • Final deprecation notice
  • Legacy API usage report
  • Version 2.0 timeline announcement

Version 2.0.0 (Phase 5)

  • Legacy API removal
  • Final migration guide
  • Success celebration 🎉

Conclusion

This migration plan provides a structured approach to completing the ActionHistory transition from ActionOptions to ActionConfig. By following these phases, we can ensure:

  1. Backward compatibility during transition
  2. Minimal disruption to existing users
  3. Performance parity or improvement
  4. Clean, modern API for future development

The key to success is gradual migration with comprehensive tooling support and clear communication throughout the process.