Public repository: timo / feel

Reader

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

docs: ADR-30 + ROADMAP — `not(tests)` test negation

public

docs: ADR-30 + ROADMAP — `not(tests)` test negation

ADR-30 records the test-mode production (drop boolean `not` from `NbPrimary` +
dedicated `InRhs` production) and the three-valued `not3` semantics. ROADMAP
moves `not(tests)` negation from "Still deferred" to done; every `in`-RHS
grammar form is now in (only semantic-value deferrals remain).

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

modified DECISIONS.md +38 −0

@@ -1040,6 +1040,44 @@
10401040
   opaque comparison-test value `(< 10)` in value position (needs a new `Value` variant with
10411041
   reflexive, range-incompatible equality; ADR-28). `not(tests)` negation too. See ROADMAP.md.
10421042
 
1043
+## ADR-30: `not(tests)` test negation on the RHS of `in` (DMN §10.3.2.6, rule 49)
1044
+
1045
+- **Context:** the last grammar-side `in`-RHS form deferred by ADR-27/ADR-28 — negating a
1046
+  positive unary-test list, `x in not([1,2,3])` / `x in not(<5)` / `x in not([1..10])`.
1047
+  ADR-28 flagged it as "LR(1)-solvable but the block is semantic." The block was a
1048
+  *token-role collision*, not a real ambiguity: in the unary-test category `not(…)` is
1049
+  **always** test negation (`x in not(t)` ≡ `not(x satisfies t)`, three-valued), NEVER the
1050
+  boolean `not(…)` built-in — but the bare-endpoint branch `NbSum → … → NbPrimary` reached
1051
+  the boolean `"not" "(" Expr ")"` production, so a `not` after `in` had two parses.
1052
+- **Decision:** ship it as a dedicated test-mode production, resolving the fork by *removing*
1053
+  the rival from the bare branch.
1054
+  - **`NbPrimary` drops the boolean `not`.** The `Nb*` chain exists only as `InRhs`'s
1055
+    bare-endpoint branch; removing `"not" "(" Expr ")"` from `NbPrimary` means the bare
1056
+    branch can never *start* with `not`. (A boolean `not(…)` is unaffected everywhere else —
1057
+    it lives in the full `Primary`, reachable through `Sum`.) Semantically this is exactly
1058
+    right: per spec a `not(…)` after `in` is test negation, not a boolean endpoint.
1059
+  - **A dedicated `InRhs → "not" "(" Comma<UnaryTestElem> ")"` production.** With the bare
1060
+    branch's `not` gone, this is the *only* production starting with `not` in the `in`-RHS
1061
+    state — one shift target, LR(1)-clean (the `build.rs` no-conflict gate proves it).
1062
+    Reusing `UnaryTestElem` means each inner element becomes a test via
1063
+    `unary_test_from_expr` exactly like a bare list, so `not(5)` is the negated `= 5` test,
1064
+    `not(<5)` a negated comparison, `not([1..10])` a negated interval — no special-casing.
1065
+  - **AST: a new `UnaryTest::Not(Vec<UnaryTest>)`.** It carries the inner test list; no
1066
+    `Expr` change. `eval_unary_test` OR-folds the inner tests (the same disjunction as a
1067
+    bare list) and negates the result with a Kleene `not3`: `not(true)=false`,
1068
+    `not(false)=true`, `not(null)=null`, and a *tainted* unknown (error-null / wrong-typed)
1069
+    stays an error-null — mirroring `and3`/`or3` provenance, so negating an unknown never
1070
+    manufactures a definite truth. (`x in not((null..10])` ⇒ null, not true.)
1071
+- **Tests:** unit test `membership_not_test_negation` covers list / bare / comparison /
1072
+  interval / mixed inner tests and the Kleene-null case directly. The ingester's
1073
+  `_in_rhs_supported` now admits `not(…)` after `in` (validated as a balanced paren group,
1074
+  like a bare bracket list). The DMN-TCK has **no** `in not(…)` case in any suite, so no
1075
+  fixture changed and no suite was re-ingested; the closed loop (`fixtures_test`) stays
1076
+  green and the form is exercised by the unit test.
1077
+- **Consequence:** every `in`-RHS *grammar* form is now in. The two remaining deferrals are
1078
+  purely semantic-value work, not grammar: unbounded omitted-endpoint ranges `[1..]` /
1079
+  `[..10]` and the opaque comparison-test value `(< 10)` in value position (both ADR-29).
1080
+
10431081
 ## Adding a wrapper — the host-binding contract
10441082
 
10451083
 The four wrappers (feel-pg, feel-wasm, feel-py, planned feel-lua) implement the same

modified ROADMAP.md +10 −4

@@ -136,12 +136,18 @@
136136
   The ingester relaxation (reverse-bracket `..` scan + multi-word `.member` blanking) did
137137
   unlock **+8** related cases in `0068`/`1156`/`0074` (suite → 2728).
138138
 
139
+### Done
140
+
141
+- **`not(tests)` negation** — ✅ **shipped (ADR-30).** `x in not([1,2,3])` / `not(<5)` /
142
+  `not([1..10])`. The collision with the boolean `not(…)` built-in was resolved exactly as
143
+  foreseen: `NbPrimary` drops the boolean `"not" "(" Expr ")"` (so the bare `in`-RHS branch
144
+  never starts with `not`) and a dedicated `InRhs → "not" "(" Comma<UnaryTestElem> ")"`
145
+  production carries it into a new `UnaryTest::Not(Vec<UnaryTest>)` — OR-folded then negated
146
+  three-valued (`not3`). LR(1)-clean (build.rs gate). The TCK has no `in not(…)` case, so it
147
+  ships unit-tested (`membership_not_test_negation`) with no fixture change.
148
+
139149
 ### Still deferred
140150
 
141
-- **`not(tests)` negation** — collides with the `not(…)` boolean built-in. LALRPOP-solvable:
142
-  a `not`-free bare InRhs primary + a dedicated `not "(" Comma<UnaryTestElem> ")"`
143
-  production (test-negation is the correct FEEL unary-test semantics, so routing all `not(`
144
-  in `in`-position there loses nothing); needs a `UnaryTest::Not` eval representation.
145151
 - **Unbounded omitted-endpoint ranges** `[1..]` / `[..10]` (distinct from a `null`
146152
   endpoint) — the grammar is LR(1)-clean (optional `Sum?` endpoints, disjoint lookaheads);
147153
   the work is `Option<Box<Expr>>` AST endpoints + eval treating an omitted side as ±∞ (vs a