From 027e021117be9b34bd224041113c373ab77d6b7e Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 08:28:54 -0500
Subject: [PATCH 1/9] feat: split business rules and view expressions out of
the core provider into packs
Move the 1.3.0 business-rules vocabulary (api, operation, binding, transition) and the
view-expressions vocabulary (origin.function, @union, @unionAll, @grain, @grainOrdinal) into
their own providers, metaobjects-rules and metaobjects-view-expressions, composed by default
in every port that carries them. Data-driven extends may now carry structural child rules so
a pack owns the child rules that admit its types. Pin the core provider's vocabulary with a
gate that points at GOVERNANCE.md and the pack mechanism. Add pack-omission conformance
fixtures.
---
CHANGELOG.md | 43 ++
.../providers.json | 2 +-
.../expected-errors.json | 15 +
.../input/meta.commerce.json | 51 ++
.../providers.json | 1 +
.../expected-errors.json | 15 +
.../input/meta.commerce.json | 89 +++
.../providers.json | 1 +
.../expected-errors.json | 15 +
.../input/meta.commerce.json | 56 ++
.../providers.json | 1 +
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../packs-left-out-model-loads/expected.json | 84 +++
.../input/meta.commerce.json | 82 +++
.../packs-left-out-model-loads/providers.json | 1 +
.../providers.json | 2 +-
.../providers.json | 2 +-
.../rules-lifecycle-inherited/providers.json | 2 +-
.../rules-lifecycle-no-api/providers.json | 2 +-
.../rules-lifecycle-no-source/providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../providers.json | 2 +-
.../rules-purchase-request/providers.json | 2 +-
fixtures/metamodel-docs/expected/providers.md | 31 +-
fixtures/metamodel-docs/expected/types/api.md | 4 +
.../metamodel-docs/expected/types/binding.md | 8 +-
.../metamodel-docs/expected/types/object.md | 8 +-
.../expected/types/operation.md | 42 +-
.../metamodel-docs/expected/types/origin.md | 12 +-
.../expected/types/transition.md | 18 +-
.../core-vocabulary.pin.json | 610 ++++++++++++++++++
.../expected-registry.json | 4 +-
fixtures/registry-conformance/providers.json | 13 +
scripts/check-core-vocabulary-pin.ts | 188 ++++++
scripts/ci-local.sh | 8 +
scripts/generate-embedded-metamodel.ts | 3 +
scripts/test-core-vocabulary-pin.ts | 90 +++
.../ConformanceAdapter.cs | 4 +
.../CoreTypesTests.cs | 3 +-
.../FixtureDiscovery.cs | 3 +
.../FullCoreRegistry.cs | 2 +
.../RegistryManifestConformanceTests.cs | 4 +
.../ViewVocabularyRc21LoaderTests.cs | 10 +-
.../MetaObjects/Core/Object/ObjectSchema.cs | 16 -
.../Core/Rules/RulesMetaDataProvider.cs | 67 ++
server/csharp/MetaObjects/CoreTypes.cs | 28 +-
.../ViewExpressionsMetaDataProvider.cs | 46 ++
server/csharp/MetaObjects/Registry.cs | 20 +-
.../Registry/Spec/SpecMetamodelReader.cs | 16 +-
.../csharp/MetaObjects/SpecMetamodel/api.json | 11 +-
.../MetaObjects/SpecMetamodel/field.json | 1 -
.../MetaObjects/SpecMetamodel/object.json | 4 -
.../MetaObjects/SpecMetamodel/origin.json | 14 -
.../MetaObjects/SpecMetamodel/transition.json | 11 +-
.../SpecMetamodel/view-expressions.json | 31 +
.../main/java/com/metaobjects/MetaRoot.java | 1 -
.../api/RulesTypesMetaDataProvider.java | 12 +-
.../com/metaobjects/object/MetaObject.java | 12 +-
.../origin/OriginTypesMetaDataProvider.java | 2 +-
.../ViewExpressionsTypesMetaDataProvider.java | 59 ++
.../registry/MetaDataRegistry.java | 43 +-
.../registry/RegistryManifest.java | 29 +-
.../registry/spec/SpecMetamodelReader.java | 14 +-
....metaobjects.registry.MetaDataTypeProvider | 1 +
.../conformance/ConformanceTest.java | 29 +-
server/python/src/metaobjects/core_types.py | 168 +----
.../metaobjects/meta/core/rules/__init__.py | 0
.../meta/core/rules/rules_provider.py | 166 +++++
.../persistence/view_expressions/__init__.py | 0
.../view_expressions_provider.py | 52 ++
.../src/metaobjects/meta/provider_extends.py | 16 +-
server/python/src/metaobjects/registry.py | 6 +
.../metaobjects/spec_metamodel/__init__.py | 11 +-
.../src/metaobjects/spec_metamodel/api.json | 11 +-
.../src/metaobjects/spec_metamodel/field.json | 1 -
.../metaobjects/spec_metamodel/object.json | 4 -
.../metaobjects/spec_metamodel/origin.json | 14 -
.../spec_metamodel/transition.json | 11 +-
.../spec_metamodel/view-expressions.json | 31 +
.../tests/conformance/conformance_adapter.py | 8 +
.../tests/conformance/fixture_discovery.py | 3 +
.../tests/unit/test_registry_completeness.py | 5 +-
.../rust/metaobjects/data/metamodel/api.json | 11 +-
.../metaobjects/data/metamodel/field.json | 1 -
.../metaobjects/data/metamodel/object.json | 4 -
.../metaobjects/data/metamodel/origin.json | 14 -
.../data/metamodel/transition.json | 11 +-
.../data/metamodel/view-expressions.json | 31 +
server/rust/metaobjects/src/providers.rs | 62 +-
.../tests/metamodel_conformance.rs | 2 +
.../packages/conformance/src/fixture.ts | 4 +
.../packages/metadata/src/core-types.ts | 36 +-
.../src/core/api/api-definition.embedded.ts | 18 +-
.../core/field/field-definition.embedded.ts | 8 -
.../core/object/object-definition.embedded.ts | 49 --
.../metadata/src/core/rules/rules-provider.ts | 47 ++
.../transition-definition.embedded.ts | 18 +-
.../metamodel-docs/provider-definitions.ts | 7 +
.../origin/origin-definition.embedded.ts | 54 --
.../view-expressions-definition.embedded.ts | 124 ++++
.../view-expressions-provider.ts | 42 ++
.../packages/metadata/src/provider-data.ts | 26 +-
.../metadata/test/conformance/adapter.ts | 4 +
.../packages/metadata/test/index.test.ts | 2 +
.../metadata/test/metamodel-docs.test.ts | 4 +-
.../origin-definition-completeness.test.ts | 6 +-
.../metadata/test/provider-data.test.ts | 6 +-
.../metadata/test/provider-vocabulary.test.ts | 16 +-
.../packages/metadata/test/provider.test.ts | 20 +-
.../packages/metadata/test/registry.test.ts | 8 +-
spec/metamodel/api.json | 11 +-
spec/metamodel/field.json | 1 -
spec/metamodel/object.json | 4 -
spec/metamodel/origin.json | 14 -
spec/metamodel/transition.json | 11 +-
spec/metamodel/view-expressions.json | 31 +
158 files changed, 2701 insertions(+), 603 deletions(-)
create mode 100644 fixtures/conformance/error-packs-left-out-api-used/expected-errors.json
create mode 100644 fixtures/conformance/error-packs-left-out-api-used/input/meta.commerce.json
create mode 100644 fixtures/conformance/error-packs-left-out-api-used/providers.json
create mode 100644 fixtures/conformance/error-packs-left-out-origin-function-used/expected-errors.json
create mode 100644 fixtures/conformance/error-packs-left-out-origin-function-used/input/meta.commerce.json
create mode 100644 fixtures/conformance/error-packs-left-out-origin-function-used/providers.json
create mode 100644 fixtures/conformance/error-packs-left-out-transition-used/expected-errors.json
create mode 100644 fixtures/conformance/error-packs-left-out-transition-used/input/meta.commerce.json
create mode 100644 fixtures/conformance/error-packs-left-out-transition-used/providers.json
create mode 100644 fixtures/conformance/packs-left-out-model-loads/expected.json
create mode 100644 fixtures/conformance/packs-left-out-model-loads/input/meta.commerce.json
create mode 100644 fixtures/conformance/packs-left-out-model-loads/providers.json
create mode 100644 fixtures/registry-conformance/core-vocabulary.pin.json
create mode 100644 scripts/check-core-vocabulary-pin.ts
create mode 100644 scripts/test-core-vocabulary-pin.ts
create mode 100644 server/csharp/MetaObjects/Core/Rules/RulesMetaDataProvider.cs
create mode 100644 server/csharp/MetaObjects/Persistence/ViewExpressions/ViewExpressionsMetaDataProvider.cs
create mode 100644 server/csharp/MetaObjects/SpecMetamodel/view-expressions.json
create mode 100644 server/java/metadata/src/main/java/com/metaobjects/origin/ViewExpressionsTypesMetaDataProvider.java
create mode 100644 server/python/src/metaobjects/meta/core/rules/__init__.py
create mode 100644 server/python/src/metaobjects/meta/core/rules/rules_provider.py
create mode 100644 server/python/src/metaobjects/meta/persistence/view_expressions/__init__.py
create mode 100644 server/python/src/metaobjects/meta/persistence/view_expressions/view_expressions_provider.py
create mode 100644 server/python/src/metaobjects/spec_metamodel/view-expressions.json
create mode 100644 server/rust/metaobjects/data/metamodel/view-expressions.json
create mode 100644 server/typescript/packages/metadata/src/core/rules/rules-provider.ts
create mode 100644 server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-definition.embedded.ts
create mode 100644 server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-provider.ts
create mode 100644 spec/metamodel/view-expressions.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bcf49f68ef..603049720f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1246,6 +1246,49 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
### Changed
+- **Business rules and view expressions are packs, not core vocabulary.** The 1.3.0 vocabulary that
+ never shipped in a release moves out of the one provider a project cannot leave out
+ (`metaobjects-core-types`) into two providers of its own, in every port that carries it
+ (TypeScript, C#, Java and Kotlin, Python, Rust). Both are composed by default, so **no model
+ changes**: every existing model loads and generates exactly as before, and the registry manifest
+ is byte-identical to the previous candidate in every row but one (below). Each pack can now be
+ left out, moved or versioned on its own, and it is moved now because moving it after the release
+ would be a break (`GOVERNANCE.md`, "Extension packs and the core metamodel": new vocabulary lives
+ in a pack until a second consumer needs it in core).
+ - **`metaobjects-rules`** (business rules, ADR-0066): `api.*`, `operation.*`, `binding.*` and
+ `transition.*`, plus the two child rules that admit them on core types, an `api` under the
+ document root and a `transition` under `field.enum`. The pack owns those rules, so composing it
+ out removes the types and the rules together.
+ - **`metaobjects-view-expressions`** (the vocabulary a projection needs to replace a hand-written
+ `@sql` view): `origin.function` and the projection attributes `@union`, `@unionAll`, `@grain`
+ and `@grainOrdinal`. The `cast` node and the SQL function set of `attr.expression`, and the
+ text `@dbColumnType` spellings, are grammar the loader parses in code, not registered
+ vocabulary, so they cannot be composed out by a provider and stay as they were.
+ - **Leaving a pack out.** Compose the default bundle without it
+ (`composeRegistry(coreProviders.filter(p => p.id !== "metaobjects-rules"))` in TypeScript, the
+ port's equivalent elsewhere). A model that does not use its types loads unchanged. A model that
+ does gets a loader error naming the unknown type, subtype or attribute
+ (`ERR_UNKNOWN_TYPE`, `ERR_UNKNOWN_SUBTYPE`, `ERR_UNKNOWN_ATTR`) and not a generator failure,
+ because the loader refuses what is invalid for the model, while a limit of one generator is
+ that generator's own error. Gated by the `packs-left-out-model-loads` and
+ `error-packs-left-out-*` conformance fixtures in every port.
+ - **One manifest row changes.** The `api` child rule on `metadata.root` is now declared in data
+ and carries its cardinality (`min` 0, `max` unbounded), where the code-registered rule carried
+ none. `metamodelVersion` stays `1.3`: it is the same vocabulary.
+ - **Embedders:** `coreTypesProvider` alone (and `registerCoreTypes`) no longer carries these two
+ packs; `coreProviders` still does. `ExtendDef` entries in a provider definition may now carry
+ structural children, which become child rules on the extended type (the mechanism a pack uses
+ to be admitted by a type core owns).
+ - **The core provider's vocabulary is pinned** (`fixtures/registry-conformance/core-vocabulary.pin.json`,
+ gate `core vocabulary is pinned` in `scripts/ci-local.sh`): adding a type, subtype, attribute or
+ child rule under `metaobjects-core-types` fails the gate with a message pointing at
+ `GOVERNANCE.md` and the pack mechanism. Regenerating the pin is a core maintainer's decision.
+ - **Reporting and requirements stay in core.** Moving them is not the same small move:
+ `object.report` and the `dimension`/`measure`/`segment` child rules are woven into
+ `object.json`, the relative-date filter value belongs to the `attr.filter` grammar, and the
+ requirements ledger is read by the `verify` gate in every port. They are the next candidates
+ for a pack of their own.
+
- **Release policy: vocabulary is versioned by feature, not by kind (ADR-0035 Amendment 5).** Adding
to or augmenting an existing feature (a type, subtype, attribute, enum value or view vocabulary,
additive and loading every existing document with the same meaning) is a PATCH; a whole new
diff --git a/fixtures/conformance/error-origin-function-free-sql/providers.json b/fixtures/conformance/error-origin-function-free-sql/providers.json
index f9bb435a37..a3019f1d62 100644
--- a/fixtures/conformance/error-origin-function-free-sql/providers.json
+++ b/fixtures/conformance/error-origin-function-free-sql/providers.json
@@ -1 +1 @@
-["metaobjects-core-types","metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-view-expressions"]
diff --git a/fixtures/conformance/error-packs-left-out-api-used/expected-errors.json b/fixtures/conformance/error-packs-left-out-api-used/expected-errors.json
new file mode 100644
index 0000000000..bc57ae5059
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-api-used/expected-errors.json
@@ -0,0 +1,15 @@
+{
+ "errors": [
+ {
+ "code": "ERR_UNKNOWN_TYPE",
+ "source": {
+ "format": "json",
+ "files": [
+ "meta.commerce.json"
+ ],
+ "jsonPath": "$['metadata.root'].children[1]['api.operational']"
+ }
+ }
+ ],
+ "warnings": []
+}
diff --git a/fixtures/conformance/error-packs-left-out-api-used/input/meta.commerce.json b/fixtures/conformance/error-packs-left-out-api-used/input/meta.commerce.json
new file mode 100644
index 0000000000..72c7279008
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-api-used/input/meta.commerce.json
@@ -0,0 +1,51 @@
+{
+ "metadata.root": {
+ "package": "acme::commerce",
+ "children": [
+ {
+ "object.entity": {
+ "name": "Program",
+ "children": [
+ {
+ "source.rdb": {
+ "@table": "programs"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "title"
+ }
+ },
+ {
+ "field.enum": {
+ "name": "status",
+ "@values": [
+ "draft",
+ "active"
+ ],
+ "@default": "draft"
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "@fields": "id"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "api.operational": {
+ "name": "Orders",
+ "children": []
+ }
+ }
+ ]
+ }
+}
diff --git a/fixtures/conformance/error-packs-left-out-api-used/providers.json b/fixtures/conformance/error-packs-left-out-api-used/providers.json
new file mode 100644
index 0000000000..1f1aa918d4
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-api-used/providers.json
@@ -0,0 +1 @@
+["metaobjects-core-types", "metaobjects-db"]
\ No newline at end of file
diff --git a/fixtures/conformance/error-packs-left-out-origin-function-used/expected-errors.json b/fixtures/conformance/error-packs-left-out-origin-function-used/expected-errors.json
new file mode 100644
index 0000000000..3b15a537ac
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-origin-function-used/expected-errors.json
@@ -0,0 +1,15 @@
+{
+ "errors": [
+ {
+ "code": "ERR_UNKNOWN_SUBTYPE",
+ "source": {
+ "format": "json",
+ "files": [
+ "meta.commerce.json"
+ ],
+ "jsonPath": "$['metadata.root'].children[1]['object.projection'].children[2]['field.string'].children[0]['origin.function']"
+ }
+ }
+ ],
+ "warnings": []
+}
diff --git a/fixtures/conformance/error-packs-left-out-origin-function-used/input/meta.commerce.json b/fixtures/conformance/error-packs-left-out-origin-function-used/input/meta.commerce.json
new file mode 100644
index 0000000000..827f085428
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-origin-function-used/input/meta.commerce.json
@@ -0,0 +1,89 @@
+{
+ "metadata.root": {
+ "package": "acme::commerce",
+ "children": [
+ {
+ "object.entity": {
+ "name": "Program",
+ "children": [
+ {
+ "source.rdb": {
+ "@table": "programs"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "title"
+ }
+ },
+ {
+ "field.enum": {
+ "name": "status",
+ "@values": [
+ "draft",
+ "active"
+ ],
+ "@default": "draft"
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "@fields": "id"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "object.projection": {
+ "name": "ProgramSummary",
+ "children": [
+ {
+ "source.rdb": {
+ "@kind": "view",
+ "@view": "v_program_summary"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "displayTitle",
+ "children": [
+ {
+ "origin.function": {
+ "@function": "title_case",
+ "@returns": "string",
+ "@args": [
+ "title"
+ ],
+ "@params": [
+ "string"
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/fixtures/conformance/error-packs-left-out-origin-function-used/providers.json b/fixtures/conformance/error-packs-left-out-origin-function-used/providers.json
new file mode 100644
index 0000000000..1f1aa918d4
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-origin-function-used/providers.json
@@ -0,0 +1 @@
+["metaobjects-core-types", "metaobjects-db"]
\ No newline at end of file
diff --git a/fixtures/conformance/error-packs-left-out-transition-used/expected-errors.json b/fixtures/conformance/error-packs-left-out-transition-used/expected-errors.json
new file mode 100644
index 0000000000..80c98f5a3a
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-transition-used/expected-errors.json
@@ -0,0 +1,15 @@
+{
+ "errors": [
+ {
+ "code": "ERR_UNKNOWN_TYPE",
+ "source": {
+ "format": "json",
+ "files": [
+ "meta.commerce.json"
+ ],
+ "jsonPath": "$['metadata.root'].children[0]['object.entity'].children[3]['field.enum'].children[0]['transition.action']"
+ }
+ }
+ ],
+ "warnings": []
+}
diff --git a/fixtures/conformance/error-packs-left-out-transition-used/input/meta.commerce.json b/fixtures/conformance/error-packs-left-out-transition-used/input/meta.commerce.json
new file mode 100644
index 0000000000..59d0713edd
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-transition-used/input/meta.commerce.json
@@ -0,0 +1,56 @@
+{
+ "metadata.root": {
+ "package": "acme::commerce",
+ "children": [
+ {
+ "object.entity": {
+ "name": "Program",
+ "children": [
+ {
+ "source.rdb": {
+ "@table": "programs"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "title"
+ }
+ },
+ {
+ "field.enum": {
+ "name": "status",
+ "@values": [
+ "draft",
+ "active"
+ ],
+ "@default": "draft",
+ "children": [
+ {
+ "transition.action": {
+ "name": "activate",
+ "@from": [
+ "draft"
+ ],
+ "@to": "active"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "@fields": "id"
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/fixtures/conformance/error-packs-left-out-transition-used/providers.json b/fixtures/conformance/error-packs-left-out-transition-used/providers.json
new file mode 100644
index 0000000000..1f1aa918d4
--- /dev/null
+++ b/fixtures/conformance/error-packs-left-out-transition-used/providers.json
@@ -0,0 +1 @@
+["metaobjects-core-types", "metaobjects-db"]
\ No newline at end of file
diff --git a/fixtures/conformance/error-projection-grain-not-object-array/providers.json b/fixtures/conformance/error-projection-grain-not-object-array/providers.json
index f9bb435a37..a3019f1d62 100644
--- a/fixtures/conformance/error-projection-grain-not-object-array/providers.json
+++ b/fixtures/conformance/error-projection-grain-not-object-array/providers.json
@@ -1 +1 @@
-["metaobjects-core-types","metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-view-expressions"]
diff --git a/fixtures/conformance/error-projection-union-shape/providers.json b/fixtures/conformance/error-projection-union-shape/providers.json
index f9bb435a37..a3019f1d62 100644
--- a/fixtures/conformance/error-projection-union-shape/providers.json
+++ b/fixtures/conformance/error-projection-union-shape/providers.json
@@ -1 +1 @@
-["metaobjects-core-types","metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-view-expressions"]
diff --git a/fixtures/conformance/error-rules-api-not-at-root/providers.json b/fixtures/conformance/error-rules-api-not-at-root/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-api-not-at-root/providers.json
+++ b/fixtures/conformance/error-rules-api-not-at-root/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-binding-method-invalid/providers.json b/fixtures/conformance/error-rules-binding-method-invalid/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-binding-method-invalid/providers.json
+++ b/fixtures/conformance/error-rules-binding-method-invalid/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-binding-path-unkeyed/providers.json b/fixtures/conformance/error-rules-binding-path-unkeyed/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-binding-path-unkeyed/providers.json
+++ b/fixtures/conformance/error-rules-binding-path-unkeyed/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-binding-path-wrong-key/providers.json b/fixtures/conformance/error-rules-binding-path-wrong-key/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-binding-path-wrong-key/providers.json
+++ b/fixtures/conformance/error-rules-binding-path-wrong-key/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-binding-route-duplicate/providers.json b/fixtures/conformance/error-rules-binding-route-duplicate/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-binding-route-duplicate/providers.json
+++ b/fixtures/conformance/error-rules-binding-route-duplicate/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-lifecycle-array/providers.json b/fixtures/conformance/error-rules-lifecycle-array/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-lifecycle-array/providers.json
+++ b/fixtures/conformance/error-rules-lifecycle-array/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-lifecycle-no-initial/providers.json b/fixtures/conformance/error-rules-lifecycle-no-initial/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-lifecycle-no-initial/providers.json
+++ b/fixtures/conformance/error-rules-lifecycle-no-initial/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-lifecycle-readonly-source/providers.json b/fixtures/conformance/error-rules-lifecycle-readonly-source/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-lifecycle-readonly-source/providers.json
+++ b/fixtures/conformance/error-rules-lifecycle-readonly-source/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-lifecycle-redeclared/providers.json b/fixtures/conformance/error-rules-lifecycle-redeclared/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-lifecycle-redeclared/providers.json
+++ b/fixtures/conformance/error-rules-lifecycle-redeclared/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-base-not-authorable/providers.json b/fixtures/conformance/error-rules-operation-base-not-authorable/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-base-not-authorable/providers.json
+++ b/fixtures/conformance/error-rules-operation-base-not-authorable/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-case-collision/providers.json b/fixtures/conformance/error-rules-operation-case-collision/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-case-collision/providers.json
+++ b/fixtures/conformance/error-rules-operation-case-collision/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-error-code-case/providers.json b/fixtures/conformance/error-rules-operation-error-code-case/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-error-code-case/providers.json
+++ b/fixtures/conformance/error-rules-operation-error-code-case/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-error-code-duplicate/providers.json b/fixtures/conformance/error-rules-operation-error-code-duplicate/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-error-code-duplicate/providers.json
+++ b/fixtures/conformance/error-rules-operation-error-code-duplicate/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-error-code-reserved/providers.json b/fixtures/conformance/error-rules-operation-error-code-reserved/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-error-code-reserved/providers.json
+++ b/fixtures/conformance/error-rules-operation-error-code-reserved/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-input-key-twice/providers.json b/fixtures/conformance/error-rules-operation-input-key-twice/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-input-key-twice/providers.json
+++ b/fixtures/conformance/error-rules-operation-input-key-twice/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-input-not-value/providers.json b/fixtures/conformance/error-rules-operation-input-not-value/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-input-not-value/providers.json
+++ b/fixtures/conformance/error-rules-operation-input-not-value/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-input-partial-key/providers.json b/fixtures/conformance/error-rules-operation-input-partial-key/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-input-partial-key/providers.json
+++ b/fixtures/conformance/error-rules-operation-input-partial-key/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-many-on-command/providers.json b/fixtures/conformance/error-rules-operation-many-on-command/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-many-on-command/providers.json
+++ b/fixtures/conformance/error-rules-operation-many-on-command/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-name-across-apis/providers.json b/fixtures/conformance/error-rules-operation-name-across-apis/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-name-across-apis/providers.json
+++ b/fixtures/conformance/error-rules-operation-name-across-apis/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-output-unresolved/providers.json b/fixtures/conformance/error-rules-operation-output-unresolved/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-output-unresolved/providers.json
+++ b/fixtures/conformance/error-rules-operation-output-unresolved/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-permission-public/providers.json b/fixtures/conformance/error-rules-operation-permission-public/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-permission-public/providers.json
+++ b/fixtures/conformance/error-rules-operation-permission-public/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-reserved-name/providers.json b/fixtures/conformance/error-rules-operation-reserved-name/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-reserved-name/providers.json
+++ b/fixtures/conformance/error-rules-operation-reserved-name/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-target-mismatch/providers.json b/fixtures/conformance/error-rules-operation-target-mismatch/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-target-mismatch/providers.json
+++ b/fixtures/conformance/error-rules-operation-target-mismatch/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-target-not-entity/providers.json b/fixtures/conformance/error-rules-operation-target-not-entity/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-target-not-entity/providers.json
+++ b/fixtures/conformance/error-rules-operation-target-not-entity/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-target-underivable/providers.json b/fixtures/conformance/error-rules-operation-target-underivable/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-target-underivable/providers.json
+++ b/fixtures/conformance/error-rules-operation-target-underivable/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-operation-unknown-transition/providers.json b/fixtures/conformance/error-rules-operation-unknown-transition/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-operation-unknown-transition/providers.json
+++ b/fixtures/conformance/error-rules-operation-unknown-transition/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-permission-shape/providers.json b/fixtures/conformance/error-rules-permission-shape/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-permission-shape/providers.json
+++ b/fixtures/conformance/error-rules-permission-shape/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-reserved-name-case/providers.json b/fixtures/conformance/error-rules-reserved-name-case/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-reserved-name-case/providers.json
+++ b/fixtures/conformance/error-rules-reserved-name-case/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-case-collision/providers.json b/fixtures/conformance/error-rules-transition-case-collision/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-case-collision/providers.json
+++ b/fixtures/conformance/error-rules-transition-case-collision/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-condition-not-boolean/providers.json b/fixtures/conformance/error-rules-transition-condition-not-boolean/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-condition-not-boolean/providers.json
+++ b/fixtures/conformance/error-rules-transition-condition-not-boolean/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-condition-unknown-field/providers.json b/fixtures/conformance/error-rules-transition-condition-unknown-field/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-condition-unknown-field/providers.json
+++ b/fixtures/conformance/error-rules-transition-condition-unknown-field/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-duplicate-name/providers.json b/fixtures/conformance/error-rules-transition-duplicate-name/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-duplicate-name/providers.json
+++ b/fixtures/conformance/error-rules-transition-duplicate-name/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-empty-from/providers.json b/fixtures/conformance/error-rules-transition-empty-from/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-empty-from/providers.json
+++ b/fixtures/conformance/error-rules-transition-empty-from/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-on-root-field/providers.json b/fixtures/conformance/error-rules-transition-on-root-field/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-on-root-field/providers.json
+++ b/fixtures/conformance/error-rules-transition-on-root-field/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-on-value/providers.json b/fixtures/conformance/error-rules-transition-on-value/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-on-value/providers.json
+++ b/fixtures/conformance/error-rules-transition-on-value/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-permission-public/providers.json b/fixtures/conformance/error-rules-transition-permission-public/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-permission-public/providers.json
+++ b/fixtures/conformance/error-rules-transition-permission-public/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-reserved-name/providers.json b/fixtures/conformance/error-rules-transition-reserved-name/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-reserved-name/providers.json
+++ b/fixtures/conformance/error-rules-transition-reserved-name/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/error-rules-transition-timed-reserved/providers.json b/fixtures/conformance/error-rules-transition-timed-reserved/providers.json
index aefa027b6a..8b1ca5bf4a 100644
--- a/fixtures/conformance/error-rules-transition-timed-reserved/providers.json
+++ b/fixtures/conformance/error-rules-transition-timed-reserved/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
\ No newline at end of file
diff --git a/fixtures/conformance/error-rules-transition-unknown-state/providers.json b/fixtures/conformance/error-rules-transition-unknown-state/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/error-rules-transition-unknown-state/providers.json
+++ b/fixtures/conformance/error-rules-transition-unknown-state/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/packs-left-out-model-loads/expected.json b/fixtures/conformance/packs-left-out-model-loads/expected.json
new file mode 100644
index 0000000000..ac9a0cd4cc
--- /dev/null
+++ b/fixtures/conformance/packs-left-out-model-loads/expected.json
@@ -0,0 +1,84 @@
+{
+ "metadata.root": {
+ "package": "acme::commerce",
+ "children": [
+ {
+ "object.entity": {
+ "name": "Program",
+ "children": [
+ {
+ "source.rdb": {
+ "@table": "programs"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "title"
+ }
+ },
+ {
+ "field.enum": {
+ "name": "status",
+ "@default": "draft",
+ "@values": [
+ "draft",
+ "active"
+ ]
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "@fields": [
+ "id"
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ "object.projection": {
+ "name": "ProgramSummary",
+ "children": [
+ {
+ "source.rdb": {
+ "@kind": "view",
+ "@view": "v_program_summary"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "displayTitle",
+ "children": [
+ {
+ "origin.passthrough": {
+ "@from": "acme::commerce::Program.title"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/fixtures/conformance/packs-left-out-model-loads/input/meta.commerce.json b/fixtures/conformance/packs-left-out-model-loads/input/meta.commerce.json
new file mode 100644
index 0000000000..27fdd31ba2
--- /dev/null
+++ b/fixtures/conformance/packs-left-out-model-loads/input/meta.commerce.json
@@ -0,0 +1,82 @@
+{
+ "metadata.root": {
+ "package": "acme::commerce",
+ "children": [
+ {
+ "object.entity": {
+ "name": "Program",
+ "children": [
+ {
+ "source.rdb": {
+ "@table": "programs"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "title"
+ }
+ },
+ {
+ "field.enum": {
+ "name": "status",
+ "@values": [
+ "draft",
+ "active"
+ ],
+ "@default": "draft"
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "@fields": "id"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "object.projection": {
+ "name": "ProgramSummary",
+ "children": [
+ {
+ "source.rdb": {
+ "@kind": "view",
+ "@view": "v_program_summary"
+ }
+ },
+ {
+ "field.long": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ },
+ {
+ "field.string": {
+ "name": "displayTitle",
+ "children": [
+ {
+ "origin.passthrough": {
+ "@from": "acme::commerce::Program.title"
+ }
+ }
+ ]
+ }
+ },
+ {
+ "identity.primary": {
+ "name": "id",
+ "extends": "acme::commerce::Program.id"
+ }
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
diff --git a/fixtures/conformance/packs-left-out-model-loads/providers.json b/fixtures/conformance/packs-left-out-model-loads/providers.json
new file mode 100644
index 0000000000..1f1aa918d4
--- /dev/null
+++ b/fixtures/conformance/packs-left-out-model-loads/providers.json
@@ -0,0 +1 @@
+["metaobjects-core-types", "metaobjects-db"]
\ No newline at end of file
diff --git a/fixtures/conformance/projection-view-vocabulary-rc21/providers.json b/fixtures/conformance/projection-view-vocabulary-rc21/providers.json
index f9bb435a37..a3019f1d62 100644
--- a/fixtures/conformance/projection-view-vocabulary-rc21/providers.json
+++ b/fixtures/conformance/projection-view-vocabulary-rc21/providers.json
@@ -1 +1 @@
-["metaobjects-core-types","metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-view-expressions"]
diff --git a/fixtures/conformance/rules-lifecycle-field-extends/providers.json b/fixtures/conformance/rules-lifecycle-field-extends/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-lifecycle-field-extends/providers.json
+++ b/fixtures/conformance/rules-lifecycle-field-extends/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-lifecycle-inherited/providers.json b/fixtures/conformance/rules-lifecycle-inherited/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-lifecycle-inherited/providers.json
+++ b/fixtures/conformance/rules-lifecycle-inherited/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-lifecycle-no-api/providers.json b/fixtures/conformance/rules-lifecycle-no-api/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-lifecycle-no-api/providers.json
+++ b/fixtures/conformance/rules-lifecycle-no-api/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-lifecycle-no-source/providers.json b/fixtures/conformance/rules-lifecycle-no-source/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-lifecycle-no-source/providers.json
+++ b/fixtures/conformance/rules-lifecycle-no-source/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-operation-cross-package/providers.json b/fixtures/conformance/rules-operation-cross-package/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-operation-cross-package/providers.json
+++ b/fixtures/conformance/rules-operation-cross-package/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-operation-declared-target/providers.json b/fixtures/conformance/rules-operation-declared-target/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-operation-declared-target/providers.json
+++ b/fixtures/conformance/rules-operation-declared-target/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-operation-name-two-packages/providers.json b/fixtures/conformance/rules-operation-name-two-packages/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-operation-name-two-packages/providers.json
+++ b/fixtures/conformance/rules-operation-name-two-packages/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-operation-versioned-apis/providers.json b/fixtures/conformance/rules-operation-versioned-apis/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-operation-versioned-apis/providers.json
+++ b/fixtures/conformance/rules-operation-versioned-apis/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/conformance/rules-purchase-request/providers.json b/fixtures/conformance/rules-purchase-request/providers.json
index aefa027b6a..f14395dbea 100644
--- a/fixtures/conformance/rules-purchase-request/providers.json
+++ b/fixtures/conformance/rules-purchase-request/providers.json
@@ -1 +1 @@
-["metaobjects-core-types", "metaobjects-db"]
+["metaobjects-core-types", "metaobjects-db", "metaobjects-rules"]
diff --git a/fixtures/metamodel-docs/expected/providers.md b/fixtures/metamodel-docs/expected/providers.md
index a8f406b9a9..068818332f 100644
--- a/fixtures/metamodel-docs/expected/providers.md
+++ b/fixtures/metamodel-docs/expected/providers.md
@@ -13,7 +13,7 @@ provider owns. This is the ownership lens over the same vocabulary
Core metaobjects metamodel types and subtypes.
-**Owns (registers):** `attr.base`, `attr.boolean`, `attr.class`, `attr.double`, `attr.expression`, `attr.filter`, `attr.int`, `attr.intMap`, `attr.long`, `attr.properties`, `attr.string`, `field.base`, `field.boolean`, `field.currency`, `field.date`, `field.decimal`, `field.double`, `field.duration`, `field.enum`, `field.float`, `field.inet`, `field.int`, `field.long`, `field.map`, `field.object`, `field.string`, `field.time`, `field.timestamp`, `field.uri`, `field.uuid`, `identity.primary`, `identity.reference`, `identity.secondary`, `layout.base`, `layout.dataGrid`, `object.base`, `object.entity`, `object.projection`, `object.report`, `object.value`, `origin.aggregate`, `origin.base`, `origin.computed`, `origin.first`, `origin.function`, `origin.passthrough`, `relationship.aggregation`, `relationship.association`, `relationship.base`, `relationship.composition`, `source.base`, `source.rdb`, `template.base`, `template.output`, `template.prompt`, `template.toolcall`, `validator.array`, `validator.atLeastOne`, `validator.base`, `validator.comparison`, `validator.exactlyOne`, `validator.length`, `validator.numeric`, `validator.presentIff`, `validator.regex`, `validator.required`, `validator.requiredWhen`, `view.base`, `view.checkbox`, `view.currency`, `view.date`, `view.dropdown`, `view.hidden`, `view.hotlink`, `view.image`, `view.month`, `view.number`, `view.password`, `view.radio`, `view.text`, `view.textarea`, `view.web`
+**Owns (registers):** `attr.base`, `attr.boolean`, `attr.class`, `attr.double`, `attr.expression`, `attr.filter`, `attr.int`, `attr.intMap`, `attr.long`, `attr.properties`, `attr.string`, `field.base`, `field.boolean`, `field.currency`, `field.date`, `field.decimal`, `field.double`, `field.duration`, `field.enum`, `field.float`, `field.inet`, `field.int`, `field.long`, `field.map`, `field.object`, `field.string`, `field.time`, `field.timestamp`, `field.uri`, `field.uuid`, `identity.primary`, `identity.reference`, `identity.secondary`, `layout.base`, `layout.dataGrid`, `object.base`, `object.entity`, `object.projection`, `object.report`, `object.value`, `origin.aggregate`, `origin.base`, `origin.computed`, `origin.first`, `origin.passthrough`, `relationship.aggregation`, `relationship.association`, `relationship.base`, `relationship.composition`, `source.base`, `source.rdb`, `template.base`, `template.output`, `template.prompt`, `template.toolcall`, `validator.array`, `validator.atLeastOne`, `validator.base`, `validator.comparison`, `validator.exactlyOne`, `validator.length`, `validator.numeric`, `validator.presentIff`, `validator.regex`, `validator.required`, `validator.requiredWhen`, `view.base`, `view.checkbox`, `view.currency`, `view.date`, `view.dropdown`, `view.hidden`, `view.hotlink`, `view.image`, `view.month`, `view.number`, `view.password`, `view.radio`, `view.text`, `view.textarea`, `view.web`
**Contributes attributes:**
@@ -31,12 +31,11 @@ Core metaobjects metamodel types and subtypes.
- `identity.secondary`: `@fields`
- `object.base`: `@object`, `@objectAdapter`
- `object.entity`: `@collectionName`, `@discriminator`, `@discriminatorValue`
-- `object.projection`: `@collectionName`, `@filter`, `@grain`, `@grainOrdinal`, `@union`, `@unionAll`
+- `object.projection`: `@collectionName`, `@filter`
- `object.report`: `@collectionName`, `@dimensions`, `@filter`, `@from`, `@measures`, `@segment`, `@spine`
- `origin.aggregate`: `@agg`, `@distinct`, `@filter`, `@of`, `@orderBy`, `@segment`, `@via`
- `origin.computed`: `@expr`
- `origin.first`: `@filter`, `@of`, `@orderBy`, `@segment`, `@via`
-- `origin.function`: `@args`, `@function`, `@params`, `@returns`, `@schema`
- `origin.passthrough`: `@convert`, `@from`, `@via`
- `relationship.aggregation`: `@cardinality`, `@objectRef`, `@onDelete`, `@onUpdate`, `@sourceRefField`, `@symmetric`, `@through`
- `relationship.association`: `@cardinality`, `@objectRef`, `@onDelete`, `@onUpdate`, `@sourceRefField`, `@symmetric`, `@through`
@@ -128,6 +127,21 @@ Prompt / AI + serialization domain — @xmlText / @example / @instruction field
- `field.uuid`: `@example`, `@instruction`, `@xmlText`
- `object.value`: `@normalize`
+## metaobjects-rules
+
+Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).
+
+**Owns (registers):** `api.base`, `api.operational`, `binding.base`, `binding.rest`, `operation.base`, `operation.command`, `operation.query`, `transition.action`, `transition.base`
+
+**Contributes attributes:**
+
+- `binding.rest`: `@method`, `@path`
+- `operation.base`: `@inputRef`, `@objectRef`, `@outputRef`, `@permission`, `@public`
+- `operation.command`: `@errors`, `@transitions`
+- `operation.query`: `@many`
+- `transition.action`: `@condition`, `@from`, `@to`
+- `transition.base`: `@permission`, `@public`
+
## metaobjects-ui
UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).
@@ -165,3 +179,14 @@ Web presentation view attrs — @rows (view.textarea) and the view.image control
- `view.image`: `@accept`, `@aspectRatio`, `@maxBytes`, `@maxEdge`, `@store`
- `view.textarea`: `@rows`
+## metaobjects-view-expressions
+
+View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes.
+
+**Owns (registers):** `origin.function`
+
+**Contributes attributes:**
+
+- `object.projection`: `@grain`, `@grainOrdinal`, `@union`, `@unionAll`
+- `origin.function`: `@args`, `@function`, `@params`, `@returns`, `@schema`
+
diff --git a/fixtures/metamodel-docs/expected/types/api.md b/fixtures/metamodel-docs/expected/types/api.md
index 2b432a814a..e4acbf3629 100644
--- a/fixtures/metamodel-docs/expected/types/api.md
+++ b/fixtures/metamodel-docs/expected/types/api.md
@@ -14,6 +14,8 @@ documentation attributes are omitted here (see [providers.md](../providers.md)).
Registry anchor for the declared API surface (ADR-0030, ADR-0054): not authorable. The `api` subtype axis is the interaction model, never the protocol; protocol lives in `binding.*` on each operation.
+**Owning provider:** metaobjects-rules
+
**Attributes**
_No subtype-specific attributes._
@@ -26,6 +28,8 @@ _No structural children._
A named, packaged request/response surface whose children are operations (ADR-0030). It is a wire contract: two of them (`v1`, `v2`) may declare the same operation side by side. The code behind it is one service per metadata package, whose surface is the package's operations (ADR-0067). Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+**Owning provider:** metaobjects-rules
+
**Rules:** Children are `operation.command` and `operation.query`. Lives at the document root. Declares no fields, sources or identities: shapes are referenced, never defined, by the surface. Operation names are compared without case, are unique across every API of one package, except one operation declared identically in two APIs, such as a versioned API beside its successor (one operation declared twice in one API merges), and may not be create, get, list, update or delete in any case (ERR_TRANSITION_NAME_COLLISION). Two declared bindings of one API may not share a method and path (ERR_BINDING_PATH_MISMATCH).
**When to use:** The application does something beyond derived CRUD: a named command (approve, cancel, import) or a named query (my open requests). Declare it here so its input, output, permission and business errors are part of the model. A plain lifecycle needs no api.operational at all: a transition nobody claims is held to derive its own command once a shell is generated, and no shell is generated yet.
diff --git a/fixtures/metamodel-docs/expected/types/binding.md b/fixtures/metamodel-docs/expected/types/binding.md
index 9ff5445830..53e23039fc 100644
--- a/fixtures/metamodel-docs/expected/types/binding.md
+++ b/fixtures/metamodel-docs/expected/types/binding.md
@@ -14,6 +14,8 @@ documentation attributes are omitted here (see [providers.md](../providers.md)).
Registry anchor for protocol bindings (ADR-0030, ADR-0054): not authorable.
+**Owning provider:** metaobjects-rules
+
**Attributes**
_No subtype-specific attributes._
@@ -26,14 +28,16 @@ _No structural children._
The HTTP method and path of an operation, declared only to override the derived ones. A query is `GET`, a command `POST`; the path is `//{id}/` for an operation with a target key and `//` without one. Most models never write it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+**Owning provider:** metaobjects-rules
+
**When to use:** An operation must keep a method or path the derived one would not give it, such as an existing public URL.
**Attributes**
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@method` | string | no | | `GET`, `POST`, `PUT`, `PATCH`, `DELETE` | — | The HTTP method. Absent: GET for a query, POST for a command. |
-| `@path` | string | no | | | — | A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH). |
+| `@method` | string | no | | `GET`, `POST`, `PUT`, `PATCH`, `DELETE` | metaobjects-rules | The HTTP method. Absent: GET for a query, POST for a command. |
+| `@path` | string | no | | | metaobjects-rules | A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH). |
**Allowed children**
diff --git a/fixtures/metamodel-docs/expected/types/object.md b/fixtures/metamodel-docs/expected/types/object.md
index d18828a9f6..b24ba50219 100644
--- a/fixtures/metamodel-docs/expected/types/object.md
+++ b/fixtures/metamodel-docs/expected/types/object.md
@@ -82,12 +82,12 @@ A derived read-only representation of entities. Its fields are extends-bound / o
| --- | --- | --- | --- | --- | --- | --- |
| `@collectionName` | string | no | | | metaobjects-core-types | The name of this object's collection, in the object's own casing (e.g. 'CaseHistory', 'Queues'): the REST collection segment (snake_cased) in every port, the reverse-finder names in C#, TypeScript and Python, the C# DbSet property, and the TypeScript list function, list hook and Drizzle table variable. It need not be a grammatical plural. Absent, the project's pluralizer derives it from the object's name (naming.collections in .metaobjects/config.json; built in: standard, none; an application may register its own). |
| `@filter` | filter | no | | | metaobjects-core-types | Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: "", startOf? }) on a date or timestamp field (rc.19). |
-| `@grain` | string | no | | | metaobjects-core-types | rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection. |
-| `@grainOrdinal` | string | no | | | metaobjects-core-types | rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array. |
+| `@grain` | string | no | | | metaobjects-view-expressions | rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection. |
+| `@grainOrdinal` | string | no | | | metaobjects-view-expressions | rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array. |
| `@object` | string | no | | | metaobjects-core-types | The native class an object binds to (ADR-0001), in place of its default runtime class: on the JVM, a fully-qualified class name. Cross-port vocabulary only Java implements so far; every port loads and type-checks it, and the others do not act on it yet. |
| `@objectAdapter` | string | no | | | metaobjects-core-types | JVM-only (ADR-0005): the fully-qualified name of an ObjectAdapter that takes over value access for this object's instances. Every port loads and type-checks it; only Java and Kotlin act on it. |
-| `@union` | string[] | no | | | metaobjects-core-types | rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless. |
-| `@unionAll` | boolean | no | | | metaobjects-core-types | rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default. |
+| `@union` | string[] | no | | | metaobjects-view-expressions | rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless. |
+| `@unionAll` | boolean | no | | | metaobjects-view-expressions | rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default. |
**Allowed children**
diff --git a/fixtures/metamodel-docs/expected/types/operation.md b/fixtures/metamodel-docs/expected/types/operation.md
index b51be413d5..78692b4fec 100644
--- a/fixtures/metamodel-docs/expected/types/operation.md
+++ b/fixtures/metamodel-docs/expected/types/operation.md
@@ -14,15 +14,17 @@ documentation attributes are omitted here (see [providers.md](../providers.md)).
Registry anchor for the attributes every operation shares (ADR-0054): not authorable.
+**Owning provider:** metaobjects-rules
+
**Attributes**
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@inputRef` | string | no | | | — | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
-| `@objectRef` | string | no | | | — | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
-| `@outputRef` | string | no | | | — | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
-| `@permission` | string | no | | | — | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
-| `@public` | boolean | no | | | — | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
+| `@inputRef` | string | no | | | metaobjects-rules | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
+| `@objectRef` | string | no | | | metaobjects-rules | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
+| `@outputRef` | string | no | | | metaobjects-rules | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
+| `@permission` | string | no | | | metaobjects-rules | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
+| `@public` | boolean | no | | | metaobjects-rules | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
**Allowed children**
@@ -32,19 +34,21 @@ Registry anchor for the attributes every operation shares (ADR-0054): not author
A named operation that changes state. Takes an `object.value` (ADR-0030). Its body is hand-written. The contract (ADR-0066) is that a generated shell around it loads the row, checks the permission and the current state, runs the body, and makes the guarded update in one transaction. No shell is generated yet: this vocabulary is registered, loaded and checked, and nothing is generated from it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+**Owning provider:** metaobjects-rules
+
**When to use:** A business action with its own name, input and rules: approve, cancel, transfer. A command that moves a lifecycle names the transitions it may make in @transitions; its body decides which one applies.
**Attributes**
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@errors` | string[] | no | | | — | The business failures the hand-written body may return, each a lower snake case code (`insufficient_funds`). They name the wire error, the OpenAPI document and the typed result; the shell will refuse an undeclared one (no shell is generated yet). A code that is not lower snake case, appears twice, or is one the route answers itself (not_found, forbidden, invalid_transition, transition_condition_failed, state_managed, validation, invalid_json, invalid_id, method_not_allowed, constraint_violation, internal) is ERR_BAD_ATTR_VALUE. |
-| `@inputRef` | string | no | | | — | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
-| `@objectRef` | string | no | | | — | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
-| `@outputRef` | string | no | | | — | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
-| `@permission` | string | no | | | — | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
-| `@public` | boolean | no | | | — | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
-| `@transitions` | string[] | no | | | — | The lifecycle moves this command may make: names of `transition.action` nodes on its target entity (ERR_OPERATION_UNKNOWN_TRANSITION otherwise). A fact of the business the model cannot compute. A transition a command lists gets no derived command of its own. Listing any requires a target (ERR_OPERATION_TARGET_UNRESOLVED). |
+| `@errors` | string[] | no | | | metaobjects-rules | The business failures the hand-written body may return, each a lower snake case code (`insufficient_funds`). They name the wire error, the OpenAPI document and the typed result; the shell will refuse an undeclared one (no shell is generated yet). A code that is not lower snake case, appears twice, or is one the route answers itself (not_found, forbidden, invalid_transition, transition_condition_failed, state_managed, validation, invalid_json, invalid_id, method_not_allowed, constraint_violation, internal) is ERR_BAD_ATTR_VALUE. |
+| `@inputRef` | string | no | | | metaobjects-rules | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
+| `@objectRef` | string | no | | | metaobjects-rules | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
+| `@outputRef` | string | no | | | metaobjects-rules | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
+| `@permission` | string | no | | | metaobjects-rules | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
+| `@public` | boolean | no | | | metaobjects-rules | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
+| `@transitions` | string[] | no | | | metaobjects-rules | The lifecycle moves this command may make: names of `transition.action` nodes on its target entity (ERR_OPERATION_UNKNOWN_TRANSITION otherwise). A fact of the business the model cannot compute. A transition a command lists gets no derived command of its own. Listing any requires a target (ERR_OPERATION_TARGET_UNRESOLVED). |
**Allowed children**
@@ -54,18 +58,20 @@ A named operation that changes state. Takes an `object.value` (ADR-0030). Its bo
A named operation that reads. Returns an `object.projection` (or an entity or value). It changes nothing. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+**Owning provider:** metaobjects-rules
+
**When to use:** A read with its own name and shape beyond derived get and list: my open requests, the dashboard summary.
**Attributes**
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@inputRef` | string | no | | | — | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
-| `@many` | boolean | no | | | — | The query returns a list and takes the filter, sort and paging contract. Not implied by the projection, so declared. Absent means one row. Legal on a query only. |
-| `@objectRef` | string | no | | | — | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
-| `@outputRef` | string | no | | | — | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
-| `@permission` | string | no | | | — | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
-| `@public` | boolean | no | | | — | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
+| `@inputRef` | string | no | | | metaobjects-rules | The `object.value` this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an `object.value` is ERR_OPERATION_SHAPE. |
+| `@many` | boolean | no | | | metaobjects-rules | The query returns a list and takes the filter, sort and paging contract. Not implied by the projection, so declared. Absent means one row. Legal on a query only. |
+| `@objectRef` | string | no | | | metaobjects-rules | The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields `extend` every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an `object.entity` (ERR_OPERATION_TARGET_UNRESOLVED). |
+| `@outputRef` | string | no | | | metaobjects-rules | The object this operation returns: an `object.projection`, `object.entity` or `object.value`. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
+| `@permission` | string | no | | | metaobjects-rules | The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as `purchasing.approve`; a package prefix may use `::` (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name `.`, with the package of the operation's API, and `verify` advises or requires an explicit one (setting `rules.permissions.names`). Several operations may share one. |
+| `@public` | boolean | no | | | metaobjects-rules | The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
**Allowed children**
diff --git a/fixtures/metamodel-docs/expected/types/origin.md b/fixtures/metamodel-docs/expected/types/origin.md
index 8e0708bb83..a592204dfe 100644
--- a/fixtures/metamodel-docs/expected/types/origin.md
+++ b/fixtures/metamodel-docs/expected/types/origin.md
@@ -96,7 +96,7 @@ _No structural children._
A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.
-**Owning provider:** metaobjects-core-types
+**Owning provider:** metaobjects-view-expressions
**Implemented in:** csharp, typescript so far — every port loads and type-checks it; the others do not act on it yet.
@@ -106,11 +106,11 @@ A value computed by a database function the project owns (rc.21): @function name
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@args` | string[] | no | | | metaobjects-core-types | The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments. |
-| `@function` | string | yes | | | metaobjects-core-types | The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase. |
-| `@params` | string[] | no | | | metaobjects-core-types | The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN). |
-| `@returns` | string | yes | | | metaobjects-core-types | The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc). |
-| `@schema` | string | no | | | metaobjects-core-types | The schema the function lives in, a plain identifier. Absent: public. |
+| `@args` | string[] | no | | | metaobjects-view-expressions | The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments. |
+| `@function` | string | yes | | | metaobjects-view-expressions | The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase. |
+| `@params` | string[] | no | | | metaobjects-view-expressions | The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN). |
+| `@returns` | string | yes | | | metaobjects-view-expressions | The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc). |
+| `@schema` | string | no | | | metaobjects-view-expressions | The schema the function lives in, a plain identifier. Absent: public. |
**Allowed children**
diff --git a/fixtures/metamodel-docs/expected/types/transition.md b/fixtures/metamodel-docs/expected/types/transition.md
index 20a5a4b6fb..65ded9d02c 100644
--- a/fixtures/metamodel-docs/expected/types/transition.md
+++ b/fixtures/metamodel-docs/expected/types/transition.md
@@ -14,6 +14,8 @@ documentation attributes are omitted here (see [providers.md](../providers.md)).
An allowed move between two values of a `field.enum`, made by an operation (ADR-0066). A `field.enum` with at least one is a lifecycle, named after the field. Its states are the enum's @values, its initial state the enum's @default, its terminal states the members no transition leaves; none of them has vocabulary of its own. Each transition is held to become a guarded update (`... WHERE id = ? AND IN (@from) [AND @condition]`), its own command when no declared operation claims it, its own permission point and its own wire error. No shell is generated yet: nothing is generated from this vocabulary, and the loader and `verify` only check it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+**Owning provider:** metaobjects-rules
+
**Rules:** Legal only under a `field.enum` of an `object.entity` (ERR_TRANSITION_NOT_ON_ENTITY). A concrete entity with a lifecycle and a source needs a writable one (ERR_TRANSITION_NOT_ON_ENTITY); on an entity with no source the lifecycle loads and is inert, deriving no command until a source is added. The field must declare @default (ERR_LIFECYCLE_NO_INITIAL). The field is not an array, and @from names at least one state (ERR_BAD_ATTR_VALUE). Names are unique across every lifecycle of the entity, compared without case, and may not be create, get, list, update or delete in any case (ERR_TRANSITION_NAME_COLLISION). A transition belongs to the entity that declares its field and to every entity extending it, never to an entity whose field merely `extends` that field; an inheritor that redeclares the field without extending it is ERR_LIFECYCLE_REDECLARED.
**When to use:** A status field whose values may only change in certain ways: a request is submitted from draft, approved or rejected from submitted. Declare each allowed move here; once a shell is generated, the generic update path will no longer write the field. A move that leaves the state where it was (from submitted to submitted) records an action that changes nothing but still happened, such as a first approval of two.
@@ -22,11 +24,11 @@ An allowed move between two values of a `field.enum`, made by an operation (ADR-
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@condition` | expression | no | | | — | A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE. |
-| `@from` | string[] | yes | | | — | The states this move may start from: members of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise), at least one (ERR_BAD_ATTR_VALUE when empty). The allowed moves are the business rule itself, so they cannot be computed. |
-| `@permission` | string | no | | | — | As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name `..`, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
-| `@public` | boolean | no | | | — | As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
-| `@to` | string | yes | | | — | The state this move ends in: one member of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise). May equal a member of @from, which records an action that leaves the state where it was. |
+| `@condition` | expression | no | | | metaobjects-rules | A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE. |
+| `@from` | string[] | yes | | | metaobjects-rules | The states this move may start from: members of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise), at least one (ERR_BAD_ATTR_VALUE when empty). The allowed moves are the business rule itself, so they cannot be computed. |
+| `@permission` | string | no | | | metaobjects-rules | As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name `..`, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
+| `@public` | boolean | no | | | metaobjects-rules | As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
+| `@to` | string | yes | | | metaobjects-rules | The state this move ends in: one member of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise). May equal a member of @from, which records an action that leaves the state where it was. |
**Allowed children**
@@ -36,12 +38,14 @@ _No structural children._
Registry anchor for the attributes every lifecycle move shares (ADR-0054): not authorable.
+**Owning provider:** metaobjects-rules
+
**Attributes**
| Attribute | Type | Required | Default | Allowed values | Provider | Description |
| --- | --- | --- | --- | --- | --- | --- |
-| `@permission` | string | no | | | — | As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name `..`, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
-| `@public` | boolean | no | | | — | As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
+| `@permission` | string | no | | | metaobjects-rules | As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name `..`, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
+| `@public` | boolean | no | | | metaobjects-rules | As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
**Allowed children**
diff --git a/fixtures/registry-conformance/core-vocabulary.pin.json b/fixtures/registry-conformance/core-vocabulary.pin.json
new file mode 100644
index 0000000000..b668375f3b
--- /dev/null
+++ b/fixtures/registry-conformance/core-vocabulary.pin.json
@@ -0,0 +1,610 @@
+{
+ "$comment": "The pinned vocabulary of the core provider (metaobjects-core-types): every type, subtype, attribute and structural child rule it owns. Derived from spec/metamodel/*.json by scripts/check-core-vocabulary-pin.ts. Do NOT regenerate this to make a failing gate pass: new vocabulary belongs in a pack (a separate provider), see GOVERNANCE.md, 'Extension packs and the core metamodel', and docs/features/extending-with-providers.md. Core takes a new type or attribute only once a second, independent consumer needs it, and that is a core maintainer's decision; the diff of this file is how that decision is reviewed.",
+ "types": {
+ "attr.base": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.boolean": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.class": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.double": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.expression": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.filter": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.int": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.intMap": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.long": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.properties": {
+ "attrs": [],
+ "children": []
+ },
+ "attr.string": {
+ "attrs": [],
+ "children": []
+ },
+ "dimension.attribute": {
+ "attrs": [
+ "of",
+ "via"
+ ],
+ "children": []
+ },
+ "dimension.time": {
+ "attrs": [
+ "grains",
+ "of",
+ "via"
+ ],
+ "children": []
+ },
+ "field.base": {
+ "attrs": [
+ "default",
+ "mutability",
+ "required",
+ "unique"
+ ],
+ "children": [
+ "origin.*:*",
+ "validator.*:*",
+ "view.*:*"
+ ]
+ },
+ "field.boolean": {
+ "attrs": [],
+ "children": []
+ },
+ "field.currency": {
+ "attrs": [
+ "currency"
+ ],
+ "children": []
+ },
+ "field.date": {
+ "attrs": [],
+ "children": []
+ },
+ "field.decimal": {
+ "attrs": [
+ "precision",
+ "scale"
+ ],
+ "children": []
+ },
+ "field.double": {
+ "attrs": [],
+ "children": []
+ },
+ "field.duration": {
+ "attrs": [],
+ "children": []
+ },
+ "field.enum": {
+ "attrs": [
+ "intValueMap",
+ "maxLength",
+ "provided",
+ "stringValueMap",
+ "values"
+ ],
+ "children": []
+ },
+ "field.float": {
+ "attrs": [],
+ "children": []
+ },
+ "field.inet": {
+ "attrs": [
+ "lenient"
+ ],
+ "children": []
+ },
+ "field.int": {
+ "attrs": [],
+ "children": []
+ },
+ "field.long": {
+ "attrs": [],
+ "children": []
+ },
+ "field.map": {
+ "attrs": [
+ "objectRef",
+ "valueType"
+ ],
+ "children": []
+ },
+ "field.object": {
+ "attrs": [
+ "objectRef"
+ ],
+ "children": []
+ },
+ "field.string": {
+ "attrs": [
+ "maxLength",
+ "stringFormat"
+ ],
+ "children": []
+ },
+ "field.time": {
+ "attrs": [],
+ "children": []
+ },
+ "field.timestamp": {
+ "attrs": [],
+ "children": []
+ },
+ "field.uri": {
+ "attrs": [
+ "lenient"
+ ],
+ "children": []
+ },
+ "field.uuid": {
+ "attrs": [],
+ "children": []
+ },
+ "identity.primary": {
+ "attrs": [
+ "fields",
+ "generation"
+ ],
+ "children": []
+ },
+ "identity.reference": {
+ "attrs": [
+ "enforce",
+ "fields",
+ "references"
+ ],
+ "children": []
+ },
+ "identity.secondary": {
+ "attrs": [
+ "fields"
+ ],
+ "children": []
+ },
+ "index.lookup": {
+ "attrs": [
+ "fields"
+ ],
+ "children": []
+ },
+ "layout.base": {
+ "attrs": [],
+ "children": []
+ },
+ "layout.dataGrid": {
+ "attrs": [],
+ "children": []
+ },
+ "measure.aggregate": {
+ "attrs": [
+ "agg",
+ "default",
+ "distinct",
+ "filter",
+ "of",
+ "segment"
+ ],
+ "children": []
+ },
+ "measure.derived": {
+ "attrs": [
+ "expr"
+ ],
+ "children": []
+ },
+ "measure.ratio": {
+ "attrs": [
+ "default",
+ "denominator",
+ "numerator"
+ ],
+ "children": []
+ },
+ "object.base": {
+ "attrs": [
+ "object",
+ "objectAdapter"
+ ],
+ "children": [
+ "field.*:*",
+ "identity.*:*",
+ "index.*:*",
+ "layout.*:*",
+ "source.*:*",
+ "validator.*:*"
+ ]
+ },
+ "object.entity": {
+ "attrs": [
+ "collectionName",
+ "discriminator",
+ "discriminatorValue"
+ ],
+ "children": [
+ "dimension.*:*",
+ "measure.*:*",
+ "relationship.*:*",
+ "segment.*:*",
+ "template.*:*"
+ ]
+ },
+ "object.projection": {
+ "attrs": [
+ "collectionName",
+ "filter"
+ ],
+ "children": []
+ },
+ "object.report": {
+ "attrs": [
+ "collectionName",
+ "dimensions",
+ "filter",
+ "from",
+ "measures",
+ "segment",
+ "spine"
+ ],
+ "children": []
+ },
+ "object.value": {
+ "attrs": [],
+ "children": [
+ "relationship.*:*"
+ ]
+ },
+ "origin.aggregate": {
+ "attrs": [
+ "agg",
+ "distinct",
+ "filter",
+ "of",
+ "orderBy",
+ "segment",
+ "via"
+ ],
+ "children": []
+ },
+ "origin.base": {
+ "attrs": [],
+ "children": []
+ },
+ "origin.computed": {
+ "attrs": [
+ "expr"
+ ],
+ "children": []
+ },
+ "origin.first": {
+ "attrs": [
+ "filter",
+ "of",
+ "orderBy",
+ "segment",
+ "via"
+ ],
+ "children": []
+ },
+ "origin.passthrough": {
+ "attrs": [
+ "convert",
+ "from",
+ "via"
+ ],
+ "children": []
+ },
+ "relationship.aggregation": {
+ "attrs": [
+ "cardinality",
+ "objectRef",
+ "onDelete",
+ "onUpdate",
+ "sourceRefField",
+ "symmetric",
+ "through"
+ ],
+ "children": []
+ },
+ "relationship.association": {
+ "attrs": [
+ "cardinality",
+ "objectRef",
+ "onDelete",
+ "onUpdate",
+ "sourceRefField",
+ "symmetric",
+ "through"
+ ],
+ "children": []
+ },
+ "relationship.base": {
+ "attrs": [
+ "cardinality",
+ "objectRef",
+ "onDelete",
+ "onUpdate",
+ "sourceRefField",
+ "symmetric",
+ "through"
+ ],
+ "children": []
+ },
+ "relationship.composition": {
+ "attrs": [
+ "cardinality",
+ "objectRef",
+ "onDelete",
+ "onUpdate",
+ "sourceRefField",
+ "symmetric",
+ "through"
+ ],
+ "children": []
+ },
+ "requirement.architectural": {
+ "attrs": [
+ "counterexample",
+ "disposition",
+ "implementedBy",
+ "level",
+ "statement",
+ "status",
+ "supersededBy",
+ "trackedBy"
+ ],
+ "children": [
+ "requirement.*:*"
+ ]
+ },
+ "requirement.functional": {
+ "attrs": [
+ "counterexample",
+ "disposition",
+ "implementedBy",
+ "level",
+ "statement",
+ "status",
+ "supersededBy",
+ "trackedBy"
+ ],
+ "children": [
+ "requirement.*:*"
+ ]
+ },
+ "segment.filter": {
+ "attrs": [
+ "filter"
+ ],
+ "children": []
+ },
+ "source.base": {
+ "attrs": [],
+ "children": []
+ },
+ "source.rdb": {
+ "attrs": [],
+ "children": []
+ },
+ "template.base": {
+ "attrs": [],
+ "children": []
+ },
+ "template.output": {
+ "attrs": [
+ "format",
+ "htmlBodyRef",
+ "kind",
+ "maxChars",
+ "owner",
+ "payloadRef",
+ "requiredTags",
+ "since",
+ "subjectRef",
+ "textBodyRef",
+ "textRef"
+ ],
+ "children": []
+ },
+ "template.prompt": {
+ "attrs": [
+ "format",
+ "maxChars",
+ "maxTokens",
+ "model",
+ "owner",
+ "payloadRef",
+ "promptStyle",
+ "requiredSlots",
+ "requiredTags",
+ "responseFormat",
+ "responseRef",
+ "since",
+ "textRef"
+ ],
+ "children": []
+ },
+ "template.toolcall": {
+ "attrs": [
+ "maxTokens",
+ "owner",
+ "payloadRef",
+ "since",
+ "toolName"
+ ],
+ "children": []
+ },
+ "validator.array": {
+ "attrs": [
+ "max",
+ "min"
+ ],
+ "children": []
+ },
+ "validator.atLeastOne": {
+ "attrs": [
+ "condition",
+ "fields"
+ ],
+ "children": []
+ },
+ "validator.base": {
+ "attrs": [
+ "max",
+ "min"
+ ],
+ "children": []
+ },
+ "validator.comparison": {
+ "attrs": [
+ "condition",
+ "left",
+ "op",
+ "right"
+ ],
+ "children": []
+ },
+ "validator.exactlyOne": {
+ "attrs": [
+ "condition",
+ "fields"
+ ],
+ "children": []
+ },
+ "validator.length": {
+ "attrs": [
+ "max",
+ "min"
+ ],
+ "children": []
+ },
+ "validator.numeric": {
+ "attrs": [
+ "max",
+ "min"
+ ],
+ "children": []
+ },
+ "validator.presentIff": {
+ "attrs": [
+ "condition",
+ "equals",
+ "field",
+ "when"
+ ],
+ "children": []
+ },
+ "validator.regex": {
+ "attrs": [
+ "max",
+ "min",
+ "pattern"
+ ],
+ "children": []
+ },
+ "validator.required": {
+ "attrs": [],
+ "children": []
+ },
+ "validator.requiredWhen": {
+ "attrs": [
+ "condition",
+ "equals",
+ "field",
+ "when"
+ ],
+ "children": []
+ },
+ "view.base": {
+ "attrs": [],
+ "children": []
+ },
+ "view.checkbox": {
+ "attrs": [],
+ "children": []
+ },
+ "view.currency": {
+ "attrs": [],
+ "children": []
+ },
+ "view.date": {
+ "attrs": [],
+ "children": []
+ },
+ "view.dropdown": {
+ "attrs": [],
+ "children": []
+ },
+ "view.hidden": {
+ "attrs": [],
+ "children": []
+ },
+ "view.hotlink": {
+ "attrs": [],
+ "children": []
+ },
+ "view.image": {
+ "attrs": [],
+ "children": []
+ },
+ "view.month": {
+ "attrs": [],
+ "children": []
+ },
+ "view.number": {
+ "attrs": [],
+ "children": []
+ },
+ "view.password": {
+ "attrs": [],
+ "children": []
+ },
+ "view.radio": {
+ "attrs": [],
+ "children": []
+ },
+ "view.text": {
+ "attrs": [],
+ "children": []
+ },
+ "view.textarea": {
+ "attrs": [],
+ "children": []
+ },
+ "view.web": {
+ "attrs": [],
+ "children": []
+ }
+ },
+ "extends": {},
+ "registeredInCode": [
+ "metadata.root"
+ ]
+}
diff --git a/fixtures/registry-conformance/expected-registry.json b/fixtures/registry-conformance/expected-registry.json
index a4d319166d..6355711847 100644
--- a/fixtures/registry-conformance/expected-registry.json
+++ b/fixtures/registry-conformance/expected-registry.json
@@ -3423,7 +3423,9 @@
{
"childType": "api",
"childSubType": "*",
- "childName": "*"
+ "childName": "*",
+ "min": 0,
+ "max": null
},
{
"childType": "field",
diff --git a/fixtures/registry-conformance/providers.json b/fixtures/registry-conformance/providers.json
index 94e5457142..dd240c3b33 100644
--- a/fixtures/registry-conformance/providers.json
+++ b/fixtures/registry-conformance/providers.json
@@ -56,6 +56,13 @@
"object.value"
]
},
+ "metaobjects-rules": {
+ "declaresTypes": true,
+ "projectsOnto": [
+ "field.enum",
+ "metadata.root"
+ ]
+ },
"metaobjects-ui": {
"declaresTypes": false,
"projectsOnto": [
@@ -70,6 +77,12 @@
"view.image",
"view.textarea"
]
+ },
+ "metaobjects-view-expressions": {
+ "declaresTypes": true,
+ "projectsOnto": [
+ "object.projection"
+ ]
}
}
}
diff --git a/scripts/check-core-vocabulary-pin.ts b/scripts/check-core-vocabulary-pin.ts
new file mode 100644
index 0000000000..24640ace34
--- /dev/null
+++ b/scripts/check-core-vocabulary-pin.ts
@@ -0,0 +1,188 @@
+#!/usr/bin/env bun
+/**
+ * Gate — the CORE provider's vocabulary is pinned.
+ *
+ * `metaobjects-core-types` is the one provider a project cannot leave out, so
+ * everything in it is vocabulary every adopter, in every port, carries. GOVERNANCE.md
+ * ("Extension packs and the core metamodel") says new vocabulary enters core only when a
+ * second, independent consumer needs it; until then it lives in a PACK: a separate
+ * provider, composed by default if it ships with the library, that a project can leave
+ * out, move or version on its own (business rules, view expressions, reporting and the
+ * requirements ledger are the worked examples; see docs/features/extending-with-providers.md).
+ *
+ * The pin makes that a mechanical failure instead of a code-review hope: adding a type,
+ * a subtype or an attribute under the `metaobjects-core-types` provider, or a structural
+ * child rule it admits, changes this file's computed view and the gate fails until
+ * `fixtures/registry-conformance/core-vocabulary.pin.json` is regenerated, which is a
+ * reviewed, core-maintainer decision (the diff shows exactly what entered core).
+ *
+ * The pin is derived from `spec/metamodel/*.json` (provider === "metaobjects-core-types"),
+ * the cross-port source of truth, so it holds for every port at once: each port embeds a
+ * byte-identical copy of those files, and the registry-conformance gate holds each port's
+ * registry to the committed manifest. The TypeScript registry is checked too, because
+ * `metadata.root` is registered in code and has no spec file.
+ *
+ * Usage: bun scripts/check-core-vocabulary-pin.ts [--update] [--spec ] [--pin ]
+ */
+import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+
+export const CORE_PROVIDER_ID = "metaobjects-core-types";
+
+interface ChildDefLike {
+ type: string;
+ subType?: string | readonly string[];
+ name: string;
+ min?: number;
+ max?: number | null;
+}
+interface TypeDefLike {
+ type: string;
+ subType: string;
+ children?: ChildDefLike[];
+}
+interface ExtendDefLike {
+ type: string;
+ subType: string | readonly string[];
+ children: ChildDefLike[];
+}
+interface DefinitionLike {
+ provider: string;
+ types?: TypeDefLike[];
+ extends?: ExtendDefLike[];
+}
+
+export interface CorePin {
+ /** "type.subType" -> its own attribute names and structural child rules, sorted. */
+ types: Record;
+ /** "type.subType" (a core-owned `extends`) -> the attribute names and child rules it adds, sorted. */
+ extends: Record;
+ /** Types core registers in code, with no spec file (the TypeScript registry check covers them). */
+ registeredInCode: string[];
+}
+
+const childKey = (c: ChildDefLike): string => {
+ const sub = Array.isArray(c.subType) ? c.subType.join("|") : (c.subType ?? "*");
+ return `${c.type}.${sub}:${c.name}`;
+};
+
+function split(children: readonly ChildDefLike[] | undefined): { attrs: string[]; children: string[] } {
+ const attrs: string[] = [];
+ const kids: string[] = [];
+ for (const c of children ?? []) {
+ if (c.type === "attr") attrs.push(c.name);
+ else kids.push(childKey(c));
+ }
+ return { attrs: attrs.sort(), children: kids.sort() };
+}
+
+function findRepoRoot(start: string): string {
+ let dir = start;
+ while (true) {
+ if (existsSync(join(dir, "spec")) && existsSync(join(dir, "server"))) return dir;
+ const parent = dirname(dir);
+ if (parent === dir) throw new Error("Could not locate repo root (dir containing spec/ and server/)");
+ dir = parent;
+ }
+}
+
+/** Compute the pin from the spec files whose provider is the core provider. */
+export function computeCorePin(specDir: string): CorePin {
+ const pin: CorePin = { types: {}, extends: {}, registeredInCode: ["metadata.root"] };
+ for (const f of readdirSync(specDir).filter((n) => n.endsWith(".json")).sort()) {
+ const def = JSON.parse(readFileSync(join(specDir, f), "utf8")) as DefinitionLike;
+ if (def.provider !== CORE_PROVIDER_ID) continue;
+ for (const t of def.types ?? []) {
+ // "*.*" is the common-attribute carrier, not a type.
+ const key = `${t.type}.${t.subType}`;
+ pin.types[key] = split(t.children);
+ }
+ for (const x of def.extends ?? []) {
+ const subs = Array.isArray(x.subType) ? x.subType : [x.subType];
+ for (const s of subs) pin.extends[`${x.type}.${s}`] = split(x.children);
+ }
+ }
+ const sorted = (o: Record): Record =>
+ Object.fromEntries(Object.entries(o).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
+ pin.types = sorted(pin.types);
+ pin.extends = sorted(pin.extends);
+ return pin;
+}
+
+const serialize = (pin: CorePin): string => JSON.stringify({ $comment: COMMENT, ...pin }, null, 2) + "\n";
+
+const COMMENT = [
+ "The pinned vocabulary of the core provider (metaobjects-core-types): every type, subtype,",
+ "attribute and structural child rule it owns. Derived from spec/metamodel/*.json by",
+ "scripts/check-core-vocabulary-pin.ts. Do NOT regenerate this to make a failing gate pass:",
+ "new vocabulary belongs in a pack (a separate provider), see GOVERNANCE.md, 'Extension packs",
+ "and the core metamodel', and docs/features/extending-with-providers.md. Core takes a new",
+ "type or attribute only once a second, independent consumer needs it, and that is a core",
+ "maintainer's decision; the diff of this file is how that decision is reviewed.",
+].join(" ");
+
+/** Human-readable difference between the committed pin and the computed one; [] when equal. */
+export function diffPins(committed: CorePin, computed: CorePin): string[] {
+ const out: string[] = [];
+ for (const section of ["types", "extends"] as const) {
+ const a = committed[section];
+ const b = computed[section];
+ for (const k of Object.keys(b)) {
+ if (!(k in a)) {
+ out.push(`+ ${section === "types" ? "type" : "core extension of"} ${k}`);
+ continue;
+ }
+ for (const field of ["attrs", "children"] as const) {
+ for (const n of b[k]![field]) if (!a[k]![field].includes(n)) out.push(`+ ${k} ${field === "attrs" ? "attribute @" : "child rule "}${n}`);
+ for (const n of a[k]![field]) if (!b[k]![field].includes(n)) out.push(`- ${k} ${field === "attrs" ? "attribute @" : "child rule "}${n}`);
+ }
+ }
+ for (const k of Object.keys(a)) if (!(k in b)) out.push(`- ${section === "types" ? "type" : "core extension of"} ${k}`);
+ }
+ return out;
+}
+
+export const FAILURE_GUIDANCE = [
+ "The core provider's vocabulary is pinned, and it changed (above).",
+ "New vocabulary does not go in core: GOVERNANCE.md, 'Extension packs and the core metamodel',",
+ "says core takes a new type, subtype or attribute only when a second, independent consumer",
+ "needs it. Put it in a pack instead: its own provider and spec/metamodel/.json",
+ "(provider id 'metaobjects-'), composed by default if it ships with the library, so a",
+ "project can leave it out. See docs/features/extending-with-providers.md and the worked",
+ "examples (metaobjects-rules, metaobjects-view-expressions).",
+ "Only if a core maintainer has decided this belongs in core, regenerate the pin with",
+ "`bun scripts/check-core-vocabulary-pin.ts --update` and justify it in the PR.",
+].join("\n");
+
+function main(): number {
+ const argv = process.argv.slice(2);
+ const arg = (flag: string): string | undefined => {
+ const i = argv.indexOf(flag);
+ return i >= 0 ? argv[i + 1] : undefined;
+ };
+ const root = findRepoRoot(dirname(fileURLToPath(import.meta.url)));
+ const specDir = arg("--spec") ?? join(root, "spec", "metamodel");
+ const pinPath = arg("--pin") ?? join(root, "fixtures", "registry-conformance", "core-vocabulary.pin.json");
+ const computed = computeCorePin(specDir);
+ if (argv.includes("--update")) {
+ writeFileSync(pinPath, serialize(computed), "utf8");
+ console.log(`wrote ${pinPath}`);
+ return 0;
+ }
+ if (!existsSync(pinPath)) {
+ console.error(`core vocabulary pin missing: ${pinPath}\n${FAILURE_GUIDANCE}`);
+ return 1;
+ }
+ const committed = JSON.parse(readFileSync(pinPath, "utf8")) as CorePin;
+ const diff = diffPins(committed, computed);
+ if (diff.length > 0) {
+ console.error(`core vocabulary changed:\n${diff.map((d) => ` ${d}`).join("\n")}\n\n${FAILURE_GUIDANCE}`);
+ return 1;
+ }
+ const n = Object.keys(computed.types).length;
+ console.log(`core vocabulary pin ok (${n} types owned by ${CORE_PROVIDER_ID}).`);
+ return 0;
+}
+
+if (import.meta.main) process.exit(main());
diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh
index 0589452977..a2962f53cd 100755
--- a/scripts/ci-local.sh
+++ b/scripts/ci-local.sh
@@ -586,6 +586,13 @@ gate_requirements_ledger() { bun_install && bun scripts/check-requirements-ledge
# the cross-port manifest and spec/metamodel — 72 concrete subtypes.
gate_requirements_vocabulary() { bun_install && bun scripts/check-requirements-vocabulary.ts && bun scripts/test-requirements-vocabulary.ts; }
+# ── the core provider's vocabulary is pinned ────────────────────────────────────
+# New vocabulary lives in a pack (a separate provider) until a second consumer needs it
+# in core (GOVERNANCE.md, "Extension packs and the core metamodel"). The pin turns that
+# into a failing gate: adding a type, attribute or child rule under metaobjects-core-types
+# changes the computed view and fails with a message pointing at the pack mechanism.
+gate_core_vocabulary_pin() { bun_install && bun scripts/check-core-vocabulary-pin.ts && bun scripts/test-core-vocabulary-pin.ts; }
+
# ── forward scaffolding: a requirement may come BEFORE its vocabulary ──────────
# Phase 3. Author the promise and the counterexample first, then scaffold the
# spec/metamodel entry it implies. The gate half is that the scaffolder proposes
@@ -1322,6 +1329,7 @@ run_gates_bun() {
if want gates; then step_if bun "scripts/ typecheck" gate_scripts_typecheck; fi
if want gates; then step_if bun "requirements ledger verifies" gate_requirements_ledger; fi
if want gates; then step_if bun "requirements cover vocabulary" gate_requirements_vocabulary; fi
+ if want gates; then step_if bun "core vocabulary is pinned" gate_core_vocabulary_pin; fi
if want gates; then step_if bun "metamodel scaffolder" gate_scaffold_metamodel; fi
if want gates; then step_if bun "requirement harness" gate_requirement_harness; fi
if want gates; then step_if bun "fixture-lint" gate_fixture_lint; fi
diff --git a/scripts/generate-embedded-metamodel.ts b/scripts/generate-embedded-metamodel.ts
index 804058ffbf..fe08fde727 100644
--- a/scripts/generate-embedded-metamodel.ts
+++ b/scripts/generate-embedded-metamodel.ts
@@ -89,6 +89,9 @@ const CONCEPT_DIRS: Record = {
// ADR-0066: the declared API surface (api / operation / binding) and lifecycle moves
api: "core/api",
transition: "core/transition",
+ // The view-expressions pack (origin.function + the projection union/grain attrs)
+ // is its own provider; its data file is spec/metamodel/view-expressions.json.
+ "view-expressions": "persistence/view-expressions",
// depth-1
template: "template",
// FR-033 S1.5: the prompt concern provider lives in template/ (templateProvider
diff --git a/scripts/test-core-vocabulary-pin.ts b/scripts/test-core-vocabulary-pin.ts
new file mode 100644
index 0000000000..7fa1ba26f5
--- /dev/null
+++ b/scripts/test-core-vocabulary-pin.ts
@@ -0,0 +1,90 @@
+#!/usr/bin/env bun
+// Self-test for scripts/check-core-vocabulary-pin.ts.
+//
+// The gate is only worth having if adding vocabulary to core actually fails it, with a
+// message that sends the author to GOVERNANCE.md and the pack mechanism, and if adding
+// the same vocabulary to a pack does NOT. Each is driven against a throwaway copy of
+// spec/metamodel, and every failing case asserts on the message, not just the exit code.
+import { spawnSync } from "node:child_process";
+import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { composeRegistry } from "../server/typescript/packages/metadata/src/provider.js";
+import { coreTypesProvider } from "../server/typescript/packages/metadata/src/core-types.js";
+import { computeCorePin } from "./check-core-vocabulary-pin.js";
+
+const ROOT = process.cwd();
+const CHECK = join(ROOT, "scripts/check-core-vocabulary-pin.ts");
+const SPEC = join(ROOT, "spec/metamodel");
+const PIN = join(ROOT, "fixtures/registry-conformance/core-vocabulary.pin.json");
+
+let failures = 0;
+const ok = (cond: boolean, what: string): void => {
+ if (!cond) {
+ failures++;
+ console.error(`FAIL: ${what}`);
+ } else console.log(`ok: ${what}`);
+};
+
+function run(specDir: string): { status: number; output: string } {
+ const r = spawnSync("bun", [CHECK, "--spec", specDir, "--pin", PIN], { encoding: "utf8" });
+ return { status: r.status ?? 1, output: `${r.stdout}${r.stderr}` };
+}
+
+function withSpecCopy(edit: (dir: string) => void): { status: number; output: string } {
+ const dir = mkdtempSync(join(tmpdir(), "mo-core-pin-"));
+ try {
+ cpSync(SPEC, dir, { recursive: true });
+ edit(dir);
+ return run(dir);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+}
+
+function editJson(dir: string, file: string, fn: (d: { types?: { children?: unknown[] }[]; extends?: unknown[] }) => void): void {
+ const p = join(dir, file);
+ const d = JSON.parse(readFileSync(p, "utf8"));
+ fn(d);
+ writeFileSync(p, JSON.stringify(d, null, 2));
+}
+
+const newAttr = { type: "attr", subType: "string", name: "shinyNewThing", min: 0, max: 1, description: "x" };
+
+// 1. The committed pin matches the spec as it stands.
+ok(run(SPEC).status === 0, "the committed pin matches spec/metamodel");
+
+// 2. A new attribute on a core type fails, naming it and pointing at the pack mechanism.
+{
+ const r = withSpecCopy((d) => editJson(d, "field.json", (j) => j.types![0]!.children!.push(newAttr)));
+ ok(r.status !== 0, "adding an attribute to a core type fails the gate");
+ ok(r.output.includes("@shinyNewThing"), " the failure names the added attribute");
+ ok(r.output.includes("GOVERNANCE.md") && r.output.includes("pack"), " the failure points at GOVERNANCE.md and the pack mechanism");
+}
+
+// 3. A new type under the core provider fails.
+{
+ const r = withSpecCopy((d) =>
+ editJson(d, "index.json", (j) => j.types!.push({ type: "gizmo", subType: "base", description: "x", children: [] } as never)),
+ );
+ ok(r.status !== 0 && r.output.includes("gizmo.base"), "adding a type to the core provider fails, naming it");
+}
+
+// 4. The same vocabulary under a pack's provider id is fine: that is the point.
+{
+ const r = withSpecCopy((d) => {
+ editJson(d, "view-expressions.json", (j) => j.types!.push({ type: "gizmo", subType: "base", description: "x", children: [] } as never));
+ });
+ ok(r.status === 0, "the same type added to a pack (not core) does not fail");
+}
+
+// 5. The TypeScript registry has no type outside the pin (catches vocabulary registered in code).
+{
+ const pin = computeCorePin(SPEC);
+ const known = new Set([...Object.keys(pin.types), ...pin.registeredInCode]);
+ const registry = composeRegistry([coreTypesProvider]);
+ const stray = registry.allTypes().map((t) => `${t.type}.${t.subType}`).filter((k) => !known.has(k));
+ ok(stray.length === 0, `the core-only TypeScript registry holds no unpinned type${stray.length ? `: ${stray.join(", ")}` : ""}`);
+}
+
+process.exit(failures === 0 ? 0 : 1);
diff --git a/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs b/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs
index fc8da8e30b..b71aaad737 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/ConformanceAdapter.cs
@@ -164,6 +164,10 @@ public static class ConformanceAdapter
["metaobjects-ui"] = MetaObjects.Presentation.Ui.UiMetaDataProvider.Instance,
// View.textarea @rows and the view.image attrs (ui-web.json).
["metaobjects-ui-web"] = MetaObjects.Presentation.Ui.UiWebMetaDataProvider.Instance,
+ // Business rules (api/operation/binding/transition) and view expressions
+ // (origin.function, @union/@grain): their own packs, outside core-types.
+ ["metaobjects-rules"] = MetaObjects.Core.Rules.RulesMetaDataProvider.Instance,
+ ["metaobjects-view-expressions"] = MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance,
["metaobjects-prompt"] = MetaObjects.Template.PromptMetaDataProvider.Instance,
// Back-compat alias: pre-rename fixtures (and other ports' fixtures) still name the
// provider "metaobjects-template"; map it to the renamed prompt provider — the same
diff --git a/server/csharp/MetaObjects.Conformance.Tests/CoreTypesTests.cs b/server/csharp/MetaObjects.Conformance.Tests/CoreTypesTests.cs
index 2ec454f11d..a381c290a1 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/CoreTypesTests.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/CoreTypesTests.cs
@@ -138,7 +138,8 @@ public void Core_provider_registers_correct_subtypes_for_source()
[Fact]
public void Core_provider_registers_correct_subtypes_for_origin()
{
- var reg = ComposedRegistry();
+ // origin.function is the view-expressions pack's, so it is composed with core.
+ var reg = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
Assert.Equal(ORIGIN_SUBTYPES.OrderBy(s => s),
reg.AllSubTypesOf(TYPE_ORIGIN).OrderBy(s => s));
}
diff --git a/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs b/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs
index 49dd9ebeac..0c5d588e28 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/FixtureDiscovery.cs
@@ -95,6 +95,9 @@ public static class FixtureDiscovery
"metaobjects-ui",
// View.textarea @rows and the view.image attrs.
"metaobjects-ui-web",
+ // The business-rules and view-expressions packs are in the default bundle.
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
};
///
diff --git a/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs b/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs
index 80dd26d275..12aabca357 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/FullCoreRegistry.cs
@@ -27,6 +27,8 @@ internal static class FullCoreRegistry
MetaObjects.Presentation.Ui.UiMetaDataProvider.Instance,
MetaObjects.Presentation.Ui.UiWebMetaDataProvider.Instance,
MetaObjects.Template.PromptMetaDataProvider.Instance,
+ MetaObjects.Core.Rules.RulesMetaDataProvider.Instance,
+ MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance,
};
/// Compose a fresh registry from the full core bundle.
diff --git a/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs b/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs
index 10b4c0a4cf..5fd76673a0 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/RegistryManifestConformanceTests.cs
@@ -33,6 +33,8 @@ public void Emit_matches_the_committed_cross_port_canonical()
// View.textarea @rows and the view.image attrs (ui-web.json).
MetaObjects.Presentation.Ui.UiWebMetaDataProvider.Instance,
MetaObjects.Template.PromptMetaDataProvider.Instance,
+ MetaObjects.Core.Rules.RulesMetaDataProvider.Instance,
+ MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance,
DocumentationTypes.DocTypesProvider,
});
@@ -70,6 +72,8 @@ public void Every_registered_per_type_attr_is_explicitly_classified()
// View.textarea @rows and the view.image attrs (ui-web.json).
MetaObjects.Presentation.Ui.UiWebMetaDataProvider.Instance,
MetaObjects.Template.PromptMetaDataProvider.Instance,
+ MetaObjects.Core.Rules.RulesMetaDataProvider.Instance,
+ MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance,
DocumentationTypes.DocTypesProvider,
});
diff --git a/server/csharp/MetaObjects.Conformance.Tests/ViewVocabularyRc21LoaderTests.cs b/server/csharp/MetaObjects.Conformance.Tests/ViewVocabularyRc21LoaderTests.cs
index 9a5385e8f0..56e83908c5 100644
--- a/server/csharp/MetaObjects.Conformance.Tests/ViewVocabularyRc21LoaderTests.cs
+++ b/server/csharp/MetaObjects.Conformance.Tests/ViewVocabularyRc21LoaderTests.cs
@@ -48,7 +48,7 @@ private static string Computed(string name, string subType, object expr) =>
private static IReadOnlyList Load(params string[] extra)
{
var json = $$"""{ "metadata.root": { "package": "acme", "children": [ {{Entities}}{{string.Concat(extra.Select(e => ",\n" + e))}} ] } }""";
- var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider });
+ var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
return new MetaDataLoader(registry).Load([new InMemoryStringSource(json, format: MetaDataFormat.Json, id: "v.json")]).Errors;
}
@@ -186,7 +186,7 @@ public void A_passthrough_over_a_reverse_hop_needs_a_unique_identity(bool unique
{ "field.string": { "name": "note", "children": [ { "origin.passthrough": { "@from": "Receipt.note", "@via": "Order.receipts" } } ] } },
{ "identity.primary": { "name": "id", "extends": "Order.primary" } } ] } } ] } }
""";
- var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider });
+ var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
var errors = new MetaDataLoader(registry).Load([new InMemoryStringSource(json, format: MetaDataFormat.Json, id: "r.json")]).Errors;
if (unique) Assert.Empty(errors);
else Assert.Contains(errors, e => e.Code.ToString() == "ERR_ORIGIN_CARDINALITY");
@@ -211,7 +211,7 @@ public void An_extender_whose_view_widened_over_a_tph_base_warns(string filter,
{ "source.rdb": { "@kind": "view", "@view": "v_trucks" } },
{ "field.string": { "name": "payload", "extends": "Truck.payloadClass" } } ] } } ] } }
""";
- var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider });
+ var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
var result = new MetaDataLoader(registry).Load([new InMemoryStringSource(json, format: MetaDataFormat.Json, id: "t.json")]);
Assert.Empty(result.Errors);
var hit = result.Warnings.Where(w => w.Contains("TruckRow", StringComparison.Ordinal)).ToList();
@@ -245,7 +245,7 @@ public void An_extender_whose_base_changed_over_a_non_tph_base_warns(string ownF
{ "source.rdb": { "@kind": "view", "@view": "v_invoice_rows" } },
{{ownField}} ] } } ] } }
""";
- var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider });
+ var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
var result = new MetaDataLoader(registry).Load([new InMemoryStringSource(json, format: MetaDataFormat.Json, id: "n.json")]);
Assert.Empty(result.Errors);
var hit = result.Warnings.Where(w => w.Contains("InvoiceRow", StringComparison.Ordinal)).ToList();
@@ -276,7 +276,7 @@ public void Origin_function_checks_its_declared_signature(string args, string pa
{ "field.string": { "name": "tier", "children": [ { "origin.passthrough": { "@from": "C2.tier" } } ] } },
{ "identity.primary": { "name": "id", "extends": "C2.id" } } ] } } ] } }
""";
- var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider });
+ var registry = Provider.ComposeRegistry(new[] { CoreTypes.CoreTypesProvider, MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance });
var errors = new MetaDataLoader(registry).Load([new InMemoryStringSource(json, format: MetaDataFormat.Json, id: "f.json")]).Errors;
if (fragment is null) Assert.Empty(errors);
else Assert.Contains(errors, e => e.Code.ToString() == "ERR_INVALID_ORIGIN" && e.Message.Contains(fragment, StringComparison.Ordinal));
diff --git a/server/csharp/MetaObjects/Core/Object/ObjectSchema.cs b/server/csharp/MetaObjects/Core/Object/ObjectSchema.cs
index 4d4d7b5a51..3a6e96d0ac 100644
--- a/server/csharp/MetaObjects/Core/Object/ObjectSchema.cs
+++ b/server/csharp/MetaObjects/Core/Object/ObjectSchema.cs
@@ -87,20 +87,4 @@ public static class ObjectSchema
"returns — lowered to an outer SQL WHERE. Resolves against the " +
"projection's own declared fields; an aggregate-derived field is not " +
"addressable (fail-closed).");
-
- ///
- /// rc.21 part B — @union / @unionAll (U15) and @grain / @grainOrdinal (U14) on an
- /// object.projection. Descriptions are single-sourced from spec/metamodel/object.json.
- ///
- public static readonly IReadOnlyList ProjectionShapeAttrs =
- [
- new AttrSchema(Name: ObjectConstants.OBJECT_PROJECTION_ATTR_UNION, ValueType: AttrConstants.ATTR_SUBTYPE_STRING, Required: false, IsArray: true,
- Description: "rc.21: the view is this projection's rows UNIONed with each named projection's rows."),
- new AttrSchema(Name: ObjectConstants.OBJECT_PROJECTION_ATTR_UNION_ALL, ValueType: AttrConstants.ATTR_SUBTYPE_BOOLEAN, Required: false,
- Description: "rc.21: with @union, keep duplicate rows (UNION ALL)."),
- new AttrSchema(Name: ObjectConstants.OBJECT_PROJECTION_ATTR_GRAIN, ValueType: AttrConstants.ATTR_SUBTYPE_STRING, Required: false,
- Description: "rc.21: the view has one row per element of this base-entity field.object array."),
- new AttrSchema(Name: ObjectConstants.OBJECT_PROJECTION_ATTR_GRAIN_ORDINAL, ValueType: AttrConstants.ATTR_SUBTYPE_STRING, Required: false,
- Description: "rc.21: with @grain, the projection field that holds the element's 1-based position."),
- ];
}
diff --git a/server/csharp/MetaObjects/Core/Rules/RulesMetaDataProvider.cs b/server/csharp/MetaObjects/Core/Rules/RulesMetaDataProvider.cs
new file mode 100644
index 0000000000..ff952fb9f2
--- /dev/null
+++ b/server/csharp/MetaObjects/Core/Rules/RulesMetaDataProvider.cs
@@ -0,0 +1,67 @@
+// The metaobjects-rules pack: the declared API surface (api / operation / binding) and
+// lifecycle moves (transition, a child of field.enum). ADR-0066, experimental.
+//
+// It is its OWN provider rather than part of metaobjects-core-types, so a project can
+// leave it out. It is in the default bundle (CoreTypes.LibraryProviders), so every
+// existing model loads unchanged. The pack owns its types AND the child rules that admit
+// them on types core owns (metadata.root holds an api; field.enum holds a transition):
+// both ride in api.json / transition.json `extends`. Compose the pack out and the types
+// are unknown. The cross-node rules (Loader/ValidationPasses.Rules.cs) only fire on
+// rules nodes. Mirrors the TS rulesProvider.
+
+using MetaObjects.Core.Api;
+using MetaObjects.Core.Transition;
+using MetaObjects.Meta;
+using MetaObjects.Registry.Spec;
+using static MetaObjects.Shared.BaseTypes;
+
+namespace MetaObjects.Core.Rules;
+
+/// The business-rules pack provider (metaobjects-rules).
+public sealed class RulesMetaDataProvider : IMetaDataTypeProvider
+{
+ /// The shared singleton — composed into the default registry.
+ public static readonly IMetaDataTypeProvider Instance = new RulesMetaDataProvider();
+
+ /// The provider id — matches the "provider" field of api.json / transition.json.
+ public const string ProviderId = "metaobjects-rules";
+
+ private static readonly Lazy Reader = new(SpecMetamodelReader.Load);
+
+ public string Id => ProviderId;
+
+ public string? Description =>
+ "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).";
+
+ public IReadOnlyList Dependencies => ["metaobjects-core-types"];
+
+ public void RegisterTypes(TypeRegistry registry)
+ {
+ // One class per type; the subtype carries no behaviour of its own. Descriptions, the
+ // structural child graph and cardinalities come from api.json / transition.json via
+ // ApplySpecDescriptions.
+ void Reg(string type, string subType, List attrs, Func factory) =>
+ registry.Register(new TypeDefinition(
+ typeId: new TypeId(type, subType),
+ description: $"{type} ({subType})",
+ childRules: [new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)],
+ factory: factory,
+ attributes: attrs));
+
+ Reg(TYPE_API, SUBTYPE_BASE, [], (tid, n) => new MetaApi(tid, n));
+ Reg(TYPE_API, ApiConstants.API_SUBTYPE_OPERATIONAL, [], (tid, n) => new MetaApi(tid, n));
+ Reg(TYPE_OPERATION, SUBTYPE_BASE, [.. ApiSchema.OperationBaseAttrs], (tid, n) => new MetaOperation(tid, n));
+ Reg(TYPE_OPERATION, ApiConstants.OPERATION_SUBTYPE_COMMAND, [.. ApiSchema.CommandAttrs], (tid, n) => new MetaOperation(tid, n));
+ Reg(TYPE_OPERATION, ApiConstants.OPERATION_SUBTYPE_QUERY, [.. ApiSchema.QueryAttrs], (tid, n) => new MetaOperation(tid, n));
+ Reg(TYPE_BINDING, SUBTYPE_BASE, [], (tid, n) => new MetaBinding(tid, n));
+ Reg(TYPE_BINDING, ApiConstants.BINDING_SUBTYPE_REST, [.. ApiSchema.RestBindingAttrs], (tid, n) => new MetaBinding(tid, n));
+ Reg(TYPE_TRANSITION, SUBTYPE_BASE, [.. TransitionSchema.TransitionBaseAttrs], (tid, n) => new MetaTransition(tid, n));
+ Reg(TYPE_TRANSITION, TransitionConstants.TRANSITION_SUBTYPE_ACTION, [.. TransitionSchema.ActionAttrs], (tid, n) => new MetaTransition(tid, n));
+
+ // The child rules that admit the pack's types on core types.
+ registry.ApplyProviderExtends(
+ Reader.Value,
+ ProviderId,
+ new Dictionary>(StringComparer.Ordinal));
+ }
+}
diff --git a/server/csharp/MetaObjects/CoreTypes.cs b/server/csharp/MetaObjects/CoreTypes.cs
index 5e09ffe41d..915399f1b9 100644
--- a/server/csharp/MetaObjects/CoreTypes.cs
+++ b/server/csharp/MetaObjects/CoreTypes.cs
@@ -80,6 +80,10 @@ public static class CoreTypes
// vocabulary only TypeScript implements so far. C# loads them strictly and ignores them.
MetaObjects.Presentation.Ui.UiWebMetaDataProvider.Instance,
MetaObjects.Template.PromptMetaDataProvider.Instance,
+ // The business-rules and view-expressions packs: their own providers, in the default
+ // bundle so every existing model loads unchanged.
+ MetaObjects.Core.Rules.RulesMetaDataProvider.Instance,
+ MetaObjects.Persistence.ViewExpressions.ViewExpressionsMetaDataProvider.Instance,
];
///
@@ -272,8 +276,6 @@ private static void RegisterCoreTypeDefs(TypeRegistry registry)
Wildcard(TYPE_TEMPLATE),
// Capability requirements are declared beside the entities they describe.
Wildcard(TYPE_REQUIREMENT),
- // ADR-0030 / ADR-0066 — a declared API surface is a top-level, packaged node.
- Wildcard(TYPE_API),
],
(tid, n) => new MetaRoot(tid, n),
[]));
@@ -323,7 +325,7 @@ private static void RegisterCoreTypeDefs(TypeRegistry registry)
// declare; its structural child graph also comes from the spec.
List objectAttrs = subType switch
{
- OBJECT_SUBTYPE_PROJECTION => [.. ObjectSchema.ObjectAttrs, ObjectSchema.ProjectionFilterAttr, .. ObjectSchema.ProjectionShapeAttrs, ObjectSchema.CollectionNameAttr],
+ OBJECT_SUBTYPE_PROJECTION => [.. ObjectSchema.ObjectAttrs, ObjectSchema.ProjectionFilterAttr, ObjectSchema.CollectionNameAttr],
OBJECT_SUBTYPE_REPORT => [.. ObjectSchema.ObjectAttrs, .. ReportingSchema.ReportAttrs, ObjectSchema.CollectionNameAttr],
OBJECT_SUBTYPE_ENTITY => [.. ObjectSchema.ObjectAttrs, ObjectSchema.CollectionNameAttr],
_ => ObjectSchema.ObjectAttrs.ToList(),
@@ -481,7 +483,8 @@ private static void RegisterCoreTypeDefs(TypeRegistry registry)
}
// origin — 3 subtypes (base + passthrough + aggregate); dispatch to subtype class
- foreach (string subType in ORIGIN_SUBTYPES)
+ // origin.function is the view-expressions pack's, not core's.
+ foreach (string subType in ORIGIN_SUBTYPES.Where(t => t != ORIGIN_SUBTYPE_FUNCTION))
{
Func nodeFactory =
OriginClassMap.TryGetValue(subType, out var originFactory)
@@ -688,23 +691,6 @@ private static void RegisterCoreTypeDefs(TypeRegistry registry)
ReportingSchema.SegmentAttrsMap[subType].ToList()));
}
- // ADR-0030 / ADR-0066 — the declared API surface (api / operation / binding) and
- // lifecycle moves (transition, a child of field.enum). One class per type; the
- // subtype carries no behaviour of its own. Descriptions, the structural child graph
- // and cardinalities come from the embedded api.json / transition.json via
- // ApplySpecDescriptions; the cross-node rules live in Loader/ValidationPasses.Rules.cs.
- void RegisterRulesType(string type, string subType, List attrs, Func factory) =>
- registry.Register(Def(type, subType, $"{type} ({subType})", [Wildcard(TYPE_ATTR)], factory, attrs));
- RegisterRulesType(TYPE_API, SUBTYPE_BASE, [], (tid, n) => new MetaApi(tid, n));
- RegisterRulesType(TYPE_API, API_SUBTYPE_OPERATIONAL, [], (tid, n) => new MetaApi(tid, n));
- RegisterRulesType(TYPE_OPERATION, SUBTYPE_BASE, [.. ApiSchema.OperationBaseAttrs], (tid, n) => new MetaOperation(tid, n));
- RegisterRulesType(TYPE_OPERATION, OPERATION_SUBTYPE_COMMAND, [.. ApiSchema.CommandAttrs], (tid, n) => new MetaOperation(tid, n));
- RegisterRulesType(TYPE_OPERATION, OPERATION_SUBTYPE_QUERY, [.. ApiSchema.QueryAttrs], (tid, n) => new MetaOperation(tid, n));
- RegisterRulesType(TYPE_BINDING, SUBTYPE_BASE, [], (tid, n) => new MetaBinding(tid, n));
- RegisterRulesType(TYPE_BINDING, BINDING_SUBTYPE_REST, [.. ApiSchema.RestBindingAttrs], (tid, n) => new MetaBinding(tid, n));
- RegisterRulesType(TYPE_TRANSITION, SUBTYPE_BASE, [.. TransitionSchema.TransitionBaseAttrs], (tid, n) => new MetaTransition(tid, n));
- RegisterRulesType(TYPE_TRANSITION, TRANSITION_SUBTYPE_ACTION, [.. TransitionSchema.ActionAttrs], (tid, n) => new MetaTransition(tid, n));
-
// template — fourth-pillar metatype (FR-004). prompt + output + toolcall;
// attr-only children. A single MetaTemplate class backs every subtype (mirrors
// source/requirement); per-subtype attr schemas drive validation (prompt +
diff --git a/server/csharp/MetaObjects/Persistence/ViewExpressions/ViewExpressionsMetaDataProvider.cs b/server/csharp/MetaObjects/Persistence/ViewExpressions/ViewExpressionsMetaDataProvider.cs
new file mode 100644
index 0000000000..24341453c2
--- /dev/null
+++ b/server/csharp/MetaObjects/Persistence/ViewExpressions/ViewExpressionsMetaDataProvider.cs
@@ -0,0 +1,46 @@
+// The metaobjects-view-expressions pack (new in 1.3.0): origin.function (a value computed by
+// a database function the project owns) and the projection shape attrs @union / @unionAll /
+// @grain / @grainOrdinal. Its own provider so a project can leave it out; it is in the
+// default bundle, so every existing model loads unchanged. Types and attrs are declared in
+// the embedded view-expressions.json. Mirrors the TS viewExpressionsProvider.
+
+using MetaObjects.Meta;
+using MetaObjects.Persistence.Origin;
+using MetaObjects.Registry.Spec;
+using static MetaObjects.Shared.BaseTypes;
+
+namespace MetaObjects.Persistence.ViewExpressions;
+
+/// The view-expressions pack provider (metaobjects-view-expressions).
+public sealed class ViewExpressionsMetaDataProvider : IMetaDataTypeProvider
+{
+ /// The shared singleton — composed into the default registry.
+ public static readonly IMetaDataTypeProvider Instance = new ViewExpressionsMetaDataProvider();
+
+ /// The provider id — matches view-expressions.json's "provider" field.
+ public const string ProviderId = "metaobjects-view-expressions";
+
+ private static readonly Lazy Reader = new(SpecMetamodelReader.Load);
+
+ public string Id => ProviderId;
+
+ public string? Description =>
+ "View expressions: origin.function and the projection @union / @unionAll / @grain / @grainOrdinal attrs.";
+
+ public IReadOnlyList Dependencies => ["metaobjects-core-types"];
+
+ public void RegisterTypes(TypeRegistry registry)
+ {
+ registry.Register(new TypeDefinition(
+ typeId: new TypeId(TYPE_ORIGIN, OriginConstants.ORIGIN_SUBTYPE_FUNCTION),
+ description: $"Origin ({OriginConstants.ORIGIN_SUBTYPE_FUNCTION})",
+ childRules: [new ChildRule(TYPE_ATTR, CHILD_RULE_WILDCARD, CHILD_RULE_WILDCARD)],
+ factory: (tid, n) => new MetaOrigin(tid, n),
+ attributes: OriginSchema.OriginAttrsMap[OriginConstants.ORIGIN_SUBTYPE_FUNCTION].ToList()));
+
+ registry.ApplyProviderExtends(
+ Reader.Value,
+ ProviderId,
+ new Dictionary>(StringComparer.Ordinal));
+ }
+}
diff --git a/server/csharp/MetaObjects/Registry.cs b/server/csharp/MetaObjects/Registry.cs
index 499512274d..742b24cd88 100644
--- a/server/csharp/MetaObjects/Registry.cs
+++ b/server/csharp/MetaObjects/Registry.cs
@@ -639,9 +639,20 @@ public void Extend(string type, string subType, IReadOnlyList? attri
foreach (ChildRule rule in childRules ?? [])
{
def.AppendChildRule(rule);
+ // Remembered so the strict structural pass (which rebuilds a spec-declared
+ // type's rules from its own JSON) keeps what a pack added.
+ string extKey = $"{type}.{subType}";
+ if (!_extendedRules.TryGetValue(extKey, out List? added))
+ {
+ _extendedRules[extKey] = added = new List();
+ }
+ added.Add(rule);
}
}
+ // (type.subType) -> structural child rules a provider added through Extend.
+ private readonly Dictionary> _extendedRules = new(StringComparer.Ordinal);
+
// ------------------------------------------------------------------
// FR-033 (provider re-home) — apply a concern provider's extends directives
// ------------------------------------------------------------------
@@ -698,9 +709,12 @@ public void ApplyProviderExtends(
}
List schemas = d.Attrs.Select(ToAttrSchema).ToList();
+ List rules = (d.StructChildren ?? [])
+ .Select(sc => new ChildRule(sc.ChildType, sc.ChildSubType, sc.ChildName, sc.Min, sc.Max, sc.MaxIsNull, sc.Named))
+ .ToList();
foreach (string subType in targets)
{
- Extend(d.Type, subType, attributes: schemas);
+ Extend(d.Type, subType, attributes: schemas, childRules: rules);
}
}
}
@@ -868,6 +882,10 @@ private void ApplyStrictStructuralChildren(MetaObjects.Registry.Spec.SpecMetamod
sc.ChildType, sc.ChildSubType, sc.ChildName,
sc.Min, sc.Max, sc.MaxIsNull, sc.Named));
}
+ if (_extendedRules.TryGetValue(key, out List? extended))
+ {
+ rules.AddRange(extended); // a pack's rule on a type it does not own
+ }
_defs[key] = CopyValidation(def, new TypeDefinition(
id, def.Description, rules, def.Factory, def.Attributes.ToList(),
diff --git a/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs b/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs
index 975ab06c7c..12ddcc8281 100644
--- a/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs
+++ b/server/csharp/MetaObjects/Registry/Spec/SpecMetamodelReader.cs
@@ -1,6 +1,6 @@
// FR-033 — the C# reader for the shared spec/metamodel/*.json provider files.
//
-// The 21 JSON files (one per concern provider) are the cross-port single source of
+// The 22 JSON files (one per concern provider) are the cross-port single source of
// truth for every type / attr / common-attr DESCRIPTION (+ optional rules/example/
// whenToUse). They are byte-identical across the ports by design, so each port READS
// them rather than hand-copying the prose — the exact duplication FR-033 kills.
@@ -108,20 +108,21 @@ public sealed record SpecExtendsDirective(
string Type,
IReadOnlyList SubTypes,
bool WildcardSubType,
- IReadOnlyList Attrs);
+ IReadOnlyList Attrs,
+ IReadOnlyList? StructChildren = null);
///
/// FR-033 — the C# reader over the embedded spec/metamodel/*.json provider files.
///
public sealed class SpecMetamodelReader
{
- /// The 21 shared provider-definition file names (keep in lockstep with spec/metamodel/).
+ /// The 22 shared provider-definition file names (keep in lockstep with spec/metamodel/).
public static readonly IReadOnlyList SpecFiles = new[]
{
"api.json", "attr.json", "db.json", "documentation.json", "field.json", "identity.json",
"index.json", "layout.json", "object.json", "origin.json", "prompt.json",
"relationship.json", "reporting.json", "requirement.json", "source.json", "template.json",
- "transition.json", "ui.json", "ui-web.json", "validator.json", "view.json",
+ "transition.json", "ui.json", "ui-web.json", "validator.json", "view-expressions.json", "view.json",
};
/// The embedded-resource logical-name prefix (RootNamespace + folder).
@@ -173,7 +174,7 @@ private SpecMetamodelReader() { }
// ------------------------------------------------------------------
///
- /// Load + parse the 21 embedded spec/metamodel/*.json files off this
+ /// Load + parse the 22 embedded spec/metamodel/*.json files off this
/// assembly's manifest resources (AOT-safe).
///
/// If a spec file is missing or unparseable.
@@ -295,6 +296,9 @@ private void Parse(JsonElement provider)
AllowedValues: a.AllowedValues,
Default: a.Default));
}
+ // A pack that owns a type also lets an existing type hold it: a structural
+ // child under `extends` is a child rule added to the target.
+ List structChildren = ParseStructChildren(e);
_extendsBlocks.Add(new ExtendsBlock(type, subTypes, wildcard, attrs));
if (providerName is not null)
{
@@ -303,7 +307,7 @@ private void Parse(JsonElement provider)
list = new List();
_providerExtends[providerName] = list;
}
- list.Add(new SpecExtendsDirective(type, subTypes, wildcard, directiveAttrs));
+ list.Add(new SpecExtendsDirective(type, subTypes, wildcard, directiveAttrs, structChildren));
}
}
}
diff --git a/server/csharp/MetaObjects/SpecMetamodel/api.json b/server/csharp/MetaObjects/SpecMetamodel/api.json
index 0f30e16e08..6c803bfba0 100644
--- a/server/csharp/MetaObjects/SpecMetamodel/api.json
+++ b/server/csharp/MetaObjects/SpecMetamodel/api.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "api",
@@ -69,5 +69,14 @@
{ "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH)." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "metadata",
+ "subType": "root",
+ "children": [
+ { "type": "api", "subType": "*", "name": "*", "min": 0, "max": null, "description": "A declared API surface (ADR-0030, ADR-0066): a top-level, packaged node. Contributed by the business-rules pack." }
+ ]
+ }
]
}
diff --git a/server/csharp/MetaObjects/SpecMetamodel/field.json b/server/csharp/MetaObjects/SpecMetamodel/field.json
index 8d4c5a2185..46a2f064ce 100644
--- a/server/csharp/MetaObjects/SpecMetamodel/field.json
+++ b/server/csharp/MetaObjects/SpecMetamodel/field.json
@@ -149,7 +149,6 @@
"whenToUse": "A field is a fixed, closed set of string values. Set @values so the union type, DB CHECK, and validation are generated — don't hand-roll constants + checks.",
"rules": "Required @values is a non-empty, duplicate-free set; each member must match ^[A-Za-z_][A-Za-z0-9_]*$ so it is a legal identifier in every target language, and is its own stored string unless @stringValueMap (string) or @intValueMap (integer) maps it. Optional FR-010/FR-011 overlays add tolerant-extract aliasing (@enumAlias), per-member docs (@enumDoc), an uncoercible-value fallback (@coerceDefault, must be one of @values), and ASCII normalization mode (@normalize).",
"children": [
- { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." },
{ "type": "attr", "subType": "string", "name": "values", "isArray": true, "min": 1, "max": 1, "description": "Member symbols of an enum-subtype field. Declaration order is significant; each is a legal identifier and its own stored string unless @stringValueMap or @intValueMap maps it." },
{ "type": "attr", "subType": "boolean", "name": "provided", "min": 0, "max": 1, "description": "FR-019: marks an abstract package-level field.enum as externally provided — codegen references the type (resolved via per-port codegen config) instead of materializing it. Default false. Not a field attr — it lives on the type declaration." },
{ "type": "attr", "subType": "int", "name": "maxLength", "min": 0, "max": 1, "description": "Column length of a string-stored enum (drives VARCHAR(n)); every member must fit. Overrides the project's enums.maxLength. Refused with @intValueMap, whose column is an integer. Justified in ADR-0023 Amendment 1." },
diff --git a/server/csharp/MetaObjects/SpecMetamodel/object.json b/server/csharp/MetaObjects/SpecMetamodel/object.json
index eb44fedc67..ddf3c6eeec 100644
--- a/server/csharp/MetaObjects/SpecMetamodel/object.json
+++ b/server/csharp/MetaObjects/SpecMetamodel/object.json
@@ -54,10 +54,6 @@
"rules": "object.projection is a derived read-only representation: every field is extends-bound, origin-derived, or self-declared-under-external-assembly, and all are read-only at the subtype level. Identity is optional and, when present, MUST extend an entity identity. Sources are restricted to read-only @kinds. The declared field set IS the exposure — an inclusive list, fail-closed. A projection NEVER declares relationships (derivation is expressed via @via, not a relationship child) and NEVER co-locates templates — hence its child set omits both relationship and template. The assembly origins (origin.aggregate / origin.computed / origin.first) live HERE, not on object.value; a SOURCELESS projection is the legal shape for a wire-assembled read model, and a template-level @payloadRef/@responseRef may target one (#210). See ADR-0028 (object taxonomy, projection).",
"children": [
{ "type": "attr", "subType": "filter", "name": "filter", "min": 0, "max": 1, "description": "Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: \"\", startOf? }) on a date or timestamp field (rc.19)." },
- { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
- { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
- { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
- { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." },
{ "type": "attr", "subType": "string", "name": "collectionName", "min": 0, "max": 1, "description": "The name of this object's collection, in the object's own casing (e.g. 'CaseHistory', 'Queues'): the REST collection segment (snake_cased) in every port, the reverse-finder names in C#, TypeScript and Python, the C# DbSet property, and the TypeScript list function, list hook and Drizzle table variable. It need not be a grammatical plural. Absent, the project's pluralizer derives it from the object's name (naming.collections in .metaobjects/config.json; built in: standard, none; an application may register its own)." }
]
},
diff --git a/server/csharp/MetaObjects/SpecMetamodel/origin.json b/server/csharp/MetaObjects/SpecMetamodel/origin.json
index e2539d6d66..c4fde970f9 100644
--- a/server/csharp/MetaObjects/SpecMetamodel/origin.json
+++ b/server/csharp/MetaObjects/SpecMetamodel/origin.json
@@ -42,20 +42,6 @@
{ "type": "attr", "subType": "expression", "name": "expr", "min": 1, "max": 1, "description": "The structured expression tree computing this field's value from the base entity's own fields (closed node grammar; shares the filter op vocabulary). Its inferred root type must equal the field's declared subType (ERR_COMPUTED_TYPE_MISMATCH)." }
]
},
- {
- "type": "origin",
- "subType": "function",
- "implementedIn": ["typescript", "csharp"],
- "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
- "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
- "children": [
- { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
- { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
- { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
- { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
- { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
- ]
- },
{
"type": "origin",
"subType": "first",
diff --git a/server/csharp/MetaObjects/SpecMetamodel/transition.json b/server/csharp/MetaObjects/SpecMetamodel/transition.json
index cbac9d3ef7..2cb444d160 100644
--- a/server/csharp/MetaObjects/SpecMetamodel/transition.json
+++ b/server/csharp/MetaObjects/SpecMetamodel/transition.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "transition",
@@ -23,5 +23,14 @@
{ "type": "attr", "subType": "expression", "name": "condition", "min": 0, "max": 1, "description": "A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "field",
+ "subType": "enum",
+ "children": [
+ { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." }
+ ]
+ }
]
}
diff --git a/server/csharp/MetaObjects/SpecMetamodel/view-expressions.json b/server/csharp/MetaObjects/SpecMetamodel/view-expressions.json
new file mode 100644
index 0000000000..4db3c0ca57
--- /dev/null
+++ b/server/csharp/MetaObjects/SpecMetamodel/view-expressions.json
@@ -0,0 +1,31 @@
+{
+ "provider": "metaobjects-view-expressions",
+ "types": [
+ {
+ "type": "origin",
+ "subType": "function",
+ "implementedIn": ["typescript", "csharp"],
+ "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
+ "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
+ { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
+ { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
+ { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
+ { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
+ ]
+ }
+ ],
+ "extends": [
+ {
+ "type": "object",
+ "subType": "projection",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
+ { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
+ { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
+ { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." }
+ ]
+ }
+ ]
+}
diff --git a/server/java/metadata/src/main/java/com/metaobjects/MetaRoot.java b/server/java/metadata/src/main/java/com/metaobjects/MetaRoot.java
index 03006079d7..3b9325adf0 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/MetaRoot.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/MetaRoot.java
@@ -126,7 +126,6 @@ public static void registerTypes(MetaDataRegistry registry) {
.optionalChild(MetaValidator.TYPE_VALIDATOR, "*", "*")
.optionalChild(com.metaobjects.template.TemplateConstants.TYPE_TEMPLATE, "*", "*")
.optionalChild(com.metaobjects.requirement.MetaRequirement.TYPE_REQUIREMENT, "*", "*")
- .optionalChild(com.metaobjects.api.ApiConstants.TYPE_API, "*", "*")
.optionalChild(com.metaobjects.attr.MetaAttribute.TYPE_ATTR, "*", "*")
);
log.debug("Registered MetaRoot type (metadata.root) with unified registry");
diff --git a/server/java/metadata/src/main/java/com/metaobjects/api/RulesTypesMetaDataProvider.java b/server/java/metadata/src/main/java/com/metaobjects/api/RulesTypesMetaDataProvider.java
index 1e87661e69..85d207a649 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/api/RulesTypesMetaDataProvider.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/api/RulesTypesMetaDataProvider.java
@@ -17,6 +17,9 @@
import com.metaobjects.registry.MetaDataRegistry;
import com.metaobjects.registry.MetaDataTypeProvider;
+import com.metaobjects.registry.spec.SpecMetamodelReader;
+
+import java.util.Map;
import com.metaobjects.transition.ActionTransition;
/**
@@ -33,8 +36,15 @@ public void registerTypes(MetaDataRegistry registry) {
CommandOperation.registerTypes(registry);
RestBinding.registerTypes(registry);
ActionTransition.registerTypes(registry);
+ // The child rules that admit these types on types core owns (an api under
+ // metadata.root, a transition under field.enum) ride in api.json / transition.json
+ // under the pack's logical id: leaving the pack out leaves neither type nor rule.
+ registry.applyProviderExtends(SpecMetamodelReader.load(), LOGICAL_ID, Map.of());
}
+ /** The pack's cross-port logical id, the {@code provider} of api.json and transition.json. */
+ public static final String LOGICAL_ID = "metaobjects-rules";
+
@Override
public String getProviderId() {
return "rules-types";
@@ -42,7 +52,7 @@ public String getProviderId() {
@Override
public String[] getDependencies() {
- return new String[]{"core-types"};
+ return new String[]{"core-types", "field-types"};
}
@Override
diff --git a/server/java/metadata/src/main/java/com/metaobjects/object/MetaObject.java b/server/java/metadata/src/main/java/com/metaobjects/object/MetaObject.java
index 8e33812bf5..17ccd7f67f 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/object/MetaObject.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/object/MetaObject.java
@@ -255,16 +255,8 @@ public static void registerEntityValueTypes(MetaDataRegistry registry) {
// object.projection, so it survives pruning here while staying off entity/value.
def.optionalAttributeWithConstraints(ATTR_FILTER)
.ofType(FilterAttribute.SUBTYPE_FILTER).asSingle();
- // rc.21 part B: @union / @unionAll (U15) and @grain / @grainOrdinal (U14), registered
- // so a strict load accepts them; the shape rules run in TypeScript and C#.
- def.optionalAttributeWithConstraints("union")
- .ofType(StringAttribute.SUBTYPE_STRING).asArray();
- def.optionalAttributeWithConstraints("unionAll")
- .ofType(com.metaobjects.attr.BooleanAttribute.SUBTYPE_BOOLEAN).asSingle();
- def.optionalAttributeWithConstraints("grain")
- .ofType(StringAttribute.SUBTYPE_STRING).asSingle();
- def.optionalAttributeWithConstraints("grainOrdinal")
- .ofType(StringAttribute.SUBTYPE_STRING).asSingle();
+ // @union / @unionAll / @grain / @grainOrdinal belong to the view-expressions pack
+ // (ViewExpressionsTypesMetaDataProvider), not to core.
});
// FR-044 — object.report: a fixed combination of dimensions and measures of ONE
diff --git a/server/java/metadata/src/main/java/com/metaobjects/origin/OriginTypesMetaDataProvider.java b/server/java/metadata/src/main/java/com/metaobjects/origin/OriginTypesMetaDataProvider.java
index 790f65e3b0..54bf2e6cd1 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/origin/OriginTypesMetaDataProvider.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/origin/OriginTypesMetaDataProvider.java
@@ -31,7 +31,7 @@ public void registerTypes(MetaDataRegistry registry) {
AggregateOrigin.registerTypes(registry);
ComputedOrigin.registerTypes(registry);
FirstOrigin.registerTypes(registry);
- FunctionOrigin.registerTypes(registry);
+ // origin.function belongs to the view-expressions pack (ViewExpressionsTypesMetaDataProvider).
}
@Override
diff --git a/server/java/metadata/src/main/java/com/metaobjects/origin/ViewExpressionsTypesMetaDataProvider.java b/server/java/metadata/src/main/java/com/metaobjects/origin/ViewExpressionsTypesMetaDataProvider.java
new file mode 100644
index 0000000000..e55e087708
--- /dev/null
+++ b/server/java/metadata/src/main/java/com/metaobjects/origin/ViewExpressionsTypesMetaDataProvider.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2026 Doug Mealing LLC dba Meta Objects
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.metaobjects.origin;
+
+import com.metaobjects.registry.MetaDataRegistry;
+import com.metaobjects.registry.MetaDataTypeProvider;
+import com.metaobjects.registry.spec.SpecMetamodelReader;
+
+import java.util.Map;
+
+/**
+ * View-expressions pack (rc.21 part B): {@code origin.function} and the projection attrs
+ * {@code @union} / {@code @unionAll} / {@code @grain} / {@code @grainOrdinal}. It is its own
+ * provider so a project can leave it out; it is in the default bundle, so every existing model
+ * loads unchanged. The types and attrs are registered so a strict load accepts them; the shape
+ * rules run in TypeScript and C#, and only the TypeScript view emitter lowers them.
+ *
+ * The projection attrs are data-driven from {@code spec/metamodel/view-expressions.json},
+ * read under the pack's logical id {@value #LOGICAL_ID}.
+ */
+public class ViewExpressionsTypesMetaDataProvider implements MetaDataTypeProvider {
+
+ /** The pack's cross-port logical id, the {@code provider} of view-expressions.json. */
+ public static final String LOGICAL_ID = "metaobjects-view-expressions";
+
+ @Override
+ public void registerTypes(MetaDataRegistry registry) {
+ FunctionOrigin.registerTypes(registry);
+ registry.applyProviderExtends(SpecMetamodelReader.load(), LOGICAL_ID, Map.of());
+ }
+
+ @Override
+ public String getProviderId() {
+ return "view-expressions-types";
+ }
+
+ @Override
+ public String[] getDependencies() {
+ return new String[]{"origin-types", "object-types"};
+ }
+
+ @Override
+ public String getDescription() {
+ return "View-expressions pack (origin.function; @union/@unionAll/@grain/@grainOrdinal on object.projection)";
+ }
+}
diff --git a/server/java/metadata/src/main/java/com/metaobjects/registry/MetaDataRegistry.java b/server/java/metadata/src/main/java/com/metaobjects/registry/MetaDataRegistry.java
index bc92b12ce3..b577b8a0ac 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/registry/MetaDataRegistry.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/registry/MetaDataRegistry.java
@@ -456,7 +456,12 @@ public synchronized void applyProviderExtends(
targets = d.subTypes();
}
for (String subType : targets) {
- applyExtendsAttrs(d.type(), subType, d.attrs());
+ if (!d.attrs().isEmpty()) {
+ applyExtendsAttrs(d.type(), subType, d.attrs());
+ }
+ if (!d.structChildren().isEmpty()) {
+ applyExtendsChildren(d.type(), subType, d.structChildren());
+ }
}
}
}
@@ -524,6 +529,40 @@ void applyExtendsAttrs(String type, String subType,
register(builder.build());
}
+ /**
+ * Add a directive's STRUCTURAL child rules to one registered {@code (type, subType)}, so a
+ * pack that owns a child type is also the provider that lets a type another provider owns
+ * hold it. Leaving the pack out leaves neither the type nor the rule. The rules are
+ * remembered so {@link #applyStrictStructuralChildren} (which replaces a declared type's
+ * structural rules with the spec's own) re-adds them.
+ */
+ private void applyExtendsChildren(String type, String subType,
+ List children) {
+ MetaDataTypeId typeId = new MetaDataTypeId(type, subType);
+ TypeDefinition existing = typeDefinitions.get(typeId);
+ if (existing == null) {
+ throw new MetaDataException(
+ "applyProviderExtends: target type must be registered before extension: "
+ + typeId.toQualifiedName());
+ }
+ TypeDefinitionBuilder builder = TypeDefinitionBuilder.from(existing);
+ builder.withRegistry(this);
+ Map remembered =
+ providerStructuralChildren.computeIfAbsent(typeId, k -> new LinkedHashMap<>());
+ for (com.metaobjects.registry.spec.SpecMetamodelReader.StructChild sc : children) {
+ ChildRequirement req = ChildRequirement.structural(
+ sc.childName(), sc.childType(), sc.childSubType(),
+ sc.min(), sc.max(), sc.maxIsNull(), sc.named());
+ builder.childRequirement(req);
+ remembered.put(directKey(req), req);
+ }
+ register(builder.build());
+ }
+
+ /** Structural child rules provider {@code extends} directives added, by target type. */
+ private final Map> providerStructuralChildren =
+ new LinkedHashMap<>();
+
/** Map a spec {@code valueType} string to the Java attr subtype constant. */
private static String extendsValueTypeToAttrSubtype(String valueType) {
if (valueType == null) {
@@ -1139,6 +1178,8 @@ && isLibraryOrigin(id.type(), id.subType(), req.getName())) {
}
directReqs.put(directKey(req), req);
}
+ // Rules a provider's extends added (its pack's child types) sit beside the spec's.
+ directReqs.putAll(providerStructuralChildren.getOrDefault(id, Map.of()));
TypeDefinition rebuilt = new TypeDefinition(
def.getImplementationClass(), id.type(), id.subType(), def.getDescription(),
diff --git a/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java b/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java
index 52ee65ddd4..097348ee82 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/registry/RegistryManifest.java
@@ -139,8 +139,26 @@ public static MetaDataRegistry composeMetamodelRegistry() {
* @return a new, unsealed registry (the caller may seal it)
*/
public static MetaDataRegistry composeMetamodelRegistry(Collection extra) {
+ return composeMetamodelRegistry(extra, Set.of());
+ }
+
+ /**
+ * As {@link #composeMetamodelRegistry(Collection)}, leaving out the metamodel providers whose
+ * {@link MetaDataTypeProvider#getProviderId()} is in {@code leaveOut} — how a project composes a
+ * vocabulary pack (business rules, view expressions) out of the default bundle. A provider that
+ * another provider depends on cannot be left out (compose fails with
+ * {@code ERR_PROVIDER_MISSING_DEPENDENCY}).
+ */
+ public static MetaDataRegistry composeMetamodelRegistry(Collection extra,
+ Collection leaveOut) {
Objects.requireNonNull(extra, "extra must not be null");
- List providers = new ArrayList<>(metamodelProviders());
+ Objects.requireNonNull(leaveOut, "leaveOut must not be null");
+ List providers = new ArrayList<>();
+ for (MetaDataTypeProvider p : metamodelProviders()) {
+ if (!leaveOut.contains(p.getProviderId())) {
+ providers.add(p);
+ }
+ }
providers.addAll(extra);
MetaDataRegistry registry = MetaDataRegistry.compose(providers);
// Force the lazy core-constraint init NOW: it expands the named inherited
@@ -234,7 +252,13 @@ public static MetaDataRegistry defaultLoaderRegistry() {
* @return a new, sealed registry
*/
public static MetaDataRegistry composeLoaderRegistry(Collection extra) {
- MetaDataRegistry r = composeMetamodelRegistry(extra);
+ return composeLoaderRegistry(extra, Set.of());
+ }
+
+ /** As {@link #composeLoaderRegistry(Collection)}, leaving out the named metamodel providers. */
+ public static MetaDataRegistry composeLoaderRegistry(Collection extra,
+ Collection leaveOut) {
+ MetaDataRegistry r = composeMetamodelRegistry(extra, leaveOut);
// The core constraint set is normally lazy-loaded on first
// getAllValidationConstraints() read — which, post-seal, would
// happen DURING a load and trip the seal guard. Force it now,
@@ -266,6 +290,7 @@ public static List metamodelProviders() {
new com.metaobjects.requirement.RequirementTypesMetaDataProvider(),
new com.metaobjects.reporting.ReportingTypesMetaDataProvider(),
new com.metaobjects.api.RulesTypesMetaDataProvider(),
+ new com.metaobjects.origin.ViewExpressionsTypesMetaDataProvider(),
new com.metaobjects.database.CoreDBMetaDataProvider(),
new com.metaobjects.source.SourceTypesMetaDataProvider(),
new com.metaobjects.origin.OriginTypesMetaDataProvider(),
diff --git a/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java b/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java
index 2afef7757c..afe8d47f71 100644
--- a/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java
+++ b/server/java/metadata/src/main/java/com/metaobjects/registry/spec/SpecMetamodelReader.java
@@ -66,12 +66,13 @@ public final class SpecMetamodelReader {
/** Classpath directory the metadata jar embeds the spec files under. */
public static final String EMBED_DIR = "spec/metamodel";
- /** The 21 shared provider-definition file names (keep in lockstep with {@code spec/metamodel/}). */
+ /** The 22 shared provider-definition file names (keep in lockstep with {@code spec/metamodel/}). */
public static final List SPEC_FILES = List.of(
"api.json", "attr.json", "db.json", "documentation.json", "field.json", "identity.json",
"index.json", "layout.json", "object.json", "origin.json", "prompt.json",
"relationship.json", "reporting.json", "requirement.json", "source.json",
- "template.json", "transition.json", "ui.json", "ui-web.json", "validator.json", "view.json");
+ "template.json", "transition.json", "ui.json", "ui-web.json", "validator.json", "view.json",
+ "view-expressions.json");
/** Wildcard token used in the JSON for "any type / any subType". */
private static final String WILDCARD = "*";
@@ -150,9 +151,13 @@ public record ExtendsAttr(String name, String valueType, boolean isArray, boolea
* (e.g. {@code ui.json}'s {@code field.*} or {@code prompt.json}'s
* {@code template.prompt}). {@code wildcardSubType} is true for the {@code "*"}
* any-subtype matcher; otherwise {@code subTypes} lists the exact subtypes.
+ * {@code structChildren} are the STRUCTURAL child rules the directive adds to each
+ * target (a pack that owns a child type also carries the rule that admits it on a type
+ * another provider owns, e.g. the business-rules pack's {@code api} on
+ * {@code metadata.root}); empty for an attr-only directive.
*/
public record ExtendsDirective(String type, List subTypes, boolean wildcardSubType,
- List attrs) {
+ List attrs, List structChildren) {
}
// providerName -> the extends directives declared in that provider's spec file
@@ -261,7 +266,8 @@ private void parse(JsonObject provider) {
if (providerName != null) {
providerExtends
.computeIfAbsent(providerName, k -> new ArrayList<>())
- .add(new ExtendsDirective(type, subTypes, wildcard, directiveAttrs));
+ .add(new ExtendsDirective(type, subTypes, wildcard, directiveAttrs,
+ parseStructChildren(e)));
}
}
}
diff --git a/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider b/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider
index a3be93e703..1bdea5d8a1 100644
--- a/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider
+++ b/server/java/metadata/src/main/resources/META-INF/services/com.metaobjects.registry.MetaDataTypeProvider
@@ -12,6 +12,7 @@ com.metaobjects.api.RulesTypesMetaDataProvider
com.metaobjects.database.CoreDBMetaDataProvider
com.metaobjects.source.SourceTypesMetaDataProvider
com.metaobjects.origin.OriginTypesMetaDataProvider
+com.metaobjects.origin.ViewExpressionsTypesMetaDataProvider
com.metaobjects.documentation.DocumentationMetaDataProvider
com.metaobjects.view.ViewTypesMetaDataProvider
com.metaobjects.layout.LayoutTypesMetaDataProvider
diff --git a/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java b/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java
index 6ca0316fe8..8d5d35b026 100644
--- a/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java
+++ b/server/java/metadata/src/test/java/com/metaobjects/conformance/ConformanceTest.java
@@ -148,10 +148,18 @@ public class ConformanceTest {
"origin-types",
"requirement-types",
// FR-044 reporting vocabulary (dimension / measure / segment).
- "reporting-types",
- // ADR-0066 business-rules vocabulary (api / operation / binding / transition).
+ "reporting-types"
+ ),
+ // ADR-0066 business-rules pack (api / operation / binding / transition) and the
+ // rc.21 view-expressions pack (origin.function, @union / @grain on a projection):
+ // their own providers, in the default bundle, left out of a fixture that does not
+ // name them.
+ "metaobjects-rules", List.of(
"rules-types"
),
+ "metaobjects-view-expressions", List.of(
+ "view-expressions-types"
+ ),
// The corpus's "metaobjects-db" provider maps to Java's
// CoreDBMetaDataProvider (id "database-extensions"), which registers the
// physical RDB attributes (@column / @dbType / @dbColumnType / ...).
@@ -373,6 +381,23 @@ static void runConformanceChecks(FixtureDiscovery.Fixture fix,
opts.setProviders(List.of(ConformanceTestProviders.EXAMPLE_CUSTOM_VOCABULARY));
}
MetaDataLoader loader = new MetaDataLoader(opts, MetaDataLoader.SUBTYPE_MANUAL, loaderName);
+ // The rules and view-expressions packs are in the default bundle; a fixture that
+ // declares a provider set without them loads against a registry composed without them.
+ List packsLeftOut = new ArrayList<>();
+ if (fix.hasProvidersJson) {
+ if (!fix.requiredProviders.contains("metaobjects-rules")) {
+ packsLeftOut.add("rules-types");
+ }
+ if (!fix.requiredProviders.contains("metaobjects-view-expressions")) {
+ packsLeftOut.add("view-expressions-types");
+ }
+ }
+ if (!packsLeftOut.isEmpty() && !handledByCompose) {
+ loader.setTypeRegistry(com.metaobjects.registry.RegistryManifest.composeLoaderRegistry(
+ fix.requiredProviders.contains("example-custom-vocabulary")
+ ? List.of(ConformanceTestProviders.EXAMPLE_CUSTOM_VOCABULARY) : List.of(),
+ packsLeftOut));
+ }
// A fixture that requires the test-only example-template-briefing provider
// gets its OWN registry (core + briefing) via setTypeRegistry — no global
// singleton mutation, so the success/fail provider-extension pair is
diff --git a/server/python/src/metaobjects/core_types.py b/server/python/src/metaobjects/core_types.py
index 8942619aaa..25f82745aa 100644
--- a/server/python/src/metaobjects/core_types.py
+++ b/server/python/src/metaobjects/core_types.py
@@ -77,33 +77,6 @@
OBJECT_SUBTYPES,
)
from .meta.core.relationship.meta_relationship import MetaRelationship
-from .meta.core.api.api_constants import (
- API_SUBTYPE_OPERATIONAL,
- BINDING_ATTR_METHOD,
- BINDING_ATTR_PATH,
- BINDING_SUBTYPE_REST,
- HTTP_METHODS,
- OPERATION_ATTR_ERRORS,
- OPERATION_ATTR_INPUT_REF,
- OPERATION_ATTR_MANY,
- OPERATION_ATTR_OBJECT_REF,
- OPERATION_ATTR_OUTPUT_REF,
- OPERATION_ATTR_PERMISSION,
- OPERATION_ATTR_PUBLIC,
- OPERATION_ATTR_TRANSITIONS,
- OPERATION_SUBTYPE_COMMAND,
- OPERATION_SUBTYPE_QUERY,
-)
-from .meta.core.api.meta_api import MetaApi, MetaBinding, MetaOperation
-from .meta.core.transition.meta_transition import MetaTransition
-from .meta.core.transition.transition_constants import (
- TRANSITION_ATTR_CONDITION,
- TRANSITION_ATTR_FROM,
- TRANSITION_ATTR_PERMISSION,
- TRANSITION_ATTR_PUBLIC,
- TRANSITION_ATTR_TO,
- TRANSITION_SUBTYPE_ACTION,
-)
from .meta.core.reporting.meta_dimension import MetaDimension
from .meta.core.reporting.meta_measure import MetaMeasure
from .meta.core.reporting.meta_segment import MetaSegment
@@ -219,10 +192,6 @@
TYPE_RELATIONSHIP,
TYPE_REQUIREMENT,
TYPE_SEGMENT,
- TYPE_API,
- TYPE_BINDING,
- TYPE_OPERATION,
- TYPE_TRANSITION,
TYPE_SOURCE,
TYPE_TEMPLATE,
TYPE_VALIDATOR,
@@ -289,8 +258,6 @@ def _register_subtypes(
factory=MetaRoot,
description="Root metadata document",
child_rules=[
- # ADR-0030 / ADR-0066 — a declared API surface is a top-level, packaged node.
- ChildRule(TYPE_API, "*"),
ChildRule(TYPE_FIELD, "*"),
ChildRule(TYPE_OBJECT, "*"),
# Capability requirements are declared beside the entities they describe.
@@ -382,14 +349,6 @@ def _register_subtypes(
required=False,
)
)
- # rc.21 part B: @union / @unionAll (U15), @grain / @grainOrdinal (U14). Registered so a
- # strict load accepts them; the shape rules run in TypeScript and C# (see CHANGELOG).
- _def.attrs.extend([
- AttrSchema(name="union", value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
- AttrSchema(name="unionAll", value_type="boolean", required=False),
- AttrSchema(name="grain", value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name="grainOrdinal", value_type=ATTR_SUBTYPE_STRING, required=False),
- ])
break
# FR-044 — object.report: declared dimensions x measures of ONE entity (@from),
@@ -533,104 +492,6 @@ def _register_subtypes(
)
)
-# ADR-0030 / ADR-0066 — the declared API surface (api / operation / binding) and the
-# lifecycle moves of a field.enum (transition). Attr scoping is per-subtype exactly as
-# spec/metamodel/api.json and transition.json declare it; the cross-node rules live in
-# loader/validate_rules.py. Mirrors TS core-types.ts.
-_OPERATION_COMMON_ATTRS = [
- AttrSchema(name=OPERATION_ATTR_INPUT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=OPERATION_ATTR_OUTPUT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=OPERATION_ATTR_OBJECT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=OPERATION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=OPERATION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
-]
-# The registry anchors: not authorable, they carry what every subtype of the type shares.
-core_provider.add(TypeDefinition(type=TYPE_API, sub_type=SUBTYPE_BASE, factory=MetaApi))
-core_provider.add(
- TypeDefinition(
- type=TYPE_OPERATION,
- sub_type=SUBTYPE_BASE,
- factory=MetaOperation,
- attrs=list(_OPERATION_COMMON_ATTRS),
- child_rules=[ChildRule(TYPE_BINDING, "*")],
- )
-)
-core_provider.add(TypeDefinition(type=TYPE_BINDING, sub_type=SUBTYPE_BASE, factory=MetaBinding))
-core_provider.add(
- TypeDefinition(
- type=TYPE_TRANSITION,
- sub_type=SUBTYPE_BASE,
- factory=MetaTransition,
- attrs=[
- AttrSchema(name=TRANSITION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=TRANSITION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
- ],
- )
-)
-core_provider.add(
- TypeDefinition(
- type=TYPE_API,
- sub_type=API_SUBTYPE_OPERATIONAL,
- factory=MetaApi,
- child_rules=[ChildRule(TYPE_OPERATION, "*")],
- )
-)
-core_provider.add(
- TypeDefinition(
- type=TYPE_OPERATION,
- sub_type=OPERATION_SUBTYPE_COMMAND,
- factory=MetaOperation,
- attrs=[
- *_OPERATION_COMMON_ATTRS,
- AttrSchema(name=OPERATION_ATTR_TRANSITIONS, value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
- AttrSchema(name=OPERATION_ATTR_ERRORS, value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
- ],
- child_rules=[ChildRule(TYPE_BINDING, "*")],
- )
-)
-core_provider.add(
- TypeDefinition(
- type=TYPE_OPERATION,
- sub_type=OPERATION_SUBTYPE_QUERY,
- factory=MetaOperation,
- attrs=[
- *_OPERATION_COMMON_ATTRS,
- AttrSchema(name=OPERATION_ATTR_MANY, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
- ],
- child_rules=[ChildRule(TYPE_BINDING, "*")],
- )
-)
-core_provider.add(
- TypeDefinition(
- type=TYPE_BINDING,
- sub_type=BINDING_SUBTYPE_REST,
- factory=MetaBinding,
- attrs=[
- AttrSchema(
- name=BINDING_ATTR_METHOD,
- value_type=ATTR_SUBTYPE_STRING,
- required=False,
- allowed_values=HTTP_METHODS,
- ),
- AttrSchema(name=BINDING_ATTR_PATH, value_type=ATTR_SUBTYPE_STRING, required=False),
- ],
- )
-)
-core_provider.add(
- TypeDefinition(
- type=TYPE_TRANSITION,
- sub_type=TRANSITION_SUBTYPE_ACTION,
- factory=MetaTransition,
- attrs=[
- AttrSchema(name=TRANSITION_ATTR_FROM, value_type=ATTR_SUBTYPE_STRING, required=True, is_array=True),
- AttrSchema(name=TRANSITION_ATTR_TO, value_type=ATTR_SUBTYPE_STRING, required=True),
- AttrSchema(name=TRANSITION_ATTR_CONDITION, value_type=ATTR_SUBTYPE_EXPRESSION, required=False),
- AttrSchema(name=TRANSITION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name=TRANSITION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
- ],
- )
-)
-
# field.* (one factory, data_type by subtype)
# Note: FIELD_SUBTYPE_ENUM is excluded from FIELD_SUBTYPES; it is registered
# separately below with its required @values AttrSchema (sharing these child rules).
@@ -833,8 +694,7 @@ def _register_subtypes(
# TypeRegistry.extend, matching the TS promptProvider split. @values + @provided
# stay in core (they are core field.enum properties, declared in field.json).
],
- # ADR-0066: a field.enum may carry lifecycle moves.
- child_rules=[*_FIELD_CHILD_RULES, ChildRule(TYPE_TRANSITION, "*")],
+ child_rules=list(_FIELD_CHILD_RULES),
)
)
@@ -1218,24 +1078,6 @@ def _register_subtypes(
)
)
-# origin.function (rc.21 part B, U10) — a call of a database function the project owns:
-# @function required, @schema and @args optional. Registered so a strict load accepts it.
-core_provider.add(
- TypeDefinition(
- type=TYPE_ORIGIN,
- sub_type="function",
- factory=MetaOrigin,
- attrs=[
- AttrSchema(name="function", value_type=ATTR_SUBTYPE_STRING, required=True),
- AttrSchema(name="schema", value_type=ATTR_SUBTYPE_STRING, required=False),
- AttrSchema(name="args", value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
- AttrSchema(name="params", value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
- AttrSchema(name="returns", value_type=ATTR_SUBTYPE_STRING, required=True),
- ],
- child_rules=[ChildRule(TYPE_ATTR, "*")],
- )
-)
-
# view.* (base + 13 control kinds). FR-033 — view.currency's @locale is re-homed to
# the UI domain provider (`ui_provider`, metaobjects-ui) via TypeRegistry.extend
# (ui.json declares @locale on view.currency), matching the TS uiProvider split. Core
@@ -1450,6 +1292,10 @@ def _register_subtypes(
from .meta.presentation.ui.ui_provider import ui_provider # noqa: E402
from .meta.presentation.ui.ui_web_provider import ui_web_provider # noqa: E402
from .documentation.doc_provider import doc_provider # noqa: E402
+from .meta.core.rules.rules_provider import rules_provider # noqa: E402
+from .meta.persistence.view_expressions.view_expressions_provider import ( # noqa: E402
+ view_expressions_provider,
+)
core_providers: list[Provider] = [
core_provider,
@@ -1460,6 +1306,10 @@ def _register_subtypes(
# view.textarea @rows and the view.image attrs (ui-web.json): cross-port vocabulary
# only TypeScript implements so far. Loaded strictly here and ignored.
ui_web_provider,
+ # The business-rules pack (ADR-0066) and the view-expressions pack are their own
+ # providers, in the default bundle so every existing model loads unchanged.
+ rules_provider,
+ view_expressions_provider,
]
# #265 — the ids of the LIBRARY providers above, as a frozen set. Consulted by
diff --git a/server/python/src/metaobjects/meta/core/rules/__init__.py b/server/python/src/metaobjects/meta/core/rules/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/server/python/src/metaobjects/meta/core/rules/rules_provider.py b/server/python/src/metaobjects/meta/core/rules/rules_provider.py
new file mode 100644
index 0000000000..a7f2a11857
--- /dev/null
+++ b/server/python/src/metaobjects/meta/core/rules/rules_provider.py
@@ -0,0 +1,166 @@
+"""rules_provider — the business-rules pack (cross-port ``metaobjects-rules``).
+
+ADR-0030 / ADR-0066, experimental: the declared API surface (api / operation /
+binding) and the lifecycle moves of a field.enum (transition). It is its OWN
+provider so a project can leave it out; it is in the default bundle
+(``core_providers``), so every existing model loads unchanged.
+
+The pack owns its types AND the child rules that admit them on types core owns
+(``metadata.root`` holds an ``api``; ``field.enum`` holds a ``transition``): both ride
+in ``api.json`` / ``transition.json`` ``extends`` and are applied below. Compose the
+pack out and the types are unknown; nothing of it is left behind in core. Attr scoping
+is per-subtype exactly as those files declare it; the cross-node rules live in
+loader/validate_rules.py. Mirrors the TS ``rulesProvider``.
+"""
+from __future__ import annotations
+
+from ....provider import Provider
+from ....registry import AttrSchema, ChildRule, TypeDefinition, TypeRegistry
+from ....shared.base_types import (
+ SUBTYPE_BASE,
+ TYPE_API,
+ TYPE_BINDING,
+ TYPE_OPERATION,
+ TYPE_TRANSITION,
+)
+from ..attr.attr_constants import (
+ ATTR_SUBTYPE_BOOLEAN,
+ ATTR_SUBTYPE_EXPRESSION,
+ ATTR_SUBTYPE_STRING,
+)
+from ...provider_extends import register_extends
+from ..api.api_constants import (
+ API_SUBTYPE_OPERATIONAL,
+ BINDING_ATTR_METHOD,
+ BINDING_ATTR_PATH,
+ BINDING_SUBTYPE_REST,
+ HTTP_METHODS,
+ OPERATION_ATTR_ERRORS,
+ OPERATION_ATTR_INPUT_REF,
+ OPERATION_ATTR_MANY,
+ OPERATION_ATTR_OBJECT_REF,
+ OPERATION_ATTR_OUTPUT_REF,
+ OPERATION_ATTR_PERMISSION,
+ OPERATION_ATTR_PUBLIC,
+ OPERATION_ATTR_TRANSITIONS,
+ OPERATION_SUBTYPE_COMMAND,
+ OPERATION_SUBTYPE_QUERY,
+)
+from ..api.meta_api import MetaApi, MetaBinding, MetaOperation
+from ..transition.meta_transition import MetaTransition
+from ..transition.transition_constants import (
+ TRANSITION_ATTR_CONDITION,
+ TRANSITION_ATTR_FROM,
+ TRANSITION_ATTR_PERMISSION,
+ TRANSITION_ATTR_PUBLIC,
+ TRANSITION_ATTR_TO,
+ TRANSITION_SUBTYPE_ACTION,
+)
+
+rules_provider = Provider("metaobjects-rules", dependencies=("metaobjects-core-types",))
+
+_OPERATION_COMMON_ATTRS = [
+ AttrSchema(name=OPERATION_ATTR_INPUT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=OPERATION_ATTR_OUTPUT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=OPERATION_ATTR_OBJECT_REF, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=OPERATION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=OPERATION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
+]
+# The registry anchors: not authorable, they carry what every subtype of the type shares.
+rules_provider.add(TypeDefinition(type=TYPE_API, sub_type=SUBTYPE_BASE, factory=MetaApi))
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_OPERATION,
+ sub_type=SUBTYPE_BASE,
+ factory=MetaOperation,
+ attrs=list(_OPERATION_COMMON_ATTRS),
+ child_rules=[ChildRule(TYPE_BINDING, "*")],
+ )
+)
+rules_provider.add(TypeDefinition(type=TYPE_BINDING, sub_type=SUBTYPE_BASE, factory=MetaBinding))
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_TRANSITION,
+ sub_type=SUBTYPE_BASE,
+ factory=MetaTransition,
+ attrs=[
+ AttrSchema(name=TRANSITION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=TRANSITION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
+ ],
+ )
+)
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_API,
+ sub_type=API_SUBTYPE_OPERATIONAL,
+ factory=MetaApi,
+ child_rules=[ChildRule(TYPE_OPERATION, "*")],
+ )
+)
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_OPERATION,
+ sub_type=OPERATION_SUBTYPE_COMMAND,
+ factory=MetaOperation,
+ attrs=[
+ *_OPERATION_COMMON_ATTRS,
+ AttrSchema(name=OPERATION_ATTR_TRANSITIONS, value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
+ AttrSchema(name=OPERATION_ATTR_ERRORS, value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
+ ],
+ child_rules=[ChildRule(TYPE_BINDING, "*")],
+ )
+)
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_OPERATION,
+ sub_type=OPERATION_SUBTYPE_QUERY,
+ factory=MetaOperation,
+ attrs=[
+ *_OPERATION_COMMON_ATTRS,
+ AttrSchema(name=OPERATION_ATTR_MANY, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
+ ],
+ child_rules=[ChildRule(TYPE_BINDING, "*")],
+ )
+)
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_BINDING,
+ sub_type=BINDING_SUBTYPE_REST,
+ factory=MetaBinding,
+ attrs=[
+ AttrSchema(
+ name=BINDING_ATTR_METHOD,
+ value_type=ATTR_SUBTYPE_STRING,
+ required=False,
+ allowed_values=HTTP_METHODS,
+ ),
+ AttrSchema(name=BINDING_ATTR_PATH, value_type=ATTR_SUBTYPE_STRING, required=False),
+ ],
+ )
+)
+rules_provider.add(
+ TypeDefinition(
+ type=TYPE_TRANSITION,
+ sub_type=TRANSITION_SUBTYPE_ACTION,
+ factory=MetaTransition,
+ attrs=[
+ AttrSchema(name=TRANSITION_ATTR_FROM, value_type=ATTR_SUBTYPE_STRING, required=True, is_array=True),
+ AttrSchema(name=TRANSITION_ATTR_TO, value_type=ATTR_SUBTYPE_STRING, required=True),
+ AttrSchema(name=TRANSITION_ATTR_CONDITION, value_type=ATTR_SUBTYPE_EXPRESSION, required=False),
+ AttrSchema(name=TRANSITION_ATTR_PERMISSION, value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name=TRANSITION_ATTR_PUBLIC, value_type=ATTR_SUBTYPE_BOOLEAN, required=False),
+ ],
+ )
+)
+
+
+#: The embedded shared provider-definition files whose ``extends`` this pack applies.
+_EXTENDS_FILES = ("api.json", "transition.json")
+
+
+def _register(registry: TypeRegistry) -> None:
+ for file_name in _EXTENDS_FILES:
+ register_extends(registry, file_name)
+
+
+rules_provider.on_register(_register)
diff --git a/server/python/src/metaobjects/meta/persistence/view_expressions/__init__.py b/server/python/src/metaobjects/meta/persistence/view_expressions/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/server/python/src/metaobjects/meta/persistence/view_expressions/view_expressions_provider.py b/server/python/src/metaobjects/meta/persistence/view_expressions/view_expressions_provider.py
new file mode 100644
index 0000000000..e6d20aec73
--- /dev/null
+++ b/server/python/src/metaobjects/meta/persistence/view_expressions/view_expressions_provider.py
@@ -0,0 +1,52 @@
+"""view_expressions_provider — the view-expressions pack (cross-port
+``metaobjects-view-expressions``).
+
+The vocabulary a projection needs to replace a hand-written ``@sql`` view: the
+``origin.function`` type (a value computed by a database function the project owns)
+and the projection attrs ``@union`` / ``@unionAll`` / ``@grain`` / ``@grainOrdinal``.
+Cross-port vocabulary only TypeScript and C# act on (``implementedIn``): Python
+registers it so a shared model loads strictly here, and acts on none of it. It is its
+OWN provider so a project can leave it out; it is in the default bundle
+(``core_providers``), so every existing model loads unchanged.
+
+The projection attrs come from ``view-expressions.json`` ``extends``. Mirrors the TS
+``viewExpressionsProvider``.
+"""
+from __future__ import annotations
+
+from ....provider import Provider
+from ....registry import AttrSchema, ChildRule, TypeDefinition, TypeRegistry
+from ....shared.base_types import TYPE_ATTR, TYPE_ORIGIN
+from ...core.attr.attr_constants import ATTR_SUBTYPE_STRING
+from ...provider_extends import register_extends
+from ..origin.meta_origin import MetaOrigin
+
+view_expressions_provider = Provider(
+ "metaobjects-view-expressions", dependencies=("metaobjects-core-types",)
+)
+
+# origin.function (rc.21 part B, U10) — a call of a database function the project owns:
+# @function required, @schema and @args optional. Registered so a strict load accepts it.
+view_expressions_provider.add(
+ TypeDefinition(
+ type=TYPE_ORIGIN,
+ sub_type="function",
+ factory=MetaOrigin,
+ attrs=[
+ AttrSchema(name="function", value_type=ATTR_SUBTYPE_STRING, required=True),
+ AttrSchema(name="schema", value_type=ATTR_SUBTYPE_STRING, required=False),
+ AttrSchema(name="args", value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
+ AttrSchema(name="params", value_type=ATTR_SUBTYPE_STRING, required=False, is_array=True),
+ AttrSchema(name="returns", value_type=ATTR_SUBTYPE_STRING, required=True),
+ ],
+ child_rules=[ChildRule(TYPE_ATTR, "*")],
+ )
+)
+
+
+
+def _register(registry: TypeRegistry) -> None:
+ register_extends(registry, "view-expressions.json")
+
+
+view_expressions_provider.on_register(_register)
diff --git a/server/python/src/metaobjects/meta/provider_extends.py b/server/python/src/metaobjects/meta/provider_extends.py
index 704be6039d..7a38f96314 100644
--- a/server/python/src/metaobjects/meta/provider_extends.py
+++ b/server/python/src/metaobjects/meta/provider_extends.py
@@ -16,7 +16,7 @@
"""
from __future__ import annotations
-from ..registry import AttrSchema, TypeRegistry
+from ..registry import AttrSchema, ChildRule, TypeRegistry
from ..spec_metamodel import AttrEntry, ExtendsTarget, load_provider_extends
#: The wildcard subtype token used in the JSON ``extends`` matchers.
@@ -62,8 +62,20 @@ def register_extends(
for target in load_provider_extends(file_name):
sub_types = _expand_subtypes(target, expansion)
schemas = [attr_schema_from_entry(a) for a in target.attrs]
+ rules = [
+ ChildRule(
+ child_type=c.child_type,
+ child_sub_type=c.child_sub_type,
+ child_name=c.child_name,
+ min=c.min,
+ max=c.max,
+ max_is_null=c.max_is_null,
+ named=c.named,
+ )
+ for c in target.children
+ ]
for st in sub_types:
- registry.extend(target.type, st, attributes=schemas)
+ registry.extend(target.type, st, attributes=schemas, child_rules=rules)
def _expand_subtypes(
diff --git a/server/python/src/metaobjects/registry.py b/server/python/src/metaobjects/registry.py
index d484c182bc..160918f4ec 100644
--- a/server/python/src/metaobjects/registry.py
+++ b/server/python/src/metaobjects/registry.py
@@ -101,6 +101,11 @@ class TypeDefinition:
# downstream provider's type validates itself.
references: list[ReferenceDescriptor] = field(default_factory=list)
validate: NodeValidator | None = None
+ # Child rules a provider ADDED via ``TypeRegistry.extend`` (a pack that owns a
+ # child type and so also owns the rule admitting it on a type another provider
+ # owns). Kept separately so the strict structural pass, which re-derives the rest
+ # of ``child_rules`` from the shared spec, does not discard them.
+ extended_child_rules: list[ChildRule] = field(default_factory=list)
@property
def key(self) -> tuple[str, str]:
@@ -443,3 +448,4 @@ def extend(
for rule in child_rules or []:
definition.child_rules.append(rule)
+ definition.extended_child_rules.append(rule)
diff --git a/server/python/src/metaobjects/spec_metamodel/__init__.py b/server/python/src/metaobjects/spec_metamodel/__init__.py
index cc2cff63bb..08a23112d8 100644
--- a/server/python/src/metaobjects/spec_metamodel/__init__.py
+++ b/server/python/src/metaobjects/spec_metamodel/__init__.py
@@ -61,6 +61,7 @@
"ui.json",
"ui-web.json",
"validator.json",
+ "view-expressions.json",
"view.json",
)
@@ -419,6 +420,9 @@ class ExtendsTarget:
type: str
sub_type: str
attrs: tuple[AttrEntry, ...]
+ # Structural child rules the directive adds (a pack that owns a child type also
+ # owns the rule admitting it on a type another provider owns).
+ children: tuple[StructChild, ...] = ()
def load_provider_extends(file_name: str) -> list[ExtendsTarget]:
@@ -443,13 +447,14 @@ def load_provider_extends(file_name: str) -> list[ExtendsTarget]:
type_ = e.get("type")
sub_el = e.get("subType")
attrs = tuple(SpecMetamodelReader._parse_attr_children(e))
+ children = tuple(SpecMetamodelReader._parse_struct_children(e))
sub_types: list[str]
if isinstance(sub_el, list):
sub_types = [str(s) for s in sub_el]
else:
sub_types = [str(sub_el)] # explicit subtype, or the literal "*"
for st in sub_types:
- out.append(ExtendsTarget(type=type_, sub_type=st, attrs=attrs))
+ out.append(ExtendsTarget(type=type_, sub_type=st, attrs=attrs, children=children))
return out
@@ -569,6 +574,7 @@ def _apply_strict_structural_children(registry, reader: SpecMetamodelReader) ->
# Keep only the non-structural rules (the any-attr wildcard); drop every
# broad structural placement, then add the strict graph.
kept = [r for r in definition.child_rules if r.child_type == TYPE_ATTR]
+ extended = list(definition.extended_child_rules)
for sc in reader.structural_children(definition.type, definition.sub_type):
kept.append(
ChildRule(
@@ -581,6 +587,9 @@ def _apply_strict_structural_children(registry, reader: SpecMetamodelReader) ->
named=sc.named,
)
)
+ # A rule a provider added with ``extend`` survives: it is not in the shared
+ # type's own graph, it belongs to the pack that owns the child type.
+ kept.extend(r for r in extended if r not in kept)
definition.child_rules[:] = kept
diff --git a/server/python/src/metaobjects/spec_metamodel/api.json b/server/python/src/metaobjects/spec_metamodel/api.json
index 0f30e16e08..6c803bfba0 100644
--- a/server/python/src/metaobjects/spec_metamodel/api.json
+++ b/server/python/src/metaobjects/spec_metamodel/api.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "api",
@@ -69,5 +69,14 @@
{ "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH)." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "metadata",
+ "subType": "root",
+ "children": [
+ { "type": "api", "subType": "*", "name": "*", "min": 0, "max": null, "description": "A declared API surface (ADR-0030, ADR-0066): a top-level, packaged node. Contributed by the business-rules pack." }
+ ]
+ }
]
}
diff --git a/server/python/src/metaobjects/spec_metamodel/field.json b/server/python/src/metaobjects/spec_metamodel/field.json
index 8d4c5a2185..46a2f064ce 100644
--- a/server/python/src/metaobjects/spec_metamodel/field.json
+++ b/server/python/src/metaobjects/spec_metamodel/field.json
@@ -149,7 +149,6 @@
"whenToUse": "A field is a fixed, closed set of string values. Set @values so the union type, DB CHECK, and validation are generated — don't hand-roll constants + checks.",
"rules": "Required @values is a non-empty, duplicate-free set; each member must match ^[A-Za-z_][A-Za-z0-9_]*$ so it is a legal identifier in every target language, and is its own stored string unless @stringValueMap (string) or @intValueMap (integer) maps it. Optional FR-010/FR-011 overlays add tolerant-extract aliasing (@enumAlias), per-member docs (@enumDoc), an uncoercible-value fallback (@coerceDefault, must be one of @values), and ASCII normalization mode (@normalize).",
"children": [
- { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." },
{ "type": "attr", "subType": "string", "name": "values", "isArray": true, "min": 1, "max": 1, "description": "Member symbols of an enum-subtype field. Declaration order is significant; each is a legal identifier and its own stored string unless @stringValueMap or @intValueMap maps it." },
{ "type": "attr", "subType": "boolean", "name": "provided", "min": 0, "max": 1, "description": "FR-019: marks an abstract package-level field.enum as externally provided — codegen references the type (resolved via per-port codegen config) instead of materializing it. Default false. Not a field attr — it lives on the type declaration." },
{ "type": "attr", "subType": "int", "name": "maxLength", "min": 0, "max": 1, "description": "Column length of a string-stored enum (drives VARCHAR(n)); every member must fit. Overrides the project's enums.maxLength. Refused with @intValueMap, whose column is an integer. Justified in ADR-0023 Amendment 1." },
diff --git a/server/python/src/metaobjects/spec_metamodel/object.json b/server/python/src/metaobjects/spec_metamodel/object.json
index eb44fedc67..ddf3c6eeec 100644
--- a/server/python/src/metaobjects/spec_metamodel/object.json
+++ b/server/python/src/metaobjects/spec_metamodel/object.json
@@ -54,10 +54,6 @@
"rules": "object.projection is a derived read-only representation: every field is extends-bound, origin-derived, or self-declared-under-external-assembly, and all are read-only at the subtype level. Identity is optional and, when present, MUST extend an entity identity. Sources are restricted to read-only @kinds. The declared field set IS the exposure — an inclusive list, fail-closed. A projection NEVER declares relationships (derivation is expressed via @via, not a relationship child) and NEVER co-locates templates — hence its child set omits both relationship and template. The assembly origins (origin.aggregate / origin.computed / origin.first) live HERE, not on object.value; a SOURCELESS projection is the legal shape for a wire-assembled read model, and a template-level @payloadRef/@responseRef may target one (#210). See ADR-0028 (object taxonomy, projection).",
"children": [
{ "type": "attr", "subType": "filter", "name": "filter", "min": 0, "max": 1, "description": "Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: \"\", startOf? }) on a date or timestamp field (rc.19)." },
- { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
- { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
- { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
- { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." },
{ "type": "attr", "subType": "string", "name": "collectionName", "min": 0, "max": 1, "description": "The name of this object's collection, in the object's own casing (e.g. 'CaseHistory', 'Queues'): the REST collection segment (snake_cased) in every port, the reverse-finder names in C#, TypeScript and Python, the C# DbSet property, and the TypeScript list function, list hook and Drizzle table variable. It need not be a grammatical plural. Absent, the project's pluralizer derives it from the object's name (naming.collections in .metaobjects/config.json; built in: standard, none; an application may register its own)." }
]
},
diff --git a/server/python/src/metaobjects/spec_metamodel/origin.json b/server/python/src/metaobjects/spec_metamodel/origin.json
index e2539d6d66..c4fde970f9 100644
--- a/server/python/src/metaobjects/spec_metamodel/origin.json
+++ b/server/python/src/metaobjects/spec_metamodel/origin.json
@@ -42,20 +42,6 @@
{ "type": "attr", "subType": "expression", "name": "expr", "min": 1, "max": 1, "description": "The structured expression tree computing this field's value from the base entity's own fields (closed node grammar; shares the filter op vocabulary). Its inferred root type must equal the field's declared subType (ERR_COMPUTED_TYPE_MISMATCH)." }
]
},
- {
- "type": "origin",
- "subType": "function",
- "implementedIn": ["typescript", "csharp"],
- "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
- "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
- "children": [
- { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
- { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
- { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
- { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
- { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
- ]
- },
{
"type": "origin",
"subType": "first",
diff --git a/server/python/src/metaobjects/spec_metamodel/transition.json b/server/python/src/metaobjects/spec_metamodel/transition.json
index cbac9d3ef7..2cb444d160 100644
--- a/server/python/src/metaobjects/spec_metamodel/transition.json
+++ b/server/python/src/metaobjects/spec_metamodel/transition.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "transition",
@@ -23,5 +23,14 @@
{ "type": "attr", "subType": "expression", "name": "condition", "min": 0, "max": 1, "description": "A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "field",
+ "subType": "enum",
+ "children": [
+ { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." }
+ ]
+ }
]
}
diff --git a/server/python/src/metaobjects/spec_metamodel/view-expressions.json b/server/python/src/metaobjects/spec_metamodel/view-expressions.json
new file mode 100644
index 0000000000..4db3c0ca57
--- /dev/null
+++ b/server/python/src/metaobjects/spec_metamodel/view-expressions.json
@@ -0,0 +1,31 @@
+{
+ "provider": "metaobjects-view-expressions",
+ "types": [
+ {
+ "type": "origin",
+ "subType": "function",
+ "implementedIn": ["typescript", "csharp"],
+ "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
+ "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
+ { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
+ { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
+ { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
+ { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
+ ]
+ }
+ ],
+ "extends": [
+ {
+ "type": "object",
+ "subType": "projection",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
+ { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
+ { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
+ { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." }
+ ]
+ }
+ ]
+}
diff --git a/server/python/tests/conformance/conformance_adapter.py b/server/python/tests/conformance/conformance_adapter.py
index b5f4bc5375..94a2bf0946 100644
--- a/server/python/tests/conformance/conformance_adapter.py
+++ b/server/python/tests/conformance/conformance_adapter.py
@@ -10,7 +10,11 @@
from metaobjects import LoadResult, MetaDataLoader
from metaobjects.core_types import core_provider, core_providers
from metaobjects.documentation import doc_provider
+from metaobjects.meta.core.rules.rules_provider import rules_provider
from metaobjects.meta.persistence.db.db_provider import db_provider
+from metaobjects.meta.persistence.view_expressions.view_expressions_provider import (
+ view_expressions_provider,
+)
from metaobjects.meta.presentation.ui.ui_provider import ui_provider
from metaobjects.meta.presentation.ui.ui_web_provider import ui_web_provider
from metaobjects.meta.template.prompt_provider import prompt_provider
@@ -129,6 +133,10 @@ def _noop_provider(provider_id: str, *deps: str) -> Provider:
ui_provider.id: ui_provider, # "metaobjects-ui"
# view.textarea @rows and the view.image attrs (ui-web.json).
ui_web_provider.id: ui_web_provider, # "metaobjects-ui-web"
+ # Business rules (api / operation / binding / transition) and the view-expressions
+ # vocabulary (origin.function, projection @union / @grain), each its own pack.
+ rules_provider.id: rules_provider, # "metaobjects-rules"
+ view_expressions_provider.id: view_expressions_provider, # "metaobjects-view-expressions"
# Back-compat alias: pre-rename fixtures (and other ports' fixtures) still name the
# provider "metaobjects-template"; map it to the renamed prompt provider — the same
# alias the TS adapter keeps (adapter.ts: "metaobjects-template": promptProvider).
diff --git a/server/python/tests/conformance/fixture_discovery.py b/server/python/tests/conformance/fixture_discovery.py
index 5e984ade58..87b97be08c 100644
--- a/server/python/tests/conformance/fixture_discovery.py
+++ b/server/python/tests/conformance/fixture_discovery.py
@@ -24,6 +24,9 @@
"metaobjects-ui",
# view.textarea @rows and the view.image attrs are cross-port vocabulary.
"metaobjects-ui-web",
+ # The business-rules and view-expressions packs are in the default bundle.
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
)
diff --git a/server/python/tests/unit/test_registry_completeness.py b/server/python/tests/unit/test_registry_completeness.py
index 05ce76d131..682251d755 100644
--- a/server/python/tests/unit/test_registry_completeness.py
+++ b/server/python/tests/unit/test_registry_completeness.py
@@ -8,7 +8,7 @@
import pytest
-from metaobjects.core_types import core_provider
+from metaobjects.core_types import core_providers
from metaobjects.meta.core.attr.attr_constants import ATTR_SUBTYPES
from metaobjects.meta.core.field.field_constants import FIELD_SUBTYPES
from metaobjects.meta.core.identity.identity_constants import IDENTITY_SUBTYPES
@@ -55,7 +55,8 @@
(TYPE_SEGMENT, SEGMENT_SUBTYPES),
]
-_registry = compose_registry([core_provider])
+# origin.function is the view-expressions pack's, so compose the default bundle.
+_registry = compose_registry(list(core_providers))
_cases = [
(type_name, sub)
diff --git a/server/rust/metaobjects/data/metamodel/api.json b/server/rust/metaobjects/data/metamodel/api.json
index 0f30e16e08..6c803bfba0 100644
--- a/server/rust/metaobjects/data/metamodel/api.json
+++ b/server/rust/metaobjects/data/metamodel/api.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "api",
@@ -69,5 +69,14 @@
{ "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH)." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "metadata",
+ "subType": "root",
+ "children": [
+ { "type": "api", "subType": "*", "name": "*", "min": 0, "max": null, "description": "A declared API surface (ADR-0030, ADR-0066): a top-level, packaged node. Contributed by the business-rules pack." }
+ ]
+ }
]
}
diff --git a/server/rust/metaobjects/data/metamodel/field.json b/server/rust/metaobjects/data/metamodel/field.json
index 8d4c5a2185..46a2f064ce 100644
--- a/server/rust/metaobjects/data/metamodel/field.json
+++ b/server/rust/metaobjects/data/metamodel/field.json
@@ -149,7 +149,6 @@
"whenToUse": "A field is a fixed, closed set of string values. Set @values so the union type, DB CHECK, and validation are generated — don't hand-roll constants + checks.",
"rules": "Required @values is a non-empty, duplicate-free set; each member must match ^[A-Za-z_][A-Za-z0-9_]*$ so it is a legal identifier in every target language, and is its own stored string unless @stringValueMap (string) or @intValueMap (integer) maps it. Optional FR-010/FR-011 overlays add tolerant-extract aliasing (@enumAlias), per-member docs (@enumDoc), an uncoercible-value fallback (@coerceDefault, must be one of @values), and ASCII normalization mode (@normalize).",
"children": [
- { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." },
{ "type": "attr", "subType": "string", "name": "values", "isArray": true, "min": 1, "max": 1, "description": "Member symbols of an enum-subtype field. Declaration order is significant; each is a legal identifier and its own stored string unless @stringValueMap or @intValueMap maps it." },
{ "type": "attr", "subType": "boolean", "name": "provided", "min": 0, "max": 1, "description": "FR-019: marks an abstract package-level field.enum as externally provided — codegen references the type (resolved via per-port codegen config) instead of materializing it. Default false. Not a field attr — it lives on the type declaration." },
{ "type": "attr", "subType": "int", "name": "maxLength", "min": 0, "max": 1, "description": "Column length of a string-stored enum (drives VARCHAR(n)); every member must fit. Overrides the project's enums.maxLength. Refused with @intValueMap, whose column is an integer. Justified in ADR-0023 Amendment 1." },
diff --git a/server/rust/metaobjects/data/metamodel/object.json b/server/rust/metaobjects/data/metamodel/object.json
index eb44fedc67..ddf3c6eeec 100644
--- a/server/rust/metaobjects/data/metamodel/object.json
+++ b/server/rust/metaobjects/data/metamodel/object.json
@@ -54,10 +54,6 @@
"rules": "object.projection is a derived read-only representation: every field is extends-bound, origin-derived, or self-declared-under-external-assembly, and all are read-only at the subtype level. Identity is optional and, when present, MUST extend an entity identity. Sources are restricted to read-only @kinds. The declared field set IS the exposure — an inclusive list, fail-closed. A projection NEVER declares relationships (derivation is expressed via @via, not a relationship child) and NEVER co-locates templates — hence its child set omits both relationship and template. The assembly origins (origin.aggregate / origin.computed / origin.first) live HERE, not on object.value; a SOURCELESS projection is the legal shape for a wire-assembled read model, and a template-level @payloadRef/@responseRef may target one (#210). See ADR-0028 (object taxonomy, projection).",
"children": [
{ "type": "attr", "subType": "filter", "name": "filter", "min": 0, "max": 1, "description": "Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: \"\", startOf? }) on a date or timestamp field (rc.19)." },
- { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
- { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
- { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
- { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." },
{ "type": "attr", "subType": "string", "name": "collectionName", "min": 0, "max": 1, "description": "The name of this object's collection, in the object's own casing (e.g. 'CaseHistory', 'Queues'): the REST collection segment (snake_cased) in every port, the reverse-finder names in C#, TypeScript and Python, the C# DbSet property, and the TypeScript list function, list hook and Drizzle table variable. It need not be a grammatical plural. Absent, the project's pluralizer derives it from the object's name (naming.collections in .metaobjects/config.json; built in: standard, none; an application may register its own)." }
]
},
diff --git a/server/rust/metaobjects/data/metamodel/origin.json b/server/rust/metaobjects/data/metamodel/origin.json
index e2539d6d66..c4fde970f9 100644
--- a/server/rust/metaobjects/data/metamodel/origin.json
+++ b/server/rust/metaobjects/data/metamodel/origin.json
@@ -42,20 +42,6 @@
{ "type": "attr", "subType": "expression", "name": "expr", "min": 1, "max": 1, "description": "The structured expression tree computing this field's value from the base entity's own fields (closed node grammar; shares the filter op vocabulary). Its inferred root type must equal the field's declared subType (ERR_COMPUTED_TYPE_MISMATCH)." }
]
},
- {
- "type": "origin",
- "subType": "function",
- "implementedIn": ["typescript", "csharp"],
- "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
- "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
- "children": [
- { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
- { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
- { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
- { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
- { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
- ]
- },
{
"type": "origin",
"subType": "first",
diff --git a/server/rust/metaobjects/data/metamodel/transition.json b/server/rust/metaobjects/data/metamodel/transition.json
index cbac9d3ef7..2cb444d160 100644
--- a/server/rust/metaobjects/data/metamodel/transition.json
+++ b/server/rust/metaobjects/data/metamodel/transition.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "transition",
@@ -23,5 +23,14 @@
{ "type": "attr", "subType": "expression", "name": "condition", "min": 0, "max": 1, "description": "A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "field",
+ "subType": "enum",
+ "children": [
+ { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." }
+ ]
+ }
]
}
diff --git a/server/rust/metaobjects/data/metamodel/view-expressions.json b/server/rust/metaobjects/data/metamodel/view-expressions.json
new file mode 100644
index 0000000000..4db3c0ca57
--- /dev/null
+++ b/server/rust/metaobjects/data/metamodel/view-expressions.json
@@ -0,0 +1,31 @@
+{
+ "provider": "metaobjects-view-expressions",
+ "types": [
+ {
+ "type": "origin",
+ "subType": "function",
+ "implementedIn": ["typescript", "csharp"],
+ "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
+ "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
+ { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
+ { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
+ { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
+ { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
+ ]
+ }
+ ],
+ "extends": [
+ {
+ "type": "object",
+ "subType": "projection",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
+ { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
+ { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
+ { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." }
+ ]
+ }
+ ]
+}
diff --git a/server/rust/metaobjects/src/providers.rs b/server/rust/metaobjects/src/providers.rs
index 543c82afa9..d5eb9a733e 100644
--- a/server/rust/metaobjects/src/providers.rs
+++ b/server/rust/metaobjects/src/providers.rs
@@ -24,6 +24,8 @@ use crate::registry::{
pub const CORE_TYPES_ID: &str = "metaobjects-core-types";
pub const DB_ID: &str = "metaobjects-db";
pub const DOCUMENTATION_ID: &str = "metaobjects-documentation";
+pub const RULES_ID: &str = "metaobjects-rules";
+pub const VIEW_EXPRESSIONS_ID: &str = "metaobjects-view-expressions";
pub const PROMPT_ID: &str = "metaobjects-prompt";
pub const UI_ID: &str = "metaobjects-ui";
pub const UI_WEB_ID: &str = "metaobjects-ui-web";
@@ -89,10 +91,10 @@ const CORE_FAMILIES: &[(&str, &str)] = &[
spec!("index"),
spec!("requirement"),
spec!("reporting"),
- spec!("api"),
- spec!("transition"),
];
+const RULES_FAMILIES: &[(&str, &str)] = &[spec!("api"), spec!("transition")];
+const VIEW_EXPRESSIONS_SPEC: (&str, &str) = spec!("view-expressions");
const DB_SPEC: (&str, &str) = spec!("db");
const DOCUMENTATION_SPEC: (&str, &str) = spec!("documentation");
const PROMPT_SPEC: (&str, &str) = spec!("prompt");
@@ -253,6 +255,8 @@ fn parse_definition(file: &str, raw: &str) -> ProviderDefinition {
/// The parsed definitions, parsed once per process.
struct Definitions {
core: Vec,
+ rules: Vec,
+ view_expressions: ProviderDefinition,
db: ProviderDefinition,
documentation: ProviderDefinition,
prompt: ProviderDefinition,
@@ -266,6 +270,8 @@ fn definitions() -> &'static Definitions {
let p = |(name, raw): (&str, &str)| parse_definition(name, raw);
Definitions {
core: CORE_FAMILIES.iter().map(|f| p(*f)).collect(),
+ rules: RULES_FAMILIES.iter().map(|f| p(*f)).collect(),
+ view_expressions: p(VIEW_EXPRESSIONS_SPEC),
db: p(DB_SPEC),
documentation: p(DOCUMENTATION_SPEC),
prompt: p(PROMPT_SPEC),
@@ -458,15 +464,14 @@ fn apply_definition(
}
for ext in &data.extends {
let mut attributes = Vec::new();
+ let mut child_rules = Vec::new();
for child in &ext.children {
- if child.type_name != ATTR_CHILD_TYPE {
- return Err(MetaError::unknown(format!(
- "applyProviderDefinition({}): extends \"{}\" may only carry attr children; found a structural child \"{}\".",
- data.provider, ext.type_name, child.type_name
- )));
- }
validate_cardinality(&data.provider, &ext.type_name, child)?;
- attributes.push(to_attr_schema(&data.provider, &ext.type_name, child)?);
+ if child.type_name == ATTR_CHILD_TYPE {
+ attributes.push(to_attr_schema(&data.provider, &ext.type_name, child)?);
+ } else {
+ child_rules.push(to_child_rule(child));
+ }
}
let sub_types = match &ext.sub_type {
ChildSubType::One(s) if s == WILDCARD => registry.all_sub_types_of(&ext.type_name),
@@ -474,7 +479,7 @@ fn apply_definition(
ChildSubType::Many(list) => list.clone(),
};
for sub in sub_types {
- registry.extend(&ext.type_name, &sub, attributes.clone(), Vec::new())?;
+ registry.extend(&ext.type_name, &sub, attributes.clone(), child_rules.clone())?;
}
}
Ok(())
@@ -484,14 +489,7 @@ fn apply_definition(
fn register_core(registry: &mut TypeRegistry) -> Result<(), MetaError> {
let mut root = TypeDefinition::new("metadata", "root", "Root metadata document");
- root.child_rules = [
- "object",
- "field",
- "validator",
- "template",
- "requirement",
- "api",
- ]
+ root.child_rules = ["object", "field", "validator", "template", "requirement"]
.iter()
.map(|t| ChildRule::wildcard(t))
.collect();
@@ -534,6 +532,32 @@ pub fn core_types_provider() -> Provider {
)
}
+/// The business-rules pack (ADR-0066): `api`, `operation`, `binding`, `transition`,
+/// and the child rules that admit them on `metadata.root` and `field.enum`.
+pub fn rules_provider() -> Provider {
+ Provider::new(
+ RULES_ID,
+ &[CORE_TYPES_ID],
+ "Business rules: declared APIs, operations, bindings and lifecycle transitions.",
+ |r| {
+ for def in &definitions().rules {
+ apply_definition(r, def)?;
+ }
+ Ok(())
+ },
+ )
+}
+
+/// View expressions: `origin.function` and the projection `@union`/`@grain` attrs.
+pub fn view_expressions_provider() -> Provider {
+ Provider::new(
+ VIEW_EXPRESSIONS_ID,
+ &[CORE_TYPES_ID],
+ "View expressions: function origins and projection unions and grains.",
+ |r| apply_definition(r, &definitions().view_expressions),
+ )
+}
+
pub fn db_provider() -> Provider {
Provider::new(
DB_ID,
@@ -583,6 +607,8 @@ pub fn ui_web_provider() -> Provider {
pub fn core_providers() -> Vec {
vec![
core_types_provider(),
+ rules_provider(),
+ view_expressions_provider(),
db_provider(),
documentation_provider(),
prompt_provider(),
diff --git a/server/rust/metaobjects/tests/metamodel_conformance.rs b/server/rust/metaobjects/tests/metamodel_conformance.rs
index abbe45daf8..b9192fb313 100644
--- a/server/rust/metaobjects/tests/metamodel_conformance.rs
+++ b/server/rust/metaobjects/tests/metamodel_conformance.rs
@@ -28,6 +28,8 @@ use metaobjects::source::ErrorSource;
const DEFAULT_PROVIDERS: &[&str] = &[
"metaobjects-core-types",
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
"metaobjects-db",
"metaobjects-documentation",
"metaobjects-prompt",
diff --git a/server/typescript/packages/conformance/src/fixture.ts b/server/typescript/packages/conformance/src/fixture.ts
index a7e300d62a..c4cfe9a09e 100644
--- a/server/typescript/packages/conformance/src/fixture.ts
+++ b/server/typescript/packages/conformance/src/fixture.ts
@@ -58,6 +58,10 @@ const DEFAULT_PROVIDERS = [
"metaobjects-ui",
// View.textarea @rows and the view.image attrs are cross-port vocabulary.
"metaobjects-ui-web",
+ // The business-rules and view-expressions packs are in the default bundle, so a
+ // fixture with no providers.json still loads every existing model.
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
];
export interface Fixture {
diff --git a/server/typescript/packages/metadata/src/core-types.ts b/server/typescript/packages/metadata/src/core-types.ts
index 39fe730d30..8bbe85b26f 100644
--- a/server/typescript/packages/metadata/src/core-types.ts
+++ b/server/typescript/packages/metadata/src/core-types.ts
@@ -6,6 +6,8 @@ import { docProvider } from "./core/documentation/doc-provider.js";
import { promptProvider } from "./template/prompt-provider.js";
import { uiProvider } from "./presentation/ui/ui-provider.js";
import { uiWebProvider } from "./presentation/ui-web/ui-web-provider.js";
+import { rulesProvider } from "./core/rules/rules-provider.js";
+import { viewExpressionsProvider } from "./persistence/view-expressions/view-expressions-provider.js";
import { type DataType } from "./data-type.js";
import type { MetaData } from "./shared/meta-data.js";
import { MetaRoot } from "./shared/meta-root.js";
@@ -58,10 +60,6 @@ import { MetaIndex } from "./core/index/meta-index.js";
import { INDEX_DEFINITION } from "./core/index/index-definition.embedded.js";
import { INDEX_SUBTYPES } from "./core/index/index-constants.js";
import { MetaRequirement } from "./core/requirement/meta-requirement.js";
-import { MetaApi, MetaBinding, MetaOperation } from "./core/api/meta-api.js";
-import { API_DEFINITION } from "./core/api/api-definition.embedded.js";
-import { MetaTransition } from "./core/transition/meta-transition.js";
-import { TRANSITION_DEFINITION } from "./core/transition/transition-definition.embedded.js";
import { REQUIREMENT_DEFINITION } from "./core/requirement/requirement-definition.embedded.js";
import { REQUIREMENT_SUBTYPES } from "./core/requirement/requirement-constants.js";
import { MetaDimension } from "./core/reporting/meta-dimension.js";
@@ -91,9 +89,6 @@ import {
TYPE_DIMENSION,
TYPE_MEASURE,
TYPE_SEGMENT,
- TYPE_API,
- TYPE_OPERATION,
- TYPE_BINDING,
SUBTYPE_ROOT,
} from "./shared/base-types.js";
import { CHILD_RULE_WILDCARD } from "./shared/structural.js";
@@ -125,6 +120,7 @@ import {
ORIGIN_SUBTYPE_AGGREGATE,
ORIGIN_SUBTYPE_COMPUTED,
ORIGIN_SUBTYPE_FIRST,
+ ORIGIN_SUBTYPE_FUNCTION,
} from "./persistence/origin/origin-constants.js";
// ---------------------------------------------------------------------------
@@ -210,8 +206,6 @@ function registerCoreTypeDefs(registry: TypeRegistry): void {
wildcard(TYPE_TEMPLATE),
// Capability requirements are declared beside the entities they describe.
wildcard(TYPE_REQUIREMENT),
- // ADR-0030 / ADR-0066 — a declared API surface is a top-level, packaged node.
- wildcard(TYPE_API),
], MetaRoot),
);
@@ -404,7 +398,8 @@ function registerCoreTypeDefs(registry: TypeRegistry): void {
// (required) + @via; aggregate adds @agg (required) + @of (required) + @via;
// collection adds @via (required).
const ORIGIN_FACTORIES: FactoryMap = Object.fromEntries(
- ORIGIN_SUBTYPES.map((subType) => [
+ // `function` is the view-expressions pack's (persistence/view-expressions).
+ ORIGIN_SUBTYPES.filter((subType) => subType !== ORIGIN_SUBTYPE_FUNCTION).map((subType) => [
`${TYPE_ORIGIN}.${subType}`,
(typeId: TypeId, name: string) =>
new (ORIGIN_CLASS_MAP.get(subType) ?? MetaOrigin)(typeId, name),
@@ -560,25 +555,6 @@ function registerCoreTypeDefs(registry: TypeRegistry): void {
registry.register(reportingDef);
}
- // ADR-0030 / ADR-0066 — the declared API surface (api / operation / binding) and
- // lifecycle moves (transition, a child of field.enum). One class per type; the
- // subtype carries no behaviour of its own. The cross-node rules live in
- // loader/rules-validation.ts.
- const RULES_FACTORIES: FactoryMap = {};
- for (const def of [...(API_DEFINITION.types ?? []), ...(TRANSITION_DEFINITION.types ?? [])]) {
- const key = `${def.type}.${def.subType}`;
- if (def.type === TYPE_API) RULES_FACTORIES[key] = (typeId: TypeId, name: string) => new MetaApi(typeId, name);
- else if (def.type === TYPE_OPERATION) RULES_FACTORIES[key] = (typeId: TypeId, name: string) => new MetaOperation(typeId, name);
- else if (def.type === TYPE_BINDING) RULES_FACTORIES[key] = (typeId: TypeId, name: string) => new MetaBinding(typeId, name);
- else RULES_FACTORIES[key] = (typeId: TypeId, name: string) => new MetaTransition(typeId, name);
- }
- for (const rulesDef of [
- ...defineProviderFromData(API_DEFINITION, RULES_FACTORIES),
- ...defineProviderFromData(TRANSITION_DEFINITION, RULES_FACTORIES),
- ]) {
- registry.register(rulesDef);
- }
-
// Declare the core cross-references ON their TypeDefinitions, so the loader's
// registry-derived validation resolves them generically (a dangling target fails the
// load). Set on the concrete subtypes the parser produces. (Production moves these into
@@ -660,6 +636,8 @@ export const coreProviders: readonly MetaDataTypeProvider[] = [
promptProvider,
uiProvider,
uiWebProvider,
+ rulesProvider,
+ viewExpressionsProvider,
];
/**
diff --git a/server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts b/server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts
index fff7337a4a..b1166a7f33 100644
--- a/server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts
+++ b/server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts
@@ -7,7 +7,7 @@
import type { ProviderDefinition } from "../../provider-data.js";
export const API_DEFINITION: ProviderDefinition = {
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "api",
@@ -170,5 +170,21 @@ export const API_DEFINITION: ProviderDefinition = {
}
]
}
+ ],
+ "extends": [
+ {
+ "type": "metadata",
+ "subType": "root",
+ "children": [
+ {
+ "type": "api",
+ "subType": "*",
+ "name": "*",
+ "min": 0,
+ "max": null,
+ "description": "A declared API surface (ADR-0030, ADR-0066): a top-level, packaged node. Contributed by the business-rules pack."
+ }
+ ]
+ }
]
};
diff --git a/server/typescript/packages/metadata/src/core/field/field-definition.embedded.ts b/server/typescript/packages/metadata/src/core/field/field-definition.embedded.ts
index 0956a07787..cc1f081144 100644
--- a/server/typescript/packages/metadata/src/core/field/field-definition.embedded.ts
+++ b/server/typescript/packages/metadata/src/core/field/field-definition.embedded.ts
@@ -268,14 +268,6 @@ export const FIELD_DEFINITION: ProviderDefinition = {
"whenToUse": "A field is a fixed, closed set of string values. Set @values so the union type, DB CHECK, and validation are generated — don't hand-roll constants + checks.",
"rules": "Required @values is a non-empty, duplicate-free set; each member must match ^[A-Za-z_][A-Za-z0-9_]*$ so it is a legal identifier in every target language, and is its own stored string unless @stringValueMap (string) or @intValueMap (integer) maps it. Optional FR-010/FR-011 overlays add tolerant-extract aliasing (@enumAlias), per-member docs (@enumDoc), an uncoercible-value fallback (@coerceDefault, must be one of @values), and ASCII normalization mode (@normalize).",
"children": [
- {
- "type": "transition",
- "subType": "*",
- "name": "*",
- "min": 0,
- "max": null,
- "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves."
- },
{
"type": "attr",
"subType": "string",
diff --git a/server/typescript/packages/metadata/src/core/object/object-definition.embedded.ts b/server/typescript/packages/metadata/src/core/object/object-definition.embedded.ts
index 56c86f361f..3bbec9aedc 100644
--- a/server/typescript/packages/metadata/src/core/object/object-definition.embedded.ts
+++ b/server/typescript/packages/metadata/src/core/object/object-definition.embedded.ts
@@ -183,55 +183,6 @@ export const OBJECT_DEFINITION: ProviderDefinition = {
"max": 1,
"description": "Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: \"\", startOf? }) on a date or timestamp field (rc.19)."
},
- {
- "type": "attr",
- "subType": "string",
- "name": "union",
- "isArray": true,
- "min": 0,
- "max": 1,
- "implementedIn": [
- "typescript",
- "csharp"
- ],
- "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless."
- },
- {
- "type": "attr",
- "subType": "boolean",
- "name": "unionAll",
- "min": 0,
- "max": 1,
- "implementedIn": [
- "typescript",
- "csharp"
- ],
- "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "grain",
- "min": 0,
- "max": 1,
- "implementedIn": [
- "typescript",
- "csharp"
- ],
- "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "grainOrdinal",
- "min": 0,
- "max": 1,
- "implementedIn": [
- "typescript",
- "csharp"
- ],
- "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array."
- },
{
"type": "attr",
"subType": "string",
diff --git a/server/typescript/packages/metadata/src/core/rules/rules-provider.ts b/server/typescript/packages/metadata/src/core/rules/rules-provider.ts
new file mode 100644
index 0000000000..52fceb39d1
--- /dev/null
+++ b/server/typescript/packages/metadata/src/core/rules/rules-provider.ts
@@ -0,0 +1,47 @@
+// rulesProvider — the business-rules pack (ADR-0066): the declared API surface
+// (api / operation / binding) and lifecycle moves (transition, a child of
+// field.enum). Experimental, new in 1.3.0.
+//
+// It is its OWN provider rather than part of metaobjects-core-types so a project can
+// leave it out, and so the vocabulary can move or be versioned on its own. It is in
+// the default bundle (`coreProviders`), so every existing model loads unchanged.
+// GOVERNANCE.md ("Extension packs and the core metamodel"): new vocabulary lives in a
+// pack until a second consumer needs it in core.
+//
+// The pack owns its types (api.json, transition.json) AND the child rules that admit
+// them on types core owns (`metadata.root` holds an `api`; `field.enum` holds a
+// `transition`) — both ride in each file's `extends`. Compose the pack out and the
+// types are unknown (ERR_UNKNOWN_TYPE); nothing of it is left behind in core. The
+// cross-node rules live in loader/rules-validation.ts and only fire on rules nodes.
+
+import type { MetaDataTypeProvider } from "../../provider.js";
+import type { TypeRegistry, TypeId } from "../../registry.js";
+import { applyProviderDefinition, type FactoryMap } from "../../provider-data.js";
+import { TYPE_API, TYPE_OPERATION, TYPE_BINDING } from "../../shared/base-types.js";
+import { MetaApi, MetaBinding, MetaOperation } from "../api/meta-api.js";
+import { API_DEFINITION } from "../api/api-definition.embedded.js";
+import { MetaTransition } from "../transition/meta-transition.js";
+import { TRANSITION_DEFINITION } from "../transition/transition-definition.embedded.js";
+
+/** The business-rules pack's provider id (a logical id, shared by every port). */
+export const RULES_PROVIDER_ID = "metaobjects-rules";
+
+export const rulesProvider: MetaDataTypeProvider = {
+ id: RULES_PROVIDER_ID,
+ dependencies: ["metaobjects-core-types"],
+ description:
+ "Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).",
+ registerTypes(registry: TypeRegistry): void {
+ // One class per type; the subtype carries no behaviour of its own.
+ const factories: FactoryMap = {};
+ for (const def of [...(API_DEFINITION.types ?? []), ...(TRANSITION_DEFINITION.types ?? [])]) {
+ const key = `${def.type}.${def.subType}`;
+ if (def.type === TYPE_API) factories[key] = (typeId: TypeId, name: string) => new MetaApi(typeId, name);
+ else if (def.type === TYPE_OPERATION) factories[key] = (typeId: TypeId, name: string) => new MetaOperation(typeId, name);
+ else if (def.type === TYPE_BINDING) factories[key] = (typeId: TypeId, name: string) => new MetaBinding(typeId, name);
+ else factories[key] = (typeId: TypeId, name: string) => new MetaTransition(typeId, name);
+ }
+ applyProviderDefinition(registry, API_DEFINITION, factories);
+ applyProviderDefinition(registry, TRANSITION_DEFINITION, factories);
+ },
+};
diff --git a/server/typescript/packages/metadata/src/core/transition/transition-definition.embedded.ts b/server/typescript/packages/metadata/src/core/transition/transition-definition.embedded.ts
index fd5c808453..33d8103649 100644
--- a/server/typescript/packages/metadata/src/core/transition/transition-definition.embedded.ts
+++ b/server/typescript/packages/metadata/src/core/transition/transition-definition.embedded.ts
@@ -7,7 +7,7 @@
import type { ProviderDefinition } from "../../provider-data.js";
export const TRANSITION_DEFINITION: ProviderDefinition = {
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "transition",
@@ -67,5 +67,21 @@ export const TRANSITION_DEFINITION: ProviderDefinition = {
}
]
}
+ ],
+ "extends": [
+ {
+ "type": "field",
+ "subType": "enum",
+ "children": [
+ {
+ "type": "transition",
+ "subType": "*",
+ "name": "*",
+ "min": 0,
+ "max": null,
+ "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves."
+ }
+ ]
+ }
]
};
diff --git a/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts b/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts
index 056e8f16a3..318fe0867a 100644
--- a/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts
+++ b/server/typescript/packages/metadata/src/metamodel-docs/provider-definitions.ts
@@ -26,6 +26,9 @@ import { UI_DEFINITION } from "../presentation/ui/ui-definition.embedded.js";
import { UI_WEB_DEFINITION } from "../presentation/ui-web/ui-web-definition.embedded.js";
import { TEMPLATE_DEFINITION } from "../template/template-definition.embedded.js";
import { PROMPT_DEFINITION } from "../template/prompt-definition.embedded.js";
+import { API_DEFINITION } from "../core/api/api-definition.embedded.js";
+import { TRANSITION_DEFINITION } from "../core/transition/transition-definition.embedded.js";
+import { VIEW_EXPRESSIONS_DEFINITION } from "../persistence/view-expressions/view-expressions-definition.embedded.js";
/**
* Every embedded provider definition the core metamodel composes from. The
@@ -49,4 +52,8 @@ export const ALL_PROVIDER_DEFINITIONS: readonly ProviderDefinition[] = [
UI_WEB_DEFINITION,
TEMPLATE_DEFINITION,
PROMPT_DEFINITION,
+ // The business-rules pack (metaobjects-rules) and the view-expressions pack.
+ API_DEFINITION,
+ TRANSITION_DEFINITION,
+ VIEW_EXPRESSIONS_DEFINITION,
];
diff --git a/server/typescript/packages/metadata/src/persistence/origin/origin-definition.embedded.ts b/server/typescript/packages/metadata/src/persistence/origin/origin-definition.embedded.ts
index acb5529821..4b0e3618a2 100644
--- a/server/typescript/packages/metadata/src/persistence/origin/origin-definition.embedded.ts
+++ b/server/typescript/packages/metadata/src/persistence/origin/origin-definition.embedded.ts
@@ -138,60 +138,6 @@ export const ORIGIN_DEFINITION: ProviderDefinition = {
}
]
},
- {
- "type": "origin",
- "subType": "function",
- "implementedIn": [
- "typescript",
- "csharp"
- ],
- "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
- "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
- "children": [
- {
- "type": "attr",
- "subType": "string",
- "name": "function",
- "min": 1,
- "max": 1,
- "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "schema",
- "min": 0,
- "max": 1,
- "description": "The schema the function lives in, a plain identifier. Absent: public."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "args",
- "isArray": true,
- "min": 0,
- "max": 1,
- "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "params",
- "isArray": true,
- "min": 0,
- "max": 1,
- "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)."
- },
- {
- "type": "attr",
- "subType": "string",
- "name": "returns",
- "min": 1,
- "max": 1,
- "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)."
- }
- ]
- },
{
"type": "origin",
"subType": "first",
diff --git a/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-definition.embedded.ts b/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-definition.embedded.ts
new file mode 100644
index 0000000000..62f14c40c2
--- /dev/null
+++ b/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-definition.embedded.ts
@@ -0,0 +1,124 @@
+// AUTO-GENERATED by scripts/generate-embedded-metamodel.ts — DO NOT EDIT.
+// Canonical source: repo-root spec/metamodel/view-expressions.json
+// Regenerate: bun run scripts/generate-embedded-metamodel.ts
+//
+// Embeds the canonical FR-033 ProviderDefinition so the provider can register
+// itself wherever the on-disk spec/ tree is unavailable (bundled builds).
+import type { ProviderDefinition } from "../../provider-data.js";
+
+export const VIEW_EXPRESSIONS_DEFINITION: ProviderDefinition = {
+ "provider": "metaobjects-view-expressions",
+ "types": [
+ {
+ "type": "origin",
+ "subType": "function",
+ "implementedIn": [
+ "typescript",
+ "csharp"
+ ],
+ "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
+ "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
+ "children": [
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "function",
+ "min": 1,
+ "max": 1,
+ "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "schema",
+ "min": 0,
+ "max": 1,
+ "description": "The schema the function lives in, a plain identifier. Absent: public."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "args",
+ "isArray": true,
+ "min": 0,
+ "max": 1,
+ "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "params",
+ "isArray": true,
+ "min": 0,
+ "max": 1,
+ "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "returns",
+ "min": 1,
+ "max": 1,
+ "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)."
+ }
+ ]
+ }
+ ],
+ "extends": [
+ {
+ "type": "object",
+ "subType": "projection",
+ "children": [
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "union",
+ "isArray": true,
+ "min": 0,
+ "max": 1,
+ "implementedIn": [
+ "typescript",
+ "csharp"
+ ],
+ "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless."
+ },
+ {
+ "type": "attr",
+ "subType": "boolean",
+ "name": "unionAll",
+ "min": 0,
+ "max": 1,
+ "implementedIn": [
+ "typescript",
+ "csharp"
+ ],
+ "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "grain",
+ "min": 0,
+ "max": 1,
+ "implementedIn": [
+ "typescript",
+ "csharp"
+ ],
+ "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection."
+ },
+ {
+ "type": "attr",
+ "subType": "string",
+ "name": "grainOrdinal",
+ "min": 0,
+ "max": 1,
+ "implementedIn": [
+ "typescript",
+ "csharp"
+ ],
+ "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array."
+ }
+ ]
+ }
+ ]
+};
diff --git a/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-provider.ts b/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-provider.ts
new file mode 100644
index 0000000000..17e3ed3834
--- /dev/null
+++ b/server/typescript/packages/metadata/src/persistence/view-expressions/view-expressions-provider.ts
@@ -0,0 +1,42 @@
+// viewExpressionsProvider — the view-expressions pack: the vocabulary a projection
+// needs to replace a hand-written `@sql` view. New in 1.3.0 (rc.21), and today acted
+// on by the TypeScript and C# ports (`implementedIn`).
+//
+// It carries `origin.function` (a value computed by a database function the project
+// owns) and the projection attributes `@union` / `@unionAll` (the view is a UNION of
+// other projections) and `@grain` / `@grainOrdinal` (one row per element of an
+// array-of-value-object field). It is its OWN provider so a project can leave it out
+// and the vocabulary can move or be versioned on its own; it is in the default bundle
+// (`coreProviders`), so every existing model loads unchanged. GOVERNANCE.md
+// ("Extension packs and the core metamodel"): new vocabulary lives in a pack until a
+// second consumer needs it in core.
+//
+// What this pack does NOT carry: the `cast` node and the SQL function set are nodes of
+// the `attr.expression` value grammar (parsed by the expression reader, not
+// registered), and the text `@dbColumnType` spellings are validated in code; neither
+// is registry vocabulary, so neither can be composed out by a provider.
+
+import type { MetaDataTypeProvider } from "../../provider.js";
+import type { TypeRegistry, TypeId } from "../../registry.js";
+import { applyProviderDefinition, type FactoryMap } from "../../provider-data.js";
+import { MetaOrigin } from "../origin/meta-origin.js";
+import { TYPE_ORIGIN } from "../../shared/base-types.js";
+import { ORIGIN_SUBTYPE_FUNCTION } from "../origin/origin-constants.js";
+import { VIEW_EXPRESSIONS_DEFINITION } from "./view-expressions-definition.embedded.js";
+
+/** The view-expressions pack's provider id (a logical id, shared by every port). */
+export const VIEW_EXPRESSIONS_PROVIDER_ID = "metaobjects-view-expressions";
+
+export const viewExpressionsProvider: MetaDataTypeProvider = {
+ id: VIEW_EXPRESSIONS_PROVIDER_ID,
+ dependencies: ["metaobjects-core-types"],
+ description:
+ "View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes.",
+ registerTypes(registry: TypeRegistry): void {
+ const factories: FactoryMap = {
+ [`${TYPE_ORIGIN}.${ORIGIN_SUBTYPE_FUNCTION}`]: (typeId: TypeId, name: string) =>
+ new MetaOrigin(typeId, name),
+ };
+ applyProviderDefinition(registry, VIEW_EXPRESSIONS_DEFINITION, factories);
+ },
+};
diff --git a/server/typescript/packages/metadata/src/provider-data.ts b/server/typescript/packages/metadata/src/provider-data.ts
index 62afcb0b64..7b8718435d 100644
--- a/server/typescript/packages/metadata/src/provider-data.ts
+++ b/server/typescript/packages/metadata/src/provider-data.ts
@@ -141,9 +141,9 @@ export interface ExtendDef {
*/
subType: string | readonly string[];
/**
- * Attrs to add to each resolved target. Concern providers add attrs only — these
- * must all be `type: "attr"` entries (lowered via `toAttrSchema`). A structural
- * child here is rejected (concern providers do not contribute child rules).
+ * Attrs and child rules to add to each resolved target. A `type: "attr"` entry
+ * lowers via `toAttrSchema`; any other entry is a structural child rule the pack
+ * adds to the target (used by a pack that owns the child type, e.g. business rules).
*/
children: ChildDef[];
}
@@ -299,23 +299,25 @@ export function applyProviderDefinition(
* For each directive: resolve the target subtypes (`"*"` → every registered subtype
* of the type; a list → each named subtype; a string → that one), lower its `attr`
* children to `AttrSchema[]`, and `registry.extend(type, sub, { attributes })`.
- * Concern providers contribute attrs only — a non-`attr` child is rejected.
+ * A structural (non-`attr`) child lowers to a child rule on the target, so a PACK
+ * that owns a type can also be the one that lets an existing type hold it (the
+ * business-rules pack's `transition` under `field.enum`): leaving the pack out
+ * removes the type AND the rule that admits it.
*/
function applyExtends(registry: TypeRegistry, data: ProviderDefinition): void {
for (const ext of data.extends ?? []) {
const attributes: AttrSchema[] = [];
+ const childRules: ChildRule[] = [];
for (const child of ext.children) {
- if (!isAttrChild(child)) {
- throw new Error(
- `applyProviderDefinition(${data.provider}): extends "${ext.type}" may only carry attr ` +
- `children; found a structural child "${child.type}".`,
- );
- }
validateCardinality(data.provider, ext.type, child);
- attributes.push(toAttrSchema(data.provider, ext.type, child));
+ if (isAttrChild(child)) {
+ attributes.push(toAttrSchema(data.provider, ext.type, child));
+ } else {
+ childRules.push(toChildRule(child));
+ }
}
for (const subType of resolveExtendSubTypes(registry, ext)) {
- registry.extend(ext.type, subType, { attributes });
+ registry.extend(ext.type, subType, { attributes, childRules });
}
}
}
diff --git a/server/typescript/packages/metadata/test/conformance/adapter.ts b/server/typescript/packages/metadata/test/conformance/adapter.ts
index 0761067d7d..ab88935953 100644
--- a/server/typescript/packages/metadata/test/conformance/adapter.ts
+++ b/server/typescript/packages/metadata/test/conformance/adapter.ts
@@ -21,6 +21,8 @@ import { docProvider } from "../../src/core/documentation/doc-provider.js";
import { promptProvider } from "../../src/template/prompt-provider.js";
import { uiProvider } from "../../src/presentation/ui/ui-provider.js";
import { uiWebProvider } from "../../src/presentation/ui-web/ui-web-provider.js";
+import { rulesProvider } from "../../src/core/rules/rules-provider.js";
+import { viewExpressionsProvider } from "../../src/persistence/view-expressions/view-expressions-provider.js";
import { MetaDataLoader } from "../../src/loader/meta-data-loader.js";
import type { MetaData } from "../../src/shared/meta-data.js";
import { canonicalSerialize, canonicalSerializeEffective } from "../../src/serializer-json.js";
@@ -159,6 +161,8 @@ export const PROVIDERS: Readonly> = {
"metaobjects-template": promptProvider,
[uiProvider.id]: uiProvider, // "metaobjects-ui" (filter/sort field markers)
[uiWebProvider.id]: uiWebProvider, // "metaobjects-ui-web" (view control attrs)
+ [rulesProvider.id]: rulesProvider, // "metaobjects-rules" (api/operation/binding/transition)
+ [viewExpressionsProvider.id]: viewExpressionsProvider, // "metaobjects-view-expressions" (origin.function, @union/@grain)
// Test-only — provider-extension-* fixtures.
"example-template-briefing": exampleTemplateBriefingProvider,
"example-custom-vocabulary": exampleCustomVocabularyProvider,
diff --git a/server/typescript/packages/metadata/test/index.test.ts b/server/typescript/packages/metadata/test/index.test.ts
index 5a4f71f0a3..3f0ca21a8a 100644
--- a/server/typescript/packages/metadata/test/index.test.ts
+++ b/server/typescript/packages/metadata/test/index.test.ts
@@ -139,6 +139,8 @@ describe("Public API surface — @metaobjectsdev/metadata index", () => {
for (const t of BASE_TYPES) {
// origin/TYPE_ORIGIN is registered separately in Task 12; skip here
if (t === "origin") continue;
+ // The business-rules pack (metaobjects-rules) owns these; core alone has none.
+ if (t === "api" || t === "operation" || t === "binding" || t === "transition") continue;
const subs = registry.allSubTypesOf(t);
expect(subs.length).toBeGreaterThan(0);
}
diff --git a/server/typescript/packages/metadata/test/metamodel-docs.test.ts b/server/typescript/packages/metadata/test/metamodel-docs.test.ts
index c5f5d3b10b..3b4fc32cbb 100644
--- a/server/typescript/packages/metadata/test/metamodel-docs.test.ts
+++ b/server/typescript/packages/metadata/test/metamodel-docs.test.ts
@@ -118,7 +118,7 @@ test("documentation common attrs are mentioned once, not repeated per type", ()
expect(providers).toContain("@description");
});
-test("providers.md indexes all six concern providers with descriptions", () => {
+test("providers.md indexes every concern provider and pack with descriptions", () => {
const out = docs();
const providers = out.get("providers.md")!;
for (const id of [
@@ -128,6 +128,8 @@ test("providers.md indexes all six concern providers with descriptions", () => {
"metaobjects-prompt",
"metaobjects-ui",
"metaobjects-ui-web",
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
]) {
expect(providers).toContain(id);
}
diff --git a/server/typescript/packages/metadata/test/origin-definition-completeness.test.ts b/server/typescript/packages/metadata/test/origin-definition-completeness.test.ts
index f812b8794e..3a567083a5 100644
--- a/server/typescript/packages/metadata/test/origin-definition-completeness.test.ts
+++ b/server/typescript/packages/metadata/test/origin-definition-completeness.test.ts
@@ -15,14 +15,16 @@
import { describe, test, expect } from "bun:test";
import { composeRegistry } from "../src/provider.js";
import { coreTypesProvider } from "../src/core-types.js";
+import { viewExpressionsProvider } from "../src/persistence/view-expressions/view-expressions-provider.js";
import { TYPE_ORIGIN } from "../src/shared/base-types.js";
import { ORIGIN_SUBTYPES } from "../src/persistence/origin/origin-constants.js";
-// Compose with ONLY the core-types provider — so `def.attributes` reflects
+// Compose with ONLY the core-types provider and the view-expressions pack (which
+// owns origin.function) — so `def.attributes` reflects
// exactly what the ORIGIN provider registered, not the doc-domain attrs that
// other providers add via registry.extend(). This isolates the externalization
// gate.
-const registry = composeRegistry([coreTypesProvider]);
+const registry = composeRegistry([coreTypesProvider, viewExpressionsProvider]);
type ExpectedAttr = {
valueType: string;
diff --git a/server/typescript/packages/metadata/test/provider-data.test.ts b/server/typescript/packages/metadata/test/provider-data.test.ts
index 83d582cf90..447e258a57 100644
--- a/server/typescript/packages/metadata/test/provider-data.test.ts
+++ b/server/typescript/packages/metadata/test/provider-data.test.ts
@@ -423,7 +423,7 @@ test("extends with a REQUIRED attr → throws (ADR-0050: projection is optional-
expect(reg.find("field", "string")!.attributes.map((a) => a.name)).not.toContain("mustBeThere");
});
-test("extends with a structural child → throws (concern providers add attrs only)", () => {
+test("extends with a structural child → adds a child rule to the target (a pack's type under a core type)", () => {
const reg = registryWithFields("string");
const data: ProviderDefinition = {
provider: "concern",
@@ -435,7 +435,9 @@ test("extends with a structural child → throws (concern providers add attrs on
},
],
};
- expect(() => applyProviderDefinition(reg, data, {})).toThrow(/may only carry attr children/);
+ applyProviderDefinition(reg, data, {});
+ const rules = reg.find("field", "string")!.childRules;
+ expect(rules.some((r) => r.childType === "validator" && r.min === 0 && r.max === null)).toBe(true);
});
test("extends targeting an unregistered subtype → throws (registry.extend has no target)", () => {
diff --git a/server/typescript/packages/metadata/test/provider-vocabulary.test.ts b/server/typescript/packages/metadata/test/provider-vocabulary.test.ts
index 6144b7f6c2..18e77e9051 100644
--- a/server/typescript/packages/metadata/test/provider-vocabulary.test.ts
+++ b/server/typescript/packages/metadata/test/provider-vocabulary.test.ts
@@ -74,12 +74,18 @@ describe("logical provider vocabulary", () => {
for (const p of coreProviders) expect(Object.keys(canonical.providers)).toContain(p.id);
});
- test("exactly one provider declares types; the rest are pure projections", () => {
- // The shape ADR-0050 describes, asserted rather than assumed. If a second type
- // provider ever appears this fails loudly, which is the moment to decide whether
- // the OWN/PROJECTED split still holds.
+ test("only core and the two named packs declare types; the rest are pure projections", () => {
+ // The shape ADR-0050 describes, asserted rather than assumed. A type-declaring
+ // provider beyond these three appearing fails this loudly, which is the moment to
+ // decide whether the OWN/PROJECTED split still holds. The packs
+ // (metaobjects-rules, metaobjects-view-expressions) own their types and project
+ // onto core's; see GOVERNANCE.md, "Extension packs and the core metamodel".
const declaring = Object.entries(canonical.providers).filter(([, v]) => v.declaresTypes);
- expect(declaring.map(([k]) => k)).toEqual(["metaobjects-core-types"]);
+ expect(declaring.map(([k]) => k)).toEqual([
+ "metaobjects-core-types",
+ "metaobjects-rules",
+ "metaobjects-view-expressions",
+ ]);
for (const [, v] of Object.entries(canonical.providers)) {
if (!v.declaresTypes) expect(v.projectsOnto.length).toBeGreaterThan(0);
}
diff --git a/server/typescript/packages/metadata/test/provider.test.ts b/server/typescript/packages/metadata/test/provider.test.ts
index 8ef8b0ee4f..349d7a18cd 100644
--- a/server/typescript/packages/metadata/test/provider.test.ts
+++ b/server/typescript/packages/metadata/test/provider.test.ts
@@ -6,6 +6,8 @@ import { docProvider } from "../src/core/documentation/doc-provider.js";
import { promptProvider } from "../src/template/prompt-provider.js";
import { uiProvider } from "../src/presentation/ui/ui-provider.js";
import { uiWebProvider } from "../src/presentation/ui-web/ui-web-provider.js";
+import { rulesProvider } from "../src/core/rules/rules-provider.js";
+import { viewExpressionsProvider } from "../src/persistence/view-expressions/view-expressions-provider.js";
import { TypeRegistry, TypeId } from "../src/registry.js";
import { MetaField } from "../src/core/field/meta-field.js";
import {
@@ -97,7 +99,7 @@ describe("coreTypesProvider", () => {
expect(registry.defaultSubTypeOf(TYPE_METADATA)).toBe(SUBTYPE_ROOT);
});
- it("coreProviders is a six-provider bundle: coreTypesProvider + dbProvider + docProvider + promptProvider + uiProvider + uiWebProvider", () => {
+ it("coreProviders is an eight-provider bundle: coreTypesProvider + dbProvider + docProvider + promptProvider + uiProvider + uiWebProvider + rulesProvider + viewExpressionsProvider", () => {
// FR-033 S1-field-A re-homed the field's filter/sort/teaching/extract/storage
// attrs out of core into the concern providers. promptProvider (renamed from
// templateProvider; id metaobjects-prompt) carries @xmlText/@example/@instruction
@@ -108,13 +110,18 @@ describe("coreTypesProvider", () => {
// bundle so the cross-port registry manifest carries the same composed
// vocabulary as before (byte-identical) — uiWebProvider's attrs land on
// PresentationOnly-excluded rows, so the manifest itself is unaffected.
- expect(coreProviders).toHaveLength(6);
+ // rulesProvider (metaobjects-rules) and viewExpressionsProvider
+ // (metaobjects-view-expressions) are packs split out of core in 1.3.0; they are in
+ // the default bundle so no model changes, and each can be composed out.
+ expect(coreProviders).toHaveLength(8);
expect(coreProviders[0]).toBe(coreTypesProvider);
expect(coreProviders[1]).toBe(dbProvider);
expect(coreProviders[2]).toBe(docProvider);
expect(coreProviders[3]).toBe(promptProvider);
expect(coreProviders[4]).toBe(uiProvider);
expect(coreProviders[5]).toBe(uiWebProvider);
+ expect(coreProviders[6]).toBe(rulesProvider);
+ expect(coreProviders[7]).toBe(viewExpressionsProvider);
});
it("registerCoreTypes registers the structural types but not the DB-domain attrs", () => {
@@ -125,8 +132,13 @@ describe("coreTypesProvider", () => {
registerCoreTypes(viaWrapper);
const viaProviders = composeRegistry(coreProviders);
- // Same structural type+subtype pairs — dbProvider only extends, adds no types.
- expect(viaWrapper.allTypes().length).toBe(viaProviders.allTypes().length);
+ // dbProvider only extends and adds no types, so the only types composeRegistry adds
+ // over core alone are the two packs' (business rules, origin.function).
+ const packTypes = ["api", "operation", "binding", "transition"];
+ const coreOnly = viaProviders.allTypes().filter(
+ (t) => !packTypes.includes(t.type) && !(t.type === "origin" && t.subType === "function"),
+ );
+ expect(viaWrapper.allTypes().length).toBe(coreOnly.length);
// But composeRegistry(coreProviders) carries strictly more attrs (the DB attrs).
const sumAttrs = (reg: TypeRegistry): number =>
diff --git a/server/typescript/packages/metadata/test/registry.test.ts b/server/typescript/packages/metadata/test/registry.test.ts
index 07db65b519..81532a91b2 100644
--- a/server/typescript/packages/metadata/test/registry.test.ts
+++ b/server/typescript/packages/metadata/test/registry.test.ts
@@ -378,9 +378,9 @@ describe("registerCoreTypes", () => {
);
});
- it("registers the correct subtypes for 'origin'", () => {
+ it("registers the correct subtypes for 'origin' (core alone omits origin.function, the view-expressions pack's)", () => {
expect(registry.allSubTypesOf(TYPE_ORIGIN).sort()).toEqual(
- [...ORIGIN_SUBTYPES].sort(),
+ ORIGIN_SUBTYPES.filter((s) => s !== "function").sort(),
);
});
@@ -450,7 +450,7 @@ describe("registerCoreTypes", () => {
expect(def!.childRules).toHaveLength(0);
});
- it("metadata.root allows object, field, validator, template, requirement and api children (NOT a bare attr — strict model)", () => {
+ it("metadata.root (core alone) allows object, field, validator, template and requirement children (NOT a bare attr, and no api: the business-rules pack adds that)", () => {
// FR-033 S1-simple: the attr wildcard is dropped from the document root; the
// genuinely-open structural wildcards stay. `requirement` joined them when
// the capability ledger became metadata (ruling amendment 3) — capability
@@ -458,7 +458,7 @@ describe("registerCoreTypes", () => {
const def = registry.find(TYPE_METADATA, SUBTYPE_ROOT);
expect(def).toBeDefined();
const childTypes = def!.childRules.map((r) => r.childType).sort();
- expect(childTypes).toEqual([TYPE_FIELD, TYPE_OBJECT, TYPE_VALIDATOR, TYPE_TEMPLATE, TYPE_REQUIREMENT, TYPE_API].sort());
+ expect(childTypes).toEqual([TYPE_FIELD, TYPE_OBJECT, TYPE_VALIDATOR, TYPE_TEMPLATE, TYPE_REQUIREMENT].sort());
});
// 6. attr.* has empty child rules
diff --git a/spec/metamodel/api.json b/spec/metamodel/api.json
index 0f30e16e08..6c803bfba0 100644
--- a/spec/metamodel/api.json
+++ b/spec/metamodel/api.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "api",
@@ -69,5 +69,14 @@
{ "type": "attr", "subType": "string", "name": "path", "min": 0, "max": 1, "description": "A path template. Its `{name}` placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH)." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "metadata",
+ "subType": "root",
+ "children": [
+ { "type": "api", "subType": "*", "name": "*", "min": 0, "max": null, "description": "A declared API surface (ADR-0030, ADR-0066): a top-level, packaged node. Contributed by the business-rules pack." }
+ ]
+ }
]
}
diff --git a/spec/metamodel/field.json b/spec/metamodel/field.json
index 8d4c5a2185..46a2f064ce 100644
--- a/spec/metamodel/field.json
+++ b/spec/metamodel/field.json
@@ -149,7 +149,6 @@
"whenToUse": "A field is a fixed, closed set of string values. Set @values so the union type, DB CHECK, and validation are generated — don't hand-roll constants + checks.",
"rules": "Required @values is a non-empty, duplicate-free set; each member must match ^[A-Za-z_][A-Za-z0-9_]*$ so it is a legal identifier in every target language, and is its own stored string unless @stringValueMap (string) or @intValueMap (integer) maps it. Optional FR-010/FR-011 overlays add tolerant-extract aliasing (@enumAlias), per-member docs (@enumDoc), an uncoercible-value fallback (@coerceDefault, must be one of @values), and ASCII normalization mode (@normalize).",
"children": [
- { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." },
{ "type": "attr", "subType": "string", "name": "values", "isArray": true, "min": 1, "max": 1, "description": "Member symbols of an enum-subtype field. Declaration order is significant; each is a legal identifier and its own stored string unless @stringValueMap or @intValueMap maps it." },
{ "type": "attr", "subType": "boolean", "name": "provided", "min": 0, "max": 1, "description": "FR-019: marks an abstract package-level field.enum as externally provided — codegen references the type (resolved via per-port codegen config) instead of materializing it. Default false. Not a field attr — it lives on the type declaration." },
{ "type": "attr", "subType": "int", "name": "maxLength", "min": 0, "max": 1, "description": "Column length of a string-stored enum (drives VARCHAR(n)); every member must fit. Overrides the project's enums.maxLength. Refused with @intValueMap, whose column is an integer. Justified in ADR-0023 Amendment 1." },
diff --git a/spec/metamodel/object.json b/spec/metamodel/object.json
index eb44fedc67..ddf3c6eeec 100644
--- a/spec/metamodel/object.json
+++ b/spec/metamodel/object.json
@@ -54,10 +54,6 @@
"rules": "object.projection is a derived read-only representation: every field is extends-bound, origin-derived, or self-declared-under-external-assembly, and all are read-only at the subtype level. Identity is optional and, when present, MUST extend an entity identity. Sources are restricted to read-only @kinds. The declared field set IS the exposure — an inclusive list, fail-closed. A projection NEVER declares relationships (derivation is expressed via @via, not a relationship child) and NEVER co-locates templates — hence its child set omits both relationship and template. The assembly origins (origin.aggregate / origin.computed / origin.first) live HERE, not on object.value; a SOURCELESS projection is the legal shape for a wire-assembled read model, and a template-level @payloadRef/@responseRef may target one (#210). See ADR-0028 (object taxonomy, projection).",
"children": [
{ "type": "attr", "subType": "filter", "name": "filter", "min": 0, "max": 1, "description": "Optional row-scope predicate (a portable attr.filter object: eq/ne/gt/gte/lt/lte/like/in/isNull with and/or, desugared to { field: { op: value } } at parse time) selecting which rows the view returns — lowered to an outer SQL WHERE. A key names one of the projection's own fields, else a field of its base entity the view need not output, else a PATH of to-one hops (identity.reference or @cardinality one relationship names) from the base then a field of the entity reached ('orderId.customerId.hasActiveMembership'), joined but not output. A reached entity field may itself be derived (entity-derived: an origin.computed or origin.first declared on the entity, inlined where the filter reaches it). An aggregate-derived field is not addressable (fail-closed); a to-many hop is refused. A value may be a relative date ({ now: \"\", startOf? }) on a date or timestamp field (rc.19)." },
- { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
- { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
- { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
- { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." },
{ "type": "attr", "subType": "string", "name": "collectionName", "min": 0, "max": 1, "description": "The name of this object's collection, in the object's own casing (e.g. 'CaseHistory', 'Queues'): the REST collection segment (snake_cased) in every port, the reverse-finder names in C#, TypeScript and Python, the C# DbSet property, and the TypeScript list function, list hook and Drizzle table variable. It need not be a grammatical plural. Absent, the project's pluralizer derives it from the object's name (naming.collections in .metaobjects/config.json; built in: standard, none; an application may register its own)." }
]
},
diff --git a/spec/metamodel/origin.json b/spec/metamodel/origin.json
index e2539d6d66..c4fde970f9 100644
--- a/spec/metamodel/origin.json
+++ b/spec/metamodel/origin.json
@@ -42,20 +42,6 @@
{ "type": "attr", "subType": "expression", "name": "expr", "min": 1, "max": 1, "description": "The structured expression tree computing this field's value from the base entity's own fields (closed node grammar; shares the filter op vocabulary). Its inferred root type must equal the field's declared subType (ERR_COMPUTED_TYPE_MISMATCH)." }
]
},
- {
- "type": "origin",
- "subType": "function",
- "implementedIn": ["typescript", "csharp"],
- "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
- "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
- "children": [
- { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
- { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
- { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
- { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
- { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
- ]
- },
{
"type": "origin",
"subType": "first",
diff --git a/spec/metamodel/transition.json b/spec/metamodel/transition.json
index cbac9d3ef7..2cb444d160 100644
--- a/spec/metamodel/transition.json
+++ b/spec/metamodel/transition.json
@@ -1,5 +1,5 @@
{
- "provider": "metaobjects-core-types",
+ "provider": "metaobjects-rules",
"types": [
{
"type": "transition",
@@ -23,5 +23,14 @@
{ "type": "attr", "subType": "expression", "name": "condition", "min": 0, "max": 1, "description": "A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE." }
]
}
+ ],
+ "extends": [
+ {
+ "type": "field",
+ "subType": "enum",
+ "children": [
+ { "type": "transition", "subType": "*", "name": "*", "min": 0, "max": null, "description": "Lifecycle moves between this enum's members (ADR-0066). An enum with at least one transition.action is a lifecycle: its states are @values, its initial state @default, its terminal states the members no transition leaves." }
+ ]
+ }
]
}
diff --git a/spec/metamodel/view-expressions.json b/spec/metamodel/view-expressions.json
new file mode 100644
index 0000000000..4db3c0ca57
--- /dev/null
+++ b/spec/metamodel/view-expressions.json
@@ -0,0 +1,31 @@
+{
+ "provider": "metaobjects-view-expressions",
+ "types": [
+ {
+ "type": "origin",
+ "subType": "function",
+ "implementedIn": ["typescript", "csharp"],
+ "description": "A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.",
+ "whenToUse": "A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "function", "min": 1, "max": 1, "description": "The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase." },
+ { "type": "attr", "subType": "string", "name": "schema", "min": 0, "max": 1, "description": "The schema the function lives in, a plain identifier. Absent: public." },
+ { "type": "attr", "subType": "string", "name": "args", "isArray": true, "min": 0, "max": 1, "description": "The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments." },
+ { "type": "attr", "subType": "string", "name": "params", "isArray": true, "min": 0, "max": 1, "description": "The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN)." },
+ { "type": "attr", "subType": "string", "name": "returns", "min": 1, "max": 1, "description": "The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc)." }
+ ]
+ }
+ ],
+ "extends": [
+ {
+ "type": "object",
+ "subType": "projection",
+ "children": [
+ { "type": "attr", "subType": "string", "name": "union", "isArray": true, "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless." },
+ { "type": "attr", "subType": "boolean", "name": "unionAll", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default." },
+ { "type": "attr", "subType": "string", "name": "grain", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection." },
+ { "type": "attr", "subType": "string", "name": "grainOrdinal", "min": 0, "max": 1, "implementedIn": ["typescript", "csharp"], "description": "rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array." }
+ ]
+ }
+ ]
+}
From faaa45b40ee192010e04e75656761bb3e3fd1983 Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 07:51:50 -0500
Subject: [PATCH 2/9] docs: state that vocabulary lives in separate providers,
not core
Rewrite 'What modularity does and does not mean' as 'Where vocabulary lives': core holds the base metamodel, other vocabulary lives in its own provider, composed by default and removable. Record honestly what still sits in metaobjects-core-types. Defer the entry rule to GOVERNANCE.md. Drop the metaobjects-forge mention from the default bundle.
---
docs/features/extending-with-providers.md | 65 ++++++++++++-------
.../extending-metaobjects-with-providers.md | 4 +-
2 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/docs/features/extending-with-providers.md b/docs/features/extending-with-providers.md
index d2e1383c56..74668cb894 100644
--- a/docs/features/extending-with-providers.md
+++ b/docs/features/extending-with-providers.md
@@ -3,9 +3,11 @@
The metamodel is **open under composition**: every type, subtype, and attribute
the loader understands is contributed by a `MetaDataTypeProvider`. The core
package ships its own provider bundle (`metaobjects-core-types`,
-`metaobjects-forge`, `metaobjects-documentation`), but the same mechanism is
-how a downstream consumer adds an application-specific subtype — e.g., a
-`template.toolcall` that the core doesn't know about.
+`metaobjects-documentation` and the other concern providers), but the same
+mechanism is how new vocabulary is added — whether by a downstream consumer
+(e.g., a `template.toolcall` that the core doesn't know about) or by this
+project: new vocabulary lives in its own provider, a pack (see
+[Where vocabulary lives](#where-vocabulary-lives)).
This page covers:
@@ -102,15 +104,32 @@ field) and pick a word no other provider on that node type already holds. A stor
provider for goes in the `attr.properties` bag, not an invented attribute. `meta types
--detail` prints the registering provider next to each attribute, so you can see what is taken.
-## What modularity does and does not mean
-
-> **MetaObjects modularity is additive and behavioural, never subtractive: every port
-> ships the same vocabulary; a concern your model does not declare costs nothing,
-> generates nothing and diagnoses nothing; and downstream providers may add optional
-> vocabulary — so any model that loads under the default bundle loads identically in
-> every port.**
-
-Concretely, you opt in by **declaring**, not by configuring:
+## Where vocabulary lives
+
+**Core holds only the base metamodel. Everything else is vocabulary in its own provider (a
+pack), composed by default and individually removable.** Reporting, business rules,
+requirements, view expressions and any new vocabulary each belong in a provider of their own.
+"Composed by default" means no model changes: a model that loads today loads identically under
+the default bundle. "Individually removable" means an embedder can leave a pack out of
+`composeRegistry`, and ADR-0050 (above) guarantees the reduced registry is coherent, with no
+silently weakened types.
+
+The rule that decides what may enter core is owned by
+[GOVERNANCE.md](../../GOVERNANCE.md#extension-packs-and-the-core-metamodel): a new type, subtype
+or attribute needs a second, independent consumer before it enters core, and until then it
+lives in an extension pack. This page does not restate it. Which mechanism to use for the
+vocabulary is [ADR-0037](../../spec/decisions/ADR-0037-metamodel-vocabulary-expansion-decision-framework.md).
+
+**Current state, pending the split (not the design intent).** Today the reporting
+(`dimension`, `measure`, `segment`), requirements (`requirement.*`) and business-rule
+vocabularies, and the newest view expressions, are still registered by the one
+`metaobjects-core-types` provider (`metadata/src/core-types.ts`), and `metaobjects-core-types`
+therefore cannot be composed without them. That is where they landed, not where they belong:
+separating each into its own provider is planned work, and no new vocabulary should follow
+their example.
+
+You opt a concern in by **declaring**, not by configuring, and a concern your model does not
+declare costs nothing, generates nothing and diagnoses nothing:
| concern | how you opt in | what exists if you don't |
|---|---|---|
@@ -119,16 +138,9 @@ Concretely, you opt in by **declaring**, not by configuring:
| prompts | declare `template.*` nodes | nothing |
| requirements | declare `requirement.*` nodes | nothing — `verify` is silent |
-**Vocabulary is not subtractable, and that is deliberate.** You cannot compose a registry
-without `template.*` or `index.*`, because a model authored elsewhere would then *fail to
-load* rather than degrade — forking the interchange format into dialects, which is the
-exact failure a cross-language standard exists to prevent. Registered-but-undeclared
-vocabulary costs a model nothing: no generator, runtime or migration path reads a type you
-never declare.
-
-Reduced compositions remain available to **library embedders** (`composeRegistry` with a
-subset), and ADR-0050 guarantees any reduced composition is *coherent* — no silently
-weakened types. Anything a reduced registry loads, the full bundle loads identically.
+Cross-port rules still hold. Every port registers the same default composition, and
+`expected-registry.json` is what all five byte-match, so a pack leaves the default bundle only
+by a decision recorded against that manifest, never per port.
## Two registration modes
@@ -652,10 +664,13 @@ overlay semantics, common patterns).
every toolcall to declare a stub `@textRef`. A new subtype
(`template.toolcall` with `@payloadRef` + `@toolName` required, no
`@textRef`) is the honest fit.
-- **The semantic concept is so universal it deserves a name in the closed
- core vocabulary.** Example: `source.rdb` is a persistence-paradigm split —
+- **The semantic concept is a structural split that needs first-class subtype
+ identity.** Example: `source.rdb` is a persistence-paradigm split —
there will eventually be `source.kv`, `source.graph`, etc., and they all
- need first-class subtype identity for cross-port codegen routing.
+ need first-class subtype identity for cross-port codegen routing. Where the
+ subtype lives (core or a pack) is decided by
+ [GOVERNANCE.md](../../GOVERNANCE.md#extension-packs-and-the-core-metamodel),
+ not by this list.
- **You need load-time error detection even in a lax load.** A strict load
(the default for every tool) refuses an undeclared `@-attr` with
`ERR_UNKNOWN_ATTR`, so a missing provider is caught either way. A lax load
diff --git a/docs/recipes/extending-metaobjects-with-providers.md b/docs/recipes/extending-metaobjects-with-providers.md
index a2a555b60e..24d38fecc0 100644
--- a/docs/recipes/extending-metaobjects-with-providers.md
+++ b/docs/recipes/extending-metaobjects-with-providers.md
@@ -181,8 +181,8 @@ $ meta gen
✓ 7 files written under src/db/generated/ + src/llm/generated/.
$ meta verify
-✓ No metadata drift. 4 providers composed:
- metaobjects-core-types, metaobjects-forge, metaobjects-documentation, example-template-toolcall
+✓ No metadata drift. Providers composed:
+ metaobjects-core-types, metaobjects-documentation, ..., example-template-toolcall
```
## What happens when the provider is missing
From fd65d3be0b8d87266459ccd498e990f7c2fad738 Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 07:53:09 -0500
Subject: [PATCH 3/9] docs: tell agents new vocabulary goes in its own
provider, not core
One sentence each in AGENTS.md (design judgment), the auto-loading cross-language rule and the authoring skill, all pointing at GOVERNANCE.md.
---
.claude/rules/cross-language-porting.md | 2 ++
AGENTS.md | 2 +-
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/.claude/rules/cross-language-porting.md b/.claude/rules/cross-language-porting.md
index 5252b3812c..4966f27c3b 100644
--- a/.claude/rules/cross-language-porting.md
+++ b/.claude/rules/cross-language-porting.md
@@ -14,6 +14,8 @@ paths:
## Cross-language porting
+New vocabulary goes in its own provider pack, never in `metaobjects-core-types` ([GOVERNANCE.md](../../GOVERNANCE.md#extension-packs-and-the-core-metamodel) owns the rule).
+
Preserve the following contracts exactly across all language ports:
**Metamodel subtype vocabularies (must be identical across languages):** the `registry-conformance` gate (`fixtures/registry-conformance/`) is the structural enforcer of this rule — each port emits its registry as a canonical manifest byte-matched to `expected-registry.json`. **All five shipped ports (TS / C# / Java / Kotlin / Python) plus Rust in preview (ADR-0065, byte-identical) are live + green** (SP-G Java/Kotlin reconciliation complete; the JVM runners compose from the defined metamodel provider set so codegen-base/om classpath SPI does not pollute the measured vocabulary). See `fixtures/registry-conformance/README.md`.
diff --git a/AGENTS.md b/AGENTS.md
index 23a0ff4d2c..b13fe33fe1 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -390,7 +390,7 @@ it is correct because the conformance corpus passes.
These are the load-bearing principles that have emerged through implementation. Apply them every time.
-- **Expanding the metamodel vocabulary follows ONE decision procedure (ADR-0037) — driven by semantic behavior, not surface storage.** Don't ask "is X a string/number/date?"; ask "what does X *do*?" Ordered test: (0) **derivable** from existing subtype + attrs (`isArray`/`@maxLength`) + structure? → derive in codegen, add nothing; (1) **physical-only** (native type/meaning unchanged)? → the `@dbColumnType` escape hatch, not first-class vocab; (2) logical — **does X have its own native type, behavior, or attributes** (a *thing* that owns custom logic)? → **subtype** (the extension point: `field.uuid`, `field.uri`, `field.inet`); a **structural variant *within* a subtype** (changes generated shape, shares native type)? → **`@kind`** (the one chartered structural-variant axis: source table/view, uri url/urn — never a catch-all, never on a plain string); otherwise X just **modifies/validates/configures** an existing type → **attribute** (boolean flag `@localTime`; validation `@stringFormat` email/hostname; config `@maxLength`). The "string formats" set splits by behavior: url/uri→`field.uri`, ip→`field.inet` (native types + behavior), only email/hostname→`@stringFormat` (plain validated strings); uuid is already `field.uuid`. Self-documentation over economy; no same-name overloads (hence `@stringFormat`, not a third `@format`). Consult it every time. See [ADR-0037](spec/decisions/ADR-0037-metamodel-vocabulary-expansion-decision-framework.md).
+- **Expanding the metamodel vocabulary follows ONE decision procedure (ADR-0037) — driven by semantic behavior, not surface storage.** Don't ask "is X a string/number/date?"; ask "what does X *do*?" Ordered test: (0) **derivable** from existing subtype + attrs (`isArray`/`@maxLength`) + structure? → derive in codegen, add nothing; (1) **physical-only** (native type/meaning unchanged)? → the `@dbColumnType` escape hatch, not first-class vocab; (2) logical — **does X have its own native type, behavior, or attributes** (a *thing* that owns custom logic)? → **subtype** (the extension point: `field.uuid`, `field.uri`, `field.inet`); a **structural variant *within* a subtype** (changes generated shape, shares native type)? → **`@kind`** (the one chartered structural-variant axis: source table/view, uri url/urn — never a catch-all, never on a plain string); otherwise X just **modifies/validates/configures** an existing type → **attribute** (boolean flag `@localTime`; validation `@stringFormat` email/hostname; config `@maxLength`). The "string formats" set splits by behavior: url/uri→`field.uri`, ip→`field.inet` (native types + behavior), only email/hostname→`@stringFormat` (plain validated strings); uuid is already `field.uuid`. Self-documentation over economy; no same-name overloads (hence `@stringFormat`, not a third `@format`). Consult it every time. See [ADR-0037](spec/decisions/ADR-0037-metamodel-vocabulary-expansion-decision-framework.md). **New vocabulary goes in its own provider pack, never in `metaobjects-core-types`** — [GOVERNANCE.md](GOVERNANCE.md#extension-packs-and-the-core-metamodel) owns the rule.
- **Each port defaults to its own language's standard behaviour; identical cross-port output is opt-in.** Generated code writes what that language's standard serializer writes: C# decimals as JSON numbers, a value object's null member as `null`. Do not standardize the ports for the convenience of our own conformance tests. A cross-port form, such as `"wire": { "decimals": "string", "nullMembers": "omit" }`, is a project setting that adopters choose. The corpora pin it explicitly in their own config and never decide a default. 1.1.0 broke this rule by making the decimal string and null omission the only output, and 1.1.2 put it back. See [ADR-0019 Amendment 2](spec/decisions/ADR-0019-runtime-return-type-contract.md).
diff --git a/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md b/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
From c3f4553c4a63ac55a1d6ad24a6914b3038c019e8 Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 07:53:23 -0500
Subject: [PATCH 4/9] test: refresh agent-context conformance goldens for the
authoring skill edit
---
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
.../metaobjects-authoring/references/choosing-a-shape.md | 4 +++-
5 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/fixtures/agent-context-conformance/csharp/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md b/fixtures/agent-context-conformance/csharp/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/fixtures/agent-context-conformance/csharp/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/fixtures/agent-context-conformance/csharp/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
diff --git a/fixtures/agent-context-conformance/java-kotlin-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md b/fixtures/agent-context-conformance/java-kotlin-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/fixtures/agent-context-conformance/java-kotlin-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/fixtures/agent-context-conformance/java-kotlin-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
diff --git a/fixtures/agent-context-conformance/java-react/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md b/fixtures/agent-context-conformance/java-react/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/fixtures/agent-context-conformance/java-react/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/fixtures/agent-context-conformance/java-react/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
diff --git a/fixtures/agent-context-conformance/python/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md b/fixtures/agent-context-conformance/python/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/fixtures/agent-context-conformance/python/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/fixtures/agent-context-conformance/python/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
diff --git a/fixtures/agent-context-conformance/ts-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md b/fixtures/agent-context-conformance/ts-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
index bb4979af93..345eb6813c 100644
--- a/fixtures/agent-context-conformance/ts-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
+++ b/fixtures/agent-context-conformance/ts-react-tanstack/expected/.claude/skills/metaobjects-authoring/references/choosing-a-shape.md
@@ -198,5 +198,7 @@ uses the registered `attr.properties` bag rather than an invented attribute.
free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from
`register` to `extend` (the `template.toolcall` precedent). A second independent
consumer wanting the same concept is a consumer→core promotion candidate (ADR-0011) —
-open an upstream issue rather than adding core vocabulary yourself. Full guidance:
+open an upstream issue rather than adding core vocabulary yourself. In this repo new
+vocabulary lives in its own provider pack, never in `metaobjects-core-types` (GOVERNANCE.md,
+"Extension packs and the core metamodel"). Full guidance:
`docs/features/downstream-metadata-decisions.md`.
From 7bdefcd29499379aaabcd402a5ea98efb019f317 Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 08:29:23 -0500
Subject: [PATCH 5/9] docs: describe the rules and view-expressions packs as
shipped; reporting and requirements stay in core
---
docs/features/extending-with-providers.md | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/docs/features/extending-with-providers.md b/docs/features/extending-with-providers.md
index 74668cb894..0445417247 100644
--- a/docs/features/extending-with-providers.md
+++ b/docs/features/extending-with-providers.md
@@ -111,7 +111,7 @@ pack), composed by default and individually removable.** Reporting, business rul
requirements, view expressions and any new vocabulary each belong in a provider of their own.
"Composed by default" means no model changes: a model that loads today loads identically under
the default bundle. "Individually removable" means an embedder can leave a pack out of
-`composeRegistry`, and ADR-0050 (above) guarantees the reduced registry is coherent, with no
+`composeRegistry` (for example `composeRegistry(coreProviders.filter(p => p.id !== "metaobjects-rules"))`), and ADR-0050 (above) guarantees the reduced registry is coherent, with no
silently weakened types.
The rule that decides what may enter core is owned by
@@ -120,13 +120,18 @@ or attribute needs a second, independent consumer before it enters core, and unt
lives in an extension pack. This page does not restate it. Which mechanism to use for the
vocabulary is [ADR-0037](../../spec/decisions/ADR-0037-metamodel-vocabulary-expansion-decision-framework.md).
-**Current state, pending the split (not the design intent).** Today the reporting
-(`dimension`, `measure`, `segment`), requirements (`requirement.*`) and business-rule
-vocabularies, and the newest view expressions, are still registered by the one
-`metaobjects-core-types` provider (`metadata/src/core-types.ts`), and `metaobjects-core-types`
-therefore cannot be composed without them. That is where they landed, not where they belong:
-separating each into its own provider is planned work, and no new vocabulary should follow
-their example.
+**Current state.** Business rules (`api`, `operation`, `binding`, `transition`, provider
+`metaobjects-rules`) and the view expressions that arrived in 1.3.0 (`origin.function`, `@union`,
+`@unionAll`, `@grain`, `@grainOrdinal`, provider `metaobjects-view-expressions`) are packs: each
+is its own provider, in the default bundle of every port that carries it, and an embedder can
+leave it out. A model that uses a left-out pack's types gets a loader error naming the unknown
+type, subtype or attribute. Reporting (`dimension`, `measure`, `segment`, `object.report`) and
+requirements (`requirement.*`) are still registered by `metaobjects-core-types`: they are woven
+into `object.json` and read by the `verify` gate in every port, so they were not a small
+mechanical move. They are the next candidates for a pack, and they are where they landed, not
+where they belong. No new vocabulary should follow their example: a gate
+(`scripts/check-core-vocabulary-pin.ts`) pins the core provider's types and attributes, so adding
+one fails with a pointer to GOVERNANCE.md and this mechanism.
You opt a concern in by **declaring**, not by configuring, and a concern your model does not
declare costs nothing, generates nothing and diagnoses nothing:
From 5a0700694a8e0c13fbcc58ee3e06f8b91c9d1abc Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 08:43:11 -0500
Subject: [PATCH 6/9] docs: refresh fixture counts, site payload and site
reference for the pack fixtures
---
AGENTS.md | 2 +-
README.md | 2 +-
docs/CONFORMANCE.md | 10 ++---
docs/ports/rust.md | 2 +-
examples/showcase/site-payload.json | 2 +-
.../tests/conformance-expected-failures.json | 2 +-
site-reference/providers.html | 25 ++++++++++--
site-reference/types/api.html | 2 +
site-reference/types/binding.html | 6 ++-
site-reference/types/object.html | 8 ++--
site-reference/types/operation.html | 39 ++++++++++---------
site-reference/types/origin.html | 12 +++---
site-reference/types/transition.html | 16 ++++----
13 files changed, 78 insertions(+), 50 deletions(-)
diff --git a/AGENTS.md b/AGENTS.md
index b13fe33fe1..81bca5916b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -74,7 +74,7 @@ PyPI has had no product change since `0.25.0` — nothing is broken.
- **Kotlin** — `codegen-kotlin` (KotlinPoet on JVM): entity + Exposed table + Spring controller + payload + relations + filter allowlist + validator + stored-proc + output-parser generators. `integration-tests-kotlin` runs the persistence-conformance corpus through Exposed against Testcontainers Postgres.
**Cross-port conformance corpora** (every port runs the shared corpus):
-- Metamodel: `fixtures/conformance/` (574 fixtures; 43 shared corpora in total — per-corpus counts + the corpus x port matrix live in `docs/CONFORMANCE.md`). TS / C# / Java / Python all green.
+- Metamodel: `fixtures/conformance/` (578 fixtures; 43 shared corpora in total — per-corpus counts + the corpus x port matrix live in `docs/CONFORMANCE.md`). TS / C# / Java / Python all green.
- Render: `fixtures/render-conformance/`. TS / C# / Java / Kotlin / Python byte-identical.
- Persistence: `fixtures/persistence-conformance/`. **Query** scenarios run on every port (TS / C# / Java / Kotlin / Python), each provisioning its test DB by executing the committed, TS-produced `canonical/schema.postgres.sql` (Postgres only — Derby dropped for the cross-port query corpus, ADR-0015; the FR-044 `report-*` scenarios also run on SQLite, MySQL and D1 where a port has the engine, see [docs/CONFORMANCE.md](docs/CONFORMANCE.md)). The **migration** scenarios are exercised by **TS only** (TS owns schema migrations). **The corpus now gates WRITES, not just reads (SP-H):** an `op: roundtrip` scenario type INSERTs through each port's runtime/ORM write codec (NOT raw SQL), reads the row back, and asserts the wire-normalized value. The `AllTypes` entity (`roundtrip-all-types.yaml`) carries one field of **every** persistable `field.*` subtype — string/int/long/double/float/decimal/boolean/date/time/timestamp(+tz)/currency/enum/uuid/object — plus an **array-of-VO** `field.object @isArray @storage:jsonb` column (`labels`, written as 2-element / empty-`[]` / single-element arrays across the three rows) — so every subtype write+read (incl. the array-of-value-object jsonb codec) round-trips through every port against Testcontainers PG. (`field.byte`/`field.short`/`field.class` were cut as non-functional registration-only stubs — the matrix tracks only genuinely-supported subtypes; see `fixtures/registry-conformance/README.md` → "Per-subtype write-round-trip matrix".)
- API-contract: `fixtures/api-contract-conformance/`. TS / C# / Java / Kotlin / Python all green — each port runs **two lanes**: a hand-rolled reference server AND its **generated** API artifact booted over HTTP (the deployed controller/routes; TS+C# full-stack vs Testcontainers PG, Java/Kotlin/Python generated controller + in-memory repo behind the consumer seam). The generated fan-out found 10 real deployment bugs golden snapshots missed. Three sub-corpora run the **generated lane only, on all five ports** — `write-through/`, `projection/` (F22: a view-only `object.projection` serves GET list + GET by id and answers every write verb with `405 {"error": "method_not_allowed"}`) and `report/` (FR-044: a view-backed `object.report` serves GET list, answers `POST` with that same `405`, and mounts no `/{id}` route). That is deliberate, not a gap: what is under test is whether a port's GENERATOR emits those routes, and a hand-rolled reference server would answer every scenario by construction. The `m2m/` sub-corpus also gates **TPH x M:N together** (base-declared, subtype-declared, abstract-mid-declared, a non-subtype source onto a subtype TARGET, and the cross-subtype source id answering `200 []`) — the two corpora were originally built disjoint (`tph/` had no relationships, `m2m/` no discriminators), which is precisely how that defect class survived.
diff --git a/README.md b/README.md
index cfe8a9d98e..85d2714acb 100644
--- a/README.md
+++ b/README.md
@@ -171,7 +171,7 @@ first-week wedge plan — and `meta init` picks up from there.
| Kotlin | **Maven Central `8.2.0`** — codegen tier on top of Java: 17 generators (entity, Exposed table, names, relations, repository, output-parser, output-prompt, render-helper, extractor, filter-allowlist, validator, Spring config, storedProc, Spring controller, requirement-tests, api-docs, report-export); 24 / 24 persistence-conformance | [`docs/ports/kotlin.md`](docs/ports/kotlin.md) | [`server/java/codegen-kotlin/`](server/java/codegen-kotlin/) · [`server/java/metadata-ktx/`](server/java/metadata-ktx/) |
| C# | **NuGet `1.2.0`** — loader + conformance + EF Core codegen + render engine + `dotnet meta` CLI all shipped | [`docs/ports/csharp.md`](docs/ports/csharp.md) | [`server/csharp/`](server/csharp/) |
| Python | **PyPI `1.2.0`** — loader + conformance + render + entity-model codegen + ObjectManager runtime shipped; schema migrations are TS-owned (ADR-0015) | [`docs/ports/python.md`](docs/ports/python.md) | [`server/python/`](server/python/) |
-| Rust | **Preview, unpublished** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 574 / 574 metamodel conformance; `cargo meta init` / `gen` / `verify --codegen` / `eject` with the `entity`, `client` and `commands` generators (ADR-0065). Schema migrations stay with the Node `meta` tool | [`docs/ports/rust.md`](docs/ports/rust.md) | [`server/rust/`](server/rust/) |
+| Rust | **Preview, unpublished** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 578 / 578 metamodel conformance; `cargo meta init` / `gen` / `verify --codegen` / `eject` with the `entity`, `client` and `commands` generators (ADR-0065). Schema migrations stay with the Node `meta` tool | [`docs/ports/rust.md`](docs/ports/rust.md) | [`server/rust/`](server/rust/) |
## Capability matrix
diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md
index 3f40e55b67..e010c04212 100644
--- a/docs/CONFORMANCE.md
+++ b/docs/CONFORMANCE.md
@@ -26,7 +26,7 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor
| Corpus | Fixtures | TS | Java | Kotlin | C# | Python |
|---|---|---|---|---|---|---|
-| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 574 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ |
+| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 578 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ |
| [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 19 | 19 / 19 | 18 / 19 (1 ledgered: `yaml-quoted-leading-zero` — Java pipeline strips quotes off `"007"`) | inherits via Java | 18 / 19 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 19 / 19 |
| [`fixtures/verify-conformance/`](../fixtures/verify-conformance/) | 45 | ✓ | ✓ | inherits via Java | ✓ | ✓ |
| [`fixtures/verify-strict-conformance/`](../fixtures/verify-strict-conformance/) | 1 | ✓ | — | — | — | ✓ |
@@ -71,7 +71,7 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor
| [`fixtures/explorer-conformance/`](../fixtures/explorer-conformance/) (the `explorer.json` data spine: `meta export --effective` + `meta verify --format json` + the generated-file manifest in, one explorer document out) | 1 case (`shop`) | ✓ (the builder is TypeScript, and reads only port-neutral inputs) | — | — | — | — |
**Rust (preview, ADR-0065) is not a column yet.** The sixth port runs these corpora
-today: `registry-conformance` (byte-identical manifest); the metamodel corpus, all 574
+today: `registry-conformance` (byte-identical manifest); the metamodel corpus, all 578
green, with every validation pass the TypeScript loader runs, in the same order, so
`server/rust/metaobjects/tests/conformance-expected-failures.json` is empty;
`yaml-conformance`, 18 of 19 (the one on `yaml-conformance-expected-failures.json`,
@@ -89,7 +89,7 @@ generator, and a scale gate over twenty copies of the fitness model. The ledgers
only shrink; the corpora without one assert each case outright. While the port is in
preview, a new fixture that fails in Rust and is not on the ledger prints a warning and does
not fail the lane; it becomes a hard failure when the port leaves preview. A regression
-still fails: the ledger's `minPassing` (574) is the number of fixtures known to pass, and the
+still fails: the ledger's `minPassing` (578) is the number of fixtures known to pass, and the
run fails when fewer do. The column joins this table when the port leaves preview.
A ✓ means the port runs the corpus green; an explicit `n / m` is used where a port
@@ -424,7 +424,7 @@ unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker.
## Fixture-to-doc mapping
-### `fixtures/conformance/` — metamodel loader + canonical serializer (574)
+### `fixtures/conformance/` — metamodel loader + canonical serializer (578)
| Fixture prefix | Feature doc |
|---|---|
@@ -822,7 +822,7 @@ JSON and verify payload feeds it unchanged.
## Orphaned fixtures (tested but not yet documented)
-The fixtures in the nine corpora mapped above (metamodel 574 + yaml 19 + verify 45
+The fixtures in the nine corpora mapped above (metamodel 578 + yaml 19 + verify 45
+ render 18 + persistence 67 + api-contract 141 + source-resolution 28 + scope 10 +
dependency 47) each map to a feature doc, and so do the two requirement corpora, `rules-check-conformance`, `shared-model-conformance`, the
`cube-model` corpus and `explorer-conformance`, whose case lists live in their own READMEs. None are orphaned today. The remaining
diff --git a/docs/ports/rust.md b/docs/ports/rust.md
index eeb2b496e5..5032675594 100644
--- a/docs/ports/rust.md
+++ b/docs/ports/rust.md
@@ -238,7 +238,7 @@ outright.
| Corpus | Rust today |
|---|---|
| `registry-conformance` | byte-identical manifest |
-| `conformance` (the metamodel corpus) | **574 of 574**, and the ledger is empty |
+| `conformance` (the metamodel corpus) | **578 of 578**, and the ledger is empty |
| `yaml-conformance` | 18 of 19. The one on the ledger, `yaml-ref-root-escape`, waits for the root-level `::` reference rules of [ADR-0059](../../spec/decisions/ADR-0059-references-resolve-once-after-the-tree.md), which are reference resolution, not a validation pass. |
| `source-resolution-conformance` | all 28 cases |
| `naming-conformance` | all of it |
diff --git a/examples/showcase/site-payload.json b/examples/showcase/site-payload.json
index d8b4588ba2..de8940334c 100644
--- a/examples/showcase/site-payload.json
+++ b/examples/showcase/site-payload.json
@@ -7,7 +7,7 @@
"metamodel": "1.3"
},
"counts": {
- "fixtures": 574,
+ "fixtures": 578,
"corpora": 43,
"baseTypes": 21
},
diff --git a/server/rust/metaobjects/tests/conformance-expected-failures.json b/server/rust/metaobjects/tests/conformance-expected-failures.json
index a38e1cb607..076df089fa 100644
--- a/server/rust/metaobjects/tests/conformance-expected-failures.json
+++ b/server/rust/metaobjects/tests/conformance-expected-failures.json
@@ -1,6 +1,6 @@
{
"language": "rust",
"notes": "The Rust port is in preview. It passes every fixture of the shared metamodel corpus, so the ledger is empty. The ledger may only shrink and is kept for the day a new fixture lands that Rust does not pass yet: list it here with the reason, and it leaves when the work that covers it lands. minPassing is the number of fixtures known to pass; the run fails when fewer do, and it may only rise.",
- "minPassing": 574,
+ "minPassing": 578,
"fixtures": []
}
diff --git a/site-reference/providers.html b/site-reference/providers.html
index 97fd3cff37..2f4e15ae08 100644
--- a/site-reference/providers.html
+++ b/site-reference/providers.html
@@ -51,7 +51,7 @@
INDEX.md lists by type.
metaobjects-core-types
Core metaobjects metamodel types and subtypes.
-Owns (registers): attr.base, attr.boolean, attr.class, attr.double, attr.expression, attr.filter, attr.int, attr.intMap, attr.long, attr.properties, attr.string, field.base, field.boolean, field.currency, field.date, field.decimal, field.double, field.duration, field.enum, field.float, field.inet, field.int, field.long, field.map, field.object, field.string, field.time, field.timestamp, field.uri, field.uuid, identity.primary, identity.reference, identity.secondary, layout.base, layout.dataGrid, object.base, object.entity, object.projection, object.report, object.value, origin.aggregate, origin.base, origin.computed, origin.first, origin.function, origin.passthrough, relationship.aggregation, relationship.association, relationship.base, relationship.composition, source.base, source.rdb, template.base, template.output, template.prompt, template.toolcall, validator.array, validator.atLeastOne, validator.base, validator.comparison, validator.exactlyOne, validator.length, validator.numeric, validator.presentIff, validator.regex, validator.required, validator.requiredWhen, view.base, view.checkbox, view.currency, view.date, view.dropdown, view.hidden, view.hotlink, view.image, view.month, view.number, view.password, view.radio, view.text, view.textarea, view.web
+Owns (registers): attr.base, attr.boolean, attr.class, attr.double, attr.expression, attr.filter, attr.int, attr.intMap, attr.long, attr.properties, attr.string, field.base, field.boolean, field.currency, field.date, field.decimal, field.double, field.duration, field.enum, field.float, field.inet, field.int, field.long, field.map, field.object, field.string, field.time, field.timestamp, field.uri, field.uuid, identity.primary, identity.reference, identity.secondary, layout.base, layout.dataGrid, object.base, object.entity, object.projection, object.report, object.value, origin.aggregate, origin.base, origin.computed, origin.first, origin.passthrough, relationship.aggregation, relationship.association, relationship.base, relationship.composition, source.base, source.rdb, template.base, template.output, template.prompt, template.toolcall, validator.array, validator.atLeastOne, validator.base, validator.comparison, validator.exactlyOne, validator.length, validator.numeric, validator.presentIff, validator.regex, validator.required, validator.requiredWhen, view.base, view.checkbox, view.currency, view.date, view.dropdown, view.hidden, view.hotlink, view.image, view.month, view.number, view.password, view.radio, view.text, view.textarea, view.web
Contributes attributes:
field.base: @default, @mutability, @required, @unique
@@ -68,12 +68,11 @@ metaobjects-core-types
identity.secondary: @fields
object.base: @object, @objectAdapter
object.entity: @collectionName, @discriminator, @discriminatorValue
-object.projection: @collectionName, @filter, @grain, @grainOrdinal, @union, @unionAll
+object.projection: @collectionName, @filter
object.report: @collectionName, @dimensions, @filter, @from, @measures, @segment, @spine
origin.aggregate: @agg, @distinct, @filter, @of, @orderBy, @segment, @via
origin.computed: @expr
origin.first: @filter, @of, @orderBy, @segment, @via
-origin.function: @args, @function, @params, @returns, @schema
origin.passthrough: @convert, @from, @via
relationship.aggregation: @cardinality, @objectRef, @onDelete, @onUpdate, @sourceRefField, @symmetric, @through
relationship.association: @cardinality, @objectRef, @onDelete, @onUpdate, @sourceRefField, @symmetric, @through
@@ -158,6 +157,18 @@ metaobjects-prompt
field.uuid: @example, @instruction, @xmlText
object.value: @normalize
+metaobjects-rules
+Business rules (ADR-0066, experimental): the declared API surface (api / operation / binding) and lifecycle moves (transition on a field.enum).
+Owns (registers): api.base, api.operational, binding.base, binding.rest, operation.base, operation.command, operation.query, transition.action, transition.base
+Contributes attributes:
+
+binding.rest: @method, @path
+operation.base: @inputRef, @objectRef, @outputRef, @permission, @public
+operation.command: @errors, @transitions
+operation.query: @many
+transition.action: @condition, @from, @to
+transition.base: @permission, @public
+
metaobjects-ui
UI/query-surface domain — @filterable / @sortable / @sortableDefaultOrder field markers driving generated CRUD filter + sort allowlists (Project D).
Contributes attributes:
@@ -190,6 +201,14 @@ metaobjects-ui-web
view.image: @accept, @aspectRatio, @maxBytes, @maxEdge, @store
view.textarea: @rows
+
+metaobjects-view-expressions
+View expressions (rc.21): origin.function plus the projection @union / @unionAll / @grain / @grainOrdinal attributes.
+Owns (registers): origin.function
+Contributes attributes:
+
+object.projection: @grain, @grainOrdinal, @union, @unionAll
+origin.function: @args, @function, @params, @returns, @schema
diff --git a/site-reference/types/api.html b/site-reference/types/api.html
index 5c973e7b66..009731dba0 100644
--- a/site-reference/types/api.html
+++ b/site-reference/types/api.html
@@ -52,12 +52,14 @@
(min..max, * = unbounded).
api.base
Registry anchor for the declared API surface (ADR-0030, ADR-0054): not authorable. The api subtype axis is the interaction model, never the protocol; protocol lives in binding.* on each operation.
+Owning provider: metaobjects-rules
Attributes
No subtype-specific attributes.
Allowed children
No structural children.
api.operational
A named, packaged request/response surface whose children are operations (ADR-0030). It is a wire contract: two of them (v1, v2) may declare the same operation side by side. The code behind it is one service per metadata package, whose surface is the package's operations (ADR-0067). Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+Owning provider: metaobjects-rules
Rules: Children are operation.command and operation.query. Lives at the document root. Declares no fields, sources or identities: shapes are referenced, never defined, by the surface. Operation names are compared without case, are unique across every API of one package, except one operation declared identically in two APIs, such as a versioned API beside its successor (one operation declared twice in one API merges), and may not be create, get, list, update or delete in any case (ERR_TRANSITION_NAME_COLLISION). Two declared bindings of one API may not share a method and path (ERR_BINDING_PATH_MISMATCH).
When to use: The application does something beyond derived CRUD: a named command (approve, cancel, import) or a named query (my open requests). Declare it here so its input, output, permission and business errors are part of the model. A plain lifecycle needs no api.operational at all: a transition nobody claims is held to derive its own command once a shell is generated, and no shell is generated yet.
Attributes
diff --git a/site-reference/types/binding.html b/site-reference/types/binding.html
index 030f661324..41d725a1c8 100644
--- a/site-reference/types/binding.html
+++ b/site-reference/types/binding.html
@@ -52,12 +52,14 @@
(min..max, * = unbounded).
binding.base
Registry anchor for protocol bindings (ADR-0030, ADR-0054): not authorable.
+Owning provider: metaobjects-rules
Attributes
No subtype-specific attributes.
Allowed children
No structural children.
binding.rest
The HTTP method and path of an operation, declared only to override the derived ones. A query is GET, a command POST; the path is /<collection>/{id}/<operation-kebab> for an operation with a target key and /<collection>/<operation-kebab> without one. Most models never write it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+Owning provider: metaobjects-rules
When to use: An operation must keep a method or path the derived one would not give it, such as an existing public URL.
Attributes
@@ -78,7 +80,7 @@ binding.rest
no |
|
GET, POST, PUT, PATCH, DELETE |
-— |
+metaobjects-rules |
The HTTP method. Absent: GET for a query, POST for a command. |
@@ -87,7 +89,7 @@ binding.rest
no |
|
|
-— |
+metaobjects-rules |
A path template. Its {name} placeholders must be exactly the target's primary key fields when the operation is keyed, and there must be none when it is not; two declared bindings of one API may not share the method and path (ERR_BINDING_PATH_MISMATCH). |
diff --git a/site-reference/types/object.html b/site-reference/types/object.html
index 7578d5a9d0..88ec8d0e73 100644
--- a/site-reference/types/object.html
+++ b/site-reference/types/object.html
@@ -214,7 +214,7 @@ object.projection
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
rc.21: the view has one row per element of this base-entity field, a field.object array stored as jsonb; a base row with no element has no row. A field whose origin.passthrough @from names the field's @objectRef value object (Address.city) reads that member of the element; the base's own fields read the parent row as usual. An origin.aggregate is refused on such a projection. |
@@ -223,7 +223,7 @@ object.projection
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
rc.21: with @grain, the name of a field.int or field.long of this projection (with no origin) that holds the element's 1-based position in the array. |
@@ -250,7 +250,7 @@ object.projection
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
rc.21: the view is this projection's rows UNIONed with each named projection's rows. Each named projection has the same effective fields as this one, in order: names, subtypes, array-ness and physical column names (ERR_BAD_ATTR_VALUE otherwise); its own @filter, joins and base apply to its rows. Usually this projection extends one branch and names the others. A named projection may be abstract and sourceless. |
@@ -259,7 +259,7 @@ object.projection
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
rc.21: with @union, keep duplicate rows (UNION ALL). Absent or false: duplicates are removed (UNION), SQL's own default. |
diff --git a/site-reference/types/operation.html b/site-reference/types/operation.html
index 9434b5301b..f984297928 100644
--- a/site-reference/types/operation.html
+++ b/site-reference/types/operation.html
@@ -52,6 +52,7 @@
(min..max, * = unbounded).
operation.base
Registry anchor for the attributes every operation shares (ADR-0054): not authorable.
+Owning provider: metaobjects-rules
Attributes
@@ -71,7 +72,7 @@ operation.base
no |
|
|
-— |
+metaobjects-rules |
The object.value this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an object.value is ERR_OPERATION_SHAPE. |
@@ -80,7 +81,7 @@ operation.base
no |
|
|
-— |
+metaobjects-rules |
The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields extend every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an object.entity (ERR_OPERATION_TARGET_UNRESOLVED). |
@@ -89,7 +90,7 @@ operation.base
no |
|
|
-— |
+metaobjects-rules |
The object this operation returns: an object.projection, object.entity or object.value. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
@@ -98,7 +99,7 @@ operation.base
no |
|
|
-— |
+metaobjects-rules |
The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as purchasing.approve; a package prefix may use :: (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name <package>.<operation>, with the package of the operation's API, and verify advises or requires an explicit one (setting rules.permissions.names). Several operations may share one. |
@@ -107,7 +108,7 @@ operation.base
no |
|
|
-— |
+metaobjects-rules |
The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
@@ -117,6 +118,7 @@ operation.base
operation.command
A named operation that changes state. Takes an object.value (ADR-0030). Its body is hand-written. The contract (ADR-0066) is that a generated shell around it loads the row, checks the permission and the current state, runs the body, and makes the guarded update in one transaction. No shell is generated yet: this vocabulary is registered, loaded and checked, and nothing is generated from it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+Owning provider: metaobjects-rules
When to use: A business action with its own name, input and rules: approve, cancel, transfer. A command that moves a lifecycle names the transitions it may make in @transitions; its body decides which one applies.
Attributes
@@ -137,7 +139,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The business failures the hand-written body may return, each a lower snake case code (insufficient_funds). They name the wire error, the OpenAPI document and the typed result; the shell will refuse an undeclared one (no shell is generated yet). A code that is not lower snake case, appears twice, or is one the route answers itself (not_found, forbidden, invalid_transition, transition_condition_failed, state_managed, validation, invalid_json, invalid_id, method_not_allowed, constraint_violation, internal) is ERR_BAD_ATTR_VALUE. |
@@ -146,7 +148,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The object.value this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an object.value is ERR_OPERATION_SHAPE. |
@@ -155,7 +157,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields extend every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an object.entity (ERR_OPERATION_TARGET_UNRESOLVED). |
@@ -164,7 +166,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The object this operation returns: an object.projection, object.entity or object.value. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
@@ -173,7 +175,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as purchasing.approve; a package prefix may use :: (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name <package>.<operation>, with the package of the operation's API, and verify advises or requires an explicit one (setting rules.permissions.names). Several operations may share one. |
@@ -182,7 +184,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
@@ -191,7 +193,7 @@ operation.command
no |
|
|
-— |
+metaobjects-rules |
The lifecycle moves this command may make: names of transition.action nodes on its target entity (ERR_OPERATION_UNKNOWN_TRANSITION otherwise). A fact of the business the model cannot compute. A transition a command lists gets no derived command of its own. Listing any requires a target (ERR_OPERATION_TARGET_UNRESOLVED). |
@@ -201,6 +203,7 @@ operation.command
operation.query
A named operation that reads. Returns an object.projection (or an entity or value). It changes nothing. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+Owning provider: metaobjects-rules
When to use: A read with its own name and shape beyond derived get and list: my open requests, the dashboard summary.
Attributes
@@ -221,7 +224,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The object.value this operation takes as its input (ADR-0030). Absent on an operation whose only parameter is the target's borrowed key. Anything other than an object.value is ERR_OPERATION_SHAPE. |
@@ -230,7 +233,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The query returns a list and takes the filter, sort and paging contract. Not implied by the projection, so declared. Absent means one row. Legal on a query only. |
@@ -239,7 +242,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The entity this operation acts on, declared only when it cannot be derived. It is derived from the input value when its fields extend every primary key field of exactly one entity, each once, else from the output's base entity; an input that borrows part of a key, one key field twice, or the keys of two entities derives nothing, so declare it. Declared and derivable, the two must agree (ERR_OPERATION_TARGET_MISMATCH). It must name an object.entity (ERR_OPERATION_TARGET_UNRESOLVED). |
@@ -248,7 +251,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The object this operation returns: an object.projection, object.entity or object.value. Which projection a query returns is the author's choice among several over one entity, so it cannot be computed. Anything else is ERR_OPERATION_SHAPE. |
@@ -257,7 +260,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The permission name the generated shell will ask the project's policy about before anything is written (no shell is generated yet). A key into grant data (who holds it is data, what the policy decides is code), so an explicit name is stable: a derived name moves when the operation is renamed. A dotted identifier path such as purchasing.approve; a package prefix may use :: (ERR_BAD_ATTR_VALUE otherwise). Absent and not @public: the shell will use the derived name <package>.<operation>, with the package of the operation's API, and verify advises or requires an explicit one (setting rules.permissions.names). Several operations may share one. |
@@ -266,7 +269,7 @@ operation.query
no |
|
|
-— |
+metaobjects-rules |
The shell will call no permission check (no shell is generated yet). Authentication is the transport's job and is unaffected. Absent means checked. Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
diff --git a/site-reference/types/origin.html b/site-reference/types/origin.html
index c0525d7233..c04fac091c 100644
--- a/site-reference/types/origin.html
+++ b/site-reference/types/origin.html
@@ -238,7 +238,7 @@ origin.first
No structural children.
origin.function
A value computed by a database function the project owns (rc.21): @function names it, @schema its schema (absent: public), and @args the fields passed to it, in order. On an entity an argument is one of its fields; on a projection, one of its own fields (not an aggregate) or a field of its base entity. @params declares each argument's type and @returns the result's: an argument must have its parameter's type (cast it through an origin.computed field otherwise), @returns must be the carrying field's subtype, and the view casts the call to the field's full column type (the one its table column would have: length or @dbColumnType spelling, precision and scale, a local or zoned timestamp), so the call is checked, never free SQL. The signature is a declaration: meta verify --db reads the function from pg_proc and fails on a parameter or return type that differs. MetaObjects never creates the function: it is owned SQL, created before the view. Declared on an entity, it is entity-derived: a projection reaching the entity reads it like any derived field. Postgres only; the SQLite view emitter refuses it.
-Owning provider: metaobjects-core-types
+Owning provider: metaobjects-view-expressions
Implemented in: csharp, typescript so far — every port loads and type-checks it; the others do not act on it yet.
When to use: A view column is the result of a function the database already holds (a PL/pgSQL state machine, a legacy computation) and cannot be expressed in @expr. Declare the call instead of hand-writing the view's @sql.
Attributes
@@ -260,7 +260,7 @@ origin.function
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
The fields passed to the function, in parameter order: field names of the host entity, or (on a projection) of the projection or its base entity. Each must be a scalar field whose subtype is the declared parameter type in @params; to pass another type, pass an origin.computed field that casts it ({ cast: { field: x }, as: }). Absent or empty: a function of no arguments. |
@@ -269,7 +269,7 @@ origin.function
yes |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
The function's name as the database names it: a plain identifier ([A-Za-z_][A-Za-z0-9_]*), quoted when it is not lowercase. |
@@ -278,7 +278,7 @@ origin.function
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
The function's declared parameter types, one field subtype per @args entry, in order (string, int, long, double, float, decimal, boolean, date, timestamp, uuid). Required when @args is not empty; an argument of another type is refused (ERR_INVALID_ORIGIN). |
@@ -287,7 +287,7 @@ origin.function
yes |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
The function's declared return type, a field subtype; it must be the carrying field's subtype (ERR_INVALID_ORIGIN). The view casts the call to the field's full column type, which would hide a wrong declaration, so meta verify --db checks it against the function's real return type (pg_proc). |
@@ -296,7 +296,7 @@ origin.function
no |
|
|
-metaobjects-core-types |
+metaobjects-view-expressions |
The schema the function lives in, a plain identifier. Absent: public. |
diff --git a/site-reference/types/transition.html b/site-reference/types/transition.html
index bae0bb4f1d..9995c08156 100644
--- a/site-reference/types/transition.html
+++ b/site-reference/types/transition.html
@@ -52,6 +52,7 @@
(min..max, * = unbounded).
transition.action
An allowed move between two values of a field.enum, made by an operation (ADR-0066). A field.enum with at least one is a lifecycle, named after the field. Its states are the enum's @values, its initial state the enum's @default, its terminal states the members no transition leaves; none of them has vocabulary of its own. Each transition is held to become a guarded update (... WHERE id = ? AND <field> IN (@from) [AND @condition]), its own command when no declared operation claims it, its own permission point and its own wire error. No shell is generated yet: nothing is generated from this vocabulary, and the loader and verify only check it. Experimental since 1.3.0: the shape may change in a MINOR, including removals and renames (docs/compatibility-policy.md).
+Owning provider: metaobjects-rules
Rules: Legal only under a field.enum of an object.entity (ERR_TRANSITION_NOT_ON_ENTITY). A concrete entity with a lifecycle and a source needs a writable one (ERR_TRANSITION_NOT_ON_ENTITY); on an entity with no source the lifecycle loads and is inert, deriving no command until a source is added. The field must declare @default (ERR_LIFECYCLE_NO_INITIAL). The field is not an array, and @from names at least one state (ERR_BAD_ATTR_VALUE). Names are unique across every lifecycle of the entity, compared without case, and may not be create, get, list, update or delete in any case (ERR_TRANSITION_NAME_COLLISION). A transition belongs to the entity that declares its field and to every entity extending it, never to an entity whose field merely extends that field; an inheritor that redeclares the field without extending it is ERR_LIFECYCLE_REDECLARED.
When to use: A status field whose values may only change in certain ways: a request is submitted from draft, approved or rejected from submitted. Declare each allowed move here; once a shell is generated, the generic update path will no longer write the field. A move that leaves the state where it was (from submitted to submitted) records an action that changes nothing but still happened, such as a first approval of two.
Attributes
@@ -73,7 +74,7 @@ transition.action
no |
|
|
-— |
+metaobjects-rules |
A guard over the entity's own fields, in the attr.expression grammar: the same name, grammar and meaning as on the cross-field validators. The shell will evaluate it against the loaded row and also put it into the guarded update's WHERE (no shell is generated yet). It cannot read the actor; that is the policy's job. A field the entity does not have, or an expression that is not boolean, is ERR_BAD_ATTR_VALUE. |
@@ -82,7 +83,7 @@ transition.action
yes |
|
|
-— |
+metaobjects-rules |
The states this move may start from: members of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise), at least one (ERR_BAD_ATTR_VALUE when empty). The allowed moves are the business rule itself, so they cannot be computed. |
@@ -91,7 +92,7 @@ transition.action
no |
|
|
-— |
+metaobjects-rules |
As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name <package>.<Entity>.<transition>, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
@@ -100,7 +101,7 @@ transition.action
no |
|
|
-— |
+metaobjects-rules |
As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
@@ -109,7 +110,7 @@ transition.action
yes |
|
|
-— |
+metaobjects-rules |
The state this move ends in: one member of the parent enum's @values (ERR_TRANSITION_UNKNOWN_STATE otherwise). May equal a member of @from, which records an action that leaves the state where it was. |
@@ -117,6 +118,7 @@ transition.action
No structural children.
transition.base
Registry anchor for the attributes every lifecycle move shares (ADR-0054): not authorable.
+Owning provider: metaobjects-rules
Attributes
@@ -136,7 +138,7 @@ transition.base
no |
|
|
-— |
+metaobjects-rules |
As on an operation: the permission name the derived command for this transition will ask the policy about (no command is derived yet). A dotted identifier path, as on an operation. Absent and not @public: the derived name <package>.<Entity>.<transition>, naming the concrete entity, so two entities' transitions of one name ask about different permissions. Read only when the transition derives its own command; a declared operation that claims it uses its own, and verify warns that this one is never read (WARN_TRANSITION_PERMISSION_SHADOWED). |
@@ -145,7 +147,7 @@ transition.base
no |
|
|
-— |
+metaobjects-rules |
As on an operation: the derived command will call no permission check (no command is derived yet). Declaring it with @permission is ERR_PERMISSION_PUBLIC_CONFLICT. |
From 74a2b6f7712eaec7bd55c25a2f7690601f371eac Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 08:48:18 -0500
Subject: [PATCH 7/9] no-mistakes(review): Compose docs-site registry from
coreProviders
---
server/typescript/packages/docs-site/src/load.ts | 7 ++++---
.../docs-site/test/provider-extension.test.ts | 15 +++++++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/server/typescript/packages/docs-site/src/load.ts b/server/typescript/packages/docs-site/src/load.ts
index 5ee9b171d1..bc8cbe7592 100644
--- a/server/typescript/packages/docs-site/src/load.ts
+++ b/server/typescript/packages/docs-site/src/load.ts
@@ -1,7 +1,7 @@
import { mkdtempSync, readdirSync, rmSync, statSync, symlinkSync } from "node:fs";
import { tmpdir } from "node:os";
import { basename, dirname, join, resolve } from "node:path";
-import { MetaDataLoader, composeRegistry, coreTypesProvider, dbProvider, docProvider, promptProvider, uiProvider } from "@metaobjectsdev/metadata";
+import { MetaDataLoader, composeRegistry, coreProviders } from "@metaobjectsdev/metadata";
import type { MetaData, MetaRoot, MetaDataTypeProvider } from "@metaobjectsdev/metadata";
import { FileSource } from "@metaobjectsdev/metadata/core";
@@ -15,7 +15,7 @@ export interface LoadedModel {
* Load N metadata source dirs into ONE root via a staging dir of symlinks.
*
* `extraProviders` are consumer-supplied metamodel providers, composed AFTER
- * the built-in bundle (core-types + db + doc + prompt + ui) — mirroring
+ * the default bundle (`coreProviders`: core-types, db, doc, prompt, ui, rules, view-expressions) — mirroring
* `loadMemory`'s `providers` option — so a site can document metadata that uses
* custom field/view/object subtypes (e.g. a project's `metaobjects.config.ts`
* `providers`). Defaults to none, so config-less callers are unchanged.
@@ -40,7 +40,8 @@ export async function loadModel(
groupNames.push(name);
symlinkSync(resolve(dir), join(staging, name));
}
- const registry = composeRegistry([coreTypesProvider, dbProvider, docProvider, promptProvider, uiProvider, ...extraProviders]);
+ const extraIds = new Set(extraProviders.map((p) => p.id));
+ const registry = composeRegistry([...coreProviders.filter((p) => !extraIds.has(p.id)), ...extraProviders]);
// Feed files in files-before-subdirs order (the same order the sdk's loadMemory
// uses), NOT fromDirectory's flat basename sort. Cross-file overlays require the
// base (typically a top-level file) to load before an overlay that lives in a
diff --git a/server/typescript/packages/docs-site/test/provider-extension.test.ts b/server/typescript/packages/docs-site/test/provider-extension.test.ts
index 32ba5cc4bf..667e1711b0 100644
--- a/server/typescript/packages/docs-site/test/provider-extension.test.ts
+++ b/server/typescript/packages/docs-site/test/provider-extension.test.ts
@@ -73,3 +73,18 @@ test("generateSite: extraProviders lets a site document custom-subtype metadata"
expect(existsSync(join(out, "index.html"))).toBe(true);
expect(r.dangling).toEqual([]);
});
+
+// The business-rules and view-expressions packs are composed by default, so a
+// model using `api.operational`, `transition.action` or `origin.function` loads
+// in the site builder exactly as it does in `meta gen` / `meta verify`.
+const fixturesRoot = join(import.meta.dir, "..", "..", "..", "..", "..", "fixtures", "conformance");
+
+test("loadModel: a model declaring api/operation/transition loads without extraProviders", async () => {
+ const model = await loadModel([join(fixturesRoot, "rules-purchase-request", "input")]);
+ expect(model.root.objects().map((o) => o.name)).toContain("PurchaseRequest");
+});
+
+test("loadModel: a projection declaring origin.function loads without extraProviders", async () => {
+ const model = await loadModel([join(fixturesRoot, "error-packs-left-out-origin-function-used", "input")]);
+ expect(model.root.objects().map((o) => o.name)).toContain("ProgramSummary");
+});
From af99844deb245cbb89d4be74c894a392d3e15692 Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 09:46:36 -0500
Subject: [PATCH 8/9] no-mistakes(test): apply changes made during test
validation
---
server/rust/metaobjects/src/providers.rs | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/server/rust/metaobjects/src/providers.rs b/server/rust/metaobjects/src/providers.rs
index d5eb9a733e..19e21d3f80 100644
--- a/server/rust/metaobjects/src/providers.rs
+++ b/server/rust/metaobjects/src/providers.rs
@@ -479,7 +479,12 @@ fn apply_definition(
ChildSubType::Many(list) => list.clone(),
};
for sub in sub_types {
- registry.extend(&ext.type_name, &sub, attributes.clone(), child_rules.clone())?;
+ registry.extend(
+ &ext.type_name,
+ &sub,
+ attributes.clone(),
+ child_rules.clone(),
+ )?;
}
}
Ok(())
@@ -490,9 +495,9 @@ fn apply_definition(
fn register_core(registry: &mut TypeRegistry) -> Result<(), MetaError> {
let mut root = TypeDefinition::new("metadata", "root", "Root metadata document");
root.child_rules = ["object", "field", "validator", "template", "requirement"]
- .iter()
- .map(|t| ChildRule::wildcard(t))
- .collect();
+ .iter()
+ .map(|t| ChildRule::wildcard(t))
+ .collect();
registry.register(root)?;
for family in &definitions().core {
for def in define_from_data(family)? {
From 23da5a8cbcf661e73e7523c14c148322119a338c Mon Sep 17 00:00:00 2001
From: Doug Mealing
Date: Fri, 20 Nov 2026 10:12:37 -0500
Subject: [PATCH 9/9] no-mistakes(document): Document core vocabulary pin in
registry README
---
fixtures/registry-conformance/README.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fixtures/registry-conformance/README.md b/fixtures/registry-conformance/README.md
index 075b5c0af9..66bb39a70d 100644
--- a/fixtures/registry-conformance/README.md
+++ b/fixtures/registry-conformance/README.md
@@ -25,6 +25,15 @@ This is the same proven pattern as `render-conformance` and
strongest signal, simplest model, no escape-hatch ledger. The logical
vocabulary must have **zero** per-port divergence by contract.
+## Core vocabulary pin
+
+[`core-vocabulary.pin.json`](./core-vocabulary.pin.json) pins what `metaobjects-core-types`
+registers. The `core vocabulary is pinned` gate in `scripts/ci-local.sh`
+(`scripts/check-core-vocabulary-pin.ts`) fails when a type, subtype, attribute or child rule is
+added to core, and points at
+[GOVERNANCE.md](../../GOVERNANCE.md#extension-packs-and-the-core-metamodel): new vocabulary goes
+in its own provider pack. Regenerating the pin is a core maintainer's decision.
+
## Manifest schema (FR-033)
The manifest carries the cross-port logical vocabulary **plus** (FR-033 Task 5)