# Roadmap — deferred FEEL coverage

Forward-looking companion to the *Roadmap: deferred scope* section of
[DECISIONS.md](DECISIONS.md) (which records the rationale for everything already
deferred or done). This file lists the **next** concrete increments, each with its
entry points and the TCK coverage it unlocks, so a follow-up can pick one up
without re-deriving the analysis.

Coverage figures are case counts from `tools/ingest_tck.py` over the DMN-TCK
compliance-level-3 suites. Today the fixture suite is **3145 cases / 110 files**
(`cargo test -p feel-core --test fixtures_test -- --nocapture`).

---

## Tier 3 — First-class range values

**Status:** ✅ **shipped.** `Value::Range` + range literals in value position, the
`range(string)` built-in, range equality, `instance of range<T>`, `in`
range-membership, and the 13 §10.3.4.6 relation built-ins all landed (commits
"first-class range values" → "range/point relation builtins"). **Realised payoff:**
`1156-range-function` 41 cases ingested, `0068-feel-equality` +3 (range equality),
`0072-feel-in` +8 (range membership) — suite 2598 → 2650; plus `1130-feel-interval`'s
132-case relation truth table as a unit test (its decisions are boxed contexts the
ingester does not read). **Comma-list-of-tests `in` now also shipped (ADR-28)**, and
**reverse-bracket interval literals (`]a..b]` / `[a..b[`) + range properties (`.start`
/ `.end` / `.start included` / `.end included`) now shipped (ADR-29)** — see below.
**Unbounded omitted-endpoint ranges (`[1..)` / `(..10]`, distinct from a `null`
bound) now shipped (ADR-31)** — see below. **The opaque comparison-test *value*
(`(< 10)` in value position) now shipped (ADR-32)** — see below. **Nothing
range-shaped remains deferred:** the ADR-27 → ADR-32 range arc is closed.

The grammar work needed **no LALR/LR rewrite**: a range literal is a `Primary` that
shares its `"[" Sum` / `"(" Sum` prefix with the list literal / grouping and branches
on `..` vs `]`/`,`/`)` — LR(1)-clean, proven by build.rs's no-conflict gate. The `in`
RHS takes a bare endpoint expression (`unary_test_from_expr` routes a written interval
to the dedicated interval test, anything else to an `Endpoint` evaluated as equality or
range membership). The historical analysis below is retained for the deferred forms.

### What it is (original analysis)

DMN ranges (`[1..10]`, `(a..b)`) are currently only a *test* on the right of `in`
— they have no value of their own. Full FEEL makes a range a first-class value:

- the `range("[1..10]")` built-in parses a string into a range value
  (`range("[1..10]") instance of range<number>`);
- ranges compare with `=` and the range relations (`before`, `after`, `meets`,
  `overlaps`, `during`, `coincides`, … — DMN §10.3.4.6);
- a range literal `[1..10]` can appear in value position (e.g. inside a list:
  `x in [[2..4], [1..3]]` is "x in range [2..4] **or** range [1..3]").

### Entry points
- **`Value`** ([crates/feel-core/src/value.rs](crates/feel-core/src/value.rs)) —
  add a `Range` variant. Likely `Range(Box<Range>)` where `Range { start, end,
  start_open, end_open }` holds two endpoint `Value`s (any orderable type) plus
  openness. Watch the 40-byte `Value` size test (`Box` the payload).
- **AST / grammar** — a range *literal* in value position. The existing
  `Interval` AST node + the `in`-RHS grammar already parse `[a..b]`; the work is
  allowing a range literal as a `Primary` (and resolving the resulting `[`-literal
  vs list-literal vs filter-subscript ambiguity — the same LR(1) bracket problem
  noted under the `in` unary-test forms below).
- **Eval** — construct a `Value::Range`; equality via the derived/`feel_order`
  comparison; the range-relation built-ins in
  [crates/feel-core/src/builtins.rs](crates/feel-core/src/builtins.rs).
- **`range(string)` built-in** — parse the bracketed string (reuse the
  `@"…"`/interval parsing in [temporal.rs](crates/feel-core/src/temporal.rs) and
  the `Interval` grammar) into a `Value::Range`; add `range` to `_BUILTINS` in the
  ingester and to `builtin_param_names`.
