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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .claude/rules/codegen-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const { data } = useSubscribers({

**Server validation:** every request validated against the allowlist. Unknown field / disallowed op / invalid value → 400 with structured error code.

**Leading wildcards are rejected by default (TS generated routes):** the generated allowlist ships `leadingWildcard: false` on every field, so a `like` pattern starting with `%` (e.g. `"%@example.com"`) → 400 `filter.leading_wildcard_disallowed` — an unanchored LIKE defeats index usage, so it is fail-closed. Opt in per field by hand-editing that field's entry in the generated `<Entity>FilterAllowlist` to `leadingWildcard: true` (hand edits inside generated files are preserved by the three-way merge). This gate is a TS-only extension — the other ports do not enforce it (see `docs/features/api-contract.md`, "TS-only filter extensions").
**Leading wildcards are rejected by default (TS generated routes):** the generated allowlist ships `leadingWildcard: false` on every field, so a `like` pattern starting with `%` (e.g. `"%@example.com"`) → 400 `filter.leading_wildcard_disallowed` — an unanchored LIKE defeats index usage, so it is fail-closed. Opt in per field by hand-editing that field's entry in the generated `<Entity>FilterAllowlist` to `leadingWildcard: true` (hand edits inside generated files are preserved by the three-way merge). The gate is part of the REST contract since 1.3.0 (`docs/features/api-contract.md`, "The list query: search, combinators and refusals"), and each other port takes it on in its 1.3.0 REST-standard work.

**Architecture:** `parseFilterParams` (in `@metaobjectsdev/runtime-ts/drizzle-fastify`) translates parsed qs into a Drizzle expression tree. `buildFilterQs` (in `@metaobjectsdev/runtime-web` and `@metaobjectsdev/tanstack`) serializes a typed filter object back to a bracketed qs URL.

Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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/` (578 fixtures; 43 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/` (578 fixtures; 45 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
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ here.**

## [Unreleased]

- **Java: a standalone `{{! comment }}` line leaves no blank line.** mustache.java kept the line break
after a standalone comment tag, so a Java render had one extra blank line where TypeScript, C# and
Python had none. `Renderer` now strips standalone comment lines before mustache.java parses them. A
template with such a line renders differently in Java, so a prompt body with one changes bytes (and
its prompt-cache prefix) on upgrade. The `render-standalone-*` fixtures pin the whitespace rules.
- **C#: an unchanged file is never rewritten.** `dotnet meta gen` already left identical output alone
when the project keeps a hash manifest. It now does the same on the path with no manifest (output
written outside the project, or a program that runs the generators with no state directory), which
Expand Down Expand Up @@ -83,6 +88,52 @@ here.**
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.
- **The REST standard's list handling is part of the cross-port contract.** `?search`,
`filter[or]` / `filter[and]`, the nesting cap, the bare-field and leading-`%` refusals, the
filter-value format check, and the `invalid_json`, `invalid_id`, `pagination.invalid_value` and
`constraint_violation` responses were TypeScript-only extensions. `docs/features/api-contract.md`
now states them as contract, with TypeScript's wire names unchanged. Two corpora hold the ports
to it:
- a new shared corpus, `fixtures/list-query-conformance/`: 95 parse cases, each a query string
in and either a filter tree in neutral values or the exact 400 body out, run with no server
and no database;
- a 20-scenario `list-query/` sub-corpus of `api-contract-conformance/`, over a 60-row seed, in
the generated lane.

TypeScript passes both. The other ports take them on in their 1.3.0 REST-standard work. The
decision is [ADR-0068](spec/decisions/ADR-0068-list-query-cross-port-contract.md). A
scenario can now send a body that is not JSON with `rawBody`.
- **runtime-ts: one list-query parse for every mount.** `parseListQuery` (exported from
`@metaobjectsdev/runtime-ts`; it does not depend on Drizzle) reads a list request into a
port-neutral `ListQuery`, and each mount compiles that for its own query library. The Drizzle
and Hono mounts and the `ObjectManager` Fastify mount all use it. The `ObjectManager` mount
(`@metaobjectsdev/runtime-ts/fastify`) takes two new options:
- `filterAllowlist`: it then serves `filter[...]`, `filter[or]` / `filter[and]` and `?search`
and refuses what the Drizzle mount refuses, with the same bodies;
- `pagination`: the `api.pagination` page size.

With no sort, the `ObjectManager` mount now orders by the primary key. The `ObjectManager`
`Filter` gains `$or` and a case-insensitive `$ilike`, and the class gains `keyFields()` and
`fieldNames()`.
- **codegen-ts: the filter and sort allowlists are available as data.**
`filterAllowlistRules(entity)` and `sortAllowlistRules(entity)` return the rules that
`<Entity>FilterAllowlist` / `SortAllowlist` are printed from. The generated files are
byte-identical.

- **Fixed: the filter nesting cap could not be reached.** `qs`'s default depth of 5 kept the sixth
bracket pair as part of the key, so `filter[or][0][or][0][or][0][a][eq]=1` read as a field named
`[0][a][eq]` and answered `invalid_filter_field` instead of `filter.nesting_too_deep`. Every
TypeScript mount now parses with `parseListQueryString`, whose depth is sized to the cap. As part
of the same fix, a combinator branch that names no field (`filter[or][0]=x`) is now
`400 invalid_filter_value` with `field: "or"`; before, it was an unknown field named `0`.
- **Fixed: on SQLite, `like` through the `ObjectManager` was case-insensitive.** The Kysely and
Drizzle drivers sent SQLite's native LIKE, which folds ASCII case, against ADR-0049. They now
lower `like` to GLOB on SQLite, as the generated routes already did, and to a binary comparison
on MySQL.
- **Fixed: `?search` on an entity with an int-backed enum answered 500 on Postgres.** The search
included every filterable text field, and an int-backed (`@intValueMap`) enum is an integer
column, so Postgres refused the ILIKE. Search now covers only fields whose operator band
includes `like`.
- **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
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
`invalid-op` / `in`-over-cap 400s) is **generated in every port** (Java `SpringControllerGenerator`,
C# `RoutesGenerator`, Python `router_generator`, Kotlin `KotlinSpringControllerGenerator`, TS) —
gated by the api-contract corpus in BOTH lanes. **Flag hand-rolled filter parsing anywhere.**
Only the *richer* surface is genuinely **TS-only**: free-text `?search=`, the explicit
`filter[or][N]` / `filter[and][N]` nested boolean combinators (+ their nesting-depth cap), and
leading-wildcard gating — do NOT flag the absence of those in a non-TS port.
The *richer* list surface — free-text `?search=`, the explicit `filter[or][N]` /
`filter[and][N]` nested boolean combinators (+ their nesting-depth cap), and leading-wildcard
gating (ADR-0068) — passes in TypeScript and is **pending** in each other port until that port's
1.3.0 REST-standard work lands. Do NOT flag the absence of those in a port that has not landed
them yet.
- **Output-parser codegen** ships in **all five ports** — Java's `SpringOutputParserGenerator`
*generates* the `<Name>Parser` (the Jackson `readValue` lives inside that generated file). A
hand-rolled parser in a **non-generated** file where a **responding `template.prompt`**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ to nothing, and does not check that each claimed node complies).
- **CALIBRATION — per-port codegen gaps:** the core `?filter[field][op]` filter grammar (all
9 operators + the generated allowlist + `invalid-field` / `invalid-op` / `in`-over-cap 400s)
is **generated in all five ports** (api-contract corpus, both lanes) — **flag hand-rolled
filter parsing anywhere.** Only the richer surface (`?search=`, explicit
`filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating) is TS-only.
filter parsing anywhere.** The richer list surface (`?search=`, explicit
`filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating; ADR-0068) passes in
TypeScript and is pending in each other port until its 1.3.0 REST-standard work lands — do not
flag its absence in a port before then.
Output-parser codegen also ships in **all five ports**, keyed on a **responding
`template.prompt`** (`@responseRef`), never on a `template.output` (ADR-0052) — Java's
`SpringOutputParserGenerator` *generates* the parser (the Jackson `readValue` lives inside
Expand Down
7 changes: 4 additions & 3 deletions agent-context/skills/metaobjects-audit/references/csharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ version across these packages is an intra-port skew finding.
generator (`<Entity>Routes.cs`, Minimal API) generates the `?filter[field][op]=value` grammar
(all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`) via the runtime `FilterParser` +
`EfCoreFilterDispatch`, validated against the generated filter allowlist (api-contract corpus,
both lanes). **Flag a hand-rolled filter parser as a finding.** Only the richer surface
(`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating) is
TS-only — do NOT flag its absence in C#.
both lanes). **Flag a hand-rolled filter parser as a finding.** The richer list surface
(`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating; ADR-0068)
passes in TypeScript and is pending in C# until the C# port's 1.3.0 REST-standard work lands —
do NOT flag its absence in C# until then.
- **Output-parser codegen ships in C#.** `output-parser` / `extractor` / `render-helper`
generators are available (list `OutputParserGenerator` in `codegen/Generators.cs`). Absence of
wired output parsers where a **responding `template.prompt`** (`@responseRef`) exists IS a
Expand Down
5 changes: 3 additions & 2 deletions agent-context/skills/metaobjects-audit/references/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ versioning — **do not flag it** (only intra-port skew matters).
`eq/ne/gt/gte/lt/lte/in/like/isNull`): it parses via the runtime `FilterParser`, validates
against the generated `<Entity>FilterAllowlist`, and 400s on unknown field / disallowed op /
over-cap `in`-list (api-contract corpus, both lanes). **Flag a hand-rolled filter parser as a
finding.** Only the *richer* surface is TS-only — `?search=`, `filter[or][N]` / `filter[and][N]`
combinators, leading-wildcard gating — do NOT flag the absence of those in Java.
finding.** The *richer* list surface — `?search=`, `filter[or][N]` / `filter[and][N]`
combinators, leading-wildcard gating (ADR-0068) — passes in TypeScript and is pending in Java
until the Java port's 1.3.0 REST-standard work lands — do NOT flag its absence in Java until then.
- **Repository interface is a hand-implemented stub.** `SpringRepositoryGenerator`
emits `<Entity>Repository.java` as a stub `interface`; the consumer hand-writes the
implementation against OMDB (or any persistence layer). Hand-written repository
Expand Down
5 changes: 3 additions & 2 deletions agent-context/skills/metaobjects-audit/references/kotlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ cross-port versioning — **do not flag it** (only intra-port skew matters).
`KotlinSpringControllerGenerator` generates the `?filter[field][op]=value` grammar (all 9
operators `eq/ne/gt/gte/lt/lte/in/like/isNull`) validated against the generated filter allowlist
(api-contract corpus, both lanes). **Flag a hand-rolled filter parser as a finding.** Only the
richer surface (`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard
gating) is TS-only — do NOT flag its absence in Kotlin.
richer list surface (`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard
gating; ADR-0068) passes in TypeScript and is pending in Kotlin until the Kotlin port's 1.3.0
REST-standard work lands — do NOT flag its absence in Kotlin until then.
- **No JVM migrate goal.** Schema migration is Node-`meta`-owned for every port
(ADR-0015). The Maven plugin has no migrate goal; `meta migrate` is correct.
7 changes: 4 additions & 3 deletions agent-context/skills/metaobjects-audit/references/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ another) matters.
generator emits an `APIRouter` whose list route parses the `?filter[field][op]=value` grammar
(all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`) via the generated `filter_parser` module,
validated against the generated filter allowlist (api-contract corpus, both lanes). **Flag a
hand-rolled filter parser as a finding.** Only the richer surface (`?search=`,
`filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating) is TS-only — do NOT
flag its absence in Python.
hand-rolled filter parser as a finding.** The richer list surface (`?search=`,
`filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating; ADR-0068) passes in
TypeScript and is pending in Python until the Python port's 1.3.0 REST-standard work lands — do
NOT flag its absence in Python until then.
- **Partial relationship + flattened-object codegen.** Relationship navigation,
non-`table` source kinds, and `field.object @storage: flattened` codegen are
partially implemented in the Python port. Do NOT flag these gaps as adopter defects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ via `metamodelVersion` (see the Phase 0 cross-language consistency item).

TypeScript is the reference implementation — it ships the full feature set:

- Filter-operator codegen: **complete** — the core `?filter[field][op]` grammar (all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`, `<Entity>FilterAllowlist`) generates in every port; TS additionally ships the richer surface (`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating).
- Filter-operator codegen: **complete** — the core `?filter[field][op]` grammar (all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`, `<Entity>FilterAllowlist`) generates in every port; the richer list surface (`?search=`, `filter[or][N]` / `filter[and][N]` combinators, leading-wildcard gating; ADR-0068) passes in TypeScript; each other port is pending until its 1.3.0 REST-standard work lands.
- Output-parser codegen: **complete** (`outputParser()` generator; `parse*`/`safeParse*`/`extract*` emitted as `<Name>.response.ts` per **responding `template.prompt`** — one carrying `@responseRef`; ADR-0052).
- ObjectManager: **complete** (`@metaobjectsdev/runtime-ts`; `kyselyDriver` / `inMemoryDriver`).
- Schema migrate / `meta verify --db`: **complete** (TS owns the shared migrate engine — ADR-0015).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ emitted too, and a measure with `@default` is a `COALESCE` whose column MySQL re
- The generated `delete<Entity>ById` checks that the row exists before deleting it.
- **`like` is case-sensitive**, as the API contract requires (ADR-0049). MySQL's default
collation is case-insensitive, so the generated routes compare with
`COLLATE utf8mb4_bin`. The TypeScript-only `?search` stays case-insensitive.
`COLLATE utf8mb4_bin`. `?search` stays case-insensitive, as the list contract states
([api-contract.md](../features/api-contract.md)).
- **Timestamps use Drizzle's `date` mode.** A `DATETIME` rejects the ISO wire form
(`2026-05-28T20:26:40.002Z` is `ERROR 1292`). The generated Zod schema coerces the ISO string
to a `Date`, Drizzle stores the UTC wall clock, and the JSON response carries ISO with `Z`.
Expand Down
Loading
Loading