agent-formal-verify 0.4.12 → 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.
Files changed (43) hide show
  1. package/CHANGES.md +150 -0
  2. package/README.md +5 -3
  3. package/package.json +2 -1
  4. package/skills/formal-verify/SKILL.md +17 -19
  5. package/skills/formal-verify/examples/kani-template/src/lib.rs +5 -6
  6. package/skills/formal-verify/examples/lean-template/Model/BoundedQueue.statements +10 -45
  7. package/skills/formal-verify/examples/tla-template/BoundedQueue.matrix +16 -13
  8. package/skills/formal-verify/examples/tla-template/BoundedQueue.mutations +92 -14
  9. package/skills/formal-verify/examples/tla-template/BoundedQueue.tla +169 -28
  10. package/skills/formal-verify/references/evidence.md +1 -1
  11. package/skills/formal-verify/references/helpers.md +33 -3
  12. package/skills/formal-verify/references/lean-brief.md +2 -2
  13. package/skills/formal-verify/references/rust-brief.md +58 -6
  14. package/skills/formal-verify/references/setup.md +23 -7
  15. package/skills/formal-verify/references/tla-brief.md +3 -3
  16. package/skills/formal-verify/scripts/baseline.py +290 -261
  17. package/skills/formal-verify/scripts/kani-check.sh +3 -1
  18. package/skills/formal-verify/scripts/kani.py +127 -59
  19. package/skills/formal-verify/scripts/kani_reader.py +592 -0
  20. package/skills/formal-verify/scripts/lean-analysis.lean +387 -0
  21. package/skills/formal-verify/scripts/lean-check.sh +6 -243
  22. package/skills/formal-verify/scripts/lean.py +484 -0
  23. package/skills/formal-verify/scripts/lean_mutations.py +195 -0
  24. package/skills/formal-verify/scripts/lean_records.py +25 -0
  25. package/skills/formal-verify/scripts/mutate.py +81 -195
  26. package/skills/formal-verify/scripts/processes.py +266 -0
  27. package/skills/formal-verify/scripts/python-tools.sh +15 -0
  28. package/skills/formal-verify/scripts/runner.py +56 -0
  29. package/skills/formal-verify/scripts/rust_source.py +74 -0
  30. package/skills/formal-verify/scripts/setup.sh +18 -19
  31. package/skills/formal-verify/scripts/storage.py +207 -0
  32. package/skills/formal-verify/scripts/surface.py +27 -0
  33. package/skills/formal-verify/scripts/sync.py +401 -0
  34. package/skills/formal-verify/scripts/tlc-matrix.sh +3 -1
  35. package/skills/formal-verify/scripts/tlc.py +501 -117
  36. package/skills/formal-verify/scripts/tlc_report.py +516 -0
  37. package/skills/formal-verify/scripts/tlc_trace.py +167 -0
  38. package/skills/setup/SKILL.md +1 -1
  39. package/skills/formal-verify/scripts/lean-mutations.lean +0 -95
  40. package/skills/formal-verify/scripts/lean-statements.py +0 -161
  41. package/skills/formal-verify/scripts/lean-tools.sh +0 -24
  42. package/skills/formal-verify/scripts/tlc-tools.sh +0 -47
  43. package/skills/formal-verify/scripts/tlc-trace.py +0 -64
@@ -0,0 +1,25 @@
1
+ # Copyright (c) 2026 Michael Denyer
2
+ # SPDX-License-Identifier: GPL-3.0-only
3
+ """Read a frozen Lean statements record."""
4
+ import json
5
+
6
+
7
+ def read_record(path):
8
+ record = json.loads(path.read_text(encoding="utf-8"))
9
+ if not isinstance(record, dict) or record.get("format") != 1:
10
+ raise ValueError(f"{path}: unsupported statements format")
11
+ if not isinstance(record.get("toolchain"), str) or not isinstance(record.get("module"), str):
12
+ raise TypeError(f"{path}: missing toolchain or module")
13
+ entries = record.get("declarations")
14
+ if not isinstance(entries, list) or not entries:
15
+ raise ValueError(f"{path}: missing declarations")
16
+ seen = set()
17
+ for entry in entries:
18
+ if not isinstance(entry, dict) or not all(isinstance(entry.get(key), str) for key in ("name", "kind", "type", "typeHash")):
19
+ raise ValueError(f"{path}: malformed declaration")
20
+ if "valueHash" not in entry or entry["valueHash"] is not None and not isinstance(entry["valueHash"], str):
21
+ raise ValueError(f"{path}: malformed value hash")
22
+ if entry["name"] in seen:
23
+ raise ValueError(f"{path}: duplicate declaration {entry['name']}")
24
+ seen.add(entry["name"])
25
+ return record
@@ -18,9 +18,9 @@ using the matrix runs. A Lean mutation is elaborated in the project, the mutated
18
18
  module alone, and reported with the theorems, lemmas, examples and #guard
