Skip to content

feat(tla-state-check): pin everystate by sha512, not just version - #54

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

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

Conversation

@glebedel

@glebedel glebedel commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

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

s2d2-s1 and others added 2 commits November 30, 2026 14:07
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 <[email protected]>
Co-authored-by: Guillaume Lebedel <[email protected]>
…ting

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 <[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.

1 issue found across 6 files

Confidence score: 5/5

  • In everystate.md, a failed download can be reported as a hash mismatch instead of the HTTP error. Check r.ok before hashing so the status is clear.
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:15">
P3: The download step doesn't check the HTTP status, so a 404 or 5xx body gets hashed and reported as a hash mismatch. Check `r.ok` before hashing so the error names the HTTP status instead.</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

…atch

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 <[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 1 file (changes from recent commits).

Confidence score: 4/5

  • In everystate.md, this catch also treats writeFileSync failures as download failures, so a disk error can leave a truncated tarball while reporting that nothing was written. Catch download errors separately or report write failures accurately.
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:15">
P3: This catch also handles `writeFileSync` failures, so a disk error can leave the tarball truncated while the command reports “nothing written” and calls it a download failure. Catch download errors separately or report save failures without claiming nothing was written.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

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 <[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 7c9cafd into main Nov 30, 2026
13 checks passed
@glebedel
glebedel deleted the feat/tla-state-check-hash-pin branch November 30, 2026 14:55
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.

2 participants