Public repository: timo / feel

Reader

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

docs: ADR-31 + ROADMAP — one uniform rule 66 for unbounded ranges

public

docs: ADR-31 + ROADMAP — one uniform rule 66 for unbounded ranges

Rewrite ADR-31: the subset/superset asymmetry is gone — literals and range()
now share rule 66 (open bracket on the omitted side), with the sole lenience the
literal `(..)`. Update ROADMAP and the ingester comments to the open-bracket
spellings (`[1..)`/`(..10]`).

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

modified DECISIONS.md +52 −49

@@ -1078,71 +1078,74 @@
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)
1081
+## ADR-31: Unbounded omitted-endpoint ranges — `[1..)` / `(..10]` (DMN §10.3.4.6)
10821082
 
10831083
 - **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**
1084
+  endpoint may be *omitted*, denoting an **unbounded** bound, `±∞`: `[1..)` is everything
1085
+  `≥ 1`, `(..10]` everything `≤ 10`, `(..)` everything. This is **semantically distinct**
10861086
   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
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
10891089
   earlier range work this ripples through *every* layer — AST, value, eval, builtins,
10901090
   grammar, the host wrappers — because both endpoints become optional everywhere.
1091
-- **Decision:** model an omitted endpoint as `None`, kept rigorously apart from `Some(null)`.
1091
+- **Decision:** model an omitted endpoint as `None`, kept rigorously apart from `Some(null)`,
1092
+  and require — everywhere, literal *and* `range()` — an **open bracket** on the omitted side
1093
+  (FEEL grammar rule 66, §10.3.2.7: an unbounded bound has its inclusivity flag false).
10921094
   - **AST `Interval.start`/`.end` → `Option<Box<Expr>>`; value `RangeVal.start`/`.end` →
10931095
     `Option<Value>`** (`None` = unbounded). `RangeVal` is still boxed behind
10941096
     `Value::Range(Box<RangeVal>)`, so `Value` stays 40 bytes (the `value_size_did_not_grow`
10951097
     guard is untouched). A present `null` bound evaluates to `Some(Value::Null)`; only a
10961098
     *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.
1099
+  - **An omitted endpoint requires an OPEN bracket on that side (rule 66).** `[1..)`,
1100
+    `(..10]`, `]1..)` are valid; `[1..]` / `[..10]` (a *closed* bracket with no value) are
1101
+    **parse errors**, exactly as `range("[1..]")` is null (next-but-one bullet). Since only an
1102
+    open bracket is writable there, an unbounded side's openness flag is always "open" — and
1103
+    is in any case ignored by every semantic operation (`±∞` is no member): equality compares
1104
+    the flag only where a side is *bounded* (`[1..)` ≠ `[1..10]`, `(..10]` ≠ `[null..10]`);
1105
+    `.start included`/`.end included` of an unbounded side is `false`; `.start`/`.end` of it
1106
+    is `null`. The flag is *stored* as written only so `string([1..))` echoes the bracket.
11031107
   - **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
1108
+    unconditionally (so `5 in [1..)`/`5 in (..10]` are true), a `Some(null)` side still goes
11051109
     three-valued. `instance of range<T>` treats an unbounded side as vacuously conforming
11061110
     (the bounded side types the range, like a null/empty slot). The §10.3.4.6 Allen relations
