Skip to content

feat: implement rfc 104 cedar entity syntax - #2478

Open
amahomm wants to merge 2 commits into
cedar-policy:mainfrom
amahomm:main
Open

feat: implement rfc 104 cedar entity syntax#2478
amahomm wants to merge 2 commits into
cedar-policy:mainfrom
amahomm:main

Conversation

@amahomm

@amahomm amahomm commented Jul 17, 2026

Copy link
Copy Markdown

Description of changes

implements cedar entity syntax as defined in rfc
104

Issue #, if available

Checklist for requesting a review

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

  • 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).

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

  • 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 confirm that docs.cedarpolicy.com (choose one, and delete the other options):

  • 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.)
    ( ^ should this be done for experimental features? )

@amahomm

amahomm commented Jul 20, 2026

Copy link
Copy Markdown
Author

oof. will look at these failed checks.
looks like they are all due to forgetting to run cargo fmt. will update

implements cedar entity syntax as defined in [rfc
104](https://github.com/cedar-policy/rfcs/blob/main/text/0104-entity-data-syntax.md)

Signed-off-by: aron hommas <aronhomm@amazon.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements the experimental RFC 104 “Cedar entity data syntax” end-to-end: parsing entity data from Cedar syntax into Entities, formatting Entities back to Cedar syntax, and wiring the new format through the public API and CLI behind the cedar-entity-syntax feature flag.

Changes:

  • Added a Cedar entity-syntax parser (LALRPOP) + AST → Entities conversion, plus pretty-printing (Entities → Cedar text) in cedar-policy-core.
  • Exposed new experimental public APIs Entities::from_cedar_str() / Entities::to_cedar_string() and associated error types in cedar-policy.
  • Added CLI support for selecting entity input format via --entities-format cedar, plus associated tests and changelog updates.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cedar-policy/src/api/err.rs Adds public error types/re-exports for Cedar entity-syntax parsing/formatting under feature flag
cedar-policy/src/api.rs Adds Entities::from_cedar_str() / Entities::to_cedar_string() plus a public-API round-trip regression test
cedar-policy/CHANGELOG.md Documents the new experimental entity-syntax API/CLI additions
cedar-policy/Cargo.toml Adds cedar-entity-syntax to experimental feature set and wires core feature
cedar-policy-core/src/entities.rs Exposes entities::cedar_syntax module behind feature flag
cedar-policy-core/src/entities/cedar_syntax.rs New module wiring for parser/formatter/conversion code (plus tests)
cedar-policy-core/src/entities/cedar_syntax/ast.rs New AST types for entity data syntax
cedar-policy-core/src/entities/cedar_syntax/err.rs New parse/conversion error types (miette diagnostics)
cedar-policy-core/src/entities/cedar_syntax/parser.rs New LALRPOP-backed parser entrypoint and error collection
cedar-policy-core/src/entities/cedar_syntax/grammar.lalrpop New entity data syntax grammar (lexer + parser productions)
cedar-policy-core/src/entities/cedar_syntax/to_entities.rs New AST → internal Entity conversion incl. namespace-aware reference resolution
cedar-policy-core/src/entities/cedar_syntax/fmt.rs New pretty-printer for emitting Cedar entity data syntax
cedar-policy-core/src/entities/cedar_syntax/test.rs New parser/conversion/round-trip/error tests and JSON↔Cedar golden pairs
cedar-policy-core/src/entities/cedar_syntax/testfiles/** New golden test inputs/expected JSON outputs covering features/edge cases
cedar-policy-core/Cargo.toml Adds cedar-entity-syntax feature and includes it in experimental
cedar-policy-core/build.rs Runs LALRPOP generation for entity syntax when feature is enabled
cedar-policy-cli/src/utils/entities.rs Adds EntitiesFormat + structured clap args to support JSON vs Cedar entity input
cedar-policy-cli/src/utils.rs Re-exports entities utilities publicly for crate consumers/tests
cedar-policy-cli/src/command/{authorize,evaluate,check_parse,partial_eval,visualize}.rs Switches commands to use the new structured entities args (and optional entities)
cedar-policy-cli/tests/sample.rs Updates integration tests to construct new entities arg structs
cedar-policy-cli/CHANGELOG.md Documents --entities-format cedar under experimental feature
cedar-policy-cli/Cargo.toml Wires cedar-entity-syntax into the CLI’s experimental feature set

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

Comment thread cedar-policy-core/src/entities/cedar_syntax/grammar.lalrpop Outdated
Comment thread cedar-policy/src/api.rs Outdated
Comment thread cedar-policy/src/api.rs Outdated
Comment thread cedar-policy/src/api.rs Outdated
@github-actions

Copy link
Copy Markdown

Coverage Report

Head Commit: cc8f9e9f9d60229562c17f86603019d4124b7e7b

Base Commit: a3e8a3faa8f79ac64ff196cf48f24a065d346916

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 85.43%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-cli/src/command/authorize.rs 🟢 3/3 100.00%
cedar-policy-cli/src/command/check_parse.rs 🟢 2/2 100.00%
cedar-policy-cli/src/command/evaluate.rs 🟢 5/6 83.33% 70
cedar-policy-cli/src/command/partial_eval.rs 🔴 0/3 0.00% 189, 224, 243
cedar-policy-cli/src/command/visualize.rs 🟢 1/1 100.00%
cedar-policy-cli/src/utils/entities.rs 🟢 38/38 100.00%
cedar-policy-core/src/entities/cedar_syntax/ast.rs 🟡 21/27 77.78% 107-111, 123
cedar-policy-core/src/entities/cedar_syntax/err.rs 🟡 122/173 70.52% 57, 59, 109-111, 125-126, 143, 145, 179-180, 222-224, 237, 266-268, 337, 343, 346-353, 355, 357, 359-361, 363-365, 367-369, 371-373, 375-377, 379-381, 383-385
cedar-policy-core/src/entities/cedar_syntax/fmt.rs 🟢 154/188 81.91% 169, 204-212, 214-226, 228-236, 238, 258
cedar-policy-core/src/entities/cedar_syntax/parser.rs 🟢 21/22 95.45% 73
cedar-policy-core/src/entities/cedar_syntax/to_entities.rs 🟢 192/199 96.48% 202-203, 225, 321-324
cedar-policy/src/api.rs 🟢 45/45 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 88.23%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟢 4704/5836 80.60% 80.45%
cedar-policy-cli 🟡 1316/1691 77.82% 77.53%
cedar-policy-core 🟢 25235/28498 88.55% 88.62%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6843/7326 93.41% 93.41%
cedar-wasm 🔴 0/28 0.00% 0.00%

@github-actions

Copy link
Copy Markdown

Coverage Report

Head Commit: 75fa41964dc05b23a0722cc28773ba260e503f75

Base Commit: a3e8a3faa8f79ac64ff196cf48f24a065d346916

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 85.43%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-cli/src/command/authorize.rs 🟢 3/3 100.00%
cedar-policy-cli/src/command/check_parse.rs 🟢 2/2 100.00%
cedar-policy-cli/src/command/evaluate.rs 🟢 5/6 83.33% 70
cedar-policy-cli/src/command/partial_eval.rs 🔴 0/3 0.00% 189, 224, 243
cedar-policy-cli/src/command/visualize.rs 🟢 1/1 100.00%
cedar-policy-cli/src/utils/entities.rs 🟢 38/38 100.00%
cedar-policy-core/src/entities/cedar_syntax/ast.rs 🟡 21/27 77.78% 107-111, 123
cedar-policy-core/src/entities/cedar_syntax/err.rs 🟡 122/173 70.52% 57, 59, 109-111, 125-126, 143, 145, 179-180, 222-224, 237, 266-268, 337, 343, 346-353, 355, 357, 359-361, 363-365, 367-369, 371-373, 375-377, 379-381, 383-385
cedar-policy-core/src/entities/cedar_syntax/fmt.rs 🟢 154/188 81.91% 169, 204-212, 214-226, 228-236, 238, 258
cedar-policy-core/src/entities/cedar_syntax/parser.rs 🟢 21/22 95.45% 73
cedar-policy-core/src/entities/cedar_syntax/to_entities.rs 🟢 192/199 96.48% 202-203, 225, 321-324
cedar-policy/src/api.rs 🟢 45/45 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 88.23%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟢 4704/5836 80.60% 80.45%
cedar-policy-cli 🟡 1316/1691 77.82% 77.53%
cedar-policy-core 🟢 25235/28498 88.55% 88.62%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6843/7326 93.41% 93.41%
cedar-wasm 🔴 0/28 0.00% 0.00%

also addresses other copilot review feedback.

Signed-off-by: aron hommas <aronhomm@amazon.com>
@github-actions

Copy link
Copy Markdown

Coverage Report

Head Commit: 1831726052b1727b2565393839bf5449ce7b0313

Base Commit: be57bc151e7e2190ec9f5705201b38d30ea5e43b

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 84.88%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy-cli/src/command/authorize.rs 🟢 3/3 100.00%
cedar-policy-cli/src/command/check_parse.rs 🟢 2/2 100.00%
cedar-policy-cli/src/command/evaluate.rs 🟢 5/6 83.33% 70
cedar-policy-cli/src/command/partial_eval.rs 🔴 0/3 0.00% 189, 224, 243
cedar-policy-cli/src/command/visualize.rs 🟢 1/1 100.00%
cedar-policy-cli/src/utils/entities.rs 🟢 38/38 100.00%
cedar-policy-core/src/entities/cedar_syntax/ast.rs 🟡 21/27 77.78% 107-111, 123
cedar-policy-core/src/entities/cedar_syntax/err.rs 🟡 122/173 70.52% 57, 59, 109-111, 125-126, 143, 145, 179-180, 222-224, 237, 266-268, 337, 343, 346-353, 355, 357, 359-361, 363-365, 367-369, 371-373, 375-377, 379-381, 383-385
cedar-policy-core/src/entities/cedar_syntax/fmt.rs 🟢 154/188 81.91% 169, 204-212, 214-226, 228-236, 238, 258
cedar-policy-core/src/entities/cedar_syntax/parser.rs 🟢 21/22 95.45% 73
cedar-policy-core/src/entities/cedar_syntax/to_entities.rs 🟢 192/199 96.48% 202-203, 225, 321-324
cedar-policy/src/api.rs 🟢 19/19 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 88.32%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% --
cedar-policy 🟢 4838/5963 81.13% --
cedar-policy-cli 🟡 1316/1691 77.82% --
cedar-policy-core 🟢 25191/28435 88.59% --
cedar-policy-formatter 🟢 914/1088 84.01% --
cedar-policy-symcc 🟢 6916/7396 93.51% --
cedar-wasm 🔴 0/28 0.00% --

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.

3 participants