Ana içeriğe geç
NM-RFC-0011

Ölçüme bağlı klasik kontrol

Tasarım belgesi · Özgün kaynak

RFC'ler tasarım ve değişiklik kayıtlarıdır. Bir önerinin burada bulunması, özelliğin kullanıma hazır olduğu anlamına gelmez. Güncel dil desteğini incele

Özgün belgedeki durum: Taslak

Bağlı özgün kaynak · SHA-256
e400e37e69637262238dc3bb8221047782d875338321f234c83810cbb4b568a6

  • Status: draft
  • Revision: 12 (2026-07-31)
  • Target contract: 0.3.0-experimental
  • Feature flag: experimental.feedForward=true
  • Owners: language, runtime, compiler, tooling
  • Depends on: NM-RFC-0003 property assertions, NM-RFC-0005 typed classical values
  • Interacts with: NM-RFC-0010 typed oracles (forbidden inside oracle bodies)
  • Does not change: stable N/M 0.1 parser, Algorithm Pack 0.2/0.3 entries
  • Adds: two exact-version Algorithm Pack 0.4 protocol entries

1. Summary

N/M already supports measurement-conditioned execution in the stable surface: NMConditional represents if (bit == 0|1)/else, both local backends execute it, JSON IR preserves it, and OpenQASM 3 export emits a structured if. The language also has derived classical Bit expressions, match, bounded until, and sample blocks. This RFC does not rename that baseline as a new feature and does not place existing source behind a flag.

The RFC adds a bounded verification and provenance layer:

  1. an extended conditional predicate tree over measurement-derived values, negotiated behind experimental.feedForward=true;
  2. a closed predicate subset with no arithmetic;
  3. branch-exhaustive verification of declared outcome invariants;
  4. normative randomness consumption plus seeded branch records and replay;
  5. a deferred-measurement equivalence check as an independent oracle of correctness;
  6. fail-closed diagnostics for every unsupported composition.
  7. exact-version verified teleportation and entanglement-swapping packages whose runnable examples retain Tier 1 branch and replay evidence.
  8. closed-world, hash-bound single-error correction maps for the NM-013 QEC family without prematurely publishing those packages.
  9. negotiated CLI, LSP, VS Code, debugger, Playground, and fail-closed export parity with explicit preservation provenance.

resetNMStabilizerQubit remains supporting implementation evidence, not the only existing feed-forward primitive. The normative compatibility baseline is the parser/runtime/IR/QASM behavior already covered by stable fixtures.

2. Motivation

Three stronger capabilities remain blocked today.

Verified teleportation and entanglement swapping. Measurement-conditioned corrections can already be written with simple if statements. What is missing is proof that every reachable measurement branch produces the same target state, a reproducible branch record, and an independent deferred-measurement equivalence fixture.

Auditable error correction. Existing bounded teaching entries may apply fixed corrections and the language can act on a measured syndrome. It cannot yet attach a branch-exhaustive proof, correction-map artifact, or replay record to that claim. New Algorithm Pack 0.4 QEC entries must remain detection-only until those stronger artifacts exist.

Auditable ancilla reuse. Reset-and-reuse already executes locally through the reset statement. Multi-round QEC still lacks a typed syndrome history, branch record, scheduling contract, and decoder interface.

2.1 The deferred-measurement objection

Teleportation can be simulated today without this feature: by the principle of deferred measurement, the measure-and-correct pair can be replaced with CNOT and CZ, postponing all measurement to the end. The objection is legitimate and this RFC does not dismiss it.

It fails for three reasons:

  • it is not how hardware or fault-tolerant protocols work, so presenting the deferred circuit as "teleportation" teaches the wrong mechanism;
  • it forbids ancilla reuse, which is the entire point of multi-round QEC;
  • it is only a complete replacement while the classical outcome is used for nothing else. Reporting, decoding, or logging the syndrome adds observable classical behavior that the deferred circuit does not carry.

The deferred form is nevertheless valuable: it is an independent reference implementation expressible in today's language, which §9.3 turns into an acceptance test.

3. Goals

  • Preserve the existing simple measurement-conditioned execution contract.
  • Extend predicates without changing stable simple if/else behavior.
  • Keep the classical predicate language closed and statically checkable.
  • Prove outcome invariance where a program claims it.
  • Keep runs reproducible under a recorded seed.
  • Preserve fail-closed behavior for every unsupported composition.
  • Keep CLI, Worker, Playground, LSP, VS Code, debugger, and export surfaces version-aligned.

4. Non-goals

  • Unbounded repeat-until-success or any measurement-conditioned loop.
  • Arbitrary classical computation between measurement and correction.
  • Feed-forward inside an oracle body (NM-RFC-0010 §8 already forbids runtime if; this RFC does not relax that).
  • Feed-forward inside a train block.
  • Branch-exhaustive verification combined with a noise model (§9.4).
  • Real-time latency claims, hardware conditional execution, or any assertion about provider feed-forward capability.
  • Classical decoders more expressive than the predicate subset of §7.

5. Scope and honest limits

Both backends already provide the required measurement projection and conditional gate execution primitives. This RFC does not add a new quantum backend primitive; Stage 3 does extend their shared classical predicate evaluator and provenance carrier for the negotiated predicate tree.

Tablo 1
BackendMeasurement modelFeed-forwardWidth
browser-stabilizertableau projection, reports deterministicexisting simple if; extended predicate under flag<= 100
browser-statevectortrajectory: sample, collapse, renormalizeexisting simple if; extended predicate under flag<= 14

The stabilizer path is where this capability matters. Every protocol this RFC unblocks — teleportation, entanglement swapping, the QEC code family — is Clifford, so the useful range is the stabilizer range, not the statevector range.

Verification is bounded separately from execution, following the model established in NM-RFC-0010 §9.5. A program may execute and still receive no invariance proof; that combination is legal and must be labeled, never silently presented as verified.

6. Source model

nm
circuit teleport(q: QReg<3>) {
  H(q[1]);
  CNOT(q[1], q[2]);

  CNOT(q[0], q[1]);
  H(q[0]);

  let m0 = measure(q[0]);
  let m1 = measure(q[1]);

  if (m1 == 1) { X(q[2]); }
  if (m0 == 1) { Z(q[2]); }

  assert_branch_invariant(q[2]);
}

The example uses the existing simple conditional spelling. A negotiated extended conditional block:

  • has a predicate drawn from the subset of §7;
  • may contain gates, further measurements, syndrome/derived-Bit operations, branch-aware assertions, and barriers;
  • may not allocate, reset, train, encode a dataset, sample, or introduce a nested control region. Those operations remain outside the conditional;
  • remains subject to the measurement and branch budgets of §9.4;
  • may not contain @noise declarations or oracle declarations.

A stable simple if (bit == 0|1) retains its existing body and serialization contract when the feature is disabled. If verification is negotiated and such a stable region contains an operation outside the Tier 1 interpreter, execution remains legal but the verifier reports Tier 2 unsupported; it is not silently reclassified as an extended conditional.

A syndrome decoder is written as a sequence of equality tests:

nm
let s = measure_all(anc[0..2]);

if (s == 0b001) { X(data[0]); }
if (s == 0b010) { X(data[1]); }
if (s == 0b100) { X(data[2]); }

7. Classical predicate subset

Stable source already accepts one measured or derived Bit compared to 0 or 1. Under experimental.feedForward=true, the extended predicate is built only from:

  • a measurement result name, or an indexed bit of a BitVec<N> result;
  • comparison == or != against a compile-time integer or bit-string literal of matching width;
  • &&, ||, and ! over such comparisons.

There is no arithmetic, no comparison between two runtime values, no function call, and no reference to any classical value that did not come from a measurement in the same program.

Predicate literals are never stored as JavaScript number. A 0b literal preserves its written width including leading zeroes and must match the operand width exactly. A decimal integer is converted at compile time to its minimal unsigned binary representation and is zero-extended to the measured operand width for comparison; its minimal representation must fit that width. The AST stores the canonical most-significant-bit-first bit string plus its source spelling. Width is limited to NM_FEED_FORWARD_MAX_RESULT_WIDTH = 100, matching the widest execution backend. This avoids IEEE-754 truncation at the stabilizer boundary.

A predicate contains at most NM_FEED_FORWARD_MAX_PREDICATE_TERMS = 16 comparison terms. This is separate from the syntactic nesting-depth limit in §16: a flat conjunction does not become deeper merely because its left-associated AST has more nodes.

This subset is deliberately narrow enough that a predicate is a Boolean function of the recorded outcome bits, which is what makes §9.1 decidable and what keeps the OpenQASM 3 lowering of §15 total.

8. Execution semantics

Statevector. measure samples an outcome from the amplitude distribution, projects the state onto the observed subspace, and renormalizes. This is the existing trajectory behavior of lib/nm/statevector-runtime.ts.

