fix: optimize login scope deduplication#235
Open
michiosw wants to merge 1 commit into
Open
Conversation
Summary This optimizes login scope resolution by deduplicating scopes in one pass. Before this, resolveLoginScopes in internal/auth/oidc.go rescanned the growing resolved slice for every requested scope, which made repeated custom scopes cost more work and made the merge path harder to reason about. Now one seen-map tracks both base scopes and custom scopes as the canonical path. Why This gives kontext-cli a cheaper runtime path for OIDC login scope assembly: custom scope input -> resolveLoginScopes -> deduplicated scope list in stable order This PR does not broaden behavior beyond the optimization scope. What changed Optimized resolveLoginScopes in internal/auth/oidc.go Removed repeated linear scans during custom scope deduplication Preserved default scope selection and custom scope order Updated tests for repeated custom scopes and default-scope overlap Verification go test ./internal/auth -count=1 go test ./internal/guard/judge -count=1 go test ./internal/guard/judge -count=5 go test ./... -count=1 -p 1 go vet ./... git diff --check Notes The required go test ./... -count=1 run still fails on fresh main in internal/guard/judge with two llama-server startup timing tests under package-parallel load. The auth change does not touch that package, and the judge package passes when rerun directly and when the suite is serialized with -p 1.
Greptile SummaryThis PR optimizes login scope resolution while keeping the same OAuth scope order. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Reviews (1): Last reviewed commit: "fix: optimize login scope deduplication" | Re-trigger Greptile |
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
Verification
go test ./...go test -race ./...go vet ./...buf generateif protobuf or generated code changedRelease notes