Skip to content

Conversation

@chaluli
Copy link
Contributor

@chaluli chaluli commented Feb 27, 2025

Description of changes

Updates Cedar's transitive closure computation. The algorithm is only sound when computing the transitive closure of DAGs and graphs with simple cycles. However, the updated transitive closure algorithm when combined with enforce_dag_from_tc is sufficient for detecting cycles, even complex cycles. The implementation also uses a slightly more efficient algorithm (that does only one scan of the input graph) if one does not care to enforce that the graph is a DAG (while sound for computing the exact transitive closure of a DAG, this variant is not sufficient for detecting even simple cycles).

This pull request also adds the remove_tc that is capable of repairing an existing graph's transitive closure when only a sub-set of the nodes within the graph need recalculated. This is used within add_entities and remove_entities to avoid re-computing the entire graph's transitive closure. This change addresses the feature request in issu #612

Issue #612

Checklist for requesting a review

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

  • A change "invisible" to users (e.g., documentation, changes to "internal" crates like cedar-policy-core, cedar-validator, etc.)

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

  • Does not update the CHANGELOG because my change does not significantly impact released code.

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

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

I confirm that docs.cedarpolicy.com (choose one, and delete the other options):

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

…existing transitive closure computation for only a sub-set of the overall nodes.

Signed-off-by: Charlie Murphy <mutmoth@amazon.com>
Signed-off-by: Charlie Murphy <mutmoth@amazon.com>
@github-actions
Copy link

Coverage Report

Head Commit: 842f89c1885adcbe0b7d8da6118785de83e80dd1

Base Commit: 6d01368f8d341b5da97b9fb0c6aa18b5a76b306a

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 97.78%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-core/src/entities.rs 🟢 15/15 100.00%
cedar-policy-core/src/transitive_closure.rs 🟢 73/75 97.33% 109-110

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 84.51%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-policy 🟢 9768/11214 87.11% 87.11%
cedar-policy-cli 🔴 529/917 57.69% 57.68%
cedar-policy-core 🟢 11496/14026 81.96% 81.90%
cedar-policy-formatter 🟢 914/1043 87.63% 87.63%
cedar-policy-validator 🟢 12143/13585 89.39% 89.38%
cedar-testing 🔴 0/426 0.00% 0.00%
cedar-wasm 🔴 0/29 0.00% 0.00%

@chaluli chaluli marked this pull request as draft February 28, 2025 16:41
… of a graph with cycles. More work needed to incorporate it in appropriate places.

Signed-off-by: Charlie Murphy <mutmoth@amazon.com>
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.

1 participant