Expand description
Safe code editing and validation pipeline (Phase 2+). This module now has real (early) support for git worktrees + patch application + validation.
Structs§
- Captured
Command - Captured command execution result.
- File
Snapshot - Proposed
Edit - A proposed change to the agent’s source code.
- Transaction
Snapshot - Validation
Command Record - Auditable record for a validation command.
- Validation
Report - Validation
Result - 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