From a48f297bd3ad21487072b774e4b4f50341dc967a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 12:45:51 +0000 Subject: [PATCH 1/6] wip(formula): type bare names and record roots in one pass; admit the index spelling to the root gate Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- packages/formula/src/cel-engine.ts | 14 ++++++++------ packages/formula/src/validate.ts | 30 ++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/packages/formula/src/cel-engine.ts b/packages/formula/src/cel-engine.ts index b3e4963cec3..89f0beab169 100644 --- a/packages/formula/src/cel-engine.ts +++ b/packages/formula/src/cel-engine.ts @@ -1260,12 +1260,14 @@ function withoutNames( } /** - * [#29959, #34662] A `record.` / `previous.` read spelled member-wise — the gate - * of every flattened record-root pass ({@link firstTypeMismatch}'s and - * `validate.ts`'s date-text one), so the two can never disagree on whether a - * source reads a root. - */ -export const RECORD_ROOT_READ_RE = /(?` / `previous.` read of a field of diff --git a/packages/formula/src/validate.ts b/packages/formula/src/validate.ts index e17b46b4fc1..3664f2da496 100644 --- a/packages/formula/src/validate.ts +++ b/packages/formula/src/validate.ts @@ -597,7 +597,9 @@ function typeSoundnessIssue( // [#34363] The `date` fields (never `datetime`) by name: `timestamp()` faults on their text. const dateOnly = new Set(Object.keys(bareCelTypes).filter((name) => fieldTypes[name] === 'date')); const bare = dateTextIssue(source, bareCelTypes, scope, role, dateArm(scope, faultOutcome, bareNamesUnproven), dateOnly); - return bare ?? (scope === 'flattened' ? recordRootDateTextIssue(source, fieldTypes, celFieldTypes, role, faultOutcome) : null); + return bare ?? (scope === 'flattened' + ? recordRootDateTextIssue(source, fieldTypes, celFieldTypes, bareCelTypes, role, faultOutcome, bareNamesUnproven) + : null); } const reference = mismatch.field ? (mismatch.root !== undefined @@ -935,19 +937,39 @@ const DATE_TEXT_FAMILY_RE = /^date-text-(?:call|arithmetic)(?:-|$)/; * their bare spellings are. Only `date-text-call*` / `date-text-arithmetic*` * are kept. The outcome arm is the row's: a root read keeps the declared * outcome whatever binds the bare names (#30025), so `bareNamesUnproven` is - * not asked. + * not asked of a verdict the roots prove alone. + * + * [#35295] Nor is a bare name left `dyn` beside the roots when the object's + * field table types it. `due_date - record.borrow_date > duration('24h')` + * subtracts one date text from another on every run, as its all-bare and + * all-root spellings do, yet the bare pass left the root `dyn` and the roots + * alone left the bare name `dyn`, so neither faulted. The bare names (less + * the ones a flow variable shadows: `bareCelTypes`) and the roots are typed + * in ONE pass, and the mixed spelling takes the same verdict, code and words. + * A genuinely unproven operand — a flow variable, a node's output, a shadowed + * name — stays `dyn` there and keeps passing (ADR-0032 §1c). That pass is + * asked only once the roots alone answered nothing, so every verdict they + * prove keeps its arm, and what it adds leans on a bare name: where a node can + * rebind one (`bareNamesUnproven`) it takes the bare name's weaker arm + * ({@link dateArm}). */ function recordRootDateTextIssue( source: string, fieldTypes: Readonly>, celFieldTypes: Readonly>, + bareCelTypes: Readonly>, role: 'predicate' | 'value', faultOutcome: ExprSchemaHint['faultOutcome'], + bareNamesUnproven: boolean | undefined, ): { issue: ExprValidationError; severity: 'error' | 'warning' } | null { if (!RECORD_ROOT_READ_RE.test(source) || !Object.values(celFieldTypes).includes('timestamp')) return null; const dateOnly = new Set(Object.keys(celFieldTypes).filter((name) => fieldTypes[name] === 'date')); - const found = dateTextIssue(source, {}, 'flattened', role, dateArm('flattened', faultOutcome, false), dateOnly, celFieldTypes); - return found && DATE_TEXT_FAMILY_RE.test(found.issue.code) ? found : null; + const judged = (bare: Readonly>, arm: DateArm | null) => { + const found = dateTextIssue(source, bare, 'flattened', role, arm, dateOnly, celFieldTypes); + return found && DATE_TEXT_FAMILY_RE.test(found.issue.code) ? found : null; + }; + return judged({}, dateArm('flattened', faultOutcome, false)) + ?? judged(bareCelTypes, dateArm('flattened', faultOutcome, bareNamesUnproven)); } /** From 4009c3f51f362b86898676c2e9dd6ed036c89749 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 12:49:55 +0000 Subject: [PATCH 2/6] test(formula): pin the mixed and index spellings, the controls that run today, and run pins over the engine's scope Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- packages/formula/src/cel-engine.ts | 11 +- .../src/validate-date-text-arithmetic.test.ts | 169 +++++++++++++++++- packages/formula/src/validate.test.ts | 6 +- 3 files changed, 180 insertions(+), 6 deletions(-) diff --git a/packages/formula/src/cel-engine.ts b/packages/formula/src/cel-engine.ts index 89f0beab169..49baa4ac39a 100644 --- a/packages/formula/src/cel-engine.ts +++ b/packages/formula/src/cel-engine.ts @@ -1272,8 +1272,12 @@ export const RECORD_ROOT_READ_RE = /(?` / `previous.` read of a field of * `celType` in a flattened condition, as written — what - * {@link firstTypeMismatch}'s record-root pass names. `null` when no such read - * is spelled member-wise (an index read, say), so the message names no field. + * {@link firstTypeMismatch}'s record-root pass names. [#35295] An index read + * (`record['due_date']`) is that read too, the one {@link RECORD_ROOT_READ_RE} + * admits, so it is named as its member spelling (`record.due_date`) — as + * {@link typedFieldRef} names it for a call — never as the bare name its + * quoted key would otherwise match. `null` when the field is read by neither + * spelling (a key computed at run time), so the message names no field. */ function offendingRecordRead( source: string, @@ -1282,7 +1286,8 @@ function offendingRecordRead( ): { field: string; root: 'record' | 'previous' } | null { for (const [name, t] of Object.entries(fieldCelTypes)) { if (t !== celType) continue; - const m = new RegExp(`(? / previous. read takes the d const codes = (source: string, hint: ExprSchemaHint = CONDITION) => errorsOf(source, hint).map((e) => e.code); /** What the run binds: the row under `record` (and `previous`), and its fields flattened bare. */ const ROW = { title: 'Dune', borrow_date: '2026-11-16', due_date: '2026-11-30', picked_up_at: '2026-11-16T09:30:00.000Z' }; - const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { ...ROW, record: ROW, previous: ROW }); + // The engine's scope (`celScope`): bare names, `record` and `previous` all under `extra` (#35295). + const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { extra: { ...ROW, record: ROW, previous: ROW } }); it('refuses timestamp() over a date field through record. and previous. under the same code as the bare name, naming the read', () => { expect(codes('timestamp(borrow_date) < now()')).toEqual(['date-text-call-run-fails']); @@ -652,3 +653,169 @@ describe('a flow condition\'s record. / previous. read takes the d expect(codes('timestamp(input.borrow_date) < now()').filter((c) => c.startsWith('date-text-'))).toEqual([]); }); }); + +// [#35295] Two spellings of the date-text mistake the #34662 pass did not reach. +// (2) Mixed: `due_date - record.borrow_date` subtracts one date text from another +// on every run, as its all-bare and all-root spellings do, but the bare pass left +// the root `dyn` and the root pass left the bare name `dyn`, so neither faulted. +// The bare names and the roots are now typed against the object's field table in +// one pass. (1) Index: `record['borrow_date']` reached neither pass; the root gate +// now admits it. A genuinely unproven operand (a flow variable, a node output, a +// shadowing name) is still `dyn`, and every expression that runs today keeps +// passing (ADR-0032 §1c). Each run here is the engine's scope (`celScope`): bare +// names, `record` and `previous` under `extra`. +describe('a flow condition types bare names and record. / previous. reads in one pass, index reads included (#35295)', () => { + const fieldTypes = { + title: 'text', borrow_date: 'date', due_date: 'date', picked_up_at: 'datetime', returned_at: 'datetime', status: 'select', + }; + const CONDITION: ExprSchemaHint = { fields: Object.keys(fieldTypes), fieldTypes, faultOutcome: 'run-fails' }; + const ROW = { + title: 'Dune', borrow_date: '2026-11-16', due_date: '2026-11-30', picked_up_at: '2026-11-16T09:30:00.000Z', + returned_at: '2026-11-20T09:30:00.000Z', status: 'open', + }; + const run = (source: string, extra: Record = {}) => celEngine.evaluate( + { dialect: 'cel', source }, + { extra: { ...ROW, record: ROW, previous: { ...ROW, due_date: '2026-11-23' }, ...extra } }, + ); + const check = (source: string, hint: ExprSchemaHint = CONDITION) => validateExpression('predicate', source, hint); + /** The one refusal `source` takes: an error, so the condition does not publish. */ + const refusalOf = (source: string, hint: ExprSchemaHint = CONDITION) => { + const r = check(source, hint); + expect(r.ok, source).toBe(false); + expect(r.warnings, source).toEqual([]); + expect(r.errors, source).toHaveLength(1); + return r.errors[0]; + }; + /** The words with the read named as written replaced: the verdict's sentence and prescription. */ + const words = (e: { message: string; params?: Record }) => { + const reference = e.params?.reference; + return typeof reference === 'string' ? e.message.split(`\`${reference}\``).join('`READ`') : e.message; + }; + /** The prescription a verdict closes on. */ + const prescription = (message: string) => message.slice(message.search(/ (?:Use `daysBetween|Parse the text)/)); + + // [mixed spelling, the consistent spellings it must agree with, hint] + const MIXED: ReadonlyArray = [ + ["due_date - record.borrow_date > duration('24h')", + ["record.due_date - record.borrow_date > duration('24h')", "due_date - borrow_date > duration('24h')"]], + ["record.due_date - borrow_date > duration('24h')", + ["record.due_date - record.borrow_date > duration('24h')", "due_date - borrow_date > duration('24h')"]], + ["due_date - previous.due_date > duration('24h')", ["record.due_date - previous.due_date > duration('24h')"]], + ["previous.due_date - due_date > duration('24h')", ["previous.due_date - record.due_date > duration('24h')"]], + ["returned_at - record.picked_up_at > duration('24h')", + ["record.returned_at - record.picked_up_at > duration('24h')", "returned_at - picked_up_at > duration('24h')"]], + ['due_date - record.borrow_date > 3', ['record.due_date - record.borrow_date > 3', 'due_date - borrow_date > 3']], + ["status == 'open' && due_date - record.borrow_date > duration('24h')", + ["status == 'open' && record.due_date - record.borrow_date > duration('24h')", + "status == 'open' && due_date - borrow_date > duration('24h')"]], + // No declared outcome: run-may-fail, as both consistent spellings take. + ["due_date - record.borrow_date > duration('24h')", + ["record.due_date - record.borrow_date > duration('24h')", "due_date - borrow_date > duration('24h')"], + { ...CONDITION, faultOutcome: undefined }], + // A node can rebind a bare name: the bare name's weaker run-may-fail arm. + ["due_date - record.borrow_date > duration('24h')", ["due_date - borrow_date > duration('24h')"], + { ...CONDITION, bareNamesUnproven: true }], + ]; + + it.each(MIXED)('refuses %s with the verdict, code and prescription of its consistent spellings', (mixed, consistent, hint = CONDITION) => { + const got = refusalOf(mixed, hint); + expect(got.code).toMatch(/^date-text-arithmetic-run-(?:fails|may-fail)$/); + for (const spelling of consistent) { + const want = refusalOf(spelling, hint); + expect(got.code, spelling).toBe(want.code); + expect(got.params?.operands, spelling).toBe(want.params?.operands); + expect(words(got), spelling).toBe(words(want)); + expect(prescription(got.message), spelling).toBe(prescription(want.message)); + } + // The run faults on the two date texts, for that reason and no other. + const r = run(mixed); + expect(r.ok, mixed).toBe(false); + expect(r.ok ? '' : r.error.message, mixed).toMatch(/no such overload: dyn - dyn/); + }); + + it('the arm: run-fails where the run is proven, run-may-fail where a node can rebind the bare name, and the all-root spelling keeps run-fails', () => { + const mixed = "due_date - record.borrow_date > duration('24h')"; + expect(refusalOf(mixed).code).toBe('date-text-arithmetic-run-fails'); + const unproven: ExprSchemaHint = { ...CONDITION, bareNamesUnproven: true }; + expect(refusalOf(mixed, unproven).code).toBe('date-text-arithmetic-run-may-fail'); + expect(refusalOf("record.due_date - record.borrow_date > duration('24h')", unproven).code).toBe('date-text-arithmetic-run-fails'); + }); + + // [index spelling, its member spelling] + const INDEX: ReadonlyArray = [ + ["timestamp(record['borrow_date']) < now()", 'timestamp(record.borrow_date) < now()'], + ["record['due_date'] - record['borrow_date'] > duration('24h')", "record.due_date - record.borrow_date > duration('24h')"], + ["isoDate(record['picked_up_at']) == '2026-11-16'", "isoDate(record.picked_up_at) == '2026-11-16'"], + ["record['due_date'] - record.borrow_date > duration('24h')", "record.due_date - record.borrow_date > duration('24h')"], + ["due_date - record['borrow_date'] > duration('24h')", "due_date - record.borrow_date > duration('24h')"], + ['timestamp(previous["borrow_date"]) < now()', 'timestamp(previous.borrow_date) < now()'], + ]; + + it.each(INDEX)('refuses the index read %s as its member spelling is refused', (index, member) => { + const got = refusalOf(index); + const want = refusalOf(member); + expect(got.code).toBe(want.code); + expect(got.params?.reference).toBe(want.params?.reference); + if (got.code.startsWith('date-text-arithmetic-')) { + // Arithmetic names the read by its member spelling: the same verdict, byte for byte. + expect({ ...got, source: member }).toEqual(want); + } else { + // A call is named as written, and its prescribed parse is proven: it checks clean and evaluates. + expect(words(got).replace(/\[["'](\w+)["']\]/g, '.$1')).toBe(words(want)); + const fixed = index.replace(/\[\s*'(\w+)'\s*\]/g, '["$1"]').replace(String(got.params?.call), String(got.params?.rewrite)); + expect(fixed).not.toBe(index); + expect(check(fixed), fixed).toEqual({ ok: true, errors: [], warnings: [] }); + expect(run(fixed), fixed).toEqual({ ok: true, value: true }); + } + const r = run(index); + expect(r.ok, index).toBe(false); + expect(r.ok ? '' : r.error.message, index).not.toMatch(/Unknown variable|undeclared reference/i); + }); + + it('the index read takes the member spelling\'s other root verdicts too: date arithmetic and the text mismatch', () => { + for (const [index, member] of [ + ["record['due_date'] + 1 > 5", 'record.due_date + 1 > 5'], + ["previous['title'] > 5", 'previous.title > 5'], + ] as const) { + expect({ ...refusalOf(index), source: member }).toEqual(refusalOf(member)); + expect(run(index).ok, index).toBe(false); + } + }); + + it('CONTROL: an index read the runtime answers stays clean and evaluates', () => { + for (const source of [ + "timestamp(record['picked_up_at']) < now()", + "record['title'] == 'Dune'", + "date(record['borrow_date']) < now()", + "daysBetween(record['borrow_date'], due_date) > 3", + "record['due_date'] > previous['due_date']", + ]) { + expect(check(source), source).toEqual({ ok: true, errors: [], warnings: [] }); + expect(run(source), source).toEqual({ ok: true, value: true }); + } + }); + + // [source, hint, what the run binds beyond the row]: an operand that is genuinely + // unproven stays `dyn` and passes, as everywhere else in the package. + const D = (iso: string) => new Date(iso); + const RUNS_TODAY: ReadonlyArray]> = [ + ["cutoff - record.due_date > duration('24h')", { ...CONDITION, flowVariables: ['cutoff'] }, { cutoff: D('2026-12-25T00:00:00Z') }], + ["cutoff - due_date > duration('24h')", { ...CONDITION, flowVariables: ['cutoff'] }, { cutoff: D('2026-12-25T00:00:00Z') }], + ["vars.cutoff - record.due_date > duration('24h')", CONDITION, { vars: { cutoff: D('2026-12-25T00:00:00Z') } }], + ["record.picked_up_at - started > duration('1h')", { ...CONDITION, flowVariables: ['started'] }, { started: D('2026-11-16T00:00:00Z') }], + ["get_policy.effective_at - record.due_date > duration('24h')", { ...CONDITION, flowVariables: ['get_policy'] }, + { get_policy: { effective_at: D('2026-12-25T00:00:00Z') } }], + // A flow variable shadowing the bare name holds an instant, not the field. + ["due_date - record.borrow_date > duration('24h')", { ...CONDITION, flowVariables: ['due_date'] }, { due_date: D('2026-12-25T00:00:00Z') }], + // Concatenation of a date's text: the runtime answers string + string. + ["record.due_date + suffix == '2026-11-30Z'", { ...CONDITION, flowVariables: ['suffix'] }, { suffix: 'Z' }], + ["prefix + record.due_date == 'due 2026-11-30'", { ...CONDITION, flowVariables: ['prefix'] }, { prefix: 'due ' }], + ["due_date + status == '2026-11-30open'", CONDITION, {}], + ["record.due_date + record.status == '2026-11-30open'", CONDITION, {}], + ]; + + it.each(RUNS_TODAY)('CONTROL: %s runs today and still passes', (source, hint, extra) => { + expect(check(source, hint), source).toEqual({ ok: true, errors: [], warnings: [] }); + expect(run(source, extra), source).toEqual({ ok: true, value: true }); + }); +}); diff --git a/packages/formula/src/validate.test.ts b/packages/formula/src/validate.test.ts index 9ca0e3cceff..46ec72c5dc3 100644 --- a/packages/formula/src/validate.test.ts +++ b/packages/formula/src/validate.test.ts @@ -1346,7 +1346,8 @@ describe('a flow condition\'s record. / previous. read takes the d errorsOf(source, hint).map((e) => ({ code: e.code, params: e.params })); /** What the run binds: the row under `record` (and `previous`), and its fields flattened bare. */ const ROW = { title: 'Dune', borrow_date: '2026-11-16', due_date: '2026-11-30', picked_up_at: '2026-11-16T09:30:00.000Z' }; - const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { ...ROW, record: ROW, previous: ROW }); + // The engine's scope (`celScope`): bare names, `record` and `previous` all under `extra` (#35295). + const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { extra: { ...ROW, record: ROW, previous: ROW } }); it('refuses date arithmetic on a date field through record. and previous. under the bare name\'s code, naming the read', () => { expect(verdicts('due_date + 1 > 5')).toEqual([{ @@ -1429,7 +1430,8 @@ describe('a flow condition that orders the bare date name before date arithmetic const verdicts = (source: string, hint: ExprSchemaHint = CONDITION) => errorsOf(source, hint).map((e) => ({ code: e.code, params: e.params, message: e.message })); const ROW = { title: 'Dune', borrow_date: '2026-11-16', due_date: '2026-11-30', picked_up_at: '2026-11-16T09:30:00.000Z' }; - const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { ...ROW, record: ROW, previous: ROW }); + // The engine's scope (`celScope`): bare names, `record` and `previous` all under `extra` (#35295). + const run = (source: string) => celEngine.evaluate({ dialect: 'cel', source }, { extra: { ...ROW, record: ROW, previous: ROW } }); it('refuses the mixed spelling with exactly the verdict the all-root spelling gets, naming the root read', () => { for (const [root, field, op] of [ From f4f4fb752e9a0d824044d9bb522431b05cf23ec9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 12:52:33 +0000 Subject: [PATCH 3/6] test(formula): type the new pins for the test project Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- .../src/validate-date-text-arithmetic.test.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/formula/src/validate-date-text-arithmetic.test.ts b/packages/formula/src/validate-date-text-arithmetic.test.ts index 5fd1ed0e4ac..b65e750f7a4 100644 --- a/packages/formula/src/validate-date-text-arithmetic.test.ts +++ b/packages/formula/src/validate-date-text-arithmetic.test.ts @@ -22,7 +22,7 @@ */ import { describe, expect, it } from 'vitest'; import { celEngine } from './cel-engine'; -import { validateExpression, type ExprSchemaHint } from './validate'; +import { validateExpression, type ExprSchemaHint, type ExprValidationError } from './validate'; const RECORD_SCOPE: ExprSchemaHint = { scope: 'record', @@ -686,9 +686,11 @@ describe('a flow condition types bare names and record. / previous. reads in one expect(r.errors, source).toHaveLength(1); return r.errors[0]; }; + /** A refusal's param by name. */ + const param = (e: ExprValidationError, key: string): unknown => (e.params as Record | undefined)?.[key]; /** The words with the read named as written replaced: the verdict's sentence and prescription. */ - const words = (e: { message: string; params?: Record }) => { - const reference = e.params?.reference; + const words = (e: ExprValidationError) => { + const reference = param(e, 'reference'); return typeof reference === 'string' ? e.message.split(`\`${reference}\``).join('`READ`') : e.message; }; /** The prescription a verdict closes on. */ @@ -717,13 +719,17 @@ describe('a flow condition types bare names and record. / previous. reads in one { ...CONDITION, bareNamesUnproven: true }], ]; - it.each(MIXED)('refuses %s with the verdict, code and prescription of its consistent spellings', (mixed, consistent, hint = CONDITION) => { + const MIXED_ROWS = MIXED.map(([mixed, consistent, hint]) => ({ + mixed, consistent, hint: hint ?? CONDITION, + arm: !hint ? 'run proven' : hint.bareNamesUnproven ? 'bare names unproven' : 'no declared outcome', + })); + it.each(MIXED_ROWS)('refuses $mixed ($arm) with the verdict, code and prescription of its consistent spellings', ({ mixed, consistent, hint }) => { const got = refusalOf(mixed, hint); expect(got.code).toMatch(/^date-text-arithmetic-run-(?:fails|may-fail)$/); for (const spelling of consistent) { const want = refusalOf(spelling, hint); expect(got.code, spelling).toBe(want.code); - expect(got.params?.operands, spelling).toBe(want.params?.operands); + expect(param(got, 'operands'), spelling).toBe(param(want, 'operands')); expect(words(got), spelling).toBe(words(want)); expect(prescription(got.message), spelling).toBe(prescription(want.message)); } @@ -755,14 +761,14 @@ describe('a flow condition types bare names and record. / previous. reads in one const got = refusalOf(index); const want = refusalOf(member); expect(got.code).toBe(want.code); - expect(got.params?.reference).toBe(want.params?.reference); + expect(param(got, 'reference')).toBe(param(want, 'reference')); if (got.code.startsWith('date-text-arithmetic-')) { // Arithmetic names the read by its member spelling: the same verdict, byte for byte. expect({ ...got, source: member }).toEqual(want); } else { // A call is named as written, and its prescribed parse is proven: it checks clean and evaluates. expect(words(got).replace(/\[["'](\w+)["']\]/g, '.$1')).toBe(words(want)); - const fixed = index.replace(/\[\s*'(\w+)'\s*\]/g, '["$1"]').replace(String(got.params?.call), String(got.params?.rewrite)); + const fixed = index.replace(/\[\s*'(\w+)'\s*\]/g, '["$1"]').replace(String(param(got, 'call')), String(param(got, 'rewrite'))); expect(fixed).not.toBe(index); expect(check(fixed), fixed).toEqual({ ok: true, errors: [], warnings: [] }); expect(run(fixed), fixed).toEqual({ ok: true, value: true }); From 7d14868c6c956aa2afd6905d5245a2333a8f72db Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 13:26:07 +0000 Subject: [PATCH 4/6] chore(spec): ADR-0087 semantic entry and changeset for the mixed and index date-text spellings Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- .changeset/35295-date-text-mixed-spelling.md | 31 +++++++++++ ...xed-or-index-spelling-date-text-refused.ts | 51 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 .changeset/35295-date-text-mixed-spelling.md create mode 100644 packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts diff --git a/.changeset/35295-date-text-mixed-spelling.md b/.changeset/35295-date-text-mixed-spelling.md new file mode 100644 index 00000000000..382fbaed7c4 --- /dev/null +++ b/.changeset/35295-date-text-mixed-spelling.md @@ -0,0 +1,31 @@ +--- +'@objectstack/formula': minor +'@objectstack/spec': minor +--- + +fix(formula)!: a flow condition's date arithmetic that mixes a bare date field with `record.FIELD` / `previous.FIELD`, and a field read by index (`record['FIELD']`), now take the verdicts their consistent spellings already took + +Clause-②: no (narrowing) +Metadata-protocol: narrowed +Skills-docs: none — `skills/objectstack-formula/SKILL.md` already states "The build refuses date arithmetic (`end - start`, `date + n`)" and that a `date` / `datetime` field is refused in a timestamp-only call, naming no spelling those rules are limited to, so they now hold for the mixed and index spellings as written; no skill teaches the index spelling + + + +**BREAKING** accept-set narrowing. In a flow condition (a start, edge or `decision` branch condition) the run binds the record's fields under their bare names and also as `record`, with the row before the write as `previous`. A `date` or `datetime` field reaches the run as its text, so subtracting one from another faults on every run and fails the flow. Two spellings of that mistake passed `os validate` and the publish door with no finding: + +- **Mixed operands.** `due_date - record.borrow_date > duration('24h')`, `previous.due_date - due_date > duration('24h')`. The all-bare (`due_date - borrow_date …`) and all-root (`record.due_date - record.borrow_date …`) spellings were refused already. The check typed the bare names and the root reads in two separate passes, each leaving the other spelling untyped; they are now typed against the object's field table in one pass. +- **Index reads.** `timestamp(record['borrow_date']) < now()`, `record['due_date'] - record['borrow_date'] > duration('24h')`, `isoDate(record['picked_up_at']) == '2026-11-16'`. The record-root passes only looked at the member spelling. An index read of `record` or `previous` now takes every verdict the member read takes in a flow condition: the date-text call and arithmetic verdicts, date arithmetic against a number (`record['due_date'] + 1 > 5`) and the text or boolean mismatch (`record['title'] > 5`), named by its member spelling. + +- **The verdict.** The code, outcome arm and words of the consistent spelling: `date-text-arithmetic-run-fails` on a record-triggered flow or a sweep of the typed object, `-run-may-fail` elsewhere. A mixed verdict that rests on a bare name takes the bare name's `-run-may-fail` arm where a node can rebind it. +- **Where.** `os validate` / `os build` (`validateStackExpressions`) report an `error`, and the flow publish door refuses the publish with `INVALID_METADATA` (422). `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. +- **Not refused.** An operand the field table does not type keeps passing: a flow variable or node output holding an instant (`cutoff - record.due_date > duration('24h')`, `get_policy.effective_at - record.due_date > duration('24h')`), a bare name a flow variable shadows, a concatenation of the date text (`prefix + record.due_date`). The run-time evaluator is unchanged. + +## FROM → TO + +| FROM | TO | +|:---|:---| +| `due_date - record.borrow_date > duration('24h')` | `daysBetween(record.borrow_date, due_date) > 1` | +| `timestamp(record['borrow_date']) < now()` | `date(record['borrow_date']) < now()` | +| `record['due_date'] - record['borrow_date'] > duration('24h')` | `daysBetween(record['borrow_date'], record['due_date']) > 1` | + +One-line fix: in a flow condition, never subtract one date field from another or hand one to a timestamp-only call, whichever way it is spelled; use `daysBetween(a, b)` for a span, `addDays(d, n)` to shift a date and `date(…)` to parse it. diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts new file mode 100644 index 00000000000..ec74e44809f --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts @@ -0,0 +1,51 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// A flow condition's date-text verdicts now reach two spellings the consistent +// ones already took (#35295): date arithmetic whose operands mix a bare field +// name with a record.FIELD / previous.FIELD read, and the index read +// record['FIELD'] / previous['FIELD']. A structured TODO, not a D2 conversion: +// which span or shift the author meant is not recorded, and the platform does +// not guess. +export const entry: SemanticMigration = { + id: 'flow-condition-mixed-or-index-spelling-date-text-refused', + surface: + 'automation.Flow conditions (a start node config.condition, edges[].condition, a decision node\'s ' + + 'config.conditions[].expression) over the object the flow is typed against, in two spellings. (1) Arithmetic ' + + 'between two date or datetime fields where one operand is read by its bare name and the other through ' + + 'record.FIELD or previous.FIELD (due_date - record.borrow_date > duration("24h"), ' + + 'previous.due_date - due_date > duration("24h")); the all-bare and all-root spellings were refused already. ' + + '(2) A field read by index, record[\'FIELD\'] or previous["FIELD"]: it now takes every verdict the member ' + + 'read record.FIELD takes in a flow condition, the date-text call and arithmetic verdicts ' + + '(timestamp(record[\'borrow_date\']) < now(), record[\'due_date\'] - record[\'borrow_date\'] > duration("24h")), ' + + 'date arithmetic against a number (record[\'due_date\'] + 1 > 5) and the text or boolean mismatch ' + + '(record[\'title\'] > 5). Not the shape: an operand the field table does not type, a flow variable, a node ' + + 'output, or a bare name a flow variable shadows (cutoff - record.due_date > duration("24h")), which still ' + + 'passes; a concatenation of the date text (prefix + record.due_date); an ordering or equality of the read', + replacement: + 'daysBetween(a, b) for the span in whole days (daysBetween(record.borrow_date, due_date) > 1), addDays(d, n) / ' + + 'addMonths(d, n) / daysFromNow(n) to shift a date, and date(...) to parse the text before a timestamp-only call ' + + '(date(record[\'borrow_date\']) < now()). For a span in hours, wrap each side in datetime(...) and read the ' + + 'Duration: (datetime(due_date) - datetime(record.borrow_date)).getHours()', + reason: + 'A flow run binds the trigger record twice: its fields flattened to bare names, and the row itself as record, ' + + 'with the row before the write as previous. A date field reaches the run as its YYYY-MM-DD text and a datetime ' + + 'field as its ISO-8601 instant text, so a subtraction of two of them faults the evaluator on every run, and a ' + + 'flow condition that faults fails the run (ADR-0032 section 1c). The authoring type check typed the bare names ' + + 'and the root reads in two separate passes, each leaving the other spelling untyped, so a mixed subtraction ' + + 'faulted neither; and its record-root passes were gated on the member spelling, so an index read reached ' + + 'none. The bare names and the root reads are now typed against the field table in one pass, and the root ' + + 'gate admits the index read: both spellings take the code, outcome arm and words their consistent spellings ' + + 'take (date-text-arithmetic-run-fails / -run-may-fail, date-text-call-*, date-arithmetic-*, type-mismatch-*). ' + + 'A mixed verdict that rests on a bare name takes the bare name\'s weaker run-may-fail arm where a node can ' + + 'rebind it. There is no mechanical rewrite: whether the author meant a span in days, in hours or a shifted ' + + 'date is a judgement about the condition. ADR-0032 / ADR-0087.', + acceptanceCriteria: + 'os validate and os build report no date-text-arithmetic, date-text-call, date-arithmetic or type-mismatch ' + + 'finding on a flow condition that mixes a bare date field with a record or previous read in arithmetic, or ' + + 'reads a field by index; POST /api/v1/packages/PKG/publish-drafts publishes the flow; a write that should ' + + 'start it runs past the condition instead of failing there. A stored flow carrying the shape still registers ' + + '(registerFlow logs it as an advisory) and keeps failing at that condition on every run until it is ' + + 'rewritten and published.', +}; From 19b1bd6c6255487373aafe5bb2bcdc51d2d4dac1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 15:09:30 +0000 Subject: [PATCH 5/6] fix(formula): the index spelling takes the date-text verdicts only; the type-mismatch root gate stays member-only Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- packages/formula/src/cel-engine.ts | 44 +++++++++++------ .../src/validate-date-text-arithmetic.test.ts | 49 +++++++++++++++---- packages/formula/src/validate.test.ts | 2 +- packages/formula/src/validate.ts | 8 +-- 4 files changed, 74 insertions(+), 29 deletions(-) diff --git a/packages/formula/src/cel-engine.ts b/packages/formula/src/cel-engine.ts index 49baa4ac39a..beb41752562 100644 --- a/packages/formula/src/cel-engine.ts +++ b/packages/formula/src/cel-engine.ts @@ -1260,34 +1260,46 @@ function withoutNames( } /** - * [#29959, #34662] A `record.` / `previous.` read — the gate of every flattened - * record-root pass ({@link firstTypeMismatch}'s and `validate.ts`'s date-text - * one), so the two can never disagree on whether a source reads a root. - * [#35295] Spelled member-wise or by index (`record['borrow_date']`, - * `previous["due_date"]`): the typed env types the index read as the member - * read, and the run hands both the same text, so the gate admits both. + * [#29959, #34662] A `record.` / `previous.` read spelled member-wise — the gate + * of {@link firstTypeMismatch}'s flattened record-root pass. [#35295] It stays + * member-only: that pass answers before the date-text family is asked, so + * opening it to the index spelling would hand an index read the text/boolean + * mismatch verdict, which can stand a date-text refusal down to a warning and + * refuses an ordering against a text field the runtime answers. The date-text + * family has its own gate, {@link RECORD_ROOT_DATE_TEXT_READ_RE}. */ -export const RECORD_ROOT_READ_RE = /(?` / `previous.` read of a field of * `celType` in a flattened condition, as written — what - * {@link firstTypeMismatch}'s record-root pass names. [#35295] An index read - * (`record['due_date']`) is that read too, the one {@link RECORD_ROOT_READ_RE} - * admits, so it is named as its member spelling (`record.due_date`) — as - * {@link typedFieldRef} names it for a call — never as the bare name its - * quoted key would otherwise match. `null` when the field is read by neither - * spelling (a key computed at run time), so the message names no field. + * {@link firstTypeMismatch}'s record-root pass names. `null` when no such read + * is spelled member-wise (an index read, say), so the message names no field. + * [#35295] With `indexReads` (the date-text pass, which + * {@link RECORD_ROOT_DATE_TEXT_READ_RE} opens to the index spelling) an index + * read (`record['due_date']`) is named too, by its member spelling + * (`record.due_date`) — as {@link typedFieldRef} names it for a call — never as + * the bare name its quoted key would otherwise match. */ function offendingRecordRead( source: string, fieldCelTypes: Readonly>, celType: FieldCelType, + indexReads = false, ): { field: string; root: 'record' | 'previous' } | null { for (const [name, t] of Object.entries(fieldCelTypes)) { if (t !== celType) continue; - const m = new RegExp(`(? / previous. read takes the d // The run faults on the date-only text, exactly as the bare spelling does. expect(run(source), source).toMatchObject({ ok: false }); } - expect(run('timestamp(borrow_date) < now()')).toMatchObject({ ok: false }); + expect(run('timestamp(borrow_date) < now()')).toMatchObject({ ok: false, error: { message: expect.stringContaining('ISO 8601') } }); }); it('CONTROL: a datetime field under timestamp(), and the prescribed parse, stay clean and evaluate', () => { @@ -667,11 +667,12 @@ describe('a flow condition\'s record. / previous. read takes the d describe('a flow condition types bare names and record. / previous. reads in one pass, index reads included (#35295)', () => { const fieldTypes = { title: 'text', borrow_date: 'date', due_date: 'date', picked_up_at: 'datetime', returned_at: 'datetime', status: 'select', + active: 'boolean', }; const CONDITION: ExprSchemaHint = { fields: Object.keys(fieldTypes), fieldTypes, faultOutcome: 'run-fails' }; const ROW = { title: 'Dune', borrow_date: '2026-11-16', due_date: '2026-11-30', picked_up_at: '2026-11-16T09:30:00.000Z', - returned_at: '2026-11-20T09:30:00.000Z', status: 'open', + returned_at: '2026-11-20T09:30:00.000Z', status: 'open', active: true, }; const run = (source: string, extra: Record = {}) => celEngine.evaluate( { dialect: 'cel', source }, @@ -775,16 +776,46 @@ describe('a flow condition types bare names and record. / previous. reads in one } const r = run(index); expect(r.ok, index).toBe(false); - expect(r.ok ? '' : r.error.message, index).not.toMatch(/Unknown variable|undeclared reference/i); + expect(r.ok ? '' : r.error.message, index).toMatch(/no such overload|no matching overload|ISO 8601/); }); - it('the index read takes the member spelling\'s other root verdicts too: date arithmetic and the text mismatch', () => { - for (const [index, member] of [ - ["record['due_date'] + 1 > 5", 'record.due_date + 1 > 5'], - ["previous['title'] > 5", 'previous.title > 5'], + it('the index read takes the date-text verdicts and no other: arithmetic against a number is the date-text refusal, a text mismatch is not judged here', () => { + const got = refusalOf("record['due_date'] + 1 > 5"); + expect(got.code).toBe('date-text-arithmetic-run-fails'); + expect(param(got, 'reference')).toBe('record.due_date'); + const r = run("record['due_date'] + 1 > 5"); + expect(r.ok ? '' : r.error.message).toMatch(/no such overload/); + // The text/boolean mismatch pass sees an index read as it did before: never opened to it by this spelling. + const mismatch = check("previous['title'] > 5"); + expect([...mismatch.errors, ...mismatch.warnings].map((e) => e.code)).not.toContainEqual(expect.stringMatching(/^type-mismatch/)); + }); + + const NO_OUTCOME: ExprSchemaHint = { ...CONDITION, faultOutcome: undefined }; + + it('an index read\'s text mismatch never stands a date-text refusal down to a warning: refused as before, on either arm', () => { + for (const [source, family] of [ + ["due_date - borrow_date > duration('1h') && record['title'] > 5", 'date-text-arithmetic'], + ["record['active'] > 5 && isoDate(picked_up_at) == 'x'", 'date-text-call'], ] as const) { - expect({ ...refusalOf(index), source: member }).toEqual(refusalOf(member)); - expect(run(index).ok, index).toBe(false); + for (const [hint, arm] of [[NO_OUTCOME, 'run-may-fail'], [CONDITION, 'run-fails']] as const) { + const r = check(source, hint); + expect(r.ok, `${source} (${arm})`).toBe(false); + expect(r.errors.map((e) => e.code), `${source} (${arm})`).toEqual([`${family}-${arm}`]); + expect(r.warnings, `${source} (${arm})`).toEqual([]); + } + expect(run(source).ok, source).toBe(false); + } + }); + + it('CONTROL: an ordering of a date read against a text field through the index spelling stays clean, as before, and evaluates', () => { + for (const source of [ + "record['due_date'] > record['title']", + "due_date > record['title']", + "record['due_date'] > title", + "record['title'] < record['due_date']", + ]) { + for (const hint of [CONDITION, NO_OUTCOME]) expect(check(source, hint), source).toEqual({ ok: true, errors: [], warnings: [] }); + expect(run(source), source).toMatchObject({ ok: true }); } }); diff --git a/packages/formula/src/validate.test.ts b/packages/formula/src/validate.test.ts index 46ec72c5dc3..95ba9f1bebc 100644 --- a/packages/formula/src/validate.test.ts +++ b/packages/formula/src/validate.test.ts @@ -1354,7 +1354,7 @@ describe('a flow condition\'s record. / previous. read takes the d code: 'date-arithmetic-run-fails', params: { operands: 'google.protobuf.Timestamp + int', reference: 'due_date' }, }]); - expect(run('due_date + 1 > 5')).toMatchObject({ ok: false }); + expect(run('due_date + 1 > 5')).toMatchObject({ ok: false, error: { message: expect.stringContaining('no such overload') } }); for (const root of ['record', 'previous'] as const) { const source = `${root}.due_date + 1 > 5`; const errors = errorsOf(source); diff --git a/packages/formula/src/validate.ts b/packages/formula/src/validate.ts index 3664f2da496..b6dbbd4689f 100644 --- a/packages/formula/src/validate.ts +++ b/packages/formula/src/validate.ts @@ -24,7 +24,7 @@ import { firstDateTextVerdict, firstTypeMismatch, inferCelType, - RECORD_ROOT_READ_RE, + RECORD_ROOT_DATE_TEXT_READ_RE, parseCelToAst, parseCelToAstWithReason, printCelAst, @@ -951,7 +951,9 @@ const DATE_TEXT_FAMILY_RE = /^date-text-(?:call|arithmetic)(?:-|$)/; * asked only once the roots alone answered nothing, so every verdict they * prove keeps its arm, and what it adds leans on a bare name: where a node can * rebind one (`bareNamesUnproven`) it takes the bare name's weaker arm - * ({@link dateArm}). + * ({@link dateArm}). The pass reads a root spelled by index too + * (`record['borrow_date']`, its own gate `RECORD_ROOT_DATE_TEXT_READ_RE`): the + * date-text verdicts are the only ones that reach the index spelling. */ function recordRootDateTextIssue( source: string, @@ -962,7 +964,7 @@ function recordRootDateTextIssue( faultOutcome: ExprSchemaHint['faultOutcome'], bareNamesUnproven: boolean | undefined, ): { issue: ExprValidationError; severity: 'error' | 'warning' } | null { - if (!RECORD_ROOT_READ_RE.test(source) || !Object.values(celFieldTypes).includes('timestamp')) return null; + if (!RECORD_ROOT_DATE_TEXT_READ_RE.test(source) || !Object.values(celFieldTypes).includes('timestamp')) return null; const dateOnly = new Set(Object.keys(celFieldTypes).filter((name) => fieldTypes[name] === 'date')); const judged = (bare: Readonly>, arm: DateArm | null) => { const found = dateTextIssue(source, bare, 'flattened', role, arm, dateOnly, celFieldTypes); From 5b8b6af2f89c9eab2c356d3c746a34db6c7935b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Dec 2026 15:18:24 +0000 Subject: [PATCH 6/6] docs(spec): the semantic entry and changeset declare the index reach as the date-text verdicts only Claude-Session: https://claude.ai/code/session_01QSeKYnrQ7UMtHofKQVjcH2 Co-authored-by: Claude --- .changeset/35295-date-text-mixed-spelling.md | 4 +-- ...xed-or-index-spelling-date-text-refused.ts | 29 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.changeset/35295-date-text-mixed-spelling.md b/.changeset/35295-date-text-mixed-spelling.md index 382fbaed7c4..34ff6facd84 100644 --- a/.changeset/35295-date-text-mixed-spelling.md +++ b/.changeset/35295-date-text-mixed-spelling.md @@ -14,11 +14,11 @@ Skills-docs: none — `skills/objectstack-formula/SKILL.md` already states "The **BREAKING** accept-set narrowing. In a flow condition (a start, edge or `decision` branch condition) the run binds the record's fields under their bare names and also as `record`, with the row before the write as `previous`. A `date` or `datetime` field reaches the run as its text, so subtracting one from another faults on every run and fails the flow. Two spellings of that mistake passed `os validate` and the publish door with no finding: - **Mixed operands.** `due_date - record.borrow_date > duration('24h')`, `previous.due_date - due_date > duration('24h')`. The all-bare (`due_date - borrow_date …`) and all-root (`record.due_date - record.borrow_date …`) spellings were refused already. The check typed the bare names and the root reads in two separate passes, each leaving the other spelling untyped; they are now typed against the object's field table in one pass. -- **Index reads.** `timestamp(record['borrow_date']) < now()`, `record['due_date'] - record['borrow_date'] > duration('24h')`, `isoDate(record['picked_up_at']) == '2026-11-16'`. The record-root passes only looked at the member spelling. An index read of `record` or `previous` now takes every verdict the member read takes in a flow condition: the date-text call and arithmetic verdicts, date arithmetic against a number (`record['due_date'] + 1 > 5`) and the text or boolean mismatch (`record['title'] > 5`), named by its member spelling. +- **Index reads.** `timestamp(record['borrow_date']) < now()`, `record['due_date'] - record['borrow_date'] > duration('24h')`, `isoDate(record['picked_up_at']) == '2026-11-16'`, `record['due_date'] + 1 > 5`. The record-root date-text pass only looked at the member spelling; it now has a gate of its own that admits an index read of `record` or `previous`, so the index read takes the date-text verdicts the member read takes, named by its member spelling, and those only (`record['due_date'] + 1 > 5` takes `date-text-arithmetic`, where its member spelling takes `date-arithmetic`; both prescribe `daysBetween` / `addDays`). The text and boolean mismatch keeps its member-only gate: through an index read, `record['title'] > 5` and an ordering against a text field (`record['due_date'] > record['title']`) are judged exactly as before, and no refusal an expression had before is stood down to a warning. - **The verdict.** The code, outcome arm and words of the consistent spelling: `date-text-arithmetic-run-fails` on a record-triggered flow or a sweep of the typed object, `-run-may-fail` elsewhere. A mixed verdict that rests on a bare name takes the bare name's `-run-may-fail` arm where a node can rebind it. - **Where.** `os validate` / `os build` (`validateStackExpressions`) report an `error`, and the flow publish door refuses the publish with `INVALID_METADATA` (422). `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. -- **Not refused.** An operand the field table does not type keeps passing: a flow variable or node output holding an instant (`cutoff - record.due_date > duration('24h')`, `get_policy.effective_at - record.due_date > duration('24h')`), a bare name a flow variable shadows, a concatenation of the date text (`prefix + record.due_date`). The run-time evaluator is unchanged. +- **Not refused.** An operand the field table does not type keeps passing: a flow variable or node output holding an instant (`cutoff - record.due_date > duration('24h')`, `get_policy.effective_at - record.due_date > duration('24h')`), a bare name a flow variable shadows, a concatenation of the date text (`prefix + record.due_date`); through an index read, the text or boolean mismatch, an ordering against a text field and equality. The run-time evaluator is unchanged. ## FROM → TO diff --git a/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts index ec74e44809f..527f4de1507 100644 --- a/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/19.flow-condition-mixed-or-index-spelling-date-text-refused.ts @@ -16,13 +16,16 @@ export const entry: SemanticMigration = { + 'between two date or datetime fields where one operand is read by its bare name and the other through ' + 'record.FIELD or previous.FIELD (due_date - record.borrow_date > duration("24h"), ' + 'previous.due_date - due_date > duration("24h")); the all-bare and all-root spellings were refused already. ' - + '(2) A field read by index, record[\'FIELD\'] or previous["FIELD"]: it now takes every verdict the member ' - + 'read record.FIELD takes in a flow condition, the date-text call and arithmetic verdicts ' - + '(timestamp(record[\'borrow_date\']) < now(), record[\'due_date\'] - record[\'borrow_date\'] > duration("24h")), ' - + 'date arithmetic against a number (record[\'due_date\'] + 1 > 5) and the text or boolean mismatch ' - + '(record[\'title\'] > 5). Not the shape: an operand the field table does not type, a flow variable, a node ' - + 'output, or a bare name a flow variable shadows (cutoff - record.due_date > duration("24h")), which still ' - + 'passes; a concatenation of the date text (prefix + record.due_date); an ordering or equality of the read', + + '(2) A date or datetime field read by index, record[\'FIELD\'] or previous["FIELD"]: it now takes the ' + + 'date-text verdicts the member read takes, and those only: a timestamp-only call ' + + '(timestamp(record[\'borrow_date\']) < now(), isoDate(record[\'picked_up_at\'])), a subtraction of two date ' + + 'texts (record[\'due_date\'] - record[\'borrow_date\'] > duration("24h")) and arithmetic on the text against a ' + + 'number (record[\'due_date\'] + 1 > 5, as date-text-arithmetic). Not the shape: an operand the field table ' + + 'does not type, a flow variable, a node output, or a bare name a flow variable shadows ' + + '(cutoff - record.due_date > duration("24h")), which still passes; a concatenation of the date text ' + + '(prefix + record.due_date); and, through an index read, the text or boolean mismatch, an ordering against a ' + + 'text field or literal (record[\'due_date\'] > record[\'title\']) and equality, which are judged exactly as ' + + 'before', replacement: 'daysBetween(a, b) for the span in whole days (daysBetween(record.borrow_date, due_date) > 1), addDays(d, n) / ' + 'addMonths(d, n) / daysFromNow(n) to shift a date, and date(...) to parse the text before a timestamp-only call ' @@ -34,15 +37,17 @@ export const entry: SemanticMigration = { + 'field as its ISO-8601 instant text, so a subtraction of two of them faults the evaluator on every run, and a ' + 'flow condition that faults fails the run (ADR-0032 section 1c). The authoring type check typed the bare names ' + 'and the root reads in two separate passes, each leaving the other spelling untyped, so a mixed subtraction ' - + 'faulted neither; and its record-root passes were gated on the member spelling, so an index read reached ' - + 'none. The bare names and the root reads are now typed against the field table in one pass, and the root ' - + 'gate admits the index read: both spellings take the code, outcome arm and words their consistent spellings ' - + 'take (date-text-arithmetic-run-fails / -run-may-fail, date-text-call-*, date-arithmetic-*, type-mismatch-*). ' + + 'faulted neither; and its record-root date-text pass was gated on the member spelling, so an index read ' + + 'reached none of it. The bare names and the root reads are now typed against the field table in one pass, and ' + + 'the date-text pass has a gate of its own that admits the index read: both spellings take the code, outcome ' + + 'arm and words their consistent spellings take (date-text-arithmetic-run-fails / -run-may-fail, ' + + 'date-text-call-*). The text and boolean mismatch keeps its member-only gate, so no verdict an index read had ' + + 'before changes and no refusal is stood down to a warning. ' + 'A mixed verdict that rests on a bare name takes the bare name\'s weaker run-may-fail arm where a node can ' + 'rebind it. There is no mechanical rewrite: whether the author meant a span in days, in hours or a shifted ' + 'date is a judgement about the condition. ADR-0032 / ADR-0087.', acceptanceCriteria: - 'os validate and os build report no date-text-arithmetic, date-text-call, date-arithmetic or type-mismatch ' + 'os validate and os build report no date-text-arithmetic or date-text-call ' + 'finding on a flow condition that mixes a bare date field with a record or previous read in arithmetic, or ' + 'reads a field by index; POST /api/v1/packages/PKG/publish-drafts publishes the flow; a write that should ' + 'start it runs past the condition instead of failing there. A stored flow carrying the shape still registers '