feat(tools): transactional ShellExecutor with snapshot+rollback (#2414)#2473
Merged
feat(tools): transactional ShellExecutor with snapshot+rollback (#2414)#2473
Conversation
Add opt-in snapshot+rollback to ShellExecutor for atomic file operations. Before executing write commands, capture filesystem snapshots of affected paths; restore on failure if auto_rollback is enabled. New config fields on ShellConfig: - transactional: bool (default false) - transaction_scope: Vec<String> glob patterns (empty = all paths) - auto_rollback: bool (default false, triggers on exit code >= 2) - auto_rollback_exit_codes: Vec<i32> explicit exit code list - snapshot_required: bool (default false, abort execution on snapshot failure) New module: zeph-tools/src/shell/transaction.rs - TransactionSnapshot using tempfile::TempDir for automatic cleanup - extract_redirection_targets() parses >, >>, 2>, 2>>, &>, &>> operators - affected_paths() combines path extraction + glob scope filtering - capture() detects and skips symlinks to prevent traversal - rollback() restores all files, collecting errors without early return Integration: - execute_block() snapshots before execution, rollbacks on condition - AuditResult::Rollback and ToolEvent::Rollback variants for audit/TUI - TUI bridge handles Rollback as AgentEvent::Status - --init wizard prompts for transactional/auto_rollback settings - --migrate-config Step 6 acknowledges new optional shell fields 903 tests pass (18 new).
5f6ed20 to
0bbe099
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ShellExecutorfor atomic file operations (closes research(tools): transactional ShellExecutor — snapshot+rollback for atomic file operations (arXiv:2512.12806) #2414)transaction.rsmodule:TransactionSnapshotcaptures filesystem state before write commands and restores on failure>,>>,2>,2>>,&>,&>>) are parsed and included in snapshot scoperollback()attempts all file restores before returning error (no early-exit on partial failure)New config fields (
[tools.shell])Integration points
--initwizard: prompts fortransactionalandauto_rollback--migrate-config: Step 6 handles new optional fieldsToolEvent::Rollbacksurfaced as status indicator viatui_bridgeAuditResult::Rollbackvariant logged to audit trailTest plan
cargo +nightly fmt --checkcleancargo clippy -- -D warningscleanFollow-up issues to file after merge
max_snapshot_bytesconfig field) — security audit MEDIUM