Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/rules/cross-language-porting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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).

Expand Down
43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
10 changes: 5 additions & 5 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | 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 | ✓ | — | — | — | ✓ |
Expand Down Expand Up @@ -71,7 +71,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | 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`,
Expand All @@ -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
Expand Down Expand Up @@ -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 |
|---|---|
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading