Skip to content

fix(install): verify curated skill content against the lockfile integrity - #3512

Merged
dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3493-frozen-skill-integrity
Oct 17, 2026
Merged

dyoshikawa merged 4 commits into
mainfrom
resolve-issue-3493-frozen-skill-integrity

Conversation

@dyoshikawa

@dyoshikawa dyoshikawa commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

rulesync install (and install --frozen) decided whether a locked source could be reused by checking only that each curated skill directory existed. Curated rules were already hashed against the lockfile integrity, so a rule edited in place was restored, but a skill edited in place under .rulesync/skills/.curated/ was silently kept.

This PR replaces the presence check with a content check:

  • checkLockedSkillsAreValid hashes every file of each locked curated skill (hidden files included) with computeSkillIntegrity and compares the result with the integrity recorded in rulesync.lock / rulesync-npm.lock.json. An edited, added or removed file makes the cache unusable, so the skill is fetched again at its locked ref and restored to the locked content, as a rule is. Under --frozen the lockfile is still not written.
  • The check is used by the github, git and npm transports and by the "existing source is fully installed" gate used when adding a source, matching what rules already do.
  • The locked hash keys files by the path the transport reported (POSIX for the GitHub API and npm, platform paths for the git transport), so on Windows both spellings are accepted.
  • A skill name an earlier source already installed is checked for presence only (the curated directory holds that source's copy), and such names are protected from a later source's refetch cleanup, so two sources sharing a skill name do not refetch forever or delete each other's copy. Entries migrated from the legacy lockfile with an empty integrity are checked for presence only.
  • Docs: docs/guide/declarative-sources.md now states that skill content is verified too (docs-content regenerated).

Not included

The issue also floats failing --frozen with a non-zero exit on a mismatch instead of restoring the file. That is a behavior change for rules as well and is left for a separate decision; this PR keeps skills consistent with how rules behave today.

Tests

  • New cases in src/lib/sources.test.ts: frozen install re-fetches a skill whose file was edited, added or removed; an existing source with an edited skill is not counted as fully installed. They fail on main.
  • The test file's mocked writeFileContent / readFileContent / listFilePathsRecursively now share an in-memory file map, so cached-skill tests seed real content and integrities instead of placeholder hashes.
  • Regression tests for a skill name shared by two sources, for an empty legacy integrity, and an install-then-frozen-install round trip.
  • pnpm cicheck passes locally.

Closes #3493

🤖 Generated with Claude Code

https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv

dyoshikawa and others added 4 commits October 17, 2026 21:54
…rity

Reusing a locked source only checked that each curated skill directory
existed, so a skill edited, extended or trimmed in place under
.rulesync/skills/.curated/ was treated as up to date by `install` and
`install --frozen`, while curated rules were already hashed against the
lockfile. Hash every file of each locked skill and compare it with the
recorded integrity before reusing the cache, so a modified skill is fetched
again at its locked ref and restored, as a rule is. The same check now
gates the "fully installed" test for existing sources when adding a source.

Closes #3493

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv
…integrity check

A skill name provided by two sources is installed by the earlier one, so a
later source's locked copy no longer matches its integrity. That made the
later source refetch on every install and, through cleanPreviousCuratedSkills,
delete the earlier source's copy before skipping the name as a duplicate.
Only check presence for locked skills an earlier source already took, protect
those names from the refetch cleanup, and apply the same rule when checking
that existing sources are fully installed. Entries migrated from the legacy
lockfile carry an empty integrity and are checked for presence only too.

Add regression tests for both cases and an install round-trip test.

Refs #3493

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv
… can be reused

The prefetch awaited every earlier source's skill claim before deciding
whether a source's lock entry could be reused, so a source without a
reusable entry could no longer list its skills until all earlier sources
had listed theirs. Pass the earlier claims as a thunk that is awaited only
once the ref, update flag and selection already allow the reuse, and cover
the parallel listing with a test. Document the two presence-only cases of
the curated skill integrity check.

Refs #3493

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012y9fNo2AAJdGocxvsHtDhv
@dyoshikawa
dyoshikawa merged commit d5fe238 into main Oct 17, 2026
9 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3493-frozen-skill-integrity branch October 17, 2026 14:03
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.

install --frozen does not verify the content of installed skills against the lockfile integrity

1 participant