Improve custom policy usage reconciliation#2836
Conversation
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughLLM provider creation and updates now always reconcile custom policy usages. Usage UUIDs are deduplicated and inserted with one batched SQL statement. Tests cover duplicate inputs, rollback behavior, and clearing usages during plain updates. ChangesLLM custom policy usage reconciliation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@platform-api/internal/repository/custom_policy.go`:
- Around line 244-261: Update the custom-policy usage INSERT flow around the
valuePlaceholders and args construction to avoid unbounded bind parameters.
Split unique policy UUIDs into bounded INSERT chunks within the existing
transaction, keeping each chunk below the lowest supported database parameter
limit and preserving deduplication and error handling.
In `@platform-api/internal/repository/llm_test.go`:
- Around line 102-104: Strengthen the assertion in the usage test around the
policy usage results to verify both distinct UUIDs, not just len(usages).
Compare the returned UUIDs order-independently against policy.UUID and
secondPolicy.UUID, while preserving the required deduplication expectation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: eebe21d7-d477-40ee-87b1-ff7dd3b23df0
📒 Files selected for processing (3)
platform-api/internal/repository/custom_policy.goplatform-api/internal/repository/llm.goplatform-api/internal/repository/llm_test.go
Purpose
Ensure custom policy usages are consistently maintained for LLM providers and reduce database transaction overhead when storing multiple policy usages.
Resolves #2802
Goals
Approach
replaceCustomPolicyUsagesTxto build one parameterized multi-rowINSERTinstead of executing one insert per policy UUID.User stories
Documentation
N/A — this is an internal persistence and performance improvement with no user-facing API or configuration changes.
Automation tests
internal/repositorytest suite passes.Security checks
Samples
N/A — no sample changes are required.
Related PRs
N/A
Test environment