JSON Schemas¶
torcul publishes JSON Schema Draft 2020-12
contracts for four JSON documents: job requests (torcul/job-request/1), job
state records (torcul/job/1), staging sidecars (torcul/staging-record/1)
and plan reports (torcul/plan-report). The --meta fixture metadata manifest
that torcul plan and torcul remux read has no published schema. All four
schema files live under schemas/ and are generated from the Rust types
through schemars. Metadata loader ·
Schema subcommand · Schema tests
Regenerate and check schemas¶
From the repository root, run the schema subcommand to write all four schema
files atomically into schemas/:
Sample version 1 documents live in
schemas/examples/job-request-1.json and
schemas/examples/job-1.json. The integration suite checks that
checked-in schemas match generator output byte for byte, conform to the Draft
2020-12 meta-schema, and accept or reject positive, negative and boundary
documents across both JSON Schema and serde. Schema tests ·
CI drift step
Published schema files¶
| File | Schema title |
Rust root type | Writer and role |
|---|---|---|---|
schemas/job-request-1.schema.json |
torcul/job-request/1 |
torcul_job::JobRequest |
Written by an external caller (such as SnatchArr) to trigger a plan, stage or apply job (ADR-0002, decision 9) |
schemas/job-1.schema.json |
torcul/job/1 |
torcul_job::Job |
Written by the planned torcul job runner at <staging_root>/<id>/job.json to record state transitions, fingerprints, plan and verification verdict (ADR-0002, decision 12) |
schemas/staging-record-1.schema.json |
torcul/staging-record/1 |
Record |
Written by torcul remux and updated by torcul verify at <output>.torcul.json (Track-policy CLI · CLI tests) |
schemas/plan-report.schema.json |
torcul/plan-report |
Vec<FileReport> |
Written by torcul plan --json <path> only when every file plans: each entry holds a plan and error: null; any planning error stops the command before the write (Track-policy CLI · CLI tests) |
Versioning and compatibility rules¶
- Unknown versions are refused.
job-request-1.schema.jsonrequiresschema: "torcul/job-request/1"andjob-1.schema.jsonrequiresschema: "torcul/job/1";serdedeserialization and JSON Schema validation both reject any other identifier.staging-record-1.schema.jsonsetsconst: 1onversion, andtorcul verifyrejects other numbers with"unsupported sidecar version". Job types · Sidecar loader · Schema tests - Requests reject unknown fields.
JobRequest,Rule,TrackRuleandRequestTitlecarry#[serde(deny_unknown_fields)](additionalProperties: falsein JSON Schema), so misspelled or unsupported request keys fail before media files are touched.rollback_daysis optional in the request and defaults to7(0..=65535). Job types · ADR-0002, decision 9 - Version 1 records grow only by optional fields.
Jobomitsdeny_unknown_fieldssotorcul/job/1can gain optional fields without breaking readers.Jobembeds the request types (JobRequest,Rule,TrackRuleandRequestTitle), which refuse unknown keys (additionalProperties: false), so a new request field is a new request version and a new job version together (torcul/job-request/2andtorcul/job/2); fields outsiderequestcan still be added withintorcul/job/1. Any incompatible change to field types, meanings or required keys increments the trailing version number. Job types · ADR-0002, decision 9 - Scalar, set and format invariants match across the schema and
serde.Fingerprint.sha256matches^sha256:[0-9a-f]{64}$,PacketProof.sha256matches^[0-9a-f]{64}$,Job.idmatches^[0-9a-f]{32}$, andTransition.atmatches the RFC 3339 UTC timestamp shape;serderefuses the same malformed strings, duplicate items inTrackRule.languagesandTrackInfo.dispositions(uniqueItems: true), and emptyTrackRule.languagesorJob.historylists (minItems: 1). Everyu8,u16,u32,u64andusizefield carries its exactmaximum(Fingerprint.mtime_nsisu64), and only standard Draft 2020-12formatvalues appear (date-time), so strict validators that reject unknown formats accept all four files. Pattern checks · Media I/O · Media model · Unique sets · Job types · Schema generator · Schema tests - Timestamps are checked without format validation.
Transition.atmatches an RFC 3339 UTC pattern (2026-11-26T17:00:07Z, optional fractional seconds), soserdeand any Draft 2020-12 validator refuse a malformed shape. The pattern checks the shape only; enable format validation (in thejsonschemacrate,should_validate_formats(true)) to also refuse impossible dates such as month 13 throughformat: "date-time". Job types · Schema tests - State-dependent fields are enforced from one table. Both
job-1.schema.json(allOf) andJobdeserialization readSTATE_RULESso every state below requires its non-null fields (Job types · Schema tests):
Job.state |
Required non-null fields | ADR-0002 decision |
|---|---|---|
verified, applying, applied, rolling_back, held |
staged_fingerprint |
Decision 13 (apply compares the staged file with the verdict's fingerprint) and decision 12 (applied-index entry liveness reads it) |
applying, applied, rolling_back |
source_fingerprint |
Decision 15 (restart inodes) and decision 14 (rollback step 1 checks the rollback copy) |
applied, rolling_back |
applied_fingerprint |
Decision 14 (rollback steps 1 and 4) |
rolling_back |
rollback_path |
Decision 14 (step 2 records the library path) |
held |
held |
Decision 15 (records held with the inodes found) |
failed |
failure |
Decision 14 (a refusal records failed) |
- Every plan-report entry holds a plan. Every entry holds a non-null
plananderror: null, and both keys are always present (torcul plan --jsonbails before writing if any file fails planning). CLI entrypoint · Plan report · Schema tests
Drift checks¶
Never edit schemas/*.schema.json by hand. Update the Rust type or its
#[schemars(...)] attribute, then run
cargo run -p torcul-cli -- schema --out schemas. Both the local
generated_schemas_match_checked_in_files test and the Check JSON Schema
drift step in CI fail if any schema file is stale or untracked.
Schema generator · Schema tests · CI drift step