Skip to content

fix(statechart): resolve configured tools from caller - #1017

Open
Ehsan-hash wants to merge 3 commits into
cursor:mainfrom
Ehsan-hash:fix/statechart-tool-paths
Open

Ehsan-hash wants to merge 3 commits into
cursor:mainfrom
Ehsan-hash:fix/statechart-tool-paths

Conversation

@Ehsan-hash

@Ehsan-hash Ehsan-hash commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

Configured relative TLC jar and Java paths stop working when statechart starts Java in its temporary snapshot directory. Resolve those paths from the caller before starting Java. Closes #973.

What changed

  • Resolve TLA2TOOLS and path-shaped JAVA values from the caller in both discovery paths.
  • Add CLI regressions and regenerate the Claude Code copy.

Scope

  • Preserve absolute paths, bare Java names on PATH, and temporary-directory isolation.
  • Leave tool installation and model checking unchanged.

Blast Radius

This affects statechart's configured tool discovery. Bare executable names still use PATH.

Verification

  • Two focused regressions pass and fail on unchanged main. Five real Java/TLC CLI scenarios pass, including three relative-path failures reproduced on main.
  • Plugin validation and the generated-tree check pass.
  • The full pstack run passed 362 of 369 tests. Four direct-TLC temporary-directory failures then passed on both main and this branch with an owned Java temp folder. Three existing signal tests that use ps also fail on main in the macOS sandbox. Hosted Linux CI remains pending.

Note

Low Risk
Narrow change to statechart tool path resolution; behavior for absolute paths and PATH-only Java names is preserved.

Overview
Fixes relative TLA2TOOLS and path-shaped JAVA env vars breaking when the statechart CLI runs Java in an isolated temp working directory.

findTlc in run.ts now resolves non-absolute tool paths against process.cwd() (the caller) via a fromCaller helper, while absolute paths and bare java on PATH are unchanged. Path-like JAVA values (absolute or containing / or \) are normalized the same way on both the explicit-TLA2TOOLS branch and the mise discovery branch, instead of passing through raw relative strings that would be interpreted from the temp cwd.

Adds tool-paths.test.ts with two CLI integration tests (fake Java/mise) that assert the expected jar classpath and that Java still runs outside the caller directory.

Reviewed by Cursor Bugbot for commit 15d26ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@deanrie

deanrie commented Oct 29, 2026

Copy link
Copy Markdown

Hey @Ehsan-hash, the run.ts change does what #973 asked, and on macOS the first of the two new tests fails for a reason unrelated to it: resolves relative TLC and Java paths from the caller with explicit TLA2TOOLS exits 91 from the fake Java with unexpected classpath: /private/var/folders/.../tools/tla2tools.jar. runCase builds root with mkdtempSync(path.join(os.tmpdir(), ...)), which on macOS is /var/folders/..., and passes path.join(root, "tools", "tla2tools.jar") as STATECHART_EXPECTED_CP; the CLI runs with cwd: root, Node reports process.cwd() with the symlink resolved (/private/var/...), so path.resolve(process.cwd(), value) produces a path that is correct but not string-equal to the expected one. The second case passes because its Java path is absolute and there is no relative jar. const root = fs.realpathSync(fs.mkdtempSync(...)) makes both cases pass here (126 of the existing cli.test.ts plus 2); that is the same /var -> /private/var class as #923 and #997. Merge-tree is clean against main (23ab063).

@Ehsan-hash

Copy link
Copy Markdown
Contributor Author

Thanks @deanrie, reproduced the /tmp to /private/tmp mismatch. Fixed in 15d26ab by canonicalizing the fixture root with fs.realpathSync, then regenerated the harness copy. Both new tests pass with canonical and symlinked temporary paths. The existing CLI checks pass with canonical temporary paths (125 selected tests; the three previously documented signal/ps cases remain host-limited). No production behavior changed.

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: a relative TLA2TOOLS or JAVA path fails, because TLC runs in the snapshot folder

2 participants