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::{
40    RunnerErrorMessages, RunnerInvocation, run_prompt_with_handling,
41    should_fallback_to_fresh_continue,
42};
43
44pub(crate) use retry::{
45    FixedBackoffSchedule, RunnerRetryPolicy, SeededRng, compute_backoff, format_duration,
46};
47pub(crate) use shell::{
48    ManagedCommand, TimeoutClass, execute_checked_command, execute_managed_command,
49    sleep_with_cancellation,
50};
51
52#[cfg(test)]
53pub(crate) use execution::{RunnerBackend, run_prompt_with_handling_backend};