Repository navigation
Cache unchanged skill catalog candidates - #5966
Merged
Merged
Conversation
SkillTreeRegistry.readTree reuses a file's previous sha256 when its dev/ino/size/mtime/ctime stat key is unchanged, so repeated catalog resolves stop rereading and rehashing every skill file on each turn. Fixes #5963 Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
slopcop/issue-5963
branch
from
October 29, 2026 06:16
a742648 to
9ad1636
Compare
Filesystems with coarse timestamps (the Linux CI runner) can give a same-size rewrite the same ctime as the version already hashed, so its stat key matches and the stale hash was reused. Like Git's racy-clean rule, a hash is reusable only when the file's ctime is at least two seconds older than the moment hashing started. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
Every turn start (and the project command list and plugin skill listing) calls
resolveSkillCatalog, andSkillTreeRegistry.readTreestreamed and SHA-256-hashed every file of every skill tree on every call, even when nothing had changed. The registry already recorded a per-filestatKey(dev, inode, size, mtime, ctime) in each manifest for the tree-content endpoint, but never consulted it before rehashing. On a real~/.bbplus the repo's plugin skill roots, each resolve re-read 74 files (576 KB).Reproduction and root-cause report: https://get-bb.github.io/reports/issues/5963.html
What changed
This replaces the original commit on this branch, which targeted the old synchronous skill code and no longer applied after #6330, #6335 and #6185.
apps/server/src/services/skills/injected-skills.ts:readTreelooks up the root's previous manifest and reuses a file'ssha256when itsstatKeyis unchanged, instead of reading it again. Mode, size and path still come from the freshlstat/stat, and symlink and non-regular-file rejection are unchanged.statKey. Following Git's racy-clean rule, a hash is reusable only if the file's ctime is at least 2 s older than the moment hashing started (HASH_REUSE_SETTLE_NS). Recently changed files are rehashed until they settle.hashReusableis a server-only field onSkillTreeFile; the/skills/tree/:hashroute projects fields explicitly, so the wire format is unchanged. There are no protocol, public API, schema, CLI or config changes.How you verified
apps/server/test/skills/skill-catalog-cache.test.ts(8 tests):createReadStreamnot called). This fails onorigin/main(2 reads).resolveSkillCatalogEntriesover~/.bbplus repo plugin skill roots, one shared registry): before, 74 reads / 576,146 bytes per resolve, ~12 ms warm median; after, 0 reads / 0 bytes on repeat resolves, ~7 ms, with an identical catalog.pnpm start:worktree: a Claude Code thread read aqa-canaryuser skill's reference file (ALPHA). The file was then rewritten at the same size with its mtime restored (BRAVO), and the next turn readBRAVO. This still held after a server restart on the final commit.pnpm exec turbo run test --filter=@bb/server -- test/skills test/internal test/threads/thread-runtime-config.test.ts: 296 tests pass in 26 files.pnpm exec turbo run typecheck lint --filter=@bb/server: passes.oxfmt --check: passes.Fixes #5963
🤖 Generated with Claude Code