Stabilizer. measure projects the tableau and reports { state, probability, deterministic }. A measurement whose outcome is forced by the stabilizer group is deterministic; on a valid codeword, syndrome measurements are exactly the deterministic case.

Randomness consumption is normative. A measurement consumes exactly one draw from the seeded source if and only if its outcome is not deterministic. Deterministic measurements consume none. Draws are taken in program order. Without this rule a recorded seed does not reproduce a run, so §19 requires a fixture that changes the number of deterministic measurements and asserts the draw sequence is unchanged.

Negotiation alone does not activate this draw contract or attach the program.feedForward carrier. The carrier is attached only when the parsed program actually contains an extended predicate, a measurement binding outside an NM-RFC-0012 collect<K> body, or an assert_branch_invariant. Consequently, turning the preview flag on for stable-only source cannot change its seeded draw sequence or serialization.

Conditional evaluation. A conditional block executes if and only if its predicate evaluates true against the outcomes recorded so far. A predicate may not reference a measurement that has not yet executed; forward references are NM-FF-004.

9. Verification model

9.1 Tier 1 — branch-exhaustive invariance

For a program with k enumerated measurement outcome bits there are at most 2^k outcome paths. The conservative count includes scalar measurements, syndromes, every bit of a vector measurement, and measurements written in either conditional arm. The retained carrier field remains named conditioningMeasurements for revision-10 compatibility, but its normative value is this enumerated outcome-bit count. The verifier forces each outcome in turn, prunes paths whose probability is zero, and then asserts:

  • invariance: for every register named in an assert_branch_invariant, the reduced state is identical across all reachable paths within the frozen tolerance;
  • conservation: the reachable path probabilities sum to 1 within the same tolerance.

An assert_branch_invariant checkpoint is identified by its distinct AST occurrence after template/import/loop preprocessing. Source line is diagnostic provenance only and is not an identity key: two expanded assertions retaining the same source line remain separate checkpoints. Only reachable paths that execute an occurrence are compared, using the reduced state at that occurrence. Later operations cannot retroactively pass or fail the checkpoint. An assertion reached on no path contributes no invariant proof; an assertion reached on one path is vacuously invariant.

Forcing an outcome is projection plus renormalization on the statevector, and a tableau projection on the stabilizer path. Both are cheap at the widths in scope: 256 branches over a 100-qubit tableau is a few hundred O(n^2) operations.

Tier 1 requires k <= NM_FEEDFORWARD_MAX_EXHAUSTIVE_MEASUREMENTS = 8, i.e. at most 256 branches.

Invariance is declared, never assumed. A program that reports a random syndrome is a perfectly valid feed-forward program with no invariant; it simply carries no assert_branch_invariant and receives no proof.

9.2 Tier 2 — seeded sampling

Programs exceeding the Tier 1 budget execute under a recorded seed and receive no invariance proof. Every surface that displays such a result must label it as sampled, and documentation must not describe it as verified.

9.3 Deferred-measurement equivalence

Where a feed-forward program has a deferred-measurement counterpart expressible in stable N/M 0.1 — measurement replaced by controlled operations, all measurement postponed to the end — the two must agree on the final distribution, and on the final state up to global phase for the invariant registers.

This is the strongest available cross-check in the current runtime. The two paths share low-level unitary/statevector kernels and density-matrix helpers, but the reference path has an independent measurement-suffix, branch-free execution path and never invokes the feed-forward measurement, predicate, or conditional runtime. §19 requires it for teleportation and entanglement swapping at minimum.

The revision 12 harness is deliberately bounded to the current statevector ceiling of five qubits. Its feed-forward input must already have a successful Tier 1 proof. The stable counterpart is a noise-free, closed unitary prefix followed by the same ordered (qubit, basis) measurement suffix and may end in a state-neutral return; measurement count alone is insufficient. Pauli- syndrome measurements require a separately specified coherent construction and fail closed in this harness.

The feed-forward side is evaluated as the probability-weighted mixture of every reachable branch. The independent reference path executes only the stable unitary prefix and never invokes the sampled runtime or classical conditional evaluator. The harness compares the complete computational-basis distribution and, for every declared invariant target, the reduced density matrix. Density matrices make the invariant comparison explicitly insensitive to one global phase. A malformed counterpart is NM-FF-013; a numeric mismatch outside §9.5 is NM-FF-014.

