Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .changeset/38959-flow-condition-verdicts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
'@objectstack/formula': minor
'@objectstack/spec': minor
---

fix(formula)!: a date-text fault is no longer hidden behind a type-mismatch warning, a text or boolean field read by index (`record['FIELD']`) takes the type-mismatch verdict, and a macro variable ordered against a text literal is no longer refused

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — `skills/objectstack-formula/SKILL.md` rule 5 already states "The build refuses date arithmetic (`end - start`, `date + n`)" and refuses a `date` / `datetime` field in a timestamp-only call, with no exception for a source that also carries a type mismatch; no skill teaches the index spelling, the type-mismatch warning, or ordering a macro variable over date fields

<!-- adr-0087: registered flow-condition-mismatch-warning-and-index-mismatch-refused -->

**BREAKING** accept-set narrowing. A flow condition that faults fails the run. Two shapes that published and then failed every run are refused:

- **A date-text fault behind a type-mismatch warning.** The authoring check reported one finding per source and asked the text / boolean type mismatch first; the date-text check was asked only when that answered nothing. Where the mismatch is a warning, `due_date - borrow_date > duration('1h') && record.title > 5` and `record.active > 5 && isoDate(picked_up_at) == 'x'` published with the warning alone. The more severe verdict now wins: the date-text error is reported instead of the warning, also when the mismatch comes first in the source. The mismatch is a warning, so the change reaches: a flow condition on a flow that is not record-triggered (`date-text-arithmetic-run-may-fail`, `date-text-call-run-may-fail`); a flow condition whose bare name a node can rebind (`bareNamesUnproven`: `date-text-arithmetic-run-fails` / `date-text-call-run-fails` over a `record.FIELD` read, the `-run-may-fail` codes over a bare one); and every record-scoped site that declares no fault outcome (`date-text-arithmetic`, `date-text-call`): a formula field `expression`, a field `visibleWhen` / `settledWhen` / `uiReadonlyWhen`, a field `conditionalFormatting[].condition`, a field group `visibleWhen`, an action `visible` / `disabled` / `pressed`, a sharing rule `condition`, and the object `uiReadonlyWhen`. Where the mismatch is an error already (a record-triggered flow, a sweep of the typed object, a site with a declared fault outcome) it keeps its code.
- **A type mismatch through an index read.** `record['title'] > 5`, `record['active'] + 1 > 3`, `previous['title'] > 5`, `record['title'] > record['active']` passed while their member spellings were judged: a text or boolean field read by index under an arithmetic or ordering operator the run has no overload for (against a number or a boolean), which faults on every row. An index read of `record` / `previous` now takes the text / boolean type-mismatch verdict its member spelling takes (`type-mismatch-run-fails`, `-sweep-run-fails`, or the `-run-may-fail` warning), named as its member spelling is named: by the member spelling, also where a member read sits beside it (`record['title'] > 5 && record.status == 'open'` names `record.title` and takes `type-mismatch-run-fails` under `bareNamesUnproven`, as `record.title > 5 && record.status == 'open'` does; before, it took the warning, and `record['title'] > 5 && record.notes == 'n'` named `record.notes`). Stated limit, carried by #39105: the name is the first field of the faulting type in the field table that the source reads, in either spelling, which need not be the operand (`previous.notes > 5 && record['title'] == 'x'` names `record.title`; it named `previous.notes`). The date-text verdicts an index read took before keep their codes. An ordering of a date read against a text field, which the run answers, with either side read by index keeps the verdict it had: unjudged where no member read is in the source (`record['due_date'] > record['title']`), otherwise the mismatch kept as before, named only by a member read, so under `bareNamesUnproven` it stays the `type-mismatch-run-may-fail` warning (`record.due_date > record['title']`, `record['due_date'] > record['title'] && record.status == 'open'`, `record.due_date > title && record['notes'] == 'n'`).

Widened in the same change, for flow conditions and record-scoped sites only: a variable a macro binds (`exists`, `all`, `exists_one`, `map`, `filter`) is typed as an element of the list it ranges over, so `[due_date, record.borrow_date].exists(d, d > '2026-01-01')`, which the runtime answers, is no longer refused as a type mismatch; `[title].exists(t, t > 5)` stays refused. A flow value envelope (an `assignment` value, a `create_record` / `update_record` `fields.*` value) keeps the verdict it had: its date-text check stands down where the mismatch check finds a mismatch and asks that check with the macro typing it had before, so `[record.due_date].exists(d, d > '2026-01-01') ? isoDate(record.picked_up_at) : 'x'` as a value registers and validates as it did. That envelope shape is carried by #39107.

- **Where.** `os validate` / `os build` report an `error`, and a door that runs the same expression pass refuses the write (the flow publish door with `INVALID_METADATA`, 422). For flow conditions `registerFlow` logs it as an advisory and still registers the flow, so a stored flow keeps its run-time behaviour until it is next published; no flow value envelope verdict changes, so no stored flow that registered before is refused at registration. The run-time evaluator is unchanged.

## FROM → TO

| FROM | TO |
|:---|:---|
| `due_date - borrow_date > duration('1h') && record.title > 5` | `daysBetween(borrow_date, due_date) >= 1 && size(record.title) > 5` |
| `record['title'] > 5` | `size(record['title']) > 5` |
| `record['active'] + 1 > 3` | `record['active'] == true` |

One-line fix: compare like with like in a flow condition, whichever way a field is spelled; use `size(…)` / `double(…)` to make text a number, `true` / `false` for a boolean, and `daysBetween(a, b)` / `addDays(d, n)` / `date(…)` for a date.
Loading
Loading