Skip to content

Add native scalar planning and optimizer integration - #1034

Open
snazy wants to merge 2 commits into
projectnessie:mainfrom
snazy:native-scalar-planning
Open

snazy wants to merge 2 commits into
projectnessie:mainfrom
snazy:native-scalar-planning

Conversation

@snazy

@snazy snazy commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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.

@snazy
snazy requested a review from XN137 November 11, 2026 07:28
if (astIss.hasIssues()) {
throw new ScriptCreateException("check failed", astIss.getIssues());
}
ast = astIss.getAst();

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.

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

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.

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.
@snazy
snazy force-pushed the native-scalar-planning branch from e91750b to e4ed978 Compare November 11, 2026 10:05
@snazy

snazy commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

Good findings! Addressed in the commit.

@snazy
snazy requested a review from XN137 November 11, 2026 10:06
boolean selectTruthy = selectTruthy(activation);
try {
return selectTruthy ? truthy.evalBoolean(activation) : falsy.evalBoolean(activation);
} catch (ValueSignal valueSignal) {

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.

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.

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.

2 participants