Skip to main content

Module editing

Module editing 

Source
Expand description

Safe code editing and validation pipeline (Phase 2+). This module now has real (early) support for git worktrees + patch application + validation.

Structs§

CapturedCommand
Captured command execution result.
FileSnapshot
ProposedEdit
A proposed change to the agent’s source code.
TransactionSnapshot
ValidationCommandRecord
Auditable record for a validation command.
ValidationReport
ValidationResult
Result of validating a proposed edit in a worktree.

Functions§

apply_and_validate
High-level helper: take a ProposedEdit, create an isolated workspace (git worktree or copy), apply the edit, run cargo check + clippy, then clean up. This is the core safety primitive of mdx-rust.
apply_and_validate_with_budget
apply_edit
Apply a proposed edit to an isolated workspace or the real agent tree.
apply_edit_to_agent
apply_patch
Apply the proposed patch inside an isolated directory. Strategy:
cleanup_isolated_workspace
create_isolated_workspace
Create a git worktree for safe experimentation (best when agent_path is a git repo root). Falls back to a filesystem copy if worktree creation fails (e.g. agent lives inside another repo).
restore_file
restore_transaction
run_command_with_timeout
Run a Command with a timeout. Returns None on timeout (treated as failure by callers).
snapshot_file
snapshot_transaction
validate_build
Run cargo check + clippy in a directory with timeout. Returns (success, combined output). A hanging or extremely slow cargo command must fail the validation instead of hanging the optimizer (P0).
validate_build_detailed
validate_build_detailed_with_budget