Skip to content

feat(tpe): add type-aware partial evaluation entity model and validation - #370

Open
muditchaudhary wants to merge 1 commit into
cedar-policy:mainfrom
muditchaudhary:tpe-step1-foundation
Open

muditchaudhary wants to merge 1 commit into
cedar-policy:mainfrom
muditchaudhary:tpe-step1-foundation

Conversation

@muditchaudhary

Copy link
Copy Markdown
Contributor

Summary

Adds the entity model for Cedar's type-aware partial evaluation (TPE) to CedarJava: entities whose attributes, parents, and tags may each be independently unknown. Everything is @Experimental and purely additive — no existing API changes.

This is the entity half of the foundation. The TPE request/response types and the authorization call itself follow in a separate PR.

What

CedarJava

  • PartialEntity — EUID always known; attrs, parents, and tags each either absent (unknown) or present and complete.
  • PartialEntities — the collection, carrying the two checks that only make sense over the whole set: no duplicate UIDs, and no in-collection parent whose own parents are unknown.
  • PartialEntityUID — partial counterpart to EntityUID, reusing EntityTypeName and EntityIdentifier. The type is always known, since TPE needs it to type check a request.
  • Constructors take a Schema and validate eagerly, so a value in hand has already been checked.

CedarJavaFFI

  • New tpe Cargo feature and src/tpe.rs with two validators, accepting a schema in either Cedar or JSON format.

Why

TPE evaluates policies against incomplete data, which needs a way to say "this entity exists but I don't know its attributes" — distinct from "I don't know whether this entity exists at all," which is expressed by leaving it out of the collection.

Validation happens at construction rather than at authorize time so that a bad entity fails where the mistake was made, with a message naming the offending attribute, instead of surfacing later as an opaque error from a call that looks unrelated.

Issue: #364

Introduces the entity-side foundation for Cedar's type-aware partial
evaluation (TPE), where an entity's attributes, parents, and tags may
each be independently unknown.

Signed-off-by: Mudit Chaudhary <chmudit@amazon.com>
@muditchaudhary
muditchaudhary marked this pull request as ready for review September 16, 2026 22:55
* @return a debug rendering of this partial entity
*/
@Override
public String toString() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we have some tests for this?

.next();
assertTrue(nullFields.getAttrs().isEmpty());
assertTrue(nullFields.getParents().isEmpty());
assertTrue(nullFields.getTags().isEmpty());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about a test checking that a present-but-empty attrs/parents/tags in the JSON comes back as present-and-empty rather than unknown? The blocks above only cover the omitted and null cases, which map to unknown.


/**
* Constructs a collection from concrete entities, each of which is fully known. Mirrors
* {@code PartialEntities::from_concrete}.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure this is true, it calls lift, which calls from_json_value?

}

@Test
public void testRejectsDuplicateUid() throws InternalException {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This covers the set entities constructed with Set but maybe we should also test from_json (i.e. build the json array of entities).

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