ObjectStackObjectStack

Object extensions — extend without forking

Add fields, validations and indexes to an object another package owns, or relabel its fields, without forking it — declaration, merge order, and what an extension may not contribute.

Every object has exactly one owning package. That package defines the table, the primary key and the core fields, and no second package may claim the same name — the registry refuses it outright.

An object extension is how a package contributes to an object it does not own. It declares fields, validations and indexes that are merged into the target at boot, and the result is indistinguishable from fields the owner had authored inline: the same DDL, the same forms and list views, the same API.

When to reach for one

SituationDo this
You need extra data on an object another package ships (sys_user, a CRM package's account)Object extension
You need a new business entity of your ownDefine your own object
Your deployment needs a field on an object an installed package shipsAn object extension in that package's paired .custom package, the field named <name>__c — below
You need an action, hook, view or page on someone else's objectDeclare that artifact at the top level and bind it to the target object — see below

Declaring one

Extensions are declared on the package, in the objectExtensions collection — never on the object schema. There is no extends: key on an object and no mixin mechanism.

import { defineObjectExtension, Field } from '@objectstack/spec/data';

export const AccountSuccessExtension = defineObjectExtension({
  extend: 'showcase_account',                  // the target object, owned elsewhere
  fields: {
    loyalty_tier: Field.select(['bronze', 'silver', 'gold'], { label: 'Loyalty Tier' }),
    csat_score: Field.number({ label: 'CSAT Score', min: 0, max: 100 }),
  },
  priority: 210,
});
export default defineStack({
  manifest: { /* … */ },
  objectExtensions: [AccountSuccessExtension],
});

The target object is owned by someone else, so defineStack() cannot verify it exists — there is nothing in your package to check the name against. A typo therefore survives the build and surfaces at boot instead, as a warning that the name has extenders but no owner; the object is then skipped entirely. If an extension's fields never appear, check that spelling first.


What an extension may contribute

KeyMerge behaviour
fieldsAdditive. Merged into the target's field map. A name the target already has is replaced, not merged — never in a .custom package, whose added fields all end in __c.
fieldPatchesApplied, field by field. Changes the display of one of the target's own fields — never one an extension adds — without replacing it — below.
validationsConcatenated. Your rules run alongside the owner's; neither replaces the other.
indexesConcatenated, same as validations.
labelReplaces the target's label — with one exception, below. A new label with no pluralLabel beside it also takes the target's plural off, since that plural names the old label: the object is served as one that declares no plural, and lists title it by its label. Set pluralLabel too to serve one. A plural the tenant set stays.
pluralLabelSame as label.
descriptionSame as label.
placeApplied once, after every extension's fields are merged. Says where the fields, groups and child lists this extension brings go on the target — below.
fieldGroups, relatedListsOnly in a base's paired .custom package. Each replaces, whole. The complete field arrangement and the complete tab list of the target, applied last — below. In any other package they are refused, and place is the key to use.
actionLayoutOnly in a base's paired .custom package. Applied arm by arm, last. Each list or record arm it writes ({ pinned, more }) replaces the arm the target serves for that scope whole; an arm it leaves out stays. In any other package it is refused, and an action the package brings is placed by its own locations and order. See choosing the header's buttons.
priorityNot merged — it orders the merge. 0–999, default 200.

Added fields are ordinary fields, so everything on the field reference applies: types, validation, required, group, formulas, and lookups back to your own objects.

What an extension may not contribute

The merge carries the keys above and nothing else. The first three below are not "unsupported yet" — there is no slot for them to arrive through, and the schema rejects each one by name with the alternative to use instead. The last two are the paired .custom package's alone: in any other package the save, publish and install doors, os validate and os build refuse them, naming place:

Key you might reach forDeclare this instead
actionsA top-level action with objectName: '<target>' in the same stack — it stays in the stack's top-level actions, and the engine's schema registry attaches it to the target object wherever the object is served, whichever package registers first; a target no loaded package registers fails the boot
hooksA top-level hook in the stack that defines the target object — a hook follows the ownership of its object, and defineStack() refuses a top-level hook bound to an object the stack does not define, an extended one included
listViewsA top-level view in the stack that defines the target object — defineStack() refuses a top-level view whose list or form data source is an object the stack does not define, an extended one included
fieldGroups (outside a .custom package)A place entry: { group: { key, label }, after: '<group>' } adds a group of your own, and { field, group, after: '<field>' } puts a field of yours into one of the target's groups — below
relatedLists (outside a .custom package)A place entry { list, after: '<tab>' } for a child object of your own package that points at the target — below. The target's own tab list stays its owner's, and the environment's

The same holds for any other key: the extension schema is strict, so an unknown key fails at authoring time with a prescription rather than being dropped in silence.


Placing what you bring

Without place, the fields you add arrive after the target's own, and a child list of yours shows wherever the record page's automatic order puts it. place names the item each one goes next to:

objectExtensions: [{
  extend: 'crm_account',
  fields: { tax_id: { type: 'text', label: 'Tax ID' } },
  place: [
    { field: 'tax_id', group: 'basic', after: 'industry' },
    { group: { key: 'tax', label: 'Tax' }, after: 'basic' },
    { list: 'acme_contract', after: 'crm_opportunity', label: 'Contracts', columns: ['name', 'amount'] },
  ],
}],
  • { field, group, after | before } puts a field of your fields into a group of the target (or one you add), right after or before a member of that group.
  • { group: { key, label, … }, after | before } adds a field group of your own, right after or before one of the target's groups. Its fields may name only fields you add.
  • { list, after | before, label?, columns? } puts a child list of your own package (a child object of your package with a lookup to the target, or object.field) right after or before one of the target's tabs, with that tab's own title and columns (each column a field of the child, checked by os validate as a relatedLists entry's columns are).

Write after or before, not both; neither means the end. An anchor may be an item another placement brings, in whatever order the two are written or installed. An anchor nobody has puts the item at the end of its group, of the groups, or of the tabs (before the approvals and activity-stream tabs). Several packages at one anchor follow ascending priority, then package name. When the target's owner already names your list or lists your field, the owner's position wins.

Placement arranges what the target declares. A list placement applies when the target declares relatedLists; a group or field placement when it declares fieldGroups. On a target that declares neither, its automatic arrangement stays and nothing is dropped: your list shows in the automatic tab order (and the entry's label / columns are not applied either, so write relatedListTitle / relatedListColumns on your child object's lookup field to title the list on every parent), and your field shows among the fields, its after / before not applied. The boot log names each placement that did not apply, with the object and your package; os validate names it too when the target is in the same stack.

A child list your package brings is shown even when the target's relatedLists does not name it: placed, where you put it; unplaced, at the end of the tabs.

You place only what you bring. A field of the target or of another package (also one you redeclare to relabel it), a group key the target already declares, or a list (or a group placing one) that is not a child object of your package is refused at authoring time, and skipped by the merge with a warning naming whose item it is. Uninstalling or disabling your package takes its items off and leaves the target's own order as it was.


Relabelling a vendor field

Replacing a field through fields takes it over whole: its type, its options and its rules become yours, and the owner's next version no longer reaches it. To change only what a person reads — "Industry" shown as "Sector", a better help text — patch the field instead:

import { defineObjectExtension } from '@objectstack/spec/data';

export const AccountWordingExtension = defineObjectExtension({
  extend: 'crm_account',
  fieldPatches: {
    industry: {
      label: 'Sector',
      inlineHelpText: 'The market the account sells into.',
      // no `options` here: `industry` takes its options from a shared picklist
    },
    type: {
      options: { customer: { label: 'Client' } },   // addressed by the stored value
    },
  },
});

A patch sets label, description, inlineHelpText and placeholder on the field, and the label of an option it addresses by its stored value — the display whitelist (BASE_FIELD_DISPLAY_WHITELIST), and nothing else. The field's type, requiredness, default, formula and which options exist stay the owner's, so the owner's upgrades keep applying and stored values never change; any other key is refused by name with that reason.

  • Every read serves it. The patch is applied in the same merge as the other keys, after the additive ones, and the list, the by-name read and the layered view agree. Uninstalling the extension serves the owner's text again.
  • Translate it in your own package. A patched label, help text, description or option label is translated from the translations of the package that ships the patch, and from its translation rows, under the same keys as the owner's text: objects.crm_account.fields.industry.label, ….help for the help text (the description when the field has none), ….options.customer for an option. The owner's translation of the text the patch replaced never applies to it. On the /meta reads a pair .custom translation of that key still comes first, and a locale your package does not translate serves the patch's text as written.
  • It reaches the owner's own fields only. A field another extension adds — or one your own extension adds in fields — is not a patch target, whatever the priorities: set that field's text where it is declared. The install door and os validate refuse such a patch, and at boot it is not applied and is named once. The platform columns the runtime adds to every object (created_at and the rest) sit in the owner's stored declaration, so the install door admits a patch of one and every read applies it, while os validate, which reads the declaration you wrote, refuses it.
  • Patch it or take it over, not both. An extension that names one field in both fields and fieldPatches is refused when it parses: fields takes the owner's field over whole, so the patch would land on your own replacement and the owner's field would reach neither. Keep the patch to change only its display, or keep the fields entry and set the text there. An option is addressed by its stored value, so a key no value can be (Tech Sector, a label) is refused too.
  • Conflicts resolve like label. Two extensions patching the same key: the higher priority wins. A tenant who has edited that text keeps their own, below.
  • A patch must name something real. A key that cannot be a field name (Industry, Annual Revenue, a label) is refused when it parses: fieldPatches is keyed by the field's name, lowercase snake_case like every key of fields. A field the target does not declare, or an option value its field does not have, is refused when the package installs and by os validate when the target is in the same stack. A field whose options come from a shared picklist has no option labels of its own to patch. At boot, an unmatched patch is not applied and is named once in the log; the boot carries on.
  • Options are the owner's too. A patch is judged against the options the owner declares, everywhere: an option another extension (or your own) adds by replacing the field through fields, or one a tenant's customization adds, is not one a patch can name, so the install door and os validate refuse it and at boot it is not applied and is named once. If an earlier layer leaves out an option the owner declares, a patch of that option is admitted but has nothing to relabel, and the boot names it once.

Naming the fields you add

Each key of an extension's fields is a field name of the target, so it follows the grammar of the target's own fields keys: lowercase snake_case, such as region_code (region_code__c in a .custom package). A key outside it (Region Code, region-code, a label) is refused when the extension parses, at fields.<key>.

Field names in an extension are not namespace-prefixed by the platform. The namespace rule (<namespace>_<name>) governs the names of objects a package defines; it does not walk objectExtensions, and it could not — the target's name belongs to its owner, not to you.

Nothing therefore stops two packages from contributing the same field name to the same object: the merge is last-writer-wins by priority, so one of the two definitions is not served. The same goes for an extension whose fields redeclares a field the owner declares. Neither is refused; at boot the registry names each such field once in the log, with every package that declares it and the one whose definition is served. Name defensively — prefix added fields with something specific to your package when the name is at all generic.

The __c suffix is reserved to the customer. A field named <name>__c may be declared only by a base package's paired .custom package, below; in any other package, on its own objects or in its extensions, it is refused, so a vendor's next version can never take a customer's field name. The save, publish and restore doors, the install door, os validate and os build all refuse it, naming the field.


Customizing an installed package's object

A customer adds to an object an installed package ships — HotCRM's crm_account — from the base's paired customization package hotcrm.custom (ADR-0146 D10). The object is extended, never replaced:

  • Every field the pair adds to a base object ends in __c (region__c); an unsuffixed field in a .custom extension is refused with the suffixed name to use. A field the base declares is changed only through fieldPatches, above.
  • The extension is an item of the pair. In code it is an objectExtensions entry of the hotcrm.custom stack; at runtime it is an object_extension item saved into the pair (PUT /api/v1/meta/object_extension/crm_account?package=hotcrm.custom, the body ObjectExtensionSchema with extend), drafted, published and exported like any item. Studio's Add field on a read-only base object writes exactly that, creating the pair on first use.
  • An object takes no overrides declaration. Declaring one on an object is refused, naming the extension as the route.
  • The pair may arrange the whole record page. Its extension, and no other package's, writes fieldGroups and relatedLists — below — and actionLayout, the order of the object's actions and which are header buttons.
import { defineObjectExtension, Field } from '@objectstack/spec/data';

export const AccountRegionExtension = defineObjectExtension({
  extend: 'crm_account',
  fields: { region__c: Field.text({ label: 'Region' }) },
});
export default defineStack({
  manifest: {
    id: 'hotcrm.custom',                  // the base's id + '.custom'
    namespace: 'crm_custom',              // the base's namespace + '_custom'
    dependencies: { hotcrm: '^3' },       // the base, at its installed major
    /* … */
  },
  objectExtensions: [AccountRegionExtension],
});

Arranging the whole record page

A record page is arranged in three layers, and each has its own way to say where things go:

LayerWhat it writesScope
The package that owns the objectfieldGroups and relatedLists on the objectThe whole arrangement
A package that extends itplace on its extensionOnly the fields, groups and child lists it brings
The environment, in the base's paired .custom packagefieldGroups and relatedLists on its extensionThe whole arrangement, over both layers above

So on an installed object the customer may move a vendor field to another group, reorder the groups, and reorder or hide tabs, without touching the vendor's package:

import { defineObjectExtension, Field } from '@objectstack/spec/data';

export const LeadPageExtension = defineObjectExtension({
  extend: 'crm_lead',
  fields: { region__c: Field.text({ label: 'Region' }) },
  // The whole field arrangement: the two groups swapped, `status` moved to `contact`.
  fieldGroups: [
    { key: 'contact', label: 'Contact', fields: ['email', 'phone', 'status'] },
    { key: 'basic', label: 'Basics', fields: ['name', 'company', 'region__c'] },
  ],
  // The whole tab list: events before tasks, the notes tab hidden.
  relatedLists: ['crm_event', 'crm_task', { list: 'crm_note', hidden: true }],
});

Both keys take the shape an object declares them in (field groups, relatedLists), and a group may list any field the object has, whoever declares it: the vendor's, another package's extension's, the pair's own __c fields. A group's relatedList may place any body table.

  • Each key replaces, whole. Written, fieldGroups replaces the groups the owner declares and the other extensions' place entries add to; relatedLists replaces the tab list the same way. Nothing is merged entry by entry. A key the extension does not write keeps the owner's arrangement with the placements, so writing only relatedLists leaves the field groups alone.
  • A field the arrangement does not list is never dropped. It shows after the last group, whatever group its owner or another extension had put it in: a field a later version of the base adds, or one a package installed later brings, appears there until the arrangement lists it. A group that lists fields shows exactly its list.
  • A tab the arrangement does not name still shows, after the listed ones. That is the reverse of an object's own relatedLists, where leaving a list out hides it. Hiding is written: { list: 'crm_note', hidden: true } hides that list's tab, whichever package brings the list, and a bare child name hides every list of that child. hidden is accepted only here; an object's own relatedLists refuses it. A list the object's owner hides by leaving it out of its own relatedLists stays hidden until the arrangement names it. The three built-in tabs are written as their bare names and keep their own rules; they are not hidden here.
  • A reader's own tab order comes on top. Each person's dragged order and hidden tabs (kept per user) are laid over this list, as they are over an object's. A tab the environment hides is not offered to them.
  • Taking it away restores the page. Remove a key, or uninstall or disable the pair, and the owner's arrangement with the placements is served again. Nothing is rewritten in the base or in another package.
  • Only the pair writes these keys. In a package that is not a .custom package they are refused at save and publish, by os validate and os build, and at install, with the prescription to use place. Within one extension, a place entry beside the key that would replace it is refused too: list the item in the arrangement instead.
  • The pair is the App's. An object's pair is the .custom package of the App the object belongs to: for an object a module of an App owns, that is the App's pair. A .custom package an earlier version created for the module itself is still read while it is installed; where both write a key, the App's pair is served. What any other .custom package writes under these keys is not refused at those doors; it is not applied, alone or beside the pair, and the boot log names the package and the object.
  • Hiding a field is written in the arrangement. hidden is not a display property a fieldPatches entry may set: a hidden field is also left out of the search index and out of a form's required check, so it is more than display. To keep a vendor field off the record page and the forms, list it in a group whose visibleWhen is false: { key: 'off_page', label: 'Not shown', fields: ['fax'], visibleWhen: 'false' }. Two limits:
    • It is presentation only, not access control. The field stays readable and writable through the API.
    • Do not use it for a required field that has no default. The create form no longer shows the field while the save still requires it, so the form cannot be submitted: the save is refused naming a field the user cannot see.

Merge order and conflicts

  1. The registry picks the base layer for the object.
  2. Every extend contribution is folded onto that base, in ascending priority order.
  3. Within a fold, the rules in the table above apply: fields and scalars are last-writer-wins, validations and indexes accumulate.

So a higher priority is applied later and wins a conflict. Two extensions with the same priority are folded in registration order (the one registered last wins), which is not a guarantee to build on — give competing extensions distinct priorities.

Merging is idempotent: re-registering a package (a metadata rebuild, a dev-server reload) replaces that package's previous contribution rather than stacking a second copy.


Extensions and tenant customization

Object contributions come in three kinds, and only the first two can be authored:

KindWho writes itWhat it is
ownThe owning packageThe base definition. Exactly one per object, always.
extendAny other packageThis page. Folded on top of the base.
overlayNobody, directlyA tenant customization layer, hydrated from stored metadata by the loader. It replaces the base at resolution time and owns nothing.

The overlay is the seam where a package extension meets a tenant's own edits: when an overlay exists it becomes the base the extensions fold onto, so extension fields survive a customized object rather than being dropped by it.

One deliberate asymmetry, ruled 2026-08-13: an extension's label, pluralLabel and description apply only while the base still carries the packaged owner's value. Once a tenant has renamed the object, the extension's packaged default yields and the tenant's name stands. A fieldPatches key yields the same way, one field (and option) at a time: a field label the tenant edited keeps the tenant's text. Fields, validations and indexes are unaffected — they merge either way. There is no escape hatch: a package cannot relabel an object a tenant has deliberately renamed.


Worked example

A customer-success package adds churn tracking to an account object owned by a CRM package — fields, a rule and an index, without touching the CRM package's source:

import { defineObjectExtension, Field } from '@objectstack/spec/data';

export const AccountChurnExtension = defineObjectExtension({
  extend: 'crm_account',
  fields: {
    cs_health_score: Field.number({ label: 'Health Score', min: 0, max: 100 }),
    cs_renewal_date: Field.date({ label: 'Renewal Date' }),
    cs_owner: Field.text({ label: 'Success Manager' }),
  },
  validations: [
    {
      name: 'cs_renewal_date_required_for_at_risk',
      type: 'script',
      severity: 'error',
      message: 'An at-risk account needs a renewal date.',
      // CEL predicate — TRUE means the record is invalid.
      condition: '!isBlank(record.cs_health_score) && record.cs_health_score < 40 && isBlank(record.cs_renewal_date)',
    },
  ],
  indexes: [{ name: 'idx_crm_account_cs_renewal', fields: ['cs_renewal_date'] }],
  priority: 300,
});

Every added name carries the cs_ prefix, so this package cannot collide with the CRM package's own fields or with another extension's. priority: 300 puts it after the default 200, so it wins against a lower-priority extension of the same object.


On this page