### wai-quantum: QIR under its profiles and jeff, read and written, every conversion checked

- **QIR** (`engine::formats::qir`): a module read as LLVM text, QIR 1.x (typed pointers) and 2.x (opaque pointers),
  under the profile its entry point names. Under the base profile a branch, a classical instruction, reading a result,
  or a gate or reset after a measurement is refused as what the profile forbids (`Q704`), on its line. Under the
  adaptive profile, measurements anywhere and forward branches on results (`__quantum__rt__read_result`, or QIR 1's
  `result_equal`) with the `i1` logic the profile allows are read as `if … else`, each branch to the block where its
  paths meet; an optional capability the module flags do not declare is forbidden, and one they declare that the reader
  does not take (loops, `switch`, `phi`, IR-defined functions, dynamic qubits or results, arrays) is refused as such
  (`Q705`). Integer and float computation the flags declare is computed on reading where its operands are constants.
  Rotations at any angle are read at their exact doubles, with a note (`Q709`) that the double-precision methods take
  them and the bit-exact method does not; a Clifford+T module stays on the bit-exact path. A program is written as QIR
  2.0: the base profile, or the adaptive one (forward branches on results with `read_result` and `br` alone) for a
  program that measures in the middle, resets or branches; Clifford+T is written as Clifford+T intrinsics and every
  angle as its exact hex double. The crate's bit-exact `quantum_qir` is unchanged.
- **jeff** (`engine::formats::jeff`, format 0.3): read and written through a small Cap'n Proto reader and writer of
  the crate's own, with no dependency (segments, far pointers, every element size, each pointer bounds-checked, a limit
  on the words visited and the depth). The entry point's dataflow graph is run in an order its values allow: registers
  extracted, inserted, sliced, split and joined by index, `for` and `while` decided on reading unrolled, a `switch` on a
  measured bit read as a condition, calls inlined, classical values computed the same on every platform. Well-known
  gates take their controls after their targets, as the schema orders them; a Pauli-product rotation `exp(iθP)` is
  lowered exactly; a custom gate is read only by a standard gate's name (`Q711`). The writer gives one function, every
  gate well-known and exact with its global phase, the bits a returned array; a program that branches is refused
  (`Q720`).
- **Codes** `Q700` to `Q721` in the reader's table (`docs/qasm-diagnostics.md`): every refusal names its place (a
  QIR line, a jeff function and operation). `docs/formats.md` says what each reader takes.
- **Every surface:** `wai-quantum convert FILE --to qasm|qir|jeff [--profile] [-o] [--json]`, each conversion checked
  by reading the output back and holding it to the program with the equivalence ladder (a program that branches, step
  for step or by every outcome's probability); every verb reads `.ll`, `.qir` and `.jeff` files, or `--from`. Both MCP
  servers serve `convert_program` (`tools.v1.json#/$defs/convert`); the job service answers `POST /v1/convert`, and a
  job may carry `{"source": {"format", "program" | "program_base64"}}` in place of `qasm` (`job-request.v1.json`), as
  both MCP servers' run tools take it (`run_quantum_circuit`, `plan_quantum_circuit`, `run_on_target` and the dry run),
  one schema and one refusal; a request whose `qasm` is what its `source` reads to is read as it is.
  The Studio opens `.ll`, `.qir` and `.jeff` files through `engine_convert` (the desktop app through its `convert`
  command): the program goes into the editor as OpenQASM 3, with the format, the check and each note under it, and a
  refusal leaves the editor as it was with its code.
- **Hostile input:** every size, count, index and bound a file gives is held to a cap before anything is made from
  it (a register's size before its qubits: a jeff register of 2^32 − 1 qubits is refused, `Q111`, where it once asked
  for 34 GB and trapped in a page); the wire reader bounds every pointer in 64 bits and counts each list element
  against the words it visits; the jeff reader counts every register slot, array element, call frame and condition
  term against one budget; the QIR reader bounds its branches' nesting, the instructions it runs over every path and
  the state each path copies; a condition is at most 1 024 terms and 32 deep once written. A conversion's check is
  not run past 262 144 gates applied or 4·10⁹ amplitudes, and says so. `tests/formats_mutation.rs` mutates every file
  of the conformance set from a fixed seed (45 153 inputs: bits flipped, files cut and spliced, every length, count,
  offset and 32-bit field inflated) and holds each to converting or a refusal with a code, within 20 s and 1 GiB,
  natively and under wasm32-wasip2 in `wai-quantum-formats.yml`.
- **Conformance** (`wai/quantum-conformance/formats/`): the QIR specification's two examples, every intrinsic, a QIR 1
  module, each profile's refusals, hand-built jeff modules, the jeff project's own structured benchmarks and examples
  unchanged, and OpenQASM written to each format with the QIR bytes pinned, run natively and under wasm32-wasip2
  (`wai-quantum-formats.yml`). `wai-web-wasm.yml`'s pins move to 19 (wasm32) and 27 (native).

