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
23 changes: 23 additions & 0 deletions changelog.d/rust-dependency-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
- **Rust resolves metadata dependencies** (FR-023), as the other ports do. `resolve_collection`
now loads each declared dependency from its committed snapshot
(`.metaobjects/deps/<name>/<artifact>`, under the id `dep:<name>/<artifact>`), in
dependency-name order ahead of the project's own files, after verifying it against
`.metaobjects/deps.lock.json`: no lock, a lock and a config that disagree, a missing snapshot
or one whose hash differs is `ERR_DEPENDENCY_SNAPSHOT_STALE`, another metamodel major is
`ERR_DEPENDENCY_METAMODEL_INCOMPATIBLE`, and two dependencies exporting one node is
`ERR_DEPENDENCY_NODE_COLLISION`. `Collection` gains `imported`, `in_scope`, `in_ledger` and
`in_migrate_scope`; `cargo meta gen` generates nothing for what a dependency exports unless
`scope.include` names its package, and refuses a new node declared into a dependency's package
(`ERR_DEPENDENCY_PACKAGE_NOT_OWNED`). The new `metaobjects::scope` matcher reads
`migrate.scope`, and `metaobjects::dependencies::requirement_ledger` answers which
requirements are the project's own ledger. Rust now runs the resolution arm of
`fixtures/dependency-conformance/` (all 36 cases, the 7 ledger cases included) and all 10
`fixtures/scope-conformance/` cases. The check arm (`cargo meta verify --deps`) is not built
yet. SHA-256 moves from `metaobjects_codegen::sha256` to `metaobjects::sha256`; the old path
re-exports it.