19
19
  lines that fail. Every public theorem recorded in the model's .statements file
20
20
  must have its proof fail on some mutation; a failing #guard does not cover it.
21
- Errors in a theorem, example or #guard count only when the unmutated model has
22
- the same statement as Lean elaborates it; renaming a definition that a statement
23
- names, for example, changes that statement and gives the mutation no verdict.
21
+ An error counts only for an original theorem, example or #guard with the same
22
+ elaborated statement. A new example cannot count by repeating an existing one's
23
+ statement. A changed statement gives the mutation no verdict.
24
24
  Lean reports fully qualified theorem names from elaborated declarations.
25
25
  This measures proof sensitivity, not whether a mutated statement is false or
26
26
  its hypotheses can hold. Private theorems are proof helpers and need no mutation. Exits 1 on a MISSED or
@@ -45,25 +45,31 @@ before it runs any tool, so a malformed mutation stops the run first.
45
45
  Usage: mutate.py <Name.mutations>
46
46
  The environment settings of tlc-matrix.sh apply to TLA+ mutations.
47
47
  """
48
- import json
49
- import shutil
50
- import subprocess
48
+ import signal
49
+
50
+ if __name__ == "__main__":
51
+ # Python's SIGINT handler raises KeyboardInterrupt, which prints a traceback when it arrives during the imports.
52
+ # Until runner.run installs its own handlers, the default action ends the process by the signal instead.
53
+ if signal.getsignal(signal.SIGINT) is signal.default_int_handler:
54
+ signal.signal(signal.SIGINT, signal.SIG_DFL)
55
+
51
56
  import sys
52
57
  import tempfile
53
58
  from collections.abc import Callable
54
- from dataclasses import dataclass, replace
59
+ from dataclasses import dataclass
55
60
  from enum import Enum
56
61
  from functools import partial
57
- from os.path import commonpath
58
62
  from pathlib import Path
59
63
 
60
- # Importing kani and tlc must not write __pycache__ into the skill directory.
64
+ # Copied skills can be read-only. Keep imported helpers from writing __pycache__ there.
61
65
  sys.dont_write_bytecode = True
62
66
 
63
67
  import kani
68
+ import lean_mutations
69
+ import runner
70
+ import storage
64
71
  import tlc
65
72
 
66
- HERE = Path(__file__).resolve().parent
67
73
  LEAN_NOTE = "NOTE Lean detections mean existing proofs fail, not that theorem statements are false or hypotheses satisfiable."
68
74
 
69
75
 
@@ -86,6 +92,7 @@ class Mutation:
86
92
  only: str
87
93
  old: str
88
94
  new: str
95
+ original: str
89
96
  source: str
90
97
 
91
98
 
@@ -145,141 +152,34 @@ def make_mutation(label, directives, model, text, language):
145
152
  stop(f"mutation '{label}': its - text occurs {count} times in {model}, want 1")
146
153
  detects, only = (lines[keyword][0].strip() if lines[keyword] else "" for keyword in SINGLE)
147
154
  new = "\n".join(lines["+"])
148
- return Mutation(label, detects, only, old, new, text.replace(old, new))
149
-
150
-
151
- def check_tla(spec, checker, plan, mutation, work):
152
- """Narrow the matrix's existing tasks to the named mutation target without changing run scope."""
153
- for module in spec.parent.glob("*.tla"):
154
- (work / module.name).write_text(module.read_text(encoding="utf-8"), encoding="utf-8")
155
- (work / spec.name).write_text(mutation.source, encoding="utf-8")
156
- covers, results = frozenset({mutation.detects}), []
157
- runner = tlc.Runner(checker, work, mutation.only, results.append, work)
158
- for task in plan:
159
- if isinstance(task, tlc.Result):
160
- if f"reach:{task.operator}" == mutation.detects:
161
- runner.check(task)
162
- elif task.reach:
163
- if f"reach:{task.reach.operator}" == mutation.detects:
164
- runner.check(task)
165
- else:
166
- checks = tuple(tlc.Check(f"{check.kind} {mutation.detects}", check.kind, (mutation.detects,))
167
- for check in task.checks if mutation.detects in check.names)
168
- if checks:
169
- runner.check(replace(task, checks=checks,
170
- check_deadlock=not any(check.kind.startswith("PROPERT") for check in checks)))
171
- if not results:
172
- return Result(Verdict.ERROR, f"no run matches '{mutation.only}' for '{mutation.detects}'")
173
- detected, errors = [], []
174
- for result in results:
175
- if result.outcome is tlc.Outcome.UNREACHED:
176
- detected.append((result, "the model never reaches this state"))
177
- elif result.outcome is tlc.Outcome.FAIL and (
178
- result.detail in (f"Error: Invariant {mutation.detects} is violated.",
179
- f"Error: Invariant {mutation.detects} is violated by the initial state:",
180
- f"Error: Property {mutation.detects} is violated by the initial state:",
181
- f"Error: Action property {mutation.detects} is violated.",
182
- "Error: Temporal properties were violated.")):
183
- detected.append((result, result.detail.removeprefix("Error: ").rstrip(".")))
184
- elif result.outcome not in (tlc.Outcome.PASS, tlc.Outcome.WITNESS):
185
- errors.extend(tlc.render(result))
186
- if errors:
187
- return Result(Verdict.ERROR, "\n".join(errors))
188
- if detected:
189
- result, error = detected[0]
190
- return Result(Verdict.DETECTED, f"{mutation.detects} fails in run '{result.label}' ({error})", covers)
191
- return Result(Verdict.MISSED, covers=covers)
192
-
193
-
194
- def lean_toolchain(project):
195
- """Return the project's Lean pin once it is ready; lean-tools.sh owns the check and its remedy."""
196
- done = subprocess.run(["bash", "-c", 'source "$1/lean-tools.sh" && lean_ready_pin "$2"', "bash", str(HERE), str(project)],
197
- capture_output=True, text=True, check=False)
198
- if done.returncode:
199
- print(done.stdout.strip())
200
- sys.exit(done.returncode)
201
- return done.stdout.strip()
202
-
203
-
204
- def lean_analysis(model, project, toolchain):
205
- """Get Lean's declaration identities and error positions, never infer them from source text."""
206
- done = subprocess.run(["elan", "run", toolchain, "lake", "--dir", str(project), "env", "lean", "--run",
207
- str(HERE / "lean-mutations.lean"), str(model)], capture_output=True, text=True, check=False)
208
- output = done.stdout + done.stderr
209
- records = [line.removeprefix("AFV_LEAN ") for line in done.stdout.splitlines() if line.startswith("AFV_LEAN ")]
210
- if done.returncode != 0 or len(records) != 1:
211
- stop(f"Lean declaration analysis did not complete:\n{output.strip()}")
155
+ return Mutation(label, detects, only, old, new, text, text.replace(old, new))
156
+
157
+
158
+ def check_tla(plan, checker, mutation, work):
212
159
  try:
