sow log
SOW records each repository write, such as add, rm, build, dist new, dist rm, local gc,
or log prune, as an operation in the repository’s state database: what was asked for, each state
it passed through, and the files it changed. sow log reads those records. Use it to
find out what changed and when, why a command failed, or how far a long build has got. log export
archives completed records as JSONL, and log prune removes old ones from the database.
Synopsis
| Flag | Commands | Meaning | Default |
|---|---|---|---|
-C, --workdir DIR |
all | Workspace discovery start directory | current directory |
-r, --repo NAME |
all | Select a repository | selection rules |
-d, --dist NAME |
log, log export |
Only operations that touched this one Dist | all |
-T, --timeout DUR |
log prune |
Maximum lock wait; 0 waits indefinitely |
0 |
-N, --no-wait |
log prune |
Fail immediately when the lock is held | false |
--passfile PATH |
log prune |
Signing password file, needed only if SOW must first recover an interrupted operation (Password files) | — |
--json |
log, log prune |
Output JSON | false |
log export writes JSONL directly and has no --json. log prune applies to the whole repository
and rejects -d.
sow log
With no argument, sow log lists the 50 most recent operations, newest first:
With --json, each entry in result.operations carries the request and the outcome:
payload_json records the intent, including config_sha256, the digest of the configuration in
force, and manifest_sha256 of the resulting Generation. Operations that build metadata also record
publication_time, a whole-second UTC timestamp that recovery reuses for metadata and signatures;
older journals and layout migrations can lack it. result_json records the outcome. A failed
operation also carries error_class and error_message:
Publication, target GC, and retain keep their own records and do not appear here. Neither do the
workspace operations init, repo new, and repo rm, which use separate recovery records.
One operation in detail
Pass an operation ID for its summary:
Add --json to read the state transitions, timing, packages, memberships, and files under
result.detail. An excerpt:
The files array uses the same phase values as sow changes:
payload, metadata, pointer, delete.
A build also appends progress events. They keep the current state and put a versioned object in
detail_json, so you can follow a long build:
The phases are rendering, promoting_payload, publishing_dists, normalizing_public_tree, and
finalizing.
Filtering by Dist
-d keeps only operations that touched one Dist, which helps when a repository serves several
distributions. It takes a single Dist; two different -d values exit 6.
Operation lifecycle
The state field shows how far an operation got:
| State | Meaning |
|---|---|
planned |
Command, arguments, targets, and intended actions are durably recorded |
staged |
New packages and metadata are written to temporary locations and verified |
applied |
Desired state and the private pending payloads it needs are committed |
built |
The complete static Generation has been switched in |
done |
Terminal: the command succeeded |
done_dirty |
Terminal: the command succeeded, but changes still need a build, usually after --skip |
failed |
Terminal: the operation failed before applied, so nothing was committed |
rolled_back |
Terminal: recovery abandoned the operation before it changed desired state, for example a planned operation left by an interrupted command |
recovering |
Not terminal: the next write command must complete or roll it back |
sow log export
log export writes terminal operations as JSONL, one complete operation detail record per line, for
archiving or for a log pipeline:
Omit FILE, or pass -, to write to stdout:
Output path
Give a new filename in an existing directory. log export never overwrites: an existing file exits
6, and a missing parent directory exits 1. A symlinked parent directory, such as /tmp on macOS,
is resolved to its physical directory before the file is created atomically and the directory synced.
sow log prune
log prune deletes eligible completed operation records older than BEFORE and reclaims the
database space. It records its own log.prune operation.
The text output shows the cutoff in UTC (this example ran at UTC+8) and the number of deleted
records as operations; --json reports it as pruned. The operation ID appears both at the
top level of the JSON envelope and in result.operation.
If another reader is using the database, the records are still deleted but space reclamation waits.
The text output then adds log deletion committed; space reclamation deferred while the database is busy, and --json sets compaction_deferred: true in result. Close the reader and run prune
again to reclaim the space.
BEFORE syntax
BEFORE is an ISO 8601 date YYYY-MM-DD, read as local midnight, or an RFC 3339 timestamp with a
time zone. Anything else is a usage error:
Records kept by prune
prune never deletes:
- an operation that is not terminal;
- a record still needed for recovery;
- a record that current package or membership state depends on;
- a Generation or its changeset.
Examples
Show the most recent write:
Find failed operations among the 50 most recent:
Archive records, then remove those older than a chosen date:
Find the operation that last touched a Dist:
Exit codes
| Command | Code | Trigger |
|---|---|---|
log |
0 |
Records printed, including an empty log |
log |
2 |
Usage error (including a non-numeric operation ID), workspace not found, or ambiguous selection |
log |
5 |
State database unreadable |
log |
6 |
The given operation ID does not exist, or two different -d values were given |
log export |
0 |
Export written |
log export |
1 |
I/O failure writing or syncing the file, or the parent directory does not exist |
log export |
2 |
Usage error or ambiguous selection |
log export |
6 |
The file already exists |
log prune |
0 |
Prune completed, including pruning nothing |
log prune |
2 |
Malformed BEFORE, -d given, or ambiguous selection |
log prune |
4 |
Repository lock held and --no-wait given or --timeout expired |
log prune |
5 |
Integrity or recovery error |
See also
- Observability & Audit — how
logfits withstatus,check, andchanges - Transactions & Recovery — the journal behind these records
sow changes— compare files between builds- JSON Output — the full log result schema