forge_engine/runtime/patch/apply.rs
1use std::path::Path;
2
3use crate::error::ForgeResult;
4use crate::runtime::patch::types::*;
5
6pub use typed_patch::LineAttributionMap;
7
8/// Apply a StructuredPatch to a workspace directory.
9///
10/// Atomic: fails entirely on any op failure (no partial apply).
11/// Returns line-mapping table for CEA position attribution.
12pub fn apply_patch(
13 patch: &StructuredPatch,
14 workspace_dir: &Path,
15) -> ForgeResult<LineAttributionMap> {
16 let fs = sandbox_workspace::LocalPatchFs::new(workspace_dir);
17 Ok(typed_patch::apply_patch(patch, &fs)?)
18}