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 ci-gate vs retry).
12//! - Re-exports preserve the existing public and `pub(crate)` API surface.
13
14mod abort;
15mod ci_gate;
16mod execution;
17mod retry;
18mod revert;
19mod shell;
20
21#[cfg(test)]
22mod tests;
23
24// --- Public API (unchanged call-site paths) ----------------------------------
25
26pub use revert::{
27    RevertDecision, RevertOutcome, RevertPromptContext, RevertPromptHandler, RevertSource,
28    apply_git_revert_mode, apply_git_revert_mode_with_context, format_revert_failure_message,
29    parse_revert_response, prompt_revert_choice_with_io,
30};
31
32// --- Crate-private API (unchanged call-site paths) ---------------------------
33
34pub(crate) use abort::{
35    RunAbort, RunAbortReason, abort_reason, is_dirty_repo_error, is_queue_validation_error,
36};
37pub(crate) use ci_gate::execute_ci_gate;
38
39pub(crate) use execution::{RunnerErrorMessages, RunnerInvocation, run_prompt_with_handling};
40
41pub(crate) use retry::{RunnerRetryPolicy, SeededRng, compute_backoff, format_duration};
42pub(crate) use shell::{
43    ManagedCommand, TimeoutClass, execute_managed_command, sleep_with_cancellation,
44};
45
46#[cfg(test)]
47pub(crate) use execution::{RunnerBackend, run_prompt_with_handling_backend};