- **`instance of range<T>`** — already representable: `FeelType::Range(Box<…>)`
  exists ([ast.rs](crates/feel-core/src/ast.rs)); wire `Value::Range` into the
  `instance of` check in [eval.rs](crates/feel-core/src/eval.rs).
- **Ingester** — drop the relevant skips and re-ingest `1156-range-function`,
  `0068-feel-equality`; re-ingest `0072-feel-in` to gain the list-of-intervals
  cases.

### Risks
- Endpoint typing: ranges of number / string / date / time / date-and-time /
  duration must all compare. Reuse `feel_order`.
- The `[`-literal ambiguity (range literal vs list literal vs `x[…]` filter) is
  the crux — see the bracket note below; it may force inlining part of the
  expression grammar or a small disambiguation pass.

---

## `in` unary-test list forms

**Status: ✅ comma-list-of-tests shipped (ADR-28).** The comma-list / paren-list /
one-element-paren-test forms — `x in [1,2,3]`, `x in (false,true)`,
`x in (1,<5,>=10)`, `x in [[2..4],[1..3]]`, `x in (=10)` / `(!=10)` — now parse as
positive unary tests and OR-fold. With the earlier comparison tests, single intervals,
bare equality and range membership (ADR-27), **`0072-feel-in` rose 255 → 325 cases**
(two skipped: one cross-type, one pre-existing). Suite **2650 → 2720 (+70)**.

The fix was **no** hand-written parser and **no** `Tier 3`-style inlining of the value
brackets: the `in`-RHS is its *own* grammatical category, so it got its own test-mode
productions plus a bracket-free `NbSum` chain for the bare-endpoint branch. Because
`NbSum` never *starts* with `[`/`(`, the `in [` / `in (` state has exactly one bracket
production (test-list / interval) instead of two competing ones (test-list vs. the
value `List`/`RangeLit`), so the interval-vs-list split is a clean first-element
factoring (`..` vs `,`/`]`/`)`) — LR(1)-clean, gate green on the first build.

### What the TCK measurement reshaped (don't re-derive these)

Two forms that looked like "next increments" were **retired by reading the TCK**, not
deferred on suspicion:

- **Null endpoint is not ±∞.** `5 in [null..10]` (and `(null..10]`, `[1..null)`, …)
  expect **null**, not membership-true. A null bound is "unknown ⇒ unknown result",
  which feel-core's three-valued `range_contains` already yields — so these five 0072
  cases are *already green*. There is **no** ±∞ membership change to make.
- **`(< 10)` is an opaque unary-test value, not a promoted range.** 0068 says
  `(< 10) = (null..10)` and `(= 10) = [10..10]` are **false**, while `(< 10) = (< 10)`,
  `(= 10) = (= 10)`, `(!= 10) = (!= 10)` are **true**. So a parenthesised comparison
  test in *value* position equals an identical test but is never equal to a `Range` —
  the "desugar to range" model is wrong. ✅ **Now shipped (ADR-32):** an opaque
  `Value::UnaryTestVal` variant with exactly that reflexive, range-incompatible equality.
  (The *membership* `in`-position forms `x in (=10)` / `(!=10)` already worked via ADR-28.)
- **Cross-type `=` skip.** `true in [false, 2, 3]` expects `false`; feel-core returns
  error-null for a non-null type mismatch under `=` (ADR-14), so it OR-folds to null.
  One 0072 case skipped (`CROSS_TYPE_EQUALITY_SKIPS`); aligning cross-type equality
  with the TCK's `false` is a separate ADR-level decision.

### Shipped — reverse-bracket intervals & range properties (ADR-29)

Exactly the two independent surgeries forecast below, plus the property handler:

- **Reverse-OPEN `]a..b]`** — the token-role case, resolved in the lexer as predicted (a
  "stateful logos pass"): a post-pass `mark_reverse_open` retags an *opening* `]` to a
  distinct `RBracketOpen` terminal. The role test is value-expected position + a forward
  `..` scan at bracket depth — no in-grammar fork, no LR conflict.
- **Reverse-CLOSE `[a..b[`** — the filter-free high-endpoint nonterminal `Endpoint` (the
  `Sum` chain minus the `Postfix [Expr]` filter), so a trailing `[` can only be the close.
  Pure grammar. Composes with reverse-OPEN: `]a..b[` ≡ `(a..b)`.
