Undo and rewind
Before W1 writes to a file for the first time in a turn, it stashes the old bytes. Rewinding puts them back.
What rewind does#
That stash is what makes the undo exact. Rewinding a turn works through it file by file:
- A file that existed and was changed is restored to exactly the bytes it had before the turn.
- A file the turn created is deleted.
- Anything that could not be put back is named, with the reason. Rewind never reports a clean sweep it did not perform.
No git is involved anywhere in this. It works the same in a repository, in a folder you never initialised, and in a folder of documents that has nothing to do with code.
How to use it#
Rewind is per turn. Each turn in a thread carries its own snapshot, so you can undo the last thing W1 did without touching the four good turns before it.
The usual moment for it is the one where you read the file list at the end of a run, see a file you did not expect, and want the previous state back before you decide what to do next.
Rewind, then say why.
Undoing the turn and immediately re-stating the task with the constraint that was missing ("same thing, but do not touch the generated files") is much more effective than arguing with a run that has already gone the wrong way.
What it does not cover#
Rewind is a file-restore mechanism. It is honest about its edges, and you should know them:
| Not covered | Why |
|---|---|
| Side effects of commands | A command that dropped a database table, pushed a branch or sent a request did a thing in the world. Rewind restores files, not consequences. |
| Files larger than 4 MB | Above that they are not stashed. The turn records that the file was too large to snapshot, so you know before you rely on it. |
| Your own edits made after the turn | If you changed a restored file yourself in the meantime, rewind says the file changed since the snapshot rather than silently overwriting your work. |
| Very old turns | Each thread keeps snapshots for its most recent turns — roughly forty — and the whole store is capped. Old snapshots fall off the end. |
Rewind is a safety net, not a backup.
Keep source control or a backup for anything you care about. A safety net is for the slip you notice immediately, not for the folder you lose next week.
Where the snapshots live#
Under your home directory, alongside the rest of the project's state:
~/.w1/userdata/workspaces/<folder>-<id>/rewind/
objects/<sha256> prior bytes, shared between turns
threads/<thread>/<run>.json one manifest per turnBlobs are content-addressed, so a file touched by ten turns is stored once. The whole store is bounded — it will not grow without limit while you work.