ralph_workflow/app/
finalization.rs1use crate::banner::{print_final_summary, PipelineSummary};
11use crate::checkpoint::{clear_checkpoint, clear_checkpoint_with_workspace};
12use crate::config::Config;
13use crate::files::protection::monitoring::PromptMonitor;
14use crate::logger::Colors;
15use crate::logger::Logger;
16use crate::pipeline::Timer;
17use crate::pipeline::{AgentPhaseGuard, Stats};
18use crate::workspace::Workspace;
19
20pub struct RuntimeStats<'a> {
22 pub timer: &'a Timer,
23 pub stats: &'a Stats,
24}
25
26pub fn finalize_pipeline(
35 agent_phase_guard: &mut AgentPhaseGuard,
36 logger: &Logger,
37 colors: Colors,
38 config: &Config,
39 runtime: RuntimeStats<'_>,
40 prompt_monitor: Option<PromptMonitor>,
41 workspace: Option<&dyn Workspace>,
42) {
43 if let Some(monitor) = prompt_monitor {
45 monitor.stop();
46 }
47
48 crate::git_helpers::end_agent_phase();
50 crate::git_helpers::disable_git_wrapper(agent_phase_guard.git_helpers);
51 if let Err(err) = crate::git_helpers::uninstall_hooks(logger) {
52 logger.warn(&format!("Failed to uninstall Ralph hooks: {err}"));
53 }
54
55 let summary = PipelineSummary {
60 total_time: runtime.timer.elapsed_formatted(),
61 dev_runs_completed: runtime.stats.developer_runs_completed as usize,
62 dev_runs_total: config.developer_iters as usize,
63 review_runs: runtime.stats.reviewer_runs_completed as usize,
64 changes_detected: runtime.stats.changes_detected as usize,
65 isolation_mode: config.isolation_mode,
66 verbose: config.verbosity.is_verbose(),
67 review_summary: None,
68 };
69 print_final_summary(colors, &summary, logger);
70
71 if config.features.checkpoint_enabled {
72 let result = if let Some(ws) = workspace {
73 clear_checkpoint_with_workspace(ws)
74 } else {
75 clear_checkpoint()
76 };
77 if let Err(err) = result {
78 logger.warn(&format!("Failed to clear checkpoint: {err}"));
79 }
80 }
81
82 agent_phase_guard.disarm();
87}