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
14 changes: 14 additions & 0 deletions .changeset/34444-formula-skill-multiselect-label-timestamp-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/skills': patch
---

docs(skills): `objectstack-formula` teaches `label()` over a multi-select and the `timestamp()` refusal over a date field

Clause-②: no
Metadata-protocol: none

The `label(record.f)` row of the `objectstack-formula` built-ins table now says what a select with `multiple: true` reads: each selected value's option label in the reader's locale, in the order the record stores them, joined with `, `; an empty selection reads `''`, as null does.

The built-ins line that lists `timestamp(s)` now says that `timestamp()` parses only a full ISO instant, so over a `date` field (its `YYYY-MM-DD` text) the build refuses it as `date-text-call`, inside `+ duration(…)` arithmetic too, and that a date is shifted with `isoDate(addDays(record.d, n))`. Both are the behaviour `@objectstack/formula` already ships; the skill only teaches it. One eval case covers each.

Paid down first under the standing ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068): three restatements were cut, each keeping another home — the `has()` paragraph's null-check sentence (the cheat-sheet `Null check` row), the template section's `shared/expression.zod.ts` sentence (Core contract and See also), and the translation-table note's per-matched-row clause (the §5 `previous` table). The token ceiling moves by the measured remainder, +11 (5997 → 6008).
18 changes: 17 additions & 1 deletion scripts/check-skills-token-ratchet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,23 @@ export const CEILINGS = new Map([
// raise path is the standing 2026-10-27 ruling, verbatim and untranslated:
// 「A:先削重复,余额按实测提高」 (ruling record 6513306068).
['skills/objectstack-data/SKILL.md', 6665],
['skills/objectstack-formula/SKILL.md', 5997], // -53 (was 6055), then -5 A2′ (was 6002)
// 5997 -> 6008 (the formula skills follow-ups of PRs #34443 and #34447): the
// `label(record.f)` row teaches a multi-select (`multiple: true`) reading each
// selected label in stored order, joined with `, `, and the built-ins line
// teaches that `timestamp()` over a `date` field is refused (`date-text-call`)
// and that a date shifts with `isoDate(addDays(record.d, n))`. Raise path the
// standing ruling 「A:先削重复,余额按实测提高」 (ruling record 6513306068,
// letter B). PAID DOWN FIRST — three restatements cut, each keeping its other
// home (listed in the PR body): the `has()` paragraph's null-check sentence
// (the cheat-sheet `Null check` row), the template section's
// `shared/expression.zod.ts` sentence (Core contract and See also), and the
// translation-table note's per-matched-row clause (§5's table). Arithmetic in
// priced bytes (stamp line excluded), against `main`'s 23952 (headroom 9): the
// text adds 321, the cuts remove 243, so the LANDED priced text is 24030
// bytes -> ceil(24030 / 4) = 6008; the ceiling moves +11, the measured
// remainder only. Pinned AT the measurement.
// ceil(($(wc -c < skills/objectstack-formula/SKILL.md) - 20) / 4) == ceil(24030 / 4)
['skills/objectstack-formula/SKILL.md', 6008], // -53 (was 6055), then -5 A2′ (was 6002), then +11 (was 5997)
['skills/objectstack-i18n/SKILL.md', 6333], // -11 (was 6349), then -5 A2′ (was 6338)
// 12705 -> 12984 (2026-08-31 app-repo-principles raise, see the block above).
// The largest of the five and the frame the other four are read under: what an
Expand Down
13 changes: 7 additions & 6 deletions skills/objectstack-formula/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ ADR-0068 — spec field docs write predicates like `current_user.positions`.
### `has()` is NOT a null check

`has(record.x)` is **true whenever the key exists**, even when its value is
`null`. To check for "value present and non-blank" use the stdlib helper
`isBlank()` or compare to `null` explicitly.
`null`.

Every server-evaluated predicate — validation rules, `requiredWhen`, option
`visibleWhen`, `readonlyWhen`, hook `condition`, the flow trigger record —
Expand Down Expand Up @@ -213,10 +212,13 @@ tests: every entry resolves at runtime, and this table documents them all.

| Function | Returns | Notes |
|:---|:---|:---|
| `label(record.f)` | string | A select value's option label in the reader's locale: `'v' + string(record.version_no) + ' · ' + label(record.kind)` reads `v2 · 清稿` (zh-CN), `v2 · Clean` (en-US). Only `record.<field>`; `''` for null. A stored (non-formula) field stores the declared label. Formula fields only: in a predicate (validation, visibility, hook) it faults, so compare the stored value |
| `label(record.f)` | string | A select value's option label in the reader's locale: `'v' + string(record.version_no) + ' · ' + label(record.kind)` reads `v2 · 清稿` (zh-CN), `v2 · Clean` (en-US). Only `record.<field>`; `''` for null or an empty selection. A multi-select (`multiple: true`) reads each selected label in stored order, joined with `, `. A stored (non-formula) field stores the declared label. Formula fields only: in a predicate (validation, visibility, hook) it faults, so compare the stored value |

Plus CEL built-ins: `has(x)`, `size(x)`, `int(x)`, `string(x)`, `bool(x)`,
`double(x)`, `timestamp(s)`, `duration(s)`.
`double(x)`, `timestamp(s)`, `duration(s)`. `timestamp()` parses only a full
ISO instant, so over a `date` field (`YYYY-MM-DD`) the build refuses it
(`date-text-call`), `+ duration(…)` included; shift a date with
`isoDate(addDays(record.d, n))`.

> Receiver methods (`s.split(',')`,
> `list.map(...)`) are called on a value, never bare, and are not in this table;
Expand Down Expand Up @@ -399,7 +401,7 @@ When migrating Salesforce-flavor metadata, apply these rules in order:

> ⚠️ `OLD.x` and `ISCHANGED(x)` both land on `previous.x`, which is `null` on an
> insert event and **fails the write** there unless guarded by `previous != null
> &&`; on update and delete events it is bound per matched row — see §5.
> &&` (§5).

> ⚠️ **Flow conditions are the exception to row 1.** The engine spreads the
> trigger record's fields, nulls included, to top level wherever no flow variable
Expand Down Expand Up @@ -463,7 +465,6 @@ a bare string (auto-wrapped) or their helper, and read the same variable scope.
| `cron` | `` cron`0 6 * * MON` `` | 5- or 6-field cron, or one of `@yearly` `@annually` `@monthly` `@weekly` `@daily` `@hourly` `@reboot` | `Job.schedule.expression` (canonical) |
| `template` | `` tmpl`Hello {{ record.first_name }}` `` | `{{ path }}` or `{{ path \| formatter[:arg] }}` — double braces only, no conditionals; the formatter whitelist is `TEMPLATE_FORMATTERS`, exported from `@objectstack/formula` | `system/email-template` `subject` / `bodyHtml` / `bodyText`, `ai/model-registry` `promptTemplate.system` / `.user`, `Object.titleFormat` (a save and `os validate` refuse it; move it to `nameField`, ADR-0079) |

`shared/expression.zod.ts` declares both surfaces and their carriers.
Missing template paths render as the empty string. Move logic into a CEL field.
A `currency` argument is a
literal code (`currency:EUR`); only an email template may read it from the send's
Expand Down
20 changes: 20 additions & 0 deletions skills/objectstack-formula/evals/cel-predicates-formulas.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@
"must_contain": ["isoDate(date(record.start_at))", "F`"],
"must_not_contain": ["isoDate(record.start_at)", "{record."]
}
},
{
"id": 11,
"prompt": "On `quote_line`, `no_margin_reasons` is a select field with `multiple: true`. Add a `margin_note` formula that shows the selected reasons as text, in the reader's language.",
"expected_output": "`F`label(record.no_margin_reasons)``. On a multi-select, `label()` reads each selected value's option label in the reader's locale, in the order the record stores them, joined with `, ` (`No sales price, No customer` to an `en-US` reader); an empty selection reads `''`. No per-option ternary or extra field is needed.",
"files": [],
"assertions": {
"must_contain": ["label(record.no_margin_reasons)", "F`"],
"must_not_contain": ["joinNonEmpty", "{record."]
}
},
{
"id": 12,
"prompt": "On `loan`, add a `due_on` formula: 7 days after the `borrow_date` date field, as `YYYY-MM-DD` text.",
"expected_output": "`F`isoDate(addDays(record.borrow_date, 7))``. A `date` field reads as its `YYYY-MM-DD` text, and `timestamp()` parses only a full ISO instant, so the build refuses `timestamp()` over the field, alone or plus a duration (`date-text-call`). `addDays` shifts the date by whole days and `isoDate` keeps the result a date.",
"files": [],
"assertions": {
"must_contain": ["isoDate(addDays(record.borrow_date, 7))", "F`"],
"must_not_contain": ["timestamp(record.borrow_date)", "{record."]
}
}
]
}
Loading