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 +39 -0
- package/package.json +1 -1
- package/skills/formal-verify/SKILL.md +6 -13
- package/skills/formal-verify/references/counter-examples.md +10 -0
- package/skills/formal-verify/references/evidence.md +2 -1
- package/skills/formal-verify/references/helpers.md +19 -7
- package/skills/formal-verify/references/setup.md +17 -4
- package/skills/formal-verify/references/tla-brief.md +16 -6
- package/skills/formal-verify/scripts/baseline.py +35 -6
- package/skills/formal-verify/scripts/kani.py +14 -8
- package/skills/formal-verify/scripts/kani_reader.py +64 -24
- package/skills/formal-verify/scripts/lean_mutations.py +8 -5
- package/skills/formal-verify/scripts/mutate.py +30 -16
- package/skills/formal-verify/scripts/processes.py +1 -1
- package/skills/formal-verify/scripts/rust_source.py +26 -15
- package/skills/formal-verify/scripts/tlc.py +170 -65
- package/skills/formal-verify/scripts/tlc_report.py +17 -10
- package/skills/setup/SKILL.md +1 -1
|
@@ -17,16 +17,19 @@ Matrix file, one directive per line (# starts a comment):
|
|
|
17
17
|
A malformed directive prints a FAIL line and the runner goes on to the next.
|
|
18
18
|
|
|
19
19
|
Usage: tlc-matrix.sh <matrix-file> [label-substring]
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
TLC_ENGINE=<name> TLA+ engine: tlc (default) or everystate
|
|
21
|
+
TLC_JAR=<path> use this existing tla2tools.jar (tlc engine)
|
|
22
|
+
TLC_CACHE=<dir> where the pinned jar lives (default ~/.cache/tla, tlc engine)
|
|
23
|
+
JAVA=<path> the java binary (default: java on PATH, tlc engine)
|
|
24
|
+
EVERYSTATE=<path> the everystate binary (default: everystate on PATH, everystate engine)
|
|
25
|
+
TLC_WORKERS=<n> worker threads (default auto)
|
|
24
26
|
TLC_TIMEOUT=<lim> per-run time limit, e.g. 90s, 30m, 1h (default 60m)
|
|
25
27
|
TLC_HTML_REPORT=<path> write a self-contained HTML report to this path
|
|
26
28
|
|
|
27
29
|
Usage: tlc.py ready
|
|
28
|
-
Checks
|
|
29
|
-
the temporary directory's free space as
|
|
30
|
+
Checks TLC_ENGINE, TLC_TIMEOUT, and the selected engine (Java and the pinned or supplied JAR for tlc;
|
|
31
|
+
everystate 0.4.6 or later for everystate), then reports the temporary directory's free space as
|
|
32
|
+
storage.py report does. setup.sh tla runs it.
|
|
30
33
|
"""
|
|
31
34
|
from __future__ import annotations
|
|
32
35
|
|
|
@@ -47,6 +50,7 @@ import sys
|
|
|
47
50
|
import tempfile
|
|
48
51
|
import time
|
|
49
52
|
import uuid
|
|
53
|
+
from contextlib import suppress
|
|
50
54
|
from dataclasses import dataclass, replace
|
|
51
55
|
from enum import Enum
|
|
52
56
|
from pathlib import Path
|
|
@@ -180,7 +184,67 @@ def _read_progress(log_path, offset, partial):
|
|
|
180
184
|
return new_offset, new_partial, latest
|
|
181
185
|
|
|
182
186
|
|
|
183
|
-
|
|
187
|
+
EVERYSTATE_VERSION = re.compile(r"^everystate (\d+)\.(\d+)\.(\d+)$")
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
class _Engine:
|
|
191
|
+
"""Shared timeout, worker, disk-warning and watched-run logic for TLA+ engines."""
|
|
192
|
+
name = "TLC"
|
|
193
|
+
log_tag = "tlc"
|
|
194
|
+
summary_suffix = ""
|
|
195
|
+
label = ""
|
|
196
|
+
ready_line = ""
|
|
197
|
+
|
|
198
|
+
def __init__(self):
|
|
199
|
+
timeout_raw = os.environ.get("TLC_TIMEOUT", "").strip() or DEFAULT_TIMEOUT
|
|
200
|
+
self.limit, self.timeout_seconds = runner.parse_limit("TLC_TIMEOUT", timeout_raw, "run time limit", "sixty minutes")
|
|
201
|
+
self.workers = os.environ.get("TLC_WORKERS") or "auto"
|
|
202
|
+
self._warned_disk = False
|
|
203
|
+
|
|
204
|
+
def _run_watched(self, command, log, progress_label=""):
|
|
205
|
+
if not self._warned_disk:
|
|
206
|
+
self._warned_disk = True
|
|
207
|
+
storage.warn_runtime()
|
|
208
|
+
start = time.monotonic()
|
|
209
|
+
deadline = start + self.timeout_seconds
|
|
210
|
+
|
|
211
|
+
def watch(process):
|
|
212
|
+
"""Wait for the checker, report its progress and stop it at the deadline; return its status and whether it timed out."""
|
|
213
|
+
next_report = start + PROGRESS_DELAY
|
|
214
|
+
offset, partial, latest = 0, "", ""
|
|
215
|
+
while True:
|
|
216
|
+
now = time.monotonic()
|
|
217
|
+
remaining = deadline - now
|
|
218
|
+
if remaining <= 0:
|
|
219
|
+
processes.stop_process(process)
|
|
220
|
+
return process.returncode, True
|
|
221
|
+
if now >= next_report:
|
|
222
|
+
offset, partial, found = _read_progress(log, offset, partial)
|
|
223
|
+
if found:
|
|
224
|
+
latest = found
|
|
225
|
+
elapsed = int(now - start)
|
|
226
|
+
prefix = f"[{self.log_tag}] {progress_label}: " if progress_label else f"[{self.log_tag}] "
|
|
227
|
+
body = f"{elapsed}s elapsed: {latest}" if latest else f"{elapsed}s elapsed"
|
|
228
|
+
# Python sets sys.stderr to None when the process starts with stderr closed.
|
|
229
|
+
# A closed or unwritable stderr must not fail a run whose checker passed.
|
|
230
|
+
if sys.stderr is not None:
|
|
231
|
+
with suppress(OSError):
|
|
232
|
+
sys.stderr.write(f"{prefix}{body}\n")
|
|
233
|
+
sys.stderr.flush()
|
|
234
|
+
next_report = now + PROGRESS_INTERVAL
|
|
235
|
+
wait_for = min(remaining, max(0.05, next_report - time.monotonic()))
|
|
236
|
+
try:
|
|
237
|
+
process.wait(timeout=wait_for)
|
|
238
|
+
return process.returncode, False
|
|
239
|
+
except subprocess.TimeoutExpired:
|
|
240
|
+
continue
|
|
241
|
+
|
|
242
|
+
with log.open("w", encoding="utf-8") as stream:
|
|
243
|
+
returncode, timed_out = processes.guarded(command, watch, stdout=stream, stderr=subprocess.STDOUT)
|
|
244
|
+
return returncode, read_raw(log), timed_out
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class Tlc(_Engine):
|
|
184
248
|
"""The pinned TLC, checked once. Nothing here downloads it."""
|
|
185
249
|
version = "v1.7.4"
|
|
186
250
|
sha256 = "936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88"
|
|
@@ -192,8 +256,7 @@ class Tlc:
|
|
|
192
256
|
return Path(os.environ.get("TLC_CACHE") or Path.home() / ".cache/tla") / f"tla2tools-{cls.version}.jar"
|
|
193
257
|
|
|
194
258
|
def __init__(self):
|
|
195
|
-
|
|
196
|
-
self.limit, self.timeout_seconds = runner.parse_limit("TLC_TIMEOUT", timeout_raw, "run time limit", "sixty minutes")
|
|
259
|
+
super().__init__()
|
|
197
260
|
self.java = os.environ.get("JAVA") or "java"
|
|
198
261
|
try:
|
|
199
262
|
# The JVM prints in the platform encoding, which need not be UTF-8.
|
|
@@ -217,24 +280,30 @@ class Tlc:
|
|
|
217
280
|
if status and "TLC - provides model checking" not in output:
|
|
218
281
|
raise runner.Unavailable(f"UNAVAILABLE tlc2.TLC cannot run from {self.jar}; save a working JAR from {self.release} "
|
|
219
282
|
f"or set TLC_JAR\n{output.rstrip()}")
|
|
220
|
-
|
|
221
|
-
|
|
283
|
+
# The TLC version in the help banner and the tla2tools release tag use different numbering.
|
|
284
|
+
banner = re.search(r"^\s*(?:TLC - provides model checking[^\n]*? - Version |TLC2 Version )([0-9][\w.+-]*)", output, re.MULTILINE)
|
|
285
|
+
checker = f"TLC {banner[1]}" if banner else "TLC"
|
|
286
|
+
jar_source = "custom JAR" if supplied else f"tla2tools {self.version}"
|
|
287
|
+
if supplied and not banner:
|
|
288
|
+
jar_source += f", version unreported, sha256 {self._jar_digest()}"
|
|
289
|
+
self.label = f"{checker} ({jar_source})"
|
|
290
|
+
self.ready_line = f"READY TLC {self.jar}"
|
|
291
|
+
|
|
292
|
+
def _jar_digest(self):
|
|
293
|
+
try:
|
|
294
|
+
return hashlib.sha256(Path(self.jar).read_bytes()).hexdigest()
|
|
295
|
+
except OSError as error:
|
|
296
|
+
raise runner.Unavailable(f"UNAVAILABLE cannot read {self.jar}; check its permissions") from error
|
|
222
297
|
|
|
223
298
|
def _check_pinned_jar(self):
|
|
224
299
|
if not Path(self.jar).is_file():
|
|
225
300
|
raise runner.Unavailable(f"UNAVAILABLE {self.jar} is missing; save tla2tools.jar from {self.release} there, or set TLC_JAR")
|
|
226
|
-
|
|
227
|
-
got = hashlib.sha256(Path(self.jar).read_bytes()).hexdigest()
|
|
228
|
-
except OSError as error:
|
|
229
|
-
raise runner.Unavailable(f"UNAVAILABLE cannot read {self.jar}; check its permissions") from error
|
|
301
|
+
got = self._jar_digest()
|
|
230
302
|
if got != self.sha256:
|
|
231
303
|
raise runner.Unavailable(f"UNAVAILABLE {self.jar} has sha256 {got}, want {self.sha256}")
|
|
232
304
|
|
|
233
305
|
def run(self, directory, module, config, reach, workers=None, progress_label=""):
|
|
234
306
|
"""Run TLC on module in directory with config; return (exit_status, log, timed_out)."""
|
|
235
|
-
if not self._warned_disk:
|
|
236
|
-
self._warned_disk = True
|
|
237
|
-
storage.warn_runtime()
|
|
238
307
|
log = directory / "tlc.log"
|
|
239
308
|
(directory / "MC.cfg").write_text(config, encoding="utf-8")
|
|
240
309
|
chosen_workers = workers if workers is not None else ("1" if reach else self.workers)
|
|
@@ -244,39 +313,71 @@ class Tlc:
|
|
|
244
313
|
command = [self.java, "-XX:+UseParallelGC", f"-Djava.io.tmpdir={java_tmp}", "-cp", self.jar, "tlc2.TLC", "-workers", chosen_workers,
|
|
245
314
|
*(["-deadlock"] if reach else []), "-cleanup", "-metadir", str(directory / "states"),
|
|
246
315
|
"-config", str(directory / "MC.cfg"), str(directory / f"{module}.tla")]
|
|
247
|
-
|
|
248
|
-
deadline = start + self.timeout_seconds
|
|
316
|
+
return self._run_watched(command, log, progress_label)
|
|
249
317
|
|
|
250
|
-
def watch(process):
|
|
251
|
-
"""Wait for TLC, report its progress and stop it at the deadline; return its status and whether it timed out."""
|
|
252
|
-
next_report = start + PROGRESS_DELAY
|
|
253
|
-
offset, partial, latest = 0, "", ""
|
|
254
|
-
while True:
|
|
255
|
-
now = time.monotonic()
|
|
256
|
-
remaining = deadline - now
|
|
257
|
-
if remaining <= 0:
|
|
258
|
-
processes.stop_process(process)
|
|
259
|
-
return process.returncode, True
|
|
260
|
-
if now >= next_report:
|
|
261
|
-
offset, partial, found = _read_progress(log, offset, partial)
|
|
262
|
-
if found:
|
|
263
|
-
latest = found
|
|
264
|
-
elapsed = int(now - start)
|
|
265
|
-
prefix = f"[tlc] {progress_label}: " if progress_label else "[tlc] "
|
|
266
|
-
body = f"{elapsed}s elapsed: {latest}" if latest else f"{elapsed}s elapsed"
|
|
267
|
-
sys.stderr.write(f"{prefix}{body}\n")
|
|
268
|
-
sys.stderr.flush()
|
|
269
|
-
next_report = now + PROGRESS_INTERVAL
|
|
270
|
-
wait_for = min(remaining, max(0.05, next_report - time.monotonic()))
|
|
271
|
-
try:
|
|
272
|
-
process.wait(timeout=wait_for)
|
|
273
|
-
return process.returncode, False
|
|
274
|
-
except subprocess.TimeoutExpired:
|
|
275
|
-
continue
|
|
276
318
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
319
|
+
class Everystate(_Engine):
|
|
320
|
+
"""The native everystate engine, checked once. Nothing here downloads it."""
|
|
321
|
+
name = "everystate"
|
|
322
|
+
log_tag = "everystate"
|
|
323
|
+
min_version = (0, 4, 6)
|
|
324
|
+
min_version_text = "0.4.6"
|
|
325
|
+
release = "https://github.com/mattzcarey/everystate/releases/tag/v0.4.6"
|
|
326
|
+
remedy = (
|
|
327
|
+
f"install everystate {min_version_text} or later from {release} "
|
|
328
|
+
"(or with Homebrew, Cargo or npm) and set EVERYSTATE if it is not on PATH"
|
|
329
|
+
)
|
|
330
|
+
|
|
331
|
+
def __init__(self):
|
|
332
|
+
super().__init__()
|
|
333
|
+
self.binary = os.environ.get("EVERYSTATE", "").strip() or "everystate"
|
|
334
|
+
try:
|
|
335
|
+
probe = processes.run_captured([self.binary, "--version"], errors="replace")
|
|
336
|
+
status, stdout, stderr = probe.returncode, probe.stdout, probe.stderr
|
|
337
|
+
except OSError as error:
|
|
338
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} cannot run: {error}; {self.remedy}") from error
|
|
339
|
+
output = (stdout + stderr).strip()
|
|
340
|
+
if status:
|
|
341
|
+
detail = f"\n{output}" if output else ""
|
|
342
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} --version failed; {self.remedy}{detail}")
|
|
343
|
+
first_line = next((line.strip() for line in stdout.splitlines() if line.strip()), "")
|
|
344
|
+
match = EVERYSTATE_VERSION.fullmatch(first_line)
|
|
345
|
+
if not match:
|
|
346
|
+
detail = f"\n{output}" if output else ""
|
|
347
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} did not report an everystate version; {self.remedy}{detail}")
|
|
348
|
+
parsed = tuple(int(part) for part in match.groups())
|
|
349
|
+
self.version = ".".join(match.groups())
|
|
350
|
+
if parsed < self.min_version:
|
|
351
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} is everystate {self.version}, want {self.min_version_text} or later; {self.remedy}")
|
|
352
|
+
self.resolved_binary = shutil.which(self.binary) or self.binary
|
|
353
|
+
self.label = f"everystate {self.version}"
|
|
354
|
+
self.summary_suffix = f" ({self.label})"
|
|
355
|
+
self.ready_line = f"READY everystate {self.version} {self.resolved_binary}"
|
|
356
|
+
|
|
357
|
+
def run(self, directory, module, config, reach, workers=None, progress_label=""):
|
|
358
|
+
"""Run everystate on module in directory with config; return (exit_status, log, timed_out)."""
|
|
359
|
+
log = directory / "tlc.log"
|
|
360
|
+
(directory / "MC.cfg").write_text(config, encoding="utf-8")
|
|
361
|
+
chosen_workers = workers if workers is not None else ("1" if reach else self.workers)
|
|
362
|
+
# -lncheck final checks temporal properties once on the complete graph instead of at periodic checkpoints.
|
|
363
|
+
command = [
|
|
364
|
+
self.binary, "-workers", chosen_workers,
|
|
365
|
+
*(["-deadlock"] if reach else []),
|
|
366
|
+
"-lncheck", "final",
|
|
367
|
+
"-config", str(directory / "MC.cfg"),
|
|
368
|
+
str(directory / f"{module}.tla"),
|
|
369
|
+
]
|
|
370
|
+
return self._run_watched(command, log, progress_label)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def engine():
|
|
374
|
+
"""Return the selected TLA+ engine from TLC_ENGINE (default: tlc)."""
|
|
375
|
+
raw = os.environ.get("TLC_ENGINE", "").strip()
|
|
376
|
+
if not raw or raw == "tlc":
|
|
377
|
+
return Tlc()
|
|
378
|
+
if raw == "everystate":
|
|
379
|
+
return Everystate()
|
|
380
|
+
raise runner.Unavailable(f"UNAVAILABLE TLC_ENGINE={raw!r} is not supported; use 'tlc' or 'everystate'")
|
|
280
381
|
|
|
281
382
|
|
|
282
383
|
class Outcome(Enum):
|
|
@@ -298,9 +399,9 @@ class Violation:
|
|
|
298
399
|
initial: bool
|
|
299
400
|
|
|
300
401
|
|
|
301
|
-
# TLC
|
|
402
|
+
# TLC 2.19 prints "Temporal properties were violated."; newer TLC names the violated property or properties.
|
|
302
403
|
VIOLATION = re.compile(r"Error: (?:(Invariant|Property|Action property) (.+) is violated(\.| by the initial state:)"
|
|
303
|
-
r"|(Temporal)
|
|
404
|
+
r"|(Temporal) propert(?:ies(?: .+)? were|y .+ was) violated\.)")
|
|
304
405
|
|
|
305
406
|
|
|
306
407
|
def violation(error):
|
|
@@ -506,7 +607,7 @@ def render(result):
|
|
|
506
607
|
Outcome.MISSING: f"FAIL {name} {label}: spec {result.detail} not found",
|
|
507
608
|
Outcome.WITNESS: f"PASS {name} reach {operator} {label}: shortest trace {result.detail}",
|
|
508
609
|
Outcome.UNREACHED: f"FAIL {name} reach {operator} {label}: the model never reaches this state",
|
|
509
|
-
Outcome.INCOMPLETE: f"FAIL {name} reach {operator} {label}: TLC did not complete the reach check",
|
|
610
|
+
Outcome.INCOMPLETE: f"FAIL {name} reach {operator} {label}: {result.detail or 'TLC did not complete the reach check'}",
|
|
510
611
|
Outcome.NO_RUN: f"FAIL {name} reach {operator}: no run matching '{result.detail}'",
|
|
511
612
|
Outcome.MALFORMED: f"FAIL {result.detail}",
|
|
512
613
|
}[result.outcome]
|
|
@@ -543,6 +644,7 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
543
644
|
config = f"CONSTANTS\n{constants}SPECIFICATION Spec\n"
|
|
544
645
|
if not task.check_deadlock:
|
|
545
646
|
config += "CHECK_DEADLOCK FALSE\n"
|
|
647
|
+
engine_name = getattr(checker, "name", "TLC")
|
|
546
648
|
if not operator:
|
|
547
649
|
start = time.monotonic()
|
|
548
650
|
status, log, timed_out = checker.run(
|
|
@@ -551,7 +653,7 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
551
653
|
)
|
|
552
654
|
elapsed = time.monotonic() - start
|
|
553
655
|
shutil.rmtree(directory / "states", ignore_errors=True)
|
|
554
|
-
result = ordinary(name, run, status, log, checker.limit if timed_out else None, traces)
|
|
656
|
+
result = ordinary(name, run, status, log, checker.limit if timed_out else None, traces, engine_name=engine_name)
|
|
555
657
|
return replace(result, constants=run_constants, checks=run_checks, duration_s=elapsed)
|
|
556
658
|
wrapper = f"Reach{uuid.uuid4().hex}"
|
|
557
659
|
invariant = f"{wrapper}Negated"
|
|
@@ -564,18 +666,18 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
564
666
|
reach=True, workers=reach_workers, progress_label=f"{name} reach {operator} {run.label}",
|
|
565
667
|
)
|
|
566
668
|
elapsed = time.monotonic() - start
|
|
567
|
-
result = witness(name, run, operator, invariant, status, log, checker.limit if timed_out else None, traces)
|
|
669
|
+
result = witness(name, run, operator, invariant, status, log, checker.limit if timed_out else None, traces, engine_name=engine_name)
|
|
568
670
|
return replace(result, constants=run_constants, checks=run_checks, duration_s=elapsed)
|
|
569
671
|
finally:
|
|
570
672
|
shutil.rmtree(directory, ignore_errors=True)
|
|
571
673
|
|
|
572
674
|
|
|
573
675
|
|
|
574
|
-
def ordinary(name, run, status, log, timeout_limit=None, traces=False):
|
|
676
|
+
def ordinary(name, run, status, log, timeout_limit=None, traces=False, *, engine_name="TLC"):
|
|
575
677
|
if timeout_limit:
|
|
576
678
|
tail = tuple(line for line in log.split("\n") if line.strip())[-10:]
|
|
577
679
|
return Result(Outcome.FAIL, name, run.label,
|
|
578
|
-
detail=f"
|
|
680
|
+
detail=f"{engine_name} timed out after {timeout_limit}; set TLC_TIMEOUT to change the limit", lines=tail)
|
|
579
681
|
if status == 0 and "No error has been found" in log:
|
|
580
682
|
found = re.findall(r"[0-9,]* distinct states found", log)
|
|
581
683
|
states = found[-1] if found else ""
|
|
@@ -586,11 +688,12 @@ def ordinary(name, run, status, log, timeout_limit=None, traces=False):
|
|
|
586
688
|
violation=violation(first), trace=tlc_trace.parse(re.split(r"\r\n|\r|\n", log)) if traces else None)
|
|
587
689
|
|
|
588
690
|
|
|
589
|
-
def witness(name, run, operator, invariant, status, log, timeout_limit=None, traces=False):
|
|
691
|
+
def witness(name, run, operator, invariant, status, log, timeout_limit=None, traces=False, *, engine_name="TLC"):
|
|
692
|
+
incomplete = f"{engine_name} did not complete the reach check"
|
|
590
693
|
if timeout_limit:
|
|
591
694
|
tail = tuple(line for line in log.split("\n") if line.strip())[-10:]
|
|
592
|
-
return Result(Outcome.INCOMPLETE, name, run.label, operator,
|
|
593
|
-
lines=(f"
|
|
695
|
+
return Result(Outcome.INCOMPLETE, name, run.label, operator, detail=incomplete,
|
|
696
|
+
lines=(f"{engine_name} timed out after {timeout_limit}; set TLC_TIMEOUT to change the limit", *tail))
|
|
594
697
|
lines = log.split("\n")
|
|
595
698
|
length = 0
|
|
596
699
|
if status == 12 and f"Error: Invariant {invariant} is violated by the initial state:" in lines:
|
|
@@ -602,7 +705,8 @@ def witness(name, run, operator, invariant, status, log, timeout_limit=None, tra
|
|
|
602
705
|
trace=tlc_trace.parse(re.split(r"\r\n|\r|\n", log)) if traces else None)
|
|
603
706
|
if status == 0 and "No error has been found" in log:
|
|
604
707
|
return Result(Outcome.UNREACHED, name, run.label, operator)
|
|
605
|
-
return Result(Outcome.INCOMPLETE, name, run.label, operator,
|
|
708
|
+
return Result(Outcome.INCOMPLETE, name, run.label, operator, detail=incomplete,
|
|
709
|
+
lines=tuple(log.removesuffix("\n").split("\n")) if log else ())
|
|
606
710
|
|
|
607
711
|
|
|
608
712
|
class Runner:
|
|
@@ -687,7 +791,7 @@ def validate_report_path(raw: str) -> Path | None:
|
|
|
687
791
|
|
|
688
792
|
def main():
|
|
689
793
|
if sys.argv[1:] == ["ready"]:
|
|
690
|
-
print(
|
|
794
|
+
print(engine().ready_line)
|
|
691
795
|
storage.report()
|
|
692
796
|
return 0
|
|
693
797
|
if not 2 <= len(sys.argv) <= 3:
|
|
@@ -697,10 +801,11 @@ def main():
|
|
|
697
801
|
if not Path(matrix).is_file():
|
|
698
802
|
print(f"FAIL {matrix} does not exist")
|
|
699
803
|
return 1
|
|
700
|
-
|
|
804
|
+
checker = engine()
|
|
701
805
|
report_path = validate_report_path(os.environ.get("TLC_HTML_REPORT", ""))
|
|
702
806
|
with tempfile.TemporaryDirectory(dir=storage.ensure_temp_root()) as work:
|
|
703
|
-
|
|
807
|
+
print(f"ENGINE {checker.label}", flush=True)
|
|
808
|
+
matrix_runner = Runner(checker, Path(matrix).resolve().parent, only, lambda result: print("\n".join(render(result)), flush=True), Path(work),
|
|
704
809
|
keep_results=report_path is not None)
|
|
705
810
|
for task in MatrixPlan(matrix):
|
|
706
811
|
matrix_runner.check(task)
|
|
@@ -711,13 +816,13 @@ def main():
|
|
|
711
816
|
summary = f"SUMMARY {matrix_runner.passed} of {matrix_runner.runs_total} runs passed"
|
|
712
817
|
if matrix_runner.reach_total:
|
|
713
818
|
summary += f", {matrix_runner.reached} of {matrix_runner.reach_total} reach checks passed"
|
|
714
|
-
summary_line = f"{summary}, {matrix_runner.states} distinct states in total"
|
|
819
|
+
summary_line = f"{summary}, {matrix_runner.states} distinct states in total{checker.summary_suffix}"
|
|
715
820
|
print(summary_line)
|
|
716
821
|
if report_path is not None:
|
|
717
822
|
import tlc_report
|
|
718
823
|
|
|
719
824
|
try:
|
|
720
|
-
tlc_report.write_html(report_path, Path(matrix).name, matrix_runner.results, summary_line, only=only)
|
|
825
|
+
tlc_report.write_html(report_path, Path(matrix).name, matrix_runner.results, summary_line, only=only, engine=checker.label)
|
|
721
826
|
except OSError as error:
|
|
722
827
|
# A failed run's status wins over a report that could not be written.
|
|
723
828
|
print(f"UNAVAILABLE TLC_HTML_REPORT={str(report_path)!r} could not be written: {error}; {REPORT_REMEDY}")
|
|
@@ -457,8 +457,8 @@ def _trace_card(idx: int, result: object) -> str:
|
|
|
457
457
|
])
|
|
458
458
|
|
|
459
459
|
|
|
460
|
-
def render_html(matrix_name: str, results: list, summary: str, *, only: str = "", generated_at: str | None = None) -> str:
|
|
461
|
-
"""Render a complete, self-contained HTML5 report for a
|
|
460
|
+
def render_html(matrix_name: str, results: list, summary: str, *, only: str = "", engine: str = "", generated_at: str | None = None) -> str:
|
|
461
|
+
"""Render a complete, self-contained HTML5 report for a TLA+ matrix run."""
|
|
462
462
|
# A file name argument that is not UTF-8 arrives with lone surrogates, which the UTF-8 page cannot hold.
|
|
463
463
|
matrix_name = os.fsencode(matrix_name).decode("utf-8", "replace")
|
|
464
464
|
timestamp = generated_at or time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
|
@@ -466,7 +466,16 @@ def render_html(matrix_name: str, results: list, summary: str, *, only: str = ""
|
|
|
466
466
|
overall = "FAIL" if has_failure else "PASS"
|
|
467
467
|
overall_cls = "badge-fail" if has_failure else "badge-pass"
|
|
468
468
|
total_s = sum(r.duration_s for r in results)
|
|
469
|
-
|
|
469
|
+
engine_title = "everystate" if engine.startswith("everystate") else "TLC"
|
|
470
|
+
meta_items = []
|
|
471
|
+
if engine:
|
|
472
|
+
meta_items.append(f" <span>Engine: <code>{_esc(engine)}</code></span>")
|
|
473
|
+
meta_items.extend([
|
|
474
|
+
f" <span>Total duration: <strong>{total_s:.2f}s</strong></span>",
|
|
475
|
+
f" <span>Generated (UTC): <code>{_esc(timestamp)}</code></span>",
|
|
476
|
+
])
|
|
477
|
+
if only:
|
|
478
|
+
meta_items.append(f" <span>Filter: <code>{_esc(only)}</code></span>")
|
|
470
479
|
rows_html = "\n".join(_table_row(idx, r) for idx, r in enumerate(results))
|
|
471
480
|
trace_cards = [_trace_card(idx, r) for idx, r in enumerate(results) if r.trace is not None and bool(r.trace.steps)]
|
|
472
481
|
traces_html = "\n".join(trace_cards) if trace_cards else '<p class="empty-note">There are no counter-example or witness traces for this run.</p>'
|
|
@@ -476,21 +485,19 @@ def render_html(matrix_name: str, results: list, summary: str, *, only: str = ""
|
|
|
476
485
|
"<head>",
|
|
477
486
|
' <meta charset="utf-8">',
|
|
478
487
|
' <meta name="viewport" content="width=device-width, initial-scale=1">',
|
|
479
|
-
f" <title>
|
|
488
|
+
f" <title>{engine_title} Report — {_esc(matrix_name)}</title>",
|
|
480
489
|
f" <style>{_STYLE}</style>",
|
|
481
490
|
"</head>",
|
|
482
491
|
"<body>",
|
|
483
492
|
' <main class="page">',
|
|
484
493
|
' <section class="card">',
|
|
485
494
|
' <div class="header-top">',
|
|
486
|
-
f" <h1>
|
|
495
|
+
f" <h1>{engine_title} Matrix Report: {_esc(matrix_name)}</h1>",
|
|
487
496
|
f' <span class="badge {overall_cls}">{overall}</span>',
|
|
488
497
|
" </div>",
|
|
489
498
|
f" <p>{_esc(summary)}</p>",
|
|
490
499
|
' <div class="meta">',
|
|
491
|
-
|
|
492
|
-
f" <span>Generated (UTC): <code>{_esc(timestamp)}</code></span>",
|
|
493
|
-
f" {filter_html}",
|
|
500
|
+
*meta_items,
|
|
494
501
|
" </div>",
|
|
495
502
|
" </section>",
|
|
496
503
|
' <section class="card">',
|
|
@@ -509,8 +516,8 @@ def render_html(matrix_name: str, results: list, summary: str, *, only: str = ""
|
|
|
509
516
|
])
|
|
510
517
|
|
|
511
518
|
|
|
512
|
-
def write_html(path: Path, matrix_name: str, results: list, summary: str, *, only: str = "") -> Path:
|
|
519
|
+
def write_html(path: Path, matrix_name: str, results: list, summary: str, *, only: str = "", engine: str = "") -> Path:
|
|
513
520
|
"""Render the HTML report and write it atomically to path."""
|
|
514
521
|
target = Path(path)
|
|
515
|
-
runner.atomic_write(target, render_html(matrix_name, results, summary, only=only))
|
|
522
|
+
runner.atomic_write(target, render_html(matrix_name, results, summary, only=only, engine=engine))
|
|
516
523
|
return target
|
package/skills/setup/SKILL.md
CHANGED
|
@@ -17,7 +17,7 @@ Prepare the complete shared toolset once, independently of any repository. Verif
|
|
|
17
17
|
|
|
18
18
|
```shell
|
|
19
19
|
bash <skill-dir>/scripts/setup.sh rust
|
|
20
|
-
bash <skill-dir>/scripts/setup.sh tla
|
|
20
|
+
TLC_ENGINE=tlc TLC_JAR= bash <skill-dir>/scripts/setup.sh tla
|
|
21
21
|
bash <skill-dir>/scripts/setup.sh lean <skill-dir>/examples/lean-template
|
|
22
22
|
```
|
|
23
23
|
|