Repository navigation
fix(approvals,audit): flow and position labels, and a renamed object's label, read as the metadata translators serve them - #36598
Conversation
… label read as /meta serves them Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPTDM2MxHR8cvoMVUX
…ls against the metadata translators Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPTDM2MxHR8cvoMVUX
…adapter does Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPTDM2MxHR8cvoMVUX
…read Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmPTDM2MxHR8cvoMVUX
📓 Docs Drift CheckThis PR changes 2 package(s): 13 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 5 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 15 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 3e18145daca12e04b011a88f51f9d84c2dff0649 && git checkout 3e18145daca12e04b011a88f51f9d84c2dff0649
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc 0e315358fad43d34606a19ccb26b064a8c3ad684 && git checkout -B drift-repro 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc && git merge --no-ff 0e315358fad43d34606a19ccb26b064a8c3ad684
node scripts/docs-audit/affected-docs.mjs --json 79d9c1435586d9b411b51a0ac395ea0c23dc3ddc
|
|
repo:objectstack#2 · os-steve · session_01ADHkmPTDM2MxHR8cvoMVUX 席位核对ACCEPT — PR #36598 @
|
|
repo:objectstack#2 · os-steve · session_01ADHkmPTDM2MxHR8cvoMVUX Landing — PR #36598 @
State: undraft + auto-merge through the queue; |
… read as /meta serves them (objectstack-ai#36620) <!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DD8XEF1VwrqXiQzo8zQCjY)_ Fixes objectstack-ai#35384 Clause-②: yes (widening) Metadata-protocol: none Skills-docs: none — Metadata-protocol is none and there is no (narrowing) arm; no skills/** file teaches either label reading ## 维护者速读 - 用户能看到什么变化:在「编写语言与默认语言不同」的部署里(例如英文编写、用户默认中文),英文读者在审批收件箱和审批页上看到的审批步骤名,以及英文收件人收到的审批通知里的对象名,改为作者原文,不再混入中文;对象在代码里改过名的,通知里显示新名。 - 为什么做:这是「审批与审计文案按元数据接口同一方式取标签」那张卡的最后两项,前两批已合并,本次合并后该卡关闭。 - 出错会怎样:只影响审批步骤名和通知里的对象名这两处显示文字,取不到时退回原先存下的文字,不会让审批或通知失败;改动可整体撤回,已存的通知照旧显示。 - 要你做什么:无。 ## What changes The rule this card carries (from objectstack-ai#34030): "resolve the label through `translateObject` with the same resolve options `/meta` builds, so `t()` carries messages only". This PR delivers the card's two remaining items (items 2 and 3 landed in objectstack-ai#36464 and objectstack-ai#36598). **1. Approval notification object label (service-messaging, plugin-approvals).** - `NotificationTextKeys.params` accepts a new value, `{ object: 'OBJECT_API_NAME', fallback }` (`NotificationObjectLabelParam`, exported from `@objectstack/service-messaging`). `renderWith` resolves it through `translateObject` (`@objectstack/spec/system`) over the object's served definition (`getSchema`) and its packaged base (`registry.getPackagedObjectBase`), both read off the data engine the renderer already holds. The resolve options are `/meta`'s: the recipient's negotiated locale, the declared fallback chain, and the declared `sourceLocale` else `defaultLocale`, inlined as `reader-locale-labels.ts` does (one exported builder is objectstack-ai#36467). `fallback` is delivered when nothing resolves. - The inline fan-out, the dispatcher (claimed rows and digests) and the inbox reader (`renderForReader`) all go through `renderWith`, so all four paths resolve the label the same way. - Widening, not replacement: `{ key, fallback }` is still accepted and still renders through `t()`, so stored outbox and inbox rows render exactly as before. The closed-shape validator (`problemOf`) admits the new shape and refuses a mixed one, a missing `fallback`, or a name that is not an object API name. The name shape is one segment of the existing catalog-key shape, so every object a `{ key: 'objects.OBJECT.label' }` param could name, the typed param can name too. - plugin-approvals `subjectParams` now emits `{ object: objectName, fallback }`. **2. Approval step label (spec, plugin-approvals).** - New spec export `resolveFlowApprovalStepLabel(bundle, flowName, nodeId, literal?, opts?)` in `packages/spec/src/system/i18n-resolver.ts`. It is the one reading of `flows.FLOW.approvals.NODE_ID.label`, using the same locale chain and the same bundle-then-literal order as `resolveFlowScreenTitle`. - `reader-locale-labels.ts` `stepLabel` resolves through it with the `/meta` resolve options it already builds for the flow, object and position labels. No key is asked of `t()` any more. - `translateFlow` is unchanged and stays unregistered in `translateMetadataDocument`. - Liveness `flows.approvals.label` evidence is re-anchored on the spec resolver. ### Export choice (seat ruling, premise measured) The seat ruled: overlay the step label inside `translateFlow` if the step-label read points already hold or read the flow document; otherwise use `resolveFlowApprovalStepLabel`. Measured at `aff34baea`: - `reader-locale-labels.ts:405-410` (`localizeRequestLabels`) has only `process_name` and `current_step` from the stored row. No flow document is in hand. It is called for every row of a list read (`approval-service.ts:10921`, `listRequests`), for the single read (`:11205`), and by the generic data door (`reader-locale-labels-middleware.ts:104`). Getting a document there would add one flow read per row. - `flowLabel` (`reader-locale-labels.ts:359`) does not read the flow document. It hands `translateFlow` a stub, `{ name: flowName }`. So do the other `translateFlow` callers in the tree: `ui/packages/app-shell/src/views/FlowRunner.tsx:445` and `ui/packages/plugin-detail/src/stageChangeStarts.tsx:106` both pass `{ name, label }`. - Only the single-read enrichment holds the document (`approval-service.ts:11340` `requestFlow`, used by `attachFlowSteps` `:11350` and `attachFlowRoute` `:11407`). The premise does not hold at the main read point, so this PR takes `resolveFlowApprovalStepLabel`. `translateFlow` and its docblock are untouched, so no client-visible change. The param's member is `object`, by seat ruling (card comment 7091274184), and the type name stays `NotificationObjectLabelParam`. Three reasons: - The member holds the object's API name, not a label. - In the spec, the word `object` always means an object's API name. - The sibling `{ key, fallback }` is also named for what it holds. The first round built it as `objectLabel` and round 2 renamed it. The mixed shape `{ object, fallback, key }` is still refused. ### Tests changed (forced) - `plugin-approvals/src/reader-locale-labels.test.ts`: two pins that drove the step label through a `t()`-only double were re-triaged onto `getTranslations`. One is "negotiates through `resolveBundleLocale`…" and the other is "asks the service once per read, and never through t()". The `objectstack-ai#35384` flow/position sourceLocale describe now also covers the step label. - `plugin-approvals/src/no-approver-note.test.ts`: its local renderer narrows the widened `ApprovalTextParam` union. TS2339 came from `check:test-typecheck`, and no assertion changed. ## Tests <details><summary>Readings</summary> - New pins: spec `i18n-resolver.test.ts` describe `resolveFlowApprovalStepLabel` (5 cases: locale + `zh` ladder, declared chain, authored locale sourceLocale en / default zh-CN, literal and empty-bundle fallbacks, own keys). service-messaging `keyed-notification-text.integration.test.ts` describe `objectstack-ai#35384` (7 cases on a real ObjectQL + SqlDriver: precondition, inline fan-out, SQL outbox + dispatcher, renamed packaged object with `/meta`'s `translateMetadataDocument` as oracle, inbox reader en / en-US / zh-CN, `t()`-only service, closed shape). plugin-approvals `approval-notification-keyed-text.integration.test.ts` describe `[objectstack-ai#35384]` (real ApprovalService plus real MessagingService: an en approver reads `Deal`, a zh-CN approver reads `商机`, a renamed object reads its rename). - Full suites on `2dfa8720` (the code head; the later merge of `origin/main` touched no file in these packages): `@objectstack/service-messaging` Test Files 80 passed (80), Tests 1084 passed (1084); `@objectstack/plugin-approvals` Test Files 127 passed (127), Tests 1883 passed (1883); `@objectstack/spec` (on `9d5362af`, spec unchanged after) Test Files 880 passed (880), Tests 28058 passed, 1 todo. Typecheck of all three packages, including spec's `check:test-typecheck` and approvals' `check:test-typecheck`: exit 0. - Round 2, the rename of the member to `object`, at `cfce553f`: `pnpm exec turbo run build` of both closures (40/40 tasks), then the typecheck of service-messaging and plugin-approvals (including `check:test-typecheck`) exited 0. `@objectstack/service-messaging` Test Files 80 passed (80), Tests 1084 passed (1084). `@objectstack/plugin-approvals` Test Files 127 passed (127), Tests 1883 passed (1883). The closed-shape pin still refuses `{ object, fallback, key }`. Spec is unchanged in round 2. - Ablation (round 1; one lock call each, `scripts/ablation-replace.mjs` plus a trap restore; every subject resolves from `src/`, so there is no dist leg; each leg's anchor went x1 to x0 and was restored with blob equal to HEAD and `git diff HEAD` empty): - Leg 1a, messaging object label read through `t()`: 5 failed / 7 of the `objectstack-ai#35384` describe. - Leg 1b, no `packagedBase`: 1 failed / 7 (the rename case). The first attempt was refused by the tool as a no-op (the replacement text already existed elsewhere), so it was re-run with a distinct replacement. - Leg 2, approvals `stepLabel` back on `t()`: 5 failed / 37. - Leg 3, spec resolver walking the declared chain for the authored locale: 1 failed / 5. - Leg 4, approvals `subjectParams` back to `{ key }`: 2 failed / 8 (both end-to-end `[objectstack-ai#35384]` cases). </details> ## Acceptance notes - Version skew: an older `service-messaging` refuses `{ object, fallback }` at `emit()`. Both packages are in the changeset `fixed` group, and the changeset says to upgrade them together. - A `t()`-only i18n double (no `getTranslations`) now gets the `fallback` for the typed param, not the `t()` row. `II18nService.getTranslations` is a required member, so every served service hands its translations over. - Other producers that name an object through `{ key: 'objects.OBJECT.label' }` keep the `t()` reading until they adopt the typed param. Only plugin-approvals emits it today (`git grep objectLabelKey` under packages/services and packages/plugins). - CI on the round-1 head `0b91c34b`: Test UI, Lint & Repo Gates and TypeScript Type Check read red, and none of them is a test or type failure. Run 45109434849 concluded `cancelled` at 04:07:57Z because the push of `cfce553f` (committed 04:07:17Z; its CI run 45109928513 was created at 04:07:32Z) superseded it. Every Test UI, Test Core, Lint and Type Check lane on `0b91c34b` concluded `cancelled` between 04:07:33Z and 04:07:57Z. The three rollups only report that: Test UI logged "the Test UI shards concluded 'cancelled'", Lint & Repo Gates logged "lint lane ... concluded `cancelled`" for four lanes, and TypeScript Type Check logged "type-check lane ... concluded `cancelled`" for three lanes, with no `error TS` line. Nothing under `ui/**` or `examples/**` consumes `NotificationTextParam`, `ApprovalTextParam` or the stored `keyed_text` (`git grep`). The only in-repo narrowing site was `no-approver-note.test.ts`, fixed in round 1. ## Verification Read first: `packages/services/service-messaging/src/notification-text.ts` (`renderWith` and the private `objectLabel` resolver; risk: the validator's new branch), `packages/spec/src/system/i18n-resolver.ts` (`resolveFlowApprovalStepLabel`), `packages/plugins/plugin-approvals/src/reader-locale-labels.ts` (`stepLabel`). Two-minute check: `pnpm --filter @objectstack/service-messaging exec vitest run src/keyed-notification-text.integration.test.ts -t 35384` should show 7 passed. The en recipient reads `Your Opportunity D_1 awaits approval.`, and the renamed object reads `Deal`. https://claude.ai/code/session_01ADHkmQNmyLgnBbCoc2iFjL 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#2 · os-steve · session_01ADHkmQNmyLgnBbCoc2iFjL --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steve · project thread
Part of #35384
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
This is stage 2 of #35384: items 2 and 3 of the remainder in release comment 7082136476. Item 1 (the approval notification subject param in service-messaging) is not in this PR, and neither is the approval STEP label (see Acceptance notes). That is why this PR says
Part of.plugin-approvals/src/reader-locale-labels.ts).readerLabelsFor().flowLabeland.positionLabelno longer go throught(), which falls back to thedefaultLocalerow. Each now uses the spec translator for its type, over every locale the i18n service holds, with the resolve options the metadata route builds (the reader's negotiated locale, the declared fallback chain, and the authored language:sourceLocale, elsedefaultLocale):translatePosition, whichGET /meta/positionserves throughtranslateMetadataDocument;translateFlow./metaserves a flow document untranslated:translateFlowis deliberately not in the dispatch table, and the flow runner applies it on the client. SotranslateFlowis the spec's one reading offlows.FLOW.label.reader-locale-labels-middleware.ts), and timeline position notes.objectLabel(approvals) andtranslatedObjectDef(audit) now givetranslateObjectthe object's served definition and its packaged base aspackagedBase. The base comes from the engine's registry (registry.getPackagedObjectBase(name)). That is the same body the metadata protocol'sgetPackagedObjectBasereads (engine.registry), and the protocol accessor is how/metaand fix(share-links): the share page names the object by its label and leaves off hidden fields #36460's share-link label getpackagedBase.readerLabelsFortakes an optional third argument,ReaderObjectSource(getSchema,registry).ApprovalService.readerLabelsand the two lock-refusal sentences inlifecycle-hooks.tspass the engine they already hold.installActivitySummaryLocalereads the base off the engine it is installed on, andreaderSummaryLocaletakes an optionalgetPackagedObjectBase.ApprovalServiceOptionsandApprovalEngineare unchanged. Nothing underpackages/spec/src/**orpackages/services/service-messaging/**is edited.Tests
reader-locale-labels.test.ts(the shared harness), two new top-level describes:sourceLocale: 'en'/defaultLocale: 'zh-CN'deployment with anenpack. First the precondition:t()gives anenreader the zh-CN rows. Thenenanden-USreaders pick nothing, so the authored snapshot stands. A pin measures thaten-USis negotiated toen. Controls: a zh-CN reader, anenpack entry, nosourceLocaledeclared, at()-only service, and one bundle per read.SchemaRegistry(a packagedOpportunitythat an extension renamesDeal).en,en-USandzh-CNreaders readDeal, and so does the oracletranslateMetadataDocument('object', served, bundle, {...options, packagedBase}). Controls: an unrenamed object, a registry that throws, and agetSchemathat throws.#24863cases that used at()-only double forflowLabelnow askstepLabel, the one label still ont().activity-summary-message.test.ts: a new top-level describe drives the installedsys_activitymiddleware over a realSchemaRegistry.en,en-USandzh-CNreaders getDeal, and the zh-CN field label still translates. Controls: an unrenamed object, and a registry whose base read throws.Readings at head 0e31535
pnpm --filter @objectstack/plugin-approvals test: Test Files 127 passed (127), Tests 1880 passed (1880).pnpm --filter @objectstack/plugin-audit test: Test Files 109 passed (109), Tests 1821 passed (1821).pnpm --filter @objectstack/plugin-approvals --filter @objectstack/plugin-audit typecheck(tsc, scripts tsconfig,check:test-typecheck): lock VERDICT command-exit 0.scripts/ablation-replace.mjsper leg, plus a trap restore. The subject resolves fromsrc/(relative import), so there is no dist leg.objectLabelwithoutpackagedBase: 3 failed / 37 (theen,en-USandzh-CNrename cases).flowLabelback ont(): 3 failed / 37 (theenanden-USauthored cases, and thet()-only case).positionLabelback ont(): 3 failed / 37 (the same three).translatedObjectDefwithoutpackagedBase: 3 failed / 24 (theen,en-USandzh-CNrename cases).git diff HEADis empty.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack@0e315358fa: 72 families. 70 exit 0. 2 NOT MEASURED (exit 3, PREREQUISITE NOT MET):check:dual-build-cjs-loads(needs a full build) andcheck:i18n(needs the built CLI closure); CI runs both.--ran: 72 derived, 70 run, 2 NOT-MEASURED, 0 UNRUN.node scripts/pm/overlap-check.mjs --branch=HEAD@0e315358fa: VERDICT clean exit 0.Acceptance notes
flows.FLOW.approvals.NODE.label) is still read throught(). No spec translator reads that key:translateFlowoverlays the flow label, the toasts and screen copy only. Reading the bundle along the locale chain inside plugin-approvals would be a second resolver besidelocaleChain. A spec export would widen@objectstack/spec, which this slice may not do. So anenreader in such a deployment still sees the zh-CN step label next to the authored flow label. The fork goes to the seat as an open question in the report./metadoes not translate flows.GET /meta/flowserves the authored document, so the flow side usestranslateFlow(the same translator, with the same resolve options), not a/metaread.protocolservice. It is the same body, the engine is already in hand at every caller, andApprovalServiceOptionsstays unchanged.approval-service.ts(one argument) andlifecycle-hooks.ts(two arguments) are beyond the claim's listed files. They are the callers that handobjectLabelits engine.Verification
Read first, by risk:
packages/plugins/plugin-approvals/src/reader-locale-labels.ts: thereaderLabelsForbody (translated,flowLabel,positionLabel,objectLabel).packages/plugins/plugin-audit/src/activity-summary-message.ts:translatedObjectDefandpackagedObjectBaseReader.packages/plugins/plugin-approvals/src/lifecycle-hooks.ts: the tworeaderLabelsFor(service, locale, engine)calls.Two-minute check:
pnpm --filter @objectstack/plugin-approvals exec vitest run src/reader-locale-labels.test.tsshould report 37 passed. The[#35384]describes coverenanden-USreaders with authored flow and position labels, and the renameDealin every locale.🤖 Generated with Claude Code
https://claude.ai/code/session_01ADHkmPTDM2MxHR8cvoMVUX