Skip to content

fix(pstack): read statechart action names without the arguments TLC 1.8.0 adds - #1288

Open
buildwithme wants to merge 1 commit into
cursor:mainfrom
buildwithme:fix/statechart-action-arguments
Open

buildwithme wants to merge 1 commit into
cursor:mainfrom
buildwithme:fix/statechart-action-arguments

Conversation

@buildwithme

Copy link
Copy Markdown

Why

TLC 1.8.0 prints the arguments of a parameterized action after its name. TLC 2.19 (tla2tools 1.7.4, the version that the skill installs) prints the name only:

Error trace -dump dot,actionlabels
TLC 2.19 <Run line 4, col 16 ...> label="Run"
TLC 1.8.0 <Run(TRUE) line 4, col 16 ...> label="Run(TRUE)"

everystate, a TLA+ checker with a TLC command line, prints the trace as 1.8.0 does and the graph as 2.19 does.

The skill reads the action name with [^\s>]+ in actionOf and with [^"]* in parseDot. With TLC 1.8.0 this gives these results:

  • A view's step() that maps Run gets Run(TRUE). The chart and the report show the raw name.
  • Send(1, "a b") is Send(1,"a in the trace and Send(1,\ in the graph, because the trace stops at the space and the graph stops at the escaped quote.
  • Two calls of one action between the same two states, such as Send(1, "a b") and Send(2, "c"), are two graph steps.
  • When the trace name and the graph name differ, lasso finds no graph step for a trace step. The report then says only "TLC found a counterexample", with no path and no loop. This is the failure that fix(pstack): keep qualified action names in statechart property traces #982 fixed for INSTANCE names. With everystate, Run(TRUE) against Run gives the same failure.

Fix

Both readers stop the name at (. TLC 1.8.0 puts the arguments last, also after an INSTANCE prefix (C!Up(1)). So the name before ( is the name that TLC 2.19 prints. Steps that differ only in their arguments become one graph step, as in TLC 2.19's graph.

tlc-NAME.out does not change. It keeps TLC's lines as TLC prints them.

Tests

  • messages.test.ts: trace lines from TLC 2.19 and TLC 1.8.0 for a Boolean argument, a string with a space, an INSTANCE action, and a "Back to state" step with a tuple. Each line gives the TLC 2.19 name.
  • chart.test.ts: the full TLC 1.8.0 graph dump of the Args spec below. parseDot gives one Send step for each pair of states, and one Back step.
  • Both tests fail on main and pass with the fix.

All test lines are TLC's output, copied from runs of TLC 2.19 and of the v1.8.0 tla2tools.jar.

End to end, with the view step = (a) => ({ Send: "you send", Back: "you go back" })[a] ?? a:

---- MODULE Args ----
EXTENDS Naturals
VARIABLE n
Send(a, b) == n < 2 /\ n' = n + 1
Back(s) == n = 2 /\ n' = 0
Next == Send(1, "a b") \/ Send(2, "c") \/ Back(<<1>>)
Spec == n = 0 /\ [][Next]_n /\ WF_n(Next)
Live == <>(n = 3)
====
Checker main This PR
TLC 2.19 The 3-step path and the loop No change
TLC 1.8.0 "TLC found a counterexample. It is in tlc-Live.out." The 3-step path and the loop
everystate 0.4.1 "TLC found a counterexample. It is in tlc-Live.out." The 3-step path and the loop

With this PR, the report.md and chart.mmd of all three checkers are the same, byte for byte. On the ActionName spec (an INVARIANT that Run(TRUE) breaks), TLC 1.8.0 on main labels each arrow and the bug path Run(TRUE). With this PR they get the view's label, as with TLC 2.19.

Checks

In pstack/skills/statechart/scripts, on macOS with Node 26:

  • TLA2TOOLS=<tla2tools 1.7.4> JAVA=<Temurin 25> npm test: 374 pass, 1 fail.
  • npm test without TLA2TOOLS, as CI runs it: 271 pass, 70 skip, 1 fail.
  • TLA2TOOLS and JAVA set to everystate 0.4.1: 347 pass, 28 fail. Main fails the same 28 tests. They compare the checker's own text, such as progress lines and SANY's error text, with TLC 2.19's recording, and everystate prints other text. The 2 new tests pass.
  • node scripts/generate-pstack-harness-trees.mjs --check: up to date.
  • node scripts/validate-plugins.mjs: pass.
  • node scripts/check-pstack-docs.mjs: 0 problems.

The one failure in each run is the launcher reached through an absolute and a relative symlink writes the committed chart on this Node in cli.test.ts. It fails on main too, and only on macOS. There, os.tmpdir() is under /var, which is a link to /private/var. The test computes its relative link from the /var path, but the link resolves from the real folder, one level deeper, so it misses the launcher. CI runs on Linux.

This PR does not change the plugin version.

….8.0 adds

TLC 1.8.0 prints a parameterized action with its arguments, as
Run(TRUE) in the error trace and label="Run(TRUE)" in the graph dump.
TLC 2.19 prints Run in both. actionOf read the trace name up to a space
or >, and parseDot read the graph label up to a quote. So a view that
maps Run missed Run(TRUE), Send(1,"a b") became Send(1,"a in the trace
and Send(1,\ in the graph, and lasso found no graph step for a trace
step. The report then said only "TLC found a counterexample".

Both readers now stop the name at (. TLC 1.8.0 puts the arguments
last, also after an INSTANCE prefix, so the name is the one TLC 2.19
prints. everystate prints the trace as 1.8.0 does and the graph as 2.19
does, and its reports now match TLC 2.19 too.

messages.test.ts and chart.test.ts check trace lines and a graph dump
copied from TLC 2.19 and TLC 1.8.0 runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant