Skip to content

sow log

Read the record of every repository write, archive it as JSONL, and prune old entries.

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

sow log [OPERATION] [-C|--workdir DIR] [-r|--repo NAME] [-d|--dist NAME] [--json]
sow log export [FILE] [-C|--workdir DIR] [-r|--repo NAME] [-d|--dist NAME]
sow log prune BEFORE [-C|--workdir DIR] [-r|--repo NAME] [-T|--timeout DUR | -N|--no-wait] [--json] [--passfile PATH]
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:

sow log
repository=demo operations=8
ID	KIND	STATE	CREATED	UPDATED
8814556690812580691	build	done	2026-11-27T08:38:00Z	2026-11-27T08:38:00Z
6831294293867956892	add	done_dirty	2026-11-27T08:37:53Z	2026-11-27T08:37:53Z
9208934936037009093	local.gc	done	2026-11-27T08:37:40Z	2026-11-27T08:37:40Z
4595017550548091657	add	done	2026-11-27T08:37:39Z	2026-11-27T08:37:40Z
8495969916600415110	rm	done	2026-11-27T08:37:32Z	2026-11-27T08:37:32Z
1171187774051474049	add	done	2026-11-27T08:37:31Z	2026-11-27T08:37:31Z
3035844290701018943	add	done	2026-11-27T08:37:29Z	2026-11-27T08:37:30Z
3830047518535999110	dist.new	done	2026-11-27T08:37:29Z	2026-11-27T08:37:29Z

With --json, each entry in result.operations carries the request and the outcome:

{
  "id": "4262183287563704350",
  "kind": "build",
  "state": "done",
  "payload_json": "{\"version\":2,\"repository\":\"pigsty\",\"kind\":\"build\",\"config_sha256\":\"37eb6dcf...\",\"skip\":false,\"dists\":[\"el9\"],\"build_dists\":[\"el9\"],\"manifest_sha256\":\"678beeae...\"}",
  "result_json": "{\"dists\":1,\"dropped_pending\":[]}",
  "created_at": "2026-08-04T04:07:40.334787Z",
  "updated_at": "2026-08-04T04:07:40.907125Z"
}

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:

{
  "id": "5995346754219751025",
  "kind": "add",
  "state": "failed",
  "result_json": "{\"accepted\":0,\"failed\":1}",
  "error_class": "rejected",
  "error_message": "no input package was accepted"
}

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:

sow log 8814556690812580691
operation=8814556690812580691 repository=demo kind=build state=done duration_ms=452 created=2026-11-27T08:38:00.520714000Z updated=2026-11-27T08:38:00.972937000Z
events=15 packages=0 memberships=0 files=12

Add --json to read the state transitions, timing, packages, memberships, and files under result.detail. An excerpt:

{
  "duration_ms": 572,
  "events": [
    {"sequence": 0, "state": "planned",  "occurred_at": "2026-08-04T04:07:40.334787Z"},
    {"sequence": 1, "state": "staged",   "occurred_at": "2026-08-04T04:07:40.380963Z"},
    {"sequence": 2, "state": "applied",  "occurred_at": "2026-08-04T04:07:40.386186Z"},
    {"sequence": 3, "state": "built",    "occurred_at": "2026-08-04T04:07:40.904730Z"},
    {"sequence": 4, "state": "done",     "occurred_at": "2026-08-04T04:07:40.907125Z"}
  ],
  "packages": [],
  "memberships": [],
  "files": [
    {"sequence": 0, "action": "update", "phase": "pointer", "path": "dists/el9/aarch64/repodata/repomd.xml", "size": 1511, "sha256": "ef071821e06c9e86ab4f6d2a56906d82bb66df251e79d1086cfd44dc8395513e"},
    {"sequence": 1, "action": "update", "phase": "pointer", "path": "dists/el9/x86_64/repodata/repomd.xml",  "size": 1514, "sha256": "a31e90ec39169f0373b108458908333c96c5f600f3c63a50c44257856f0d2d55"}
  ]
}

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:

{
  "state": "applied",
  "detail_json": "{\"version\":1,\"kind\":\"build_progress\",\"phase\":\"rendering\",\"completed\":1,\"total\":2,\"jobs\":8}"
}

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.

sow log -d trixie -r pigsty

Operation lifecycle

The state field shows how far an operation got:

planned → staged → applied → built → done
                        └────────→ done_dirty
   any nonterminal → recovering → built / done / done_dirty / rolled_back / failed
   pre-apply error  → failed
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:

sow log export /srv/audit/pigsty-ops.jsonl -r pigsty
exported 12 operations to /srv/audit/pigsty-ops.jsonl

Omit FILE, or pass -, to write to stdout:

sow log export - -r pigsty | gzip > pigsty-ops-$(date +%F).jsonl.gz

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.

sow log prune 2027-01-01 -r pigsty
pruned log repository=pigsty operation=8150803833883584722 before=2026-12-31T16:00:00.000000000Z operations=1

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:

sow log prune yesterday -r pigsty
usage error: BEFORE must be YYYY-MM-DD or an RFC 3339 timestamp with timezone

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:

sow log -r pgsql --json | jq -r '.result.operations[0] | "\(.id)\t\(.kind)\t\(.state)"'

Find failed operations among the 50 most recent:

sow log -r pgsql --json | jq -r '.result.operations[] | select(.state=="failed") | "\(.id)\t\(.error_class)\t\(.error_message)"'

Archive records, then remove those older than a chosen date:

sow log export /srv/audit/pgsql-$(date +%Y%m).jsonl -r pgsql
sow log prune 2026-05-01 -r pgsql

Find the operation that last touched a Dist:

sow log -d el9 -r pgsql --json | jq -r '.result.operations[0].id'

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

Table reader