Repository navigation
feat: add tla-state-check plugin - #52
Merged
Merged
Conversation
Finds implicit state machines in a codebase, models each in TLA+ in a scratch directory, checks them with everystate 0.4.3, verifies every counterexample against the code and reports real bugs by issue type. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
There was a problem hiding this comment.
4 issues found across 12 files
Confidence score: 3/5
SKILL.mdfetches and runs[email protected]without verifying the package artifact. Require user approval before running it with their permissions.SKILL.mdrelies on a POSIX shell for its scratch-directory step, so the workflow can stop on Windows hosts without one. Use a host-portable temporary-directory approach or document a Windows-specific path.- A customized
TMPDIRcan put scratch files inside the target repository, contradicting the no-repository-writes promise. Verify the resolved directory is outside the repository. README.mdsays only code-confirmed counterexamples are reported, but the skill also reportsunverifiedfindings and verdict counts for model artifacts. Describe the verdict-based report instead.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md">
<violation number="1" location="plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md:43">
P2: A customized `TMPDIR` can point inside the target repository, causing this command to write specs and checker output there despite the no-repository-writes promise. Resolve the directory and verify it is outside the repository before writing.</violation>
<violation number="2" location="plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md:43">
P2: The scratch-directory step is not portable to Windows hosts that lack a POSIX shell, so the advertised workflow can stop before model checking starts. Use the host's temporary-directory API or provide an explicit Windows-compatible fallback.</violation>
<violation number="3" location="plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md:67">
P2: Require user approval before fetching and executing `[email protected]`; pinning only the version does not verify the package artifact that `npx` runs with the user's permissions.</violation>
</file>
<file name="plugins/engineering/tla-state-check/README.md">
<violation number="1" location="plugins/engineering/tla-state-check/README.md:5">
P2: This sentence promises that only code-confirmed counterexamples are reported, but the skill also reports `unverified` findings and verdict counts for model artifacts. Describe the verdict-based report instead, so users do not mistake an unverified trace for a confirmed bug-free result.</violation>
</file>
Heads up: you’re close to your included review allowance. Set a flex budget so reviews don’t pause.
Turn on auto-fix | Re-trigger cubic
Ask before the first npx fetch, treat all repo content and checker output as untrusted, keep scratch outside the repo on any host, handle dirty worktrees, count failed items as conserved, and describe the verdict-based report accurately. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
There was a problem hiding this comment.
1 issue found across 9 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md">
<violation number="1" location="plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md:20">
P2: `npm view ...` is another registry request, contradicting the “only network access” policy and potentially allowing an unapproved lookup. Mark it explicitly as a separately user-approved action or remove the command.</violation>
</file>
Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
There was a problem hiding this comment.
0 issues found across 1 file (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Requires human review: This PR does not meet the repository auto-approval settings.
Turn on auto-fix | Re-trigger cubic
glebedel
added a commit
that referenced
this pull request
Nov 30, 2026
## What changed PR #52 (`tla-state-check`) merged at 0ff2feb before the review fix landed, so `main` still has the consent bug the review found. This PR carries that fix forward onto `main`: - `skills/tla-state-check/SKILL.md`: the rule now asks before the version probe too. The old text let an agent run `everystate --version` before the user's yes when an `everystate` was already installed. That command executes whatever binary is first on `PATH`, so it is a run without consent. The new text says to ask even when one is installed. - `skills/tla-state-check/references/everystate.md`: a copy edit (semicolon after the integrity hash becomes a full stop). - Version 1.0.0 to 1.0.1 in both plugin manifests and the `marketplace.json` entry, so existing installs receive the change. The fix was first pushed to the feature branch as b76d589 and cherry-picked onto `main` here as f0b24dc. No other file changed. Requested by [email protected] in the Slack thread (C0C90EFJ0DQ, 1796040539.253869): dogfood the plugin, make sure review comments are addressed, run the review gates. ## Verification Run on this branch, after the version bump: - `python3 scripts/generate_codex_marketplace.py --check`: pass - `python3 scripts/validate_codex_plugins.py`: pass - `python3 scripts/check_plugin_versions.py --base origin/main`: pass (1 plugin touched, versioned correctly) - `python3 -m unittest discover -s tests`: 322 run, OK (1 skipped) - `ruff check scripts/*.py tests/*.py`: pass - `mypy scripts`: pass - `claude plugin validate --strict` on the plugin: pass Not run, and why: - `validate` with pinned Claude Code and Codex CLIs, `generator-windows`, and `scan-skills` (SkillSpector): these need CI or tools not available in this sandbox. CI runs them on this PR. - `/forge:forge` and `/eng-review`: not available in this environment, so the fallback is the review agent's security and code-quality pass (findings: the consent item above, fixed; one low copy-edit, fixed). - The Haiku-dogfood of the consent rule itself was not re-run on the merged `main` version. The change is text in `SKILL.md`; the before and after lines are in the diff. Company-agnostic check: `git grep` for StackOne in this plugin prints only the `author`, `homepage`, `repository` and install-command lines, the same ones every plugin on `main` carries. --------- Co-authored-by: S2D2 <[email protected]> Co-authored-by: Claude Haiku 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
glebedel
added a commit
that referenced
this pull request
Nov 30, 2026
Answers Guillaume's question on #52 ("should that not be sha pinned?"): yes. The skill pinned `[email protected]` by version only, so it trusted the registry to serve the same bytes. npm's own integrity check compares against a hash from that same registry, so it does not help if the registry entry changes. Requested by [email protected] in the Slack thread (C0C90EFJ0DQ, 1796040539.253869). ## What changed - `references/everystate.md`: the run is now two commands. A `node -e` one-liner downloads `https://registry.npmjs.org/everystate/-/everystate-0.4.3.tgz`, hashes it in memory and, only when its sha512 matches the hash written in the skill, writes it to `everystate-0.4.3.tgz.part` and renames it to `everystate-0.4.3.tgz`. Then `npm exec --package=./everystate-0.4.3.tgz` runs that file. On any failure it prints why, exits 1 and leaves no tarball under the final name, and the skill tells the agent to stop and report the message. - The download line runs again before every checker run, so a tarball swapped on disk between runs is caught. - `SKILL.md` step 2 and the README describe the new flow. The requirement is now Node.js 18 or later (for `fetch`). - Version 1.0.1 to 1.1.0 in `plugin.json` and the `marketplace.json` entry; Codex manifest regenerated. ### Why not `npm pack` + a separate hash check (my first commit, 0ef9073) A Codex security pass found two holes in it, both closed in ab476f3: 1. `npm pack` follows the `dist.tarball` the registry metadata names. If that points at a git source, npm runs its `prepare` script before any hash check. A fixed URL with the check in memory means nothing from the package runs or lands on disk before the check. 2. The check used `h!==...`. Under `cmd.exe` with delayed expansion, `!` is eaten and the comparison flips. The new command has no `!`. cubic then found two P3s (5ce5b09, 51650b2): an HTTP error was reported as a hash mismatch, and a failed write could leave a partial tarball. Both fixed and resolved. ## Verification (dogfood on 51650b2, Node 22, live npm registry) | Case | Result | |---|---| | Download with the pinned hash | exit 0, 7,501,007-byte tarball written | | Spec that holds (`x <= 2`) | everystate exit 0 | | Spec that breaks (`x <= 1`) | everystate exit 12, `Invariant Inv is violated` | | Pin changed by one character | exit 1, `Hash mismatch, nothing written`, no file | | Wrong version URL (404) | exit 1, `Download or save failed: HTTP 404 from <url>`, no file | | No network | exit 1, `Download or save failed: fetch failed`, no file | | Read-only directory, unprivileged user | exit 1, `Download or save failed: EACCES ...`, no file | | `!` in the command | 0 occurrences | ## Gates (head 51650b2) | Gate | Result | |---|---| | `generate_codex_marketplace.py --check` | pass | | `validate_codex_plugins.py` | pass (21 local, 5 external) | | `check_plugin_versions.py --base origin/main` | pass (1.1.0) | | `python3 -m unittest discover -s tests` | OK (1 skipped) | | ruff, mypy | pass | | `claude plugin validate --strict .` | pass | | Em/en dash grep on changed docs | 0 | | Codex security pass | 0ef9073: 2 findings, fixed. 51650b2: none (P0 to P3) | | cubic | 2 P3s fixed and resolved; 5/5, no issues on 51650b2 | | `/code-review` (low) | no findings | | CI (Aikido check code + Deep Review, CodeQL, validate, generator-windows, scan-skills, skillspector, codex-sync) | all pass | | `/forge:forge`, `/eng-review` | not run: unavailable in this sandbox (Unknown skill) | ## After merge Check that the marketplace lists tla-state-check 1.1.0, and run the skill's download line against `main` from a clean directory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: S2D2 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Guillaume Lebedel <[email protected]>
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.
What changed
Adds
tla-state-check(engineering), a plugin with one skill. Given a codebase, it finds the state machines nobody drew (status columns, state enums, job and run lifecycles, retries and timers, acquired and released handles and slots, health checks, startup, shutdown and deploy ordering), writes a small TLA+ model for each in a scratch directory outside the repo, checks it with everystate pinned to 0.4.3, and checks every counterexample against the code at the commit under review. Each one is classified as a real bug, unverified, or a model artifact; real bugs get one of seven issue types. The report gives counts per verdict and issue type, each finding withfile:line, the event trace, the broken invariant and a one-line fix, and what was not checked. It does not open fix PRs unless asked.SKILL.mdholds the goal, boundaries and the ordered pipeline (write spec, run, verify against code, classify, report). The everystate command reference and the issue-type taxonomy are inreferences/. No scripts, hooks, commands or agents.Reads: the target repository's code, config and migrations. Writes: specs, configs, checker output and the report into a fresh
mktemp -ddirectory under$TMPDIR, never into the target repo. Network: onlynpxfetching[email protected]from npm, which the skill asks the user about once per session before the first run (the package has no install script and ships native binaries plus a WebAssembly fallback; the reference records its integrity hash). No telemetry, no pipe-to-shell. All repo content and checker output is treated as data, not instructions.Plugins touched
tla-state-checkAlso: one entry in
.claude-plugin/marketplace.json, a row in the root README plugin table, the catalog description, and regenerated Codex files.How it was verified
python3 scripts/generate_codex_marketplace.py --check: passpython3 -m unittest discover -s tests: 322 tests OK (1 skipped)python3 scripts/validate_codex_plugins.py: passpython3 scripts/check_plugin_versions.py --base origin/main: pass (1 plugin touched)ruff checkandmypy scripts: passclaude plugin validate --strict .: passCLAUDE_CONFIG_DIRandCODEX_HOME; the skill is present in both plugin caches-json), 13 liveness, 150 parse error, 151 config error; an evaluation error returned 255, which the reference notes/tmpscratch path) fixed withmktemp -d; one low (install URLs naming the repo owner in the plugin README) left as is, matching every other plugin README and the templatescripts/scan-skills.sh: not run locally (skillspectornot installed here); left to thescan-skillsCI jobrequirements-dev.txtdid not install on this machine's Python 3.10 (coverage==7.17.5needs a newer Python); the checks above ran with the runtime requirements plus ruff and mypyChecklist
git grepshows only author, homepage and install lines, as in other plugins)plugin.jsonand its catalog entry (new plugin, 1.0.0 in both)🤖 Generated with Claude Code