213
- analysis = json.loads(records[0])
214
- for field in ("declarations", "commands", "errors"):
215
- if not isinstance(analysis[field], list):
216
- raise TypeError(f"{field} must be a list")
217
- except (ValueError, KeyError, TypeError) as error:
218
- stop(f"invalid Lean declaration analysis: {error}")
219
- return analysis
220
-
221
-
222
- def contains(item, position):
223
- return item["start"] <= position < item["end"]
224
-
225
-
226
- def original_location(model, mutation, position):
227
- """Map an unchanged command back across the one replacement; label inserted commands explicitly."""
228
- original, old, new = model.read_text(encoding="utf-8"), mutation.old, mutation.new
229
- start = original.index(old)
230
- offset = sum(len(line) + 1 for line in mutation.source.split("\n")[:position[0] - 1]) + position[1]
231
- if offset < start:
232
- original_offset, suffix = offset, ""
233
- elif offset >= start + len(new):
234
- original_offset, suffix = offset + len(old) - len(new), ""
235
- else:
236
- original_offset, suffix = start, " (mutation replacement)"
237
- line = original.count("\n", 0, original_offset) + 1
238
- return f"{model}:{line}{suffix}"
239
-
240
-
241
- def is_witness(name, declarations):
242
- parent, _, last = name.rpartition(".")
243
- return last == "witness" and any(decl["theorem"] and decl["name"] == parent for decl in declarations)
244
-
245
-
246
- def check_lean(model, project, toolchain, unmutated_statements, mutation, work):
247
- """Attribute every error to an elaborated theorem, or else a guard/example command, whose statement the unmutated model also has; the mutation covers those."""
248
- copy = work / model.name
249
- copy.write_text(mutation.source, encoding="utf-8")
250
- analysis = lean_analysis(copy, project, toolchain)
251
- if not analysis["errors"]:
252
- return Result(Verdict.MISSED)
253
- failed = []
254
- for error in analysis["errors"]:
255
- position = [error["pos"]["line"], error["pos"]["column"]]
256
- where = f"{error['fileName']}:{position[0]}:{position[1]}: {error['data']}"
257
- checks = [("theorem " + decl["name"], (decl["name"], decl["type"]))
258
- for decl in analysis["declarations"] if decl["theorem"] and contains(decl, position)]
259
- if not checks:
260
- checks = [(f"{cmd['property']} at {original_location(model, mutation, cmd['start'])}",
261
- (cmd["property"], cmd["statement"]))
262
- for cmd in analysis["commands"] if cmd["property"] and contains(cmd, position)]
263
- for name, key in checks:
264
- if key not in unmutated_statements:
265
- return Result(Verdict.ERROR, f"{name}: the mutation changes its statement, "
266
- f"so this error does not show its proof or check failing\n{where}")
267
- if error["fileName"] != str(copy) or not checks:
268
- return Result(Verdict.ERROR, where)
269
- failed.extend(name for name, (property, _) in checks
270
- if name not in failed and not is_witness(property, analysis["declarations"]))
271
- if not failed:
160
+ detection = plan.check(checker, mutation.detects, mutation.only, mutation.source, work)
161
+ except ValueError as error:
162
+ return Result(Verdict.ERROR, str(error))
163
+ covers = frozenset({mutation.detects})
164
+ if detection is None:
165
+ return Result(Verdict.MISSED, covers=covers)
166
+ return Result(Verdict.DETECTED, detection, covers)
167
+
168
+
169
+ def check_lean(broken_checks, mutation, work):
170
+ try:
171
+ failures = broken_checks(mutation, work)
172
+ except ValueError as error:
173
+ return Result(Verdict.ERROR, str(error))
174
+ if not failures:
272
175
  return Result(Verdict.MISSED)
