Adaptive Learning Triggers - Learning When to Learn

Intelligent triggers based on patterns, not arbitrary time intervals

🎯 Adaptive Learning Triggers

The Problem with Time-Based Triggers

❌ "Run pattern extraction every week"

Problems:
β”œβ”€ Week with 500 decisions: Extraction too late, patterns missed
β”œβ”€ Week with 5 decisions: Wasted compute, nothing to learn
β”œβ”€ Urgent pattern (same error 10x): Waits until Sunday
└─ Arbitrary: Why 7 days? Why not 3? Why not 14?

The Solution: Event-Driven Learning

βœ… "Learn when there's something to learn"

Triggers:
β”œβ”€ Volume: 100 new decisions since last extraction
β”œβ”€ Repetition: Same question asked 3+ times
β”œβ”€ Performance: Success rate drops below threshold
β”œβ”€ Confidence: Average confidence declining
└─ Novelty: New category/domain detected

Trigger System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    LEARNING TRIGGER SYSTEM                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚   VOLUME    β”‚    β”‚ REPETITION  β”‚    β”‚ PERFORMANCE β”‚         β”‚
β”‚  β”‚   Counter   β”‚    β”‚  Detector   β”‚    β”‚   Monitor   β”‚         β”‚
β”‚  β”‚             β”‚    β”‚             β”‚    β”‚             β”‚         β”‚
β”‚  β”‚  100 new    β”‚    β”‚  Same Q 3x  β”‚    β”‚  <80% rate  β”‚         β”‚
β”‚  β”‚  decisions  β”‚    β”‚  in 24hrs   β”‚    β”‚  for type   β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚         β”‚                  β”‚                  β”‚                 β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                            β”‚                                    β”‚
β”‚                            β–Ό                                    β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚                   β”‚  TRIGGER QUEUE  β”‚                          β”‚
β”‚                   β”‚                 β”‚                          β”‚
β”‚                   β”‚  Priority-based β”‚                          β”‚
β”‚                   β”‚  De-duplicated  β”‚                          β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                            β”‚                                    β”‚
β”‚                            β–Ό                                    β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚                   β”‚  LEARNING JOB   β”‚                          β”‚
β”‚                   β”‚   EXECUTOR      β”‚                          β”‚
β”‚                   β”‚                 β”‚                          β”‚
β”‚                   β”‚  Pattern extractβ”‚                          β”‚
β”‚                   β”‚  Rule promotion β”‚                          β”‚
β”‚                   β”‚  Archive check  β”‚                          β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Trigger Types

1. Volume Trigger

interface VolumeTrigger {
  type: 'volume';
  threshold: number;        // Default: 100 decisions
  scope: 'global' | 'category' | 'agent';
  currentCount: number;
  lastTriggered: Date;
}

// Example: Different thresholds per category
const volumeThresholds = {
  'build': 50,      // Build issues: learn faster
  'angular': 100,   // Angular: standard
  'architecture': 20, // Architecture: rare but important
  'default': 100
};

2. Repetition Trigger

interface RepetitionTrigger {
  type: 'repetition';
  question: string;
  occurrences: number;
  threshold: number;        // Default: 3
  timeWindow: number;       // Default: 24 hours
  firstSeen: Date;
  lastSeen: Date;
}

// When triggered: Extract pattern IMMEDIATELY
// "If the same question is asked 3+ times, we should have a pattern for it"

3. Performance Trigger

interface PerformanceTrigger {
  type: 'performance';
  metric: 'success_rate' | 'confidence' | 'reference_rate';
  category: string;
  currentValue: number;
  threshold: number;
  trend: 'declining' | 'stable' | 'improving';
}

// Example thresholds
const performanceThresholds = {
  success_rate: 0.80,    // Below 80% success: re-analyze
  confidence: 0.75,      // Below 75% avg confidence: need patterns
  reference_rate: 0.30,  // Below 30% patterns used: wrong patterns?
};

4. Novelty Trigger

interface NoveltyTrigger {
  type: 'novelty';
  detected: 'new_category' | 'new_technology' | 'new_pattern';
  identifier: string;
  occurrences: number;
  firstSeen: Date;
}

// When new category detected (e.g., "AI integration" decisions appearing):
// - Lower threshold for learning (learn fast from new domain)
// - Higher urgency for pattern extraction

5. Confidence Drop Trigger

interface ConfidenceDropTrigger {
  type: 'confidence_drop';
  category: string;
  previousAvg: number;
  currentAvg: number;
  dropPercentage: number;
  threshold: number;      // Default: 15% drop
}

// If confidence drops 15%+ in a category:
// - Something changed (new patterns, deprecated patterns)
// - Trigger re-analysis

