Repository navigation
Commit d33bf5a
feat(spec): an object extension places the fields, groups and child lists it brings (place) (#36236)
Fixes #35901
Clause-②: yes (widening)
Metadata-protocol: semantic
Skills-docs: follow-up #35902
## 维护者速读
- 扩展包作者可以写明自己带来的字段、分组、子表排在原对象哪一项后面;记录页、表单和 Studio 按同一个结果显示,不写就和以前一样。
-
属于「记录页标签与分组」专题;父对象声明了页签表或分组才生效,没声明时照旧排在末尾并在启动日志里说明。别的包带来的子表不再被父对象的页签表藏掉,没写位置的排在页签末尾。
- 已经声明页签表的对象会多出其他已安装包的子表页签;父对象可以在自己的页签表里点名它来换位置,撤回本改动即恢复原样。
- 无。
## What changes
An `objectExtensions` entry gains `place`, a list of `{ field, group,
after | before }`, `{ group: { key, label, … }, after | before }` and `{
list, after | before, label?, columns? }` entries. The registry applies
them once, in `foldExtendersOntoDefinition`, after every contributor's
fields are merged, so every reader (record page, forms, Studio, the data
and metadata doors) gets one arrangement.
- **Spec** (`packages/spec/src/data/object.zod.ts`): the three placement
shapes and `ObjectExtensionSchema.place`. The parse refuses a field
outside the extension's own `fields`, both anchors at once, an item
placed twice or next to itself, and a field whose own `group` disagrees
with its placement. `defineStack` (`collectExtensionPlacementErrors` in
`stack.zod.ts`) refuses a list, or a placed group's `relatedList`, that
is not a child object of the extension's own package pointing at the
target, a group key the target declares, and a placed field (or a placed
group's `fields` entry) the target declares. The extension's
`fieldGroups` / `relatedLists` keys now prescribe `place`. The
`relatedLists` describe states the cross-package exception.
- **Merge** (`packages/objectql/src/registry-extension-placement.ts`,
wired into
`registry-object-registration.ts#foldExtendersOntoDefinition`): three
passes (groups, fields, lists) over the extensions in ascending
priority, then package id. A field joins a group's member list (a group
with no `fields` gets its current members written out on the served copy
first, so its order does not move). A list is spliced into
`relatedLists`; no anchor means the end of the tabs, before a trailing
`sys_approval_request` / `sys_activity` run. An anchor the object lacks
sends the item to the end. An item the object (or the base the fold
starts from) already arranges keeps that position, so a folded body
re-folds to itself. Notes go once per registry to the boot log
(`console.warn`, like `reportFieldPatchMisses`).
`engine-registration.ts` carries `place` onto the extension def.
- **Arm (a), one switch**: `PLACEMENT_ARRANGES_DECLARED_ONLY` (read only
by `arrangementDeclared`). List placements apply only where the target
declares a non-empty `relatedLists`; group and field placements only
where it declares `fieldGroups`. Elsewhere the automatic arrangement
stays and the boot log names the placement, including that a list
entry's `label` / `columns` and a field's `after` / `before` are inert,
and pointing to `relatedListTitle` / `relatedListColumns` on the child's
FK (Fable's three points).
- **`os validate`**
(`packages/lint/src/validate-extension-placement.ts`, in the
reference-integrity suite): `extension-placement-not-applied` and
`extension-placement-anchor-missing`, both warnings, with `os explain`
entries. It sees a target only when the target is in the same stack, so
the boot log stays the main channel; both texts say so.
- **Console flip** (`deriveRelatedLists`): on a parent that declares
`relatedLists`, a side list whose child belongs to another package than
the parent is kept (placed ones sit at the spliced entry; unplaced ones
after the listed lists). `arrangeDeclaredTabs` ranks an unnamed related
tab before a trailing run of listed approvals / stream tabs.
- **Studio** (`RelatedListsEditor`): such a list shows read-only among
the unlisted rows with a "from <package>" badge, and the preview draws
it where the record page does. The editor still edits only the authored
layers, so a save never copies an extension's placements into the owner.
- Semantic migration entry
`object-extension-place-and-cross-package-lists` (states the flip); the
#35897 entry's "a later change" clause now points to it. The two entries
name each other by entry id, not by tracker number: `os migrate meta`
prints an entry's text verbatim and
`packages/cli/test/migrate-meta-engine-guidance.test.ts` refuses a
tracker id there (ce3ab59). Dated notes in ADR-0085 §2 and ADR-0146
D10. Changeset carries both declaration lines and narrows #35897's note
in its own text.
- **ADR-0122 aliases**: `ObjectExtensionFieldPlacement` and
`ObjectExtensionListPlacement` have one shape, so they are pinned
isomorphic in `packages/spec/src/type-alias-convention.pin.test.ts` (886
→ 888, with its history line). `ObjectExtensionGroupPlacement` nests
`ObjectFieldGroupSchema`, which has a parsed shape, so it gains
`ObjectExtensionGroupPlacementParsed`; `api-surface` and
`export-origins` regenerated (33961ec).
Rulings applied: 7073014077 (F1 + F2 = 「父对象声明了才生效」; an unplaced
other-package list on a declared parent goes at the end of the tabs,
「装了就自动排在末尾」, flipping 7072511859's hiding).
Small calls (the thread's, accepted at claim 7072929733):
1. Several items at one anchor: after an anchor they follow it in
ascending priority, then package id; before an anchor they precede it in
the same order.
2. A field inserted into a group without `fields` gets that group's
current members materialised on the served copy, and the field's `group`
set to the group.
3. "End of tabs" means before the trailing run of `sys_approval_request`
/ `sys_activity`; `before:` one of those that the parent leaves unlisted
is that same position and is not named as a miss.
4. "Another package" means the child and the parent both belong to a
package (not `sys_metadata`) and the two differ; package-less children
keep #35897's rule.
5. When the owner already names the list or lists the field, the owner's
position wins (silently).
6. Item 4 is enforced at parse, at `defineStack`, and by a skip plus
warning in the merge, for every placement shape and whichever door
registered the extension (a manifest body reaches the registry unparsed;
the stored `object_extension` row is parsed only): a field by where it
comes from (the owner's, then the extension folded first), a group's
`fields` and its `relatedList`, and a list. The merge skips a list (or a
group placing one) only on a positive verdict (the child is registered
and owned by another package, or by none); an absent child is never a
verdict, since its package may register it later in the boot.
7. A missing anchor puts the item at the end, named in the boot log and
by `os validate`. An anchor another placement brings is found whatever
order the two are written or registered in (each pass places in rounds),
which is what `os validate` already accepted.
Follow-up for #35902 (from Fable's review, corrected by the L2): nothing
in HotCRM changes meaning today. Its modules use `objectExtensions`
(o2c, psa, revenue) but none writes `place`, and none of its objects
declares `relatedLists`. About 30 of its objects already declare
`fieldGroups`, so a field or group placement there applies as soon as a
module writes one; a list placement waits until the parent declares its
tab list.
## Review round 1 (reviewed head `ce3ab59e`; fixes in `c151007b`)
- **L1-c must-fix 1 / L2 S1**: pass 1 judges a placed group's
`relatedList` with the same `childPackageOf` verdict as pass 3 and skips
the group, named, on a foreign owner; an unregistered child is no
verdict. Pinned for a raw body and for a body parsed by
`ObjectExtensionSchema` and registered through `registerObjectExtension`
(the stored door, which runs no `defineStack`). The registry can receive
an unparsed `place` (the manifest loop in `engine-registration.ts` reads
the authored manifest as is), so the merge also drops from a placed
group's `fields` any name the extension does not own, named.
- **L2 S2**: a field is owned by where it comes from.
`placementContributorsOf` takes the owner's field names: an extension
owns only the keys of its `fields` that neither the owner nor an
extension folded earlier declares. A display-only redeclaration of an
owner field therefore cannot place it (merge: skipped, named).
`defineStack` refuses such a placement, at the entry and in a placed
group's `fields`, where the stack defines the extended object.
- **L2 S3**: the merge resolves an anchor another placement brings in
any order (`placeInRounds`: rounds in placement order; what still waits
when a round places nothing goes to the end, named). `os validate` and
the merge now agree.
- **L2 S4**: a list placement's `columns` are judged by
`validateRelatedListRefs` as a `relatedLists` entry's are
(`related-list-column-unknown`, error), top level and package bodies,
with the same field / injected-column / path rules; its explanation says
so.
- **N1** (both reviews): the `place` describe now says what is refused
where; another package's same group key is merged once and named, not
refused.
- **N2**: left as is (no effect on what shows). S1 covers who owns a
group's list, not whether a list of the extension's own package points
at the extended object; `defineStack` refuses that at build, and on an
unbuilt body the served entry names a list the record page places
nothing for.
- **L1-c nits**: the #35897 entry's sentence is now history ("was hidden
too until the parent named it; since
object-extension-place-and-cross-package-lists it shows at the end of
the tabs"); the ADR-0085 note adds that the parent cannot hide another
package's list (only that package's FK `relatedList: false` does).
- Changeset and docs: the HotCRM sentence (above), and the own-items,
anchor-order and `columns` rules.
## Tests
- `packages/spec/src/data/object-extension-place.test.ts`: the three
shapes and every parse refusal, at its path.
- `packages/spec/src/stack-extension-place.test.ts`: `defineStack`
refusals (ADR-0112 envelope) and the missing-anchor no-refusal; round 1:
a redeclared owner field placed at the entry or in a group's `fields` is
refused, placing its own field beside the redeclaration is not.
- `packages/objectql/src/registry-extension-placement.test.ts`: tax_id
after industry; before an anchor and at the end; a group that lists
members; industry removed → last in the group plus one log line; an
added group; lists after / before / at the end; owner position wins; two
packages at one anchor by priority, then package name, in both
registration orders; uninstall and disable restore the owner's order;
re-fold is idempotent; arm (a) for lists and groups with the log text;
foreign items skipped and named; an unregistered child is no verdict;
the manifest loop carries `place`; the pure function returns by
reference. Round 1: a group placing the owner's list (raw and through
the stored door) is not added; its own or an unregistered list is
(control); a group's foreign field is left out; a redeclared owner
field, and a field an earlier extension declares, are not moved; forward
anchors for lists, groups across packages and fields; an anchor nobody
brings still goes to the end.
- `packages/lint/src/validate-extension-placement.test.ts`: control,
not-applied for lists and groups, each missing anchor, sibling anchors,
package bodies, suite membership.
- `packages/lint/src/validate-related-list-refs.test.ts` (round 1): a
placement's columns, control, unknown at the top level and in a package
body, a child outside the stack unjudged.
-
`ui/packages/app-shell/src/utils/__tests__/deriveRelatedLists.otherPackage-35901.test.ts`,
`ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.test.ts`
(trailing run),
`ui/packages/app-shell/src/views/studio-design/ObjectSettingsPanel.relatedListsOtherPackage-35901.test.tsx`.
## Acceptance notes
- With no `place` written, every object is served as before (the fold
returns the merged body by reference when no extension carries
placements).
- A parent with no `relatedLists` / `fieldGroups` keeps its automatic
arrangement; nothing is dropped.
- First files to read, by risk:
`packages/objectql/src/registry-extension-placement.ts` (the splice and
the idempotence rule),
`ui/packages/app-shell/src/utils/deriveRelatedLists.ts` (the flip
branch),
`packages/spec/src/stack.zod.ts#collectExtensionPlacementErrors`.
- Two-minute check: `pnpm --filter @objectstack/objectql exec vitest run
src/registry-extension-placement.test.ts` → 34 passed.
## Verification
<details><summary>Local runs</summary>
- spec: `vitest run --project local` on the two new files plus every
test touching `ObjectExtensionSchema` / `objectExtensions` /
`relatedLists` and `src/migrations`: all passed.
- objectql: `tsc --noEmit` clean; the new file (23) plus the extension,
overlay and engine-registration tests (135): passed.
- lint: `tsc --noEmit` clean; the new rule, suite membership and rule
explanations (33): passed.
- ui: `deriveRelatedLists` and tab-arrangement tests (95) and the Studio
tab-list tests: passed. Three app-shell util files fail locally only
because `@objectstack/client` was not built in this container; they do
not import the changed code.
- `pnpm --filter @objectstack/spec check:generated --fix`: regenerated
and committed.
- `pnpm check:spec-parsed-alias`: OK (888 pinned isomorphic); the pin
test passed; `tsc -p tsconfig.test.json` reports nothing in the pin
file.
- A probe over all 639 semantic entries finds no tracker id in the
fields `os migrate meta` prints; spec `src/migrations` tests (198)
passed.
- CI: every check green on `42d56e66` (74 check-runs: 63 success, 11
skipped), and on `ce3ab59e` before the round-1 fixes.
- Round 1: spec placement, `defineStack`, migrations and alias-pin tests
(227) passed, `tsc` clean; objectql `tsc` clean, the placement file (34)
and every extension / overlay / engine-registration test (23 files, 373)
passed; lint `tsc` clean, related-list refs, placement, suite and
explanation tests (52) passed; `check:generated --fix` regenerated.
- Main merged in `507fac34` (no conflicts); the protocol index
regenerated from the merged tree (`42d56e66`). On the merged tree: alias
gate OK, 640 semantic entries with no tracker id, objectql extension and
placement tests (13 files, 155), lint (52) and spec placement /
migrations / object tests (21 files, 657) passed.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUxeTKkCvZ2iariHQf
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgUxeTKkCvZ2iariHQf -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 3f7fdd0 commit d33bf5a
43 files changed
Lines changed: 2946 additions & 81 deletions
File tree
- .changeset
- content/docs
- data-modeling
- references
- api
- data
- system
- docs
- adr
- audits/2026-07-unknown-key-strictness-ledger.counts
- packages
- lint/src
- objectql/src
- spec
- api-surface
- authorable-surface
- declaration-map
- export-origins
- json-schema.manifest
- src
- data
- migrations/entries/semantic
- ui/packages
- app-shell/src
- utils
- __tests__
- views/studio-design
- i18n/src/namespaces/studio
- plugin-detail/src/synth
- __tests__
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 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | | - | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
| 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 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
96 | 153 | | |
97 | 154 | | |
98 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
963 | 963 | | |
964 | 964 | | |
965 | 965 | | |
966 | | - | |
| 966 | + | |
967 | 967 | | |
968 | 968 | | |
969 | 969 | | |
| |||
0 commit comments