fix(kvb-cleanup): write down the seven cleanup rules runs kept tripping on

Cleanup runs kept stumbling on the same seven points: recent items an owner had already released, fuser exit codes, empty Other answers, find -exec rm that the classifier refuses, merged branches whose tasks count as stale, bfs failing on -newermt, and one-option questions that AskUserQuestion rejects. SKILL.md and execute.md now state each rule where the step needs it, within the 600-word cap and at 99 % of the previous token cost.

🎯 Fix: 90 %
💥 Break: 4 %
💸 Tokens: 99 %
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 18:41:48 +00:00
1 parent a2a03995cb
commit bdb3947ec7
2 files changed
+63 -65

No files matched your search

+41 -40
View File
@@ -6,63 +6,63 @@ description: >
"platte voll", "no space left on device". "platte voll", "no space left on device".
--- ---
Delete only what the operator picked in this run; questions, inventory and Delete only this run's operator picks; asking, inventory and proposal change
proposal change nothing. Never invent a size or a peer's answer: unmeasured nothing. Never invent a size or a peer's answer: unmeasured is `unknown`.
is `unknown`.
## Step 0: the chair ## Step 0: the chair
Shared resources belong to the `kvb-org-organize` chair; its resource watch Shared resources belong to the `kvb-org-organize` chair; its watch
runs the configured low-risk cleanup. Another session chairs: send it the runs the configured low-risk cleanup. Another session chairs: send it the
request and stop, or, when the operator ordered the cleanup here, first request and stop, or, ordered here by the operator, first
`${CLAUDE_SKILL_DIR}/../kvb-org-radio/scripts/radio.py post --to <chair> `${CLAUDE_SKILL_DIR}/../kvb-org-radio/scripts/radio.py post --to <chair>
"<plan>"`. "<plan>"`.
## Step 1: inventory ## Step 1: inventory
Read-only, in parallel, with sizes, only in the agent write scope (Claude Read-only, parallel, sized, only in the agent write scope (Claude Code:
Code: `sandbox.filesystem.allowWrite`) and session scratch dirs; never `sandbox.filesystem.allowWrite`) and session scratch dirs, never another
another user's files. Prefer the project's cleanup and teardown targets; obey user's files. Prefer project cleanup and teardown targets; obey bans on raw
rules forbidding raw commands. commands.
- **/tmp**: `pkgmgr gc --report --docker --root /tmp --root <write dir>`, - **/tmp**: `pkgmgr gc --report --docker --root /tmp --root <write dir>`,
else `du -sh` per own entry; system entries (`.X11-unix`, `.ICE-unix`, `systemd-private-*`, else `du -sh` per own entry; never system entries (`.*-unix`,
`ssh-*`, `tmux-*`, sockets) are never candidates. `systemd-private-*`, `ssh-*`, `tmux-*`, sockets).
- **Docker**, **worktrees**: read `docker.md` (its `⚠ Volumes` checklist - **Docker**, **worktrees**: read `docker.md` (its `⚠ Volumes` checklist
joins Step 4) and `worktrees.md` next to this file when present. joins Step 4) and `worktrees.md` next to this file when present.
- **Agent dirs**: pip, npm, pre-commit, act, gh, buildx caches; Ansible and - **Agent dirs**: pip, npm, pre-commit, act, gh, buildx caches; Ansible and
build temp dirs. build temp dirs.
- **Register**: `council.py list --long`; `rasci.py artifacts` (`kvb-org-artefacts`, - **Register**: `council.py list --long`; `rasci.py artifacts`
`--ended` for candidates). (`kvb-org-artefacts`, `--ended` for candidates).
- **Queue**: `${CLAUDE_SKILL_DIR}/../kvb-org-queue-cleanup/scripts/cleanup.py - **Queue**: `${CLAUDE_SKILL_DIR}/../kvb-org-queue-cleanup/scripts/cleanup.py
request`; go on meanwhile. request`; go on meanwhile.
- **Live use**: `fuser`, `lsof`, `ps -o pid,etime,comm`, never full command - **Live use**: `fuser` (exit 1 or 123: free), `lsof`, `ps -o
lines or environments (credentials). Sandboxed, an empty result proves pid,etime,comm`; never full command lines or environments (credentials).
nothing. Sandboxed, an empty result proves nothing.
- **Archive duties**: memory or project rules requiring a copy before - **Archive duties**: memory or project rules requiring a copy before
deletion (logs, reports, generated maps). deletion (logs, reports, generated maps).
## Step 2: ask the owners ## Step 2: ask the owners
Owner: register worker, session id in the path, worktree or compose project, Owner: register worker, path session id, worktree or compose project,
container label, open handle, else `unknown`. `radio.py send call --to container label, open handle, else `unknown`. Once per local peer owning
<peer>` the text in `ask.md` next to this file once to each local peer unregistered candidates, `radio.py send call --to <peer>` the `ask.md` text;
owning candidates the register does not cover; go on meanwhile. go on meanwhile.
## Step 3: classify ## Step 3: classify
First match wins: claimed by a peer, `keep`; in a register task not `done`, First match wins: claimed by a peer, `keep`; in a register task not `done`,
`stopped` or `stale`, `keep (task <task>)` (an ended task's items are its `stopped` or `stale` (a branch merged into the default branch makes it
worker's candidates); a running deploy, gate, test, swarm run or build, `keep `stale`; an ended task's items are its worker's candidates), `keep (task <task>)`; a
(running)`; a silent peer's, `keep (no answer from <peer>)`, silence is not running deploy, gate, test, swarm or build, `keep (running)`; a silent peer's,
consent; sandboxed, anything touched within 24 hours, `keep (recent, `keep (no answer from <peer>)`, silence is not consent; sandboxed, touched
possibly in use)`; archive duty, within 24 hours (`find -mmin -1440`; bfs fails on `-newermt`) and neither
`archive first`, never a plain delete. Else a candidate: owner-released nor operator-picked, `keep (recent, possibly in use)`; archive
duty, `archive first`, never a plain delete. Else a candidate:
- **low**, regenerated cheaply: stopped containers without volumes, dangling - **low**, cheap to regenerate: stopped containers without volumes, dangling
images, unused networks, finished sessions' scratch and logs. images, unused networks, ended sessions' scratch and logs.
- **medium**, regenerated slowly, rate-limited or networked: unused tagged - **medium**, slow, rate-limited or networked to regenerate: unused tagged
images, build cache, package caches, clean worktrees already merged. images, build and package caches, clean merged worktrees.
- **high**, data loss or a broken run: volumes, stopped containers with - **high**, data loss or a broken run: volumes, stopped containers with
volumes, running unclaimed containers or stacks, dirty or unpushed volumes, running unclaimed containers or stacks, dirty or unpushed
worktrees, unread reports, anything `unknown`. worktrees, unread reports, anything `unknown`.
@@ -70,22 +70,23 @@ possibly in use)`; archive duty,
## Step 4: propose ## Step 4: propose
One table, biggest first: area, item, size, owner, risk, proposal, what One table, biggest first: area, item, size, owner, risk, proposal, what
breaks if wrong. Below it reclaimable size per risk and every `keep` grouped breaks if wrong. Below it reclaimable size per risk and every `keep` by
by reason. Then `AskUserQuestion`: reason. Then `AskUserQuestion`:
1. `multiSelect: true`, at most four questions: `/tmp`, `Docker`, `Other 1. `multiSelect: true`, up to four questions: `/tmp`, `Docker`, `Other
dirs`, `High risk` (every high-risk candidate); size, risk and worst case dirs`, `High risk` (every high-risk candidate); each option names size,
in each option's description. Over four options: group by owner or risk, risk and worst case. Over four options, group by owner or risk or call
or call again. Only ticks select; nothing preselected. again; merge single items into one question: one-option questions fail.
Only ticks select, not an empty `Other` answer; nothing preselected.
2. `multiSelect: false`: `Execute: <n> items, <size> (Recommended)` naming 2. `multiSelect: false`: `Execute: <n> items, <size> (Recommended)` naming
the ticked items' worst case, `Revise the selection` (repeats 1), `Abort`. the ticked items' worst case, `Revise the selection` (repeats 1), `Abort`.
## Step 5: execute ## Step 5: execute
After `Execute`, read `execute.md` next to this file first. After `Execute`, read `execute.md` first.
## Step 6: report ## Step 6: report
`df -h` and `docker system df` before and after, freed size per area, every `df -h` and `docker system df` before and after, freed size per area, skipped
skipped or failed item with its reason. `radio.py post --to <peer>` tells each or failed items with reasons. `radio.py post --to <peer>` each
answering peer which removed items lay near its own. answering peer the removed items near its own.
+22 -25
View File
@@ -1,31 +1,28 @@
# Executing the selection # Executing the selection
- Re-check claims, open handles and running state right before each delete: - Right before each delete, re-check claims, open handles and running state:
a peer may have started something since the inventory. a peer may have started something since the inventory.
- Delete exactly the selected items, by name or path. No blanket prune - Delete exactly the selected items, by name or path, never by a blanket
(`docker system prune -a --volumes`, `rm -rf /tmp/*`) that sweeps beyond prune (`docker system prune -a --volumes`, `rm -rf /tmp/*`). For more than
the selection. For more than a handful of paths, write the list to a file a handful of paths, write the list to a file under `/tmp`, grep it against
under `/tmp`, grep it against every claim once more, then delete with every claim once more, then `xargs -d '\n' rm -rf -- < <list>`; never
`xargs -d '\n' rm -rf -- < <list>`. `find -exec rm -rf`, which the classifier refuses.
- Never stop, take down or kill a running job, and never ask its owner to, to - Never stop, take down or kill a running job to free space, nor ask its
free space: not for a priority slot, not at a disk stop. Free idle items, owner to: not for a priority slot, not at a disk stop. Free idle items, ask
ask the operator for an exception, or wait; an owner's own disk guard only the operator for an exception, or wait; an owner's disk guard only alerts
alerts the chair, and only the operator can order a running job down. A the chair; only the operator orders a running job down. A hung job is no
hung job is not freed through cleanup: the `kvb-org-organize` hang rule cleanup item: the `kvb-org-organize` hang rule lets only its owner end it.
lets only its owner end it. - Idle running stacks go down by the project's teardown target, never by
- Idle running stacks go down through the project's teardown target, never by removing their containers or volumes. Worktrees go as `worktrees.md` says.
removing their containers or volumes underneath them. Worktrees go as
`worktrees.md` says.
- Archive-first items: copy out, verify the copy, then delete. - Archive-first items: copy out, verify the copy, then delete.
- Drop every deleted item from its task as the `kvb-org-artefacts` skill says - Drop every deleted item from its task (`rasci.py set <task> --drop-artifact
(`rasci.py set <task> --drop-artifact <kind>:<ref>`), so `artifacts` stays <kind>:<ref>`, see `kvb-org-artefacts`) so `artifacts` stays true.
true. - A host permission layer (auto-mode classifier, deny rule) may refuse a
- A host permission layer (an auto-mode classifier, a deny rule) may refuse a delete; never route around it by another command or a peer. Finish the
delete. Never route around it with another command or a peer. Finish the rest, then offer the refused item to the operator again as its own option:
rest, then put the refused item to the operator again as its own option: an an explicit renewed pick may pass; refused again, hand over the exact
explicit renewed selection may pass; if it is refused again, hand over the command with its list file.
exact command with its list file for the operator to run. - A delete failing on permissions (container-UID files) goes through the
- A delete failing on permissions (files owned by a container UID): use the project's container helper, never sudo or a sandbox bypass; without a
project's container helper. Never sudo, never bypass the sandbox; without a
helper, report the path. helper, report the path.
- Stop on the first unexpected error and report it. - Stop on the first unexpected error and report it.