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 AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ PyPI has had no product change since `0.25.0` — nothing is broken.

**Cross-port conformance corpora** (every port runs the shared corpus):
- Metamodel: `fixtures/conformance/` (584 fixtures; 49 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 / Java / Kotlin / Python byte-identical; C# and Rust each carry a `KnownDrift` render ledger, recorded in `docs/CONFORMANCE.md`.
- Render: `fixtures/render-conformance/`. TS / Java / Kotlin / Python / C# / Rust byte-identical; the C# and Rust drift ledgers are empty (`docs/CONFORMANCE.md`).
- Persistence: `fixtures/persistence-conformance/`. **Query** scenarios run on every port (TS / C# / Java / Kotlin / Python; `op: guardedUpdate` is TS-only until each port's 1.3.0 guarded update lands), 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** (the Node reference helper writes them; a native tool is equally first-class, ADR-0015 Amendment 2). **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.
- YAML / verify corpora green across the ports that ship those layers.
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ here.**

## [Unreleased]

- **C# and Rust render dotted names, a list's `length` and `0` as TypeScript does.** C# resolves a
dotted name whole against each context, innermost outward, so a context holding only the first
segment no longer hides an outer match (`render-shadowed-dotted-prefix`). The Rust
`metaobjects-render` crate now renders with its own Mustache engine in place of `mustache-ng`:
the same whole-path lookup, a list's `length` as a number, and `0` falsy for a section while it
still prints as `0` (`render-list-length`, `render-zero-falsiness`). Both render-conformance
drift ledgers are empty. A Rust template that printed a list or an object now writes it as
JavaScript does (`1,2` / `[object Object]`) instead of nothing, and the U+FDD0 / U+FDD1
characters are no longer refused.

## [1.3.0] — 2026-12-01


Expand Down
16 changes: 7 additions & 9 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 19 | 19 / 19 | 19 / 19 | inherits via Java | 18 / 19 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 19 / 19 | 18 / 19 (1 ledgered: `yaml-ref-root-escape`, the ADR-0059 root-level `::` rules) |
| [`fixtures/verify-conformance/`](../fixtures/verify-conformance/) | 45 | ✓ | ✓ | inherits via Java | ✓ | ✓ | ✓ |
| [`fixtures/verify-strict-conformance/`](../fixtures/verify-strict-conformance/) | 1 | ✓ | — | — | — | ✓ | — |
| [`fixtures/render-conformance/`](../fixtures/render-conformance/) | 26 | ✓ | ✓ | inherits via Java | 25 / 26 (1 ledgered: `render-shadowed-dotted-prefix`, Stubble stops a dotted name at the first context holding its first segment) | ✓ | 23 / 26 (3 ledgered: `render-shadowed-dotted-prefix`, `render-list-length`, `render-zero-falsiness`, `mustache-ng`'s lookup, data model and truthiness) |
| [`fixtures/render-conformance/`](../fixtures/render-conformance/) | 26 | ✓ | ✓ | inherits via Java | ✓ | ✓ | ✓ |
| [`fixtures/jinja-render-conformance/`](../fixtures/jinja-render-conformance/) (ADR-0061 — Jinja bodies render the same in jinja2 and nunjucks) | 16 | ✓ (nunjucks) | refuses Jinja (`ERR_TEMPLATE_ENGINE_UNSUPPORTED`) | refuses, via Java | refuses Jinja (`ERR_TEMPLATE_ENGINE_UNSUPPORTED`) | ✓ (jinja2) | refuses Jinja (`ERR_TEMPLATE_ENGINE_UNSUPPORTED`) |
| [`fixtures/jinja-verify-conformance/`](../fixtures/jinja-verify-conformance/) (ADR-0061 — the payload check over a Jinja body) | 31 | ✓ | refuses Jinja | refuses, via Java | refuses Jinja | ✓ | refuses Jinja |
| [`fixtures/extract-conformance/`](../fixtures/extract-conformance/) | 58 | ✓ | ✓ | inherits the shared JVM engine | ✓ | ✓ | ✓ |
Expand Down Expand Up @@ -499,14 +499,12 @@ that must refuse carries `expected-error.txt` in place of `expected.txt`, holdin
the render must raise (`render verify failed: ERR_VAR_NOT_ON_PAYLOAD (<name>)`). Every port that runs
this corpus reads that convention; every port requires it to appear in the raised message (Python's jinja runner compares it exactly).

Two engines read a case differently from the shared baseline (the TypeScript renderer on
mustache.js), and each runner ledgers the case instead of skipping it, asserting it STILL
differs so the ledger only shrinks. C# (Stubble) ledgers `render-shadowed-dotted-prefix`: it stops
a dotted name at the first context holding its first segment. Rust (`mustache-ng`) ledgers that
case, `render-list-length` (a list's `length` is not a property of its data) and
`render-zero-falsiness` (numbers reach the engine as text, so 0 is truthy). Closing a Rust entry
means resolving names and truthiness in the crate instead of the engine, which is larger than a
localized change and is not done here.
Every port renders every case byte-identical to the shared baseline (the TypeScript renderer on
mustache.js). The C# and Rust runners keep a drift ledger, empty today: a case an engine reads
differently is ledgered rather than skipped, and asserted to STILL differ, so the ledger only
shrinks. C# resolves a dotted name whole against each context through Stubble's value getters;
the Rust crate renders with its own Mustache engine, which follows the baseline's name lookup,
truthiness and whitespace rules.

### `fixtures/jinja-render-conformance/` (16) and `fixtures/jinja-verify-conformance/` (31)

Expand Down
10 changes: 4 additions & 6 deletions docs/features/templates-and-payloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,10 @@ via their respective conformance runners (Kotlin on the Java engine), and so doe
`metaobjects-render` crate. See [`docs/CONFORMANCE.md`](../CONFORMANCE.md)
for the per-port pass/skip ledger.

Two renderers still drift on a case their engine reads differently, and ledger it rather than
skip it: C# on `render-shadowed-dotted-prefix` (Stubble stops a dotted name at the first context
holding its first part), and Rust on that case, `render-list-length` and `render-zero-falsiness`
(the `mustache-ng` engine's own name lookup, data model and truthiness). A ledgered case must
still differ from the baseline, so an engine that comes into agreement fails its runner until the
entry leaves the ledger.
Every port renders every case the same. The C# and Rust runners keep a drift ledger, empty
today: a case an engine reads differently is ledgered rather than skipped, and must still differ
from the baseline, so an engine that comes into agreement fails its runner until the entry leaves
the ledger.

**Jinja bodies (Python and TypeScript, ADR-0061)**

Expand Down
4 changes: 2 additions & 2 deletions docs/ports/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ 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. |
| 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 is the crate's own, following the reference renderer's name lookup, truthiness and whitespace rules. |
| 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`). |
Expand Down Expand Up @@ -630,7 +630,7 @@ outright.
| `template-output-render-conformance` | the welcome page and email, the nested payload and the cross-package payloads, rendered through generated `render-helper` crates that a probe builds; the drift cases fail `gen`, and a body edited after generation fails the render |
| `verify-conformance` | all 45 cases, through `metaobjects_render::verify`, the check `cargo meta verify --templates` runs, with no ledgered case and no Rust expectation file |
| `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 but the three the ledger holds — `render-shadowed-dotted-prefix`, `render-list-length`, `render-zero-falsiness` (`mustache-ng` has its own name lookup, data model and truthiness); a ledgered case must still differ, the rest render byte-identical through `metaobjects_render::render` (the Mustache engine underneath is `mustache-ng`) |
| `render-conformance` | every case, byte-identical through `metaobjects_render::render` (the crate's own Mustache engine); the drift ledger is empty, and a case added to it must still differ |
| `response-verify-conformance` | all 7 cases: the reply check the template gate adds — `ERR_RESPONSE_UNRESOLVED`, and, for an xml prompt, `ERR_RESPONSE_TAG_UNDECLARED` |
| `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` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class RenderConformanceTests
/// </summary>
private static readonly HashSet<string> KnownDrift = new(StringComparer.Ordinal)
{
"render-shadowed-dotted-prefix",
};

private static string CorpusRoot()
Expand Down
52 changes: 52 additions & 0 deletions server/csharp/MetaObjects.Render.Tests/RenderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,56 @@ public void Deterministic_same_inputs_identical_output()
Assert.Equal(a, b);
Assert.Equal("1|2|3|", a);
}

// A dotted name is tried WHOLE against each context, innermost outward (mustache.js). Where the
// whole path resolves to a present null, that context wins: it renders empty and is falsy, and
// the outer value is NOT reached.
[Fact]
public void A_dotted_path_resolving_to_a_present_null_stops_at_that_context()
{
var payload = Obj(
("a", Obj(("b", Obj(("v", 1L))))),
("items", new List<object> { Obj(("a", Obj(("b", Obj(("v", null)))))) }));
Assert.Equal("[]none", Render("text", payload, P(),
template: "{{#items}}[{{a.b.v}}]{{^a.b.v}}none{{/a.b.v}}{{/items}}"));
}

[Fact]
public void A_shadowed_dotted_prefix_falls_through_in_triple_ampersand_and_changed_delimiters()
{
var payload = Obj(
("a", Obj(("b", "<1>"))),
("items", new List<object> { Obj(("a", Obj(("c", 2L)))) }));
Assert.Equal("<1>|<1>|&lt;1&gt;", Render("html", payload, P(),
template: "{{#items}}{{{a.b}}}|{{& a.b}}|{{=<% %>=}}<% a.b %><%={{ }}=%>{{/items}}"));
}

// A list index is a property to mustache.js (`"0" in arr`), so a dotted name reads through it;
// a non-canonical index (`01`) is not a property, so it is a missing variable, as in TS.
[Fact]
public void A_dotted_name_reads_a_list_element_by_index()
{
var payload = Obj(("items", new List<object> { Obj(("name", "x")) }));
Assert.Equal("First: x", Render("text", payload, P(),
template: "{{#items.0}}First: {{name}}{{/items.0}}"));
Assert.Equal("x", Render("text", payload, P(), template: "{{items.0.name}}"));
var ex = Assert.Throws<RenderException>(() => Render("text", payload, P(), template: "{{items.01}}"));
Assert.Equal("render verify failed: ERR_VAR_NOT_ON_PAYLOAD (items.01)", ex.Message);
}

private sealed class Dynamic : System.Dynamic.DynamicObject
{
public override IEnumerable<string> GetDynamicMemberNames() => ["x"];

public override bool TryGetMember(System.Dynamic.GetMemberBinder binder, out object? result)
{
result = binder.Name == "x" ? "42" : null;
return binder.Name == "x";
}
}

[Fact]
public void A_dotted_name_through_a_dynamic_object_reads_its_member() =>
Assert.Equal("42", Render("text", Obj(("obj", Obj(("dyn", new Dynamic())))), P(),
template: "{{obj.dyn.x}}"));
}
Loading
Loading