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 @@ -71,7 +71,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/` (459 fixtures; 38 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/` (471 fixtures; 38 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
31 changes: 29 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ _npm `1.3.0` (full lockstep across all 14 `@metaobjectsdev/*` publish candidates

**`metamodelVersion` moves to `1.3`.** This release adds vocabulary (`field.duration`,
`validator.exactlyOne`, `@constraintName`, `@condition`, `@maxLength` on `field.enum`,
`@sequenceStart`, `@sequenceName`, `@flattenedColumnPrefix`, the `pascal` column rule and
`@collectionName`) and nothing that loaded before stops loading. The registry gains two
`@sequenceStart`, `@sequenceName`, `@flattenedColumnPrefix`, the `pascal` column rule,
`@collectionName`, and the `case` and `now` expression nodes) and nothing that loaded before
stops loading. The registry gains two
fields on a type or attr entry, carried into the registry manifest: `implementedIn` (cross-port
vocabulary only the named ports implement so far, e.g. the `view.*` controls, `["typescript"]`) and
`ports` (vocabulary only the named ports ever act on, e.g. `@objectAdapter`, `["java", "kotlin"]`:
Expand Down Expand Up @@ -137,6 +138,32 @@ Each item below is described in full under Added, Changed or Fixed; this list is
(`ERR_AMBIGUOUS_PATH`). A declared relationship or reference of the same name still wins. Every
port's loader implements it, gated by `origin-reverse-reference-hop`,
`origin-reverse-hop-collection-name` and `error-origin-reverse-hop-ambiguous`.
- **Expressions and relative dates in views.** These load and validate in every port's loader,
each gated by shared conformance fixtures:
- a projection's and an `origin.first` / `origin.aggregate`'s `@filter` take a relative date
(`{ "now": "-P7D" }`), checked for its shape (`projection-filter-relative-now`,
`origin-filter-relative-now`); the fixtures `error-relative-date-origin-host` and
`error-relative-date-wrong-host`, which asserted the refusal, are removed;
- an `origin.computed` expression may use `now` and `case` (searched, or simple with an
`operand`), and a ref in it may name another of the projection's own fields (a passthrough,
an `origin.first` or another `origin.computed`, never itself or an aggregate) before a base
field (`origin-computed-case-over-joined`, `error-origin-computed-case-mixed-types`). A
simple `case` compares a literal `when` with any `operand`, so an enum or long operand maps
its codes to labels. A `case`'s results and a `coalesce`'s arguments unify a numeric literal
with any numeric field and a `now` with a date or timestamp (`origin-computed-literal-unifies`);
- the loaders refuse what a view cannot lower: a `now` whose value is not an ISO-8601 duration
or whose `startOf` is not day, week or month (`error-origin-computed-now-bad-duration`); a
searched `case` whose `when` is not boolean (`error-origin-computed-case-non-boolean-when`);
computed fields that refer to each other in a cycle (`error-origin-computed-cycle`); and a
malformed relative date in a view host's `@filter` (`error-relative-date-view-host-malformed`),
or one on a field that is not a `field.date` or `field.timestamp`, where a projection's key
names its own field and an origin's names a field of its `@of` entity or `@via` terminal
(`error-relative-date-non-temporal-field`); and an expression node that carries a key its
kind does not take, such as a misspelled `else` on a `case` or a `field` node that also
carries `case` (`ERR_UNKNOWN_EXPR_NODE`, `error-origin-computed-case-unknown-key`,
`error-origin-computed-node-mixed-keys`);
- a validator `@condition` still refuses `case` and `now` (`ERR_BAD_ATTR_VALUE`,
`error-validator-condition-now`): it becomes a database CHECK, which can hold neither.

- **An int-backed enum can be an array.** `@intValueMap` together with `isArray: true` (the
map on the field, or inherited from a shared enum) now loads in every port instead of
Expand Down
6 changes: 3 additions & 3 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) | 459 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ |
| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 471 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ |
| [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 16 | 16 / 16 | 15 / 16 (1 ledgered: `yaml-quoted-leading-zero` — Java pipeline strips quotes off `"007"`) | inherits via Java | 15 / 16 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 16 / 16 |
| [`fixtures/verify-conformance/`](../fixtures/verify-conformance/) | 45 | ✓ | ✓ | inherits via Java | ✓ | ✓ |
| [`fixtures/verify-strict-conformance/`](../fixtures/verify-strict-conformance/) | 1 | ✓ | — | — | — | ✓ |
Expand Down Expand Up @@ -354,7 +354,7 @@ unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker.

## Fixture-to-doc mapping

### `fixtures/conformance/` — metamodel loader + canonical serializer (459)
### `fixtures/conformance/` — metamodel loader + canonical serializer (471)

| Fixture prefix | Feature doc |
|---|---|
Expand Down Expand Up @@ -716,7 +716,7 @@ JSON and verify payload feeds it unchanged.

## Orphaned fixtures (tested but not yet documented)

The fixtures in the nine corpora mapped above (metamodel 459 + yaml 16 + verify 45
The fixtures in the nine corpora mapped above (metamodel 471 + yaml 16 + verify 45
+ render 18 + persistence 62 + api-contract 123 + source-resolution 25 + scope 10 +
dependency 47) each map to a feature doc, and so do the two requirement corpora, `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
1 change: 1 addition & 0 deletions docs/features/migrations-and-drift.md
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ attributes shape it, all database-only (no generated code reads them):
it out.
- **`@condition`** on a cross-field validator (`comparison`, `requiredWhen`, `presentIff`,
`atLeastOne`, `exactlyOne`) is an expression, in the grammar `origin.computed` uses, over the entity's fields.
It refuses `case` and `now` (`ERR_BAD_ATTR_VALUE`): a database CHECK can hold neither.
The rule holds only where the condition does: the CHECK is `(NOT condition) OR (rule)`, with
the negation folded in (`kind = 'Owned'` becomes `kind <> 'Owned'`). It is checked at load
(`ERR_BAD_ATTR_VALUE`): every field it names is a field of the entity, it is a boolean
Expand Down
2 changes: 1 addition & 1 deletion docs/features/reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ only beside `now`.

| Rule | Code | Refused |
|---|---|---|
| **F1** | `ERR_BAD_ATTR_FILTER` | A relative value anywhere except the `@filter` of a `segment`, a `measure.aggregate` or an `object.report`. In a `layout.dataGrid` preset, a projection `@filter` or an `origin.aggregate` `@filter` it fails the load, because no lowering exists for those hosts. |
| **F1** | `ERR_BAD_ATTR_FILTER` | A relative value anywhere except the `@filter` of a `segment`, a `measure.aggregate`, an `object.report`, an `object.projection`, an `origin.first` or an `origin.aggregate`. In a `layout.dataGrid` preset it fails the load, because no lowering exists for that host. On a projection or an origin, F2 applies in full: a projection's key names one of its own fields, and an origin's key names a field of its `@of` entity, or of its `@via` terminal when it has no `@of`. |
| **F2** | `ERR_BAD_ATTR_FILTER` | A relative value on any field except a `field.date` or `field.timestamp`; under any operator except `gt, gte, lt, lte`; as an object that carries keys besides `now` and `startOf`; with a duration that does not match the ISO-8601 pattern `^[+-]?P(?!$)(\d+Y)?(\d+M)?(\d+W)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?$`; or with a `startOf` other than `day`, `week` or `month`. |

An operator-less `{ "occurredAt": { "now": "-P7D" } }` is read as `eq`, and `eq` is not one
Expand Down
8 changes: 8 additions & 0 deletions docs/features/source-kinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ round out the read-model vocabulary: **`origin.computed`** carries a closed `@ex
expression grammar (a derived scalar computed from other fields), and **`origin.first`** picks
one related row's column along a `@via` path (an argmax-style projection; nullable).

**Expressions and relative dates.** An `origin.computed` `@expr` may use `case`
(`{ "case": [ { "when": …, "then": … } ], "else": … }`, or with an `operand` for the simple
form) and `now` (the current instant), and a `{ "field": … }` ref in it names one of the
projection's own fields first (a passthrough, an `origin.first` or another `origin.computed`,
never itself or an aggregate), else a base field. An `origin.first` or `origin.aggregate`
`@filter`, like a projection's, may hold a relative date (`{ "now": "-P7D" }`, see
[reporting.md](reporting.md#relative-dates-in-filters)). Every port's loader validates these.

**Projection row-scope `@filter` (#207).** Distinct from the *per-aggregate* `@filter` above,
an **object-level `@filter` on an `object.projection`** scopes the whole view's rows — it
lowers to the view's outer `WHERE`. This is the metadata-managed way to express a
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/site-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"metamodel": "1.3"
},
"counts": {
"fixtures": 459,
"fixtures": 471,
"corpora": 38,
"baseTypes": 17
},
Expand Down
4 changes: 2 additions & 2 deletions fixtures/conformance/ERROR-CODES.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"ERR_TEMPLATE_NOT_STATIC": "Build-time verify (ADR-0061, Jinja bodies, Python and TypeScript): a template reference the check cannot settle statically — a computed attribute or include name, a dynamic subscript, a call, a tag outside the supported set. Reported rather than passed; path = the expression or tag.",
"ERR_TEMPLATE_SYNTAX": "Build-time verify: the template body, or a template it includes or imports, does not parse. Jinja bodies (ADR-0061, Python and TypeScript): path = the parser's message, which is engine-specific. Mustache bodies (every port): an unbalanced section (a close with no open, a close naming another section, a section never closed); path = the section's name.",
"ERR_TEMPLATE_ENGINE_UNSUPPORTED": "Build-time verify and render (ADR-0061): a template body is written for an engine this port does not ship — a Jinja body (.jinja / .j2 / .jinja2) in the Java, Kotlin or C# port, which render Mustache only. path = the template ref.",
"ERR_BAD_ATTR_FILTER": "An attr.filter references a field that is not addressable in that context or uses a disallowed op: a dataGrid @filter over a non-filterable field or an op disallowed for the field's subtype, or a projection row-scope @filter over a non-declared (dangling) or aggregate-derived field (#207). FR-044: a segment / measure.aggregate / object.report @filter names a field its entity (or @from) lacks or an op illegal for the field (S1); a relative-date value { \"now\": \"<duration>\" } appears outside the @filter of a segment, measure.aggregate or object.report (F1); or a relative-date value sits on a field that is not field.date/field.timestamp, under an op other than gt/gte/lt/lte, carries a value that is not an ISO-8601 duration, or has a startOf other than day, week or month, or a key besides now and startOf (F2).",
"ERR_BAD_ATTR_FILTER": "An attr.filter references a field that is not addressable in that context or uses a disallowed op: a dataGrid @filter over a non-filterable field or an op disallowed for the field's subtype, or a projection row-scope @filter over a non-declared (dangling) or aggregate-derived field (#207). FR-044: a segment / measure.aggregate / object.report @filter names a field its entity (or @from) lacks or an op illegal for the field (S1); a relative-date value { \"now\": \"<duration>\" } appears outside the @filter of a segment, measure.aggregate, object.report, object.projection, origin.aggregate or origin.first (F1); or a relative-date value sits on a field that is not field.date/field.timestamp, under an op other than gt/gte/lt/lte, carries a value that is not an ISO-8601 duration, or has a startOf other than day, week or month, or a key besides now and startOf (F2).",
"ERR_STORAGE_FLATTENED_ARRAY": "@storage \"flattened\" cannot be combined with isArray=true.",
"ERR_SEQUENCE_START_OUT_OF_RANGE": "An identity.primary @sequenceStart is below 1, or above the largest value its key field can hold (2147483647 for a field.int). Postgres would refuse the sequence when the migration is applied, so the model is refused at load.",
"ERR_SEQUENCE_WITHOUT_INCREMENT": "An identity.primary sets @sequenceStart or @sequenceName, but its @generation is not \"increment\". Only an increment key draws from a sequence, so the attribute would change nothing: the identity is refused rather than silently ignored.",
Expand Down Expand Up @@ -96,7 +96,7 @@
"ERR_INVALID_REPORT": "FR-044: an object.report is invalid: @from does not resolve to an object.entity (R1); a @dimensions item names no dimension of @from, omits the grain of a time dimension, uses a grain the dimension does not declare, gives a grain to an attribute dimension, or repeats (R2); a @measures item resolves to no measure at all (R3); the report declares a field.* or identity.* child (R4) or a writable source (R5); two items derive the same report field name (R6); or @segment names no segment of @from (R7).",
"ERR_REPORT_FOREIGN_MEASURE": "FR-044: an object.report lists a measure (bare or dotted) that belongs to an entity other than @from (R3). All measures of a report come from @from; combining two fact tables is a second report.",
"ERR_COMPUTED_TYPE_MISMATCH": "#195: an origin.computed @expr tree's inferred root type does not equal the carrying field's declared field.<subType>. A computed column's type is DERIVED from its expression, never asserted (no @convert escape), so a mismatch is a hard load error (sibling of ERR_PASSTHROUGH_TYPE_MISMATCH).",
"ERR_UNKNOWN_EXPR_NODE": "#195: an origin.computed @expr tree contains a node whose kind/op/fn is not in the closed expression grammar (field/value refs, comparisons sharing the filter op vocabulary, isNull/isNotNull, and/or/not, coalesce). Fail-closed per ADR-0023; the detail names the offending token.",
"ERR_UNKNOWN_EXPR_NODE": "#195: an origin.computed @expr tree contains a node whose kind/op/fn is not in the closed expression grammar (field/value refs, comparisons sharing the filter op vocabulary, isNull/isNotNull, and/or/not, coalesce, case, now), or a node carries a key its kind does not take (a misspelled `else`, or a `field` node that also carries `case`). Fail-closed per ADR-0023; the detail names the offending token.",
"ERR_SQL_BODY_WITH_UNMANAGED": "#208: a source.rdb declares both @sql (author-supplied body) and @unmanaged (DDL owned elsewhere). The two markers are the mutually exclusive non-default states of one DDL-ownership axis — contradictory on a single source.",
"ERR_SQL_BODY_ON_WRITABLE_KIND": "#208: a source.rdb declares @sql with a writable @kind (\"table\", the default). A hand-written CREATE TABLE would bypass the column-diff machinery; tables are fully modeled or @unmanaged, never opaque-bodied.",
"ERR_ORIGIN_UNDER_SQL_BODY": "#208: a host object whose read source carries @sql also declares an origin.*-bearing (derived) field, or (on object.projection) an @filter (#207) — two sources of truth for the same body (the synthesized derivation/outer-WHERE vs. the author's verbatim SQL). Fail-closed.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"errors": [
{
"code": "ERR_INVALID_ORIGIN",
"source": {
"format": "json",
"files": [
"meta.views.json"
],
"jsonPath": "$['metadata.root'].children[2]['object.projection'].children[2]['field.string'].children[0]['origin.computed']"
}
}
],
"warnings": []
}
Loading
Loading