Skip to main content

ralph_workflow/app/
context.rs

1//! Pipeline context types.
2//!
3//! This module defines the context structures used throughout the pipeline execution.
4
5use crate::agents::AgentRegistry;
6use crate::cli::Args;
7use crate::config::Config;
8use crate::logger::Colors;
9use crate::logger::Logger;
10use crate::logging::RunLogContext;
11use crate::prompts::template_context::TemplateContext;
12use crate::workspace::Workspace;
13
14/// Context for running the pipeline.
15///
16/// Groups together the various parameters needed to run the development/review/commit
17/// pipeline, reducing function parameter count and improving maintainability.
18pub struct PipelineContext {
19    pub args: Args,
20    pub config: Config,
21    pub registry: AgentRegistry,
22    pub developer_agent: String,
23    pub reviewer_agent: String,
24    pub developer_display: String,
25    pub reviewer_display: String,
26    pub repo_root: std::path::PathBuf,
27    /// Workspace for explicit path resolution (no CWD dependency).
28    ///
29    /// Uses `Arc<dyn Workspace>` for proper dependency injection:
30    /// - Production code passes `Arc::new(WorkspaceFs::new(...))`
31    /// - Tests can pass `Arc::new(MemoryWorkspace::new(...))`
32    pub workspace: std::sync::Arc<dyn Workspace>,
33    pub logger: Logger,
34    pub colors: Colors,
35    pub template_context: TemplateContext,
36    pub executor: std::sync::Arc<dyn crate::executor::ProcessExecutor>,
37    /// Run log context for per-run log path resolution.
38    ///
39    /// Provides paths to all log files under the per-run directory
40    /// (`.agent/logs-<run_id>/`). This ensures all logs from a single
41    /// pipeline invocation are grouped together for easy debugging.
42    pub run_log_context: RunLogContext,
43}