Repository navigation
Conversation
| if (astIss.hasIssues()) { | ||
| throw new ScriptCreateException("check failed", astIss.getIssues()); | ||
| } | ||
| ast = astIss.getAst(); |
There was a problem hiding this comment.
codex finding:
- [P2] Checked planning changes membership results in ScriptHost — ScriptHost.java:136. Using the checked AST enables constant-set optimization by default. For example, dyn(1.0) in [1] previously returned true through CEL numeric equality; it now reaches EvalSetMembership, whose type-name check rejects double versus int, causing ScriptExecutionException. The set optimization needs to preserve list-membership semantics before enabling it for existing scripts
| }; | ||
| } | ||
|
|
||
| static Interpretable maybeOptimizeConstUnary(Interpretable i, InterpretableCall call) { |
There was a problem hiding this comment.
codex finding
- [P2] Optimizer extraction removes public methods — InterpretableDecorator.java:107–110. The removed maybeOptimizeConstUnary and maybeOptimizeSetMembership methods were implicitly public interface methods with public parameter types. Existing callers will fail compilation or encounter NoSuchMethodError. Keep forwarding methods delegating to BuiltInOptimizer to preserve compatibility.
if it used to be part of the public and we remove it intentionally, we might want to call it out in PR description
Evaluate eligible checked scalar expressions without intermediate `Val` wrappers. Preserve established fallback for incompatible adapters, overloads, and decorators; compose native islands with built-in constant folding and retain differential, root-shape, policy, and public API coverage. `ScriptHost` now plans from the checked AST, enabling checked-expression optimizations. Constant-list membership preserves CEL numeric equality, including mixed numeric types and NaN behavior. Existing public optimizer helper methods remain available as forwarding methods, preserving source and binary compatibility.
e91750b to
e4ed978
Compare
|
Good findings! Addressed in the commit. |
| boolean selectTruthy = selectTruthy(activation); | ||
| try { | ||
| return selectTruthy ? truthy.evalBoolean(activation) : falsy.evalBoolean(activation); | ||
| } catch (ValueSignal valueSignal) { |
There was a problem hiding this comment.
more codex finding:
- [P2] Preserve exception handling in native conditionals — NativeScalarNodes.java:806–812. Native conditionals catch only ValueSignal, whereas the established EvalAttr converts all evaluation exceptions into CEL errors. With b=true and s=StringT.stringOf(null), (b ? s == 'value' : false) || true previously returns true: the conditional converts the comparison’s NullPointerException into an error, which || true suppresses. Native evaluation instead throws an internal-error exception. Preserve the exception conversion around both the condition and selected branch.
There was a problem hiding this comment.
Thanks! Fixed in the new commit
| public final Object resolve(Activation activation) { | ||
| return usesPartialAttribute(activation) | ||
| ? partialAttribute.resolve(activation) | ||
| : attr.resolve(activation); | ||
| } | ||
|
|
||
| final boolean usesPartialAttribute(Activation activation) { | ||
| return activation instanceof Activation.PartialActivation && partialAttribute != null; | ||
| } |
There was a problem hiding this comment.
codex finding:
- [P2] Native selectors enable partial evaluation without
OptPartialEval—resolve()switches to the partial attribute whenever the input is aPartialActivation, regardless of program options. For checkedattrs.answer == 1, supplyingattrs.answer = 1and an unknown pattern for that field now returns unknown by default, while addingOptDisableNativeEvalorOptTrackStatereturnstrue. Evaluation results therefore depend on optimization or instrumentation settings. Preserve the configured attribute factory’s behavior and enable qualifier-pattern matching only withOptPartialEval.
There was a problem hiding this comment.
Native selectors now use the program’s configured attribute factory. attrs.answer == 1 returns true by default, with optimization, and with state tracking. With OptPartialEval and a matching unknown pattern, it returns unknown.
| return null; | ||
| } | ||
| // An InList call always has a Lister right operand. | ||
| Lister list = (Lister) listConstant.value(); |
There was a problem hiding this comment.
codex finding:
BuiltInOptimizer.java:128 — Preserve CEL errors during membership folding
true || ({'k': 1} in [{'k': 1, string(b'k'): 2}]) should evaluate to true. If evaluated, the duplicate key produces a CEL error that || must absorb. Here the list folds to an Err, and the cast to Lister throws ClassCastException during ScriptHost.build(). The cast predates this PR, and switching ScriptHost to checked planning makes it reachable by default. Could we require the folded value to be a Lister before applying the rewrite?
|
|
||
| @Override | ||
| public boolean evalBoolean(Activation activation) { | ||
| return NativeSupport.booleanValue(adapter, resolveRaw(activation)); |
There was a problem hiding this comment.
codex finding:
NativeScalarNodes.java:186 — Keep binding errors visible to ||
Consider x || true with x bound to a supplier that throws Err.ErrException. The previous optimized plan converted it to a CEL error at the lookup, so || returned true. The new lookup lets it escape to Prog.eval, which converts it after the whole expression has unwound. Could we convert Err.ErrException at the lookup so the logical operator can apply CEL’s error-absorption rule?
| Expr expr, ResolvedFunction resolvedFunction, Interpretable[] arguments) { | ||
| Call call = expr.getCallExpr(); | ||
| if (!policy.builtInOptimizationEnabled() | ||
| || !resolvedFunction.overloadId.equals(Overloads.InList) |
There was a problem hiding this comment.
codex finding:
Planner.java:503 — Honor the registered membership overload
ProgramOption.functions documents support for overriding built-ins. If an application registers Overloads.InList to return false, the checked expression 1 in [1] returns false with optimization disabled. This rewrite returns true without calling the registered implementation. The existing checked optimizer has the same gap. Could we require the resolved implementation to be the standard membership overload before applying the rewrite?
Evaluate eligible checked scalar expressions without intermediate
Valwrappers. Preserve established fallback for incompatible adapters, overloads, and decorators; compose native islands with built-in constant folding and retain differential, root-shape, policy, and public API coverage.ScriptHostnow plans from the checked AST, enabling checked-expression optimizations. Constant-list membership preserves CEL numeric equality, including mixed numeric types and NaN behavior.Existing public optimizer helper methods remain available as forwarding methods, preserving source and binary compatibility.