cedar-policy / cedar

Implementation of the Cedar Policy Language
https://www.cedarpolicy.com
Apache License 2.0
892 stars 80 forks source link

Entity Slicing: `EntityLoader` trait #1208

Closed oflatt closed 1 month ago

oflatt commented 2 months ago

Description of changes

This PR adds a new way to load entities based on their ids. This makes entity slicing easier to implement, since the trait implementor does not need to worry about entity dereferences. To make this PR work, type annotations had to be added to the entity manifest.

The API is flexible: users can choose to use the [AccessTrie] in entity requests to only load some fields of entities. It's also batched, so that as many entities as possible are loaded at the same time (in a breadth-first traversal of the entity manifest).

Loading of ancestors is separated from loading of entities so that particular ancestors can be named.

This PR doesn't make this API public yet, but it could be made public with some wrapper structs.

PR stack: https://github.com/cedar-policy/cedar/pull/1102 https://github.com/cedar-policy/cedar/pull/1105 https://github.com/cedar-policy/cedar/pull/1154 https://github.com/cedar-policy/cedar/pull/1156 https://github.com/cedar-policy/cedar/pull/1171

1196

https://github.com/cedar-policy/cedar/pull/1208 (This PR)

DRT testing PR: https://github.com/cedar-policy/cedar-spec/pull/429

Issue #, if available

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

I confirm that this PR (choose one, and delete the other options):

I confirm that cedar-spec (choose one, and delete the other options):

shaobo-he-aws commented 1 month ago

Closed in favor of a single PR.