|
| 1 | +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | + |
| 3 | +import type { SemanticMigration } from '../../types.js'; |
| 4 | + |
| 5 | +// #29366: an object extension's `fieldPatches` is keyed by the key schema |
| 6 | +// `ObjectSchema.fields` reads. A semantic entry and not a conversion: the key |
| 7 | +// that was meant is the name of a field the target declares, and a rewrite of |
| 8 | +// the spelling (lower-casing, `-` to `_`) can land on a different field or on |
| 9 | +// none, so which field is the author's to name. |
| 10 | +export const entry: SemanticMigration = { |
| 11 | + id: 'object-extension-field-patch-key-grammar-refused', |
| 12 | + surface: |
| 13 | + '`objectExtensions[].fieldPatches` keys (`defineObjectExtension({ fieldPatches })`) that are not a ' |
| 14 | + + 'field name: any key outside the lowercase snake_case grammar of an object\'s `fields` keys, such as ' |
| 15 | + + 'a label (`Industry`, `Annual Revenue`) or a kebab spelling (`annual-revenue`).', |
| 16 | + replacement: |
| 17 | + 'The name of the field the extended object declares, the key of its `fields` entry: ' |
| 18 | + + '`fieldPatches: { industry: { label: \'Sector\' } }`, never `fieldPatches: { Industry: { … } }`.', |
| 19 | + reason: |
| 20 | + 'A field patch addresses one of the target\'s own fields by name, and every field name is lowercase ' |
| 21 | + + 'snake_case, so a key outside that grammar can never match a field. The schema used to take any ' |
| 22 | + + 'string, so such a patch parsed in `defineStack`, was stored by the `object_extension` save door, ' |
| 23 | + + 'and booted: the registry fold only named it in the log and applied nothing, and `os validate` ' |
| 24 | + + 'refused it only when the target object was part of the composed stack. The author read "Sector" ' |
| 25 | + + 'in their package while the screen kept the vendor\'s label. The key is now judged where it is ' |
| 26 | + + 'written, by the same key schema the field map uses.', |
| 27 | + acceptanceCriteria: |
| 28 | + 'Every `fieldPatches` key in the stack is the name of a field its `extend` target declares, and ' |
| 29 | + + '`os validate` passes. A key outside the grammar is refused at parse with one `invalid_key` issue ' |
| 30 | + + 'at `fieldPatches.KEY` that names the grammar and an example. A stored `object_extension` row whose ' |
| 31 | + + 'body still carries such a key no longer parses, so the sync that registers stored extensions names ' |
| 32 | + + 'the row (`INVALID_METADATA`) and registers none of it, its `fields` included, and its next save is ' |
| 33 | + + 'refused until the key is renamed to the field it meant.', |
| 34 | +}; |
0 commit comments