All posts

10 min readPost 2

Lifespans, a graveyard, cremation: why not just use the Recycle Bin

Sending expired files to the OS Recycle Bin sounded like the easiest design, and our first prototype did exactly that—until we replaced it with a private graveyard on the same night. Here is why the Recycle Bin breaks down for AI agent workflows, how single-handle renames and pre-move manifests keep restores exact, and when the Recycle Bin still makes sense.

On this page
  1. The Recycle Bin assumes "delete now," not "expire later"
  2. Five verbs, one job each
  3. How the graveyard guarantees you restore the exact object you took
  4. Resurrect never overwrites; purge is the only permanent delete
  5. When the Recycle Bin is still the right tool

Give a file a countdown timer, and when the timer expires, drop it in the system Recycle Bin. That is almost every engineer's first instinct upon hearing about Obituary—a CLI (obit) and background daemon (obitd) that puts expiry timers on scratch files created by AI coding agents. Our very first prototype did exactly that via Windows IFileOperation.

Within hours of getting that prototype running, we tore out the Recycle Bin path and built Obituary's own private graveyard.

Splitting deletion into five explicit verbs—register, extend, bury, resurrect, and purge—gave every dangerous step exactly one owner in code: one place that verifies identity, one place that moves files, and one place that can permanently destroy user data.

The Recycle Bin assumes "delete now," not "expire later" ​

The OS Recycle Bin works well when a human hits Delete by accident. Put it in an automated AI-agent workflow and four gaps open immediately:

  • The Recycle Bin assumes someone chose to delete right now. Debug scripts, screenshots, and repro logs written by an agent are still useful in the moment; they only turn into junk two days later, long after the session ended. Files need a lifespan attached at creation time.
  • Agent cleanup commands bypass the Recycle Bin anyway. rm -rf, git clean -fdx, and Remove-Item destroy files on the spot, and WSL, Linux servers, and Docker containers have no Windows Recycle Bin to begin with.
  • Handing a file to the Recycle Bin surrenders custody. The Recycle Bin tracks neither the agent, the session, nor the project, and it enforces its own space caps and eviction rules. Windows SHFILEOPSTRUCTW even has a dedicated flag—FOF_WANTNUKEWARNING (see the Microsoft documentation)—to warn when a file will be permanently nuked instead of recycled.
  • There is no scripted, safe undo. Restoring from the Recycle Bin is built for GUI clicks. When an agent buries the wrong file, it needs a single command—obit resurrect <id>—that puts the exact object back without overwriting anything new. Under Recycle Bin mode, obit resurrect cannot reach those files.

Why post-hoc AI cleanup is the wrong bet ​

Asking an agent to scan a repo after the fact and guess which untracked files look like junk carries the highest possible blast radius: one wrong guess wipes uncommitted source code. From our first graveyard design, safety rested on hard rules rather than model judgment:

  • Files tracked by Git are never registered automatically, with no override flag.
  • First-time automatic handling in any project requires human approval.
  • Right before an expired entry is buried, Obituary queries Git one more time.

Every ledger entry also records its source, project, and session so obit stats can report how much was buried, how much disk space was freed, and how many items were resurrected.

Five verbs, one job each ​

With a private graveyard in place, a tracked file moves through five explicit states: registered with a countdown, expired, buried into the graveyard, restorable throughout its retention window (7 days by default), and finally purged.

ActionCommandWhat it does
Registerobit mark <path> <lifespan> (add), obit mktempAssigns a lifespan to a path; mktemp creates a self-expiring temp folder
Extendobit extendPushes the expiry time forward
Spareobit spare (cancel)Stops tracking while leaving the file untouched
Buryobit bury, or automatic on expiryMoves the target into the same-volume graveyard without deleting
Resurrectobit resurrectRestores to the original path, never overwriting existing files
Purgeobit purge, or automatic after retentionPermanently deletes user content—the only place in the codebase that does
Diagram of Obituary's lifecycle: register, expire, bury into the graveyard, then resurrect or permanently delete, with the matching command beside each step
A file's lifecycle in Obituary: registered with a countdown, moved into a restorable graveyard on expiry, and permanently deleted only after the retention window ends.

Here is a real run from 1.6.0 inside an isolated demo folder (the first command also wakes a local daemon if one is not already running):

text
$ obit mark debug.log 3d
#1 added    C:\obit-demo\debug.log  expires 2026-11-24 15:05 (in 3d)
started a daemon for now; `obit daemon enable` sets up the hidden 5-minute runner that survives restarts

$ obit mark screenshots 1d
#2 added    C:\obit-demo\screenshots  expires 2026-11-22 15:05 (in 1d)

$ obit list
ID  EXPIRES           LEFT  PATH                         NOTE
#2  2026-11-22 15:05  1d    C:\obit-demo\screenshots
#1  2026-11-24 15:05  3d    C:\obit-demo\debug.log

$ obit bury old-output
#3 buried   C:\obit-demo\old-output  (6 B, restorable until 2026-11-28 15:05)

$ obit graveyard
ID  BURIED            PURGE  SIZE  PATH
#3  2026-11-21 15:05  in 7d  6 B   C:\obit-demo\old-output
pending recovery: 0

