ralph_workflow/files/mod.rs
1//! File management utilities for Ralph's agent files.
2//!
3//! This module manages the `.agent/` directory structure and files:
4//! - PLAN.md, ISSUES.md, STATUS.md, NOTES.md lifecycle
5//! - commit-message.txt management
6//! - PROMPT.md validation
7//! - Isolation mode file cleanup
8//! - Result extraction from agent JSON logs
9//! - File integrity verification and checksums
10//! - Error recovery and state repair
11//! - Real-time file system monitoring for PROMPT.md protection
12//!
13//! # Module Organization
14//!
15//! The files module is organized by domain concern:
16//!
17//! - [`io`] - File I/O operations (agent files, recovery, backup, context)
18//! - [`protection`] - File protection and integrity (validation, integrity, monitoring)
19//! - [`llm_output_extraction`] - LLM output extraction (commit message, JSON extraction)
20//! - [`result_extraction`] - Plan and issue extraction from logs
21//!
22//! # Isolation Mode
23//!
24//! By default, Ralph operates in isolation mode where STATUS.md, NOTES.md,
25//! and ISSUES.md are not persisted between runs. This prevents context
26//! contamination from previous runs.
27//!
28//! # Orchestrator-Controlled File I/O
29//!
30//! The orchestrator is the sole entity responsible for writing output files.
31//! Agent JSON output is extracted and written by the orchestrator, ensuring
32//! consistent file handling regardless of agent behavior.
33
34// Domain-driven submodules
35pub mod io;
36pub mod protection;
37
38// Extraction modules (already domain-organized)
39pub mod llm_output_extraction;
40pub mod result_extraction;
41
42// Re-exports from new domain structure for backward compatibility
43pub use io::{
44 clean_context_for_reviewer, clean_context_for_reviewer_with_workspace, cleanup_generated_files,
45 cleanup_generated_files_with_workspace, create_prompt_backup,
46 create_prompt_backup_with_workspace, delete_commit_message_file,
47 delete_commit_message_file_with_workspace, delete_issues_file_for_isolation,
48 delete_issues_file_for_isolation_with_workspace, delete_plan_file,
49 delete_plan_file_with_workspace, ensure_files, file_contains_marker,
50 file_contains_marker_with_workspace, make_prompt_read_only,
51 make_prompt_read_only_with_workspace, make_prompt_writable,
52 make_prompt_writable_with_workspace, read_commit_message_file,
53 read_commit_message_file_with_workspace, reset_context_for_isolation,
54 setup_xsd_schemas_with_workspace, update_status, update_status_with_workspace,
55 verify_file_not_corrupted_with_workspace, write_commit_message_file,
56 write_commit_message_file_with_workspace, write_file_atomic_with_workspace,
57};
58
59pub use protection::{
60 restore_prompt_if_needed, validate_prompt_md, validate_prompt_md_with_workspace,
61};
62pub use result_extraction::extract_issues;
63#[cfg(any(test, feature = "test-utils"))]
64pub use result_extraction::extract_plan;