9.4 Noise is excluded from Tier 1

A noise model multiplies measurement branches by noise trajectories, and the product is not bounded by the Tier 1 budget. A program that declares @noise and uses feed-forward is Tier 2 only. This is a verification restriction, not an execution restriction: such programs run normally.

9.5 Tolerance

NM_FEEDFORWARD_VERIFICATION_TOLERANCE = 1e-10, frozen with this contract and consistent with NM-RFC-0010 §9.4. Comparisons are tolerance statements; exact floating-point equality is never claimed. Where a branch comparison yields a discrete result — a syndrome table, a correction map — the discrete value is what is stored and hashed.

9.6 Discrete QEC correction maps

Stage 8 uses a separate, algebraic verification path for the four planned NM-013 code definitions. It does not relabel one sampled circuit path as a branch-exhaustive proof.

For each code, the verifier stores the ordered Pauli stabilizer generators and checks:

  1. every generator has the declared data width;
  2. all generators commute under the binary symplectic product;
  3. their GF(2) rank is exactly n - k;
  4. every error in the declared single-physical-error model has a non-zero syndrome;
  5. errors sharing a syndrome are accepted only if their product belongs to the stabilizer span;
  6. the selected correction times every covered error belongs to that same span.

The resulting ordered syndrome-to-correction table is canonically serialized with recursively sorted object keys and hashed as a discrete-correction-map artifact. Validation recomputes that hash, then compares the complete canonical content with the built-in closed-world artifact. Object key order is irrelevant; identity-hash equality alone does not excuse changed content. A decoder formatter may lower the table only to the closed equality/&& predicate subset of §7, and its syndrome width may not exceed the 16-term predicate budget.

The frozen Stage 8 scopes are:

Tablo 2
Planned codeData + syndrome qubitsCovered error modelCovered errorsUnique syndromes
qec.perfect5_code@0.45 + 4one physical X, Y, or Z1515
qec.steane7_code@0.47 + 6one physical X, Y, or Z2121
qec.surface_d3_patch@0.49 + 8one physical X, Y, or Z2723
qec.repetition_code25@0.413 + 12one physical X only1313

The surface-code collisions are deliberate degeneracy and are accepted only by the stabilizer-span rule above. The repetition-code decoder has twelve syndrome bits, exceeds the eight-bit Tier 1 budget, and therefore remains Tier 2 if executed. Algebraic map verification is not a noise result, multi-round decoder, minimum-weight decoder, fault-tolerance proof, or hardware claim.

All four records remain verification-artifact-only. Their package identifiers are planned identities, not installable package-registry entries; NM-014's scale visualization requirement must land before NM-013 publishes them.

10. Determinism and reproducibility

  • Every run records the seed, the ordered outcome bits, and the branch taken at each conditional.
  • The experiment record, workspace snapshot, and QASM 3 sidecar carry that record.
  • Replay validates the retained record as a closed, bounded artifact before using its effective seed. The seed is bound to retained source @seed, experiment workload metadata, workspace reproducibility metadata, and QASM 3 sidecar module metadata wherever those fields are present.
  • Replaying a recorded seed must reproduce the complete record exactly: ordered outcomes, branch decisions, random-draw count, and Tier 1/Tier 2 evidence. Any missing or differing field is NM-FF-011; matching only the final quantum state is insufficient.
  • A different seed may take a different branch; for a program with a declared invariant, the invariant result must not change. §19 requires a fixture over at least sixteen distinct seeds.
  • Golden fixtures for feed-forward programs are keyed on the seed. A fixture without a recorded seed is invalid.

11. Interaction with existing contracts

Tablo 3
ContractInteraction
NM-RFC-0010 §8 oracle bodiesFeed-forward forbidden. Runtime if is already rejected; this RFC adds NM-FF-002 naming the feature explicitly so the error is actionable.
train blocksForbidden. The adjoint-gradient model (lib/nm/adjoint-gradient.ts) has no defined gradient across a measurement branch. NM-FF-003.
NM-RFC-0003 property assertionsAssertions become branch-aware: an assertion inside a conditional is evaluated only on paths that reach it, and the report states the reachable-path count.
DebuggerTimeline frames record the branch taken and the outcome bit that selected it. Existing NM_DEBUG_MAX_TIMELINE_FRAMES budget applies per path, not per program.
OptimizerMay not move an operation across a measurement or into/out of a conditional block.
Stabilizer eligibilityUnchanged: predicates are classical, so a Clifford program with feed-forward remains stabilizer-eligible.

