Public repository: timo / feel

Reader

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

docs: ADR-31 + ROADMAP — unbounded omitted-endpoint ranges

public

docs: ADR-31 + ROADMAP — unbounded omitted-endpoint ranges

Record the unbounded-range decision (Option endpoints; ±∞ ≠ a `null` bound;
openness ignored on an unbounded side; `range()` stays strict per TCK 1156) and
mark the feature shipped in the roadmap, leaving only the value-position
comparison-test `(< 10)` deferred.

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

modified DECISIONS.md +53 −0

@@ -1078,6 +1078,59 @@
10781078
   purely semantic-value work, not grammar: unbounded omitted-endpoint ranges `[1..]` /
10791079
   `[..10]` and the opaque comparison-test value `(< 10)` in value position (both ADR-29).
10801080
 
1081
+## ADR-31: Unbounded omitted-endpoint ranges — `[1..]` / `[..10]` (DMN §10.3.4.6)
1082
+
1083
+- **Context:** the most invasive of the three range deferrals (ADR-27 → ADR-30). A range
1084
+  endpoint may be *omitted*, denoting an **unbounded** bound, `±∞`: `[1..]` is everything
1085
+  `≥ 1`, `[..10]` everything `≤ 10`, `[..]` everything. This is **semantically distinct**
1086
+  from a *present* `null` endpoint: `[null..10]` keeps the three-valued "unknown" membership
1087
+  (`5 in [null..10]` ⇒ null, per DMN-TCK 0072), while `[..10]` is a definite bound
1088
+  (`5 in [..10]` ⇒ true). The two must never collapse to the same representation. Unlike the
1089
+  earlier range work this ripples through *every* layer — AST, value, eval, builtins,
1090
+  grammar, the host wrappers — because both endpoints become optional everywhere.
1091
+- **Decision:** model an omitted endpoint as `None`, kept rigorously apart from `Some(null)`.
1092
+  - **AST `Interval.start`/`.end` → `Option<Box<Expr>>`; value `RangeVal.start`/`.end` →
1093
+    `Option<Value>`** (`None` = unbounded). `RangeVal` is still boxed behind
1094
+    `Value::Range(Box<RangeVal>)`, so `Value` stays 40 bytes (the `value_size_did_not_grow`
1095
+    guard is untouched). A present `null` bound evaluates to `Some(Value::Null)`; only a
1096
+    *syntactically* omitted endpoint is `None`.
1097
+  - **Openness of an unbounded side is meaningless and ignored.** `±∞` is never a member, so
1098
+    the bracket written there carries no semantics. Equality compares the openness flag only
1099
+    where a side is *bounded* (`[1..]` = `[1..)`, both `[1, +∞)`; but `[1..]` ≠ `[1..10]`, and
1100
+    `[..10]` ≠ `[null..10]`); `.start included`/`.end included` of an unbounded side is
1101
+    `false`; `.start`/`.end` of it is `null`. The flag is *stored* as written only so
1102
+    `string([1..])` can echo the user's bracket.
1103
+  - **Eval.** `range_contains` takes `Option<&Value>` per side — a `None` side is satisfied
1104
+    unconditionally (so `5 in [1..]`/`5 in [..10]` are true), a `Some(null)` side still goes
1105
+    three-valued. `instance of range<T>` treats an unbounded side as vacuously conforming
1106
+    (the bounded side types the range, like a null/empty slot). The §10.3.4.6 Allen relations
1107
+    view each operand through a `Bound { NegInf, Val, PosInf }` (an omitted lower = `NegInf`,
1108
+    upper = `PosInf`); `±∞` compares below/above every value and two same-sign `±∞` are equal,
1109
+    so `before([..5],[10..])`, `includes([..],[3..7])`, `coincides([..5],(..5])` need no
1110
+    further special-casing.
1111
+  - **Grammar (LR(1)-clean, build.rs gate).** Endpoints become optional via `Sum?` for the
1112
+    low side (`..` ∉ FIRST(Sum), and `[` after the opener is still the empty `List`) and a
1113
+    new `HiEnd` nonterminal for the high side: `Endpoint IntervalEnd` (bounded) **or** a bare
1114
+    `]`/`)` (unbounded). The unbounded-high case deliberately omits the reverse-close `[`
1115
+    (`[` ∈ FIRST(Endpoint), so after `..` a `[` always shifts into a nested-endpoint parse);
1116
+    the rare `[1..[` is simply spelt `[1..)`. Reused verbatim by `RangeLit` (value position)
1117
+    and the `InRhs` interval *tests*.
1118
+  - **`range()` string builtin stays STRICT — it rejects an omitted endpoint.** This is the
1119
+    one surprise: DMN-TCK 1156 `004_e`/`004_f` make `range("[..2]")` and `range("[1..]")`
1120
+    **null**. So the unbounded feature lives in *literal/value* position and membership, but
1121
+    the `range()` function still requires both endpoints present (the closed loop is ground
1122
+    truth; the function-vs-literal asymmetry is the TCK's, not ours).
1123
+- **Tests:** the unit test `unbounded_ranges` covers membership (incl. the `[..10]` ≠
1124
+  `[null..10]` distinction both ways), value-position equality, range properties, `instance
1125
+  of`, `string(...)` rendering, and the Allen relations over unbounded operands.
1126
+  `range_builtin` keeps `range("[..2]")`/`range("[1..]")` as null cases (matching 1156). The
1127
+  ingester's structural `..`-scan already admitted unbounded forms (the `..` still sits inside
1128
+  its bracket group); 0072 / 1156 re-ingest produced **no** fixture change, and the closed
1129
+  loop (`fixtures_test`) stays green.
1130
+- **Consequence:** every §10.3.4.6 range *grammar* form is now in. The only remaining range
1131
+  deferral is the opaque comparison-test *value* `(< 10)` in value position (ADR-28's measured
1132
+  semantics; needs a new `Value` variant), which is unrelated to endpoints.
1133
+
10811134
 ## Adding a wrapper — the host-binding contract
