Skip to content

Conversation

shaobo-he-aws
Copy link
Contributor

@shaobo-he-aws shaobo-he-aws commented Nov 11, 2024

Description of changes

This PR implements RFC 48 (schema annotations).

Issue #, if available

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

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

Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
@shaobo-he-aws shaobo-he-aws marked this pull request as draft November 11, 2024 22:09
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
@shaobo-he-aws shaobo-he-aws removed the request for review from andrewmwells-amazon December 5, 2024 23:13
Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

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

To issues:

  • Doesn't handle @foo empty annotation syntax
  • Adds a new error variant to a public and exhaustive enum

@shaobo-he-aws
Copy link
Contributor Author

  • Doesn't handle @foo empty annotation syntax

I did do it but realized that it wasn't in the RFC.

@john-h-kastner-aws
Copy link
Contributor

  • Doesn't handle @foo empty annotation syntax

I did do it but realized that it wasn't in the RFC.

fair, but empty annotation came about after the RFC was written, so I'd assume the intent of the RFC was to support annotations in schema as they exist for policies

Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
@shaobo-he-aws shaobo-he-aws changed the title RFC 48 prototype RFC 48 implementation Dec 13, 2024
Copy link
Contributor

@cdisselkoen cdisselkoen left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for all the great work

Comment on lines +111 to +112
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Before this PR, the EST Annotations type was just #[cfg_attr(feature = "wasm", tsify(type = "Record<string, string>"))]. This PR would seem to include the .val and .loc fields in the Wasm type. Is that a breaking change? I don't think it makes sense to have .loc fields allowed in the EST. Maybe the tsify type for Annotation here should just be string, and we figure out how to let Wasm construct Annotation from just a string?

Copy link
Contributor

Choose a reason for hiding this comment

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

I had some similar concerns. More generally, I just don't fully understand how this PR affects the wasm api, so I can't assert that we're not breaking it or exposing new details we'd rather not stablize

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that Annotation is still a type alias to SmolStr in the generated TS files.

#[serde(default)]
#[serde(skip_serializing_if = "BTreeMap::is_empty")]
#[serde(with = "::serde_with::rust::maps_duplicate_key_is_error")]
#[cfg_attr(feature = "wasm", tsify(type = "Record<string, Annotation>"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe my comment above about locs in the EST should have been here. I didn't realize there were two Annotations types now

Copy link
Contributor

Choose a reason for hiding this comment

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

(but it looks like there's just the one Annotation type containing the loc, so my comment still applies)

Co-authored-by: Craig Disselkoen <cdiss@amazon.com>
Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

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

looking good

Comment on lines +111 to +112
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[cfg_attr(feature = "wasm", tsify(into_wasm_abi, from_wasm_abi))]
Copy link
Contributor

Choose a reason for hiding this comment

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

I had some similar concerns. More generally, I just don't fully understand how this PR affects the wasm api, so I can't assert that we're not breaking it or exposing new details we'd rather not stablize

Signed-off-by: Shaobo He <shaobohe@amazon.com>
Signed-off-by: Shaobo He <shaobohe@amazon.com>
@shaobo-he-aws shaobo-he-aws merged commit ed35ba7 into main Dec 16, 2024
17 of 19 checks passed
@shaobo-he-aws shaobo-he-aws deleted the feature/shaobo/rfc48 branch December 16, 2024 17:14
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