Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
"concurrency",
"race-conditions"
],
"version": "1.0.1",
"version": "1.1.0",
"author": {
"name": "StackOne",
"url": "https://github.com/StackOneHQ"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tla-state-check",
"version": "1.0.1",
"version": "1.1.0",
"description": "Find the state machines a codebase never drew, model each in TLA+ outside the repo, model check them with everystate, and check every counterexample against the code before calling it a bug.",
"author": {
"name": "StackOne",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions plugins/engineering/tla-state-check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ checked.
- Write or commit specs into the target repository.
- Open issues, branches or pull requests, unless you ask for that in the session.
- Send your code, specs, traces, transcripts or environment variables anywhere. The only
network access is `npx` fetching the pinned `[email protected]` package from the npm registry,
which the agent asks you about before the first run in a session.
network access is downloading the `[email protected]` tarball from a fixed npm registry URL,
which the agent asks you about before the first run in a session. The download checks the
tarball's sha512 against the hash pinned in the skill, writes nothing if it differs, and the
agent then stops.
- Collect telemetry, run install hooks, or pipe a download into a shell.

## Requirements

- Claude Code v2.x+ or OpenAI Codex
- Node.js with `npx`, and access to the npm registry for the first run
- Node.js 18 or later with `npm`, and access to the npm registry

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Places implicit state machines hide:
- Report only. Opening issues, fix branches or pull requests needs the user's explicit yes in
this session.
- Running the checker downloads and executes a third-party npm package with the user's
permissions, so ask once per session before the first `npx` run, naming the package and
permissions, so ask once per session before the first fetch, naming the package and
version. Ask even when an `everystate` is already installed: running `everystate --version`
executes whatever binary is first on the `PATH`, so do not run it before the user's yes. The
only network use is that fetch from the npm registry. Do not send code, specs, traces,
Expand All @@ -72,8 +72,9 @@ through this pipeline in order:
code allows: two workers, a redelivered message, a timer firing after cancel, a crash between
two writes. Keep constants tiny (two workers, two items, retry limit 2) so the check finishes
in seconds.
2. **Run everystate** from the scratch directory:
`npx -y [email protected] -config <spec>.cfg <spec>.tla`, then read the exit code. The command, flags and exit codes are in `references/everystate.md`.
2. **Run everystate** from the scratch directory with the hash-pinned command in
`references/everystate.md` (download the 0.4.3 tarball, keep it only if its sha512 matches
the pin, run it), then read the exit code. That file also has the flags and exit codes.
3. **Check each counterexample against the code** at the recorded commit, step by step. Find the
lines that allow each transition in the trace and look for a guard, lock, transaction,
unique constraint or conditional update the model left out.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,33 @@ no install script and needs no Java.

## Command

Two commands, both from the scratch directory that holds the spec. The first downloads the
0.4.3 tarball, hashes it in memory and, only if the hash matches the pin, writes it to a
`.part` file and renames that to `everystate-0.4.3.tgz`, so a failed write never leaves a
partial tarball under that name. The second runs the checker from that file:

```bash
npx -y [email protected] -config <spec>.cfg <spec>.tla
node -e "const u='https://registry.npmjs.org/everystate/-/everystate-0.4.3.tgz',p='sha512-zG2jpVd194+ZAItfGB7wwMhJmUwHD32QBIZpa1rTS/hBhr1L+Do/69l+g4lu0VyPQ9rz6t4lSMF3G7tt+4SK8g==';fetch(u).then(r=>{if(r.ok){return r.arrayBuffer()}throw new Error('HTTP '+r.status+' from '+u)}).then(b=>{const d=Buffer.from(b),h='sha512-'+require('crypto').createHash('sha512').update(d).digest('base64');if(h===p){const f=require('fs');f.writeFileSync('everystate-0.4.3.tgz.part',d);f.renameSync('everystate-0.4.3.tgz.part','everystate-0.4.3.tgz')}else{console.error('Hash mismatch, nothing written: '+h);process.exit(1)}}).catch(e=>{console.error('Download or save failed: '+e.message);process.exit(1)})"
npm exec --yes --package=./everystate-0.4.3.tgz -- everystate -config <spec>.cfg <spec>.tla
```

Run it from the scratch directory that holds the spec. Keep the version pinned: the exit codes
and output below were checked against 0.4.3. The only network access is `npx` fetching that
package from the npm registry; ask the user before the first fetch in a session.
If the first command exits non-zero, stop: do not run the checker, and tell the user what it
printed (a hash mismatch with the hash it got, or the download or save error). Run the first
command again before each checker run, even when the tarball is already there: `npm exec`
runs whatever the file holds at that moment, and the download is what checks it.

npm checks the downloaded tarball against the registry's integrity hash. For 0.4.3 that hash is
`sha512-zG2jpVd194+ZAItfGB7wwMhJmUwHD32QBIZpa1rTS/hBhr1L+Do/69l+g4lu0VyPQ9rz6t4lSMF3G7tt+4SK8g==`.
A user who wants to compare it can run `npm view [email protected] dist.integrity` themselves;
the agent does not make that extra registry request. Do not check for an installed copy with
`everystate --version` before the user's yes: it runs whatever binary is first on `PATH`.
The hash is the pin. A version number alone trusts the registry to serve the same bytes, and
npm's own integrity check compares the tarball with a hash fetched from that same registry. This
command compares it with the hash recorded here, from everystate 0.4.3 as published, before
anything from the package is written to disk or run. It fetches a fixed registry URL rather than
using `npm pack`, which follows whatever tarball location the registry metadata names and can
run a `prepare` script from a git source before any check. The package has no dependencies and
no install scripts, so the tarball is everything that runs. The command has no `!`, so Windows
`cmd.exe` with delayed expansion leaves it intact. It needs Node.js 18 or later for `fetch`.
Keep the version and the hash together: the exit codes and output below were checked against
0.4.3. The only network access is that download from the npm registry; ask the user before the
first one in a session. Do not check for an installed copy with `everystate --version` before
the user's yes: it runs whatever binary is first on `PATH`.

## Flags

Expand Down