From 51553a52cb3340249c7f4ff14faa4e31ccb2e54c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 02:56:09 +0000 Subject: [PATCH 1/3] feat(lint)!: a validation rule message is a {{ }} template over the judged record (wip) Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs Co-authored-by: Claude --- .../src/data/objects/account.object.ts | 2 +- .../src/system/translations/index.ts | 10 +- packages/lint/src/authoring-rules.ts | 18 +- packages/lint/src/validate-expressions.ts | 35 +++ .../src/validate-rule-message-templates.ts | 212 ++++++++++++++++++ packages/spec/src/data/validation.zod.ts | 35 ++- ....validation-rule-message-template-holes.ts | 35 +++ packages/spec/src/system/translation.zod.ts | 14 +- 8 files changed, 353 insertions(+), 8 deletions(-) create mode 100644 packages/lint/src/validate-rule-message-templates.ts create mode 100644 packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts diff --git a/examples/app-showcase/src/data/objects/account.object.ts b/examples/app-showcase/src/data/objects/account.object.ts index 8c02c73a842..40b95f9f5f5 100644 --- a/examples/app-showcase/src/data/objects/account.object.ts +++ b/examples/app-showcase/src/data/objects/account.object.ts @@ -181,7 +181,7 @@ export const Account = ObjectSchema.create({ label: 'Support Config Shape', description: 'Support config must declare a known tier and a positive seat count.', field: 'support_config', - message: 'Support Config must be { tier: standard|premium|enterprise, seats?: >=1 }.', + message: 'Support Config must name a tier (standard, premium or enterprise) and, if it sets seats, at least 1 seat.', schema: { type: 'object', properties: { diff --git a/examples/app-showcase/src/system/translations/index.ts b/examples/app-showcase/src/system/translations/index.ts index 184a7ea7493..915dd453d5c 100644 --- a/examples/app-showcase/src/system/translations/index.ts +++ b/examples/app-showcase/src/system/translations/index.ts @@ -162,7 +162,7 @@ export const ShowcaseTranslationBundle = { message: 'Billing Email must be a valid email address.', }, support_config_shape: { - message: 'Support Config must be { tier: standard|premium|enterprise, seats?: >=1 }.', + message: 'Support Config must name a tier (standard, premium or enterprise) and, if it sets seats, at least 1 seat.', }, churn_reason_consistency: { message: 'Churn reason consistency.', @@ -644,13 +644,15 @@ export const ShowcaseTranslationBundle = { // there. Vocabulary is the one this bundle already established: // 生命周期 / 税号 / 账单邮箱 / 支持配置 / 流失原因 are the field labels // right above, so a refusal names the field with the same word the form - // does. The `support_config_shape` shape stays in its source spelling — - // it is a machine contract the author must type back, not prose. + // does. The `support_config_shape` sentence keeps the machine words + // `tier` / `seats` and the tier values in their source spelling — they + // are what the author types back — but no braces: a rule message is a + // `{{ }}` template, and a single-brace token there is refused. _validations: { account_lifecycle: { message: '客户生命周期的状态流转无效。' }, tax_id_format: { message: '税号格式应为 12-3456789。' }, billing_email_format: { message: '账单邮箱必须是有效的邮箱地址。' }, - support_config_shape: { message: '支持配置必须为 { tier: standard|premium|enterprise, seats?: >=1 }。' }, + support_config_shape: { message: '支持配置必须指定 tier(standard、premium 或 enterprise);如填写 seats,至少为 1。' }, churn_reason_consistency: { message: '流失原因一致性。' }, churn_reason_present: { message: '客户标记为流失时必须填写流失原因。' }, churn_reason_absent: { message: '只有客户已流失时才能填写流失原因。' }, diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index 337571bb04d..e667f798c02 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -922,8 +922,24 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ // build alike (`object 'TARGET' · objectExtensions[0] · validation 'N'`). // MEASURED first: 0 first-party `objectExtensions` entries carry a // validation rule (examples/**, packages/**, HotCRM). + // + // [#37909, ruling P3] A validation rule's `message` is a `{{ }}` template + // over `record` / `previous` (`validate-rule-message-templates.ts`): the + // object and extension walks judge each rule's message, nested branches + // included, so an `object` or `object_extension` write carrying a refused + // one answers 422. `translation` joins, for ONE pass: each translated rule + // message of the written item (`objects.OBJECT._validations.RULE.message`), + // judged as the authored message is; on a translation write + // `runStackExpressionPasses` runs that pass alone, by construction. Every + // finding is an `error` (a narrowing no conversion carries: the message + // stays a string, so a stored rule or bundle keeps loading until its next + // save). MEASURED first over the shipped corpus at `1fef2ed7c4`: 40 rule + // messages and 196 translations (examples/**, platform-objects, the + // plugins and services) → 3 refused, the showcase `support_config_shape` + // message and its two translations, reworded in the same change; 0 carry + // a `{{ }}` hole. surfaces: CLI_AND_RUNTIME, - runtimeTypes: ['flow', 'action', 'hook', 'object', 'view', 'page', 'object_extension'], + runtimeTypes: ['flow', 'action', 'hook', 'object', 'view', 'page', 'object_extension', 'translation'], run: (stack, ctx) => runStackExpressionPasses(stack, { runtimeWriteType: ctx.runtimeWriteType, diff --git a/packages/lint/src/validate-expressions.ts b/packages/lint/src/validate-expressions.ts index a14e272cc13..f80eff12bdf 100644 --- a/packages/lint/src/validate-expressions.ts +++ b/packages/lint/src/validate-expressions.ts @@ -120,6 +120,12 @@ import { bulkConfirmTemplateRoots } from '@objectstack/spec/ui'; // is a `template` slot too, judged in its own module by the same judge. import { actionCopyTemplateIssues } from './validate-action-copy-templates.js'; import { actionRefusalTemplateIssues, hookRefusalTemplateIssues } from './validate-hook-refusal-templates.js'; +import { + ruleMessages, + ruleMessageTemplateIssues, + ruleMessageTranslationIssues, + VALIDATION_MESSAGE_SLOT, +} from './validate-rule-message-templates.js'; import { workingDayElsewhereMessage, workingDayValueSiteIssues } from './validate-working-day-sites.js'; // [#15137] The `value`-role half. Same two published primitives the engine // composes at `registerFlow` (`AutomationEngine.valueEnvelopeRefusals`), in the @@ -2648,6 +2654,14 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression if (options.runtimeWriteType === 'page') { return actionCopyTemplateIssues(stack, { actions: false, objects: false, pages: true }); } + // [#37909, ruling P3] On a `translation` write exactly ONE pass judges too — + // the translated validation-rule messages of the written item + // (`validate-rule-message-templates.ts`), each a `{{ }}` template over the + // judged record, against the door's live objects. Every other pass reads a + // collection a translation write does not carry. + if (options.runtimeWriteType === 'translation') { + return ruleMessageTranslationIssues(stack, { atSaveDoor: true, fields: buildFieldIndex(recordsOf(stack.objects)) }); + } // [#33154] The extension door hands the objects as the registry SERVES // them, and a served definition carries the system columns the registry // injects (`created_at`, `owner_id`, …) as declared fields; the build reads @@ -4110,6 +4124,22 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression checkNullGuards(`${locus} · ${p.label}`, p.label, p.raw, objectName, ruleOutcome); atSlot(p.key, first); } + // [#37909, ruling P3] The rule's `message` — and each nested branch's — + // is a `{{ }}` template over `record` / `previous`: a single-brace token, + // a hole over another root, a hole that is not one of the object's own + // fields one segment deep, logic and an unknown formatter are errors + // (`validate-rule-message-templates.ts`). The object's fields are read as + // served (`fieldIndex`), so a field an extension adds resolves. + const fields = objectName !== undefined ? fieldIndex.get(objectName) : undefined; + for (const m of ruleMessages(rule)) { + issues.push(...ruleMessageTemplateIssues(m.text, { + where: `${where} ${m.label}message`, + ...(rulePath ? { path: `${rulePath}.${m.key}` } : {}), + slot: VALIDATION_MESSAGE_SLOT, + objectName, + fields, + })); + } }; // ── Object validation-rule + formula predicates ──────────────────── @@ -4931,6 +4961,11 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression // `defaultValue` (every run) or a seed record's expression value (off an // object write), the two value sites the passes above do not walk. issues.push(...workingDayValueSiteIssues(stack, { data: !objectWrite })); + // [#37909, ruling P3] Each translated validation-rule message + // (`objects.OBJECT._validations.RULE.message`), judged as the authored + // message is, off an object write (the object write's snapshot carries no + // bundle; a `translation` write ran this pass alone, above). + if (!objectWrite) issues.push(...ruleMessageTranslationIssues(stack, { atSaveDoor: false, fields: fieldIndex })); return issues; } diff --git a/packages/lint/src/validate-rule-message-templates.ts b/packages/lint/src/validate-rule-message-templates.ts new file mode 100644 index 00000000000..45f1e759a61 --- /dev/null +++ b/packages/lint/src/validate-rule-message-templates.ts @@ -0,0 +1,212 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [#37909, ruling P3] Judge a validation rule's `message` — and each of its + * `objects.OBJECT._validations.RULE.message` translations — as the ADR-0032 §3 + * `{{ }}` template it is, over the judged record. + * + * The roots are the spec's, `VALIDATION_MESSAGE_TEMPLATE_ROOTS` + * (`@objectstack/spec/data`): `record`, the merged record the rule judged, and + * `previous`, the stored row before an update. Three steps, the action copy + * pass's two (`validate-action-copy-templates.ts`) and one that is the rule + * message's own: + * + * 1. `closedScopeTemplateRefusal` (`@objectstack/spec/automation`, the one + * reading of the single-brace dialect) names a single-brace `{…}` or + * `${…}` token — with its `{{ }}` spelling where a bound root spells it — + * and a hole over a root the message does not bind. A message carrying + * neither goes on. + * 2. It is compiled as the `template` it is (`validateExpression('template', + * …)`), which names a hole holding logic, an unknown formatter and an + * empty hole. + * 3. Each hole over `record` or `previous` names one of the object's own + * fields, one segment deep: a bare root, a read through a field + * (`{{ record.account.name }}`) and — where the object's fields are known + * — a field the object does not declare would render a blank fragment, + * and each is named. An argument-less `currency` formatter is not refused + * here: the rule message formats in the organization's default currency. + * + * Every finding is an ERROR: `objectstack validate` and `compile` fail, and the + * publish gate refuses an `object`, `object_extension` or `translation` write + * carrying one. The message stays a string and the parse does not judge it, so + * a stored rule or bundle keeps loading until its next save; the save is + * judged. + */ + +import { validateExpression } from '@objectstack/formula'; +import { closedScopeTemplateRefusal } from '@objectstack/spec/automation'; +import { VALIDATION_MESSAGE_TEMPLATE_ROOTS } from '@objectstack/spec/data'; +import { nearestName } from './object-graph.js'; +import type { ExprIssue } from './validate-expressions.js'; + +type AnyRec = Record; + +const isRec = (v: unknown): v is AnyRec => typeof v === 'object' && v !== null && !Array.isArray(v); + +/** How a finding names an authored rule message. */ +export const VALIDATION_MESSAGE_SLOT = "A validation rule's `message`"; + +/** How a finding names a translated rule message. */ +export const VALIDATION_MESSAGE_TRANSLATION_SLOT = "A validation rule's translated `message`"; + +/** Every `{{ … }}` hole of a sentence — the template engine's `HOLE_RE`, its inner text as written. */ +const HOLE = /\{\{([^}]*)\}\}/g; + +/** A hole's path — the template engine's `PATH_ONLY_RE`; a hole that fails it is the compile step's to name. */ +const HOLE_PATH = /^[\w$.[\]]+$/; + +const ROOTS: ReadonlySet = new Set(VALIDATION_MESSAGE_TEMPLATE_ROOTS); + +/** A path's segments as the engine resolves them (`[i]` read as `.i`). */ +function segmentsOf(path: string): string[] { + return path.replace(/\[(\w+)\]/g, '.$1').split('.').filter((segment) => segment !== ''); +} + +/** + * The refusal of each hole over `record` / `previous` that does not name one + * of the object's own fields, one segment deep. `fields` is the object's field + * names as served, or `undefined` when the object is not known here — then only + * the depth is judged. + */ +function holeShapeRefusals(text: string, fields: readonly string[] | undefined, objectName: string | undefined): string[] { + const out: string[] = []; + const seen = new Set(); + for (const m of text.matchAll(HOLE)) { + const hole = m[0]; + if (seen.has(hole)) continue; + seen.add(hole); + const inner = m[1]!; + const bar = inner.indexOf('|'); + const path = (bar === -1 ? inner : inner.slice(0, bar)).trim(); + if (!HOLE_PATH.test(path)) continue; + const segments = segmentsOf(path); + const root = segments[0]; + if (root === undefined || !ROOTS.has(root)) continue; + if (segments.length === 1) { + out.push( + `\`${hole}\` names the whole \`${root}\`, which renders no sentence: name one of its fields, ` + + `\`{{ ${root}.FIELD }}\`.`, + ); + continue; + } + if (segments.length > 2) { + out.push( + `\`${hole}\` reads through \`${segments[1]}\`, and a hole in a validation rule's message names one of the ` + + `object's own fields, one segment deep (\`{{ ${root}.${segments[1]} }}\`): compute the value into a field ` + + 'of the object and name that field.', + ); + continue; + } + const field = segments[1]!; + if (fields === undefined || fields.includes(field)) continue; + const near = nearestName(field, fields); + out.push( + `\`${hole}\` names \`${field}\`, which object '${objectName ?? '?'}' does not declare, so the hole renders a ` + + `blank fragment: name one of its fields${near === undefined ? '' : ` (did you mean \`${root}.${near}\`?)`}.`, + ); + } + return out; +} + +/** Where one judged sentence is reported. */ +export interface RuleMessageSite { + /** The human locator every finding opens with. */ + readonly where: string; + /** The sentence's key path, absent when the authored collection has no index to spell. */ + readonly path?: string; + /** How a refusal names the slot. */ + readonly slot: string; + /** The object the rule runs on. */ + readonly objectName: string | undefined; + /** The object's field names as served, or `undefined` when they are not known here. */ + readonly fields: readonly string[] | undefined; +} + +/** Every finding one rule message (or one translation of it) draws, at `site`. */ +export function ruleMessageTemplateIssues(text: unknown, site: RuleMessageSite): ExprIssue[] { + if (typeof text !== 'string') return []; + const issues: ExprIssue[] = []; + const refuse = (message: string, source: string): void => { + issues.push({ where: site.where, message, source, severity: 'error', ...(site.path ? { path: site.path } : {}) }); + }; + const refusal = closedScopeTemplateRefusal(text, { slot: site.slot, roots: VALIDATION_MESSAGE_TEMPLATE_ROOTS }); + if (refusal !== undefined) { + refuse(refusal, text); + return issues; + } + const compiled = validateExpression('template', text).errors; + for (const e of compiled) refuse(e.message, e.source); + if (compiled.length > 0) return issues; + for (const message of holeShapeRefusals(text, site.fields, site.objectName)) refuse(`${site.slot}: ${message}`, text); + return issues; +} + +/** + * Every message a rule carries, with the key suffix and the locator suffix it + * is named at: the rule's own `message`, and each nested `conditional` + * branch's (`then.message`, `otherwise.then.message`, …), at every depth. + */ +export function ruleMessages(rule: AnyRec): Array<{ key: string; label: string; text: unknown }> { + const out: Array<{ key: string; label: string; text: unknown }> = []; + const walk = (r: AnyRec, key: string, label: string): void => { + out.push({ key: `${key}message`, label, text: r.message }); + for (const branch of ['then', 'otherwise'] as const) { + const nested = r[branch]; + if (!isRec(nested)) continue; + const name = typeof nested.name === 'string' ? nested.name : '?'; + walk(nested, `${key}${branch}.`, `${label}${branch} → '${name}' `); + } + }; + walk(rule, '', ''); + return out; +} + +/** A bundle key as a config-path member: `.en`, or `["zh-CN"]` for a tag carrying `-`. */ +function member(key: string): string { + return /^[A-Za-z_$][\w$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`; +} + +/** How {@link ruleMessageTranslationIssues} reads the stack. */ +export interface RuleMessageTranslationOptions { + /** + * The runtime publish gate's `translation` write: `translations[0]` is the + * written ITEM (one bundle entry plus its `locale`), not a bundle of locales. + */ + readonly atSaveDoor: boolean; + /** Field names by object, as served — an object it does not carry is judged on depth alone. */ + readonly fields: ReadonlyMap; +} + +/** + * Every finding the translated rule messages of `stack.translations` draw — + * each `objects.OBJECT._validations.RULE.message`, judged as the authored + * message is (see the module header). + */ +export function ruleMessageTranslationIssues(stack: AnyRec, options: RuleMessageTranslationOptions): ExprIssue[] { + const issues: ExprIssue[] = []; + const bundles = Array.isArray(stack.translations) ? stack.translations : []; + bundles.forEach((bundle: unknown, bi: number) => { + if (!isRec(bundle)) return; + const entries: Array<[string, unknown, string]> = options.atSaveDoor + ? (typeof bundle.locale === 'string' ? [[bundle.locale, bundle, `translations[${bi}]`]] : []) + : Object.entries(bundle).map(([locale, data]) => [locale, data, `translations[${bi}]${member(locale)}`]); + for (const [locale, data, base] of entries) { + if (!isRec(data) || !isRec(data.objects)) continue; + for (const [objectName, node] of Object.entries(data.objects)) { + if (!isRec(node) || !isRec(node._validations)) continue; + for (const [ruleName, entry] of Object.entries(node._validations)) { + if (!isRec(entry)) continue; + issues.push(...ruleMessageTemplateIssues(entry.message, { + where: `locale "${locale}" · object "${objectName}" · validation "${ruleName}" message`, + path: `${base}.objects${member(objectName)}._validations${member(ruleName)}.message`, + slot: VALIDATION_MESSAGE_TRANSLATION_SLOT, + objectName, + fields: options.fields.get(objectName), + })); + } + } + } + }); + return issues; +} + diff --git a/packages/spec/src/data/validation.zod.ts b/packages/spec/src/data/validation.zod.ts index 7e7301269ec..7e3a688606b 100644 --- a/packages/spec/src/data/validation.zod.ts +++ b/packages/spec/src/data/validation.zod.ts @@ -122,6 +122,39 @@ import { MetadataProtectionFields } from '../kernel/metadata-protection.zod'; * not enforcement. */ import { lazySchema } from '../shared/lazy-schema'; +/** + * The roots a hole in a validation rule's `message` may name — and in each of + * its `objects.OBJECT._validations.RULE.message` translations (ADR-0032 §3, + * one delimiter, `{{ }}`). + * + * - `record` — the merged record the rule judged: the prior row overlaid with + * the write, the record its `condition` read. + * - `previous` — the stored row before an update; it holds nothing on insert. + * + * A hole names one of the object's own fields, one segment deep + * (`{{ record.total_price }}`), with an optional formatter from the template + * engine's whitelist (`{{ record.total_price | currency }}`), never logic. + * `objectstack validate`, `objectstack compile` and the runtime publish gate + * judge every rule message and every translation against these roots with + * `closedScopeTemplateRefusal` (`automation/flow-text-slot-template.ts`) and + * then compile it as a `template`: a single-brace `{…}` token, a hole over + * another root, a hole reaching through a field, a hole over a field the + * object does not declare, logic and an unknown formatter are each an error. + * The message stays a string; a stored rule that carries a refused message + * keeps loading and is judged at its next save. + */ +export const VALIDATION_MESSAGE_TEMPLATE_ROOTS = ['record', 'previous'] as const; + +/** The `.describe()` text of a validation rule's `message`, shared by the six variants. */ +const VALIDATION_MESSAGE_DESCRIPTION = + 'The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. ' + + 'A hole names one of the object\'s own fields, one segment deep, under `record` (the merged record the rule ' + + 'judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: ' + + '`Total {{ record.total_price | currency }} is below what was received ({{ record.received_amount | currency }}).` ' + + 'A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at ' + + '`objectstack validate`, `compile` and the publish gate. Stays a string; translate it at ' + + '`objects.OBJECT._validations.RULE.message`, which reads the same holes.'; + /** * Keys every validation-rule variant shares. * @@ -154,7 +187,7 @@ const BASE_VALIDATION_SHAPE = { // Feedback severity: z.enum(['error', 'warning', 'info']).default('error'), - message: z.string().describe('Error message to display to the user'), + message: z.string().describe(VALIDATION_MESSAGE_DESCRIPTION), // ADR-0010 — runtime protection envelope (internal — set by the loader). ...MetadataProtectionFields, diff --git a/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts b/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts new file mode 100644 index 00000000000..2193deabb28 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/19.validation-rule-message-template-holes.ts @@ -0,0 +1,35 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// A validation rule's `message`, and each of its translations, is an ADR-0032 +// `{{ }}` template over the judged record (`record`, and `previous` on +// update); the doors refuse a single-brace token there. Semantic only: the +// message was plain text and a brace in it was shown as written, so no +// conversion knows whether a brace was prose or meant as a hole; the message +// stays a string, so a stored rule keeps loading until its next save. +export const entry: SemanticMigration = { + id: 'validation-rule-message-template-holes', + surface: 'a validation rule\'s `message` (an object\'s `validations[]`, a nested `conditional` branch\'s, and an ' + + '`objectExtensions[]` entry\'s `validations[]`) and each `objects.OBJECT._validations.RULE.message` translation ' + + '— a sentence carrying a single-brace `{…}` or `${…}` token, or a `{{ }}` hole', + replacement: 'a sentence with no braces, or a `{{ }}` hole naming one of the object\'s own fields under `record` ' + + '(the merged record the rule judged) or `previous` (the stored row before an update), one segment deep, with ' + + 'an optional whitelisted formatter: `Total {total_price} is below {received}` becomes `Total {{ ' + + 'record.total_price | currency }} is below {{ record.received_amount | currency }}`, and a brace that was ' + + 'prose (`must be { tier: standard|premium }`) is reworded without it (`must name a tier: standard or ' + + 'premium`).', + reason: 'A rule message could not name the record\'s values, so a refusal could say that a limit was crossed ' + + 'but not by how much. The message is now a `{{ }}` template over the judged record, and `objectstack ' + + 'validate`, `compile` and the publish gate (an object, object extension or translation write) refuse a ' + + 'single-brace or `${…}` token, a hole over another root, a hole that reads through a field or names a field ' + + 'the object does not declare, and a hole holding logic or an unknown formatter, each named with its remedy ' + + 'or its `{{ }}` spelling. Before, every brace was shown to the person as written. The message stays a ' + + 'string and the parse does not judge it, so a stored rule or bundle keeps loading and is judged at its next ' + + 'save. No conversion is registered: a brace in a stored message was prose or a placeholder that never ' + + 'rendered, and only the author knows which.', + acceptanceCriteria: 'Run `objectstack validate`: it reports no `expression-invalid` finding at a validation ' + + 'rule\'s `message` (`objects[N].validations[M].message`, `.then.message`, `objectExtensions[N].validations[M]' + + '.message`) or at a `translations[N].LOCALE.objects.OBJECT._validations.RULE.message`. Trigger each rule whose ' + + 'message you reworded and confirm the refusal reads as intended in every locale the bundle carries.', +}; diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 0b4455fae8e..da1c6a8fdab 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -952,6 +952,13 @@ export const ObjectTranslationDataSchema = lazySchema(() => strictObject({ * A nested `conditional` branch rule carries its own `name` and is addressed * by it; the wrapping `conditional`'s own `message` never reaches a user (the * branch supplies the violation), so it has nothing to translate. + * + * **A translation is the same template the authored message is.** The rule + * message is a `{{ }}` template over the judged record + * (`VALIDATION_MESSAGE_TEMPLATE_ROOTS`, `data/validation.zod.ts`), and each + * translation carries the same holes in its own words. The doors judge every + * translation exactly as they judge the authored message — not this parse, + * so a stored bundle keeps loading and is judged at its next save. */ _validations: z.record(z.string(), strictObject({ surface: 'this validation rule translation', @@ -978,7 +985,12 @@ export const ObjectTranslationDataSchema = lazySchema(() => strictObject({ }, }, { message: z.string().optional() - .describe("Translated rejection message — overlays the rule's authored `message` on every rejected write"), + .describe( + "Translated rejection message — overlays the rule's authored `message` on every rejected write. The same " + + '`{{ }}` template the authored message is, over the same roots (`record`, `previous`; ' + + '`VALIDATION_MESSAGE_TEMPLATE_ROOTS`): a single-brace `{…}` token, a hole over another root or field, ' + + 'and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate.', + ), })).optional().describe('Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`)'), /** From ee990050eabbd162412e6d391473e1d271f8f92a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 03:00:28 +0000 Subject: [PATCH 2/3] test(lint): pin the rule message template judge at the build and the doors Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs Co-authored-by: Claude --- .../37909-rule-message-template-holes.md | 32 +++ .../lint/src/authored-site-expression.test.ts | 13 ++ ...time-gate.translation-writes-38623.test.ts | 9 +- packages/lint/src/validate-expressions.ts | 8 +- .../validate-rule-message-templates.test.ts | 206 ++++++++++++++++++ 5 files changed, 262 insertions(+), 6 deletions(-) create mode 100644 .changeset/37909-rule-message-template-holes.md create mode 100644 packages/lint/src/validate-rule-message-templates.test.ts diff --git a/.changeset/37909-rule-message-template-holes.md b/.changeset/37909-rule-message-template-holes.md new file mode 100644 index 00000000000..1539376223e --- /dev/null +++ b/.changeset/37909-rule-message-template-holes.md @@ -0,0 +1,32 @@ +--- +'@objectstack/lint': minor +'@objectstack/spec': minor +--- + +feat(lint)!: a validation rule's message is a `{{ }}` template over the judged record, and a single brace there is refused + +Clause-②: no (narrowing) +Metadata-protocol: narrowed + + + +**BREAKING** accept-set narrowing, shipped as `minor`: a validation rule's `message`, and each `objects.OBJECT._validations.RULE.message` translation, that carries a single-brace `{…}` or `${…}` token was accepted before and is refused now by `objectstack validate`, `objectstack compile` and the runtime publish gate (rule `expression-invalid`, an error; `422` on an `object`, `object_extension` or `translation` write). The schema is unchanged: `message` stays a string and the parse does not judge it, so a stored rule or bundle keeps loading and is judged at its next save. + +The message is now a `{{ }}` template (ADR-0032 §3) over the record the rule judged. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or `previous` (the stored row before an update), with an optional whitelisted formatter: `{{ record.total_price | currency }}`. The doors judge every rule message (a nested `conditional` branch's and an `objectExtensions[]` entry's included) and every translation of one with `closedScopeTemplateRefusal`, then compile it as a `template`, and refuse: + +- a single-brace `{…}` or `${…}` token, with its `{{ }}` spelling where the token names a field under `record` or `previous`; +- a hole over any other root (`{{ amount }}`, `{{ current_user.name }}`); +- a hole naming the whole root (`{{ record }}`), reading through a field (`{{ record.account.name }}`), or naming a field the object does not declare (`{{ record.totl }}`, with the nearest field named); +- a hole holding logic or an unknown formatter. + +Filling the holes at run time is the next change on this card; until it lands, a hole that passes the doors is returned as written. + +- **Exports.** `@objectstack/spec/data` gains `VALIDATION_MESSAGE_TEMPLATE_ROOTS` (`['record', 'previous']`). The `message` describe of the six validation-rule variants and of the `_validations` translation entry now state the template. +- **The ADR-0087 ledger** gains the semantic entry `validation-rule-message-template-holes` under step 19. + +FROM → TO: + +- `message: 'Support Config must be { tier: standard|premium|enterprise, seats?: >=1 }.'` → `message: 'Support Config must name a tier (standard, premium or enterprise) and, if it sets seats, at least 1 seat.'` +- `message: 'Total {total_price} is below {received_amount}'` → `message: 'Total {{ record.total_price | currency }} is below {{ record.received_amount | currency }}'` + +One-line fix: run `objectstack validate`, then reword each refused message without braces or write each token as the `{{ record.FIELD }}` hole the finding names, in the authored message and in every translation of it. diff --git a/packages/lint/src/authored-site-expression.test.ts b/packages/lint/src/authored-site-expression.test.ts index 85843ab3f09..275d8172da5 100644 --- a/packages/lint/src/authored-site-expression.test.ts +++ b/packages/lint/src/authored-site-expression.test.ts @@ -125,11 +125,15 @@ const WALK_PUSHES: Record = { actionRefusalTemplateIssues: "an action refusal's template sentences over its declared params: no rule or field expression", // [#35356] ADR-0157 D4/D6: working-day calls at value sites the engine loads no calendar for. workingDayValueSiteIssues: "a field's expression `defaultValue` and a seed record's expression values: no rule or formula `expression`", + // [#37909] A translation bundle's `_validations.RULE.message` templates. + ruleMessageTranslationIssues: "a translated validation-rule message's template holes: no rule or field expression", }; /** The passes the walk pushes whole from INSIDE a site's regions: classified with that site's calls, in `SITE_CALLS`. */ const WALK_PUSHES_IN_REGION: Record = { formulaCycleIssues: 'formula', + // [#37909] The rule's own `message` templates, judged in the rule pass. + ruleMessageTemplateIssues: 'validation', }; /** An object whose own formulas read each other: a cycle the gate refuses on each of its members. */ @@ -229,6 +233,15 @@ const SITE_CALLS: Record> = { kind: 'pass', fixture: { objects: [REQ, BAL], expression: 'record.days > 3', severity: 'error', names: 'days' }, }, + // [#37909] The rule's `message` is a `{{ }}` template the rule pass + // judges; the tool judges one predicate, and its probe rule carries a + // plain message (its own name), so the pass has nothing to say here. + ruleMessages: { kind: 'plumbing', why: "lists the rule's messages, nested branches included" }, + ruleMessageTemplateIssues: { + kind: 'pass-silent-here', + why: "judges the rule's `message`, not its predicate; the probe rule's message is plain text", + fixture: { objects: [REQ, BAL], expression: "record.title == 'x'" }, + }, }, formula: { validateExpression: VALIDATOR, diff --git a/packages/lint/src/runtime-gate.translation-writes-38623.test.ts b/packages/lint/src/runtime-gate.translation-writes-38623.test.ts index dff4ef568e0..aabcee2634e 100644 --- a/packages/lint/src/runtime-gate.translation-writes-38623.test.ts +++ b/packages/lint/src/runtime-gate.translation-writes-38623.test.ts @@ -49,7 +49,12 @@ const rulesOf = (fs: Array<{ rule: string }>) => fs.map((f) => f.rule); describe('a translation write reaches the translation rule at the door (#38623)', () => { it('the write type dispatches the suite, and the suite dispatches exactly the translation member', () => { expect(stackKeyForType('translation')).toBe('translations'); - expect(runtimeAuthoringRulesFor('translation').map((r) => r.name)).toEqual(['validateReferenceIntegrity']); + // [#37909] The expression rule joins for one pass, the translated + // validation-rule messages (`validate-rule-message-templates.test.ts`). + expect(runtimeAuthoringRulesFor('translation').map((r) => r.name)).toEqual([ + 'validateStackExpressions', + 'validateReferenceIntegrity', + ]); const members = REFERENCE_INTEGRITY_RULES .filter((m) => (m.runtimeTypes ?? ['flow']).includes('translation')) .map((m) => m.name); @@ -62,7 +67,7 @@ describe('a translation write reaches the translation rule at the door (#38623)' expect(rulesOf(result.advisories)).toEqual([TRANSLATION_TARGET_UNKNOWN]); expect(result.advisories[0]!.severity).toBe('warning'); expect(result.advisories[0]!.path).toBe('translations[0].objects.crm_lead.fields.zzz_removed'); - expect(result.rulesRun).toEqual(['validateReferenceIntegrity']); + expect(result.rulesRun).toEqual(['validateStackExpressions', 'validateReferenceIntegrity']); }); it('⭐ LIT — an object, a validation rule and a milestone nothing declares are advised too', () => { diff --git a/packages/lint/src/validate-expressions.ts b/packages/lint/src/validate-expressions.ts index f80eff12bdf..71dd90fafdd 100644 --- a/packages/lint/src/validate-expressions.ts +++ b/packages/lint/src/validate-expressions.ts @@ -4131,10 +4131,10 @@ export function runStackExpressionPasses(stack: AnyRec, options: StackExpression // (`validate-rule-message-templates.ts`). The object's fields are read as // served (`fieldIndex`), so a field an extension adds resolves. const fields = objectName !== undefined ? fieldIndex.get(objectName) : undefined; - for (const m of ruleMessages(rule)) { - issues.push(...ruleMessageTemplateIssues(m.text, { - where: `${where} ${m.label}message`, - ...(rulePath ? { path: `${rulePath}.${m.key}` } : {}), + for (const { key, label, text } of ruleMessages(rule)) { + issues.push(...ruleMessageTemplateIssues(text, { + where: `${where} ${label}message`, + ...(rulePath ? { path: `${rulePath}.${key}` } : {}), slot: VALIDATION_MESSAGE_SLOT, objectName, fields, diff --git a/packages/lint/src/validate-rule-message-templates.test.ts b/packages/lint/src/validate-rule-message-templates.test.ts new file mode 100644 index 00000000000..5db0c47d848 --- /dev/null +++ b/packages/lint/src/validate-rule-message-templates.test.ts @@ -0,0 +1,206 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * [#37909, ruling P3] A validation rule's `message`, and each of its + * `objects.OBJECT._validations.RULE.message` translations, is a `{{ }}` + * template over `record` / `previous`, judged at `objectstack validate` / + * `compile` (`validateStackExpressions`) and at the runtime publish gate + * (`runRuntimeAuthoringRules`) on an `object`, `object_extension` and + * `translation` write. Every finding is an error. + */ +import { describe, expect, it } from 'vitest'; + +import { runRuntimeAuthoringRules } from './runtime-gate.js'; +import { validateStackExpressions } from './validate-expressions.js'; +import { + ruleMessageTemplateIssues, + VALIDATION_MESSAGE_SLOT, + VALIDATION_MESSAGE_TRANSLATION_SLOT, +} from './validate-rule-message-templates.js'; + +const FIELDS = ['total_price', 'received_amount', 'status', 'account']; + +/** The messages one sentence draws, judged over an object declaring {@link FIELDS}. */ +const judge = (text: string, fields: readonly string[] | 'unknown' = FIELDS) => + ruleMessageTemplateIssues(text, { + where: 'w', + slot: VALIDATION_MESSAGE_SLOT, + objectName: 'sales_order', + fields: fields === 'unknown' ? undefined : fields, + }).map((i) => i.message); + +const order = (validations: unknown[]) => ({ + name: 'sales_order', + fields: { + total_price: { type: 'currency' }, + received_amount: { type: 'currency' }, + status: { type: 'select', options: [{ value: 'draft', label: 'Draft' }, { value: 'confirmed', label: 'Confirmed' }] }, + account: { type: 'lookup', reference: 'account' }, + }, + validations, +}); + +const rule = (message: string, over: Record = {}) => ({ + name: 'total_below_received', + type: 'script', + condition: 'record.total_price < record.received_amount', + message, + ...over, +}); + +/** The `expression-invalid` findings of `validateStackExpressions` located at a rule message. */ +const messageFindings = (stack: Record) => + validateStackExpressions(stack).filter((i) => / message$/.test(i.where)); + +describe('a validation rule message is judged as a template (#37909)', () => { + it('DARK — plain text, holes over own fields under both roots, and whitelisted formatters pass', () => { + expect(judge('Total price must not be below the received amount.')).toEqual([]); + expect(judge('Order total {{ record.total_price | currency }} is below what was received ' + + '({{ record.received_amount | currency }}).')).toEqual([]); + expect(judge('Status cannot move from {{ previous.status }} to {{ record.status }}.')).toEqual([]); + expect(judge('Total {{ record.total_price | number }}')).toEqual([]); + }); + + it('⭐ LIT — a single-brace path token is refused with its `{{ }}` spelling', () => { + const [message, ...rest] = judge('Total {record.total_price} is below {record.received_amount}.'); + expect(rest).toEqual([]); + expect(message).toContain(VALIDATION_MESSAGE_SLOT); + expect(message).toContain('Write `Total {record.total_price} is below {record.received_amount}.` as ' + + '`Total {{ record.total_price }} is below {{ record.received_amount }}.`'); + }); + + it('⭐ LIT — a single-brace token over no bound root, and a `${…}` token, are refused', () => { + expect(judge('Total {total_price} is too low.')[0]).toContain('`{total_price}` names `total_price`, which this slot does not bind'); + expect(judge('Must be { tier: standard|premium }.')).toHaveLength(1); + expect(judge('Total ${record.total_price} is too low.')[0]).toContain('as `Total {{ record.total_price }} is too low.`'); + }); + + it('⭐ LIT — a hole over another root is refused', () => { + const [message] = judge('Hello {{ current_user.name }}, the total {{ amount }} is too low.'); + expect(message).toContain('binds only `record`, `previous`'); + expect(message).toContain('`{{ current_user.name }}`, `{{ amount }}`'); + }); + + it('⭐ LIT — logic and an unknown formatter are refused by the template compile', () => { + expect(judge('Total {{ record.total_price + 1 }}')).toHaveLength(1); + expect(judge('Total {{ record.total_price | shout }}')).toHaveLength(1); + }); + + it('⭐ LIT — a hole must name one of the object\'s own fields, one segment deep', () => { + expect(judge('The {{ record }} is wrong.')[0]).toContain('names the whole `record`'); + expect(judge('Account {{ record.account.name }} is closed.')[0]).toContain('reads through `account`'); + const [unknown] = judge('Total {{ record.total_prise }} is too low.'); + expect(unknown).toContain("names `total_prise`, which object 'sales_order' does not declare"); + expect(unknown).toContain('did you mean `record.total_price`?'); + // An object whose fields are not known here is judged on depth alone. + expect(judge('Total {{ record.total_prise }} is too low.', 'unknown')).toEqual([]); + expect(judge('Account {{ record.account.name }}', 'unknown')).toHaveLength(1); + }); +}); + +describe('objectstack validate judges every rule message (#37909)', () => { + it('⭐ LIT — an object rule\'s message is refused at its key path', () => { + const found = messageFindings({ objects: [order([rule('Total {record.total_price} is too low.')])] }); + expect(found).toHaveLength(1); + expect(found[0]!.severity).toBe('error'); + expect(found[0]!.where).toBe("object 'sales_order' · validation 'total_below_received' message"); + expect(found[0]!.path).toBe('objects[0].validations[0].message'); + }); + + it('⭐ LIT — a nested `conditional` branch\'s message is refused at the branch', () => { + const found = messageFindings({ + objects: [order([{ + name: 'confirm_checks', + type: 'conditional', + when: "record.status == 'confirmed'", + message: 'Confirmation checks.', + then: rule('Total {{ record.totl }} is below what was received.'), + }])], + }); + expect(found.map((f) => [f.where, f.path])).toEqual([ + ["object 'sales_order' · validation 'confirm_checks' then → 'total_below_received' message", + 'objects[0].validations[0].then.message'], + ]); + }); + + it('⭐ LIT — a rule an `objectExtensions` entry adds is judged against the target as served', () => { + const stack = { + objects: [order([])], + objectExtensions: [{ + extend: 'sales_order', + fields: { invoiced_amount: { type: 'currency' } }, + validations: [ + rule('Total {{ record.total_price | currency }} is below invoiced {{ record.invoiced_amount | currency }}.'), + rule('Total {{ record.nope }}', { name: 'second' }), + ], + }], + }; + const found = messageFindings(stack); + expect(found.map((f) => f.path)).toEqual(['objectExtensions[0].validations[1].message']); + }); + + it('⭐ LIT — each translation of a rule message is judged too, per locale', () => { + const found = messageFindings({ + objects: [order([rule('Total {{ record.total_price }} is too low.')])], + translations: [{ + en: { objects: { sales_order: { _validations: { total_below_received: { message: 'Total {{ record.total_price }} is too low.' } } } } }, + 'zh-CN': { objects: { sales_order: { _validations: { total_below_received: { message: '总价 {total_price} 过低。' } } } } }, + }], + }); + expect(found.map((f) => [f.where, f.path])).toEqual([ + ['locale "zh-CN" · object "sales_order" · validation "total_below_received" message', + 'translations[0]["zh-CN"].objects.sales_order._validations.total_below_received.message'], + ]); + expect(found[0]!.message).toContain(VALIDATION_MESSAGE_TRANSLATION_SLOT); + }); + + it('DARK — a clean stack draws no message finding', () => { + expect(messageFindings({ + objects: [order([rule('Total {{ record.total_price | currency }} is below {{ record.received_amount | currency }}.')])], + translations: [{ 'zh-CN': { objects: { sales_order: { _validations: { total_below_received: { message: '总价 {{ record.total_price | currency }} 低于已收 {{ record.received_amount | currency }}。' } } } } } }], + })).toEqual([]); + }); +}); + +describe('the runtime publish gate refuses a refused rule message (#37909)', () => { + it('⭐ LIT — an object write answers with the error', () => { + const result = runRuntimeAuthoringRules({ + type: 'object', + item: order([rule('Total {record.total_price} is too low.')]), + context: { objects: [] }, + }); + const messages = result.errors.filter((e) => e.path.endsWith('.message')); + expect(messages.map((e) => [e.rule, e.path])).toEqual([ + ['expression-invalid', 'objects.sales_order.validations[0].message'], + ]); + }); + + it('⭐ LIT — a translation write answers with the error at the item\'s path', () => { + const result = runRuntimeAuthoringRules({ + type: 'translation', + item: { + name: 'zh_cn', + locale: 'zh-CN', + objects: { sales_order: { _validations: { total_below_received: { message: '总价 {{ record.total_prise }} 过低。' } } } }, + }, + context: { objects: [order([rule('Total too low.')])], permissions: [], books: [], datasets: [] }, + }); + expect(result.errors.map((e) => [e.rule, e.path])).toEqual([ + ['expression-invalid', 'translations[0].objects.sales_order._validations.total_below_received.message'], + ]); + expect(result.errors[0]!.message).toContain('did you mean `record.total_price`?'); + }); + + it('DARK — a translation write whose messages are clean answers with no error', () => { + const result = runRuntimeAuthoringRules({ + type: 'translation', + item: { + name: 'zh_cn', + locale: 'zh-CN', + objects: { sales_order: { _validations: { total_below_received: { message: '总价 {{ record.total_price | currency }} 过低。' } } } }, + }, + context: { objects: [order([rule('Total too low.')])], permissions: [], books: [], datasets: [] }, + }); + expect(result.errors).toEqual([]); + }); +}); From a73007e9d05c5da24b72ae540fa0e409c1058406 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 03:05:53 +0000 Subject: [PATCH 3/3] chore(spec): regenerate the references and export ledgers for the rule message template Claude-Session: https://claude.ai/code/session_01ADHkmQ6vV3YvhJWKF1gSDs Co-authored-by: Claude --- content/docs/references/data/validation.mdx | 44 +++++++++---------- packages/spec/api-surface/data.json | 1 + .../docs/references/system/translation.md | 2 +- packages/spec/export-origins/data.json | 1 + 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/content/docs/references/data/validation.mdx b/content/docs/references/data/validation.mdx index eac8ee194c5..2afcd8b5295 100644 --- a/content/docs/references/data/validation.mdx +++ b/content/docs/references/data/validation.mdx @@ -133,7 +133,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -158,7 +158,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -181,7 +181,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -206,7 +206,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -231,7 +231,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -255,7 +255,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -279,7 +279,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -302,7 +302,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -327,7 +327,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -352,7 +352,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -376,7 +376,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -405,7 +405,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -434,7 +434,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -464,7 +464,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -493,7 +493,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -521,7 +521,7 @@ const result = ConditionalValidationSchema.parse(data); | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -559,7 +559,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -588,7 +588,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -619,7 +619,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -650,7 +650,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -680,7 +680,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | @@ -710,7 +710,7 @@ This schema accepts one of the following structures: | **priority** | `integer` | optional (default: `100`) | Execution priority (lower runs first, default: 100) | | **tags** | `string[]` | optional | Categorization tags (e.g., "compliance", "billing") | | **severity** | `Enum<'error' \| 'warning' \| 'info'>` | optional (default: `"error"`) | | -| **message** | `string` | ✅ | Error message to display to the user | +| **message** | `string` | ✅ | The sentence a refused write returns to the person: a `{{ }}` template (ADR-0032 §3) over the judged record. A hole names one of the object's own fields, one segment deep, under `record` (the merged record the rule judged) or, on update, `previous` (the stored row), with an optional whitelisted formatter: `Total {{ record.total_price \| currency }} is below what was received ({{ record.received_amount \| currency }}).` A single-brace `{…}` token, a hole over any other root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. Stays a string; translate it at `objects.OBJECT._validations.RULE.message`, which reads the same holes. | | **_lock** | `Enum<'none' \| 'no-overlay' \| 'no-delete' \| 'full'>` | optional | Item-level lock — controls overlay & delete (ADR-0010). | | **_lockReason** | `string` | optional | Human-readable reason shown when a write is refused by _lock. | | **_lockSource** | `Enum<'artifact' \| 'package' \| 'env-forced'>` | optional | Layer that set _lock (artifact \| package \| env-forced). | diff --git a/packages/spec/api-surface/data.json b/packages/spec/api-surface/data.json index 270425bb1cf..555669f5bdd 100644 --- a/packages/spec/api-surface/data.json +++ b/packages/spec/api-surface/data.json @@ -983,6 +983,7 @@ "UnknownImportMappingTarget (interface)", "UnorderedPaginationConformanceCase (interface)", "UserActionTransferResolution (interface)", + "VALIDATION_MESSAGE_TEMPLATE_ROOTS (const)", "VALID_AST_OPERATORS (const)", "VALUE_DOMAIN_FIELD_TYPES (const)", "VALUE_ROUNDTRIP_CASES (const)", diff --git a/packages/spec/docs/references/system/translation.md b/packages/spec/docs/references/system/translation.md index 85ea05e66d5..c65e53a9763 100644 --- a/packages/spec/docs/references/system/translation.md +++ b/packages/spec/docs/references/system/translation.md @@ -162,7 +162,7 @@ Translation data for a single field | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **message** | `string` | optional | Translated rejection message — overlays the rule's authored `message` on every rejected write | +| **message** | `string` | optional | Translated rejection message — overlays the rule's authored `message` on every rejected write. The same `{{ }}` template the authored message is, over the same roots (`record`, `previous`; `VALIDATION_MESSAGE_TEMPLATE_ROOTS`): a single-brace `{…}` token, a hole over another root or field, and logic in a hole are refused at `objectstack validate`, `compile` and the publish gate. | ### Nested Shape: `ObjectTranslationData._milestones[string][string]` diff --git a/packages/spec/export-origins/data.json b/packages/spec/export-origins/data.json index 3378dc1e5e7..69a9161b135 100644 --- a/packages/spec/export-origins/data.json +++ b/packages/spec/export-origins/data.json @@ -968,6 +968,7 @@ "UnknownImportMappingTarget": "src/data/import-mapping-target.ts#UnknownImportMappingTarget (interface)", "UnorderedPaginationConformanceCase": "src/data/pagination-conformance.ts#UnorderedPaginationConformanceCase (interface)", "UserActionTransferResolution": "src/data/user-action-transfer.ts#UserActionTransferResolution (interface)", + "VALIDATION_MESSAGE_TEMPLATE_ROOTS": "src/data/validation.zod.ts#VALIDATION_MESSAGE_TEMPLATE_ROOTS (const)", "VALID_AST_OPERATORS": "src/data/filter.zod.ts#VALID_AST_OPERATORS (const)", "VALUE_DOMAIN_FIELD_TYPES": "src/data/field.zod.ts#VALUE_DOMAIN_FIELD_TYPES (const)", "VALUE_ROUNDTRIP_CASES": "src/data/value-roundtrip-conformance.ts#VALUE_ROUNDTRIP_CASES (const)",