Repository navigation
fix(service-automation): a flow write node's refusal is worded in the run's locale, as the record doors word it - #25929
Conversation
… run's locale — resolveRunDataContext carries AutomationContext.locale into the data context Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011W59GGh1a3YnDbRLcBJYxe
…he run's locale Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011W59GGh1a3YnDbRLcBJYxe
📓 Docs Drift Check2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a73da9e90266b4d029df0804d99c5ea55a0f55f3 && git checkout a73da9e90266b4d029df0804d99c5ea55a0f55f3
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2a728ba2acf52c13d1918c2afca7b79bf391e1f5 ba44680f415241b163b401922827917157501b41 && git checkout -B drift-repro 2a728ba2acf52c13d1918c2afca7b79bf391e1f5 && git merge --no-ff ba44680f415241b163b401922827917157501b41
node scripts/docs-audit/affected-docs.mjs --json 2a728ba2acf52c13d1918c2afca7b79bf391e1f5 |
席位核对 · ACCEPT ·
|
| item | reading |
|---|---|
| Shape | draft, base main, Fixes #25809, Clause-②: no and Metadata-protocol: none line-initial, patch changeset. |
| Files (3, +231/−2) | service-automation/src/runtime-identity.ts, one integration test, one changeset: inside the claim's surface (no runtime edit was needed). No packages/spec/**, so no contract review is owed. Not governed (check-governed-merges --pr 25929), 233 changed lines. |
| Fix | resolveRunDataContext carries AutomationContext.locale into the run's data context on both runAs arms; the engine's existing translation hook words the refusal and innerRefusal.message carries it. One translation path, as ruled (triage 6399842990). Seat's own read: locale is presentation only — no security middleware keys on it — and is absent on a run no person started, which keeps the authored text. |
| Evidence | red first: 6 failed / 2 passed at cb0a2fcf4f plus the test, 8/8 with the fix; per-arm ablation reds exactly that arm's three cases. Node verdicts: create_record, update_record, delete_record fixed; get_record and the lookup expander are reads, no change. |
| Gates | dispatch-gates 68/68 exit 0, --ran 0 NOT-MEASURED; package suite 2,667/2,667; typecheck and eslint 0. CI at this act: in progress. |
| Landing | ready + auto-merge through the relay once every check on this head is green or an expected skip. |
Generated by Claude Code
Requested by Leehom · project thread
Fixes #25809
Clause-②: no
Metadata-protocol: none
What changes
A refusal a flow's write node meets is now worded in the language of the person who started the run, as their own record save is.
The run already carries that language (
AutomationContext.locale, seeded by the/actionsdoor atpackages/runtime/src/action-execution.tsand by the trigger door).resolveRunDataContext(packages/services/service-automation/src/runtime-identity.ts), the one place that maps a run to the ObjectQLcontextits data nodes pass, dropped it. It now carrieslocaleon bothrunAsarms (RunDataContext.locale). The engine's existing translation hook (ObjectQL#validationMessageContext, bridged to the i18n service) does the rest: an authored rule'sobjects.OBJECT._validations.RULE.message, the built-in catalog, aDELETE_RESTRICTEDsentence's labels. The translated text reaches the caller through the path the inner-refusal ruling added: the crud node's catch arm puts it oninnerRefusal.message, and the four doors emit it in theFLOW_FAILEDdetails.No second translation path: nothing in service-automation translates anything. A run no person started (record-change, schedule, webhook) has no locale and keeps the authored text, as before.
Measurement — red first
packages/services/service-automation/src/flow-write-refusal-locale.integration.test.ts: a real kernel (ObjectQL + better-sqlite3), an object with an authoredscriptrule, and a zh-CN bundle on the engine's i18n service. Each case first asserts the record door's own answer for the same write (ql.insertwithlocale: 'zh-CN'answers金额不能为负数。).cb0a2fcf4(origin/main) plus the test alone: 6 failed / 2 passed (8).create_recordandupdate_recordreturnedinnerRefusal.message: "Amount must not be negative."under bothrunAsarms;delete_recordreturnedThis Account is still referenced by 1 Deal record(s) through “Account”. Delete or reassign them first.(English labels). The two passing cases are the no-locale controls.447414c4): 8 passed (8).Every flow write node, with a verdict
create_recordupdate_recorddelete_recordDELETE_RESTRICTED: the sentence named objects by their English labels (measured red). Fixed.get_recordcontext.localeonly for refusal wording (validation messages, delete restriction), so a read has nothing to word. Carries the locale; no behaviour change.plugin.ts,setRecordExpander)resolveRunDataContext; same asget_record.approval/approval_revise(plugin-approvals)resolveRunDataContext. Out of this card's file surface; not measured.connector_action,http_*,notify,screenAll four data nodes take their context from
resolveRunDataContext(DATA_NODE_TYPES), so the fix is one place and cannot drift between node types.Tests
flow-write-refusal-locale.integration.test.ts— 8 cases: create / update / delete underrunAs: 'user'and'system'in zh-CN, plus the no-locale control per arm.447414c4), viascripts/ablation-replace.mjs(anchor 1 → 0, blob moved; restore: blob == HEADd5d8492ba58e,git diff HEADempty). The subject is imported from source (./plugin.js), so nodist/leg applies....(locale ? { locale } : {}),(system arm): 3 failed / 5 passed — the threerunAs: 'system'zh-CN cases.if (locale) out.locale = locale;(user arm): 3 failed / 5 passed — the threerunAs: 'user'zh-CN cases.pnpm --filter @objectstack/service-automation test: Test Files 203 passed (203), Tests 2667 passed (2667).pnpm --filter @objectstack/service-automation typecheck: exit 0 (incl.check:test-typecheck).eslint --no-inline-config packages/services/service-automation: exit 0.Gates (local subset)
node scripts/pm/dispatch-gates.mjs --commandsatba44680f4derives 68 families for this diff (3 paths). All 68 ran with exit 0;--ranreconciliation:68 derived, 68 run, 0 NOT-MEASURED, 0 UNRUN(exit 0).check-plugin-teardown-shape --self-test(re-run after fetching its fixture commit) andcheck:dual-build-cjs-loads(re-run after a fullpnpm build, lock VERDICT exit 0). Both re-ran to exit 0.447414c4(the code at its final bytes, before the changeset commit); the 12 the changeset added to the derivation ran atba44680f4.test:repoand the repo-widepnpm lintare CI's.Acceptance notes
AutomationContext.locale's docblock (packages/spec/src/contracts/automation-service.ts) lists its readers as the refusingendnode and thescreenexecutor; the data nodes are now a third reader. Not edited here:packages/spec/**is outside this claim's file surface. Carrier: none.localeon their session, as the same user's record-door write already gives them. Presentation only: no security middleware keys on it./actionsdoor's half (ec.locale→AutomationContext.locale) and the details carriage (flowFailureDetails) were already on main and are unchanged; this PR pins the engine leg, where the gap was.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_011W59GGh1a3YnDbRLcBJYxe