diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 3c36049..be456d3 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -249,7 +249,7 @@ "concurrency", "race-conditions" ], - "version": "1.0.1", + "version": "1.1.0", "author": { "name": "StackOne", "url": "https://github.com/StackOneHQ" diff --git a/plugins/engineering/tla-state-check/.claude-plugin/plugin.json b/plugins/engineering/tla-state-check/.claude-plugin/plugin.json index cb64e22..9e0fba3 100644 --- a/plugins/engineering/tla-state-check/.claude-plugin/plugin.json +++ b/plugins/engineering/tla-state-check/.claude-plugin/plugin.json @@ -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", diff --git a/plugins/engineering/tla-state-check/.codex-plugin/plugin.json b/plugins/engineering/tla-state-check/.codex-plugin/plugin.json index 6188f60..b3d4fd1 100644 --- a/plugins/engineering/tla-state-check/.codex-plugin/plugin.json +++ b/plugins/engineering/tla-state-check/.codex-plugin/plugin.json @@ -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", diff --git a/plugins/engineering/tla-state-check/README.md b/plugins/engineering/tla-state-check/README.md index d911697..35dfef3 100644 --- a/plugins/engineering/tla-state-check/README.md +++ b/plugins/engineering/tla-state-check/README.md @@ -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 `everystate@0.4.3` package from the npm registry, - which the agent asks you about before the first run in a session. + network access is downloading the `everystate@0.4.3` 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 diff --git a/plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md b/plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md index edc74b4..f5c9daa 100644 --- a/plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md +++ b/plugins/engineering/tla-state-check/skills/tla-state-check/SKILL.md @@ -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, @@ -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 everystate@0.4.3 -config .cfg .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. diff --git a/plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md b/plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md index 0055aa1..9c56044 100644 --- a/plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md +++ b/plugins/engineering/tla-state-check/skills/tla-state-check/references/everystate.md @@ -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 everystate@0.4.3 -config .cfg .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 .cfg .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 everystate@0.4.3 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