### wai-quantum: error correction and mitigation, completed and on every surface

Codes with certified distances, decoders each held to the exhaustive ground truth (every error below half the distance corrected to a trivial residual), the error-correction texts read and written as they are, and mitigation in a job with its error bars and assumptions (`wai-quantum/docs/qec.md`).

- **Colour codes** (`quantum_color`): the triangular 6.6.6 codes of odd distance, `[[(3d² + 1)/4, 1, d]]`, decoded by restriction to matching on the three restricted lattices, lifted at each colour with both logical classes kept, and completed below half the distance by an exact search; every error below half the distance corrected, checked to `d = 9`. Matching alone is shown missing 16, 16 and 10 of the 190 errors of weight at most two at `d = 5`.
- **Distance certificates** (`quantum_distance`): an exhaustive search over connected supports, symmetries checked before use (a bivariate-bicycle code's translations), each sector's distance with a witness, `no_logical_below` and the node count, re-checked node for node (`wai.quantum.distance/1`); surface, toric, Steane, colour and bivariate-bicycle codes to 144 qubits certified in the tests, `[[288, 12, 18]]` in 18 s.
- **Correlated matching** (`quantum_match::CorrelatedMatching`): exact matching twice through a model's decomposed faults, the second answer kept only when the model's mechanisms explain it more cheaply; fewer failures than exact matching on the same shots (338 against 440 at `d = 5`, `p = 0.006`, 20,000 shots), and on every set of one or two faults of the `d = 5`, two-round experiment it misses 73 pairs where matching misses 103. The circuit-level ground truth for matching: every edge set below half the graph's distance corrected.
- **Sliding-window decoding** (`quantum_window`): a stream decoded as rounds arrive, `commit` rounds committed and `buffer` rounds decided again, with a stated latency budget per round and each window's time measured on the machine and labelled so; a window that covers everything is the batch decoder on every shot, and every edge set below half the distance is corrected once the buffer is `(d + 1)/2` rounds.
- **The error-correction texts** (`quantum_qec_text`): the ecosystem's circuit text with tags, Pauli-target observables, coordinates and `REPEAT`, and the detector error model text with `^` decompositions, declarations, `repeat` and `shift_detectors`, read as written and written back; a circuit's model keeps its tags and coordinates. Conformance vectors (`quantum-conformance/qec-text/`) hold every form, the model each circuit gives and each refusal (`tests/qec_text_conformance.rs`).
- **Mitigation in a job** (`engine::mitigate`, `"mitigate"` beside `"noise"`): zero-noise extrapolation by folding (Richardson, linear or exponential), error amplification and probabilistic error cancellation from a sparse Pauli–Lindblad model learned by simulated benchmarking, Clifford data regression, virtual distillation, and readout inversion. Each value raw and mitigated with its error bar, beside the ideal one the simulation knows, the method's options and its stated bias and variance assumptions, sealed with the job; refusals under `J008`.
- **Twirling and decoupling as compile passes** (`engine::compile`, `"twirl": SEED`, `"dd": "xx" | "xy4"`): each two-qubit Clifford gate framed by a seeded Pauli and its image, each distinct frame proved the gate by the equivalence ladder; decoupling pulses in each idle window, the sequence proved the identity; the whole circuit checked by the ladder where it decides.
- **One error-correction call for every host** (`engine::qec`: `code`, `decode`, `threshold`), refusals under `J009`, each answer sealed in a job's form:
  - the command line: `wai-quantum qec code|decode|threshold`, `run --mitigate`, `compile --twirl --dd`; the research forms stay at `wai-quantum lab qec`;
  - both MCP servers: `qec_code`, `qec_decode` and `qec_threshold`, and `mitigate` on runs and `twirl`/`dd` on compiles; the generated agent docs list them;
  - the service: `POST /v1/qec/code`, `/v1/qec/decode` and `/v1/qec/threshold`, bounded here (`J031`, with the command that runs it locally);
  - the Studio: an error-correction pane (the lattice, a syndrome made by flipping qubits, the correction and its residual, the certificate's witness, a threshold plot) and mitigation in the Noise section; the browser engine (`qec`) and the desktop app (`qec`);
  - Python: `qec_code`, `qec_decode`, `qec_threshold`, and `run(..., mitigate=...)`.
- **Schemas** (the version contract): an error-correction answer (`wai.quantum.qec/1`: a code, a decode or a threshold, each naming the engine and its schema inside what its receipt seals), a distance certificate (`wai.quantum.distance/1`) and a job's mitigation (`wai.quantum.mitigation/1`); the job request names `mitigate`, and a compile's options `twirl` and `dd`. `qec_code`, `qec_decode` and `qec_threshold` answer to their output schemas on both servers, and the strict tests call each, a mitigated run and a compile with both passes. Mitigation's refusals are `J008` and error correction's `J009` (`J007` is a set that does not read).
- **Not done:** a magic-state cultivation circuit generator; its non-Clifford stages would need state-vector checks against a reproduced reference.
- **CI:** `wai-quantum-qec.yml` runs every new module's tests and the text conformance in release, each named test required to pass; `wai-web-wasm.yml` requires the browser engine's error-correction and mitigation tests by name, natively and under wasm32.