10821135
 
10831136
 The four wrappers (feel-pg, feel-wasm, feel-py, planned feel-lua) implement the same

modified ROADMAP.md +20 −9

@@ -24,8 +24,10 @@
2424
 ingester does not read). **Comma-list-of-tests `in` now also shipped (ADR-28)**, and
2525
 **reverse-bracket interval literals (`]a..b]` / `[a..b[`) + range properties (`.start`
2626
 / `.end` / `.start included` / `.end included`) now shipped (ADR-29)** — see below.
27
-**Still deferred:** unbounded ranges (`[1..]`, `[..10]`) and the comparison-test-as-range
28
-*value* (`(< 10)` in value position) — both reshaped by a TCK measurement (below).
27
+**Unbounded omitted-endpoint ranges (`[1..]` / `[..10]` / `[..]`, distinct from a `null`
28
+bound) now shipped (ADR-31)** — see below. **Still deferred:** only the
29
+comparison-test-as-range *value* (`(< 10)` in value position) — reshaped by a TCK
30
+measurement (below).
2931
 
3032
 The grammar work needed **no LALR/LR rewrite**: a range literal is a `Primary` that
3133
 shares its `"[" Sum` / `"(" Sum` prefix with the list literal / grouping and branches
@@ -146,22 +148,31 @@
146148
   three-valued (`not3`). LR(1)-clean (build.rs gate). The TCK has no `in not(…)` case, so it
147149
   ships unit-tested (`membership_not_test_negation`) with no fixture change.
148150
 
151
+### Shipped: unbounded omitted-endpoint ranges (ADR-31)
152
+
153
+`[1..]` / `[..10]` / `[..]` — an omitted endpoint is `±∞`, kept **distinct** from a present
154
+`null` bound (`[..10]` is a definite bound; `[null..10]` stays three-valued unknown). AST
155
+`Interval` and value `RangeVal` endpoints became `Option<…>` (`None` = unbounded); `Value`
156
+stays 40 bytes (`RangeVal` is boxed). Grammar is LR(1)-clean: `Sum?` low endpoint + a new
157
+`HiEnd` nonterminal (bounded `Endpoint IntervalEnd` or a bare `]`/`)` for unbounded-high),
158
+proven by the build.rs gate. An unbounded side's bracket openness is ignored (it has no
159
+member), and the Allen relations view operands through a `NegInf`/`Val`/`PosInf` bound. **The
160
+`range()` string builtin stays strict** — `range("[..2]")`/`range("[1..]")` are null per
161
+DMN-TCK 1156 (`004_e`/`004_f`), so the closed loop needed no fixture change. Exercised by the
162
+`unbounded_ranges` unit test.
163
+
149164
 ### Still deferred
150165
 
151
-- **Unbounded omitted-endpoint ranges** `[1..]` / `[..10]` (distinct from a `null`
152
-  endpoint) — the grammar is LR(1)-clean (optional `Sum?` endpoints, disjoint lookaheads);
153
-  the work is `Option<Box<Expr>>` AST endpoints + eval treating an omitted side as ±∞ (vs a
154
-  `null` bound's three-valued "unknown").
155166
 - **Value-position comparison-test value** `(< 10)` — grammar-clean (`"(" CmpOp Sum ")"`,
156167
   no token in `FIRST(Expr)` clashes); blocked on a new opaque `Value` variant with
157168
   reflexive, range-incompatible equality (ADR-28's measured semantics: `(<10) = (<10)` true,
158169
   `(<10) = (null..10)` false).
159170
 
160
-### Entry points (for the remaining value-test / unbounded work)
171
+### Entry points (for the remaining value-test work)
161172
 
162173
 - Grammar: [feel.lalrpop](crates/feel-core/src/feel.lalrpop) — the `InRhs` /
163
-  `UnaryTestElem` / `NbSum` / `Endpoint` chains are the templates; unbounded ranges touch
164
-  `RangeLit` / `IntervalEnd`, the value-test `(< 10)` a new `Primary` alternative.
174
+  `UnaryTestElem` / `NbSum` / `Endpoint` chains are the templates; the value-test `(< 10)`
175
+  needs a new `Primary` alternative.
165176
 - Detector: `_balanced_bracket_group` / `_in_rhs_supported` / `_value_range_brackets_ok`
166177
   in [tools/ingest_tck.py](tools/ingest_tck.py).
167178