workspace-metabolism
One policy file controls the whole life cycle of files in your workspace: classify, audit, clean into a recycle area (rollback anytime), purge, and verify — every step leaves a hash-chained audit trail. Python 3.11+, zero dependencies, Windows / Linux / macOS.
Why this exists
Most disk tools either show you space (ncdu, duf) or delete things
(rmlint). workspace-metabolism is different: a policy file defines what
every path is worth (grades G1–G4), and the tool only ever does what the policy
allows — nothing more.
- G1 never touch / G2 keep / G3 approve + reference check / G4 auto
- Deletion is never direct: items move to a recycle area, then
rollbackrestores them after a per-file SHA-256 integrity check - Every action lands in a hash-chained journal;
verifydetects any edit - Read-only
auditreports candidates, unregistered paths, disk alerts, growth trend and possible duplicates - Optional protected window (e.g. trading hours, business hours) during which marked entries are never touched
- Scheduled runs are supported out of the box on Windows (Task Scheduler) and
Linux/macOS (cron) via templates in
examples/
🧬 Philosophy
workspace-metabolism treats your AI-generated workspace as a living system,
inspired by biological metabolism: audit → clean → verify → rollback, with
recyclable cleanup and a hash-chained audit trail. Cleanup is the means;
metabolism is the frame. The one-liner: loops keep the agent running;
metabolism keeps the workspace alive. We call this framing Agentic
Metabolic Engineering
— managing the byproducts of agent-driven software workspaces. Full write-up:
docs/philosophy.md · the story.
Quick start
# install from PyPI
pip install workspace-metabolism
# or run without installing anything:
# PYTHONPATH=src python -m workspace_metabolism --help
# try it on a throwaway workspace (builds demo files, runs status/audit/clean)
python examples/demo.py
Point the tool at your own workspace:
wm --root /path/to/workspace --registry examples/registry.example.json status
wm --root /path/to/workspace --registry examples/registry.example.json audit
wm --root /path/to/workspace --registry examples/registry.example.json clean --grades G4 --yes
wm --root /path/to/workspace --registry examples/registry.example.json rollback <run_id>
Copy examples/registry.example.json, edit the paths and retention rules, and
register every directory you want to manage. Nothing is cleaned unless it is
registered in the policy file.
Commands
| Command | What it does |
|---|---|
audit |
Read-only health check; writes a report and a journal entry |
clean --grades G4 |
Move expired items to the recycle area (dry-run by default) |
clean --grades G3 |
Same, but requires --approve + --approver |
rollback <run_id> |
Restore one cleanup run after an integrity check |
purge --older-than 30 |
Delete expired recycle batches (the only real delete) |
verify |
Check the journal hash chain and run manifests |
status |
Overview of workspace, recycle area and pending candidates |
Global flags:
| Flag | Meaning |
|---|---|
--root PATH |
Workspace to govern (default: current directory) |
--state-dir PATH |
Journal / recycle / runs / reports (default: system cache directory, outside the workspace) |
--registry PATH |
Policy registry JSON (required for audit / clean / status) |
--protected-window HH:MM-HH:MM |
Weekday window; entries marked protected are skipped while active |
The default state directory lives outside the workspace on purpose — a
git add . in your project can never sweep the audit journal into version
control.
Policy file
{
"version": 1,
"defaults": {
"recycle_retention_days": 30,
"max_item_mb": 2560,
"disk_alert_free_gb": 20,
"disk_alert_free_pct": 15,
"dupe_scan_dirs": ["tmp", "cache"]
},
"never_clean": [".git", "README.md", "src"],
"entries": [
{"path": "logs", "grade": "G4", "cleanup": "auto", "retention_days": 30},
{"path": "archive", "grade": "G3", "cleanup": "approve", "retention_days": 60},
{"path": "**/__pycache__", "grade": "G4", "cleanup": "auto", "retention_days": 30}
]
}
| Field | Meaning |
|---|---|
path |
Path or glob (*, **/) relative to --root |
grade |
G1 never / G2 keep / G3 approve / G4 auto |
cleanup |
never, auto or approve |
retention_days |
Idle days before the item becomes a candidate (required unless cleanup=never) |
scope |
Optional: files_only (top-level files of a directory) |
protected |
Optional: skip while a --protected-window is active |
remote_authoritative |
Optional: display marker for data with a remote source of truth |
category |
Optional free-form label for your own classification |
Safety model
cleanis dry-run unless--yesis given.- G4 needs
--yes; G3 needs--approveand--approver(audit trail). - Items move to the recycle area with per-file SHA-256 hashes;
rollbackverifies them before restoring and refuses to overwrite an existing path. purgeis the only command that truly deletes, and only inside the recycle area after retention.- The journal is a hash chain;
verifydetects any tampering.
Scheduled runs
Templates with {{PLACEHOLDERS}} are in examples/:
- Windows —
register_schedule.template.ps1: daily read-only audit (20:30), weekly G4 clean (Saturday 10:00), monthly purge (1st, 10:30). - Linux/macOS —
register_cron.template.sh: same schedule via cron.
Replace {{WM_CMD}}, {{ROOT}}, {{REGISTRY}}, {{STATE_DIR}} (and
{{USER}} in cron) with your values. The scripts deliberately do not
auto-detect your environment — your paths, your call.
Development
python -m pip install -e . pytest
python -m pytest
CI runs the full test suite on Ubuntu, Windows and macOS with Python 3.11 and 3.12. Issues are handled on weekends; pull requests are welcome.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file workspace_metabolism-0.1.2.tar.gz.
File metadata
- Download URL: workspace_metabolism-0.1.2.tar.gz
- Upload date:
- Size: 103.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28fb446af55ed0704d23ecbfcadfa3dbe934461fd94c6d87453770f6fdb80ea7
|
|
| MD5 |
12b1382e31cf29fb5ce08e70061ef249
|
|
| BLAKE2b-256 |
8dc2c938dae424fd149b438badc2fee50607761722da87e6cbf36c5622553470
|
File details
Details for the file workspace_metabolism-0.1.2-py3-none-any.whl.
File metadata
- Download URL: workspace_metabolism-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
436ec9e9451a3f15eff7377bf6c74675033871dcb47a7c13ebb82f8d91d3d407
|
|
| MD5 |
5a88c9d07730fa788c4db30878d09c94
|
|
| BLAKE2b-256 |
5d22192c94c9cd875048f4b7e52fabca52e5f9485c09eacc013145a391f9d2c8
|