generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Labels
feature-requestThis issue requets a substantial new featureThis issue requets a substantial new feature
Description
Category
Internal refactors/changes -- consider "Internal improvement" instead of "Feature request"
Describe the feature you'd like to request
As a follow-up to #2091, I'm wondering if it's possible and/or worth it to further simplify TPE error-free expressions, even in presence of partially-known data.
For example,
- After the validator has done its pass, it might assign the singleton
TrueorFalsetypes to (sub-)expressions. However, we don't use this information when converting fromExpr<Option<Type>>toResidualtoday, although that could prune some part of the residual in a sound manner, right?- As a concrete example, the validator is able to deduce that e.g.
principal has nonexistentfieldisFalse(and its negationtrue). However, one can replace this withfalse/true, again, only when we know the expression is error-free, as e.g. alsoprincipal.num + 1 == 2 && principal has nonexistentfieldhas singleton typeFalse, but could error.
- As a concrete example, the validator is able to deduce that e.g.
- If the ancestors of
entity1in<entity1> in [<entity2>, <entity3>, ...]is not known, only equality betweenentity1andentity2is checked, and not e.g. whetherentity1andentity3are equal. This means thatUser::"alice" in [User::"bob", User::"alice"]is not reduced totruewhen the ancestors ofUser::"alice"are not known, even if that information is not needed to assign a truth value. Note that this is done only when all<entity_i>are concrete, so no errors can happen. - Right now, it seems like type information is not at all used in the Evaluator (see this PoC). Maybe one place it could be used, is to fold
<error-free-t1> == <error-free-t2>of distinct types intofalse. This would not work if the LHS or RHS could error, as then the error would need to be propagated upwards instead and thus cannot be replaced. - Similarly, it seems like the following special cases could be reduced (although not super likely):
<error-free> in []=>false[].contains(<error-free>)=>false<error-free>.containsAny([])=>false[].containsAny(<error-free>)=>false<error-free>.containsAll([])=>true[].containsAll(<error-free>)cannot be deduced, as<error-free>could evaluate into[]=>trueor[a, b, c, ...]=>false.
- Not very likely to happen, and maybe not worth implementing, but
if <error-free> then <res> else <res>is<res>, if bothResidualcases (concrete or partial) are equal.Eqis not implemented forResidualat the moment, was this due to some specific reason or just not needed so far? Are there worries that expression comparisons could be too expensive to perform in this case? <error-free> like "*"=>true
Any thoughts on the following? These are some of the rewrites I came to think of, but maybe there are more.
Would be interesting to hear your thoughts @emina @john-h-kastner-aws
Describe alternatives you've considered
Not implement these in core, defer to downstream users. I already implemented <error-free> like "*" => true for the Kubernetes use-case (right now, by disallowing users to write such expressions), as that would otherwise be a pretty big gotcha for users, given how I implemented things right now.
Additional context
No response
Is this something that you'd be interested in working on?
- 👋 I may be able to implement this feature request
-
⚠️ This feature might incur a breaking change
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature-requestThis issue requets a substantial new featureThis issue requets a substantial new feature