Expand description
Git wrapper for blocking commits during agent phase.
This module provides safety mechanisms to prevent accidental commits while an AI agent is actively modifying files. It works through two mechanisms:
- Marker file: Creates
<git-dir>/ralph/no_agent_commitduring agent execution. Both the git wrapper and hooks check for this file. - PATH wrapper: Installs a temporary
gitwrapper script that interceptscommit,push, andtagcommands when the marker file exists.
All enforcement state files live inside the git metadata directory (<git-dir>/ralph/)
so they are invisible to working-tree scans and cannot be confused with product code.
The wrapper is automatically cleaned up when the agent phase ends, even on
unexpected exits (Ctrl+C, panics) via cleanup_agent_phase_silent.
§Module structure
This module is split into focused submodules:
marker— marker file creation and repairpath_wrapper— PATH wrapper directory management- [
script] — wrapper shell script generation phase— agent phase lifecycle and self-healing checkscleanup— cleanup utilities
Re-exports§
pub use super::phase::ProtectionCheckResult;
Structs§
Functions§
- capture_
head_ oid - cleanup_
agent_ phase_ protections_ silent_ at - cleanup_
agent_ phase_ silent - cleanup_
agent_ phase_ silent_ at - cleanup_
orphaned_ marker - cleanup_
orphaned_ marker_ with_ workspace - cleanup_
orphaned_ wrapper_ at - clear_
agent_ phase_ global_ state - create_
marker_ with_ workspace - detect_
unauthorized_ commit - disable_
git_ wrapper - end_
agent_ phase - end_
agent_ phase_ in_ repo - ensure_
agent_ phase_ protections - marker_
exists_ with_ workspace - remove_
marker_ with_ workspace - start_
agent_ phase - start_
agent_ phase_ in_ repo - try_
remove_ ralph_ dir - verify_
ralph_ dir_ removed - verify_
wrapper_ cleaned