Repository navigation
Commit 0e2e4f5
feat(automation): a flow writes a field marked as text in the organization's language (#34438)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XDoXcW9MrHfRMhTtSzNmhoC)_
Fixes #34062
Part of #34445 (covered completely; the seat closes it when this merges,
since the landing tool takes one closing line)
Ruling-ref: 6913660232 (B); 6929082704 (A, unreadable Localization
setting)
Clause-②: yes (widening)
Metadata-protocol: added
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.FLOW.records.NODE_ID.fields.FIELD` key and the
organization-language rule)
## 维护者速读
- **改了什么**:流程的 `create_record` / `update_record` 字段值可以标记为文本 `{ dialect:
'template', source }`;写入记录时按组织语言挑译文(先挑译文模板,再填 `{{ }}`
占位)。裸字符串仍按字面写入,不翻译。
- **为什么改**:裁决 6913660232(B):记录是全组织共读的,中文组织不该存进英文句子(hotcrm#2494)。组织语言 =
本地化设置(有人设置过)→ 应用声明的 `i18n.defaultLocale` → 原文;从不取发起人的语言。
- **风险与回滚**:纯加宽,原来合法的流程写出的值完全不变;只有标记了文本的字段才多读一次组织语言。回滚 = revert 本
PR。唯一新的失败路径:本地化设置读取抛错时该节点失败、不写入(可走 fault 边)。这一条已由你裁定为 A「A 这一步失败,不写入」(记录
6929082704):漏译仍是已裁的不中断情形;读不到设置等于不知道组织语言,所以不写入。
-
**先看**:`packages/services/service-automation/src/builtin/crud-nodes.ts`(`resolveFieldValues`:读组织语言、挑译文、读取失败即失败);`packages/spec/src/automation/builtin-node-config.zod.ts`(`FlowRecordFieldValueSchema`,契约加宽处);`packages/core/src/organization-locale.ts`(共享的组织语言读取器)。
- **两分钟验证**:`pnpm --filter @objectstack/service-automation exec vitest
run src/builtin/record-field-text.test.ts`,预期 24 个用例全绿(zh-CN 默认、en-US
发起人仍写 zh-CN、设置 ja-JP 胜出、缺译文写原文、裸字符串原样、读设置失败不写入、未注册设置取应用默认);Studio
一侧:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/inspectors/flowValueSlots-12101.test.tsx
packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts`,预期
44 个用例全绿。
- **需要你做的**:无,席位落地。
## What changes
- **Contract (spec).** A `create_record` / `update_record` `fields`
value may be the text envelope `{ dialect: 'template', source }`
(`FlowRecordFieldValueSchema`), beside the CEL envelope and the literal.
Its `source` is judged as a text slot: `{{ }}` holes; a single-brace
token and a blank source are refused at the envelope's `source`. Every
other value slot still refuses a template envelope. The expression
ledger hands the text envelope to the text-slot judge, not the CEL one
(`FlowNodeExpressionPath.textEnvelope`, `isFlowTextEnvelopeShaped`);
`FLOW_NODE_TEXT_SLOTS` gains the two `fields` maps as `envelopeOnly`
slots, so a bare string there stays a literal.
- **Translation face.** `TranslationDataSchema.flows` gains
`records.NODE_ID.fields.FIELD`, judged as the text slot it translates;
the key is spelled by `flowRecordFieldTextKey`
(`@objectstack/spec/system`). Liveness row `flows.records` seeded `live`
with its reader.
- **One reader of the organization's language (core).**
`resolveOrganizationLocale` / `readOrganizationLocaleSetting` in
`@objectstack/core`: the `localization.locale` setting when somebody set
it (`source !== 'default'`), else the `i18n` service's
`getDefaultLocale()`, else nothing. Not
`resolveLocalizationContext().locale` (its default layer is the `en-US`
placeholder). Convergence: the seed loader's rung 1 now calls
`readOrganizationLocaleSetting` (identical behaviour). The auth mail and
the notification text keep their own code: each answers a different
question (the auth mail binds the workspace's setting at boot and on
change, and its SMS reads the default too; the notification text reads
the recipient first and has no setting rung), so converging them would
change their answers.
- **Runtime (service-automation).**
`AutomationEngine.setOrganizationLocaleResolver` /
`organizationLocale(context)`, wired by the plugin through the exported
`organizationLocaleReader(ctx)`. The record executors read the language
once per node, and only when the node marks text. For each marked value
they call `renderFlowTextSlot` with the run context's `locale` replaced
by the organization's (parameter 2: never the starter's), so the
translation is picked first and the holes are filled after (parameter
1). No translation, or no language, writes the authored text and the run
goes on (parameter 5).
- **Tooling (lint, reached by the CLI).** `collectExpectedEntries` walks
each marked field, so `os i18n extract` scaffolds the key and the
existing coverage check asks for it (no new gate). `objectstack
validate` refuses a key over an unknown node, a node that is not a
record write, or a field the node does not mark. `lint-flow-patterns`
reads a record write's `fields` as value slots except the marked text.
- **Studio (app-shell).** The flow inspector judges a `create_record` /
`update_record` `fields` cell with `FlowRecordFieldValueSchema`
(`recordFieldValueRefusal` in `flow-value-envelope.ts`, wired in
`FlowNodeConfigField.tsx`'s `keyValue` case), so a text envelope reads
as valid and a malformed value shows the spec's own refusal. Every other
key-value map keeps its judge.
- **Docs.** `content/docs/automation/flows.mdx` gains "Text a record
keeps — a field value marked as text";
`content/docs/ui/translations.mdx` gains the key row.
Not built here, per the ruling: hooks and actions (#34374, parameter 7),
backfill (parameter 6), `org.locale` (parameter 8).
## Tests
-
`packages/services/service-automation/src/builtin/record-field-text.test.ts`
(new, 24): through the real in-memory i18n service, the plugin's own
`organizationLocaleReader` and a real ObjectQL engine over a recording
driver, for both node types: a zh-CN app with no Localization row writes
the zh-CN pick in a record-change run with no user; a run started by an
en-US user still writes zh-CN; a `ja-JP` setting somebody set wins
(asked for the run's organization), and CONTROL: the `source: 'default'`
placeholder does not; a missing translation writes the authored text and
the run completes; a bare string is written verbatim, and CONTROL: the
marked field beside it is translated; a settings read that throws fails
the node and writes nothing; an unregistered Localization setting
(`SETTINGS_UNKNOWN_NAMESPACE` / `SETTINGS_UNKNOWN_KEY`) writes the app
default and the run completes, and CONTROL: any other settings failure
(`SETTINGS_STORE_UNAVAILABLE`) still fails the node; CONTROL: a write
that marks no text never reads the language; a single-brace token is
refused at `registerFlow` as field text.
- `packages/qa/dogfood/test/flow-record-text-org-locale.dogfood.test.ts`
(new, 3): a real boot with `i18n.defaultLocale: 'zh-CN'` and the
record-change trigger. A system insert's run writes the zh-CN pick, the
untranslated mark as authored and the bare string verbatim; a REST
trigger started with `Accept-Language: en-US` still writes zh-CN
(CONTROL: an en-US entry exists); after `settings.set('localization',
'locale', 'ja-JP')` the next run writes the ja-JP pick.
- Spec: `record-field-text.test.ts` (new);
`flow-text-slot-template.test.ts`, `flows-translation-face.test.ts`
extended. Core: `organization-locale.test.ts` (new). Lint:
`validate-translation-references.test.ts` extended. CLI:
`test/i18n-flow-record-text-coverage.test.ts` (new: walker key, coverage
gate, extract skeleton).
- Studio:
`ui/packages/app-shell/src/views/metadata-admin/inspectors/flow-value-envelope.test.ts`
(extended: the record-field judge, parity with
`CreateRecordConfigSchema` / `UpdateRecordConfigSchema`, CONTROL that
other maps still refuse a text envelope) and
`flowValueSlots-12101.test.tsx` (extended: the hole-mode pin learns
`envelopeOnly` with a CONTROL; #34445's acceptance, a text envelope
shows no refusal and CONTROL a single-brace source is still refused, for
both node types).
- Fixture triage (the deleted branch is "a template envelope in `fields`
is malformed"): three rows that pinned it are retargeted, not respelled.
`crud-fields-value-envelope.test.ts` and
`validate-expressions.fields-value-slot.test.ts` now pin a `cron`
dialect as the malformed envelope, and `builtin-node-config.test.ts`
pins the single-brace template at `fields.total.source`. The lint file
gains a located "field text" refusal with a `{{ }}` CONTROL.
<details><summary>Ablation of the translate call (one-off, not
committed; run by area o1-C before the hand-over)</summary>
`node scripts/ablation-replace.mjs --file
packages/services/service-automation/src/builtin/crud-nodes.ts --anchor
"const text = flowName === undefined" --replacement "const text = true
|| flowName === undefined" -- ...` (the test imports the executor from
`src`, so no dist leg). Leg 0 at 485d1c7: 18/18 passed. Mutation landed
(anchor 1 → 0, blob 58d9e36 → 72bf866b): **10 failed | 8 passed** —
every translation pin and both translation CONTROLs red, for both node
types; the 8 that stay green are the ones that never read a translation
(missing translation, settings failure, no-text CONTROL, registration
refusal). Restored: blob == HEAD, `git diff HEAD` empty; 18/18 passed.
</details>
<details><summary>Package suites</summary>
This thread reran every suite after merging origin/main (at `920f54c4`,
a full build first, each run under the verify lock; the only later
commit, `b585364d`, edits the changeset's `Skills-docs:` line):
- `pnpm --filter @objectstack/spec check:generated`: exit 0.
- `typecheck` exit 0 for spec, core, runtime, service-automation, lint,
cli.
- core 150 files / 3600 passed; service-automation 286 files / 4070
passed; lint 212 files / 9072 passed; runtime 609 files / 11218 passed,
19 skipped; cli `--project unit` 425 files / 6032 passed; spec 846 files
/ 27066 passed, 1 todo.
- `packages/qa/dogfood`
`test/flow-record-text-org-locale.dogfood.test.ts`: 1 file, 3 passed.
Readings before the hand-over (area o1-C, at `485d1c7c` / `c881dac1`)
are in the report on #34062.
</details>
## Acceptance notes
- **Unreadable setting fails the node (maintainer ruling A 「A
这一步失败,不写入」, record 6929082704, an addition to ruling 6913660232).** When
the Localization setting cannot be READ (the settings service throws),
the node fails and writes nothing, instead of writing the authored text.
Parameter 5 covers a missing translation, which is the ruled no-fail
case; an unreadable setting means the organization's language cannot be
known, and writing the authored text would silently store the wrong
language while the run reports success. The shared reader propagates the
throw for the reason the seed loader already does. A `fault` edge routes
it. Writing the authored text with a warning instead is a one-line
change in `resolveFieldValues`. A host that registers no `localization`
setting (`SETTINGS_UNKNOWN_NAMESPACE` / `SETTINGS_UNKNOWN_KEY`) has none
set, and the app default answers (review 6924979595 S1, pinned).
- An empty render (every hole empty) writes `null`, as other text slots
render nothing.
- Organization = `AutomationContext.tenantId`; a run with none asks the
settings service with no scope (its own reach), as the seed loader does.
- File surface beyond the claim: `packages/core/**` (the one shared
reader: `seed-locale.ts` lives in runtime, which service-automation
cannot import) and
`packages/lint/src/{i18n-walk,validate-translation-references,lint-flow-patterns}.ts`
(where `os i18n extract`, the coverage check and `objectstack validate`
actually walk; the CLI utils re-export them).
`content/docs/ui/translations.mdx` gains one row.
- `dropped-refinements.baseline.json` grows by 9 sites in two families
already in the ledger: `automation/FlowRecordFieldValue`'s root (the
`celValueSlotSchema` `superRefine`, as at `automation/FlowValueSlot`'s
root) and `flows.records.fields.valueType` under the eight schemas the
census reaches (the ninth, `api/InstalledPackageAtEitherStage`, holds
the same leaf past the census's `MAX_DEPTH` of 14 hops, so it has no
row; PR comment 6924993336) (the `flowTextSlotTranslation()` leaf, as at
`flows.notices.message` and `flows.refusals.message`).
`refinement-projection.ts` has no arm for either judge, and adding one
is a public-contract decision outside this card. Accounting: PR comment
6924875958.
## Verification
Local gates: the `dispatch-gates.mjs --commands` list derived at
`920f54c4` (125 commands), each run with its exit code recorded; the
changeset gates and the teardown self-test were rerun on the final head
`b585364d`. `--ran` reconciliation: 125 derived, 125 run, 0
NOT-MEASURED. 124 exit 0. One red, not from this diff: `pnpm
check:platform-checklist` exit 1, `approvals.approver-resolution-matrix:
VARIANTS STALE` (`ApproverType` has 11 members on main since the
`platform_admin` approver landed, the item still expects 10); this
branch does not touch `approval.zod.ts` or
`docs/qa/platform-checklist/`, so the same tree on main reds the same
way (read, not run on main). `check-plugin-teardown-shape --self-test`
first answered exit 3 for the shallow clone; after fetching its control
commit it answers exit 0. Every family the PR's CI runs is read from its
check-runs, not rerun here. `test:repo` is left to CI (`Test Core`).
Full dogfood battery: not run. The title has no `!` and the `Clause-②`
arm is `(widening)`, so os-dev.md does not require it; the new dogfood
file was run on its own.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5oC2FdKXYRD1jEVYJP)_
<!-- signed: repo:objectstack#1 · os-project-manager ·
session_01FEkQ5pmEYLVFDcQ1Z1CS8H -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3bf9c5c commit 0e2e4f5
45 files changed
Lines changed: 1809 additions & 62 deletions
File tree
- .changeset
- content/docs
- automation
- references
- automation
- system
- ui
- docs/audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- cli/test
- core/src
- lint/src
- qa/dogfood/test
- runtime/src
- services/service-automation/src
- builtin
- spec
- api-surface
- declaration-map
- export-origins
- json-schema.manifest
- liveness
- state-counts
- src
- automation
- system
- ui/packages/app-shell/src/views/metadata-admin/inspectors
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
570 | 612 | | |
571 | 613 | | |
572 | 614 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
218 | 225 | | |
219 | 226 | | |
220 | 227 | | |
| |||
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
343 | | - | |
| 350 | + | |
344 | 351 | | |
345 | 352 | | |
346 | 353 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
| 115 | + | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
470 | 471 | | |
471 | 472 | | |
472 | 473 | | |
| 474 | + | |
473 | 475 | | |
474 | 476 | | |
475 | 477 | | |
| |||
711 | 713 | | |
712 | 714 | | |
713 | 715 | | |
| 716 | + | |
714 | 717 | | |
715 | 718 | | |
716 | 719 | | |
| |||
921 | 924 | | |
922 | 925 | | |
923 | 926 | | |
| 927 | + | |
924 | 928 | | |
925 | 929 | | |
926 | 930 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
0 commit comments