Skip to main content

Crate moesniper

Crate moesniper 

Source

Re-exports§

pub use diff::generate_preview;
pub use indent::auto_indent_content;
pub use indent::needs_indent_fix;
pub use indent::validate_indentation;
pub use config::DalLevel;
pub use config::SniperConfig;
pub use security::normalize_path_secure;
pub use security::validate_path;
pub use security::PathSecurityError;
pub use security::SecurityPolicy;

Modules§

config
Configuration types for sniper. Configuration management for sniper.
diff
Diff generation for dry-run previews. Diff generation for sniper dry-run mode.
indent
Indentation validation and auto-fix utilities. Indentation detection and auto-correction for sniper.
security
Path security validation and sanitization. Path security validation and sanitization.

Structs§

ManifestOp
A single operation within a batch manifest.
MemoryStats
Snapshot of memory statistics from a ResourceGuard at a point in time.
RiskTelemetry
Composite risk telemetry computed from a live ResourceGuard.
SniperLock
File-based lock with configurable timeout and stale lock detection.

Constants§

BACKUP_DIR
Directory name for storing backups and lock files.
NAME
Library name (matches Cargo.toml).
VERSION
Library version string (matches Cargo.toml).

Functions§

check_file_size
Check if file size exceeds the configured limit.
compute_context_hash
Verify pre-edit context: hash 3 lines before start and 3 lines after end, compare against the expected hash. Returns Ok if match, Err with message if not. Compute context hash: hashes 3 lines before start and 3 lines after end. Returns the full SHA-256 hash as a hex string.
count_recent_backups
Counts backups for a file hash created within the last window_secs seconds. Returns the count of recent backups. Used for manifest promotion detection.
create_backup
Creates a timestamped backup of a file in the backup directory.
find_latest_backup
Finds the most recent backup for a given file.
get_path_hash
Returns a hex-encoded hash of a file path for backup naming.
handle_backtrack_error
Centralized handling for llmosafe Backtrack Signal (-7).
hex_decode
Strict hex decoding: skips whitespace, errors on non-hex or odd-length strings.
hex_encode
Hex encode a byte slice.
normalize_path
Normalize a file path.
purge_old_backups
Purge old backups according to retention policy.
recommend_from_risk
Recommends an action based on the current resource risk level.
verify_context
write_atomic
Writes content to a file atomically using a temporary file and rename.
write_atomic_with_dal
Atomic write gated by a pre-created ResourceGuard with DAL-level enforcement.