Skip to content

feat: optimize aliased BatchCheck requests - #311

Draft
Siddhant-K-code wants to merge 5 commits into
openfga:mainfrom
Siddhant-K-code:feat/optimize-batch-check-aliases
Draft

feat: optimize aliased BatchCheck requests#311
Siddhant-K-code wants to merge 5 commits into
openfga:mainfrom
Siddhant-K-code:feat/optimize-batch-check-aliases

Conversation

@Siddhant-K-code

@Siddhant-K-code Siddhant-K-code commented Aug 19, 2026

Copy link
Copy Markdown
Member

Description

Adds an opt-in optimize_relation_aliases option to async and sync BatchCheck.

When enabled, the SDK:

  • reads and caches the pinned authorization model;
  • resolves only pure same-object computed-userset aliases;
  • combines checks only when user, object, context, and contextual tuples are identical;
  • maps the server result back to every original correlation ID and request.

The default BatchCheck behavior is unchanged.

Why

Applications often use intent-specific permissions that are pure aliases of a shared relation. Sending each alias as a separate item preserves a useful application-level contract, but can repeat the same authorization evaluation within one batch. This opt-in path keeps the original relations and correlation IDs visible to callers while reducing redundant checks.

Safety

  • Requires an explicit authorization model ID.
  • Caches aliases by store and immutable model ID.
  • Does not optimize unions, intersections, differences, tuple-to-userset rewrites, other-object computed usersets, missing targets, or cycles.
  • Preserves group boundaries across users, object types, object IDs, context, and contextual tuples.
  • Preserves per-item allowed and error responses.

Testing

  • 627 non-integration tests pass.
  • Async and sync tests verify one canonical item per distinct group and map every result to its original correlation ID and request.
  • Project coverage is 86%, above the unchanged 80% target.
  • Changed executable lines have 100% diff coverage.
  • Ruff formatting and linting pass.
  • Mypy passes for the changed source files.

The README is generated; its source template should receive the equivalent update before merge.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e21d258b-86f3-49f3-9d52-37077485ec82

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

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.

@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.93%. Comparing base (62fbd9a) to head (ca6c3a4).

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #311       +/-   ##
===========================================
+ Coverage   69.93%   85.93%   +15.99%     
===========================================
  Files         142      143        +1     
  Lines       10774    10925      +151     
===========================================
+ Hits         7535     9388     +1853     
+ Misses       3239     1537     -1702     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants