Skip to content

Add unchecked Entities constructors that skip transitive closure - #2552

Draft
Harrichael wants to merge 1 commit into
cedar-policy:mainfrom
Harrichael:entities-unchecked-constructors
Draft

Harrichael wants to merge 1 commit into
cedar-policy:mainfrom
Harrichael:entities-unchecked-constructors

Conversation

@Harrichael

@Harrichael Harrichael commented Sep 2, 2026 •

Copy link
Copy Markdown

Description of changes

Motivation: callers that keep a large pre-loaded entity graph in memory and already maintain its closure themselves can avoid paying to recompute it on every construction or update. This follows the Entities::decode_unchecked precedent from #2387. No changes to cedar-policy-core; the AssumeAlreadyComputed mode already existed there.

Adds Entities::from_entities_unchecked and Entities::upsert_entities_unchecked to the cedar-policy crate. They mirror from_entities and upsert_entities exactly, except that they pass TCComputation::AssumeAlreadyComputed to the core layer instead of ComputeNow, so the transitive closure of the entity hierarchy is neither computed nor checked. The caller must supply a hierarchy that is already acyclic and transitively closed (every ancestor listed in each entity's parents).

Everything else the checked constructors do still applies: duplicate detection, schema conformance checking, and adding Action entities from the schema in from_entities_unchecked. Only transitive closure computation and cycle detection are skipped.

Issue #, if available

Resolves #2378

Checklist for requesting a review

The change in this PR is:

  • A backwards-compatible change requiring a minor version bump to cedar-policy (e.g., addition of a new API).

I confirm that this PR:

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

I confirm that cedar-spec:

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

I confirm that docs.cedarpolicy.com:

  • Does not require updates because my change does not impact the Cedar language specification.

Signed-off-by: Michael Harrington <michaeltoddharrington@gmail.com>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

Coverage Report

Head Commit: 15a2c884c2ca01d787f67b719b01dd298df49233

Base Commit: ec30badc0fbc331741982553bbec29af6ba262ea

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 96.30%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy/src/api.rs 🟢 26/27 96.30% 690

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 88.40%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟢 4895/5998 81.61% 81.54%
cedar-policy-cli 🟡 1294/1669 77.53% 77.53%
cedar-policy-core 🟢 24675/27839 88.63% 88.63%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6930/7405 93.59% 93.59%
cedar-wasm 🔴 0/28 0.00% 0.00%

This branch has not been deployed

No deployments
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.

Allow unchecked construction of Entities for pre-fetched graph use cases

1 participant