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: 1 addition & 1 deletion .claude/rules/cross-language-porting.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Preserve the following contracts exactly across all language ports:
- Relationship subtypes: `association`, `aggregation`, `composition`. Cardinality via `@cardinality: one|many`; target via `@objectRef`. **M:N (FR-018) slim vocabulary:** `@cardinality: "many"` + `@objectRef` (target) + `@through` (the junction/through entity — a third entity that MUST declare two `identity.reference` children, one per FK side). The relationship's FK fields are **derived** from those references (the `identity.reference` SSOT for FK direction), never restated. `@sourceRefField` (optional) disambiguates a *directed* self-join by naming the source-side FK field on the junction (the other reference is the target side); on a `@cardinality: one` relationship it instead names which of several `identity.reference` nodes onto the same target this relationship navigates, short-circuiting the unique-candidate/`@sourceRefField`/name-pairing ladder (#368, [ADR-0029](spec/decisions/ADR-0029-entity-child-extends-and-via-inference.md) Amendment 1) — an unresolvable 1:N reference set is `ERR_INVALID_RELATIONSHIP` at load. `@symmetric` (optional boolean) marks an *undirected* self-join (union-on-read) — valid only when `@objectRef` == the declaring entity, and mutually exclusive with `@sourceRefField`. The pre-FR-018 `@joinEntity`/`@joinFields` attrs are REMOVED. Validation errors: symmetric-on-hetero / symmetric+sourceRefField → `ERR_BAD_ATTR_VALUE`; junction-missing-two-references / sourceRefField-not-matching / M:N-attr-on-1:N / **junction-unpairable** → `ERR_INVALID_RELATIONSHIP`. **Unpairable means the junction declares its two references but neither resolves to the navigating entity, or neither to the `@objectRef` target** — declaring two references is NOT enough, and the loader now checks WHAT they point at (owner ruling 2026-09-20). It does so by running the real FK derivation and converting its failure, never a parallel re-implementation, so the loader and the derivation cannot drift; scope mirrors codegen's own iteration exactly — every CONCRETE, non-projection object crossed with its EFFECTIVE relationships, NOT deduped by declaration, because pairing is a property of the navigating entity and an inherited M:N can pair from one subtype and not another. Before the ruling this loaded clean and then diverged: TS and C# warned and emitted no traversal route (a silent 404), while Java, Kotlin and Python failed the build. Gated by `fixtures/conformance/error-relationship-m2m-junction-unpairable/`.
- Index subtypes: `index.lookup` (non-unique retrieval index; uniqueness is encoded in the **type**: `identity.secondary` = unique alternate key, `index.lookup` = non-unique; `@unique` is REMOVED from `identity.secondary` — `ERR_UNKNOWN_ATTR` on any legacy `@unique`). RDB-physical escapes `@using`/`@expr`/`@where`/`@orders` are registered by the db provider on **both** `identity.secondary` and `index.lookup`. `index.fulltext` / `index.vector` / `index.spatial` are reserved on the subtype axis — documented, NOT registered (YAGNI + 1.0 vocab freeze). See [ADR-0040](spec/decisions/ADR-0040-index-type-and-secondary-key-purity.md).
- Layout subtypes: `dataGrid`
- API subtypes: `api.base` / `api.operational` (request/response surface, a root child; subtype axis = interaction model, NEVER protocol — protocol lives in `binding.*` per operation: `binding.rest` (`@method`, `@path`) now, `messaging`/`grpc` reserved; the event/streaming sibling of `api.operational` is reserved). Children: `operation.query` (`@outputRef`, `@many`) / `operation.command` (`@inputRef` → `object.value`, `@transitions`, `@errors`); both take `@inputRef`, `@outputRef`, `@objectRef` (only when the target cannot be derived), `@permission`, `@public`. Derived CRUD (FR-008/009) stays the zero-config default; declared `api` extends it. Org-tier modeling (application/service/network/deployment) stays OUT of core — provider SPI, FQN references. See [ADR-0030](spec/decisions/ADR-0030-declared-api-surface-and-org-tier-boundary.md). **Registered in all five ports since 1.3.0, experimental** (may change in a MINOR) ([ADR-0066](spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md)), with the loader rules (`error-rules-*` fixtures) and the `verify` rules gate (`fixtures/rules-check-conformance/`); nothing is generated from it yet (`fixtures/codegen-noop/rules/`).
- API subtypes: `api.base` / `api.operational` (request/response surface, a root child; subtype axis = interaction model, NEVER protocol — protocol lives in `binding.*` per operation: `binding.rest` (`@method`, `@path`) now, `messaging`/`grpc` reserved; the event/streaming sibling of `api.operational` is reserved). Children: `operation.query` (`@outputRef`, `@many`) / `operation.command` (`@inputRef` → `object.value`, `@transitions`, `@errors`); both take `@inputRef`, `@outputRef`, `@objectRef` (only when the target cannot be derived), `@permission`, `@public`. Derived CRUD (FR-008/009) stays the zero-config default; declared `api` extends it. Org-tier modeling (application/service/network/deployment) stays OUT of core — provider SPI, FQN references. See [ADR-0030](spec/decisions/ADR-0030-declared-api-surface-and-org-tier-boundary.md). **Registered in all five ports since 1.3.0, experimental** (may change in a MINOR) ([ADR-0066](spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md)), with the loader rules (`error-rules-*` fixtures) and the `verify` rules gate (`fixtures/rules-check-conformance/`); the flat generators generate nothing from it (`fixtures/codegen-noop/rules/`); the ADR-0067 layer generators do (C# `rules-names` and `contract-types` so far).
- Transition subtypes: `transition.action` (a child of `field.enum` on an `object.entity`: `@from`, `@to`, `@condition` in the validators' grammar, `@permission`, `@public`); `transition.base` is the abstract root and `transition.timed` is reserved, not registered. An enum with a transition IS a lifecycle — states, initial state (`@default`), terminal states and each unclaimed transition's command are derived, never declared (ADR-0066). A transition's `@from` lists enum members, not object references: every port's ref-bearing-attr check excludes `transition.*` nodes. A lifecycle belongs to the declaring entity and its `extends` descendants, NEVER to an entity whose field merely `extends` the lifecycle field (filter by the declaring field's owner); a command claims a transition NODE for its target and every entity extending it. Transition and operation names compare case-insensitively; operation names are unique per PACKAGE across its APIs, except one operation declared identically in two APIs (a versioned API). A lifecycle on an entity with no source loads and is inert (no derived command, no permission checks); the writable-source check applies once a source exists. A `@permission` is a dotted identifier path (a package prefix may use `::`); an absent one derives `<package>.<operation>` for an operation and `<package>.<Entity>.<transition>` for a transition's command.
- Currency attrs: `@currency` (ISO 4217), `@locale` (BCP 47)
- Schema attrs: `@schema` on `source.rdb` (DB schema name; Postgres default `public`, SQLite rejects non-default values)
Expand Down
38 changes: 37 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,43 @@ here.**
owned generator, template, support or runtime file, or the `codegen/pom.xml`, that already holds
exactly the reference content is left alone and reported as identical, with or without `force`.
The codegen fingerprint, `metaobjects:fmt` and `metaobjects:init` also compare before they write.

- **C#: a `contract-types` generator writes each entity's create and update records (ADR-0067 layer 1).**
Opt-in, beside `entity`: add `new ContractTypesGenerator()` to `codegen/Generators.cs`. For each
writable entity it writes `<Entity>Contracts.g.cs` with `<Entity>Create` and `<Entity>Update`,
`sealed record`s carrying the entity's validation attributes and wire converters. Neither carries
what the server owns: a generated key, an `@autoSet` stamp, a `readOnly` or derived field, a TPH
discriminator. A required member with no `@default` is a `required` member of the create record, so
a body that omits it does not bind. A `writeOnce` field is on the create record and off the update
record, since it is frozen after create. Every update member is optional; `<Entity>Update.From` binds a
body and records which keys it carried, so `Has` tells an omitted member (untouched) from an
explicit null (cleared), and validation refuses null on a required member. The lifecycle field
stays on both, so the service shell can check it and refuse a change with `409 state_managed`. The
validation and converter attributes moved out of `EntityGenerator` into `ContractMembers`, which
eject hands over with either generator; the entity's output is unchanged. The shared generator
manifest gains the `contract-types` entry (C# only for now).
- **C#: a `rules-names` generator writes the business-rules names as constants (ADR-0067 layer 0).**
It is opt-in, like any generator: add `new RulesNamesGenerator()` to `codegen/Generators.cs`. For
each entity with a lifecycle it writes `<Entity>Rules.g.cs`, with each lifecycle's states, initial
and terminal states, transitions, and the permission each derived command asks for. For each
`api.operational` it writes `<Api>Operations.g.cs`, with each operation's name, permission and
`@errors` codes. It also writes `RuleErrorCodes.g.cs` once, with the shell's own codes. Permission
names are derived the way `verify` derives them, and `rules.lifecycle.commands` decides which
transitions get one. A model with no rules vocabulary gets no file. It is a layer generator, so the
flat generators' output is unchanged and the codegen-noop rules corpus still holds them. The shared
generator manifest gains the `rules-names` entry (C# only for now).
- **C#: the codegen project sets every `GenConfig` option.** `dotnet meta init` now writes a
`Generators.Configure` method beside the generator list, and `codegen/Program.cs` passes it to
`CodegenCli.Run`. It receives the config a run builds from its flags and `.metaobjects/config.json`
and returns the one the generators see. That makes the options no flag or config key sets
reachable on the normal path: `ContextTypeName`, `PropertyNaming`, `ProvidedEnumNamespace`,
`PackageNamespaces`, `TypeOverrides`, `Convention`, `UnmappedStrategy` and the rest. `gen` and
`verify --codegen` both apply it. An existing codegen project keeps working unchanged; to use it,
add the method and pass `Generators.Configure` as the third argument in `Program.cs`.
- **C#: an unknown top-level key in `.metaobjects/config.json` warns.** It was ignored without a word,
so a misspelt key (`scopes` for `scope`) did nothing. It is still ignored, and nothing fails,
because a newer MetaObjects may have written it, but each one is now named once on standard error
with the known keys, in the words TypeScript uses. A key inside a block C# owns (`csharp`,
`naming`, `wire` and the rest) is refused as before.
- **C#: a `@sequenceStart` whose migrations project lacks the design-time services line is a generation
error.** When `dotnet meta gen` can see the context's `ModelSnapshot.cs` in another project and that
project does not carry `[assembly: DesignTimeServicesReference]`, the next `dotnet ef migrations add`
Expand Down
13 changes: 8 additions & 5 deletions docs/features/business-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ is needed, which moves are legal, and what a command may return, so all three ca
**What 1.3.0 ships.** The vocabulary, checked when it loads and by `verify`, in all five ports.
The Rust port loads the vocabulary and runs the same loader rules, and its `verify` runs the
same rules gate, held to `fixtures/rules-check-conformance/` ([Rust port](../ports/rust.md)).
A requirement can claim an operation or a transition. Nothing is generated from the vocabulary
yet: the service shells that enforce these rules at run time are later work (ADR-0067): service
generators an app adds to its generator list, as it adds any generator. A lifecycle in a project
A requirement can claim an operation or a transition. The flat generators generate nothing from
the vocabulary. The layer generators of ADR-0067 do, and an app adds them to its generator list as
it adds any generator. The first are C#'s `rules-names`, which writes the states, transitions,
permissions and error codes as constants, and `contract-types`, which writes each entity's create
and update records ([C# port](../ports/csharp.md)). The service shells that
enforce these rules at run time are later work. A lifecycle in a project
that wires none will be advised by `verify` once that check lands; today the flat routes enforce
nothing and `verify` says nothing about it. Until the shells land, a model with this vocabulary
generates byte-identical code to the same model without it. The design is [ADR-0066](../../spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md).
nothing and `verify` says nothing about it. Every flat generator writes byte-identical code for
a model with this vocabulary and the same model without it. The design is [ADR-0066](../../spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md).

**Experimental.** This vocabulary, its loader rules, its `verify` checks and its settings may
change in a MINOR, including removals and renames, until generated services run on it in an
Expand Down
18 changes: 11 additions & 7 deletions docs/features/metadata-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ surfaces have no such limit.
The non-TypeScript ports read a **neutral subset** of that file —
`schema_version` and `sources` — and ignore every other top-level key, so the
TypeScript-owned keys beside them (`migrate`, `extract`, and the rest) never
become a four-port concern. The Node CLI remains the file's only writer;
`meta init --config-only` writes it into a Maven- or pip-rooted project without
adding a TypeScript scaffold.
become a four-port concern. The C# port names an unknown top-level key on standard
error, once per key, and still ignores it ([C# port](../ports/csharp.md#configure)).
The Node CLI remains the file's only writer; `meta init --config-only` writes it into
a Maven- or pip-rooted project without adding a TypeScript scaffold.

**`scope` and `migrate.scope` remain Node-CLI-only, but Java's `<filters>` name glob is
the same grammar.** Since 8.2.0 the Maven plugin's `<filters>` patterns use `scope`'s
Expand Down Expand Up @@ -173,8 +174,9 @@ Consequences worth knowing:
Both parse (the config shape is fixed now so a later phase slots in without a config
migration) and both throw `ERR_SOURCE_KIND_UNSUPPORTED` when the toolchain tries to
resolve them. A misspelled key such as `{ "pathh": "model" }` is a **load error**,
not a silently ignored extra: `.metaobjects/config.json` is validated strictly, top
level and every nested block.
not a silently ignored extra: the TypeScript toolchain validates `.metaobjects/config.json`
strictly, top level and every nested block (the C# port warns on an unknown top-level key
instead; see [C# port](../ports/csharp.md#configure)).

---

Expand Down Expand Up @@ -542,7 +544,8 @@ the per-level walk order layer 1 preserves is pinned by
| `ERR_COLLECTION_NOT_FOUND` | No `sources` were declared **and** no default `metaobjects/` directory exists |

A schema violation in `.metaobjects/config.json` itself (an unknown key, a wrong
type) surfaces as the config load error and stops the command.
type) surfaces as the TypeScript config load error and stops the command. The C# port
warns on an unknown top-level key and carries on.

---

Expand Down Expand Up @@ -625,7 +628,8 @@ reproduce.

`ConfigSchema` is `.strict()` at every level — the top level, `sources` entries,
`scope`, `migrate`, and `migrate.d1`. A key that used to be silently dropped is now
a load error that stops the command.
a load error that stops the command. This is the TypeScript toolchain's rule; the C# port
keeps its top-level check a warning ([C# port](../ports/csharp.md#configure)).

This is deliberate and it is the whole point: a stripped key means the setting you
wrote does not exist, and the command runs as if you had never written it.
Expand Down
4 changes: 2 additions & 2 deletions docs/features/migrations/upgrading-1.0-to-1.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ skip them, so read the whole list before you regenerate.
it ("Unrecognized key(s) in object: 'naming'"), but a 1.0.x C#, Java or Python tool ignores
the unknown key without a word and keeps its old column names. A mixed estate therefore does
not fail: the old port reads and writes columns named like the fields while the new ones use
`snake_case`. From 1.1.0 on, an unknown key there is a warning in TypeScript, so the next key
a release adds is not the same trap.
`snake_case`. From 1.1.0 on, an unknown key there is a warning in TypeScript, and from 1.3.0 on
in C#, so the next key a release adds is not the same trap.
- **Mixed-version exports.** A 1.1 `meta export` file can hold a root-level reference written
`::Name`, which 1.0.x refuses (`ERR_RELATIVE_REF_IN_CANONICAL`). Read 1.1 exports with 1.1
tools.
Expand Down
9 changes: 5 additions & 4 deletions docs/features/own-your-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -1575,8 +1575,8 @@ writes its output through come with it

The generator list is `codegen/Generators.cs` (ADR-0034 Amendment 9), compiled by the
console project `codegen/Codegen.csproj` (referencing `MetaObjects.Codegen` at the tool's
version) and run by `codegen/Program.cs`, two lines that pass `Generators.All` to the public
runner. `dotnet meta init` writes the three files; eject writes each one that is missing,
version) and run by `codegen/Program.cs`, two lines that pass `Generators.All` and `Generators.Configure`
to the public runner. `dotnet meta init` writes the three files; eject writes each one that is missing,
and when it writes `Generators.cs` the list holds the copies it just ejected, as
`new Codegen.Generators.<Name>()`. After that all three are yours: eject never touches them
again, even with `--force`, and prints the entry to add instead, in place of the packaged
Expand Down Expand Up @@ -1613,7 +1613,8 @@ namespace:

| Eject | Also writes |
|---|---|
| `entity` | `Fr019SharedEnum.cs` (shared and provided enums), `M2MNavigation.cs` (the many-to-many navigation), `ReverseFinders.cs` (the reverse FK finders), `XmlDocBuilder.cs` (doc comments) |
| `entity` | `ContractMembers.cs` (the validation and wire-converter attributes), `Fr019SharedEnum.cs` (shared and provided enums), `M2MNavigation.cs` (the many-to-many navigation), `ReverseFinders.cs` (the reverse FK finders), `XmlDocBuilder.cs` (doc comments) |
| `contract-types` | `ContractMembers.cs`, `Fr019SharedEnum.cs`, `XmlDocBuilder.cs` |
| `db-context` | `Fr019SharedEnum.cs`, `M2MNavigation.cs`, `XmlDocBuilder.cs` |
| `routes` | `M2MNavigation.cs` |
| `output-parser`, `extractor` | `ExtractDelegateEmitter.cs`, `Fr010FieldMapping.cs`; `extractor` also `Fr019SharedEnum.cs` |
Expand Down Expand Up @@ -1651,7 +1652,7 @@ edits are untouched:
```bash
scratch=$(mktemp -d)
dotnet meta eject entity --root "$scratch"
cp "$scratch"/codegen/generators/{Fr019SharedEnum,M2MNavigation,ReverseFinders,XmlDocBuilder}.cs codegen/generators/
cp "$scratch"/codegen/generators/{ContractMembers,Fr019SharedEnum,M2MNavigation,ReverseFinders,XmlDocBuilder}.cs codegen/generators/
dotnet meta gen --list # no longer reports an emitter missing
```

Expand Down
Loading
Loading