Skip to content

Commit 65ce798

Browse files
docs(skills): objectstack-formula says == / != on a list-valued field is refused and teaches the null-guarded membership test (#36354)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9JpRoUZGqtwqMU5k7b4C58D)_ Fixes #36217 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:照着对外发布的公式技能写条件的 AI 作者,现在会被告知「多值字段不能直接拿来和单个值比较相等或不相等」,并按条件所在的位置拿到对应的正确写法:普通条件、流程条件、共享规则条件各一种;此前技能对此只字未提。 - 为什么做:校验器已经开始拒绝这种比较(它在每一行上都得出同一个答案,条件永远不变),这是「多值字段相等比较收紧」那项工作欠下的技能配套,替写多选、标签类字段条件的作者解决「被拒了却不知道该怎么改」的问题;共享规则那一种写法尤其要紧,照普通写法写出来的共享规则不会授予任何人权限。 - 出错会怎样:只改技能文字、两道技能自测题和一条发布说明,不动任何代码与契约;最坏情况是作者读到一段讲得不清楚的说明,直接撤回本次改动即可恢复原文。 - 要你做什么:审批这个受治理的技能改动(技能目录属于需要你亲自批准的范围);席位会先完成自己的核对与达档复审再来请你。 ## What changes `skills/objectstack-formula/SKILL.md`, the published formula skill, gains a note directly under the CEL cheat-sheet's operator table. It says that `==` / `!=` between a list-valued field and a scalar literal is refused, names the refusal as the validator emits it, names which fields are list-valued, and shows the refused form beside the rewrite the refusal prescribes at each site, for `==` and for `!=`: ```text record.tags == 'vip' # REFUSED # evaluated as CEL; has() covers a sparse action row and a null `previous` (has(record.tags) && record.tags != null && 'vip' in record.tags) (!has(record.tags) || record.tags == null || !('vip' in record.tags)) # bare name in a flow condition (has() takes no bare name) (tags != null && 'vip' in tags) (tags == null || !('vip' in tags)) # SharingRule `condition`: compiled to a query filter, where has() and a literal-first `in` do not lower (record.tags != null && record.tags.contains('vip')) (record.tags == null || !record.tags.contains('vip')) ``` The six rewrites are what `listMembershipRewrite` (`packages/formula/src/validate.ts`) returns at each site, read on `origin/main` at 9abc732 after merging it into this branch; the file is unchanged up to dda5e74. The skill writes the literal single-quoted where the validator prints it double-quoted; nothing else differs, and a probe compares the two mechanically (see Tests). The three sites: - **evaluated as CEL** (a `record.` / `previous.` read): the `in` test, guarded by `has()` and `!= null`. `has()` is what keeps the test from faulting on an action's sparse row and on a `previous` that is `null`. - **a bare name in a flow condition**: the `in` test behind `!= null` alone, because `has()` takes no bare name. - **a sharing rule's `condition`**: `.contains()`. That condition is never evaluated as CEL. It is compiled to a query filter, where `in` lowers only with a field on its left and `has()` does not lower at all, so the CEL spelling there is refused at build and the rule grants nothing. This is the one site lint marks as filter-compiled (`packages/lint/src/validate-expressions.ts`, the sharing-rule `check` call). Every rewrite is parenthesised whole, as the validator writes it, so it can stand where the comparison stood (`A && (…)`). The list of list-valued fields is now the full set: `multiselect` / `checkboxes` / `tags` (`MULTI_OPTION_TYPES`), and `select` / `radio` / `lookup` / `user` / `file` / `image` with `multiple: true` (`MULTI_CAPABLE_TYPES`, `packages/spec/src/data/field-value.zod.ts`). The note no longer offers `.exists()`. The validator prescribes `in` and `.contains()`, and the eval case grades the `in` spelling. ### Paid for by deletion, ceiling unchanged The file had 32 tokens of headroom under its ratchet ceiling (6008), and the note costs more. No ceiling was raised. Twelve restatements were cut from the same file, each keeping another home. The first six were in the head reviewed before; the last six pay for the per-site spellings. | Cut | Where it still lives | |:---|:---| | the `has()` section's opening sentence ("true whenever the key exists") | the cheat-sheet row `Key existence (NOT null-safety)`, the section heading, and the paragraph that follows | | the Salesforce-flavor block's clause "`os build` errors with a located message, and the flow engine throws" | the `Verify your work` section | | "Hook conditions and validation predicates bind the same two roots" | the `previous` table directly under it, and the cheat-sheet row `Previous record (update hooks, validation rules)` | | "Record-change flow triggers ride the same dispatch" | the `previous` table's `after*` row, which names the record-change flow trigger | | "It is a refusal, never a silent downgrade to one hook call" | the same paragraph's "the platform refuses a predicate write" | | the translation table's double-quoted-string row | the cheat-sheet row `String literal` ("CEL parses the double-quoted form too") | | the stdlib intro's "there is no `src/` to read in an installed app" | the same sentence's "ships `dist` only" | | "Use `daysBetween(a, b)` for whole days, two `datetime(…)` for hours (row below)" in the date-arithmetic note | the table directly under it: rows `Inclusive span`, `Tenure in years` and `Hours between` | | the `Sub-day offset` row's "the calendar helpers land on UTC midnight" | the Dates table rows for `today()`, `daysFromNow(n)` and `daysAgo(n)`, each "at UTC midnight" | | the parenthesis "`previous.status`, where `previous` is `null`" in the unevaluable-condition warning | the `previous` table's insert row: `null`, and "a column read off it (`previous.x`) has no value and faults" | | the second transition-condition code block (`previous.status != 'done' && record.status == 'done'`) | the section's first example, the same shape with another value (`previous.status != 'escalated' && record.status == 'escalated'`); the sentence it illustrated stays | | the first half of the translation table's warning ("`OLD.x` and `ISCHANGED(x)` both land on `previous.x`, which is `null` on an insert event") | the `OLD.x` and `ISCHANGED(x)` rows directly above it, and the `previous` table's insert row; the warning keeps "`previous.x` fails the write on an insert unless guarded by `previous != null &&`" | Skill size readings (lines are the measure; tokens as the ratchet counts them): | | Before (`origin/main` 9abc732) | After (5dfda71) | |:---|---:|---:| | `skills/objectstack-formula/SKILL.md`, lines | 491 | 493 (+2) | | same file, priced tokens / ceiling | 5976 / 6008 | 6007 / 6008 | | all `skills/*/SKILL.md`, lines | 4950 | 4952 (+2) | | ratcheted authored bundle, tokens / ceiling | 197507 / 202541 | 197538 / 202541 | | whole shipped tree, tokens | 290262 | 290686 | `.changeset/36217-formula-skill-list-equality.md`: a `patch` for `@objectstack/skills`, which ships the `skills/**` tree through its `dist`. Its text follows the note: the three spellings, the twelve cuts, the two eval cases. Two eval cases exercise the note, in `skills/objectstack-formula/evals/cel-predicates-formulas.json`: - **13**, a hook `condition` over a `tags` field (evaluated as CEL): must contain `record.labels != null`, `in record.labels` and the `P` tag. It now forbids the wrong literal as a wrong answer writes it, the `P` tag followed by `record.labels == 'urgent'`, and no longer the bare comparison, which a correct answer names as the thing refused. Its reference answer is the validator's spelling. - **14**, a sharing rule `condition` over the same field: must contain `record.labels != null` and `record.labels.contains(`, and forbids the wrong literal and a `has(record.labels) &&` guard, which does not lower. Eval fixtures are measured by the token ratchet, not ratcheted. ## Tests Nothing here changes tested behaviour, so there is no ablation. Two throwaway probes, both at 5dfda71. <details><summary>The six rewrites against the validator, the evaluator and the filter compiler</summary> A probe read the six rewrite lines out of the skill file and ran `validateExpression`, `celEngine.evaluate`, `compileCelToFilter` and `matchesFilterCondition` from `packages/formula/src` over them (run with `tsx`, `@objectstack/spec` resolved to its source). Last line: `PROBE OK: 0 unexpected`. | Check | Reading | |:---|:---| | each line equals `params.rewrite` of the `list-equality` refusal at its site (quote character aside): CEL site `==` and `!=`, flow site `==` and `!=`, sharing rule `==` and `!=` | 6 of 6 equal | | each line is accepted by the validator at its site | 6 of 6 accepted | | CEL-site lines evaluated on a list holding the value / not holding it / empty / `null` / key absent | `==`: `true` / `false` / `false` / `false` / `false`; `!=`: the negation; no fault | | CEL-site lines on `previous = null` | `==` `false`, `!=` `true`, no fault | | flow-site lines on the same rows bound as top-level names (key absent does not occur there) | `==`: `true` / `false` / `false` / `false`; `!=`: the negation | | sharing-rule lines lowered by `compileCelToFilter` and matched against the same five rows | lower; match exactly the rows where the value is a member (`!=`: the others) | | CONTROL: the two CEL-site lines, and plain `record.tags != null && 'vip' in record.tags`, handed to `compileCelToFilter` | `not lowered: unsupported`, all three | | each type the note names is refused: `multiselect`, `checkboxes`, `tags`; `select`, `radio`, `lookup`, `user`, `file`, `image` with the field named multi-valued | 9 of 9 refused as `list-equality` | | CONTROL: the six multi-capable types, not multiple | 0 of 6 refused | </details> <details><summary>The eval file's reference answers under its own grader</summary> `gradeAnswer` (`packages/qa/scenarios/src/skill-evals/grade.ts`) over each case's `expected_output`, cases parsed by the runner's own `parseEvalFile`: | Tree | Reading | |:---|:---| | d319685 (the head reviewed before; control) | cases 1 to 12 PASS; case 13 FAIL, `forbidden=["record.labels == 'urgent'"]` | | 5dfda71 | cases 1 to 14 PASS | Named answers at 5dfda71, each graded as expected: case 13 passes the note's CEL spelling and the plain null-guarded `in` spelling, and fails the refused form and the `.contains()` spelling; case 14 passes the note's `.contains()` spelling (single- or double-quoted, with or without the `P` tag), and fails the CEL spelling, a `has()`-guarded `.contains()` and the refused form. </details> ## Acceptance notes - The cuts fall outside the operator-table area the claim's file surface describes, inside the same file. They are the payment the ratchet asks for; each row above names the surviving home. - After this change the file's headroom is 1 token (4 bytes). - Not taught, for the byte budget: at a sharing rule the validator passes a number or boolean literal to `.contains()` as its text (`record.f == 3` becomes `record.f.contains("3")`); and at a flow condition the refusal fires only where the run is proven to bind a row of the typed object. Neither changes what an author should write for a text value; the refusal's own message carries the exact rewrite in both cases. - The card's two bare membership forms (`'x' in record.tags`, `record.tags.exists(t, t == 'x')`) are accepted by the validator and fault on a `null` list. The skill teaches the validator's guarded forms and does not offer `.exists()`. Noted here and not filed. - Read, not measured: the skill's "Surfaces" section says an unevaluable `SharingRule` `condition` "aborts the write". The lint rule for sharing rules (`packages/lint/src/validate-sharing-rule-enforceability.ts`) describes a different outcome for a condition that does not lower: a build error, and at runtime a rule that is skipped and grants nothing, with one WARN line. That sentence is outside this card and was left as it is. Noted here and not filed. - `main` moved from 9abc732 to dda5e74 after the merge. The seven commits touch no file under `skills/`, `packages/formula/`, the sharing-rule call in lint, the eval grader or the token ratchet, so the branch was not merged again. ## Verification Read first: the new note under the cheat-sheet table in `skills/objectstack-formula/SKILL.md` beside `listMembershipRewrite` in `packages/formula/src/validate.ts`, then the twelve deletions in the same diff, then cases 13 and 14 in the eval file. Two-minute check: `node scripts/check-skills-token-ratchet.mjs` — expect the formula row to read `6007 / 6008` and every file within its ceiling. <details><summary>Local gates at 5dfda71</summary> The derived set (`node scripts/pm/dispatch-gates.mjs --commands`, 49 commands) was run in full; `--ran` reconciliation: "49 derived famil(ies) accounted for — 44 run, 5 NOT-MEASURED (5 DERIVED from a recorded exit 3)". 44 exited 0, among them `node scripts/check-skills-token-ratchet.mjs` ("6007 tokens (ceiling 6008; headroom 1)"), `pnpm --filter @objectstack/spec run check:skill-docs` ("Skill docs in sync"), `pnpm check:skill-links`, `pnpm check:skill-identifier-liveness`, `pnpm check:skill-compatibility`, `pnpm check:skill-frame-sync`, `pnpm check:doc-authoring`, `pnpm check:nul-bytes`, `pnpm check:published-files`, `node scripts/check-empty-changeset.mjs --base origin/main`, `node scripts/check-changeset-no-major.mjs --base origin/main`. NOT MEASURED locally (exit 3, prerequisite not met: each reads built package output): `pnpm --filter @objectstack/lint run check:doc-formula-expressions`, `pnpm check:dts-closure`, `pnpm check:dual-build-cjs-loads`, `pnpm check:lean-entry-closure`, `pnpm check:sourcemap-no-sources-content`. The build they need never got the container's shared verify lock: three waits of 5, 540 and 540 seconds, all `queue-timeout`, behind one dogfood run that held the lock for more than 80 minutes. CI ran them on this head: all 29 completed check-runs on 5dfda71 are `success` (16 more are skipped), among them Lint & Repo Gates, Lint · docs & code guards, Lint · repo & tooling gates, Lint · PM dispatch-gates, TypeScript Type Check, Type Check · source gates, Build Core, Test Core, Check Changeset and Governed Surface Queue Guard. Outside the derived set: `pnpm --filter @objectstack/spec run check:skill-refs` exit 0 ("10 generated files in sync"). </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01ADHkmRY38EZf38Yy3zthbY <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmRY38EZf38Yy3zthbY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ee651ce commit 65ce798

3 files changed

Lines changed: 69 additions & 27 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/skills': patch
3+
---
4+
5+
docs(skills): `objectstack-formula` says that `==` / `!=` between a list-valued field and a scalar is refused, and teaches the membership test each site takes
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The CEL cheat-sheet of the `objectstack-formula` skill gains a note under its operator table: `==` / `!=` between a list-valued field (`multiselect`, `checkboxes`, `tags`, or a `select` / `radio` / `lookup` / `user` / `file` / `image` field with `multiple: true`) and a scalar literal is refused by the validator as `list-equality` ("list compared with a scalar"), because CEL compares the whole list and the expression answers one constant on every row. The note shows the refused form and the rewrite the refusal prescribes at each site, null-guarded (`in` faults on a `null` list) and parenthesised whole, for `==` and for `!=`:
11+
12+
- where the expression is evaluated as CEL: `(has(record.tags) && record.tags != null && 'vip' in record.tags)` and `(!has(record.tags) || record.tags == null || !('vip' in record.tags))`; the `has()` covers a sparse action row and a `previous` that is `null`;
13+
- a bare name in a flow condition: `(tags != null && 'vip' in tags)` and `(tags == null || !('vip' in tags))`, since `has()` takes no bare name;
14+
- a sharing rule's `condition`, which is compiled to a query filter: `(record.tags != null && record.tags.contains('vip'))` and `(record.tags == null || !record.tags.contains('vip'))`, since `has()` and an `in` with the literal first do not lower there.
15+
16+
This is the behaviour `@objectstack/formula` already ships; the skill only teaches it.
17+
18+
Paid for by deletion in the same file, with the token ceiling unchanged (6008): twelve restatements were cut, each keeping another home — the `has()` section's opening sentence (the cheat-sheet `Key existence (NOT null-safety)` row and the paragraph that follows it), the Salesforce-flavor block's `os build` / runtime clause (the `Verify your work` section), the sentence saying hook conditions and validation predicates bind the same two roots (the `previous` table under it), the sentence saying record-change flow triggers ride the same dispatch (the same table's `after*` row), the closing "It is a refusal" sentence of the 10 000-row paragraph (that paragraph's own "the platform refuses"), the translation table's `"abc"` row (the cheat-sheet `String literal` row), the stdlib intro's "there is no `src/` to read" clause (the same sentence's "ships `dist` only"), the "use `daysBetween` / two `datetime(…)`" sentence of the date-arithmetic note (the table under it), the sub-day-offset row's "the calendar helpers land on UTC midnight" (the `today()` / `daysFromNow` / `daysAgo` rows), the "`previous.status`, where `previous` is `null`" parenthesis of the unevaluable-condition warning (the `previous` table's insert row), the second transition-condition example (the section's first example, the same shape), and the first half of the translation table's `previous.x` warning (the `OLD.x` and `ISCHANGED(x)` rows above it and the same insert row).
19+
20+
Two eval cases exercise the note: a hook `condition` over a `tags` field (the CEL spelling) and a sharing rule `condition` over the same field (the `.contains()` spelling).

‎skills/objectstack-formula/SKILL.md‎

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,30 @@ transforms — see objectstack-data), not an expression dialect.
8282
| Key existence (NOT null-safety) | `has(record.foo)` |
8383
| Null check | `record.foo == null` or `isBlank(record.foo)` |
8484

85+
**`==` / `!=` between a list field and a scalar literal is refused** (`list-equality`, "list compared
86+
with a scalar": one constant on every row) — `multiselect` / `checkboxes` / `tags`, or `select` /
87+
`radio` / `lookup` / `user` / `file` / `image` with `multiple: true`. Test membership, null-guarded
88+
(`in` faults on `null`) and parenthesised, per site — the `==` rewrite, then the `!=` one:
89+
90+
```text
91+
record.tags == 'vip' # REFUSED
92+
# evaluated as CEL; has() covers a sparse action row and a null `previous`
93+
(has(record.tags) && record.tags != null && 'vip' in record.tags)
94+
(!has(record.tags) || record.tags == null || !('vip' in record.tags))
95+
# bare name in a flow condition (has() takes no bare name)
96+
(tags != null && 'vip' in tags)
97+
(tags == null || !('vip' in tags))
98+
# SharingRule `condition`: compiled to a query filter, where has() and a literal-first `in` do not lower
99+
(record.tags != null && record.tags.contains('vip'))
100+
(record.tags == null || !record.tags.contains('vip'))
101+
```
102+
85103
The org context is `{ id, tier }` — there is no `os.org.slug` or `os.org.name`.
86104
The evaluator also binds the current user as `current_user` (alias `user`) per
87105
ADR-0068 — spec field docs write predicates like `current_user.positions`.
88106

89107
### `has()` is NOT a null check
90108

91-
`has(record.x)` is **true whenever the key exists**, even when its value is
92-
`null`.
93-
94109
Every server-evaluated predicate — validation rules, `requiredWhen`, option
95110
`visibleWhen`, `readonlyWhen`, hook `condition`, the flow trigger record —
96111
reads a `record` (and, where §5 binds it, a `previous`) that is **total over
@@ -140,8 +155,7 @@ has(record.viewer) && has(record.viewer.can_approve) && record.viewer.can_approv
140155

141156
## ObjectStack CEL standard library
142157

143-
Registered automatically by `@objectstack/formula`, which ships `dist` only —
144-
there is no `src/` to read in an installed app. Its exported
158+
Registered automatically by `@objectstack/formula`, which ships `dist` only. Its exported
145159
`CEL_STDLIB_FUNCTIONS` is the advertised bare-callable subset, pinned by two
146160
tests: every entry resolves at runtime, and this table documents them all.
147161

@@ -166,15 +180,15 @@ tests: every entry resolves at runtime, and this table documents them all.
166180
167181
> **No date arithmetic.** The build refuses `date + n` and `end - start`: a
168182
> date or date-time mixed with a number, or minus another, reads `null`, and
169-
> `today()` / `now()` minus a date field reads `{}`. Use `daysBetween(a, b)` for whole days, two `datetime(…)` for hours (row below).
183+
> `today()` / `now()` minus a date field reads `{}`.
170184
171185
| Want | Write — never bare `end - start`, `date + n`, `today() + 30` |
172186
|:---|:---|
173187
| Inclusive span | `daysBetween(record.start_date, record.end_date) + 1` |
174188
| Shift a date | `daysFromNow(n)` / `addDays(d, n)` / `addMonths(d, n)` |
175189
| Tenure in years | `daysBetween(record.hire_date, today()) / 365` |
176190
| Hours between | `double((datetime(record.end_at) - datetime(record.start_at)).getMinutes()) / 60.0` |
177-
| Sub-day offset | `now() + duration("3h")` — the calendar helpers land on UTC midnight |
191+
| Sub-day offset | `now() + duration("3h")` |
178192

179193
**Numbers**
180194

@@ -278,8 +292,7 @@ P`!isBlank(record.po_number)`;
278292

279293
Conditional requiredness: [objectstack-data](../objectstack-data/SKILL.md#conditional-field-rules).
280294

281-
❌ Salesforce-flavor — **fails CEL compile**: `os build` errors with a
282-
located message, and the flow engine throws if it ever reaches runtime:
295+
❌ Salesforce-flavor — **fails CEL compile**:
283296

284297
```ts
285298
"status = 'qualified'"
@@ -321,8 +334,7 @@ P`previous.status != 'escalated' && record.status == 'escalated'`
321334
`record` is the record's **state**, not this write's diff: stored row ⊕
322335
payload, so `record.status == 'escalated'` is true on *every* update of an
323336
already-escalated record. Comparing against `previous` is the only way to say
324-
"just became". Hook `condition`s and validation predicates bind the same two
325-
roots — one scope, one meaning, whichever surface reads it.
337+
"just became".
326338

327339
**Where `previous` is bound, and where it is not:**
328340

@@ -336,7 +348,7 @@ roots — one scope, one meaning, whichever surface reads it.
336348
| `before*` hook `condition` on a predicate (`multi: true`) write | **that row's pre-write row** — `beforeUpdate` / `beforeDelete` dispatch once PER MATCHED ROW too, each on a single-record-shaped context whose `input.id` names the row (ADR-0058 Addendum II, D1/D2); `record` is that row's state, stored ⊕ payload, as on any update. Only the *payload* stays batch-scoped — see below the table |
337349

338350
⚠️ **An unevaluable condition ABORTS the operation.** A column read off
339-
`previous` on an insert (`previous.status`, where `previous` is `null`) — like
351+
`previous` on an insert — like
340352
a typo'd key (`record.stauts`), a retired field, or a comparison CEL has no
341353
overload for — does **not** degrade to "the hook did not fire": it **fails the
342354
write**, with an error naming the hook and the key — `before*` and `after*`
@@ -345,19 +357,12 @@ the condition is evaluated before any handler runs).
345357

346358
**A transition condition needs no special handling for bulk writes.**
347359
Write it once, on a `before*` or an `after*` event, and it means the same thing
348-
whether the write carries an id or a predicate:
349-
350-
<!-- os:check -->
351-
```ts
352-
import { P } from '@objectstack/spec';
353-
P`previous.status != 'done' && record.status == 'done'`
354-
```
360+
whether the write carries an id or a predicate.
355361

356362
A predicate (`multi: true`) write is N record changes, so every record-scoped
357363
declaration on it is evaluated **per row** — `previous` is that row's own
358364
pre-write state, `record` its real state, not the bare payload (ADR-0058,
359-
bulk-write Addenda I and II). Record-change flow triggers ride the same
360-
dispatch. `before*` is no exception to the *condition*; the asymmetry is what a
365+
bulk-write Addenda I and II). `before*` is no exception to the *condition*; the asymmetry is what a
361366
`before*` handler WRITES: one `updateMany` takes one SET clause, so every row's
362367
dispatch carries the one payload and a rewrite made on any row applies to every
363368
matched row (D3). A rewrite *decided* per row must assign the same key set on
@@ -369,8 +374,7 @@ batch whole, before any write, when two rows disagree
369374
Above 10 000 matched rows the platform refuses a predicate write on an object
370375
with per-row hooks in either phase — one ceiling for `before*` and `after*`,
371376
checked before the first dispatch (ADR-0058 Addendum II, D6) — rather than fan
372-
out that many handler runs inside one write; paginate the write. It is a
373-
refusal, never a silent downgrade to one hook call.
377+
out that many handler runs inside one write; paginate the write.
374378

375379
---
376380

@@ -388,7 +392,6 @@ When migrating Salesforce-flavor metadata, apply these rules in order:
388392
| `AND` | `&&` |
389393
| `OR` | `\|\|` |
390394
| `NOT(x)` | `!x` |
391-
| `"abc"` | `'abc'` |
392395
| `IF(c, a, b)` | `c ? a : b` |
393396
| `ISBLANK(x)` | `isBlank(record.x)` |
394397
| `CONCAT(a, b)` | `coalesce(a, '') + coalesce(b, '')` |
@@ -397,9 +400,8 @@ When migrating Salesforce-flavor metadata, apply these rules in order:
397400
| `ISCHANGED(x)` | `previous.x != record.x` |
398401
| `MONTH_DIFF`, `MID`, `LEFT`, `RIGHT`, `SUBSTITUTE` | _not in stdlib — propose addition_ |
399402

400-
> ⚠️ `OLD.x` and `ISCHANGED(x)` both land on `previous.x`, which is `null` on an
401-
> insert event and **fails the write** there unless guarded by `previous != null
402-
> &&` (§5).
403+
> ⚠️ `previous.x` **fails the write** on an insert unless guarded by
404+
> `previous != null &&` (§5).
403405
404406
> ⚠️ **Flow conditions are the exception to row 1.** The engine spreads the
405407
> trigger record's fields, nulls included, to top level wherever no flow variable

‎skills/objectstack-formula/evals/cel-predicates-formulas.json‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,26 @@
120120
"must_contain": ["isoDate(addDays(record.borrow_date, 7))", "F`"],
121121
"must_not_contain": ["timestamp(record.borrow_date)", "{record."]
122122
}
123+
},
124+
{
125+
"id": 13,
126+
"prompt": "On `ticket`, `labels` is a `tags` field. Write the hook `condition` that is true when the ticket carries the `urgent` label.",
127+
"expected_output": "`P`(has(record.labels) && record.labels != null && 'urgent' in record.labels)``. `labels` holds a list, so `record.labels == 'urgent'` compares the whole list with a scalar and is refused (`list-equality`): it answers `false` on every row. A hook `condition` is evaluated as CEL, so membership is `in`, behind a `!= null` guard, because `in` faults on a `null` list.",
128+
"files": [],
129+
"assertions": {
130+
"must_contain": ["record.labels != null", "in record.labels", "P`"],
131+
"must_not_contain": ["P`record.labels == 'urgent'", "{record."]
132+
}
133+
},
134+
{
135+
"id": 14,
136+
"prompt": "On `ticket`, `labels` is a `tags` field. Write the sharing rule `condition` that matches the tickets carrying the `urgent` label.",
137+
"expected_output": "`P`(record.labels != null && record.labels.contains('urgent'))``. A sharing rule's `condition` is compiled to a query filter, not evaluated as CEL, so membership is `.contains()`: `has()` and an `in` with the literal first do not lower there, and the rule would grant nothing. `record.labels == 'urgent'` compares the whole list with a scalar and is refused (`list-equality`).",
138+
"files": [],
139+
"assertions": {
140+
"must_contain": ["record.labels != null", "record.labels.contains("],
141+
"must_not_contain": ["P`record.labels == 'urgent'", "has(record.labels) &&", "{record."]
142+
}
123143
}
124144
]
125145
}

0 commit comments

Comments
 (0)