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 process_groups;
18mod process_wait;
19mod retry;
20mod revert;
21mod shell;
22
23#[cfg(test)]
24mod tests;
25
26// --- Public API (unchanged call-site paths) ----------------------------------
27
28pub use revert::{
29    RevertDecision, RevertOutcome, RevertPromptContext, RevertPromptHandler, RevertSource,
30    apply_git_revert_mode, apply_git_revert_mode_with_context, format_revert_failure_message,
31    parse_revert_response, prompt_revert_choice_with_io,
32};
33
34// --- Crate-private API (unchanged call-site paths) ---------------------------
35
36pub(crate) use abort::{
37    RunAbort, RunAbortReason, abort_reason, is_dirty_repo_error, is_queue_validation_error,
38};
39pub(crate) use ci_gate::execute_ci_gate;
40pub(crate) use process_groups::isolate_child_process_group;
41pub(crate) use process_wait::{
42    ChildTerminationReason, ChildWaitOptions, wait_for_child_with_callbacks,
43};
44
45pub(crate) use execution::{
46    RunnerErrorMessages, RunnerExecutionContext, RunnerFailureHandling, RunnerInvocation,
47    RunnerRetryState, RunnerSettings, run_prompt_with_handling, should_fallback_to_fresh_continue,
48};
49
50pub(crate) use retry::{
51    FixedBackoffSchedule, RunnerRetryPolicy, SeededRng, compute_backoff, format_duration,
52};
53pub(crate) use shell::{
54    ManagedCommand, TimeoutClass, execute_checked_command, execute_managed_command,
55    sleep_with_cancellation,
56};
57
58#[cfg(test)]
59pub(crate) use execution::{
60    RunnerBackend, RunnerBackendResumeSession, RunnerBackendRunPrompt,
61    run_prompt_with_handling_backend,
62};