Issue #2721: Kani mode in the emitter: the switch, harnesses and a byte-identical guard

Open and answer this issue on GitHub.

blocked, safety · opened 2026-11-22 · updated 2026-11-22 · 0 comments

Records ADR-proof-kani-v1 (Kani checks the prover’s proofs on the emitted Rust, in a mode of its own); the second of its six issues. Needs #2720

Goal

A switch that makes the emitter write a crate Kani can check — the crate attributes and one harness per checked function — while every build without the switch writes byte-identical Rust. No contracts yet: they come in the two issues after this one.

Governing decision

ADR-proof-kani-v1 D1 (a mode of its own; byte-identical output without it; nobody pays for it who does not run it), D6 (harnesses under cfg(kani), the crate attributes under cfg_attr(kani, …)). ADR-001 D1 (output is Rust).

Today (read in the code)

To build

  1. The switch. A setting kani that the emitter reads once into its state (where --bounds is read; the builder names the field). Off by default; on, it changes nothing yet. Test: tests/compiler/tests/kani_mode_off_writes_the_same_rust.nika lowered with and without the switch on a program with a counted loop, a dropped index check and a function with a precondition; the .stdout is the comparison’s result (same).
  2. The crate attributes. With the switch, the crate’s head gets #[cfg_attr(kani, feature(stmt_expr_attributes, proc_macro_hygiene))]. Test: the lowered head of the same program with the switch, as .stdout.
  3. The harnesses. With the switch, each function the prover checked (ADR-306 D14: every index and operation proved) gets a #[cfg(kani)] #[kani::proof_for_contract(name)] harness whose arguments are kani::any(); a Vec[T] argument is kani::vec::any_vec::<T, 8>() (the bound is the builder’s, named in the report; a bigger one is ADR-proof-kani-v1’s not decided). A function whose argument type has no kani::Arbitrary is not harnessed and named in the report of item 4. Test: the lowered harness of the probe program, as .stdout.
  4. The report. With the switch, nikaia test writes one line per function not harnessed and why (not harnessed: f: argument Map[String, i64] has no Arbitrary). Test: a program with such a function; its report line as .stdout.

Done when nikaia test with the switch writes a crate that cargo kani -Z function-contracts -Z loop-contracts runs (every harness passes, having no contracts yet) on the probe program of the first issue (a_counted_loop_drops_its_index_check_for_kani.nika), and without the switch the lowering of std and of every test is byte-identical (checked by lower-std before and after, its diff empty, quoted). Item 4’s commit carries Fixes #N. Each surprise is a Found: line in the report, never a new issue number.

Files and limits

Ruled out

Back to Open Issues