Overview
Evolution strategies control the balance between repair, optimize, and innovate intents. They inform the selector logic and adjust the circuit breaker behavior.
EVOLVE_STRATEGY=balanced|innovate|harden|repair-only|early-stabilize|steady-state|auto
Location: src/gep/strategy.js
Strategy Presets
balanced (Default)
Normal operation. Steady growth with stability.
{
repair: 0.20,
optimize: 0.30,
innovate: 0.50,
repairLoopThreshold: 0.50,
label: 'Balanced'
}
- 20% repair: Fix critical errors
- 30% optimize: Refactor and improve existing code
- 50% innovate: Add new features
- Circuit breaker: Triggers when >50% of last 8 cycles were failed repairs
When to use:
- Production systems with moderate error rates
- Continuous improvement workflows
- Default for most use cases
innovate
System is stable. Maximize new features and capabilities.
{
repair: 0.05,
optimize: 0.15,
innovate: 0.80,
repairLoopThreshold: 0.30,
label: 'Innovation Focus'
}
- 5% repair: Minimal firefighting
- 15% optimize: Minor improvements
- 80% innovate: Aggressive feature development
- Circuit breaker: Very sensitive (30% repair ratio triggers innovation)
When to use:
- After a successful hardening phase
- Low error rate environments
- Rapid prototyping
Do not use during incident response or high error rate periods.
harden
After a big change. Focus on stability and robustness.
{
repair: 0.40,
optimize: 0.40,
innovate: 0.20,
repairLoopThreshold: 0.70,
label: 'Hardening'
}
- 40% repair: Fix bugs introduced by recent changes
- 40% optimize: Improve reliability and performance
- 20% innovate: Limited new features
- Circuit breaker: Tolerates more repair cycles (70% threshold)
When to use:
- After major feature releases
- Post-incident recovery
- Before production deployment
repair-only
Emergency. Fix everything before doing anything else.
{
repair: 0.80,
optimize: 0.20,
innovate: 0.00,
repairLoopThreshold: 1.00,
label: 'Repair Only'
}
- 80% repair: Focus on fixing errors
- 20% optimize: Refactor broken code
- 0% innovate: NO new features
- Circuit breaker: Never triggers (allows indefinite repair cycles)
When to use:
- Incident response
- Critical production issues
- High error rate environments (>50% of logs are errors)
This mode disables innovation entirely. Use only during emergencies.
early-stabilize
First cycles. Prioritize fixing existing issues before innovating.
{
repair: 0.60,
optimize: 0.25,
innovate: 0.15,
repairLoopThreshold: 0.80,
label: 'Early Stabilization'
}
- 60% repair: Fix initial bugs
- 25% optimize: Improve existing code
- 15% innovate: Small feature additions
- Circuit breaker: High tolerance (80% threshold)
When to use:
- First 5 evolution cycles (auto-applied)
- New workspace setup
- After major refactoring
Auto-detection: Automatically applied for cycles 1-5 when no explicit strategy is set.
Location: src/gep/strategy.js:100-104
steady-state
Evolution saturated. Maintain existing capabilities. Minimal innovation.
{
repair: 0.60,
optimize: 0.30,
innovate: 0.10,
repairLoopThreshold: 0.90,
label: 'Steady State'
}
- 60% repair: Keep system healthy
- 30% optimize: Gradual improvements
- 10% innovate: Rare new features
- Circuit breaker: Very high tolerance (90% threshold)
When to use:
- Long-running production systems
- After reaching desired feature set
- Low change environments
Auto-detection: Triggered by evolution_saturation or force_steady_state signals.
Location: src/gep/strategy.js:107-111
auto
Adaptive strategy selection based on cycle count and saturation signals.
Heuristics:
- Cycles 1-5: Apply
early-stabilize
- Saturation detected: Apply
steady-state
- Otherwise: Use
balanced
Saturation signals:
force_steady_state
evolution_saturation
Location: src/gep/strategy.js:85-119
Intent Balancing
Strategies inform the selector via intent allocation ratios. The selector scores genes based on category match:
// Example: balanced strategy
if (gene.category === 'repair') score += 0.20;
if (gene.category === 'optimize') score += 0.30;
if (gene.category === 'innovate') score += 0.50;
The highest-scoring gene is selected.
Circuit Breaker
The circuit breaker detects repair loops and forces innovation to break the cycle.
How it works
- Read last N events from
events.jsonl (default: 3)
- Check if all are failed repairs with the same gene
- If true and streak ≥ threshold: set
FORCE_INNOVATION=true
- Selector switches to innovation intent
Location: src/evolve.js:787-811
Thresholds by strategy
| Strategy | Repair Loop Threshold |
|---|
balanced | 0.50 (50%) |
innovate | 0.30 (30%) |
harden | 0.70 (70%) |
repair-only | 1.00 (never triggers) |
early-stabilize | 0.80 (80%) |
steady-state | 0.90 (90%) |
Example: With balanced strategy, if 4 out of last 8 cycles were failed repairs (50%), the circuit breaker forces innovation.
Backward Compatibility
FORCE_INNOVATION
Legacy environment variable. Maps to innovate strategy.
FORCE_INNOVATION=true
# Equivalent to:
EVOLVE_STRATEGY=innovate
Location: src/gep/strategy.js:90-93
Usage Examples
Production hardening after release
EVOLVE_STRATEGY=harden node index.js --loop
Emergency incident response
EVOLVE_STRATEGY=repair-only node index.js --loop
Rapid prototyping
EVOLVE_STRATEGY=innovate node index.js --loop
Adaptive long-term operation
EVOLVE_STRATEGY=auto node index.js --loop
Custom Strategies
To define custom strategies, edit src/gep/strategy.js:
var STRATEGIES = {
'my-custom': {
repair: 0.30,
optimize: 0.40,
innovate: 0.30,
repairLoopThreshold: 0.60,
label: 'My Custom Strategy',
description: 'Balanced with higher optimize focus',
},
};
Then:
EVOLVE_STRATEGY=my-custom node index.js
Strategy Selection Flow
Best Practices
- Start with auto: Let the evolver adapt to your workspace lifecycle
- Monitor circuit breaker: Frequent forced innovation indicates gene quality issues
- Use repair-only sparingly: Only for emergencies
- Harden after innovation sprints: Stabilize before returning to balanced
- Review strategy every 50 cycles: Adjust based on outcome success rates
Troubleshooting
Strategy not applied
Check if FORCE_INNOVATION or circuit breaker is overriding your setting:
grep -r "FORCE_INNOVATION" memory/evolution/
Too many repairs
Switch to harden or repair-only:
EVOLVE_STRATEGY=harden node index.js --loop
Stuck in repair loop
Circuit breaker should auto-trigger. If not, check repairLoopThreshold:
node -e "console.log(require('./src/gep/strategy').resolveStrategy())"