← Back to Plugins
Tools

Disk Pressure Guard

jamesdwilson By jamesdwilson 👁 14 views ▲ 0 votes

Experimental cache-only macOS disk pressure guard for OpenClaw, with a shared-lock launchd fallback and bounded cleanup.

GitHub

README

# 🛟 OpenClaw disk pressure guard

**A bounded, cache-only safety net for macOS.**

![Platform](https://img.shields.io/badge/platform-macOS-black) ![Python](https://img.shields.io/badge/engine-Python_3-blue) ![Status](https://img.shields.io/badge/status-experimental-orange) ![Tests](https://img.shields.io/badge/fixture_tests-38_passed-brightgreen)

Keep a full disk from becoming a bigger incident. A dependency-free Python engine supports an OpenClaw plugin and an independent macOS LaunchAgent fallback, sharing one lock and cooldown.

> **Inactive by default.** Cloning this repository does not install a plugin, load a LaunchAgent, or start cleanup. Running `engine.py run` explicitly authorises permanent deletion of eligible cache files. Review the source and allowlist first.

## How it works

```text
Five-minute check → free space healthy? → leave caches alone
                  ↓ below threshold
           shared lock + cooldown
                  ↓
           inspect exact cache allowlist
                  ↓
           bounded cleanup → one local receipt
```

## Small budgets, explicit limits

| Setting | Default |
| --- | --- |
| Trigger / target free space | 5 GiB / 10 GiB |
| Maximum deletion per attempt | 2 GiB / 2,000 files |
| Cooperative time budget | 20 seconds |
| Minimum file age | 24 hours |
| Cooldown | One hour |
| Traversal ceiling | 20,000 entries, depth 20 |

Directories are never deleted. Downloads, documents, projects, model weights and arbitrary caller-supplied paths are outside the allowlist. Eligible files are unlinked permanently, not moved to Trash.

## Safety design

- Exact built-in allowlist: selected Homebrew, Mozilla updater, Brave updater and Codex/Chrome/Brave Default browser caches under your home directory.
- Active or uncertain application state skips cleanup. Failed process observation fails closed.
- Symlink, ownership, permission, hardlink, inode and directory-identity checks reduce accidental traversal and replacement risks.
- Plugin and fallback share a kernel lock, cooldown and bounded receipt. No growing log history.
- No network dependency, telemetry or language-model calls in the cleanup path.

## Inspect without deleting

Requires macOS and Python 3. The current plugin and plist pin Python to `/Library/Frameworks/Python.framework/Versions/3.14/bin/python3`; review and adjust that executable path for your installation.

```sh
python3 -B engine.py status
python3 -B engine.py dry-run
```

Dry-run does not delete cache data or replace the receipt. It may create the package-owned state directory and lock. Keep the package in a user-owned, non-group/world-writable path: ancestry checks are deliberately strict.

## Run the fixture tests

```sh
python3 -B -m unittest -v test_engine.py
node --experimental-vm-modules --test test_plugin.mjs
```

The reviewed suite contains 30 Python engine tests and 8 mocked plugin tests, including concurrent processes, caps, cooldown, relocation, protected sentinels, malformed responses and lifecycle handling. These tests do not establish production authorization or operational fallback acceptance.

## Optional integration, manual review required

The manifest and `index.mjs` provide an OpenClaw plugin targeting version 2026.11.3 or later. It registers `disk-pressure-guard.status` with `operator.read` and `disk-pressure-guard.dry-run` with `operator.admin`; both require profile access. Its service checks every five minutes once activated.

The plist is a **template**, with an intentionally invalid absolute engine path. Do not load it unchanged. The plugin and fallback must reference the **same physical package directory** to share lock and cooldown. Use a reviewed linked installation, not separate copies.

No installation or activation is performed by this repository. Before operational use, review capabilities through OpenClaw plugin management, verify unauthorized/under-scoped calls are denied, and test fallback execution and receipt reporting on the target Mac.

## Known limits

Experimental safety tooling, not a storage guarantee. Process snapshots cannot guarantee OS-wide inactivity. Final check-to-unlink races remain possible under hostile concurrent mutation. Time caps are cooperative between bounded operations, not hard real-time deadlines. Cache removal may slow subsequent launches. Notifications do not guarantee Telegram delivery. A full disk can still prevent other applications from recovering.

## Layout

- `engine.py`: cleanup policy, filesystem checks and CLI
- `index.mjs`: OpenClaw adapter
- `local.disk-pressure-guard.plist`: independent macOS fallback template
- `test_engine.py`, `test_plugin.mjs`: isolated verification

Built with Pi, reviewed with fixture-based safeguards. **Prepared and tested; not activated.**
tools

Comments

Sign in to leave a comment

Loading comments...