Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion docs/adr/0035-config-driven-master-detail.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0035: Config-driven master-detail (declare on the relationship, forms derive)

**Status**: Accepted · **Amended** (2026-10-28, [#27069](https://github.com/objectstack-ai/objectstack/issues/27069), maintainer rulings on that card: 「A」, an ordered list on the parent, and 「明细行的子表放在右侧合适嘛?」 / 「他如果做到放在基本信息下面,而条款和备注在后面」, line items in the record body) — `relatedList: 'primary'` is a **placement** (the record body, as a full-width table), no longer a prominence hint that orders lists; the order is the parent object's `relatedLists`; and an omitted `relatedList` on a `master_detail` FK that sets `inlineEdit` is now `'primary'` by default. See the note under the read-side table. · **Amended** (2026-11-19, [#35597](https://github.com/objectstack-ai/objectstack/issues/35597), under the record-page epic [#35590](https://github.com/objectstack-ai/objectstack/issues/35590), maintainer's words on that card: 「就是master-detail表类型的子表」 / 「主从的子表是否应该默认出现在概览的左侧区域?关键字段下面。」) — an omitted `relatedList` on ANY `master_detail` FK is `'primary'` (a body table) by default, `inlineEdit` or not; its totals are server-owned. See the second note under the read-side table. · **Amended** (2026-11-20, [#35889](https://github.com/objectstack-ai/objectstack/issues/35889), same epic, maintainer's words on that card: 「主从子表我认为不应该自动申明放在概览中,除非我通过 fieldGroup 强制指定」) — that default is withdrawn: an omitted `relatedList` on a `master_detail` FK is a tab, and the list is a body table (in the record page, the parent's forms and its edit state) only where a parent field group names it, and `inlineEdit` no longer inlines a child in the form by itself. See the third note under the read-side table. · **Amended** (2026-11-20, [#35897](https://github.com/objectstack-ai/objectstack/issues/35897) and [#35899](https://github.com/objectstack-ai/objectstack/issues/35899), epic [#35896](https://github.com/objectstack-ai/objectstack/issues/35896), maintainer's words: 「其实除了 overview,我们直接用 relatedLists 是不是就可以。」 / 「三个内置项,是不是可以直接用对应的对象名」) — a declared `relatedLists` is the record page's tab list (unlisted side lists show no tab), with the attachments, approvals and activity-stream tabs placed by object name and an entry's own title and columns. See the fourth note under the read-side table.
**Status**: Accepted · **Amended** (2026-10-28, [#27069](https://github.com/objectstack-ai/objectstack/issues/27069), maintainer rulings on that card: 「A」, an ordered list on the parent, and 「明细行的子表放在右侧合适嘛?」 / 「他如果做到放在基本信息下面,而条款和备注在后面」, line items in the record body) — `relatedList: 'primary'` is a **placement** (the record body, as a full-width table), no longer a prominence hint that orders lists; the order is the parent object's `relatedLists`; and an omitted `relatedList` on a `master_detail` FK that sets `inlineEdit` is now `'primary'` by default. See the note under the read-side table. · **Amended** (2026-11-19, [#35597](https://github.com/objectstack-ai/objectstack/issues/35597), under the record-page epic [#35590](https://github.com/objectstack-ai/objectstack/issues/35590), maintainer's words on that card: 「就是master-detail表类型的子表」 / 「主从的子表是否应该默认出现在概览的左侧区域?关键字段下面。」) — an omitted `relatedList` on ANY `master_detail` FK is `'primary'` (a body table) by default, `inlineEdit` or not; its totals are server-owned. See the second note under the read-side table. · **Amended** (2026-11-20, [#35889](https://github.com/objectstack-ai/objectstack/issues/35889), same epic, maintainer's words on that card: 「主从子表我认为不应该自动申明放在概览中,除非我通过 fieldGroup 强制指定」) — that default is withdrawn: an omitted `relatedList` on a `master_detail` FK is a tab, and the list is a body table (in the record page, the parent's forms and its edit state) only where a parent field group names it, and `inlineEdit` no longer inlines a child in the form by itself. See the third note under the read-side table. · **Amended** (2026-11-20, [#35897](https://github.com/objectstack-ai/objectstack/issues/35897) and [#35899](https://github.com/objectstack-ai/objectstack/issues/35899), epic [#35896](https://github.com/objectstack-ai/objectstack/issues/35896), maintainer's words: 「其实除了 overview,我们直接用 relatedLists 是不是就可以。」 / 「三个内置项,是不是可以直接用对应的对象名」) — a declared `relatedLists` is the record page's tab list (unlisted side lists show no tab), with the attachments, approvals and activity-stream tabs placed by object name and an entry's own title and columns. See the fourth note under the read-side table. · **Amended** (2026-12-02, [#38140](https://github.com/objectstack-ai/objectstack/issues/38140), ruling record [`7303122859`](https://github.com/objectstack-ai/objectstack/issues/38140#issuecomment-7303122859) of 2026-12-01, the option the maintainer chose: 「退役这个配置」) — the layered surface loses its middle layer: a form view's `subforms` is retired at protocol 19, and authoring it is refused. A child table entered with its parent is declared on the parent object, by the field group of the third note under the read-side table. See the note under the layered-surface table and the note under "Where derivation is wired".
**Author**: surfaced while making master-detail (parent + child line-item) entry a first-class, low-config capability
**Affects**: `@objectstack/spec` (field schema), `@object-ui/plugin-form`, `@object-ui/plugin-view`, `@object-ui/app-shell`; builds on ADR-0034 (atomic multi-write) and the cross-object batch endpoint (#1604)

Expand Down Expand Up @@ -58,6 +58,53 @@ All three converge on the same runtime: `MasterDetailForm`, which renders the
parent's fields + an editable child grid per collection and persists everything
through the transactional batch.

> **Amended (2026-12-02, #38140; built by #39061).** The table's middle row no
> longer holds: a form view's `subforms` is retired at protocol 19 under
> ADR-0049's enforce-or-remove (ruling record 7303122859 on the card: the
> maintainer chose 「退役这个配置」, the option whose consequence line reads
> 「写了直接报错并提示改用对象字段分组里的子表」). The key had no reader left.
> The console's record create and edit forms stopped loading a form view
> (#36425; ADR-0050's note of 2026-11-24 on that card) and take a record's
> child tables from the object alone
> (`ui/packages/app-shell/src/utils/recordFormNavigation.ts#recordFormSubforms`),
> and the page a named or public form opens on
> (`ui/apps/console/src/components/FormPage.tsx`) does not read the key. So
> the key is a tombstone on `packages/spec/src/ui/view.zod.ts#FormViewSchema`,
> and on the `form` item that takes that shape by reference (ADR-0159 D2):
> writing it is refused at parse with a prescription that names the
> replacement, and the protocol-19 conversion `form-view-subforms-removed`
> deletes it from stored rows and existing sources. The replacement is the
> 2026-11-20 note under the read-side table (#35889): a field group of the
> PARENT object whose `relatedList` names the child
> (`fieldGroups[].relatedList`), which every create and edit form of the
> object draws (the 2026-11-21 note says where). The conversion does not write
> that group, because placing a child on the object changes every form of the
> object; the semantic entry `ui-form-view-subforms-retired` leaves that
> choice to the author. What the row offered is written in the data model
> too: a child needs no `inlineEdit` for a group to place it (the 2026-11-20
> note says which lists a group may place), and the derived columns are
> overridden on the child's relationship field (`inlineColumns`, beside
> `inlineTitle` and `inlineAmountField`). Two layers are left in metadata: the
> parent's field group (the first row, read with the 2026-11-20 note) and the
> `object-master-detail-form` page block. "All three converge" now counts
> those two and the React `ObjectForm` block's own `subforms` prop (declared
> in `packages/spec/src/ui/react-blocks.ts`), which the retirement does not
> touch. The entry keys Derivation rules names as overrides
> (`relationshipField`, `columns`, `amountField`) are still written on that
> prop and on a page block's `details` entry. Four more sentences of this
> record name the retired layer and are read with this note. "(a form view
> that declares its own subforms still inlines what it declares)" in the
> 2026-11-20 note no longer holds. "(a form view's own subforms)" in the
> 2026-11-21 note names a case that is gone; its rule stands for a child no
> group places that a page block's `details` or the React block's `subforms`
> hands in. "`subforms` (view) overrides" under Consequences is no longer an
> escape hatch. "`subforms` on `ObjectFormSchema`/`FormViewSchema`" under
> Status of implementation records what shipped: objectui's
> `ObjectFormSchema` keeps the prop, and `FormViewSchema` now refuses the key.
> `form-view-subforms.spec.ts`, listed there, keeps its name and drives the
> table the object derives. The wiring has its own note, under "Where
> derivation is wired".

### Derivation rules

- **Relationship FK**: the child field of type `master_detail`/`lookup` whose
Expand Down Expand Up @@ -240,6 +287,23 @@ view as `subforms`. Because every form host — the create/edit modal
master-detail form for free. `ModalForm`/`DrawerForm` host the master-detail form
inside their envelope and suppress their own footer (the form owns its Save).

> **Amended (2026-12-02, #38140).** The paragraph above is the wiring as first
> shipped. Two later changes and the retirement replace its first two
> sentences; the third, on the envelope and the footer, is unchanged.
> `ui/packages/app-shell/src/providers/MetadataProvider.tsx#attachInlineSubforms`
> no longer scans for `inlineEdit` relationships: for each parent it collects
> the children a field group of that parent places (#35889, the 2026-11-20
> note under the read-side table). It no longer merges them into a form view
> either: it sets them on the parent object as `groupSubforms` (#36425). The
> console's record forms (the New and Edit dialog, the full-page form, and a
> create or edit an action opens) load no form view, so none reads a form
> view's `subforms`: each asks the object for that list
> (`recordFormSubforms`, cited in the note under the layered-surface table)
> and hands it to the form it opens as the `subforms` prop. `ObjectForm`,
> `ModalForm` and `DrawerForm` each still route a `subforms` they are handed
> to `MasterDetailForm`. With the form view's key retired, that derived list
> is the only one a record form carries.

## Consequences

- **For authors / AI generators**: master-detail is a one-line modeling decision
Expand Down
7 changes: 6 additions & 1 deletion docs/adr/0050-form-layout-vs-presentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0050: Form layout vs presentation — split the overloaded `FormView.type`

**Status**: Accepted (2026-10-28, letter A′ on #27032, ruling record 6464210455) — cutover card #27155 (spec) + #27159 (renderer); the 2026-10-20 amendment stands · **Amended** (2026-10-20, letter B′ on [#24692](https://github.com/objectstack-ai/objectstack/issues/24692), ruling record [`6281834942`](https://github.com/objectstack-ai/objectstack/issues/24692#issuecomment-6281834942), maintainer 「同意」) — the list add-record open mode is no longer declared on `addRecord`; see the note under Decision 2. · **Amended** (2026-11-24, [#36086](https://github.com/objectstack-ai/objectstack/issues/36086)) — two dated notes under Decision 2: on an object's list `navigation.mode` is deprecated and no longer picks how a record opens ([#35910](https://github.com/objectstack-ai/objectstack/pull/35910)), and the console's record create and edit forms are the object's own, no longer an internal form view ([#36543](https://github.com/objectstack-ai/objectstack/pull/36543)). Decision 2 and its 2026-10-20 note are left as written.
**Status**: Accepted (2026-10-28, letter A′ on #27032, ruling record 6464210455) — cutover card #27155 (spec) + #27159 (renderer); the 2026-10-20 amendment stands · **Amended** (2026-10-20, letter B′ on [#24692](https://github.com/objectstack-ai/objectstack/issues/24692), ruling record [`6281834942`](https://github.com/objectstack-ai/objectstack/issues/24692#issuecomment-6281834942), maintainer 「同意」) — the list add-record open mode is no longer declared on `addRecord`; see the note under Decision 2. · **Amended** (2026-11-24, [#36086](https://github.com/objectstack-ai/objectstack/issues/36086)) — two dated notes under Decision 2: on an object's list `navigation.mode` is deprecated and no longer picks how a record opens ([#35910](https://github.com/objectstack-ai/objectstack/pull/35910)), and the console's record create and edit forms are the object's own, no longer an internal form view ([#36543](https://github.com/objectstack-ai/objectstack/pull/36543)). Decision 2 and its 2026-10-20 note are left as written. · **Amended** (2026-12-02, [#38140](https://github.com/objectstack-ai/objectstack/issues/38140), ruling record [`7303122859`](https://github.com/objectstack-ai/objectstack/issues/38140#issuecomment-7303122859) of 2026-12-01, the option the maintainer chose: 「退役这个配置」) — a dated note under Decision 3 and one under Decision 4: the form view's `subforms`, which those decisions and the TL;DR name as the master-detail spelling, is retired at protocol 19, and single-record master-detail is declared on the parent object ([ADR-0035](./0035-config-driven-master-detail.md) as amended). Decisions 3 and 4 are left as written.
**Deciders**: ObjectStack Protocol Architects
**Builds on**: [ADR-0014](./0014-record-form-field-type.md) (record form field type), [ADR-0017](./0017-object-has-many-view.md) (object-bound views), [ADR-0049](./0049-no-unenforced-security-properties.md) (declared ≠ enforced discipline)
**Consumers**: `@objectstack/spec` (`ui/view.zod.ts` `FormViewSchema`), `@object-ui/plugin-form` (`ObjectForm` + `TabbedForm`/`WizardForm`/`SplitForm`/`DrawerForm`/`ModalForm`), `@object-ui/app-shell` (`RecordFormPage`, `AppContent`, `useActionModal`), examples + templates form views.
Expand Down Expand Up @@ -48,8 +48,13 @@ So `drawer`/`modal`/`split` *as `FormView.type` values* are **redundant with —
> **Note (2026-11-24, [#36425](https://github.com/objectstack-ai/objectstack/issues/36425); built by [#36543](https://github.com/objectstack-ai/objectstack/pull/36543)):** the 2026-10-20 note says the create form is chosen by convention from the object's form views. The console no longer chooses one. Its record create and edit forms (the New and Edit dialog, the full-page form, and a create or edit an action opens) are the object's own: they list the object's fields, less a `showOnCreate: false` field on a create (`ui/packages/app-shell/src/utils/recordFormFields.ts#recordFormFieldNames`), laid out by the object's `fieldGroups` and following the rules on its fields. An internal form view (`formViews.create`, `form`, `formViews.default`) still installs and steers nothing there. A form view still decides its own form in two places: a public form (`sharing.enabled: true`), and a named form a `form`-type action opens. The 2026-10-20 note is left as written; read its convention clause with this note.

3. **Remove `split` from `FormView.type`.** Master-detail is already `subforms` (single-record parent/child) + the list's `NavigationMode:'split'` (list+detail). A form-level `split` is a third, redundant spelling.

> **Note (2026-12-02, [#38140](https://github.com/objectstack-ai/objectstack/issues/38140), ruling record [`7303122859`](https://github.com/objectstack-ai/objectstack/issues/38140#issuecomment-7303122859), maintainer 「退役这个配置」; built by [#39061](https://github.com/objectstack-ai/objectstack/pull/39061)):** this decision, and the TL;DR's "master-detail is already `subforms`", name a form view's `subforms` as the spelling of single-record master-detail. That key is retired at protocol 19 (ADR-0049 enforce-or-remove). It had no reader left: the console's record create and edit forms load no form view (the 2026-11-24 note on #36425 under Decision 2), and the page a named or public form opens on does not read the key. Writing `subforms` on a form is refused at parse, with a prescription that names the replacement. Single-record master-detail is declared on the parent object: a field group whose `relatedList` names the child, which every create and edit form of the object draws ([ADR-0035](./0035-config-driven-master-detail.md), its notes of 2026-11-20 on #35889 and of 2026-12-02). The removal this decision makes stands, and the prescription a retired `split` value gets now names that field group where it named `subforms`. This note is about the `subforms` half of the sentence only. Decision 3 is left as written.

4. **`ObjectForm` drops its `drawer`/`modal`/`split` branches** (`DrawerForm`/`ModalForm` become caller-supplied containers; `SplitForm` retires in favour of `subforms`). It keeps `simple`/`tabbed`/`wizard`.

> **Note (2026-12-02, [#38140](https://github.com/objectstack-ai/objectstack/issues/38140)):** `SplitForm` is retired as this decision says. "In favour of `subforms`" is read with the note under Decision 3: the form view's key is retired too. What is left under that name is the React `ObjectForm` block's own `subforms` prop (declared in `packages/spec/src/ui/react-blocks.ts`), which the block's master-detail arm reads and the retirement does not touch. Decision 4 is left as written.

## Migration (low cost — breaking spec, tiny blast radius)

- Spec: narrow the `FormViewSchema.type` enum (spec-major: the removed values are a breaking surface change).
Expand Down
Loading