Hierarchical reasoning #2
                
     Open
            
            
          
  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.
  
    
  
    
This PR completes the integration of Hierarchical Reasoning Model (HRM) principles into RIPER, transforming it from a partially hierarchical system to a fully hierarchical reasoning framework. Based on the paper "Hierarchical Reasoning Model" (arXiv:2506.21734v3), these optimizations add adaptive convergence, deep supervision, and learning capabilities across all workflow phases.
Background: Inspiration from HRM Paper
Note: This implementation is inspired by the Hierarchical Reasoning Model paper—it follows the spirit and principles, but does not implement the actual HRM algorithms (neural networks, gradient approximations, Q-learning, etc.). Instead, we adapt the conceptual insights to RIPER's workflow architecture.
The Hierarchical Reasoning Model introduces principles that inspired this work:
Our Adaptation: We translate these neural network principles into workflow design patterns—convergence criteria, quality gates, phase routing, and pattern-based learning.
What Changed
Before: Partial Hierarchical Reasoning
Result: 4 out of 8 phases had proper convergence/validation
After: Complete Hierarchical Reasoning
Result: 8 out of 8 phases have convergence/validation/learning
The 4 Optimizations
1. INNOVATE Convergence Criteria
File:
.claude/agents/research-innovate.mdProblem: INNOVATE phase could explore indefinitely or stop prematurely with no quality check.
Solution: Added exploration assessment with convergence rule:
HRM Parallel: L-module convergence to local equilibrium before H-module update
Impact: Prevents premature design decisions and over-exploration waste
2. PLAN Quality Gate
File:
.claude/agents/plan-execute.mdProblem: Plans could be incomplete or ambiguous but still get saved and sent for approval.
Solution: Added self-validation checklist before saving:
HRM Parallel: Deep supervision at planning level
Impact: Incomplete specifications caught before execution phase
3. REVIEW Phase Routing
File:
.claude/agents/review.mdProblem: When issues found, unclear which phase to return to for fixes.
Solution: Added explicit hierarchical routing decision matrix:
HRM Parallel: Hierarchical error correction - route errors to appropriate level
Impact: Fixes happen at the right hierarchy level, not treating symptoms
4. Memory Learning Algorithm
File:
.claude/commands/memory/recall.mdProblem: Memory bank collected metadata but didn't learn patterns or make recommendations.
Solution: Added pattern matching and learning rules:
HRM Parallel: Q-learning from experience (ACT mechanism)
Impact: System learns from past tasks, optimizes iteration allocation
Supporting Changes
Enhanced Memory Metadata
File:
.claude/commands/memory/save.mdAdded structured metadata for learning:
Adaptive Workflow Orchestration
File:
.claude/commands/riper/workflow.mdEnhanced workflow with:
Technical Details
Files Modified (6 total)
Total: 223 lines added, 5 lines removed
Convergence Thresholds
Architecture Alignment
Expected Benefits
Quantitative Improvements
Qualitative Improvements
Backward Compatibility
✅ All changes are additive - no breaking changes
✅ Existing workflows continue to function
✅ New features can be adopted incrementally
✅ No new files required - all within existing structure
Testing Strategy
Unit Testing (Per Phase)
Integration Testing (Full Workflow)
Learning System Testing
Migration Guide
For Existing Users
No action required - system is backward compatible. To leverage new features:
Start using convergence markers:
[CONVERGENCE: confidence=X/10, ready=Y/N]in RESEARCH[INNOVATION CONVERGENCE: approaches=X, confidence=X/10, ready=Y/N]in INNOVATEUse quality gate in PLAN:
[PLAN QUALITY: ...]header to plansFollow phase routing:
Populate memory metadata:
For New Users
The workflow now self-optimizes:
References
Checklist
This PR transforms RIPER into a fully hierarchical reasoning system aligned with cutting-edge AI research, while maintaining the simplicity and elegance of the original design.