From 0009fe1b6134e97dee890a8ca7fad7e76cc14965 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 13:41:16 +0000 Subject: [PATCH 01/13] wip(spec,core): a record field value marked as text, and the organization-language reader Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude --- packages/core/src/index.ts | 6 + packages/core/src/organization-locale.test.ts | 50 ++++++++ packages/core/src/organization-locale.ts | 116 ++++++++++++++++++ packages/runtime/src/seed-locale.ts | 11 +- .../src/automation/builtin-node-config.zod.ts | 113 +++++++++++++++-- .../automation/flow-node-expression-paths.ts | 32 +++++ .../src/automation/flow-text-slot-template.ts | 16 +++ .../src/system/flows-translation-face.test.ts | 32 ++++- packages/spec/src/system/i18n-resolver.ts | 21 ++++ packages/spec/src/system/translation.zod.ts | 50 ++++++++ 10 files changed, 429 insertions(+), 18 deletions(-) create mode 100644 packages/core/src/organization-locale.test.ts create mode 100644 packages/core/src/organization-locale.ts diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index c040c631a45..b9344790bdb 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -53,6 +53,12 @@ export * from './stack-auth.js'; // record page, so both roots that construct `AuthPlugin` (`os serve` and // `DevPlugin`) leave `plugin-auth`'s out alike (ruling A on objectstack#23015). export * from './stack-organization-record-page.js'; +// The organization's language — the one reader of the deployment-default +// ladder (`localization.locale` when set → `i18n.defaultLocale`) for text the +// platform writes on the organization's behalf. Here because its readers sit +// in packages that cannot import each other (`@objectstack/service-automation` +// and `@objectstack/runtime`'s seed load), and both already depend on this one. +export * from './organization-locale.js'; export * from './lite-kernel.js'; export * from './types.js'; export * from './logger.js'; diff --git a/packages/core/src/organization-locale.test.ts b/packages/core/src/organization-locale.test.ts new file mode 100644 index 00000000000..d8bdd0705d5 --- /dev/null +++ b/packages/core/src/organization-locale.test.ts @@ -0,0 +1,50 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import { describe, it, expect, vi } from 'vitest'; +import { readOrganizationLocaleSetting, resolveOrganizationLocale } from './organization-locale.js'; + +/** A settings door answering `localization.locale` with `answer`, recording the scope it was asked in. */ +function settingsAnswering(answer: { value?: unknown; source?: string } | undefined) { + return { get: vi.fn(async () => answer) }; +} + +const i18nDefault = (locale: unknown) => ({ getDefaultLocale: () => locale }); + +describe('resolveOrganizationLocale — the deployment-default ladder for text written on the organization\'s behalf', () => { + it('rung 1: a Localization setting somebody set wins over the app default', async () => { + const settings = settingsAnswering({ value: 'ja-JP', source: 'tenant' }); + expect(await resolveOrganizationLocale({ settings, i18n: i18nDefault('zh-CN'), organizationId: 'org_1' })) + .toEqual({ locale: 'ja-JP', source: 'organization-setting' }); + expect(settings.get).toHaveBeenCalledWith('localization', 'locale', { tenantId: 'org_1' }); + }); + + it('the manifest placeholder (`source: default`) is not a choice: the app default answers', async () => { + const settings = settingsAnswering({ value: 'en-US', source: 'default' }); + expect(await resolveOrganizationLocale({ settings, i18n: i18nDefault('zh-CN') })) + .toEqual({ locale: 'zh-CN', source: 'app-default' }); + // CONTROL: the same answer with any other source is the organization's. + expect(await resolveOrganizationLocale({ settings: settingsAnswering({ value: 'en-US', source: 'global' }), i18n: i18nDefault('zh-CN') })) + .toEqual({ locale: 'en-US', source: 'organization-setting' }); + }); + + it('no settings service, no getDefaultLocale, a throwing one or a blank answer: nothing is guessed', async () => { + expect(await resolveOrganizationLocale({})).toBeUndefined(); + expect(await resolveOrganizationLocale({ i18n: {} })).toBeUndefined(); + expect(await resolveOrganizationLocale({ i18n: { getDefaultLocale: () => { throw new Error('x'); } } })).toBeUndefined(); + expect(await resolveOrganizationLocale({ i18n: i18nDefault(' ') })).toBeUndefined(); + expect(await resolveOrganizationLocale({ settings: settingsAnswering(undefined), i18n: i18nDefault(' zh-CN ') })) + .toEqual({ locale: 'zh-CN', source: 'app-default' }); + }); + + it('a settings read that throws propagates — a failed read is not "not set"', async () => { + const settings = { get: vi.fn(async () => { throw new Error('store down'); }) }; + await expect(resolveOrganizationLocale({ settings, i18n: i18nDefault('zh-CN') })).rejects.toThrow('store down'); + }); + + it('readOrganizationLocaleSetting asks with no scope for a caller naming no organization', async () => { + const settings = settingsAnswering({ value: ' fr-FR ', source: 'env' }); + expect(await readOrganizationLocaleSetting(settings, undefined)).toBe('fr-FR'); + expect(settings.get).toHaveBeenCalledWith('localization', 'locale', {}); + expect(await readOrganizationLocaleSetting({ get: 'not a function' }, 'org_1')).toBeUndefined(); + }); +}); diff --git a/packages/core/src/organization-locale.ts b/packages/core/src/organization-locale.ts new file mode 100644 index 00000000000..95ed7ec1f43 --- /dev/null +++ b/packages/core/src/organization-locale.ts @@ -0,0 +1,116 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The organization's language — ONE reader of the deployment-default ladder + * (maintainer ruling 2026-09-02, quoted in `@objectstack/plugin-auth`'s + * `auth-manager.ts`: 「……其次才是部署默认(`localization.locale` → + * `i18n.defaultLocale`)。」), for a sentence the platform writes on the + * organization's behalf rather than for one person. + * + * Two rungs, first answer wins (ruling 6913660232, parameter 3): + * + * 1. **The organization's Localization setting** — `localization.locale` + * read through the `settings` service for `organizationId`, so the + * service's own cascade (env override, the organization's row, the + * `global` row) decides. ⛔ Only a value somebody SET counts: the + * manifest's built-in default (`en-US`, `source: 'default'`) is the + * platform's placeholder, not the organization's choice, and taking it + * would make rung 2 unreachable — every organization that never opened + * Setup → Localization would read `en-US` over the app's declared default. + * 2. **The app's declared `i18n.defaultLocale`** — what the `i18n` service + * answers from `getDefaultLocale()`. ⛔ NOT the settings cascade's + * default layer, and so NOT `resolveLocalizationContext().locale`: that + * layer holds the `en-US` placeholder and answers it on a `zh-CN` boot. + * + * No rung answers ⇒ `undefined`: the caller writes the text as authored. + * Never an `'en'` guess. + * + * A host with no `settings` service has no organization setting to honour, so + * rung 1 is skipped. A settings read that THROWS is not skipped: the + * organization's choice may exist and could not be read, and answering another + * language over it would look like success. The throw reaches the caller, + * which decides what a failed read means for its own write. The `i18n` hop is + * probed rather than assumed, as every other reader of the deployment default + * probes it: `getDefaultLocale` is optional on the contract, so a service + * without it, or one whose call throws, answers nothing for rung 2. + * + * The other readers of the same ladder keep their own code because each + * answers a different question: the auth mail binds the workspace's setting at + * boot and on change, the notification text reads the recipient first, and the + * seed load reads the installing user between the two rungs. The seed load's + * rung 1 IS this one and calls {@link readOrganizationLocaleSetting}. + */ + +/** Which rung answered. */ +export type OrganizationLocaleSource = 'organization-setting' | 'app-default'; + +/** The organization's language and where it came from (for a caller's log line). */ +export interface ResolvedOrganizationLocale { + locale: string; + source: OrganizationLocaleSource; +} + +/** The part of the `settings` service read here — structural, as `plugin-auth` reads it. */ +export interface OrganizationLocaleSettingsDoor { + get( + namespace: string, + key: string, + ctx?: { tenantId?: string }, + ): Promise<{ value?: unknown; source?: string } | undefined | null>; +} + +/** What {@link resolveOrganizationLocale} is handed. Every field is optional. */ +export interface OrganizationLocaleInput { + /** The `settings` service, or `undefined` when the host has none. */ + settings?: unknown; + /** The `i18n` service, or `undefined` when the host has none. */ + i18n?: unknown; + /** The organization the text is written for. Absent: the settings service's own reach for a caller naming none. */ + organizationId?: string; +} + +/** A non-empty, trimmed string, or `undefined`. */ +function localeText(value: unknown): string | undefined { + if (typeof value !== 'string') return undefined; + const trimmed = value.trim(); + return trimmed === '' ? undefined : trimmed; +} + +/** + * Rung 1 alone: the organization's `localization.locale` when somebody SET it + * (`source !== 'default'`), else `undefined`. A `settings` value without a + * `get` answers `undefined`; a `get` that throws propagates. + */ +export async function readOrganizationLocaleSetting( + settings: unknown, + organizationId: string | undefined, +): Promise { + const door = settings as Partial | null | undefined; + if (!door || typeof door.get !== 'function') return undefined; + const orgId = localeText(organizationId); + const resolved = await door.get('localization', 'locale', orgId ? { tenantId: orgId } : {}); + const value = localeText(resolved?.value); + return value && resolved?.source !== 'default' ? value : undefined; +} + +/** Rung 2 alone: the app's declared default language off the `i18n` service, probed. */ +function appDefaultLocale(i18n: unknown): string | undefined { + const service = i18n as { getDefaultLocale?: unknown } | null | undefined; + if (!service || typeof service.getDefaultLocale !== 'function') return undefined; + try { + return localeText((service.getDefaultLocale as () => unknown).call(service)); + } catch { + // Optional on the contract and best-effort at every reader: no answer. + return undefined; + } +} + +/** Resolve the organization's language. See the module docblock for the rungs. */ +export async function resolveOrganizationLocale( + input: OrganizationLocaleInput, +): Promise { + const set = await readOrganizationLocaleSetting(input.settings, input.organizationId); + if (set) return { locale: set, source: 'organization-setting' }; + const declared = appDefaultLocale(input.i18n); + return declared ? { locale: declared, source: 'app-default' } : undefined; +} diff --git a/packages/runtime/src/seed-locale.ts b/packages/runtime/src/seed-locale.ts index 618581bf5ba..cd661bce282 100644 --- a/packages/runtime/src/seed-locale.ts +++ b/packages/runtime/src/seed-locale.ts @@ -1,6 +1,7 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. import { SystemObjectName } from '@objectstack/spec/system'; +import { readOrganizationLocaleSetting } from '@objectstack/core'; /** * The locale a seed load filters `Seed.locale` on, for ONE organization — the @@ -132,12 +133,12 @@ export async function resolveSeedLocaleForLoad( const h = host as SeedLocaleHost | null | undefined; const organizationId = localeText(question.organizationId); + // Rung 1 is the organization-language reader's own rung 1 + // (`@objectstack/core`'s `readOrganizationLocaleSetting`): one reading of + // "somebody set it", shared with the text a flow writes for the organization. const settings = serviceOf(h, 'settings'); - if (settings && typeof settings.get === 'function') { - const resolved = await settings.get('localization', 'locale', organizationId ? { tenantId: organizationId } : {}); - const value = localeText(resolved?.value); - if (value && resolved?.source !== 'default') return { locale: value, source: 'organization-setting' }; - } + const setting = await readOrganizationLocaleSetting(settings, organizationId); + if (setting) return { locale: setting, source: 'organization-setting' }; const userId = localeText(question.userId); const ql = serviceOf(h, 'objectql'); diff --git a/packages/spec/src/automation/builtin-node-config.zod.ts b/packages/spec/src/automation/builtin-node-config.zod.ts index a202503880f..d59c69e5a2e 100644 --- a/packages/spec/src/automation/builtin-node-config.zod.ts +++ b/packages/spec/src/automation/builtin-node-config.zod.ts @@ -101,7 +101,7 @@ import { lazySchema } from '../shared/lazy-schema'; import { strictObject } from '../shared/strict-object'; import { transportProjectionArray } from '../data/projection-names-a-field'; import { refuseCatchallProtoKey, refuseRecordProtoKey } from '../shared/record-proto-key-guard'; -import { flowFilterOperands, isExpressionEnvelopeShaped } from './flow-node-expression-paths'; +import { flowFilterOperands, isExpressionEnvelopeShaped, isFlowTextEnvelopeShaped } from './flow-node-expression-paths'; // [#19939] The retirement of the `{…}` template dialect from value slots — the // one judge, composed into every value slot's contract below rather than // re-spelled here. @@ -369,9 +369,13 @@ export type AssignmentExpressionValueParsed = z.infer { + if (options.text && isFlowTextEnvelopeShaped(value)) { + for (const issue of recordFieldTextEnvelopeIssues(value)) ctx.addIssue({ code: 'custom', ...issue }); + return; + } if (!isExpressionEnvelopeShaped(value)) { // [#19939] A literal: refused only where it still spells the retired // `{…}` dialect, at the string's own path inside the value. @@ -380,6 +384,14 @@ function celValueSlotSchema(description: string) { } return; } + if (options.text && value.dialect !== 'cel') { + ctx.addIssue({ + code: 'custom', + path: ['dialect'], + message: `${VALUE_ENVELOPE_REFUSAL} \`dialect\`: ${RECORD_FIELD_ENVELOPE_DIALECTS}`, + }); + return; + } const result = AssignmentExpressionValueSchema.safeParse(value); if (result.success) return; for (const issue of result.error.issues) { @@ -394,6 +406,43 @@ function celValueSlotSchema(description: string) { .meta({ description, xExpression: 'value' }); } +/** + * The dialects a record field value's envelope may name, as the refusal of + * any other says it (a `cron` envelope, a misspelled dialect). + */ +const RECORD_FIELD_ENVELOPE_DIALECTS = + 'A record field value takes a `cel` envelope, evaluated to the value written, or a `template` text envelope ' + + "(`{ dialect: 'template', source: 'Escalated: {{ record.priority }} priority' }`), a sentence for people to read " + + "that is written in the organization's language; no other dialect has a meaning here."; + +/** + * The text envelope a record field value is MARKED as text with — + * `{ dialect: 'template', source }` (ruling 6913660232 on objectstack#34062, + * letter B, parameter 4). `ExpressionSchema`'s template envelope, the spelling + * a notify node's `title` / `message` already take, in its EVALUATED form: the + * executor renders `source`, so it is required and non-blank. + */ +const RecordFieldTextEnvelopeSchema = EvaluatedExpressionSchema.safeExtend({ dialect: z.literal('template') }); + +/** + * Why a record field's text envelope is refused, each issue led by + * {@link VALUE_ENVELOPE_REFUSAL}: an envelope that is not a valid one, or a + * `source` the one text-slot judge refuses (a single-brace `{token}`, a hole + * over a `$` name the engine does not bind). The `{{ }}` compile is the + * doors' (`registerFlow`, `objectstack validate`), as for every text slot. + */ +function recordFieldTextEnvelopeIssues(value: unknown): { path: PropertyKey[]; message: string }[] { + const result = RecordFieldTextEnvelopeSchema.safeParse(value); + if (!result.success) { + return result.error.issues.map((issue) => { + const where = issue.path.length > 0 ? `\`${issue.path.map(String).join('.')}\`: ` : ''; + return { path: issue.path, message: `${VALUE_ENVELOPE_REFUSAL} ${where}${issue.message}` }; + }); + } + const refusal = textSlotTemplateRefusal(result.data.source); + return refusal === undefined ? [] : [{ path: ['source'], message: `${VALUE_ENVELOPE_REFUSAL} \`source\`: ${refusal}` }]; +} + /** * What a value in a `value`-role slot may be (#14149, generalised in #19938, * narrowed in #19939) — an expression, or a literal: @@ -452,6 +501,47 @@ export const FlowValueSlotSchema = celValueSlotSchema( export type FlowValueSlot = z.input; export type FlowValueSlotParsed = z.infer; +/** + * What a `create_record` / `update_record` `fields` value may be — the + * {@link FlowValueSlotSchema} rule, plus a third form (ruling 6913660232 on + * objectstack#34062, letter B): a **text envelope**, + * `{ dialect: 'template', source }`, which marks the value as a sentence the + * record keeps for people to read. + * + * - a **CEL value envelope** is evaluated to the value written, as in every + * value slot; + * - a **text envelope** is written as text in the ORGANIZATION's language: + * the executor picks the translated template at + * `flows..records..fields.` + * (`flowRecordFieldTextKey`, `system/i18n-resolver.ts`) in the + * organization's language — its Localization setting when somebody set it, + * else the app's declared `i18n.defaultLocale` — and only then fills its + * `{{ }}` holes over the run's variables, the way a screen's text is picked. + * Never the language of the person who started the run: stored text is + * data the whole organization reads. With no translation, or no language + * to pick, the authored `source` is written, and the run goes on. `source` + * is judged as a text slot: non-blank, and a single-brace `{token}` is + * refused with its `{{ }}` spelling; + * - any other value is the literal it spells — a bare string included + * (`status: 'escalated'` is written as it is, never translated). + * + * The forms are told apart by SHAPE, as in every value slot; a third dialect + * (`cron`) is refused. It carries the same `xExpression: 'value'` marker: the + * map is still the ledger's `value` slot, whose entries say it takes the text + * envelope too (`textEnvelope`). + */ +export const FlowRecordFieldValueSchema = celValueSlotSchema( + 'A field value: a CEL value envelope `{ dialect: \'cel\', source }` evaluated to the value written, a text ' + + 'envelope `{ dialect: \'template\', source }` — a sentence for people to read, written in the organization\'s ' + + 'language (its translation picked at `flows..records..fields.`, then its `{{ }}` holes ' + + 'filled; the authored text when none is held) — or a literal written as it is (a bare string is never ' + + 'translated; a `{…}` template token in it is refused)', + { text: true }, +); + +export type FlowRecordFieldValue = z.input; +export type FlowRecordFieldValueParsed = z.infer; + /** * What a `loop`'s or a `map`'s `collection` is (#19939) — the sentence every * refusal of a value there that is neither a list nor an envelope leads with. @@ -663,11 +753,12 @@ export const CreateRecordConfigSchema = lazySchema(() => strictObject({ /** * Field values to write on the new record — a `value`-role slot of the * expression ledger (`create_record.fields.*`, #19938): each value is a CEL - * value envelope or a literal ({@link FlowValueSlotSchema}); a `{token}` - * template is refused there since #19939. + * value envelope, a text envelope or a literal + * ({@link FlowRecordFieldValueSchema}); a `{token}` template is refused + * there since #19939. */ - fields: z.record(z.string(), FlowValueSlotSchema).optional() - .describe('Field values to write on the new record: each key is a field name, each value a CEL value envelope or a literal'), + fields: z.record(z.string(), FlowRecordFieldValueSchema).optional() + .describe('Field values to write on the new record: each key is a field name, each value a CEL value envelope, a text envelope (a sentence written in the organization\'s language) or a literal'), /** * Flow variable bound to the created record (`{var.id}` works even when the * driver returns a bare id) — never a `$` name: those are the engine's (#22502). @@ -704,12 +795,12 @@ export const UpdateRecordConfigSchema = lazySchema(() => strictObject({ filter: flowFilterSlotSchema(`Field/value pairs identifying the record(s) to update: ${FILTER_OPERAND_DESCRIPTION}`).optional(), /** * Field values to write — a `value`-role slot of the expression ledger - * (`update_record.fields.*`, #19938): each value is a CEL value envelope or - * a literal ({@link FlowValueSlotSchema}); a `{token}` template is refused - * there since #19939. + * (`update_record.fields.*`, #19938): each value is a CEL value envelope, a + * text envelope or a literal ({@link FlowRecordFieldValueSchema}); a + * `{token}` template is refused there since #19939. */ - fields: z.record(z.string(), FlowValueSlotSchema).optional() - .describe('Field values to write: each key is a field name, each value a CEL value envelope or a literal'), + fields: z.record(z.string(), FlowRecordFieldValueSchema).optional() + .describe('Field values to write: each key is a field name, each value a CEL value envelope, a text envelope (a sentence written in the organization\'s language) or a literal'), /** * Declare BULK intent — this node may update EVERY row `filter` matches. * diff --git a/packages/spec/src/automation/flow-node-expression-paths.ts b/packages/spec/src/automation/flow-node-expression-paths.ts index 0208b348ebe..5188fe7dd76 100644 --- a/packages/spec/src/automation/flow-node-expression-paths.ts +++ b/packages/spec/src/automation/flow-node-expression-paths.ts @@ -297,6 +297,21 @@ export interface FlowNodeExpressionPath { * every depth. */ readonly filterOperands?: true; + /** + * The slot ALSO takes a text envelope, `{ dialect: 'template', source }` — + * a sentence for people to read that the executor writes as text, picking + * its translation in the organization's language before it fills the + * `{{ }}` holes (ruling 6913660232 on objectstack#34062, letter B). Today + * the `create_record` / `update_record` `fields` map, and only it + * (parameter 4: the author marks the text, and only those two maps). + * + * Changes one thing: {@link resolveFlowNodeExpressions} does not emit such + * an envelope ({@link isFlowTextEnvelopeShaped}), because it is no CEL value + * to check — its judge is the text-slot judge, which reaches it through the + * text-slot list (`FLOW_NODE_TEXT_SLOTS`, `flow-text-slot-template.ts`). Every + * other dialect is emitted as on any value slot, and refused there. + */ + readonly textEnvelope?: true; } /** @@ -474,6 +489,9 @@ export const FLOW_NODE_EXPRESSION_PATHS: readonly FlowNodeExpressionPath[] = [ path: 'fields.*', role: 'value', label: 'create_record field value', + // A field value may be marked as text the record keeps for people to + // read (ruling 6913660232): the text-slot judge's, not this walk's. + textEnvelope: true, }, { // The same map on the update node (`UpdateRecordConfigSchema`). Its @@ -483,6 +501,7 @@ export const FLOW_NODE_EXPRESSION_PATHS: readonly FlowNodeExpressionPath[] = [ path: 'fields.*', role: 'value', label: 'update_record field value', + textEnvelope: true, }, { // [#19939] The maps a node hands to a CALLEE as its inputs (#11182 @@ -821,6 +840,17 @@ export function isExpressionEnvelopeShaped(value: unknown): value is { dialect: ); } +/** + * A TEXT envelope — `{ dialect: 'template', … }` — on a value slot that takes + * one ({@link FlowNodeExpressionPath.textEnvelope}): text for people to read, + * written in the organization's language, never a CEL value. Shape only, like + * {@link isExpressionEnvelopeShaped}; whether it is a valid one is the + * slot contract's and the text-slot judge's question. + */ +export function isFlowTextEnvelopeShaped(value: unknown): value is { dialect: 'template' } { + return isExpressionEnvelopeShaped(value) && value.dialect === 'template'; +} + /** * Resolve every expression slot the ledger declares for `nodeType` against a * concrete `config`, filling in array indices and wildcard keys. @@ -893,6 +923,8 @@ export function resolveFlowNodeExpressions( const block = flowNodeExpressionBlock(entry); walk(root, entry.path.split('.'), '', slotEmitter(entry, (path, value) => { if (entry.role === 'value') { + // A text envelope is no CEL value: the text-slot judge reads it. + if (entry.textEnvelope && isFlowTextEnvelopeShaped(value)) return; if (isExpressionEnvelopeShaped(value)) out.push({ entry, block, path, value }); } else if (typeof value === 'string') { // #17493 — every string in a `predicate` slot is emitted, a BLANK one diff --git a/packages/spec/src/automation/flow-text-slot-template.ts b/packages/spec/src/automation/flow-text-slot-template.ts index 16d1fda453a..2fee89e3a7c 100644 --- a/packages/spec/src/automation/flow-text-slot-template.ts +++ b/packages/spec/src/automation/flow-text-slot-template.ts @@ -206,6 +206,16 @@ export interface FlowNodeTextSlot { * path (`headers.X-Request-Id`); without it the key's value is the slot. */ readonly eachValue?: true; + /** + * Only a TEXT envelope (`{ dialect: 'template', source }`) is a text slot + * here; a bare string is a literal value, written as it is spelled — today a + * `create_record` / `update_record` `fields` value, where the author MARKS a + * field value as text the record keeps for people to read (ruling + * 6913660232 on objectstack#34062, parameter 4: `status: 'escalated'` stays + * a literal). The executor picks the marked text's translation in the + * organization's language before it fills the holes. + */ + readonly envelopeOnly?: true; } /** @@ -240,6 +250,10 @@ export const FLOW_NODE_TEXT_SLOTS: readonly FlowNodeTextSlot[] = [ { nodeType: 'screen', key: 'description', label: 'screen description' }, { nodeType: 'end', key: 'message', label: 'end message' }, { nodeType: 'save_notice', key: 'message', label: 'save_notice message' }, + // A field value MARKED as text — a text envelope — in the map a record + // write carries (`crud-nodes.ts` renders it in the organization's language). + { nodeType: 'create_record', key: 'fields', label: 'create_record field text', eachValue: true, envelopeOnly: true }, + { nodeType: 'update_record', key: 'fields', label: 'update_record field text', eachValue: true, envelopeOnly: true }, ]; /** @@ -550,11 +564,13 @@ export function flowNodeTextSlotSources(nodeType: string, config: unknown): Flow if (slot.eachValue) { if (value === null || typeof value !== 'object' || Array.isArray(value)) continue; for (const [name, entry] of Object.entries(value as Record)) { + if (slot.envelopeOnly && typeof entry === 'string') continue; const source = templateSlotSource(entry); if (source !== undefined) out.push({ path: `${slot.key}.${name}`, label: slot.label, source }); } continue; } + if (slot.envelopeOnly && typeof value === 'string') continue; const source = templateSlotSource(value); if (source !== undefined) out.push({ path: slot.key, label: slot.label, source }); } diff --git a/packages/spec/src/system/flows-translation-face.test.ts b/packages/spec/src/system/flows-translation-face.test.ts index 2ea98dbabb6..dadf1e0963b 100644 --- a/packages/spec/src/system/flows-translation-face.test.ts +++ b/packages/spec/src/system/flows-translation-face.test.ts @@ -49,7 +49,13 @@ import { describe, expect, it } from 'vitest'; import { FlowSchema, FlowNodeSchema } from '../automation/flow.zod'; -import { EndConfigSchema, SaveNoticeConfigSchema, ScreenConfigSchema } from '../automation/builtin-node-config.zod'; +import { + CreateRecordConfigSchema, + EndConfigSchema, + SaveNoticeConfigSchema, + ScreenConfigSchema, + UpdateRecordConfigSchema, +} from '../automation/builtin-node-config.zod'; import { NotifyConfigSchema } from '../automation/io-node-config.zod'; import { ApprovalNodeConfigSchema, APPROVAL_NODE_TYPE } from '../automation/approval.zod'; import { getBuiltinNodeConfigContracts } from '../automation/flow-node-config-refusals'; @@ -174,6 +180,26 @@ const RUNNER_SLOTS: Readonly> = { 'notices.NODE.message', "the sentence the writer reads with the save, picked by the engine in the writer's locale", ), + + // The record writes (ruling 6913660232 on objectstack#34062, letter B): a + // `fields` value MARKED as text — a text envelope — is a sentence the record + // keeps, picked by the engine in the organization's language before its + // holes are filled. Tier 1 for the `save_notice` reason: the engine renders + // it. A bare string or a CEL envelope in the same map is a value, which the + // one `fields.*` row covers: the key is read only for the text envelope. + 'create_record.objectName': noReader('an object name — the object the row is inserted into'), + 'create_record.outputVariable': noReader('a variable name the created row binds'), + 'create_record.fields.*': keyed( + 'records.NODE.fields.FIELD', + "a field value marked as text (a text envelope): the record keeps it for people to read, written in the " + + "organization's language; any other value is data the run computes or spells, never translated", + ), + 'update_record.objectName': noReader('an object name — the object whose rows are updated'), + 'update_record.filter': noReader('a match condition — field names, operators and the values the run compares'), + 'update_record.fields.*': keyed( + 'records.NODE.fields.FIELD', + 'a field value marked as text, as on `create_record.fields.*`', + ), }; /** @@ -280,6 +306,8 @@ function runnerLeaves(): string[] { ...prefixed('screen', textLeaves(ScreenConfigSchema)), ...prefixed('end', textLeaves(EndConfigSchema)), ...prefixed('save_notice', textLeaves(SaveNoticeConfigSchema)), + ...prefixed('create_record', textLeaves(CreateRecordConfigSchema)), + ...prefixed('update_record', textLeaves(UpdateRecordConfigSchema)), ]; } @@ -295,7 +323,7 @@ function otherNodeLeaves(): string[] { contracts.set(APPROVAL_NODE_TYPE, ApprovalNodeConfigSchema); const out: string[] = []; for (const [type, schema] of contracts) { - if (type === 'screen' || type === 'save_notice') continue; // tier 1 + if (type === 'screen' || type === 'save_notice' || type === 'create_record' || type === 'update_record') continue; // tier 1 const regions = new Set((FLOW_REGION_SLOTS_BY_TYPE.get(type) ?? []).map((slot) => slot.key)); for (const leaf of textLeaves(schema, (p) => regions.has(p.split(/[.[]/)[0]!))) { if (COPY_WORD.test(leaf.replace(/\[\]/g, '').replace(/\.\*/g, ''))) out.push(`${type}.${leaf}`); diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index 474feebd981..e3a7d44cc7c 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -4401,6 +4401,27 @@ export function flowNoticeMessageKey(flowName: string, nodeId: string): string { return `flows.${flowName}.notices.${nodeId}.message`; } +/** + * Dot-notation i18n key for the text a `create_record` / `update_record` node + * writes into a field — `flows..records..fields.` + * (ruling 6913660232 on objectstack#34062, letter B). + * + * The sibling of {@link flowNoticeMessageKey}, for the same reason: the + * automation engine picks the translated TEMPLATE before it fills the + * `{{ }}` holes, because the record keeps the text already rendered. Unlike + * every other flow key it is picked in the ORGANIZATION's language (its + * Localization setting when somebody set it, else the app's declared + * `i18n.defaultLocale`), never the run's: stored text is data the whole + * organization reads, not a prompt for the person who started the run. + * + * `flowName` is `Flow.name`, `nodeId` the record node's `FlowNode.id`, and + * `fieldName` the key of its `fields` map whose value is a text envelope + * (`{ dialect: 'template', source }`, `FlowRecordFieldValueSchema`). + */ +export function flowRecordFieldTextKey(flowName: string, nodeId: string, fieldName: string): string { + return `flows.${flowName}.records.${nodeId}.fields.${fieldName}`; +} + /** * Dot-notation i18n key for a hook's declared refusal message — * `hooks..refusals..message` (#26170, maintainer ruling 6431311681 diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 3592c0fb39a..c502db0aab4 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -1683,6 +1683,7 @@ const appTranslationDataShape = () => ({ * flows..screens..fields..options. (#22507) * flows..refusals..message (a refused `end` node, #22450) * flows..approvals..label (an `approval` node's step label) + * flows..records..fields. (text a record write keeps) * * Every user-read string slot of the flow schemas is either one of these * keys or recorded, with its reason, in the family pin @@ -1824,6 +1825,32 @@ const appTranslationDataShape = () => ({ * `objectstack validate` refuses a key over an unknown flow, an unknown * node, or a node that is not a `save_notice`. * + * ## `records` — the text a record write keeps (ruling 6913660232) + * + * flows..records..fields. + * + * A `create_record` / `update_record` node's `fields` value MARKED as text — + * a text envelope, `{ dialect: 'template', source }` + * (`FlowRecordFieldValueSchema`) — is a sentence the record keeps for people + * to read ("Auto-escalated: critical priority"). Under the maintainer's + * ruling on objectstack#34062 (letter B, 「B 平台按组织语言挑译文」) it is + * translated where it is written: the engine reads + * `flowRecordFieldTextKey(flow, node, field)` (`system/i18n-resolver.ts`) + * through the `i18n` service in the ORGANIZATION's language — its + * Localization setting when somebody set it, else the app's declared + * `i18n.defaultLocale` — and only then fills the holes. Never the language + * of the person who started the run: stored text is data the whole + * organization reads. With no entry, or no language to pick, the authored + * text is written and the run goes on. A bare string in `fields` is a + * literal value and has no key. + * + * Addressed by `Flow.name`, the record node's `FlowNode.id` (at any depth, + * an ADR-0031 region included) and the field name, the `fields` map's own + * key. Judged as the text slot it translates (`flowTextSlotTranslation`). + * `objectstack validate` refuses a key over an unknown flow, an unknown + * node, a node that is not a record write, or a field the node does not + * mark as text. + * * ## `successMessage` / `errorMessage` — the terminal toasts (#22507) * * flows..successMessage @@ -1907,6 +1934,7 @@ const appTranslationDataShape = () => ({ refusal: 'refusals', ends: 'refusals', approval: 'approvals', notice: 'notices', saveNotices: 'notices', + record: 'records', // The spellings the toast pair arrives in from an action translation, // which spells its own success toast `successMessage` with these aliases. success: 'successMessage', successText: 'successMessage', @@ -2041,6 +2069,28 @@ const appTranslationDataShape = () => ({ + "by the engine in the triggering writer's locale in place of the authored one", ), })).optional().describe('Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node'), + // [ruling 6913660232] The text a record write keeps, picked by the ENGINE + // in the ORGANIZATION's language before its holes are filled — addressed + // by `FlowNode.id` like `notices`, then by the field name. + records: z.record(z.string(), strictObject({ + surface: 'this flow record-write translation', + history: TRANSLATION_HISTORY, + // The map's own name on the node is `fields`; the spellings an author + // holding a neighbouring surface's word arrives with. + aliases: { values: 'fields', fieldValues: 'fields' }, + }, { + // The one text-slot judge, applied to each translation exactly as + // `FlowRecordFieldValueSchema` applies it to the text envelope's + // `source`; an empty string is the untranslated skeleton slot (the + // authored text is written). + fields: z.record(z.string(), flowTextSlotTranslation()).optional().describe( + 'Translated text keyed by field name — each a `{{ }}` template like the text envelope it translates, picked by ' + + "the engine in the organization's language and written in its place; only a field the node marks as text " + + 'is translated', + ), + })).optional().describe( + 'Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node', + ), })).optional().describe('Screen-flow translations keyed by flow name'), /** From 99d7ff41dad2dbf8f0fcb6f5fd2e7da781da94a7 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 13:52:13 +0000 Subject: [PATCH 02/13] wip(automation,lint): write marked text in the organization's language; walk and judge its keys Claude-Session: https://claude.ai/code/session_01FEkQ5kgF3mo9f7LXuv5hac Co-authored-by: Claude --- packages/lint/src/i18n-walk.ts | 31 ++++++- .../src/validate-translation-references.ts | 60 ++++++++++++- .../src/builtin/crud-nodes.ts | 86 +++++++++++++++++-- .../services/service-automation/src/engine.ts | 46 ++++++++++ .../services/service-automation/src/plugin.ts | 15 +++- 5 files changed, 227 insertions(+), 11 deletions(-) diff --git a/packages/lint/src/i18n-walk.ts b/packages/lint/src/i18n-walk.ts index e49b28b027f..568e6d84b71 100644 --- a/packages/lint/src/i18n-walk.ts +++ b/packages/lint/src/i18n-walk.ts @@ -133,6 +133,7 @@ * flows..successMessage / .errorMessage (#22507) * flows..refusals..message (#22450) * flows..notices..message (#28251) + * flows..records..fields. (ruling 6913660232) * flows..approvals..label (#24916) * ^ walked because the ledger's `flows` row is `live` and warns no * author; a group the ledger does warn on is left out of the walk @@ -172,7 +173,7 @@ import { pageTabItemKey, walkAddressedPageComponents, } from '@objectstack/spec/system'; -import { FLOW_REGION_SLOTS_BY_TYPE, flowScreenFieldOptionKey, templateSlotSource } from '@objectstack/spec/automation'; +import { FLOW_REGION_SLOTS_BY_TYPE, flowScreenFieldOptionKey, isFlowTextEnvelopeShaped, templateSlotSource } from '@objectstack/spec/automation'; import { DEFAULT_METADATA_TYPE_REGISTRY } from '@objectstack/spec/kernel'; import { deriveFieldGroupLayout } from '@objectstack/spec/data'; import { APPROVAL_NODE_TYPE } from '@objectstack/spec/automation'; @@ -2078,6 +2079,14 @@ const REFUSED_OUTCOME = 'refused'; */ const SAVE_NOTICE_NODE_TYPE = 'save_notice'; +/** + * [ruling 6913660232] The nodes whose `fields` values + * `flows..records..fields.` addresses: a record write + * whose field value is MARKED as text — a `{ dialect: 'template', source }` + * envelope (`FlowRecordFieldValueSchema`). + */ +const RECORD_WRITE_NODE_TYPES: ReadonlySet = new Set(['create_record', 'update_record']); + /** * Depth ceiling for the region recursion, mirroring the ceiling the spec-side * walks use (`conversions/walk.ts`, `automation/control-flow.zod.ts`) and for @@ -2362,6 +2371,26 @@ function walkScreenFlows(config: any, out: ExpectedEntry[]): void { pushOptional(out, ['flows', flowName, 'notices', nodeId, 'message'], inlineText(cfg.message), 'flow', scope); } + // [ruling 6913660232] `flows..records..fields.` — a + // `create_record` / `update_record` field value MARKED as text (a + // `{ dialect: 'template', source }` envelope), at any depth of the same + // node universe. The engine reads that key (`flowRecordFieldTextKey`) in + // the ORGANIZATION's language before it fills the holes, so the seed is + // the authored template, holes and all. A bare string in `fields` is a + // literal value, never translated, and has no key. + for (const node of nodes) { + if (!node || typeof node !== 'object' || !RECORD_WRITE_NODE_TYPES.has(node.type)) continue; + const nodeId = typeof node.id === 'string' && node.id.length > 0 ? node.id : undefined; + if (!nodeId) continue; + const cfg = node.config && typeof node.config === 'object' ? node.config : {}; + const fields = cfg.fields && typeof cfg.fields === 'object' && !Array.isArray(cfg.fields) ? cfg.fields : {}; + for (const [fieldName, value] of Object.entries(fields as Record)) { + if (!isFlowTextEnvelopeShaped(value)) continue; + const source = inlineText((value as { source?: unknown }).source); + pushOptional(out, ['flows', flowName, 'records', nodeId, 'fields', fieldName], source, 'flow', scope); + } + } + // [#24916] `flows..approvals..label` — an `approval` node's // step label, the name its request shows the submitter and the approvers. // The approvals door reads that key in the reader's locale for the diff --git a/packages/lint/src/validate-translation-references.ts b/packages/lint/src/validate-translation-references.ts index 6be4fdf6182..0304d69749f 100644 --- a/packages/lint/src/validate-translation-references.ts +++ b/packages/lint/src/validate-translation-references.ts @@ -247,7 +247,7 @@ */ import { AUDIENCE_ANCHOR_POSITIONS, expandViewContainer } from '@objectstack/spec'; -import { APPROVAL_NODE_TYPE, flowScreenFieldOptionKey } from '@objectstack/spec/automation'; +import { APPROVAL_NODE_TYPE, flowScreenFieldOptionKey, isFlowTextEnvelopeShaped } from '@objectstack/spec/automation'; import { FLOW_TERMINAL_MESSAGE_KEYS, deriveImplicitPackageBook, @@ -290,6 +290,13 @@ const END_NODE_TYPE = 'end'; */ const SAVE_NOTICE_NODE_TYPE = 'save_notice'; +/** + * [ruling 6913660232] The nodes a `flows..records.*` key addresses: a + * `create_record` / `update_record` node, whose `fields` values the author may + * MARK as text. Local consts for {@link SCREEN_NODE_TYPE}'s reason. + */ +const RECORD_WRITE_NODE_TYPES: ReadonlySet = new Set(['create_record', 'update_record']); + /** * The component a misplaced `components..items` key most often sits on: a * `page:accordion` declares `items[].label` too, but its panels carry no @@ -501,6 +508,13 @@ interface FlowFacts { * `flows..notices.` key addresses, at any depth. */ notices: Set; + /** + * [ruling 6913660232] Record-write node id → the fields whose value it + * MARKS as text (a `{ dialect: 'template', source }` envelope) — the only + * fields a `flows..records..fields.` key translates. + * Every `create_record` / `update_record` node is listed, marking none or not. + */ + records: Map>; /** * The ids of the `approval` nodes — the nodes a * `flows..approvals.` key addresses, at any depth. @@ -1614,6 +1628,7 @@ function buildUniverse(stack: AnyRec): Universe { const screens = new Map(); const refusals = new Set(); const notices = new Set(); + const records = new Map>(); const approvals = new Set(); const otherNodes = new Map(); const messages = new Set(FLOW_TERMINAL_MESSAGE_KEYS.filter((key) => typeof flow[key] === 'string')); @@ -1630,6 +1645,14 @@ function buildUniverse(stack: AnyRec): Universe { } if (nodeType === APPROVAL_NODE_TYPE) approvals.add(nodeId); if (nodeType === SAVE_NOTICE_NODE_TYPE) notices.add(nodeId); + if (nodeType && RECORD_WRITE_NODE_TYPES.has(nodeType) && !records.has(nodeId)) { + const marked = new Set(); + const fields = isRec(node.config) ? asRecord(node.config.fields) : {}; + for (const [fieldName, value] of Object.entries(fields)) { + if (isFlowTextEnvelopeShaped(value)) marked.add(fieldName); + } + records.set(nodeId, marked); + } continue; } const config = isRec(node.config) ? node.config : undefined; @@ -1649,7 +1672,7 @@ function buildUniverse(stack: AnyRec): Universe { hasDescription: typeof config?.description === 'string' && config.description.length > 0, }); } - flows.set(flowName, { screens, refusals, notices, approvals, messages, otherNodes }); + flows.set(flowName, { screens, refusals, notices, records, approvals, messages, otherNodes }); }; for (const flow of recordsOf(stack.flows)) collectFlowRecord(flow, { ownDeclaration: true }); for (const flow of artifactProvidedRecords(stack, 'flows')) { @@ -2466,6 +2489,39 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind `Save-notice translations are keyed by the \`id\` of a \`save_notice\` node.`, ); } + // ── flows..records..fields. (ruling 6913660232) ── + for (const [nodeId, rawRecord] of Object.entries(asRecord(rawFlow.records))) { + const marked = flow.records.get(nodeId); + if (!marked) { + const nodeType = flow.screens.has(nodeId) ? SCREEN_NODE_TYPE : flow.otherNodes.get(nodeId); + orphan( + `${inLocale} · flow "${flowName}" · record write "${nodeId}"`, + `${flowPath}.records.${nodeId}`, + nodeType + ? `Translations are keyed to record write "${nodeId}", which flow "${flowName}" declares as ` + + `${/^[aeiou]/.test(nodeType) ? 'an' : 'a'} \`${nodeType}\` node, not a \`create_record\` or ` + + `\`update_record\`, so nothing resolves this key.` + : `Translations are keyed to record write "${nodeId}", a node id flow "${flowName}" does not ` + + `declare, so the text it names keeps its authored language.` + + suggest(nodeId, flow.records.keys()), + `Record-write translations are keyed by the \`id\` of a \`create_record\` or \`update_record\` node.`, + ); + continue; + } + for (const fieldName of Object.keys(asRecord(isRec(rawRecord) ? rawRecord.fields : undefined))) { + if (marked.has(fieldName)) continue; + orphan( + `${inLocale} · flow "${flowName}" · record write "${nodeId}" · field "${fieldName}"`, + `${flowPath}.records.${nodeId}.fields.${fieldName}`, + `Translations are keyed to field "${fieldName}" of record write "${nodeId}" in flow ` + + `"${flowName}", whose \`fields\` value there is not marked as text, so nothing resolves this ` + + `key: only a \`{ dialect: 'template', source }\` value is written in the organization's language, ` + + `and a bare string is a value written as it is spelled.` + + suggest(fieldName, marked), + `Mark the value as text — \`{ dialect: 'template', source: '…' }\` — or drop the key.`, + ); + } + } // ── flows..approvals. ────────────────────────────── for (const nodeId of Object.keys(asRecord(rawFlow.approvals))) { if (flow.approvals.has(nodeId)) continue; diff --git a/packages/services/service-automation/src/builtin/crud-nodes.ts b/packages/services/service-automation/src/builtin/crud-nodes.ts index e8198559c64..58d9e36c89c 100644 --- a/packages/services/service-automation/src/builtin/crud-nodes.ts +++ b/packages/services/service-automation/src/builtin/crud-nodes.ts @@ -5,6 +5,7 @@ import { defineActionDescriptor, flowFilterOperands, isExpressionEnvelopeShaped, + isFlowTextEnvelopeShaped, GetRecordConfigSchema, CreateRecordConfigSchema, UpdateRecordConfigSchema, @@ -20,6 +21,7 @@ import type { AutomationContext, IDataEngine } from '@objectstack/spec/contracts import { isAcceptedFilterComparand, isListComparandOperator, type DroppedFieldsEvent } from '@objectstack/spec/data'; import { StandardErrorCode } from '@objectstack/spec/api'; import { isStoredMetadataBodyObject, STORED_METADATA_BODY_PRESCRIPTION } from '@objectstack/spec/kernel'; +import { flowRecordFieldTextKey } from '@objectstack/spec/system'; import { collectStoredMetadataFilterFields, ephemeralStoredHashDigest, @@ -31,8 +33,8 @@ import { type StoredHashDigest, } from '@objectstack/metadata-protocol'; import type { AutomationEngine } from '../engine.js'; -import type { VariableMap } from './template.js'; -import { resolveValueSlotMap } from './value-slot-map.js'; +import { renderTextSlot, type VariableMap } from './template.js'; +import { resolveValueSlot, resolveValueSlotMap } from './value-slot-map.js'; import { refuseNode } from '../guard-refusal.js'; import { parseNodeConfig } from './parse-config.js'; import { resolveRunDataContext, stampSystemInsertOwner } from '../runtime-identity.js'; @@ -315,14 +317,80 @@ function writtenRowCount(result: unknown): number { * recursed into an envelope as plain data: a text or JSON column received the * literal `{"dialect":"cel","source":"…"}` with the run reporting success, and * a number column was refused by the data engine. + * + * [ruling 6913660232] A value MARKED as text — a text envelope — is written + * in the organization's language (see the body); a map that marks none + * resolves exactly as before, with no read of that language. Answers + * `{ error }`, a runtime failure, when that language could not be read. */ -function resolveFieldValues( +async function resolveFieldValues( engine: AutomationEngine, + node: { id: string }, + nodeType: 'create_record' | 'update_record', fields: Record | undefined, variables: VariableMap, context: AutomationContext, -): Record { - return resolveValueSlotMap(engine, fields, variables, 'fields', context); +): Promise<{ fields: Record } | { error: string }> { + const entries = Object.entries(fields ?? {}); + if (!entries.some(([, value]) => isFlowTextEnvelopeShaped(value))) { + return { fields: resolveValueSlotMap(engine, fields, variables, 'fields', context) }; + } + // [ruling 6913660232] A value MARKED as text — `{ dialect: 'template', + // source }` (`FlowRecordFieldValueSchema`) — is a sentence the record keeps + // for the whole organization to read, so it is written in the + // ORGANIZATION's language (parameter 2: never the starter's, so the run's + // own `locale` is replaced, not consulted): the translated template is + // picked at `flowRecordFieldTextKey` first, then its `{{ }}` holes are + // filled (parameter 1, the #22507 rule through `renderFlowTextSlot`, the one + // text renderer and the one `i18n` channel). No translation, or no language + // to pick, writes the authored text and the run goes on (parameter 5). + // Read once per node, and only for a map that marks text. + let locale: string | undefined; + try { + locale = await engine.organizationLocale(context); + } catch (err: unknown) { + // The organization's language could not be READ — not "it has none". + // Writing the authored text would store another language over a choice + // that may exist, with the run reporting success, so the node fails: + // a runtime failure a `fault` edge routes, and a re-run succeeds once + // the read does. + return { + error: + `${nodeType}: the organization's language could not be read ` + + `(${err instanceof Error ? err.message : String(err)}), so nothing was written: the text marked for ` + + `${entries.filter(([, v]) => isFlowTextEnvelopeShaped(v)).map(([k]) => `'${k}'`).join(', ')} ` + + 'would otherwise be stored in a language the organization may not use. Re-run the flow once the ' + + 'Localization setting can be read.', + }; + } + const flowName = typeof context.flowName === 'string' && context.flowName.length > 0 ? context.flowName : undefined; + const textContext: AutomationContext = { ...context, locale }; + const out: Record = {}; + for (const [field, value] of entries) { + if (!isFlowTextEnvelopeShaped(value)) { + out[field] = resolveValueSlot(engine, value, variables, `fields.${field}`, context); + continue; + } + const authored = (value as { source?: unknown }).source; + // An executor driven outside a run has no flow name, so no key: the + // authored text renders, as on a screen. + const text = flowName === undefined + ? renderTextSlot(authored, variables, context.currency) + : engine.renderFlowTextSlot( + { + key: flowRecordFieldTextKey(flowName, node.id, field), + authored, + subject: `flow '${flowName}' ${nodeType} '${node.id}' field '${field}'`, + shownAs: 'the field', + }, + variables, + textContext, + ); + // A sentence whose every hole came out empty renders no text: the + // field is written empty (`null`), never with its holes as written. + out[field] = text ?? null; + } + return { fields: out }; } /** @@ -705,7 +773,9 @@ export function registerCrudNodes(engine: AutomationEngine, ctx: PluginContext): // #19938 / #11182 ruling D — a CEL value envelope in `fields.*` is // evaluated; every other value is a literal (#19939 retired the // `{…}` dialect there — `parseNodeConfig` above refused it). - const fields = resolveFieldValues(engine, cfg.fields, variables, context); + const resolvedFields = await resolveFieldValues(engine, node, 'create_record', cfg.fields, variables, context); + if ('error' in resolvedFields) return { success: false, error: resolvedFields.error }; + const fields = resolvedFields.fields; const outputVariable = cfg.outputVariable; const data = getData(); @@ -884,7 +954,9 @@ export function registerCrudNodes(engine: AutomationEngine, ctx: PluginContext): // #19938 / #11182 ruling D — a CEL value envelope in `fields.*` is // evaluated; every other value is a literal (#19939 retired the // `{…}` dialect there — `parseNodeConfig` above refused it). - const fields = resolveFieldValues(engine, cfg.fields, variables, context); + const resolvedFields = await resolveFieldValues(engine, node, 'update_record', cfg.fields, variables, context); + if ('error' in resolvedFields) return { success: false, error: resolvedFields.error }; + const fields = resolvedFields.fields; const data = getData(); if (!data) { diff --git a/packages/services/service-automation/src/engine.ts b/packages/services/service-automation/src/engine.ts index ffb47b4129f..7f94063219f 100644 --- a/packages/services/service-automation/src/engine.ts +++ b/packages/services/service-automation/src/engine.ts @@ -928,6 +928,22 @@ export type FlowTenantCurrencyResolver = ( tenantId: string | undefined, ) => Promise | string | undefined; +/** + * Resolves the language of a run's ORGANIZATION — the language a sentence the + * flow writes into a record is picked in (ruling 6913660232 on + * objectstack#34062, letter B): the organization's Localization setting when + * somebody set it, else the app's declared `i18n.defaultLocale`. Injected by + * the host — the automation plugin bridges it to `@objectstack/core`'s + * `resolveOrganizationLocale`, the one reader of that ladder. Returns + * `undefined` when neither answers; the text is then written as authored. + * Rejects when the read FAILED: it learned nothing, so the record node fails + * rather than writing another language over the organization's choice. + * When unwired, nothing is picked: marked text is written as authored. + */ +export type FlowOrganizationLocaleResolver = ( + tenantId: string | undefined, +) => Promise | string | undefined; + /** * Re-reads the specified single-hop lookup relations of a record-change flow's * triggering record so `{record..}` templates can traverse them @@ -3292,6 +3308,8 @@ export class AutomationEngine implements IAutomationService { /** Bridge to the host's localization read so a run carries its organization's * default currency, if wired. See {@link FlowTenantCurrencyResolver}. */ private tenantCurrencyResolver: FlowTenantCurrencyResolver | null = null; + /** The run organization's language for text a record write keeps, if wired. See {@link FlowOrganizationLocaleResolver}. */ + private organizationLocaleResolver: FlowOrganizationLocaleResolver | null = null; private executionLogs: ExecutionLogEntry[] = []; private readonly maxLogSize: number; /** Level for the per-run summary line (#4354). See {@link RunSummaryLogLevel}. */ @@ -4750,6 +4768,34 @@ export class AutomationEngine implements IAutomationService { this.tenantCurrencyResolver = resolver; } + /** + * Wire the engine to the host's reader of the organization's language, the + * language a `create_record` / `update_record` node writes a field value + * marked as text in ({@link organizationLocale}). The automation plugin + * bridges it to `@objectstack/core`'s `resolveOrganizationLocale`. Passing + * `null` detaches it: marked text is then written as authored. + */ + setOrganizationLocaleResolver(resolver: FlowOrganizationLocaleResolver | null): void { + this.organizationLocaleResolver = resolver; + } + + /** + * The language of the run's organization (`context.tenantId`), read when a + * record node writes a field value marked as text — ruling 6913660232 on + * objectstack#34062: that text is picked in the ORGANIZATION's language, + * never the run's (`AutomationContext.locale`, the language of whoever + * started it), because the record keeps it for everyone in the + * organization. Read where it is used, never at run setup, so a run that + * writes no marked text pays no read. `undefined` when unwired or when no + * rung answers; rejects when the read failed ({@link FlowOrganizationLocaleResolver}). + */ + async organizationLocale(context: AutomationContext): Promise { + const resolver = this.organizationLocaleResolver; + if (!resolver) return undefined; + const locale = await resolver(context?.tenantId); + return typeof locale === 'string' && locale.trim() !== '' ? locale.trim() : undefined; + } + /** * Wire the record lookup-expander (#3475). The automation plugin bridges it * to a `findOne(..., { expand, context })` on the same data engine the CRUD diff --git a/packages/services/service-automation/src/plugin.ts b/packages/services/service-automation/src/plugin.ts index cb46c0f084e..13d4dadddf2 100644 --- a/packages/services/service-automation/src/plugin.ts +++ b/packages/services/service-automation/src/plugin.ts @@ -1,7 +1,7 @@ // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. import type { Plugin, PluginContext } from '@objectstack/core'; -import { RUNTIME_COMPATIBILITY_PACKAGE_ID, effectiveTenancyPosture, isServiceNotRegisteredError, resolveLocalizationContext, resolveUserAuthzGrants } from '@objectstack/core'; +import { RUNTIME_COMPATIBILITY_PACKAGE_ID, effectiveTenancyPosture, isServiceNotRegisteredError, resolveLocalizationContext, resolveOrganizationLocale, resolveUserAuthzGrants } from '@objectstack/core'; import type { IClusterService, IJobService, IPubSub } from '@objectstack/spec/contracts'; import { installedManifestsOf, type InstalledPackageSource } from '@objectstack/metadata-core'; import type { @@ -2236,6 +2236,19 @@ export class AutomationServicePlugin implements Plugin { // node renders, never at boot (see `i18nServiceReader`). this.engine.setI18nServiceSource(i18nServiceReader(ctx)); + // [ruling 6913660232] The organization's language, for a record field + // value marked as text: its Localization setting when somebody set it, + // else the app's declared `i18n.defaultLocale` — the one reader of that + // ladder. Both services are probed when a record node asks, never at + // boot, for `i18nServiceReader`'s reason. + this.engine.setOrganizationLocaleResolver(async (tenantId) => { + let settings: unknown; + let i18n: unknown; + try { settings = ctx.getService('settings'); } catch { settings = undefined; } + try { i18n = ctx.getService('i18n'); } catch { i18n = undefined; } + return (await resolveOrganizationLocale({ settings, i18n, organizationId: tenantId }))?.locale; + }); + // Register as global service — other plugins access via ctx.getService('automation') ctx.registerService('automation', this.engine); From 264b90a9ff74c6c5ebb8fde859299fac411dec14 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 14:04:27 +0000 Subject: [PATCH 03/13] wip(spec,automation): pin the record field text contract; export the plugin's organization-language reader Co-Authored-By: Claude --- .../services/service-automation/src/plugin.ts | 31 +++-- .../flow-text-slot-template.test.ts | 29 ++++- .../src/automation/record-field-text.test.ts | 109 ++++++++++++++++++ .../src/system/flows-translation-face.test.ts | 4 +- 4 files changed, 162 insertions(+), 11 deletions(-) create mode 100644 packages/spec/src/automation/record-field-text.test.ts diff --git a/packages/services/service-automation/src/plugin.ts b/packages/services/service-automation/src/plugin.ts index 13d4dadddf2..63a909c7fa1 100644 --- a/packages/services/service-automation/src/plugin.ts +++ b/packages/services/service-automation/src/plugin.ts @@ -1564,6 +1564,29 @@ export function i18nServiceReader(ctx: Pick): () => }; } +/** + * [ruling 6913660232] The engine's reader of the run organization's language — + * the language a record write's field value MARKED as text is written in: + * `@objectstack/core`'s `resolveOrganizationLocale`, the one reader of the + * deployment-default ladder (the Localization setting when somebody set it, + * else the app's declared `i18n.defaultLocale`). + * + * Both services are resolved at QUESTION time, for {@link i18nServiceReader}'s + * reason. A composition with neither answers `undefined`, and the text is + * written as authored; a settings read that throws rejects. + */ +export function organizationLocaleReader( + ctx: Pick, +): (tenantId: string | undefined) => Promise { + return async (tenantId) => { + let settings: unknown; + let i18n: unknown; + try { settings = ctx.getService('settings'); } catch { settings = undefined; } + try { i18n = ctx.getService('i18n'); } catch { i18n = undefined; } + return (await resolveOrganizationLocale({ settings, i18n, organizationId: tenantId }))?.locale; + }; +} + /** * AutomationServicePlugin — Core engine plugin * @@ -2241,13 +2264,7 @@ export class AutomationServicePlugin implements Plugin { // else the app's declared `i18n.defaultLocale` — the one reader of that // ladder. Both services are probed when a record node asks, never at // boot, for `i18nServiceReader`'s reason. - this.engine.setOrganizationLocaleResolver(async (tenantId) => { - let settings: unknown; - let i18n: unknown; - try { settings = ctx.getService('settings'); } catch { settings = undefined; } - try { i18n = ctx.getService('i18n'); } catch { i18n = undefined; } - return (await resolveOrganizationLocale({ settings, i18n, organizationId: tenantId }))?.locale; - }); + this.engine.setOrganizationLocaleResolver(organizationLocaleReader(ctx)); // Register as global service — other plugins access via ctx.getService('automation') ctx.registerService('automation', this.engine); diff --git a/packages/spec/src/automation/flow-text-slot-template.test.ts b/packages/spec/src/automation/flow-text-slot-template.test.ts index 8c56c557967..dbacdae9b2b 100644 --- a/packages/spec/src/automation/flow-text-slot-template.test.ts +++ b/packages/spec/src/automation/flow-text-slot-template.test.ts @@ -29,7 +29,7 @@ import { tmpl } from '../shared/expression.zod'; import { FLOW_TERMINAL_MESSAGE_KEYS } from '../system/i18n-resolver'; describe('FLOW_NODE_TEXT_SLOTS — where the `{{ }}` text slots are', () => { - it('names exactly the nine slots whose rendered value is only ever text', () => { + it('names exactly the eleven slots whose rendered value is only ever text', () => { // [#19939] `notify.actionUrl` joined: the link a person follows, text with // holes (`/crm_case/{{ record.id }}`), which the 17.x executor stringified. // Then an `http` node's `url` and each `headers` value (stage S5): the @@ -46,9 +46,16 @@ describe('FLOW_NODE_TEXT_SLOTS — where the `{{ }}` text slots are', () => { 'end.message', // [#28251] the sentence the writer reads with the save. 'save_notice.message', + // [ruling 6913660232] a record field value MARKED as text. + 'create_record.fields', + 'update_record.fields', ]); - // Only `headers` is a map whose every value is a slot of its own. - expect(FLOW_NODE_TEXT_SLOTS.filter((s) => s.eachValue).map((s) => `${s.nodeType}.${s.key}`)).toEqual(['http.headers']); + // `headers` is a map whose every value is a slot of its own; a record + // write's `fields` is a map whose every TEXT ENVELOPE is one. + expect(FLOW_NODE_TEXT_SLOTS.filter((s) => s.eachValue).map((s) => `${s.nodeType}.${s.key}`)) + .toEqual(['http.headers', 'create_record.fields', 'update_record.fields']); + expect(FLOW_NODE_TEXT_SLOTS.filter((s) => s.envelopeOnly).map((s) => `${s.nodeType}.${s.key}`)) + .toEqual(['create_record.fields', 'update_record.fields']); }); }); @@ -401,6 +408,22 @@ describe('flowNodeTextSlotSources — the text slots one node config carries', ( expect(flowNodeTextSlotSources('notify', { title: 42, message: { dialect: 'cel', source: 'x' } })).toEqual([]); expect(flowNodeTextSlotSources('notify', undefined)).toEqual([]); }); + + it('reads a record write\'s field value only where it is MARKED as text — a bare string is a value (ruling 6913660232)', () => { + const fields = { + escalation_reason: { dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' }, + status: 'escalated', + note: 'Hi {record.name}', + owner: { dialect: 'cel', source: 'record.owner' }, + }; + for (const type of ['create_record', 'update_record'] as const) { + expect(flowNodeTextSlotSources(type, { objectName: 'crm_case', fields })).toEqual([ + { path: 'fields.escalation_reason', label: `${type} field text`, source: 'Auto-escalated: {{ record.priority }} priority' }, + ]); + } + // CONTROL: the same map on a node whose `fields` is no text slot yields nothing. + expect(flowNodeTextSlotSources('get_record', { objectName: 'crm_case', fields })).toEqual([]); + }); }); describe('flowNodeTextSlotSources — an http node\'s url and each headers value (#19939)', () => { diff --git a/packages/spec/src/automation/record-field-text.test.ts b/packages/spec/src/automation/record-field-text.test.ts new file mode 100644 index 00000000000..cf190919544 --- /dev/null +++ b/packages/spec/src/automation/record-field-text.test.ts @@ -0,0 +1,109 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * A `create_record` / `update_record` field value MARKED as text (ruling + * 6913660232 on objectstack#34062, letter B, parameter 4): the contract half. + * + * The text envelope `{ dialect: 'template', source }` is the one spelling, on + * those two `fields` maps only; a bare string stays a literal value, and every + * other value slot still refuses a template envelope. Its translation lives at + * `flows..records..fields.`, judged as the text slot it + * translates. + */ + +import { describe, it, expect } from 'vitest'; +import { + AssignmentValueSchema, + CreateRecordConfigSchema, + FlowRecordFieldValueSchema, + FlowValueSlotSchema, + UpdateRecordConfigSchema, + VALUE_ENVELOPE_REFUSAL, +} from './builtin-node-config.zod'; +import { resolveFlowNodeExpressions } from './flow-node-expression-paths'; +import { flowRecordFieldTextKey } from '../system/i18n-resolver'; +import { TranslationDataSchema } from '../system/translation.zod'; + +const TEXT = { dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' } as const; + +const issuesOf = (result: { success: boolean; error?: { issues: { path: PropertyKey[]; message: string }[] } }) => + (result.error?.issues ?? []).map((i) => ({ path: i.path.map(String).join('.'), message: i.message })); + +describe('a record field value marked as text — the contract', () => { + it('both record writes accept a text envelope beside a literal and a CEL envelope, and keep each as written', () => { + const fields = { escalation_reason: TEXT, status: 'escalated', owner: { dialect: 'cel', source: 'record.owner' } }; + for (const schema of [CreateRecordConfigSchema, UpdateRecordConfigSchema]) { + const result = schema.safeParse({ objectName: 'crm_case', fields }); + expect(result.success, JSON.stringify(issuesOf(result))).toBe(true); + expect((result as { data: { fields: unknown } }).data.fields).toEqual(fields); + } + }); + + it('judges the text as a text slot: a single-brace token and a blank source are refused at the envelope', () => { + const token = CreateRecordConfigSchema.safeParse({ + objectName: 'crm_case', fields: { reason: { dialect: 'template', source: 'Escalated {record.priority}' } }, + }); + expect(token.success).toBe(false); + const [refusal] = issuesOf(token); + expect(refusal?.path).toBe('fields.reason.source'); + expect(refusal?.message.startsWith(VALUE_ENVELOPE_REFUSAL)).toBe(true); + expect(refusal?.message).toContain('{{ record.priority }}'); + + const blank = FlowRecordFieldValueSchema.safeParse({ dialect: 'template', source: ' ' }); + expect(blank.success).toBe(false); + expect(issuesOf(blank)[0]?.path).toBe('source'); + }); + + it('refuses a third dialect by naming the two it takes', () => { + const cron = FlowRecordFieldValueSchema.safeParse({ dialect: 'cron', source: '0 * * * *' }); + expect(cron.success).toBe(false); + expect(issuesOf(cron)).toEqual([{ path: 'dialect', message: expect.stringContaining('`template` text envelope') }]); + }); + + it('CONTROL: every other value slot still refuses a template envelope — the text form is the record writes\' alone', () => { + expect(FlowValueSlotSchema.safeParse(TEXT).success).toBe(false); + expect(AssignmentValueSchema.safeParse(TEXT).success).toBe(false); + expect(FlowRecordFieldValueSchema.safeParse(TEXT).success).toBe(true); + }); + + it('a bare string is the literal it spells — never marked, never a text slot', () => { + expect(FlowRecordFieldValueSchema.parse('escalated')).toBe('escalated'); + // CONTROL: the retired `{…}` token is still refused in a literal. + expect(FlowRecordFieldValueSchema.safeParse('Hi {record.name}').success).toBe(false); + }); +}); + +describe('the expression ledger hands the text envelope to the text-slot judge, not the CEL one', () => { + it('does not emit a record write\'s text envelope as a value expression, and still emits its CEL envelope', () => { + const config = { objectName: 'crm_case', fields: { reason: TEXT, owner: { dialect: 'cel', source: 'record.owner' } } }; + for (const type of ['create_record', 'update_record']) { + expect(resolveFlowNodeExpressions(type, config).map((f) => f.path)).toEqual(['fields.owner']); + } + }); + + it('CONTROL: on a slot that takes no text envelope, a template envelope is emitted — for the CEL judge to refuse', () => { + const found = resolveFlowNodeExpressions('assignment', { assignments: { note: TEXT } }); + expect(found.map((f) => f.path)).toEqual(['assignments.note']); + }); +}); + +describe('the translation key a marked field is picked at', () => { + it('is `flows..records..fields.`', () => { + expect(flowRecordFieldTextKey('case_escalation', 'set_reason', 'escalation_reason')) + .toBe('flows.case_escalation.records.set_reason.fields.escalation_reason'); + }); + + it('the face keeps it, judged as the text slot it translates', () => { + const ok = TranslationDataSchema.safeParse({ + flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: '自动升级:{{ record.priority }} 优先级' } } } } }, + }); + expect(ok.success, JSON.stringify(ok.error?.issues)).toBe(true); + expect((ok as { data: any }).data.flows.case_escalation.records.set_reason.fields.escalation_reason) + .toBe('自动升级:{{ record.priority }} 优先级'); + + const token = TranslationDataSchema.safeParse({ + flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: '自动升级:{record.priority}' } } } } }, + }); + expect(token.success).toBe(false); + }); +}); diff --git a/packages/spec/src/system/flows-translation-face.test.ts b/packages/spec/src/system/flows-translation-face.test.ts index dadf1e0963b..1c48f0d56f1 100644 --- a/packages/spec/src/system/flows-translation-face.test.ts +++ b/packages/spec/src/system/flows-translation-face.test.ts @@ -384,8 +384,10 @@ describe('the flows translation face covers every user-read flow slot (#22507)', // Every slot the engine renders as text, on any node type, is classified. const all = { ...RUNNER_SLOTS, ...OTHER_NODE_SLOTS }; + // A map slot (`eachValue`) is classified where its values sit (`.*`). for (const slot of FLOW_NODE_TEXT_SLOTS) { - expect(rowFor(all, `${slot.nodeType}.${slot.key}`), `${slot.label} has no disposition`).toBeDefined(); + const leaf = `${slot.nodeType}.${slot.key}${slot.eachValue ? '.*' : ''}`; + expect(rowFor(all, leaf), `${slot.label} has no disposition`).toBeDefined(); } }); From 57f3b264b03cc31c91c14929f4898b42ef8d5dec Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 14:10:10 +0000 Subject: [PATCH 04/13] test,docs(automation): pin the organization-language write end to end; document the marked record text Co-Authored-By: Claude --- .../34062-flow-record-text-org-locale.md | 23 ++ content/docs/automation/flows.mdx | 42 +++ content/docs/ui/translations.mdx | 1 + .../i18n-flow-record-text-coverage.test.ts | 124 +++++++++ .../validate-translation-references.test.ts | 51 ++++ ...low-record-text-org-locale.dogfood.test.ts | 202 ++++++++++++++ .../src/builtin/record-field-text.test.ts | 259 ++++++++++++++++++ .../spec/dropped-refinements.baseline.json | 27 +- .../spec/json-schema.manifest/automation.json | 1 + packages/spec/liveness/translation.json | 16 ++ 10 files changed, 739 insertions(+), 7 deletions(-) create mode 100644 .changeset/34062-flow-record-text-org-locale.md create mode 100644 packages/cli/test/i18n-flow-record-text-coverage.test.ts create mode 100644 packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts create mode 100644 packages/services/service-automation/src/builtin/record-field-text.test.ts diff --git a/.changeset/34062-flow-record-text-org-locale.md b/.changeset/34062-flow-record-text-org-locale.md new file mode 100644 index 00000000000..f6c0a968ed1 --- /dev/null +++ b/.changeset/34062-flow-record-text-org-locale.md @@ -0,0 +1,23 @@ +--- +'@objectstack/spec': minor +'@objectstack/core': minor +'@objectstack/service-automation': minor +'@objectstack/lint': minor +'@objectstack/runtime': patch +--- + +feat(automation): a flow writes a field marked as text in the organization's language + +Clause-②: yes (widening) — `create_record` / `update_record` `fields` values now also take the text envelope `{ dialect: 'template', source }` (`FlowRecordFieldValueSchema`), and the translation face gains `flows..records..fields.`; every value accepted before is accepted and written as before +Metadata-protocol: added +Skills-docs: follow-up owed — skills/objectstack-automation/SKILL.md (the record write's field values: the text envelope beside the CEL envelope and the literal), skills/objectstack-i18n/SKILL.md (the `flows..records..fields.` key and the organization-language rule) + +A `create_record` / `update_record` field value can now be marked as text: `{ dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' }`. The node writes that sentence in the organization's language, because everyone in the organization reads the record. It picks the translated template at `flows..records..fields.` first, then fills its `{{ }}` holes. The language is the Localization setting (`localization.locale`) when somebody set it, else the app's declared `i18n.defaultLocale`. It is never the language of the person who started the run, so a run started by a button writes the same text as a record-change run. + +- A missing translation, or no language to pick, writes the authored text, and the run goes on. +- A bare string is still a literal and is written as spelled. Only the `fields` map of these two nodes takes the text envelope; every other value slot still refuses it. The source is judged as a text slot: a single-brace `{token}` is refused with its `{{ }}` spelling. +- A Localization setting that cannot be read fails the node and writes nothing, so another language is never stored over a choice that may exist. A `fault` edge routes the failure. +- `os i18n extract` scaffolds the key, and the existing coverage check reports it missing against `supportedLocales`. `objectstack validate` refuses a key over an unknown node, over a node that is not a record write, or over a field the node does not mark as text. +- Text is picked when it is written. Records already written are not changed. + +`@objectstack/core` exports `resolveOrganizationLocale` and `readOrganizationLocaleSetting`: one reader of the organization's language, for text the platform writes on the organization's behalf. `@objectstack/runtime`'s seed-locale resolver now reads its organization-setting rung through `readOrganizationLocaleSetting`; its answers are unchanged. diff --git a/content/docs/automation/flows.mdx b/content/docs/automation/flows.mdx index 32c7df752a8..c2815f3ee1e 100644 --- a/content/docs/automation/flows.mdx +++ b/content/docs/automation/flows.mdx @@ -567,6 +567,48 @@ check. [#22110]: https://github.com/objectstack-ai/objectstack/issues/22110 +### Text a record keeps — a field value marked as text + +A `create_record` / `update_record` field value is a literal or a CEL value +envelope, and a literal string is written exactly as spelled. A field that +stores a **sentence people read** — an escalation reason, a status note — is +marked as text instead, with the text envelope `{ dialect: 'template', source }`. +Only the `fields` map of these two nodes takes it; every other value slot +refuses it. + +```typescript +{ + id: 'set_reason', type: 'update_record', label: 'Set reason', + config: { + objectName: 'crm_case', + filter: { id: { dialect: 'cel', source: 'record.id' } }, + fields: { + escalation_reason: { dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' }, + status: 'escalated', // a literal: written as spelled, never translated + }, + }, +} +``` + +- `source` is a text slot like the ones above: `{{ }}` holes over the flow's + variables, and a single-brace `{…}` token is refused with its `{{ }}` spelling. +- The text is written in the **organization's** language, because everyone in + the organization reads the record: the Localization setting + (`localization.locale`) when somebody set it, else the app's declared + `i18n.defaultLocale`. It is never the language of the person who started the + run — a button-started run writes the same text a record-change run does. +- The translated template is picked first, then its holes are filled. Its key is + `flows..records..fields.`; `os i18n extract` scaffolds + it and `os lint` reports it missing against `supportedLocales`, like every + other `flows.*` key. +- A missing translation, or no language to pick, writes the authored text and + the run goes on. A Localization setting that cannot be **read** fails the + node and writes nothing: the organization's choice may exist, and writing + another language over it would look like success. A `fault` edge routes it. +- The text is picked once, when it is written. Records written before a + translation existed keep what they hold, and changing the Localization setting + does not rewrite them. + **Create Record:** ```typescript diff --git a/content/docs/ui/translations.mdx b/content/docs/ui/translations.mdx index 957ccca2f6f..1989336eb87 100644 --- a/content/docs/ui/translations.mdx +++ b/content/docs/ui/translations.mdx @@ -90,6 +90,7 @@ export default defineStack({ | Page tab labels (`page:tabs` items) | `pages..components..items..label` — keyed by the tabs component's `id` and the item's `value`; an item without a `value` has no key (localize it with an inline locale map), and `page:accordion` panels have none | | A page `object-form`'s thank-you panel | `pages..components..submitBehavior.title` / `.message` — keyed by the `object-form` component's `id` (a form without an `id` has no key), by the same rules as a form view's panel | | Screen-flow wizards (flow label, screen headings and body text, screen field copy) | `flows..label` / `flows..screens..title` / `.description` / `.fields..label` / `.placeholder` / `.inlineHelpText` — a screen field's help text is `inlineHelpText`, the key the field itself declares, not `help`; see the boundary note below | +| Text a flow writes into a record (a `create_record` / `update_record` field value marked `{ dialect: 'template', source }`) | `flows..records..fields.` — picked in the organization's language (the Localization setting when set, else the app's `i18n.defaultLocale`), never the run starter's; see [Flows](/docs/automation/flows#text-a-record-keeps--a-field-value-marked-as-text) | | Hook refusal messages | `hooks..refusals..message` — one per entry of the hook's `refusals` catalogue — and `hooks..refusals..reasons..message`, one per reason an entry declares. A hook (a `js` body or a TypeScript `handler`) refuses by code, optionally with a declared reason, and the server answers the refusal with this sentence in the caller's locale, else the declared one. A translation of an entry that declares `params` keeps its `{{ name }}` holes; the server fills them after picking the translation | | Position label / description | `positions..label` / `description` — keyed by the position's `name`; overlaid on every served position, which is the list the console's position picker draws | | Permission-set label / description | `permissions..label` / `description` — the group is spelled as the stack spells the collection (`permissions[]`), keyed by the set's `name` | diff --git a/packages/cli/test/i18n-flow-record-text-coverage.test.ts b/packages/cli/test/i18n-flow-record-text-coverage.test.ts new file mode 100644 index 00000000000..992da16326b --- /dev/null +++ b/packages/cli/test/i18n-flow-record-text-coverage.test.ts @@ -0,0 +1,124 @@ +// Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license. +// +// objectstack#34062 (ruling 6913660232) — a record field value marked as text +// joins the flow bucket. +// +// A `create_record` / `update_record` field value marked `{ dialect: +// 'template', source }` is a sentence the record keeps, written in the +// organization's language. The bundle has a key for it +// (`flows..records..fields.`) and the engine reads that +// key before it fills the holes. These pins are the CLI half (parameter 5): the +// walker scaffolds the key, the existing coverage gate demands it, and the key +// the walker writes is the very address the engine asks for +// (`flowRecordFieldTextKey`). A bare string is a literal and has no key. +// +// The ledger mock is `i18n-flow-refusal-coverage.test.ts`'s, for its reason. + +import { describe, it, expect, vi } from 'vitest'; + +vi.mock('@objectstack/lint', async (importOriginal) => ({ + ...(await importOriginal()), + authorWarnedProperties: () => new Set(), +})); + +import { collectExpectedEntries, extractTranslations } from '../src/utils/i18n-bundle-extract.js'; +import { computeI18nCoverage } from '../src/utils/i18n-coverage.js'; +import { TranslationDataSchema, flowRecordFieldTextKey } from '@objectstack/spec/system'; + +const REASON = 'Auto-escalated: {{ record.priority }} priority'; + +const caseEscalation = { + name: 'case_escalation', + label: 'Case escalation', + type: 'record_change', + nodes: [ + { id: 'start', type: 'start', label: 'Start', config: { objectName: 'crm_case', triggerType: 'record-after-update' } }, + { + id: 'set_reason', type: 'update_record', label: 'Set reason', + config: { + objectName: 'crm_case', + filter: { id: { dialect: 'cel', source: 'record.id' } }, + fields: { + escalation_reason: { dialect: 'template', source: REASON }, + status: 'escalated', + owner: { dialect: 'cel', source: 'record.owner' }, + }, + }, + }, + { + id: 'log', type: 'create_record', label: 'Log', + config: { objectName: 'crm_case_log', fields: { note: { dialect: 'template', source: 'Escalated.' } } }, + }, + { id: 'done', type: 'end', label: 'Done' }, + ], + edges: [], +}; + +const recordEntries = (config: any) => + collectExpectedEntries(config).filter((e) => e.path[0] === 'flows' && e.path[2] === 'records'); + +describe('what the walker harvests from a record write (ruling 6913660232)', () => { + it('emits one key per field marked as text, keyed as the engine reads it, seeded with the template', () => { + const entries = recordEntries({ flows: [caseEscalation] }); + expect(entries.map((e) => e.path.join('.'))).toEqual([ + flowRecordFieldTextKey('case_escalation', 'set_reason', 'escalation_reason'), + flowRecordFieldTextKey('case_escalation', 'log', 'note'), + ]); + expect(entries[0]).toMatchObject({ sourceValue: REASON, inline: REASON, source: 'flow' }); + // CONTROL: the bare string and the CEL envelope beside it have no key. + expect(entries.some((e) => e.path.includes('status') || e.path.includes('owner'))).toBe(false); + }); +}); + +describe('the coverage gate demands the marked text (ruling 6913660232)', () => { + const tree = (flows?: Record) => ({ + i18n: { defaultLocale: 'en', supportedLocales: ['en', 'zh-CN'] }, + flows: [caseEscalation], + translations: [{ 'zh-CN': { ...(flows ? { flows } : {}) } }], + }); + const zhRecords = (config: any) => + computeI18nCoverage(config).issues.filter( + (i) => i.locale === 'zh-CN' && i.key.startsWith('flows.') && i.key.includes('.records.'), + ); + + it('reports each untranslated marked field in the flow bucket', () => { + const issues = zhRecords(tree()); + expect(issues.map((i) => i.key).sort()).toEqual([ + 'flows.case_escalation.records.log.fields.note', + 'flows.case_escalation.records.set_reason.fields.escalation_reason', + ]); + expect(issues[0]!.source).toBe('flow'); + }); + + it('goes quiet once they are translated', () => { + expect(zhRecords(tree({ + case_escalation: { + records: { + set_reason: { fields: { escalation_reason: '自动升级:{{ record.priority }} 优先级' } }, + log: { fields: { note: '已升级。' } }, + }, + }, + }))).toEqual([]); + }); +}); + +describe('the skeleton `os i18n extract` writes (ruling 6913660232)', () => { + const result = extractTranslations({ flows: [caseEscalation] }, { locales: ['en', 'zh-CN'] }); + + it('writes the template into the default locale and an empty slot into the others', () => { + expect((result.bundles.en as any).flows.case_escalation.records).toEqual({ + set_reason: { fields: { escalation_reason: REASON } }, + log: { fields: { note: 'Escalated.' } }, + }); + expect((result.bundles['zh-CN'] as any).flows.case_escalation.records).toEqual({ + set_reason: { fields: { escalation_reason: '' } }, + log: { fields: { note: '' } }, + }); + }); + + it('parses through the schema it is written for, in every locale', () => { + for (const [locale, bundle] of Object.entries(result.bundles)) { + expect(TranslationDataSchema.safeParse(bundle).success, `skeleton for ${locale}`).toBe(true); + } + }); +}); diff --git a/packages/lint/src/validate-translation-references.test.ts b/packages/lint/src/validate-translation-references.test.ts index adedbf952ae..614a7c55769 100644 --- a/packages/lint/src/validate-translation-references.test.ts +++ b/packages/lint/src/validate-translation-references.test.ts @@ -5028,3 +5028,54 @@ describe('validateTranslationReferences — doc books (#26690)', () => { )).map((f) => f.path)).toEqual(['translations[0].en.books.com.example.crm.groups.start']); }); }); + +describe('validateTranslationReferences — text a flow writes into a record (ruling 6913660232)', () => { + const caseStack = { + flows: [ + { + name: 'case_escalation', + type: 'record_change', + nodes: [ + { id: 'start', type: 'start', label: 'Start', config: { objectName: 'crm_case', triggerType: 'record-after-update' } }, + { + id: 'set_reason', type: 'update_record', label: 'Set reason', + config: { + objectName: 'crm_case', + filter: { id: { dialect: 'cel', source: 'record.id' } }, + fields: { + escalation_reason: { dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' }, + status: 'escalated', + }, + }, + }, + { id: 'tell', type: 'save_notice', label: 'Tell', config: { message: 'Escalated' } }, + ], + }, + ], + }; + const bundle = (flows: unknown) => ({ ...caseStack, translations: [{ 'zh-CN': { flows } }] }); + const keyed = (fields: Record, nodeId = 'set_reason') => + bundle({ case_escalation: { records: { [nodeId]: { fields } } } }); + + it('reports nothing for a field the node marks as text', () => { + expect(validateTranslationReferences(keyed({ escalation_reason: '自动升级:{{ record.priority }} 优先级' }))).toEqual([]); + }); + + it('refuses a key over a field whose value is a bare string — a literal is never translated', () => { + const findings = validateTranslationReferences(keyed({ status: '已升级' })); + expect(findings).toHaveLength(1); + expect(findings[0].rule).toBe(TRANSLATION_TARGET_UNKNOWN); + expect(findings[0].severity).toBe('error'); + expect(findings[0].path).toBe('translations[0]["zh-CN"].flows.case_escalation.records.set_reason.fields.status'); + }); + + it('refuses a key over an UNKNOWN node, and one over a node that is not a record write', () => { + const unknown = validateTranslationReferences(keyed({ escalation_reason: 'x' }, 'set_reasn')); + expect(unknown.map((f) => f.path)).toEqual(['translations[0]["zh-CN"].flows.case_escalation.records.set_reasn']); + expect(unknown[0].message).toContain('Did you mean "set_reason"?'); + + const otherType = validateTranslationReferences(keyed({ message: 'x' }, 'tell')); + expect(otherType.map((f) => f.path)).toEqual(['translations[0]["zh-CN"].flows.case_escalation.records.tell']); + expect(otherType[0].message).toContain('`save_notice` node'); + }); +}); diff --git a/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts b/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts new file mode 100644 index 00000000000..61bf1ac4e48 --- /dev/null +++ b/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts @@ -0,0 +1,202 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// [#34062, ruling 6913660232] A sentence a flow writes into a record is +// written in the ORGANIZATION's language — on a real boot: the app's declared +// `i18n.defaultLocale`, the `translations` the stack loads into the i18n +// service, the settings service's `localization.locale`, the record-change +// trigger, the REST trigger door and the ObjectQL engine the row lands in. +// +// The app declares `i18n.defaultLocale: 'zh-CN'` and no Localization row is +// written until the last case, so the language the platform answers for the +// organization is the app's own. Each flow writes one note with three fields: +// +// - `reason`: marked as text, translated in zh-CN and ja-JP; +// - `detail`: marked as text, translated in no locale; +// - `kind`: a bare string — a literal, never translated. +// +// Boots a fixture stack of its own, so it stays out of `SHARED_SHOWCASE`. + +import { describe, it, expect, beforeAll, afterAll } from 'vitest'; +import { bootStack, type VerifyStack } from '@objectstack/verify'; +import { RecordChangeTriggerPlugin } from '@objectstack/trigger-record-change'; +import { defineStack } from '@objectstack/spec'; + +const CASE = 'rtx_case'; +const NOTE = 'rtx_note'; +const ON_CHANGE = 'rtx_escalate'; +const BY_HAND = 'rtx_escalate_now'; +const SYSTEM_CTX = { isSystem: true, positions: [], permissions: [] }; + +const REASON = 'Auto-escalated: {{ priority }} priority'; +const DETAIL = 'Raised for {{ priority }}'; + +/** The note write both flows end in, reading the `priority` variable; `via` names the run. */ +const writeNote = (via: unknown) => ({ + id: 'write_note', type: 'create_record', label: 'Write note', + config: { + objectName: NOTE, + fields: { + via, + reason: { dialect: 'template', source: REASON }, + detail: { dialect: 'template', source: DETAIL }, + kind: 'escalation', + }, + }, +}); + +const fixtureStack = defineStack({ + manifest: { + id: 'com.dogfood.flow-record-text-org-locale', + namespace: 'rtx', + version: '0.0.0', + type: 'app', + name: 'Flow Record Text Org Locale Fixture', + description: 'A flow writes a translated sentence into a record (#34062).', + }, + requires: ['automation', 'triggers'], + i18n: { defaultLocale: 'zh-CN', supportedLocales: ['zh-CN', 'en-US', 'ja-JP'] }, + objects: [ + { + name: CASE, label: 'Case', sharingModel: 'public_read_write', + fields: { title: { type: 'text', label: 'Title' }, priority: { type: 'text', label: 'Priority' } }, + }, + { + name: NOTE, label: 'Note', sharingModel: 'public_read_write', + fields: { + via: { type: 'text', label: 'Via' }, + reason: { type: 'text', label: 'Reason' }, + detail: { type: 'text', label: 'Detail' }, + kind: { type: 'text', label: 'Kind' }, + }, + }, + ], + flows: [ + { + name: ON_CHANGE, label: 'Escalate on create', type: 'record_change', status: 'active', + variables: [{ name: 'priority', type: 'text' }], + nodes: [ + { id: 'start', type: 'start', label: 'Start', config: { objectName: CASE, triggerType: 'record-after-create' } }, + { id: 'read', type: 'assignment', label: 'Read', config: { assignments: { priority: { dialect: 'cel', source: 'record.priority' } } } }, + writeNote({ dialect: 'cel', source: "'rc:' + record.title" }), + { id: 'end', type: 'end', label: 'End' }, + ], + edges: [ + { id: 'e1', source: 'start', target: 'read' }, + { id: 'e2', source: 'read', target: 'write_note' }, + { id: 'e3', source: 'write_note', target: 'end' }, + ], + }, + { + name: BY_HAND, label: 'Escalate now', type: 'autolaunched', status: 'active', + variables: [{ name: 'priority', type: 'text', isInput: true }, { name: 'via', type: 'text', isInput: true }], + nodes: [ + { id: 'start', type: 'start', label: 'Start' }, + writeNote({ dialect: 'cel', source: 'via' }), + { id: 'end', type: 'end', label: 'End' }, + ], + edges: [ + { id: 'e1', source: 'start', target: 'write_note' }, + { id: 'e2', source: 'write_note', target: 'end' }, + ], + }, + ], + translations: [ + { + 'zh-CN': { + flows: { + [ON_CHANGE]: { records: { write_note: { fields: { reason: '自动升级:{{ priority }} 优先级' } } } }, + [BY_HAND]: { records: { write_note: { fields: { reason: '自动升级:{{ priority }} 优先级' } } } }, + }, + }, + 'en-US': { + flows: { + [BY_HAND]: { records: { write_note: { fields: { reason: 'EN: escalated, {{ priority }}' } } } }, + }, + }, + 'ja-JP': { + flows: { + [ON_CHANGE]: { records: { write_note: { fields: { reason: '自動エスカレーション:{{ priority }} 優先度' } } } }, + }, + }, + }, + ], +} as never); + +describe('dogfood: a flow writes a marked field in the organization\'s language (#34062)', () => { + let stack: VerifyStack; + let token: string; + let ql: any; + + /** The one note a run wrote with `via`, waited for briefly: an after-create run lands with its write. */ + const noteVia = async (via: string): Promise> => { + for (let i = 0; i < 50; i++) { + const rows = await ql.find(NOTE, { where: { via }, context: SYSTEM_CTX }); + if (rows.length > 0) { + expect(rows, `one note via ${via}`).toHaveLength(1); + return rows[0]; + } + await new Promise((r) => setTimeout(r, 100)); + } + throw new Error(`no note was written via ${via}`); + }; + + /** A record nobody wrote as a person: the trigger's run carries no user and no locale. */ + const systemCase = async (title: string, priority: string) => { + await ql.insert(CASE, { title, priority }, { context: SYSTEM_CTX }); + }; + + /** Start the hand-run flow as the signed-in admin, in a stated language. */ + const runByHand = async (via: string, locale: string) => { + const res = await stack.api(`/automation/${BY_HAND}/trigger`, { + method: 'POST', + headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}`, 'Accept-Language': locale }, + body: JSON.stringify({ params: { priority: 'High', via } }), + }); + const text = await res.text(); + expect(res.status, `POST /automation/${BY_HAND}/trigger: ${text.slice(0, 300)}`).toBeLessThan(300); + return JSON.parse(text); + }; + + beforeAll(async () => { + stack = await bootStack(fixtureStack, { automation: true, extraPlugins: [new RecordChangeTriggerPlugin()] }); + token = await stack.signIn(); + ql = await stack.kernel.getServiceAsync('objectql'); + }, 300_000); + + afterAll(async () => { + await stack?.stop?.(); + }); + + it('a record-change run with no user writes the zh-CN translation, holes filled; an untranslated mark and a bare string as authored', async () => { + await systemCase('Printer down', 'High'); + const note = await noteVia('rc:Printer down'); + expect(note.reason).toBe('自动升级:High 优先级'); + // A missing translation writes the authored text, and the run completed. + expect(note.detail).toBe('Raised for High'); + // A bare string is the literal it spells. + expect(note.kind).toBe('escalation'); + }); + + it('a run a person started in en-US still writes the organization\'s zh-CN — never the starter\'s language', async () => { + await runByHand('button-en', 'en-US'); + const note = await noteVia('button-en'); + expect(note.reason).toBe('自动升级:High 优先级'); + // CONTROL: the en-US entry exists and is not what was written. + expect(note.reason).not.toBe('EN: escalated, High'); + }); + + it('a Localization setting somebody set wins over the app default', async () => { + const settings = stack.kernel.getService('settings') as { + set(namespace: string, key: string, value: unknown, ctx?: object): Promise; + get(namespace: string, key: string, ctx?: object): Promise<{ value: unknown; source: string }>; + }; + await settings.set('localization', 'locale', 'ja-JP', {}); + expect((await settings.get('localization', 'locale', {})).source).not.toBe('default'); + + await systemCase('Server down', 'Low'); + const note = await noteVia('rc:Server down'); + expect(note.reason).toBe('自動エスカレーション:Low 優先度'); + // CONTROL: the untranslated mark still writes the authored text under the setting. + expect(note.detail).toBe('Raised for Low'); + }); +}); diff --git a/packages/services/service-automation/src/builtin/record-field-text.test.ts b/packages/services/service-automation/src/builtin/record-field-text.test.ts new file mode 100644 index 00000000000..a3f1a3b4f17 --- /dev/null +++ b/packages/services/service-automation/src/builtin/record-field-text.test.ts @@ -0,0 +1,259 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * A `create_record` / `update_record` field value MARKED as text is written in + * the ORGANIZATION's language — ruling 6913660232 on objectstack#34062, letter + * B, the executor half. + * + * The record keeps the sentence for everyone in the organization, so the + * translated template is picked first (at + * `flows..records..fields.`) and its `{{ }}` holes are + * filled after (parameter 1), in the language the organization reads + * (parameter 3): the Localization setting when somebody set it, else the app's + * declared `i18n.defaultLocale`, else the authored text — never the language of + * whoever started the run (parameter 2). A bare string is a literal and is + * written as it is spelled (parameter 4); a missing translation writes the + * authored text and the run completes (parameter 5). + * + * Every pin runs through the REAL in-memory `i18n` service, the plugin's own + * `organizationLocaleReader` (the function `AutomationServicePlugin` wires) and + * a real ObjectQL engine over a recording driver: the verdict is the row that + * reaches the store. + */ + +import { describe, it, expect } from 'vitest'; +import { ObjectQL } from '@objectstack/objectql'; +import { createMemoryI18n } from '@objectstack/core'; +import type { AutomationContext } from '@objectstack/spec/contracts'; + +import { AutomationEngine } from '../engine.js'; +import { i18nServiceReader, organizationLocaleReader } from '../plugin.js'; +import { registerCrudNodes } from './crud-nodes.js'; + +function makeLogger(): any { + const l: any = { info() {}, warn() {}, error() {}, debug() {}, trace() {}, fatal() {} }; + l.child = () => l; + return l; +} + +const AUTHORED = 'Auto-escalated: {{ record.priority }} priority'; +const ZH = '自动升级:{{ record.priority }} 优先级'; +const JA = '自動エスカレーション:{{ record.priority }} 優先度'; + +/** The organization's Localization row, as the `settings` service answers it. */ +type SettingsAnswer = { value?: unknown; source?: string } | undefined | (() => never); + +function settingsService(answer: SettingsAnswer) { + const asked: Array<{ tenantId?: string }> = []; + return { + asked, + async get(_ns: string, _key: string, ctx?: { tenantId?: string }) { + asked.push(ctx ?? {}); + if (typeof answer === 'function') answer(); + return answer as { value?: unknown; source?: string } | undefined; + }, + }; +} + +function makeRecordingDriver() { + const writes: Array<{ op: 'create' | 'update'; data: Record }> = []; + const driver: any = { + name: 'recording', version: '0.0.0', supports: {}, + async connect() {}, async disconnect() {}, async checkHealth() { return true; }, async execute() { return null; }, + async find() { return []; }, + async findOne() { return { id: 'case_1' }; }, + async create(_o: string, data: Record) { writes.push({ op: 'create', data: { ...data } }); return { id: 'case_1', ...data }; }, + async update(_o: string, id: string, data: Record) { writes.push({ op: 'update', data: { ...data } }); return { id, ...data }; }, + async updateMany() { return 0; }, + async delete() { return true; }, async deleteMany() { return 0; }, async count() { return 0; }, + async bulkCreate(o: string, rows: Record[]) { return Promise.all(rows.map((r) => driver.create(o, r))); }, + async bulkUpdate() { return []; }, async bulkDelete() {}, + async beginTransaction() { return { __trx: true, commit: async () => {}, rollback: async () => {} }; }, + async commit() {}, async rollback() {}, + }; + return { driver, writes }; +} + +interface StackOptions { + /** The app's declared `i18n.defaultLocale` (the memory service's default). */ + defaultLocale?: string; + /** Translation bundles by locale. */ + bundles?: Record>; + /** What the `settings` service answers for `localization.locale`; absent ⇒ no service. */ + settings?: SettingsAnswer; +} + +async function makeStack(options: StackOptions = {}) { + const logger = makeLogger(); + const ql = new ObjectQL({ logger }); + const { driver, writes } = makeRecordingDriver(); + ql.registerDriver(driver, true); + await ql.init(); + ql.registry.registerObject({ + name: 'crm_case', + fields: { + id: { name: 'id', type: 'text', primaryKey: true }, + priority: { name: 'priority', type: 'text' }, + status: { name: 'status', type: 'text' }, + escalation_reason: { name: 'escalation_reason', type: 'text' }, + internal_note: { name: 'internal_note', type: 'text' }, + }, + } as any, 'test'); + + const i18n = createMemoryI18n(); + if (options.defaultLocale) i18n.setDefaultLocale(options.defaultLocale); + for (const [locale, data] of Object.entries(options.bundles ?? {})) i18n.loadTranslations(locale, data); + const settings = options.settings === undefined ? undefined : settingsService(options.settings); + + const services: Record = { data: ql, i18n, ...(settings ? { settings } : {}) }; + const getService = ((name: string): T => { + if (name in services) return services[name] as T; + throw new Error(`service '${name}' not registered`); + }) as never; + + const automation = new AutomationEngine(logger); + automation.setI18nServiceSource(i18nServiceReader({ getService })); + automation.setOrganizationLocaleResolver(organizationLocaleReader({ getService })); + registerCrudNodes(automation, { logger, getService: (n: string) => (n === 'data' ? ql : undefined) } as any); + return { automation, writes, settings }; +} + +type WriteNode = 'create_record' | 'update_record'; + +function escalationFlow(nodeType: WriteNode, fields: Record) { + const config: Record = { objectName: 'crm_case', fields }; + if (nodeType === 'update_record') config.filter = { id: 'case_1' }; + return { + name: 'case_escalation', label: 'Case Escalation', type: 'record_change', + nodes: [ + { id: 'start', type: 'start', label: 'Start', config: { objectName: 'crm_case', triggerType: 'record-after-update' } }, + { id: 'set_reason', type: nodeType, label: 'Set reason', config }, + { id: 'end', type: 'end', label: 'End' }, + ], + edges: [ + { id: 'e1', source: 'start', target: 'set_reason' }, + { id: 'e2', source: 'set_reason', target: 'end' }, + ], + } as any; +} + +const MARKED = { escalation_reason: { dialect: 'template', source: AUTHORED }, status: 'escalated' }; +const ZH_BUNDLE = { flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: ZH } } } } } }; +const JA_BUNDLE = { flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: JA } } } } } }; + +/** A record-change run: no user, no locale — the trigger's own context. */ +const recordChange = (): AutomationContext => ({ + event: 'record-after-update', object: 'crm_case', tenantId: 'org_1', + record: { id: 'case_1', priority: 'High' }, +} as unknown as AutomationContext); + +/** A run a person started (a button), carrying that person's own language. */ +const startedBy = (locale: string): AutomationContext => ({ + userId: 'usr_ada', locale, tenantId: 'org_1', + record: { id: 'case_1', priority: 'High' }, +} as unknown as AutomationContext); + +const NODE_TYPES: readonly WriteNode[] = ['create_record', 'update_record']; + +describe.each(NODE_TYPES)('%s — a field value marked as text is written in the organization\'s language', (nodeType) => { + it('a zh-CN app with no Localization row: a record-change run with no user writes the zh-CN translation, holes filled', async () => { + const { automation, writes } = await makeStack({ defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE }, settings: { value: 'en-US', source: 'default' } }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes).toHaveLength(1); + expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); + }); + + it('a run a person started in en-US still writes the organization\'s zh-CN — never the starter\'s language', async () => { + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', + bundles: { 'zh-CN': ZH_BUNDLE, 'en-US': { flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: 'EN pick {{ record.priority }}' } } } } } } }, + settings: { value: 'en-US', source: 'default' }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', startedBy('en-US')); + + expect(result.success, result.error).toBe(true); + expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); + }); + + it('a Localization setting somebody set wins over the app default, asked for the run\'s organization', async () => { + const { automation, writes, settings } = await makeStack({ + defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE, 'ja-JP': JA_BUNDLE }, settings: { value: 'ja-JP', source: 'tenant' }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes[0].data.escalation_reason).toBe('自動エスカレーション:High 優先度'); + expect(settings!.asked).toEqual([{ tenantId: 'org_1' }]); + }); + + it('CONTROL — the setting\'s `source: default` placeholder is not a choice: the app default answers', async () => { + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE, 'ja-JP': JA_BUNDLE }, settings: { value: 'ja-JP', source: 'default' }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + await automation.execute('case_escalation', recordChange()); + + expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); + }); + + it('a missing translation writes the authored text, holes filled, and the run completes', async () => { + const { automation, writes } = await makeStack({ defaultLocale: 'zh-CN', bundles: { 'zh-CN': { flows: {} } } }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes[0].data.escalation_reason).toBe('Auto-escalated: High priority'); + }); + + it('a bare string is the literal it spells: written verbatim, never translated', async () => { + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', + bundles: { 'zh-CN': { flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: ZH, status: '已升级', internal_note: '内部' } } } } } } }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, { ...MARKED, internal_note: 'Raised by {{ record.priority }}' })); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes[0].data.status).toBe('escalated'); + expect(writes[0].data.internal_note).toBe('Raised by {{ record.priority }}'); + // CONTROL: the marked field beside them in the same write IS translated. + expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); + }); + + it('a Localization read that FAILS fails the node and writes nothing — a failed read is not "not set"', async () => { + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE }, settings: () => { throw new Error('settings store down'); }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success).toBe(false); + expect(result.error).toContain(`${nodeType}: the organization's language could not be read (settings store down)`); + expect(writes).toEqual([]); + }); + + it('CONTROL — a write that marks no text never reads the organization\'s language', async () => { + const { automation, writes, settings } = await makeStack({ + defaultLocale: 'zh-CN', settings: () => { throw new Error('settings store down'); }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, { status: 'escalated' })); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes[0].data.status).toBe('escalated'); + expect(settings!.asked).toEqual([]); + }); +}); diff --git a/packages/spec/dropped-refinements.baseline.json b/packages/spec/dropped-refinements.baseline.json index 9c0f485b189..707a851edf6 100644 --- a/packages/spec/dropped-refinements.baseline.json +++ b/packages/spec/dropped-refinements.baseline.json @@ -2,8 +2,8 @@ "description": "Shrink-only ledger of every PUBLISHED JSON Schema that is STILL WIDER than the Zod type it was generated from, because a rule written as `.refine()` reaches the runtime and not the file (#18670). `z.toJSONSchema()` has no arm for a `custom` check: a plain record, the same record with a `.refine()`, and the same record with an ABORTING `.refine()` all project byte-identically (measured on zod 4.4.3, the version packages/spec resolves). So a document one of these files ACCEPTS can still be refused at parse time, and an author -- or an AI -- validating against packages/spec/json-schema/** finds out a release later. Each `sites` path is a position under that schema at which a refinement is dropped; the same paths are written onto the artifact itself as `x-dropped-refinements`. Item 2 closed the first patterns: a refinement DECLARED through the closed list in src/shared/refinement-projection.ts is emitted into the published file, reads `projected` rather than `dropped`, and its row LEAVES this ledger in the same PR -- which is why the ledger shrinks and never grows on a repair. Every refinement outside that closed list stays here, and adding an arm to the list is a public-contract decision, not a refactor. Hand-edited on purpose and with no `gen:` script: a generator would let a new gap be admitted by running a command instead of by a decision, which is the silence this ledger exists to end. Adding, removing or moving a site fails packages/spec/scripts/build-schemas.ts until the line moves with it, and the failure prints the corrected entry in full. ⛔ Do not delete or weaken a refinement to shorten this file -- the runtime rule is correct; it is the projection that is silent, and the remedy is to teach the closed list a NAMED pattern, never to drop the rule.", "measured": { "zod": "4.4.3", - "publishedSchemasWithDroppedRefinements": 265, - "droppedRefinementSites": 1081, + "publishedSchemasWithDroppedRefinements": 266, + "droppedRefinementSites": 1090, "refinementSitesThatDidProject": 728, "refinementSitesWithNoJsonFormToCompare": 0 }, @@ -170,6 +170,7 @@ "manifest.translations.element", "manifest.translations.element.valueType.flows.valueType.errorMessage", "manifest.translations.element.valueType.flows.valueType.notices.valueType.message", + "manifest.translations.element.valueType.flows.valueType.records.valueType.fields.valueType", "manifest.translations.element.valueType.flows.valueType.refusals.valueType.message", "manifest.translations.element.valueType.flows.valueType.screens.valueType.description", "manifest.translations.element.valueType.flows.valueType.screens.valueType.title", @@ -382,7 +383,8 @@ "translations.flows.valueType.screens.valueType.description", "translations.flows.valueType.screens.valueType.title", "translations.flows.valueType.successMessage", - "translations.flows.valueType.notices.valueType.message" + "translations.flows.valueType.notices.valueType.message", + "translations.flows.valueType.records.valueType.fields.valueType" ] }, "api/GetUiViewResponse": { @@ -774,6 +776,11 @@ "in.waitEventConfig" ] }, + "automation/FlowRecordFieldValue": { + "sites": [ + "" + ] + }, "automation/FlowRegion": { "sites": [ "nodes.element.lazy.in.waitEventConfig" @@ -1588,6 +1595,7 @@ "", "valueType.flows.valueType.errorMessage", "valueType.flows.valueType.notices.valueType.message", + "valueType.flows.valueType.records.valueType.fields.valueType", "valueType.flows.valueType.refusals.valueType.message", "valueType.flows.valueType.screens.valueType.description", "valueType.flows.valueType.screens.valueType.title", @@ -1601,7 +1609,8 @@ "flows.valueType.screens.valueType.description", "flows.valueType.screens.valueType.title", "flows.valueType.successMessage", - "flows.valueType.notices.valueType.message" + "flows.valueType.notices.valueType.message", + "flows.valueType.records.valueType.fields.valueType" ] }, "system/Schedule": { @@ -1616,7 +1625,8 @@ "flows.valueType.screens.valueType.description", "flows.valueType.screens.valueType.title", "flows.valueType.successMessage", - "flows.valueType.notices.valueType.message" + "flows.valueType.notices.valueType.message", + "flows.valueType.records.valueType.fields.valueType" ] }, "system/ServerRateLimitConfig": { @@ -1659,6 +1669,7 @@ "", "valueType.flows.valueType.errorMessage", "valueType.flows.valueType.notices.valueType.message", + "valueType.flows.valueType.records.valueType.fields.valueType", "valueType.flows.valueType.refusals.valueType.message", "valueType.flows.valueType.screens.valueType.description", "valueType.flows.valueType.screens.valueType.title", @@ -1672,7 +1683,8 @@ "flows.valueType.screens.valueType.description", "flows.valueType.screens.valueType.title", "flows.valueType.successMessage", - "flows.valueType.notices.valueType.message" + "flows.valueType.notices.valueType.message", + "flows.valueType.records.valueType.fields.valueType" ] }, "system/TranslationItem": { @@ -1682,7 +1694,8 @@ "flows.valueType.screens.valueType.description", "flows.valueType.screens.valueType.title", "flows.valueType.successMessage", - "flows.valueType.notices.valueType.message" + "flows.valueType.notices.valueType.message", + "flows.valueType.records.valueType.fields.valueType" ] }, "ui/Action": { diff --git a/packages/spec/json-schema.manifest/automation.json b/packages/spec/json-schema.manifest/automation.json index af7064ee146..9a8cddd09a1 100644 --- a/packages/spec/json-schema.manifest/automation.json +++ b/packages/spec/json-schema.manifest/automation.json @@ -50,6 +50,7 @@ "automation/FlowFunctionLoweredDeclaration", "automation/FlowNode", "automation/FlowNodeAction", + "automation/FlowRecordFieldValue", "automation/FlowRegion", "automation/FlowRunGateSummary", "automation/FlowRunNodeSummary", diff --git a/packages/spec/liveness/translation.json b/packages/spec/liveness/translation.json index be20ea086f1..99edfe5be48 100644 --- a/packages/spec/liveness/translation.json +++ b/packages/spec/liveness/translation.json @@ -222,6 +222,22 @@ }, "note": "[#28251] Seeded `live` together with its reader: the key and the engine read that makes it true land in one change (Prime Directive 10). A `save_notice` node runs inside the record write that started its flow, so the sentence is rendered in the locale of the person who made that write, before the write answers. The translation is a text slot like the source: `TranslationDataSchema` refuses a single-brace `{token}` in it through `textSlotTemplateRefusal`, and `objectstack validate` (`validate-translation-references.ts`) refuses a key over an unknown flow, an unknown node, or a node that is not a `save_notice`. No objectui reader is involved: the console draws the served `notice` verbatim. DRILLED to its one key, `message`, so no blanket verdict covers an unclassified child: the entry's face is closed (`.strict()`)." }, + "records": { + "status": "live", + "verifiedAt": "2026-11-16", + "evidenceScope": "in-repo", + "evidence": "packages/services/service-automation/src/builtin/crud-nodes.ts#resolveFieldValues (the one reader of the group: the `create_record` / `update_record` executors read each `records.` entry for its `fields`, the drilled child below)", + "children": { + "fields": { + "status": "live", + "verifiedAt": "2026-11-16", + "evidenceScope": "in-repo", + "evidence": "packages/services/service-automation/src/builtin/crud-nodes.ts#resolveFieldValues (for each field value marked as text, `{ dialect: 'template', source }`, asks `flows..records..fields.`, spelled by `flowRecordFieldTextKey`, in the ORGANIZATION's language read through `AutomationEngine.organizationLocale`, and writes the rendered pick in place of the authored template); packages/services/service-automation/src/node-text-rendering.ts#renderFlowTextSlot (picks the translated template through the `i18n` service, negotiated by `resolveBundleLocale`, then fills its holes; a miss echoes the key and the authored template renders)", + "producer": "packages/runtime/src/app-plugin.ts#loadTranslations (hands each bundle's locale data to the i18n service whole, `flows` included); packages/services/service-automation/src/plugin.ts#i18nServiceReader (the engine's lazy reader of that service); packages/services/service-automation/src/plugin.ts#organizationLocaleReader (answers the language through `@objectstack/core`'s `resolveOrganizationLocale`: the `localization.locale` setting somebody set, else the `i18n` service's `getDefaultLocale()`)" + } + }, + "note": "[#34062, ruling 6913660232] Seeded `live` together with its reader: the key and the engine read that makes it true land in one change (Prime Directive 10). A record keeps the sentence for everyone in the organization, so it is picked in the organization's language, never the run starter's, once, when it is written: no backfill, and a later setting change rewrites nothing. Only a value MARKED as text is read (`FlowRecordFieldValueSchema`); a bare string is a literal and has no key. The translation is a text slot like the source: `TranslationDataSchema` refuses a single-brace `{token}` in it through `textSlotTemplateRefusal`, and `objectstack validate` (`validate-translation-references.ts`) refuses a key over an unknown flow, an unknown node, a node that is not a `create_record` / `update_record`, or a field the node does not mark as text. DRILLED to its one key, `fields`, so no blanket verdict covers an unclassified child: the entry's face is closed (`.strict()`)." + }, "approvals": { "status": "live", "verifiedAt": "2026-10-21", From 8654c312e505f90ab46f1cca4dbd78f50e70ab64 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 14:16:49 +0000 Subject: [PATCH 05/13] chore(spec): regenerate the reference docs, api surface, origins, declaration map and ledger counts Co-Authored-By: Claude --- .../references/automation/builtin-node-config.mdx | 15 +++++++++++---- content/docs/references/index.mdx | 10 +++++----- content/docs/references/system/translation.mdx | 4 ++++ .../system.md | 2 +- packages/spec/api-surface/automation.json | 4 ++++ packages/spec/api-surface/system.json | 1 + packages/spec/declaration-map/automation.json | 2 ++ packages/spec/export-origins/automation.json | 4 ++++ packages/spec/export-origins/system.json | 1 + .../spec/liveness/state-counts/translation.md | 2 +- 10 files changed, 34 insertions(+), 11 deletions(-) diff --git a/content/docs/references/automation/builtin-node-config.mdx b/content/docs/references/automation/builtin-node-config.mdx index e2821be3f6c..008883674ee 100644 --- a/content/docs/references/automation/builtin-node-config.mdx +++ b/content/docs/references/automation/builtin-node-config.mdx @@ -104,8 +104,8 @@ Deliberately absent: ## TypeScript Usage ```typescript -import { AssignmentConfigSchema, AssignmentExpressionValueSchema, AssignmentValueSchema, CreateRecordConfigSchema, DeleteRecordConfigSchema, EndConfigSchema, FlowCollectionSlotSchema, FlowValueSlotSchema, GetRecordConfigSchema, MapConfigSchema, SaveNoticeConfigSchema, ScreenConfigSchema, ScreenFieldConfigSchema, UpdateRecordConfigSchema } from '@objectstack/spec/automation'; -import type { AssignmentConfig, AssignmentExpressionValue, AssignmentValue, CreateRecordConfig, DeleteRecordConfig, EndConfig, FlowCollectionSlot, FlowValueSlot, GetRecordConfig, MapConfig, SaveNoticeConfig, ScreenConfig, ScreenFieldConfig, UpdateRecordConfig } from '@objectstack/spec/automation'; +import { AssignmentConfigSchema, AssignmentExpressionValueSchema, AssignmentValueSchema, CreateRecordConfigSchema, DeleteRecordConfigSchema, EndConfigSchema, FlowCollectionSlotSchema, FlowRecordFieldValueSchema, FlowValueSlotSchema, GetRecordConfigSchema, MapConfigSchema, SaveNoticeConfigSchema, ScreenConfigSchema, ScreenFieldConfigSchema, UpdateRecordConfigSchema } from '@objectstack/spec/automation'; +import type { AssignmentConfig, AssignmentExpressionValue, AssignmentValue, CreateRecordConfig, DeleteRecordConfig, EndConfig, FlowCollectionSlot, FlowRecordFieldValue, FlowValueSlot, GetRecordConfig, MapConfig, SaveNoticeConfig, ScreenConfig, ScreenFieldConfig, UpdateRecordConfig } from '@objectstack/spec/automation'; // Validate data const result = AssignmentConfigSchema.parse(data); @@ -154,7 +154,7 @@ Value the variable takes: a CEL value envelope `{ dialect: 'cel', source }` eval | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **objectName** | `string` | ✅ | Object to insert into | -| **fields** | `Record` | optional | Field values to write on the new record: each key is a field name, each value a CEL value envelope or a literal | +| **fields** | `Record` | optional | Field values to write on the new record: each key is a field name, each value a CEL value envelope, a text envelope (a sentence written in the organization's language) or a literal | | **outputVariable** | `string` | optional | Flow variable bound to the created record — a name without a leading `$` (the `$` names are the flow engine's own), read as `{{ name }}` | @@ -215,6 +215,13 @@ CEL value envelope `{ dialect: 'cel', source }` — evaluated by the expression --- +--- + +## FlowRecordFieldValue + +A field value: a CEL value envelope `{ dialect: 'cel', source }` evaluated to the value written, a text envelope `{ dialect: 'template', source }` — a sentence for people to read, written in the organization's language (its translation picked at `flows..records..fields.`, then its `{{ }}` holes filled; the authored text when none is held) — or a literal written as it is (a bare string is never translated; a `{…}` template token in it is refused) + + --- ## FlowValueSlot @@ -340,7 +347,7 @@ A value: a CEL value envelope `{ dialect: 'cel', source }` evaluated by the expr | :--- | :--- | :--- | :--- | | **objectName** | `string` | ✅ | Object to update | | **filter** | `Record` | optional | Field/value pairs identifying the record(s) to update: each operand — a field's value, an operator's comparand (`{"$ne": null}`), a list comparand's element — is a CEL value envelope `{ dialect: 'cel', source }` evaluated before the query (one that evaluates to null refuses the node), a query placeholder such as `{current_user_id}` or `{today}` the query engine resolves, or a literal; a flow `{…}` template token is refused | -| **fields** | `Record` | optional | Field values to write: each key is a field name, each value a CEL value envelope or a literal | +| **fields** | `Record` | optional | Field values to write: each key is a field name, each value a CEL value envelope, a text envelope (a sentence written in the organization's language) or a literal | | **multi** | `boolean` | optional | Declare bulk intent: update every row the filter matches (default false — a predicate update without it is refused by the engine) | diff --git a/content/docs/references/index.mdx b/content/docs/references/index.mdx index f90a1e35549..81db3f38a2c 100644 --- a/content/docs/references/index.mdx +++ b/content/docs/references/index.mdx @@ -1,7 +1,7 @@ --- title: Protocol reference — every schema by module navTitle: Protocol Reference -description: Every schema published by @objectstack/spec — 1664 schemas across 14 protocol modules +description: Every schema published by @objectstack/spec — 1665 schemas across 14 protocol modules --- {/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */} @@ -22,7 +22,7 @@ counts are sums of the rows they head. Regenerate with | :--- | ---: | ---: | :--- | | [AI Protocol](/docs/references/ai) | 14 | 81 | Agents, tools, skills, RAG and knowledge sources, model registry, conversations. | | [API Protocol](/docs/references/api) | 36 | 494 | REST contracts, endpoints, routing, realtime, batch, discovery. | -| [Automation Protocol](/docs/references/automation) | 16 | 81 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. | +| [Automation Protocol](/docs/references/automation) | 16 | 82 | Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. | | [Data Protocol](/docs/references/data) | 35 | 187 | Objects, fields, queries, filters, datasources and drivers — the ObjectQL layer. | | [Identity Protocol](/docs/references/identity) | 5 | 27 | Users and accounts, organizations, positions, SCIM provisioning. | | [Integration Protocol](/docs/references/integration) | 1 | 23 | The single connector protocol (ADR-0097) — catalog descriptors and provider-bound instances. | @@ -34,7 +34,7 @@ counts are sums of the rows they head. Regenerate with | [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. | | [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. | | [UI Protocol](/docs/references/ui) | 16 | 176 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. | -| **Total** | **218** | **1664** | 14 protocol modules | +| **Total** | **218** | **1665** | 14 protocol modules | --- @@ -112,7 +112,7 @@ REST contracts, endpoints, routing, realtime, batch, discovery. ## Automation Protocol -**Source:** `packages/spec/src/automation/` · **Import:** `@objectstack/spec/automation` · **16 pages, 81 schemas** +**Source:** `packages/spec/src/automation/` · **Import:** `@objectstack/spec/automation` · **16 pages, 82 schemas** Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execution records. @@ -123,7 +123,7 @@ Flows and their nodes, approvals, ETL pipelines, webhooks, state machines, execu | [`approval.zod.ts`](/docs/references/automation/approval) | `ApprovalDecision`, `ApprovalEscalation`, `ApprovalNodeApprover`, `ApprovalNodeConfig`, `ApproverType`, `DecisionOutputDef` | | [`assignment-rule.zod.ts`](/docs/references/automation/assignment-rule) | `AssignmentRule`, `AssignmentRuleEntry`, `AssignmentStrategy`, `AssignmentTarget` | | [`bpmn-interop.zod.ts`](/docs/references/automation/bpmn-interop) | `BpmnDiagnostic`, `BpmnElementMapping`, `BpmnExportOptions`, `BpmnImportOptions`, `BpmnInteropResult`, `BpmnUnmappedStrategy`, `BpmnVersion` | -| [`builtin-node-config.zod.ts`](/docs/references/automation/builtin-node-config) | `AssignmentConfig`, `AssignmentExpressionValue`, `AssignmentValue`, `CreateRecordConfig`, `DeleteRecordConfig`, `EndConfig`, `FlowCollectionSlot`, `FlowValueSlot`, `GetRecordConfig`, `MapConfig`, `SaveNoticeConfig`, `ScreenConfig`, `ScreenFieldConfig`, `UpdateRecordConfig` | +| [`builtin-node-config.zod.ts`](/docs/references/automation/builtin-node-config) | `AssignmentConfig`, `AssignmentExpressionValue`, `AssignmentValue`, `CreateRecordConfig`, `DeleteRecordConfig`, `EndConfig`, `FlowCollectionSlot`, `FlowRecordFieldValue`, `FlowValueSlot`, `GetRecordConfig`, `MapConfig`, `SaveNoticeConfig`, `ScreenConfig`, `ScreenFieldConfig`, `UpdateRecordConfig` | | [`control-flow.zod.ts`](/docs/references/automation/control-flow) | `FlowRegion`, `LoopConfig`, `ParallelBranch`, `ParallelConfig`, `RetryPolicy`, `TryCatchConfig`, `TryCatchErrorValue` | | [`execution.zod.ts`](/docs/references/automation/execution) | `Checkpoint`, `ConcurrencyPolicy`, `ExecutionError`, `ExecutionErrorSeverity`, `ExecutionLog`, `ExecutionStatus`, `ExecutionStepLog`, `ExecutionStepMetrics`, `ExecutionStepSkipReason`, `FlowRunGateSummary`, `FlowRunNodeSummary`, `FlowRunSummary` | | [`flow.zod.ts`](/docs/references/automation/flow) | `Flow`, `FlowEdge`, `FlowNode`, `FlowNodeAction`, `FlowVariable`, `FlowVersionHistory` | diff --git a/content/docs/references/system/translation.mdx b/content/docs/references/system/translation.mdx index ce8d7f44e0d..0c52cf5211f 100644 --- a/content/docs/references/system/translation.mdx +++ b/content/docs/references/system/translation.mdx @@ -292,6 +292,7 @@ Translation data for a single object | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | +| **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | ### Nested Shape: `PlatformTranslationData.hooks[string]` @@ -470,6 +471,7 @@ Translation data for a single object | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | +| **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | ### Nested Shape: `ServedTranslationData.hooks[string]` @@ -711,6 +713,7 @@ Translation data for a single object | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | +| **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | ### Nested Shape: `TranslationData.hooks[string]` @@ -921,6 +924,7 @@ Translation data for a single object | **refusals** | `Record` | optional | Refusal translations keyed by the node id (`FlowNode.id`) of an `end` node declaring `outcome: 'refused'` | | **approvals** | `Record` | optional | Approval-step translations keyed by the node id (`FlowNode.id`) of an `approval` node | | **notices** | `Record` | optional | Save-notice translations keyed by the node id (`FlowNode.id`) of a `save_notice` node | +| **records** | `Record }>` | optional | Record-write text translations keyed by the node id (`FlowNode.id`) of a `create_record` / `update_record` node | ### Nested Shape: `TranslationItem.hooks[string]` diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md index 25a387f907f..3ae8141da10 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate. | Dir | Sites | |---|---| -| `system/` | 403 | +| `system/` | 404 | diff --git a/packages/spec/api-surface/automation.json b/packages/spec/api-surface/automation.json index 7a7b47ae248..fcc0ddd2bbd 100644 --- a/packages/spec/api-surface/automation.json +++ b/packages/spec/api-surface/automation.json @@ -185,6 +185,9 @@ "FlowNodeTextSlotSource (interface)", "FlowNodeValueTemplateRefusal (interface)", "FlowParsed (type)", + "FlowRecordFieldValue (type)", + "FlowRecordFieldValueParsed (type)", + "FlowRecordFieldValueSchema (const)", "FlowRegion (type)", "FlowRegionArity (type)", "FlowRegionParsed (type)", @@ -357,6 +360,7 @@ "importBpmnToConstructs (function)", "isExpressionEnvelopeShaped (function)", "isFlowFunctionEffect (function)", + "isFlowTextEnvelopeShaped (function)", "normalizeDecisionOutputs (function)", "normalizeFlowFunctionEntry (function)", "parseFlowNodeRegions (function)", diff --git a/packages/spec/api-surface/system.json b/packages/spec/api-surface/system.json index f6182010904..424f7f86c9b 100644 --- a/packages/spec/api-surface/system.json +++ b/packages/spec/api-surface/system.json @@ -863,6 +863,7 @@ "docAudienceAllows (function)", "emailTemplateForm (const)", "flowNoticeMessageKey (function)", + "flowRecordFieldTextKey (function)", "flowRefusalMessageKey (function)", "flowScreenCopyKey (function)", "flowTerminalMessageKey (function)", diff --git a/packages/spec/declaration-map/automation.json b/packages/spec/declaration-map/automation.json index 54cb29d3134..033d3a73740 100644 --- a/packages/spec/declaration-map/automation.json +++ b/packages/spec/declaration-map/automation.json @@ -92,6 +92,8 @@ "FlowNode": "automation/FlowNode", "FlowNodeAction": "automation/FlowNodeAction", "FlowNodeSchema": "automation/FlowNode", + "FlowRecordFieldValue": "automation/FlowRecordFieldValue", + "FlowRecordFieldValueSchema": "automation/FlowRecordFieldValue", "FlowRegion": "automation/FlowRegion", "FlowRegionSchema": "automation/FlowRegion", "FlowRunGateSummary": "automation/FlowRunGateSummary", diff --git a/packages/spec/export-origins/automation.json b/packages/spec/export-origins/automation.json index 740a3e6ff88..cc4e09f0d43 100644 --- a/packages/spec/export-origins/automation.json +++ b/packages/spec/export-origins/automation.json @@ -179,6 +179,9 @@ "FlowNodeTextSlotSource": "src/automation/flow-text-slot-template.ts#FlowNodeTextSlotSource (interface)", "FlowNodeValueTemplateRefusal": "src/automation/flow-value-slot-template.ts#FlowNodeValueTemplateRefusal (interface)", "FlowParsed": "src/automation/flow.zod.ts#FlowParsed (type)", + "FlowRecordFieldValue": "src/automation/builtin-node-config.zod.ts#FlowRecordFieldValue (type)", + "FlowRecordFieldValueParsed": "src/automation/builtin-node-config.zod.ts#FlowRecordFieldValueParsed (type)", + "FlowRecordFieldValueSchema": "src/automation/builtin-node-config.zod.ts#FlowRecordFieldValueSchema (const)", "FlowRegion": "src/automation/control-flow.zod.ts#FlowRegion (type)", "FlowRegionArity": "src/automation/region-slots.ts#FlowRegionArity (type)", "FlowRegionParsed": "src/automation/control-flow.zod.ts#FlowRegionParsed (type)", @@ -350,6 +353,7 @@ "importBpmnToConstructs": "src/automation/bpmn-mapping.ts#importBpmnToConstructs (function)", "isExpressionEnvelopeShaped": "src/automation/flow-node-expression-paths.ts#isExpressionEnvelopeShaped (function)", "isFlowFunctionEffect": "src/automation/flow-function.zod.ts#isFlowFunctionEffect (function)", + "isFlowTextEnvelopeShaped": "src/automation/flow-node-expression-paths.ts#isFlowTextEnvelopeShaped (function)", "normalizeDecisionOutputs": "src/automation/approval.zod.ts#normalizeDecisionOutputs (function)", "normalizeFlowFunctionEntry": "src/automation/flow-function.zod.ts#normalizeFlowFunctionEntry (function)", "parseFlowNodeRegions": "src/automation/control-flow.zod.ts#parseFlowNodeRegions (function)", diff --git a/packages/spec/export-origins/system.json b/packages/spec/export-origins/system.json index a98d0a5b914..97efa9679d1 100644 --- a/packages/spec/export-origins/system.json +++ b/packages/spec/export-origins/system.json @@ -823,6 +823,7 @@ "docAudienceAllows": "src/system/book.zod.ts#docAudienceAllows (function)", "emailTemplateForm": "src/system/email-template.form.ts#emailTemplateForm (const)", "flowNoticeMessageKey": "src/system/i18n-resolver.ts#flowNoticeMessageKey (function)", + "flowRecordFieldTextKey": "src/system/i18n-resolver.ts#flowRecordFieldTextKey (function)", "flowRefusalMessageKey": "src/system/i18n-resolver.ts#flowRefusalMessageKey (function)", "flowScreenCopyKey": "src/system/i18n-resolver.ts#flowScreenCopyKey (function)", "flowTerminalMessageKey": "src/system/i18n-resolver.ts#flowTerminalMessageKey (function)", diff --git a/packages/spec/liveness/state-counts/translation.md b/packages/spec/liveness/state-counts/translation.md index 03c986d6b07..c02ba4059bd 100644 --- a/packages/spec/liveness/state-counts/translation.md +++ b/packages/spec/liveness/state-counts/translation.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `translation` | 44 | 0 | 0 | 0 | 2 | 46 | +| `translation` | 45 | 0 | 0 | 0 | 2 | 47 | From 5f61572e256b29614eb2b88f0de2c8613f113421 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 14:24:34 +0000 Subject: [PATCH 06/13] test(automation): a record-change run of a system write declares runAs system; a template envelope is the record field's text form Co-Authored-By: Claude --- .../flow-record-text-org-locale.dogfood.test.ts | 2 ++ .../src/builtin/crud-fields-value-envelope.test.ts | 5 ++++- .../src/builtin/record-field-text.test.ts | 14 ++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts b/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts index 61bf1ac4e48..f6422d0be5a 100644 --- a/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts +++ b/packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts @@ -73,6 +73,8 @@ const fixtureStack = defineStack({ flows: [ { name: ON_CHANGE, label: 'Escalate on create', type: 'record_change', status: 'active', + // The case is inserted by a system write, so the run holds no trigger user. + runAs: 'system', variables: [{ name: 'priority', type: 'text' }], nodes: [ { id: 'start', type: 'start', label: 'Start', config: { objectName: CASE, triggerType: 'record-after-create' } }, diff --git a/packages/services/service-automation/src/builtin/crud-fields-value-envelope.test.ts b/packages/services/service-automation/src/builtin/crud-fields-value-envelope.test.ts index dd62114e435..8b665b70b3e 100644 --- a/packages/services/service-automation/src/builtin/crud-fields-value-envelope.test.ts +++ b/packages/services/service-automation/src/builtin/crud-fields-value-envelope.test.ts @@ -142,7 +142,10 @@ const MALFORMED: ReadonlyArray<{ label: string; envelope: Record) { if (nodeType === 'update_record') config.filter = { id: 'case_1' }; return { name: 'case_escalation', label: 'Case Escalation', type: 'record_change', + // A record-change run of a system write holds no trigger user; the write + // runs as the system, as such a flow declares. + runAs: 'system', nodes: [ { id: 'start', type: 'start', label: 'Start', config: { objectName: 'crm_case', triggerType: 'record-after-update' } }, { id: 'set_reason', type: nodeType, label: 'Set reason', config }, @@ -220,13 +223,13 @@ describe.each(NODE_TYPES)('%s — a field value marked as text is written in the defaultLocale: 'zh-CN', bundles: { 'zh-CN': { flows: { case_escalation: { records: { set_reason: { fields: { escalation_reason: ZH, status: '已升级', internal_note: '内部' } } } } } } }, }); - automation.registerFlow('case_escalation', escalationFlow(nodeType, { ...MARKED, internal_note: 'Raised by {{ record.priority }}' })); + automation.registerFlow('case_escalation', escalationFlow(nodeType, { ...MARKED, internal_note: 'Raised by hand' })); const result = await automation.execute('case_escalation', recordChange()); expect(result.success, result.error).toBe(true); expect(writes[0].data.status).toBe('escalated'); - expect(writes[0].data.internal_note).toBe('Raised by {{ record.priority }}'); + expect(writes[0].data.internal_note).toBe('Raised by hand'); // CONTROL: the marked field beside them in the same write IS translated. expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); }); @@ -256,4 +259,11 @@ describe.each(NODE_TYPES)('%s — a field value marked as text is written in the expect(writes[0].data.status).toBe('escalated'); expect(settings!.asked).toEqual([]); }); + + it('a single-brace token in the marked text is refused at registerFlow, located at the field, as a text slot', async () => { + const { automation } = await makeStack({ defaultLocale: 'zh-CN' }); + expect(() => automation.registerFlow('case_escalation', escalationFlow(nodeType, { + escalation_reason: { dialect: 'template', source: 'Escalated {record.priority}' }, + }))).toThrow(`node 'set_reason' (${nodeType}) ${nodeType} field text at config.fields.escalation_reason`); + }); }); From c881dac19d9ee0c6a1ba371133bb4029d9f334f6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 15:32:43 +0000 Subject: [PATCH 07/13] fix(lint): a record write's marked text is a text slot, its other values stay value slots; retarget the template-dialect fixtures Co-Authored-By: Claude --- packages/lint/src/lint-flow-patterns.ts | 24 +++++++++++++++---- ...date-expressions.fields-value-slot.test.ts | 15 +++++++++++- .../automation/builtin-node-config.test.ts | 5 +++- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/lint/src/lint-flow-patterns.ts b/packages/lint/src/lint-flow-patterns.ts index 58780e66860..e7ca060623b 100644 --- a/packages/lint/src/lint-flow-patterns.ts +++ b/packages/lint/src/lint-flow-patterns.ts @@ -161,6 +161,7 @@ import { FlowNodeAction, flowNodeTextSlotSources, flowNodeValueTemplateRefusals, + isFlowTextEnvelopeShaped, textSlotTemplateRefusal, VALUE_SLOT_TEMPLATE_REFUSAL, } from '@objectstack/spec/automation'; @@ -1004,13 +1005,28 @@ function literalAt(nodeType: string, path: readonly (string | number)[]): { at: return { at, hint }; } -/** `config` without its node type's `{{ }}` text slots — the strings no template renders. */ +/** + * `config` without its node type's `{{ }}` text slots — the strings no template + * renders. A slot whose text is only its MARKED values (`envelopeOnly`: a record + * write's `fields`, ruling 6913660232) loses only those text envelopes; its + * other values are value slots and stay, so a bare string there is still read + * as the literal it is. + */ function withoutTextSlots(nodeType: unknown, config: unknown): unknown { if (!config || typeof config !== 'object' || Array.isArray(config)) return config; - const keys = FLOW_NODE_TEXT_SLOTS.filter((slot) => slot.nodeType === nodeType).map((slot) => slot.key); - if (keys.length === 0) return config; + const slots = FLOW_NODE_TEXT_SLOTS.filter((slot) => slot.nodeType === nodeType); + if (slots.length === 0) return config; const rest: AnyRec = { ...(config as AnyRec) }; - for (const key of keys) delete rest[key]; + for (const slot of slots) { + if (!slot.envelopeOnly) { + delete rest[slot.key]; + continue; + } + const map = rest[slot.key]; + if (map && typeof map === 'object' && !Array.isArray(map)) { + rest[slot.key] = Object.fromEntries(Object.entries(map as AnyRec).filter(([, v]) => !isFlowTextEnvelopeShaped(v))); + } + } return rest; } diff --git a/packages/lint/src/validate-expressions.fields-value-slot.test.ts b/packages/lint/src/validate-expressions.fields-value-slot.test.ts index 8b75486052f..6080627eb29 100644 --- a/packages/lint/src/validate-expressions.fields-value-slot.test.ts +++ b/packages/lint/src/validate-expressions.fields-value-slot.test.ts @@ -88,7 +88,10 @@ describe('`fields.*` value slot — the malformed envelope is a located error at it.each(NODE_TYPES.flatMap((t) => [ [t, 'no `source`', { dialect: 'cel' }, EVALUATED_EXPRESSION_SOURCE_REQUIRED], [t, 'a whitespace-only `source`', { dialect: 'cel', source: ' ' }, EVALUATED_EXPRESSION_SOURCE_REQUIRED], - [t, 'a `template` dialect', { dialect: 'template', source: 'Hi {name}' }, 'only the `cel` dialect'], + // A `template` envelope is the field's TEXT form (ruling 6913660232 on + // #34062), judged as a text slot below; a dialect that is neither is still + // a malformed value envelope. + [t, 'a dialect neither `cel` nor `template`', { dialect: 'cron', source: '0 * * * *' }, 'only the `cel` dialect'], [t, 'CEL that does not parse', { dialect: 'cel', source: 'price *' }, ''], [t, 'an unknown function', { dialect: 'cel', source: 'nosuchfn(price)' }, ''], ] as const))('%s: %s — rule `expression-invalid`, severity `error`, at `config.fields.total`', (nodeType, _what, envelope, detail) => { @@ -108,6 +111,16 @@ describe('`fields.*` value slot — the malformed envelope is a located error at expect(splitBySeverity(findings).errors).toHaveLength(1); }); + it.each(NODE_TYPES)('%s: a `template` envelope is judged as the field\'s text — a single-brace token is a located error there', (nodeType) => { + const findings = validate(nodeType, crud(nodeType, { subject: 'Quote', total: { dialect: 'template', source: 'Hi {name}' } })); + expect(findings).toHaveLength(1); + expect(findings[0]!.rule).toBe(EXPRESSION_INVALID); + expect(findings[0]!.severity).toBe('error'); + expect(findings[0]!.where).toContain(`node 'w' (${nodeType}) ${nodeType} field text at config.fields.total`); + // CONTROL: the same envelope with its `{{ }}` spelling is clean. + expect(validate(nodeType, crud(nodeType, { subject: 'Quote', total: { dialect: 'template', source: 'Hi {{ name }}' } }))).toEqual([]); + }); + it.each(NODE_TYPES)('%s: a valid envelope, the run user as `current_user`, a date macro\'s CEL string form and literals are clean', (nodeType) => { expect(validate(nodeType, crud(nodeType, { total: { dialect: 'cel', source: 'round(price * 100) / 100.0' }, diff --git a/packages/spec/src/automation/builtin-node-config.test.ts b/packages/spec/src/automation/builtin-node-config.test.ts index 8fa88b57a6e..d30c7c31ea6 100644 --- a/packages/spec/src/automation/builtin-node-config.test.ts +++ b/packages/spec/src/automation/builtin-node-config.test.ts @@ -881,7 +881,10 @@ describe('CRUD `fields` value contract — the CEL value envelope beside literal [type, schema, wrap, 'no `source`', { dialect: 'cel' }, 'fields.total.source'], [type, schema, wrap, 'a whitespace-only `source`', { dialect: 'cel', source: ' ' }, 'fields.total.source'], [type, schema, wrap, 'an `ast`-only envelope', { dialect: 'cel', ast: { kind: 'const', value: 1 } }, 'fields.total.source'], - [type, schema, wrap, 'a `template` dialect', { dialect: 'template', source: 'Hi {name}' }, 'fields.total.dialect'], + // A `template` envelope is the field's TEXT form (ruling 6913660232 on + // #34062): its dialect is taken, and its text is judged as a text slot, so + // a single-brace token is refused at the source. + [type, schema, wrap, 'a `template` text holding a single-brace token', { dialect: 'template', source: 'Hi {name}' }, 'fields.total.source'], [type, schema, wrap, 'an unknown dialect', { dialect: 'javascript', source: '1 + 1' }, 'fields.total.dialect'], ] as const))('%s REFUSES a malformed envelope with %s — code `custom`, at the field\'s path, led by the slot-neutral sentence', (_type, schema, wrap, _what, envelope, path) => { const result = schema.safeParse(wrap({ subject: 'x', total: envelope })); From b585364d44e88c02577b333b3f1db0fbff0ea18d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 17:31:09 +0000 Subject: [PATCH 08/13] docs(changeset): name the skills follow-up card for the record write's text envelope Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .changeset/34062-flow-record-text-org-locale.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/34062-flow-record-text-org-locale.md b/.changeset/34062-flow-record-text-org-locale.md index f6c0a968ed1..a81649c4589 100644 --- a/.changeset/34062-flow-record-text-org-locale.md +++ b/.changeset/34062-flow-record-text-org-locale.md @@ -10,7 +10,7 @@ feat(automation): a flow writes a field marked as text in the organization's lan Clause-②: yes (widening) — `create_record` / `update_record` `fields` values now also take the text envelope `{ dialect: 'template', source }` (`FlowRecordFieldValueSchema`), and the translation face gains `flows..records..fields.`; every value accepted before is accepted and written as before Metadata-protocol: added -Skills-docs: follow-up owed — skills/objectstack-automation/SKILL.md (the record write's field values: the text envelope beside the CEL envelope and the literal), skills/objectstack-i18n/SKILL.md (the `flows..records..fields.` key and the organization-language rule) +Skills-docs: follow-up #34434 — skills/objectstack-automation/SKILL.md (the record write's field values: the text envelope beside the CEL envelope and the literal), skills/objectstack-i18n/SKILL.md (the `flows..records..fields.` key and the organization-language rule) A `create_record` / `update_record` field value can now be marked as text: `{ dialect: 'template', source: 'Auto-escalated: {{ record.priority }} priority' }`. The node writes that sentence in the organization's language, because everyone in the organization reads the record. It picks the translated template at `flows..records..fields.` first, then fills its `{{ }}` holes. The language is the Localization setting (`localization.locale`) when somebody set it, else the app's declared `i18n.defaultLocale`. It is never the language of the person who started the run, so a run started by a button writes the same text as a record-change run. From ce287ea51184d454bee88e14f4199a586cc527c2 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 18:22:26 +0000 Subject: [PATCH 09/13] fix(automation): an unregistered Localization setting is not set, so the app default answers a marked record text Review 6924979595 S1: a host that loads no localization manifest answers SETTINGS_UNKNOWN_NAMESPACE / SETTINGS_UNKNOWN_KEY; nobody can have set the language there, so the automation bridge reads it as unset and the next rung answers. Any other settings failure still fails the node. The shared reader and the seed loader are unchanged. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .../src/builtin/record-field-text.test.ts | 31 +++++++++++++++ .../services/service-automation/src/plugin.ts | 39 ++++++++++++++++++- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/packages/services/service-automation/src/builtin/record-field-text.test.ts b/packages/services/service-automation/src/builtin/record-field-text.test.ts index eb90e65f76e..6875dcee1da 100644 --- a/packages/services/service-automation/src/builtin/record-field-text.test.ts +++ b/packages/services/service-automation/src/builtin/record-field-text.test.ts @@ -247,6 +247,37 @@ describe.each(NODE_TYPES)('%s — a field value marked as text is written in the expect(writes).toEqual([]); }); + it.each(['SETTINGS_UNKNOWN_NAMESPACE', 'SETTINGS_UNKNOWN_KEY'])( + 'a host that registers no Localization setting (%s) has none set: the app default answers and the run completes', + async (code) => { + const unregistered = Object.assign(new Error(`localization.locale is not registered (${code})`), { code }); + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE }, settings: () => { throw unregistered; }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success, result.error).toBe(true); + expect(writes).toHaveLength(1); + expect(writes[0].data.escalation_reason).toBe('自动升级:High 优先级'); + }, + ); + + it('CONTROL — any other settings failure with a code is still a failed read: the node fails and writes nothing', async () => { + const locked = Object.assign(new Error('settings store down'), { code: 'SETTINGS_STORE_UNAVAILABLE' }); + const { automation, writes } = await makeStack({ + defaultLocale: 'zh-CN', bundles: { 'zh-CN': ZH_BUNDLE }, settings: () => { throw locked; }, + }); + automation.registerFlow('case_escalation', escalationFlow(nodeType, MARKED)); + + const result = await automation.execute('case_escalation', recordChange()); + + expect(result.success).toBe(false); + expect(result.error).toContain(`${nodeType}: the organization's language could not be read (settings store down)`); + expect(writes).toEqual([]); + }); + it('CONTROL — a write that marks no text never reads the organization\'s language', async () => { const { automation, writes, settings } = await makeStack({ defaultLocale: 'zh-CN', settings: () => { throw new Error('settings store down'); }, diff --git a/packages/services/service-automation/src/plugin.ts b/packages/services/service-automation/src/plugin.ts index 5c5f5bc7635..7a14db55f3d 100644 --- a/packages/services/service-automation/src/plugin.ts +++ b/packages/services/service-automation/src/plugin.ts @@ -1593,7 +1593,44 @@ export function organizationLocaleReader( let i18n: unknown; try { settings = ctx.getService('settings'); } catch { settings = undefined; } try { i18n = ctx.getService('i18n'); } catch { i18n = undefined; } - return (await resolveOrganizationLocale({ settings, i18n, organizationId: tenantId }))?.locale; + return (await resolveOrganizationLocale({ settings: unregisteredSettingIsUnset(settings), i18n, organizationId: tenantId }))?.locale; + }; +} + +/** + * The settings service's refusal of a namespace or key nobody REGISTERED — + * `SETTINGS_UNKNOWN_NAMESPACE` / `SETTINGS_UNKNOWN_KEY`, as `@objectstack/objectql`'s + * home-localization bridge reads them. A host that loads no `localization` + * manifest has no setting anybody could have set, so for the organization's + * language it is "not set", the same as a host with no settings service. + */ +function isUnregisteredSetting(err: unknown): boolean { + const code = (err as { code?: unknown } | null | undefined)?.code; + return code === 'SETTINGS_UNKNOWN_NAMESPACE' || code === 'SETTINGS_UNKNOWN_KEY'; +} + +/** + * [ruling 6913660232, review 6924979595 S1] The settings door the reader is + * handed, with an unregistered `localization.locale` answered as not set, so + * the next rung (the app's declared default) answers. Any other throw still + * propagates: the setting may exist and could not be read, and the record + * node fails rather than store another language over it. Kept here, in the + * automation bridge, so the shared reader and the seed loader's rung 1 stay + * as they are. + */ +function unregisteredSettingIsUnset(settings: unknown): unknown { + const door = settings as { get?: unknown } | null | undefined; + if (!door || typeof door.get !== 'function') return settings; + const get = door.get as (namespace: string, key: string, ctx?: { tenantId?: string }) => Promise; + return { + async get(namespace: string, key: string, ctx?: { tenantId?: string }) { + try { + return await get.call(settings, namespace, key, ctx); + } catch (err: unknown) { + if (isUnregisteredSetting(err)) return undefined; + throw err; + } + }, }; } From f4212591a08a70c96eee5787da516fdfd4c8e85f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 18:22:52 +0000 Subject: [PATCH 10/13] docs(changeset): an unregistered Localization setting reads as unset; name the Studio inspector carrier Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .changeset/34062-flow-record-text-org-locale.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/34062-flow-record-text-org-locale.md b/.changeset/34062-flow-record-text-org-locale.md index a81649c4589..7493c54e478 100644 --- a/.changeset/34062-flow-record-text-org-locale.md +++ b/.changeset/34062-flow-record-text-org-locale.md @@ -16,7 +16,8 @@ A `create_record` / `update_record` field value can now be marked as text: `{ di - A missing translation, or no language to pick, writes the authored text, and the run goes on. - A bare string is still a literal and is written as spelled. Only the `fields` map of these two nodes takes the text envelope; every other value slot still refuses it. The source is judged as a text slot: a single-brace `{token}` is refused with its `{{ }}` spelling. -- A Localization setting that cannot be read fails the node and writes nothing, so another language is never stored over a choice that may exist. A `fault` edge routes the failure. +- A Localization setting that cannot be read fails the node and writes nothing, so another language is never stored over a choice that may exist. A `fault` edge routes the failure. A host that registers no `localization` setting has none set, so the app's declared default answers. +- The Studio flow inspector still marks a text envelope in a record node's `fields` as invalid; the row is kept on save. That inspector half is carried by #34445. - `os i18n extract` scaffolds the key, and the existing coverage check reports it missing against `supportedLocales`. `objectstack validate` refuses a key over an unknown node, over a node that is not a record write, or over a field the node does not mark as text. - Text is picked when it is written. Records already written are not changed. From 2c13aeb6af60ea70454810cb97d563d60bd4a6c5 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:28:41 +0000 Subject: [PATCH 11/13] fix(studio): a record write's fields cell judges a text envelope by the record-field rule; the hole-mode pin learns envelopeOnly Review 6926148182 S4: the inspector judges create_record / update_record fields cells with FlowRecordFieldValueSchema, so a text envelope shows no refusal and a malformed value keeps the spec's own sentence. The 12101 hole-mode pin leaves envelopeOnly text slots out and pins the two fields maps as not hole-mode. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .../inspectors/FlowNodeConfigField.tsx | 10 ++++- .../inspectors/flow-value-envelope.test.ts | 40 ++++++++++++++++++- .../inspectors/flow-value-envelope.ts | 24 +++++++++++ .../inspectors/flowValueSlots-12101.test.tsx | 27 ++++++++++++- 4 files changed, 97 insertions(+), 4 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx index 166faba3258..2c03d7d651a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/FlowNodeConfigField.tsx @@ -36,7 +36,9 @@ import { FlowExprIssue } from './FlowExprIssue.js'; import { FlowFieldHelp } from './FlowFieldHelp.js'; import { isEditableValueEnvelope, + isRecordFieldValueSlot, isValueEnvelopeSlot, + recordFieldValueRefusal, valueEnvelopeRefusal, writeValueEnvelope, } from './flow-value-envelope.js'; @@ -798,7 +800,13 @@ export function FlowNodeConfigField({ field, value, onCommit, disabled, locale, // objectui#12101 — a map whose every value is a flow text slot (http // `headers`) renders `{{ }}` holes in each value cell. valueMode: field.refMode === 'hole' ? 'hole' : undefined, - valueRefusal: isFilterOperandSlot(context?.node?.type, field.path) ? filterOperandRefusal : undefined, + // A record write's `fields` value may also be a text envelope, so + // its cells are judged by the spec's record-field rule. + valueRefusal: isFilterOperandSlot(context?.node?.type, field.path) + ? filterOperandRefusal + : isRecordFieldValueSlot(context?.node?.type, field.path) + ? recordFieldValueRefusal + : undefined, // objectstack#33838 — a map the run judges against a closed key set // (a connector action's declared inputs): each other key is marked // as refused, and the declared keys no sibling field types are diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts index d569dd65949..e612a9e92ab 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts @@ -21,7 +21,9 @@ import { } from '@objectstack/spec/automation'; import { isEditableValueEnvelope, + isRecordFieldValueSlot, isValueEnvelopeSlot, + recordFieldValueRefusal, valueEnvelopeRefusal, writeValueEnvelope, } from './flow-value-envelope'; @@ -120,9 +122,8 @@ describe('isValueEnvelopeSlot — read off the spec expression ledger (objectui# // schema refuses a malformed envelope in its map with exactly the messages // the editor shows (`valueEnvelopeRefusal`), and accepts the well-formed // envelope and a plain literal string it accepts. + // A record write's `fields` is judged by its own rule, the next case. const slots = { - 'create_record:fields': (v: unknown) => CreateRecordConfigSchema.safeParse({ objectName: 'account', fields: { name: v } }), - 'update_record:fields': (v: unknown) => UpdateRecordConfigSchema.safeParse({ objectName: 'account', fields: { name: v } }), 'screen:defaults': (v: unknown) => ScreenConfigSchema.safeParse({ defaults: { name: v } }), 'script:inputs': (v: unknown) => ScriptConfigSchema.safeParse({ function: 'my_fn', inputs: { name: v } }), 'subflow:input': (v: unknown) => SubflowConfigSchema.safeParse({ flowName: 'child_flow', input: { name: v } }), @@ -147,6 +148,41 @@ describe('isValueEnvelopeSlot — read off the spec expression ledger (objectui# }); }); +describe('recordFieldValueRefusal — a record write\'s `fields` takes a text envelope too (objectstack#34445)', () => { + const slots = { + 'create_record:fields': (v: unknown) => CreateRecordConfigSchema.safeParse({ objectName: 'account', fields: { name: v } }), + 'update_record:fields': (v: unknown) => UpdateRecordConfigSchema.safeParse({ objectName: 'account', fields: { name: v } }), + } as const; + const TEXT = { dialect: 'template', source: 'Escalated: {{ record.priority }} priority' }; + + it('answers true only for the two record writes\' `config.fields` map', () => { + expect(isRecordFieldValueSlot('create_record', ['config', 'fields'])).toBe(true); + expect(isRecordFieldValueSlot('update_record', ['config', 'fields'])).toBe(true); + expect(isRecordFieldValueSlot('assignment', ['config', 'fields'])).toBe(false); + expect(isRecordFieldValueSlot('create_record', ['config', 'filter'])).toBe(false); + expect(isRecordFieldValueSlot(undefined, ['config', 'fields'])).toBe(false); + }); + + it('refuses a malformed envelope with exactly the sentences each node\'s own schema gives', () => { + for (const [slot, parse] of Object.entries(slots)) { + for (const bad of [{ dialect: 'cel' }, { dialect: 'js', source: 'a' }, { dialect: 'template', source: '{record.id}' }]) { + const parsed = parse(bad); + expect(parsed.success, `${slot}: ${JSON.stringify(bad)} is refused`).toBe(false); + const messages = parsed.success ? [] : parsed.error.issues.map((i) => i.message); + expect(messages, `${slot}: with the same sentences the editor shows`).toEqual(recordFieldValueRefusal(bad)); + } + for (const good of [{ dialect: 'cel', source: 'a + 1' }, 'plain text', 30, TEXT]) { + expect(parse(good).success, `${slot}: ${JSON.stringify(good)} is accepted`).toBe(true); + expect(recordFieldValueRefusal(good)).toBeNull(); + } + } + }); + + it('CONTROL — the value-map rule other maps use still refuses the text envelope', () => { + expect(valueEnvelopeRefusal(TEXT)).not.toBeNull(); + }); +}); + describe('writeValueEnvelope — the objectui#3218 write table, applied to a value envelope', () => { it('writes a fresh envelope in the slot’s dialect when there is no prior one', () => { const out = writeValueEnvelope(undefined, 'amount * 2'); diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.ts b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.ts index d21a260a289..ac496fa2ca6 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.ts +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.ts @@ -44,6 +44,7 @@ import { AssignmentExpressionValueSchema, AssignmentValueSchema, + FlowRecordFieldValueSchema, FLOW_NODE_EXPRESSION_PATHS, flowNodeExpressionBlock, isExpressionEnvelopeShaped, @@ -130,6 +131,29 @@ export function valueEnvelopeRefusal(value: unknown): string[] | null { return result.success ? null : result.error.issues.map((issue) => issue.message); } +/** + * Whether `path` is a record write's `fields` map (`create_record` / + * `update_record`), whose values the spec judges with + * `FlowRecordFieldValueSchema`: a CEL value envelope, a literal, or a + * `template` text envelope written in the organization's language. + */ +export function isRecordFieldValueSlot(nodeType: unknown, path: readonly string[]): boolean { + return ( + (nodeType === 'create_record' || nodeType === 'update_record') && + path.length === 2 && path[0] === 'config' && path[1] === 'fields' + ); +} + +/** + * The spec's refusal of `value` as a record write's field value, one message + * per issue, or `null` when `FlowRecordFieldValueSchema` accepts it. A text + * envelope is accepted there, where {@link valueEnvelopeRefusal} refuses it. + */ +export function recordFieldValueRefusal(value: unknown): string[] | null { + const result = FlowRecordFieldValueSchema.safeParse(value); + return result.success ? null : result.error.issues.map((issue) => issue.message); +} + /** * The spec's refusal of an expression left blank, read once from the spec's * own judge rather than restated: the messages {@link valueEnvelopeRefusal} diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx index b190316af2b..a5177329412 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx @@ -102,12 +102,23 @@ describe('objectui#12101 — hole mode is exactly the text slots the spec names' .filter((f) => f.refMode === 'hole') .map((f) => `${type}.${f.path[1]}`), ); + // An `envelopeOnly` slot (a record write's `fields`, objectstack#34062) is + // text only where a value is a `template` envelope; a bare string there is + // a literal, so the map is not a hole-mode field. The inspector's text + // envelope cell is objectstack#34445's. const rendered = FLOW_NODE_TEXT_SLOTS.filter((s) => - fieldsForNodeType(s.nodeType).some((f) => f.path[0] === 'config' && f.path[1] === s.key), + !s.envelopeOnly && fieldsForNodeType(s.nodeType).some((f) => f.path[0] === 'config' && f.path[1] === s.key), ).map((s) => `${s.nodeType}.${s.key}`); expect(holeFields.sort()).toEqual(rendered.sort()); }); + it('a record write\'s `fields` is an envelopeOnly text slot and not a hole-mode field (inspector half: objectstack#34445)', () => { + for (const type of ['create_record', 'update_record']) { + expect(FLOW_NODE_TEXT_SLOTS.find((s) => s.nodeType === type && s.key === 'fields')?.envelopeOnly).toBe(true); + expect(fieldOf(type, 'fields').refMode).not.toBe('hole'); + } + }); + it('a served http url / headers keeps hole mode (the descriptor marks neither)', () => { const served = jsonSchemaToFlowFields({ type: 'object', @@ -172,6 +183,20 @@ describe('objectui#12101 — a value map writes a literal or a CEL value envelop } }); +describe('objectstack#34445 — a record write\'s `fields` cell judges a text envelope by the record-field rule', () => { + for (const type of ['create_record', 'update_record']) { + it(`${type}.fields: a text envelope shows no refusal`, () => { + renderMap(type, 'fields', { escalation_reason: { dialect: 'template', source: 'Escalated: {{ record.priority }}' } }); + expect(screen.queryByRole('alert')).toBeNull(); + }); + + it(`CONTROL — ${type}.fields: a malformed envelope is still refused`, () => { + renderMap(type, 'fields', { escalation_reason: { dialect: 'template', source: '{record.priority}' } }); + expect(screen.getByRole('alert').textContent ?? '').toContain('{{'); + }); + } +}); + describe('objectui#12101 — each http header value renders {{ }} holes', () => { it('the picker inserts {{ x }}', async () => { const onCommit = renderMap('http', 'headers', { Authorization: 'Bearer ' }); From 55b0d8818ebbea001759887cca05c59e61bd9673 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 19:33:10 +0000 Subject: [PATCH 12/13] docs(changeset): the Studio inspector half of the record-field rule ships here The record node's fields cells are judged by FlowRecordFieldValueSchema in 2c13aeb6, so the changeset's carrier sentence becomes the fix line, and app-shell gets its patch bump. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .changeset/34062-flow-record-text-org-locale.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/34062-flow-record-text-org-locale.md b/.changeset/34062-flow-record-text-org-locale.md index 7493c54e478..29f3cc235d5 100644 --- a/.changeset/34062-flow-record-text-org-locale.md +++ b/.changeset/34062-flow-record-text-org-locale.md @@ -4,6 +4,7 @@ '@objectstack/service-automation': minor '@objectstack/lint': minor '@objectstack/runtime': patch +'@object-ui/app-shell': patch --- feat(automation): a flow writes a field marked as text in the organization's language @@ -17,7 +18,7 @@ A `create_record` / `update_record` field value can now be marked as text: `{ di - A missing translation, or no language to pick, writes the authored text, and the run goes on. - A bare string is still a literal and is written as spelled. Only the `fields` map of these two nodes takes the text envelope; every other value slot still refuses it. The source is judged as a text slot: a single-brace `{token}` is refused with its `{{ }}` spelling. - A Localization setting that cannot be read fails the node and writes nothing, so another language is never stored over a choice that may exist. A `fault` edge routes the failure. A host that registers no `localization` setting has none set, so the app's declared default answers. -- The Studio flow inspector still marks a text envelope in a record node's `fields` as invalid; the row is kept on save. That inspector half is carried by #34445. +- The Studio flow inspector judges a record node's `fields` cells by the same rule (`FlowRecordFieldValueSchema`), so a text envelope there reads as valid and a malformed value still shows the spec's refusal. Fixes #34445. - `os i18n extract` scaffolds the key, and the existing coverage check reports it missing against `supportedLocales`. `objectstack validate` refuses a key over an unknown node, over a node that is not a record write, or over a field the node does not mark as text. - Text is picked when it is written. Records already written are not changed. From 2b13583e52d58a46f3cfb5f481234440d4be7a74 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 16 Nov 2026 20:06:10 +0000 Subject: [PATCH 13/13] test(studio): the inspector pin pays its first lint load at collection The edited 12101 pin reaches the dynamic `@objectstack/lint` import through FlowNodeConfigField, so check:test-source-alias asks for the module-top side-effect import the sibling ObjectView pins already carry. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP --- .../metadata-admin/inspectors/flowValueSlots-12101.test.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx index a5177329412..03fe3adef46 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx @@ -39,6 +39,10 @@ import { FLOW_NODE_CONFIG_TYPES, fieldsForNodeType, mergeServerFlowFields, type import { jsonSchemaToFlowFields } from './json-schema-to-fields'; import { flowFieldZh } from '../i18n'; import type { ScopeGroup } from './useFlowScope'; +// The inspector reaches `objectPickerClosure`'s and `celAuthoring`'s dynamic +// `@objectstack/lint` import; its first load is paid here, at collection, +// never inside a case's clock (`check:test-source-alias`). +import '@objectstack/lint'; afterEach(cleanup);