Skip to main content

Module loop_registry

Module loop_registry 

Source
Expand description

Loop registry for tracking active Ralph loops across workspaces.

The registry maintains a list of running loops with their metadata, providing discovery and coordination capabilities for multi-loop scenarios.

§Design

  • JSON persistence: Single JSON file at .ralph/loops.json
  • File locking: Uses flock() for concurrent access safety
  • PID-based stale detection: Automatically cleans up entries for dead processes

§Example

use ralph_core::loop_registry::{LoopRegistry, LoopEntry};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let registry = LoopRegistry::new(".");

    // Register this loop
    let entry = LoopEntry::new("implement auth", Some("/path/to/worktree"));
    let id = registry.register(entry)?;

    // List all active loops
    for loop_entry in registry.list()? {
        println!("Loop {}: {}", loop_entry.id, loop_entry.prompt);
    }

    // Deregister when done
    registry.deregister(&id)?;
    Ok(())
}

Structs§

LoopEntry
Metadata for a registered loop.
LoopRegistry
Registry for tracking active Ralph loops.

Enums§

RegistryError
Errors that can occur during registry operations.