From 56dcfb1e8610749cadcfdbd8b8e0c10655582e8e Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:23:13 +0000 Subject: [PATCH 1/3] docs(skills): label() over a multi-select reads each selected label, joined The objectstack-formula built-ins table now says what the formula engine does for a select with `multiple: true`: label() reads each selected value's option label in the reader's locale, in stored order, joined with ", "; an empty selection reads ''. One eval case exercises it. Claude-Session: https://claude.ai/code/session_01ADHkmSXPDB46NVRepWVrL3 Co-authored-by: Claude --- skills/objectstack-formula/SKILL.md | 2 +- .../evals/cel-predicates-formulas.json | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/skills/objectstack-formula/SKILL.md b/skills/objectstack-formula/SKILL.md index eaad399726a..1484787cb03 100644 --- a/skills/objectstack-formula/SKILL.md +++ b/skills/objectstack-formula/SKILL.md @@ -213,7 +213,7 @@ 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.`; `''` 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.`; `''` 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)`. diff --git a/skills/objectstack-formula/evals/cel-predicates-formulas.json b/skills/objectstack-formula/evals/cel-predicates-formulas.json index 3b61565993b..1365e5c2681 100644 --- a/skills/objectstack-formula/evals/cel-predicates-formulas.json +++ b/skills/objectstack-formula/evals/cel-predicates-formulas.json @@ -100,6 +100,16 @@ "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."] + } } ] } From 6879097717615cb4837333e57c80585c34634dc8 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:23:37 +0000 Subject: [PATCH 2/3] docs(skills): timestamp() over a date field is refused; shift a date with addDays The objectstack-formula built-ins line now says what the formula gate refuses: timestamp() parses only a full ISO instant, so over a date field (YYYY-MM-DD text) the build refuses it as date-text-call, plus-duration arithmetic included, and a date is shifted with isoDate(addDays(record.d, n)). One eval case exercises it. Claude-Session: https://claude.ai/code/session_01ADHkmSXPDB46NVRepWVrL3 Co-authored-by: Claude --- skills/objectstack-formula/SKILL.md | 5 ++++- .../evals/cel-predicates-formulas.json | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/skills/objectstack-formula/SKILL.md b/skills/objectstack-formula/SKILL.md index 1484787cb03..4c0b056a8a5 100644 --- a/skills/objectstack-formula/SKILL.md +++ b/skills/objectstack-formula/SKILL.md @@ -216,7 +216,10 @@ tests: every entry resolves at runtime, and this table documents them all. | `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.`; `''` 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; diff --git a/skills/objectstack-formula/evals/cel-predicates-formulas.json b/skills/objectstack-formula/evals/cel-predicates-formulas.json index 1365e5c2681..704dafc4c22 100644 --- a/skills/objectstack-formula/evals/cel-predicates-formulas.json +++ b/skills/objectstack-formula/evals/cel-predicates-formulas.json @@ -110,6 +110,16 @@ "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."] + } } ] } From 3890dfea2e4ff342ebf70812ff26c5a291b52015 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 22:24:28 +0000 Subject: [PATCH 3/3] docs(skills): pay the formula skill's two teachings down first, raise by the remainder Three restatements in skills/objectstack-formula/SKILL.md are cut, each keeping its other 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 section 5 previous table). The token ceiling moves by the measured remainder only, 5997 -> 6008, under the standing ruling recorded as 6513306068. Changeset for the two cards. Claude-Session: https://claude.ai/code/session_01ADHkmSXPDB46NVRepWVrL3 Co-authored-by: Claude --- ...a-skill-multiselect-label-timestamp-date.md | 14 ++++++++++++++ scripts/check-skills-token-ratchet.mjs | 18 +++++++++++++++++- skills/objectstack-formula/SKILL.md | 6 ++---- 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 .changeset/34444-formula-skill-multiselect-label-timestamp-date.md diff --git a/.changeset/34444-formula-skill-multiselect-label-timestamp-date.md b/.changeset/34444-formula-skill-multiselect-label-timestamp-date.md new file mode 100644 index 00000000000..64d54edb367 --- /dev/null +++ b/.changeset/34444-formula-skill-multiselect-label-timestamp-date.md @@ -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). diff --git a/scripts/check-skills-token-ratchet.mjs b/scripts/check-skills-token-ratchet.mjs index 5914db2d453..38af93dda09 100644 --- a/scripts/check-skills-token-ratchet.mjs +++ b/scripts/check-skills-token-ratchet.mjs @@ -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 diff --git a/skills/objectstack-formula/SKILL.md b/skills/objectstack-formula/SKILL.md index 4c0b056a8a5..d83179412f1 100644 --- a/skills/objectstack-formula/SKILL.md +++ b/skills/objectstack-formula/SKILL.md @@ -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 — @@ -402,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 @@ -466,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