- **Range properties** `.start` / `.end` / `.start included` / `.end included` — a
  `Value::Range` arm in `member_access`. `0074-feel-properties`'s `range_001`–`005`
  decisions (interval-range properties) are now **ingested** as boxed-context fixture
  cases (+5; `0074` suite 43 → 48). `range_006`–`011` (the comparison-test values
  `(<10)` etc., ADR-32) followed in **ADR-33** — a `Value::UnaryTestVal` arm in both
  `member_access` and `instance of range<T>` (+5; `0074` 48 → 53); the
  `range_properties` unit test covers all bracket forms *and* the six operator forms
  as a fast regression. `1130-feel-interval`'s 14 Allen-relation
  context decisions are now also **ingested** (+14 fixture cases, 132 boolean
  assertions covered). The ingester relaxation (reverse-bracket `..` scan +
  multi-word `.member` blanking) did unlock **+8** related cases in
  `0068`/`1156`/`0074` (suite → 2728).

### Done

- **`not(tests)` negation** — ✅ **shipped (ADR-30).** `x in not([1,2,3])` / `not(<5)` /
  `not([1..10])`. The collision with the boolean `not(…)` built-in was resolved exactly as
  foreseen: `NbPrimary` drops the boolean `"not" "(" Expr ")"` (so the bare `in`-RHS branch
  never starts with `not`) and a dedicated `InRhs → "not" "(" Comma<UnaryTestElem> ")"`
  production carries it into a new `UnaryTest::Not(Vec<UnaryTest>)` — OR-folded then negated
  three-valued (`not3`). LR(1)-clean (build.rs gate). The TCK has no `in not(…)` case, so it
  ships unit-tested (`membership_not_test_negation`) with no fixture change.

### Shipped: unbounded omitted-endpoint ranges (ADR-31)

`[1..)` / `(..10]` — an omitted endpoint is `±∞`, kept **distinct** from a present `null`
bound (`(..10]` is a definite bound; `[null..10]` stays three-valued unknown). Per FEEL
grammar rule 66 an omitted endpoint requires an **open** bracket on that side and at most
one endpoint may be omitted, so `[1..]` / `[..10]` (closed, no value) and `(..)` (both
omitted) are parse errors — the same rule the `range()` string obeys, so there is no
literal-vs-`range()` surprise. AST `Interval` and value `RangeVal` endpoints became
`Option<…>` (`None` = unbounded); `Value` stays 40 bytes (`RangeVal` is boxed). Grammar is
LR(1)-clean: the closed opener `"["` keeps its low endpoint mandatory; each open opener
`"("`/`]` splits present-low (any `HiEnd`) / omitted-low (bounded high) — which forbids
`(..)`; `HiEnd`'s unbounded form is the open `")"` only. Proven by the build.rs gate. An
unbounded side's openness is ignored (it has no member), and the Allen relations view
operands through a `NegInf`/`Val`/`PosInf` bound. `range()` follows the same rule 66 —
`range("[2..)")` ≡ `>=2`, while `range("[..2]")`/`range("[1..]")` are null (DMN-TCK 1156
`004_e`/`004_f`); the closed loop needed no fixture change. Exercised by the
`unbounded_ranges` and `unbounded_closed_bracket_is_a_parse_error` unit tests.

### Shipped: opaque comparison-test value (ADR-32)

`(< 10)` / `(= 10)` / `(!= 10)` in **value** position — exactly as forecast, grammar-clean
with a single new `Primary` alternative `"(" CmpOp Sum ")"` (no `CmpOp` token in
`FIRST(Expr)`, so no clash with grouping or the range form; build.rs gate green). It is an
**opaque** `Value::UnaryTestVal { op, endpoint }` (boxed; `Value` stays 40 bytes), **not** a
promoted range: equality is structural and reflexive (`(<10) = (<10)` → true) but
range-incompatible (`(<10) = (null..10)`, `(=10) = [10..10]` → false) — the measured 0068
semantics that falsified the desugar hypothesis (ADR-28's `range_006` question, now resolved).
It has no order, no host type, and conforms to no `instance of` type but `Any`; `string(...)`
echoes the written form. The ingester's value-position reject now fires only for a *bracket*-led
comparison (`[< 10]`, no production) not after `in`. Re-ingested `0068-feel-equality`
**101 → 109** (the eight `range_006`/`range_007…012` cases). Exercised by the
`value_position_comparison_test` unit test (incl. an `in`-position regression block).

### Shipped: FEEL lambda / typed params + first-class built-ins (ADR-35/36)

Two increments on top of ADR-23's user-defined-function foundation.
**ADR-35** adds typed formal parameters (`function (a: number) body`, FEEL rule 56)
by extending the grammar's `FnDef` production with a `FormalParam` rule that parses
`name` or `name: Type` via the existing `InstanceType` nonterminal — the annotation
is discarded, only the name flows into `Expr::FnDef`. **ADR-36** makes bare built-in
names (e.g. `abs`, `sqrt`) evaluate to `Value::Function(Func::Builtin(name))` as
first-class values, enabling them to be passed as arguments and invoked through closure
parameters. Together these unlock DMN-TCK `0092-feel-lambda` testCases 001–014 and 016
(015 is TCK-commented-out; 017/018 needed `sort(list, function)` — shipped in ADR-37).
Fixture is hand-written (`crates/feel-core/tests/fixtures/0092-feel-lambda.json`),
mirroring the 0030 pattern. **Suite 2880 → 2896**.

### Shipped: Java-style FEEL comments (ADR-34)

Two logos skip patterns on a single `Comment` variant (`//[^\n]*` with
`allow_greedy = true`, and `/\*([^*]|\*[^/])*\*/`) strip both comment forms at
lexer pass 1 — before the `instance of` / name-join / reverse-bracket post-passes.
`fits_slice_grammar` receives a `strip_comments()` pre-pass so comment words are
never mistaken for free identifiers. **Unlocked:** `0073-feel-comments` +3 cases.
Suite **2887 → 2890**.

### Shipped: range properties + `instance of` for the comparison-test value (ADR-33)

The other half of §10.3.2.7 that ADR-32 left open. The spec calls `(< 10)` *"a typed
instance of the range type"* (Table 42): it **has** range properties (the operator's
missing endpoint is `null` + not included; the present endpoint's inclusivity follows
the operator) and it **is** a `range<T>`. ADR-32 had declared it typeless and gave it no
member access — a §10.3.2.7 deviation. ADR-33 adds a `Value::UnaryTestVal` arm to both
`member_access` (`eval.rs`) and `value_conforms_to` (`types.rs`), derived from the boxed
`{ op, endpoint }`, **without** touching its opaque equality: `(=10).start`/`.end` are
`10`/`10` though `(=10) ≠ [10..10]`, and `(<10) instance of range<number>` is true though
`(<10) = (..10)` is false — properties/conformance and equality are independent facets,
exactly as 0068 + 0074 jointly demand. Re-ingested `0074-feel-properties` `range_006`/
`007`/`009`/`010`/`011` (the five cases ADR-29's proviso had parked in
`OUT_OF_SCOPE_EXPR_SKIPS`); `0074` **48 → 53**, suite **2872 → 2877**. Exercised by the
extended `range_properties` unit test.

---

### Shipped: higher-order `sort` + matching `list replace` (ADR-37)

An `Applier` trait threads the evaluator's function-apply capability (invoke +
recursion-depth guard) into `builtins::call`, enabling `sort(list, precedes)` and
the matching form of `list replace(list, match, newItem)`. Stable insertion sort for
`sort`; dispatch on `Value::Function` in `args[1]` for `list replace`. Ingester
extended: `"sort"` added to `_BUILTINS`; `fits_slice_grammar` blanks untyped
`function(...)` literals and adds their params to the allowed-name set, enabling
auto-ingest of `0013-sort` and the 6 previously-skipped function-form cases in
`1155-list-replace-function`. `0092-feel-lambda` testCases 017/018 hand-written.
**Suite 2896 → 2907.**

## Smaller, independent deferrals

- **General invocation of a non-function → null** ✅ **shipped (ADR-38).**
  Literal callees (`null()`, `123()`, `"abs"(-1)`, `@"date"()`, `true()`, `false()`)
  and unknown names (`non_existing_function()`) all yield null per DMN §10.3.2.13.2.
  Full `1131-feel-function-invocation` suite now passes (8/8).
  Still deferred: invoking an arbitrary *expression* that holds a function —
  `var(args)` or `lib.fn(args)` — would require widening the grammar beyond literal
  callees and reintroduces the `Name`-vs-`Var` dispatch ambiguity.
- **Target-type coercion** (§10.3.2.9.4) ✅ **shipped (ADR-39).**
  `0082-feel-coercion` — 31 of 36 active cases ingested; the 5 skips are all
  `decisionService_*` invocations requiring the DRG layer. Four implicit conversion
  rules implemented in `coerce()` (`types.rs`): null → null; from-singleton-list
  (ONE level); to-singleton-list; conforms-to. Typed formal parameters now flow
  all the way through `FnDef` → `Closure` → `bind_params` where an arg that
  doesn't conform to its declared type coerces the call result to null. BKMs
  inlined as function literals in the ingester. **Suite 2915 → 2946.**
- **Leading-dot & exponent number literals (§10.3.2.3.1 / grammar rule 35)** ✅ **shipped (ADR-40).**
  `0100/0101/0102-feel-constants` (compliance-level-2) — 12 cases: 2 boolean, 6
  number, 4 string. The only engine gap was the lexer's `Num` regex, which did not
  allow a leading-dot mantissa (`.872`) or an exponent (`1.2e3`); widened to full
  rule-35 coverage. No ingester or grammar change needed — `fits_slice_grammar`
  already admitted these expressions. **Suite 2946 → 2958.**
- **Structured-input + path access — `0008-LX-arithmetic`** ✅ **shipped (ADR-41).**
  `0008-LX-arithmetic` (compliance-level-2) — 3 cases: loan payment formula
  `(loan.principal*loan.rate/12)/(1-(1+loan.rate/12)**-loan.termMonths)` with
  a structured `tLoan` context input. No engine or ingester change was needed —
  `<component>` nesting, `Value::Context` binding, and path access were already
  fully operational. **Suite 2958 → 2961.**
- **BKM invocation + arithmetic — `0009-invocation-arithmetic`** ✅ **shipped (ADR-42).**
  `0009-invocation-arithmetic` (compliance-level-2) — 3 cases: BKM-backed decision
  `PMT(Loan.amount, Loan.rate, Loan.term)+fee` with `PMT` inlined via the `__result`
  wrapper. First suite combining BKM inlining with positional invocation and arithmetic
  (canonical §10.6.5 "Calculation" pattern). No engine or ingester change needed.
  **Suite 2961 → 2964.**
- **Deferred quick-win suites — `0005`, `0016`, `0032`, `0034`, `0070`** ✅ **shipped (ADR-45).**
  Five suites ingested without engine changes: literal BKM invocation (0005, 3 cases),
  some/every over context list (0016, 2), if/then/else with date input (0032, 6),
  DRG leaf decisions (0034, 2), and the full `instance of` truth table (0070, 129).
  Also added `DECIMAL_LIST_SKIPS` for `0003-iteration` (list-of-f64, no epsilon mode).
  **Suite 3003 → 3145.**
- **Boxed-expression element forms — `1150–1154` & `1161`** ✅ **shipped (ADR-44).**
  Six compliance-level-3 suites covering DMN 1.5 `<conditional>`, `<filter>`,
  `<for>/<some>/<every>`, and `<list>` element forms — 18 cases across 6 files.
  Ingester extended with four new parsers; engine needed no changes (all constructs
  already implemented). Three deviation-skips documented (`BOXED_PREDICATE_DEVIATION_SKIPS`,
  ADR-24 / ADR-13/14). Also fixed a latent `parse_value_elem` bug where an explicit
  `xsi:type="xsd:string"` with text `"true"` was mis-parsed as boolean.
  **Suite 2985 → 3003.**
- **Emoji / non-XID names** as bare context keys (`{🐎: "bar"}`,
  `0083-feel-unicode`) — the lexer accepts XID identifiers only; 2 cases skipped
  (`NON_XID_NAME_SKIPS`).
- **Singleton-list ↔ scalar coercion** at decision/argument boundaries
  (`0021-singleton-list`, §10.3.2.9.4) — a DMN typing rule, not an expression
  rule; `OUT_OF_SCOPE_EXPR_SKIPS`.
- **Decision-table / DRG semantics** (decision services) — out of scope for a
  FEEL *expression* engine; 5 `decisionService_*` cases in `0082` skipped.
