agent-formal-verify 0.4.11 → 0.4.12

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,9 @@
1
1
  # Changes
2
2
 
3
+ ## 0.4.12 - Kani harness time limits checked before any harness runs
4
+
5
+ The Rust checker, the mutation runner and `setup.sh rust` now check `KANI_HARNESS_TIMEOUT` before Kani runs. The setting takes a whole number from 1 to 4294967295 with an optional unit `s`, `m` or `h`, as Kani 0.68.0 reads it, and spaces around the value are ignored. For any other value, including `0`, the helpers print `UNAVAILABLE` and check no harness. Before this change, `0` stopped every harness at once, and a value that Kani rejects failed every harness with a message about a missing result file. The limit cannot be turned off, so set a long one, such as `24h`, instead. A harness that reaches the limit fails with a message that names the limit with its unit, such as `90s` for a value of `90`, and the setting that changes it. The setup guide says that each harness check can take up to the limit, so run the Rust checker and the mutation runner in the background or with a command timeout longer than the total.
6
+
3
7
  ## 0.4.11 - Antigravity install, stricter verdicts and a Kani harness time limit
4
8
 
5
9
  Kani now checks the configured crate and requires a satisfied cover witness for each passing harness. Each Rust mutation starts from a passing harness. Coverage is checked per harness source file, and the checker supports Kani stubs. A missing toolchain version file no longer hides the original compiler error.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-formal-verify",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
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",
@@ -5,6 +5,6 @@ Detailed behaviour of the verification scripts under `scripts/`. Run each helper
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
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. 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.
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
- - **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. 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.
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. So does 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
10
  - **Baseline helper ([`scripts/baseline.py`](../scripts/baseline.py))**: records what each model specifies and later names each part that changed. For TLA+ it records each run's inputs and effective checks, each reach check's selected run and inputs, and the definitions of `Spec`, of the checked and reach operators, and of the operators those reference, including the initial state. It resolves operators through sibling modules named by `EXTENDS`, including transitive imports. When a local `INSTANCE` introduces substitutions or an imported module has indented definitions that the reader cannot resolve, it compares the complete local module texts with comments and formatting removed, so edits to unrelated definitions in those modules also need review. A matrix recorded before import tracking needs review and a fresh record. It shares the matrix runner's execution plan, so a check applies only to the runs after it in its section. It does not follow `Spec` into the actions it names under `[][...]_vars`, `WF_` or `SF_`, because every correction of the transcription changes them. An operator that `Spec` names outside those, such as a fairness definition, is followed into its actions. A column-0 definition whose header it cannot read, such as an infix operator, is recorded whether or not a property references it, with the operators it references. For Lean it records the `.statements` file. For Kani it records each qualified harness name and each `kani::assume`, `kani::any_where`, `kani::cover!` and `#[kani::stub]` with its qualified owning function, including helper functions. The Rust reader supports free functions under inline modules; a Kani form in a macro, implementation or trait body, or another owner it cannot identify, fails the record. A spelling it cannot read, such as an import that renames `kani::assume`, also fails. It does not record a harness's assertions, input construction, surrounding guards or calls to assumption helpers; read `git diff` for those. Create a new record after updating the helper if it reports an unsupported record format.
@@ -74,7 +74,7 @@ bundle's driver directly, without invoking the auto-installing Cargo wrapper.
74
74
  A registered Cargo installer is not required after setup. Relative `KANI_HOME`
75
75
  paths resolve against the caller's directory before any temporary work begins.
76
76
  The helper installs no Kani runtime. `UNAVAILABLE` means not checked; follow the
77
- printed installation remedy before making any claim about the code. A compilation
77
+ printed remedy before making any claim about the code. A compilation
78
78
  error, missing harness or incomplete verifier report fails.
79
79
 
80
80
  A discovery failure that names Kani's bundled toolchain means that code Kani
