Modifying the Schema
UD's schema can be extended at runtime. Namespaces separate application definitions from the base schema. Creation validates the complete definition; deletion checks whether other objects still depend on it.
Namespaces #
All new definitions live in a namespace: a schemaNamespace OU created
directly under /Configuration/Schema.
The flat set of unprefixed base definitions is reserved forever. Even the
local organization extends the schema through its own namespace;
/Configuration/Schema/Homelab/, /Configuration/Schema/Acme/. Namespaces
hold definitions only; they cannot nest.
Namespace names can be dotted, and reverse-DNS (com.acme.tools) is the
convention for anything redistributable, which makes vendor collisions
structurally unlikely rather than merely hoped against. Short names remain
fine for org-internal extensions. gip and ud are permanently reserved,
being GIP's service namespaces.
A namespaced definition's wire name is Namespace-name. A facet badging
in the Acme namespace is addressed everywhere; API, console, attribute
lookups; as Acme-badging. The hyphen is structural: it is the namespace
separator, which is exactly why native definition names cannot contain one.
See naming rules. Collisions
between namespaces are therefore structurally impossible, not conventionally
unlikely.
Create complete definitions #
A definition is created complete, in one atomic call; object and
attributes together. The API's create accepts an attributes map; the
console's create modal generates a field per attribute of the chosen class.
The engine fills in lifecycle: active and system: false itself.
Every schema write then passes a trial recompile of the whole schema. An
attribute definition missing its syntax, an extension whose target is not a
class, a dangling facet reference; any incoherence rejects the write
atomically, with the compiler's message, as if it never happened.
Once created, a definition is immutable and immovable: no attribute edits, no renames, no moves. Add and delete are the only verbs. To fix a definition, delete it and recreate it.
The recreated definition is a new definition with a new GUID, so anything that referenced the old one dangles visibly rather than silently rebinding. This is the no-resurrection guarantee: a deleted definition's name can be reused, but its identity can never be impersonated.
The unused-delete rule #
A definition can be deleted only when provably unused.
| Kind | Blocked while… |
|---|---|
| attribute | any object holds values for it, any value uses it as a meta key, any attribute lists it in legalMeta, or any facet references it |
| facet | any class composes it, any extension grafts it, or any object has it attached |
| class | any instance exists; including restorable soft-deleted ones; shredded skeletons do not count; or any extension targets it |
| class extension | any instance of the target class holds values in attributes the extension exclusively provides |
Refusals enumerate their blockers by name: attribute still has values on: /Sales/Jack, facet is used by class Acme-badgeHolder. Teardown is a matter
of reading the error.
Two shapes of teardown work:
- Dependency order; clear values, remove the extension, then the facet, then the attribute, then the namespace.
- Wholesale; deleting a namespace takes its entire contents down in one atomic subtree delete, and usage between the dying definitions themselves does not count. Only usage from outside the namespace blocks.
Definition deletion is the same soft delete as everywhere else. A deleted definition sits restorably in the morgue; restoring it recompiles the schema and revives its wire name, refused if the name has been retaken; then hardens to a skeleton when the restore window closes. Values stored under a definition die at its shred: data whose meaning can never return is not kept.
Class extensions #
A class extension grafts facets onto a class its author does not own. It
is the mechanism for "an app needs a tracking number on every user" without
touching the user class.
An extension is a definition of class classExtension, living in the
extender's namespace, declaring a targetClass and the facets to add.
From the moment it exists, every instance of the target class carries those
facets in its surface. Delete the extension and the surface shrinks back;
refused, per the table above, while instances still hold values only the
extension permits.
The target class object is never modified. The extension is entirely the extender's property, living in their namespace, removable with their namespace.
Add badge colors to users #
Use the JSON API to create an attribute, attach it to a facet, and extend the
user class with that facet. These requests were checked against version
0.1.0. Each create returns an object whose id supplies the next request's
GUID placeholder.
Before you start, resolve /Configuration/Schema and an existing user's path
through GET /api/path/<path>. Resolve /Configuration/Schema/user for the
base class GUID. The console's create dialog can also perform these steps.
-
Create the namespace under the schema OU:
POST /api/objects/<schema-ou-guid>/children { "name": "Acme", "class": "schemaNamespace" } -
Create the complete attribute definition under the namespace:
POST /api/objects/<acme-guid>/children { "name": "badgeColor", "class": "attributeDefinition", "attributes": { "syntax": [{ "value": "string" }], "singleValued": [{ "value": "true" }], "matching": [{ "value": "caseless" }] } } -
Create a facet referencing that attribute's GUID:
POST /api/objects/<acme-guid>/children { "name": "badging", "class": "facetDefinition", "attributes": { "attributes": [{ "value": "<badge-color-guid>" }] } } -
Extend the base
userclass with the facet:POST /api/objects/<acme-guid>/children { "name": "userBadging", "class": "classExtension", "attributes": { "targetClass": [{ "value": "<user-class-guid>" }], "facets": [{ "value": "<badging-guid>" }] } }User objects now include
Acme-badgingin their effective facet surface. -
Set a user's badge color:
PUT /api/objects/<user-guid>/attributes/Acme-badgeColor { "values": [{ "value": "red" }] }
The stored attribute uses the namespaced wire name Acme-badgeColor.
Reference values in these requests are GUIDs; the console also accepts paths
and resolves them before submitting a request.