Skip to main content

Module patch

Module patch 

Source
Expand description

Span-safe replacement engine with atomic writes and validation gates.

This module provides byte-exact patching with:

  • Atomic file replacement (write temp + fsync + rename)
  • File hash validation (before/after)
  • Tree-sitter reparse gate (multi-language)
  • Compiler validation gate (multi-language)
  • Optional rust-analyzer gate (Rust only)
  • Automatic rollback on any failure

Re-exports§

pub use pattern::apply_pattern_replace;
pub use pattern::find_pattern_in_files;
pub use pattern::PatternReplaceConfig;
pub use pattern::PatternReplaceResult;

Modules§

pattern
Pattern-based search and replace with AST confirmation.

Structs§

BackupManifest
Manifest describing a backup operation.
BackupWriter
Writer for creating backups of files before patching.
FilePatchSummary
Result summary for a patched file.
PreviewReport
Preview metadata describing the diff produced by a patch.
SpanBatch
Collection of replacements that must succeed atomically.
SpanReplacement
Replacement to apply within a specific file.

Functions§

apply_batch_with_validation
Apply multiple span replacements atomically across files.
apply_patch_with_validation
Apply a patch with comprehensive validation and automatic rollback.
load_batches_from_file
Load span batches from a JSON manifest.
preview_patch
Preview a patch by cloning the workspace, applying the change, and validating there.
preview_patch_with_content
Preview a patch and return before/after content for diff generation.
replace_span
Replace byte span without validation (legacy method for backward compatibility).
restore_from_manifest
Restore files from a backup manifest.
validate_utf8_span
Validate that a span aligns with UTF-8 boundaries.