Skip to main content

ralph/
runutil.rs

1//! Shared helpers for runner invocations with consistent error handling.
2//!
3//! Responsibilities:
4//! - Provide a single "runutil" surface for runner execution helpers and revert/abort utilities.
5//! - Re-export cohesive submodules so call sites keep using `crate::runutil::{...}`.
6//!
7//! Not handled here:
8//! - Prompt template rendering, queue/task persistence, or runner selection logic.
9//!
10//! Invariants/assumptions:
11//! - Submodules remain cohesive (execution vs revert vs abort vs shell vs retry).
12//! - Re-exports preserve the existing public and `pub(crate)` API surface.
13
14mod abort;
15mod execution;
16mod retry;
17mod revert;
18mod shell;
19
20#[cfg(test)]
21mod tests;
22
23// --- Public API (unchanged call-site paths) ----------------------------------
24
25pub use revert::{
26    RevertDecision, RevertOutcome, RevertPromptContext, RevertPromptHandler, RevertSource,
27    apply_git_revert_mode, apply_git_revert_mode_with_context, format_revert_failure_message,
28    parse_revert_response, prompt_revert_choice_with_io,
29};
30
31pub use shell::shell_command;
32
33// --- Crate-private API (unchanged call-site paths) ---------------------------
34
35pub(crate) use abort::{
36    RunAbort, RunAbortReason, abort_reason, is_dirty_repo_error, is_queue_validation_error,
37};
38
39pub(crate) use execution::{RunnerErrorMessages, RunnerInvocation, run_prompt_with_handling};
40
41pub(crate) use retry::{RunnerRetryPolicy, SeededRng, compute_backoff, format_duration};
42
43#[cfg(test)]
44pub(crate) use execution::{RunnerBackend, run_prompt_with_handling_backend};