agent-formal-verify 0.4.13 → 0.4.14
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 +14 -0
- package/package.json +1 -1
- package/skills/formal-verify/SKILL.md +10 -10
- package/skills/formal-verify/references/evidence.md +1 -1
- package/skills/formal-verify/references/helpers.md +32 -3
- package/skills/formal-verify/references/setup.md +1 -1
- package/skills/formal-verify/references/tla-brief.md +1 -1
- package/skills/formal-verify/scripts/baseline.py +157 -626
- package/skills/formal-verify/scripts/kani_reader.py +592 -0
- package/skills/formal-verify/scripts/rust_source.py +74 -0
- package/skills/formal-verify/scripts/surface.py +27 -0
- package/skills/formal-verify/scripts/sync.py +5 -5
- package/skills/formal-verify/scripts/tlc.py +90 -13
- package/skills/formal-verify/scripts/tlc_report.py +516 -0
- package/skills/formal-verify/scripts/tlc_trace.py +97 -0
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 0.4.14 - an HTML report of TLC runs, and Kani baselines that say what they did not read or check
|
|
4
|
+
|
|
5
|
+
`scripts/tlc-matrix.sh` writes a self-contained HTML report when `TLC_HTML_REPORT` names a path. The report has a table of the runs and, for each failing or `reach` witness trace, a state chain to step through, the variables each step changed, and the trace as Mermaid `stateDiagram-v2` source to copy. It loads nothing over the network. The matrix runner checks the path after Java and TLC and before the first run, and replaces the file in one step. A written report leaves the printed lines and the exit status as they are without a report. A path where the report cannot be written prints an `UNAVAILABLE TLC_HTML_REPORT=...` line and exits with status 3. If the write fails after the runs, the runner prints that line and exits with status 1 when a run failed and 3 otherwise. `scripts/tlc_report.py` builds the report from the traces that `scripts/tlc_trace.py` now parses. The Mermaid labels keep the trace's TLA+ text: each character that Mermaid reads as syntax, such as `{`, `:` or `"`, is written as a Mermaid entity code, such as `#123;`, which Mermaid draws as that character. So are the space in words that Mermaid reads anywhere on a line, such as `direction LR`, and the first bracket of `[[fork]]`, `[[join]]` or `[[choice]]`, and a U+FEFF, which Mermaid reads as whitespace, so a state, transition or lasso label that holds them is kept. The last step of a liveness counter-example that ends in stuttering, which TLC prints as `State N: Stuttering` with no variables, lists the variables of the state it repeats. A matrix file name that is not valid UTF-8 shows U+FFFD in the report in place of the bytes that cannot be decoded. The table row of a failing run with a trace shows, beside the link to the trace, the lines that the matrix runner prints under the run.
|
|
6
|
+
|
|
7
|
+
`scripts/baseline.py move --module` now prints `FAIL baseline: cannot rename the recorded item '<item>', which is not a Kani harness, assume, cover or stub` and exits 1 when a recorded Kani entry holds such an item, such as one added to the record file by hand, and it leaves the record file as it was. Before this change, it printed a Python traceback.
|
|
8
|
+
|
|
9
|
+
`scripts/baseline.py` now records a Kani harness's `#[kani::should_panic]` and `#[kani::unwind(<n>)]` attributes, written alone or as any argument of `#[cfg_attr(kani, ...)]`, in the harness's value after its `cfg` guards, such as `kani::unwind(2)`, so adding, removing or changing either prints `CHANGED`. Any other form of either, such as one under `#[cfg_attr(all(kani, test), ...)]` or one that `use kani::unwind;` brings in, fails the record. The record leaves out either attribute on a function that is not a harness, which Kani refuses to compile. Before this change, the record did not read them, so adding `#[kani::should_panic]` to a harness, which then passes only when it panics, or lowering its `unwind` bound printed `UNCHANGED`. A harness without either attribute keeps its recorded value. A record that holds a harness with either attribute prints `CHANGED` once, with the attribute under `new:`; record the file again. The Rust brief puts `#[kani::unwind(N)]` on every harness, so this applies to most recorded harness files.
|
|
10
|
+
|
|
11
|
+
`scripts/baseline.py` now notes each route in a Kani harness file's crates that it cannot read, in the value of every harness in the file, as `unread(<file>: <route>; ...)` with the file relative to the harness file's directory, and `record` prints `route not read: <reason>` for each, with the file and, except for a file that fails to parse, the line. Such a route is a `mod <name>;` or an `include!` inside a macro, such as `cfg_if!`, including a `mod $name;` that a macro builds, or inside a block, such as a function body or `const _: () = { ... }`. It is also a `mod` declaration whose `#[path]` the record cannot read, an `include!` whose path it cannot read, or a file on the way that fails to parse. The record cannot tell where such a route leads, so it notes each one for every harness file in the crate, even when a route that it reads also reaches the file, and adding or removing one prints `CHANGED`. It still does not follow such a route or record its guards, so a guard changed on it prints no `CHANGED` line. `SKILL.md` and `references/evidence.md` now limit the `cfg` guards that `compare` covers to the routes that the record reads. Before this change, the record left such a route out without a word when another route reached the file. A harness file in a crate without such a route keeps its recorded value. A record that holds a harness file in a crate with one prints `CHANGED` once, with the note under `new:`; record the file again. So does a harness moved with `move` into a production file whose crate has one, and `references/helpers.md` now accepts such a move.
|
|
12
|
+
|
|
13
|
+
`scripts/baseline.py compare` now prints `NOT CHECKED <file>` for a Kani harness file in a Cargo package that `record` could not check against Kani, such as when Kani was missing or the package did not compile, when none of the file's recorded parts changed. The line under it says that `compare` cannot tell a harness that stopped compiling from one that never compiled. When Kani runs at `compare`, a `not compiled now harness <name>` line follows for each recorded harness that Kani does not compile, such as one that a dropped default feature switched off, or one behind a feature that is not a default, which never compiles. When Kani cannot run at `compare` either, a line gives the reason. Such a file does not count as a change, so `compare` exits 0 when no file prints `CHANGED`, and the `SUMMARY` line ends with `, <k> not checked`. A changed part, or a harness that Kani compiles under a name that no route the record reads gives, still prints `CHANGED`. A file that `record` did check against Kani still prints `CHANGED` with a `FAIL` line when Kani cannot run at `compare`. When `move` merges an entry recorded without Kani with one recorded with it, the merged entry now keeps the second entry's list of compiled harnesses, marked `"partial": true`, so `compare` prints `not compiled harness <name>` when one of them stops compiling. Before, `move` dropped that list. Step 3 of the skill now says to report a `NOT CHECKED` file as not checked against Kani. Before this change, `compare` printed `CHANGED` for such a file every time, so it could exit 0 only after a fresh `record`, which would accept the agents' edits as the baseline. A record made with 0.4.12, which holds no Kani list for any harness file, now prints `NOT CHECKED` for each harness file in a Cargo package whose parts are unchanged.
|
|
14
|
+
|
|
15
|
+
`scripts/baseline.py` now names the line where a `mod` item starts when it cannot read the item's `#[path]`, in the `route not read:` line that `record` prints and in the message of a `record` that no readable route reaches. Before this change, it named an earlier line: the one where the previous item or the enclosing `{` ends, or line 1 for the first item in a file, also after inner attributes such as `#![allow(dead_code)]`.
|
|
16
|
+
|
|
3
17
|
## 0.4.13 - baseline routes checked against the harnesses Kani compiles
|
|
4
18
|
|
|
5
19
|
`scripts/baseline.py` reads a route to a Kani harness file only through `mod` declarations, `#[path]` attributes and `include!` items outside macros and function bodies. It does not guess from source text whether a macro, an attribute macro or an `include!` that it cannot read builds another route. The check against the harnesses that Kani compiles covers such a route, so `#[path = "proofs.rs"] mod readable;` beside `cfg_if::cfg_if! { if #[cfg(kani)] { mod proofs; } }` fails `record` with the name that Kani gives the harness on the route inside the macro, such as `proofs::a`. When Kani cannot run at `record`, `compare` makes the check. A route inside a function body, an inline module in one included, and one through a `const _` block, are routes that the record does not read. A harness file outside any Cargo package gets no such check.
|
package/package.json
CHANGED
|
@@ -63,15 +63,15 @@ Each setup command also reports the temporary directory's free space; [tool setu
|
|
|
63
63
|
|
|
64
64
|
If a system prerequisite such as Java or elan is missing, use the [setup skill](../setup/SKILL.md) to prepare it within the user's installation constraints and existing authorization. Report any prerequisite that cannot be prepared. If `java` on PATH has no runtime, set `JAVA` to a working JDK's `java` binary for the setup helper and the matrix runner.
|
|
65
65
|
|
|
66
|
-
Read the [helper reference](references/helpers.md) before you interpret a helper's output. The helpers:
|
|
66
|
+
Read the [helper reference](references/helpers.md) before you interpret a helper's output. It says what each helper checks and prints. The helpers:
|
|
67
67
|
|
|
68
|
-
- The setup helper
|
|
69
|
-
- The matrix runner
|
|
70
|
-
- The Lean checker
|
|
71
|
-
- The Rust checker
|
|
72
|
-
- The mutation runner
|
|
73
|
-
- The sync helper
|
|
74
|
-
- The baseline helper
|
|
68
|
+
- The setup helper: [`scripts/setup.sh`](scripts/setup.sh)
|
|
69
|
+
- The matrix runner: [`scripts/tlc-matrix.sh`](scripts/tlc-matrix.sh)
|
|
70
|
+
- The Lean checker: [`scripts/lean-check.sh`](scripts/lean-check.sh)
|
|
71
|
+
- The Rust checker: [`scripts/kani-check.sh`](scripts/kani-check.sh)
|
|
72
|
+
- The mutation runner: [`scripts/mutate.py`](scripts/mutate.py)
|
|
73
|
+
- The sync helper: [`scripts/sync.py`](scripts/sync.py)
|
|
74
|
+
- The baseline helper: [`scripts/baseline.py`](scripts/baseline.py)
|
|
75
75
|
|
|
76
76
|
Run every existing model's checker and mutations once, before any agent changes a model, and record the results. Then record what the models specify with `python3 <skill-dir>/scripts/baseline.py record <record-file> <model files>`, naming each existing `.matrix`, `.statements` and Kani harness file. Put `<record-file>` in a temporary directory outside the repository, and leave its path out of every brief. For a TLA+ or Lean model a pass shows only that the old description still holds; a Kani harness runs the code as it is now. A model that still describes the code needs no agent. When it passes, refresh its header as step 5 says; when it fails, take the failure through step 4. A Kani compile error means the harness no longer fits the code, so give it to an agent. An UNCOVERED line means the mutations file lacks a bug that the property detects, not that the code fails; give the model to an agent to add one. A check that passes here and fails after the update was passing on a stale description; say so in the reply.
|
|
77
77
|
|
|
@@ -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 cover or stub changed, a Kani harness was removed, renamed, no longer compiles or had its `cfg` guards changed, 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 removed assertion or narrowed input in a Kani harness. 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.
|
|
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 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 removed assertion or narrowed input in a Kani harness. 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
|
|
|
@@ -121,7 +121,7 @@ Each fact about a model has one home:
|
|
|
121
121
|
|
|
122
122
|
When a model's covered code is gone, propose retiring it in the reply. With the user's agreement, delete its files, including a Lean model's `.statements` record, its CI steps and its row in the testing documentation. For a Kani harness in a production file, delete its `#[cfg(kani)]` module, the header comment above it and its mutations file, not the production file.
|
|
123
123
|
|
|
124
|
-
Do not add a report file per bug
|
|
124
|
+
Do not add a report file per bug or paste run tables or traces into several documents. Write an HTML report only when asked. Set `TLC_HTML_REPORT` for the matrix runner to a path outside the repository unless told otherwise. Write `<skill-dir>` in any committed command; a path from this machine fails for the next reader.
|
|
125
125
|
|
|
126
126
|
## What this does not cover
|
|
127
127
|
|
|
@@ -12,7 +12,7 @@ Include the matching meaning from this table where each kind of evidence first a
|
|
|
12
12
|
| A bounded search passes | Every input up to the stated bound was tried. |
|
|
13
13
|
| 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
14
|
| 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 the `cfg` attributes that can switch it off, and function-owned assumption, cover and stub. It does not cover a Kani harness's assertions, input construction, the conditions around its assertions
|
|
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, and function-owned assumption, cover and stub. It does not cover a Kani harness's assertions, input construction, the conditions around its assertions, calls to assumption helpers or the `cfg` attributes on a route that its record value lists under `unread(...)`; `git diff` does. |
|
|
16
16
|
| UNAVAILABLE | The tool could not run. This target was not checked; give the printed remedy. |
|
|
17
17
|
| reproduced | A deterministic test or race-detector run fails on the production code. |
|
|
18
18
|
| reachable at shipped settings | The shipped constants and callers permit the counter-example, but no production reproduction has confirmed it yet. |
|
|
@@ -3,9 +3,38 @@
|
|
|
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
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. Copy [`examples/tla-template/`](../examples/tla-template/BoundedQueue.tla) to start a spec and its matrix.
|
|
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
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. 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. 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
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.
|
|
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.
|
|
11
|
-
-
|
|
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
|
+
- Output:
|
|
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.
|
|
13
|
+
- `SYNC none: <reason>; compare the model with the code in full` means that no commit it read qualifies. The reason says whether it stopped at the last 100 commits of the model files, and names each rename and merge that it could not follow.
|
|
14
|
+
- Each `PATH <path>` line is a path the covered code has had since the sync commit: each source file through every rename since then, each file where `git grep` finds a covered name as a whole word now, and each file where a commit since then added or removed a covered name as a whole word.
|
|
15
|
+
- `MISSING <name>: <commits>` names a covered name found in none of the files searched, with the commits since the sync that added or removed it, or `no commit since the sync removed it`. A name that Rust files mention only in comments and strings also gets one. So does a name found only in data files, such as `.json`, `.yml` or `.toml` files, or in other files with no extension, such as a `Makefile`. Those files stay in the `PATH` lines.
|
|
16
|
+
- `READ <command>` is the `git log -p` command over every `PATH`, which includes commits made at an intermediate path and code that moved to another file.
|
|
17
|
+
- `FAIL <reason>` exits 1: outside a git repository, for a `--source` path that no commit has, and when `git grep` fails.
|
|
18
|
+
- Cannot see:
|
|
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
|
+
- 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
|
+
- **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
|
+
- Output of `record <record-file> <model files>`:
|
|
23
|
+
- `RECORDED <file> <digest>` for each file, with an indented `previous <digest>` line under it when the file's entry had another digest.
|
|
24
|
+
- 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
|
+
- 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
|
+
- `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.
|
|
28
|
+
- An indented `added <item>`, which only a new Kani assumption or stub prints.
|
|
29
|
+
- 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
|
+
- An indented `file is missing`: the recorded file no longer exists.
|
|
31
|
+
- 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.
|
|
32
|
+
- An indented `not checked against Kani at record, ...`: `record` could not check the file against Kani, so `compare` cannot tell a harness that stopped compiling from one that never compiled, such as one behind a feature that is not a default. When Kani runs at `compare`, an indented `not compiled now harness <name>` follows for each recorded harness that Kani does not compile. When Kani could not run at `compare` either, the next line gives the reason. When nothing else changed, the file prints `NOT CHECKED` instead of `CHANGED`. When `move` merges such an entry with one that `record` checked against Kani, the merged entry keeps the checked entry's harnesses, so `compare` still prints `not compiled harness <name>` for them and needs Kani. A `NOT CHECKED` file does not count as a change, so `compare` exits 0 when no file printed `CHANGED`. Report its harnesses as not checked against Kani, and name each harness on a `not compiled now` line under it.
|
|
33
|
+
- An indented `FAIL <reason>`: the helper could not read the file or ask Kani, which `compare` needs for a harness file that `record` checked against Kani, or Kani compiles a harness from the file under a name that no route the record reads gives. The reason names the problem.
|
|
34
|
+
- `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
|
+
- Cannot see:
|
|
36
|
+
- 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, a harness's assertions, input construction, the conditions around its assertions and calls to assumption helpers; read `git diff` for those.
|
|
38
|
+
- 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
|
+
- 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
|
+
- `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.
|
|
@@ -34,7 +34,7 @@ python3 <skill-dir>/scripts/mutate.py /path/to/models/Name.mutations
|
|
|
34
34
|
|
|
35
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.
|
|
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. 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
|
+
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.
|
|
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
|
|
|
@@ -49,7 +49,7 @@ bash <skill-dir>/scripts/tlc-matrix.sh <absolute-path>/tla/<Name>.matrix
|
|
|
49
49
|
python3 <skill-dir>/scripts/mutate.py <absolute-path>/tla/<Name>.mutations
|
|
50
50
|
```
|
|
51
51
|
|
|
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.
|
|
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.
|
|
53
53
|
|
|
54
54
|
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
55
|
|