WIP: Bust pin cache when solargraph's own lib code changes - #54
Draft
apiology wants to merge 1 commit into
Draft
Conversation
…VERSION PinCache.work_dir keys the on-disk cache directory on Solargraph::VERSION alone. Marshal silently tolerates loading pins serialized by an older Pin::Callable definition with fewer ivars (missing ones just read back as nil), so a gem source swap that changes Pin behavior without bumping VERSION -- e.g. a downstream Gemfile switching a git-sourced solargraph dependency to a different commit, common in fork-based development -- can leave stale pins in place after upgrading. This was flagged via castwide#1274 (comment): after PR castwide#1274 added Pin::Callable#block_required?, a consumer bisecting by swapping gem revisions without clearing ~/.cache/solargraph got block_required? == false (nil from the old-schema cached pin) for an RBS signature whose block is genuinely required, letting a generic-returning block overload spuriously match a call with no block and leak an unresolved generic<X> into the inferred return type. Reproduced by populating the cache on the pre-castwide#1274 commit and then switching to the post-castwide#1274 commit under the same forced VERSION, without clearing the cache. Fold a digest of solargraph's own lib/ file mtimes+sizes into work_dir so any code change -- not just a VERSION bump -- busts the cache. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QYGSCei2o8gmaghfjc15Uo
3 tasks
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.
Summary
PinCache.work_dirkeys the on-disk cache directory only onSolargraph::VERSION, a hardcoded string.Marshal.loadsilently tolerates deserializing pins that were serialized by an olderPin::Callabledefinition with fewer ivars (missing ones just read back asnil), so a gem source swap that changesPinbehavior without bumpingVERSIONcan leave stale, schema-mismatched pins cached on disk after upgrading.solargraphgem revision (git-sourced, sameVERSIONbefore/after) without clearing~/.cache/solargraph. That gavePin::Callable#block_required? == false(nilread back from the old-schema cached pin) for an RBS signature whose block is genuinely required, letting a generic-returning block overload spuriously match a call site with no block and leak an unresolvedgeneric<X>into the inferred return type.VERSION, don't clear the cache -> same symptom on the same minimal repro from the linked comment. Clearing the cache (or this fix) makes it go away.lib/file mtimes+sizes intowork_dir, so any code change -- not just aVERSIONbump -- busts the cache automatically.Marked draft/WIP: this is a real, reproduced bug, but low urgency (self-resolves once affected users clear their cache once) -- opening now mainly so the finding and fix aren't lost.
Test plan
bundle exec rspec spec/pin_cache_spec.rb-- new spec covers digest sensitivity and that it's folded intowork_dirbundle exec rspec-- full suite green (1625 examples, 0 failures, 60 pending)bundle exec rubocop lib/solargraph/pin_cache.rb spec/pin_cache_spec.rb-- cleanbundle exec solargraph typecheck --level strong lib/solargraph/pin_cache.rb-- no new problems on modified linesGenerated with Claude Code
https://claude.ai/code/session_01QYGSCei2o8gmaghfjc15Uo