Skip to content

feat(apply)!: delete at once instead of moving to a trash - #90

Merged
merge-loop[bot] merged 2 commits into
mainfrom
cb/apply-deletes
Nov 19, 2026
Merged

merge-loop[bot] merged 2 commits into
mainfrom
cb/apply-deletes

Conversation

@cjber

@cjber cjber commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

keeper apply now deletes at once. A trash on the same disk freed nothing until a purge 14 days later, so a cleanup reported space the machine did not have.

flowchart LR
  plan[keeper plan] --> apply[keeper apply PLAN --yes]
  apply --> rescan[rescan: id and state match]
  rescan --> check[live process or mount inside? refuse]
  check --> hook[deleteHook for worktrees]
  hook --> rm[delete for good]
  rm --> log[audit log: deleted paths and bytes]
Loading

What changed

  • apply deletes removals right away. undo, purge, --older-days and the trash directory are gone.
  • Right before each deletion apply checks again that no running process has its cwd in, or holds a file in, the path, and that no filesystem is mounted inside it. If either is true, apply refuses that finding.
  • Every apply logs deleted in the audit log: each path and its bytes.
  • A deleted worktree's git metadata goes with it. Its local branch is deleted too, but only if it has not moved.
  • The first apply, or the first nightly auto run, reports the measured size of any trash an older keeper left (oldTrash) and then deletes it. Old transactions are deleted only after the same mount check and the delete hook, and a branch is dropped only if it has not moved.
  • Config purgeHook is now deleteHook, run with the worktree path. A failing hook keeps the worktree.
  • The action trash is now delete, and schemaVersion is 8, so cached findings are invalidated.
  • README, SKILL.md, the site, AGENTS.md, help text, the smoke script and the bugpatrol docs drop the undo and purge language. The step after apply is now done.

Callers

Nothing calls keeper purge. The timer runs keeper auto daily and keeper sample hourly. The commented # purgeHook line in dotfiles config/keeper/config.toml should be renamed to deleteHook there. The hook script only reads $1, so it still works.

Verification

  • bun run gate:changed passes: biome, tsc, 136 tests across the touched test files, and the changelog check.
  • Every new test runs in temp directories only:
    • apply deletes and logs, and a stale plan is refused;
    • a process that starts working in a path after the scan blocks its deletion;
    • old trash is deleted, including read-only directories and a transaction missing its manifest;
    • old trash with a mount inside is kept;
    • an old worktree's branch is dropped only if it has not moved;
    • a failing delete hook keeps the worktree;
    • mount checks, including mounts the hook adds.

Review

Codex (gpt-reserve, xhigh) and Muse reviewed the diff independently; both findings lists overlapped heavily and neither failed. Fixed:

  • The old purgeHook config key is still read as deleteHook, so an upgrade does not fail on an unknown key.
  • A plan made by another keeper version is refused, so an old trash-era plan cannot delete for good.
  • Old trash is emptied after the plan rescan, so a stale plan does not empty it, and it gets the same running-process check as any deletion.
  • The old-trash report counts only the transactions deleted and their size; kept ones are listed.
  • The running-process check runs before the delete hook, and again after it.
  • apply exits 5 when old trash was kept, and the wizard reports old trash too.
  • A failing git worktree prune is reported; a path that cannot be read is no longer treated as already gone.
  • Stale undo and purge calls in the patrol routines and the "cannot move whole" blocker text are updated.

Not changed: a per-path process recheck for grouped findings (a process would have to start inside a later path within one apply), and deletion-ledger entries for transcript parent directories.

Closes #89

🤖 Generated with Claude Code

A trash on the same disk freed nothing until a purge 14 days later, so a
cleanup reported space the machine did not have. apply now deletes for good,
and the safety lives in what a plan may include plus a last check right before
each deletion: no live process may work in or hold a file in the path, and no
filesystem may be mounted inside it.

undo, purge and --older-days are gone. The first apply or nightly run reports
the size of any trash an older keeper kept, then deletes it. Every apply logs
each deleted path and its bytes. purgeHook becomes deleteHook, run with the
worktree's path before deletion; the action "trash" becomes "delete" and the
scan schema version is 8.

Closes #89

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Deploying keeper with  Cloudflare Pages  Cloudflare Pages

Latest commit: d1a3ef0
Status: ✅  Deploy successful!
Preview URL: https://6b0a53dd.keeper-9oy.pages.dev
Branch Preview URL: https://cb-apply-deletes.keeper-9oy.pages.dev

View logs

Accept the old purgeHook key, refuse plans from another version, empty old trash after the rescan with a holder check and per-transaction bytes, check holders before the delete hook, surface old trash errors in the exit code and wizard, and drop stale undo and purge from the patrol routines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cjber cjber added the mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it label Nov 19, 2026
@merge-loop

merge-loop Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Merged as d010b50.

@merge-loop
merge-loop Bot merged commit d010b50 into main Nov 19, 2026
7 checks passed
@merge-loop
merge-loop Bot deleted the cb/apply-deletes branch November 19, 2026 02:57
@merge-loop merge-loop Bot removed the mergepatrol Queue this PR: Mergepatrol rebases, tests and merges it label Nov 19, 2026
merge-loop Bot pushed a commit that referenced this pull request Nov 19, 2026
Prepares keeper 0.7.0: moves the Unreleased CHANGELOG entries under
0.7.0 and bumps package.json. 0.7.0 carries the breaking change from #90
(apply deletes at once; undo, purge and the trash are gone; purgeHook is
now deleteHook). After merge, the merged main commit is tagged with `bun
scripts/release.ts tag`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

apply should delete removals at once, not move them to trash

1 participant