diff --git a/.changeset/form-subforms-retirement-tidy.md b/.changeset/form-subforms-retirement-tidy.md new file mode 100644 index 00000000000..eb32eb36db5 --- /dev/null +++ b/.changeset/form-subforms-retirement-tidy.md @@ -0,0 +1,8 @@ +--- +'@objectstack/spec': patch +--- + +Clause-②: no +Metadata-protocol: none + +The upgrade text around the retired form `subforms` key now names the same remedy for a lookup child as the stack's own refusal. The `form.subforms` parse prescription and the protocol-19 `ui-form-view-subforms-retired` entry say that a field group places only a body table: a lookup child's foreign key declares `relatedList: 'primary'` (a `master_detail` key that declares no `relatedList` needs nothing), or the stack refuses the group. The protocol-18 `ui-form-view-type-layout-only` entry no longer points readers at `subforms` for child records entered with the parent; it names the field group's `relatedList` instead. Nothing an author can write changes. diff --git a/content/docs/references/ui/view.mdx b/content/docs/references/ui/view.mdx index 7abfe818687..5d3a697a06c 100644 --- a/content/docs/references/ui/view.mdx +++ b/content/docs/references/ui/view.mdx @@ -212,7 +212,7 @@ Column footer summary configuration | **modalSize** | `never` | optional | [REMOVED] `view.form.modalSize` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no form view opens in a dialog, so nothing reads it from a form view. Delete the key: the console's New and Edit dialogs lay a record out by the object's `fieldGroups` and choose their own size, a form opened by name gets a page of its own, and the React `ObjectForm` block keeps its own `modalSize` prop for the modal it opens with `formType='modal'`. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **sections** | `{ name?: string; label?: string \| Record; description?: string; collapsible?: boolean; … }[]` | optional | | | **groups** | `{ name?: string; label?: string \| Record; description?: string; collapsible?: boolean; … }[]` | optional | [LEGACY ALIAS → `sections`] Accepted for back-compat and folded onto `sections` at parse; `sections` wins when both are present. Prefer `sections`. | -| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | +| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. A group places only a body table: a lookup child's FK declares `relatedList: 'primary'` (a master_detail FK that declares no `relatedList` needs nothing), or the stack refuses the group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **sharing** | `{ enabled?: boolean; publicLink?: string; password?: string; allowedDomains?: string[]; … }` | optional | Public sharing configuration for this form | | **submitBehavior** | `{ kind: 'thank-you'; title?: string; message?: string } \| { kind: 'redirect'; url: string; delayMs?: integer } \| { kind: 'continue' } \| { kind: 'next-record' }` | optional | Post-submit behavior. On the `redirect` arm, `url` is relative-only and interpolates only declared record fields as `{{record.field_name}}`, URL-escaped. | | **buttons** | `{ submit?: object; cancel?: object }` | optional | Form action-button visibility & labels; folded onto the flat renderer props by ObjectUI ObjectForm. | @@ -534,7 +534,7 @@ Form-view select option — the object-field option shape minus the per-option ` | **data** | `{ provider: 'object'; object: string } \| { provider: 'value'; items: any[] } \| { provider: 'schema'; schemaId: string; schema?: Record }` | optional | Data source configuration (defaults to "object" provider) | | **sections** | `{ name?: string; label?: string \| Record; description?: string; collapsible?: boolean; … }[]` | optional | | | **groups** | `{ name?: string; label?: string \| Record; description?: string; collapsible?: boolean; … }[]` | optional | [LEGACY ALIAS → `sections`] Accepted for back-compat and folded onto `sections` at parse; `sections` wins when both are present. Prefer `sections`. | -| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | +| **subforms** | `never` | optional | [REMOVED] `form.subforms` was removed in @objectstack/spec 19.0.0 (ADR-0049) — no renderer reads it: the page a form opened by name or by a public link gets never drew a child table, and a record's New and Edit forms take their child tables from the object, not from a form. Delete the key. To enter child rows with the record, place the child table on the object: a field group whose `relatedList` names the child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every New and Edit form of the object draws at that group. A group places only a body table: a lookup child's FK declares `relatedList: 'primary'` (a master_detail FK that declares no `relatedList` needs nothing), or the stack refuses the group. The React `ObjectForm` block keeps its own `subforms` prop. Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **sharing** | `{ enabled?: boolean; publicLink?: string; password?: string; allowedDomains?: string[]; … }` | optional | Public sharing configuration for this form | | **submitBehavior** | `{ kind: 'thank-you'; title?: string; message?: string } \| { kind: 'redirect'; url: string; delayMs?: integer } \| { kind: 'continue' } \| { kind: 'next-record' }` | optional | Post-submit behavior. On the `redirect` arm, `url` is relative-only and interpolates only declared record fields as `{{record.field_name}}`, URL-escaped. | | **buttons** | `{ submit?: object; cancel?: object }` | optional | Form action-button visibility & labels; folded onto the flat renderer props by ObjectUI ObjectForm. | diff --git a/packages/metadata-core/src/artifact-forward-conversion-package-body.test.ts b/packages/metadata-core/src/artifact-forward-conversion-package-body.test.ts index 26966fbe3dc..c64007edb83 100644 --- a/packages/metadata-core/src/artifact-forward-conversion-package-body.test.ts +++ b/packages/metadata-core/src/artifact-forward-conversion-package-body.test.ts @@ -31,6 +31,7 @@ import { type ConversionNotice, } from '@objectstack/spec'; import { applyArtifactForwardConversions } from './artifact-forward-conversion.js'; +import { SUPERSEDED_AT_THIS_DOOR, afterRetiringEntries, derivedRetiringIds } from './artifact-forward-conversion.test-support.js'; const SUBJECT = 'dashboard-refresh-interval-to-refresh-interval-seconds'; @@ -41,60 +42,6 @@ const DOOR_DEFAULT_FLIPS: readonly string[] = [ 'permission-view-all-fields-beside-record-bypass', ]; -/** - * [ADR-0159 D7, ADR-0049] Released step-18 fixtures whose surface a LATER - * major's retired entry rewrites or deletes, where this door replays that entry in the same window: its - * `retiredAfter` is at or above the artifact's floor, so the per-entry half - * opens it beside the step. The fixture is a released major's and is never - * edited. The rule is the one `packages/spec`'s `conversions.test.ts` states - * for the whole table (`SUPERSEDED_FIXTURES`): the expected result is the - * retiring entries applied, in the order listed, to the fixture's `after`, - * and every notice beyond the fixture's own is one of theirs, at the site - * they report. Each of these authors its form in `views[]`, which the - * major-19 form move, replayed at this door, moves to `forms[]`; one also - * carries the form's `subforms` list, which `form-view-subforms-removed` - * (protocol 19) deletes from the moved form. The order is the registry's. - */ -const SUPERSEDED_AT_THIS_DOOR: Readonly> = { - 'form-view-option-default-removed': ['view-forms-to-form-items'], - 'view-item-owner-hidden-removed': ['view-forms-to-form-items'], - 'view-overlay-owner-hidden-removed': ['view-forms-to-form-items'], - 'form-layout-inline-grid-to-vertical': ['view-forms-to-form-items'], - 'view-list-tabs-removed': ['view-forms-to-form-items'], - 'form-view-subform-columns-canonicalized': ['view-forms-to-form-items', 'form-view-subforms-removed'], - 'form-field-public-picker-removed': ['view-forms-to-form-items'], - 'view-list-filterable-fields-removed': ['view-forms-to-form-items'], - 'form-view-presentation-types-removed': ['view-forms-to-form-items'], - 'form-view-buttons-reset-removed': ['view-forms-to-form-items'], - 'form-view-drawer-keys-removed': ['view-forms-to-form-items'], -}; - -/** - * A fixture's `after` as this door leaves it: its retiring entries applied in - * the order listed, and the site each one reports (`ID at PATH`, the path - * relative to the fixture). Every listed entry must be a registered, - * load-retired entry of a later major that changes what it is handed; one that - * stopped firing means its row above is stale and must go. An entry with no - * row comes back as given, with no site. - */ -function afterRetiringEntries( - entry: { id: string; toMajor: number }, - after: Record, -): { stack: Record; sites: string[] } { - const sites: string[] = []; - let stack = after; - for (const id of SUPERSEDED_AT_THIS_DOOR[entry.id] ?? []) { - const retiring = ALL_CONVERSIONS.find((c) => c.id === id); - expect(retiring, `${id} must be registered`).toBeDefined(); - expect(retiring!.retiredFromLoadPath, `${id} must be retired from the load path, or this door never opens it`).toBe(true); - expect(retiring!.toMajor, `${id}: a superseding entry comes from a LATER major`).toBeGreaterThan(entry.toMajor); - const reported = sites.length; - stack = retiring!.apply(stack, (detail) => { sites.push(`${id} at ${detail.path}`); }); - expect(sites.length, `${id} must change what it is handed of this fixture's \`after\``).toBeGreaterThan(reported); - } - return { stack, sites }; -} - const versionTriple = (v: string): [number, number, number] => v.split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10)) as [number, number, number]; @@ -410,6 +357,12 @@ describe('[#23027] the conversion reaches every package body — ADR-0130 D4 opt it('every superseded fixture names a retired step-18 entry, so no row outlives its fixture', () => { for (const id of Object.keys(SUPERSEDED_AT_THIS_DOOR)) expect(STEP_18.map((c) => c.id), id).toContain(id); }); + + // The row agrees with the registry, and so with `packages/spec`'s + // `SUPERSEDED_FIXTURES`, which is held to the same derivation. + it('every step-18 fixture\'s row lists exactly the later entries that change its `after`', () => { + for (const entry of STEP_18) expect(SUPERSEDED_AT_THIS_DOOR[entry.id] ?? [], entry.id).toEqual(derivedRetiringIds(entry)); + }); }); }); diff --git a/packages/metadata-core/src/artifact-forward-conversion.test-support.ts b/packages/metadata-core/src/artifact-forward-conversion.test-support.ts new file mode 100644 index 00000000000..e42d65a2a52 --- /dev/null +++ b/packages/metadata-core/src/artifact-forward-conversion.test-support.ts @@ -0,0 +1,102 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * The superseded-fixture table of the artifact door, shared by the two suites + * that replay the released step-18 fixtures through it + * (`artifact-forward-conversion.test.ts`, the definition's own collections, and + * `artifact-forward-conversion-package-body.test.ts`, each package body). One + * table, so a change to a fixture cannot leave one suite's copy stale. + * + * `packages/spec`'s `conversions.test.ts` states the same rule for the whole + * conversion table (`SUPERSEDED_FIXTURES`) and keeps its own copy, because a + * shared source across the two packages would need a new published export of + * `@objectstack/spec`. The two copies are held together by a rule instead of an + * import: each row must equal {@link derivedRetiringIds} for its fixture, and + * both suites assert that, so a fixture change that moves the derived list + * turns both red at once and names the row. + * + * Test support only: neither `index.ts` nor `testing.ts` imports it, so it is + * not in the published build. + */ + +import { expect } from 'vitest'; +import { ALL_CONVERSIONS } from '@objectstack/spec'; + +/** + * [ADR-0159 D7, ADR-0049] Released step-18 fixtures whose surface a LATER + * major's retired entry rewrites or deletes, where this door replays that entry in the same window: its + * `retiredAfter` is at or above the artifact's floor, so the per-entry half + * opens it beside the step. The fixture is a released major's and is never + * edited. The rule is the one `packages/spec`'s `conversions.test.ts` states + * for the whole table (`SUPERSEDED_FIXTURES`): the expected result is the + * retiring entries applied, in the order listed, to the fixture's `after`, + * and every notice beyond the fixture's own is one of theirs, at the site + * they report. Each of these authors its form in `views[]`, which the + * major-19 form move, replayed at this door, moves to `forms[]`; one also + * carries the form's `subforms` list, which `form-view-subforms-removed` + * (protocol 19) deletes from the moved form. The order is the registry's. + */ +export const SUPERSEDED_AT_THIS_DOOR: Readonly> = { + 'form-view-option-default-removed': ['view-forms-to-form-items'], + 'view-item-owner-hidden-removed': ['view-forms-to-form-items'], + 'view-overlay-owner-hidden-removed': ['view-forms-to-form-items'], + 'form-layout-inline-grid-to-vertical': ['view-forms-to-form-items'], + 'view-list-tabs-removed': ['view-forms-to-form-items'], + 'form-view-subform-columns-canonicalized': ['view-forms-to-form-items', 'form-view-subforms-removed'], + 'form-field-public-picker-removed': ['view-forms-to-form-items'], + 'view-list-filterable-fields-removed': ['view-forms-to-form-items'], + 'form-view-presentation-types-removed': ['view-forms-to-form-items'], + 'form-view-buttons-reset-removed': ['view-forms-to-form-items'], + 'form-view-drawer-keys-removed': ['view-forms-to-form-items'], +}; + +/** + * The retiring entries a fixture's row must list, read off the registry: every + * entry of a later major, in registry order, that changes what it is handed + * when the ones before it in this list have been applied to the fixture's + * `after`. `packages/spec`'s `conversions.test.ts` derives its rows the same + * way, so the two tables cannot disagree on a fixture. + */ +export function derivedRetiringIds(entry: { + id: string; + toMajor: number; + fixture: { after: Record }; +}): string[] { + const ids: string[] = []; + let stack: Record = structuredClone(entry.fixture.after); + for (const later of ALL_CONVERSIONS) { + if (later.toMajor <= entry.toMajor) continue; + let fired = false; + const next = later.apply(structuredClone(stack), () => { fired = true; }); + if (!fired) continue; + ids.push(later.id); + stack = next; + } + return ids; +} + +/** + * A fixture's `after` as this door leaves it: its retiring entries applied in + * the order listed, and the site each one reports (`ID at PATH`, the path + * relative to the fixture). Every listed entry must be a registered, + * load-retired entry of a later major that changes what it is handed; one that + * stopped firing means its row above is stale and must go. An entry with no + * row comes back as given, with no site. + */ +export function afterRetiringEntries( + entry: { id: string; toMajor: number }, + after: Record, +): { stack: Record; sites: string[] } { + const sites: string[] = []; + let stack = after; + for (const id of SUPERSEDED_AT_THIS_DOOR[entry.id] ?? []) { + const retiring = ALL_CONVERSIONS.find((c) => c.id === id); + expect(retiring, `${id} must be registered`).toBeDefined(); + expect(retiring!.retiredFromLoadPath, `${id} must be retired from the load path, or this door never opens it`).toBe(true); + expect(retiring!.toMajor, `${id}: a superseding entry comes from a LATER major`).toBeGreaterThan(entry.toMajor); + const reported = sites.length; + stack = retiring!.apply(stack, (detail) => { sites.push(`${id} at ${detail.path}`); }); + expect(sites.length, `${id} must change what it is handed of this fixture's \`after\``).toBeGreaterThan(reported); + } + return { stack, sites }; +} diff --git a/packages/metadata-core/src/artifact-forward-conversion.test.ts b/packages/metadata-core/src/artifact-forward-conversion.test.ts index dea6f3eb5e4..3c4072eb4eb 100644 --- a/packages/metadata-core/src/artifact-forward-conversion.test.ts +++ b/packages/metadata-core/src/artifact-forward-conversion.test.ts @@ -25,6 +25,7 @@ import { type ArtifactConversionNotice, } from './artifact-forward-conversion.js'; import { checkProtocolCompat } from './protocol-handshake.js'; +import { SUPERSEDED_AT_THIS_DOOR, afterRetiringEntries, derivedRetiringIds } from './artifact-forward-conversion.test-support.js'; // ── Mirror pin ─────────────────────────────────────────────────────────────── // `ArtifactConversionNotice` is a structural mirror of the spec root's @@ -55,60 +56,6 @@ const DOOR_DEFAULT_FLIPS: readonly string[] = [ 'permission-view-all-fields-beside-record-bypass', ]; -/** - * [ADR-0159 D7, ADR-0049] Released step-18 fixtures whose surface a LATER - * major's retired entry rewrites or deletes, where this door replays that entry in the same window: its - * `retiredAfter` is at or above the artifact's floor, so the per-entry half - * opens it beside the step. The fixture is a released major's and is never - * edited. The rule is the one `packages/spec`'s `conversions.test.ts` states - * for the whole table (`SUPERSEDED_FIXTURES`): the expected result is the - * retiring entries applied, in the order listed, to the fixture's `after`, - * and every notice beyond the fixture's own is one of theirs, at the site - * they report. Each of these authors its form in `views[]`, which the - * major-19 form move, replayed at this door, moves to `forms[]`; one also - * carries the form's `subforms` list, which `form-view-subforms-removed` - * (protocol 19) deletes from the moved form. The order is the registry's. - */ -const SUPERSEDED_AT_THIS_DOOR: Readonly> = { - 'form-view-option-default-removed': ['view-forms-to-form-items'], - 'view-item-owner-hidden-removed': ['view-forms-to-form-items'], - 'view-overlay-owner-hidden-removed': ['view-forms-to-form-items'], - 'form-layout-inline-grid-to-vertical': ['view-forms-to-form-items'], - 'view-list-tabs-removed': ['view-forms-to-form-items'], - 'form-view-subform-columns-canonicalized': ['view-forms-to-form-items', 'form-view-subforms-removed'], - 'form-field-public-picker-removed': ['view-forms-to-form-items'], - 'view-list-filterable-fields-removed': ['view-forms-to-form-items'], - 'form-view-presentation-types-removed': ['view-forms-to-form-items'], - 'form-view-buttons-reset-removed': ['view-forms-to-form-items'], - 'form-view-drawer-keys-removed': ['view-forms-to-form-items'], -}; - -/** - * A fixture's `after` as this door leaves it: its retiring entries applied in - * the order listed, and the site each one reports (`ID at PATH`, the path - * relative to the fixture). Every listed entry must be a registered, - * load-retired entry of a later major that changes what it is handed; one that - * stopped firing means its row above is stale and must go. An entry with no - * row comes back as given, with no site. - */ -function afterRetiringEntries( - entry: { id: string; toMajor: number }, - after: Record, -): { stack: Record; sites: string[] } { - const sites: string[] = []; - let stack = after; - for (const id of SUPERSEDED_AT_THIS_DOOR[entry.id] ?? []) { - const retiring = ALL_CONVERSIONS.find((c) => c.id === id); - expect(retiring, `${id} must be registered`).toBeDefined(); - expect(retiring!.retiredFromLoadPath, `${id} must be retired from the load path, or this door never opens it`).toBe(true); - expect(retiring!.toMajor, `${id}: a superseding entry comes from a LATER major`).toBeGreaterThan(entry.toMajor); - const reported = sites.length; - stack = retiring!.apply(stack, (detail) => { sites.push(`${id} at ${detail.path}`); }); - expect(sites.length, `${id} must change what it is handed of this fixture's \`after\``).toBeGreaterThan(reported); - } - return { stack, sites }; -} - const versionTriple = (v: string): [number, number, number] => v.split(/[.-]/).slice(0, 3).map((n) => Number.parseInt(n, 10)) as [number, number, number]; @@ -1012,6 +959,12 @@ describe('[#23001] the major-step half — a ^18 artifact built during the v18 p it('every superseded fixture names a retired step-18 entry, so no row outlives its fixture', () => { for (const id of Object.keys(SUPERSEDED_AT_THIS_DOOR)) expect(STEP_18.map((c) => c.id), id).toContain(id); }); + + // The row agrees with the registry, and so with `packages/spec`'s + // `SUPERSEDED_FIXTURES`, which is held to the same derivation. + it('every step-18 fixture\'s row lists exactly the later entries that change its `after`', () => { + for (const entry of STEP_18) expect(SUPERSEDED_AT_THIS_DOOR[entry.id] ?? [], entry.id).toEqual(derivedRetiringIds(entry)); + }); }); }); diff --git a/packages/spec/src/conversions/conversions.test.ts b/packages/spec/src/conversions/conversions.test.ts index c81820ed6e7..04b1abe19b6 100644 --- a/packages/spec/src/conversions/conversions.test.ts +++ b/packages/spec/src/conversions/conversions.test.ts @@ -145,6 +145,28 @@ describe('conversion layer (ADR-0087 D2)', () => { } }); + // [#39067] `packages/metadata-core` keeps its own copy of + // the step-18 rows (`SUPERSEDED_AT_THIS_DOOR`, the artifact door's), because a + // shared source would need a new published export of this package. Both + // copies are held to this one derivation from the registry, so a fixture + // change that moves a row turns both red at once. + it('every fixture\'s row lists exactly the later entries that change its `after`, in registry order', () => { + for (const conversion of ALL_CONVERSIONS) { + const derived: string[] = []; + let stack: Record = structuredClone(conversion.fixture.after); + for (const later of ALL_CONVERSIONS) { + if (later.toMajor <= conversion.toMajor) continue; + let fired = false; + const next = later.apply(structuredClone(stack), () => { fired = true; }); + if (!fired) continue; + derived.push(later.id); + stack = next; + } + const listed = SUPERSEDED_FIXTURES[conversion.id]; + expect(listed ? retiringIdsOf(listed) : [], conversion.id).toEqual(derived); + } + }); + describe('immutability & non-interference', () => { it('returns the same reference when nothing converts', () => { const clean = { objects: [{ name: 'account' }], flows: [{ name: 'f', nodes: [] }] }; diff --git a/packages/spec/src/conversions/entries/18/form-view-subform-columns-canonicalized.ts b/packages/spec/src/conversions/entries/18/form-view-subform-columns-canonicalized.ts index 3fa44826c02..a219dc6d9b0 100644 --- a/packages/spec/src/conversions/entries/18/form-view-subform-columns-canonicalized.ts +++ b/packages/spec/src/conversions/entries/18/form-view-subform-columns-canonicalized.ts @@ -20,7 +20,7 @@ import { type Dict, isDict, respellInlineGridColumns } from '../shared.js'; * half of the #20901 closure of the form-view carrier (protocol 18). * * `FormViewSchema.subforms[].columns` was `z.array(z.any())` through 17.5.0 and - * now references `InlineGridColumnSchema`, whose alias table refuses `field` + * at protocol 18 referenced `InlineGridColumnSchema`, whose alias table refuses `field` * with a prescription naming `name`. That is the break a relationship field's * `inlineColumns` took in #9227, and the respelling is the same one: it runs * through {@link respellInlineGridColumns}, shared with @@ -40,10 +40,14 @@ import { type Dict, isDict, respellInlineGridColumns } from '../shared.js'; * stored-row seam wraps a `view` row as `{ views: [row] }` in any of those * spellings — and the assembled-manifest `viewItems` channel * ({@link ASSEMBLED_VIEW_ITEMS_KEY}) carries the last two. A list payload is - * never judged. `FormViewSchema` is the only schema that declares `subforms`. + * never judged. At protocol 18 `FormViewSchema` was the only schema that + * declared `subforms`. Protocol 19 retired the key (ADR-0049): the parse + * refuses it, and `form-view-subforms-removed` deletes the list this entry + * respells, so a replay from 17 respells a column and then drops it. * - * `retiredFromLoadPath`: the parse refuses `field` with the prescription, so a - * live author is taught rather than rewritten. The entry exists so stored rows + * `retiredFromLoadPath`: at 18 the parse refused `field` with the + * prescription, so a live author was taught rather than rewritten (from 19 it + * refuses the whole key, above). The entry exists so stored rows * and assembled artifacts replay clean, and so `os migrate meta` lists the edit. * Idempotent by construction: the rewrite leaves no `field` on the entry. */ diff --git a/packages/spec/src/conversions/entries/shared.ts b/packages/spec/src/conversions/entries/shared.ts index 1bca4ea3070..6ff05edeee5 100644 --- a/packages/spec/src/conversions/entries/shared.ts +++ b/packages/spec/src/conversions/entries/shared.ts @@ -158,8 +158,10 @@ const stripKeys = ( * carriers — a relationship field's `inlineColumns` * ({@link fieldColumnListsCanonicalized}) and a form view's `subforms[].columns` * ({@link formViewSubformColumnsCanonicalized}) — so the two conversions cannot - * drift on what they rewrite, as the two carriers cannot on what they accept - * (both reference `InlineGridColumnSchema`). + * drift on what they rewrite, as the two carriers could not on what they + * accepted (both referenced `InlineGridColumnSchema` until protocol 19 retired + * the form's `subforms`, ADR-0049; the protocol-19 `form-view-subforms-removed` + * now deletes the list the form-view entry respells). * * `{ field: 'x' }` → `{ name: 'x' }`, every other key kept. An entry already * carrying `name` is left alone — rewriting a live key on the strength of a diff --git a/packages/spec/src/data/inline-grid-columns.ts b/packages/spec/src/data/inline-grid-columns.ts index 1ff39b24b71..93f1f362ee5 100644 --- a/packages/spec/src/data/inline-grid-columns.ts +++ b/packages/spec/src/data/inline-grid-columns.ts @@ -10,8 +10,11 @@ * * - a child relationship field that sets `inlineEdit`, with no * `inlineColumns` (`FieldSchema.inlineColumns`); - * - a form view's `subforms[]` entry with no `columns` - * (`FormViewSchema.subforms`). + * - an entry of the React `ObjectForm` block's `subforms` prop with no + * `columns` (the block's overlay in `ui/react-blocks.ts`). + * + * A form view's `subforms[]` entry was a carrier too until protocol 19 retired + * the form's `subforms` (ADR-0049); the parse refuses that key now. * * The derivation used to live only in the renderer (objectui's * `deriveColumns`), so no author-time tool could ask what such a grid draws: diff --git a/packages/spec/src/migrations/entries/semantic/18.ui-form-view-type-layout-only.ts b/packages/spec/src/migrations/entries/semantic/18.ui-form-view-type-layout-only.ts index ee04e28a539..18fa1324971 100644 --- a/packages/spec/src/migrations/entries/semantic/18.ui-form-view-type-layout-only.ts +++ b/packages/spec/src/migrations/entries/semantic/18.ui-form-view-type-layout-only.ts @@ -29,8 +29,10 @@ export const entry: SemanticMigration = { + 'the drawer by default (`navigation.mode`), the console\'s New and Edit dialogs open the record form ' + 'themselves and choose their own size, and an action `type: \'modal\'` opens the page it targets. A ' + 'record beside its list is a reader\'s own preference in the list\'s Display menu; child records ' - + 'edited beside the parent are `subforms`, and on a page that is an `object-master-detail-form` ' - + 'block. An `object-form` block that opened in a drawer or dialog keeps its `drawer` or `modal` ' + + 'entered with the parent are a field group on the parent object whose `relatedList` names the child ' + + '(`fieldGroups[].relatedList`; a lookup child\'s FK declares `relatedList: \'primary\'`), which every ' + + 'New and Edit form of the object draws, and on a page an `object-master-detail-form` block. An ' + + '`object-form` block that opened in a drawer or dialog keeps its `drawer` or `modal` ' + '`formType` — the block is the caller that opens it', reason: 'ADR-0050: `type` held two orthogonal dimensions — the form\'s internal layout and the container it ' diff --git a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts index 8b346b6d4d5..ebeb3826f11 100644 --- a/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/19.ui-form-view-subforms-retired.ts @@ -15,7 +15,10 @@ export const entry: SemanticMigration = { replacement: 'a field group on the PARENT object whose `relatedList` names the child: ' + '`{ key: \'lines\', label: \'Lines\', relatedList: \'\' }` (or `\'.\'` when the child ' - + 'points at the parent more than once), in the `fieldGroups` order where the table should sit. Every New ' + + 'points at the parent more than once), in the `fieldGroups` order where the table should sit. A group ' + + 'places only a body table, so when the child points at the parent through a lookup, that FK declares ' + + '`relatedList: \'primary\'` (a master_detail FK that declares no `relatedList` needs nothing); otherwise ' + + 'the stack refuses the group. Every New ' + 'and Edit form of the object then draws the child table at that group and saves the record and its rows ' + 'together. What an entry set beside `childObject` goes on the child\'s relationship field: `title` is ' + '`inlineTitle`, `columns` is `inlineColumns` and `amountField` is `inlineAmountField`. `totalField` ' diff --git a/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index d22ac0a3782..e0138fd3f6c 100644 --- a/packages/spec/src/ui/component.zod.ts +++ b/packages/spec/src/ui/component.zod.ts @@ -124,9 +124,10 @@ import type { KeySetGuidance } from '../shared/suggestions.zod'; // `FormSectionSchema` (view.zod.ts) so one mixing rule serves both escape hatches. import { SectionGroupKeySchema, sectionGroupReferenceRefinement } from '../shared/section-group-reference'; // [#20928] `object-master-detail-form`'s `details[].columns` is the SAME inline -// grid column a relationship field's `inlineColumns` and a form view's -// `subforms[].columns` take, referenced rather than copied: all three carriers -// feed one objectui grid. [#21464] An inline `object-form` field's metadata +// grid column a relationship field's `inlineColumns` takes, referenced rather +// than copied: the carriers feed one objectui grid (a form view's +// `subforms[].columns` was one more until protocol 19 retired the form's +// `subforms`, ADR-0049). [#21464] An inline `object-form` field's metadata // members a field widget reads off it (`rows`, `accept`, `reference`, …) take the // object field's own member schemas, by reference, and its option's `label`, // `description` and `visibleWhen` the object field's option's — see @@ -2585,8 +2586,8 @@ const RECORD_LINE_ITEMS_HISTORY = * MongoDB-style record and the AST forms; the contract does not. * * `columns` IS {@link InlineGridColumnSchema} — the same object a relationship - * field's `inlineColumns`, a form view's `subforms[].columns` and an - * `object-master-detail-form` detail entry's `columns` take, not a copy: the + * field's `inlineColumns` and an `object-master-detail-form` detail entry's + * `columns` take, not a copy: the * panel hands its columns to the same objectui grid (`GridField`, whose * `GridColumn` declares exactly that schema's twenty-one keys and IS the spec's * type by reference). The column also means here what it means on those @@ -7437,17 +7438,17 @@ const MASTER_DETAIL_DETAIL_HISTORY = * A key nobody reads is not declared. * * `columns` IS {@link InlineGridColumnSchema}, the same object a relationship - * field's `inlineColumns` and a form view's `subforms[].columns` take: the - * renderer hydrates an authored list with the same `hydrateColumns` and draws - * it in the same grid, so every rule the column carries holds here too, with - * its own prescription. A column that declares no `type` takes it from the + * field's `inlineColumns` takes: the renderer hydrates an authored list with + * the same `hydrateColumns` and draws it in the same grid, so every rule the + * column carries holds here too, with its own prescription. A column that declares no `type` takes it from the * child field when the grid hydrates it, which this schema cannot see; * `defineStack`'s cross-reference check judges that resolved type * (`collectHydratedInlineColumnErrors` in `stack.zod.ts`). * - * The keys the entry shares with a form view's `subforms[]` entry take that - * entry's types and alias table, so one concept is spelled one way on both - * child-collection surfaces. The two it adds are the renderer's own: + * The keys and alias table are the ones a form view's `subforms[]` entry + * declared until protocol 19 retired that key (ADR-0049), so a project moving + * a child collection off a form spells it the same way here. The two it adds + * are the renderer's own: * `formFields` (the per-row expand form) and `inlineMode` (the two form * factors a relationship field's `inlineEdit` names; absence takes the * relationship's own resolution only on an entry the renderer derives, and its @@ -7459,9 +7460,9 @@ const MASTER_DETAIL_DETAIL_HISTORY = * resolving a locale map. * * A factory called inside {@link ObjectMasterDetailFormPropsSchema}'s own lazy - * body, the way a form view's `subforms[]` entry is built inline in its - * parent's: a standalone `lazySchema` here would be a function-typed proxy that - * nothing exports, which the schema-graph walks (`alias-integrity.test.ts`) + * body, the way a form view's `subforms[]` entry was built inline in its + * parent's until protocol 19: a standalone `lazySchema` here would be a + * function-typed proxy that nothing exports, which the schema-graph walks (`alias-integrity.test.ts`) * never descend into, so its alias table would go unjudged. */ /** diff --git a/packages/spec/src/ui/form-view-drawer-keys-retirement.test.ts b/packages/spec/src/ui/form-view-drawer-keys-retirement.test.ts index 0b332fb8143..cd4a7e06c3a 100644 --- a/packages/spec/src/ui/form-view-drawer-keys-retirement.test.ts +++ b/packages/spec/src/ui/form-view-drawer-keys-retirement.test.ts @@ -78,6 +78,7 @@ import { collectConversionNotices } from '../conversions/apply'; import { ALL_CONVERSIONS } from '../conversions/registry'; import { applyConversionsToStoredItem } from '../conversions/stored'; import type { ConversionNotice } from '../conversions/types'; +import { fieldGroupBodyTableRefusal } from '../data/related-list-body-table'; import { MIGRATIONS_BY_MAJOR, RETIRED_KEYS_BY_MAJOR } from '../migrations/registry'; import { defineStack } from '../stack.zod'; import { ComponentPropsMap, ObjectFormPropsSchema } from './component.zod'; @@ -756,6 +757,22 @@ describe(`the D2 conversion ${SUBFORMS_CONVERSION_ID}`, () => { expect(entries[0]!.conversionIds).toEqual([SUBFORMS_CONVERSION_ID]); expect(entries[0]!.acceptanceCriteria.length).toBeGreaterThan(0); }); + + // The upgrade text and the stack's own refusal must name one remedy for a + // lookup child: a field group places only a body table, and the refusal of a + // group naming a lookup side card tells the author to mark that FK + // `relatedList: 'primary'`. The prescription and the D3 entry say so too. + it("names the lookup child's `relatedList: 'primary'`, the remedy the stack's field-group refusal names", () => { + const refusal = fieldGroupBodyTableRefusal('crm_lead', 1, 'crm_lead_line', [ + { child: 'crm_lead_line', field: 'lead', def: { type: 'lookup' } }, + ]); + expect(refusal).toContain("Set relatedList: 'primary' on that FK"); + const r = FormViewSchema.safeParse({ type: 'simple', sections: SECTIONS, subforms: [{ childObject: 'crm_lead_line' }] }); + expect(r.success).toBe(false); + expect(r.error!.issues[0]!.message).toContain("`relatedList: 'primary'`"); + const d3 = MIGRATIONS_BY_MAJOR[19]!.semantic.find((s) => s.id === SUBFORMS_D3_ID)!; + expect(d3.replacement).toContain("`relatedList: 'primary'`"); + }); }); // ─── Tree-scoped absence, inside the radius the package already declares ─── diff --git a/packages/spec/src/ui/view.zod.ts b/packages/spec/src/ui/view.zod.ts index ce6390eaa5b..d5cdebfd118 100644 --- a/packages/spec/src/ui/view.zod.ts +++ b/packages/spec/src/ui/view.zod.ts @@ -5506,7 +5506,9 @@ const FORM_VIEW_SUBFORMS_RETIRED = + 'forms take their child tables from the object, not from a form. Delete the key. To enter child rows ' + 'with the record, place the child table on the object: a field group whose `relatedList` names the ' + 'child relationship (`fieldGroups[].relatedList`, a child object name or `object.field`), which every ' - + 'New and Edit form of the object draws at that group. The React `ObjectForm` block keeps its own ' + + 'New and Edit form of the object draws at that group. A group places only a body table: a lookup ' + + 'child\'s FK declares `relatedList: \'primary\'` (a master_detail FK that declares no `relatedList` ' + + 'needs nothing), or the stack refuses the group. The React `ObjectForm` block keeps its own ' + '`subforms` prop. ' + 'Run `os migrate meta --from 18` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand.'; diff --git a/ui/packages/plugin-form/src/deriveMasterDetail.ts b/ui/packages/plugin-form/src/deriveMasterDetail.ts index 06c9eabf0cc..994825f830d 100644 --- a/ui/packages/plugin-form/src/deriveMasterDetail.ts +++ b/ui/packages/plugin-form/src/deriveMasterDetail.ts @@ -352,20 +352,22 @@ function deriveColumn( * render time, here, so it still parses. `objectui validate` cannot see it * either: the `object-form` mirror judges a subform's `columns` with the spec's * own `InlineGridColumnSchema` (objectui#11266), and the child object's fields - * are not in the document it judges. Only `defineStack` refuses it, at publish, by resolving - * `name` against the child object's fields: on a relationship field's - * `inlineColumns` and on a form view's `subforms[].columns`, and only when the - * stack declares that child object (objectstack-ai/objectstack#20927). Nothing + * are not in the document it judges. Only `defineStack` refuses it, at + * publish, by resolving `name` against the child object's fields: on a + * relationship field's `inlineColumns` (a form view's `subforms[].columns` was + * the other carrier until protocol 19 retired the form's `subforms`), and only + * when the stack declares that child object (objectstack-ai/objectstack#20927). Nothing * in objectui does that, and this is the first place in objectui the child * field is known, so the report is made here — ⛔ never a silent drop. * - * The declared arm is reported too. On a form view's `subforms[].columns` both - * validators refuse a typed currency column carrying `scale`: the spec's - * `FormViewSchema` holds each column to `InlineGridColumnSchema` from 17.6.0, - * and the `object-form` mirror takes that schema by reference (objectui#11266). - * Neither runs between a stored or code-built form view and this function, so - * such a column can still arrive here, and it is reported rather than read in - * silence. + * The declared arm is reported too. The `object-form` mirror refuses a typed + * currency column carrying `scale` in a `subforms[].columns` entry, because it + * takes `InlineGridColumnSchema` by reference (objectui#11266); the spec held a + * form view's `subforms[].columns` to the same schema from 17.6.0 until + * protocol 19 retired that key. No validator runs between the `subforms` an + * `ObjectForm` is handed (the block's own prop, or the list the host derives + * from the parent's field groups) and this function, so such a column can + * still arrive here, and it is reported rather than read in silence. * * Once per column per page load (the `sectionFields.ts` convention): this runs * on every child-schema resolve. The first sentence is the spec's refusal with diff --git a/ui/packages/plugin-view/src/ObjectView.tsx b/ui/packages/plugin-view/src/ObjectView.tsx index 95f11df62e1..219272c856e 100644 --- a/ui/packages/plugin-view/src/ObjectView.tsx +++ b/ui/packages/plugin-view/src/ObjectView.tsx @@ -2883,9 +2883,11 @@ export const ObjectView: React.FC = ({ defaults: schema.form?.defaults, readOnly: schema.form?.readOnly || formMode === 'view', className: schema.form?.className, - // Master-detail by config: a form view can declare inline child - // collections; ObjectForm renders them as an atomic master-detail form - // (no bespoke page). ObjectForm skips them in view mode. + // Master-detail by config: this node's own `form.subforms` (the objectui + // `object-view` schema's, not a spec form view's key, which protocol 19 + // retired) lists inline child collections; ObjectForm renders them as + // an atomic master-detail form (no bespoke page). ObjectForm skips them + // in view mode. subforms: schema.form?.subforms, onSuccess: handleFormSuccess, onCancel: handleFormCancel,