Skip to content

feat(tools): add PurgeArchives, an age-based purge with a fail-closed directory guard - #1794

Open
xmasyx wants to merge 1 commit into
danielmiessler:mainfrom
xmasyx:feat/purge-archives
Open

feat(tools): add PurgeArchives, an age-based purge with a fail-closed directory guard#1794
xmasyx wants to merge 1 commit into
danielmiessler:mainfrom
xmasyx:feat/purge-archives

Conversation

@xmasyx

@xmasyx xmasyx commented Aug 7, 2026

Copy link
Copy Markdown

Offered in #1614; you said yes to (5).

Deletes files older than N days (default 14) inside an archive directory. A manual archive is a grace window, not forever: silence means it goes after N days, a KEEP- prefix means it stays. The trigger is lazy, called right after archiving something by hand, so the directory prunes itself as a side effect of being used and there is no scheduler.

The guard is the reason to take it. It refuses any directory whose basename is not exactly the sentinel (--dir-name, default _archive). A tool that deletes by age is one bad argument away from deleting live work, so the check is not "this path looks plausible": the directory has to be named as an archive, which is a property no working directory acquires by accident. Files only, never subdirectories; dotfiles skipped; every action logged; --dry-run touches nothing.

bun LIFEOS/TOOLS/PurgeArchives.ts <dir> [--days N] [--dir-name NAME] [--dry-run]

Verified against a fixture tree, case by case: pointed at a live directory it refuses with exit 1 and leaves the contents intact; --dry-run prints and deletes nothing; the real run removes only the expired non-KEEP- file while KEEP-, fresh files, dotfiles and subdirectories all survive; the sentinel override works; --days abc is rejected with exit 1.

… directory guard

Deletes files older than N days (default 14) inside an archive directory,
sparing anything prefixed KEEP-. The guard is the point: it refuses any
directory whose basename is not exactly the sentinel (--dir-name, default
_archive), so it cannot be pointed at live work by a bad argument. Files
only, never subdirectories, dotfiles skipped, --dry-run touches nothing.

Requested in danielmiessler#1614.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant