agent-formal-verify 0.4.17 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # Changes
2
2
 
3
+ ## 0.4.19 - Protocols between processes in the TLA+ brief, TLA+ runs with stderr closed, and Kani baseline and mutation fixes
4
+
5
+ Step 1 of the skill now searches for protocols between processes or services, such as retries, timeouts, leases, idempotency keys, queue consumers and webhook handlers, and the TLA+ brief says how to model them: lost and repeated messages and crashes are separate actions that constants inject at any point, a timeout can fire whenever a caller waits, each send remains separately deliverable, including a retry with the same payload, and messages can arrive in any order, a crash keeps only durable state and a restart runs the recovery code, a request can still take effect after its caller times out, and a lease can expire while its holder still acts. The brief says which of these steps get fairness. Such a model checks `TypeOK` and the one promise whose break harms a user, and adds a property from a short list, such as at most one effect per request key or no accepted write with a lower fencing token, only when the code makes that promise. The brief now sizes each step to the atomic unit that the code guarantees, such as a critical section, a compare-and-swap, or a transaction whose isolation or conflict mechanism protects its whole relevant read/decision/write dependency, so row locks or per-key conditions alone do not collapse an unprotected predicate read and later write, and it lists mutations for these protocols.
6
+
7
+ Step 1's search for protocols between processes finds the short terms `ack`, `lease` and `ttl` inside identifiers such as `acquire_lease`, `AckDelivery` and `CACHE_TTL`, which can be the only sign of a protocol in a file, and skips words such as `release`, `packet` and `stack`. The two `rg` commands are in the "Find process protocols" section of `references/helpers.md`.
8
+
9
+ The steps for a failing check, from mapping its trace to the code through reachability, reproduction, the fix and its pull request, moved from step 4 of `SKILL.md` to `references/counter-examples.md`. The skill tells the agent to read that file for each violation, and keeps two of its rules in the body: change code only when the user asked for fixes, and never reword a property to pass. The skill body drops from 23,690 to 21,879 bytes, which leaves room under the 24,000 bytes that Antigravity loads.
10
+
11
+ A TLA+ matrix run, or a mutation run on a TLA+ model, that starts with `stderr` closed now reaches its verdicts, with Java TLC or everystate, and writes no elapsed-time lines. Before this change, Python set `sys.stderr` to `None` in such a process, so the first `[tlc]` or `[everystate]` elapsed-time report stopped the run with an `AttributeError`: a passing matrix run exited 1 and printed nothing after its `ENGINE` line.
12
+
13
+ The baseline now keeps a `kani::cover!` whose condition can run user code, such as a comparison through a user `PartialEq`, a field access that can call `Deref`, or an operator on operands whose types the reader cannot establish. It still omits empty covers, bare boolean values, comparisons of primitive literals and short-circuit combinations of them. A cover such as `kani::cover!(state.next == 3)` is now part of the recorded harness body, so an existing record can report a one-time change for it. Before this change, the baseline discarded such a cover as a simple comparison, so a cover whose comparison made a later assertion pass printed `UNCHANGED`.
14
+
15
+ A Rust mutation run now builds each mutant from its staged copy when the crate or a local dependency has a Cargo build script, including one with a custom name. Each such mutant gets a fresh source and target directory, so its build scripts run against that copy. Other crates still share one target directory across mutants. Before this change, a reused build-script output could point back to the unmutated crate or name a generated file missing from the copy.
16
+
17
+ The baseline now records a helper beside a Kani harness in a module inside a function. Before this change, the reader treated every function nested in another function as covered by its parent, even with no record of the parent, so an edit to such a helper printed `UNCHANGED`.
18
+
19
+ The baseline now names a Kani method by its owner type as written, literal arguments included. Before this change, it blanked the contents of literals in the owner name, so exchanging the implementations for `Input<'a'>` and `Input<'b'>` printed `UNCHANGED`, although the harness then checked other inputs.
20
+
21
+ The baseline now ignores the spacing that rustfmt changes between separate Rust operators, so `let y=&x;` and `let y = &x;` record the same body. It keeps a space that stops two tokens from joining or a comment from opening, and it keeps all punctuation spacing inside macro and attribute inputs, which procedural macros can read. A record from an earlier version compares under the same rules. Before this change, running rustfmt on a harness made the baseline report a changed body.
22
+
23
+
24
+ ## 0.4.18 - everystate as an optional TLA+ engine, Kani baselines that read methods and report added functions, and elapsed time for Lean mutants
25
+
26
+ Kani baselines now include helper and method signatures. Changing a generator helper from `fn input() -> u16` to `fn input() -> u8` prints `CHANGED` even when its body stays `{ kani::any() }`. Older records show the added signature on the first comparison.
27
+
28
+ The Kani baseline reads methods in impls with braced const arguments, such as `impl Input<{ WIDTH * 2 }>`. Older records can lack those methods. Review them against the original revision and record the file again.
29
+
30
+ `scripts/baseline.py` now also records the body of each method in an `impl` or trait block in a Kani module that holds a harness, or in a module under one, as the item `body <method>`, written as a harness body is. A method's name puts its block's header between angle brackets, without the whitespace that a reformat can change, such as `proofs::<impl kani::Arbitrary for State>::any`, and a `kani::assume`, `kani::any_where` or `kani::cover!` inside the method is recorded under that name. Before this change, the record did not read such a method, so changing `next: kani::any()` to `next: 0` in the `any` of an `impl kani::Arbitrary for State` beside the template's harnesses printed `UNCHANGED`, and a `kani::assume` inside a method failed the record with `cannot identify a function owner`. A `#[kani::proof]`, `#[kani::stub]`, `#[kani::should_panic]` or `#[kani::unwind]` on a method still fails the record, as does a Kani form in an `impl` or trait block inside a function body. A method outside the modules that hold harnesses is still read only for its assumptions and covers. A record made before this change prints `CHANGED` once, with the line `previous baseline did not record the methods beside its harnesses`, when the file has such a method; check each one against the original revision, then record the file again.
31
+
32
+ `setup.sh tla`, the TLA+ matrix runner and the mutation runner can now check models with the native everystate engine, version 0.4.6 or later, in place of Java TLC. Set `TLC_ENGINE=everystate`, and set `EVERYSTATE` to the binary's path when it is not on `PATH`. The everystate engine needs no JDK and no `tla2tools.jar`, and the helpers never download it. `setup.sh tla` prints an `UNAVAILABLE` line and exits 3 when the binary is missing or older than 0.4.6. The runners run everystate with `-lncheck final`, which checks temporal properties once on the complete state graph, and end the `SUMMARY` line with `(everystate <version>)`. Java TLC is still the default and the reference checker, and the setup skill still prepares only Java TLC. The everystate engine skips some of SANY's semantic checks, and its result differs from TLC's on some models, so check with Java TLC when the result must be authoritative.
33
+
34
+ Each run of the matrix runner, and each mutation run on a TLA+ model, now prints an `ENGINE` line before its first check, such as `ENGINE TLC 2.19 (tla2tools v1.7.4)`, and the HTML report that `TLC_HTML_REPORT` writes names the engine. A `TLC_ENGINE` value other than `tlc` or `everystate`, such as `TLC`, now makes `setup.sh tla` and both runners print `UNAVAILABLE TLC_ENGINE='TLC' is not supported; use 'tlc' or 'everystate'` and exit 3, before the matrix runner checks `TLC_HTML_REPORT` and before any run starts. An unset or empty `TLC_ENGINE` still selects Java TLC. Before this change, the helpers ignored `TLC_ENGINE`.
35
+
36
+ `scripts/baseline.py compare` now prints `CHANGED`, with the line `added body <function>`, when a free function or method that the record does not hold appears in a Kani module that holds a harness, or in a module under one. Such a function can shadow a production function that `use super::*;` brings in, so a harness calls it with no edit to its own body. Before this change, adding `fn claim(_window: u16, _state: State) -> Option<State> { None }` to the template's `mod proofs` made `claim_keeps_invariant` call it, so Kani passed the harness with a bug in the production `claim` and reported its assertion unreachable, while `compare` printed `UNCHANGED`. The body of an added harness is still allowed. A harness added in a module that held none puts that module's functions in the record, so each of them prints `added body <function>` once; check each one against the original revision, then record the file again. Accept a new function only when each recorded body that names it is also listed as added or changed, and revert it when an unchanged recorded body names it. For a file with no added function or method, a record made before this change prints the same status as before.
37
+
38
+ The mutation runner now reports long Lean elaborations on `stderr` as the Lean checker does. After fifteen seconds, and every thirty seconds after that, it writes `[lean] unmutated model: <N>s elapsed` while Lean elaborates the unmutated model and `[lean] mutation <label>: <N>s elapsed` while Lean elaborates a mutant, where `<label>` is the label on the mutation's `mutation` line. The printed results on `stdout` and the exit status do not change. Before this change, the runner reported only the checker's `build`, `audit` and `replay` steps, so a long mutant check printed nothing until it finished.
39
+
40
+ A Kani check, a Lean checker step or a Lean mutant check that starts with `stderr` closed now reaches its verdict and writes no elapsed-time lines. Before this change, Python set `sys.stderr` to `None` in such a process, so the first elapsed-time report stopped the check with an `AttributeError`.
41
+
3
42
  ## 0.4.17 - one Cargo build directory per Rust mutation run, and elapsed time for long Kani and Lean runs
4
43
 
5
44
  The Rust mutation runner now builds the crate for discovery, for the unmutated checks and for every mutation in one Cargo target directory, so Kani compiles the crate's dependencies once per run rather than once per mutation. Each mutation still checks a fresh copy of the crate. The target directory is in a temporary directory that the runner removes when it ends, including when `SIGTERM`, `SIGINT` or `SIGHUP` stops it. A copy keeps the modification times of the original files, which can be older than the previous mutant's build, so Kani's Cargo now compares file contents to decide what to rebuild. By modification times alone, such a copy would reuse the mutant's build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-formal-verify",
3
- "version": "0.4.17",
3
+ "version": "0.4.19",
4
4
  "description": "Model-check protocols with TLA+, prove invariants with Lean 4, and check bounded Rust functions with Kani.",
5
5
  "author": {
6
6
  "name": "Michael Denyer",
@@ -34,7 +34,7 @@ Record the sync commit, the commits read and the answers to two questions in the
34
34
 
35
35
  Then search for new targets in code no model covers, unless the user asked only to recheck the existing models.
36
36
 
37
- Search with `rg` for `pthread_cond`, `pthread_mutex`, `atomic_`, `std::condition_variable`, `sync.Cond`, `chan`, `select`, `asyncio.Condition`, `Semaphore`, `atexit` and `setjmp`. Also search for protocol state names such as `ready`, `stop`, `done`, `finished`, `pending`, `inflight`, `head`, `tail` and `exiting`. Classify each hit:
37
+ Search with `rg` for `pthread_cond`, `pthread_mutex`, `atomic_`, `std::condition_variable`, `sync.Cond`, `chan`, `select`, `asyncio.Condition`, `Semaphore`, `atexit` and `setjmp`. Also search for protocol state names such as `ready`, `stop`, `done`, `finished`, `pending`, `inflight`, `head`, `tail` and `exiting`. For protocols between processes, run the [identifier searches](references/helpers.md#find-process-protocols) for acknowledgements, leases, retries and related operations. Classify each hit:
38
38
 
39
39
  - Model hand-written protocols, including hand-overs, bounded pipelines, queues with ordered output, shutdown, cleanup, retry and lease loops.
40
40
  - Leave data-parallel loops over disjoint indices to ThreadSanitizer or the language's race detector, and say so in the reply.
@@ -45,7 +45,7 @@ For Rust functions, also search for `unsafe`, `as u32`, `as usize`, `checked_`,
45
45
 
46
46
  For each target, list the commits that fixed a bug in its code, from `git log --format='%h %s' -- <source files>`. A fix commit is one whose message, linked issue or added test names a bug in a covered function. A model that passes on the code before a fix would not have caught that bug, so the briefs replay each fix commit in the row as a mutation.
47
47
 
48
- Write a table with one row per target before modelling. A protocol and the arithmetic it depends on are separate targets. For a protocol, record its threads, shared variables, every wait and what wakes it, terminal states such as joined or closed, and resources whose ownership moves. Include slots, buffers, file handles and resources that `close` frees. For a Lean target, record the functions, their integer types and the property. Start with waits that have no escape, resources freed by two paths, and errors raised on a different thread from the one that reports them. Read the whole source file for each target so the model follows the code.
48
+ Write a table with one row per target before modelling. A protocol and the arithmetic it depends on are separate targets. For a protocol, record its threads, shared variables, every wait and what wakes it, terminal states such as joined or closed, and resources whose ownership moves. Between processes, also record the messages, durable state and failure points. Include slots, buffers, file handles and resources that `close` frees. For a Lean target, record the functions, their integer types and the property. Start with waits that have no escape, resources freed by two paths, and errors raised on a different thread from the one that reports them. Read the whole source file for each target so the model follows the code.
49
49
 
50
50
  Then ask the user whether to add an independent review of each model's properties, which costs one more agent per target. Use the host's question tool where it has one, such as `AskUserQuestion` in Claude Code. Do not ask when the request already says whether to review. When the user cannot answer, as in a headless run, skip the review and say in the reply that the properties were not reviewed.
51
51
 
@@ -54,7 +54,7 @@ Then ask the user whether to add an independent review of each model's propertie
54
54
  Prepare tools after picking targets and before launching agents. The helpers are in this skill's `scripts/` directory. Stay in the target repository and run each helper with `bash` and its absolute path. Pass absolute paths to models and matrices. [Tool setup](references/setup.md) describes the pins, caches and environment settings.
55
55
 
56
56
  - When a target needs Kani, run `bash <skill-dir>/scripts/setup.sh rust`. Before any agent starts, declare `cfg(kani)` in each target crate's `Cargo.toml`, a moved harness's production crate among them, as the Kani template's `[lints.rust]` entry does, or under `[workspace.lints.rust]` when the crate sets `lints.workspace = true`. Without it, rustc warns about every harness module, and a build with `-D warnings` fails.
57
- - When a target needs TLA+, run `bash <skill-dir>/scripts/setup.sh tla`.
57
+ - When a target needs TLA+, run `bash <skill-dir>/scripts/setup.sh tla` with the selected engine. Java TLC is the default. For a native run, use `TLC_ENGINE=everystate` and any `EVERYSTATE` binary path from [tool setup](references/setup.md). Reuse the setup settings for baseline checks, mutations and final reruns.
58
58
  - When a target needs Lean, every Lean model in the repository shares one Lake project. If the repository has none, copy `lakefile.toml`, `lake-manifest.json` and `lean-toolchain` from `<skill-dir>/examples/lean-template/` to `lean/` in the target repository, once. Then run `bash <skill-dir>/scripts/setup.sh lean <absolute-model-project-path>`.
59
59
 
60
60
  Require a successful exit and a `READY` line from each command. A helper that cannot run prints `UNAVAILABLE` and exits 3. Report it as "not checked" with its remedy. It is neither a pass nor a failure of the model. A check that ran and failed exits 1; usage errors exit 2. The setup helper reuses ready tools and installs a missing Lean pin, so the user does not need to rerun `/agent-formal-verify:setup` when a target or pin changes. Keep the installed skill files read-only and copy templates into the target repository.
@@ -81,7 +81,7 @@ Spawn one agent per target, in parallel when supported. Use the host runtime's a
81
81
 
82
82
  - the target's row from the table, with its source files and line ranges;
83
83
  - the model's name, `<Name>`, which for a new Kani harness is the stem of its production file, such as `lib`, and for a Lean target the absolute path of the Lake project, or for Kani the absolute path of the crate;
84
- - the absolute path of this skill's directory as `<skill-dir>`, and any `JAVA` setting;
84
+ - the absolute path of this skill's directory as `<skill-dir>`, and for TLA+ the selected `TLC_ENGINE` plus any `EVERYSTATE`, `JAVA`, `TLC_JAR` or `TLC_CACHE` settings used during setup;
85
85
  - the instruction to read `<skill-dir>/references/tla-brief.md` for a protocol, `<skill-dir>/references/lean-brief.md` for arithmetic, or `<skill-dir>/references/rust-brief.md` for a Rust function, in full and to follow it;
86
86
  - for an existing model, its files.
87
87
 
@@ -89,7 +89,7 @@ Name the brief file and leave its text out of the prompt. The [TLA+ brief](refer
89
89
 
90
90
  An agent writes only its own files, `tla/<Name>.tla`, `.matrix` and `.mutations`, `lean/Model/<Name>.lean`, `.mutations` and `.statements`, or the `#[cfg(kani)]` harness module in the production file that defines its Rust function and the `.mutations` file beside it, so parallel agents share none. Give one agent every Rust target in one production file. An existing Lean project keeps its layout and must pin Lean 4.20.0 or later. A Kani harness that an earlier run wrote in a crate of its own moves into its production file when the Rust brief's "Moving a harness" section allows, so it gets an agent even when it passes; otherwise its agent edits it and its `.mutations` file in place.
91
91
 
92
- When the agents have reported, delete each moved harness's old file, and its crate, workspace entry and CI steps once they hold nothing else. Then rerun every check in this thread: the matrix runner on each matrix file, the Lean checker on the whole project without a file name, the Rust checker on each crate, and the mutation runner on each mutations file. Take each verdict from these runs, not from an agent's report. For a moved harness, first run `baseline.py move` as the [helper reference](references/helpers.md) says. Then run `python3 <skill-dir>/scripts/baseline.py compare <record-file>`. It exits 1 and prints CHANGED with the changed parts when a recorded property, fairness condition, matrix line, `.statements` record, Kani harness or helper body, cover or stub changed, a Kani harness was removed, renamed, no longer compiles or had its `cfg` guards changed on a route the record reads, or a Kani assumption was added or changed. Accept a move only as that reference says. Also read `git diff` for each model that existed before this run, for the changes the record does not cover, such as a theorem newly marked `private`, a new guard in a TLA+ action, or a narrowed input in a Kani helper outside the harness's module. Each such change needs the evidence its row cites, a specification correction accepted below, or for a re-freeze another reason the Lean brief permits. Revert any change without it and give the model back to its agent with the reason. Run the comparison again until it exits 0. Report each file that prints `NOT CHECKED` as not checked against Kani.
92
+ When the agents have reported, delete each moved harness's old file, and its crate, workspace entry and CI steps once they hold nothing else. Then rerun every check in this thread: the matrix runner on each matrix file, the Lean checker on the whole project without a file name, the Rust checker on each crate, and the mutation runner on each mutations file. Take each verdict from these runs, not from an agent's report. For a moved harness, first run `baseline.py move` as the [helper reference](references/helpers.md) says. Then run `python3 <skill-dir>/scripts/baseline.py compare <record-file>`. It exits 1 and prints CHANGED with the changed parts when a recorded property, fairness condition, matrix line, `.statements` record, Kani harness or helper body, cover or stub changed, a Kani harness was removed, renamed, no longer compiles or had its `cfg` guards changed on a route the record reads, a Kani assumption was added or changed, or a function or method was added beside a Kani harness. Accept a move only as that reference says. Also read `git diff` for each model that existed before this run, for the changes the record does not cover, such as a theorem newly marked `private`, a new guard in a TLA+ action, or a narrowed input in a Kani helper outside the harness's module. Each such change needs the evidence its row cites, a specification correction accepted below, or for a re-freeze another reason the Lean brief permits. Revert any change without it and give the model back to its agent with the reason. Run the comparison again until it exits 0. Report each file that prints `NOT CHECKED` as not checked against Kani.
93
93
 
94
94
  Accept a specification correction when a reviewer finding, a missed mutation, an UNCOVERED result with source evidence, or a checked witness demonstrates a gap in the old statement. Read the old and proposed guarantees against the callers, record the evidence and decision in the target's row, and permit the corresponding re-freeze even when production code is unchanged. The correction must preserve the intended guarantee or strengthen it over the intended inputs. A broken proof alone does not justify changing a statement. A weaker guarantee or a new assumption excluding shipped inputs needs evidence of an intentional production contract change or the user's explicit agreement. Rerun all checks after the accepted correction and re-freeze. Then run `baseline.py record <record-file>` again on that model's file, and add the previous and new digests it prints to the row.
95
95
 
@@ -99,14 +99,7 @@ When the user chose the review, spawn one reviewer per model once these checks p
99
99
 
100
100
  For a closed Lean proof, compare the model's printed differential vectors with the production function in the repository's native test framework. Report the agreement count and integer widths. Claim that the proof describes the code only after this comparison agrees, or state beside the verdict that the vectors were not run.
101
101
 
102
- For each violation, in this order:
103
-
104
- 1. Read the reduced trace that the matrix runner prints under the FAIL line, the inputs that Lean's bounded search prints, or Kani's failed check and playback inputs. Map each step to a code event and source line.
105
- 2. Check reachability against the real constants and callers. If a violation occurs at `Slots=1` while the code ships `Slots=4`, decide whether the trace needs the smaller count or can also occur at the shipped one. Report the first as safe only while the count stays at the shipped value, and the second as a reachable bug. Keep the boundary configuration in the matrix either way.
106
- 3. Reproduce a reachable trace with a deterministic test, a ThreadSanitizer or race-detector run, or a stress loop using the trace's counts. Hooks, a small slot count or barriers can force the interleaving. If no practical reproduction exists, report that limitation and the model configuration that demonstrates the violation. Concrete inputs from Lean or Kani always allow a unit test. If it passes on the production code, correct the model or harness and rerun.
107
- 4. Change code only when the user asked for fixes. Otherwise report the trace, the reproduction and the proposed fix, and stop here. The model then describes the code as written, so its failing check is the record of the bug. Do not reword the property to pass, prove its negation or add runs that expect failure. Mutations for a failing property wait for the fix.
108
- 5. Fix only a violation that shipped settings can reach, and only with a reproduction from step 3 unless none is practical. Report the rest. Apply the smallest fix that prevents the trace, update the model to match, and rerun its matrix, the Lean checker or the Rust checker, then its mutations and any reproducing test. Keep the model and code change together.
109
- 6. When the user asked for commits or pull requests, use one PR per bug. Include the model, its mutations file, the fix and any reproducing test. In the description, name the theorem, `#guard`, TLC property or Kani harness that failed, and say when no test reproduces the bug. Write the rest as the Reply section says.
102
+ For each violation, read the [counter-example steps](references/counter-examples.md) in full and follow them in order: map the trace to the code, check reachability, reproduce, then fix or report. Change code only when the user asked for fixes. Do not reword the property to pass, prove its negation or add runs that expect failure.
110
103
 
111
104
  ## 5. Keep the proof, and record each result once
112
105
 
@@ -0,0 +1,10 @@
1
+ # Counter-examples
2
+
3
+ Take each violation that a check reports through these steps, in this order:
4
+
5
+ 1. Read the reduced trace that the matrix runner prints under the FAIL line, the inputs that Lean's bounded search prints, or Kani's failed check and playback inputs. Map each step to a code event and source line.
6
+ 2. Check reachability against the real constants and callers. If a violation occurs at `Slots=1` while the code ships `Slots=4`, decide whether the trace needs the smaller count or can also occur at the shipped one. Report the first as safe only while the count stays at the shipped value, and the second as a reachable bug. Keep the boundary configuration in the matrix either way.
7
+ 3. Reproduce a reachable trace with a deterministic test, a ThreadSanitizer or race-detector run, or a stress loop using the trace's counts. Hooks, a small slot count or barriers can force the interleaving. If no practical reproduction exists, report that limitation and the model configuration that demonstrates the violation. Concrete inputs from Lean or Kani always allow a unit test. If it passes on the production code, correct the model or harness and rerun.
8
+ 4. Change code only when the user asked for fixes. Otherwise report the trace, the reproduction and the proposed fix, and stop here. The model then describes the code as written, so its failing check is the record of the bug. Do not reword the property to pass, prove its negation or add runs that expect failure. Mutations for a failing property wait for the fix.
9
+ 5. Fix only a violation that shipped settings can reach, and only with a reproduction from item 3 unless none is practical. Report the rest. Apply the smallest fix that prevents the trace, update the model to match, and rerun its matrix, the Lean checker or the Rust checker, then its mutations and any reproducing test. Keep the model and code change together.
10
+ 6. When the user asked for commits or pull requests, use one PR per bug. Include the model, its mutations file, the fix and any reproducing test. In the description, name the theorem, `#guard`, TLC property or Kani harness that failed, and say when no test reproduces the bug. Write the rest as the skill's [Reply section](../SKILL.md#reply) says.
@@ -5,6 +5,7 @@ Include the matching meaning from this table where each kind of evidence first a
5
5
  | Evidence | Meaning to give |
6
6
  | --- | --- |
7
7
  | TLC passes | TLC tried every ordering of the modelled steps at the listed small sizes and found none that breaks the property. The SUMMARY line's state total is the size of that search, not a count of real runs. |
8
+ | everystate passes | The native `everystate` engine tried every ordering of the modelled steps at the listed small sizes (using `-lncheck final` for liveness) and found none that breaks the property. The runner uses in-memory storage and needs no JVM. Report the engine version. Compare speed only when both engines were timed on the same workload. Use Java TLC for an authoritative TLC/SANY verdict because everystate skips some SANY semantic checks and can produce a different liveness counter-example. |
8
9
  | Kani passes | Kani checked every input within the stated bounds and found no violation. Larger inputs are not covered. |
9
10
  | Lean passes | Lean proved the property for every input, under the listed assumptions. |
10
11
  | Kernel replay passed | Lean's kernel checked every declaration of the built modules a second time, including any that a command added without a check. `unavailable` means the pinned Lean has no `leanchecker`, so this second check did not run. |
@@ -12,7 +13,7 @@ Include the matching meaning from this table where each kind of evidence first a
12
13
  | A bounded search passes | Every input up to the stated bound was tried. |
13
14
  | Mutations detected | Deliberate bugs were planted in copies of the model, and the checks caught each one. For Lean, this shows that existing proofs fail, not that the mutated statements are false. |
14
15
  | Past fix detected | The checks fail on the behaviour before a recorded bug fix. For Lean, report proof sensitivity separately from whether a checked counterexample establishes that the property rules out that bug. |
15
- | Specification unchanged | The baseline comparison preserved each recorded run's inputs and checks, reach check's selected inputs, property and fairness definition, action subscript such as `vars`, statement record, qualified Kani harness name with its `should_panic` and `unwind` attributes and the `cfg` attributes that can switch it off on each route the record reads, function-owned assumption, cover and stub, and body of each Kani harness and of each function in a module that holds one, such as an input helper, including its assertions, input construction and the conditions around its assertions, apart from comments, layout and covers whose conditions cannot run code. It does not cover the body of a method in an `impl` or trait block or of a function outside those modules, apart from its assumptions, covers and stubs, or the `cfg` attributes on a route that its record value lists under `unread(...)`; `git diff` does. |
16
+ | Specification unchanged | The baseline comparison preserved each recorded run's inputs and checks, reach check's selected inputs, property and fairness definition, action subscript such as `vars`, statement record, qualified Kani harness name with its `should_panic` and `unwind` attributes and the `cfg` attributes that can switch it off on each route the record reads, function-owned assumption, cover and stub, and body of each Kani harness and of each function or method in a module that holds one, such as an input helper or an `impl kani::Arbitrary`, including its assertions, input construction and the conditions around its assertions, apart from comments, layout and covers whose conditions cannot run code. It also found no function or method added in those modules, other than a new harness, since one can shadow a function that a glob import brings in. It does not cover the body of a function or method outside those modules, apart from its assumptions, covers and stubs, or the `cfg` attributes on a route that its record value lists under `unread(...)`; `git diff` does. |
16
17
  | UNAVAILABLE | The tool could not run. This target was not checked; give the printed remedy. |
17
18
  | reproduced | A deterministic test or race-detector run fails on the production code. |
18
19
  | reachable at shipped settings | The shipped constants and callers permit the counter-example, but no production reproduction has confirmed it yet. |
@@ -2,11 +2,11 @@
2
2
 
3
3
  Detailed behaviour of the verification scripts under `scripts/`. Run each helper from the target repository using `bash` or `python3` with `<skill-dir>` resolved to the installed `formal-verify` skill directory.
4
4
 
5
- - **Setup helper ([`scripts/setup.sh`](../scripts/setup.sh))**: verifies the pinned TLC JAR (`tla`), checks the pinned Kani driver and bundled Rust toolchain (`rust`), and is the only helper that installs a Lean toolchain (`lean`).
6
- - **Matrix runner ([`scripts/tlc-matrix.sh`](../scripts/tlc-matrix.sh))**: runs TLC with a matrix of constants and prints one `PASS` or `FAIL` per run with its state count, then a `SUMMARY` line with the totals. Stops each run after sixty minutes, or after the limit in `TLC_TIMEOUT` as [setup](setup.md) describes, and forwards periodic elapsed-time and `Progress(...)` updates to `stderr` during long runs. A failing run prints its error trace reduced by [`scripts/tlc_trace.py`](../scripts/tlc_trace.py) to the variables each step changed. Set `TLC_HTML_REPORT=<path>` to also write a self-contained offline HTML report through [`scripts/tlc_report.py`](../scripts/tlc_report.py) with the run table, an interactive native SVG state chain, a variable diff panel, and copyable Mermaid `stateDiagram-v2` source for each failing and `reach` witness trace. The runner checks the path after Java and TLC and before the first run, and a path where it cannot write the report prints an `UNAVAILABLE TLC_HTML_REPORT=...` line with the remedy and exits 3. It replaces the report in one step, and a written report leaves `stdout` and the exit status as they are without one. If the write fails after the runs, the runner prints the same line and exits 1 when a run failed and 3 otherwise. `tlc.py ready` and `mutate.py` ignore the variable. Copy [`examples/tla-template/`](../examples/tla-template/BoundedQueue.tla) to start a spec and its matrix.
7
- - **Lean checker ([`scripts/lean-check.sh`](../scripts/lean-check.sh))**: builds every `.lean` file in the pinned Lake project and audits every declaration of every built module. It fails on a build error, a `sorry`, a declaration that rests on an axiom beyond `propext`, `Classical.choice` and `Quot.sound`, or a `.lean` file that no Lake library owns. It checks each `<Property>.witness` theorem against its property's hypotheses, and fails on a witness that states something else, as the [Lean brief](lean-brief.md) describes. It then replays every built module, and every project module it imports, through the Lean kernel with the pin's `leanchecker`, which rejects a declaration that a command added without a kernel check. A pin without `leanchecker`, such as Lean 4.20.0, passes with the replay reported as unavailable. While the build, the audit or the replay runs, the checker writes a line such as `[lean] build: 45s elapsed` to `stderr` after fifteen seconds and every thirty seconds after that. Use `--freeze` before the file names to record statement types and definition bodies in each model's `.statements` file before proving it. Freezing permits `sorry` and reports `FROZEN`, not a proof `PASS`. Later checks enforce those records and permit proof changes and added declarations. Given file names after the project, it checks only those files. Copy [`examples/lean-template/Model/BoundedQueue.lean`](../examples/lean-template/Model/BoundedQueue.lean) to start a model.
5
+ - **Setup helper ([`scripts/setup.sh`](../scripts/setup.sh))**: verifies the pinned TLC JAR (`tla`), or `everystate` 0.4.6 or later when `TLC_ENGINE=everystate`, checks the pinned Kani driver and bundled Rust toolchain (`rust`), and is the only helper that installs a Lean toolchain (`lean`).
6
+ - **Matrix runner ([`scripts/tlc-matrix.sh`](../scripts/tlc-matrix.sh))**: runs TLC (or the native `everystate` engine with `-lncheck final` when `TLC_ENGINE=everystate`, requiring no JDK or JAR) with a matrix of constants. It prints an `ENGINE` line naming the checker and version before the first run, then one `PASS` or `FAIL` per run with its state count, then a `SUMMARY` line with the totals (tagged with `(everystate <version>)` when using `everystate`). Stops each run after sixty minutes, or after the limit in `TLC_TIMEOUT` as [setup](setup.md) describes, and forwards periodic elapsed-time and `Progress(...)` updates to `stderr` during long runs. A failing run prints its error trace reduced by [`scripts/tlc_trace.py`](../scripts/tlc_trace.py) to the variables each step changed. Set `TLC_HTML_REPORT=<path>` to also write a self-contained offline HTML report through [`scripts/tlc_report.py`](../scripts/tlc_report.py) with the active engine metadata, the run table, an interactive native SVG state chain, a variable diff panel, and copyable Mermaid `stateDiagram-v2` source for each failing and `reach` witness trace. The runner checks the path after checking the TLA+ engine and before the first run, and a path where it cannot write the report prints an `UNAVAILABLE TLC_HTML_REPORT=...` line with the remedy and exits 3. It replaces the report in one step, and a written report leaves `stdout` and the exit status as they are without one. If the write fails after the runs, the runner prints the same line and exits 1 when a run failed and 3 otherwise. `tlc.py ready` and `mutate.py` ignore the variable. Copy [`examples/tla-template/`](../examples/tla-template/BoundedQueue.tla) to start a spec and its matrix.
7
+ - **Lean checker ([`scripts/lean-check.sh`](../scripts/lean-check.sh))**: builds every `.lean` file in the pinned Lake project and audits every declaration of every built module. It fails on a build error, a `sorry`, a declaration that rests on an axiom beyond `propext`, `Classical.choice` and `Quot.sound`, or a `.lean` file that no Lake library owns. It checks each `<Property>.witness` theorem against its property's hypotheses, and fails on a witness that states something else, as the [Lean brief](lean-brief.md) describes. It then replays every built module, and every project module it imports, through the Lean kernel with the pin's `leanchecker`, which rejects a declaration that a command added without a kernel check. A pin without `leanchecker`, such as Lean 4.20.0, passes with the replay reported as unavailable. While the build, the audit or the replay runs, the checker writes a line such as `[lean] build: 45s elapsed` to `stderr` after fifteen seconds and every thirty seconds after that. The mutation runner writes the same lines while it runs the checker on the unmutated model. It then writes `[lean] unmutated model: <N>s elapsed` while Lean elaborates that model, and a line such as `[lean] mutation no step: 45s elapsed`, which names the mutation, while Lean elaborates each mutant. Use `--freeze` before the file names to record statement types and definition bodies in each model's `.statements` file before proving it. Freezing permits `sorry` and reports `FROZEN`, not a proof `PASS`. Later checks enforce those records and permit proof changes and added declarations. Given file names after the project, it checks only those files. Copy [`examples/lean-template/Model/BoundedQueue.lean`](../examples/lean-template/Model/BoundedQueue.lean) to start a model.
8
8
  - **Rust checker ([`scripts/kani-check.sh`](../scripts/kani-check.sh))**: runs the pinned Kani on the crate's proof harnesses. It reports each harness's unwind bound and check count, requires a satisfied cover witness in each passing harness, rejects failed checks, and prints concrete playback tests when available. It stops each harness after five minutes, or after the limit in `KANI_HARNESS_TIMEOUT` as [setup](setup.md) describes, and fails a harness that reaches the limit with a message that names the setting. Each harness check, here or in the mutation runner, can take up to that limit, so run the command in the background or with a command timeout longer than the total. While Kani builds the crate or checks a harness, the checker and the mutation runner write a line such as `[kani] proofs::claim_keeps_invariant: 45s elapsed` to `stderr` after fifteen seconds and every thirty seconds after that. When discovery fails because code Kani compiles uses a feature newer than Kani's bundled toolchain (error E0658), the failure names that toolchain, and the [Rust brief](rust-brief.md) says what to rewrite or report. Copy [`examples/kani-template/`](../examples/kani-template/src/lib.rs) for a bounded-queue example.
9
- - **Mutation runner ([`scripts/mutate.py`](../scripts/mutate.py))**: takes a model's `<Name>.mutations` file and applies each listed bug to a temporary copy of the model. It prints `DETECTED` or `MISSED` per mutation with what failed, `UNCOVERED` for a TLA+ property or a Kani harness in the adjacent Rust file that no mutation targets or for a public theorem in a Lean model's `.statements` file whose proof no mutation makes fail, and a `SUMMARY` line. Lean names are fully qualified. A Lean `DETECTED` line means the existing proof fails; it does not establish that the statement is false or its hypotheses can hold. A Lean mutation that changes the statement of a theorem, example or `#guard`, such as renaming a definition that the statement names, reaches no verdict, and so does a mutation that edits the text of a theorem whose proof then fails. The runner matches a failing example or `#guard` to one occurrence in the original model, so a failure in an example or `#guard` that the mutation adds, or in one that it cannot match to a single original occurrence, also reaches no verdict. So does a TLA+ mutation whose check reaches the TLC time limit, or a Kani mutation whose harness reaches the Rust checker's time limit. A mutation with no verdict stops the run with a `FAIL` line. A Lean model needs its `.statements` file before its mutations run. All three templates include a mutations file.
9
+ - **Mutation runner ([`scripts/mutate.py`](../scripts/mutate.py))**: takes a model's `<Name>.mutations` file and applies each listed bug to a temporary copy of the model. Each Rust mutation gets a fresh copy of the source. When the crate or a local dependency has a Cargo build script, each mutation also gets its own target directory so the script runs for that source tree. Otherwise every mutation reuses the same source and target paths to cache dependency builds. It prints `DETECTED` or `MISSED` per mutation with what failed, `UNCOVERED` for a TLA+ property or a Kani harness in the adjacent Rust file that no mutation targets or for a public theorem in a Lean model's `.statements` file whose proof no mutation makes fail, and a `SUMMARY` line. Lean names are fully qualified. A Lean `DETECTED` line means the existing proof fails; it does not establish that the statement is false or its hypotheses can hold. A Lean mutation that changes the statement of a theorem, example or `#guard`, such as renaming a definition that the statement names, reaches no verdict, and so does a mutation that edits the text of a theorem whose proof then fails. The runner matches a failing example or `#guard` to one occurrence in the original model, so a failure in an example or `#guard` that the mutation adds, or in one that it cannot match to a single original occurrence, also reaches no verdict. So does a TLA+ mutation whose check reaches the `TLC_TIMEOUT` limit, or a Kani mutation whose harness reaches the Rust checker's time limit. TLA+ runs inherit `TLC_ENGINE`, print the `ENGINE` line before checking the unmutated model, and tag `SUMMARY` with `(everystate <version>)` when using `everystate`. A mutation with no verdict stops the run with a `FAIL` line. A Lean model needs its `.statements` file before its mutations run. All three templates include a mutations file.
10
10
  - **Sync helper ([`scripts/sync.py`](../scripts/sync.py))**: takes an existing model's files, the source files its header names as `--source` and the functions and shared variables it covers as `--name`, and lists what changed since the model was last synced. [Step 1 of the skill](../SKILL.md#1-pick-the-targets) says what to do with its `SYNC none`, `READ` and `MISSING` lines.
11
11
  - Output:
12
12
  - `SYNC <commit> <reason>` gives the sync commit: the header's `Source read at` commit when `HEAD`'s history contains it, and otherwise the last commit of the model files that qualifies, with the reason the header's commit was not used. For a model file that is also given as `--source`, such as a production file with its Kani harness, a commit qualifies only when it changed the code of the file's `#[cfg(kani)]` items and none of its other code.
@@ -19,13 +19,14 @@ Detailed behaviour of the verification scripts under `scripts/`. Run each helper
19
19
  - Documents, such as `.md`, `.txt` and `.tex` files and `README` or `CHANGELOG` with no extension, TLA+ and Lean model files, and each of the model's files that is not also given as `--source` are not searched, unless a source path has the same extension. They get no `PATH` line, and the `READ` command does not show their changes, such as a changelog entry.
20
20
  - In languages other than Rust, such as C, JavaScript or Python, a mention of a covered name in a comment or a string counts as finding it, so the name gets no `MISSING` line even when only a comment still mentions it.
21
21
  - **Baseline helper ([`scripts/baseline.py`](../scripts/baseline.py))**: records what each model specifies and later names each part that changed. [Steps 2](../SKILL.md#2-prepare-the-tools) and [3](../SKILL.md#3-model-one-target-per-agent) of the skill say when to run `record` and `compare`, list the changes that `compare` reports and say what to do with them.
22
+ - The Kani baseline includes helpers in an inline module declared inside a function when that module holds a harness. A baseline made before support for these modules can lack their helpers. Review those helpers against the original revision and record the file again.
22
23
  - Output of `record <record-file> <model files>`:
23
24
  - `RECORDED <file> <digest>` for each file, with an indented `previous <digest>` line under it when the file's entry had another digest.
24
25
  - An indented `not checked against Kani: <reason>` line: Kani is missing or the harness file's Cargo package does not compile, so the entry holds what the file's text shows alone.
25
26
  - Output of `compare <record-file>`, which exits 1 when a recorded file changed. Each indented line under `CHANGED` counts as a change, except the `not checked against Kani at record, ...` line and the lines under it:
26
27
  - `UNCHANGED <file>`, `CHANGED <file>` or `NOT CHECKED <file>` for each recorded file, then `SUMMARY <n> unchanged, <m> changed`, which ends with `, <k> not checked` when a file printed `NOT CHECKED`.
27
- - An indented `removed <item>`, or `changed <item>` with its `old:` and `new:` values. A Kani harness's value is the `cfg` guards that can switch it off, followed by its `kani::should_panic` and `kani::unwind(<n>)` attributes and the `unread(...)` note that "Cannot see" describes. When more than one route that the record reads leads to the file, the value holds each route as its crate root's path relative to the harness file's directory and its guards, such as `routes(lib.rs: unguarded; main.rs: cfg(feature = "slow"))`, so adding, removing or guarding any route, or moving a guard from one route to another, changes the harness. The item `body <function>` holds, for a harness and for each other free function in a module that holds a harness or under one, such as an input helper, the text between the function's braces without comments, without each `kani::cover!` call whose condition cannot run code, which is an item of its own, and without whitespace except one space where two tokens would otherwise join, such as `{let(window,state)=inputs();...}`. Re-indenting or rewrapping the body leaves it unchanged, but a trailing comma that a formatter adds or removes changes it. A cover whose condition holds a call, a block, an index, `?`, `return`, `break`, `continue`, `await` or `yield` can return early or change a value before an assertion, so it stays in the body, and adding one changes the body. Accept such a change when the `new:` value differs from the `old:` value only by the added cover and its condition only reads values, then record the file again. A record made before bodies were recorded prints `previous baseline did not record harness bodies` once, and one made before the other functions' bodies were recorded prints `previous baseline did not record the functions beside its harnesses` once. For those records, check each harness body against the original revision before recording the file again.
28
- - An indented `added <item>`, which only a new Kani assumption or stub prints. A `kani::any_where` assumption includes the complete call, including explicit type arguments. Older records used one representation for plain assumptions and generator predicates. For those records, check the assumptions and generator types against the original revision before recording the file again.
28
+ - An indented `removed <item>`, or `changed <item>` with its `old:` and `new:` values. A Kani harness's value is the `cfg` guards that can switch it off, followed by its `kani::should_panic` and `kani::unwind(<n>)` attributes and the `unread(...)` note that "Cannot see" describes. When more than one route that the record reads leads to the file, the value holds each route as its crate root's path relative to the harness file's directory and its guards, such as `routes(lib.rs: unguarded; main.rs: cfg(feature = "slow"))`, so adding, removing or guarding any route, or moving a guard from one route to another, changes the harness. The item `body <function>` holds, for a harness and for each other free function or method in an `impl` or trait block in a module that holds a harness or under one, such as an input helper or the `any` of an `impl kani::Arbitrary`, the normalized body without comments, without each `kani::cover!` call whose condition cannot run code, which is an item of its own, and without whitespace except one space where two tokens would otherwise join, such as `{let(window,state)=inputs();...}`. For a helper, the value includes its declaration so a change to a qualifier such as `async`, a parameter, return type or `where` clause is visible even when the body stays the same. An older record shows the added signature on its first comparison. Check it against the recorded revision before recording again. A method's name preserves literals in its block's header, so `impl Input<'a'>` and `impl Input<'b'>` keep separate records. The name puts the header, without the whitespace that a reformat can change, between angle brackets, such as `proofs::<impl kani::Arbitrary for State>::any`, and its assumptions and covers carry that name. Reformatting `let y=&x;` as `let y = &x;` leaves the body unchanged. A space that separates a compound operator counts, as does spacing between operators inside a macro's input, where the macro can inspect it. A trailing comma that a formatter adds or removes also changes the body. The reader omits an empty cover, a boolean name or literal, a comparison between scalar literals (booleans, numbers, characters or byte characters), and short-circuit combinations of those conditions. It keeps other expressions, including `state.next == 3`, as well as string and byte-string comparisons that can call stubbed library code. Field access can call `Deref` and comparisons can call an implementation of `PartialEq`. Review an added cover with a retained condition for implicit calls and side effects before accepting the change. An older record can report changed bodies once for covers it omitted. Check each reported cover against the original revision before recording the file again. A record made before bodies were recorded prints `previous baseline did not record harness bodies` once, one made before the other functions' bodies were recorded prints `previous baseline did not record the functions beside its harnesses` once, and one made before the methods' bodies were recorded prints `previous baseline did not record the methods beside its harnesses` once. For those records, check each harness body against the original revision before recording the file again.
29
+ - An indented `added <item>`, which only a new Kani assumption, stub or `body <function>` prints. A function or method added in a module that holds a harness, or under one, can shadow a function that a glob import such as `use super::*;` brings in, so a harness calls the new function with no edit to its own body. Every such function or method prints `added body <function>`, whatever its name, except a new harness, whose body is allowed with it. A harness added in a module that held none puts that module's functions in the record, so each of them prints `added body <function>` once. A record made before the other functions' or the methods' bodies were recorded also prints `added body <function>` for each body it did not record. Check a function that existed at the original revision against that revision. Accept a new function only when each recorded body that names it is listed as added or changed and its change is accepted, and revert it when an unchanged recorded body names it, since that body now calls the new function in place of the one it checked. Then record the file again. A `kani::any_where` assumption includes the complete call, including explicit type arguments. Older records used one representation for plain assumptions and generator predicates. For those records, check the assumptions and generator types against the original revision before recording the file again.
29
30
  - In a TLA+ module where a local `INSTANCE` introduces substitutions, or that has an indented definition outside a `LET` or a column-0 definition inside one, the helper compares the complete text of each local module it loaded, with comments removed, so a change to a definition that no property uses also needs review. So does a column-0 definition whose header the helper cannot read, such as an infix operator, which it records with the operators it references, whether or not a property references it.
30
31
  - An indented `file is missing`: the recorded file no longer exists.
31
32
  - An indented `not compiled harness <name>`: Kani compiles a stored harness on no route, such as when `Cargo.toml` drops a default feature that a route's `cfg` needs.
@@ -34,7 +35,18 @@ Detailed behaviour of the verification scripts under `scripts/`. Run each helper
34
35
  - `FAIL baseline: <reason>` exits 1, and a `usage:` line exits 2. `record` fails this way for a file it cannot read, such as a harness file that no route the record reads reaches or a Kani form the record cannot read, where `compare` prints an indented `FAIL` under `CHANGED`. Both fail this way for an unsupported or malformed record file.
35
36
  - Cannot see:
36
37
  - In TLA+, the actions that `Spec` names under `[][...]_vars`, `WF_` or `SF_`. It does follow the subscript of those forms and of `<<A>>_vars`, such as `vars`, in every definition it follows, and it follows an operator that `Spec` names outside those forms, such as a fairness definition, into its actions.
37
- - In Kani, the body of a method in an `impl` or trait block, such as an `impl kani::Arbitrary`, and of a function outside the modules that hold harnesses, apart from their assumptions, covers and stubs; read `git diff` for those.
38
+ - In Kani, the body of a function or method outside the modules that hold harnesses, apart from its assumptions, covers and stubs; read `git diff` for those.
38
39
  - A route that the record cannot read: a `mod` declaration or `include!` inside a macro like `cfg_if!`, including a `mod $name;` that a macro builds, or inside a block such as a function body, a `#[path]` or `include!` whose path it cannot read, or a file on the way that fails to parse. It cannot tell where such a route leads, so `record` prints `route not read: <reason>`, which names the file and, except for a file that fails to parse, the line, for each one in the harness file's crates. It adds each to every harness's value as `unread(<file>: <route>; ...)`, with the file relative to the harness file's directory. Adding or removing such a route prints `CHANGED`. It does not record the route's guards, and Kani's check fails only when the route gives the harness another module path, so a guard changed on it can print no `CHANGED` line; read `git diff` for it. When no route that it reads reaches the file, `record` fails and names each of them.
39
40
  - A Kani harness file outside any Cargo package is read from its text alone, so neither `record` nor `compare` asks Kani which harnesses it compiles.
40
41
  - `baseline.py move <record-file> <old file> <new file>` moves a model's record entry to the file the model moved to, reading the record alone, so a later `compare` checks the new file against what the old one specified, including the harnesses that Kani compiled. For a Kani harness moved into a module of its production file, add `--module <old module> <new module>`, each relative to its file, with `crate` for the file's root, such as `--module crate proofs` for harnesses that sat at the old crate's root, even when the production file is `src/queue.rs`. When the new file already has an entry, the two are merged, and an item in both fails the move. It prints `MOVED <old> -> <new>`. Accept a move when `compare` prints `UNCHANGED`, or `NOT CHECKED` for an entry that `record` could not check against Kani, and `git diff` shows the old file's harness lines in the new module with only their indentation changed, plus the `use crate as <name>;` line and the `#[cfg(kani)] mod proofs` lines around them. When the production file's crate has a route that the record cannot read, `compare` prints a `changed harness` line for each moved harness whose `new:` value only adds an `unread(...)` note to its `old:` value; accept those too, then record the new file again. Any other change, such as an edited assertion, needs the evidence its row cites.
42
+
43
+ ## Find process protocols
44
+
45
+ Run both searches from the repository root. The short terms match identifier components in names such as `acquire_lease`, `AckDelivery` and `CACHE_TTL`. Matching substrings anywhere would also return `release`, `packet` and `stack`.
46
+
47
+ ```sh
48
+ rg -n -e '(^|[^[:alnum:]])(ack|lease|ttl)([^[:lower:]]|$)' \
49
+ -e '(Ack|Lease|Ttl)([^[:lower:]]|$)' \
50
+ -e '(^|[^[:upper:]])(ACK|LEASE|TTL)([^[:lower:]]|$)'
51
+ rg -ni 'acknowledg|retr(y|ies)|time_?out|idempoten|dedup|fencing|for[[:blank:]]+update|compare_?(and_?)?(swap|set|exchange)|web_?hook|consumer'
52
+ ```
@@ -20,7 +20,7 @@ The left-behind processes share the process group of the runner that ended. To f
20
20
  ps -A -o stat,pid,ppid,pgid,command | grep '^T'
21
21
  ```
22
22
 
23
- A left-behind checker has lost its runner, so its parent is process 1 or a service manager such as `systemd --user`, and it runs a command such as TLC's `java`, `cargo-kani`, `cbmc`, `cargo`, `elan`, `lake` or `lean`. A job that you suspended yourself, such as an editor stopped with Ctrl-Z, has your shell as its parent; leave it alone. To list every process in a left-behind checker's group, including those still running, run `ps -A -o stat,pid,ppid,pgid,command` and keep the rows whose group matches the checker's. End each one with `kill -KILL <pid>`, or with `kill -TERM <pid>` followed by `kill -CONT <pid>` to let it clean up first. Do not signal the whole group, which can also hold the shell or job that started the runner.
23
+ A left-behind checker has lost its runner, so its parent is process 1 or a service manager such as `systemd --user`, and it runs a command such as TLC's `java`, `everystate`, `cargo-kani`, `cbmc`, `cargo`, `elan`, `lake` or `lean`. A job that you suspended yourself, such as an editor stopped with Ctrl-Z, has your shell as its parent; leave it alone. To list every process in a left-behind checker's group, including those still running, run `ps -A -o stat,pid,ppid,pgid,command` and keep the rows whose group matches the checker's. End each one with `kill -KILL <pid>`, or with `kill -TERM <pid>` followed by `kill -CONT <pid>` to let it clean up first. Do not signal the whole group, which can also hold the shell or job that started the runner.
24
24
 
25
25
  ## TLA+ and TLC
26
26
 
@@ -32,12 +32,25 @@ bash <skill-dir>/scripts/tlc-matrix.sh /path/to/models/Name.matrix
32
32
  python3 <skill-dir>/scripts/mutate.py /path/to/models/Name.mutations
33
33
  ```
34
34
 
35
- The plugin does not download TLC. Save `tla2tools.jar` from the [TLA+ release](https://github.com/tlaplus/tlaplus/releases/tag/v1.7.4) pinned in `scripts/tlc.py` as `~/.cache/tla/tla2tools-v1.7.4.jar`; the setup helper verifies its pinned SHA256 and names that path and release when the file is missing or does not match. Set `TLC_CACHE` to choose another cache directory. Set `TLC_JAR` to use an existing JAR; an explicitly supplied JAR is trusted and must already exist.
35
+ The plugin does not download TLC. Save `tla2tools.jar` from the [TLA+ release](https://github.com/tlaplus/tlaplus/releases/tag/v1.7.4) pinned in `scripts/tlc.py` as `~/.cache/tla/tla2tools-v1.7.4.jar`; the setup helper verifies its pinned SHA256 and names that path and release when the file is missing or does not match. Set `TLC_CACHE` to choose another cache directory. Set `TLC_JAR` to use an existing JAR; an explicitly supplied JAR is trusted and must already exist. Matrix and mutation output starts with an `ENGINE` line before any model checks. It gives the version from TLC’s help banner and identifies the pinned release or custom JAR. If a custom build omits its version, the runner records the JAR’s SHA256. The HTML report uses the same label.
36
36
 
37
- The matrix runner requires the JAR and a working Java runtime. It checks for Python 3.9 or later before running, so a failing model can always print its reduced trace. It does not download tools. Each run checks the formula its spec names `Spec` and sees only the modules beside that spec. `TLC_WORKERS` controls the TLC worker count. Set `TLC_HTML_REPORT=<path>` to write a self-contained offline HTML report (matrix summary, interactive SVG state chain, variable diffs, and copyable Mermaid source for failing and `reach` witness traces) via `scripts/tlc_report.py`; the runner checks the target path after Java and TLC and before starting TLC, prints `UNAVAILABLE` and exits 3 when it cannot write there, and writes the report atomically without changing `stdout` or exit status on success (`tlc.py ready` and `mutate.py` ignore `TLC_HTML_REPORT`). Each run stops after sixty minutes by default; set `TLC_TIMEOUT` to change the limit using a whole number from 1 to 4294967295 with an optional unit `s`, `m` or `h`, such as `90s` or `1h`. For any other value, `setup.sh tla`, the matrix runner and the mutation runner print `UNAVAILABLE` and exit 3 without running TLC. A run that reaches the limit fails with a message naming the limit and `TLC_TIMEOUT`, and a mutation run that reaches it reaches no verdict. During long runs, the runner forwards periodic elapsed-time and `Progress(...)` updates from `tlc.log` to `stderr`. Each run gives the JVM its own `java.io.tmpdir` inside the run directory, so TLC runs started at the same time do not delete each other's copy of the standard modules. A `-Djava.io.tmpdir` in `_JAVA_OPTIONS` overrides it, because the JVM reads that variable after the command line; set the temporary directory with `TMPDIR` instead.
37
+ With Java TLC, the matrix runner requires the JAR and a working Java runtime; with everystate, it needs neither. It checks for Python 3.9 or later before running, so a failing model can always print its reduced trace. It does not download tools. Each run checks the formula its spec names `Spec` and sees only the modules beside that spec. `TLC_WORKERS` sets the worker count for either engine. Set `TLC_HTML_REPORT=<path>` to write a self-contained offline HTML report (matrix summary, interactive SVG state chain, variable diffs, and copyable Mermaid source for failing and `reach` witness traces) via `scripts/tlc_report.py`; the runner checks the target path after the TLA+ engine and before the first run, prints `UNAVAILABLE` and exits 3 when it cannot write there, and writes the report atomically without changing `stdout` or exit status on success (`tlc.py ready` and `mutate.py` ignore `TLC_HTML_REPORT`). Each run stops after sixty minutes by default; set `TLC_TIMEOUT` to change the limit using a whole number from 1 to 4294967295 with an optional unit `s`, `m` or `h`, such as `90s` or `1h`. For any other value, `setup.sh tla`, the matrix runner and the mutation runner print `UNAVAILABLE` and exit 3 without running TLC. A run that reaches the limit fails with a message naming the limit and `TLC_TIMEOUT`, and a mutation run that reaches it reaches no verdict. During long runs, the runner forwards periodic elapsed-time and `Progress(...)` updates from `tlc.log` to `stderr`. With Java TLC, each run gives the JVM its own `java.io.tmpdir` inside the run directory, so TLC runs started at the same time do not delete each other's copy of the standard modules. A `-Djava.io.tmpdir` in `_JAVA_OPTIONS` overrides it, because the JVM reads that variable after the command line; set the temporary directory with `TMPDIR` instead.
38
38
 
39
39
  The mutation runner reads `Name.mutations` beside `Name.tla` and `Name.matrix`. For each mutation it copies the spec, replaces the listed text, and runs the matrix runner with the one property the mutation names, so it needs the same tools and settings.
40
40
 
41
+ ### Optional native engine (`everystate`)
42
+
43
+ Java TLC (`TLC_ENGINE=tlc`, the default) remains the reference TLA+ checker. To run matrices and mutations without a JDK or `tla2tools.jar`, set `TLC_ENGINE=everystate` with [everystate](https://github.com/mattzcarey/everystate) 0.4.6 or later (verified through `everystate --version`; never downloaded by the helpers). Set `EVERYSTATE` to the binary path when it is not on PATH. Any other `TLC_ENGINE` value prints `UNAVAILABLE` and exits 3 before checking `TLC_HTML_REPORT` or starting a run.
44
+
45
+ ```shell
46
+ # Install through Homebrew, Cargo, npm or the GitHub release archives, then check readiness:
47
+ TLC_ENGINE=everystate bash <skill-dir>/scripts/setup.sh tla
48
+ TLC_ENGINE=everystate bash <skill-dir>/scripts/tlc-matrix.sh /path/to/models/Name.matrix
49
+ TLC_ENGINE=everystate python3 <skill-dir>/scripts/mutate.py /path/to/models/Name.mutations
50
+ ```
51
+
52
+ The runner invokes `everystate` natively with `-lncheck final` so temporal properties are checked once on the complete state graph, forwards `[everystate]` elapsed-time and `Progress(...)` updates to `stderr`, and tags `SUMMARY` lines and HTML reports with `everystate <version>`. The runner uses everystate’s in-memory storage. The engine skips four SANY-only semantic checks from TLC's test suite; keep Java TLC for models that exceed RAM or when an authoritative TLC/SANY check is required.
53
+
41
54
  ## Rust and Kani
42
55
 
43
56
  Install Rust and Cargo, then install Kani 0.68.0, the version pinned in [`scripts/kani.py`](../scripts/kani.py):
@@ -82,7 +95,7 @@ Helpers print `UNAVAILABLE` and exit 3 when a required tool is missing, unusable
82
95
 
83
96
  The helpers live in this plugin, not in the target repository. In CI, check out `michael-denyer/agent-formal-verify` at a pinned commit into a separate directory and run the helpers from its `skills/formal-verify/scripts/`. Update that pin deliberately, as for any other tool. A repository that vendors the scripts instead must keep their GPL-3.0-only license headers.
84
97
 
85
- Install the chosen runtime and the pinned TLC JAR, and for Rust the pinned Kani, in the CI environment, run the setup helper, then run the matrix runner, Lean checker, Rust checker or mutation runner as a separate step. Cache elan's toolchain directory if useful, and keep the version pins with the models. Use the same `TLC_JAR` and `JAVA` settings in setup and verification.
98
+ Install the chosen runtime and the pinned TLC JAR (or an `everystate` 0.4.6+ binary when running with `TLC_ENGINE=everystate`), and for Rust the pinned Kani, in the CI environment, run the setup helper, then run the matrix runner, Lean checker, Rust checker or mutation runner as a separate step. Cache elan's toolchain directory if useful, and keep the version pins with the models. Use the same `TLC_ENGINE`, `TLC_JAR`, `JAVA` and `EVERYSTATE` settings in setup and verification.
86
99
 
87
100
  ```yaml
88
101
  - uses: actions/checkout@<commit>
@@ -1,6 +1,6 @@
1
1
  # TLA+ modelling brief
2
2
 
3
- Follow this brief to model one thread protocol with TLA+ and TLC. Your task gives the source files and line ranges, the threads and shared variables, the model's `<Name>`, the absolute path `<skill-dir>` and any `JAVA` setting. Read the whole of each source file so the model follows the code.
3
+ Follow this brief to model one thread or process protocol with TLA+ and TLC. Your task gives the source files and line ranges, the threads and shared variables, the model's `<Name>`, the absolute path `<skill-dir>` and the TLA+ engine settings from setup. Read the whole of each source file so the model follows the code.
4
4
 
5
5
  ## Files
6
6
 
@@ -14,14 +14,23 @@ The row in your task gives the commits since the model was last synced and says
14
14
 
15
15
  Apply each requirement that fits the protocol, and say in the report which did not.
16
16
 
17
- - Use one step per critical section under the mutex and one per unlocked phase, such as build, parse or consume. Add an explicit `lock` variable when multiple lock acquisitions can race.
17
+ - Make each step exactly as large as the atomic unit the code guarantees, such as a critical section under the mutex or one atomic load, store or compare-and-swap. A read followed by a write with no such guarantee is two steps. Use one step per unlocked phase that touches only the thread's own data, such as build, parse or consume. Add an explicit `lock` variable when multiple lock acquisitions can race.
18
+ - Collapse a database transaction's committed effect only when serializable isolation or the actual conflict mechanism protects the whole read/decision/write dependency relevant to the property. Identify which rows, ranges or predicates the locks or conditional writes protect, and why every competing writer must conflict or abort. `SELECT ... FOR UPDATE` alone does not establish this: locking returned rows can leave an empty result or future matching inserts unprotected. A version check or conditional insert can protect one key while leaving a capacity decision over other keys stale. Otherwise, model reads and commit separately. Let a serializable commit fail when the code retries a serialization error, and keep effects outside the database transaction separate.
18
19
  - Use a program counter per thread. Represent a condition-variable wait as a pc value in the wait set. Only a broadcast, signal or spurious wakeup can leave that set. The woken thread must retake the mutex and reread the state before acting. Give spurious wakeups no fairness requirement. In this encoding, a lost wakeup appears as a liveness violation rather than a TLC deadlock. Explain that in the header and check liveness.
19
20
  - Model resource ownership as a variable. Each slot or buffer must be free, in exactly one queue, or held by exactly one thread. Each produced item must be recorded by the consumer, awaiting hand-over, or freed.
20
21
  - When `longjmp`, an exception, a panic or `exit()` can leave a critical section without unlocking, use separate variables for the mutex's actual owner and the lock ownership recorded in the thread's live frames. An unwind can leave these inconsistent and block later acquisitions. Preserve that state so the model can detect the hang. List every allocation and exit call that can run under each lock, including out-of-memory exits.
21
22
  - Let the consumer call `next` any number of times, stop calling, or call `close` from any idle point. Include close before the first call, after the last item and after an error. When the producer has a failure path, let it fail at any item through a constant set `FailAt`.
23
+ - For a protocol between processes or services, give the network and the processes their failures as separate actions: a lost or repeated message, a crash, and a timeout. Inject loss, duplication and crash at any point, through constants such as `LoseAt`, `DupAt` and `CrashAt` whose matrix values cover every point, as `FailAt` does, and let the caller's timer fire at any point while it waits. Allow any in-flight message to arrive next. Keep one entry per send, using a bounded send ID or a count for each payload, so retries with the same request key and payload can both arrive. To model network duplication, deliver a copy without removing it. A crash keeps the durable state and clears the state in memory; a restart action then runs the recovery code. A timeout changes only the caller's state: the request may already have taken effect, or may still arrive and take effect later. For a lease, let the lease expire while its holder still acts on it, as after a pause, so a stale holder's write can reach storage. Give loss, duplication and crash no fairness. Give weak fairness to each process's steps, to delivery of a message that was not lost, to restart, and to the caller's own timer while it waits. Use at least two clients or workers, two or three retries and one crash.
22
24
  - Check small instances and boundary cases. Use slot counts of 1, 2 and the shipped count, item counts of 0, 1, 3 and 5, and one, two and three workers.
23
25
  - Name a reachable state predicate for each blocking or boundary behaviour the properties depend on, such as a full window, an empty queue, a parked waiter or an injected failure. Add `reach <Operator> | <label-substring>` to its matrix section. It selects the first run whose label contains the substring. A command-line filter skips the reach check if it excludes that selected run.
24
26
  - Check `TypeOK`, the ownership partition, delivery order, no delivery after end or error, the documented error-ordering guarantee, and no double free or leak at `closed`. For liveness, check that each blocking call returns, `close` terminates from every allowed calling state, and a run without `close` reaches the end. Require weak fairness on thread steps except consumer choices and spurious wakeups. Add strong fairness on a mutex acquisition only when a counter-example shows pure starvation by a spuriously waking peer. Name that assumption in the spec.
27
+ - For a protocol between processes or services, check `TypeOK` and the promise whose break harms a user, stated in one sentence from the code, such as "a card is charged at most once". Add a property from this list only when the code makes that promise to its callers:
28
+ - an effect happens at most once per request key, under repeated requests and retries;
29
+ - each accepted request is eventually acknowledged or reported as failed, under the fairness above;
30
+ - the lock service grants a lease to at most one process at a time, and storage accepts no write whose fencing token is lower than the highest token it has accepted;
31
+ - no update is lost when two writers read and then write the same record;
32
+ - an acknowledged write survives a crash, when the code itself orders the write to durable storage before the acknowledgement;
33
+ - a retry loop ends, by success or by giving up, including when the server answers every attempt with a permanent error.
25
34
 
26
35
  ## Keep the spec small
27
36
 
@@ -38,22 +47,23 @@ Write each fact once.
38
47
  ```
39
48
 
40
49
  - Define a guard or expression that two actions or properties share as one operator.
50
+ - Parenthesize `SUBSET`, `UNION` and `DOMAIN` when combined with binary set operators (such as `(UNION S) \cup T`) so the spec parses identically on TLC 1.7.4 and `everystate` (which follows post-2.19 precedence).
41
51
  - Keep mutations in the mutations file. The spec has no `Mutation` constant and no branch for a planted bug. When one replacement restores the behaviour before a fix, list it as a mutation instead of adding a constant that switches the fix off.
42
52
 
43
53
  ## Check
44
54
 
45
- Stay in the target repository and pass absolute paths:
55
+ Run both commands from the target repository with absolute paths. Apply the engine settings from your task to each command.
46
56
 
47
57
  ```shell
48
58
  bash <skill-dir>/scripts/tlc-matrix.sh <absolute-path>/tla/<Name>.matrix
49
59
  python3 <skill-dir>/scripts/mutate.py <absolute-path>/tla/<Name>.mutations
50
60
  ```
51
61
 
52
- The matrix runner prints PASS or FAIL per run and a SUMMARY line. A failing run prints its error trace, reduced to the variables each step changed. When the user requests an HTML report, set `TLC_HTML_REPORT=<absolute-path>.html` (outside the repository unless requested otherwise) when running `tlc-matrix.sh` to write a self-contained offline HTML report with interactive SVG traces, variable diffs, and copyable Mermaid `stateDiagram-v2` source for failing and `reach` witness traces.
62
+ The matrix runner prints PASS or FAIL per run and a SUMMARY line. A failing run prints its error trace, reduced to the variables each step changed. The initial `ENGINE` line identifies the checker in both matrix and mutation output. With everystate the `SUMMARY` line also records `(everystate <version>)`. Set `TLC_ENGINE=tlc` for a follow-up Java TLC run when SANY semantic checks, disk-backed state storage, or an authoritative TLC verdict is required. When the user requests an HTML report, set `TLC_HTML_REPORT=<absolute-path>.html` (outside the repository unless requested otherwise) when running `tlc-matrix.sh` to write a self-contained offline HTML report with engine metadata, interactive SVG traces, variable diffs, and copyable Mermaid `stateDiagram-v2` source for failing and `reach` witness traces.
53
63
 
54
64
  Each reach check prints its own PASS with the shortest witness length in states and transitions, or FAIL when the model never reaches the state. Witness searches use one worker and ignore deadlock so they can finish exploring a stopped model; `reach:` mutations run with `TLC_WORKERS` because confirming `UNREACHED` explores the full state graph without a witness trace. Attach each `reach` check—especially those paired with `detects reach:<Operator>`—to the smallest boundary `run` that exercises the predicate rather than large fault-injection configurations. The SUMMARY counts reach checks separately; its state total covers ordinary runs only. Use `detects reach:<Operator>` for a mutation that removes a required state. Reach checks do not count as properties for mutation coverage.
55
65
 
56
- Before reporting a pass, list mutations that represent plausible code bugs in the mutations file. Try replacing `while` with `if`, removing a broadcast, replacing FIFO order with stack order, leaving a flag set, or taking an item without removing it. Each mutation names the one property that must fail on it. For each fix commit in your row, add a mutation that restores the behaviour the code had before the fix, with the commit's short hash in its label. The mutation runner applies each to a copy of the spec, using only matrix runs where its named check is in scope. The same detector must pass on the original spec at those settings before a mutant can earn credit. Temporal mutations disable TLC's separate deadlock check so that the temporal property itself must fail; a deadlock alone earns no detection. Revise a property it reports as UNCOVERED, and the property or the mutation behind each MISSED line.
66
+ Before reporting a pass, list mutations that represent plausible code bugs in the mutations file. Try replacing `while` with `if`, removing a broadcast, replacing FIFO order with stack order, leaving a flag set, or taking an item without removing it. For a protocol between processes, also try removing the request-key check, acknowledging before the durable write, retrying a permanent error, splitting a compare-and-swap or transaction the code relies on into a separate read and write, and removing the version or token check from a conditional write. Each mutation names the one property that must fail on it. For each fix commit in your row, add a mutation that restores the behaviour the code had before the fix, with the commit's short hash in its label. The mutation runner applies each to a copy of the spec, using only matrix runs where its named check is in scope. The same detector must pass on the original spec at those settings before a mutant can earn credit. Temporal mutations disable TLC's separate deadlock check so that the temporal property itself must fail; a deadlock alone earns no detection. Revise a property it reports as UNCOVERED, and the property or the mutation behind each MISSED line.
57
67
 
58
68
  ## Report
59
69
 
@@ -64,4 +74,4 @@ Report only after reading the output of both commands. If either exits 3 with `U
64
74
  - each reach predicate, its selected run and witness length;
65
75
  - each FAIL line, with every step of its trace mapped to a code event and `file:line`;
66
76
  - for each counter-example, whether the shipped constants and callers can reach it;
67
- - the real-code constraints the model lacks and the properties it could not express.
77
+ - the real-code constraints the model lacks and the properties it could not express; for a protocol between processes, name the failures it does not inject and what it assumes of clocks, storage durability and database isolation.
@@ -19,10 +19,14 @@ change, and so is an added item whose kind narrows what is checked.
19
19
  items, the file and each out-of-line mod declaration that leads to the file from a crate root, through
20
20
  #[path], with each route in the file's crates that the record cannot read, such as a mod
21
21
  declaration inside a macro, and each kani::assume, kani::any_where, kani::cover! and
22
- #[kani::stub] with its owning free function, under inline modules. Unsupported owners fail. Added covers and harnesses are allowed.
23
- Added assumes and stubs are changes. Also the body of each harness and of each other free function in
24
- a module that holds a harness, or under one, without its comments, the kani::cover! calls whose
25
- conditions cannot run code, and the whitespace that a reformat can change.
22
+ #[kani::stub] with its owning free function, under inline modules, or method in an impl or trait block,
23
+ such as proofs::<impl kani::Arbitrary for State>::any. Unsupported owners fail. Added covers and harnesses are allowed.
24
+ Added assumes and stubs are changes. Also the body of each harness and of each other free function or
25
+ method in a module that holds a harness, or under one, without its comments, the kani::cover! calls whose
26
+ conditions cannot run code, and the whitespace that a reformat can change. A helper's record includes
27
+ its attributes, qualifiers, parameters, return type and where clause as well as its body. An added
28
+ function or method there is a change, since it can shadow one that a glob import brings in. An added
29
+ harness can still have its own body.
26
30
  In a Cargo package, also the recorded harnesses that Kani compiles from the file; Kani must give
27
31
  each harness it compiles there a module path that a route the record reads gives, and a harness
28
32
  that no longer compiles is a change.
@@ -55,6 +59,7 @@ import runner
55
59
  import tlc
56
60
  from kani_reader import KANI_KEY, RouteReader, compiled_problems, kani_surface
57
61
  from lean_records import read_record as read_lean_record
62
+ from rust_source import normalized
58
63
  from surface import STRING, Surface, collapse
59
64
 
60
65
  FORMAT = 2
@@ -324,6 +329,20 @@ def may_omit_generator_types(entry):
324
329
  return not entry.get("generator_types") and any(key.startswith("assume ") for key in entry["surface"])
325
330
 
326
331
 
332
+ def compact_kani_record(surface, current):
333
+ """Earlier records kept spaces between punctuation even where Rust reads two separate operators."""
334
+ compact = {}
335
+ for name, value in surface.items():
336
+ if name not in current and (item := KANI_KEY.fullmatch(name)) and "<" in item[2]:
337
+ name = item[1] + normalized(item[2]) + (item[3] or "")
338
+ if name.startswith("body ") and value != current.get(name):
339
+ value = normalized(value)
340
+ if name in compact:
341
+ raise ValueError(f"operator spacing merges recorded items named {name}; review them and record the file again")
342
+ compact[name] = value
343
+ return compact
344
+
345
+
327
346
  class KaniKind:
328
347
  """Record, compare and move the harnesses, assumptions, covers and stubs of a Kani file, checked against what Kani compiles."""
329
348
 
@@ -337,6 +356,7 @@ class KaniKind:
337
356
  entry = model_entry(self.name, surface)
338
357
  entry["generator_types"] = True
339
358
  entry["helper_bodies"] = True
359
+ entry["method_bodies"] = True
340
360
  notes = [f" route not read: {route.message}" for route in self.reader.unread(path)]
341
361
  # A harness that no longer compiles is recorded from its text alone; compare asks Kani again.
342
362
  try:
@@ -351,7 +371,12 @@ class KaniKind:
351
371
 
352
372
  def changes(self, entry, path):
353
373
  surface = kani_surface(path, self.reader)
354
- lines = differences(entry["surface"], surface, ("assume", "stub"))
374
+ recorded_surface = compact_kani_record(entry["surface"], surface)
375
+ lines = differences(recorded_surface, surface, ("assume", "stub"))
376
+ # An added function or method can shadow one that a glob import such as `use super::*;` brings in, so a
377
+ # harness calls it with no edit to a recorded body. An added harness's own body is allowed with it.
378
+ lines += [f" added {name}" for name in surface if name.startswith("body ") and name not in recorded_surface
379
+ and "harness " + name.removeprefix("body ") not in surface]
355
380
  if may_omit_generator_types(entry):
356
381
  lines.insert(0, " previous baseline stored assumptions without distinguishing any_where input types; review the original assumptions and record this file again")
357
382
  if any(name.startswith("harness ") and "body " + name.removeprefix("harness ") not in entry["surface"] for name in entry["surface"]):
@@ -359,6 +384,8 @@ class KaniKind:
359
384
  # A record's keys cannot show whether it read the functions beside its harnesses, so the entry says so.
360
385
  if not entry.get("helper_bodies") and any(name.startswith("body ") and "harness " + name.removeprefix("body ") not in surface for name in surface):
361
386
  lines.insert(0, " previous baseline did not record the functions beside its harnesses; review each of them against the original revision and record this file again")
387
+ if not entry.get("method_bodies") and any(name.startswith("body ") and "<" in name for name in surface):
388
+ lines.insert(0, " previous baseline did not record the methods beside its harnesses; review each of them against the original revision and record this file again")
362
389
  unchecked = (" not checked against Kani at record, so compare cannot tell a harness that "
363
390
  "stopped compiling from one that never compiled")
364
391
  try:
@@ -380,7 +407,7 @@ class KaniKind:
380
407
  compiled = entry.get("compiled", [])
381
408
  return (isinstance(compiled, list) and all(isinstance(name, str) for name in compiled)
382
409
  and isinstance(entry.get("partial", False), bool) and isinstance(entry.get("generator_types", False), bool)
383
- and isinstance(entry.get("helper_bodies", False), bool))
410
+ and isinstance(entry.get("helper_bodies", False), bool) and isinstance(entry.get("method_bodies", False), bool))
384
411
 
385
412
  def moved(self, entry, module, new, existing):
386
413
  surface, compiled = entry["surface"], entry.get("compiled")
@@ -400,6 +427,8 @@ class KaniKind:
400
427
  result["generator_types"] = True
401
428
  if all(part.get("helper_bodies") for part in (entry, existing) if part is not None):
402
429
  result["helper_bodies"] = True
430
+ if all(part.get("method_bodies") for part in (entry, existing) if part is not None):
431
+ result["method_bodies"] = True
403
432
  if compiled is not None:
404
433
  result["compiled"] = sorted(compiled)
405
434
  if partial: