docs: record context value type, path access, and bound-input ingestion
public
docs: record context value type, path access, and bound-input ingestion ADR-12 (Value::Context + path access + context literals), ADR-11 updated for inputNode context binding and direct-literalExpression extraction, ADR-10 marked superseded, and roadmap entries for the deferred array index and the contested if-null-condition semantics. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Changeset | 663ea02a9895c6e681da5100b48e420649d6a0e2 |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | 75db96d7c13a |
| Children | |
| Pushlog | by timo via ssh |
modified DECISIONS.md +65 −16
| @@ -119,7 +119,7 @@ | ||
| 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. |
| 121 | 121 | |
| 122 | -## ADR-10: `Value` extended with String and List | |
| 122 | +## ADR-10: `Value` extended with String and List (map type superseded by ADR-12) | |
| 123 | 123 | |
| 124 | 124 | - **Context:** The core language needs strings (comparison, literals) and lists |
| 125 | 125 | (`for` results, list literals, `some`/`every` sources). |
| @@ -131,21 +131,56 @@ | ||
| 131 | 131 | - **Consequence:** ADR-1 (Cardinal Rule) and ADR-4 (JSON boundary) are intact; |
| 132 | 132 | only the wrapper mapping grew. List equality/`expected` comparison is |
| 133 | 133 | structural and exact (no per-element `f64_epsilon`). |
| 134 | - | |
| 135 | -## ADR-11: Ingestion fitness is self-contained-expression detection | |
| 134 | +- **Status:** The "no map type" part is superseded by **ADR-12** — nested-object | |
| 135 | + input and path access pulled `Value::Context` in. | |
| 136 | + | |
| 137 | +## ADR-12: `Value::Context` map type, path access, and context literals | |
| 138 | + | |
| 139 | +- **Context:** Real input is structured (nested objects), and the TCK dirs we | |
| 140 | + most wanted to unlock (e.g. 0016-some-every with `i.price`) need a context/map | |
| 141 | + value and member access. Identifiers were also ASCII-only, rejecting names | |
| 142 | + like `über`. | |
| 143 | +- **Decision:** | |
| 144 | + - Identifiers widen to Unicode letters/digits (`[\p{L}_][\p{L}\p{N}_]*`); | |
| 145 | + keyword precedence and longest-match are unaffected. | |
| 146 | + - Add `Value::Context(BTreeMap<String, Value>)` — a FEEL context. `BTreeMap` | |
| 147 | + gives structural (order-insensitive) equality for free and deterministic, | |
| 148 | + key-ordered JSON output. Contexts are unordered, so they are **not** orderable | |
| 149 | + (`<`/`>` → null); equality is three-valued and recursive like lists. | |
| 150 | + - Grammar gains a `Postfix` layer for path access `a.b.c` (binds tighter than | |
| 151 | + unary minus; `..` stays a distinct token) and a context literal | |
| 152 | + `{a: 1, b: a + 1}` (keys are a `Name` or string literal). Context-literal | |
| 153 | + entries bind **progressively** — a later entry may reference an earlier one. | |
| 154 | + - Path on a non-context, or a missing member, is `null` (ADR-9 spirit). | |
| 155 | + - Boundary mapping (ADR-4) extends in both wrappers: JSON objects ↔ | |
| 156 | + `Value::Context` (previously objects mapped to null). | |
| 157 | +- **Consequence:** ADR-1 and ADR-4 hold; only wrapper mapping and core grew. | |
| 158 | + `feel_eval('p.age', '{"p":{"age":42}}'::jsonb)` now returns `42`, and | |
| 159 | + `feel_eval('{a:1}')` returns a jsonb object. `if` semantics are **unchanged** | |
| 160 | + (a non-boolean/null condition still → null; see Roadmap). | |
| 161 | + | |
| 162 | +## ADR-11: Ingestion fitness is slice-grammar detection with bound inputs | |
| 136 | 163 | |
| 137 | 164 | - **Context:** The old predicate was two per-form regexes (integer-add, |
| 138 | 165 | 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. | |
| 166 | +- **Decision:** `fits_slice_grammar(expression, input_names)` keeps a | |
| 167 | + literal-expression decision iff every name in it is acceptable — a keyword, a | |
| 168 | + for/some/every loop variable, a context-literal key, a member access | |
| 169 | + (`.field`), or one of the case's captured `<inputNode>` names — **and** it uses | |
| 170 | + no out-of-scope syntax (temporal `@`, filters, parenthesised range tests, | |
| 171 | + multiple iteration contexts, `in` forms other than a bracketed interval). | |
| 172 | + Context literals `{}` are now in scope (ADR-12). Each case's `<inputNode>` | |
| 173 | + values are captured into a `context` object and bound during evaluation, so | |
| 174 | + input-reading expressions are now ingestible. `parse_decisions` only accepts a | |
| 175 | + decision whose **direct** logic is a `<literalExpression>` (relations/contexts/ | |
| 176 | + decision tables are skipped, not mined for inner cells). It is intentionally | |
| 177 | + conservative: a borderline case is skipped rather than risk a false positive. | |
| 145 | 178 | - **Consequence:** The engine itself remains the source of truth — the |
| 146 | 179 | 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. | |
| 180 | + case against its bound context, so any predicate leak fails loudly and the | |
| 181 | + predicate is tightened. Cases the predicate over-skips are reported, never | |
| 182 | + silently wrong. (This loop already caught a relation decision wrongly mined as | |
| 183 | + `"widget"`, and the contested 0032 `if`-null case — see Roadmap.) | |
| 149 | 184 | |
| 150 | 185 | ## Roadmap: deferred scope (recorded, not yet built) |
| 151 | 186 | |
| @@ -163,8 +198,22 @@ | ||
| 163 | 198 | deferral and activates the placeholder `temporal-interval-mapping` deviation |
| 164 | 199 | rule. Unlocks 0007-date-time, 1115–1121, and the temporal halves of |
| 165 | 200 | 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. | |
| 201 | +- **inputNode context binding in ingestion** — *done (ADR-11/ADR-12).* Each | |
| 202 | + `<testCase>`'s `<inputNode>` values are captured into a per-fixture `context`, | |
| 203 | + 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. | |
| 207 | + | |
| 208 | +- **Array index access** — FEEL `list[n]` is 1-based, supports negative-from-end | |
| 209 | + indexing, and is `null` out of range; the same `[...]` syntax is also a boolean | |
| 210 | + filter `list[predicate]`. Deferred (chosen this round). Implement later as a | |
| 211 | + postfix operator on the `Postfix` layer (alongside path access); the grammar | |
| 212 | + 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. | |