Skip to main content

Module loop_completion

Module loop_completion 

Source
Expand description

Loop completion handler for worktree-based loops.

Handles post-completion actions for loops running in git worktrees, including auto-merge queue integration.

§Design

When a loop completes successfully (CompletionPromise):

  • Primary loop: No special handling (runs in main workspace)
  • Worktree loop with auto-merge: Enqueue to merge queue for merge-ralph
  • Worktree loop without auto-merge: Log completion, leave worktree for manual merge

§Example

use ralph_core::loop_completion::{LoopCompletionHandler, CompletionAction};
use ralph_core::loop_context::LoopContext;
use std::path::PathBuf;

// Primary loop - no special action
let primary = LoopContext::primary(PathBuf::from("/project"));
let handler = LoopCompletionHandler::new(true); // auto_merge enabled
let action = handler.handle_completion(&primary, "implement auth").unwrap();
assert!(matches!(action, CompletionAction::None));

// Worktree loop with auto-merge - enqueues to merge queue
let worktree = LoopContext::worktree(
    "ralph-20250124-a3f2",
    PathBuf::from("/project/.worktrees/ralph-20250124-a3f2"),
    PathBuf::from("/project"),
);
let action = handler.handle_completion(&worktree, "implement auth").unwrap();
assert!(matches!(action, CompletionAction::Enqueued { .. }));

Structs§

CompletionLanding
Landing details included in completion actions.
LoopCompletionHandler
Handler for loop completion events.

Enums§

CompletionAction
Action taken upon loop completion.
CompletionError
Errors that can occur during completion handling.