12. AST and IR carrier

ts
type NMSourceRange = {
  start: { line: number; column: number };
  end: { line: number; column: number };
};

type NMRegisterSlice = {
  register: string;
  start: number;
  endInclusive: number;
};

type NMMeasurementBinding = {
  kind: "measurement-binding";
  name: string;
  operand: NMQubitRef | NMRegisterSlice;
  width: number;
  sourceRange: NMSourceRange;
};

type NMClassicalPredicate =
  | {
      kind: "compare";
      result: string;
      bit?: number;
      operator: "==" | "!=";
      literal: { bits: string; source: string };
    }
  | { kind: "and" | "or"; left: NMClassicalPredicate; right: NMClassicalPredicate }
  | { kind: "not"; operand: NMClassicalPredicate };

type NMVerifiedConditional = {
  kind: "if";
  predicate: NMClassicalPredicate;
  body: NMStatement[];
  elseBody?: NMStatement[];
  sourceRange: NMSourceRange;
};

type NMBranchInvariantAssertion = {
  kind: "assertBranchInvariant";
  target: {
    register: string;
    index?: number;
    resolvedIndices: number[];
  };
  line: number;
};

type NMBranchRecord = {
  contractVersion: "0.3.0-experimental";
  seed: string;
  outcomes: number[];
  branchesTaken: boolean[];
  randomDraws: number;
  verification:
    | {
        tier: 1;
        label: "verified";
        backend: "statevector" | "stabilizer";
        conditioningMeasurements: number;
        reachablePaths: number;
        probabilitySum: number;
        tolerance: 1e-10;
        invariants: string[];
      }
    | {
        tier: 2;
        label: "sampled";
        conditioningMeasurements?: number;
        reason?: "budget" | "noise" | "unsupported" | "undeclared";
      };
};

NMMeasurementBinding is the Stage 3 carrier for measure_all/BitVec<N>. Stage 2 predicates operate over the existing scalar NMMeasurement, NMSyndromeMeasurement, and measurement-derived NMBitAssignment carriers. Stage 3 completed the vector binding, so full-width and indexed references now validate and execute against the same ordered bit vector. Revision 4 adds the feature-gated NMBranchInvariantAssertion; a target may be one statically indexed qubit or an entire declared register, and is resolved before Tier 1 enumeration starts.

The executable IR already contains conditional regions. Revision 2 therefore extends the existing carrier instead of replacing a flat gate list:

  • stable simple conditions retain the current binding/operator/value fields and byte-identical serialization;
  • negotiated extended conditions additionally carry predicate;
  • verified execution may attach a separate NMBranchRecord.

Readers that understand only the stable fields may continue reading stable programs. A reader encountering predicate or NMBranchRecord without declared version support must fail closed rather than flattening a sampled path. Merely enabling the parser option does not emit this module contract; actual use of an NM-RFC-0011 carrier does. An NM-RFC-0012 measurement binding scoped to collect<K> carries only the typed-collection module contract unless separate NM-RFC-0011 syntax is also present.

13. Diagnostics

Tablo 4
CodeMeaning
NM-FF-001Extended predicate or verification syntax used without explicit feature negotiation; stable simple if/else is never rejected by this code
NM-FF-002Feed-forward is not permitted inside an oracle body (NM-RFC-0010 §8)
NM-FF-003Feed-forward is not permitted inside a train block
NM-FF-004Predicate references a measurement that has not executed
NM-FF-005Predicate uses a construct outside the closed subset of §7
NM-FF-006Literal width does not match the measurement result width
NM-FF-007Conditional block contains syntax outside the closed body subset of §6 (for example allocation, reset, training, encoding, sampling, or nested control)
NM-FF-008Enumerated measurement outcome-bit count exceeds the Tier 1 budget
NM-FF-009Declared branch invariant does not hold across reachable paths
NM-FF-010Reachable path probabilities do not sum to one within tolerance
NM-FF-011Result replay does not reproduce the recorded branch sequence
NM-FF-012Target lowering cannot preserve conditional execution
NM-FF-013Deferred-measurement counterpart violates the closed reference contract
NM-FF-014Deferred-measurement distribution or invariant state differs
NM-FF-015The Tier 1 verifier encountered a gate/backend support mismatch and failed closed instead of dropping a branch

