Skip to content

feat(policy): add sort support to ListSubjectConditionSets API#3272

Open
dsm20 wants to merge 11 commits intomainfrom
feat/DSPX-2686-add-sort-listconditionsets
Open

feat(policy): add sort support to ListSubjectConditionSets API#3272
dsm20 wants to merge 11 commits intomainfrom
feat/DSPX-2686-add-sort-listconditionsets

Conversation

@dsm20
Copy link
Copy Markdown
Contributor

@dsm20 dsm20 commented Apr 7, 2026

Resolves DSPX-2686

Proposed Changes

Changes

Protoservice/policy/subjectmapping/subject_mapping.proto

  • SortSubjectConditionSetsType enum (UNSPECIFIED, CREATED_AT, UPDATED_AT)
  • SubjectConditionSetsSort message (field + direction)
  • repeated SubjectConditionSetsSort sort = 11 on ListSubjectConditionSetsRequest with
    max_items = 1 constraint
  • Regenerated protos and docs

SQLservice/policy/db/queries/subject_mappings.sql

  • CASE WHEN sort blocks in listSubjectConditionSets query
  • Fallback scs.created_at DESC + tiebreaker scs.id ASC

Goservice/policy/db/utils.go + service/policy/db/subject_mappings.go

  • GetSubjectConditionSetsSortParams(): maps enum to SQL-compatible field/direction
    strings
  • ListSubjectConditionSets handler wired to call mapper and pass params to sqlc query

Tests

  • 8 unit tests for the enum mapper helper (nil, empty, unspecified, each field +
    direction)
  • 5 integration tests (created_at ASC/DESC, updated_at ASC/DESC, unspecified fallback)
    using createSortTestSubjectConditionSets suite helper
  • Protovalidate sort constraint test (Test_ListSubjectConditionSetsRequest_Sort)

Notes

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

Summary by CodeRabbit

  • New Features

    • Added sorting for Subject Condition Set listings by created_at or updated_at (ASC/DESC). Requests accept at most one sort entry; default ordering is created_at DESC with deterministic tie-breaker when omitted or unspecified.
  • Documentation

    • Clarified shared sort-direction semantics: unspecified direction → ASC when a sort field is provided; omitted/UNSPECIFIED sort fields defer to each List endpoint’s documented default ordering.
  • Tests

    • Added unit and integration tests covering sort parameter handling, ordering, and validation.

@dsm20 dsm20 requested review from a team as code owners April 7, 2026 21:05
@github-actions github-actions bot added comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation labels Apr 7, 2026
@dsm20 dsm20 marked this pull request as draft April 7, 2026 21:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Adds single-field sorting for ListSubjectConditionSets: proto/OpenAPI/docs updates, new sort enum/message, helper to map proto sort to SQL, conditional ORDER BY in the query for created_at/updated_at with tie-breakers, and unit + integration tests validating sorts and fallbacks.

Changes

Cohort / File(s) Summary
Proto & Docs
service/policy/subjectmapping/subject_mapping.proto, service/policy/selectors.proto, docs/grpc/index.html, docs/openapi/policy/subjectmapping/subject_mapping.openapi.yaml, docs/openapi/policy/attributes/attributes.openapi.yaml, docs/openapi/policy/namespaces/namespaces.openapi.yaml, docs/openapi/policy/selectors.openapi.yaml
Added SortSubjectConditionSetsType enum and SubjectConditionSetsSort message; added sort (repeated, max 1) to ListSubjectConditionSetsRequest; documented policy.SortDirection semantics across APIs.
DB SQL & Generated Bindings
service/policy/db/subject_mappings.sql, service/policy/db/subject_mappings.sql.go, service/policy/db/subject_mappings.sql.go (generated)
Replaced fixed ORDER BY with conditional ORDER BY driven by SortField/SortDirection (created_at/updated_at ASC/DESC), added deterministic tie-breakers (created_at DESC, id ASC), adjusted SQL parameter ordering and updated generated params struct to include sort fields.
Go DB Layer & Utils
service/policy/db/subject_mappings.go, service/policy/db/utils.go
List handler now extracts sort params via new GetSubjectConditionSetsSortParams and passes SortField/SortDirection into query params; added helper mapping proto enums to SQL field/direction with sentinel behavior (empty when UNSPECIFIED).
Tests
service/integration/subject_mappings_test.go, service/policy/db/utils_test.go, service/policy/subjectmapping/subject_condition_set_test.go
Added integration tests for created_at/updated_at sorting (ASC/DESC) and UNSPECIFIED fallback; unit tests for sort-param mapping and validation enforcing max 1 sort item.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Service as Service Handler
    participant Utils as Sort Utils
    participant SQL as Query Builder
    participant DB as PostgreSQL

    Client->>Service: ListSubjectConditionSets(request with optional sort)
    Service->>Utils: GetSubjectConditionSetsSortParams(request.sort)
    Utils-->>Service: (sortField, sortDirection) or ("","")
    Service->>SQL: Execute listSubjectConditionSets(sortField, sortDirection, offset, limit)
    SQL->>DB: SELECT ... ORDER BY (CASE on sortField & sortDirection), scs.created_at DESC, scs.id ASC LIMIT/OFFSET
    DB-->>SQL: Rows ordered
    SQL-->>Service: Result rows
    Service-->>Client: ListSubjectConditionSetsResponse
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

size/m

Suggested reviewers

  • c-r33d
  • alkalescent

Poem

🐰 Hop-hop, I map and sort,

created_at leads, updated follows short,
ASC or DESC I softly choose,
One-field order—no more to lose,
Rows hop home, tidy and sure.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding sort support to the ListSubjectConditionSets API. It is concise, specific, and directly corresponds to the primary objective of the PR.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/DSPX-2686-add-sort-listconditionsets

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces sorting capabilities to the ListSubjectConditionSets API, enabling more flexible data retrieval. The changes include updates to the protocol buffers, database query logic, and the application layer to map and apply sort parameters. This enhancement maintains backward compatibility while providing a robust mechanism for ordering results by creation or update timestamps.

Highlights

  • API Enhancement: Added strongly-typed sort support to the ListSubjectConditionSets RPC, allowing users to sort by created_at or updated_at fields.
  • Database Updates: Updated the SQL query for listing subject condition sets to support dynamic sorting with a fallback to created_at DESC.
  • Testing: Implemented comprehensive unit and integration tests to verify sorting functionality, including edge cases and validation constraints.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: docs/openapi/**/* (1)
    • docs/openapi/policy/subjectmapping/subject_mapping.openapi.yaml
  • Ignored by pattern: protocol/**/* (1)
    • protocol/go/policy/subjectmapping/subject_mapping.pb.go
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The data flows in rows so neat, With timestamps guiding every beat. From oldest past to newest day, Our sorting logic leads the way.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions bot added the size/s label Apr 7, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces sorting capabilities for SubjectConditionSets, allowing results to be ordered by creation or update timestamps. The implementation includes updates to the protobuf definitions, SQL queries, and database utility functions, along with comprehensive integration and unit tests. The review feedback suggests improving test stability by replacing or extending time.Sleep calls, ensuring Go version compatibility for loop syntax, and refactoring the SQL ORDER BY logic for better readability and maintenance.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 201.355785ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 109.205181ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 401.113533ms
Throughput 249.31 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.448471345s
Average Latency 432.459448ms
Throughput 115.08 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 182.898187ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 95.745032ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 390.913289ms
Throughput 255.81 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.16180795s
Average Latency 400.466374ms
Throughput 124.50 requests/second

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/grpc/index.html`:
- Around line 16535-16550: The documentation entry for
SORT_SUBJECT_CONDITION_SETS_TYPE_UNSPECIFIED is missing its fallback semantics;
update the enum comment for SORT_SUBJECT_CONDITION_SETS_TYPE_UNSPECIFIED in the
proto (or the source that generates docs) to explicitly state that the server
will treat UNSPECIFIED as "created_at DESC" (i.e., sort by created_at
descending) and then regenerate the gRPC docs so the generated HTML table
includes that description next to SORT_SUBJECT_CONDITION_SETS_TYPE_UNSPECIFIED.

In `@service/integration/subject_mappings_test.go`:
- Around line 2574-2604: createSortTestSubjectConditionSets currently leaves
three SubjectConditionSet rows behind; modify it to register a cleanup that
deletes the created IDs after the test finishes by capturing the ids slice and
calling the delete operation in s.T().Cleanup. Specifically, after creating each
SubjectConditionSet (via PolicyClient.CreateSubjectConditionSet) capture the
created.GetId() into ids and then register s.T().Cleanup(func() { for _, id :=
range ids { _ = s.db.PolicyClient.DeleteSubjectConditionSet(s.ctx, id) } }) (or
use the existing deletion helper if present) so the helper cleans up its created
SubjectConditionSet rows automatically.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1016e002-3fe0-4d39-a4d9-d8c50912bdc0

📥 Commits

Reviewing files that changed from the base of the PR and between ca46c63 and b14043d.

⛔ Files ignored due to path filters (1)
  • protocol/go/policy/subjectmapping/subject_mapping.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (10)
  • docs/grpc/index.html
  • docs/openapi/policy/subjectmapping/subject_mapping.openapi.yaml
  • service/integration/subject_mappings_test.go
  • service/policy/db/queries/subject_mappings.sql
  • service/policy/db/subject_mappings.go
  • service/policy/db/subject_mappings.sql.go
  • service/policy/db/utils.go
  • service/policy/db/utils_test.go
  • service/policy/subjectmapping/subject_condition_set_test.go
  • service/policy/subjectmapping/subject_mapping.proto

@dsm20 dsm20 force-pushed the feat/DSPX-2686-add-sort-listconditionsets branch from e9d1a0d to b14043d Compare April 8, 2026 15:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 207.533748ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 104.875247ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 397.21213ms
Throughput 251.75 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.413363568s
Average Latency 432.463504ms
Throughput 115.17 requests/second

@dsm20 dsm20 marked this pull request as ready for review April 8, 2026 16:21
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@service/policy/selectors.proto`:
- Around line 62-63: The inline comment for SORT_DIRECTION_UNSPECIFIED is
misleadingly absolute; update the comment for the enum value
SORT_DIRECTION_UNSPECIFIED in the SortDirection enum so it does not state an
unconditional default (e.g., change "// defaults to ASC" to a conditional
phrasing like "// treated as ASC when a sort field is provided; actual fallback
may be defined per-request" or remove the default note entirely), and ensure any
concrete defaulting behavior is documented on the request-level List* fields
rather than on the enum value.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 9db5b9a1-a41a-4812-b4af-e5d765d3bf25

📥 Commits

Reviewing files that changed from the base of the PR and between b14043d and 7a62e09.

⛔ Files ignored due to path filters (2)
  • protocol/go/policy/selectors.pb.go is excluded by !**/*.pb.go
  • protocol/go/policy/subjectmapping/subject_mapping.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (7)
  • docs/grpc/index.html
  • docs/openapi/policy/attributes/attributes.openapi.yaml
  • docs/openapi/policy/namespaces/namespaces.openapi.yaml
  • docs/openapi/policy/selectors.openapi.yaml
  • docs/openapi/policy/subjectmapping/subject_mapping.openapi.yaml
  • service/policy/selectors.proto
  • service/policy/subjectmapping/subject_mapping.proto

dsm20 added 9 commits April 8, 2026 12:38
getSortDirection helper already added in listAttributes PR, will need to
resolve conflicts when both merge. GetSubjectConditionSetSortParams
helper added in utils.go. Wired sort params through DB layer, changed
SQL, and regenerated sqlc
utils_test.go
added test in utils_test.go covering nil, empty, unspecified,
created_at, updated_at with ASC/DESC. added sort validation cases to
pre-existing ListSubjectConditionSetsRequest protovalidate tests (1 item
valid, 2 items valid)
same with other APIs, this test gets a standalone function to deal with the 3 required tests for protovalidation
in subject_mappings_test.go (where the SCS integ. tests live), added a
helper createSortTestSubjectConditionSets() for the 5 SCS sort tests:
created_at ASC/DESC, updated_at ASC/DESC, and unspecified/falls to
default. Only one helper needed because all tests are time-based.
SortDirection enum gets expanded comments for clarity, and ListSCSRequest in subject_mappings.proto gets comment clarifying how this endpoint handles defaults/unspecified.
test helper function for subject mappings (on main) and this branch were in the same spot and conflicting. this should keep both and resolve the issue. also regen protos which was conflicting as well
@dsm20 dsm20 force-pushed the feat/DSPX-2686-add-sort-listconditionsets branch from 7a62e09 to dc38494 Compare April 8, 2026 16:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 200.565713ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 98.776235ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 384.2157ms
Throughput 260.27 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 41.473286502s
Average Latency 412.956303ms
Throughput 120.56 requests/second

last PR (merged) introduced constants for created_at and updated_at (goconst was getting mad)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 200.174545ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 100.486003ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 391.948174ms
Throughput 255.14 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.333562494s
Average Latency 401.940916ms
Throughput 123.97 requests/second

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
service/policy/selectors.proto (1)

62-63: ⚠️ Potential issue | 🟡 Minor

Remove the stale unconditional default note on SORT_DIRECTION_UNSPECIFIED.

The new enum-level doc is endpoint-neutral, but the inline // defaults to ASC still reads as a global default and conflicts with the request-level fallback model described just above.

Suggested doc fix
-  SORT_DIRECTION_UNSPECIFIED = 0; // defaults to ASC
+  SORT_DIRECTION_UNSPECIFIED = 0;
Based on learnings: keep `SortDirection` endpoint-neutral and document concrete fallback/default ordering on request-level `List*` fields, not enum value docs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@service/policy/selectors.proto` around lines 62 - 63, Remove the stale inline
note on SORT_DIRECTION_UNSPECIFIED in the SortDirection enum: delete the "//
defaults to ASC" comment so the enum remains endpoint-neutral; instead ensure
any concrete fallback/default ordering is documented on the request-level List*
fields (e.g., ListPolicies, ListRules) where the endpoint-specific behavior is
defined.
service/integration/subject_mappings_test.go (1)

2713-2743: ⚠️ Potential issue | 🟡 Minor

Clean up the helper-created subject condition sets.

This helper still leaves three unmapped rows behind on every call. Because the suite reuses one database across methods, those leftovers make later list/prune tests more order-dependent than they need to be.

Suggested cleanup registration
 func (s *SubjectMappingsSuite) createSortTestSubjectConditionSets(label string) []string {
 	const count = 3
 	ids := make([]string, count)
+	s.T().Cleanup(func() {
+		for _, id := range ids {
+			if id != "" {
+				_, _ = s.db.PolicyClient.DeleteSubjectConditionSet(s.ctx, id)
+			}
+		}
+	})
 	for i := range count {
 		if i > 0 {
 			time.Sleep(5 * time.Millisecond)
 		}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@service/integration/subject_mappings_test.go` around lines 2713 - 2743,
createSortTestSubjectConditionSets currently leaves created SubjectConditionSet
rows behind; after creating the IDs via
s.db.PolicyClient.CreateSubjectConditionSet in
createSortTestSubjectConditionSets, register cleanup to remove them (either
immediately delete each created id or call s.T().Cleanup with a closure that
iterates ids and calls s.db.PolicyClient.DeleteSubjectConditionSet(s.ctx, id) /
appropriate delete method) so the test suite database is left clean; reference
createSortTestSubjectConditionSets, s.db.PolicyClient.CreateSubjectConditionSet
and the corresponding delete method (e.g., DeleteSubjectConditionSet) when
implementing the teardown.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@service/policy/db/utils_test.go`:
- Around line 519-584: Add a new test case to
Test_GetSubjectConditionSetsSortParams: include a cases entry for UPDATED_AT
with Direction policy.SortDirection_SORT_DIRECTION_ASC so the
SubjectConditionSetsSort mapping covers both ASC and DESC; specifically add a
slice element in the cases array that sets sort to
[]*subjectmapping.SubjectConditionSetsSort{{Field:
subjectmapping.SortSubjectConditionSetsType_SORT_SUBJECT_CONDITION_SETS_TYPE_UPDATED_AT,
Direction: policy.SortDirection_SORT_DIRECTION_ASC}} and expectedField
"updated_at" and expectedDir "ASC" to mirror the existing UPDATED_AT DESC case.

---

Duplicate comments:
In `@service/integration/subject_mappings_test.go`:
- Around line 2713-2743: createSortTestSubjectConditionSets currently leaves
created SubjectConditionSet rows behind; after creating the IDs via
s.db.PolicyClient.CreateSubjectConditionSet in
createSortTestSubjectConditionSets, register cleanup to remove them (either
immediately delete each created id or call s.T().Cleanup with a closure that
iterates ids and calls s.db.PolicyClient.DeleteSubjectConditionSet(s.ctx, id) /
appropriate delete method) so the test suite database is left clean; reference
createSortTestSubjectConditionSets, s.db.PolicyClient.CreateSubjectConditionSet
and the corresponding delete method (e.g., DeleteSubjectConditionSet) when
implementing the teardown.

In `@service/policy/selectors.proto`:
- Around line 62-63: Remove the stale inline note on SORT_DIRECTION_UNSPECIFIED
in the SortDirection enum: delete the "// defaults to ASC" comment so the enum
remains endpoint-neutral; instead ensure any concrete fallback/default ordering
is documented on the request-level List* fields (e.g., ListPolicies, ListRules)
where the endpoint-specific behavior is defined.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a4da4aba-ef6d-4fc3-aa43-fc102d23ac81

📥 Commits

Reviewing files that changed from the base of the PR and between 7a62e09 and 481b5d0.

⛔ Files ignored due to path filters (2)
  • protocol/go/policy/selectors.pb.go is excluded by !**/*.pb.go
  • protocol/go/policy/subjectmapping/subject_mapping.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (14)
  • docs/grpc/index.html
  • docs/openapi/policy/attributes/attributes.openapi.yaml
  • docs/openapi/policy/namespaces/namespaces.openapi.yaml
  • docs/openapi/policy/selectors.openapi.yaml
  • docs/openapi/policy/subjectmapping/subject_mapping.openapi.yaml
  • service/integration/subject_mappings_test.go
  • service/policy/db/queries/subject_mappings.sql
  • service/policy/db/subject_mappings.go
  • service/policy/db/subject_mappings.sql.go
  • service/policy/db/utils.go
  • service/policy/db/utils_test.go
  • service/policy/selectors.proto
  • service/policy/subjectmapping/subject_condition_set_test.go
  • service/policy/subjectmapping/subject_mapping.proto

updated_at ASC was missing, now there is full coverage
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 185.212248ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 87.868097ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 411.969991ms
Throughput 242.74 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 40.132037183s
Average Latency 399.509324ms
Throughput 124.59 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant