Skip to content

feat: add tla-state-check plugin - #52

Merged
glebedel merged 4 commits into
mainfrom
feat/tla-state-check
Nov 30, 2026
Merged

glebedel merged 4 commits into
mainfrom
feat/tla-state-check

Conversation

@glebedel

@glebedel glebedel commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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 with file: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.md holds 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 in references/. 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 -d directory under $TMPDIR, never into the target repo. Network: only npx fetching [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

Plugin Old version New version
tla-state-check (new) 1.0.0

Also: 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: pass
  • python3 -m unittest discover -s tests: 322 tests OK (1 skipped)
  • python3 scripts/validate_codex_plugins.py: pass
  • python3 scripts/check_plugin_versions.py --base origin/main: pass (1 plugin touched)
  • ruff check and mypy scripts: pass
  • claude plugin validate --strict .: pass
  • Installed from this checkout in Claude Code and Codex with throwaway CLAUDE_CONFIG_DIR and CODEX_HOME; the skill is present in both plugin caches
  • everystate 0.4.3 flags and exit codes checked against its README and by running toy specs: 0 pass, 10 assumption false, 11 deadlock, 12 invariant violated (also with -json), 13 liveness, 150 parse error, 151 config error; an evaluation error returned 255, which the reference notes
  • Codex security pass: one medium (predictable /tmp scratch path) fixed with mktemp -d; one low (install URLs naming the repo owner in the plugin README) left as is, matching every other plugin README and the template
  • Review comments from cubic, Aikido and SkillSpector: all answered; fixes in a767620 (ask before the first npx fetch, all repo content untrusted, scratch path checked outside the repo, Windows temp folder, dirty worktree handling, failed items in the conservation invariant, accurate README wording)
  • scripts/scan-skills.sh: not run locally (skillspector not installed here); left to the scan-skills CI job
  • requirements-dev.txt did not install on this machine's Python 3.10 (coverage==7.17.5 needs a newer Python); the checks above ran with the runtime requirements plus ruff and mypy

Checklist

  • No company, customer or personal names, internal URLs or machine paths (the company-agnostic git grep shows only author, homepage and install lines, as in other plugins)
  • Version bumped in the plugin's plugin.json and its catalog entry (new plugin, 1.0.0 in both)
  • Plugin README lists the skills, commands, agents and hooks it ships

🤖 Generated with Claude Code

s2d2-s1 and others added 2 commits November 30, 2026 13:06
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]>
@glebedel glebedel self-assigned this Nov 30, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 12 files

Confidence score: 3/5

  • SKILL.md fetches and runs [email protected] without verifying the package artifact. Require user approval before running it with their permissions.
  • SKILL.md relies 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 TMPDIR can put scratch files inside the target repository, contradicting the no-repository-writes promise. Verify the resolved directory is outside the repository.
  • README.md says 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.
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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
glebedel merged commit 0ff2feb into main Nov 30, 2026
13 checks passed
@glebedel
glebedel deleted the feat/tla-state-check branch November 30, 2026 13:41
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]>
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.

3 participants