You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 08f4bad
Browse filesBrowse the repository at this point in the historyBrowse files
fix(metadata-protocol): a code package's placed tab or added field is saved in its source text from a translated read (#36813)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB9Gqqp1VYZwEqbXEm1YsTjU)_
Refs #36595 (items 1, 2, 3; item 4 is left out and reported to the seat
as a fork)
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufziH9MVhWYLVCiw5eXB
## 维护者速读
- 用户无感:只有直接调用接口、把翻译后的对象读结果整份存回去的客户端才会碰到;控制台和工作室的编辑器本来就存原文,前后都不变。
- 属于「关联列表标题翻译」的收尾:别的已安装代码包插入的标签页标题、添加的字段,在非原文语言下保存时,不再把译文存成原文。
- 出错的后果是这类标题或字段名被存成某一种语言的译文,其他语言的用户都看到它;本改动只影响保存时的还原,撤回即恢复原行为。
- 无。
## What changes
**Item 1 (save door, main item).** `restoreTranslatedEchoes` takes a new
optional `packagedOwner` beside `packagedBase`. With it, what the
packaged base carries beyond the owner (a field a code extender adds
under a name the owner does not declare, and a `relatedLists` entry
whose `list` the owner does not name, i.e. one a code extender's `place`
splices in) is the LAST source, used only for an incoming field or entry
the stored row does not declare at all. The save door
(`ProtocolDiscoveryAndBasesFacet.restoreTranslatedObjectEchoes`) reads
the owner from the engine's registry (`getPackagedObjectOwner`, the read
`getPackagedObjectBase` already falls back to) and hands it in. Landing
point: `protocol-translated-echo.ts`, as the dispatch expected, plus the
one hand-over line in `protocol-discovery-and-bases.ts`. The objectql
packaged-base producer is unchanged: it already carries the placed
entries and added fields (#36574's route (a)); what was missing was a
source on the save side.
What does not change, by construction:
- A field or entry the stored row declares is never compared with the
packaged base, so a tenant's rename keeps its text even when it equals a
catalog string (the guard the `packagedBase` docblock on
`restoreTranslatedEchoes` describes).
- A field or entry the OWNER declares and the stored row dropped is not
served by the fold (`overlay ?? own`), so a body carrying it again keeps
its text.
- With no stored row the source already is the packaged base, so the new
cut is empty.
- The stored-row migration path (`protocol-save.ts`, `source: item`) and
the pure injected-column half (`source: undefined`) pass no owner and
behave as before.
**Reachability (measured on origin/main 844218f, by reading).** No
in-repo editor reaches the edge:
- Studio/Setup editors seed their buffer from the layered read's
authored copy (`ui/packages/data-objectstack/src/authored-layers.ts`,
`authoredBuffer`: the `draft` layer, else an object's `overlay ??
code`), never the translated served read; `ResourceEditPage.tsx` uses it
for every translatable type.
- The record page's tab save composes over the layered read
(`recordTabsConfigSave.ts`, "composed over what is STORED, never what is
served").
- The `?state=draft` read is translated but not folded
(`protocol-meta-item-reads.ts`, the #8027 note: the fold runs after the
draft return), so it never carries a placed entry.
- The plain `GET /meta/object/NAME` read IS folded and translated
(`translateMetaDocument` in `packages/rest/src/meta-item-read-gate.ts`),
and `PUT /meta/object/NAME` runs `restoreTranslatedObjectEchoes` with
the stored row as source. So the edge is reachable by any API client
that saves the read it got back; the fix applies as defence for that
door. Not reproduced over HTTP in this PR.
**Item 2 (N4): documented deviation, no fix — a seat-accepted deviation
(repo:objectstack#3, 2026-11-24T01:45Z).** The base judges "declares
`relatedLists`" on the owner; the fold judges it on its base layer
(`overlay ?? own`). Making the base follow a tenant overlay would make
the PACKAGED base read a tenant row (the docblock defines it as the code
layer, before any overlay) and would change which text a reader sees in
a case the card does not settle (a catalog translation instead of the
authored placement label), which the dispatch routes to a fork. The
deviation is now stated in the `TranslateDocumentOptions.packagedBase`
docblock: where only a tenant overlay declares `relatedLists`, the
placed tab has no packaged counterpart, reads as authored, and the
deployment catalog does not translate it. No wrong text is served (the
label shown is the extender's own source).
**Item 3 (N5): docblock only.** `TranslateDocumentOptions.packagedBase`
(`packages/spec/src/system/i18n-resolver.ts`) now names the placed
`relatedLists` entries beside `validations` and added `fields`.
**Item 4 (lint union): left out, reported as a fork.** Measured with a
throwaway probe (deleted): an owner-labelled `_relatedLists.contact` key
resolves with 0 findings when a `.custom` arrangement hides the entry
(`{ list: 'contact', hidden: true }`) or names it bare (`['case',
'contact']`); the control (owner entry unlabelled, arrangement hides it)
gives 1 `translation-target-unknown` finding at severity `error`.
Tightening the rule would therefore turn an accepted key into an `os
validate` error, a `(narrowing)` arm, so it is not in this PR.
No ruling governs the edited lines: the `ruling` / `maintainer` / `⛔`
lines near each edit were read; the only one nearby
(`protocol-translated-echo.ts`, the patch-entry rule "asked through
`packagedOwner` ... by `scalarOverridesPackagedBase`, ⛔ never a second
copy") is about patch entries and is untouched; the new source asks no
override question. Decisions cited: ADR-0029 D9.2 / D9.2a.
## Tests
- Item 1: `protocol-translated-echo.test.ts`, describe "a code
extender's placed title or added field, over a stored row that predates
it": the pure restore, the tenant-rename and owner-dropped controls, and
the door test "the save door hands the restore the packaged owner: a
non-source-locale save over the stored row lacking the entry keeps the
source title" (the card's re-check criterion).
- Item 2: the deviation text in the `packagedBase` docblock.
- Item 3: the same docblock's first paragraph.
## Acceptance notes
- `restoreTranslatedEchoes`' local callback parameter in `sourceOf` is
also spelled `packagedOwner` (pre-existing, a different thing: the
packaged slot owner for a patch entry). The new argument is always read
as `args.packagedOwner`; no shadowing, but the names read alike.
- The lint comment in `validate-translation-references.ts` says "where
the target declares" (the looser spelling the review's N4 noted); left
as is, outside this PR's items.
## Verification
Two-minute check: `pnpm --filter @objectstack/metadata-protocol exec
vitest run --maxWorkers=2 src/protocol-translated-echo.test.ts` shows 19
passed, including the five cases of the new describe.
Read first: `packages/metadata-protocol/src/protocol-translated-echo.ts`
(the `extenderDoc` cut: the stored-row and owner exclusions are the
risk), then `protocol-discovery-and-bases.ts` (the owner read), then the
docblock in `i18n-resolver.ts`.
<details><summary>Local runs (head 15e4188)</summary>
- `vitest run src/protocol-translated-echo.test.ts
src/protocol-translated-echo.related-lists-36528.test.ts`: Test Files 2
passed, Tests 22 passed.
- Full `@objectstack/metadata-protocol` suite under the lock: Test Files
365 passed, 9 skipped (374); Tests 23359 passed, 45 skipped; VERDICT
command-exit 0.
- `@objectstack/metadata-protocol` typecheck: exit 0 (`--listFiles`
includes the test file).
- `@objectstack/objectql` door files
(`protocol-meta-effective-schema.test.ts`,
`registry-related-lists-label-translation-36528.test.ts`) against the
rebuilt closure: 28 passed.
- `pnpm --filter @objectstack/spec build && pnpm --filter
@objectstack/spec check:generated`: all 14 generated artifacts up to
date.
</details>
<details><summary>Ablation (committed fix, restored to HEAD by
blob)</summary>
- Removing the `['extender', extenderDoc]` source (`node
scripts/ablation-replace.mjs`, anchor 1 to 0, blob 120e8d8 to
6ca9d157): 3 failed / 16 passed: the pure restore, the owner-dropped
case's extender half, and the door test. Restored: blob == HEAD
(120e8d8), `git diff HEAD` empty.
- Removing the door's `packagedOwner` hand-over in
`protocol-discovery-and-bases.ts` (anchor 1 to 0): 1 failed (the door
test) / 18 passed. Restored: blob == HEAD, `git diff HEAD` empty.
</details>
<details><summary>Derived gate families</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 90 commands; all 90 run locally,
`--ran` reconciliation: 90 derived, 90 run, 0 UNRUN.
- 85 exited 0 at 13ff81c; the seven that read the test file
(`check:cross-package-test-inputs`, `check:tier-file-adoption`,
`check:nul-bytes`, `check:undeclared-dep-imports`,
`check:test-source-alias`, `check:issue-citations`,
`check-closing-keyword-parity`) re-run at 15e4188: all exit 0.
- `check:test-source-alias` was red at 13ff81c (the new door test
reached `@objectstack/lint` through dynamic imports inside a clock);
fixed by the module-top import it prescribes, green at 15e4188.
- NOT MEASURED, reason: `check-plugin-teardown-shape --self-test` (exit
3: shallow clone cannot reach its pinned fixture commit);
`check:dts-closure` (exit 1), `check:dual-build-cjs-loads` (exit 3,
PREREQUISITE NOT MET) and `check:lean-entry-closure` (exit 3): each
reads the whole tree's built `dist/`, which this worktree does not hold.
CI's.
- `test:repo` (the vitest `repo` project), Test Core shards, Build Core,
type-check lanes and the dogfood battery: CI's.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufziH9MVhWYLVCiw5eXB
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufziH9MVhWYLVCiw5eXB)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufziH9MVhWYLVCiw5eXB -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(metadata-protocol): a tab a code package places, or a field it adds, is saved in its source text from a translated read
7
+
8
+
Clause-②: no
9
+
Metadata-protocol: none
10
+
11
+
The `/meta` read of an object serves a related-list tab that another installed code package places into the object's `relatedLists` (its `place`), and a field such a package adds, translated for the caller's language. When the object has a stored customization row saved before that package was installed, the row carries no copy of either. A save of that translated read in a language other than the source (the whole body sent back through `PUT /meta/object/NAME`) then had nothing to compare them with, so the translation was stored as the tab title or the field label, and every other language read it from then on.
12
+
13
+
The save door now compares them with the packaged definition as a last resort: a tab whose `list` the owning package does not name, or a field the owning package does not declare, that the stored row does not declare at all, is compared with what the packaged definition carries, and its translation is stored as that source text. The save answer names each such slot in `advisories` (`translated-label-echo`), as it does for every other restored label. A title or label the stored row does declare is never compared with the packaged definition, so a customer's own rename keeps its text, even when it equals some language's catalog entry. A tab or field the owning package declares and the stored row dropped is left as the body carries it.
14
+
15
+
Console and Studio editors already save the stored document rather than the translated read, so they never reached this; a client that saved the translated read back did.
16
+
17
+
`TranslateDocumentOptions.packagedBase` now says that an object's packaged definition carries the tabs a code package places, and that a placement is judged on the owning package there but on the customization row by the served object: where only a customization row declares `relatedLists`, the placed tab has no packaged counterpart and the deployment catalog does not translate its title.
it('the save door hands the restore the packaged owner: a non-source-locale save over the stored row lacking the entry keeps the source title',async()=>{
0 commit comments