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

qec_version

string

Yes

Format version in "major.minor" form (regex ^[0-9]+\.[0-9]+$).

code

code section

Yes

Algebraic definition of the QEC code.

register_template

register_template section

Yes

Declarative register layout for circuit operations.

operations

operations section

Yes

Circuit implementations for all operation types.

error_correction_cycle

EC cycle section

Yes

EC cycle composition from syndrome measurement variants.

decoder_config

decoder_config section

No

Optional syndrome-decoder capability declaration and per-detector metadata.

qubit_layout

qubit_layout section

No

Optional spatial geometry and structural metadata.

properties

properties section

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

code_type

string

Enum: "css", "stabilizer", "subsystem_css", "subsystem_stabilizer"

Determines which additional fields are required.

n

integer

>= 1

Number of physical qubits.

k

integer

>= 1

Number of logical qubits.

d

distance

—

Code distance (symmetric or asymmetric).

logical_operators

logical_operators

—

Representative logical X and Z operators.

Conditional Requirements by code_type

code_type

Additional required fields

"css"

H_X, H_Z

"stabilizer"

stabilizer_generators

"subsystem_css"

gauge_X, gauge_Z

"subsystem_stabilizer"

gauge_generators

Optional Fields (all code types)

Field

Type

Description

name

string

Human-readable code name.

H_X

binary_matrix_or_ref

X-type parity check matrix.

H_Z

binary_matrix_or_ref

Z-type parity check matrix.

stabilizer_generators

pauli_string_list_or_ref

Stabilizer generators as Pauli strings.

gauge_generators

pauli_string_list_or_ref

Gauge generators (subsystem codes).

gauge_X

binary_matrix_or_ref

X-type gauge generator matrix.

gauge_Z

binary_matrix_or_ref

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

global

object

No

Shared registers (see below).

per_code_block

object

Yes

Per-block registers (see below).

global

additionalProperties: false

Field

Type

Required

ancilla_qregs

named_register_map

No

cregs

named_register_map

No

per_code_block

additionalProperties: false

Field

Type

Required

data_qreg

register_entry

Yes

ancilla_qregs

named_register_map

No

cregs

named_register_map

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

state_preparation

keyed default/variants container (state_preparation)

Logical state initialization circuits, keyed by target logical state.

syndrome_measurement

flat default/variants container (syndrome_measurement)

Syndrome extraction circuits.

logical_gates

logical-addressing (generic)

Logical gate circuits.

data_measurement

keyed default/variants container (data_measurement)

Data measurement circuits, keyed by measurement basis.

Optional Operations

Field

Type

Description

logical_measurement

logical-addressing (logical_measurement)

Non-destructive logical measurement circuits.

reset

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

state_key_string

^[01+\-ij]+$

state_preparation, reset

basis_key_string

enum ["Z","X","Y"]

data_measurement

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

uuid

string

author

string or array of string

Singular or list.

creator

string

Tool/software that generated the file.

license

string

created_date

string

No format constraint (e.g. ISO 8601 not enforced).

references

array of reference_entry

Bibliographic references.

description

string

reference_entry

Definition: $defs/reference_entry. additionalProperties: false.

Field

Type

Required

Constraints

Description

key

string

Yes

Pattern ^[A-Za-z][A-Za-z0-9_-]*$

Stable citation key; must be unique within the file.

title

string

No

—

Paper / resource title.

doi

string

No

—

DOI without URL prefix.

arxiv

string

No

—

arXiv identifier.

url

string

No

format: "uri" (annotation-only)

Fallback URL when no DOI / arXiv.

note

string

No

—

Short human-readable role note.

authors

string

No

—

Verbatim author list, rendered as-is.

year

integer

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_type

string

—

Tiling/tessellation type (e.g. "4.8.8", "square").

topology

string

—

Manifold topology (e.g. "planar", "torus").

cell_complex

cell_complex or $ref

—

Combinatorial cell complex structure.

embedding

embedding

—

Geometric embedding of the cell complex.

qubit_placement

object

—

Maps registers to cell complex elements or provides explicit coordinates.

cell_complex

Definition: $defs/cell_complex. additionalProperties: false.

