sow gc
Run sow gc to reclaim unused local package files. For an R2 target, sow gc TARGET records eligible objects and sow gc TARGET --delete removes those that still qualify.
Synopsis
--passfile supplies signing credentials when recovering an interrupted local mutation. Collection itself does not sign files. See Password files for source selection and format.
| Flag | Meaning | Default |
|---|---|---|
-C, --workdir DIR |
Workspace discovery start directory | current directory |
-r, --repo NAME |
Select a Repository for local GC only | selection rules |
--delete |
Allow physical deletion on an R2 target, including resuming an interrupted deletion | false |
-T, --timeout DUR |
Maximum Repository-lock wait; 0 waits indefinitely |
0 |
-N, --no-wait |
Fail immediately when the lock is held | false |
--passfile PATH |
Password file for this invocation | per-key config, then SOW_GPG_PASSFILE |
--json |
Output JSON | false |
gc TARGET -r NAME is a usage error because the target already binds a Repository. Passing --delete without TARGET is also a usage error. Neither mode accepts --dist.
Local GC
Run local GC after the Repository has a completed, clean build. If it is dirty, run sow build first. GC deletes a pool package only when none of these records references it:
- current Desired or Built membership, or prior Built membership kept for older clients;
- explicit
retainrecords; - recovery and non-terminal Operation state;
- publication records;
- active maintenance work.
SOW first replays any interrupted retain-remove-* tombstones, then journals the operation and persists a local GC plan (.sow/<repo>/recovery/<operation-id>/plan.json) before unlinking pool payloads. Large unreachable backlogs execute in bounded batches below the 64 MiB plan limit. If an interruption occurs after some files are deleted, a subsequent recovery replays the recorded plan, verifies that every active current, previous, and retained Generation pointer is withdrawn before retiring a Generation, and completes the new Generation. When payloads are removed, the Repository advances to a new Generation. When nothing is eligible, the command is an idempotent no-op.
Target GC
Target GC waits for the target’s configured cache grace period (max_cache_ttl directly for new grace records in SOW 0.9.0; existing later deadlines remain effective) and checks which objects are still needed:
| Provider | Behavior |
|---|---|
filesystem |
After the grace period, conditionally delete eligible objects, verify that their public URLs are absent, and record the result |
r2 |
Save a candidate report by default. Pass --delete to reclaim eligible objects after grace |
For filesystem targets, SOW scopes the prospective target path check so sibling targets that share a parent directory (such as /srv/www/pgsql and /srv/www/pigsty) do not block each other.
Use a target prefix written exclusively by this workspace. R2 deletion can follow a candidate report or run directly. SOW rechecks protected publications and each object’s size, SHA-256 metadata, and ETag before calling DeleteObject. The identity check and delete are separate storage requests. SOW then verifies storage absence and a public HTTP 404 or 410 and records a causal-epoch deletion receipt. If the run stops partway through, rerun sow gc TARGET --delete; running without --delete rejects an unfinished conditional-delete report with exit 6.
A no-op means no maintenance is due.
Exit behavior
| Code | Trigger |
|---|---|
0 |
GC completed or nothing was eligible |
1 |
Filesystem, provider, network, or runtime failure |
2 |
Usage, Workspace discovery, invalid sow.yml, or implicit Repository ambiguity |
4 |
Repository write lock unavailable |
5 |
Recovery, state, receipt, or manifest evidence is inconsistent |
6 |
Explicit Repository/target is not configured or safe, or deletion is rejected by a safety precondition |
See also
sow retain— protect package files from local GCsow publish— create target checkpoints and receipts- Publication Model — provider guarantees and cache grace