Skip to content

Avoid cloning enum entity type variants lists#2283

Merged
john-h-kastner-aws merged 3 commits intomainfrom
avoid-cloning-enum-choices
Apr 3, 2026
Merged

Avoid cloning enum entity type variants lists#2283
john-h-kastner-aws merged 3 commits intomainfrom
avoid-cloning-enum-choices

Conversation

@john-h-kastner-aws
Copy link
Copy Markdown
Contributor

@john-h-kastner-aws john-h-kastner-aws commented Apr 2, 2026

Description of changes

Requires a change to previously untested protobuf parsing code. Tests are added separately in #2282

Issue #, if available

Checklist for requesting a review

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

  • A breaking change requiring a major version bump to cedar-policy (e.g., changes to the signature of an existing API).
  • A backwards-compatible change requiring a minor version bump to cedar-policy (e.g., addition of a new API).
  • A bug fix or other functionality change requiring a patch to cedar-policy.
  • A change "invisible" to users (e.g., documentation, changes to "internal" crates like cedar-policy-core, cedar-validator, etc.)
  • A change (breaking or otherwise) that only impacts unreleased or experimental code.

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

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).
  • 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.
  • Requires updates, and I have made / will make these updates myself. (Please include in your description a timeline or link to the relevant PR in cedar-spec, and how you have tested that your updates are correct.)
  • Requires updates, but I do not plan to make them in the near future. (Make sure that your changes are hidden behind a feature flag to mark them as experimental.)
  • I'm not sure how my change impacts cedar-spec. (Post your PR anyways, and we'll discuss in the comments.)

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.
  • Requires updates, and I have made / will make these updates myself. (Please include in your description a timeline or link to the relevant PR in cedar-docs. PRs should be targeted at a staging-X.Y branch, not main.)
  • I'm not sure how my change impacts the documentation. (Post your PR anyways, and we'll discuss in the comments.)

@john-h-kastner-aws john-h-kastner-aws changed the title Avoid clones if options for entity enum type Avoid cloning enum entity type variants lists Apr 2, 2026
Signed-off-by: John Kastner <jkastner@amazon.com>
#[serde(rename = "enum")]
/// The nonempty set of possible EIDs
choices: NonEmpty<SmolStr>,
choices: NonEmpty<Eid>,
Copy link
Copy Markdown
Contributor Author

@john-h-kastner-aws john-h-kastner-aws Apr 3, 2026

Choose a reason for hiding this comment

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

wasm build failure is probaly here. Need to figure out how to tell tsify this is still a string

Copy link
Copy Markdown
Contributor

@victornicolet victornicolet Apr 3, 2026

Choose a reason for hiding this comment

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

Is it possible to tell just Eid is a string?
There is a related issue with NonEmpty in wasm: #2155
It would be nice if we keep the NonEmpty, so that when we fix the type, all rust uses of NonEmpty are fixed. I think the issue references a possible place for a fix actually.
I think it's a minor thing though.

Signed-off-by: John Kastner <jkastner@amazon.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Coverage Report

Head Commit: 61ea5d49d86ec64feb303aff38adbed3e67b4dcc

Base Commit: 8734ea0112c85892dd4b25254894de6ecbd4567c

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 80.77%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-core/src/entities/conformance.rs 🟢 5/5 100.00%
cedar-policy-core/src/entities/json/schema.rs 🔴 0/1 0.00% 174
cedar-policy-core/src/tpe/request.rs 🔴 2/6 33.33% 158, 174, 451-452
cedar-policy-core/src/validator/cedar_schema/fmt.rs 🟢 1/1 100.00%
cedar-policy-core/src/validator/coreschema.rs 🟢 5/5 100.00%
cedar-policy-core/src/validator/rbac.rs 🟢 1/1 100.00%
cedar-policy-core/src/validator/schema/entity_type.rs 🟢 1/1 100.00%
cedar-policy-symcc/src/symcc/env.rs 🟢 1/1 100.00%
cedar-policy/src/proto/validator.rs 🟢 5/5 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 87.57%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟡 4226/5353 78.95% 74.90%
cedar-policy-cli 🟡 1136/1581 71.85% 71.85%
cedar-policy-core 🟢 24002/27267 88.03% 87.81%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6752/7262 92.98% 92.98%
cedar-wasm 🔴 0/28 0.00% 0.00%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 3, 2026

Coverage Report

Head Commit: c4befabc84b7fdf2a01c3e105477676605700fbb

Base Commit: 8734ea0112c85892dd4b25254894de6ecbd4567c

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 80.77%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-core/src/entities/conformance.rs 🟢 5/5 100.00%
cedar-policy-core/src/entities/json/schema.rs 🔴 0/1 0.00% 174
cedar-policy-core/src/tpe/request.rs 🔴 2/6 33.33% 158, 174, 451-452
cedar-policy-core/src/validator/cedar_schema/fmt.rs 🟢 1/1 100.00%
cedar-policy-core/src/validator/coreschema.rs 🟢 5/5 100.00%
cedar-policy-core/src/validator/rbac.rs 🟢 1/1 100.00%
cedar-policy-core/src/validator/schema/entity_type.rs 🟢 1/1 100.00%
cedar-policy-symcc/src/symcc/env.rs 🟢 1/1 100.00%
cedar-policy/src/proto/validator.rs 🟢 5/5 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 87.54%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟡 4226/5353 78.95% 74.90%
cedar-policy-cli 🟡 1136/1581 71.85% 71.85%
cedar-policy-core 🟢 24002/27279 87.99% 87.81%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6752/7262 92.98% 92.98%
cedar-wasm 🔴 0/28 0.00% 0.00%

@john-h-kastner-aws john-h-kastner-aws merged commit 4cb5358 into main Apr 3, 2026
25 of 26 checks passed
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.

4 participants