"""Create recovery_planner
Generated by Phi-Octopus Eden
2025-12-14 12:46:09.161709
"""

```python
"""
create_recovery_planner
Generated by Eden via recursive self-improvement
2025-10-31 21:48:17.965548
"""

class RecoveryPlanner:
    def __init__(self):
        """Initialize the recovery planner with an empty plan."""
        self.plan = []

    def add_step(self, step_id, action, condition=None, dependencies=[]):
        """
        Add a step to the recovery plan.
        
        Args:
            step_id (str): Unique identifier for the step.
            action (callable): Function that performs this step's action.
            condition (callable, optional): Function returning bool indicating if this step should run.
            dependencies (list of str, optional): IDs of previous steps required by this one.
        """
        self.plan.append({
            'id': step_id,
            'action': action,
            'condition': condition,
            'dependencies': dependencies
        })

    def sort_steps(self):
        """Sort the steps in topological order based on their dependencies."""
        from collections import defaultdict
        
        # Build a graph of dependencies
        graph = defaultdict(list)
        for step in self.plan:
            for dep in step['dependencies']:
                graph[dep].append(step['id'])
        
        # Perform topological sorting using Kahn's algorithm
        in_degree = {step['id']: len(step['dependencies']) for step in self.plan}
        queue = [step['id'] for step in self.plan if in_degree[step['id']] == 0]
        sorted_steps = []
        
        while queue:
            node = queue.pop(0)
            sorted_steps.append(node)
            for neighbor in graph[node]:
                in_degree[neighbor] -= 1
                if in_degree[neighbor] == 0:
                    queue.append(neighbor)
                    
        # Reorder the plan based on the sorted steps
        reordered_plan = []
        step_id_to_index = {step['id']: i for i, step in enumerate(self.plan)}
        for step_id in sorted_steps:
            index = step_id_to_index[step_id]
            reordered_plan.append(self.plan[index])
            
        self.plan = reordered_plan

    def execute_plan(self):
        """Execute the recovery plan in order, skipping steps where conditions aren't met."""
        for step in self.plan:
            if not step['condition'] or step['condition']():
                try:
                    print(f"Executing step {step['id']}...")
                    step['action']()
                except Exception as e:
                    print(f"Error executing step {step['id']}: {e}")
                    return False
                    
        return True

# Example usage
if __name__ == "__main__":
    import os
    
    def check_file_exists():
        """Check if the file exists before attempting to delete it."""
        return not os.path.exists("example.txt")
    
    def create_example_file():
        """Create an example file."""
        with open("example.txt", 'w') as f:
            f.write("Example content")
            
    def delete_example_file():
        """Delete the example file if it exists."""
        try:
            os.remove("example.txt")
        except FileNotFoundError:
            pass
            
    # Create and use recovery planner
    rp = RecoveryPlanner()
    rp.add_step('create', create_example_file, dependencies=[])
    rp.add_step('check_exists', check_file_exists)
    rp.add_step('delete_if_needed', delete_example_file, dependencies=['check_exists'])
    
    rp.sort_steps()
    success = rp.execute_plan()
    if not success:
        print("Recovery plan failed to execute completely.")
```