You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fea0712
Browse filesBrowse the repository at this point in the historyBrowse files
docs(skills): teach a validation rule message's {{ }} holes (#38787)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9SNzk6FfxPPrxLwCB5BftuN)_
Part of #37909 — PR 3 of the ruling's sequencing (skills and docs),
claim amendment 5 (7279412658). PR 1 (#38687, merged as 9cbb41b) is the
doors; PR 2 (#38736, merged as 49c09ed) is the render. This PR
teaches what the merged tree does.
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:没有运行时变化;技能 objectstack-data 与文档「Validation
metadata」页开始教规则提示语里的 `{{ record.字段 }}` 占位、格式化器、币种规则(你选的
A)、看不到的字段留空、译文先填、提示语是纯文本。
- 为什么做:维护者已裁(P3);前两步已合入,这是第三步,让写元数据的 AI 和人知道怎么写、写了会显示什么。
- 出错会怎样:最坏是教错一句,AI 写出的提示语被发布校验拒(会点名正确写法)或某个占位显示为空;不影响任何保存是否被拒。
- 要你做什么:skills 是受管面,请 os-zhuang 审批;ratchet 行按「A:先削重复,余额按实测提高」抬了 235 个
token(先删了 699 字节重复)。
## What changes
Ruling P3 (card comment 7239726323), the currency ruling A (7277046538),
and the items PR 1's and PR 2's contract records left to this PR.
- **`skills/objectstack-data/rules/validation.md`** gains § Messages —
Record Values in Holes: the `record` / `previous` roots (`previous`
empty on insert), one segment, own fields; the formatter whitelist with
`| currency:EUR`; what the doors refuse (a single brace, a read through
a field, another root, logic); a bare `| currency` in the organization's
default currency, and with none set that hole empty while the server log
names the setting (ruling A); a field holding its own currency names the
code or uses `| number:2` (PR 2 contract record, E2); a field the person
whose write was refused cannot read, or sees masked, renders empty,
`default:` included; the translation takes the same holes and is filled
first; the sentence is plain text (PR 2 contract record: "PR 3's docs
should say the sentence is text").
- **`content/docs/data-modeling/validation.mdx`** — the `message` row of
Common Properties points at a new § Messages with a worked example, the
two roots, the formatter table, currency, the field floor (including
writes an automation makes on someone's behalf, and a person-less system
write), translations and plain text.
- **`content/docs/ui/translations.mdx`** — the one bullet that said a
validation message is "substituted whole — there is no interpolation …
`{variable}` placeholders in it are not filled", false since PR 2, now
says a translation fills the same `{{ }}` holes, translation first, the
fallback, and that a single brace is refused at publish.
-
**`packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts`**
— PR 1's contract record N3: the example renamed the field between FROM
(`{received}`) and TO (`record.received_amount`); FROM now reads
`{received_amount}`. One word; nothing else in the entry moves.
### Token ratchet (`scripts/check-skills-token-ratchet.mjs`)
`skills/objectstack-data/rules/validation.md` had no headroom (3862 /
3862). Paid down first inside the file: § Incorrect vs Correct and its
table-of-contents entry are deleted, since its one example (a rule with
no `events` runs on insert and update; scope it with `events:
['update']`) restates § Events, which stays. -699 bytes cut, +1638
added: 15448 -> 16387 bytes (+939) -> `ceil(16387 / 4)` = 4097 tokens;
the row moves 3862 -> 4097, the measured remainder, pinned at the
measurement. Raise path: the standing maintainer ruling 2026-10-27
「A:先削重复,余额按实测提高」 (ruling record 6513306068). `SKILL.md` gains no byte.
No other row moves.
### Outside the original claimed file surface
The seat widened the surface by its relay of 2026-11-30T13:21Z:
`content/docs/ui/translations.mdx` (that one bullet), the ratchet row,
the `.changeset` note, and the one word in the semantic entry.
## Acceptance notes
- Read before writing: the merged `rule-message-render.ts`,
`engine-rule-message-rendering.ts`, the formula `templateEngine`
formatters (`TEMPLATE_FORMATTERS`, `splitHoleFormatter`) and
`ExecutionContext.timezone`.
- Plain text: no console error or toast renderer in `ui/packages` puts a
message through `dangerouslySetInnerHTML` (the files that use it are
page HTML, rich text, charts, markdown and code blocks).
`@object-ui/core`'s deprecated `ObjectValidationEngine` was not audited
(PR 2 contract record, outside the diff).
- Out of scope: PR 1's N4 (private copies of the hole grammar, a code
dedupe) and PR 2's N3 (`packages/lint/src/seed-row-refusals.ts` prints
blank holes), as the seat agreed; PR 2's N2 and N7 stand as recorded; N8
is #38759.
- No eval case: the file surface holds no eval file.
## Verification
Head `17319d01f6c6dfc2eb9b7c9ef0daebf764eed391`, on main `49c09ed902`.
- Full build: `bash scripts/pm/os-verify-lock.sh -c 'pnpm build
--concurrency=2'` → VERDICT command-exit 0 (123/123 tasks).
- Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`, re-derived after the last commit, same
133): each run with stdin closed, recorded `cmd :: exit N`. All 133 exit
0.
- First round on `995a1318c6`: 132 green, `pnpm check:skill-links` red —
the table-of-contents link `#messages--record-values-in-holes` did not
match the heading, whose code span slugs to
`messages--record-values-in---holes`. Root fix in `17319d01f6`: the
heading drops the code span (its body shows the holes), the link now
resolves, and the ratchet row is pinned at the new measurement (4097).
The 15 skills / changeset / ratchet gates were re-run on the new head,
all exit 0; no other file changed.
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran=FILE` → 133 derived, 133 run, 0 NOT-MEASURED, 0 UNRUN.
- `node scripts/check-skills-token-ratchet.mjs` and `--self-test` → exit
0; `node scripts/check-skill-links.mjs` → 290 links, 161 fragments
resolve.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs
<!-- signed: repo:objectstack@os-steve · os-steve ·
session_01ADHkmQ6vV3YvhJWKF1gSDs -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
docs(skills): the objectstack-data validation rules teach a rule message's `{{ }}` holes
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
`skills/objectstack-data/rules/validation.md` gains § Messages — Record Values in Holes, teaching what the refusal sentence does since validation rule messages were rendered at run time: a hole names one of the object's own fields under `record` (the judged record) or `previous` (the stored row before an update, empty on insert), with at most one whitelisted formatter; a bare `| currency` formats in the organization's default currency, and with none set that hole renders empty while the server log names the setting (Setup → Localization); a field holding its own currency names the code (`| currency:EUR`) or uses `| number:2`; a field the person whose write was refused cannot read, or sees masked, renders empty, `default:` included; a translation at `objects.<object>._validations.<rule>.message` takes the same holes and is filled first; the sentence is plain text.
12
+
13
+
§ Incorrect vs Correct is gone: its one example (a rule with no `events` runs on insert and update; scope it with `events: ['update']`) restated § Events.
14
+
15
+
The upgrade entry `validation-rule-message-template-holes` (`@objectstack/spec`) names the same field before and after in its example: `Total {total_price} is below {received_amount}` becomes `Total {{ record.total_price | currency }} is below {{ record.received_amount | currency }}`.
|`message`|`string`| ✅ |The sentence a refused write returns to the person; may show the record's values in `{{ }}` holes ([Messages](#messages))|
78
78
|`events`|`enum[]`| optional | When to run: `'insert'`, `'update'` (default: `['insert', 'update']`). No `'delete'` — guard deletions with a `beforeDelete` lifecycle hook |
@@ -300,6 +300,51 @@ Apply validation only when a condition is met:
300
300
301
301
The outer conditional evaluates the `when` CEL predicate, then recurses into `then` (when true) or `otherwise` (when false). The nested rule supplies the violation message; the conditional itself carries the required base `message`.
302
302
303
+
## Messages
304
+
305
+
A rule's `message` is the sentence the person who saved reads when the rule refuses the write. It is a `{{ }}` template, so it can say by how much a limit was crossed, not only that it was:
message: 'Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}).',
314
+
}
315
+
```
316
+
317
+
A refused save then reads `Total $1,200.00 is below what was received ($1,500.00).`
318
+
319
+
**What a hole may name.** One of the object's own fields, one segment deep, under one of two roots:
320
+
321
+
| Root | Holds |
322
+
| :--- | :--- |
323
+
|`record`| The record the rule judged: the stored row with this write applied |
324
+
|`previous`| The stored row before an update. On insert there is none, so a `previous` hole renders empty |
325
+
326
+
`objectstack validate`, `objectstack compile` and the publish gate refuse a single-brace token (`{total_price}`, `${total_price}`), a hole over any other root (`{{ user.name }}`), a hole that reads through a field (`{{ record.account.name }}`), a field the object does not declare, and logic in a hole. Each refusal names the spelling to use. A rule stored before these checks keeps loading and is judged at its next save.
327
+
328
+
**Formatters.** A hole takes at most one, after a `|`. Values are formatted in the language the refusal is negotiated in:
329
+
330
+
| Formatter | Renders |
331
+
| :--- | :--- |
332
+
|`number`, `number:2`| A grouped number, optionally with fixed decimals |
333
+
|`currency`, `currency:EUR`| An amount in the organization's default currency, or in the ISO 4217 code written in capitals |
334
+
|`percent`, `percent:1`| A 0–1 ratio as a percentage |
335
+
|`date`, `date:long`, `date:iso`| A calendar date |
336
+
|`datetime`, `datetime:long`, `datetime:iso`| An instant, in the organization's time zone, UTC when none is set (`iso` stays UTC) |
337
+
|`upper`, `lower`, `trim`, `truncate:80`| Text, changed or cut with an ellipsis |
338
+
|`default:'n/a'`| The text given, when the field is empty |
339
+
340
+
**Currency.** A bare `| currency` formats in the organization's default currency, set in Setup → Localization (`localization.currency`). When none is set, that hole renders empty, the rest of the sentence still fills, and the server log names the rule and the setting to fill. An amount is never shown in a currency nobody chose. A `currency` field that carries its own currency (a per-record or fixed currency) is still formatted in the organization's default by a bare `| currency`; name the code (`| currency:EUR`) or use `| number:2` for such a field.
341
+
342
+
**Fields the person cannot read stay empty.** A hole shows a value only when the person whose write was refused may read that field unmasked. A field they cannot read, a field masked for them, and a password, secret or internal field render empty, and `default:` does not fill them. The same holds when an automation writes on someone's behalf: a `runAs: 'system'` flow someone started, an action, an approval step. The sentence is worded for that person, so it shows what they may read. A system write that names no person (a schedule, a platform job) is read only in the server log, and shows every field but password, secret and internal ones. If the platform cannot tell what the person may read, every hole renders empty and the server log says why. Whether the write is refused never depends on the message.
343
+
344
+
**Translations.** A translated message at `objects.<object>._validations.<rule>.message` reads the same holes and is filled first. If it does not render, the authored message is filled instead and the server log names the translation.
345
+
346
+
**Plain text.** The filled sentence is text, never markup: a value shows exactly as stored, so a client must render it as text.
347
+
303
348
## Priority
304
349
305
350
When multiple validations exist, `priority` controls execution order:
0 commit comments