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§
- Loop
Entry - Metadata for a registered loop.
- Loop
Registry - Registry for tracking active Ralph loops.
Enums§
- Registry
Error - Errors that can occur during registry operations.