11071111
     view each operand through a `Bound { NegInf, Val, PosInf }` (an omitted lower = `NegInf`,
11081112
     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
1113
+    so `before((..5],[10..))`, `includes((..),[3..7])`, `coincides((..5],]..5])` need no
11101114
     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 follows FEEL grammar rule 66 exactly — an omitted endpoint
1119
-    needs an OPEN bracket.** Rule 66 has three alternatives: (a) both endpoints present,
1120
-    (b) `open start ".." endpoint end` (lower omitted, open start), (c) `start ".." endpoint
1121
-    open end` (upper omitted, open end). So `range("[2..)")` ≡ `>=2` and `range("(..2)")` ≡
1122
-    `<2` are valid (spec §10.3.4.6 examples), while a *closed* bracket with no value, or
1123
-    *both* endpoints omitted, is null: `range("[..2]")` / `range("[1..]")` (DMN-TCK 1156
1124
-    `004_e`/`004_f`, described as "closed … endpoint with no value is not valid") plus
1125
-    `range("[..]")` / `range("(..)")`. This is **stricter** than the lenient unbounded
1126
-    *literal* `[..2]` in value position (which accepts any bracket): the spec's grammar for
1127
-    bracket-with-omitted-endpoint lives only inside the `range()` string (rule 66) — the
1128
-    language proper expresses an unbounded range via a comparison operator (`>= 1`, mapped to
1129
-    a one-endpoint range, spec §10.3.2.7), not a bracket literal. feel-core lifting the
1130
-    bracket spelling into value/test position is the superset (next bullet).
1131
-- **Tests:** the unit test `unbounded_ranges` covers membership (incl. the `[..10]` ≠
1132
-  `[null..10]` distinction both ways), value-position equality, range properties, `instance
1133
-  of`, `string(...)` rendering, and the Allen relations over unbounded operands.
1134
-  `range_builtin` keeps `range("[..2]")`/`range("[1..]")` as null cases (matching 1156). The
1135
-  ingester's structural `..`-scan already admitted unbounded forms (the `..` still sits inside
1136
-  its bracket group); 0072 / 1156 re-ingest produced **no** fixture change, and the closed
1137
-  loop (`fixtures_test`) stays green.
1138
-- **Subset vs. superset:** the spec proper has *no* bracket-with-omitted-endpoint literal in
1139
-  value/test position — an unbounded range there is written `>= 1` / `< 10` (a comparison that
1140
-  maps to a one-endpoint range, §10.3.2.7). The bracket spelling `[1..]` / `(..2)` is only the
1141
-  `range()`-string grammar (rule 66). feel-core therefore **leniently extends** that bracket
1142
-  spelling into value-position and `in`-test literals (`[1..]`, `[..10]`, even `[..]`, any
1143
-  bracket) — a deliberate *superset* for ergonomics, with the spec's semantics (an unbounded
1144
-  side's inclusivity flag is false, §10.3.2.7). The `range()` *function* stays a faithful
1145
-  *subset*-tight implementation of rule 66 (open-bracket required, ≤ one omitted endpoint).
1115
+  - **Grammar (LR(1)-clean, build.rs gate).** A new `HiEnd` nonterminal carries the part after
1116
+    `..`: `Endpoint IntervalEnd` (bounded, any close bracket) **or** the bare open `")"`
1117
+    (unbounded high). The *closed* opener `"["` keeps its low endpoint **mandatory** (`Sum`);
1118
+    the *open* openers `"("` / `]`(RBracketOpen) take it optional (`Sum?`). So a closed bracket
1119
+    on an omitted side has no production — `[1..]` / `[..10]` simply don't parse. The
1120
+    unbounded-high form is `")"` only: no `"]"` (closed) and no reverse-close `"["` (`[` ∈
1121
+    FIRST(Endpoint), so after `..` a `[` always shifts into a nested-endpoint parse — the rare
1122
+    `[1..[` is spelt `[1..)`). Reused verbatim by `RangeLit` (value position) and the `InRhs`
1123
+    interval *tests*. (`..` ∉ FIRST(Sum) keeps the optional-low choice one-token-clean.)
1124
+  - **`range()` string builtin follows the SAME rule 66.** Rule 66 alternatives: (a) both
1125
+    endpoints present, (b) `open start ".." endpoint end`, (c) `start ".." endpoint open end`.
1126
+    So `range("[2..)")` ≡ `>=2` and `range("(..2)")` ≡ `<2` are valid (spec §10.3.4.6
1127
+    examples), while a closed bracket with no value, or *both* endpoints omitted, is null:
1128
+    `range("[..2]")` / `range("[1..]")` (DMN-TCK 1156 `004_e`/`004_f`, "closed … endpoint with
1129
+    no value is not valid") plus `range("[..]")` / `range("(..)")`. (range() additionally
1130
+    rejects `(..)`/both-omitted, which has no rule-66 alternative; the *literal* `(..)` — the
1131
+    universal range — is the one deliberate lenience, see below.)
1132
+- **One uniform rule, one small lenience.** Literal *and* `range()` now obey rule 66's
1133
+  open-bracket requirement, so there is no `[1..]`-parses-but-`range("[1..]")`-is-null
1134
+  surprise. The single difference: the *literal* `(..)` (both endpoints omitted, both open) is
1135
+  accepted as the universal range `(-∞,+∞)` — harmless and occasionally handy — whereas
1136
+  `range("(..)")` is null (rule 66 has no both-omitted alternative, and the function mirrors
1137
+  the string grammar exactly). Note the spec's *canonical* unbounded value is actually the
1138
+  comparison `>= 1` / `< 10` (mapped to a one-endpoint range, §10.3.2.7); the bracket spelling
1139
+  is rule-66 sugar that feel-core makes available in value/test position too.
1140
+- **Tests:** `unbounded_ranges` covers membership (incl. the `(..10]` ≠ `[null..10]`
1141
+  distinction both ways), value-position equality, range properties, `instance of`,
1142
+  `string(...)` rendering, and the Allen relations over unbounded operands;
1143
+  `unbounded_closed_bracket_is_a_parse_error` pins the rule-66 rejection of `[1..]` / `[..10]`.
1144
+  `range_builtin` covers the open-bracket `range("[2..)")` ≡ `>=2` plus the closed-bracket /
1145
+  both-omitted null cases (1156). The ingester's structural `..`-scan still admits unbounded
1146
+  forms (the open-bracket requirement is the parser's job, and the DMN-TCK has no
1147
+  value-position unbounded literal — `range("…")` strings are blanked); 0072 / 1156 re-ingest
1148
+  produced **no** fixture change, and the closed loop (`fixtures_test`) stays green.
11461149
 - **Consequence:** every §10.3.4.6 range *grammar* form is now in. The only remaining range
