Repository navigation
Commit d24e4ab
feat(spec,app-shell): controlled_by_parent refusal carries a code; Studio settings tab words it in en and zh (#36579)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi973kVV4iHmicnT3W3avzhv3)_
Fixes #36526
Clause-②: yes
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:Studio
里给对象选「跟随所属的主记录」却没有合适的主从字段时,设置页现在用中文或英文的业务话说明哪里不对、该改哪个字段,不再显示带 ADR
编号的英文开发者原文。
- 为什么做:属于 Studio 文案业务化专题,接着上一张设置页去掉 ADR 编号的改动,把这条拒绝提示也改成作者能看懂的话。
- 出错会怎样:最坏是提示文字措辞不准或退回英文原文,保存是否被拒的判断不变;可以直接撤回本 PR。
- 要你做什么:无。
## What changes
**Spec (`@objectstack/spec`).** The `controlled_by_parent` master
refusal now carries a machine-readable code. Both raise sites,
`ObjectSchema`'s refinement (`refuseControlledByParentWithoutOneMaster`)
and `defineStack`'s extension-merge gate
(`applyControlledByParentExtensionGate`), stamp `params: { code:
CONTROLLED_BY_PARENT_MASTER_INVALID, shape }` on the issue. `shape` is
the existing published `ControlledByParentMasterShape`. The new constant
and a `ControlledByParentMasterIssueParams` type are exported from
`@objectstack/spec/data`, and the code is registered in
`ERROR_CODE_LEDGER` under `@objectstack/spec` (the
`PLUGIN_UI_REQUIRED_KEY_MISSING` precedent: a code on a zod issue's
`params.code`, door `none`). Which objects are refused, and at which
path, is unchanged.
Where the code is visible: on the zod issue itself (any `ObjectSchema` /
`ObjectStackDefinitionSchema` `safeParse`, which is the Studio tab's
path) and on `defineStack`'s `STACK_SCHEMA_INVALID` refusal, whose
`issues` are the raw zod issues (measured on this head:
`objects.0.sharingModel` carries `{ code, shape: 'no-master' }`). Where
it is not: the metadata save door's `422 INVALID_METADATA`. Its
`issues[]` entries come from `zodIssuesToMetadataIssues`
(`@objectstack/metadata-protocol`) and keep `path`, `message` and zod's
issue code (`custom`) only. The const's JSDoc, the ledger row's comment
and the changeset say exactly this. Carrying `params` through that
envelope would be a wire change and is not made here.
The three English message arms drop the developer citation: `ADR-0055
§1: since @objectstack/spec 18, …` becomes `Since @objectstack/spec 18,
…`. The prescription in each arm is unchanged. Card re-check: `grep -n
"ADR-0055 §1" packages/spec/src/data/controlled-by-parent-master.ts` now
hits docblock lines only, no message line.
**Studio (`@object-ui/app-shell`, `@object-ui/i18n`).**
`cbpMasterRefusal` (owd-sharing.ts) still parses the save door's
`ObjectSchema` on a probe, and now returns `{ message, shape, fields }`:
it reads the shape off the issue only when `params.code` is the spec's
code, and lists the fields the author has to act on.
`ObjectSettingsPanel` renders the `studio` namespace row the shape
selects (`engine.studio.settings.cbpRefusal*`, six shapes, en and zh),
naming the fields by label (key when unlabeled). With no code on the
issue, or a shape with no row, it shows the spec's message as before.
The shape-to-key map is typed on the spec's shape union, so a new shape
fails type-check until it has a row. The probe now also carries the
master's writability flags: on a `master_detail` field it copies
`readonly` and `system` when they are booleans, exactly as written (the
spec's module-private `UNWRITABLE_MASTER_FLAGS`, hard-coded in
owd-sharing.ts with a comment naming it; no new spec export). Before,
the probe dropped both flags, so a master marked `readonly: true` or
`system: true` was refused by the save door (shape
`master-not-writable`) while the tab showed nothing. Now the tab shows
that shape's row. The field that row names is the master as the parse
reads it: the one `master_detail` declared `required: true`, else the
object's only `master_detail` (on the parsed map an omitted `required`
is `false`, the optional master). Reading it off the raw probe named no
field for a flagged master that writes no `required`, and the row
printed an empty name. `cbpMasterRefusal` takes the issue whose
`params.code` is the spec's code, and falls back to the custom issue at
`sharingModel` / `fields` only when none carries it. The en
`required-lookup-only` wording has a one-field row and a several-field
row (`cbpRefusalRequiredLookupsOnly`); zh carries both keys for parity.
The stale docblock claim "The spec does not export the check" is
corrected: `controlledByParentMasterRefusal` is exported; the probe
keeps parsing `ObjectSchema` so the code it reads is the one the save
door stamps.
Naming: the code name `CONTROLLED_BY_PARENT_MASTER_INVALID` is accepted
by seat ruling 7088548226 on this PR (precedent: the spec's
`<SUBJECT>_INVALID` refusal codes such as `STACK_SCHEMA_INVALID` and
`DATASET_INVALID`).
Route chosen: one new ledger code plus the existing `shape` vocabulary
as the sub-discriminator. The shape alone does not identify the refusal
family on an arbitrary issue, and ADR-0112 registers a code that ships
in `dist`.
Generated artifacts regenerated: `packages/spec/api-surface/data.json`,
`packages/spec/export-origins/data.json`,
`content/docs/references/api/{error-code-ledger,contract,automation-api}.mdx`.
## Tests
Changed tests (forced by the change):
- `packages/spec/src/data/object.test.ts`: the two `toMatch` pins that
ended in `ADR-0055 §1:` and the two `toContain('since @objectstack/spec
18, …')` pins now read `Since @objectstack/spec 18, …`; `issuesOf` also
returns `params`.
- `ui/packages/app-shell/src/views/studio-design/owd-sharing.test.ts`:
the three `cbpMasterRefusal(...)` equality pins compare `.message`.
-
`ui/packages/app-shell/src/views/studio-design/ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`:
the two cases that expected the spec text verbatim in `owd-cbp-refusal`
now expect the business wording.
New assertions:
- `object.test.ts`: every reachable shape (`no-master`,
`required-lookup-only`, `several-masters`, `several-required-masters`,
`master-not-writable`) carries `params` equal to `{ code:
CONTROLLED_BY_PARENT_MASTER_INVALID, shape }`, and no message matches
`ADR-`.
- `stack-cbp-extension-master.test.ts`: the extension-merge issue
carries the same `params`.
- `owd-sharing.test.ts`: shape and named fields per shape, including
`master-not-writable` for a master marked `readonly` or `system` (and no
refusal when both are `false`), and the same shape naming the master
when it writes no `required`; the shape equals the one on the save
door's issue; the key map covers all six shapes; the spec-parity cases
add a readonly required master and a system optional master.
- `ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`: a new describe
renders five shapes in eight cases (a readonly and a system required
master, and a readonly master that writes no `required`, all show the
`master-not-writable` row naming the field; one required lookup and two
required lookups take the one-field and several-field rows) in en-US and
zh-CN and checks the exact row text, that zh differs from en, and that
neither contains `ADR-`, `@objectstack/spec`, `sharingModel`,
`master_detail` or `required: `.
<details><summary>Ablation (one reading, then restored)</summary>
Mutation via `scripts/ablation-replace.mjs` on
`packages/spec/src/data/object.zod.ts`: the refinement's `code:
CONTROLLED_BY_PARENT_MASTER_INVALID` replaced with `code:
'ABLATION_36526'`. Anchor 1 to 0, blob 723be4e to 3889e32b7048.
Spec rebuilt; `ablation-dist-preflight.mjs @objectstack/spec
ABLATION_36526` found the marker in 2 dist files.
- spec `object.test.ts` + `stack-cbp-extension-master.test.ts`: 1 failed
/ 227 passed (`no-master: expected { code: 'ABLATION_36526', …(1) } to
deeply equal { …(2) }`).
- ui `owd-sharing.test.ts` +
`ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`: 11 failed / 30
passed (the shape reads `undefined`, the panel falls back to the spec
text).
Restore: blob back to HEAD 723be4e, `git diff HEAD` empty; spec
rebuilt; `--absent` preflight: marker absent from all 614 built files,
working tree clean.
Second reading, for the flag carry (patch round 1, head ca3ebc2):
`scripts/ablation-replace.mjs` replaced the probe's flag copy in
`owd-sharing.ts` with a no-op (anchor 1 to 0, blob fb3c386 to
bd773cd5b26b; the tests read this source directly, no build in between).
`owd-sharing.test.ts` +
`ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`: 5 failed / 41
passed, the five readonly/system cases. Restore: blob back to HEAD
fb3c386, `git diff HEAD` empty, `git status --porcelain` empty.
Third reading, for the master resolution (patch round 2, head
c8366b9): `scripts/ablation-replace.mjs` made the only-`master_detail`
arm of `refusalFields` return no field (anchor 1 to 0, blob be67de1
to 25dda5fdf07b; source read directly, no build). `owd-sharing.test.ts`
+ `ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`: 2 failed / 46
passed, the two omitted-`required` cases. Restore: blob back to HEAD
be67de1, `git diff HEAD` empty, `git status --porcelain` empty.
</details>
<details><summary>Local runs</summary>
- `pnpm --filter @objectstack/spec test`: Test Files 875 passed, Tests
27973 passed, 1 todo.
- `ui` vitest `packages/app-shell/src/views/studio-design/` +
`packages/i18n/src/__tests__/studio-namespace.test.ts`: Test Files 356
passed, Tests 2791 passed.
- Downstream refusal suites (metadata-protocol 2 files 50 tests,
objectql 2 files 38 tests, plugin-security 4 files 187 tests, lint 5
files 826 tests): all passed.
- `pnpm --filter @objectstack/spec typecheck`, `pnpm --filter
@object-ui/i18n type-check`, `pnpm --filter @object-ui/app-shell
type-check`: exit 0.
- `pnpm --filter @objectstack/spec check:generated`: all 14 artifacts up
to date.
- Gate list from `node scripts/pm/dispatch-gates.mjs --commands` at
2d20f93: 126 derived, 125 run with exit 0, 1 NOT MEASURED (`pnpm
check:dual-build-cjs-loads`: PREREQUISITE NOT MET, it reads every
package's dist and this box has no full build; CI carries it). `--ran`
reconciliation: 126 accounted, 0 unrun.
- Patch round 1 (head ca3ebc2): `owd-sharing.test.ts`,
`ObjectSettingsPanel.cbpRequiredMaster-12326.test.tsx`,
`ObjectSettingsPanel.businessWording-36512.test.tsx`,
`PackageOwdOverviewPanel.cbpRequiredMaster-12326.test.tsx` and
`studio-namespace.test.ts`: 5 files / 85 tests passed; `pnpm --filter
@object-ui/app-shell type-check` exit 0. `dispatch-gates --commands` at
ca3ebc2 derives the same 126 families as at 2d20f93 (no family newly
touched), so none was re-run; `--ran` reconciliation still 126
accounted, 1 NOT MEASURED.
- Patch round 2 (head c8366b9): spec build, `pnpm --filter
@objectstack/spec typecheck` and `object.test.ts` +
`stack-cbp-extension-master.test.ts` + `error-code-ledger.test.ts` +
`controlled-by-parent-master.test.ts`: 4 files / 301 tests passed;
`check:generated` all 14 up to date. ui targeted suites (the same five
files): 87 tests passed; `@object-ui/i18n` and `@object-ui/app-shell`
type-check exit 0. `dispatch-gates --commands` at c8366b9 derives the
same 126 families (none newly touched); the twelve that read the changed
text (error-code casing, dispatcher vocabulary, status conformance, the
three changeset gates, doc-authoring, nul-bytes, issue-citations,
error-code-provenance, api-surface, ui `scripts/`) were re-run, all exit
0; `--ran` reconciliation 126 accounted, 1 NOT MEASURED.
- All other readings above were taken at head 2d20f93 (after merging
origin/main ad50d61), except the full spec suite, the full
studio-design suite and the ablation, which ran before the merge (at
bc5a55626 and a6b5ec9, whose source is identical; a6b5ec9 adds only
the changeset); the targeted refusal suites were re-run after the merge:
spec `src/data/` + stack + ledger 191 files / 6806 tests passed, ui 5
files / 80 tests passed.
</details>
## Acceptance notes
- Card claim: the governing `Claim:` on #36526 is comment 7088513159,
naming this card thread's branch `claude/project-thread-h6ofg9`.
- `master-not-required` cannot reach the tab through a raw parse (an
omitted `required` defaults to `false` first); its row exists for
completeness.
## Verification
Read first:
`ui/packages/app-shell/src/views/studio-design/owd-sharing.ts`
(`refusalShape`, `refusalFields`),
`packages/spec/src/data/object.zod.ts` (the refinement's `params`),
`ui/packages/i18n/src/namespaces/studio/zh.ts` (the six rows).
Two-minute check: in Studio, open an object with no master-detail field,
set sharing to "Follows its parent record" with the console in Chinese.
Expected: the red line under the picker reads
「该对象设为「跟随所属的主记录」,但它没有可跟随的主从关系字段,因此无法保存。…」 with no ADR number.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmSBA2pE8xHD9x1XEXj
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmSBA2pE8xHD9x1XEXj -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f66340a commit d24e4ab
18 files changed
Lines changed: 530 additions & 50 deletions
File tree
- .changeset
- content/docs/references/api
- packages/spec
- api-surface
- export-origins
- src
- api
- data
- ui/packages
- app-shell/src/views/studio-design
- i18n/src/namespaces/studio
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
428 | | - | |
| 428 | + | |
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| 147 | + | |
146 | 148 | | |
147 | 149 | | |
148 | 150 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| 144 | + | |
143 | 145 | | |
144 | 146 | | |
145 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1907 | 1907 | | |
1908 | 1908 | | |
1909 | 1909 | | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
1910 | 1921 | | |
1911 | 1922 | | |
1912 | 1923 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
101 | 136 | | |
102 | 137 | | |
103 | 138 | | |
| |||
228 | 263 | | |
229 | 264 | | |
230 | 265 | | |
231 | | - | |
| 266 | + | |
232 | 267 | | |
233 | 268 | | |
234 | 269 | | |
| |||
245 | 280 | | |
246 | 281 | | |
247 | 282 | | |
248 | | - | |
| 283 | + | |
249 | 284 | | |
250 | 285 | | |
251 | 286 | | |
| |||
285 | 320 | | |
286 | 321 | | |
287 | 322 | | |
288 | | - | |
| 323 | + | |
289 | 324 | | |
290 | 325 | | |
291 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
1635 | 1636 | | |
1636 | 1637 | | |
1637 | 1638 | | |
1638 | | - | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
1639 | 1646 | | |
1640 | 1647 | | |
1641 | 1648 | | |
| |||
1653 | 1660 | | |
1654 | 1661 | | |
1655 | 1662 | | |
1656 | | - | |
| 1663 | + | |
1657 | 1664 | | |
1658 | 1665 | | |
1659 | 1666 | | |
| |||
1692 | 1699 | | |
1693 | 1700 | | |
1694 | 1701 | | |
1695 | | - | |
| 1702 | + | |
1696 | 1703 | | |
1697 | | - | |
1698 | | - | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
1699 | 1729 | | |
1700 | 1730 | | |
1701 | 1731 | | |
| |||
0 commit comments