@@ -43,7 +43,7 @@ Kani supports Linux and macOS on x86_64 and aarch64. See the [pinned installatio
43
43
 
44
44
  The Rust checker discovers proof harnesses and checks each selected harness separately. It reports the unwind bound and check count, rejects an insufficient bound and any cover condition that was not satisfied, and prints a concrete playback test for a failed assertion when Kani can produce one. Larger inputs and loops remain outside the reported bounds. Crate builds may obtain dependencies declared in Cargo; the template has none.
45
45
 
46
- Kani stops each harness after five minutes. Set `KANI_HARNESS_TIMEOUT` to change the limit, in the format of Kani's `--harness-timeout` option, such as `90s` or `20m`. A harness that reaches the limit fails with a message that names it, and a mutation that reaches it gets no verdict.
46
+ Kani stops each harness after five minutes. Set `KANI_HARNESS_TIMEOUT` to change the limit to a whole number from 1 to 4294967295 with an optional unit `s`, `m` or `h`, such as `90s` or `20m`. A number with no unit counts seconds. The limit cannot be turned off, so set a long one, such as `24h`, instead. For any other value, the Rust checker, the mutation runner and `setup.sh rust` print `UNAVAILABLE` and check no harness. A harness that reaches the limit fails with a message that names the limit and the setting, and a mutation that reaches it gets no verdict. Each harness check can take up to the limit, so run the command in the background or give it a timeout longer than the total.
47
47
 
48
48
  The mutation runner reads `Name.mutations` beside `Name.rs`, uses the bundled Cargo to find the crate's workspace and local dependencies, and copies them to a temporary directory with their relative paths intact. It checks the harness named by `detects` and leaves the source crate unchanged. Each harness must have a mutation that its property detects.
49
49
 
@@ -5,6 +5,7 @@
5
5
  import argparse
6
6
  import json
7
7
  import os
8
+ import re
8
9
  import subprocess
9
10
  import sys
10
11
  import tempfile
@@ -62,7 +63,14 @@ class Kani:
62
63
 
63
64
  def __init__(self):
64
65
  home = Path(os.environ.get("KANI_HOME", Path.home() / ".kani")).resolve()
65
- self.timeout = os.environ.get("KANI_HARNESS_TIMEOUT") or "5m"
66
+ self.timeout = os.environ.get("KANI_HARNESS_TIMEOUT", "").strip() or "5m"
67
+ limit = re.fullmatch(r"\+?0*([1-9][0-9]{0,9})([smh]?)", self.timeout)
68
+ if not limit or int(limit[1]) >= 2**32:
69
+ raise Unavailable(f"KANI_HARNESS_TIMEOUT={self.timeout!r} is not a harness time limit; set a whole "
70
+ "number from 1 to 4294967295 with an optional unit s, m or h, such as 90s or 20m, "
71
+ "or unset it for five minutes")
72
+ # Kani reads a number with no unit as seconds; name the unit when reporting the limit.
73
+ self.limit = limit[1] + (limit[2] or "s")
66
74
  bundle = home / f"kani-{self.version}"
67
75
  remedy = (f"run cargo install --locked kani-verifier --version {self.version} "
68
76
  "then cargo kani setup")
@@ -203,8 +211,8 @@ def harness_result(report, kani, name, returncode):
203
211
  raise CheckError("unsupported Kani result schema or version")
204
212
  if any(detail.get("harness_id") == name and detail.get("exit_status") == "timeout"
205
213
  for detail in report.get("error_details", [])):
206
- raise CheckError(f"the solver did not finish within KANI_HARNESS_TIMEOUT={kani.timeout}; "
207
- "narrow the harness or raise the limit")
214
+ raise CheckError(f"the solver did not finish within the {kani.limit} harness limit; "
215
+ "narrow the harness or set KANI_HARNESS_TIMEOUT to a longer limit")
208
216
  verification = report["verification_results"]
209
217
  summary, results = verification["summary"], verification["results"]
210
218
  if summary["status"] != "completed" or summary["executed"] != 1 or summary["total_harnesses"] != 1: