From 0ef9073cea9e6269b112e4aea1d14ede5b6baf02 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Mon, 30 Nov 2026 14:07:57 +0000 Subject: [PATCH 1/4] feat(tla-state-check): pin everystate by sha512, not just version Fetch the 0.4.3 tarball with npm pack, check its sha512 against the hash recorded in the skill, and run the checker from that local tarball. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- .claude-plugin/marketplace.json | 2 +- .../.claude-plugin/plugin.json | 2 +- .../tla-state-check/.codex-plugin/plugin.json | 2 +- plugins/engineering/tla-state-check/README.md | 7 +++--- .../skills/tla-state-check/SKILL.md | 7 +++--- .../tla-state-check/references/everystate.md | 24 ++++++++++++------- 6 files changed, 27 insertions(+), 17 deletions(-) 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..0ab8701 100644 --- a/plugins/engineering/tla-state-check/README.md +++ b/plugins/engineering/tla-state-check/README.md @@ -66,14 +66,15 @@ 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 `npm pack` fetching the `everystate@0.4.3` tarball from the npm registry, + which the agent asks you about before the first run in a session. The agent checks the + tarball's sha512 against the hash pinned in the skill and stops if it differs. - 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 with `npm`, and access to the npm registry for the first run ## 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..a587677 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` (fetch the 0.4.3 tarball, check its sha512, 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..971121e 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,18 +7,26 @@ no install script and needs no Java. ## Command +Fetch the package once per scratch directory, check its hash against the pin below, then run +the checker from that local tarball: + ```bash -npx -y everystate@0.4.3 -config .cfg .tla +npm pack everystate@0.4.3 +node -e "const h='sha512-'+require('crypto').createHash('sha512').update(require('fs').readFileSync('everystate-0.4.3.tgz')).digest('base64');if(h!==process.argv[1]){console.error('everystate-0.4.3.tgz does not match the pinned hash: '+h);process.exit(1)}" sha512-zG2jpVd194+ZAItfGB7wwMhJmUwHD32QBIZpa1rTS/hBhr1L+Do/69l+g4lu0VyPQ9rz6t4lSMF3G7tt+4SK8g== +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. +Run all three from the scratch directory that holds the spec. Later runs in the same directory +skip the first two lines. If the hash check fails, stop: do not run the checker, and tell the +user the hash npm served. -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 +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. The +check above compares it with the hash recorded here, from everystate 0.4.3 as published. The +package has no dependencies and no install scripts, so the tarball is everything that runs. +Keep the version and the hash together: the exit codes and output below were checked against +0.4.3. The only network access is `npm pack` fetching that tarball from the npm registry; ask +the user before the first fetch 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 From ab476f3155ac78ed9076a79cf8f934e8616fe6d0 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Mon, 30 Nov 2026 14:15:00 +0000 Subject: [PATCH 2/4] fix(tla-state-check): download by fixed URL and check hash before writing npm pack follows the dist.tarball the registry metadata names and can run a prepare script from a git source before any check. Download the fixed registry URL instead, hash in memory, and write the tarball only on a match. The command has no '!', so cmd.exe delayed expansion cannot flip the comparison. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- plugins/engineering/tla-state-check/README.md | 9 +++--- .../skills/tla-state-check/SKILL.md | 4 +-- .../tla-state-check/references/everystate.md | 31 +++++++++++-------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/plugins/engineering/tla-state-check/README.md b/plugins/engineering/tla-state-check/README.md index 0ab8701..35dfef3 100644 --- a/plugins/engineering/tla-state-check/README.md +++ b/plugins/engineering/tla-state-check/README.md @@ -66,15 +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 `npm pack` fetching the `everystate@0.4.3` tarball from the npm registry, - which the agent asks you about before the first run in a session. The agent checks the - tarball's sha512 against the hash pinned in the skill and stops if it differs. + 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 `npm`, 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 a587677..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 @@ -73,8 +73,8 @@ through this pipeline in order: 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 with the hash-pinned command in - `references/everystate.md` (fetch the 0.4.3 tarball, check its sha512, run it), then read - the exit code. That file also has the flags and exit codes. + `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 971121e..2ba7252 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,27 +7,32 @@ no install script and needs no Java. ## Command -Fetch the package once per scratch directory, check its hash against the pin below, then run -the checker from that local tarball: +Two commands, both from the scratch directory that holds the spec. The first downloads the +0.4.3 tarball, hashes it in memory and writes `everystate-0.4.3.tgz` only if the hash matches +the pin. The second runs the checker from that file: ```bash -npm pack everystate@0.4.3 -node -e "const h='sha512-'+require('crypto').createHash('sha512').update(require('fs').readFileSync('everystate-0.4.3.tgz')).digest('base64');if(h!==process.argv[1]){console.error('everystate-0.4.3.tgz does not match the pinned hash: '+h);process.exit(1)}" sha512-zG2jpVd194+ZAItfGB7wwMhJmUwHD32QBIZpa1rTS/hBhr1L+Do/69l+g4lu0VyPQ9rz6t4lSMF3G7tt+4SK8g== +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=>r.arrayBuffer()).then(b=>{const d=Buffer.from(b),h='sha512-'+require('crypto').createHash('sha512').update(d).digest('base64');if(h===p){require('fs').writeFileSync('everystate-0.4.3.tgz',d)}else{console.error('Hash mismatch, nothing written: '+h);process.exit(1)}})" npm exec --yes --package=./everystate-0.4.3.tgz -- everystate -config .cfg .tla ``` -Run all three from the scratch directory that holds the spec. Later runs in the same directory -skip the first two lines. If the hash check fails, stop: do not run the checker, and tell the -user the hash npm served. +If the first command exits non-zero, stop: do not run the checker, and tell the user the hash it +printed. 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. 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. The -check above compares it with the hash recorded here, from everystate 0.4.3 as published. The -package has no dependencies and no install scripts, so the tarball is everything that runs. +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 `npm pack` fetching that tarball from the npm registry; ask -the user before the first fetch 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`. +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 From 5ce5b093e82bb2401d1549817d31dbd85eb1cfac Mon Sep 17 00:00:00 2001 From: S2D2 Date: Mon, 30 Nov 2026 14:20:56 +0000 Subject: [PATCH 3/4] fix(tla-state-check): report HTTP and network errors, not a hash mismatch Addresses cubic review on #54: check r.ok before hashing and catch fetch failures, so a 404 or offline run says why and still writes nothing. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- .../skills/tla-state-check/references/everystate.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 2ba7252..09a2e0a 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 @@ -12,14 +12,14 @@ Two commands, both from the scratch directory that holds the spec. The first dow the pin. The second runs the checker from that file: ```bash -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=>r.arrayBuffer()).then(b=>{const d=Buffer.from(b),h='sha512-'+require('crypto').createHash('sha512').update(d).digest('base64');if(h===p){require('fs').writeFileSync('everystate-0.4.3.tgz',d)}else{console.error('Hash mismatch, nothing written: '+h);process.exit(1)}})" +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){require('fs').writeFileSync('everystate-0.4.3.tgz',d)}else{console.error('Hash mismatch, nothing written: '+h);process.exit(1)}}).catch(e=>{console.error('Download failed, nothing written: '+e.message);process.exit(1)})" npm exec --yes --package=./everystate-0.4.3.tgz -- everystate -config .cfg .tla ``` -If the first command exits non-zero, stop: do not run the checker, and tell the user the hash it -printed. 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. +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 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. 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 From 51650b2cecb8680d8e3de7897794af94c4328e58 Mon Sep 17 00:00:00 2001 From: S2D2 Date: Mon, 30 Nov 2026 14:25:34 +0000 Subject: [PATCH 4/4] fix(tla-state-check): write the checked tarball via .part and rename Addresses cubic review on #54: a failed write no longer leaves a partial everystate-0.4.3.tgz, and the error says download or save failed. Co-Authored-By: Claude Opus 5.5 Co-authored-by: Guillaume Lebedel <10488548+glebedel@users.noreply.github.com> --- .../skills/tla-state-check/references/everystate.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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 09a2e0a..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 @@ -8,18 +8,19 @@ 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 writes `everystate-0.4.3.tgz` only if the hash matches -the pin. The second runs the checker from that file: +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 -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){require('fs').writeFileSync('everystate-0.4.3.tgz',d)}else{console.error('Hash mismatch, nothing written: '+h);process.exit(1)}}).catch(e=>{console.error('Download failed, nothing written: '+e.message);process.exit(1)})" +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 ``` 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 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. +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. 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