# Storage and vacuum

Measure a store, read what is live and what is reclaimable, and sweep safely.

Stop the service. Report with `stats`. Rehearse with `vacuum --dry-run`. Sweep with `vacuum --sweep`. Name every pin kept outside the store, or the sweep cannot honour it.

## Before you begin

Stop the service before planning a sweep. Both commands work on the data directory directly. stats can also report beside a live writer and marks that moving view, but vacuum refuses beside one. Know every place a reference to this store is kept outside the directory.

## Measure first


1. Run the report. It deletes nothing.

**Terminal**

```bash
haematite stats /var/lib/haematite/ward --json
```


2. Read the live and reclaimable figures. If reclaimable is a small share of the total, there is nothing to sweep.

3. Rehearse the sweep. The full pass runs and the deletion set is reported, with nothing removed.

**Terminal**

```bash
haematite vacuum /var/lib/haematite/ward --dry-run
```



## Sweep

**Terminal**

```bash
haematite vacuum /var/lib/haematite/ward --sweep
```


This makes a new plan under the writer lock. It matches the dry run only if data and pin metadata have not changed. Policy blockers refuse before the first deletion; an I/O failure during unlinking can leave partial progress.

> Pins outside the store
> Name every snapshot file and reference directory with `--snapshot-file` and `--refs-dir`. A pin the vacuum cannot see is one it cannot honour.


## If the run is refused

The refusal names the blocker. Fix it and rehearse again. A new store without a metadata manifest also needs an explicit completeness attestation for both dry run and sweep. The examples without that flag demonstrate the refusal until a complete manifest exists. The `--attest-metadata-complete` flag is your word that the metadata is complete, for the one refusal that asks for it. Only pass it when it is true.

## Check the history log

**Terminal**

```bash
haematite history-check /var/lib/haematite/ward --show 20
```
