Turn Undo

Put a project back the way it was before an agent's turn. This takes one command, and it works even after the turn's changes have landed.

mur agent turn list rustsmith                 # turns you can undo, newest first
mur agent turn undo rustsmith <turn> --dry-run  # show what would change, write nothing
mur agent turn undo rustsmith <turn>            # restore, after a confirmation prompt

Available from MUR 2.92.1.

Which turns are covered

An agent that has bash, write_file, or edit_file bound does each turn in a throwaway git worktree of the project. When the turn ends, the changes are promoted back into the project. The settlement card's ~ changed row comes from that diff, so files a bash redirect wrote are counted too. See Settlement.

Before the promote, MUR saves the original bytes of every path the turn touched. They are stored by content hash under the agent's home:

~/.mur/agents/<agent>/edits/cas/<sha256>      # the before-bytes, deduplicated
~/.mur/agents/<agent>/edits/turns/<turn>.json # what the turn modified, deleted, or added

A turn gets a worktree only when the agent's working directory is the root of a git repository. If the directory is inside a repository but not at its root, MUR does not guess. The turn works on the project directly and has nothing to undo. Set MUR_TURN_TRACK=0 to turn worktrees off entirely.

If saving the snapshot fails, the promote still happens. That turn just won't show up in turn list.

Listing turns

mur agent turn list rustsmith
mur agent turn list rustsmith --json
TURN                                         PROMOTED                  FILES   STATE  PROJECT

FILES counts the paths undo would act on. STATE reads undone for a turn that has already been reversed. The agent name is case-insensitive.

Undoing a turn

Undo prints its plan before doing anything:

  • restore: a file the turn modified or deleted gets its original bytes back
  • remove: a file the turn added is deleted
  • skip: a file that was never saved (see below), with the reason
mur agent turn undo rustsmith <turn> --dry-run   # plan only: "dry run — nothing written"
mur agent turn undo rustsmith <turn>             # asks first; the default answer is no
mur agent turn undo rustsmith <turn> --yes       # -y, skip the prompt

When it finishes, it reports undone turn '<turn>': N restored, N removed, N skipped.

Undo is last-write-wins

Undo puts back the bytes from before the turn. Anything that changed one of those files after the promote gets overwritten, whether that was you or a later turn. There is no merge. Undo does flag every such path as CHANGED SINCE PROMOTE and prints a warning with the count before it asks. Run --dry-run first if you have kept working in the project.

Once per turn

A turn can be undone only once. A second attempt is refused with an undo cannot be undone. To undo several turns, undo them newest first.

What is never saved

Undo skips symlinks, directories, and any file whose contents the secret redactor would change. The plan lists each one as skip. Undo cannot restore them, and secrets never end up in the snapshot store.

In murmur

mur agent turn undo asks for confirmation, so murmur's !command sends it through the terminal handover, the same way it handles mur browser auth. Using --dry-run or --yes doesn't change that.