ralph/commands/run/parallel/mod.rs
1//! Parallel run loop supervisor and worker orchestration for direct-push mode.
2//!
3//! Responsibilities:
4//! - Coordinate parallel task execution across multiple workers.
5//! - Manage settings resolution and preflight validation.
6//! - Track worker capacity and task pruning.
7//! - Handle direct-push integration from workers.
8//!
9//! Policy helpers live in focused modules (`settings`, `preflight`, `spawn`, `pruning`, `capacity`);
10//! this file is the crate facade: module graph, shared constants, and re-exports.
11//!
12//! Not handled here:
13//! - Main orchestration loop (see `orchestration.rs`).
14//! - State initialization (see `state_init.rs`).
15//! - Worker lifecycle (see `worker.rs`).
16//! - Integration loop logic (see `integration.rs`).
17//!
18//! Invariants/assumptions:
19//! - Queue order is authoritative for task selection.
20//! - Workers run in isolated per-task workspaces on the target base branch.
21//! - Workers push directly to the target branch (no PRs).
22//! - One active worker per task ID (enforced by upsert_worker).
23
24mod args;
25mod capacity;
26mod cleanup_guard;
27mod integration;
28mod orchestration;
29mod path_map;
30mod preflight;
31mod pruning;
32mod settings;
33mod spawn;
34pub mod state;
35mod state_init;
36mod sync;
37mod worker;
38mod workspace_cleanup;
39
40use state_init::load_or_init_parallel_state;
41
42// =============================================================================
43// Marker File Constants (for CI failure detection)
44// =============================================================================
45
46/// Marker file name for CI gate failure diagnostics.
47/// Written to workspace when CI fails so coordinator/status tooling can inspect failures.
48pub const CI_FAILURE_MARKER_FILE: &str = ".ralph/cache/ci-failure-marker";
49
50/// Marker file name for blocked push outcomes from integration loop.
51pub const BLOCKED_PUSH_MARKER_FILE: &str = ".ralph/cache/parallel/blocked_push.json";
52
53/// Fallback marker file used only when primary marker path is unavailable.
54pub const CI_FAILURE_MARKER_FALLBACK_FILE: &str = ".ralph-ci-failure-marker";
55
56// Re-export public APIs from submodules
57pub use integration::{IntegrationConfig, IntegrationOutcome, RemediationHandoff};
58pub(crate) use integration::{read_blocked_push_marker, run_integration_loop};
59pub(crate) use orchestration::run_loop_parallel;
60pub use settings::default_push_backoff_ms;
61pub use state::{WorkerLifecycle, WorkerRecord};
62
63pub(crate) use capacity::{
64 can_start_more_tasks, effective_active_worker_count, initial_tasks_started,
65};
66pub(crate) use preflight::preflight_parallel_workspace_root_is_gitignored;
67pub(crate) use pruning::prune_stale_workers;
68pub(crate) use settings::{
69 ParallelRunOptions, ParallelSettings, overrides_for_parallel_workers, resolve_parallel_settings,
70};
71pub(crate) use spawn::spawn_worker_with_registered_workspace;