From 211e1fac0dd906aae1cc403f28b71d8da5c61647 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 19:18:47 +0000 Subject: [PATCH 1/6] feat(lint): judge object_extension writes with the duplicate-field-label rule An extension published at runtime can add a field under a label the object it extends already shows (owner_id included). The rule now runs on the object_extension door too: it folds the written entry onto its target as served, among the target's other packages' extensions by priority, and the gate's differential charges the write only with the clash its entry creates. Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE Co-authored-by: Claude --- packages/lint/src/authoring-rules.ts | 38 +++++- .../src/lint-duplicate-field-labels.test.ts | 6 +- .../lint/src/lint-duplicate-field-labels.ts | 51 ++++++- packages/lint/src/rule-explanations.ts | 4 +- .../runtime-gate.object-formula-cycle.test.ts | 5 +- ...runtime-gate.object-formula-writes.test.ts | 4 +- .../src/runtime-gate.object-writes.test.ts | 124 ++++++++++++++++++ packages/lint/src/runtime-gate.ts | 4 + ...e-security-posture.runtime-surface.test.ts | 6 +- 9 files changed, 223 insertions(+), 19 deletions(-) diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index b82edd68e27..7de75ecd751 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -356,15 +356,23 @@ export interface AuthoringRuleContext { * so a name it does not carry is refused there; on the CLI commands they are * one app's declaration, and the object-reference ladder (sibling packages, * platform names, a platform-prefixed name advised at `warning`) applies. + * + * [#33644] `lintDuplicateFieldLabels` reads `object_extension` only, on the + * argument `validateStackExpressions` gives for the same write: there the + * snapshot's objects are the registry's served definitions, carrying the + * injected columns as declared fields, so the rule reads them back to the + * authored shape the build judges (`stripInjectedSystemColumns`). */ runtimeWriteType?: string; /** * [#33494] Set by the runtime gate on an `object_extension` write only: the * written entry's target's other packages' published extensions, as the - * host's registry holds them. Read by one rule, `validateStackExpressions`, - * whose extension walk folds the written entry among them by priority (the - * build's own fold, `objectsAsServed`), so the door judges the definition - * the build judges (`StackExpressionOptions.storedObjectExtensions`). + * host's registry holds them. Read by two rules, each folding the written + * entry among them by priority (the build's own fold, `objectsAsServed`), so + * the door judges the definition the build judges: + * `validateStackExpressions`' extension walk + * (`StackExpressionOptions.storedObjectExtensions`) and (#33644) + * `lintDuplicateFieldLabels` (`DuplicateFieldLabelOptions`). */ storedObjectExtensions?: readonly StoredObjectExtension[]; /** @@ -2370,6 +2378,19 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ // another object; a re-save of that object is judged on its own body, as // for every gating rule at this door. No boot or registration path runs // this table, so an app already installed keeps loading. + // + // [#33644] `object_extension` joins: an extension adds fields to an object + // it does not own, and the registry folds them onto it, so one can add a + // field under a label the target already shows (`owner_id` included). The + // door hands the written entry and the target as served without the written + // package's own extension; the rule folds the entry among the target's other + // packages' extensions by priority (`storedObjectExtensions`, the build's + // fold) and reads the served objects back to their authored shape + // (`runtimeWriteType`, the expression rule's argument for the same input). + // The differential charges the write with the clash its entry creates and + // nothing the target already carried. MEASURED first: the one first-party + // `objectExtensions` entry (app-showcase's `showcase_account` overlay) adds + // no clash, as written or in any locale. { name: 'lintDuplicateFieldLabels', tier: 'gating', @@ -2377,9 +2398,12 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ commands: ALL, source: 'packages/lint/src/lint-duplicate-field-labels.ts', surfaces: CLI_AND_RUNTIME, - runtimeTypes: ['object'], - run: (stack) => - lintDuplicateFieldLabels(stack).map((f) => ({ + runtimeTypes: ['object', 'object_extension'], + run: (stack, ctx) => + lintDuplicateFieldLabels(stack, { + ...(ctx.storedObjectExtensions !== undefined ? { storedObjectExtensions: ctx.storedObjectExtensions } : {}), + ...(ctx.runtimeWriteType === 'object_extension' ? { servedObjects: true } : {}), + }).map((f) => ({ severity: f.severity, rule: f.rule, where: f.where, diff --git a/packages/lint/src/lint-duplicate-field-labels.test.ts b/packages/lint/src/lint-duplicate-field-labels.test.ts index f825c345370..92322da5522 100644 --- a/packages/lint/src/lint-duplicate-field-labels.test.ts +++ b/packages/lint/src/lint-duplicate-field-labels.test.ts @@ -82,10 +82,12 @@ describe('lintDuplicateFieldLabels', () => { expect(lintDuplicateFieldLabels({ objects: [obj] })).toEqual([]); }); - it('is a gating entry the three commands and the object publish door run', () => { + it('is a gating entry the three commands and the object and object_extension publish doors run', () => { const entry = AUTHORING_RULES.find((r) => r.name === 'lintDuplicateFieldLabels'); expect(entry?.tier).toBe('gating'); - expect(entry?.runtimeTypes).toEqual(['object']); + // [#33644] `object_extension` joins; its door pins live in + // `runtime-gate.object-writes.test.ts`. + expect(entry?.runtimeTypes).toEqual(['object', 'object_extension']); const stack = { objects: [ticketObject()] }; for (const command of ['validate', 'build', 'lint'] as const) { const rules = runAuthoringRules(command, { normalized: stack, parsed: stack }).filter((f) => f.rule === FIELD_LABEL_DUPLICATE); diff --git a/packages/lint/src/lint-duplicate-field-labels.ts b/packages/lint/src/lint-duplicate-field-labels.ts index 0d904837d0c..0274137a6d2 100644 --- a/packages/lint/src/lint-duplicate-field-labels.ts +++ b/packages/lint/src/lint-duplicate-field-labels.ts @@ -61,6 +61,24 @@ * carries a clash is refused until the clash is fixed. Nothing on the boot or * registration path runs the author-time rules, so an app that is already * installed keeps loading and serving. + * + * ## The `object_extension` door + * + * An extension published at runtime (Studio's add-field on a `.custom` pair, + * the `/meta` doors, an MCP or AI author) adds fields to an object it does not + * own, so it can add one under a label the target already shows, `owner_id` + * included. The door hands the gate the written entry as the stack's only + * `objectExtensions` member and the live objects as the registry serves them, + * the target without the written package's own stored extension (which the + * write replaces), so the fold below judges the target as it will be served + * after the write. Two inputs make that the build's fold: the target's OTHER + * packages' extensions with their priorities (`storedObjectExtensions`), so a + * field two packages tie on is left out as the build leaves it out, and the + * injected columns read back to the platform's own definitions + * (`stripInjectedSystemColumns`, as the expression rule reads the served + * objects there), so `owner_id` is named as the platform's column. The gate's + * differential charges the write only with a clash its entry creates: a clash + * the target already carried is in the baseline too, with the same message. */ import { @@ -69,7 +87,13 @@ import { type ObjectLike, type TranslationBundle, } from '@objectstack/spec/system'; -import { objectsAsServed, objectsWithoutTiedFields, recordsOf } from './object-graph.js'; +import { stripInjectedSystemColumns } from '@objectstack/metadata-core'; +import { + objectsAsServed, + objectsWithoutTiedFields, + recordsOf, + type StoredObjectExtension, +} from './object-graph.js'; import { injectedColumnDefsFor } from './system-fields.js'; type AnyRec = Record; @@ -160,15 +184,36 @@ function quoteList(names: readonly string[]): string { return `${quoted.slice(0, -1).join(', ')} and ${quoted[quoted.length - 1]}`; } +/** What the `object_extension` publish door states beyond the stack (see the module note). */ +export interface DuplicateFieldLabelOptions { + /** + * The written extension's target's other packages' published extensions, + * folded among the written entry by priority. Stated by the door only. + */ + storedObjectExtensions?: readonly StoredObjectExtension[]; + /** + * The objects are the registry's SERVED definitions, carrying the injected + * columns as declared fields: read them back to the authored shape first. + * Set by the door on an `object_extension` write only. + */ + servedObjects?: boolean; +} + /** * Report every object that serves two or more visible fields under one label. * Returns a (possibly empty) list of findings; never throws. */ -export function lintDuplicateFieldLabels(stack: AnyRec): DuplicateFieldLabelFinding[] { +export function lintDuplicateFieldLabels( + stack: AnyRec, + options: DuplicateFieldLabelOptions = {}, +): DuplicateFieldLabelFinding[] { const findings: DuplicateFieldLabelFinding[] = []; if (!isRec(stack)) return findings; + if (options.servedObjects === true) { + stack = { ...stack, objects: recordsOf(stack.objects).map((o) => stripInjectedSystemColumns(o)) }; + } const declared = recordsOf(stack.objects); - const served = objectsWithoutTiedFields(objectsAsServed(stack)); + const served = objectsWithoutTiedFields(objectsAsServed(stack, options.storedObjectExtensions ?? [])); declared.forEach((obj, i) => { const objectName = typeof obj.name === 'string' ? obj.name : undefined; diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index baf57a7ab04..538a3fd389d 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -6165,7 +6165,9 @@ const FIELD_LABEL_DUPLICATE_EXPLANATION: RuleExplanation = { 'and the finding names that locale.', 'An error at `os build`, `os validate`, `os lint` and the metadata publish door. At the door a write of ' + 'another object is never refused for a clash a stored object carries, while saving the object itself is ' + - 'refused until its clash is fixed; nothing on the boot path runs the rule, so an installed app keeps ' + + 'refused until its clash is fixed. An `object_extension` publish is refused for a clash the fields it ' + + 'adds create on the object it extends, judged on that object as it will be served, and never for one ' + + 'the object already carried. Nothing on the boot path runs the rule, so an installed app keeps ' + 'loading. To fix it, give each ' + 'visible field its own label (in the translation bundle too, when only a translation clashes), set ' + '`hidden: true` on the field readers should not see, or drop the duplicate and use the platform\'s column.', diff --git a/packages/lint/src/runtime-gate.object-formula-cycle.test.ts b/packages/lint/src/runtime-gate.object-formula-cycle.test.ts index e0a1e7995d9..c92c73e3dc4 100644 --- a/packages/lint/src/runtime-gate.object-formula-cycle.test.ts +++ b/packages/lint/src/runtime-gate.object-formula-cycle.test.ts @@ -294,7 +294,10 @@ describe('#33153 — formula cycles an object extension adds, at the object_exte it('the target\'s own stored cycle is not the extension write\'s to answer for (the differential)', () => { const cyclic = target({ f_x: formula('record.f_y + 1'), f_y: formula('record.f_x + 1') }); - const result = gateExtension(extension({ e__c: formula('record.quantity * 2') }), [cyclic]); + // [#33644] A label of its own: under the helper's shared 'F' the entry + // would join the target's `f_x` / `f_y` label group, a clash the + // duplicate-label rule charges to the extension at this door. + const result = gateExtension(extension({ e__c: { ...formula('record.quantity * 2'), label: 'E' } }), [cyclic]); expect(result.errors, dump(result)).toEqual([]); }); diff --git a/packages/lint/src/runtime-gate.object-formula-writes.test.ts b/packages/lint/src/runtime-gate.object-formula-writes.test.ts index e8fdacd5640..4fa252ebe7b 100644 --- a/packages/lint/src/runtime-gate.object-formula-writes.test.ts +++ b/packages/lint/src/runtime-gate.object-formula-writes.test.ts @@ -364,7 +364,7 @@ describe('#33072 — the object_extension door judges an extension field\'s form it('`validateStackExpressions` is on the object_extension door, beside the vocabulary freeze', () => { // [#33217] And the two validation-rule artifact checks (regex, JSON schema). expect(runtimeAuthoringRulesFor('object_extension').map((r) => r.name)) - .toEqual(['validateStackExpressions', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); + .toEqual(['validateStackExpressions', 'lintDuplicateFieldLabels', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); }); it('⭐ LIT — an extension formula calling an unregistered function (`sqrt`) is REFUSED, at the entry the build names', () => { @@ -422,7 +422,7 @@ describe('#33072 — the object_extension door judges an extension field\'s form const result = gateExtension(item); expect(result.errors, dump(result)).toEqual([]); expect(result.advisories, dump(result)).toEqual([]); - expect(result.rulesRun).toEqual(['validateStackExpressions', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); + expect(result.rulesRun).toEqual(['validateStackExpressions', 'lintDuplicateFieldLabels', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); } }); diff --git a/packages/lint/src/runtime-gate.object-writes.test.ts b/packages/lint/src/runtime-gate.object-writes.test.ts index a028f460d59..88c2dac074c 100644 --- a/packages/lint/src/runtime-gate.object-writes.test.ts +++ b/packages/lint/src/runtime-gate.object-writes.test.ts @@ -35,8 +35,10 @@ * harness (issue #4716, comment 5328421898). They are permanent here so the * evidence the exemption rests on cannot rot silently. */ +import { applyInjectedSystemColumns } from '@objectstack/metadata-core'; import { describe, expect, it } from 'vitest'; import { AUTHORING_RULES } from './authoring-rules.js'; +import { lintDuplicateFieldLabels } from './lint-duplicate-field-labels.js'; import { REFERENCE_INTEGRITY_RULES } from './reference-integrity-suite.js'; import { runRuntimeAuthoringRules, @@ -641,6 +643,128 @@ describe('the object write door refuses a write that serves two visible fields u }); }); +/** + * #33644 — the `object_extension` door judges the clash an extension adds to + * the object it extends. The door hands the written entry and the target as + * the registry SERVES it (the injected columns carried as declared fields, the + * written package's own stored extension left out), which `served()` stands + * in for; the differential charges the write only with a clash its entry + * creates. + */ +describe('the object_extension door refuses an extension that adds a field under a label its target already shows', () => { + const TARGET = { + name: 'xl_ticket', + label: 'Ticket', + sharingModel: 'private', + fields: { subject: { type: 'text', label: 'Subject' }, status: { type: 'text', label: 'Status' } }, + }; + const served = (obj: Record = TARGET) => applyInjectedSystemColumns(obj); + const ext = (fields: Record, over: Record = {}) => ({ + extend: 'xl_ticket', + fields, + ...over, + }); + const gateExtension = (item: unknown, objects: unknown[] = [served()], storedObjectExtensions?: unknown[]) => + runRuntimeAuthoringRules({ + type: 'object_extension', + item, + context: { objects }, + ...(storedObjectExtensions !== undefined ? { storedObjectExtensions: storedObjectExtensions as never } : {}), + }); + const labelErrors = (result: ReturnType) => + result.errors.filter((e) => e.rule === 'field-label-duplicate'); + const atBuild = (stack: Record) => lintDuplicateFieldLabels(stack).map((f) => f.message); + + it('the rule is on the object_extension door, and still on the object door', () => { + expect(runtimeAuthoringRulesFor('object_extension').map((r) => r.name)).toContain('lintDuplicateFieldLabels'); + expect(runtimeAuthoringRulesFor('object').map((r) => r.name)).toContain('lintDuplicateFieldLabels'); + }); + + it('⭐ LIT — an extension field labelled like the injected owner_id in zh-CN is REFUSED, naming the target, both fields and the label', () => { + const item = ext({ assignee: { type: 'user', label: '负责人' } }); + const result = gateExtension(item); + const errs = labelErrors(result); + expect(errs, JSON.stringify(result.errors)).toHaveLength(1); + expect(errs[0]!.severity).toBe('error'); + expect(errs[0]!.where).toBe('object "xl_ticket"'); + // Located on the target, keyed by name on the wire. + expect(errs[0]!.path).toBe('objects.xl_ticket.fields'); + expect(errs[0]!.message).toContain("'assignee' and 'owner_id' under one label \"负责人\" when read in locale zh-CN"); + // Read back to the authored shape, the served owner_id is named as the + // platform's column, as the build names it. + expect(errs[0]!.message).toContain("'owner_id' is a column the platform adds"); + // The build's finding over the same entry, byte for byte. + expect(atBuild({ objects: [TARGET], objectExtensions: [item] })).toEqual([errs[0]!.message]); + }); + + it('⭐ LIT — an extension field labelled like one of the target\'s own fields is REFUSED in the authored pass', () => { + const errs = labelErrors(gateExtension(ext({ topic: { type: 'text', label: 'Subject' } }))); + expect(errs).toHaveLength(1); + expect(errs[0]!.message).toContain("object \"xl_ticket\" shows fields 'subject' and 'topic' under one label \"Subject\", so"); + }); + + it('an unrelated extension write (a label of its own, or the clashing field hidden) is not charged (the controls)', () => { + for (const item of [ + ext({ escalation_level: { type: 'number', label: 'Escalation Level' } }), + ext({ assignee: { type: 'user', label: '处理人' } }), + ext({ assignee: { type: 'user', label: '负责人', hidden: true } }), + ]) { + const result = gateExtension(item); + expect(result.rulesRun).toContain('lintDuplicateFieldLabels'); + expect(labelErrors(result), JSON.stringify(result.errors)).toEqual([]); + } + }); + + it('the target\'s own object save is not blamed for a clash an extension write was refused for', () => { + const refused = gateExtension(ext({ assignee: { type: 'user', label: '负责人' } })); + expect(labelErrors(refused)).toHaveLength(1); + // Refused, the entry is not stored, so the target is served as before; + // its own save is judged on the body it sends and is clean. + const save = runRuntimeAuthoringRules({ + type: 'object', + item: { ...TARGET, description: 'edited' }, + context: { objects: [served()] }, + }); + expect(save.rulesRun).toContain('lintDuplicateFieldLabels'); + expect(save.errors, JSON.stringify(save.errors)).toEqual([]); + }); + + it('a clash the target already carries is not charged to an extension write that does not create it (the differential)', () => { + const clashing = { + ...TARGET, + fields: { ...TARGET.fields, phone: { type: 'phone', label: 'Phone' }, mobile: { type: 'phone', label: 'Phone' } }, + }; + // The control: the target's clash is real, the build reports it. + expect(atBuild({ objects: [clashing] })).toHaveLength(1); + const unrelated = gateExtension(ext({ escalation_level: { type: 'number', label: 'Escalation Level' } }), [served(clashing)]); + expect(labelErrors(unrelated), JSON.stringify(unrelated.errors)).toEqual([]); + // An entry that joins the clash changes it, and is charged. + const joins = labelErrors(gateExtension(ext({ fax: { type: 'phone', label: 'Phone' } }), [served(clashing)])); + expect(joins).toHaveLength(1); + expect(joins[0]!.message).toContain("'fax', 'mobile' and 'phone' under one label \"Phone\""); + }); + + it('folds the entry among the target\'s other packages\' extensions by priority, as the build does', () => { + // Another package's extension adds `region` at the default priority; the + // served target carries it as a plain field. + const other = { extend: 'xl_ticket', fields: { region: { type: 'text', label: 'Region' } } }; + const servedWithOther = served({ ...TARGET, fields: { ...TARGET.fields, region: other.fields.region } }); + const item = ext({ region: { type: 'text', label: 'Subject' } }); + // A tie at one priority leaves the field out at the build: which + // definition wins is registration order. + expect( + atBuild({ objects: [TARGET], packages: [{ manifest: { objectExtensions: [other] } }, { manifest: { objectExtensions: [item] } }] }), + ).toEqual([]); + expect(labelErrors(gateExtension(item, [servedWithOther], [other]))).toEqual([]); + // Without the other packages' priorities the door would judge the written + // definition alone (the reading the stated extensions exist to correct). + expect(labelErrors(gateExtension(item, [servedWithOther]))).toHaveLength(1); + // A higher priority wins outright, at the build and at the door alike. + const winning = ext({ region: { type: 'text', label: 'Subject' } }, { priority: 210 }); + expect(labelErrors(gateExtension(winning, [servedWithOther], [other]))).toHaveLength(1); + }); +}); + /** * #10064 — the WIRE spelling of a collection-resident finding's path. * diff --git a/packages/lint/src/runtime-gate.ts b/packages/lint/src/runtime-gate.ts index 1244d717919..186490e62e9 100644 --- a/packages/lint/src/runtime-gate.ts +++ b/packages/lint/src/runtime-gate.ts @@ -295,6 +295,10 @@ const TYPE_TO_STACK_KEY: Readonly> = { // pass: the extension walk over the written entry's fields. It resolves // `record.FIELD` into `objects`, which every snapshot already carries, so the // row still needs no context collection of its own. + // + // [#33644] `lintDuplicateFieldLabels` crosses too: it folds the written + // entry onto its target in `objects` (as served, without the written + // package's own extension), so it needs no context collection either. object_extension: 'objectExtensions', }; diff --git a/packages/lint/src/validate-security-posture.runtime-surface.test.ts b/packages/lint/src/validate-security-posture.runtime-surface.test.ts index b65a553f4ce..39226eb5871 100644 --- a/packages/lint/src/validate-security-posture.runtime-surface.test.ts +++ b/packages/lint/src/validate-security-posture.runtime-surface.test.ts @@ -568,7 +568,7 @@ describe('validateSecurityPosture at the runtime publish surface (#7576 → #830 expect(stackKeyForType('object_extension')).toBe('objectExtensions'); // [#33217] The validation-rule artifact checks (regex, JSON schema) cross on it too. expect(runtimeAuthoringRulesFor('object_extension').map((r) => r.name)) - .toEqual(['validateStackExpressions', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); + .toEqual(['validateStackExpressions', 'lintDuplicateFieldLabels', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); const roleSelect = { type: 'select', label: 'Group Function', options: [{ value: 'l1', label: 'Tier 1' }] }; const refused = runRuntimeAuthoringRules({ @@ -583,7 +583,7 @@ describe('validateSecurityPosture at the runtime publish surface (#7576 → #830 // positional and names it. expect(refused.errors[0].path).toBe('objectExtensions[0].fields.role.name'); expect(refused.errors[0].where).toBe('field "sd_agent.role"'); - expect(refused.rulesRun).toEqual(['validateStackExpressions', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); + expect(refused.rulesRun).toEqual(['validateStackExpressions', 'lintDuplicateFieldLabels', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); // The two labels the entry serves, at the same door. const labelled = runRuntimeAuthoringRules({ @@ -603,7 +603,7 @@ describe('validateSecurityPosture at the runtime publish surface (#7576 → #830 }); expect(clean.errors).toEqual([]); expect(clean.advisories).toEqual([]); - expect(clean.rulesRun).toEqual(['validateStackExpressions', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); + expect(clean.rulesRun).toEqual(['validateStackExpressions', 'lintDuplicateFieldLabels', 'validateSecurityRoleWord', 'validateRuleCompilability', 'validateRuleSchemaFormats']); // Not a context row: the baseline carries no `objectExtensions`, and the // candidate holds exactly the written item. From 315696ed817ba5b7da867cbbaf23854abd383e18 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 19:21:33 +0000 Subject: [PATCH 2/6] feat(lint): keep the published signature; semantic entry, changeset and docs for the extension door Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE Co-authored-by: Claude --- ...4-object-extension-door-label-duplicate.md | 23 ++++++++++ .../docs/deployment/validating-metadata.mdx | 5 ++- packages/lint/src/authoring-rules.ts | 7 +-- .../lint/src/lint-duplicate-field-labels.ts | 11 ++++- ...sion-door-field-label-duplicate-refused.ts | 43 +++++++++++++++++++ 5 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 .changeset/33644-object-extension-door-label-duplicate.md create mode 100644 packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts diff --git a/.changeset/33644-object-extension-door-label-duplicate.md b/.changeset/33644-object-extension-door-label-duplicate.md new file mode 100644 index 00000000000..94337340e8d --- /dev/null +++ b/.changeset/33644-object-extension-door-label-duplicate.md @@ -0,0 +1,23 @@ +--- +'@objectstack/lint': minor +'@objectstack/spec': minor +--- + +fix(lint): the runtime `object_extension` publish door refuses an extension that adds a field under a label the object it extends already shows (`field-label-duplicate`) + +Clause-②: no (narrowing) — the `object_extension` publish door (Studio's add-field on a `.custom` pair, `PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) now refuses an extension whose fields create a `field-label-duplicate` clash on the object it extends. No exported type or signature changes. Measured first-party: the two extension entries (`examples/app-showcase` on `showcase_account`, three fields; `packages/plugins/plugin-auth` on `sys_sso_provider`, one `secret` field) add no clash, as written or in any locale, so nothing first-party is newly refused. HotCRM: not measured. +Metadata-protocol: narrowed +Skills-docs: none owed — this PR edits `content/docs/deployment/validating-metadata.mdx` (the object extension door paragraph names the rule); `os explain field-label-duplicate` names the door; `skills/objectstack-data` teaches `defineObjectExtension({ extend, fields })` and reusing `owner_id` instead of a second owner field without saying the runtime door is exempt, so the door now gives the verdict the build already gives. + + + +**BREAKING** accept-set narrowing of the runtime `object_extension` publish door (`lintDuplicateFieldLabels` joins its `runtimeTypes`). + +`os build`, `os validate` and `os lint` refuse an object whose visible fields share one label, extension fields of the same stack folded in, and the publish door refused it on an `object` write. An `object_extension` write ran no such judgment, so an extension could add a field under a label its target already shows (a `user` field labelled 负责人 beside the injected `owner_id`, which a `zh-CN` reader is served as 负责人) and publish with a 200: two columns of one name in every grid, card and form of the object. + +- On an `object_extension` write the rule judges the target as it will be served after the write: the door's live target without the package's own stored extension (which the write replaces), the written entry folded in among the target's other packages' extensions by priority, as `os build` folds every package's entry. A field two packages add at the priority that decides it is left out, as at the build. The injected columns are read as the platform's, so the finding names `owner_id` as the platform's column. +- A refusal is the gate's `422 INVALID_METADATA` with issue rule `field-label-duplicate`, located on the extended object (`objects.TARGET.fields`), naming the object, every field of the group, the shared label and, when only some locales clash, those locales: the message the build gives for the same entry. +- The gate's differential charges the write only with a clash its entry creates: a clash the target already carries is not the extension's to answer for, while an entry that joins one changes the group and is refused. +- Unchanged: the object save door, `os build`, `os validate`, `os lint`, a draft save (never gated), and a stored extension, which is served and is judged only when it is published again. + +Migration: before publishing an extension again, give each field it adds a label the extended object does not already show (in the translation bundle too, when only a translation clashes), set `hidden: true` on it, or drop it and use the field the object already has (the platform's `owner_id` for an owner). Upgrade-guide entry `object-extension-door-field-label-duplicate-refused`. diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx index c88c83202c1..842cbbda8bc 100644 --- a/content/docs/deployment/validating-metadata.mdx +++ b/content/docs/deployment/validating-metadata.mdx @@ -629,7 +629,10 @@ every package's entry (#33494), so both judge the same definition of each field: the written entry's where its priority decides the field (a name the target already serves included), another package's where that one outranks it. On a declared object neither judges a field two packages add at the priority -that decides it. +that decides it. A field the entry adds under a label the target already shows, +the platform's `owner_id` included, is refused as `field-label-duplicate` +(#33644), judged on the target as it will be served after the write, so only a +clash the entry creates is charged and one the target already carried is not. **Declared enforcement that cannot run** is two rows for the mirror-image reason, and #4716 is where it split. That heading covers four rule ids, and diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index 7de75ecd751..c180204de8c 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -157,7 +157,7 @@ import { lintConnectorCredentialLiterals } from './lint-connector-credential-lit import { lintLivenessProperties } from './lint-liveness-properties.js'; import { lintAutonumberFormats } from './lint-autonumber-formats.js'; import { lintViewRefs } from './lint-view-refs.js'; -import { lintDuplicateFieldLabels } from './lint-duplicate-field-labels.js'; +import { duplicateFieldLabelFindings } from './lint-duplicate-field-labels.js'; import { validateRetiredPermissionResidue } from './validate-retired-permission-residue.js'; import { validateEmailTemplateHolePlacements } from './validate-email-template-hole-placements.js'; import { validateEmailTemplateHoleGrammar } from './validate-email-template-hole-grammar.js'; @@ -372,7 +372,8 @@ export interface AuthoringRuleContext { * the door judges the definition the build judges: * `validateStackExpressions`' extension walk * (`StackExpressionOptions.storedObjectExtensions`) and (#33644) - * `lintDuplicateFieldLabels` (`DuplicateFieldLabelOptions`). + * `lintDuplicateFieldLabels` (`DuplicateFieldLabelOptions`, read by the + * module-internal `duplicateFieldLabelFindings`). */ storedObjectExtensions?: readonly StoredObjectExtension[]; /** @@ -2400,7 +2401,7 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ surfaces: CLI_AND_RUNTIME, runtimeTypes: ['object', 'object_extension'], run: (stack, ctx) => - lintDuplicateFieldLabels(stack, { + duplicateFieldLabelFindings(stack, { ...(ctx.storedObjectExtensions !== undefined ? { storedObjectExtensions: ctx.storedObjectExtensions } : {}), ...(ctx.runtimeWriteType === 'object_extension' ? { servedObjects: true } : {}), }).map((f) => ({ diff --git a/packages/lint/src/lint-duplicate-field-labels.ts b/packages/lint/src/lint-duplicate-field-labels.ts index 0274137a6d2..0a42c78a62f 100644 --- a/packages/lint/src/lint-duplicate-field-labels.ts +++ b/packages/lint/src/lint-duplicate-field-labels.ts @@ -203,7 +203,16 @@ export interface DuplicateFieldLabelOptions { * Report every object that serves two or more visible fields under one label. * Returns a (possibly empty) list of findings; never throws. */ -export function lintDuplicateFieldLabels( +export function lintDuplicateFieldLabels(stack: AnyRec): DuplicateFieldLabelFinding[] { + return duplicateFieldLabelFindings(stack); +} + +/** + * {@link lintDuplicateFieldLabels} with what the `object_extension` publish + * door states beyond the stack. The registry entry calls this; it is not on + * the package's entries, so the published signature is unchanged. + */ +export function duplicateFieldLabelFindings( stack: AnyRec, options: DuplicateFieldLabelOptions = {}, ): DuplicateFieldLabelFinding[] { diff --git a/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts new file mode 100644 index 00000000000..df2fd66b0f9 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts @@ -0,0 +1,43 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// #33644: an accept-set narrowing of the runtime `object_extension` publish +// door. `field-label-duplicate` (`object-field-label-duplicate-refused`) +// judged `object` writes only, so an extension published at runtime (Studio's +// add-field on a `.custom` pair, `PUT /api/v1/meta/object_extension/TARGET`, +// an MCP or AI author) could add a field under a label the object it extends +// already shows, `owner_id` included. It now asks the same question there. No +// D2 conversion: which field keeps the label is the author's choice and is +// not recorded anywhere, and a stored row is not re-judged until it is +// published again. +export const entry: SemanticMigration = { + id: 'object-extension-door-field-label-duplicate-refused', + surface: + 'an `object_extension` item published at runtime (Studio\'s add-field on a `.custom` pair, ' + + '`PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) whose `fields` add a visible ' + + 'field under a label the extended object already shows, as written or in a locale a reader is served, ' + + 'e.g. `{ extend: \'crm_ticket\', fields: { assignee__c: { type: \'user\', label: \'负责人\' } } }` beside the ' + + 'injected `owner_id`, which a `zh-CN` reader is served as 负责人.', + replacement: + 'Give the extension\'s field its own label (in the translation bundle too, when only a translation clashes), ' + + 'set `hidden: true` on it, or drop it and use the field the object already shows (the platform\'s ' + + '`owner_id` for an owner). The door refuses the shape as `field-label-duplicate` (`422 INVALID_METADATA`, ' + + 'located on the extended object, `objects.TARGET.fields`), naming the object, every field of the group and ' + + 'the shared label.', + reason: + 'The registry folds an extension\'s fields onto the object it extends, so a field it adds under a label the ' + + 'object already shows is a second column of that name in every grid, card and form of the object, and ' + + 'editing one reads as editing the other. `os build` and `os validate` refuse it when the stack declares the ' + + 'object; the publish door ran the rule on `object` writes only, so the same entry published with a 200. The ' + + 'door now judges the object as it will be served after the write: the entry folded in among the object\'s ' + + 'other packages\' extensions by priority, without the package\'s own stored extension, which the write ' + + 'replaces. Only a clash the entry creates is charged; one the object already carried is not the ' + + 'extension\'s to answer for. Measured at the change: the two first-party entries (`examples/app-showcase` ' + + 'on `showcase_account`, `plugin-auth` on `sys_sso_provider`) add no clash. ADR-0087.', + acceptanceCriteria: + 'Publish each extension again: the publish answers 200 with no `field-label-duplicate` issue, and every ' + + 'visible field of the extended object reads under its own label as written and in every locale the platform ' + + 'translates. An extension already stored in the shape keeps being served; its next publish is refused until ' + + 'the field is relabelled, hidden or dropped.', +}; From 36843a361fc2c4f3ad3c94c44ead53b15fecbdf1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:54:02 +0000 Subject: [PATCH 3/6] fix(lint): an extension write is not charged for what is left of a clash it shrank The door's differential compares whole messages, which name every member of a label group, so an entry that took a member out of a clash the target already served read as a new clash. On an object_extension write the rule now leaves out a group every member of which already shared the label on the target without the entry. Pins the shrink cases and the stored-extension target save; corrects the first-party count and the translation remedy. Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE Co-authored-by: Claude --- packages/lint/src/authoring-rules.ts | 18 ++- .../lint/src/lint-duplicate-field-labels.ts | 103 ++++++++++++------ packages/lint/src/rule-explanations.ts | 3 +- .../src/runtime-gate.object-writes.test.ts | 51 +++++++++ 4 files changed, 137 insertions(+), 38 deletions(-) diff --git a/packages/lint/src/authoring-rules.ts b/packages/lint/src/authoring-rules.ts index c180204de8c..4fdaeb8a8ee 100644 --- a/packages/lint/src/authoring-rules.ts +++ b/packages/lint/src/authoring-rules.ts @@ -361,7 +361,9 @@ export interface AuthoringRuleContext { * argument `validateStackExpressions` gives for the same write: there the * snapshot's objects are the registry's served definitions, carrying the * injected columns as declared fields, so the rule reads them back to the - * authored shape the build judges (`stripInjectedSystemColumns`). + * authored shape the build judges (`stripInjectedSystemColumns`); and it + * leaves out a label group every member of which already shared the label on + * the target without the written entry, a clash the entry did not create. */ runtimeWriteType?: string; /** @@ -2388,10 +2390,14 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ // packages' extensions by priority (`storedObjectExtensions`, the build's // fold) and reads the served objects back to their authored shape // (`runtimeWriteType`, the expression rule's argument for the same input). - // The differential charges the write with the clash its entry creates and - // nothing the target already carried. MEASURED first: the one first-party - // `objectExtensions` entry (app-showcase's `showcase_account` overlay) adds - // no clash, as written or in any locale. + // The write is charged with the clash its entry creates and nothing the + // target already carried: the gate's differential cancels an unchanged + // group, and the rule itself drops a group every member of which already + // shared the label on the target (one the entry shrank by taking a member + // out), whose message the baseline cannot hold. MEASURED first: the two + // first-party `objectExtensions` entries (app-showcase's `showcase_account` + // overlay, plugin-auth's `sys_sso_provider` secret) add no clash, as + // written or in any locale. { name: 'lintDuplicateFieldLabels', tier: 'gating', @@ -2403,7 +2409,7 @@ export const AUTHORING_RULES: readonly AuthoringRule[] = [ run: (stack, ctx) => duplicateFieldLabelFindings(stack, { ...(ctx.storedObjectExtensions !== undefined ? { storedObjectExtensions: ctx.storedObjectExtensions } : {}), - ...(ctx.runtimeWriteType === 'object_extension' ? { servedObjects: true } : {}), + ...(ctx.runtimeWriteType === 'object_extension' ? { extensionWrite: true } : {}), }).map((f) => ({ severity: f.severity, rule: f.rule, diff --git a/packages/lint/src/lint-duplicate-field-labels.ts b/packages/lint/src/lint-duplicate-field-labels.ts index 0a42c78a62f..233725edf53 100644 --- a/packages/lint/src/lint-duplicate-field-labels.ts +++ b/packages/lint/src/lint-duplicate-field-labels.ts @@ -76,9 +76,16 @@ * field two packages tie on is left out as the build leaves it out, and the * injected columns read back to the platform's own definitions * (`stripInjectedSystemColumns`, as the expression rule reads the served - * objects there), so `owner_id` is named as the platform's column. The gate's - * differential charges the write only with a clash its entry creates: a clash - * the target already carried is in the baseline too, with the same message. + * objects there), so `owner_id` is named as the platform's column. The write + * is charged only with a clash its entry creates: a clash the target already + * carried is in the gate's baseline too, with the same message, and a group + * every member of which already shared the label on the target (what is left + * of a clash after the entry took a member out, by a new label, `hidden: true` + * or a tie at the deciding priority) is not reported, since its message names + * fewer fields than the baseline's and would otherwise read as new. The door + * carries no `translations`, so it compares the authored labels and the + * platform's own translations of its columns only; a clash a translation + * bundle creates is the build's to find. */ import { @@ -192,11 +199,13 @@ export interface DuplicateFieldLabelOptions { */ storedObjectExtensions?: readonly StoredObjectExtension[]; /** - * The objects are the registry's SERVED definitions, carrying the injected - * columns as declared fields: read them back to the authored shape first. - * Set by the door on an `object_extension` write only. + * The publish door's `object_extension` write: the objects are the + * registry's SERVED definitions (the injected columns carried as declared + * fields), read back to the authored shape first; and a group the written + * entry did not create (every member already shared the label on the + * target) is not reported. Set by the door on that write only. */ - servedObjects?: boolean; + extensionWrite?: boolean; } /** @@ -207,6 +216,38 @@ export function lintDuplicateFieldLabels(stack: AnyRec): DuplicateFieldLabelFind return duplicateFieldLabelFindings(stack); } +/** + * One object's clashing label groups per pass (the authored pass, then each + * locale), over `servedObj`'s fields with the injected columns beneath them. + */ +function clashPassesOf( + obj: AnyRec, + objectName: string, + servedObj: AnyRec | undefined, + bundle: TranslationBundle, +): { injectedNames: Set; passes: Map> } { + // The injected columns first, so an authored field of the same name + // replaces the platform's definition, as it does at registration. + const fields: Record = {}; + const injectedNames = new Set(); + for (const [name, def] of injectedColumnDefsFor(obj)) { + fields[name] = { ...def }; + injectedNames.add(name); + } + for (const f of recordsOf(servedObj?.fields)) { + if (typeof f.name !== 'string') continue; + fields[f.name] = f; + injectedNames.delete(f.name); + } + const passes = new Map>(); + passes.set(AUTHORED, clashes(visibleLabels(fields))); + for (const locale of localesOf(bundle)) { + const doc = translateObject({ name: objectName, fields } as ObjectLike, bundle, { locale }); + passes.set(locale, clashes(visibleLabels((doc.fields ?? {}) as Record))); + } + return { injectedNames, passes }; +} + /** * {@link lintDuplicateFieldLabels} with what the `object_extension` publish * door states beyond the stack. The registry entry calls this; it is not on @@ -218,47 +259,47 @@ export function duplicateFieldLabelFindings( ): DuplicateFieldLabelFinding[] { const findings: DuplicateFieldLabelFinding[] = []; if (!isRec(stack)) return findings; - if (options.servedObjects === true) { + const extensionWrite = options.extensionWrite === true; + if (extensionWrite) { stack = { ...stack, objects: recordsOf(stack.objects).map((o) => stripInjectedSystemColumns(o)) }; } + const stored = options.storedObjectExtensions ?? []; const declared = recordsOf(stack.objects); - const served = objectsWithoutTiedFields(objectsAsServed(stack, options.storedObjectExtensions ?? [])); + const served = objectsWithoutTiedFields(objectsAsServed(stack, stored)); + // On an extension write, each target as served WITHOUT the written entry: + // the same objects and stored extensions, no `objectExtensions` of the + // stack's own. Index-aligned with `declared` (the fold maps one to one). + const before = extensionWrite + ? objectsWithoutTiedFields(objectsAsServed({ objects: stack.objects }, stored)) + : undefined; declared.forEach((obj, i) => { const objectName = typeof obj.name === 'string' ? obj.name : undefined; if (!objectName) return; - // The injected columns first, so an authored field of the same name - // replaces the platform's definition, as it does at registration. - const fields: Record = {}; - const injectedNames = new Set(); - for (const [name, def] of injectedColumnDefsFor(obj)) { - fields[name] = { ...def }; - injectedNames.add(name); - } - for (const f of recordsOf(served[i]?.fields)) { - if (typeof f.name !== 'string') continue; - fields[f.name] = f; - injectedNames.delete(f.name); - } - const bundle = fieldBundleFor(stack, objectName); + const { injectedNames, passes: candidatePasses } = clashPassesOf(obj, objectName, served[i], bundle); + const beforePasses = before ? clashPassesOf(obj, objectName, before[i], bundle).passes : undefined; + // group key (sorted field names + label) → the passes it clashes in. const groups = new Map(); - const record = (pass: string, labels: ReadonlyMap): void => { - for (const [label, names] of clashes(labels)) { + for (const [pass, clashing] of candidatePasses) { + for (const [label, names] of clashing) { + // [#33644] On an extension write a group every member of which + // already shared this label on the target in this pass is no clash + // the entry created: it is the target's own, or what is left of it + // after the entry took a member out (relabelled, hidden, or tied at + // the deciding priority). The gate's differential compares whole + // messages, which name every member, so a shrunken group would + // otherwise read as new. + const prior = beforePasses?.get(pass)?.get(label); + if (prior && names.every((n) => prior.includes(n))) continue; const sorted = [...names].sort(); const key = `${sorted.join('\u0000')}\u0001${label}`; const group = groups.get(key) ?? { names: sorted, label, passes: [] }; group.passes.push(pass); groups.set(key, group); } - }; - - record(AUTHORED, visibleLabels(fields)); - for (const locale of localesOf(bundle)) { - const doc = translateObject({ name: objectName, fields } as ObjectLike, bundle, { locale }); - record(locale, visibleLabels((doc.fields ?? {}) as Record)); } for (const { names, label, passes } of groups.values()) { diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 538a3fd389d..3f0150e4bb1 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -6167,7 +6167,8 @@ const FIELD_LABEL_DUPLICATE_EXPLANATION: RuleExplanation = { 'another object is never refused for a clash a stored object carries, while saving the object itself is ' + 'refused until its clash is fixed. An `object_extension` publish is refused for a clash the fields it ' + 'adds create on the object it extends, judged on that object as it will be served, and never for one ' + - 'the object already carried. Nothing on the boot path runs the rule, so an installed app keeps ' + + 'the object already carried, nor for what is left of one after the extension took a field out of it. ' + + 'Nothing on the boot path runs the rule, so an installed app keeps ' + 'loading. To fix it, give each ' + 'visible field its own label (in the translation bundle too, when only a translation clashes), set ' + '`hidden: true` on the field readers should not see, or drop the duplicate and use the platform\'s column.', diff --git a/packages/lint/src/runtime-gate.object-writes.test.ts b/packages/lint/src/runtime-gate.object-writes.test.ts index 88c2dac074c..be24b6bd461 100644 --- a/packages/lint/src/runtime-gate.object-writes.test.ts +++ b/packages/lint/src/runtime-gate.object-writes.test.ts @@ -763,6 +763,57 @@ describe('the object_extension door refuses an extension that adds a field under const winning = ext({ region: { type: 'text', label: 'Subject' } }, { priority: 210 }); expect(labelErrors(gateExtension(winning, [servedWithOther], [other]))).toHaveLength(1); }); + + it('an entry that takes a member out of a clash the target already serves is not charged for what is left', () => { + // The target serves `subject` and `topic` under `Subject`, and another + // package's extension adds `region` under `Subject` too: one group of three. + const clashing = { ...TARGET, fields: { ...TARGET.fields, topic: { type: 'text', label: 'Subject' } } }; + const other = { extend: 'xl_ticket', fields: { region: { type: 'text', label: 'Subject' } } }; + const servedClash = served({ ...clashing, fields: { ...clashing.fields, region: other.fields.region } }); + // The control: the three-member group is real, at the build. + expect(atBuild({ objects: [clashing], objectExtensions: [other] })).toEqual([ + expect.stringContaining("'region', 'subject' and 'topic' under one label \"Subject\""), + ]); + for (const item of [ + ext({ region: { type: 'text', label: 'Region' } }, { priority: 210 }), + ext({ region: { type: 'text', label: 'Subject', hidden: true } }, { priority: 210 }), + // A tie at the deciding priority leaves `region` out of the comparison. + ext({ region: { type: 'text', label: 'Region' } }), + ]) { + const result = gateExtension(item, [servedClash], [other]); + expect(result.rulesRun).toContain('lintDuplicateFieldLabels'); + // `'subject' and 'topic'` is the target's own clash, smaller now. + expect(labelErrors(result), JSON.stringify(result.errors)).toEqual([]); + } + // Taking `region` out and putting a new field in under the label is a + // clash the entry creates, and is charged. + const swaps = labelErrors(gateExtension( + ext({ region: { type: 'text', label: 'Region' }, headline: { type: 'text', label: 'Subject' } }, { priority: 210 }), + [servedClash], + [other], + )); + expect(swaps).toHaveLength(1); + expect(swaps[0]!.message).toContain("'headline', 'subject' and 'topic' under one label \"Subject\""); + }); + + it('a clashing extension already stored is not charged to the target\'s own object save; the build reports it on the target', () => { + const stored = { extend: 'xl_ticket', fields: { assignee: { type: 'user', label: '负责人' } } }; + // Stored before the door judged extensions: the registry serves its field + // on the target. + const servedWithStored = served({ ...TARGET, fields: { ...TARGET.fields, assignee: stored.fields.assignee } }); + const save = runRuntimeAuthoringRules({ + type: 'object', + item: { ...TARGET, description: 'edited' }, + context: { objects: [servedWithStored] }, + }); + expect(save.rulesRun).toContain('lintDuplicateFieldLabels'); + // The save is judged on the body it sends, which carries no extension field. + expect(save.errors, JSON.stringify(save.errors)).toEqual([]); + // At the build the stack's extension folds onto the declared target, and + // the clash is reported there. + const built = lintDuplicateFieldLabels({ objects: [TARGET], objectExtensions: [stored] }); + expect(built.map((f) => f.where)).toEqual(['object "xl_ticket"']); + }); }); /** From c51fcc1d7ca1811bba1eb5f777a5aa842fab9867 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 20:54:28 +0000 Subject: [PATCH 4/6] docs(spec): the extension door's remedy reads no translation bundle Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE Co-authored-by: Claude --- ...33644-object-extension-door-label-duplicate.md | 4 ++-- content/docs/deployment/validating-metadata.mdx | 3 ++- ...xtension-door-field-label-duplicate-refused.ts | 15 ++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.changeset/33644-object-extension-door-label-duplicate.md b/.changeset/33644-object-extension-door-label-duplicate.md index 94337340e8d..e7890161350 100644 --- a/.changeset/33644-object-extension-door-label-duplicate.md +++ b/.changeset/33644-object-extension-door-label-duplicate.md @@ -17,7 +17,7 @@ Skills-docs: none owed — this PR edits `content/docs/deployment/validating-met - On an `object_extension` write the rule judges the target as it will be served after the write: the door's live target without the package's own stored extension (which the write replaces), the written entry folded in among the target's other packages' extensions by priority, as `os build` folds every package's entry. A field two packages add at the priority that decides it is left out, as at the build. The injected columns are read as the platform's, so the finding names `owner_id` as the platform's column. - A refusal is the gate's `422 INVALID_METADATA` with issue rule `field-label-duplicate`, located on the extended object (`objects.TARGET.fields`), naming the object, every field of the group, the shared label and, when only some locales clash, those locales: the message the build gives for the same entry. -- The gate's differential charges the write only with a clash its entry creates: a clash the target already carries is not the extension's to answer for, while an entry that joins one changes the group and is refused. +- The write is charged only with a clash its entry creates: a clash the target already carries is not the extension's to answer for, nor is what is left of one after the entry took a field out of it (a new label, `hidden: true`, or a tie at the deciding priority); an entry that joins one changes the group and is refused. - Unchanged: the object save door, `os build`, `os validate`, `os lint`, a draft save (never gated), and a stored extension, which is served and is judged only when it is published again. -Migration: before publishing an extension again, give each field it adds a label the extended object does not already show (in the translation bundle too, when only a translation clashes), set `hidden: true` on it, or drop it and use the field the object already has (the platform's `owner_id` for an owner). Upgrade-guide entry `object-extension-door-field-label-duplicate-refused`. +Migration: before publishing an extension again, give each field it adds a label the extended object does not already show, set `hidden: true` on it, or drop it and use the field the object already has (the platform's `owner_id` for an owner). The door compares labels as written and as the platform translates its own columns; it reads no translation bundle, so a bundle edit neither raises nor clears a refusal there (`os build` and `os validate` judge the bundle). Upgrade-guide entry `object-extension-door-field-label-duplicate-refused`. diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx index 842cbbda8bc..b9c3b08b737 100644 --- a/content/docs/deployment/validating-metadata.mdx +++ b/content/docs/deployment/validating-metadata.mdx @@ -632,7 +632,8 @@ On a declared object neither judges a field two packages add at the priority that decides it. A field the entry adds under a label the target already shows, the platform's `owner_id` included, is refused as `field-label-duplicate` (#33644), judged on the target as it will be served after the write, so only a -clash the entry creates is charged and one the target already carried is not. +clash the entry creates is charged: not one the target already carried, nor +what is left of one after the entry took a field out of it. **Declared enforcement that cannot run** is two rows for the mirror-image reason, and #4716 is where it split. That heading covers four rule ids, and diff --git a/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts index df2fd66b0f9..0d27b4dbbf0 100644 --- a/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts @@ -20,11 +20,12 @@ export const entry: SemanticMigration = { + 'e.g. `{ extend: \'crm_ticket\', fields: { assignee__c: { type: \'user\', label: \'负责人\' } } }` beside the ' + 'injected `owner_id`, which a `zh-CN` reader is served as 负责人.', replacement: - 'Give the extension\'s field its own label (in the translation bundle too, when only a translation clashes), ' - + 'set `hidden: true` on it, or drop it and use the field the object already shows (the platform\'s ' - + '`owner_id` for an owner). The door refuses the shape as `field-label-duplicate` (`422 INVALID_METADATA`, ' - + 'located on the extended object, `objects.TARGET.fields`), naming the object, every field of the group and ' - + 'the shared label.', + 'Give the extension\'s field its own label, set `hidden: true` on it, or drop it and use the field the object ' + + 'already shows (the platform\'s `owner_id` for an owner). The door compares the labels as written and as the ' + + 'platform translates its own columns (`owner_id` reads 负责人 to a `zh-CN` reader); it reads no translation ' + + 'bundle, so a bundle edit neither raises nor clears a refusal there (`os build` and `os validate` judge the ' + + 'bundle). The door refuses the shape as `field-label-duplicate` (`422 INVALID_METADATA`, located on the ' + + 'extended object, `objects.TARGET.fields`), naming the object, every field of the group and the shared label.', reason: 'The registry folds an extension\'s fields onto the object it extends, so a field it adds under a label the ' + 'object already shows is a second column of that name in every grid, card and form of the object, and ' @@ -32,8 +33,8 @@ export const entry: SemanticMigration = { + 'object; the publish door ran the rule on `object` writes only, so the same entry published with a 200. The ' + 'door now judges the object as it will be served after the write: the entry folded in among the object\'s ' + 'other packages\' extensions by priority, without the package\'s own stored extension, which the write ' - + 'replaces. Only a clash the entry creates is charged; one the object already carried is not the ' - + 'extension\'s to answer for. Measured at the change: the two first-party entries (`examples/app-showcase` ' + + 'replaces. Only a clash the entry creates is charged; one the object already carried, or what is left of it ' + + 'after the entry took a field out, is not the extension\'s to answer for. Measured at the change: the two first-party entries (`examples/app-showcase` ' + 'on `showcase_account`, `plugin-auth` on `sys_sso_provider`) add no clash. ADR-0087.', acceptanceCriteria: 'Publish each extension again: the publish answers 200 with no `field-label-duplicate` issue, and every ' From 98cb74ae47a4b6caffabe0a8e62f5a905a14f207 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 21:23:31 +0000 Subject: [PATCH 5/6] test(runtime): the formula-door fixtures give each extension field a label of its own The extension door now refuses an entry that serves two visible fields under one label, so the fixtures that shared the helper's label F would be refused for that before the cycle they pin. Each field gets its own label; the assertions are unchanged. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE --- .../src/domains/meta-object-extension-item.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/runtime/src/domains/meta-object-extension-item.test.ts b/packages/runtime/src/domains/meta-object-extension-item.test.ts index 6800034e727..1e3e05c8a18 100644 --- a/packages/runtime/src/domains/meta-object-extension-item.test.ts +++ b/packages/runtime/src/domains/meta-object-extension-item.test.ts @@ -707,7 +707,7 @@ describe('[#33216] the publish door judges the one-hop leaf through a lookup the }); describe('[#33153] the publish door refuses a formula cycle the extension adds, as `os build` does', () => { - const formula = (expression: string) => ({ type: 'formula', label: 'F', expression, returnType: 'number' }); + const formula = (expression: string, label = 'F') => ({ type: 'formula', label, expression, returnType: 'number' }); const where = (field: string) => `object 'crm_account' · objectExtensions[0] · field '${field}' expression`; /** `os build`'s cycle findings at the extension, over the base as authored. */ const atBuild = (item: unknown) => { @@ -719,7 +719,7 @@ describe('[#33153] the publish door refuses a formula cycle the extension adds, for (const [label, fields, members] of [ ['a formula reading itself', { a__c: formula('record.a__c') }, ['a__c']], - ['two formulas reading each other', { a__c: formula('record.b__c'), b__c: formula('record.a__c') }, ['a__c', 'b__c']], + ['two formulas reading each other', { a__c: formula('record.b__c', 'A'), b__c: formula('record.a__c', 'B') }, ['a__c', 'b__c']], ] as const) { it(`⭐ LIT — ${label} is refused with the build's rule id and location on each member; no field is served`, async () => { const item = { extend: TARGET, fields }; @@ -739,7 +739,7 @@ describe('[#33153] the publish door refuses a formula cycle the extension adds, } it('⭐ CONTROL — a chain of formulas the extension adds publishes and is served', async () => { - const item = { extend: TARGET, fields: { b__c: formula('record.a__c * 2'), a__c: formula('1 + 1') } }; + const item = { extend: TARGET, fields: { b__c: formula('record.a__c * 2', 'B'), a__c: formula('1 + 1', 'A') } }; expect(atBuild(item)).toEqual([]); const rig = await boot(); @@ -750,7 +750,7 @@ describe('[#33153] the publish door refuses a formula cycle the extension adds, }); describe('[#33494] the publish door serves the winner `os build` serves when another package extends the same field', () => { - const formula = (expression: string) => ({ type: 'formula', label: 'F', expression, returnType: 'number' }); + const formula = (expression: string, label = 'F') => ({ type: 'formula', label, expression, returnType: 'number' }); const number = { type: 'number', label: 'Sibling' }; /** A third package, registered as an extender of the account at the priority given. */ const SIBLING = 'com.acme.sibling'; @@ -785,8 +785,8 @@ describe('[#33494] the publish door serves the winner `os build` serves when ano } it('⭐ LIT — a higher sibling\'s formula closing a cycle through the entry\'s other field is refused on that field, as `os build` refuses it', async () => { - const sibling = { s__c: formula('record.a__c + 1') }; - const item = { extend: TARGET, priority: 200, fields: { s__c: number, a__c: formula('record.s__c * 2') } }; + const sibling = { s__c: formula('record.a__c + 1', 'S') }; + const item = { extend: TARGET, priority: 200, fields: { s__c: number, a__c: formula('record.s__c * 2', 'A') } }; const where = "object 'crm_account' · objectExtensions[0] · field 'a__c' expression"; expect(atBuild(sibling, 300, item)).toContain(where.replace('objectExtensions[0]', 'packages[1].manifest.objectExtensions[0]')); From 4fa9c1cde6fea13918ad94c78e8a1b16e8a0bf74 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 22:31:45 +0000 Subject: [PATCH 6/6] fix(lint): the extension door names the same-entry clash and offers no translation bundle An extension whose own two fields share a label the target does not show is refused too; the semantic entry, changeset and docs now say so, and a door case pins it. On the extension door the hint drops the translation bundle remedy, since the door reads no bundle. The before-write snapshot is read only for the objects the written entry extends; verdicts are unchanged. Claude-Session: https://claude.ai/code/session_01ADHkmTKdZ14pCk23CyRWjE Co-authored-by: Claude --- ...4-object-extension-door-label-duplicate.md | 6 ++--- .../docs/deployment/validating-metadata.mdx | 4 +-- .../lint/src/lint-duplicate-field-labels.ts | 18 ++++++++++--- packages/lint/src/rule-explanations.ts | 5 ++-- .../src/runtime-gate.object-writes.test.ts | 26 +++++++++++++++++++ ...sion-door-field-label-duplicate-refused.ts | 9 ++++--- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/.changeset/33644-object-extension-door-label-duplicate.md b/.changeset/33644-object-extension-door-label-duplicate.md index e7890161350..ffa0d829bb3 100644 --- a/.changeset/33644-object-extension-door-label-duplicate.md +++ b/.changeset/33644-object-extension-door-label-duplicate.md @@ -3,7 +3,7 @@ '@objectstack/spec': minor --- -fix(lint): the runtime `object_extension` publish door refuses an extension that adds a field under a label the object it extends already shows (`field-label-duplicate`) +fix(lint): the runtime `object_extension` publish door refuses an extension that adds a field under a label the object it extends already shows, or under the label of another field of the same extension (`field-label-duplicate`) Clause-②: no (narrowing) — the `object_extension` publish door (Studio's add-field on a `.custom` pair, `PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) now refuses an extension whose fields create a `field-label-duplicate` clash on the object it extends. No exported type or signature changes. Measured first-party: the two extension entries (`examples/app-showcase` on `showcase_account`, three fields; `packages/plugins/plugin-auth` on `sys_sso_provider`, one `secret` field) add no clash, as written or in any locale, so nothing first-party is newly refused. HotCRM: not measured. Metadata-protocol: narrowed @@ -13,11 +13,11 @@ Skills-docs: none owed — this PR edits `content/docs/deployment/validating-met **BREAKING** accept-set narrowing of the runtime `object_extension` publish door (`lintDuplicateFieldLabels` joins its `runtimeTypes`). -`os build`, `os validate` and `os lint` refuse an object whose visible fields share one label, extension fields of the same stack folded in, and the publish door refused it on an `object` write. An `object_extension` write ran no such judgment, so an extension could add a field under a label its target already shows (a `user` field labelled 负责人 beside the injected `owner_id`, which a `zh-CN` reader is served as 负责人) and publish with a 200: two columns of one name in every grid, card and form of the object. +`os build`, `os validate` and `os lint` refuse an object whose visible fields share one label, extension fields of the same stack folded in, and the publish door refused it on an `object` write. An `object_extension` write ran no such judgment, so an extension could add a field under a label its target already shows (a `user` field labelled 负责人 beside the injected `owner_id`, which a `zh-CN` reader is served as 负责人), or two fields of its own under one label, and publish with a 200: two columns of one name in every grid, card and form of the object. - On an `object_extension` write the rule judges the target as it will be served after the write: the door's live target without the package's own stored extension (which the write replaces), the written entry folded in among the target's other packages' extensions by priority, as `os build` folds every package's entry. A field two packages add at the priority that decides it is left out, as at the build. The injected columns are read as the platform's, so the finding names `owner_id` as the platform's column. - A refusal is the gate's `422 INVALID_METADATA` with issue rule `field-label-duplicate`, located on the extended object (`objects.TARGET.fields`), naming the object, every field of the group, the shared label and, when only some locales clash, those locales: the message the build gives for the same entry. - The write is charged only with a clash its entry creates: a clash the target already carries is not the extension's to answer for, nor is what is left of one after the entry took a field out of it (a new label, `hidden: true`, or a tie at the deciding priority); an entry that joins one changes the group and is refused. - Unchanged: the object save door, `os build`, `os validate`, `os lint`, a draft save (never gated), and a stored extension, which is served and is judged only when it is published again. -Migration: before publishing an extension again, give each field it adds a label the extended object does not already show, set `hidden: true` on it, or drop it and use the field the object already has (the platform's `owner_id` for an owner). The door compares labels as written and as the platform translates its own columns; it reads no translation bundle, so a bundle edit neither raises nor clears a refusal there (`os build` and `os validate` judge the bundle). Upgrade-guide entry `object-extension-door-field-label-duplicate-refused`. +Migration: before publishing an extension again, give each field it adds a label the extended object does not already show and no other field of the same extension carries, set `hidden: true` on it, or drop it and use the field the object already has (the platform's `owner_id` for an owner). The door compares labels as written and as the platform translates its own columns; it reads no translation bundle, so a bundle edit neither raises nor clears a refusal there (`os build` and `os validate` judge the bundle). Upgrade-guide entry `object-extension-door-field-label-duplicate-refused`. diff --git a/content/docs/deployment/validating-metadata.mdx b/content/docs/deployment/validating-metadata.mdx index b9c3b08b737..ff349ada78d 100644 --- a/content/docs/deployment/validating-metadata.mdx +++ b/content/docs/deployment/validating-metadata.mdx @@ -630,8 +630,8 @@ field: the written entry's where its priority decides the field (a name the target already serves included), another package's where that one outranks it. On a declared object neither judges a field two packages add at the priority that decides it. A field the entry adds under a label the target already shows, -the platform's `owner_id` included, is refused as `field-label-duplicate` -(#33644), judged on the target as it will be served after the write, so only a +the platform's `owner_id` included, or under the label of another field of the +same entry, is refused as `field-label-duplicate` (#33644), judged on the target as it will be served after the write, so only a clash the entry creates is charged: not one the target already carried, nor what is left of one after the entry took a field out of it. diff --git a/packages/lint/src/lint-duplicate-field-labels.ts b/packages/lint/src/lint-duplicate-field-labels.ts index 233725edf53..0bc822ffb5c 100644 --- a/packages/lint/src/lint-duplicate-field-labels.ts +++ b/packages/lint/src/lint-duplicate-field-labels.ts @@ -67,7 +67,8 @@ * An extension published at runtime (Studio's add-field on a `.custom` pair, * the `/meta` doors, an MCP or AI author) adds fields to an object it does not * own, so it can add one under a label the target already shows, `owner_id` - * included. The door hands the gate the written entry as the stack's only + * included, or two of its own fields under one label the target does not + * show; both are refused. The door hands the gate the written entry as the stack's only * `objectExtensions` member and the live objects as the registry serves them, * the target without the written package's own stored extension (which the * write replaces), so the fold below judges the target as it will be served @@ -85,7 +86,7 @@ * fewer fields than the baseline's and would otherwise read as new. The door * carries no `translations`, so it compares the authored labels and the * platform's own translations of its columns only; a clash a translation - * bundle creates is the build's to find. + * bundle creates is the build's to find, and the hint offers no bundle. */ import { @@ -96,6 +97,7 @@ import { } from '@objectstack/spec/system'; import { stripInjectedSystemColumns } from '@objectstack/metadata-core'; import { + objectExtensionsByTarget, objectsAsServed, objectsWithoutTiedFields, recordsOf, @@ -269,9 +271,13 @@ export function duplicateFieldLabelFindings( // On an extension write, each target as served WITHOUT the written entry: // the same objects and stored extensions, no `objectExtensions` of the // stack's own. Index-aligned with `declared` (the fold maps one to one). + // Read only for the objects the written entry extends: any other object's + // clashes are the same before and after the write, and the gate's + // differential already leaves them uncharged. const before = extensionWrite ? objectsWithoutTiedFields(objectsAsServed({ objects: stack.objects }, stored)) : undefined; + const writtenTargets = extensionWrite ? new Set(objectExtensionsByTarget(stack).keys()) : undefined; declared.forEach((obj, i) => { const objectName = typeof obj.name === 'string' ? obj.name : undefined; @@ -279,7 +285,8 @@ export function duplicateFieldLabelFindings( const bundle = fieldBundleFor(stack, objectName); const { injectedNames, passes: candidatePasses } = clashPassesOf(obj, objectName, served[i], bundle); - const beforePasses = before ? clashPassesOf(obj, objectName, before[i], bundle).passes : undefined; + const beforePasses = + before && writtenTargets?.has(objectName) ? clashPassesOf(obj, objectName, before[i], bundle).passes : undefined; // group key (sorted field names + label) → the passes it clashes in. const groups = new Map(); @@ -323,7 +330,10 @@ export function duplicateFieldLabelFindings( : ''), hint: 'Give each visible field its own label' + - (authored ? '' : ' (in the translation bundle too, for a locale only a translation clashes in)') + + // The extension door reads no translation bundle (the clash it finds + // in a locale is the platform's own translation), so its hint + // offers none: a bundle is judged at `os build` / `os validate`. + (authored || extensionWrite ? '' : ' (in the translation bundle too, for a locale only a translation clashes in)') + ', or set `hidden: true` on the one readers should not see, or drop the duplicate field' + (injected.length > 0 ? ` and use the platform's ${quoteList(injected)} instead of declaring a second field for the same thing.` diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 3f0150e4bb1..e2b162fc639 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -6166,11 +6166,12 @@ const FIELD_LABEL_DUPLICATE_EXPLANATION: RuleExplanation = { 'An error at `os build`, `os validate`, `os lint` and the metadata publish door. At the door a write of ' + 'another object is never refused for a clash a stored object carries, while saving the object itself is ' + 'refused until its clash is fixed. An `object_extension` publish is refused for a clash the fields it ' + - 'adds create on the object it extends, judged on that object as it will be served, and never for one ' + + 'adds create on the object it extends, two of its own fields included, judged on that object as it will be served, and never for one ' + 'the object already carried, nor for what is left of one after the extension took a field out of it. ' + 'Nothing on the boot path runs the rule, so an installed app keeps ' + 'loading. To fix it, give each ' + - 'visible field its own label (in the translation bundle too, when only a translation clashes), set ' + + 'visible field its own label (in the translation bundle too, when only a translation clashes; the publish ' + + 'door reads no bundle, the build does), set ' + '`hidden: true` on the field readers should not see, or drop the duplicate and use the platform\'s column.', ], }; diff --git a/packages/lint/src/runtime-gate.object-writes.test.ts b/packages/lint/src/runtime-gate.object-writes.test.ts index be24b6bd461..0b3e515dd5e 100644 --- a/packages/lint/src/runtime-gate.object-writes.test.ts +++ b/packages/lint/src/runtime-gate.object-writes.test.ts @@ -703,6 +703,32 @@ describe('the object_extension door refuses an extension that adds a field under expect(errs[0]!.message).toContain("object \"xl_ticket\" shows fields 'subject' and 'topic' under one label \"Subject\", so"); }); + it('⭐ LIT — an extension whose own two fields share a label the target does not show is REFUSED, naming both fields', () => { + const item = ext({ a__c: { type: 'number', label: 'Region' }, b__c: { type: 'text', label: 'Region' } }); + expect(TARGET.fields).not.toHaveProperty('region'); + const result = gateExtension(item); + const errs = labelErrors(result); + expect(errs, JSON.stringify(result.errors)).toHaveLength(1); + expect(errs[0]!.path).toBe('objects.xl_ticket.fields'); + expect(errs[0]!.message).toContain("object \"xl_ticket\" shows fields 'a__c' and 'b__c' under one label \"Region\", so"); + expect(atBuild({ objects: [TARGET], objectExtensions: [item] })).toEqual([errs[0]!.message]); + // The control: the same two fields under labels of their own publish. + const own = gateExtension(ext({ a__c: { type: 'number', label: 'Region' }, b__c: { type: 'text', label: 'Region code' } })); + expect(labelErrors(own), JSON.stringify(own.errors)).toEqual([]); + }); + + it('the door\'s hint offers no translation bundle for a clash only a locale shows (the door reads none); the build\'s still does', () => { + const item = ext({ assignee: { type: 'user', label: '负责人' } }); + const errs = labelErrors(gateExtension(item)); + expect(errs).toHaveLength(1); + expect(errs[0]!.message).toContain('when read in locale zh-CN'); + expect(errs[0]!.hint).not.toContain('translation bundle'); + expect(errs[0]!.hint).toContain('Give each visible field its own label'); + const build = lintDuplicateFieldLabels({ objects: [TARGET], objectExtensions: [item] }); + expect(build).toHaveLength(1); + expect(build[0]!.hint).toContain('(in the translation bundle too, for a locale only a translation clashes in)'); + }); + it('an unrelated extension write (a label of its own, or the clashing field hidden) is not charged (the controls)', () => { for (const item of [ ext({ escalation_level: { type: 'number', label: 'Escalation Level' } }), diff --git a/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts index 0d27b4dbbf0..5ec9c2db78b 100644 --- a/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts +++ b/packages/spec/src/migrations/entries/semantic/18.object-extension-door-field-label-duplicate-refused.ts @@ -7,7 +7,8 @@ import type { SemanticMigration } from '../../types.js'; // judged `object` writes only, so an extension published at runtime (Studio's // add-field on a `.custom` pair, `PUT /api/v1/meta/object_extension/TARGET`, // an MCP or AI author) could add a field under a label the object it extends -// already shows, `owner_id` included. It now asks the same question there. No +// already shows, `owner_id` included, or two fields of its own under one +// label. It now asks the same question there. No // D2 conversion: which field keeps the label is the author's choice and is // not recorded anywhere, and a stored row is not re-judged until it is // published again. @@ -16,11 +17,13 @@ export const entry: SemanticMigration = { surface: 'an `object_extension` item published at runtime (Studio\'s add-field on a `.custom` pair, ' + '`PUT /api/v1/meta/object_extension/TARGET`, the MCP and AI authoring doors) whose `fields` add a visible ' - + 'field under a label the extended object already shows, as written or in a locale a reader is served, ' + + 'field under a label the extended object already shows, or under the label of another field of the same ' + + 'extension, as written or in a locale a reader is served, ' + 'e.g. `{ extend: \'crm_ticket\', fields: { assignee__c: { type: \'user\', label: \'负责人\' } } }` beside the ' + 'injected `owner_id`, which a `zh-CN` reader is served as 负责人.', replacement: - 'Give the extension\'s field its own label, set `hidden: true` on it, or drop it and use the field the object ' + 'Give the extension\'s field a label of its own (one neither the object nor another field of the extension ' + + 'shows), set `hidden: true` on it, or drop it and use the field the object ' + 'already shows (the platform\'s `owner_id` for an owner). The door compares the labels as written and as the ' + 'platform translates its own columns (`owner_id` reads 负责人 to a `zh-CN` reader); it reads no translation ' + 'bundle, so a bundle edit neither raises nor clears a refusal there (`os build` and `os validate` judge the '