JSON schema¶
The JSON schema defines the nested structure of a QECX file: required and optional keys (also called fields), the type and accepted set of values for each key, etc., in accordance with the format specification. This page should be used as a reference when unsure which keys and values to use. The more complex cross-field rules that a schema cannot express are only defined in the format specification.
Note
Download the raw schema: qecx_v0.1.schema.json.
Top-Level Structure¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Format version in |
|
Yes |
Algebraic definition of the QEC code. |
|
|
Yes |
Declarative register layout for circuit operations. |
|
|
Yes |
Circuit implementations for all operation types. |
|
|
Yes |
EC cycle composition from syndrome measurement variants. |
|
|
No |
Optional syndrome-decoder capability declaration and per-detector metadata. |
|
|
No |
Optional spatial geometry and structural metadata. |
|
|
No |
Optional metadata and provenance. |
1. Code Section¶
Definition: $defs/code_section
Describes the algebraic structure of the quantum error correcting code.
Always-Required Fields¶
Field |
Type |
Constraints |
Description |
|---|---|---|---|
|
|
Enum: |
Determines which additional fields are required. |
|
|
>= 1 |
Number of physical qubits. |
|
|
>= 1 |
Number of logical qubits. |
|
— |
Code distance (symmetric or asymmetric). |
|
|
— |
Representative logical X and Z operators. |
Conditional Requirements by code_type¶
|
Additional required fields |
|---|---|
|
|
|
|
|
|
|
|
Optional Fields (all code types)¶
Field |
Type |
Description |
|---|---|---|
|
|
Human-readable code name. |
|
X-type parity check matrix. |
|
|
Z-type parity check matrix. |
|
|
Stabilizer generators as Pauli strings. |
|
|
Gauge generators (subsystem codes). |
|
|
X-type gauge generator matrix. |
|
|
Z-type gauge generator matrix. |
Extra keys are allowed (additionalProperties: true).
2. Register Template Section¶
Definition: $defs/register_template_section
Declares the register layout used by circuit operations. Two scopes exist:
registers shared across the entire circuit (global) and registers
instantiated per code block (per_code_block).
additionalProperties: false: no extra keys allowed.
Fields¶
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object |
No |
Shared registers (see below). |
|
object |
Yes |
Per-block registers (see below). |
global¶
additionalProperties: false
Field |
Type |
Required |
|---|---|---|
|
No |
|
|
No |
per_code_block¶
additionalProperties: false
Field |
Type |
Required |
|---|---|---|
|
Yes |
|
|
No |
|
|
No |
3. Operations Section¶
Definition: $defs/operations_section
Contains circuit implementations for every operation type the format
supports. Extra operation keys are allowed (additionalProperties: true).
Required Operations¶
Field |
Type |
Description |
|---|---|---|
|
keyed default/variants container (state_preparation) |
Logical state initialization circuits, keyed by target logical state. |
|
flat default/variants container (syndrome_measurement) |
Syndrome extraction circuits. |
|
logical-addressing (generic) |
Logical gate circuits. |
|
keyed default/variants container (data_measurement) |
Data measurement circuits, keyed by measurement basis. |
Optional Operations¶
Field |
Type |
Description |
|---|---|---|
|
logical-addressing (logical_measurement) |
Non-destructive logical measurement circuits. |
|
keyed default/variants container (reset) |
Qubit reset circuits, keyed by target logical state. |
Flat Default/Variants Containers¶
syndrome_measurement uses a flat default/variants container:
{
"default": "<variant-name>", // string, required
"variants": { // object, required, minProperties: 1
"<variant-name>": { ... } // typed variant object
}
}
additionalProperties: false: only default and variants are allowed.
Each operation type uses a specialised variant schema (see Variant Types below).
Keyed Default/Variants Containers¶
state_preparation, reset, and data_measurement use a keyed
default/variants container. The operation’s top level is a map from an
outer key (target logical state or measurement basis) to an inner flat
default/variants container:
{
"<outer-key>": {
"default": "<variant-name>",
"variants": {
"<variant-name>": { ... }
}
}
}
Outer-key string types:
Definition |
Pattern / enum |
Used by |
|---|---|---|
|
|
|
|
enum |
|
state_key_string is a character-class check. For k=1 codes the valid
single-character keys are "0", "1", "+", "-", "i", "j"
(mapping to |0⟩, |1⟩, |+⟩, |-⟩, |+i⟩, |-i⟩).
basis_key_string is a direct enum; the format restricts to a single Pauli
character applied uniformly across the block.
The inner container is the same shape as the flat default/variants container.
Logical-Addressing (logical_gates and logical_measurement)¶
Logical-addressing operations use a different structure: a mapping from gate/observable name to an array of operand groups (at least 1 entry).
logical_gates:
"<gate-name>": [ operand_group, operand_group, ... ]
logical_measurement:
"<observable-pauli>": [ operand_group_logical_measurement, ... ]
See Operand Groups for the operand group schema.
4. Properties Section¶
Definition: $defs/properties_section
Optional metadata and provenance. All fields are optional.
Extra keys are allowed (additionalProperties: true).
Field |
Type |
Notes |
|---|---|---|
|
|
|
|
|
Singular or list. |
|
|
Tool/software that generated the file. |
|
|
|
|
|
No format constraint (e.g. ISO 8601 not enforced). |
|
|
Bibliographic references. |
|
|
reference_entry¶
Definition: $defs/reference_entry. additionalProperties: false.
Field |
Type |
Required |
Constraints |
Description |
|---|---|---|---|---|
|
|
Yes |
Pattern |
Stable citation key; must be unique within the file. |
|
|
No |
— |
Paper / resource title. |
|
|
No |
— |
DOI without URL prefix. |
|
|
No |
— |
arXiv identifier. |
|
|
No |
|
Fallback URL when no DOI / arXiv. |
|
|
No |
— |
Short human-readable role note. |
|
|
No |
— |
Verbatim author list, rendered as-is. |
|
|
No |
— |
Publication year. |
At least one of doi, arxiv, or url must be present on each entry
(anyOf of required).
5. Qubit Layout Section¶
Definition: $defs/qubit_layout_section
Optional spatial geometry for codes with geometric structure.
All fields are optional.
Extra keys are allowed (additionalProperties: true).
Field |
Type |
Constraints |
Description |
|---|---|---|---|
|
|
— |
Tiling/tessellation type (e.g. |
|
|
— |
Manifold topology (e.g. |
|
cell_complex or |
— |
Combinatorial cell complex structure. |
|
— |
Geometric embedding of the cell complex. |
|
|
object |
— |
Maps registers to cell complex elements or provides explicit coordinates. |
cell_complex¶
Definition: $defs/cell_complex. additionalProperties: false.
Field |
Type |
Required |
Constraints |
Description |
|---|---|---|---|---|
|
|
Yes |
>= 1 |
Total number of vertices (0-cells). |
|
array of |
Yes |
Each index >= 0 |
Vertex index pairs (1-cells). |
|
array of objects |
No |
Each face: |
Face definitions (2-cells). |
Each face object (additionalProperties: false):
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
array of |
Yes |
minItems: 3, each >= 0 |
|
|
No |
>= 0 |
embedding¶
Definition: $defs/embedding. additionalProperties: false.
Field |
Type |
Required |
Constraints |
Description |
|---|---|---|---|---|
|
|
Yes |
>= 1 |
Embedding space dimension. |
|
|
Yes |
— |
E.g. |
|
array of arrays of |
Yes |
— |
One coordinate tuple per vertex. |
qubit_placement¶
Map from register name (string key) to one of:
Cell-placed ($defs/qubit_placement_cell, additionalProperties: false):
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
Enum: |
|
array of |
Yes |
Each >= 0 |
Explicit coordinates ($defs/qubit_placement_coordinates, additionalProperties: false):
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
array of arrays of |
Yes |
— |
6. Error Correction Cycle Section¶
Definition: $defs/error_correction_cycle_section. additionalProperties: false.
Defines how syndrome measurement variants compose into complete error correction cycles.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Name of the default cycle variant. |
|
object of ec_cycle_variant |
Yes |
At least one named variant ( |
EC Cycle Variant¶
Definition: $defs/ec_cycle_variant. additionalProperties: false.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
No |
Human-readable description. |
|
|
No |
Whether cycle provides FT guarantees. |
|
array of ec_cycle_step |
Yes |
Ordered measurement steps (minItems: 1). |
|
No |
Repeat entire step sequence (default: 1). |
|
|
array of |
No |
Citation keys resolving to entries in |
EC Cycle Step¶
Definition: $defs/ec_cycle_step. additionalProperties: false.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Name of a |
|
No |
Repeat this step (default: 1). |
integer_or_ref¶
Definition: $defs/integer_or_ref.
oneOf: integer (>= 1) or parametric_ref.
Parametric Ref¶
Definition: $defs/parametric_ref. additionalProperties: false.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Dot-notation path resolving to a field in the document (e.g. |
The same object is reused wherever a value may be a reference. The resolved
value is not restricted to integers by parametric_ref itself: the >= 1
integer constraint belongs to integer_or_ref (used by
repeat), while decoder_config reuses
parametric_ref for non-integer, optionally projected (*) references. The
schema constrains only the object shape (ref string key); resolution
semantics are handled by the loader/validator.
7. Decoder Config Section¶
Definition: $defs/decoder_config_section
Optional top-level section declaring which syndrome decoders the code
implementation supports and, for each, the per-detector metadata that decoder
needs. The section maps a decoder slug (a short decoder name, string key) to
a config body. Slug presence is itself the capability declaration: a slug with
an empty body declares support with no extra metadata; an omitted
decoder_config declares no decoders. An empty decoder_config ({}) is
valid. Semantic validity (anchor names, list lengths, cross-section references,
ref resolution) is delegated to the validator.
additionalProperties: { $ref: decoder_entry }: every key is a decoder slug
whose value is a decoder_entry. No fixed property names.
Decoder Entry¶
Definition: $defs/decoder_entry. additionalProperties: { $ref: decoder_tag_anchor_map }.
One decoder slug’s config body: an optional reserved parameters object plus
any number of per-detector tags.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
object |
No |
Reserved key: free map of global, non-per-detector settings for this decoder. Opaque to the generic layer; interpreted by the decoder. |
(tag) |
No |
A per-detector tag (e.g. |
Any key other than parameters is a per-detector tag (the schema admits any
tag name; additionalProperties resolves to decoder_tag_anchor_map).
Decoder Tag Anchor Map¶
Definition: $defs/decoder_tag_anchor_map. additionalProperties: { $ref: decoder_anchor_value }.
A single per-detector tag’s assignment. Keys are either a syndrome source
name (matching the source of a syndrome classical register, e.g. H_X,
H_Z, stabilizer_generators) or the reserved syndrome_measurement
override key.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
No |
Reserved key: per-register override keyed by variant then classical register. |
|
(source name) |
No |
A syndrome source field name; value is a list (one entry per syndrome operator of that source) or a whole-value parametric ref. |
Any key other than syndrome_measurement is a source name
(additionalProperties resolves to decoder_anchor_value).
Decoder Anchor Value¶
Definition: $defs/decoder_anchor_value. oneOf:
A parametric_ref (whole-value reference resolving to such a list).
Decoder Value List¶
Definition: $defs/decoder_value_list.
An array (items: {}, any type) with one entry per syndrome operator (or per
register bit, when used inside a syndrome_measurement override). Each entry is
one per-detector tag value: a primitive (integer, string, boolean), a structured
value (such as a vector or map), or a parametric ref resolving element-wise. The
entry type is decoder-defined; the schema does not constrain it (the
decoder-specific validator checks it).
Decoder Syndrome Override¶
Definition: $defs/decoder_syndrome_override.
A per-register override nested two levels: variant name maps to an object keyed by classical register name, whose value is a per-register-bit value list or a whole-value ref.
additionalProperties (outer): an object whose additionalProperties is
decoder_anchor_value. That is: variant -> classical register -> decoder_anchor_value. No fixed property
names at either level.
Decoder Config Parametric References¶
The decoder-config value entries and whole-value entries reuse
parametric_ref (the same {"ref": "<dot.path>"} object as
error_correction_cycle.repeat), but generalize it: a referenced value is not
integer-only, and a path may contain at most one * projection segment (e.g.
"qubit_layout.cell_complex.faces.*.color"), which maps the suffix over the
list at that position and resolves to a list. This generalization is a semantic
property of resolution, not a schema constraint: the schema admits the same
parametric_ref object shape everywhere.
Reusable Type Definitions ($defs)¶
Binary Matrix¶
Three representations exist:
binary_matrix_dense¶
A 2D array of 0/1 integers.
[[1, 0, 1], [0, 1, 0]]
Outer:
arrayof rows.Inner:
arrayofinteger, each constrained to enum[0, 1].
binary_matrix_sparse¶
An object with rows and shape. additionalProperties: false.
{
"rows": [[0, 2], [1]],
"shape": [2, 3]
}
Field |
Type |
Constraints |
|---|---|---|
|
array of arrays of |
Per-row list of column indices of nonzero entries. |
|
array of exactly 2 |
|
binary_matrix¶
oneOf: dense or sparse.
binary_matrix_or_ref¶
oneOf: binary_matrix (dense or sparse) or $ref object.
Pauli Strings¶
pauli_string¶
A string matching ^[IXYZ]+$ (one or more characters from the alphabet {I, X, Y, Z}).
pauli_string_list¶
An array of pauli_string values.
pauli_string_list_or_ref¶
oneOf: pauli_string_list or $ref object.
Logical Operators¶
Definition: $defs/logical_operators. additionalProperties: false.
Field |
Type |
Constraints |
|---|---|---|
|
array of |
minItems: 1 |
|
array of |
minItems: 1 |
Both X and Z are required.
Note: No Y logical operators are defined: only X-type and Z-type.
Distance¶
Definition: $defs/distance. oneOf:
Symmetric: a single
integer>= 1.Asymmetric: an object with required
XandZfields, bothinteger>= 1.additionalProperties: false.
Ref Object¶
Definition: $defs/ref_object.
Used for the archive container to point to external files within the archive.
Field |
Type |
Required |
|---|---|---|
|
|
Yes |
The $ref value is a relative path within the archive.
Note: no pattern constraint on the path string.
Register Purpose¶
Definition: $defs/register_purpose.
A string enum naming the role a register plays in the QEC protocol. Shared by
register_entry, operation_qreg_entry, and operation_creg_entry via $ref,
so the allowed values are defined in exactly one place.
Enum: "logical_data", "logical_measurement", "syndrome", "flag", "cat", "verification", "magic_state", "transversal_readout", "custom".
Register Entry¶
Definition: $defs/register_entry. additionalProperties: true.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
>= 1 |
|
No |
Role enum; see Register Purpose. |
|
|
|
No |
Free-text description of the purpose. |
Named Register Map¶
Definition: $defs/named_register_map.
An object mapping register names (string keys) to register_entry values.
Operation Register Entries¶
These describe registers within operation variants, where the register’s
relationship to the template is specified via scope.
operation_qreg_entry (Quantum Registers)¶
additionalProperties: true.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
Enum: |
|
|
Conditional |
Required when scope is |
|
|
Conditional |
Required when scope is |
|
|
No |
>= 0. Used in logical-addressing block entries. |
|
No |
See Register Purpose. |
|
|
|
No |
Scope semantics:
"global"/"block": the register references a template register viaref."scratch": a temporary register local to the variant, sized bysize."output": a register the variant creates, sized bysize, retained after the operation returns.
operation_creg_entry (Classical Registers)¶
additionalProperties: true. Same structure as qreg, with one extra scope.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
Enum: |
|
|
Conditional |
Required when scope is |
|
|
Conditional |
Required when scope is |
|
|
No |
>= 0. |
|
No |
See Register Purpose. |
|
|
|
No |
Scope semantics:
"global"/"block": references a template register viaref."scratch": temporary register, sized bysize."output": classical output register, sized bysize.
Variant Types¶
All variants share a common base and add operation-specific required fields.
variant_base (Common Fields)¶
additionalProperties: true: allows specialised variant fields to pass through allOf composition.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Whether the variant is fault-tolerant. |
|
string or |
Yes |
OpenQASM 3.0 circuit fragment (inline or external). |
|
|
No |
Human-readable description. |
|
No |
Quantum register declarations for this variant. |
|
|
No |
Classical register declarations for this variant. |
|
|
array of |
No |
Citation keys resolving to entries in |
|
array of syndrome_creg_entry |
No |
Readout declarations, one bit per check. Required by |
|
array of transversal_readout_creg_entry |
No |
Readout declarations, one bit per block qubit read. Required by |
Both readout fields are typed on variant_base, so every operation kind accepts them and
validates their entries.
Syndrome Creg Entry¶
Definition: $defs/syndrome_creg_entry. additionalProperties: false.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Output classical register name. |
|
|
Yes |
Code section source field this maps to. |
|
array of |
No |
Rows of the source, in bit order. |
|
|
No |
>= 0. Operand block label. |
|
No |
Frame the checks are named in. |
Transversal Readout Creg Entry¶
Definition: $defs/transversal_readout_creg_entry. additionalProperties: false.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
|
Yes |
Output classical register name. |
|
|
Yes |
Code section source field this maps to. |
|
array of |
No |
Rows of the source the entry declares. |
|
array of |
No |
Block qubit each register bit reads. |
|
|
No |
>= 0. Operand block label. |
|
No |
Frame the checks are named in. |
Check Frame¶
Definition: $defs/check_frame.
A string enum naming the frame a readout declaration names its checks in. Shared by
syndrome_creg_entry and transversal_readout_creg_entry via $ref.
Enum: "entry", "exit".
state_preparation_variant¶
Extends variant_base via allOf. No additional fields; the target logical state is
specified by the outer key of the keyed default/variants container.
syndrome_measurement_variant¶
Extends variant_base via allOf. Repetition is controlled by
error_correction_cycle, not by individual variants.
No additional fields. Requires at least one of the variant_base fields syndrome_cregs
and transversal_readout_cregs (an anyOf of two required lists); both may be present.
data_measurement_variant¶
Extends variant_base via allOf. The measurement basis is specified by the outer key
of the keyed default/variants container.
Additional Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
Name of the classical register holding the result. |
reset_variant¶
Extends variant_base via allOf. No additional fields; the target logical state is
specified by the outer key of the keyed default/variants container.
logical_measurement_variant¶
Extends variant_base via allOf.
Additional Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
Name of the classical register holding the result. |
Operand Groups¶
Used within logical-addressing to describe which logical qubits a gate acts on and what circuit variants implement it.
operand_group (for logical_gates)¶
additionalProperties: false.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
array of operand_entry |
Yes |
minItems: 1 |
|
|
Yes |
Name of the default variant. |
|
object mapping name to |
Yes |
minProperties: 1 |
operand_group_logical_measurement (for logical_measurement)¶
additionalProperties: false. Same structure but variants use logical_measurement_variant.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
array of operand_entry |
Yes |
minItems: 1 |
|
|
Yes |
Name of the default variant. |
|
object mapping name to |
Yes |
minProperties: 1 |
Operand Entry¶
Definition: $defs/operand_entry. additionalProperties: false.
Field |
Type |
Required |
Constraints |
|---|---|---|---|
|
|
Yes |
>= 0. Identifies the code block. |
|
|
Yes |
Index of the logical qubit within the block, or |
|
|
No |
Semantic role label (e.g. |
Summary of additionalProperties Settings¶
Understanding where extra keys are accepted vs rejected is important for correctness review.
Definition |
|
|---|---|
Top-level object |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
All flat default/variants containers |
|
Inner containers under keyed default/variants ( |
|
Keyed default/variants containers (outer) |
controlled by |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
schema ( |
|
schema ( |
|
schema ( |
|
schema (object whose |
Semantic Constraints¶
This document describes JSON shape only. Cross-field, mathematical, and other
constraints beyond JSON Schema’s expressive power (dimension and algebraic
consistency, QASM validity, reference resolution, and the rest of the format’s
normative requirements) are catalogued in the format specification’s
requirements table (docs/format_specification.md, §8 Format
Requirements) and enforced by the semantic validator
(src/qecx/validation/rules.py, ALL_RULES;
src/qecx/validation/validator.py). The catalogue and the rule registry
are kept in sync by the drift guards in
tests/validation/test_format_requirements.py. The specification is the
source of truth for both what a requirement means and whether a requirement
exists; this document is not a second copy of that catalogue.
Schema metadata¶
Property |
Value |
|---|---|
JSON Schema dialect |
|
Schema ID |
|
File extension |
|
Top-level type |
|
Extra top-level keys allowed |
Yes ( |