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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ here.**
path of the machine the tool was built on into `codegen/Cargo.toml`: the owned crate names the exact
crates.io release by default, and `--engine <directory | git-url[#rev]>` names a checkout or a git
revision. The three crates lose `publish = false`, carry their packaging metadata, and the `rust` lane
runs `cargo publish --dry-run`. Nothing is published. `cargo meta verify` now runs the business-rules
runs `cargo publish --dry-run` over all four crates. Nothing is published. The new `metaobjects-render`
crate carries the Rust prompt render, the reply parser and the output-format fragment. `cargo meta eject --force` leaves a
copy that already matches the shipped generator untouched. `cargo meta verify` now runs the business-rules
gate (ADR-0066) too: the same five findings, severities and message text as the other ports, under the
four `rules.*` and `verify.lifecycle.unreachable` settings, held to `fixtures/rules-check-conformance/`.

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 | **Crates ready to publish, not yet published** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 578 / 578 metamodel conformance; `cargo meta init` / `gen` / `verify` / `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 | **Crates ready to publish, not yet published** — loader (JSON + YAML), project and source resolution, naming and all 41 validation passes; 578 / 578 metamodel conformance; prompt render and the reply parser (`metaobjects-render`); `cargo meta init` / `gen` / `verify` / `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
8 changes: 5 additions & 3 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ cases); `naming-conformance` (all of it); `codegen-skip-conformance` (ADR-0064),
about templates and one about the three-way merge, are named with their reason in its
runner); `validation-conformance`, every case, through the generated `validate()`;
`decimal-wire` and `duration-wire`, every vector, against the code the generated support
crate carries; the `core` cases of `writer-conformance` (ADR-0063); and
crate carries; `render-conformance`, every case byte-identical, `extract-conformance`, all 58
cases, and `output-prompt-conformance`, all 17 in all three styles with the round trip, in the
`metaobjects-render` crate; the `core` cases of `writer-conformance` (ADR-0063); and
`generator-registry-conformance`, with the eject contract's census, completeness and depth
(ADR-0034 Amendment 8). It also runs the codegen-compile gate (below) with every shipped
generator, and a scale gate over twenty copies of the fitness model. The ledgers above may
only shrink; the corpora without one assert each case outright. 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 ADR-0065 turns the warning off. A regression
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 runs the render, persistence and API-contract corpora.
run fails when fewer do. The column joins this table when the port runs the persistence and API-contract corpora.