NM-FF-009 must report which two paths disagree, their outcome bits, and the magnitude of the disagreement. NM-FF-008 must report the counted outcome bits and the budget, and state that the program may still run under Tier 2.

Stage 8 correction-map diagnostics use a separate namespace:

Tablo 5
CodeMeaning
NM-QEC-001Code dimensions or Pauli generator syntax are invalid
NM-QEC-002Two stabilizer generators do not commute
NM-QEC-003Stabilizer generators are not GF(2)-independent
NM-QEC-004A declared correctable error has the zero syndrome
NM-QEC-005One syndrome aliases errors that are not stabilizer-equivalent
NM-QEC-006A retained correction-map artifact differs from the built-in closed-world artifact

14. Tooling behavior

CLI:

text
nm check main.nm --experimental-feed-forward
nm run main.nm --experimental-feed-forward --seed <value>
nm export main.nm --to qasm3 --experimental-feed-forward

JSON output records the effective flag, the seed, the verification tier, the reachable-path count, and the declared invariants.

Editors negotiate initializationOptions.nm.experimental.feedForward, and must provide semantic tokens for measurement bindings and conditional blocks, hover showing the verification tier, and diagnostics at both the predicate and the conditional body.

Playground and Worker default the toggle off, surface the seed, and label a Tier 2 result as sampled rather than verified.

15. Export policy

OpenQASM 3 has mid-circuit measurement into bit registers and if (c == 1) { ... }; N/M already uses this carrier for stable simple conditions. The extended predicate subset of §7 must lower structurally. Strict export emits the conditional structure; it does not flatten to a single branch. If the active target cannot preserve conditional execution, export fails with NM-FF-012 rather than emitting one sampled path.

Qiskit, Cirq, and PennyLane exporters must record whether the target framework preserves conditional semantics, and must not claim the N/M invariance proof carried over.

16. Security and resource controls

  • Branch enumeration is bounded by 2^8 before any allocation.
  • Predicate nesting depth is bounded by NM_FEED_FORWARD_MAX_PREDICATE_DEPTH = 16; this counts explicit syntactic parenthesis/negation nesting, not the height of a left-associated flat AST.
  • Predicate comparison count is independently bounded by NM_FEED_FORWARD_MAX_PREDICATE_TERMS = 16.
  • A predicate is bounded by NM_FEED_FORWARD_MAX_PREDICATE_TOKENS = 128, NM_FEED_FORWARD_MAX_PREDICATE_SOURCE_BYTES = 4096, and result width 100.
  • Seeds are reproducibility identifiers, not secrets, and must not be used as randomness for anything security-relevant.
  • Measurement outcomes and seeds must not enter telemetry without the existing privacy and consent contract.

17. Migration and compatibility

Stable N/M source, including simple if/else, match, bounded until, classical Bit expressions, and their existing QASM 3 carriers, parses and executes identically when the feature is disabled. Only the extended predicate or verification syntax is rejected with NM-FF-001. No existing Algorithm Pack entry is rewritten by this RFC; stronger QEC claims ship only as new, separately versioned packages.

18. Staged implementation

  1. Baseline freeze: fixture the existing simple conditional, match, bounded until, statevector/stabilizer execution, JSON IR, optimizer, and QASM 3 behavior before changing the carrier.
  2. Parser-only experimental: extended predicate AST, feature negotiation, NM-FF-001/004/005/006/007 diagnostics. Stable conditionals remain on their existing path.
  3. Runtime extension: evaluate extended predicates on both backends; add normative randomness consumption and seed recording without changing stable result serialization.
  4. Tier 1 verifier: branch enumeration, invariance and conservation checks, NM-FF-008/009/010.
  5. Reproducibility: experiment record, snapshot, replay, NM-FF-011.
  6. Deferred-measurement equivalence harness (§9.3).
  7. Teleportation and entanglement swapping as Pack 0.4 entries.
  8. QEC correction for the code family of NM-013.
  9. Export and tooling parity: extended QASM 3 predicate carrier, debugger branch frames, CLI/LSP/Playground.
  10. Preview evaluation: cross-platform matrix, fuzzing, hostile predicates, performance ratchets, named review.