Field

Type

Required

Constraints

Description

num_vertices

integer

Yes

>= 1

Total number of vertices (0-cells).

edges

array of [int, int]

Yes

Each index >= 0

Vertex index pairs (1-cells).

faces

array of objects

No

Each face: vertices required, color optional

Face definitions (2-cells).

Each face object (additionalProperties: false):

Field

Type

Required

Constraints

vertices

array of integer

Yes

minItems: 3, each >= 0

color

integer

No

>= 0

embedding

Definition: $defs/embedding. additionalProperties: false.

Field

Type

Required

Constraints

Description

dimension

integer

Yes

>= 1

Embedding space dimension.

coordinate_type

string

Yes

—

E.g. "cartesian", "lattice_units".

vertex_coordinates

array of arrays of number, or $ref

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

cell

string

Yes

Enum: "vertex", "edge", "face"

mapping

array of integer

Yes

Each >= 0

Explicit coordinates ($defs/qubit_placement_coordinates, additionalProperties: false):

Field

Type

Required

Constraints

coordinates

array of arrays of number, or $ref

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

default

string

Yes

Name of the default cycle variant.

variants

object of ec_cycle_variant

Yes

At least one named variant (minProperties: 1).

EC Cycle Variant

Definition: $defs/ec_cycle_variant. additionalProperties: false.

Field

Type

Required

Description

description

string

No

Human-readable description.

fault_tolerant

boolean

No

Whether cycle provides FT guarantees.

steps

array of ec_cycle_step

Yes

Ordered measurement steps (minItems: 1).

repeat

integer_or_ref

No

Repeat entire step sequence (default: 1).

references

array of string

No

Citation keys resolving to entries in properties.references.

EC Cycle Step

Definition: $defs/ec_cycle_step. additionalProperties: false.

Field

Type

Required

Description

measurement

string

Yes

Name of a syndrome_measurement variant.

repeat

integer_or_ref

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

ref

string

Yes

Dot-notation path resolving to a field in the document (e.g. "code.d").

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

parameters

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)

decoder_tag_anchor_map

No

A per-detector tag (e.g. color, weight). The key is the tag name; the value is an anchor map.

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

syndrome_measurement

decoder_syndrome_override

No

Reserved key: per-register override keyed by variant then classical register.

(source name)

decoder_anchor_value

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:

  1. A decoder_value_list.

  2. 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: array of rows.

  • Inner: array of integer, 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

rows

array of arrays of integer (>= 0)

Per-row list of column indices of nonzero entries.

shape

array of exactly 2 integers (>= 0)

[m, n]: matrix dimensions.

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

X

array of pauli_string

minItems: 1

Z

array of pauli_string

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:

  1. Symmetric: a single integer >= 1.

  2. Asymmetric: an object with required X and Z fields, both integer >= 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

$ref

string

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

size

integer

Yes

>= 1

purpose

register_purpose

No

Role enum; see Register Purpose.

purpose_description

string

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

scope

string

Yes

Enum: "global", "block", "scratch", "output"

ref

string

Conditional

Required when scope is "global" or "block".

size

integer

Conditional

Required when scope is "scratch" or "output". >= 1.

block_index

integer

No

>= 0. Used in logical-addressing block entries.

purpose

register_purpose

No

See Register Purpose.

purpose_description

string

No

Scope semantics:

  • "global" / "block": the register references a template register via ref.

  • "scratch": a temporary register local to the variant, sized by size.

  • "output": a register the variant creates, sized by size, retained after the operation returns.

operation_creg_entry (Classical Registers)

additionalProperties: true. Same structure as qreg, with one extra scope.

Field

Type

Required

Constraints

scope

string

Yes

Enum: "global", "block", "scratch", "output"

ref

string

Conditional

Required when scope is "global" or "block".

size

integer

Conditional

Required when scope is "scratch" or "output". >= 1.

block_index

integer

No

>= 0.

purpose

register_purpose

No

See Register Purpose.

purpose_description

string

No

Scope semantics:

  • "global" / "block": references a template register via ref.

  • "scratch": temporary register, sized by size.

  • "output": classical output register, sized by size.


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

