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>
| Changeset | 7ca50f8bf17e5b33d49171a9f585ca1bf7de0c8f |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | 325251e27ae8 |
| Children | |
| Pushlog | by timo via ssh |
modified DECISIONS.md +30 −13
| @@ -112,9 +112,9 @@ | ||
| 112 | 112 | this directly (e.g. `true and 123` → null, `false = 0` → null, `100 / 0` → |
| 113 | 113 | null). |
| 114 | 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`. | |
| 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.) | |
| 118 | 118 | - **Consequence:** This is a visible behaviour change at the wrappers — |
| 119 | 119 | `feel_eval('1 + true')` now returns JSON `null` instead of raising an ERROR. |
| 120 | 120 | It is required for the three-valued TCK cases to pass and matches the spec. |
| @@ -182,6 +182,30 @@ | ||
| 182 | 182 | silently wrong. (This loop already caught a relation decision wrongly mined as |
| 183 | 183 | `"widget"`, and the contested 0032 `if`-null case — see Roadmap.) |
| 184 | 184 | |
| 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 | + | |
| 185 | 209 | ## Roadmap: deferred scope (recorded, not yet built) |
| 186 | 210 | |
| 187 | 211 | These were considered and deliberately deferred to keep the slice thin. Listed so |
| @@ -201,19 +225,12 @@ | ||
| 201 | 225 | - **inputNode context binding in ingestion** — *done (ADR-11/ADR-12).* Each |
| 202 | 226 | `<testCase>`'s `<inputNode>` values are captured into a per-fixture `context`, |
| 203 | 227 | 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). | |
| 207 | 231 | |
| 208 | 232 | - **Array index access** — FEEL `list[n]` is 1-based, supports negative-from-end |
| 209 | 233 | indexing, and is `null` out of range; the same `[...]` syntax is also a boolean |
| 210 | 234 | filter `list[predicate]`. Deferred (chosen this round). Implement later as a |
| 211 | 235 | postfix operator on the `Postfix` layer (alongside path access); the grammar |
| 212 | 236 | 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. | |