Implementation state on 2026-07-31:

  • Stage 1 is complete and remains a separate stable-baseline fixture.
  • Stage 2 is complete in the Core parser: explicit experimental.feedForward=true, the lossless predicate AST, precedence-aware !/&&/|| parser, NM-FF-001 through NM-FF-007, source printer, JSON IR, strict sidecar reader and OpenQASM 3 carrier are fixture-backed. NM-FF-002 and NM-FF-003 name their prohibited oracle/train composition even when the feed-forward flag is absent; these regions never inherit the stable top-level simple-conditional baseline.
  • Stage 3 is complete for the bounded sampled runtime carrier. measure_all(q[start..end]) produces an ordered, statically sized BitVec<N> binding; full-width and indexed predicates execute on statevector and stabilizer. Deterministic measurements consume no seeded draw when the experimental contract is active, while the flag-off compatibility path preserves its frozen legacy draw sequence. Every negotiated run carries an explicit or generated replay seed, ordered outcomes, branch decisions, draw count, and a Tier 2 sampled label in SimulationResult. Negotiation without actual RFC-0011 syntax leaves stable metadata and seeded draw order unchanged. The carrier round-trips through the printer, JSON IR and strict OpenQASM 3 sidecar; the sidecar fails closed if its negotiation metadata or slice integrity is removed.
  • Stage 4 is complete in Core. Feature-gated assert_branch_invariant(q[index])/assert_branch_invariant(q) declarations are preserved by the printer, JSON IR, strict OpenQASM 3 sidecar and sidecar import; OpenQASM 2 rejects them rather than erasing the proof request. The verifier enumerates and projects at most eight measurement outcome bits, prunes zero-probability paths, checks probability conservation, and compares reduced density matrices on statevector or canonical reduced stabilizer signatures without lowering the 100-qubit backend to statevector. Successful teleportation carries Tier 1 verified evidence with four reachable paths; missing correction, budget overflow and conservation failure are fixture-backed as NM-FF-009/008/010. Branch-local assertions are keyed by their distinct post-preprocessing AST occurrence, even when expansion preserves the same source line, and compare only paths that reach them. Verifier/backend support drift fails closed as NM-FF-015. Assertion-free and noise-bearing programs remain legal and explicitly Tier 2.
  • Stage 5 is complete. replayNMFeedForwardBranchRecord validates a strict, bounded record, executes with its explicit or generated effective seed, and requires exact equality of outcomes, branch decisions, random-draw count and verification evidence; mismatch is NM-FF-011. Experiment records and their bounded store, workspace snapshots, and strict OpenQASM 3 sidecars retain defensive copies of the record, bind its seed to source/artifact metadata, and reject tampering or silent seed divergence. Sixteen seeded teleportation runs prove exact replay, invariant stability, and at least two branch sequences; implicit-seed replay reports deterministic provenance.
  • Stage 6 is complete as a bounded Core harness. verifyNMDeferredMeasurementEquivalence requires a successful Tier 1 feed-forward proof, enumerates its complete statevector branch mixture, and compares it with an independently executed stable unitary prefix. Ordered final measurement targets/bases, the complete basis distribution, and every declared invariant reduced density matrix are checked at the frozen tolerance. Teleportation and entanglement swapping pass; a missing coherent correction is NM-FF-014, while an interleaved gate or mismatched measurement signature is NM-FF-013. The five-qubit ceiling and Pauli-syndrome exclusion are explicit rather than silently approximated; a final state-neutral return is accepted after the ordered measurement suffix.
  • Stage 7 is complete. algorithms.teleportation3@0.4 and algorithms.entanglement_swap4@0.4 are immutable stdlib/package-registry entries with matching gallery metadata and runnable examples. The stdlib contract exports their unitary protocol prefixes; each linked example owns the measurements, corrections and assert_branch_invariant declarations so the proof request remains visible at the call site. Both examples are statevector-bounded, require the explicit feed-forward opt-in, produce four reachable Tier 1 branches, export through strict OpenQASM 3, and carry honest local-simulation/no-hardware limitations. Gallery deep links negotiate the flag, while the Worker protocol proves both flag-off rejection and flag-on execution without a parameter-sweep fallback.
  • Stage 8 is complete at the Core verification-artifact boundary defined by §9.6. Four planned NM-013 codes expose deterministic, hash-bound syndrome-to-correction maps and exact lookup source in the closed predicate subset. Canonical key-order-independent serialization, recomputed identity hashes and the 16-term decoder ceiling are enforced. Public Core exports and the spec catalog carry their explicit verification-artifact-only state and NM-014 publication dependency. Installable QEC packages, gallery cards and runnable code-state correction examples are deliberately not published by this stage.
  • Stage 9 is complete. CLI check/run/debug expose the explicit --experimental-feed-forward negotiation and retain Tier 1/Tier 2 evidence in both human and JSON output. LSP initialization, diagnostics, completions, hover and semantic tokens negotiate the same capability; the VS Code extension forwards its matching setting and highlights the experimental syntax. Statevector and stabilizer debugger timelines now include branch frames with the evaluated predicate, selected arm and measurement outcomes. The Playground shows a dedicated verification/provenance panel plus the same branch decisions in its timeline.
  • Stage 9 export behavior is fail-closed. OpenQASM 3 remains the lossless carrier. OpenQASM 2 and the current Qiskit, Cirq and PennyLane exporters return NM-FF-012 instead of erasing dynamic control; their provenance states that conditional semantics were not preserved and the invariance proof was not carried over. The official external OpenQASM parser fixture includes both the stable one-bit conditional, a negotiated compound &&/||/! predicate, and a measure_all/BitVec predicate with a retained assert_branch_invariant proof request. It asserts exact exported predicate and measurement text and that each conditional survives as one structured branching AST node. The capability manifest, changelog, stability registry, public Core exports and /api/nm/spec catalog publish the same experimental, local-simulation-only Tier boundaries.
  • Stage 10 automated preparation is complete locally. The deterministic PR profile adds 512 valid predicate round-trips and 512 hostile fail-closed predicates; the nightly profile raises each set to 10,000. A maximum Tier 1 ratchet executes eight conditioning measurements and all 256 reachable stabilizer branches under a 312.5 ms p95 and 80 MiB RSS-delta budget. Both gates, the Stage 9 conformance suite and the ordinary developer-tool checks are frozen into the Windows/Linux Node 20/22 G3 matrix.
  • Stage 10 remains open until that protected matrix produces retained evidence for one exact candidate and an independent named human completes `docs/runbooks/nm-rfc-0011-preview-review.md`. Local runs, generated fixtures, this RFC revision and the review template do not satisfy G3/G5/G10 or authorize preview promotion.

