JSON Output
With --json, a SOW command writes one versioned JSON document instead of human-readable
text, so a script gets stable field names rather than parsing log lines. Look here for
the envelope every response shares, how errors and IDs are typed, and the result fields
of each command.
The document is a single newline-terminated line on stdout; diagnostics go to stderr.
Successful create and prune runs put their warnings and skipped entries inside
the JSON result and leave stderr empty. log export is the exception: it writes JSON
Lines and does not accept --json.
Envelope
Every JSON response has these seven fields:
| Field | Type | Meaning |
|---|---|---|
schema |
string | sow.cli/v1 |
command |
string | Command name including any subcommand, such as repo ls |
ok |
boolean | true on success; false when errors is not empty |
repository |
string or null | The selected repository, when the response is tied to one |
operation |
string or null | Operation or publication attempt ID, per command (see below) |
result |
object or null | Command data, including partial or diagnostic results on failure |
errors |
array | Error objects with code, class, and message |
A successful configuration check, shown here on several lines:
A command that fails before doing meaningful work usually returns result: null. Some
failures still return a useful result: a failed check, a partially successful add,
or a maintenance error after a database commit, which reports what did commit. Keep the
result when ok is false, and read it together with status and the operation log
before retrying; a nonzero exit does not mean the transaction rolled back.
Errors
Branch on code or class, never on message text. The classes are runtime, usage,
discovery, config, partial, lock, integrity, rejected, and interrupted;
Exit codes maps them to exit codes and next steps.
Identities
Treat operation and Generation IDs as strings. Operation IDs can exceed the range of integers that JavaScript represents exactly. Generation IDs are 20-digit, zero-padded decimal strings, so they also sort correctly as text:
This applies to generation, built_generation, base_generation, and base when it
names a Generation. Desired-state revisions and counts are JSON numbers.
The top-level operation field holds:
| Command | Value |
|---|---|
add, rm without preview, build, local gc, log prune |
Journal ID, if one was allocated |
publish, publish --abort |
Publication attempt ID, if available |
log ID |
The requested operation ID |
Other commands (create, prune, init, config, ls, show, where, retain, export) |
null |
A null operation does not mean the command is read-only. The top-level repository is
null for create, prune, init, config check, and repo ls. where sets it when
-r/--repo is given and leaves it null when searching every repository; each entry
in result.locations names its own repository either way.
Simple repositories: create and prune
sow create returns:
| Result field | Meaning |
|---|---|
dir |
Absolute path of the indexed directory |
rpm, deb |
Retained RPM and DEB file counts from this scan. Identical copies count separately and share one index entry |
kept |
Sorted file names retained by this scan |
removed |
Files removed by --pigsty |
skipped |
{path, reason} objects for packages skipped in the default fault-tolerant mode, when present |
warnings |
Warning strings from scanning or publication, when present |
marker |
Whether the completion marker was produced |
marker_sha256 |
Marker digest, present with the marker |
noop |
No public file needed to change |
recovered |
Always false; a simple repository has no journal to recover |
signed, signer |
Signed file names and signer identity, when available |
dropped_metadata |
Unsupported repomd.xml data types (such as group, updateinfo, or modules) that create replaced, when present |
sow prune returns:
| Result field | Meaning |
|---|---|
dir |
Target directory path |
dry_run |
Whether --dry-run was set |
kept |
Sorted file names of the top-level RPMs kept |
candidates |
{path, latest} objects: each removal candidate and the RPM that replaces it |
removed |
File names of removed RPMs |
skipped |
{path, reason} objects for RPMs skipped in the default fault-tolerant mode, when present |
warnings |
Warning strings, such as corrupt packages, equal-version conflicts, or unmatched --protect names, when present |
index_updated |
Whether repodata/ was rewritten |
marker |
Whether repo_complete exists after completion |
noop |
Whether a live run made no changes. A preview checks removal candidates and any pending completion marker. It does not predict an index rewrite |
Initialization and configuration
| Command | Result |
|---|---|
init |
workspace, config_created, repositories_initialized, dists_initialized, existing |
config check |
workspace, repositories, dists |
config show |
The effective configuration: schema, architectures, repos, and targets when present |
Resolved signing settings can include public key fingerprints and certificate snapshot hashes. The fingerprint and hash arrays are sorted independently; do not pair them by index. See Check signing settings.
Repositories and Dists
repo ls returns result.repositories[]; repo new and repo show return one
repository object directly. Its fields are name, path, protected, dists,
generation, desired_revision, status, packages, memberships, and config, plus
dirty_reasons and recent_operation when available. packages counts stored package
objects and memberships counts desired Dist memberships, so one object in two Dists
counts as one package and two memberships.
An operation summary has id, kind, state, created_at, and updated_at, plus an
optional error_class. status.pending_operation and status.recent_operation use the
same shape.
dist ls returns result.dists[]; dist new and dist show return one Dist object with
name, format, architectures, desired_members, built_members, generation,
dirty, status, effective_config_sha256, config, and an optional dirty_reasons.
Each architecture entry has family and ecosystem_arch; a DEB view of family x86_64
has the ecosystem name amd64, for example.
repo rm and dist rm return name, removed, and noop.
repo migrate returns repository, repository_id, from_layout, to_layout,
schema_from, schema_to, phase, generation, grace_not_before (null when no grace
deadline applies), legacy_aliases, complete, and an optional warnings. Warnings from
an aborted migration name retained temporary stages or incomplete cleanup. Once the
repository is selected, a failed migration still reports it in the response. See
repo migrate for the phases.
add, rm, and build
All three report the repository state after the operation: repository,
desired_revision, built_generation, and dirty.
add also returns operation, accepted, failed, memberships_added,
memberships_removed, and items[]. Each item has input and status, plus format,
coordinate, sha256, a per-Dist dists map, and error when those are known.
| Item status | Meaning |
|---|---|
accepted |
A new package entered membership |
reused |
An existing package object was reused; membership can still change |
excluded |
Policy kept the package out of every selected Dist |
failed |
The input failed; read error |
Each entry of the dists map is accepted, excluded, or limited, so one package can
have different outcomes in different Dists. memberships_removed grows when limit
pushes older versions out.
rm returns an optional operation, removed[], the selected dists, changes[], and
check. Each removed record has dist, sha256, coordinate, and name. A preview
has check: true, and only prediction_complete: true means its predicted file list is
complete. rm never deletes pool bytes.
build returns operation, the Dists it considered in dists, and noop. A no-op build
creates no Generation.
status and check
status returns status, ready_to_copy, desired_revision, built_generation,
dirty_dists, dirty_reasons, pending, and repository_locked, plus
pending_operation, recent_operation, and lock_holder when they apply. status is
clean, dirty, recovering, or error, and pending holds count and bytes. A
successful query can report any of those states: ok: true means the query worked, not
that the repository is healthy. Run check before publishing or copying.
check returns repository, status, ready_to_copy, built_generation,
desired_revision, and layers[]. Each layer has name, ok, checked, and issues.
The normal layers, in order, are config, state, public-modes, retained,
package-bytes, desired-membership, index, signature, and generation-manifest.
During an active layout transition, the first three are followed by layout-transition
instead. A repository-wide check can pass every consistency layer and still exit 5 when desired changes need building. With -d, status and check report ready_to_copy for the selected Dists. Omit -d to gate delivery of the entire repository.
changes
The result has repository, base, generation, dirty, and changes[]. Each change
contains:
| Field | Values |
|---|---|
op |
add, update, delete |
phase |
payload, metadata, pointer, delete |
path |
Slash-separated path relative to the repository root |
size, sha256 |
Present for added and updated files; omitted for deletions |
changes first runs the same verification as check. It works on a dirty repository,
but exits 5 while an operation is pending or the repository is recovering or fails
verification.
Without a base, the comparison is against the previous built Generation. Base 0 lists
the complete current tree, and a numbered base compares that recorded Generation with
the current one. These are local file differences; remote changes are the business of
publish and target gc.
Package queries
| Command | Result fields |
|---|---|
ls |
repository, selected dists, dirty, packages[] |
show |
repository, package |
where |
reference, locations[] |
A package object has sha256, format, coordinate, architecture, canonical_arch,
pool_path, filename, size, name, source, version, kind, storage,
created_revision, dists, and built_dists, plus optional epoch, release, RPM
payload_sha256 and signature_key, and warning.
architectureis the package’s own name (noarch,amd64, and so on);canonical_archisx86_64,aarch64, orneutral.storageispoolorpending. It describes the local workspace, not remote publication.distsis the desired membership;built_distsis the membership of the last build.- A package object’s
coordinatehas no format prefix: prependformatand:to get a CLI reference. Coordinates inwherelocations already include it.
Each where location has repository, dists, built_dists, sha256, and
coordinate.
Publication and maintenance
| Command | Main result fields |
|---|---|
publish |
repository, target, provider, generation, optional attempt/checkpoint, phase, objects, noop |
publish --abort |
repository, target, provider, attempt, phase, objects |
retain add/rm |
repository, record, record_identity, path |
retain ls |
repository, generations[] |
Local gc |
Optional operation, repository, base_generation, generation, objects, bytes, noop |
Target gc |
repository, target, provider, phase, reports, candidates, deleted_objects, deleted_bytes, retained_objects, pending_grace, completed_attempts, noop |
export rpm-leaf |
repository, repository_id, generation, dist, arch, directory, method, signed, signer_identity, packages, files, manifest_sha256 |
publish --rebind returns the normal publish shape. For R2, the default target GC
report and gc TARGET --delete share the target GC fields; the latter records verified
removals in deleted_objects and deleted_bytes.
Operation logs
log returns repository and operations[], newest first. log ID returns
repository and detail, which holds operation, duration_ms, events, packages,
memberships, and files:
| Detail array | Record fields |
|---|---|
events |
sequence, state, detail_json, occurred_at |
packages |
sequence, input_path, disposition; optional package_sha256, coordinate, error_class, message, dists |
memberships |
sequence, dist, package_sha256, action |
files |
sequence, action, phase, path; optional size, sha256 |
payload_json, result_json, and event detail_json are strings that contain JSON, so
decode them separately. Operations that build metadata record publication_time in
payload_json; layout migrations and journals written without a recorded time omit it.
log prune returns operation, repository, before, pruned, and
compaction_deferred. A date-only argument is resolved in the machine’s local time zone,
and before holds the resolved timestamp.
log export writes one complete operation record per line, without the envelope:
The output file must not exist yet. A symlinked parent directory, such as /tmp on
macOS, is resolved to its physical path before the file is created atomically and the
directory is synced.
Use a validation result in a script
The script fails unless the local repository passes check, then prints its current file
manifest. To publish it, run sow publish TARGET for a configured target.