How the graveyard guarantees you restore the exact object you took ​

Moving files aside and putting them back sounds simple until concurrency and crashes enter the picture.

Same-volume renames, kept outside every repository ​

Graveyard placement obeys one rule:

  • On the drive holding Obituary's data directory, graves live in graveyard/ inside that data directory.
  • On every other drive, graves live in a hidden .obituary\graveyard folder at that volume's root.

Keeping graves on the same volume turns burial into an atomic rename—instant, with no half-copied state. Keeping them outside project folders ensures git clean -fdx can never wipe the graveyard itself.

Each grave gets its own directory named from the ledger ID, a UTC timestamp, and six random characters, holding the buried file or directory verbatim:

text
graveyard/
└── 3-20261121T070527Z-376905/
    └── old-output/
        └── report.txt

Verify and rename on the same handle ​

On Windows, burial opens the target, verifies its volume serial number, 128-bit file ID, type, and link count, and performs the rename into the grave through that exact same handle.

Splitting identity verification and rename into two path-based calls leaves a race window: an editor performing an atomic save in those milliseconds can swap in a brand-new file at the same path, and the rename buries the new file instead. Doing both operations on one pinned handle eliminates that window completely.

Write a manifest first; when uncertain, stop ​

The move runs under the ledger write lock after re-verifying that the entry has not changed, is still due, contains no longer-lived child entries, and—for automatic entries—still passes rules and Git checks.

To survive a crash between the filesystem move and the ledger commit, Obituary first writes a small manifest under the graveyard root recording the ID, original path, target identity, grave identity, reason, and source. On the next run, recovery reads pending manifests first:

  • If the grave holds the exact object described in the manifest, Obituary completes the ledger entry.
  • If the grave is empty, Obituary cleans up the aborted manifest.
  • If anything else happened, Obituary refuses to touch it, logs the state, and surfaces a warning in obit doctor.

Do nothing when uncertain is the floor beneath the entire design. Owning the graveyard meant building full crash-recovery and manifest verification ourselves, which absorbed most of our early review rounds. The payoff is turning a bad agent deletion from an incident into a single undo command.

Resurrect never overwrites; purge is the only permanent delete ​

obit resurrect puts a buried item back at its original path. If something else now occupies that path, Obituary refuses to overwrite it and restores alongside with a suffix:

text
$ mkdir old-output

$ obit resurrect 3
#3 resurrected  C:\obit-demo\old-output (resurrected)

$ ls -1
debug.log
old-output
old-output (resurrected)
screenshots

Restoration is harder than burial because the world moves on ​

At burial time, Obituary records every ancestor directory from the original path up to the volume root. Before restoring, it walks and verifies that chain:

  • If any ancestor has since been replaced by a symlink, junction, or mount point, restoration refuses so the file cannot be diverted somewhere unexpected.
  • Missing parent directories are recreated, and if restoration is rejected later in the call, newly created empty directories are rolled back by their creation handles.
  • Name collisions are detected atomically by the rename itself rather than probing first and renaming second.

Expiry runs unattended ​

Give a scratch file a 3-second lifespan and the resident daemon moves it into the graveyard automatically:

text
$ obit mark scratch.txt 3s
#4 added    C:\obit-demo\scratch.txt  expires 2026-11-21 15:05 (in 3s)

$ obit graveyard
ID  BURIED            PURGE  SIZE  PATH
#4  2026-11-21 15:05  in 7d  7 B   C:\obit-demo\scratch.txt
pending recovery: 0

Purge: the single permanent-deletion path in the codebase ​

Across the entire repository, permanent deletion of user content happens only inside purge, and only on a grave that passes verifyGrave—registered in the ledger, holding a single entry, matching the recorded identity.

Sweeping and burying only ever move objects. Purging early before retention expires stays gated on a human:

  • obit purge --all or explicit ID/path purges print every target first and prompt [y/N].
  • Non-interactive calls fail unless --yes is passed, with an error telling agents to ask the user first.
  • The MCP server does not expose a purge tool at all.
Screenshot of the Obituary desktop window showing the Graveyard page in calendar view: 12 graves arranged across a week by purge date, with Resurrect and Purge buttons at the top
The Graveyard page in the desktop window (sample data): each grave sits on the day it will be permanently deleted, with one-click Resurrect and early Purge controls.

When the Recycle Bin is still the right tool ​

For manually deleting a single document in a file manager, the OS Recycle Bin is plenty, and Obituary does not try to replace it.

Users who prefer it can switch Obituary to Recycle Bin mode in configuration so expired files go straight to the OS bin. The trade-off is clear: obit resurrect cannot restore them, and because the system shell API recycles by path after our identity check, a few-millisecond window exists where a swapped file could land in the Recycle Bin (still recoverable there manually).

Obituary pays off in proportion to how much scratch debris your agents leave behind. If an agent edits two files a day, the difference is minor; if agents constantly run test suites, capture screenshots, and spin up temporary directories, having every artifact expire into a restorable graveyard changes how cleanly you can work.

All posts