fault_tolerant

boolean

Yes

Whether the variant is fault-tolerant.

qasm

string or $ref

Yes

OpenQASM 3.0 circuit fragment (inline or external).

description

string

No

Human-readable description.

qregs

operation_qregs_map

No

Quantum register declarations for this variant.

cregs

operation_cregs_map

No

Classical register declarations for this variant.

references

array of string

No

Citation keys resolving to entries in properties.references.

syndrome_cregs

array of syndrome_creg_entry

No

Readout declarations, one bit per check. Required by syndrome_measurement_variant unless transversal_readout_cregs is present.

transversal_readout_cregs

array of transversal_readout_creg_entry

No

Readout declarations, one bit per block qubit read. Required by syndrome_measurement_variant unless syndrome_cregs is present.

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

name

string

Yes

Output classical register name.

source

string

Yes

Code section source field this maps to.

indices

array of integer (>= 0)

No

Rows of the source, in bit order.

block_index

integer

No

>= 0. Operand block label.

frame

check_frame

No

Frame the checks are named in.

Transversal Readout Creg Entry

Definition: $defs/transversal_readout_creg_entry. additionalProperties: false.

Field

Type

Required

Description

name

string

Yes

Output classical register name.

source

string

Yes

Code section source field this maps to.

indices

array of integer (>= 0)

No

Rows of the source the entry declares.

qubits

array of integer (>= 0)

No

Block qubit each register bit reads.

block_index

integer

No

>= 0. Operand block label.

frame

check_frame

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

result_creg

string

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

result_creg

string

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

operands

array of operand_entry

Yes

minItems: 1

default

string

Yes

Name of the default variant.

variants

object mapping name to variant_base

Yes

minProperties: 1

operand_group_logical_measurement (for logical_measurement)

additionalProperties: false. Same structure but variants use logical_measurement_variant.

Field

Type

Required

Constraints

operands

array of operand_entry

Yes

minItems: 1

default

string

Yes

Name of the default variant.

variants

object mapping name to logical_measurement_variant

Yes

minProperties: 1

Operand Entry

Definition: $defs/operand_entry. additionalProperties: false.

Field

Type

Required

Constraints

block

integer

Yes

>= 0. Identifies the code block.

logical_qubit

integer (>= 0) or null

Yes

Index of the logical qubit within the block, or null.

role

string

No

Semantic role label (e.g. "control", "target").


Summary of additionalProperties Settings

Understanding where extra keys are accepted vs rejected is important for correctness review.

Definition

additionalProperties

Top-level object

true

code_section

true

register_template_section

false

register_template_section.global

false

register_template_section.per_code_block

false

operations_section

true

properties_section

true

qubit_layout_section

true

binary_matrix_sparse

false

logical_operators

false

distance (object form)

false

register_entry

true

operation_qreg_entry

true

operation_creg_entry

true

variant_base

true

syndrome_creg_entry

false

transversal_readout_creg_entry

false

operand_entry

false

operand_group

false

operand_group_logical_measurement

false

All flat default/variants containers

false

Inner containers under keyed default/variants (_inner)

false

Keyed default/variants containers (outer)

controlled by propertyNames + per-key additionalProperties

cell_complex

false

cell_complex face items

false

embedding

false

qubit_placement_cell

false

qubit_placement_coordinates

false

error_correction_cycle_section

false

ec_cycle_variant

false

ec_cycle_step

false

parametric_ref

false

decoder_config_section

schema ($ref decoder_entry): every key is a decoder slug

decoder_entry

schema ($ref decoder_tag_anchor_map): keys other than parameters are per-detector tags

decoder_tag_anchor_map

schema ($ref decoder_anchor_value): keys other than syndrome_measurement are source names

decoder_syndrome_override

schema (object whose additionalProperties is $ref decoder_anchor_value)


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

draft/2020-12

Schema ID

https://haiqu.ai/schemas/qecx/v0.1/qecx.schema.json

File extension

.qecx, in either container: inline JSON, or an archive with $ref pointers

Top-level type

object

Extra top-level keys allowed

Yes (additionalProperties: true)