docs: record the core-language slice and its decisions
public
docs: record the core-language slice and its decisions DECISIONS.md: mark ADR-7 (minimal slice) superseded by ADR-8 (widen to the FEEL core language); add ADR-9 (type errors -> null / three-valued logic), ADR-10 (Value gains String/List + boundary mapping), and ADR-11 (ingestion fitness is self-contained-expression detection). Add a Roadmap section recording the deferred scope (built-in functions, temporal types, inputNode context binding). README.md: replace the "what the slice can evaluate" summary with the core language; refresh the fixture-regeneration commands (10 dirs, ~300 cases), the pgrx test count (7), and the example queries/smoke output. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Changeset | d9a507f295bc4efa5a0ec3efe21dc238a55e2bee |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | 965b8dd042d0 |
| Children | |
| Pushlog | by timo via ssh |
modified DECISIONS.md +86 −1
| @@ -72,7 +72,7 @@ | ||
| 72 | 72 | `f64_epsilon` + `epsilon`). The feel-core fixture test honours that mode. New |
| 73 | 73 | deviations are added as registry entries, not by editing expectations by hand. |
| 74 | 74 | |
| 75 | -## ADR-7: Deliberately minimal grammar slice | |
| 75 | +## ADR-7: Deliberately minimal grammar slice (superseded by ADR-8) | |
| 76 | 76 | |
| 77 | 77 | - **Context:** The goal is to prove the dual-target architecture, not FEEL |
| 78 | 78 | completeness. |
| @@ -83,3 +83,88 @@ | ||
| 83 | 83 | - **Consequence:** Most TCK decisions in a file are (correctly) skipped and |
| 84 | 84 | reported. Widening the engine means widening the grammar and the ingestion |
| 85 | 85 | predicate together. |
| 86 | +- **Status:** Superseded by **ADR-8** — the architecture is proven, so the slice | |
| 87 | + was widened to the FEEL *core language*. The principle (widen grammar and | |
| 88 | + ingestion predicate together) still holds. | |
| 89 | + | |
| 90 | +## ADR-8: Widen the slice to the FEEL core language | |
| 91 | + | |
| 92 | +- **Context:** With the dual-target architecture proven, the next useful step is | |
| 93 | + language coverage. The reference scope is the "core language" taught in | |
| 94 | + [learn-dmn-in-15-minutes](https://learn-dmn-in-15-minutes.com/learn/the-feel-language): | |
| 95 | + operators, literals, and control flow. | |
| 96 | +- **Decision:** The grammar now covers: literals (number, string, boolean, null, | |
| 97 | + list); arithmetic (`+ - * /`, `**` left-associative, unary `-`); comparison | |
| 98 | + (`< <= > >= = !=`, `between`, interval `in`); three-valued `and`/`or`/`not`; | |
| 99 | + and control flow (`if/then/else`, `for … return`, `some/every … satisfies`) | |
| 100 | + with variable references. **Built-in functions and temporal types are still | |
| 101 | + out of scope** (see Roadmap). Numbers remain `f64` (ADR-2). `**` is | |
| 102 | + left-associative and unary `-` binds tighter than `**` (`-3 ** 2 == 9`), | |
| 103 | + matching DMN-TCK 0075. | |
| 104 | +- **Consequence:** The grammar is a full lalrpop precedence ladder (still | |
| 105 | + conflict-free). The ingestion predicate widened in lockstep (ADR-11). Function | |
| 106 | + and temporal TCK dirs are still skipped and reported. | |
| 107 | + | |
| 108 | +## ADR-9: Type errors evaluate to `null` (three-valued logic) | |
| 109 | + | |
| 110 | +- **Context:** FEEL is built on three-valued (Kleene) logic and is null-friendly: | |
| 111 | + most operations on the wrong type yield `null`, not an error. The TCK encodes | |
| 112 | + this directly (e.g. `true and 123` → null, `false = 0` → null, `100 / 0` → | |
| 113 | + null). | |
| 114 | +- **Decision:** The evaluator returns `Value::Null` for type mismatches, division | |
| 115 | + by zero, non-finite arithmetic, non-boolean logic operands, and non-boolean | |
| 116 | + `if` conditions. `FeelError` is now effectively **parse-only**; evaluation | |
| 117 | + always produces a `Value`. | |
| 118 | +- **Consequence:** This is a visible behaviour change at the wrappers — | |
| 119 | + `feel_eval('1 + true')` now returns JSON `null` instead of raising an ERROR. | |
| 120 | + It is required for the three-valued TCK cases to pass and matches the spec. | |
| 121 | + | |
| 122 | +## ADR-10: `Value` extended with String and List | |
| 123 | + | |
| 124 | +- **Context:** The core language needs strings (comparison, literals) and lists | |
| 125 | + (`for` results, list literals, `some`/`every` sources). | |
| 126 | +- **Decision:** Add `Value::String` and `Value::List`. Deliberately **no** | |
| 127 | + context/map value type yet — the slice uses list literals, not contexts, so | |
| 128 | + path access (`i.price`) is unnecessary. The boundary mapping (ADR-4) extends | |
| 129 | + accordingly: both wrappers serialise strings to JSON strings and lists to JSON | |
| 130 | + arrays, and accept the same on input (nested objects map to null). | |
| 131 | +- **Consequence:** ADR-1 (Cardinal Rule) and ADR-4 (JSON boundary) are intact; | |
| 132 | + only the wrapper mapping grew. List equality/`expected` comparison is | |
| 133 | + structural and exact (no per-element `f64_epsilon`). | |
| 134 | + | |
| 135 | +## ADR-11: Ingestion fitness is self-contained-expression detection | |
| 136 | + | |
| 137 | +- **Context:** The old predicate was two per-form regexes (integer-add, | |
| 138 | + integer-range). The widened grammar can't be captured that way. | |
| 139 | +- **Decision:** `fits_slice_grammar` now keeps a literal-expression decision iff | |
| 140 | + it is **self-contained** (no free identifiers — i.e. no input variables and no | |
| 141 | + built-in function names) **and** uses no out-of-scope syntax (temporal `@`, | |
| 142 | + context `{}`, filters, parenthesised range tests, multiple iteration contexts, | |
| 143 | + `in` forms other than a bracketed interval). It is intentionally conservative: | |
| 144 | + a borderline case is skipped rather than risk a false positive. | |
| 145 | +- **Consequence:** The engine itself remains the source of truth — the | |
| 146 | + fixture-driven test (`cargo test -p feel-core`) parses and evaluates every kept | |
| 147 | + case, so any predicate leak fails loudly and the predicate is tightened. Cases | |
| 148 | + the predicate over-skips are reported, never silently wrong. | |
| 149 | + | |
| 150 | +## Roadmap: deferred scope (recorded, not yet built) | |
| 151 | + | |
| 152 | +These were considered and deliberately deferred to keep the slice thin. Listed so | |
| 153 | +the rationale and entry points survive: | |
| 154 | + | |
| 155 | +- **Built-in functions** — numeric (`abs`, `sqrt`, `even`/`odd`, `min`/`max`, | |
| 156 | + `sum`, `count`, modulo), string (`string length`, `upper`/`lower case`, | |
| 157 | + `substring`, `contains`), list (`append`, `concatenate`, `distinct values`, | |
| 158 | + `sort`). Needs a function-call grammar production, FEEL's space-containing names | |
| 159 | + (`string length`), a builtin dispatch table, and reactivation of the many | |
| 160 | + already-self-contained `feel-*-function` TCK dirs. | |
| 161 | +- **Temporal types** — `date`/`time`/`date and time`/`duration` values, their | |
| 162 | + constructor functions, and `@"…"` literals. Largest lift; reverses ADR-5's | |
| 163 | + deferral and activates the placeholder `temporal-interval-mapping` deviation | |
| 164 | + rule. Unlocks 0007-date-time, 1115–1121, and the temporal halves of | |
| 165 | + 0100-arithmetic / 0075-exponent. | |
| 166 | +- **inputNode context binding in ingestion** — read each `<testCase>`'s | |
| 167 | + `<inputNode>` values into a per-fixture context, build a `Context` in the | |
| 168 | + fixture test, and bind it during evaluation. Unlocks the variable-using dirs | |
| 169 | + (0016-some-every, 0032-conditionals, 0012-list-functions) — the latter also | |
| 170 | + needing a `Value::Context` map type and path access. | |
modified README.md +41 −15
| @@ -13,10 +13,23 @@ | ||
| 13 | 13 | tools/ingest_tck.py DMN-TCK literal-expression -> feel-core fixture (with deviations) |
| 14 | 14 | ``` |
| 15 | 15 | |
| 16 | -What the slice can evaluate: number literals, binary `+`, interval literals | |
| 17 | -(`[a..b]`, `(a..b]`, `[a..b)`, `(a..b)`) and the `in` membership test. See | |
| 18 | -[DECISIONS.md](DECISIONS.md) for the architecture decisions and accepted | |
| 19 | -deviations (notably: numbers are `f64`, not spec `decimal128`). | |
| 16 | +What the slice can evaluate — the FEEL **core language** | |
| 17 | +([learn-dmn-in-15-minutes](https://learn-dmn-in-15-minutes.com/learn/the-feel-language)): | |
| 18 | + | |
| 19 | +- **Literals:** number, string, boolean, `null`, list (`[1, 2, 3]`, `[]`). | |
| 20 | +- **Arithmetic:** `+ - * /`, `**` (left-associative), unary `-`. Division by | |
| 21 | + zero / type errors → `null`. | |
| 22 | +- **Comparison:** `< <= > >= = !=`, `between … and …`, interval `in` | |
| 23 | + (`[a..b]`, `(a..b]`, `[a..b)`, `(a..b)`) over numbers and strings. | |
| 24 | +- **Logic:** `and` / `or` / `not(…)` with three-valued (Kleene) semantics. | |
| 25 | +- **Control flow:** `if … then … else …`, `for v in src return …`, | |
| 26 | + `some/every v in src satisfies …` (over list literals and integer ranges | |
| 27 | + `a..b`), and variable references. | |
| 28 | + | |
| 29 | +Built-in functions and temporal types are still out of scope. See | |
| 30 | +[DECISIONS.md](DECISIONS.md) for the architecture decisions, the deferred-scope | |
| 31 | +roadmap, and accepted deviations (notably: numbers are `f64`, not spec | |
| 32 | +`decimal128`; type errors evaluate to `null`). | |
| 20 | 33 | |
| 21 | 34 | ## Architecture invariant (Cardinal Rule) |
| 22 | 35 | |
| @@ -68,17 +81,27 @@ | ||
| 68 | 81 | (the `decimal-vs-f64` rule switches numeric results to epsilon comparison), and |
| 69 | 82 | prints a summary of processed / skipped cases and which deviation rules fired. |
| 70 | 83 | |
| 71 | -The two fixtures used by the test are regenerated with: | |
| 84 | +The fixtures used by the test (10 files, ~300 self-contained cases) are | |
| 85 | +regenerated by pointing the script at each TCK dir, e.g.: | |
| 72 | 86 | |
| 73 | 87 | ```sh |
| 74 | -# numeric '+' case -> comparison f64_epsilon (decimal128 vs f64 deviation) | |
| 75 | -python tools/ingest_tck.py tests/tck/TestCases/compliance-level-2/0105-feel-math \ | |
| 76 | - -o crates/feel-core/tests/fixtures/0105-feel-math.json | |
| 88 | +# numeric arithmetic -> f64_epsilon (decimal128 vs f64); type errors -> null | |
| 89 | +python tools/ingest_tck.py tests/tck/TestCases/compliance-level-3/0100-arithmetic \ | |
| 90 | + -o crates/feel-core/tests/fixtures/0100-arithmetic.json | |
| 77 | 91 | |
| 78 | -# range 'in' cases -> comparison exact (cross-checks interval inclusivity vs TCK) | |
| 92 | +# range 'in' cases -> exact (cross-checks interval inclusivity vs TCK) | |
| 79 | 93 | python tools/ingest_tck.py tests/tck/TestCases/compliance-level-3/0072-feel-in \ |
| 80 | 94 | -o crates/feel-core/tests/fixtures/0072-feel-in.json |
| 95 | + | |
| 96 | +# for-loops -> list results | |
| 97 | +python tools/ingest_tck.py tests/tck/TestCases/compliance-level-3/0084-feel-for-loops \ | |
| 98 | + -o crates/feel-core/tests/fixtures/0084-feel-for-loops.json | |
| 81 | 99 | ``` |
| 100 | + | |
| 101 | +The other ingested dirs are `0105-feel-math` (compliance-level-2), | |
| 102 | +`0064`/`0065`/`0066` (and/or/not), `0071-feel-between`, | |
| 103 | +`0075-feel-exponent`, and `0099-arithmetic-negation`. The script reports the | |
| 104 | +self-contained cases it kept and the out-of-scope ones it skipped. | |
| 82 | 105 | |
| 83 | 106 | (The `tests/tck` submodule must be checked out: `git submodule update --init`.) |
| 84 | 107 | |
| @@ -104,12 +127,13 @@ | ||
| 104 | 127 | cargo pgrx init --pg18 $(which pg_config) |
| 105 | 128 | ``` |
| 106 | 129 | |
| 107 | -Run the in-process pgrx tests — includes `feel_eval('1 + 1','{}') = '2'::jsonb`, | |
| 108 | -the range case, and the defaulted-`context` case: | |
| 130 | +Run the in-process pgrx tests — `1 + 1`, range membership, the defaulted | |
| 131 | +`context` case, plus `if/then/else`, a `for` loop returning a jsonb array, and | |
| 132 | +string comparison: | |
| 109 | 133 | |
| 110 | 134 | ```sh |
| 111 | 135 | cargo pgrx test -p feel-pg pg18 |
| 112 | -# test result: ok. 3 passed; 0 failed | |
| 136 | +# test result: ok. 6 passed; 0 failed | |
| 113 | 137 | ``` |
| 114 | 138 | |
| 115 | 139 | Compile-only against system PG headers (no pgrx init needed): |
| @@ -124,8 +148,10 @@ | ||
| 124 | 148 | cargo pgrx run -p feel-pg pg18 |
| 125 | 149 | # then in psql: |
| 126 | 150 | # CREATE EXTENSION feel_pg; |
| 127 | -# SELECT feel_eval('1 + 1'); -- 2 | |
| 128 | -# SELECT feel_eval('5 in [1..10]', '{}'); -- true | |
| 151 | +# SELECT feel_eval('1 + 1'); -- 2 | |
| 152 | +# SELECT feel_eval('5 in [1..10]', '{}'); -- true | |
| 153 | +# SELECT feel_eval('if 1 < 2 then 10 else 20'); -- 10 | |
| 154 | +# SELECT feel_eval('for i in [1,2,3] return i + 1'); -- [2, 3, 4] | |
| 129 | 155 | ``` |
| 130 | 156 | |
| 131 | 157 | Note: the pgrx extension name is `feel_pg` (underscored) — see |
| @@ -137,7 +163,7 @@ | ||
| 137 | 163 | rustup target add wasm32-unknown-unknown |
| 138 | 164 | cargo install wasm-pack --locked # if not already installed |
| 139 | 165 | wasm-pack build crates/feel-wasm --target nodejs |
| 140 | -node crates/feel-wasm/smoke.mjs # prints: 2 \n true | |
| 166 | +node crates/feel-wasm/smoke.mjs # one line per case, then "smoke test passed" | |
| 141 | 167 | ``` |
| 142 | 168 | |
| 143 | 169 | Compile-only check without wasm-pack: |