sow retain
Each build replaces the current Generation, and once nothing else refers to them,
sow gc may delete packages that only the old Generation used. sow retain
marks a Generation to keep: it verifies the Generation, saves a frozen copy of its manifest and
metadata references in private state, and makes local GC keep every package file it needs. The
packages stay in the shared pool, so retention copies nothing. It does not restore or publish the
old view; it keeps the bytes and the record of what that Generation contained.
Synopsis
GENERATION is a decimal integer greater than zero.
Options
| Flag | Commands | Meaning |
|---|---|---|
-C, --workdir DIR |
all | Workspace discovery start directory |
-r, --repo NAME |
all | Select a repository (selection rules) |
-T, --timeout DUR |
add, rm |
Maximum lock wait; 0 (default) waits indefinitely |
-N, --no-wait |
add, rm |
Fail immediately when the lock is held |
--json |
all | Output JSON |
retain add
retain add accepts only the current Generation, so run it right after the build you want to
keep and before the next build replaces it. Take the number from sow status or the build output:
Any other Generation is rejected with exit 6:
Adding the same Generation again changes nothing, provided its retained record still passes verification.
retain ls
An empty list is a successful result.
retain rm
retain rm releases a Generation by removing its retained record:
It deletes no package files. A later local sow gc reclaims them once no other
record or operation needs them. Removing a Generation that is not retained is a no-op that succeeds.
Details
Interrupted removal
Before deleting a record, SOW writes a removal plan
(.sow/<repo>/stage/retain-remove-<GENERATION>.plan.json) and moves the record to a tombstone
(.sow/<repo>/stage/retain-remove-<GENERATION>). If the removal stops halfway, rerun retain rm
or run local sow gc; either replays the tombstone and finishes the job. Until then, the retained
layer of sow check reports the unfinished removal.
Damaged records
If a retained record is damaged, retain rm, retain ls, local gc, and check report an error,
and the retained layer of check names the Generation. To discard the damaged record:
- Stop workspace writers.
- Move
.sow/<repo>/retained/<GENERATION>to a backup location outside the workspace. - Run
sow checkagain.
Moving the record also removes its protection against GC.
Exit behavior
| Code | Trigger |
|---|---|
0 |
Operation completed, including an empty list or a no-op |
1 |
Filesystem or runtime I/O failure |
2 |
Invalid Generation syntax, discovery error, or implicit repository selection is ambiguous |
4 |
Write lock unavailable for add or rm |
5 |
Generation manifest or repository state is inconsistent |
6 |
Explicit repository is not configured, retain add does not name the current Generation, or another safety rule rejects the request |
See also
sow gc— reclaim packages that no retained Generation needssow changes— compare a Generation with an earlier one- Repository Layout — where retained records live