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.
Stale tracks
A turn's worktree lives at <project>/.worktrees/turn-* and is removed when the turn ends. Some outlive it: a promote that was refused, a worktree that could not be deleted, or a runtime that died mid-turn. MUR reclaims these instead of letting them pile up.
Each track records the process that opened it. A track is reclaimable once it has been quiet for the grace period and one of these holds:
| Reason | Meaning |
|---|---|
released | its owner handed it back: promote refused, removal failed, or promoted but not yet deleted |
owner_dead | the process that opened it has exited |
legacy | no owner record (a track from before this change) and older than 24 hours |
A track whose owner is still running and has not released it is never touched, so another session on the same project is safe.
Reclaiming saves the track's diff as a patch first and removes the worktree only if the patch was written.
Automatically. Every time an agent opens a new track, it sweeps the same project in the background. Patches go to ~/.mur/artifacts/<agent>/turn-tracks/. If a reclaimed track held changes, an open item points you to the patch.
On demand. For a project no agent has touched since its tracks went stale:
mur track prune --dry-run # list what would be reclaimed; change nothing
mur track prune # reclaim; patches go to ~/.mur/artifacts/track-prune/<project>-<id>/
mur track prune --grace 0 --json # skip the grace period, one JSON array on stdout
prune works from any directory in the repository, including inside a turn track, and --project <dir> points it elsewhere. Each reclaimed track with changes is listed with the command that restores it, git apply --3way <patch>. If any track fails to reclaim, the command exits non-zero.
The grace period defaults to 30 minutes. --grace overrides it for one run (0, 10m, 2h). To change it everywhere, set it in ~/.mur/config.yaml:
turn_track:
stale_grace_mins: 30
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 backremove: a file the turn added is deletedskip: 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.