11471150
   deferral is the opaque comparison-test *value* `(< 10)` in value position (ADR-28's measured
11481151
   semantics; needs a new `Value` variant), which is unrelated to endpoints — and which, once

modified ROADMAP.md +15 −11

@@ -24,7 +24,7 @@
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
-**Unbounded omitted-endpoint ranges (`[1..]` / `[..10]` / `[..]`, distinct from a `null`
27
+**Unbounded omitted-endpoint ranges (`[1..)` / `(..10]` / `(..)`, distinct from a `null`
2828
 bound) now shipped (ADR-31)** — see below. **Still deferred:** only the
2929
 comparison-test-as-range *value* (`(< 10)` in value position) — reshaped by a TCK
3030
 measurement (below).
@@ -150,16 +150,20 @@
150150
 
151151
 ### Shipped: unbounded omitted-endpoint ranges (ADR-31)
152152
 
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.
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). Per
155
+FEEL grammar rule 66 an omitted endpoint requires an **open** bracket on that side, so
156
+`[1..]` / `[..10]` (closed, no value) are parse errors — the same rule the `range()` string
157
+obeys, so there is no literal-vs-`range()` surprise. AST `Interval` and value `RangeVal`
158
+endpoints became `Option<…>` (`None` = unbounded); `Value` stays 40 bytes (`RangeVal` is
159
+boxed). Grammar is LR(1)-clean: the closed opener `"["` keeps its low endpoint mandatory,
160
+the open `"("`/`]` take it optional, and a new `HiEnd` nonterminal gives the high side
161
+(bounded `Endpoint IntervalEnd` or the open `")"` for unbounded-high) — proven by the
162
+build.rs gate. An unbounded side's openness is ignored (it has no member), and the Allen
163
+relations view operands through a `NegInf`/`Val`/`PosInf` bound. `range()` follows the same
164
+rule 66 — `range("[2..)")` ≡ `>=2`, while `range("[..2]")`/`range("[1..]")` are null (DMN-TCK
165
+1156 `004_e`/`004_f`); the closed loop needed no fixture change. Exercised by the
166
+`unbounded_ranges` and `unbounded_closed_bracket_is_a_parse_error` unit tests.
163167
 
164168
 ### Still deferred
165169
 

modified tools/ingest_tck.py +8 −5

@@ -143,9 +143,12 @@
143143
     """True if every `..` in value-position `s` sits inside a bracketed range literal /
144144
     interval feel-core parses — INCLUDING the reverse-bracket spellings `]a..b]`
145145
     (exclusive lower, ≡ `(a..b]`) and `[a..b[` (exclusive upper, ≡ `[a..b)`) and the
146
-    UNBOUNDED spellings `[1..]` / `[..10]` / `[..]` (an omitted endpoint is `±∞`;
147
-    ADR-31), all shipped now. An omitted endpoint needs no special casing: the `..`
148
-    still sits inside its bracket group, so the structural balance check accepts it. A
146
+    UNBOUNDED spellings `[1..)` / `(..10]` / `(..)` (an omitted endpoint is `±∞`, valid
147
+    only behind an OPEN bracket per grammar rule 66; a closed `[1..]` / `[..10]` does NOT
148
+    parse — ADR-31), all shipped now. The structural balance check accepts the unbounded
149
+    `..` (it still sits inside its bracket group); the open-bracket requirement on an
150
+    omitted endpoint is enforced by the parser, not here (and the DMN-TCK has no
151
+    value-position unbounded literal anyway — `range("[1..]")` is a blanked string). A
149152
     scan that does NOT require bracket *types* to match: FEEL intervals legitimately mix
150153
     `[`/`(`/`]` (`(1..2]`), so an opener and a closer pair by nesting alone. Reverse
151154
     roles resolve positionally — a `]` with nothing open is a reverse-open opener; a `[`
@@ -349,8 +352,8 @@
349352
             # `[1..10] instance of range<number>`, `]1..10].start`) or a
350353
             # membership-interval RHS (`x in [a..b]`, validated further by the
351354
             # membership scan below). The reverse-bracket spellings `]a..b]` / `[a..b[`
352
-            # and the unbounded spellings `[1..]` / `[..10]` (ADR-31) are in scope now
353
-            # (shipped), so the structural scan accepts them and
355
+            # and the open-bracket unbounded spellings `[1..)` / `(..10]` (ADR-31) are in
356
+            # scope now (shipped), so the structural scan accepts them and
354357
             # rejects only a bare top-level `..` or genuinely unbalanced brackets.
355358
             if not _value_range_brackets_ok(s):
356359
                 return False