273
- return Result(Verdict.DETECTED, "proof/check fails: " + "; ".join(failed), frozenset(failed))
176
+ return Result(Verdict.DETECTED, "proof/check fails: " + "; ".join(failures), frozenset(failures))
274
177
 
275
178
 
276
179
  def check_rust(model, project, verifier, bounds, sources, mutation, work):
277
180
  """Run Kani on the named harness in a mutated copy of the crate; the mutation covers that harness."""
278
- anchor = Path(commonpath(sources))
279
- for source in sources:
280
- if not any(parent in sources for parent in source.parents):
281
- shutil.copytree(source, work / "source" / source.relative_to(anchor), ignore=shutil.ignore_patterns("target", ".git"))
282
- copy, covers = work / "source" / project.relative_to(anchor), frozenset({mutation.detects})
181
+ copy = sources.stage(project, work / "source")
182
+ covers = frozenset({mutation.detects})
283
183
  (copy / model.relative_to(project)).write_text(mutation.source, encoding="utf-8")
284
184
  # Cargo resolves configuration from cwd, including paths outside the copied packages.
285
185
  outcome = kani.verify(copy, work, verifier, mutation.detects, bounds[mutation.detects].unwind, cwd=project)
@@ -295,43 +195,29 @@ def project_root(model, *markers):
295
195
 
296
196
 
297
197
  def tla_runner(spec, mutations):
298
- """Preserve the execution plan of every matching spec section, and check TLC once."""
198
+ """Preserve the execution plan of every matching spec section, check TLC once, and pass the unmutated
199
+ spec on every run the mutations select."""
299
200
  matrix = spec.with_suffix(".matrix")
300
201
  if not matrix.is_file():
301
202
  stop(f"{matrix} is missing; mutations use its checks and runs")
