Cache normalized organization membership lookups - #302
Open
hosom wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: bff1e95b-3949-4ae8-b3a5-737fd278a977
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Mixed-case usernames loaded from the predictive cache can be incorrectly reported as non-members.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
lib/entitlements/service/github.rb — The predictive-cache path copies member UIDs into entry[:value] without normalizing them (lines… |
What changed in this PR
Adds cached, case-insensitive organization membership lookups to avoid repeatedly enumerating membership maps.
Changes:
- Adds and synchronizes normalized membership sets.
- Uses direct membership lookups when generating ignored users.
- Adds coverage for caching, isolation, invalidation, and mutations.
| File | Description |
|---|---|
lib/entitlements/service/github.rb |
Implements normalized membership caching. |
lib/entitlements/backend/github_team/provider.rb |
Uses cached membership lookups. |
lib/entitlements/backend/github_org/service.rb |
Synchronizes membership mutations. |
spec/unit/entitlements/service/github_spec.rb |
Tests lookup caching and invalidation. |
spec/unit/entitlements/backend/github_team/provider_spec.rb |
Tests ignored-user generation. |
spec/unit/entitlements/backend/github_team/controller_spec.rb |
Updates membership mocks. |
spec/unit/entitlements/backend/github_org/service_spec.rb |
Tests mutation synchronization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def org_member?(username) | ||
| org_members | ||
| entry = Entitlements.cache[:github_org_members].fetch(org_signature) | ||
| entry[:normalized_members] ||= Set.new(entry[:value].keys) |
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.

Split from #300 so that PR remains focused on GraphQL connection reuse.
This adds a cached, case-insensitive organization membership lookup and keeps it synchronized as members are added or removed. GitHub team ignored-user generation uses the lookup instead of repeatedly normalizing and enumerating the full organization membership map.