Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Evaluation DRT #308

Merged
merged 2 commits into from
Jun 13, 2024
Merged

Partial Evaluation DRT #308

merged 2 commits into from
Jun 13, 2024

Conversation

aaronjeline
Copy link
Contributor

@aaronjeline aaronjeline commented May 8, 2024

Issue #, if available:
N/A
Description of changes:
Adds DRT for partial evaluation

It does find a discrepancy

@aaronjeline aaronjeline force-pushed the aeline/partial-eval branch from 12e7ba5 to b1bc1f5 Compare May 8, 2024 14:29
@aaronjeline aaronjeline marked this pull request as ready for review May 8, 2024 15:08
@aaronjeline aaronjeline requested review from cdisselkoen and khieta May 8, 2024 15:08
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 good to me overall

cedar-drt/fuzz/fuzz_targets/partial-eval.rs Outdated Show resolved Hide resolved
cedar-drt/fuzz/fuzz_targets/partial-eval.rs Outdated Show resolved Hide resolved
cedar-drt/fuzz/fuzz_targets/partial-eval.rs Outdated Show resolved Hide resolved
cedar-drt/fuzz/src/lib.rs Outdated Show resolved Hide resolved
cedar-drt/fuzz/src/lib.rs Outdated Show resolved Hide resolved
cedar-lean/DiffTest/Parser.lean Show resolved Hide resolved
cedar-lean/DiffTest/Parser.lean Show resolved Hide resolved
cedar-lean/DiffTest/Parser.lean Show resolved Hide resolved
cedar-drt/fuzz/fuzz_targets/partial-eval.rs Show resolved Hide resolved
cedar-drt/fuzz/fuzz_targets/partial-eval.rs Show resolved Hide resolved
Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

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

Some high-level comments

  • I imagine we'll also want to be DRT'ing policies, since the logic to compute the "definitely erroring policies" and such is a little confusing. Might make sense to add an additional target in this PR, like how we have abac-type-directed and eval_type_directed.
  • Let's change the name to partial-eval-type-directed for consistency with the other targets.
  • Can you add support for PE to Cli/Main.lean too? Should be easy since you've already set up the DRT functionality.

cedar-lean/DiffTest/Parser.lean Show resolved Hide resolved
cedar-lean/DiffTest/Parser.lean Show resolved Hide resolved
let unknown_type: Option<ast::Type> = target_type.clone().try_into().ok();
match unknown_type {
Some(ty) => Ok(ast::Expr::unknown(ast::Unknown::new_with_type(name, ty))),
None => Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))),
}
Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name)))
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Bumping this question from @khieta as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted, good catch @khieta

| .ok v => ValueOrExpr.value <$> (jsonToValue v)
| .error _ => match json.getObjVal? "Expr" with
| .ok e => ValueOrExpr.expr <$> (jsonToPartialExpr e)
| .error _ => .error "Expected either `expr` or `value`"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| .error _ => .error "Expected either `expr` or `value`"
| .error _ => .error "jsonToValueOrExpr: expected either `Expr` or `Value`"

Copy link
Contributor

Choose a reason for hiding this comment

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

did you reject this suggestion? it was resolved but it doesn't appear in the latest diff

cedar-lean/Cedar/Spec/ExtFun.lean Outdated Show resolved Hide resolved
@aaronjeline
Copy link
Contributor Author

Some high-level comments

  • I imagine we'll also want to be DRT'ing policies, since the logic to compute the "definitely erroring policies" and such is a little confusing. Might make sense to add an additional target in this PR, like how we have abac-type-directed and eval_type_directed.

Absolutely, just waiting for partial auth code to be merged

  • Let's change the name to partial-eval-type-directed for consistency with the other targets.

Will do

  • Can you add support for PE to Cli/Main.lean too? Should be easy since you've already set up the DRT functionality.

Sure

@cdisselkoen
Copy link
Contributor

Partial auth code was merged last week (#299) :)

@aaronjeline aaronjeline force-pushed the aeline/partial-eval branch 5 times, most recently from 807602b to b28b0b2 Compare May 22, 2024 17:46
@aaronjeline aaronjeline requested review from cdisselkoen and emina May 22, 2024 17:46
@aaronjeline
Copy link
Contributor Author

Blocked by: cedar-policy/cedar#898

cedar-lean/Cedar/Partial/Expr.lean Show resolved Hide resolved
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.

Nothing in my comments needs to be blocking

cedar-drt/fuzz/fuzz_targets/partial-eval.rs Show resolved Hide resolved
cedar-drt/fuzz/src/lib.rs Show resolved Hide resolved
cedar-lean/Cedar/Thm/Data/Applicative.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Data/Applicative.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Data/Applicative.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Data/Applicative.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Partial/Expr/Lemmas.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Partial/Expr/Lemmas.lean Outdated Show resolved Hide resolved
cedar-lean/Cedar/Thm/Partial/Expr/Lemmas.lean Outdated Show resolved Hide resolved
@aaronjeline aaronjeline force-pushed the aeline/partial-eval branch from 5fa3e9b to 51ed147 Compare May 24, 2024 18:50
@aaronjeline aaronjeline requested review from cdisselkoen and emina May 29, 2024 13:17
cedar-drt/fuzz/fuzz_targets/partial-eval.rs Show resolved Hide resolved
let unknown_type: Option<ast::Type> = target_type.clone().try_into().ok();
match unknown_type {
Some(ty) => Ok(ast::Expr::unknown(ast::Unknown::new_with_type(name, ty))),
None => Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name))),
}
Ok(ast::Expr::unknown(ast::Unknown::new_untyped(name)))
Copy link
Contributor

Choose a reason for hiding this comment

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

Bumping this question from @khieta as well

@aaronjeline aaronjeline force-pushed the aeline/partial-eval branch from cc79fee to 122d198 Compare June 13, 2024 13:45
@aaronjeline aaronjeline requested a review from cdisselkoen June 13, 2024 13:45
PolicyKind::True => Expr::val(true),
PolicyKind::False => Expr::val(false),
PolicyKind::Error => Expr::add(Expr::val(1), Expr::val(false)),
PolicyKind::Residual => Expr::get_attr(Expr::var(ast::Var::Context), "unknown".into()),
Copy link
Contributor

Choose a reason for hiding this comment

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

should this expression include an actual unknown?

theorem roundtrip (e : Spec.Expr) (pe : Partial.Expr) :
e.asPartialExpr = pe ↔ pe.asSpec = some e := by
apply Iff.intro <;> intros h
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption }
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe something like this is clearer?

Suggested change
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption }
· apply roundtrip₂ ; assumption
· apply roundtrip₁ ; assumption

Copy link
Contributor

Choose a reason for hiding this comment

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

Or, instead of assumption, use h directly.

Suggested change
all_goals { (first | apply roundtrip₂ | apply roundtrip₁) <;> assumption }
· exact roundtrip₂ _ _ h
· exact roundtrip₁ _ _ h

or something similar

| .ok v => ValueOrExpr.value <$> (jsonToValue v)
| .error _ => match json.getObjVal? "Expr" with
| .ok e => ValueOrExpr.expr <$> (jsonToPartialExpr e)
| .error _ => .error "Expected either `expr` or `value`"
Copy link
Contributor

Choose a reason for hiding this comment

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

did you reject this suggestion? it was resolved but it doesn't appear in the latest diff

@aaronjeline aaronjeline merged commit b15dcac into main Jun 13, 2024
6 checks passed
@aaronjeline aaronjeline deleted the aeline/partial-eval branch June 13, 2024 14:10
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