Meta-Learning: Learning When to Learn

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    META-LEARNING SYSTEM                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                  β”‚
β”‚  After 1,000 decisions, analyze:                                β”‚
β”‚  β”œβ”€ Which triggers produced useful patterns?                    β”‚
β”‚  β”œβ”€ Which thresholds are too high/low?                         β”‚
β”‚  β”œβ”€ Which categories need faster learning?                     β”‚
β”‚  └─ What's the optimal batch size for extraction?              β”‚
β”‚                                                                  β”‚
β”‚  Learn trigger effectiveness:                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚ Trigger      β”‚ Patterns β”‚ Useful β”‚ Effectiveness β”‚      β”‚    β”‚
β”‚  │──────────────│──────────│────────│───────────────│      β”‚    β”‚
β”‚  β”‚ Volume(100)  β”‚    45    β”‚   32   β”‚     71%       β”‚      β”‚    β”‚
β”‚  β”‚ Repetition   β”‚    12    β”‚   11   β”‚     92%       β”‚ ⭐   β”‚    β”‚
β”‚  β”‚ Performance  β”‚     8    β”‚    6   β”‚     75%       β”‚      β”‚    β”‚
β”‚  β”‚ Novelty      β”‚     5    β”‚    4   β”‚     80%       β”‚      β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                                  β”‚
β”‚  Insight: Repetition trigger most effective                     β”‚
β”‚  Action: Lower repetition threshold from 3 to 2                 β”‚
β”‚                                                                  β”‚
β”‚  After 5,000 decisions:                                         β”‚
β”‚  β”œβ”€ Build patterns: Stable, slow down extraction               β”‚
β”‚  β”œβ”€ Angular patterns: Growing, maintain rate                   β”‚
β”‚  β”œβ”€ AI integration: New, accelerate extraction                 β”‚
β”‚  └─ Auto-adjust thresholds per category                        β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Trigger Priority & De-duplication

interface TriggerPriority {
  // Highest priority: Immediate action needed
  CRITICAL: ['performance_drop', 'repeated_failure'];
  
  // High priority: Should process soon
  HIGH: ['repetition', 'confidence_drop'];
  
  // Normal priority: Process in batch
  NORMAL: ['volume', 'novelty'];
  
  // Low priority: Background processing
  LOW: ['cleanup', 'archive_check'];
}

// De-duplication: Don't run same extraction twice
interface TriggerDeduplication {
  // If volume trigger fires for 'build' category:
  // - Check if repetition already triggered for build
  // - If yes, combine into single extraction job
  // - Track which triggers contributed
}

Learning Job Types

1. Pattern Extraction

Triggered by: Volume, Repetition, Performance
Input: Batch of decisions matching criteria
Output: Extracted patterns, rule candidates

2. Rule Promotion

Triggered by: Pattern reaching threshold
Input: Pattern with 10+ successful uses
Output: Promoted to core rule

3. Anti-Pattern Detection

Triggered by: Repeated failures
Input: Failed decisions
Output: Anti-patterns (what NOT to do)

4. Archive Eligibility Check

Triggered by: Volume (after extraction)
Input: Decisions with extracted patterns
Output: Decisions ready for archive

Implementation

// Trigger Service
@Injectable()
export class AdaptiveTriggerService {
  private triggers = new Map<string, TriggerState>();
  private triggerQueue: PriorityQueue<Trigger>;
  
  // Called on every new decision
  async onNewDecision(decision: Decision): Promise<void> {
    // Check all trigger conditions
    await this.checkVolumeTrigger(decision);
    await this.checkRepetitionTrigger(decision);
    await this.checkPerformanceTrigger(decision);
    await this.checkNoveltyTrigger(decision);
    
    // Process any fired triggers
    await this.processTriggerQueue();
  }
  
  // Called on outcome report
  async onOutcomeReported(decisionId: string, success: boolean): Promise<void> {
    await this.updatePerformanceMetrics(decisionId, success);
    await this.checkConfidenceDropTrigger();
  }
  
  // Process triggers by priority
  private async processTriggerQueue(): Promise<void> {
    while (!this.triggerQueue.isEmpty()) {
      const trigger = this.triggerQueue.pop();
      
      // De-duplicate with pending jobs
      if (this.isDuplicate(trigger)) continue;
      
      // Execute appropriate learning job
      await this.executeLearningJob(trigger);
    }
  }
}

Comparison: Time-Based vs Adaptive

Aspect Time-Based Adaptive
Trigger Every 7 days When needed
Responsiveness Days late Minutes
Compute waste High (slow weeks) Minimal
Pattern quality Averaged Targeted
Learning speed Fixed Accelerates with activity
Optimization Manual tuning Self-optimizing

Benefits

  1. Responsive: Learn immediately when patterns emerge
  2. Efficient: No wasted compute on quiet periods
  3. Adaptive: Thresholds optimize over time
  4. Targeted: Different triggers for different situations
  5. Self-improving: Meta-learning adjusts the system itself

Next Steps