Skip to main content

ralph_workflow/git_helpers/
wrapper.rs

1//! Git wrapper for blocking commits during agent phase.
2//!
3//! This module provides safety mechanisms to prevent accidental commits while
4//! an AI agent is actively modifying files. It works through two mechanisms:
5//!
6//! - **Marker file**: Creates `<git-dir>/ralph/no_agent_commit` during agent
7//!   execution. Both the git wrapper and hooks check for this file.
8//! - **PATH wrapper**: Installs a temporary `git` wrapper script that intercepts
9//!   `commit`, `push`, and `tag` commands when the marker file exists.
10//!
11//! All enforcement state files live inside the git metadata directory (`<git-dir>/ralph/`)
12//! so they are invisible to working-tree scans and cannot be confused with product code.
13//!
14//! The wrapper is automatically cleaned up when the agent phase ends, even on
15//! unexpected exits (Ctrl+C, panics) via [`cleanup_agent_phase_silent`].
16//!
17//! # Module structure
18//!
19//! This module is split into focused submodules:
20//! - [`marker`] — marker file creation and repair
21//! - [`path_wrapper`] — PATH wrapper directory management
22//! - [`script`] — wrapper shell script generation
23//! - [`phase`] — agent phase lifecycle and self-healing checks
24//! - [`cleanup`] — cleanup utilities
25
26// Real implementation — boundary module (file stem is `io`).
27include!("wrapper/io.rs");