Skip to content

adding decode_unchecked API and refactoring validation#2387

Merged
victornicolet merged 9 commits into
mainfrom
victornicolet/protobuf-decode-unchecked
Jun 12, 2026
Merged

adding decode_unchecked API and refactoring validation#2387
victornicolet merged 9 commits into
mainfrom
victornicolet/protobuf-decode-unchecked

Conversation

@victornicolet

@victornicolet victornicolet commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description of changes

Adds a new <target type>::decode_unchecked API to protobuf implems, with a refactoring of where the validation occurs to make it more obvious.

This makes a "breaking change" on the experimental protobufs feature by sealing the Protobuf trait (and adding methods). As we stabilize this, I think it's a good idea, in order to allow adding methods in the future without breaking.

Checklist for requesting a review

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

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

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):

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

@victornicolet victornicolet force-pushed the victornicolet/protobuf-decode-unchecked branch from 3060df4 to d8eacec Compare June 9, 2026 14:59
Signed-off-by: Victor Nicolet <victornl@amazon.com>
Signed-off-by: Victor Nicolet <victornl@amazon.com>
Signed-off-by: Victor Nicolet <victornl@amazon.com>
@victornicolet victornicolet force-pushed the victornicolet/protobuf-decode-unchecked branch from d8eacec to 8c5348b Compare June 9, 2026 15:00
Signed-off-by: Victor Nicolet <victornl@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

This PR introduces an unchecked protobuf decoding API (decode_unchecked) across protobuf-backed public types, and refactors protobuf decoding so that structural validation is performed in a single, more explicit place (the checked decode path), while allowing callers to opt out of validation for trusted/round-tripped data.

Changes:

  • Adds decode_unchecked to the protobuf decoding interface and centralizes validation in the default decode implementation.
  • Refactors proto model ↔ core/API conversions to avoid performing validation during TryFrom, enabling truly unchecked decoding.
  • Updates protobuf decoding behavior for Entities to optionally skip transitive-closure computation on the unchecked path and adds roundtrip tests for decode_unchecked.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cedar-policy/src/proto/validator.rs Stops validating during schema model→core conversion to defer validation to the checked decode path.
cedar-policy/src/proto/traits.rs Introduces TryValidate and refactors Protobuf::decode to validate the decoded value; adds decode_unchecked.
cedar-policy/src/proto/policy.rs Removes validation from proto→AST conversions for templates/policy sets to support unchecked decoding.
cedar-policy/src/proto/entities.rs Factors out entities model conversion with configurable transitive-closure mode (and updates docs).
cedar-policy/src/proto/ast.rs Removes validation from proto→AST entity/expression conversion so checked decoding can own validation.
cedar-policy/src/proto/api.rs Updates Protobuf impls to provide decode_unchecked, adds special handling for Entities, and adds tests.
cedar-policy/CHANGELOG.md Notes the behavior change and introduces decode_unchecked in the unreleased changelog entry.

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

Comment thread cedar-policy/src/proto/entities.rs Outdated
Comment thread cedar-policy/CHANGELOG.md Outdated
victornicolet and others added 4 commits June 9, 2026 11:39
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Victor Nicolet <victornl@amazon.com>
Signed-off-by: Victor Nicolet <victornl@amazon.com>
@github-actions

This comment was marked as outdated.

@victornicolet victornicolet marked this pull request as ready for review June 9, 2026 16:46
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Coverage Report

Head Commit: 505d826a755a3e8362411db2223d4e218b6c46c7

Base Commit: b0708054b119e8c9fb49225df70493628ac63923

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 86.84%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy/src/proto/api.rs 🟢 19/20 95.00% 136
cedar-policy/src/proto/ast.rs 🟢 2/2 100.00%
cedar-policy/src/proto/entities.rs 🟢 17/17 100.00%
cedar-policy/src/proto/policy.rs 🟢 1/1 100.00%
cedar-policy/src/proto/traits.rs 🟡 26/35 74.29% 196-198, 212, 214-215, 220, 222-223
cedar-policy/src/proto/validator.rs 🟢 1/1 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 87.87%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% 92.55%
cedar-policy 🟢 4530/5644 80.26% 79.93%
cedar-policy-cli 🟡 1230/1621 75.88% 75.88%
cedar-policy-core 🟢 24429/27725 88.11% 88.11%
cedar-policy-formatter 🟢 914/1088 84.01% 84.01%
cedar-policy-symcc 🟢 6777/7274 93.17% 93.17%
cedar-wasm 🔴 0/28 0.00% 0.00%

@victornicolet victornicolet requested a review from lianah June 10, 2026 20:55
Comment thread cedar-policy/src/proto/api.rs Outdated
Signed-off-by: Victor Nicolet <victornl@amazon.com>
@victornicolet victornicolet requested a review from lianah June 12, 2026 20:01
@github-actions

Copy link
Copy Markdown

Coverage Report

Head Commit: 41f6e5f3032be4ac56f87ad3b9b7a05c4bd986a3

Base Commit: b0708054b119e8c9fb49225df70493628ac63923

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 86.67%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy/src/proto/api.rs 🟢 18/19 94.74% 136
cedar-policy/src/proto/ast.rs 🟢 2/2 100.00%
cedar-policy/src/proto/entities.rs 🟢 17/17 100.00%
cedar-policy/src/proto/policy.rs 🟢 1/1 100.00%
cedar-policy/src/proto/traits.rs 🟡 26/35 74.29% 196-198, 212, 214-215, 220, 222-223
cedar-policy/src/proto/validator.rs 🟢 1/1 100.00%

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 87.90%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4722/5102 92.55% --
cedar-policy 🟢 4530/5644 80.26% --
cedar-policy-cli 🟡 1257/1649 76.23% --
cedar-policy-core 🟢 24576/27882 88.14% --
cedar-policy-formatter 🟢 914/1088 84.01% --
cedar-policy-symcc 🟢 6777/7274 93.17% --
cedar-wasm 🔴 0/28 0.00% --

@victornicolet victornicolet merged commit 7459598 into main Jun 12, 2026
32 of 34 checks passed
@victornicolet victornicolet deleted the victornicolet/protobuf-decode-unchecked branch June 12, 2026 20:22
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