Repository navigation
fix(pstack): write non-ASCII chart captions as strings TLC can parse - #871
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
statechart.mjs from-chartcannot check a chart whose state captions contain any non-ASCII character.chart-to-tla.mjscopies each caption into the generated spec as a TLA+ string, and SANY only accepts ASCII inside strings, so a caption likeDon’t pay(curly apostrophe),Waiting…,Café, or one with an emoji makes TLC stop with "Parsing or semantic analysis failed" before it checks a single rule. The skill tells people to write captions in the reader's own words, and editors often turn a typed apostrophe or...into these characters, so ordinary hand-drawn charts run into this.The fix writes each non-ASCII character into the TLA+ string as a Mermaid-style
#code;entity (for example"Don#8217;t pay"), so every string the spec contains is ASCII. The generated map file gets aCAPTIONStable from each encoded string back to the original caption, andstate()looks values up there, so the charts, stories, and the from-chart comparison all keep showing the captions exactly as drawn. Captions that are already ASCII, transition labels (which only end up in comments and in the JavaScript map), and the rest of the output stay the same.The new
test/chart-to-tla-ascii.test.mjsadds two tests. The first draws a chart with…,’,é, and an emoji, then checks that every string in the generated spec is printable ASCII and that the map reads each one back as its caption. It runs without TLC. The second runsfrom-charton the same chart through TLC, expects the%% neverrule to break, and expects the spec to draw the chart back unchanged. Both fail onmain(a non-ASCII string, then the SANY parse failure) and pass with this change. The from-chart, chart-to-tla, and guard tests instatechart.test.mjsstill pass with TLC available, and the harness tree is regenerated.Note
Low Risk
Scoped to statechart code generation and map display; behavior for ASCII-only charts is unchanged aside from the optional CAPTIONS lookup.
Overview
Fixes TLC/SANY parse failures when Mermaid state captions include typographic or Unicode text (curly quotes, ellipsis, accents, emoji).
chart-to-tla.mjsnow runs state names through anascii()encoder before they become TLA+ string literals, emitting Mermaid-style#code;entities so every string in the spec stays printable ASCII. The generated*.map.mjsadds aCAPTIONStable (encoded → original) andstate()decodes through it, sofrom-chartcomparisons and displayed labels still match the chart verbatim.Adds
chart-to-tla-ascii.test.mjs: one test asserts ASCII-only.tlastrings and map round-trip without TLC; another (when TLC is present) runsfrom-charton the same chart and expects the never-rule break plus an unchanged redraw.Reviewed by Cursor Bugbot for commit 2babb8e. Bugbot is set up for automated code reviews on this repo. Configure here.