ralph_workflow/phases/
integrity.rs1use crate::workspace::Workspace;
6
7pub fn ensure_prompt_integrity(
21 workspace: &dyn Workspace,
22 logger: &crate::logger::Logger,
23 phase: &str,
24 iteration: u32,
25) {
26 let result = crate::files::validate_prompt_md_with_workspace(workspace, false, false);
28
29 for warning in &result.warnings {
31 if warning.contains("restored from") {
32 logger.warn("[PROMPT_INTEGRITY] PROMPT.md was missing or empty and has been restored from backup");
33 logger.warn(&format!(
34 "[PROMPT_INTEGRITY] Deletion detected during {phase} phase (iteration {iteration})"
35 ));
36 logger.warn("[PROMPT_INTEGRITY] Possible cause: Agent used 'rm' or file write tools on PROMPT.md");
37 logger.success(
38 &warning.replace("PROMPT.md was missing and was automatically ", "PROMPT.md "),
39 );
40 return;
41 }
42 }
43
44 for error in &result.errors {
46 if error.contains("not found") || error.contains("missing") || error.contains("empty") {
47 logger.error(&format!(
48 "[PROMPT_INTEGRITY] Failed to restore PROMPT.md: {error}"
49 ));
50 logger.error(&format!(
51 "[PROMPT_INTEGRITY] Error occurred during {phase} phase (iteration {iteration})"
52 ));
53 logger.error("Pipeline may not function correctly without PROMPT.md");
54 return;
55 }
56 }
57
58 }