Public repository: timo / feel

Reader

An interpreter of FEEL, written in Rust, with integrations for PostgreSQL, WASM, Lua, and Python.

docs: record ADR-13 (if condition semantics) and unlock 0032

public

docs: record ADR-13 (if condition semantics) and unlock 0032

ADR-13 documents the null-vs-wrong-type if-condition synthesis, ADR-9 gains a
cross-reference, and the roadmap notes 0032-conditionals as unlocked.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Changeset7ca50f8bf17e5b33d49171a9f585ca1bf7de0c8f
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parents325251e27ae8
Children
Pushlog
by timo via ssh

modified DECISIONS.md +30 −13

@@ -112,9 +112,9 @@
112112
   this directly (e.g. `true and 123` → null, `false = 0` → null, `100 / 0` →
113113
   null).
114114
 - **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`.
115
+  by zero, non-finite arithmetic, non-boolean logic operands, and wrong-TYPE `if`
116
+  conditions. `FeelError` is now effectively **parse-only**; evaluation always
117
+  produces a `Value`. (A *null* `if` condition is a special case — see ADR-13.)
118118
 - **Consequence:** This is a visible behaviour change at the wrappers —
119119
   `feel_eval('1 + true')` now returns JSON `null` instead of raising an ERROR.
120120
   It is required for the three-valued TCK cases to pass and matches the spec.
@@ -182,6 +182,30 @@
182182
   silently wrong. (This loop already caught a relation decision wrongly mined as
183183
   `"widget"`, and the contested 0032 `if`-null case — see Roadmap.)
184184
 
185
+## ADR-13: `if` distinguishes a null condition from a wrong-type one
186
+
187
+- **Context:** Enabling input-bound TCK ingestion (ADR-11/12) surfaced
188
+  0032-conditionals, where `if bool then … else …` with `bool = null` expects the
189
+  **else** branch (→ 90). Our `if` (ADR-9) returned `null` for any non-boolean
190
+  condition, matching Camunda/feel-scala — which *deliberately* deviates from the
191
+  TCK, arguing a mistyped condition should not be silently swallowed. The OMG DMN
192
+  reference (jDMN, validating the TCK) instead treats `if` as
193
+  `condition == true ? then : else`, so false/null/non-boolean all go to else.
194
+- **Decision:** Adopt a synthesis that is TCK-compliant *and* honours Camunda's
195
+  argument, keyed on the *kind* of condition:
196
+  - `true` → then; `false` → else.
197
+  - `null` → **else** — `null` is a legitimate FEEL value meaning "not true", and
198
+    the TCK requires it. (This is the one point where we must diverge from
199
+    Camunda to stay TCK-compliant.)
200
+  - any other type (number, string, list, context) → **null** — a genuine type
201
+    error, kept visible per ADR-9. This honours Camunda's concern. The TCK never
202
+    tests a wrong-type `if` condition, so nothing forces us off the safe path
203
+    here; we knowingly diverge from jDMN only on this untested input.
204
+- **Consequence:** 0032-conditionals (cases 001–003) ingests and passes;
205
+  `if 5 then 1 else 2` and `if "x" then 1 else 2` stay `null` (existing tests
206
+  unchanged). The divergence from jDMN is confined to untested wrong-type
207
+  conditions and is documented rather than silent.
208
+
185209
 ## Roadmap: deferred scope (recorded, not yet built)
186210
 
187211
 These were considered and deliberately deferred to keep the slice thin. Listed so
@@ -201,19 +225,12 @@
201225
 - **inputNode context binding in ingestion** — *done (ADR-11/ADR-12).* Each
202226
   `<testCase>`'s `<inputNode>` values are captured into a per-fixture `context`,
203227
   built into a `Context` in the fixture test and bound during evaluation.
204
-  Unlocked 0016-some-every (path access over a list of contexts). 0012-list-
205
-  functions stays skipped (all list built-ins). 0032-conditionals is held back —
206
-  see below.
228
+  Unlocked 0016-some-every (path access over a list of contexts) and
229
+  0032-conditionals (cases 001–003, after the `if`-semantics decision in ADR-13).
230
+  0012-list-functions stays skipped (all list built-ins).
207231
 
208232
 - **Array index access** — FEEL `list[n]` is 1-based, supports negative-from-end
209233
   indexing, and is `null` out of range; the same `[...]` syntax is also a boolean
210234
   filter `list[predicate]`. Deferred (chosen this round). Implement later as a
211235
   postfix operator on the `Postfix` layer (alongside path access); the grammar
212236
   conflict with list literals / interval `in [a..b]` must be checked deliberately.
213
-
214
-- **`if` with a non-boolean / null condition** — the engine returns `null`
215
-  (ADR-9), matching Camunda/feel-scala; the DMN-TCK reference (0032-conditionals,
216
-  null condition) instead takes the `else` branch (→ 90). This is genuinely
217
-  contested between engines and orthogonal to the context work, so 0032 is not
218
-  ingested yet and the strict null-propagation semantics is kept. Revisit as its
219
-  own decision.