Upgrading: a Rust project that declares `dependencies` must now have the snapshot and lock
`meta deps sync` writes, where before the declaration was read and ignored. `Collection` gains
the public fields `resolved_dependencies`, `file_ids`, `imported_packages` and
`imported_nodes` and one private field, so it can no longer be built with a struct literal;
build it with `resolve_collection`.
23 changes: 14 additions & 9 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`fixtures/source-resolution-conformance/`](../fixtures/source-resolution-conformance/) | 30 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ | ✓ |
| [`fixtures/reference-source-conformance/`](../fixtures/reference-source-conformance/) | 6 cases | ✓ (reference implementation) | ✓ | inherits via Java (plus its own codegen exclusion test) | ✓ | ✓ | ✓ |
| [`fixtures/response-verify-conformance/`](../fixtures/response-verify-conformance/) | 7 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ | ✓ |
| [`fixtures/scope-conformance/`](../fixtures/scope-conformance/) | 10 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ | — |
| [`fixtures/dependency-conformance/`](../fixtures/dependency-conformance/) | 47 cases (36 resolution, 7 of them with a ledger arm, + 11 check) + 32 transport cases | ✓ (reference implementation; all four arms) | ✓ (resolution arm, all 36, ledger included; check arm, all 11) | inherits via Java | ✓ (resolution arm, all 36, ledger included; check arm, all 11, as `verify --deps`) | ✓ (resolution arm, all 36 identically, ledger included; check arm, all 11, as `deps check` and `verify --deps`; the transport arm is Node-only) | — |
| [`fixtures/scope-conformance/`](../fixtures/scope-conformance/) | 10 cases | ✓ (reference implementation) | ✓ | inherits via Java | ✓ | ✓ | ✓ (`scope_conformance.rs`) |
| [`fixtures/dependency-conformance/`](../fixtures/dependency-conformance/) | 47 cases (36 resolution, 7 of them with a ledger arm, + 11 check) + 32 transport cases | ✓ (reference implementation; all four arms) | ✓ (resolution arm, all 36, ledger included; check arm, all 11) | inherits via Java | ✓ (resolution arm, all 36, ledger included; check arm, all 11, as `verify --deps`) | ✓ (resolution arm, all 36 identically, ledger included; check arm, all 11, as `deps check` and `verify --deps`; the transport arm is Node-only) | ✓ (resolution arm, all 36, ledger included, through the ledger's scan: no requirement gate yet, RS-V2; check arm not yet) |
| [`fixtures/shared-model-conformance/`](../fixtures/shared-model-conformance/) | 15 cases (9 publish + 6 refusal) | ✓ (reference implementation) | ✓ (all 15; `SharedModelConformanceTest`) | inherits via Java (`KotlinSharedModelGeneratorTest` pins the generator) | ✓ (all 15; `SharedModelConformanceTests`) | ✓ (all 15; `test_shared_model_conformance.py`) | — |
| [`fixtures/agent-context-conformance/`](../fixtures/agent-context-conformance/) (the static agent files each port's `agent-docs` writes; every port runs all 6 stacks, not only its own) | 6 | ✓ (reference) | ✓ (`metaobjects:agent-docs`) | inherits via Java (the same Maven goal) | ✓ (`dotnet meta agent-docs`) | ✓ | ✓ (`cargo meta agent-docs`) |
| [`fixtures/agent-pages-pointer/`](../fixtures/agent-pages-pointer/) (the always-on agent file names the agent pages the last `gen` wrote, from the committed `.hashes/`) | 3 cases | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | ✓ |
| [`fixtures/list-query-conformance/`](../fixtures/list-query-conformance/) (how a list route reads its query string: filter tree, search, sort, page, or the named 400) | 95 cases | ✓ (reference; the source of the expected answers) | planned (R-JV) | planned (R-KT) | ✓ (`ListQueryConformanceTests`) | planned (R-PY) | ✓ (`list_query_conformance.rs`, the parser `meta_http` ships) |
| [`fixtures/docs-page-conformance/`](../fixtures/docs-page-conformance/) (the requirement pages and the model-only schema page, built from the docs view: each page's rows, data and bytes) | 4 cases | ✓ (reference; the source of the expected bytes) | ✓ (`DocsPageConformanceTest`) | ✓ (through Java: the Kotlin generators call the JVM page builder) | ✓ | ✓ | ✓ (rows from the view; no requirement ledger, RS-V2) |
| [`fixtures/docs-page-conformance/`](../fixtures/docs-page-conformance/) (the requirement pages and the model-only schema page, built from the docs view: each page's rows, data and bytes) | 4 cases | ✓ (reference; the source of the expected bytes) | ✓ (`DocsPageConformanceTest`) | ✓ (through Java: the Kotlin generators call the JVM page builder) | ✓ | ✓ | ✓ (rows from the view; requirement ledger not applied yet, RS-V2) |
| [`fixtures/metamodel-docs/`](../fixtures/metamodel-docs/) (the vocabulary reference pages: each page's data and bytes, shared `templates/metamodel/`) | 1 (23 pages) | ✓ (reference; the source of the expected bytes) | ✓ (`MetamodelDocsCorpusTest`) | ✓ (through Java's builder and emitter) | ✓ (`MetamodelDocsTests`) | ✓ (`test_metamodel_docs_conformance.py`) | ✓ (`tests/metamodel_docs.rs`) |
| [`fixtures/fmt-conformance/`](../fixtures/fmt-conformance/) (#304 — `meta fmt`) | 13 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | — (no `fmt`) |
| [`fixtures/field-lint-conformance/`](../fixtures/field-lint-conformance/) (the `verify` field authoring lint) | 15 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | — |
Expand Down Expand Up @@ -423,7 +423,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, reference-source, naming, skip, validation, wire-vector, writer, generator-registry, render, verify, response-verify, extract, output-prompt, template-output-render, list-query, persistence and api-contract corpora, and the `verify --templates` CLI test; 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, reference-source, scope, dependency, naming, skip, validation, wire-vector, writer, generator-registry, render, verify, response-verify, extract, output-prompt, template-output-render, list-query, persistence and api-contract corpora, and the `verify --templates` CLI test; 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 Expand Up @@ -652,7 +652,7 @@ matching is case-sensitive.** These are exactly the rules four independent
implementations would otherwise each get slightly wrong — the failure mode that
produced the cross-port `LIKE`/`ILIKE` divergence fixed in 0.21.6.

**TypeScript, Java, Kotlin, C# and Python run it.** The reference implementation is
**TypeScript, Java, Kotlin, C#, Python and Rust run it.** The reference implementation is
[`server/typescript/packages/metadata/src/scope.ts`](../server/typescript/packages/metadata/src/scope.ts)
(`compilePattern` / `compileScope` / `matchesScope`; `@metaobjectsdev/sdk` re-exports
it unchanged, since it moved there from `sdk` when FR-023 needed it from
Expand All @@ -663,7 +663,9 @@ Python's port (`server/python/src/metaobjects/scope.py`, `matches_scope` using
`-1` limit, because `String.split` would otherwise drop a trailing empty segment and
let `acme::` compile instead of failing. C#'s (`MetaObjects.Config.Scope`, run by
`ScopeConformanceTests`) anchors with `\A…\z` rather than `^…$`, since .NET's `$`
also matches before a trailing newline. Kotlin has no runner of its own: it inherits
also matches before a trailing newline. Rust's (`metaobjects::scope`, run by
`tests/scope_conformance.rs`) matches segment by segment with no regular expression,
and its unit tests pin the invalid-pattern refusals. Kotlin has no runner of its own: it inherits
the Java loader. Each of those two guards is pinned by a test beside the corpus, since
the corpus asserts matches only and carries no invalid-pattern case.

Expand All @@ -678,7 +680,7 @@ no per-port fixture. The corpus has four arms:

- **Resolution (36 cases).** Every case's `expectFiles`/`expectImported`/`expectSelected`/
`expectMigrateGoverned`/`expectLoadError` assertions. **TypeScript (the reference
implementation), Python, Java and C# all run all 36, identically**, with no exemption. The two
implementation), Python, Java, C# and Rust all run all 36, identically**, with no exemption. The two
overlay cases that need a view child as incidental content use `view.currency` (the one
concrete `view.*` subtype registered cross-port), not `view.text` — a prior revision used
`view.text`, which Python did not register then, and carried a since-discharged allowlist
Expand All @@ -689,6 +691,9 @@ no per-port fixture. The corpus has four arms:
whether object coverage is measured (never by an imported requirement). Each port asserts it
through its requirement gate's scan and again through its requirement-tests walk: TypeScript in
`cli/test/dependency-ledger-conformance.test.ts`, the other ports in their resolution runner.
Rust has neither a requirement gate nor a requirement-tests generator yet (RS-V2), so
`tests/dependency_conformance.rs` asserts the ledger through the scan they will read
(`metaobjects::dependencies::requirement_ledger`).
An eighth case refuses a new requirement declared into a dependency's package
(`ERR_DEPENDENCY_PACKAGE_NOT_OWNED`) on the load-time path.
- **Check (11 cases, `expectCheck`).** For each declared dependency, `current`, `drifted` or
Expand Down Expand Up @@ -849,8 +854,8 @@ and what it leaves out.
`server/java/codegen-base/src/test/java/com/metaobjects/docs/pages/DocsPageConformanceTest.java`
(Kotlin's generators call the same JVM page builder),
`server/python/tests/conformance/test_docs_page_conformance.py` and
`server/rust/metaobjects-codegen/tests/docs_page_conformance.rs`. Rust has no requirement ledger
of its own (RS-V2), so its pages list every requirement the view carries.
`server/rust/metaobjects-codegen/tests/docs_page_conformance.rs`. Rust's page generators do not
apply the requirement ledger yet (RS-V2), so its pages list every requirement the view carries.

### `fixtures/agent-pages-pointer/` (3 cases)

Expand Down
34 changes: 14 additions & 20 deletions docs/features/metadata-dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ owned packages — with no resolution at all; it just reads

## Every dependency-aware port loads the committed snapshot, never the live path

Once synced, TypeScript's, Python's and Java's collection resolvers (Kotlin loads through
Java's; a Spring app's runtime loader reads the same snapshot off the classpath) load dependency artifacts from the committed
Once synced, TypeScript's, Python's, Java's, C#'s and Rust's collection resolvers (Kotlin loads
through Java's; a Spring app's runtime loader reads the same snapshot off the classpath) load dependency artifacts from the committed
snapshot **first**, then your own project files, offline, with no transport
involved. At load time it checks the snapshot against the lock and refuses
(`ERR_DEPENDENCY_SNAPSHOT_STALE`) when they disagree — a missing lock for a declared
Expand Down Expand Up @@ -356,7 +356,8 @@ So `scope.include` narrows a Python project's *own* codegen output not at all
only ever widens which imported package is let back in. **Java and Kotlin follow Python**
(`DependencySet.inScope`, read by `GeneratorUtil`'s selection points and `RestSurfaceGate`):
the import-exclusion conjunct only, because those generators have never scoped the project's
own objects either. Do not read the TypeScript formula above as describing every port.
own objects either. **Rust follows Python too** (`Collection::in_scope`, read by `cargo meta`'s
project load). Do not read the TypeScript formula above as describing every port.

`migrate`, `verify --db`, and offline generate compose the schema-side twin, which
also removes an excluded import from the *expected* schema before drift is computed
Expand Down Expand Up @@ -408,7 +409,8 @@ with its model: an overlay of one resolves, and `meta verify` can see it. By def
stay the **publisher's** ledger, not yours. The requirement gate does not check, count,
summarise or lint them, the `requirement-tests` generator writes no test for them, and the
requirements pages (`requirementsFile()`'s `requirements.toon`, the agent docs' `agent/requirements.md`, an entity page's
"Required by") do not list them.
"Required by") do not list them. (Rust has no requirement gate or `requirement-tests`
generator yet, and its pages do not apply the ledger: [Rust port](../ports/rust.md).)
That is the same default as an imported entity's code generation, for the same reason:
you did not declare them.

Expand Down Expand Up @@ -844,31 +846,23 @@ but **not** built yet — do not assume any of the following exists:
ports' check resolves `path` only; any other dependency reports `unresolved` and names the Node
`meta deps check`, because resolving it needs the consumer's installed packages or local package
caches (a check that cannot check must not pass).
- **A Rust check.** The Rust port loads committed snapshots, but `cargo meta verify --deps`
exits 2; run the Node `meta deps check`.

## Verified by

- [`fixtures/dependency-conformance/`](../../fixtures/dependency-conformance/) — 47
cases. 36 pin resolution (including `npm`, `python`, `maven` and `nuget` dependencies loading from their
committed snapshot with nothing installed), the exhaustive `imported`/`inScope`/`inMigrateScope` sets,
overlay/extends/reference behavior against a synced snapshot, and every load- and
resolution-time error above, run by TypeScript (the reference implementation),
Python and Java (Kotlin loads through the Java loader and Maven plugin, so it inherits the
corpus run and adds a codegen test that an imported entity emits nothing). 11 pin the upstream
check (`current`, `drifted`, `unresolved`), run by TypeScript, Java (Kotlin through the same
`metaobjects:verify` goal), Python (`metaobjects deps check`, `verify --deps`) and C#
(`dotnet meta verify --deps`).
resolution-time error above. 11 pin the upstream check (`current`, `drifted`, `unresolved`).
Four artifacts under `fixtures/dependency-conformance/artifacts/` are
pinned by sha256 in the README so the corpus itself can never silently drift.
Python's runner asserts all 36 resolution cases identically to TypeScript's, with no
exemptions — the two overlay cases that need a view child as incidental content
use `view.currency` (the one concrete `view.*` subtype registered cross-port,
per `fixtures/registry-conformance/expected-registry.json`), not `view.text`,
so they exercise the full imported/selected/governed assertions like every
other case. Seven resolution cases also pin the ledger (`expectLedger`, `expectCoverageMeasured`):
which requirements are the project's own and whether coverage is measured, asserted in
TypeScript, Python, Java and C# through each port's requirement gate and through its
`requirement-tests` identities walk, and in TypeScript through the rows the requirements
pages list (only the TypeScript runner checks those rows). `transport-cases.json` beside it pins the `npm`, `python`, `maven` and `nuget` transports
Seven resolution cases also pin the ledger (`expectLedger`, `expectCoverageMeasured`):
which requirements are the project's own and whether coverage is measured. Which ports run
which arm, and how each asserts the ledger:
[`CONFORMANCE.md`](../CONFORMANCE.md#fixturesdependency-conformance-47-cases--32-transport-cases).
`transport-cases.json` beside it pins the `npm`, `python`, `maven` and `nuget` transports
themselves (32 cases: packages laid out under a temp `node_modules`, on a temp
Python import path, as a jar in a temp local Maven repository and as a package in a temp NuGet
cache, the directory each resolves to, the exact lock `sync` writes, and
Expand Down
Loading
Loading