feat(evaluator): route CEL-dialect component/action predicates to the canonical engine (#2661)#2664
Merged
Merged
Conversation
… canonical engine (#2661) Component/action `visible`/`disabled`/`hidden` predicates ran on the home-grown JS `ExpressionEvaluator`, while field rules (fieldRules.ts) and row/list conditionals (evalRowPredicate) already delegate to `@objectstack/formula`. So a `{ dialect: 'cel' }` predicate in a renderer/action surface was executed as JavaScript — CEL-only forms (`x in list`, `has()`, typed `==`, the today()/ daysFromNow() catalog) diverged from or faulted against server enforcement. - core: ExpressionEvaluator.evaluateCondition now detects a `{ dialect: 'cel' }` envelope and evaluates it on the canonical engine (via evalFieldPredicate), binding record.* + the context bag (features.*/user.*/app.*). Fail-soft to visible/enabled (legacy parity); throwOnError still fails closed on a *faulting* predicate, never on a genuine false. Fixes every SchemaRenderer visibility read. - react: toPredicateInput preserves a CEL envelope (instead of collapsing it to a `${source}` string), and useCondition accepts + forwards it. Action buttons (action-icon/group/bar/button) now evaluate CEL visible/enabled/disabled on the canonical engine. Back-compat: bare strings and `${…}` templates stay on the legacy JS path; only an explicit `{ dialect: 'cel' }` envelope is rerouted. Also fixes a pre-existing preserve-caught-error lint in evaluateExpression's catch (adds { cause }). Verified: core evaluator + react hooks + SchemaRenderer + action-renderer suites green (585 core/react, incl. new #2661 tests); core & react type-check clean; eslint 0 errors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SuiM565BZ3TR1VD3prMguB
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…aks build)
The 2-arg `new Error(msg, { cause })` form needs ES2022 lib; this package
targets lower, so tsc failed TS2554 in the Bundle Analysis build. It was a
gratuitous fix for a non-CI-gated lint rule on pre-existing code — reverted to
the original single-arg throw. The #2661 CEL routing is unchanged.
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
os-zhuang
marked this pull request as ready for review
July 18, 2026 14:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2661.
Problem
ObjectUI evaluated runtime predicates through two engines that diverged:
visibleWhen/readonlyWhen/requiredWhen)fieldRules.ts→@objectstack/formulaevalRowPredicate→@objectstack/formulavisible/disabled/hiddenExpressionEvaluatorSo a
{ dialect: 'cel' }predicate on a renderer/action surface was executed as JavaScript — CEL-only forms (x in list,has(), typed==, thetoday()/daysFromNow()catalog) behaved differently from, or faulted against, server enforcement. This is the split #2661 tracks.Fix — converge the remaining tier onto the canonical engine
@object-ui/core—ExpressionEvaluator.evaluateConditiondetects a{ dialect: 'cel', source }envelope and evaluates it viaevalFieldPredicate(the same@objectstack/formulapath field rules use), binding therecordnamespace plus the context bag as top-level scope (record.*,features.*,user.*,app.*). Fail-soft to visible/enabled (legacy parity);throwOnErrorcallers still fail closed on a faulting predicate, never on a genuinefalse. This fixes all 8SchemaRenderervisibility/disabled reads at once.@object-ui/react—toPredicateInputpreserves a CEL envelope instead of collapsing it to${source}, anduseConditionaccepts + forwards it. Action buttons (action-icon/group/bar/button) now evaluate CELvisible/enabled/disabledon the canonical engine.Back-compat: bare strings and
${…}templates stay on the legacy JS path (deprecation window); only an explicit{ dialect: 'cel' }envelope is rerouted.{ dialect: 'template' }is unaffected.Together with the
^15.1.1alignment (#2662), a renderer CEL predicate reaches the identical verdict as the server — including framework'sdateField == today()fix (objectstack-ai/objectstack#3205) once it lands in a published 15.x.Tests / verification
ExpressionEvaluator.test.ts— CEL envelope routes to the canonical engine (proven via CELinvs JSindivergence),record.*/features.*binding, ISO-date ordering vstoday(), fail-soft default,throwOnErrorfail-closed on fault (genuinefalsedoesn't throw), empty source, and back-compat (bare/${…}/templatestay legacy).useExpression.test.ts—toPredicateInputpreserves cel envelopes / still wraps bare+template;useConditionevaluates a cel envelope on the canonical engine.SchemaRenderer.*+ action renderers (585 core/react + 4 action).@object-ui/core&@object-ui/reacttype-checkclean;eslint0 errors (also fixed a pre-existingpreserve-caught-errorinevaluateExpression's catch). Changeset: minor (core, react).Not in scope
The legacy
${…}JS-template dialect remains for plain-string predicates (deprecation window). A future step could warn on/parse those toward CEL, but this PR keeps them byte-for-byte to avoid churn.🤖 Generated with Claude Code
Generated by Claude Code