Skip to content

feat: natural language - #477

Merged
stefan-gorules merged 2 commits into
masterfrom
feat/natural-language
Jul 7, 2026
Merged

feat: natural language#477
stefan-gorules merged 2 commits into
masterfrom
feat/natural-language

Conversation

@stefan-gorules

Copy link
Copy Markdown
Contributor

Natural language projection for expressions

This PR allows engine to describe expressions in a natural language. It adds a read-side API that turns any ZEN expression into a stream of structured tokens that a client can render as a plain sentence, in any language.

What it delivers

Some examples of expressions and the sentences a client renders from the projected tokens:

Expression Shown to the user as
customer.age >= 18 customer.age is at least 18
customer.country in ['US', 'CA'] customer.country is one of US, CA
age in [18..65] age is between 18 and 65
> 100 (decision table cell) greater than 100
all(order.items as item, item.price > 100) every order.items has price greater than 100

The engine does not produce those words. It produces tokens, and the words come from the client's dictionary:

  • Token projection. An expression comes back as typed tokens (field, operator, number) instead of text. Each token carries its position in the original source, so edits made on the sentence can be written back precisely.
  • No English in the engine. Tokens carry stable symbols ("gte", "where", "sum"). Clients map symbols to phrases.
  • Editing guidance built in. Where it knows more than the raw text shows, the engine says so: enum fields include their allowed values with ready-to-insert literals, operators include the alternatives valid for the operand types, date-like strings are marked for date pickers.

How it helps

  • It is the foundation for rule editors that show and edit logic as sentences, with the engine guaranteeing the sentence always matches the real expression.
  • Type-aware hints let editors offer only valid choices, which prevents malformed rules at the source.
  • Purely additive: evaluation, tracing and all existing APIs are unchanged.

@stefan-gorules
stefan-gorules merged commit 6858c1b into master Jul 7, 2026
57 checks passed
@stefan-gorules
stefan-gorules deleted the feat/natural-language branch July 7, 2026 19:50
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