Skip to content

fix(docs): correct boolean logic for multiple SubjectMappings#3222

Open
eugenioenko wants to merge 1 commit intomainfrom
fix/subject-mapping-docs-boolean-logic
Open

fix(docs): correct boolean logic for multiple SubjectMappings#3222
eugenioenko wants to merge 1 commit intomainfrom
fix/subject-mapping-docs-boolean-logic

Conversation

@eugenioenko
Copy link
Copy Markdown
Contributor

@eugenioenko eugenioenko commented Mar 30, 2026

Summary

  • The migration doc for SubjectConditionSets incorrectly stated that multiple SubjectMappings for the same AttributeValue are ANDed together
  • The actual PDP implementation (subject_mapping_builtin_actions.go) ORs them: if any SubjectMapping evaluates to true, the subject is entitled to the AttributeValue
  • Updated the doc to accurately describe the boolean logic at each level

Test plan

  • Verify the updated doc matches the behavior in service/internal/subjectmappingbuiltin/subject_mapping_builtin_actions.go

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified policy evaluation documentation with refined boolean logic specifications, detailing updated semantics for how conditions are combined during policy decision processing.

…docs

The migration doc incorrectly stated that multiple SubjectMappings for the
same AttributeValue are ANDed together. The actual implementation ORs them:
if any SubjectMapping evaluates to true, the subject is entitled to the
AttributeValue. Updated the doc to match the code behavior in
subject_mapping_builtin_actions.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Eugene Yakhnenko <eugene.yakhnenko@virtru.com>
@eugenioenko eugenioenko requested review from a team as code owners March 30, 2026 17:06
@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 corrects a technical inaccuracy in the documentation regarding how SubjectMappings are evaluated. By aligning the documentation with the actual implementation in the PDP, it ensures that developers and administrators have a correct understanding of the boolean logic governing subject entitlement.

Highlights

  • Documentation Correction: Updated the SubjectConditionSets migration documentation to accurately reflect that multiple SubjectMappings for the same AttributeValue are ORed, rather than ANDed.
  • Boolean Logic Clarification: Provided a clear breakdown of the boolean evaluation logic for SubjectMappings, SubjectSets, and ConditionGroups to ensure consistency with the PDP implementation.

🧠 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.

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 logic was stated as AND, / But code had a different command. / With OR in the flow, / The docs had to grow, / To help all the users understand.

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 comp:db DB component comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) labels Mar 30, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

This change updates migration documentation to clarify PDP boolean evaluation semantics. It refines how multiple SubjectMappings, SubjectSets, and ConditionGroups are combined, replacing a global AND relationship with finer-grained logic: OR for SubjectMappings, AND for SubjectSets and ConditionGroups.

Changes

Cohort / File(s) Summary
Migration Documentation
service/policy/db/migrations/20240305000000_add_subject_condition_sets.md
Clarified boolean evaluation semantics for PDP: SubjectMappings now combine via OR (any match entitles subject), while SubjectSets and ConditionGroups within them combine via AND. Updated guidance on administrative control points for boolean operators.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A logic dance, both AND and OR,
SubjectMappings bloom like clover, at the door,
OR unites what once was bound,
AND keeps the structures tightly wound,
Truth flows through the policy ground! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(docs): correct boolean logic for multiple SubjectMappings' clearly and specifically describes the main change: correcting documentation about boolean logic for SubjectMappings, which aligns with the changeset updating migration documentation to accurately reflect the OR semantics.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/subject-mapping-docs-boolean-logic

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

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/db/migrations/20240305000000_add_subject_condition_sets.md`:
- Around line 32-41: The Background paragraph earlier in this migration doc
incorrectly states that multiple SubjectMapping entries are ANDed; update that
paragraph to say multiple SubjectMapping entries are ORed (i.e., any matching
SubjectMapping entitles the subject) and ensure it references SubjectMapping,
SubjectConditionSet, and ConditionGroup consistently with the later section so
the document uniformly describes: SubjectMappings = OR, multiple SubjectSets in
a SubjectConditionSet = AND, and multiple ConditionGroups on a SubjectSet = AND.
🪄 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: f94b2c24-c03c-46c8-86ea-23125600143c

📥 Commits

Reviewing files that changed from the base of the PR and between 6590228 and 3d21d56.

📒 Files selected for processing (1)
  • service/policy/db/migrations/20240305000000_add_subject_condition_sets.md

Comment on lines +32 to +41
A PDP evaluates subject mappings with the following boolean logic:
- more than one SubjectMapping for an Attribute Value: OR (any matching mapping entitles the subject)
- more than one SubjectSet in the JSONB of a SubjectConditionSet: AND
- more than one ConditionGroup on a SubjectSet: AND

ConditionGroups are the only place a policy platform administrator has direct control over the boolean
operator to associate Conditions via AND or OR. If an admin needs OR logic across SubjectSets
in a SubjectConditionSet, that can be accomplished with multiple SubjectMappings for the same
AttributeValue (since SubjectMappings are ORed), or with multiple AttributeValues and an
AttributeDefinition rule of ANY_OF associating them together.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Resolve conflicting boolean semantics elsewhere in this same doc

This section is now correct, but the Background still says multiple SubjectMappings are ANDed (Line 8 and Line 9), which directly contradicts this update. Please update that earlier paragraph too, otherwise the migration doc remains internally inconsistent.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@service/policy/db/migrations/20240305000000_add_subject_condition_sets.md`
around lines 32 - 41, The Background paragraph earlier in this migration doc
incorrectly states that multiple SubjectMapping entries are ANDed; update that
paragraph to say multiple SubjectMapping entries are ORed (i.e., any matching
SubjectMapping entitles the subject) and ensure it references SubjectMapping,
SubjectConditionSet, and ConditionGroup consistently with the later section so
the document uniformly describes: SubjectMappings = OR, multiple SubjectSets in
a SubjectConditionSet = AND, and multiple ConditionGroups on a SubjectSet = AND.

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 updates the documentation for PDP boolean logic in the subject condition sets migration file, clarifying that multiple SubjectMappings for an Attribute Value are evaluated using OR logic. Feedback indicates that the Background section of the same document needs to be updated to reflect this change and maintain internal consistency.

in a SubjectSet, or multiple SubjectSets in a SubjectMapping, that can be accomplished with multiple
AttributeValues and an AttributeDefinition rule of ANY_OF associating them together.
A PDP evaluates subject mappings with the following boolean logic:
- more than one SubjectMapping for an Attribute Value: OR (any matching mapping entitles the subject)
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

This correction to OR logic is accurate and improves clarity. However, it creates an inconsistency with the Background section of this same document.

Lines 7-9 still state an AND relationship for multiple SubjectMappings:

An `Attribute Value` will relate to one or more `SubjectMapping`s with an
`AND` relationship, and each `SubjectMapping` will relate to one `SubjectConditionSet` to contextualize the
Attribute so each `Attribute Value -> 1+ SubjectConditionSets` considered `AND`ed together.

To ensure the documentation is consistent, please consider updating the Background section to also reflect the OR logic for multiple SubjectMappings per Attribute Value.

@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 145.17062ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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.097979ms
Throughput 260.35 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.346291959s
Average Latency 391.729703ms
Throughput 127.08 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

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) size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant