8 min readPost 34
Beyond files: why we refuse to auto-delete WSL distros and images, and how os.Root locks down Docker volume graves
Expanding Obituary beyond local files raises an unforgiving question: where must automatic deletion stop? Across 25–28 November we enforced a four-gate admission rule barring WSL distros and Docker images from auto-cleanup, fought three review rounds of Windows cmd /c quoting to block wsl --unregister, confined Docker volume graves inside Go os.Root, and landed our stdlib-only extres.Provider contract.

On this page
Obituary started by attaching countdowns to local files and folders. Yet developer SSDs rarely fill up from kilobyte logs—they fill up from tens of gigabytes of Docker containers, local volumes, images, build caches, and WSL distributions.
Expanding a cleanup tool beyond files carries an obvious trap: treating every space-hogging object as fair game for automatic burial. Whenever an object lacks a lossless, non-overwriting restore path, automation turns from safety net into landmine.
Across 25–28 November we shipped four interlocking pieces of our external-resource foundation: a four-gate admission boundary, real-engine Docker container contract tests with StartedAt drift protection, a three-round Windows cmd /c parser battle guarding wsl --unregister, Go os.Root confinement for Docker volume graves, and a zero-cycle extres.Provider contract.

Four admission gates: why WSL distros and Docker images are barred from auto-delete
Nothing outside plain files enters Obituary's automatic burial/purge lifecycle unless it satisfies all four prerequisites: verifiable immutable identity, reliable lossless no-overwrite restore, proof that failure keeps the original intact, and an isolated automated E2E suite that never touches host state.
Evaluating real developer resources against those four gates drew sharp lines:
- Docker containers pass: full 64-character ID, pinned
DaemonID, and creation timestamp provide immutable identity; expiry runsdocker stop(keeping writable layers intact),obit resurrectrunsdocker start, and post-retention purge runsdocker rmwithout-vor-f. On 25 November we closed a subtle reclamation bug withStartedAtdrift detection (2bfbba6): if a user manually started a buried container during its 7-day retention and later stopped it again, checking onlyRunning=falseused to purge it; comparing the recordedStartedAtnow detects the newer run and keeps the container as reclaimed. On 27 November we added a five-subtest real-engine E2E suite (TestDockerContainerRealEngine,4744adf,9185071) running in CI against Docker Engine29.10.0. Standalone non-Pod Podman containers follow the exact same model as our planned first non-Docker pilot. - Docker local volumes stay explicit + guarded: opt-in only via
--docker-volume, archived via a pinned-digest read-only offline Debian container with SHA-256 and Docker event verification, and never overwriting an existing volume on restore. - Docker images, build caches, VHDX disks, local VMs, and k8s are forbidden from auto-delete: locally built images and expired private tags have no lightweight lossless offline restore loop, so they remain read-only diagnostics, manual guides, and
docker system prune --volumesdelete-guard denials. - WSL distributions are strictly barred from auto-burial and auto-unregister:
wsl --export+wsl --importlooks reversible until you inspect what breaks—wsl --importgenerates a brand-new GUID and losesDefaultUid, Microsoft Store package links, and Windows Terminal profiles; exporting multi-GB tarballs risks filling the host disk; and automated WSL tests would mutate realHKCU\...\Lxssregistry keys, violating test isolation.
Guarding wsl --unregister: three review rounds inside Windows cmd /c quoting
Because Obituary refuses to auto-delete WSL distributions, the right protection is intercepting wsl --unregister statically in the delete guard—zero subprocess calls, zero registry reads—and pointing users to wsl --export <distro> <backup.tar> (validating distro names against ^[a-zA-Z0-9][a-zA-Z0-9_.-]*$ ≤ 128 chars to avoid untrusted string injection, and halting option parsing at --/-e/--exec so wsl -d Ubuntu -- echo --unregister passes untouched).
Three adversarial review rounds across Bash, PowerShell, and cmd.exe (c4604c5, 36b8a43, 8b22ca5) caught four gnarly Windows shell traps:
128×exponential PowerShell wrapper blowup:psCommandTailWSLDeletionoriginally recursed down two paths on the same argument slice, causing2^7blowup (63.1× allocation growth) on nestedpowershell -cwrappers. Removing the double recursion restored strict linearO(depth · N)runtime, guarded byTestWSLWrapperDeepNestingLinear(0.02 s).cmd.exe /cRule 2 quoting with trailing redirections: Windowscmd /cstrips the first and last"whenever a command begins with"while preserving everything after the closing quote. Checking onlytrimmed[len-1] == '"'missedcmd /c "wsl --unregister Ubuntu" 2>&1,> nul, and""C:\Program Files\WSL\wsl.exe" --unregister Ubuntu" 2>&1! Slicingtrimmed[1:last] + trimmed[last+1:]closed every trailing-redirection and chained bypass while keepingecho "a && wsl --unregister Ubuntu"clean.- Whitespace-separated
@tokens and glued flags:@ wsl --unregister Ubuntu,@ @ cmd /c "...",/c"wsl...", and/cwslare all valid CMD invocations. AddingcmdStripAtWordsandsplitCmdExecFlag(usingstrings.EqualFoldrather thanstrings.ToLowerto avoid UTF-8 byte-length shifts on the Unicode Kelvin signK) sealed them cleanly. - Locked with two compile-time mutations:
detect-wsl-unregisterandhook-wsl-unregister-guidancepassed across all 26 full-plus-mutation CI jobs.
Four hidden Docker volume bugs—and 3-hop os.Root grave confinement
Auditing external-resource coupling revealed Kind == KindContainer checks scattered across 25+ call sites. That duplication hid four real defects affecting KindDockerVolume:
- Expired volumes dropped in default graveyard mode:
sweepBurialsfiltered outKindContaineryet missedKindDockerVolume, sending expired volumes into file settlement whereIdentity == nilrefused and dropped them. - Background
Tick()routed volumes into file batch purge:purgeContainerRequestssimilarly missedKindDockerVolume. sameBurialbroke every volume purge withErrUnsafe: unconditional checks forGraveID != nil && Identity != nilcausedbeginPurgeto reject all Docker volumes.- Tracked volumes broke
OnlyNewfile registration:RegistrationScopeand diagnostics only skipped containers, hittingnil Identityand emitting bogusidentity-errorevents whenever a volume was tracked.
Unifying IsFile() / IsExternal() across 20+ call sites (908eaa0, zero ledger format changes) fixed all four immediately.
The R1 review blocker: blocking copied ledgers and symlink escapes with os.Root
Right after those fixes, read-only review flagged a serious blocker: what if a ledger copied from a different OBIT_HOME—or a tampered archive directory replaced by a symlink—pointed b.Grave at a volume.tar outside the active graveyard?
internal/core/lifecycle/volume_archive.go (0f4e097) locks every Docker volume archive operation inside Go's os.Root:
- Strict path shape: rejects any
..segment, requires basenamevolume.tarand exact<ID>-<16hex>directory naming, and verifies canonical path equality inside<OBIT_HOME>/graveyard/docker-volumes/<dir>/volume.tar. - Three-hop
os.OpenRoot+Lstat: walksOBIT_HOME→graveyard→graveyard/docker-volumes→<dir>, rejecting symlinks or Windows reparse points at every hop withErrUnsafe. - Confined verification and removal:
openRegularInRootchecks bothLstatand handleStatfor regular files, verifiesvolume.tarSHA-256, capsvolume.tar.jsonat 1 MiB viaio.LimitReader, validatesVersion == 1,VolumePhase == "removed", and exact ID/Kind/Grave/Digest match, removes files strictly throughsub.Remove, and closessubbefore removing the empty folder for Windows lock safety. - Purge/resurrect mutex and clock-rollback safety:
resurrectDockerVolumerefuses whilePurgeIntent != nil, and interrupted purges withPurgeIntent != nilcan safely resume verification and cleanup even if the system clock rolled backward. All 14 new negative tests proved red-first and passed 26/26 full-plus-mutation CI.
Finishing cleanly: a zero-cycle, stdlib-only extres.Provider
Only after hardening those real implementations did we extract the abstraction on 28 November: internal/core/extres (a19d1ef) imports only Go's standard library (context, encoding/json, time) with zero dependency on internal/docker:
- Minimal 6-method
Provider:Validate,Inspect,Verify,Bury,Resurrect, andPurge(plusKind()), modeled on Obituary's safety state machine rather than generic CRUD or brittle runtime plugins. - Optional capability interfaces:
RetentionPolicy,Doctor, andDiscoverer. - Zero breaking migration:
docker.ContainerProvideranddocker.VolumeProviderwrap our battle-tested logic intact (noNameCollision,StartedAtdrift, pinned-digest archives,os.Rootconfinement) while preserving v14–v18 ledger JSON verbatim and enforcing out-of-lock external calls + durable pre-send intents + read-back verification for every external resource to come.
Managing more than files never means loosening deletion discipline—the wider the blast radius, the tighter the admission gates and path confinement have to become.