Global Policy Support for LLM Providers and Proxies#2238
Conversation
|
Important Review skippedToo many files! This PR contains 248 files, which is 98 over the limit of 150. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (248)
You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0eabb3a to
2ac0e23
Compare
|
@coderabbitai review --dir gateway/ |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Explore the gateway/ directory structure
tree gateway/ 2>/dev/null || find gateway/ -type f | sortLength of output: 26240 🏁 Script executed: #!/bin/bash
# Get all Go files in gateway/ directory
fd -e go . gateway/ | sortLength of output: 26174 🏁 Script executed: #!/bin/bash
# Get the PR diff for gateway/ directory
gh pr diff 2238 --repo wso2/api-platform -- 'gateway/**' 2>/dev/null | head -3000Length of output: 377 🏁 Script executed: #!/bin/bash
# Get list of changed files in the PR
gh api repos/wso2/api-platform/pulls/2238/files --paginate --jq '.[].filename' 2>/dev/null | grep '^gateway/' | sortLength of output: 6758 🏁 Script executed: #!/bin/bash
# Get PR details
gh pr view 2238 --repo wso2/api-platform 2>/dev/null || echo "Cannot access PR"Length of output: 2536 🏁 Script executed: #!/bin/bash
# Get diffs for key source files
for file in \
"gateway/gateway-controller/pkg/utils/llm_transformer.go" \
"gateway/gateway-controller/pkg/utils/mcp_transformer.go" \
"gateway/gateway-controller/pkg/config/llm_validator.go" \
"gateway/gateway-controller/pkg/config/mcp_validator.go" \
"gateway/gateway-controller/pkg/api/handlers/resource_response.go"; do
echo "=== DIFF: $file ==="
gh api "repos/wso2/api-platform/pulls/2238/files" --paginate --jq ".[] | select(.filename == \"$file\") | .patch" 2>/dev/null
echo ""
doneLength of output: 20868 🏁 Script executed: #!/bin/bash
# Get the management openapi yaml diff
gh api "repos/wso2/api-platform/pulls/2238/files" --paginate --jq '.[] | select(.filename == "gateway/gateway-controller/api/management-openapi.yaml") | .patch' 2>/dev/null | head -500Length of output: 16191 🏁 Script executed: #!/bin/bash
# Check for deploymenttransform package mentioned in PR
fd -e go . gateway/ | xargs grep -l "deploymenttransform" 2>/dev/null
rg -r "deploymenttransform" gateway/ --include="*.go" -l 2>/dev/null
# Check if the package exists
find gateway/ -type d -name "deploymenttransform" 2>/dev/nullLength of output: 542 🏁 Script executed: #!/bin/bash
# Get diff for llm_validator_policy_exclusivity_test.go
gh api "repos/wso2/api-platform/pulls/2238/files" --paginate \
--jq '.[] | select(.filename == "gateway/gateway-controller/pkg/config/llm_validator_policy_exclusivity_test.go") | .patch' 2>/dev/nullLength of output: 6545 🏁 Script executed: #!/bin/bash
# Get diff for main.go and api_validator.go
for file in \
"gateway/gateway-controller/cmd/controller/main.go" \
"gateway/gateway-controller/pkg/config/api_validator.go"; do
echo "=== DIFF: $file ==="
gh api "repos/wso2/api-platform/pulls/2238/files" --paginate --jq ".[] | select(.filename == \"$file\") | .patch" 2>/dev/null
echo ""
doneLength of output: 1988 🏁 Script executed: #!/bin/bash
# Get diff for llm_transformer_test.go
gh api "repos/wso2/api-platform/pulls/2238/files" --paginate \
--jq '.[] | select(.filename == "gateway/gateway-controller/pkg/utils/llm_transformer_test.go") | .patch' 2>/dev/null | head -300Length of output: 11312 🏁 Script executed: #!/bin/bash
# Check actual file content for withGlobalAdvancedRatelimitKeyExtraction and collectOperationLevelLLMPolicies
# to verify slice aliasing concern in transformProxy/transformProvider
cat gateway/gateway-controller/pkg/utils/llm_transformer.go | grep -n "append\|merged\|spec.Policies\|gp\[" | head -40Length of output: 2035
Review:
|
… yaml; and api key policy not applying globally
c42b801 to
e09ac78
Compare
Purpose
Introduces
globalPoliciesandoperationPoliciesas first-class fields on LLM provider and proxy deployment artifacts, replacing the flat policies list. This enables provider-wide policy enforcement — such as a rate limit that applies across all operations — without duplicating configuration per path.Schema change
Artifacts now carry two distinct policy lists:
Gateway version-aware delivery
A new
deploymenttransformpackage handles artifact adaptation at deploy time. Gateways at version ≥ 1.2.0 receive the new globalPolicies/operationPolicies shape; older gateways transparently receive the legacy flattened policies list with the correct apiVersion stamp — no gateway-side change required for backward compatibility.AI Workspace UI
Guardrails tabs updated for both LLM proxies and service providers to surface global vs. per-operation policy configuration.
Version bump
Gateway management API and artifact apiVersion promoted to
v1alpha2; platform-api resource URL promoted tov1alpha2.