Skip to content

fix(pstack): strip CRLF from TLC output so ENDMSG markers close - #1287

Closed
lnuxe wants to merge 2 commits into
cursor:mainfrom
lnuxe:fix/statechart-crlf-linesof-1170
Closed

lnuxe wants to merge 2 commits into
cursor:mainfrom
lnuxe:fix/statechart-crlf-linesof-1170

Conversation

@lnuxe

@lnuxe lnuxe commented Nov 19, 2026

Copy link
Copy Markdown

What

The Windows JVM writes CRLF. outputLines in run.ts splits on \n and leaves a trailing \r, so the $-anchored @!@!@ENDMSG regex in frontends/messages.ts fails to match and the message never closes. readVerdict then sees no rule that broke and the worker exits silently with code 1, writing no chart.mmd / report.md.

Normalize every line in linesOf (the shared line-splitting entry in frontends/dot.ts) so all consumers (readMessages, parseDot, marks) are CRLF-safe.

Fixes #1170.

Repro (simulated CRLF from the Windows JVM)

const crlf = lf.split("\n").join("\r\n");
// before: 4 parsed items, 0 messages closed (START/END never match \r)
// after:  2 parsed items, message closes correctly

Verification

tests pass fail skipped
baseline 340 270 0 70
this change 341 271 0 70
  • New test CRLF line endings (Windows JVM) still close @!@!ENDMSG markers asserts LF and CRLF parse identically (8/8 pass in messages.test.ts).
  • The 70 skipped are pre-existing (require TLC/Java not installed locally).
  • tsc --noEmit on my files: clean (the 4 errors in run.ts/cli.test.ts are the pre-existing strict-typecheck baseline documented in pstack statechart: strict typecheck reports four errors in run.ts and CLI tests #1141).
  • Regenerated harness/ with scripts/generate-pstack-harness-trees.mjs; --check passes.

CI

validate-plugins.yml runs on pstack/** + harness/** and will cover this change.

linkedLauncher creates its links under os.tmpdir(), which on macOS is a
symlink (/tmp -> /private/tmp, /var -> /private/var). path.relative()
computes the link target lexically from the symlinked path, but the
kernel resolves the link's ".." segments from the physical directory,
which is one level deeper, so the spawn target does not exist and the
"launcher reached through a symlink" test fails.

Resolve the temp directory with fs.realpathSync() before building the
link so both sides are physical. Fixes cursor#1164.
The Windows JVM writes CRLF. outputLines splits on \n and leaves a
trailing \r, so the $ anchored @!@!@Endmsg regex fails to match and a
message stays open; readVerdict then sees no rule that broke and the
worker exits silently with code 1.

Normalize each line in linesOf so every consumer (messages, dot, marks)
is CRLF-safe. Fixes cursor#1170.
@lnuxe

lnuxe commented Nov 19, 2026

Copy link
Copy Markdown
Author

Closing as superseded by #1292 (maintainer's broader CRLF + Windows fix).

@lnuxe lnuxe closed this Nov 19, 2026
@lnuxe

lnuxe commented Nov 19, 2026

Copy link
Copy Markdown
Author

Superseded by #1292. Main merged a broader fix for the same root cause: a splitLines helper splits on \r?\n in linesOf/fileLines/outputLines, and it also adds native-Windows process management (Bug 2) plus corpus replays with Windows line ends. That covers the CRLF half of #1170 more completely than this PR, so closing this one rather than forcing a merge on a worse-scope change.

@lnuxe
lnuxe deleted the fix/statechart-crlf-linesof-1170 branch November 19, 2026 22:18
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.

statechart: silent exit on Windows — CRLF line endings break message parsing + POSIX-only process management

1 participant