A ✓ means the port runs the corpus green; an explicit `n / m` is used where a port
carries a ledgered divergence. The ledgered YAML fixtures are documented divergences (see the
Expand Down Expand Up @@ -416,7 +418,7 @@ Per-port runners + commands:
| Kotlin | `cd server/java && mvn -pl codegen-kotlin test` (snapshot suite) | `mvn -f server/java/integration-tests-kotlin/pom.xml test` (needs Docker) | `mvn -f server/java/integration-tests-kotlin/pom.xml test -Dtest=ApiContractConformanceTest` (needs Docker) |
| C# | `dotnet test` (per project) | `scripts/integration-test.sh csharp` (needs Docker) | `dotnet test server/csharp/MetaObjects.IntegrationTests/MetaObjects.IntegrationTests.csproj --filter "FullyQualifiedName~ApiContractConformanceTest"` (needs Docker) |
| Python | `pytest` (per package) | `scripts/integration-test.sh python` (needs Docker) | `cd server/python && uv run --extra integration pytest tests/integration/test_api_contract.py` (needs Docker) |
| Rust | `cd server/rust && cargo test` (registry, metamodel, YAML, source-resolution, naming, skip, validation, wire-vector, writer and generator-registry corpora; the codegen-compile and scale gates, which run `cargo check` on generated crates and drive the generated client over HTTP against a local stub) | — | — |
| Rust | `cd server/rust && cargo test` (registry, metamodel, YAML, source-resolution, naming, skip, validation, wire-vector, writer, generator-registry, render, extract and output-prompt corpora; the codegen-compile and scale gates, which run `cargo check` on generated crates and drive the generated client over HTTP against a local stub) | — | — |

The `persistence-conformance` corpus is intentionally **on-demand** — none of the
unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ docs/
├── kotlin.md
├── csharp.md
├── python.md
└── rust.md # the Rust port: loader, validation, cargo meta (init/gen/verify/eject) and its three generators
└── rust.md # the Rust port: loader, validation, prompt render and reply parser, cargo meta (init/gen/verify/eject) and its three generators
```

If this list and `ls docs/features/` ever disagree, trust the directory listing —
Expand Down
4 changes: 2 additions & 2 deletions docs/features/prerelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ pushed: a sha nobody can fetch is not a record.

### Rust

There is no Rust candidate on the private registry: the three crates are `publish = false` and
the registry serves npm, PyPI, NuGet and Maven. A Rust consumer **pins the commit** the
There is no Rust candidate on the private registry: the four crates are ready to publish and not
published, and the registry serves npm, PyPI, NuGet and Maven. A Rust consumer **pins the commit** the
candidate's row in the log names:

```toml
Expand Down
21 changes: 14 additions & 7 deletions docs/ports/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ It reads a project, validates it, serializes it and generates code from it, and
same shared conformance corpora as the other five ports. Its command, `cargo meta`, runs the whole
codegen loop on a JSON or YAML model: `init`, `gen`, `verify --codegen` and `eject`. Three generators
ship: `entity`, `client` and `commands`, and a project chooses which of them run in
`metaobjects.config.json`. The three crates are **ready to publish but not published**: they package and
`metaobjects.config.json`. The four crates are **ready to publish but not published**: they package and
build from their packages (a `cargo publish --dry-run` runs in the `rust` lane), and there is no release
on crates.io yet, so there is nothing to `cargo add` or `cargo install` from a registry. You work from a
checkout of this repository until the first release.
Expand All @@ -16,8 +16,8 @@ decisions behind the port (why Rust, the layout, the conformance rules), read th
## What works today

The loader is the `metaobjects` crate, and the workspace at `server/rust/` adds the codegen crate
(`metaobjects-codegen`, the run engine and generator) and the CLI crate (`metaobjects-cli`, the
`cargo-meta` binary). What each area does:
(`metaobjects-codegen`, the run engine and generator), the CLI crate (`metaobjects-cli`, the
`cargo-meta` binary) and the prompt crate (`metaobjects-render`, render and the reply parser). What each area does:

| Area | What it does |
|---|---|
Expand All @@ -27,6 +27,8 @@ The loader is the `metaobjects` crate, and the workspace at `server/rust/` adds
| Registry | The type registry and the built-in providers. It is strict and sealed after bootstrap, with the same `ERR_*` codes as the other ports. |
| Validation | All 41 validation passes the TypeScript loader runs, in the same order, the business-rules pass among them (operations, permission names and lifecycles, [ADR-0066](../../spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md)). The ordered list is `PASSES` in `server/rust/metaobjects/src/validate/mod.rs`. |
| Serializer | The canonical serializer. A tree it loads serializes to the same bytes the other ports write. |
| Prompt rendering | `metaobjects_render::render` renders a `template.*` body over a JSON payload as every port does: partials expanded ahead of time, each `{{value}}` escaped for the template's format (`text`, `markdown`, `html`, `xml`, `csv`, `spreadsheet`, `json`), derived `has<Field>` and `-last` accessors, and a fail-closed `maxChars` budget. The Mustache engine underneath is the `mustache-ng` crate. |
| Reply parser | `metaobjects_render::extract::extract` reads a typed answer out of a model's reply (FR-010, FR-011): fences, prose, comments, trailing commas and cut-off values tolerated, every declared field classified (`EXTRACTED`, `DEFAULTED`, `LOST_OPTIONAL`, `LOST_REQUIRED`, `MALFORMED`) and coerced to its kind, under a `STRICT`, `NORMAL` or `LOOSE` tolerance. `metaobjects_render::prompt::render_output_format` writes the output-format fragment that asks for that answer, in the `guide`, `inline` and `exampleOnly` styles. |
| Frozen tree | The loader freezes the tree when it finishes. A frozen tree memoizes its resolved reads (effective children, attributes and array-ness), so many readers can share one. |
| Timings | Every load records how long each phase and each validation pass took (`LoadResult::timings`). |
| Code generation (`cargo meta`) | The run engine, three generators (`entity`, `client`, `commands`), the codegen drift gate and `eject`. See [The command](#the-command-cargo-meta) and [What `gen` writes](#what-gen-writes) below. |
Expand All @@ -52,7 +54,7 @@ and the same `git` + `rev` on a `metaobjects` dependency). The candidate log
| `cargo meta init [--project <dir>]` | Scaffolds `.metaobjects/config.json`, `.metaobjects/.gitignore` (which keeps `.gen-state/.hashes/` committed), a first `metaobjects/meta.app.yaml` and `metaobjects.config.json`, the list of generators to run (see [Choosing generators](#choosing-generators)). It writes only what is missing, and never adds an empty metadata file to a project that already has metadata. |
| `cargo meta gen [ENTITY...]` | Generates the crates. It skips the whole run when the model, the project config and the generators are unchanged ([ADR-0064](../../spec/decisions/ADR-0064-skip-codegen-when-nothing-changed.md)), writes only files whose bytes changed, removes a generated file nothing emits any more, and refuses to overwrite or delete a generated file that was edited by hand. It prints what it created, updated and removed, and the crates to re-check. |
| `cargo meta verify [--codegen] [--full]` | The codegen drift gate: renders in memory, compares with disk, writes nothing, and exits 1 on drift, naming each file. Locally it may answer from the stored skip key; `--full`, or a set `CI` variable, always renders. `--codegen` runs that gate alone. A bare `verify` also runs the business-rules gate ([ADR-0066](../../spec/decisions/ADR-0066-business-rules-operations-and-lifecycles.md)) on the loaded model, and prints nothing about it when the model declares no operation and no transition; an error-severity finding (a `rules.permissions.names` of `require`, or `verify.lifecycle.unreachable` of `error`) exits 1. `--db`, `--templates` and `--deps` exit 2 with the reason and where that check lives. |
| `cargo meta eject <generator>...` | Copies a shipped generator into the project to own. `--undo` takes back copies still identical to the shipped source; `--list` shows what can be ejected and how each owned copy compares. See [Owning a generator](#owning-a-generator). |
| `cargo meta eject <generator>...` | Copies a shipped generator into the project to own. An existing copy is refused; `--force` replaces it with the reference, and leaves a copy that already matches untouched. `--undo` takes back copies still identical to the shipped source; `--list` shows what can be ejected and how each owned copy compares. See [Owning a generator](#owning-a-generator). |

`gen` and `verify` share `--project <dir>`, `--out <dir>` (default `generated`), `--generators <a,b>`,
`--strict` and `--timings`. `gen` adds `--force` and `--list`. `cargo meta --help` is the reference.
Expand Down Expand Up @@ -280,6 +282,9 @@ outright.
| `decimal-wire`, `duration-wire` | every vector, against the code the support crate carries |
| `writer-conformance` | every `core` case of the code writer ([ADR-0063](../../spec/decisions/ADR-0063-generators-own-layout.md)) |
| `generator-registry-conformance` | the shipped generators are exactly the registry's `rust` entries, with its tier and layer, and the eject contract's census, completeness and depth hold (ADR-0034 Amendment 8) |
| `render-conformance` | every case, byte-identical, through `metaobjects_render::render` (the Mustache engine underneath is `mustache-ng`) |
| `extract-conformance` | all 58 cases, through `metaobjects_render::extract::extract` |
| `output-prompt-conformance` | all 17 cases in all three `@promptStyle` styles, with the extract round trip, through `metaobjects_render::prompt::render_output_format` |

Two gates have no corpus of their own:

Expand All @@ -296,8 +301,8 @@ Two gates have no corpus of their own:
a slow machine.

Rust is not yet a column in the [per-corpus table](../CONFORMANCE.md#per-corpus-totals); it joins
when the port runs the render, persistence and API-contract corpora. The other corpora (render, persistence, API contract) need code the
port does not have yet.
when the port runs the persistence and API-contract corpora, which need a service tier the port does
not have yet. It runs the render, extract and output-format corpora today.

### Load benchmark

Expand All @@ -319,7 +324,9 @@ regeneration, peak memory), so a port's speed can be tracked per feature next to
- **A three-way merge.** A hand-edited generated file is refused by name, as in every port but
TypeScript; change the model or own the generator instead.
- **The service tier.** No `ObjectManager`, no persistence drivers and no web adapters.
- **Templates and prompts.** No render engine, no payload value objects and no output parser.
- **Prompt codegen.** The render engine and the reply parser exist as a library; no generator yet
writes a template's payload type or its response parser from the model, and there is no template
gate in `verify`.
- **Publication.** The crates are publishable and the lane proves they package (`cargo publish
--dry-run`), but nothing is published: there is no crates.io release yet, and publishing waits for
the owner's go ([ADR-0065](../../spec/decisions/ADR-0065-rust-is-the-sixth-port.md) Amendment 3).
Expand Down
3 changes: 2 additions & 1 deletion fixtures/extract-conformance/expected-field-kinds.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"java": "server/java/render/src/main/java/com/metaobjects/render/extract/FieldKind.java",
"csharp": "server/csharp/MetaObjects.Render/Extract/FieldKind.cs",
"typescript": "server/typescript/packages/render/src/extract/types.ts",
"python": "server/python/src/metaobjects/render/extract/types.py"
"python": "server/python/src/metaobjects/render/extract/types.py",
"rust": "server/rust/metaobjects-render/src/extract/types.rs"
},
"kotlinReusesJava": true,
"$kotlinNote": "Kotlin ships no extract engine of its own — metadata-ktx drives the shared Java one, so there is no Kotlin FieldKind to check and adding one would itself be the drift.",
Expand Down
2 changes: 1 addition & 1 deletion fixtures/output-prompt-conformance/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# output-prompt-conformance

Pins the FR-010 output-format prompt fragment (`OutputFormatRenderer`) byte-identically
across all five ports. Each case directory holds:
across all six ports. Each case directory holds:

- `spec.json` — a unified field descriptor (the cross-port oracle input).
- `expected.guide.txt`, `expected.inline.txt`, `expected.exampleOnly.txt` — byte-exact
Expand Down
8 changes: 8 additions & 0 deletions scripts/check-extract-field-kinds.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ function membersOf(port, src) {
return m[1].split(",").map((s) => s.trim()).filter(Boolean)
.map((s) => s.toUpperCase());
}
case "rust": {
// pub enum FieldKind { String, Int, ... } (PascalCase variants; doc comments and
// attributes on their own lines are stripped first)
const m = src.match(/enum\s+FieldKind\s*\{([^}]*)\}/);
if (!m) return null;
return m[1].split("\n").filter((l) => !/^\s*(\/\/|#\[)/.test(l)).join("\n")
.split(",").map((s) => s.trim()).filter(Boolean).map((s) => s.toUpperCase());
}
case "typescript": {
// export const FieldKind = { STRING: "STRING", ... } as const;
const m = src.match(/const\s+FieldKind\s*=\s*\{([\s\S]*?)\}\s*as\s+const/);
Expand Down
26 changes: 26 additions & 0 deletions server/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions server/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# The Rust port of MetaObjects. ADR-0065 records why it exists and how it differs from the
# other ports; its Amendment 3 records that it is a full, publishable language.
#
# Three crates:
# Four crates:
# `metaobjects` metamodel registry, loader, canonical serializer.
# `metaobjects-codegen` the run engine (skip key, hash manifest, writer) and the
# `entity` generator.
# `metaobjects-cli` the `cargo-meta` binary, so `cargo meta gen` works.
# `metaobjects-render` prompt render, the reply parser and the output-format fragment.
[workspace]
resolver = "3"
members = ["metaobjects", "metaobjects-codegen", "metaobjects-cli"]
members = ["metaobjects", "metaobjects-codegen", "metaobjects-cli", "metaobjects-render"]

[workspace.package]
version = "0.1.0"
Expand Down
Loading
Loading