302
- section, ours = [], False
303
- for directive in tlc.directives(tlc.read_raw(matrix).split("\n")):
304
- if isinstance(directive, tlc.Malformed):
305
- stop(f"{matrix}: {directive.message}")
306
- if isinstance(directive, tlc.Spec):
307
- ours = (matrix.parent / directive.path).resolve() == spec
308
- if ours:
309
- section.append(tlc.Spec(spec.name))
310
- elif ours:
311
- section.append(directive)
312
- targets = {name for d in section if isinstance(d, tlc.Check) for name in d.names}
313
- reaches = {f"reach:{d.operator}" for d in section if isinstance(d, tlc.Reach)}
203
+ try:
204
+ plan = tlc.MatrixPlan(matrix).mutations_for(spec)
205
+ except ValueError as error:
206
+ stop(str(error))
314
207
  for mutation in mutations:
315
- if mutation.detects not in targets and mutation.detects not in reaches:
208
+ if mutation.detects not in plan.detectors:
316
209
  stop(f"mutation '{mutation.label}': detects '{mutation.detects}', which {matrix} does not check")
317
- try:
318
- checker = tlc.Tlc()
319
- except tlc.Unavailable as error:
320
- print(error)
321
- sys.exit(3)
322
- return targets, partial(check_tla, spec, checker, tuple(tlc.execution_plan(section)))
323
-
324
-
325
- def frozen_theorems(model):
326
- """Return the theorem names the model's .statements record holds."""
327
- record = model.with_suffix(".statements")
328
- if not record.is_file():
329
- stop(f"{record} is missing; freeze the model with lean-check.sh --freeze before checking its mutations")
330
- try:
331
- return {entry["name"] for entry in json.loads(record.read_text(encoding="utf-8"))["declarations"]
332
- if entry["kind"] == "theorem"}
333
- except (OSError, ValueError, KeyError, TypeError) as error:
334
- stop(f"invalid statements record {record}: {error}")
210
+ try:
211
+ plan.selected(mutation.detects, mutation.only)
212
+ except ValueError as error:
213
+ stop(f"mutation '{mutation.label}': {error}")
214
+ checker = tlc.Tlc()
215
+ with tempfile.TemporaryDirectory(prefix="formal-tlc-originals-", dir=storage.ensure_temp_root()) as temporary:
216
+ try:
217
+ plan.check_originals(checker, [(mutation.detects, mutation.only) for mutation in mutations], Path(temporary))
218
+ except ValueError as error:
219
+ stop(str(error))
220
+ return plan.properties, partial(check_tla, plan, checker)
335
221
 
336
222
 
337
223
  def lean_runner(model, mutations):
@@ -339,38 +225,25 @@ def lean_runner(model, mutations):
339
225
  project = project_root(model, "lakefile.toml", "lakefile.lean")
340
226
  if project is None:
341
227
  stop(f"{model} is in no Lake project")
342
- frozen = frozen_theorems(model)
343
- toolchain = lean_toolchain(project)
344
- analysis = lean_analysis(model, project, toolchain)
345
- if analysis["errors"]:
346
- stop(f"unmutated Lean model does not elaborate: {analysis['errors'][0]['data']}")
347
- targets = {"theorem " + decl["name"] for decl in analysis["declarations"]
348
- if decl["theorem"] and not decl["private"] and decl["name"] in frozen
349
- and not is_witness(decl["name"], analysis["declarations"])}
350
- statements = {(decl["name"], decl["type"]) for decl in analysis["declarations"] if decl["theorem"]}
351
- statements |= {(cmd["property"], cmd["statement"]) for cmd in analysis["commands"]
352
- if cmd["property"] and cmd["statement"] is not None}
353
- return targets, partial(check_lean, model, project, toolchain, statements)
228
+ targets, broken_checks = lean_mutations.prepare(model, project)
229
+ return targets, partial(check_lean, broken_checks)
354
230
 
355
231
 
356
232
  def rust_runner(model, mutations):
357
233
  project = project_root(model, "Cargo.toml")
358
234
  if project is None:
359
235
  stop(f"{model} is in no Rust crate")
360
- try:
361
- verifier = kani.Kani()
362
- except kani.Unavailable as error:
363
- print(f"UNAVAILABLE {error}")
364
- sys.exit(3)
365
- with tempfile.TemporaryDirectory(prefix="formal-kani-discover-") as temporary:
236
+ verifier = kani.Kani()
237
+ with tempfile.TemporaryDirectory(prefix="formal-kani-discover-", dir=storage.ensure_temp_root()) as temporary:
366
238
  work = Path(temporary)
367
239
  try:
368
240
  bounds = kani.discover(project, work, verifier)
369
- sources = verifier.source_roots(project)
241
+ sources = verifier.crate_sources(project)
370
242
  for mutation in mutations:
371
243
  if mutation.detects not in bounds:
372
244
  stop(f"mutation '{mutation.label}': unknown harness '{mutation.detects}'")
373
245
  selected = {mutation.detects for mutation in mutations}
246
+ kani.reject_should_panic(bounds, sorted(selected))
374
247
  for name in sorted(selected):
375
248
  outcome = kani.verify(project, work, verifier, name, bounds[name].unwind)
376
249
  if outcome.verdict is not kani.Verdict.PASS:
@@ -382,7 +255,8 @@ def rust_runner(model, mutations):
382
255
  return targets, partial(check_rust, model, project, verifier, bounds, sources)
383
256
 
384
257
 
385
- # Each runner checks the names the mutations detect, then returns the names they must cover and a check for one mutation.
258
+ # Each runner checks the names the mutations detect and that the unmutated model passes the checks they select,
259
+ # then returns the names they must cover and a check for one mutation.
386
260
  # A TLA+ or Rust mutation covers the name it detects; a Lean mutation covers the theorems that fail on it.
387
261
  LANGUAGES = {
388
262
  ".tla": Language("TLA+", needs_detects=True, takes_only=True, runner=tla_runner),
@@ -392,6 +266,12 @@ LANGUAGES = {
392
266
 
393
267
 
394
268
  def main():
269
+ # A FAIL line can carry Lean's UTF-8 messages, so write them as UTF-8 whatever the locale, as lean.py does.
270
+ sys.stdout.reconfigure(encoding="utf-8", errors="surrogateescape")
271
+ # Users run this file directly, so no shell helper has checked the version for the Rust runner.
272
+ if sys.version_info < (3, 9): # noqa: UP036 -- ruff assumes the floor this line enforces
273
+ print(f"UNAVAILABLE python3 is Python {'.'.join(map(str, sys.version_info[:3]))}; install Python 3.9 or later")
274
+ sys.exit(3)
395
275
  if len(sys.argv) != 2:
396
276
  stop("usage: mutate.py <Name.mutations>", 2)
397
277
  path = Path(sys.argv[1]).resolve()
@@ -404,16 +284,18 @@ def main():
404
284
  language, text = LANGUAGES[model.suffix], model.read_text(encoding="utf-8")
405
285
  mutations = [make_mutation(label, directives, model, text, language) for label, directives in parse(path)]
406
286
  targets, check = language.runner(model, mutations)
287
+ storage.warn_runtime()
288
+ temp_root = storage.ensure_temp_root()
407
289
 
408
290
  detected, covered = 0, set()
409
291
  for mutation in mutations:
410
- with tempfile.TemporaryDirectory() as work:
292
+ with tempfile.TemporaryDirectory(dir=temp_root) as work:
411
293
  result = check(mutation, Path(work))
412
294
  if result.verdict is Verdict.ERROR:
413
295
  stop(f"mutation '{mutation.label}' did not reach a verdict:\n{result.detail.strip()}")
414
296
  detected += result.verdict is Verdict.DETECTED
415
297
  covered |= result.covers
416
- print(f"{result.verdict.value} {mutation.label}" + (f": {result.detail}" if result.detail else ""))
298
+ print(f"{result.verdict.value} {mutation.label}" + (f": {result.detail}" if result.detail else ""), flush=True)
417
299
  uncovered = sorted(targets - covered)
418
300
  for name in uncovered:
419
301
  print(f"UNCOVERED {name}")
@@ -421,8 +303,12 @@ def main():
421
303
  print(LEAN_NOTE)
422
304
  print(f"SUMMARY {detected} of {len(mutations)} mutations detected"
423
305
  + (f", {len(uncovered)} properties without a mutation" if uncovered else ""))
424
- sys.exit(0 if detected == len(mutations) and not uncovered else 1)
306
+ return 0 if detected == len(mutations) and not uncovered else 1
425
307
 
426
308
 
427
309
  if __name__ == "__main__":
428
- main()
310
+ try:
311
+ runner.run(main)
312
+ except lean_mutations.AnalysisError as error:
313
+ print(error)
314
+ sys.exit(error.status)