agent-formal-verify 0.4.16 → 0.4.18
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 +24 -0
- package/package.json +1 -1
- package/skills/formal-verify/SKILL.md +3 -3
- package/skills/formal-verify/references/evidence.md +2 -1
- package/skills/formal-verify/references/helpers.md +8 -8
- package/skills/formal-verify/references/setup.md +17 -4
- package/skills/formal-verify/references/tla-brief.md +4 -3
- package/skills/formal-verify/scripts/baseline.py +18 -5
- package/skills/formal-verify/scripts/kani.py +18 -7
- package/skills/formal-verify/scripts/kani_reader.py +38 -19
- package/skills/formal-verify/scripts/lean.py +7 -6
- package/skills/formal-verify/scripts/lean_mutations.py +8 -5
- package/skills/formal-verify/scripts/mutate.py +60 -42
- package/skills/formal-verify/scripts/processes.py +29 -3
- package/skills/formal-verify/scripts/tlc.py +165 -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
|
|
|
@@ -180,7 +183,63 @@ def _read_progress(log_path, offset, partial):
|
|
|
180
183
|
return new_offset, new_partial, latest
|
|
181
184
|
|
|
182
185
|
|
|
183
|
-
|
|
186
|
+
EVERYSTATE_VERSION = re.compile(r"^everystate (\d+)\.(\d+)\.(\d+)$")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class _Engine:
|
|
190
|
+
"""Shared timeout, worker, disk-warning and watched-run logic for TLA+ engines."""
|
|
191
|
+
name = "TLC"
|
|
192
|
+
log_tag = "tlc"
|
|
193
|
+
summary_suffix = ""
|
|
194
|
+
label = ""
|
|
195
|
+
ready_line = ""
|
|
196
|
+
|
|
197
|
+
def __init__(self):
|
|
198
|
+
timeout_raw = os.environ.get("TLC_TIMEOUT", "").strip() or DEFAULT_TIMEOUT
|
|
199
|
+
self.limit, self.timeout_seconds = runner.parse_limit("TLC_TIMEOUT", timeout_raw, "run time limit", "sixty minutes")
|
|
200
|
+
self.workers = os.environ.get("TLC_WORKERS") or "auto"
|
|
201
|
+
self._warned_disk = False
|
|
202
|
+
|
|
203
|
+
def _run_watched(self, command, log, progress_label=""):
|
|
204
|
+
if not self._warned_disk:
|
|
205
|
+
self._warned_disk = True
|
|
206
|
+
storage.warn_runtime()
|
|
207
|
+
start = time.monotonic()
|
|
208
|
+
deadline = start + self.timeout_seconds
|
|
209
|
+
|
|
210
|
+
def watch(process):
|
|
211
|
+
"""Wait for the checker, report its progress and stop it at the deadline; return its status and whether it timed out."""
|
|
212
|
+
next_report = start + PROGRESS_DELAY
|
|
213
|
+
offset, partial, latest = 0, "", ""
|
|
214
|
+
while True:
|
|
215
|
+
now = time.monotonic()
|
|
216
|
+
remaining = deadline - now
|
|
217
|
+
if remaining <= 0:
|
|
218
|
+
processes.stop_process(process)
|
|
219
|
+
return process.returncode, True
|
|
220
|
+
if now >= next_report:
|
|
221
|
+
offset, partial, found = _read_progress(log, offset, partial)
|
|
222
|
+
if found:
|
|
223
|
+
latest = found
|
|
224
|
+
elapsed = int(now - start)
|
|
225
|
+
prefix = f"[{self.log_tag}] {progress_label}: " if progress_label else f"[{self.log_tag}] "
|
|
226
|
+
body = f"{elapsed}s elapsed: {latest}" if latest else f"{elapsed}s elapsed"
|
|
227
|
+
sys.stderr.write(f"{prefix}{body}\n")
|
|
228
|
+
sys.stderr.flush()
|
|
229
|
+
next_report = now + PROGRESS_INTERVAL
|
|
230
|
+
wait_for = min(remaining, max(0.05, next_report - time.monotonic()))
|
|
231
|
+
try:
|
|
232
|
+
process.wait(timeout=wait_for)
|
|
233
|
+
return process.returncode, False
|
|
234
|
+
except subprocess.TimeoutExpired:
|
|
235
|
+
continue
|
|
236
|
+
|
|
237
|
+
with log.open("w", encoding="utf-8") as stream:
|
|
238
|
+
returncode, timed_out = processes.guarded(command, watch, stdout=stream, stderr=subprocess.STDOUT)
|
|
239
|
+
return returncode, read_raw(log), timed_out
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class Tlc(_Engine):
|
|
184
243
|
"""The pinned TLC, checked once. Nothing here downloads it."""
|
|
185
244
|
version = "v1.7.4"
|
|
186
245
|
sha256 = "936a262061c914694dfd669a543be24573c45d5aa0ff20a8b96b23d01e050e88"
|
|
@@ -192,8 +251,7 @@ class Tlc:
|
|
|
192
251
|
return Path(os.environ.get("TLC_CACHE") or Path.home() / ".cache/tla") / f"tla2tools-{cls.version}.jar"
|
|
193
252
|
|
|
194
253
|
def __init__(self):
|
|
195
|
-
|
|
196
|
-
self.limit, self.timeout_seconds = runner.parse_limit("TLC_TIMEOUT", timeout_raw, "run time limit", "sixty minutes")
|
|
254
|
+
super().__init__()
|
|
197
255
|
self.java = os.environ.get("JAVA") or "java"
|
|
198
256
|
try:
|
|
199
257
|
# The JVM prints in the platform encoding, which need not be UTF-8.
|
|
@@ -217,24 +275,30 @@ class Tlc:
|
|
|
217
275
|
if status and "TLC - provides model checking" not in output:
|
|
218
276
|
raise runner.Unavailable(f"UNAVAILABLE tlc2.TLC cannot run from {self.jar}; save a working JAR from {self.release} "
|
|
219
277
|
f"or set TLC_JAR\n{output.rstrip()}")
|
|
220
|
-
|
|
221
|
-
|
|
278
|
+
# The TLC version in the help banner and the tla2tools release tag use different numbering.
|
|
279
|
+
banner = re.search(r"^\s*(?:TLC - provides model checking[^\n]*? - Version |TLC2 Version )([0-9][\w.+-]*)", output, re.MULTILINE)
|
|
280
|
+
checker = f"TLC {banner[1]}" if banner else "TLC"
|
|
281
|
+
jar_source = "custom JAR" if supplied else f"tla2tools {self.version}"
|
|
282
|
+
if supplied and not banner:
|
|
283
|
+
jar_source += f", version unreported, sha256 {self._jar_digest()}"
|
|
284
|
+
self.label = f"{checker} ({jar_source})"
|
|
285
|
+
self.ready_line = f"READY TLC {self.jar}"
|
|
286
|
+
|
|
287
|
+
def _jar_digest(self):
|
|
288
|
+
try:
|
|
289
|
+
return hashlib.sha256(Path(self.jar).read_bytes()).hexdigest()
|
|
290
|
+
except OSError as error:
|
|
291
|
+
raise runner.Unavailable(f"UNAVAILABLE cannot read {self.jar}; check its permissions") from error
|
|
222
292
|
|
|
223
293
|
def _check_pinned_jar(self):
|
|
224
294
|
if not Path(self.jar).is_file():
|
|
225
295
|
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
|
|
296
|
+
got = self._jar_digest()
|
|
230
297
|
if got != self.sha256:
|
|
231
298
|
raise runner.Unavailable(f"UNAVAILABLE {self.jar} has sha256 {got}, want {self.sha256}")
|
|
232
299
|
|
|
233
300
|
def run(self, directory, module, config, reach, workers=None, progress_label=""):
|
|
234
301
|
"""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
302
|
log = directory / "tlc.log"
|
|
239
303
|
(directory / "MC.cfg").write_text(config, encoding="utf-8")
|
|
240
304
|
chosen_workers = workers if workers is not None else ("1" if reach else self.workers)
|
|
@@ -244,39 +308,71 @@ class Tlc:
|
|
|
244
308
|
command = [self.java, "-XX:+UseParallelGC", f"-Djava.io.tmpdir={java_tmp}", "-cp", self.jar, "tlc2.TLC", "-workers", chosen_workers,
|
|
245
309
|
*(["-deadlock"] if reach else []), "-cleanup", "-metadir", str(directory / "states"),
|
|
246
310
|
"-config", str(directory / "MC.cfg"), str(directory / f"{module}.tla")]
|
|
247
|
-
|
|
248
|
-
deadline = start + self.timeout_seconds
|
|
311
|
+
return self._run_watched(command, log, progress_label)
|
|
249
312
|
|
|
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
313
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
314
|
+
class Everystate(_Engine):
|
|
315
|
+
"""The native everystate engine, checked once. Nothing here downloads it."""
|
|
316
|
+
name = "everystate"
|
|
317
|
+
log_tag = "everystate"
|
|
318
|
+
min_version = (0, 4, 6)
|
|
319
|
+
min_version_text = "0.4.6"
|
|
320
|
+
release = "https://github.com/mattzcarey/everystate/releases/tag/v0.4.6"
|
|
321
|
+
remedy = (
|
|
322
|
+
f"install everystate {min_version_text} or later from {release} "
|
|
323
|
+
"(or with Homebrew, Cargo or npm) and set EVERYSTATE if it is not on PATH"
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
def __init__(self):
|
|
327
|
+
super().__init__()
|
|
328
|
+
self.binary = os.environ.get("EVERYSTATE", "").strip() or "everystate"
|
|
329
|
+
try:
|
|
330
|
+
probe = processes.run_captured([self.binary, "--version"], errors="replace")
|
|
331
|
+
status, stdout, stderr = probe.returncode, probe.stdout, probe.stderr
|
|
332
|
+
except OSError as error:
|
|
333
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} cannot run: {error}; {self.remedy}") from error
|
|
334
|
+
output = (stdout + stderr).strip()
|
|
335
|
+
if status:
|
|
336
|
+
detail = f"\n{output}" if output else ""
|
|
337
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} --version failed; {self.remedy}{detail}")
|
|
338
|
+
first_line = next((line.strip() for line in stdout.splitlines() if line.strip()), "")
|
|
339
|
+
match = EVERYSTATE_VERSION.fullmatch(first_line)
|
|
340
|
+
if not match:
|
|
341
|
+
detail = f"\n{output}" if output else ""
|
|
342
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} did not report an everystate version; {self.remedy}{detail}")
|
|
343
|
+
parsed = tuple(int(part) for part in match.groups())
|
|
344
|
+
self.version = ".".join(match.groups())
|
|
345
|
+
if parsed < self.min_version:
|
|
346
|
+
raise runner.Unavailable(f"UNAVAILABLE {self.binary} is everystate {self.version}, want {self.min_version_text} or later; {self.remedy}")
|
|
347
|
+
self.resolved_binary = shutil.which(self.binary) or self.binary
|
|
348
|
+
self.label = f"everystate {self.version}"
|
|
349
|
+
self.summary_suffix = f" ({self.label})"
|
|
350
|
+
self.ready_line = f"READY everystate {self.version} {self.resolved_binary}"
|
|
351
|
+
|
|
352
|
+
def run(self, directory, module, config, reach, workers=None, progress_label=""):
|
|
353
|
+
"""Run everystate on module in directory with config; return (exit_status, log, timed_out)."""
|
|
354
|
+
log = directory / "tlc.log"
|
|
355
|
+
(directory / "MC.cfg").write_text(config, encoding="utf-8")
|
|
356
|
+
chosen_workers = workers if workers is not None else ("1" if reach else self.workers)
|
|
357
|
+
# -lncheck final checks temporal properties once on the complete graph instead of at periodic checkpoints.
|
|
358
|
+
command = [
|
|
359
|
+
self.binary, "-workers", chosen_workers,
|
|
360
|
+
*(["-deadlock"] if reach else []),
|
|
361
|
+
"-lncheck", "final",
|
|
362
|
+
"-config", str(directory / "MC.cfg"),
|
|
363
|
+
str(directory / f"{module}.tla"),
|
|
364
|
+
]
|
|
365
|
+
return self._run_watched(command, log, progress_label)
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
def engine():
|
|
369
|
+
"""Return the selected TLA+ engine from TLC_ENGINE (default: tlc)."""
|
|
370
|
+
raw = os.environ.get("TLC_ENGINE", "").strip()
|
|
371
|
+
if not raw or raw == "tlc":
|
|
372
|
+
return Tlc()
|
|
373
|
+
if raw == "everystate":
|
|
374
|
+
return Everystate()
|
|
375
|
+
raise runner.Unavailable(f"UNAVAILABLE TLC_ENGINE={raw!r} is not supported; use 'tlc' or 'everystate'")
|
|
280
376
|
|
|
281
377
|
|
|
282
378
|
class Outcome(Enum):
|
|
@@ -298,9 +394,9 @@ class Violation:
|
|
|
298
394
|
initial: bool
|
|
299
395
|
|
|
300
396
|
|
|
301
|
-
# TLC
|
|
397
|
+
# TLC 2.19 prints "Temporal properties were violated."; newer TLC names the violated property or properties.
|
|
302
398
|
VIOLATION = re.compile(r"Error: (?:(Invariant|Property|Action property) (.+) is violated(\.| by the initial state:)"
|
|
303
|
-
r"|(Temporal)
|
|
399
|
+
r"|(Temporal) propert(?:ies(?: .+)? were|y .+ was) violated\.)")
|
|
304
400
|
|
|
305
401
|
|
|
306
402
|
def violation(error):
|
|
@@ -506,7 +602,7 @@ def render(result):
|
|
|
506
602
|
Outcome.MISSING: f"FAIL {name} {label}: spec {result.detail} not found",
|
|
507
603
|
Outcome.WITNESS: f"PASS {name} reach {operator} {label}: shortest trace {result.detail}",
|
|
508
604
|
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",
|
|
605
|
+
Outcome.INCOMPLETE: f"FAIL {name} reach {operator} {label}: {result.detail or 'TLC did not complete the reach check'}",
|
|
510
606
|
Outcome.NO_RUN: f"FAIL {name} reach {operator}: no run matching '{result.detail}'",
|
|
511
607
|
Outcome.MALFORMED: f"FAIL {result.detail}",
|
|
512
608
|
}[result.outcome]
|
|
@@ -543,6 +639,7 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
543
639
|
config = f"CONSTANTS\n{constants}SPECIFICATION Spec\n"
|
|
544
640
|
if not task.check_deadlock:
|
|
545
641
|
config += "CHECK_DEADLOCK FALSE\n"
|
|
642
|
+
engine_name = getattr(checker, "name", "TLC")
|
|
546
643
|
if not operator:
|
|
547
644
|
start = time.monotonic()
|
|
548
645
|
status, log, timed_out = checker.run(
|
|
@@ -551,7 +648,7 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
551
648
|
)
|
|
552
649
|
elapsed = time.monotonic() - start
|
|
553
650
|
shutil.rmtree(directory / "states", ignore_errors=True)
|
|
554
|
-
result = ordinary(name, run, status, log, checker.limit if timed_out else None, traces)
|
|
651
|
+
result = ordinary(name, run, status, log, checker.limit if timed_out else None, traces, engine_name=engine_name)
|
|
555
652
|
return replace(result, constants=run_constants, checks=run_checks, duration_s=elapsed)
|
|
556
653
|
wrapper = f"Reach{uuid.uuid4().hex}"
|
|
557
654
|
invariant = f"{wrapper}Negated"
|
|
@@ -564,18 +661,18 @@ def run_task(checker, matrix_dir, task, work, source=None, traces=False):
|
|
|
564
661
|
reach=True, workers=reach_workers, progress_label=f"{name} reach {operator} {run.label}",
|
|
565
662
|
)
|
|
566
663
|
elapsed = time.monotonic() - start
|
|
567
|
-
result = witness(name, run, operator, invariant, status, log, checker.limit if timed_out else None, traces)
|
|
664
|
+
result = witness(name, run, operator, invariant, status, log, checker.limit if timed_out else None, traces, engine_name=engine_name)
|
|
568
665
|
return replace(result, constants=run_constants, checks=run_checks, duration_s=elapsed)
|
|
569
666
|
finally:
|
|
570
667
|
shutil.rmtree(directory, ignore_errors=True)
|
|
571
668
|
|
|
572
669
|
|
|
573
670
|
|
|
574
|
-
def ordinary(name, run, status, log, timeout_limit=None, traces=False):
|
|
671
|
+
def ordinary(name, run, status, log, timeout_limit=None, traces=False, *, engine_name="TLC"):
|
|
575
672
|
if timeout_limit:
|
|
576
673
|
tail = tuple(line for line in log.split("\n") if line.strip())[-10:]
|
|
577
674
|
return Result(Outcome.FAIL, name, run.label,
|
|
578
|
-
detail=f"
|
|
675
|
+
detail=f"{engine_name} timed out after {timeout_limit}; set TLC_TIMEOUT to change the limit", lines=tail)
|
|
579
676
|
if status == 0 and "No error has been found" in log:
|
|
580
677
|
found = re.findall(r"[0-9,]* distinct states found", log)
|
|
581
678
|
states = found[-1] if found else ""
|
|
@@ -586,11 +683,12 @@ def ordinary(name, run, status, log, timeout_limit=None, traces=False):
|
|
|
586
683
|
violation=violation(first), trace=tlc_trace.parse(re.split(r"\r\n|\r|\n", log)) if traces else None)
|
|
587
684
|
|
|
588
685
|
|
|
589
|
-
def witness(name, run, operator, invariant, status, log, timeout_limit=None, traces=False):
|
|
686
|
+
def witness(name, run, operator, invariant, status, log, timeout_limit=None, traces=False, *, engine_name="TLC"):
|
|
687
|
+
incomplete = f"{engine_name} did not complete the reach check"
|
|
590
688
|
if timeout_limit:
|
|
591
689
|
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"
|
|
690
|
+
return Result(Outcome.INCOMPLETE, name, run.label, operator, detail=incomplete,
|
|
691
|
+
lines=(f"{engine_name} timed out after {timeout_limit}; set TLC_TIMEOUT to change the limit", *tail))
|
|
594
692
|
lines = log.split("\n")
|
|
595
693
|
length = 0
|
|
596
694
|
if status == 12 and f"Error: Invariant {invariant} is violated by the initial state:" in lines:
|
|
@@ -602,7 +700,8 @@ def witness(name, run, operator, invariant, status, log, timeout_limit=None, tra
|
|
|
602
700
|
trace=tlc_trace.parse(re.split(r"\r\n|\r|\n", log)) if traces else None)
|
|
603
701
|
if status == 0 and "No error has been found" in log:
|
|
604
702
|
return Result(Outcome.UNREACHED, name, run.label, operator)
|
|
605
|
-
return Result(Outcome.INCOMPLETE, name, run.label, operator,
|
|
703
|
+
return Result(Outcome.INCOMPLETE, name, run.label, operator, detail=incomplete,
|
|
704
|
+
lines=tuple(log.removesuffix("\n").split("\n")) if log else ())
|
|
606
705
|
|
|
607
706
|
|
|
608
707
|
class Runner:
|
|
@@ -687,7 +786,7 @@ def validate_report_path(raw: str) -> Path | None:
|
|
|
687
786
|
|
|
688
787
|
def main():
|
|
689
788
|
if sys.argv[1:] == ["ready"]:
|
|
690
|
-
print(
|
|
789
|
+
print(engine().ready_line)
|
|
691
790
|
storage.report()
|
|
692
791
|
return 0
|
|
693
792
|
if not 2 <= len(sys.argv) <= 3:
|
|
@@ -697,10 +796,11 @@ def main():
|
|
|
697
796
|
if not Path(matrix).is_file():
|
|
698
797
|
print(f"FAIL {matrix} does not exist")
|
|
699
798
|
return 1
|
|
700
|
-
|
|
799
|
+
checker = engine()
|
|
701
800
|
report_path = validate_report_path(os.environ.get("TLC_HTML_REPORT", ""))
|
|
702
801
|
with tempfile.TemporaryDirectory(dir=storage.ensure_temp_root()) as work:
|
|
703
|
-
|
|
802
|
+
print(f"ENGINE {checker.label}", flush=True)
|
|
803
|
+
matrix_runner = Runner(checker, Path(matrix).resolve().parent, only, lambda result: print("\n".join(render(result)), flush=True), Path(work),
|
|
704
804
|
keep_results=report_path is not None)
|
|
705
805
|
for task in MatrixPlan(matrix):
|
|
706
806
|
matrix_runner.check(task)
|
|
@@ -711,13 +811,13 @@ def main():
|
|
|
711
811
|
summary = f"SUMMARY {matrix_runner.passed} of {matrix_runner.runs_total} runs passed"
|
|
712
812
|
if matrix_runner.reach_total:
|
|
713
813
|
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"
|
|
814
|
+
summary_line = f"{summary}, {matrix_runner.states} distinct states in total{checker.summary_suffix}"
|
|
715
815
|
print(summary_line)
|
|
716
816
|
if report_path is not None:
|
|
717
817
|
import tlc_report
|
|
718
818
|
|
|
719
819
|
try:
|
|
720
|
-
tlc_report.write_html(report_path, Path(matrix).name, matrix_runner.results, summary_line, only=only)
|
|
820
|
+
tlc_report.write_html(report_path, Path(matrix).name, matrix_runner.results, summary_line, only=only, engine=checker.label)
|
|
721
821
|
except OSError as error:
|
|
722
822
|
# A failed run's status wins over a report that could not be written.
|
|
723
823
|
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
|
|