19. Acceptance criteria

  • Every diagnostic NM-FF-001 through NM-FF-015 has positive and negative fixtures.
  • Existing simple conditional, match, bounded until, runtime, IR, optimizer, and QASM 3 golden fixtures remain byte-identical with the flag disabled.
  • Teleportation produces the same target state on all four reachable branches, proven by Tier 1, and matches its deferred-measurement counterpart up to global phase.
  • Entanglement swapping passes the same pair of checks.
  • Both protocol examples resolve their exact @0.4 package, run through the Worker boundary only with explicit feed-forward negotiation, and remain represented in the bilingual Algorithm Gallery with their limitations.
  • Every §9.6 QEC artifact recomputes from commuting, independent generators; covers its frozen single-error model; rejects non-stabilizer-equivalent syndrome collisions; fails closed after tampering; and lowers to parseable feature-gated predicates without being advertised as an installable package.
  • A program whose outcome genuinely varies carries no invariant, is reported as such, and does not fail verification.
  • A fixture varying the count of deterministic measurements proves the draw sequence is unchanged, per §8.
  • At least sixteen distinct seeds produce identical invariant results and at least two distinct branch sequences.
  • Replay of a recorded seed reproduces the branch sequence exactly.
  • Feed-forward inside an oracle body and inside a train block both fail closed with the specific diagnostic, not a generic parse error.
  • A noise-bearing feed-forward program is labeled Tier 2 everywhere it is displayed.
  • Strict QASM 3 export is accepted by the official external parser, whose AST report retains the structured conditional; the strict sidecar independently round-trips the N/M predicate tree.
  • Direct Core, Worker, CLI, LSP, VS Code, and Playground results agree.
  • Documentation states that conditional execution is simulated locally and makes no claim about hardware feed-forward latency or provider support.

20. Deferred work

Repeat-until-success. Requires an unbounded measurement-conditioned loop, which has no branch bound and therefore no Tier 1 analogue. It needs an iteration budget and a termination contract, and belongs in its own RFC.

Classical decoders beyond §7. Minimum-weight perfect matching and lookup tables larger than the predicate subset require a real classical computation model between measurement and correction. Deferred with the surface code work.

Multi-round QEC scheduling. Ancilla reuse across rounds is unlocked by this RFC, but round scheduling, syndrome history typing, and decoder interfaces are a separate QEC RFC.

Hardware conditional execution. Provider feed-forward capability, latency budgets, and calibration are out of scope and must not be implied by any surface that runs this feature locally.