Skip to content

Cache normalized organization membership lookups - #302

Open
hosom wants to merge 1 commit into
mainfrom
cache-normalized-org-membership
Open

Cache normalized organization membership lookups#302
hosom wants to merge 1 commit into
mainfrom
cache-normalized-org-membership

Conversation

@hosom

@hosom hosom commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bff1e95b-3949-4ae8-b3a5-737fd278a977
Copilot AI balanced review requested due to automatic review settings September 9, 2026 20:33

Copilot AI 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.

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 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity 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)
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