| @@ -1078,6 +1078,59 @@ |
| 1078 | 1078 | purely semantic-value work, not grammar: unbounded omitted-endpoint ranges `[1..]` / |
| 1079 | 1079 | `[..10]` and the opaque comparison-test value `(< 10)` in value position (both ADR-29). |
| 1080 | 1080 | |
| 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 | + |
| 1081 | 1134 | ## Adding a wrapper — the host-binding contract |
| 1082 | 1135 | |
| 1083 | 1136 | The four wrappers (feel-pg, feel-wasm, feel-py, planned feel-lua) implement the same |