Skip to main content

forge_engine/runtime/patch/
validate.rs

1use crate::config::ForgeConfig;
2use crate::runtime::patch::types::*;
3
4pub use typed_patch::ValidationResult;
5
6/// Validate a StructuredPatch against policy and invariant rules.
7///
8/// Returns all violations (not fail-fast).
9pub fn validate_patch(patch: &StructuredPatch, config: &ForgeConfig) -> ValidationResult {
10    typed_patch::validate_patch(
11        patch,
12        &typed_patch::PatchPolicy {
13            forbidden_paths: config.forbidden_paths.clone(),
14            allow_test_modifications: config.allow_test_modifications,
15            max_files_changed: config.caps.max_files_changed,
16            max_total_lines_changed: config.caps.max_total_lines_changed,
17            max_lines_changed_per_file: config.caps.max_lines_changed_per_file,
18        },
19    )
20}