Skip to content

feat(policy): DSPX-2541 add narrow attribute read APIs#3627

Closed
alkalescent wants to merge 2 commits into
mainfrom
DSPX-2541-policy-key-mapping-apis
Closed

feat(policy): DSPX-2541 add narrow attribute read APIs#3627
alkalescent wants to merge 2 commits into
mainfrom
DSPX-2541-policy-key-mapping-apis

Conversation

@alkalescent

@alkalescent alkalescent commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add two narrow read RPCs to the attributes service, the first PR in a multi-PR effort to stop returning the full attribute+value graph from GetAttributeValuesByFqns (the current "get everything" API):
    • GetKeyMappingsByFqns — client-side key split path. Returns, per value FQN, the attribute rule and the effective SimpleKasKeys (FQN-keyed map). No subject mappings, resource mappings, obligations, sibling values, or metadata.
    • GetEntitleableAttributesByFqns — server-side decisioning path. Returns, per value FQN, the rule, value id, ordered definition_value_fqns (for hierarchy rule logic), and subject mappings (FQN-keyed map). No KAS keys/grants.
  • Regenerate protocol/go and docs/ from the protos.

This PR is proto + generated protocol/go only, so protocol/go can be released and consumed by the follow-up service and SDK PRs. Handlers, DB queries, the GetEntitlements/PDP memory optimization, SDK migration, and deprecation of GetAttributeValuesByFqns are tracked as later PRs.

The sdk/sdkconnect wrapper regeneration is intentionally excluded; it lands in the SDK PR alongside the protocol/go dependency bump (matching prior proto PRs).

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

  • make proto-lint — clean.
  • buf breaking --against origin/main service — additive, no breaking changes.
  • cd protocol/go && go build ./... && go vet ./... — clean.
  • Service build against the pinned protocol/go release (GOWORK=off) passes; the new RPCs are not yet implemented (follow-up PRs).

Related

Add GetKeyMappingsByFqns (client-side key split path) and GetEntitleableAttributesByFqns (server-side decisioning path) to the attributes service, with regenerated protocol/go and docs. These narrow read APIs return only the fields each caller needs, in FQN-keyed maps, replacing the full attribute+value graph returned by GetAttributeValuesByFqns.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@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 two new narrow-read RPC methods to the attributes service. These changes are part of a broader initiative to optimize performance by moving away from the monolithic 'get everything' API, allowing clients and services to fetch only the specific data required for their respective workflows, such as key split construction or entitlement resolution.

Highlights

  • New API: GetKeyMappingsByFqns: Introduced a narrow read RPC to retrieve only essential key-mapping information, including attribute rules and effective KAS keys, for client-side key split construction.
  • New API: GetEntitleableAttributesByFqns: Introduced a narrow read RPC to fetch entitlement-specific data, such as attribute rules, value identities, and subject mappings, to support server-side decisioning.
  • Documentation and Protocol Updates: Regenerated the protocol definitions and gRPC documentation to include the new RPC methods.
New Features

🧠 You can now enable Memory (public preview) 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/attributes/attributes.openapi.yaml
  • Ignored by pattern: protocol/**/* (3)
    • protocol/go/policy/attributes/attributes.pb.go
    • protocol/go/policy/attributes/attributes_grpc.pb.go
    • protocol/go/policy/attributes/attributesconnect/attributes.connect.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 the 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 counterproductive. 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.


Two new paths for data flow, Narrow reads to make it go. Less to fetch and less to store, Efficiency at the core.

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.

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cdde036f-2b2d-4e1d-a49d-a9d481a57452

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-2541-policy-key-mapping-apis

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.

@github-actions github-actions Bot added comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) docs Documentation size/s labels Jun 17, 2026

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

Copy link
Copy Markdown
Contributor

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 two new narrow read APIs to the AttributesService in attributes.proto: GetKeyMappingsByFqns (for client-side key split construction) and GetEntitleableAttributesByFqns (for server-side entitlement resolution), along with their corresponding request/response messages and updated documentation. The feedback suggests adding item-level validation to the fqns fields in both requests to ensure they are non-empty URIs, and using the fully qualified name policy.AttributeRuleTypeEnum for consistency across package references.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +355 to +358
repeated string fqns = 1 [(buf.validate.field).repeated = {
min_items: 1
max_items: 250
}];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The fqns repeated field lacks validation for individual items. Adding items validation ensures that each FQN is a non-empty, valid URI, preventing malformed inputs from propagating further into the service.

  repeated string fqns = 1 [(buf.validate.field).repeated = {
    min_items: 1
    max_items: 250
    items: {
      string: {
        min_len: 1
        uri: true
      }
    }
  }];

// the attribute value FQN this mapping is for
string fqn = 1;
// the attribute rule, which governs how splits combine (any_of / all_of / hierarchy)
AttributeRuleTypeEnum rule = 2;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other referenced types (like policy.SimpleKasKey and policy.SubjectMapping) and to ensure robust cross-package resolution, use the fully qualified name policy.AttributeRuleTypeEnum.

Suggested change
AttributeRuleTypeEnum rule = 2;
policy.AttributeRuleTypeEnum rule = 2;

Comment on lines +386 to +389
repeated string fqns = 1 [(buf.validate.field).repeated = {
min_items: 1
max_items: 250
}];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The fqns repeated field lacks validation for individual items. Adding items validation ensures that each FQN is a non-empty, valid URI, preventing malformed inputs from propagating further into the service.

  repeated string fqns = 1 [(buf.validate.field).repeated = {
    min_items: 1
    max_items: 250
    items: {
      string: {
        min_len: 1
        uri: true
      }
    }
  }];

// the parent attribute definition FQN
string attribute_fqn = 2;
// the attribute rule, which drives rule logic during decisioning
AttributeRuleTypeEnum rule = 3;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other referenced types (like policy.SimpleKasKey and policy.SubjectMapping) and to ensure robust cross-package resolution, use the fully qualified name policy.AttributeRuleTypeEnum.

Suggested change
AttributeRuleTypeEnum rule = 3;
policy.AttributeRuleTypeEnum rule = 3;

CI builds the workspace via go.work, so adding GetKeyMappingsByFqns and GetEntitleableAttributesByFqns to the generated handler interface requires AttributesService to satisfy them in this PR. Embed the generated UnimplementedAttributesServiceHandler so the new RPCs return CodeUnimplemented until their handlers land in the stacked follow-up PRs (the embedded defaults are shadowed by the real methods there).

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

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

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 466.285886ms
Throughput 214.46 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.017018513s
Average Latency 428.012373ms
Throughput 116.23 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

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

See the workflow run for details.

@alkalescent

Copy link
Copy Markdown
Contributor Author

Superseded by the collapsed per-API PRs #3632 (GetKeyMappingsByFqns) and #3633 (GetEntitleableAttributesByFqns). Restructured so each new RPC ships with its proto, generated code, and handler in one PR, matching repo convention (e.g. 4c3d53d) and removing the need for the Unimplemented-handler embed.

@alkalescent alkalescent deleted the DSPX-2541-policy-key-mapping-apis branch June 17, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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