Repository navigation
Description
statechart at 6c75f4e (current main) does not work on Windows. Observed on Windows 11 with Node.js 22.23.4, TLC 1.7.4 (TLA2TOOLS) and JDK 25 (JAVA).
Problems
- The command dies at start with
Error: spawn /bin/sh ENOENT, whatever the spec. The janitor inscripts/statechart.tsandkillGroupinscripts/run.tsspawn/bin/shdirectly. - A broken rule is not reported. With
/bin/shworked around, a spec whose INVARIANT breaks exits 2 withTLC exited 12 on <spec>, but its output names no rule that broke, and writes no chart or report. TLC's-tooloutput on Windows ends each@!@!@ENDMSG ... @!@!@line with CRLF (23 of 101 lines in one run). The other lines end with LF.outputLines/fileLinesinrun.tsandlinesOfinfrontends/dot.tssplit on"\n", so a\rstays at the end and the$-anchored patterns infrontends/messages.tsnever match. Running the same spec and cfg with plaintlc2.TLCprintsError: Invariant <name> is violated. - The worker's temp folder survives a killed run.
statechart.tspassesTMPDIRto the worker so itsos.tmpdir()lands inside the folder the janitor removes. On Windows,os.tmpdir()readsTEMP/TMPand ignoresTMPDIR, so the worker'sstatechart-*folder is created in the system temp folder and stays there after the parent is killed. --outwith an existing empty folder fails withEPERM, although the usage says the folder "must be new or empty". On Windows, renaming a folder onto an existing folder returnsEPERMeven when the target is empty. TherenameSync(done, dest)fallback only handlesENOTEMPTY/EEXIST.- The test suite cannot run on Windows. Most of
node --test test/*.test.tsspawns thestatechartshell launcher directly and fails withspawn EFTYPE, so none of the above is covered there.
Repro
Any spec reproduces 1. For 2, a minimal spec whose invariant breaks in a few steps is enough. For 4, mkdir out then statechart Spec.tla --out out.
A fix we use downstream
This patch covers 1 to 3 and keeps the POSIX commands unchanged:
https://github.com/yasuyuki/agent-skills/blob/1d5d597607719817d68fa8d93ddb7b29aba07f81/bundles/pstack/patches/statechart-windows.patch
- On
win32,killGrouprunstaskkill /T /F /PID <pid>. The janitor is a small script evaluated by the same runtime (-e, orevalunder Deno). It waits for stdin to end, then runstaskkilland removes the stage and temp folders. - The worker gets
TEMPandTMPas well asTMPDIR. - TLC output and dot text are split on
/\r?\n/.
With the patch on Windows, a spec where every rule holds exits 0 with its chart. A spec with two broken invariants exits 1 and names both rules with their shortest paths. Killing the parent mid-run leaves no java process, stage folder or temp folder. 4 and 5 are not addressed by the patch.
Activity
Sync log: 2026-11-04 check, no upstream change, issue #17 noted
statechart: run on Windows (#17)
backnotprop commentedon Nov 4, 2026
Thanks @yasuyuki, this is a great report. Every claim checked out against the code.
Your patch is applied on
mainin 06572d2, unchanged and credited to you. It covers 1 to 3. On macOS the statechart suite gives the same results with and without it, so the POSIX paths are unchanged. I can't run it on Windows here, so that part rests on your testing.The mirror will carry it as a community fix until Cursor ships an equivalent. The open upstream fix is cursor/plugins#1147, and it's tracked in cursor/plugins#1170.
I'm leaving this open for 4 (
EPERMon an empty--outfolder) and 5 (the suite on Windows).statechart: drop the trailing CR at chunk ends (#17)
backnotprop commentedon Nov 5, 2026
Follow-up: the patch left a gap.
outputLinesandfileLinescut each chunk at its last\n, so the last line keeps its\r, and the$-anchoredENDMSGpattern can miss it. I reproduced it on macOS with a CRLF file and fixed it onmainwith the same change as cursor/plugins#1147:buf[cut - 1] === 13 ? cut - 1 : cut. You may want this in your downstream patch too.backnotprop commentedon Nov 20, 2026
Cursor fixed this upstream in cursor/plugins#1292 (pstack 0.15.46): statechart no longer uses
/bin/shon Windows, reads TLC's\r\nline ends, and its janitor cleans up after a killed run. The mirror synced 0.15.46 and now uses upstream's fix in place of the community patch.Thank you @yasuyuki for the patch, which kept statechart working on Windows here until then. Closing. Please reopen if anything still breaks on Windows.