diff --git a/.claude/rules/codegen-architecture.md b/.claude/rules/codegen-architecture.md index 53141388b4..90150fd479 100644 --- a/.claude/rules/codegen-architecture.md +++ b/.claude/rules/codegen-architecture.md @@ -168,7 +168,7 @@ origins live on `object.projection` only. Gated end-to-end by `fixtures/api-contract-conformance/projection/` (view-only) and `.../write-through/` (table + replica view). -**Column and table naming** is `naming` in `.metaobjects/config.json` (ADR-0058), read by every port: `columns` `snake_case` (default) | `literal` | `kebab-case`, `tables` `snake_case` (default) | `literal`. Generators read it as `ctx.columnNamingStrategy` (set from the loaded root); `metaobjects.config.ts` no longer takes it. +**Column and table naming** is `naming` in `.metaobjects/config.json` (ADR-0058), read by every port: `columns` `snake_case` (default) | `literal` | `kebab-case` | `pascal` (upper-cases the first letter only) | a name the application registered (ADR-0058 Amendment 1), `tables` `snake_case` (default) | `literal`. Generators read it as `ctx.columnNamingStrategy` (set from the loaded root); `metaobjects.config.ts` no longer takes it. ### Currency (Project F) diff --git a/.claude/rules/cross-language-porting.md b/.claude/rules/cross-language-porting.md index 630ae79ac2..81c8556ad6 100644 --- a/.claude/rules/cross-language-porting.md +++ b/.claude/rules/cross-language-porting.md @@ -27,7 +27,7 @@ Preserve the following contracts exactly across all language ports: - Currency attrs: `@currency` (ISO 4217), `@locale` (BCP 47) - Schema attrs: `@schema` on `source.rdb` (DB schema name; Postgres default `public`, SQLite rejects non-default values) - Storage attrs: `@storage` on `field.object` (with `@objectRef`) — values `flattened` / `jsonb` / `subdocument`. Unifies "owned types" (flattened storage) and "structured JSONB" (jsonb storage). Defaults to single-jsonb-column when absent (back-compat). -- Enum: `field.enum` is a first-class field subtype (peer of `currency`), string-backed. Required `@values` string-array attr (member symbols). Members must be a non-empty set, each matching `^[A-Za-z_][A-Za-z0-9_]*$`, no duplicates — every port's loader enforces this (own-only) emitting `ERR_BAD_ATTR_VALUE` (missing `@values` → `ERR_MISSING_REQUIRED_ATTR`). Reuse via abstract `field.enum` + `extends`. Codegen: TS union + `z.enum`, C# `enum` + EF `HasConversion()`, DB `varchar` + `CHECK`. **Int-backed storage shipped** (`@intValueMap`, a `{memberSymbol: int}` map, switches the column to `integer` + int `CHECK` while the wire format, the generated type and every runtime value stay the member SYMBOL; a MAP rather than a positional array so reordering `@values` cannot silently re-map every member; `@isArray` + `@intValueMap` is a LOAD ERROR, and an unmapped stored integer THROWS in all five ports). Display labels and native PG enum remain deferred (see `docs/superpowers/specs/2026-05-23-enum-datatype-design.md`). +- Enum: `field.enum` is a first-class field subtype (peer of `currency`), string-backed. Required `@values` string-array attr (member symbols). Members must be a non-empty set, each matching `^[A-Za-z_][A-Za-z0-9_]*$`, no duplicates — every port's loader enforces this (own-only) emitting `ERR_BAD_ATTR_VALUE` (missing `@values` → `ERR_MISSING_REQUIRED_ATTR`). Reuse via abstract `field.enum` + `extends`. Codegen: TS union + `z.enum`, C# `enum` + EF `HasConversion()`, DB `varchar` + `CHECK`. **Int-backed storage shipped** (`@intValueMap`, a `{memberSymbol: int}` map, switches the column to `integer` + int `CHECK` while the wire format, the generated type and every runtime value stay the member SYMBOL; a MAP rather than a positional array so reordering `@values` cannot silently re-map every member; an int-backed enum array loads in every port and stores each element as its declared integer — TypeScript and C# persist it on every engine, Python on Postgres only, Java's OMDB refuses it at the codec, and Kotlin's Exposed generator emits no enum array column yet; an unmapped stored integer THROWS in all five ports). Display labels and native PG enum remain deferred (see `docs/superpowers/specs/2026-05-23-enum-datatype-design.md`). - Documentation common attrs (any node): `description`, `title`, `notes`, `deprecated`, `replacedBy`, `seeAlso`, `aliases`. Registered via the cross-language `commonAttrs` registry hook (`registerCommonAttrs` / `RegisterCommonAttrs` / `register_common_attrs` / Java `MetaDataRegistry.registerCommonAttribute` — wired in all four ports). `notes` is the internal-only rationale slot — never emitted to user-facing doc-gen (JSDoc / XML-doc / Postgres `COMMENT ON` / Mermaid prose). **The `description` / `notes` split is by CONTENT KIND, not audience** — an audience split invites writing the same content twice at two levels of politeness. `description` states what the element IS and COVERS (scope and boundary, derivable from the model); `notes` states what you had to look OUTSIDE the model to learn (evidence, citations, what breaks if it changes). Mechanical test: a sentence belongs in `notes` exactly when it would have to change because the IMPLEMENTATION changed while the model did not. `title` is a noun phrase, `summary` a one-line sentence. TS doc-gen ships all three tiers; C# ships XML-doc + COMMENT ON. See `docs/superpowers/specs/2026-05-24-documentation-provider-design.md`. **Wire format:** diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index c80646a310..48d92dfe15 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -66,7 +66,10 @@ jobs: POSTGRES_DB: metaobjects_test ports: - 5432:5432 + # The data directory (the image's VOLUME) on a size-capped tmpfs: a throwaway database + # never touches the runner's drives. options: >- + --tmpfs /var/lib/postgresql/data:rw,size=2g --health-cmd "pg_isready -U metaobjects -d metaobjects_test" --health-interval 10s --health-timeout 5s @@ -75,6 +78,16 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + - name: Postgres durability off (a throwaway database) + # A service container takes no server flags, so set them on the running server. Its data + # directory is already a tmpfs (options above); nothing in it needs to survive a crash. + run: >- + docker exec ${{ job.services.postgres.id }} + psql -U metaobjects -d metaobjects_test + -c "ALTER SYSTEM SET fsync = off" + -c "ALTER SYSTEM SET synchronous_commit = off" + -c "ALTER SYSTEM SET full_page_writes = off" + -c "SELECT pg_reload_conf()" - name: Set up Bun (TS lanes) if: matrix.lane == 'ts-slow' || matrix.lane == 'cube' diff --git a/.github/workflows/local-ci.yml b/.github/workflows/local-ci.yml index 490ba50626..9acd7ba41e 100644 --- a/.github/workflows/local-ci.yml +++ b/.github/workflows/local-ci.yml @@ -16,15 +16,16 @@ # success — which RE-RUNS the stale lane instead of merely reporting it stale. # That needs `actions: read` below to see its own history. # -# The ts and java ports are each split into parallel jobs — a FAST lane (the -# quick pure-code correctness signal: ts-fast = build+typecheck/conformance/ -# completeness, java-fast = java+kotlin conformance), a UNIT lane for ts (ts-unit = -# the full per-package suites — metadata/render/runtime-ts + client/web — that -# ts-fast's named-file conformance gate leaves ungated), and a SLOW lane (docker -# integration + heavy build: ts-slow, java-slow = reactor + integration). The -# split surfaces the verdict fast and means a cancel/OOM/flake mid-integration no -# longer kills the fast signal. `detect` emits the umbrella token (`ts` / `java`); -# all of that port's jobs gate on it. +# The ts port is split into parallel jobs — a FAST lane (the quick pure-code +# correctness signal: ts-fast = build+typecheck/conformance/completeness), a UNIT +# lane (ts-unit = the full per-package suites — metadata/render/runtime-ts + +# client/web — that ts-fast's named-file conformance gate leaves ungated), and a +# SLOW lane (docker integration: ts-slow). The split surfaces the verdict fast and +# means a cancel/OOM/flake mid-integration no longer kills the fast signal. The java +# port is ONE job, java-slow = the full reactor with tests on (which already runs +# every java and kotlin conformance class) + docker integration: a separate +# conformance-only job would run those same classes a second time. `detect` emits +# the umbrella token (`ts` / `java`); all of that port's jobs gate on it. # # Integration-running jobs (ts-slow, python, csharp, java-slow) share a Postgres # SIDECAR instead of each test booting its own Testcontainers Postgres per @@ -147,7 +148,10 @@ jobs: POSTGRES_DB: metaobjects_test ports: - 5432 # dynamic host port — no fixed-port collision + # The data directory (the image's VOLUME) on a size-capped tmpfs: a throwaway database + # never touches the runner's drives. options: >- + --tmpfs /var/lib/postgresql/data:rw,size=2g --health-cmd "pg_isready -U metaobjects -d metaobjects_test" --health-interval 10s --health-timeout 5s @@ -156,6 +160,16 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + - name: Postgres durability off (a throwaway database) + # A service container takes no server flags, so set them on the running server. Its data + # directory is already a tmpfs (options above); nothing in it needs to survive a crash. + run: >- + docker exec ${{ job.services.postgres.id }} + psql -U metaobjects -d metaobjects_test + -c "ALTER SYSTEM SET fsync = off" + -c "ALTER SYSTEM SET synchronous_commit = off" + -c "ALTER SYSTEM SET full_page_writes = off" + -c "SELECT pg_reload_conf()" - env: METAOBJECTS_TEST_PG_URL: postgres://metaobjects:metaobjects@localhost:${{ job.services.postgres.ports['5432'] }}/metaobjects_test # Arms migrate-ts's real-Postgres suites (apply / lifecycle / rollback / @@ -177,21 +191,9 @@ jobs: RUNTIME_TS_PG_EXPECT: '1' run: scripts/ci-local.sh --only ts-slow --strict-toolchains - # Java FAST lane — java + kotlin conformance only (the quick correctness signal). - # No docker/integration, so no sidecar. - java-fast: - needs: detect - if: contains(needs.detect.outputs.ports, 'java') - runs-on: [self-hosted, linux] - timeout-minutes: 25 - steps: - - uses: actions/checkout@v4 - with: - persist-credentials: false - - run: scripts/ci-local.sh --only java-fast --strict-toolchains - - # Java SLOW lane — full reactor + docker integration (java + kotlin). Uses the - # shared Postgres sidecar so integration stops booting per-scenario containers. + # Java lane — full reactor with tests on (every java and kotlin conformance class + # lives in a reactor module, so it runs here) + docker integration (java + kotlin). + # Uses the shared Postgres sidecar so integration stops booting per-scenario containers. java-slow: needs: detect if: contains(needs.detect.outputs.ports, 'java') @@ -206,7 +208,10 @@ jobs: POSTGRES_DB: metaobjects_test ports: - 5432 + # The data directory (the image's VOLUME) on a size-capped tmpfs: a throwaway database + # never touches the runner's drives. options: >- + --tmpfs /var/lib/postgresql/data:rw,size=2g --health-cmd "pg_isready -U metaobjects -d metaobjects_test" --health-interval 10s --health-timeout 5s @@ -215,6 +220,16 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + - name: Postgres durability off (a throwaway database) + # A service container takes no server flags, so set them on the running server. Its data + # directory is already a tmpfs (options above); nothing in it needs to survive a crash. + run: >- + docker exec ${{ job.services.postgres.id }} + psql -U metaobjects -d metaobjects_test + -c "ALTER SYSTEM SET fsync = off" + -c "ALTER SYSTEM SET synchronous_commit = off" + -c "ALTER SYSTEM SET full_page_writes = off" + -c "SELECT pg_reload_conf()" - env: METAOBJECTS_TEST_PG_URL: postgres://metaobjects:metaobjects@localhost:${{ job.services.postgres.ports['5432'] }}/metaobjects_test run: scripts/ci-local.sh --only java-slow --strict-toolchains @@ -233,7 +248,10 @@ jobs: POSTGRES_DB: metaobjects_test ports: - 5432 + # The data directory (the image's VOLUME) on a size-capped tmpfs: a throwaway database + # never touches the runner's drives. options: >- + --tmpfs /var/lib/postgresql/data:rw,size=2g --health-cmd "pg_isready -U metaobjects -d metaobjects_test" --health-interval 10s --health-timeout 5s @@ -242,6 +260,16 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + - name: Postgres durability off (a throwaway database) + # A service container takes no server flags, so set them on the running server. Its data + # directory is already a tmpfs (options above); nothing in it needs to survive a crash. + run: >- + docker exec ${{ job.services.postgres.id }} + psql -U metaobjects -d metaobjects_test + -c "ALTER SYSTEM SET fsync = off" + -c "ALTER SYSTEM SET synchronous_commit = off" + -c "ALTER SYSTEM SET full_page_writes = off" + -c "SELECT pg_reload_conf()" - env: METAOBJECTS_TEST_PG_URL: postgres://metaobjects:metaobjects@localhost:${{ job.services.postgres.ports['5432'] }}/metaobjects_test run: scripts/ci-local.sh --only python --strict-toolchains @@ -260,7 +288,10 @@ jobs: POSTGRES_DB: metaobjects_test ports: - 5432 + # The data directory (the image's VOLUME) on a size-capped tmpfs: a throwaway database + # never touches the runner's drives. options: >- + --tmpfs /var/lib/postgresql/data:rw,size=2g --health-cmd "pg_isready -U metaobjects -d metaobjects_test" --health-interval 10s --health-timeout 5s @@ -269,12 +300,22 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false + - name: Postgres durability off (a throwaway database) + # A service container takes no server flags, so set them on the running server. Its data + # directory is already a tmpfs (options above); nothing in it needs to survive a crash. + run: >- + docker exec ${{ job.services.postgres.id }} + psql -U metaobjects -d metaobjects_test + -c "ALTER SYSTEM SET fsync = off" + -c "ALTER SYSTEM SET synchronous_commit = off" + -c "ALTER SYSTEM SET full_page_writes = off" + -c "SELECT pg_reload_conf()" - env: METAOBJECTS_TEST_PG_URL: postgres://metaobjects:metaobjects@localhost:${{ job.services.postgres.ports['5432'] }}/metaobjects_test run: scripts/ci-local.sh --only csharp --strict-toolchains notify: - needs: [detect, gates, ts-fast, ts-unit, ts-slow, java-fast, java-slow, python, csharp] + needs: [detect, gates, ts-fast, ts-unit, ts-slow, java-slow, python, csharp] if: always() && contains(needs.*.result, 'failure') runs-on: [self-hosted, linux] steps: diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index c1467e9373..08dda900dc 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -12,8 +12,9 @@ name: pr-ci # WHICH PORTS: `detect` maps the PR's changed paths to ports with # scripts/ci-affected-ports.sh, the same mapper local-ci.yml uses. A change under a # port's directory selects that port; a change to fixtures/, spec/, scripts/, .github/, -# agent-context/ or anything unrecognised selects ALL ports (the mapper fails open); a -# docs-only change selects none and runs only the offline `gates` lane. +# agent-context/, docs/ or anything unrecognised selects ALL ports (the mapper fails +# open); only the root prose files (README.md, CHANGELOG.md, CONTRIBUTING.md, +# AGENTS.md, CLAUDE.md) select none and run only the offline `gates` lane. # # WHAT RUNS PER PORT: unit tests plus the conformance corpora, not the docker # integration suites (integration-tests.yml owns those, on tags and on demand): @@ -96,6 +97,7 @@ jobs: steps: - uses: actions/checkout@v4 with: + fetch-depth: 0 # the mutation gate needs a merge base with origin/$GITHUB_BASE_REF to diff-scope persist-credentials: false - uses: oven-sh/setup-bun@v2 with: diff --git a/.nm-triage-nonprod b/.nm-triage-nonprod new file mode 100644 index 0000000000..5409416478 --- /dev/null +++ b/.nm-triage-nonprod @@ -0,0 +1,11 @@ +# Paths that no-mistakes triage counts as non-production (one glob per line). +# Conformance corpora and other test fixtures: data, gated by every port's runner. +fixtures/** +# The metamodel spec and the copies generated from it into each port. +spec/metamodel/*.json +server/csharp/MetaObjects/SpecMetamodel/*.json +server/python/src/metaobjects/spec_metamodel/*.json +server/typescript/packages/metadata/src/**/*.embedded.ts +# The generated reference site and showcase payload. +site-reference/** +examples/showcase/site-payload.json diff --git a/.no-mistakes.yaml b/.no-mistakes.yaml index 4653976392..8420058c3d 100644 --- a/.no-mistakes.yaml +++ b/.no-mistakes.yaml @@ -7,16 +7,23 @@ # conformance.yml's lanes, integration-tests.yml's Testcontainers matrix), so pinning the # gate to it runs exactly the repository's checks, the same ones GitHub runs. # -# THE SPLIT. These two commands together are exactly `scripts/ci-local.sh --quick`, cut -# along the script's own `--only` section boundaries so neither step repeats the other. -# `scripts/ci-local.sh --help` enumerates what each section contains, and -# `MO_CI_LIST_ONLY=1 scripts/ci-local.sh --only
` prints its exact step list. -# Measured green on a warm tree 2026-09-18: test 256s, lint 23s. The test step's mutation -# gate is DIFF-SCOPED (gate_completeness_diff in the script): it mutates only the -# stryker.conf.mjs `mutate` files the branch changed against its base, and SKIPs when it -# changed none. Before 2026-11-14 it ran the full pass every round, 10-45 min under load -# and most of this step's wall time. The full pass is `--only mutation`, the flagless -# run's mutation lane, and conformance.yml (tags, nightly, dispatch). +# THE SPLIT. `lint` is `--only gates`, the one lane every change runs. `test` is +# `--affected`: it lists what the branch changed against its merge base, maps the paths to +# lanes with scripts/ci-lane-map.txt, prints which lanes it selected, skipped and why, and +# runs only those (ts-fast + ts-unit for a TypeScript or web-client change; java-slow, +# python or csharp for a change confined to that port; every selectable lane for a change +# to fixtures, spec, scripts, workflows, agent-context, docs or any path the map does not +# claim; none for a change to only the root README, CHANGELOG, CONTRIBUTING, AGENTS or CLAUDE +# files, which the gates lane covers). Selected lanes run exactly as +# `--only --no-integration` does, so a lane's contents are unchanged. Force every +# lane with MO_CI_FULL=1. Before 2026-11-15 this step was always `--only ts-fast --only +# ts-unit`, so a Java, Python or C# change was validated by the TypeScript tests and by +# nothing in its own port. Measured green on a warm tree 2026-09-18: ts-fast + ts-unit +# 256s, gates 23s. The test step's mutation gate is DIFF-SCOPED (gate_completeness_diff in +# the script) and runs inside ts-fast: it mutates only the stryker.conf.mjs `mutate` files +# the branch changed against its base, and SKIPs when it changed none. That is unchanged by +# the selection. The full pass is `--only mutation`, the flagless run's mutation lane, and +# conformance.yml (tags, nightly, dispatch). # # ORDER IS LOAD-BEARING, and it is why the work is split this way round rather than one # `--quick` in `test`. The pipeline runs test BEFORE lint. The `gates` section contains @@ -39,18 +46,19 @@ # NOT all of them, which is the part worth being exact about: five invoke `node` directly # (publish-set, script-name hooks, extract field kinds, metamodel-version, migration guides), # `check-publish-intent.sh` spawns `node` internally, and `gate_positioning_claims` invokes -# bare `bun`. What holds across both kinds is the flag's safety: it cannot misfire on a -# missing dotnet/mvn/uv, because nothing in `gates`, `ts-fast` or `ts-unit` invokes them. +# bare `bun`. `gates`, `ts-fast` and `ts-unit` invoke no dotnet/mvn/uv. `--affected` can select the +# lanes that do, and there the flag is the point: a change to that port with its toolchain +# missing FAILS, where a plain run would skip it and report green. # -# WHAT IS DELIBERATELY NOT HERE — the rest of the flagless `scripts/ci-local.sh`: the C#, -# Java, Kotlin and Python conformance lanes, the full Java reactor, and -# integration-tests.yml's five-port Testcontainers matrix plus the migrate-ts / runtime-ts -# real-Postgres suites (`--only ts-slow`). Dropped for cost — they turn a ~4.5 minute step -# into a much longer one on every round — and for dependence: they need dotnet, mvn, uv and -# a live Docker daemon, which a gate host is not guaranteed to have, and neither -# `--strict-toolchains` (a missing toolchain FAILS) nor its absence (a down Docker SKIPS -# silently) gives an honest per-change signal when they are missing. docs/RELEASING.md -# requires the flagless run before `bun publish`, which is where they are enforced. +# WHAT IS DELIBERATELY NOT HERE — the docker half. `--affected` implies `--no-integration`: +# integration-tests.yml's five-port Testcontainers matrix, the migrate-ts / runtime-ts +# real-Postgres suites (`--only ts-slow`) and the cube live check need a live Docker daemon, +# which a gate host is not guaranteed to have, and a down daemon SKIPS silently without +# `--strict-toolchains`. They turn a ~4.5 minute step into a much longer one on every round. +# A port's selected lane DOES need its toolchain (dotnet, mvn, uv), and under +# `--strict-toolchains` a missing one FAILS rather than skipping, so a change to that port +# is never reported green unchecked. docs/RELEASING.md requires the flagless run before +# `bun publish`, which is where the docker half and every lane are enforced. # # NOTE: this file must be at the repo ROOT as `.no-mistakes.yaml` (NOT under # .no-mistakes/), and repo commands are read from the DEFAULT BRANCH — so nothing here @@ -61,7 +69,7 @@ # commands above already run the same script the GitHub workflows run. commands: - test: "scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains" + test: "scripts/ci-local.sh --affected --strict-toolchains" lint: "scripts/ci-local.sh --only gates --strict-toolchains" # Public repository: keep PR bodies short and the run intent out of them. @@ -70,5 +78,37 @@ pr: appendix: collapsed # Mark a failing test command as pre-existing when it also fails on the base. +# +# THE EVIDENCE PHASE. After `commands.test` passes, the gate ALWAYS runs an agent that derives +# end-user scenarios and drives the product itself; no setting turns that turn off. It, not +# `commands.test`, is the long part of this step: 264 recorded Test steps for this repository +# average about 43 minutes, 130 of them over 30, against 4-5 for the command itself, and the +# agent's budget is 75 minutes on this host. Its prompt is the one thing a repository controls, +# so the runbook below scopes it the way `--affected` scopes the command: by the paths the +# change touches (`path_instructions` match the changed-file list, as scripts/ci-lane-map.txt +# does). This is guidance to a model, not a switch: it narrows what the agent is told to do +# and does not bound it. The bound is the host's `test_agent_timeout`. These fields are read +# from the default branch only, so they too take effect after merge. test: base_attribution: true + instructions: | + This repository ships libraries, a code generator and command line tools. There is no server or app to start. The test command already ran the lanes this change affects, and its output begins with the lanes it selected and skipped, so do not re-run the full suites or the lanes of ports the change does not touch. Drive the changed behavior directly instead: run the affected CLI command or generator on a small fixture from the fixtures directory, or the focused tests of the module the change touches. Keep to at most three scenarios and finish in about ten minutes. Report no-surface when the change has no runtime behavior, such as documentation, comments, CI configuration or metadata. + path_instructions: + - path: "docs/**" + instructions: | + Documentation only. There is nothing to start or drive. Return no-surface at once without running anything: the test command already ran the lanes whose tests read these pages, and the gates lane checks the prose. + - path: "server/typescript/**" + instructions: | + TypeScript port. Drive the meta CLI from the workspace on a fixture, or run bun test in only the package the change touches. Do not run the Java, Python or C# suites. + - path: "client/web/**" + instructions: | + Web client packages. Run bun test in only the package the change touches and check that its built entry still bundles. Do not run the server suites. + - path: "server/java/**" + instructions: | + Java and Kotlin ports. Run mvn test for only the Maven modules the change touches, with -pl and -am, not the whole reactor. Do not run the TypeScript, Python or C# suites. + - path: "server/python/**" + instructions: | + Python port. Run pytest on only the test modules the change touches. Do not run the TypeScript, Java or C# suites. + - path: "server/csharp/**" + instructions: | + C# port. Run dotnet test on only the test project the change touches. Do not run the TypeScript, Java or Python suites. diff --git a/AGENTS.md b/AGENTS.md index 6ac8a5b6a2..b9f825d63a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,7 +22,7 @@ The first four ship per-language today across the five ports (TS / C# / Java / P ## Status -_Last refreshed 2026-10-30._ +_Last refreshed 2026-11-17._ **1.0 gating — the quiet period is RETIRED (2026-09-06).** `docs/1.0-readiness.md` §G3 no longer asks for "one coordinated release with no metamodel-breaking change." It measured a @@ -39,14 +39,16 @@ because a conformance corpus gates the ports against each other and never agains in ADR-0035 **Amendment 3**. Do not reintroduce a waiting gate in any form. -**Where the versions are.** `latest` is **`1.2.0`** on npm, **`8.2.0`** on Maven Central, -**`1.2.0`** on PyPI and **`1.2.0`** on NuGet (the Maven major is always **npm major + 7**, so -1.2.0 is 8.2.0). **1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4 and 1.2.0 are released.** 1.0.13 is the last 1.0.x release; the four registries moved together on 1.0.13, 1.0.12, 1.0.11, 1.0.10 and 1.0.9 (Maven skipped 8.0.8), and earlier Maven alone took 1.0.6 (8.0.6) while the other three skipped that +**Where the versions are.** `latest` is **`1.2.3`** on npm, **`8.2.3`** on Maven Central, +**`1.2.3`** on PyPI and **`1.2.3`** on NuGet (the Maven major is always **npm major + 7**, so +1.2.3 is 8.2.3). **1.1.0 through 1.2.0, 1.2.1 (Python only), 1.2.2 and 1.2.3 are released.** +`CHANGELOG.md` carries a dated **[1.3.0]** section, but no registry has published it yet (the +npm publish prep is still open); and the 1.2.x line has `1.2.4-rc.N` candidates cut. 1.0.13 is the last 1.0.x release; the four registries moved together on 1.0.13, 1.0.12, 1.0.11, 1.0.10 and 1.0.9 (Maven skipped 8.0.8), and earlier Maven alone took 1.0.6 (8.0.6) while the other three skipped that number. Both patterns are the convergent-publishing rule working as intended. **1.0 is CUT** and **1.1 is released**: the 1.0.0-rc candidates through 1.0.13 are superseded, and npm's `next` tag is REPOINTED onto each release — not deleted, because `dist-tag rm` 403s for every token we hold (`docs/RELEASING.md` §4). `metamodelVersion` read **`1.0`** through 1.0.13 — C4 landed and G4 shipped it, and no 1.0.x patch moved it (1.0.4 relaxed `@sourceRefField` onto `@cardinality: one` with a prose-only -manifest footprint, and was ruled a hold). `metamodelVersion` read **`1.1`** from 1.1.0 through 1.1.3 for the FR-044 reporting vocabulary and the requirements slice 1 (the first slice of two, covering existence gates and per-entity coverage). **It reads `1.2` from 1.1.4** for calendar-aligned relative report windows (`startOf` on a relative date). Per-release detail lives in **`CHANGELOG.md`** — it is the log, and this file does +manifest footprint, and was ruled a hold). `metamodelVersion` read **`1.1`** from 1.1.0 through 1.1.3 for the FR-044 reporting vocabulary and the requirements slice 1 (the first slice of two, covering existence gates and per-entity coverage). **It reads `1.2` from 1.1.4** through every published release since, for calendar-aligned relative report windows (`startOf` on a relative date). The merged tree claims **`1.3`** (`METAMODEL_VERSION` in every port) — main's 1.3.0 and the line's 1.2.4 both carry it, and neither is published. Per-release detail lives in **`CHANGELOG.md`** — it is the log, and this file does not duplicate it. The npm surface is **14 `@metaobjectsdev/*` packages in full lockstep**; the two `angular` @@ -71,16 +73,16 @@ 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/` (475 fixtures; 39 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/` (526 fixtures; 42 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. - YAML / verify corpora green across the ports that ship those layers. - **Codegen-compile gate** (all five ports; a GATE, not a corpus — it has no fixtures of its own and no row in the matrix). Every corpus above gates BEHAVIOUR; none asks whether the emitted code BUILDS, which is how four "generated code does not compile" defects shipped in 1.0.4 with the whole matrix green — `gen` exits 0 in all four cases and the adopter's build is the first thing that disagrees. Each port generates from `fixtures/persistence-conformance/canonical/meta.fitness.json` (reused deliberately: a second kitchen sink would drift from the one the other corpora already maintain) and compiles the emitted tree with its real compiler — `ts.createProgram` / Roslyn / `javac` / `KotlinCompilation` / (Python, having no static compiler) importing the generated package plus `ruff` F821. **Every port excludes its framework-bound route tier** (TS `routesFile`, C# `RoutesGenerator`, Java `SpringControllerGenerator`, Kotlin `KotlinSpringControllerGenerator`): those imports are not on an in-memory compile's classpath and stubbing them drowns the signal, so that tier is proven by the api-contract integration lane instead. One cross-port rule, not four local concessions. Found 5 further real defects on first run. Boundary detail: `docs/CONFORMANCE.md` → "Split coverage". -**Key cross-language features shipped:** FR5 family (a/b/c/d/e + WARN envelope-shape — actionable loader errors per ADR-0009); FR-003 (Java RDB runtime persistence + projections; schema migrations are TS-only — the Java migration engine was removed); FR-006 (template.output parser-on-receipt codegen per ADR-0010 in all 5 ports); FR-008 + FR-009 (cross-port REST API contract + the nine filter operators); FR-018 (M:N relationship codegen in all 5 ports — entity navigation + idiomatic ORM wiring [Drizzle m2m / EF Core `UsingEntity` / Spring repo+JPA / Exposed / Pydantic+route as the SQLAlchemy-secondary equivalent] + REST traversal `GET //{id}/` + Tier-2 docs, gated by the shared api-contract m2m corpus in both lanes + persistence-conformance; the TanStack M:N client hook is a deferred client-ergonomics follow-up); SP-H (field-subtype end-to-end hardening: every concrete `field.*` subtype write+read round-trips cross-port via the persistence `op: roundtrip` gate; cut `field.byte`/`field.short`/`field.class` non-functional stubs; cross-port filter-op reconciliation for uuid/currency); source v2 paradigm (ADR-0007); metadata-ktx Kotlin facade; per-target output directories (TS codegen); FR-044 (the reporting vocabulary — `dimension.attribute`/`dimension.time`, `measure.aggregate`/`measure.ratio`, `segment.filter`, `object.report`, `@spine` on a report to take rows from a to-one dimension entity, `@default` on a measure for empty aggregates, plus the relative-date filter value — registered and loader-validated in all five ports; a report that declares a read-only `source.rdb @kind: view` is lowered to a SQL view by `meta migrate` and read by every port, and served by a generated read-only list route in every port, gated by the api-contract `report/` sub-corpus; the TypeScript `cube-model` reference generator writes the vocabulary as Cube data-model files, gated by the `fixtures/cube-model/` corpus and a `cube` lane that loads the output into a real Cube; a served report gets the generated TanStack list hook (`useList`) but no grid or form, see [docs/features/reporting.md](docs/features/reporting.md) and [docs/features/cube-export.md](docs/features/cube-export.md)). +**Key cross-language features shipped:** FR5 family (a/b/c/d/e + WARN envelope-shape — actionable loader errors per ADR-0009); FR-003 (Java RDB runtime persistence + projections; schema migrations are TS-only — the Java migration engine was removed); FR-006 (template.output parser-on-receipt codegen per ADR-0010 in all 5 ports); FR-008 + FR-009 (cross-port REST API contract + the nine filter operators); FR-018 (M:N relationship codegen in all 5 ports — entity navigation + idiomatic ORM wiring [Drizzle m2m / EF Core `UsingEntity` / Spring repo+JPA / Exposed / Pydantic+route as the SQLAlchemy-secondary equivalent] + REST traversal `GET //{id}/` + Tier-2 docs, gated by the shared api-contract m2m corpus in both lanes + persistence-conformance; the TanStack M:N client hook is a deferred client-ergonomics follow-up); SP-H (field-subtype end-to-end hardening: every concrete `field.*` subtype write+read round-trips cross-port via the persistence `op: roundtrip` gate; cut `field.byte`/`field.short`/`field.class` non-functional stubs; cross-port filter-op reconciliation for uuid/currency); source v2 paradigm (ADR-0007); metadata-ktx Kotlin facade; per-target output directories (TS codegen); FR-044 (the reporting vocabulary — `dimension.attribute`/`dimension.time`, `measure.aggregate`/`measure.ratio`, `segment.filter`, `object.report`, `@spine` on a report to take rows from a to-one dimension entity, `@default` on a measure for empty aggregates, plus the relative-date filter value — registered and loader-validated in all five ports; a report that declares a read-only `source.rdb @kind: view` is lowered to a SQL view by `meta migrate` and read by every port, and served by a generated read-only list route in every port, gated by the api-contract `report/` sub-corpus; the TypeScript `cube-model` reference generator writes the vocabulary as Cube data-model files, gated by the `fixtures/cube-model/` corpus and a `cube` lane that loads the output into a real Cube; a served report gets the generated TanStack list hook (`use`, or `useList` when the plural is the name) but no grid or form, see [docs/features/reporting.md](docs/features/reporting.md) and [docs/features/cube-export.md](docs/features/cube-export.md)). -**Release 1.1.0** (released; npm `1.1.0`, PyPI `1.1.0`, NuGet `1.1.0` and Maven Central `8.1.0`; the latest is 1.2.0 / 8.2.0). The reporting release (FR-044): declare dimensions, measures, segments and an `object.report`, and get a SQL view, a served read-only list route in every port, a generated TanStack list hook, and a Cube data model, with `@spine` for rows that have no facts and `@default` for an empty measure. Also carries the first slice of requirements (the gate in every port's `verify`), the derived-key parity fix across the ports, and the list-hook and nested-average fixes found by the first adopter. See the `CHANGELOG.md` 1.1.0 section for the full scope, pre-release RC history, and the diffs to expect when you upgrade (ejected generators and keyless projections). It also makes documentation a set of generators in every port (ADR-0034 Amendment 9): the docs commands are removed, and `docs/features/migrations/docs-are-generators.md` is the upgrade path. The last 1.0.x release, 1.0.13 (2026-10-03), was a PATCH on 1.0.x. +**Release 1.1.0** (released; npm `1.1.0`, PyPI `1.1.0`, NuGet `1.1.0` and Maven Central `8.1.0`; the latest is 1.2.3 / 8.2.3). The reporting release (FR-044): declare dimensions, measures, segments and an `object.report`, and get a SQL view, a served read-only list route in every port, a generated TanStack list hook, and a Cube data model, with `@spine` for rows that have no facts and `@default` for an empty measure. Also carries the first slice of requirements (the gate in every port's `verify`), the derived-key parity fix across the ports, and the list-hook and nested-average fixes found by the first adopter. See the `CHANGELOG.md` 1.1.0 section for the full scope, pre-release RC history, and the diffs to expect when you upgrade (ejected generators and keyless projections). It also makes documentation a set of generators in every port (ADR-0034 Amendment 9): the docs commands are removed, and `docs/features/migrations/docs-are-generators.md` is the upgrade path. The last 1.0.x release, 1.0.13 (2026-10-03), was a PATCH on 1.0.x. Active and planned work lives in GitHub: issues labelled `FR`, milestones for releases, and the MetaObjects Roadmap project board. `spec/roadmap.md` keeps the release direction and the FR → issue → spec index. Process: `docs/ROADMAP-PROCESS.md`. @@ -129,7 +131,8 @@ adds the C#/Java/Kotlin/Python conformance lanes, the Java reactor and `integrat Testcontainers matrix. Run `--quick` before opening a PR and the full script before a tag; `MO_CI_LIST_ONLY=1 scripts/ci-local.sh [flags]` prints what a selection would run without running it. The no-mistakes validation gate runs the script for you — see `.no-mistakes.yaml`, -whose `lint` and `test` commands partition `--quick` between the two steps. That file is read +whose `test` command runs `--affected` (only the lanes the change touches, per +`scripts/ci-lane-map.txt`) and whose `lint` command runs `--only gates`. That file is read from the **default branch**, so it does nothing until it is merged to `main`. **`leak-scan` is hosted again.** `main`'s protection requires that one status, and `hygiene.yml` @@ -260,7 +263,7 @@ import { EntityFetcherProvider, EntityGrid } from "@metaobjectsdev/tanstack"; - **TS runtime**: Bun-first for development (zero-config TS, native test runner). Node-compatible for distribution; users install via npm/pnpm/bun without lock-in to Bun's runtime. - **Module system**: ESM only. No CommonJS, no transpile step required. - **Storage format**: JSON files in `metaobjects/meta..json` at project root. `.metaobjects/.gen-state/` holds the codegen merge base: the snapshot **bodies are gitignored** (a second full copy of all generated output), but **`.hashes.json` is COMMITTED** — one hash per generated path, and the only thing that lets `meta gen` tell "this file is exactly what I wrote" from "somebody edited this" on a machine that did not generate it. Ignore it and a fresh clone or CI runner silently overwrites hand edits; commit it and an edited file is refused by name instead. -- **Codegen substrate**: ts-poet for greenfield emit, ts-morph for in-place edits, Biome for format pass, `git merge-file --diff3` for hand-edit-preserving regen. +- **Codegen substrate**: the vendored ts-poet printer (`codegen-ts/src/poet.ts`) for greenfield emit, ts-morph for in-place edits, Biome for format pass, `git merge-file --diff3` for hand-edit-preserving regen. - **Runtime substrate**: Kysely for TS (user-provided connection, async-only). - **Migration substrate**: Postgres + SQLite for TS v0.3. - **Metadata location**: resolved via `resolveCollection()` (`@metaobjectsdev/sdk`) — the single authority. `metaobjects/` is the **default value of `sources`** and nothing else: no other module, command or user-facing message may assert that a directory of that name exists or is where metadata lives. Exactly five sites may name it — `sdk/src/metadata-files.ts` (`DEFAULT_METADATA_DIR`, its single definition), `sdk/src/sources.ts` (`DEFAULT_SOURCES`, **the** default), `sdk/src/collection.ts` (inside `resolveCollection`, *applying* that default), `sdk/src/index.ts` (the barrel re-export of the constant, no use), and `cli/src/commands/init.ts` (the scaffolder **writing** the layout). Enforced by `sdk/test/no-hardcoded-metadata-dir.test.ts`, whose allowlist demands a written reason per entry. See [docs/features/metadata-sources.md](docs/features/metadata-sources.md). @@ -499,3 +502,27 @@ inverse of metadata-is-the-spine. *OMDB engine debt* — FR-003 Plan 4 closed th anti-patterns; the Spring Boot 3 starter and OMDB autoconfiguration shipped. *WARN envelope-shape on `expected-warnings.json`* — every runner asserts it; the legacy string-list path is retired. + +## Disk I/O: keep throwaway data off the drives + +Test databases, sandboxes and temp files must not wear out the developer's drives. + +- **Throwaway data goes in RAM.** Put scratch files, mutation-testing sandboxes (Stryker +`tempDirName`) and test-only temp directories under `$DEV_SCRATCH` (fall back to the system temp +directory when it is unset). Delete what you create when the run ends. +- **Test databases run on a capped tmpfs at the image's `VOLUME` path** (`postgres:18*`: +`/var/lib/postgresql`; `postgres:16/17` and `pgvector:*-pg17`: `/var/lib/postgresql/data`; +`mysql:8*`: `/var/lib/mysql`; check others with `docker image inspect -f '{{json .Config.Volumes}}'`), +`size=2g`, with Postgres durability off: `-c fsync=off -c synchronous_commit=off -c full_page_writes=off`. +- **Every container you start, you remove.** Use `docker run --rm`, Testcontainers with Ryuk enabled, +or explicit teardown in a `finally`/`trap`. Never leave a hand-started database running after your +task. A database you mean to keep gets the label `dev.keep=true`. +- **Generators and tools never rewrite a file whose bytes did not change**, write any manifest once per +run (not once per file), and verify drift in memory rather than by rendering everything to a temp +directory. +- **Run the narrowest tests that prove the change** while iterating (one module, the affected test +classes); run the full suite once, before the PR. +- **No background processes outlive the task.** Kill test watchers, dev servers and sandboxes you +started before you finish. + +Project specifics: test databases start in the TypeScript `integration-tests` package (`src/postgres-container.ts`, `src/mysql-container.ts`, `src/cube-container.ts`, sharing `src/throwaway.ts`), the Python `tests/integration/` launchers (`postgres_container.py`, `mysql_container.py`, `throwaway.py`), the C# `MetaObjects.IntegrationTests/Runner/PostgresContainer.cs`, the Java and Kotlin Testcontainers `PostgresContainer` classes under `server/java/integration-tests*`, and the services and sidecars in `.github/workflows/integration-tests.yml` and `local-ci.yml`. diff --git a/CHANGELOG.md b/CHANGELOG.md index dd30248c38..ced70ca534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,81 @@ here.** ## [Unreleased] +**New metamodel vocabulary: `measure.derived` and its `@expr`.** It is additive: nothing that +loaded before stops loading. This vocabulary ships in 1.3.0 with `metamodelVersion` 1.3 if it merges before the 1.3.0 publish; if it lands after, the next release moves `metamodelVersion`. + +### Upgrading + +- **`api.unknownFields: reject` is the one deliberate default change.** A generated create, PUT + or PATCH route that dropped an undeclared top-level key now answers `400 unknown_fields`, in + existing projects too, once they regenerate (under "Changed" below). Set + `"api": { "unknownFields": "drop" }` to keep the old answer. Everything else new here is either + a fix to input no client should send or a setting a project has to turn on. +- **C#: a `readOnly` property has a private setter.** Regenerating gives every `readOnly` + property a private setter, whatever its shape (under "Security" below), so hand code that + assigned one (`row.Role = ...`) no longer compiles. The value belongs to the server: set it + through a database default or EF Core (`db.Entry(row).Property(r => r.Role).CurrentValue`), + which writes private setters. +- **Java and Kotlin: `` now narrow every generator.** The `codegen-spring` and + `codegen-kotlin` generators ignored a generator's `` and wrote every object; they now + honour them, as the `codegen-base` generators always did. A pom whose filters were inert + generates fewer files: remove the `` that no longer describe what you want. + +### Security + +- **Generated create routes wrote fields a client must never set, in Java, Kotlin, C# and + Python; the TypeScript update shape let a client re-key a row.** An external review of 1.2.0 + found that the Python routes passed raw request input to the repository (fixed for Python in + 1.2.1). An audit of the other ports found the same class of hole on create, in the plain and + the TPH per-subtype handlers: + - **Java** (`codegen-spring`): create forwarded a client-sent generated `id`, `readOnly` and + derived fields to `repository.create`, and in TPH also the discriminator and a sibling + subtype's columns to `createWithType`. + - **Kotlin** (`codegen-kotlin`): create wrote `readOnly` columns, and TPH create wrote every + column of the union table, a sibling subtype's included. + - **C#** (`MetaObjects.Codegen`): create bound the request to the entity and added it as + sent, so a client-sent generated `id` was inserted, a POST to one subtype's route with + another subtype's `type` created a row of that other subtype, M:N navigation collections in + the body were inserted with the row, and a `readOnly` field other than a plain scalar (an + enum, array, value object or map, or any TPH subtype field) had a public setter. A `readOnly` + property now has a private setter on every shape, so System.Text.Json does not bind it, and + a `@required` `readOnly` field is neither demanded of the create body nor held to its + `[Required]` there, so such an entity stays creatable. A `readOnly` key or discriminator + gets no reset, because its private setter already keeps the body out. + - **Java and Kotlin**: a `@required` `readOnly` or derived column (a value object included) + is no longer demanded of the create body once the route drops it. + - **TypeScript** (`codegen-ts`): an ASSIGNED primary key stayed in `UpdateSchema`, so + PATCH or PUT could change the row's key. A generated key was already refused. + + Every port now drops these keys silently before the write, as the TypeScript create already + did: a server-generated key, a `readOnly` or derived field, and in TPH the discriminator (the + route's subtype is its only source) and every column the route's subtype does not declare. An + assigned key is still the caller's on create. No port answers them with a 400. A key the + entity does not declare is a separate case, now a project setting (`api.unknownFields`, + under "Changed" below). Java DTOs and Kotlin entity classes that are a + write route's request body (and the value objects nested in one) now carry + `@JsonIgnoreProperties(ignoreUnknown = true)`, so binding no longer depends on the host's + `ObjectMapper` (a plain one answered 400). The Python 1.2.1 fix is carried forward to this + line, and the Python TPH create and update now drop a body's discriminator instead of answering + 400 for a foreign one. + + Gated by three shared api-contract scenarios: `input-server-owned-dropped` (generated and + reference lanes in every port), and `tph/tph-input-server-owned-dropped` and + `tph/tph-input-foreign-discriminator-dropped`, which send a client `id`, a foreign + discriminator, a sibling subtype's column and a `writeOnce` change. The TPH scenarios run in + the generated and reference lanes in TypeScript and C#, and in the generated lane only in + Python, Java and Kotlin, which have no TPH reference server. A `readOnly` `role` column in the + `secret-fields` corpus covers the rest. Scenarios gain `absent: [keys]` (the key is missing) + and `unset: [keys]` (missing or null) assertions. These are the 1.2.2 fixes from the `1.2.x` + line, carried forward. Adopters with ejected (owned) generators need the same change made by + hand. + + ## [1.2.4] — 2026-11-15 +_PENDING: version to be chosen by the captain; metamodel 1.3 is claimed by both sides (this section is the release line's, merged beside main's 1.3.0)._ + + _In preparation; cut as release candidates `1.2.4-rc.N` (npm and NuGet `1.2.4-rc.N`, Maven Central `8.2.4-rc.N`). It carries everything on the release line since 1.2.0 that 1.2.2 and 1.2.3 did not ship; their own changes are in their sections below. Earlier candidates of this work were cut as `1.2.3-rc.N` @@ -34,6 +107,347 @@ vocabulary; upgrade every port together. ### Added +- **A code writer for generators: `CodeWriter` and `TsWriter` in `@metaobjectsdev/codegen-ts`** + (ADR-0063). A generator says what a line contains, and the writer decides where it sits. It + builds the file in memory with no formatter. It collects imports while the body is written, + treats blank lines as requests that collapse, and prints a list on one line when the line fits + 120 columns, otherwise one item per line. `TsWriter` accepts ts-poet `Code` fragments and + collects their `imp()` imports, so a generator can move to it one function at a time. The + writer is exported from the package root and from `@metaobjectsdev/codegen-ts/engine`, so an + owned (ejected) generator can use it too. Both classes are built to be extended: every + method is public or protected, so a subclass can override one step, such as import order, + and keep the rest. ADR-0063 also rules that reference generators will be extended the same + way, one overridable method per piece of output, without promising those methods are stable + between minor versions. The contract is `spec/code-writer.md`, pinned by + the new `fixtures/writer-conformance/` corpus. No shipped generator uses the writer yet, so + generated output does not change in this release. + +- **Select objects to regenerate in every port.** C# `dotnet meta gen --entities A,B` (and + `verify --codegen --entities`) and, for Java and Kotlin, `mvn metaobjects:generate + -Dmeta.entities=A,B` regenerate only the named objects' files, like TypeScript's + `meta gen A B` and Python's `--entities`. Names are short object names. A file built from the + whole model (C#'s `AppDbContext`, the Java and Kotlin validator registry, report export writer + and binding provider) still renders from the whole model, a narrowed run neither deletes nor + forgets the other objects' files, and a blank selection or a name that matches no object is + refused (exit 2 in C#, a failed goal in Maven). +- **`meta gen ...` refuses a name that matches no object**, with exit 2 and nothing + written, as Python, C# and the Maven plugin do. It used to drop the unknown name silently + when another name matched, and only warn when none did. +- **The Java loader's initialization timeout is a setting.** It stays 30 seconds by default. Raise + it with `-Dmeta.loaderTimeoutMs` (or ``) on the Maven plugin, + `LoaderOptions.setInitTimeoutMs`, the loader argument `initTimeoutMs`, or the system property + `metaobjects.loader.initTimeoutMs`; the timeout error names them. +- **A page size for generated list routes: `api.pagination`, in every port.** An external review + of 1.2.0 found that list endpoints had no hard cap: the TypeScript and C# routes returned the + whole table when `limit` was omitted, and `?limit=100000` was accepted in every port. The new + `api.pagination` block in `.metaobjects/config.json` gives a generated entity or projection list a + default page and refuses a larger `limit`; `meta init` writes it for a new project. **A project + without the setting behaves exactly as before**, because a cap added on upgrade would silently + truncate a client that reads a whole list; each port's verify advises (`unbounded-list-pages`, + never a failure). A negative `limit`, and in C# a `limit` or `offset` that is not a whole number, + now answers the malformed-bound 400 rather than reaching the store, and `limit=0` is a page of + zero rows in every port (the C# route served the default page). Every port's generated list + routes read it (TypeScript through a new `pagination` option on the runtime mounts); an owned + (ejected) routes copy picks it up when it is re-ejected. Gated in the generated lane of every port + by the new `fixtures/api-contract-conformance/api-settings/` sub-corpus, whose + `config-blocks.json` every port's config reader runs. The answers, limits and exceptions are in + [docs/features/api-contract.md](docs/features/api-contract.md#sort--pagination). A config key, not + vocabulary: `metamodelVersion` does not move. + +- **Report measures over Money and other value-object members (FR-044 R12).** A dimension's or + measure's `@of` may name `Entity.field.member`, a member of a value object stored with + `@storage: flattened` (`Payment.amount.amount`, `Payment.amount.currency`); the report reads + the member's own column. A `sum`, `avg`, `min` or `max` of a numeric member loads only when the + report lists a dimension over each non-numeric member of the same value object (its + currency), so amounts in different currencies are never combined; the rule follows the + measure into ratio and derived-measure operands. A member of a jsonb value object, an unknown + member and a deeper path are refused at load, and the Cube exporter refuses member paths. + Loader rules and report-shape derivation in TypeScript, C#, Java and Python. +- **`measure.derived`: arithmetic between measures (FR-044 R13).** `@expr` is FR-037 R5's + first arithmetic wave: `add`, `subtract`, `multiply` and `divide` over two operands, where an + operand is `{ "field": }` (a numeric `measure.aggregate` or `measure.ratio` of the + entity, or a numeric attribute dimension the report lists) or `{ "value": }`. It + expresses a ratio scaled to a percent and a measure over a grouped quantity (utilization = + billable hours × 100 ÷ (weekly capacity × 52 ÷ 12); budget burn = cost ÷ budget). The result + is a nullable `decimal`; `divide` reads null on a zero divisor. `meta migrate` lowers it on + Postgres, SQLite, MySQL and D1, every port reads and serves it, and the Cube exporter writes + one over measures as a `number` member (one reading a dimension is refused). Loader rule M11, + report rule R13 and a conformance fixture per refusal, in every loader port. + +- **`verify.handEdits`: a hand-edited generated file can fail `meta verify`.** `meta verify + --codegen` already listed each generated file carrying a hand edit, but always exited 0, so a + rule changed by hand in generated code (a `max(32)` made `max(64)`) passed the gate. Set + `"verify": { "handEdits": "fail" }` in `.metaobjects/config.json` and it exits 1; `"notice"` + keeps the report and exit 0. `--allow-hand-edits` relaxes `fail` for one run, and the existing + `--forbid-hand-edits` still forces a failure for one run (passing both is refused). The report + names each file, how to see the edit, how to drop it (or move a changed rule into the + metadata), and how to keep it. A project without the key behaves exactly as before. The C#, + Java, Kotlin and Python gates compare generated files byte for byte and already fail on any + edit; the docs now say so. +- **`migrate.foreignKeyIndexes`: an index on every foreign key, without the `efcore` renames.** + With it on, `meta migrate` gives each enforced foreign key that the primary key, a unique key or + an index does not already lead with a `__idx` index. The Drizzle and Prisma + generators, the C# `AppDbContext` and the Kotlin Exposed tables declare the same indexes under + the same names; Java and Python map no indexes. It adds nothing under the `efcore` conventions + (which already index every foreign key) or on MySQL. A project without the key is unchanged and + keeps the unindexed-foreign-key advisory, which now names the option. Gated by two new + persistence-corpus migration scenarios (adding the indexes to an existing schema, and the + converged no-op). Java's config reader now carries the `migrate` block's + `foreignKeyIndexes`, `conventions` and `dialect` on the loaded root (`MigrateSettings`). + +- **`meta init --skills-dir ` and `meta agent-docs --skills-dir `: install the skills + for any coding assistant.** The `metaobjects-*` skills went only to `.claude/skills/`, which + Claude Code reads. `--skills-dir .agents/skills` (or any project-relative directory) puts them + where another assistant looks; the choice is recorded in `.metaobjects/.agent-context.json`, + so a later `--refresh-docs` keeps it, and moving the directory prunes the untouched copies at + the old one along with the skill directories that leaves empty (the old skills directory + itself stays, and so does any skill directory still holding a file of yours). The always-on file names the directory, so an assistant that does not load + skills opens `//SKILL.md` by path. A directory outside the project is refused. +- **[What differs by language](docs/features/language-differences.md).** One page lists what + the same model does differently per port: that schema migrations and database checks need + the Node `meta` tool in every language, the list default and cap, the validation error body, + filter extras, field names in code, generated data access and hand-edit handling. Every port + page now says up front that migrations and `verify --db` run in Node, and the README's + getting-started path says it for Java, Kotlin, C# and Python teams. +- **The shared render-drift case now holds the email helper too.** 1.3.0 made a template + variable that is not on the payload raise `ERR_VAR_NOT_ON_PAYLOAD` at render time, and + `fixtures/template-output-render-conformance/runtime-drift/` held it for the `@kind: document` + helper and the `template.prompt` helper (the TypeScript `promptRender()` handle and the Python + helper over a Mustache body among them). A re-audit of every generated render path in the five + ports found none that still renders an unknown variable as empty, but the `@kind: email` + helper was not in the case. It now is: `runtime-drift/email-subject/`, `email-html/` and + `email-text/` each drift one part of a `WelcomeEmail`, and every port's runner checks that + the subject, the html body and the text body each raise. No generated code changes. + +### Changed + +- **Generation now skips when nothing changed, in every port (ADR-0064).** `meta gen`, + `metaobjects gen`, `dotnet meta gen` and `mvn metaobjects:generate` build a key from the loaded + model (each root node in canonical effective form), the generators' identity (built engine code, + config, owned generators, templates, declared extra inputs, project config) and the output-changing + flags, before anything renders. When it matches the last successful run and + every generated file still holds the bytes that run left, nothing renders and nothing is + written. The key is kept, uncommitted, in `.metaobjects/.gen-state/.fingerprint-.json`. A + run that names entities forces exactly those: it never skips, and it neither writes nor + satisfies the full-run key. `--force` + (`-Dmetaobjects.force=true` on Maven) renders everything, and a generator that cannot declare + what it reads opts out with `cache: false` or its port's equivalent. Locally, `verify --codegen` + may answer "no drift" from the same key (`--full` renders; CI always renders), and compares in + memory, with no temp tree, whenever it renders. The hash manifest is written once per run in every + port, only when an entry changed; a file whose fresh bytes equal what is on disk is never + rewritten; TypeScript runs `git merge-file` only for a file edited by hand. A forward-port of + the 1.2.x change, with the skip ADR numbered ADR-0064 on this line. + +- **A write with a key the entity does not declare is refused by default: `api.unknownFields`. + Existing projects get `reject` when they regenerate.** Until now every port dropped an + undeclared body key silently, so a client that misspelled a field (`emial`) got a 200 and lost + the value without a word. A generated create, PUT or PATCH route now answers + `400 unknown_fields` before validation and writes nothing. To keep the old behaviour set + `"api": { "unknownFields": "drop" }` in `.metaobjects/config.json` and regenerate. A declared key + the client may not set is still dropped, not refused, so a client that sends back a row it read + keeps working. `meta init` writes `reject` for a new project. TypeScript passes the declared + field list to the runtime mounts as a new `knownFields` option (a mount given none keeps + dropping); Java and Kotlin read the raw body, so the answer does not depend on Jackson's + `FAIL_ON_UNKNOWN_PROPERTIES`, and the Java value-object records nested in a write route's body now + carry `@JsonIgnoreProperties(ignoreUnknown = true)` (they answered `400 invalid_type` before). + Pinned by `input-unknown-fields-rejected`, `tph/tph-unknown-fields-rejected` and + `jsonb/jsonb-nested-undeclared-key-dropped` (both lanes of every port) and + `api-settings/unknown-fields-dropped` (`drop`, generated lane). The rule, which keys count as + declared and how each port matches them: + [docs/features/api-contract.md](docs/features/api-contract.md#unknown-request-fields-apiunknownfields). + Upgrade notes: + [docs/features/migrations/unknown-fields-reject-by-default.md](docs/features/migrations/unknown-fields-reject-by-default.md). + A config key, not vocabulary: `metamodelVersion` does not move. + +- **A validation 400 lists every issue in every port.** The same model answered a failed create or + update differently by language: TypeScript listed each problem, while C#, Java, Kotlin and Python + returned a bare `{"error": "validation"}` (found by an external review of 1.2.0). Every port now + answers with an `issues` list holding every failure, in the shape + [docs/features/api-contract.md](docs/features/api-contract.md#a-validation-error-lists-every-issue) + defines. C# ships a new `ValidationIssues` runtime file (also copied by `dotnet meta eject routes`), + and its create route now reads the body itself so an unbindable body lists its issue rather than + answering an empty 400. Java ships `ValidationIssues` beside `PatchValidationException`, and a + patch binds every field before it throws. Kotlin emits `MetaValidationIssues.kt` with the + controllers. Python maps every Pydantic error in `constraint_errors`. The hand-rolled reference + servers list issues too, and two shared scenarios pin the list in both lanes + (`validation-lists-issues`, `tph/tph-validation-lists-issues`, with a new `issues` corpus + assertion). A client that read only `error` is unaffected. An owned (ejected) routes copy keeps + the bare answer until it is re-ejected. + +- **The always-on agent file works with any coding assistant, carries the REST conventions, + and is written once.** `.metaobjects/CLAUDE.md`, an identical copy of `.metaobjects/AGENTS.md` + that nothing imported, is no longer written; a refresh removes an untouched one and names a + hand-edited one. The text no longer tells the reader to use a root `CLAUDE.md` only, and + `--wire-root` on a project with neither root file now creates `AGENTS.md` as well as + `CLAUDE.md`, each with a plain pointer line beside the `@` import. A first init on a project + that has only a root `CLAUDE.md` creates `AGENTS.md` too (assistants other than Claude Code + read no `@` import out of `CLAUDE.md`); a refresh creates no root file and instead prints one + advisory line naming the missing `AGENTS.md`. A new "Calling the + generated REST API" block gives the filter form (`?filter[status][eq]=active`, never + `?status=active`) with its nine operators, sorting and paging (including each port's default + when `limit` is omitted), and the error bodies. To offset it, the Java and Kotlin generator + class lists, the TypeScript catalog pipeline and the prompt and report rules moved behind the + skills they already pointed to. Measured on the agent-context conformance stacks (C#, + Java + React, Java + Kotlin + React + TanStack, Python, TypeScript + React + TanStack), the + file an assistant loads each session is 5,580 / 6,045 / 6,705 / 5,585 / 6,572 bytes, from + 4,978 / 5,767 / 6,731 / 4,983 / 6,207: the REST block adds more than the moved detail takes + out. The always-on bytes written to disk fall by 44 to 50% because the copy is gone. The C#, + Java and Python staleness notices no longer name `.claude/skills`. +- **Breaking, TypeScript: a value object is never renamed; one claim registry refuses real + collisions** (amending ADR-0044 and ADR-0056). `acme::alpha::Note` is declared as `Note` in its + own module; the `AcmeAlphaNote` derived name, `assignEmittedNames` and its + `ERR_PAYLOAD_NAME_COLLISION` backstop (`naming/collision-names.ts`) are removed — the + entity-tier `ERR_COLLECTION_NAME_COLLISION` pre-pass (`naming/collection-name-collision.ts`) + stays, refusing two objects that claim one collection name — + and `RenderContext.valueObjectNames` and `RenderContext.packageOf` are `@deprecated` identity + shims for one release. Each generator claims what it emits through + `ctx.claim(scope, name, claimant, remedy)`: `entityFile()` and `queriesFile()` a module's type + and collection names in its directory, `barrel()` its re-exports, the routes generators their + REST segments per entry. A second claimant fails with `ERR_NAME_COLLISION` (a codegen-time code + declared by `@metaobjectsdev/codegen-ts`), naming both. A file that meets two same-named value + objects binds each under a package-qualified local alias (`import type { Note as AcmeAlphaNote } + from "../alpha/Note.js"`); the extract tier's mirrors and mappers are named by that alias + (`AcmeAlphaNoteExtracted`). `valueObjectModuleSpecifier` takes the value object's node. + **Upgrade note:** two same-named value objects in two packages under the flat layout (or behind + a barrel) now fail with the collision error; set `outputLayout: "package"` (and drop the barrel, + or rename one), and update imports of the old `AcmeAlphaNote` names. An owned generator copy is + refreshed with `meta eject --list`. +- **`meta init` writes stricter defaults for a new project.** The scaffolded + `.metaobjects/config.json` now carries `"verify": { "handEdits": "fail" }` and (except on + MySQL) `"migrate": { "foreignKeyIndexes": true }`, each as its own visible setting, beside the + `api` block. `dotnet meta init` and `metaobjects init` now write the same `migrate`, `verify` + and `api` settings, so a new project starts the same in every port. An existing config is left + as it is. +- **Agent context routes report work to the reporting vocabulary.** The `meta init` agent guide + and the `metaobjects-authoring` skill now send grouped totals, dashboard numbers and read-only + report views to `object.report` (`references/declaring-reports.md`) before the `@sql` escape, + which they describe as the last resort for bodies the vocabulary cannot express. +- **`@metaobjectsdev/cli` no longer installs the native Biome binary.** `codegen-ts-react`, + `codegen-ts-tanstack` and the source-only `codegen-ts-angular` declared `@biomejs/biome` as a + peer dependency, which npm installs automatically, so every CLI install carried the ~94 MB + `@biomejs/cli-` binary that nothing runs: codegen formats through the WebAssembly + build (`@biomejs/wasm-nodejs`). The peer is gone (it stays a devDependency for this repo's own + lint gate), and a fresh npm install of the CLI drops from 245 MB to 151 MB of `node_modules`. + `scripts/check-peer-ranges.ts` now fails a publishable package that requires `@biomejs/biome` + through `dependencies` or a non-optional peer. +- **Release scripts: a patch can be cut from a `release/.` maintenance branch** + (brought from `release/1.2`, where 1.2.2 shipped this way). `scripts/release.mjs` and + `scripts/finish-release.mjs` accept that branch as well as `main`. The version must be on the + branch's own line, every push goes to that branch, and the sync check compares against it. + `release.mjs` also refuses, before anything is published, a version older than the newest + release and a release candidate of a version that already shipped, because either would move + npm's `latest` backwards. A minor or major cut is now refused while the previous maintenance + branch holds a commit that is not on `main`; `docs/RELEASING.md` Step 0 gains the same check. +- **`@metaobjectsdev/cli` no longer installs `dprint-node`.** The TypeScript generators printed + code with `ts-poet`, which loads `dprint-node` on import, and dprint-node ships all seven of + its platform binaries in one package (24 MB, of which a machine runs one). `codegen-ts` now + vendors the part of ts-poet the generators use (`src/poet.ts`, Apache-2.0, licence in + `LICENSE.ts-poet`) and runs the same dprint TypeScript plugin as WebAssembly + (`@dprint/typescript`, pinned to 0.87.1, the version dprint-node 1.0.8 compiles in, 5 MB) with + ts-poet's configuration, so generated code is byte-identical: every codegen golden and + conformance fixture is unchanged. `codegen-ts-react`, `codegen-ts-tanstack` and + `codegen-ts-angular` drop their `ts-poet` dependency and import the printer from + `@metaobjectsdev/codegen-ts/engine`, which an ejected template also uses. A bare `ts-poet` + import in an older owned generator is still pointed at that entry by `meta gen`, which + carries `code`, `imp`, `joinCode`, `Import` and the `Code` type; ts-poet's `def`, `literalOf`, + `arrayOf`, `asOneline`, `Import.fromMaybeString`, `saveFiles`, `conditionalOutput` and its + `toString` import options are not carried over, so an owned generator that imports one of them + no longer loads. A fresh npm + install of the CLI drops from 151 MB (134,641,989 bytes) to 133 MB (115,302,944 bytes) of + `node_modules`. `scripts/check-peer-ranges.ts` now also fails a publishable package that + requires `dprint-node`, `ts-poet` or any `@types/*` package through `dependencies`, + `optionalDependencies` or a non-optional peer; a type package a published `.d.ts` imports goes + in its `ALLOWED_TYPES_DEPS` + with the reason. No `@metaobjectsdev/*` package declares `@types/node`: the 3 MB copy in the + install comes through the libSQL driver (`@libsql/isomorphic-ws` → `@types/ws`), which is + unchanged here. This also repairs the standalone binary (`bun run build:binary`): `--compile` + cannot embed dprint-node's native `.node` file, so a binary built from 1.2.0 crashed with + `Cannot find module './dprint-node.linux-x64-gnu.node'` on every command that loads the + codegen engine, `meta migrate` and `meta verify --db` included. Those schema commands, the + binary's documented scope, now run; `meta gen` is still not supported inside the binary. +- **Test databases stay off the drives.** Every Docker-backed database launcher in every port + (the TypeScript `integration-tests` Postgres, MySQL and Cube containers; the Python MySQL and + Postgres launchers; the C# MySQL and Postgres runners; the Java and Kotlin Testcontainers + classes; the services and sidecars in the integration-test and local-CI workflows and + `scripts/ci-local.sh`) mounts a 2 GiB tmpfs at the image's `VOLUME` path, and Postgres runs + with `fsync`, `synchronous_commit` and `full_page_writes` off. Each container is removed when + its run ends: by `--rm`, by Ryuk when a killed process never reaches its own cleanup, and by an + exit or SIGTERM handler that also removes anonymous volumes. The Stryker mutation gate for the + metadata package builds its sandbox under `$DEV_SCRATCH` (the system temp directory when unset) + and stops its test runners with it. Contributor steps are in [CONTRIBUTING.md](CONTRIBUTING.md). + +### Deprecated + +- **C#: `ValueObjectNames.Names(root)`.** A value object is never renamed, so it now returns the + identity map (resolution key to PascalCase name) and is `[Obsolete]` for one release, matching + the TypeScript and Python shims. Use `ValueObjectNames.TypeName(obj, root)`. + +### Fixed + +- **The Java loader loads a large model.** Each child added to a node was checked against a + list of the keys already added, so a root with 1,160 objects took more than the 30-second + timeout to load and failed. The check is a set lookup now, and a reference resolves through + the per-type name index instead of a scan of the root. Twenty copies of the canonical + conformance model (1,160 objects) load in about 2 seconds of CPU, and `LargeModelLoadTest` + holds that to a budget. Java and Kotlin. +- **`gen ` no longer shrinks the files rendered from the whole model.** Narrowing a run + to some entities (`meta gen Post`, Python `metaobjects gen --entities Post`) handed every + generator only the named entities, so a whole-model file (the TypeScript barrel and Cube + model, Python's shared enums module, duration codec and report writers, and the object index + Python's entity and route generators resolve relations through) was rendered from just them. A narrowed run now writes only the named entities' own files, + and every whole-model file it writes is byte-identical to a full run's. A generator sees the + whole model in `ctx.entities` and the narrowing as `ctx.selected`; `perEntity` (`per_entity`) + applies it. A Python target's declared `entities` still bounds that target's model. The C# and + Maven entity selection added in this release follows the same rule. Two consequences to expect: a narrowed run + checks the whole model as a full run does (a sourced object with no `dialect`, colliding + collection names), because the files it writes are rendered from it; and an owned generator + that writes one file per object by looping over `ctx.entities` itself, instead of through + `perEntity`, now sees every object, so it should set each file's `sourceNode` (the runner + then drops the unnamed objects' files) or apply `ctx.selected`. +- **`gen` writes `.hashes.json` once per run, and not at all when nothing changed.** TypeScript, + Python and C# re-read and re-wrote the whole manifest after every generated file, so a run of + N files wrote it N times; they now hold it in memory for the run and write it once, as Java + already did. Python's `metaobjects gen` output changes, which matters to a script that parses it: + it now lists only the files it wrote, and its summary line counts the files it left as they + were (unchanged or skipped) separately instead of reporting them as written. A run that + fails still records the files it wrote before failing, and a failed manifest write then no + longer hides the error that stopped the run. +- **`meta gen` loads the metadata once.** The unknown-attribute warning re-loaded the project + strictly on every run; it now reuses the generation load and parses strictly again only when + the lenient load reported an unknown bare key. `meta gen` also no longer imports a database + driver: the migration advice it prints reads `@metaobjectsdev/migrate-ts/offline`, a new + subpath with the schema builder and diff and none of the introspection or apply code. + +- **A projection view keeps the columns a reverse `@via` hop feeds.** An origin `@via` that walks + an `identity.reference` backwards (`Project.timeEntries`, #560) loaded, but `meta migrate` left + its `origin.aggregate` / `origin.first` columns out of `CREATE VIEW` without a word. The view + emitter now resolves the hop the way the loader does and joins from the holder of the + reference. Gated by a Postgres test that creates the view and reads it. +- **`origin.aggregate` `sum`/`avg`/`min`/`max` over a value-object field is refused at load.** + `@of: Invoice.total` on a flattened Money field loaded and emitted `SUM(i.total)`, a column that + does not exist. Every port now refuses it with `ERR_INVALID_ORIGIN` and says to aggregate a + scalar field; gated by the `error-origin-aggregate-value-object` conformance fixture. Refusing, + rather than summing the flattened amount column, keeps a sum from adding amounts in different + currencies. `count` is unaffected. +- **A long foreign-key index or constraint name no longer reappears on every `meta migrate`.** + `migrate.foreignKeyIndexes` named an index `
__idx` with no length check, and + Postgres stores a name over 63 bytes cut to 63, so the diff (which compares names exactly) + proposed the index again on every run. On Postgres the name is now cut to the 63 bytes Postgres + stores (SQLite and D1 keep it whole), and the C# EF context and the Kotlin Exposed tables + declare the same cut name. The diff also matches a foreign-key constraint by its stored name, + so a derived `
__fk` over the limit is no longer proposed as a rename. A new + shared corpus, `fixtures/foreign-key-index-conformance/`, pins which foreign keys get an index + and its name, and the TypeScript, C# and Kotlin rules all pass it; two migration scenarios + prove a long name converges on Postgres. A declared `index.lookup` or `identity.secondary` + name, and a `@unique` field's derived `
__unique`, is created under the name + Postgres stores in the same way, so it no longer reappears on every run either. The Drizzle + tables, the EF context and the Exposed tables declare that cut name too; the shared corpus + pins it with a long `index.lookup` and `identity.secondary` (`declared..json`). +- **`mvn metaobjects:verify` refuses the model `mvn metaobjects:generate` refuses.** Two metadata + packages that generate into one output directory (`ERR_NAME_COLLISION`) and a REST collection + claimed twice (`ERR_COLLECTION_NAME_COLLISION`) were checked by the generate goal only, so a + project could verify clean on a model generate would refuse. Java and Kotlin. + - **The rc.21 view vocabulary: what a projection needs to replace a hand-written `@sql` view.** Every construct is closed and typed, never free SQL; the TypeScript view emitter lowers them on Postgres and SQLite (SQLite spells each with its own functions, or refuses what it cannot mean), @@ -220,6 +634,402 @@ vocabulary; upgrade every port together. (`ERR_BAD_ATTR_VALUE`) in every port. A declared CHECK name another constraint on the table already has, or one over 63 bytes on Postgres, is refused by `meta migrate` and `meta verify` (`ERR_CHECK_NAME`). See `docs/features/migrations-and-drift.md`, "CHECKs from validators". +## [1.3.0] — 2026-11-11 + +_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, +`@collectionName`, the `case` and `now` expression nodes, `@segment` on `origin.first` / +`origin.aggregate`, and the `isDistinctFrom` / `isNotDistinctFrom` filter ops) 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"]`: +the JVM runtime both share acts on it). The manifest's row +set grows by the `implementedIn` rows that used to be carved out. A port that reports `1.2` does not +know that vocabulary; upgrade every port together. + +### Upgrading from 1.2.0 + +Each item below is described in full under Added, Changed or Fixed; this list is where to start. + +- **`validator.atLeastOne` takes no `@max`.** A model that carries `@max: 1` on an `atLeastOne` + fails to load; a rule meaning "exactly one of these fields" is the new `validator.exactlyOne`. +- **C# durations on the wire.** A `field.duration` is written in each language's standard form + by default (`TimeSpan`'s `"01:30:00"` in C#). A project that wants ISO-8601 (`"PT1H30M"`) in + every port sets `"wire": { "durations": "iso" }` in `.metaobjects/config.json`. +- **Breaking, C#: `ColumnNamingStrategy` and `TableNamingRule` are classes, not enums.** The + built-ins keep their names and `Pascal` is new; code that switched on them or used them as + constants needs the change described under Changed. The new `pascal` column rule is opt-in + (`"naming": { "columns": "pascal" }`). +- **Deprecated: `tsOnly` in `meta types --format json`.** It is still emitted through 1.3.x, + derived from the new `implementedIn`, and is removed in 1.4. Read `implementedIn` instead. +- **A template that names a variable not on its payload now raises at render time** instead of + rendering the variable as empty. Regenerate, and fix the name the error reports. +- **C#, EF Core migrations.** The first `dotnet ef migrations add` after upgrading scaffolds the + indexes, comments and CHECK constraints the context now declares. A Postgres context gets + generated design-time services that scaffold a changed `@sequenceStart` safely; in EF's default + layout they need no code, and `dotnet meta gen` prints the one line to add when the migrations + live in another project. A self-hosted codegen runner sets `GenConfig.Dialect`. A nullable enum + with `@default` now starts at its default instead of NULL. See the C# upgrade notes under + Changed. +- **A changed `@sequenceStart` moves an existing counter forward only.** It records the start and, + when the next id would be below `GREATEST(start, max(id) + 1)`, moves the counter there. It never + restarts and never moves a counter back. +- **A value object is never renamed.** One that shared its short name with a value object in + another package used to be generated under a package-qualified name (`AcmeAlphaNote`); it now + keeps its own name everywhere. Two objects that would emit one name into one scope are refused + with `ERR_NAME_COLLISION`, naming both. Place them apart: `outputLayout: "package"` in + TypeScript and Python, `csharp.packageNamespaces` in C#. Java and Kotlin never renamed. +- **`meta init` and `metaobjects init` scaffold the package output layout.** New projects get + `outputLayout: "package"` (one directory per metadata package); `dotnet meta init` writes the + matching C# keys. An existing project changes nothing: the engine default stays flat. +- **`@dbSetName` is `@collectionName`.** The attr was never published under its first name, so + there is no alias: a model that set `@dbSetName` in a pre-release build renames it. +- **`metamodelVersion` is `1.3`.** Upgrade every port together. + +### Added + +- **A working loop first in the agent context.** The always-on file `meta init` scaffolds + (`.metaobjects/AGENTS.md` and `CLAUDE.md`) now opens with the whole loop for the declared + stack, in order: configure and run the generators (one step per declared server, with the + import or class names to wire, plus the web client when one is declared), the schema + (`meta migrate --from-db` for the first migration, `apply-pending` at boot, and a later + change with `--rename-column`, `--rename-table` and `--allow`), requirements, and the verify + commands to run before calling work done. It shrinks from about 19 KB to about 5 KB. The + principles it carried move, word for word, to `metaobjects-codegen/references/principles.md`, + and the port-sync and upgrade paragraphs to `metaobjects-verify/references/upgrading.md`. It + no longer tells an agent to read a skill's `SKILL.md` by path, and says the loop needs no + skill. The skill trigger evals gain mid-task cases. +- **`meta init --dialect sqlite|postgres|mysql|d1`.** Writes the codegen `dialect` and, for + sqlite, postgres and d1, `migrate.dialect`, and the next steps print that dialect's first + migration. `--dialect d1` is `--d1`; the two together with different dialects are refused. + MySQL is codegen only, as before: the next steps say `meta migrate` does not own its schema. +- **`meta gen` names `requirementTests()` when nothing tests the requirements.** A model that + declares `requirement.*` nodes, with no `requirement-tests` generator wired, gets one advisory + line naming the import. The exit code is unchanged. + +- **Cross-port vocabulary that only some ports implement so far (`implementedIn`).** A registry + type or attr may name the ports that implement it so far (`"implementedIn": ["typescript"]` on + its `spec/metamodel` entry, carried into the registry manifest). It is still cross-port + vocabulary: every port registers it and loads it strictly, and a port that has not implemented + it ignores it. The 13 generic `view.*` controls, `view.textarea @rows` and the five `view.image` + attrs are `["typescript"]`; `object.* @object` is `["java"]`. They used to be carved out of the + manifest (`PRESENTATION_ONLY`, `NATIVE_BINDING`); both carve-outs are gone, and the registry + canonical grows by those rows. `meta types` marks them `[ts; pending elsewhere]` / `[java; + pending elsewhere]` (it used to say `[ts-only]`, "the cross-port contract does not carry it"; its + JSON change is under Changed), and the metamodel docs now cover the view controls. + `@objectAdapter` is port-scoped (`"ports": ["java", "kotlin"]`, below). C#, Java, + Kotlin and Python now register the `metaobjects-ui-web` attrs (`view.textarea @rows` and the + `view.image` attrs), and C# and Python register `@object` / `@objectAdapter`, so a model that + uses any of them loads strictly in every port. Gated by the conformance fixtures + `view-kind1-controls`, `object-kind1-jvm-binding-attrs` and + `error-kind1-view-unregistered-attr`, and by the registry canonical. +- **Port-scoped vocabulary.** A registry attr may name the ports + that act on it (`"ports": ["java", "kotlin"]` on its `spec/metamodel` entry, carried into the registry + manifest). Every port registers and type-checks it, so a model that carries it loads under every + port's strict loader; a port not named does nothing with it. An attr the registry does not carry + still fails, and a wrong value type fails in every port (Java now refuses a list given to a scalar + string attr, as the other ports did). `meta types` marks such an attr `[java+kotlin]` (one port: + `[csharp-only]`) and its JSON carries `ports`. `@objectAdapter` is the one there is. +- **`@collectionName`, and the `naming.collections` pluralizer.** An `object.entity`, + `object.projection` or `object.report` may name its collection in its own casing + (`"@collectionName": "CaseHistory"`); it need not be a grammatical plural. In every port it + names the REST collection segment, snake_cased with an acronym-aware split (`FAQs` serves + `/faqs`, shared by `fixtures/naming-conformance/collection-segments.json`, which every port + runs), and the api reference and report export follow it. In C#, TypeScript and Python it also + names the reverse finders (Java and Kotlin name a finder by its foreign-key field); in C# the + DbSet property (in place of the derived plural, which the api reference reads through it), and + in TypeScript the list function, the list hook and the Drizzle table variable. Two objects whose collection names meet are refused by name. A project that declares + neither the attr nor `naming.collections` keeps every generated name and URL. Absent, the project's + pluralizer derives the name: `"naming": { "collections": "standard" }` (the default) or `"none"` + in `.metaobjects/config.json`, or one the application registers (`registerPluralizer` in + TypeScript, `NamingStrategies.RegisterPluralizer` in C#, `NamingStrategies.registerPluralizer` in + Java, `register_pluralizer` in Python). Every port registers the attr and reads the key, and + refuses an unknown pluralizer when it reads the config. +- **Reverse `@via` hops.** An origin's `@via` hop may walk an `identity.reference` backwards, from + the entity it targets to the entity holding it, named by the holder's collection name in lower + camel case (`Patient.consents` walks `Consent.patient`; a declared `"@collectionName": + "CaseHistory"` gives `Case.caseHistory`). The hop is to-many, so a passthrough across it is + refused and an aggregate over it is allowed, and two references that answer one name are refused + (`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 its `operand`, so an enum or long operand maps + its codes to labels. A literal compared with a field, as a `when` against a field operand or + on either side of a comparison, must be of that field's kind and, for a `field.enum`, one of + its `@values`, the rule a validator `@condition` already follows (`ERR_INVALID_ORIGIN`, + `error-origin-computed-literal-not-enum-member`, `error-origin-computed-literal-wrong-kind`). + A `case`'s results and a `coalesce`'s arguments unify a whole-number + literal with any numeric field, a fractional literal only with a `field.double`, `field.float` + or `field.decimal` (refused beside a long, int or currency field, + `error-origin-computed-literal-fractional`), 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. +- **Segments and correlated filters on origins.** An `origin.first` / `origin.aggregate` may scope + its related rows by a `@segment` declared on that entity (`ERR_INVALID_ORIGIN` otherwise), and + its `@filter` may compare a related column with a base-row field (`{ "eq": { "field": + "statusId" } }`, or the null-safe `isDistinctFrom` / `isNotDistinctFrom`, which take only such an + operand; `ERR_BAD_ATTR_FILTER` for an unknown base field or another op). Every port's loader + validates them (`origin-segment-scoped`, `origin-correlated-filter-and-segment`, + `error-origin-segment-unresolved`, `error-origin-correlated-operand-unknown`). +- **Filter paths, flattened members and inherited filters in projections.** A projection's + `@filter` key may name a field of its base entity the view does not output, or a path of to-one + hops from the base. A projection that extends another is checked against the effective (ANDed) + filter of its chain. An origin's `@from` / `@of` may name a member of a flattened value object. + Every port's loader validates them, gated by eleven new shared fixtures. A report dimension's + required flag now treats an unenforced reference, or a hop onto a TPH subtype, as possibly + missing. +- **A view the lowering cannot express is refused, not shortened.** The TypeScript view extractor + skipped any origin it could not lower, so a projection loaded clean and `meta migrate` created a + view missing a column its generated type declares. Each such shape now fails, naming the + projection and the field: an aggregate-derived entity field read where a row-level value is + needed, a computed reference cycle, a relative date on a field that is not temporal, and an + unknown origin or aggregate. +- **The view vocabulary lowers to SQL.** `meta migrate` builds every port's views, and it now + writes the shapes the loaders accept: an entity's derived `origin.first` / `origin.computed` + field is inlined wherever a projection reaches it (a `@filter` key or path, a passthrough + `@from`, a field bound with `extends`); an origin's `@segment` is ANDed with its `@filter`; + a base-row operand compares in place, with `isDistinctFrom` / `isNotDistinctFrom` written as + `IS [NOT] DISTINCT FROM` on Postgres and `IS NOT` / `IS` on SQLite; relative dates lower in + projection and origin filters; searched and simple `case` and a `now` leaf lower in a computed + expression, and a computed field may read the projection's other fields. +- **A reference over a flattened member reads the member's column.** A reference whose `@fields` + names a member of a flattened value object (`"address.countryId"`) now resolves to that member's + real column in the foreign key `meta migrate` emits, a view's join, a passthrough `@from` onto + the member, and the Drizzle key the reverse finder and `relations()` block read. Two references + onto one target now each read the join their own `@via` walked, rather than the first join to + that entity. +- **One wording for a to-many passthrough, in every port.** The refusal of a passthrough across a + reverse `@via` hop names the hop as the path wrote it and the reference it walks + (`@via hop "consents" is to-many (reverse hop over identity.reference "patient")`), and Java's and + Python's wording of the refusal now matches the other ports'. The fixtures + `error-origin-passthrough-reverse-hop` (new) and `error-origin-passthrough-to-many` pin the + message. + +- **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 + failing with `ERR_ENUM_INT_VALUE_MAP_ARRAY`, which is removed. Each element is stored as its + declared integer and read back as its member: `integer[]` on Postgres, and a JSON array of + numbers on SQLite, D1 and MySQL. A stored integer that maps to no member fails the read, as + it does for a scalar. The refusal had a cost beyond arrays: the map is read through + `extends`, so one map on a shared enum blocked every scalar column that used it whenever any + array field shared the enum too. Per port: + - TypeScript: ObjectManager and the generated Drizzle columns map elements on every engine + (Postgres through the element codec under `.array()`, SQLite and MySQL through a whole-array + JSON codec). An unmapped member throws on write, because the array column has no `CHECK` + to reject it. `meta migrate` already produced `integer[]`. + - C#: the generated array conversion now compiles (it wraps the pair in a `ValueConverter`), + the `UnmappedEnumValue` helper is emitted when a flattened value object's array member is + the only int-backed enum, projection and report-row enum arrays get the element converter + (they read stored ints as ordinals before), and a non-required int-backed enum array is + nullable. + - Python: ObjectManager maps elements on write, read and filter operands on Postgres. Its + SQLite and MySQL dialects store no primitive array, so the new scenario is deferred there. + - Java: OMDB stores no enum array on any engine, so its codec refuses an int-backed one on + write and read instead of writing symbols. Kotlin's Exposed table generator emits a scalar + column for an enum array, so generated code for an int-backed enum array does not compile + yet (see `KNOWN_GAPS.md`). Both defer the new scenario. + Gated by the positive conformance fixtures `enum-int-backed-array` and + `enum-int-backed-array-inherited`, and the persistence scenario `roundtrip-int-enum-array`. + +- **A shared model can carry its requirements, and a consumer can inherit them (FR-023).** The + publisher's `shared-model` generator takes `requirements: true` (TypeScript `sharedModelFile`, + the Java/Kotlin generator arg `requirements`, C# `SharedModelGenerator.Requirements`; default + off) and then publishes the selected `requirement.*` nodes beside the model they describe; a + requirement claiming a node outside the selection is refused at publish. `template.*` is never + published. On the consumer side, `requirements.inherit` in `.metaobjects/config.json` names the + dependency packages whose requirements join the project's ledger, by the same explicit-include + rule as `scope.include` (`**` names nothing). A dependency's requirement that is not inherited + still loads, so an overlay of it resolves, but the requirement gate, its summary and lint, the + `requirement-tests` generators and the requirements pages leave it out; `requirementTestIdentities` + (TypeScript) and `requirement_test_identities` (Python) take the collection's ledger predicate + as `inLedger` / `in_ledger`, as the generator does. An imported requirement never switches object + coverage on, inherited or not, as a library's never does. Every port reads the key (TypeScript, + Python, Java, Kotlin through Java, C#). A consumer on an older toolchain treats a published + requirement as its own, so upgrade consumers before publishing with `requirements: true`. See + `docs/features/metadata-dependencies.md`, "Inheriting a dependency's requirements". + +- **`maven` and `nuget` dependency transports (FR-023).** `meta deps sync` and `meta deps check` can + now read a shared model out of a published package that is already in the local cache, so a JVM or + .NET consumer no longer needs the publisher's directory on disk. `{ "name": "x", "maven": + "com.acme:model", "version": "1.0.0" }` reads the jar in the local Maven repository (honouring + `$MAVEN_REPO_LOCAL`, `-Dmaven.repo.local`, `settings.xml`'s ``, then + `~/.m2/repository`); `{ "name": "x", "nuget": "Acme.Model", "version": "1.0.0" }` reads the package + in the NuGet global packages folder (`$NUGET_PACKAGES`, else `~/.nuget/packages`). Both read the + manifest and artifact from the package's `metaobjects/` directory (`dir` changes it), write the same + snapshot and lock entry a `path` sync writes, and refuse a package that is not cached with the + coordinates and the command that fetches it (`mvn dependency:get`, `dotnet restore`); nothing is + downloaded. The config and lock readers in Java, Kotlin, Python and C# accept the new keys, and + their `check` reports such a dependency `unresolved` and names the Node `meta deps check`. + `dependency-conformance` gains 2 resolution cases and 18 transport cases. +- **Java, Kotlin and C#: publish a shared model (FR-023).** A `shared-model` generator in every one + of the three ports writes the artifact `.metaobjects.json` and the manifest + `metaobjects.pkg.json`, byte-identical to the TypeScript `sharedModelFile()` and gated by + `fixtures/shared-model-conformance/` (the engine is `SharedModel` in the Java `metadata` module + and `MetaObjects.Config.SharedModel` in C#). Java and Kotlin run it through `metaobjects:generate` + (version from the project's ``) and eject it with `mvn metaobjects:eject`; C# declares + `SharedModelGenerator` in `codegen/Generators.cs` (version from ``) and ejects it with + `dotnet meta eject shared-model`. `generator-registry-conformance` now lists `java`, `kotlin` and + `csharp` under `shared-model`. The Node `meta deps sync` remains the only writer of the lock and + the snapshot. +- **Java and Kotlin: a Spring app loads a shared model's committed snapshot at runtime, and + `metaobjects:verify` checks dependency drift.** `metaobjects:generate` now ships + `.metaobjects/deps.lock.json` and `.metaobjects/deps/**` as resources (target path `.metaobjects`) + when the project has a lock. When `classpath:.metaobjects/deps.lock.json` exists, the Spring + application loader loads each snapshot before `metaobjects.metadata-sources`, verified as the build + does (`ERR_DEPENDENCY_SNAPSHOT_STALE`, `ERR_DEPENDENCY_PACKAGE_NOT_OWNED`), so an entity that + `extends` an imported node boots; an imported node stays load-only. With no lock and nothing + declared, nothing changes. `mvn metaobjects:verify -Dmeta.verify.mode=deps` re-resolves each + declared `path` dependency, hashes its artifact against the lock and fails with + `ERR_DEPENDENCY_UPSTREAM_DRIFT` when it is `drifted` or `unresolved`, passing the shared + `expectCheck` corpus arm; it is opt-in and not part of the default gate set. New public API: + `Dependencies.check`, `Dependencies.SnapshotReader`, `DependencySet.ofSnapshot` and a + `MetaDataLoader.fromUris` overload that takes a `DependencySet`. See `docs/features/metadata-dependencies.md`. + +- **Python and C# check a shared model against its publisher (FR-023 Phase 2).** `metaobjects deps + check`, `metaobjects verify --deps` (Python) and `dotnet meta verify --deps` (C#) re-resolve each + declared dependency's `path`, read the publisher's `metaobjects.pkg.json`, hash the artifact and + compare with `deps.lock.json`, with the same three states as `meta deps check` (`current`, + `drifted`, `unresolved`) and the same `ERR_DEPENDENCY_UPSTREAM_DRIFT` exit for anything else. + Both run the 11 `expectCheck` cases of `fixtures/dependency-conformance/`. The check writes + nothing, is never part of a bare `verify`, and resolves the `path` transport only: an `npm` or + `python` dependency reports `unresolved` and names the Node `meta deps check`. In C# it runs + before the metadata loads, so a dependency declared but not yet synced is reported `unresolved` + first (the check exits 1); the load that follows still refuses the missing or stale snapshot with + `ERR_DEPENDENCY_SNAPSHOT_STALE` and exit 2. The Node `meta deps sync` stays the only writer of the lock and the + snapshot. See [docs/features/metadata-dependencies.md](docs/features/metadata-dependencies.md). + +- **A model explorer site, built by `docsSiteFile()`.** The docs site now shows what the + software does and how the model is designed: a main page with count tiles and the feature and + quality cards with their roll-ups, a model map with slices (package, requirement subtree, + prompt) and colour-by (kind, API, claims, capability, status), a page per object, projection, + report, prompt and requirement with a one-hop mini-map, the traceability matrix, a trace from a + requirement to the files generated from it, the API index and a gaps page. Every page is drawn + from `explorer.json`, which the generator builds in the same run from the loaded model, the + requirement gate's ledger, the files the run wrote and the routes it mounts; it runs after the + other generators wherever it is listed. Declared status is a filled chip with its glyph, gate + verdicts are outlines, roll-ups are bars, and no colour reports a test result. Pages are marked + for Pagefind, work at phone width, depend on the model alone (so `meta verify --codegen` holds + them) and are link-checked. The graphs load Cytoscape.js from `assetBase`. `meta eject + docs-site` now copies the explorer's `explorer-*.mustache` templates and `explorer.css` / + `explorer.js` beside the classic theme. `buildExplorer` takes an optional `routes` input, and + nodes carry their declaration `order`. Each `requirements.rows` entry in `meta verify + --format json` now carries `node`: the entity's resolution key on a + `WARN_REQUIREMENT_OBJECT_UNCLAIMED` row, `""` on every other row, and each finding in a + `requirementLedger` row carries its `message`. See `docs/features/explorer-site.md`. + +- **Generated record models enforce the cross-field validators in every port.** + `validator.comparison`, `validator.requiredWhen`, `validator.presentIff`, + `validator.atLeastOne` and the new `validator.exactlyOne` used to render only as DB `CHECK` + constraints, so a store with no `CHECK` support (a graph or document database) enforced none of + them and the application had to repeat the rules in its writer. The full create/insert model now enforces them with the language's native + mechanism: a Zod refinement on the insert schema (TypeScript), a class-level Bean Validation + constraint on the create DTO (Java, Kotlin), `IValidatableObject` (C#) and a Pydantic + `model_validator` (Python). Semantics mirror the `CHECK` derivation: null-safe, `comparison` passes + when either side is null, `@equals` is read per the gating field's subtype, and a rule with a + `@condition` is checked only when the condition is true (false or null lets the record through, as + the `CHECK`'s `NOT (condition) OR (rule)` does). PATCH and + partial-update models are unchanged (a partial body cannot see the merged row, so the database + `CHECK` remains the enforcement there), and `CHECK` emission is unchanged. A record that violates a + declared rule is now rejected at the model where it used to reach the database. Gated by + `fixtures/validation-conformance/cross-field-cases.json` in all five ports. + +- **Two providers can no longer claim one attribute name on a node type.** The registry now + records which provider registered each attribute and refuses a second provider's claim at + composition, in all five ports (TypeScript, Python, C#, Java, Kotlin). A repeat on the same + `(type, subType)` keeps `ERR_PROVIDER_ATTR_CONFLICT` (its message now names the owner); a name + another provider already holds on the shared root or a descendant subtype is the new + `ERR_PROVIDER_ATTR_SHADOW`. The refusal names both providers and the attribute, whichever + registers first, and leaves nothing in the registry. The same provider repeating its own name, + sibling subtypes sharing a name, and registration outside a provider all stay legal. The shipped + core providers have no such collision, so existing projects see no change. `meta types --detail` + prints the registering provider beside each attribute, and its JSON carries a `provider` field. + A common attribute is accepted on every node type, so it counts as a claim on every slot: a + second provider registering a common attribute name another provider holds, as a common + attribute or on any type, and a provider declaring a per-type attribute whose name another + provider registered as common, are both `ERR_PROVIDER_ATTR_CONFLICT`, in either order (two + common registrations used to be first-wins). The registry records each common attribute's + provider. Java's core providers no longer declare a per-type `@description` beside the + documentation provider's common one (same type, same meaning); `@description` is still accepted + on every node. This is how per-paradigm physical-name words (`@column`, `@field`) stay safe as + providers multiply; no wire-name attribute is added. See ADR-0062 and + `docs/features/extending-with-providers.md`. New conformance fixtures: `attr-shadow-inherited`, + `attr-shadow-descendant`, `attr-shadow-extend`, `common-attr-conflict`, + `common-attr-per-type-after`, `common-attr-per-type-before` and the `attr-ownership/` sub-corpus. Fixes #527. + +- **`field.duration`: a fixed-length span of time, in every port.** `TimeSpan` in C#, + `java.time.Duration` in Java and Kotlin, `timedelta` in Python, and a string in TypeScript; + a Postgres `interval` column, and a 64-bit integer of microseconds on SQLite, D1 and MySQL, so + sorting and range filters follow the span on every database. On the wire each port writes its own + language's standard form by default; `"wire": { "durations": "iso" }` makes every port write one + canonical ISO-8601 form (`PT1H30M`, `PT26H`, `-PT1M30S`, `PT0S`) at its own precision: as many + fractional digits as its duration type holds (6 in TypeScript and Python, 7 in C#, 9 in Java and + Kotlin). The database keeps microseconds, so a C#, Java or Kotlin server can answer a POST with + more digits than it stored; read the row back for the stored value. A week is 7 days and a day 24 + hours; years and months are refused. Postgres does not accept a + signed ISO-8601 duration as input, so a value bound as text, and a declared `@default`, use + its own `HH:MM:SS` spelling, which it returns unchanged. Filters: every numeric operator. + Shared vectors in `fixtures/duration-wire/`; see `docs/features/field-types.md`. Each port is + limited only by its own duration type and each database by its own column. + - **`wire.durations`: `"native"` (default) or `"iso"`**, beside `decimals` and `nullMembers` in + `.metaobjects/config.json` (ADR-0019 Amendment 2). `native` is the language's own serializer, + both ways: System.Text.Json's `TimeSpan` form in C# (`"01:30:00"`), `Duration.toString()` in + Java and Kotlin, Pydantic's `timedelta` form in Python (which folds 24 hours into a day, + `"P1DT2H"`), and the canonical string in TypeScript. `iso` is the canonical form in every port. + A filter operand is ISO-8601 in both modes. **Upgrade note:** a C# project that wants + ISO-8601 durations on the wire (`"PT1H30M"`) sets `"wire": { "durations": "iso" }`; without + it, C# writes `TimeSpan`'s own form (`"01:30:00"`). The api-contract and persistence corpora pin `iso`, + and a new `api-contract-conformance/duration/` sub-corpus gates it through every port's + generated routes on Postgres and SQLite (and MySQL and D1 where a port has them). + - An owned (ejected) generator copy from before this release does not know `field.duration`: + re-eject it (`meta eject --force`, or merge) before a model uses one. Models without a + duration are unaffected. + - A live Postgres `interval` column modelled as a `field.string`, the only way to model one + until now, is still read as text by `meta migrate` and `meta verify`, so it does not become + drift. Change it to `field.duration` to get the native column and type. +- **CHECK names, conditions and "exactly one" from validators.** `@constraintName` on a validator + that generates a CHECK (`numeric`, `length`, `regex` and the cross-field validators), and on a + `field.enum` for its membership CHECK, names the CHECK `meta migrate` + generates, for a database whose CHECKs were named by hand. A cross-field validator + (`comparison`, `requiredWhen`, `presentIff`, `atLeastOne`, `exactlyOne`) takes `@condition`, an + expression over the entity's fields, so the rule holds only where it does. The new + `validator.exactlyOne` says exactly one of its `@fields` is present, and becomes a + `num_nonnulls(...) = 1` CHECK (a sum of presence tests on SQLite and D1). The generated create + model enforces both as well, in every port (see the record-model entry above): an `exactlyOne` + rule, and a conditional rule only where its condition is true. They are optional; a model without + them generates what it did. A `@condition` naming a field the entity does not have, one that is not + a boolean expression, one comparing a field with a literal of another kind (or with `null`), or an + `exactlyOne` naming fewer than two fields, is refused at load (`ERR_BAD_ATTR_VALUE`) in every port. + **Upgrade note:** `validator.atLeastOne` takes no `@max`; a rule meaning "exactly one of these + fields" is `validator.exactlyOne`, so a model carrying `@max: 1` on an `atLeastOne` fails to load + until the validator is renamed and the `@max` removed. A declared CHECK name another constraint on the table + already has, or one over 63 bytes on Postgres, is refused by `meta migrate` and `meta verify` + (`ERR_CHECK_NAME`). See `docs/features/migrations-and-drift.md`, "CHECKs from validators". - **Contract emitters: JSON Schema and OpenAPI generators (FR-022).** `jsonSchemaFile()` (`contract-schema`) writes JSON Schema 2020-12 for each object's read, create and update shapes, and a strict structured-output subset with `profile: "strict"`. `openApiFile()` (`openapi`) writes one @@ -322,6 +1132,122 @@ vocabulary; upgrade every port together. only where the column type does not already enforce the rule. A validator with a declared `@constraintName` keeps its CHECK. A malformed `checks` block is refused when the config loads. See `docs/features/migrations-and-drift.md`, "CHECKs from validators". + +- **The data spine for a model explorer.** These changes are data only. No screen reads the new + data yet. + - `meta export --effective` writes the effective canonical JSON. Every field, child and attribute + a node inherits through `extends` is written onto that node. + - `meta verify --format json` adds `requirementLedger`, one row per requirement. A row carries its + digest, each `@implementedBy` link with the node the gate resolved it to, the findings against + it, and a `clean`, `warn` or `error` verdict. Text output is unchanged. + - `meta gen` records, in `.hashes.json`, the node each per-entity file was rendered from: + `{ "hash", "generatedBy", "sourceNode" }`. `EmittedFile.sourceNode` lets an owned generator set + it, and `perEntity` sets it automatically. A file rendered from the whole model keeps the plain + hash entry. The field is not called `generator`, because on the JVM that word claims ownership. + - `@metaobjectsdev/docs-site` exports `buildExplorer` and `serializeExplorer`. Together they build a + deterministic `explorer.json` from those three inputs. The file holds nodes, typed edges, the + requirement ledger, the generated files for each node, and derived slices for each package, + requirement subtree and prompt. + + Gated by the new `fixtures/explorer-conformance/` corpus. See `docs/features/explorer-data.md`. + No metamodel vocabulary changes, and `metamodelVersion` does not move. +- **`@flattenedColumnPrefix`: name a flattened value object's columns.** On a `field.object` with + `@storage: "flattened"`, it replaces the default prefix (the field's column and `_`) verbatim; + `""` keeps the members' own column names. It sits on the embedding field because one value + object embedded twice needs two prefixes. Flattened column names now come from core naming in + every port (`resolveFlattenedColumnName` in TypeScript, `PhysicalNaming.ResolveFlattenedColumnName` + in C#, `ColumnNaming.resolveFlattened` on the JVM, `resolve_flattened_column_name` in Python), and + `meta migrate`, the Prisma schema, the C# EF mapping and the Kotlin Exposed tables all use it. Set + on any other storage, it is refused at load (`ERR_FLATTENED_COLUMN_PREFIX_WITHOUT_FLATTENED_STORAGE`). + See `docs/features/field-types.md`, "Embedded value objects". +- **Names artifacts carry a flattened value object's member columns.** Each member of a + `@storage: "flattened"` value object is a column of the owning table, and the owner's names + artifact now has a constant for each, named by core naming: `fields.shipTo.members.street.column` + in TypeScript, `ShipToStreetColumn` in C#, `SHIP_TO_STREET_COLUMN` in Java and Kotlin, + `SHIPMENT_SHIP_TO_STREET_COLUMN` in Python, keyed `shipTo.street` in the column-by-field maps. + The generated EF Core and Exposed bindings spell these columns through the same core naming + function. A member constant + that would share its name with another constant is left out with a warning, so every model + that generated before still generates. In C# and Java, a names class no longer extends its + base's when that would make a base constant that is not a column of its own table reachable + through it (a flattened field redeclared as jsonb, say); it is emitted complete instead. +- **`@sequenceStart` and `@sequenceName` on `identity.primary`.** An `@generation: increment` + key's sequence can be given its first value and its physical name, so a model can reproduce a + table that keeps a low id range for seeded rows, or adopt a sequence that kept its name across + a table rename. On Postgres `meta migrate` creates + `GENERATED BY DEFAULT AS IDENTITY (SEQUENCE NAME "…" START WITH n)`, reads the live sequence + back from the catalog, and alters one whose declared start or name differs in place: a new + start is recorded (`ALTER SEQUENCE … START WITH n`) and the counter moves forward only, to + `GREATEST(n, max(id) + 1)` when it sits below that, never back and never by `RESTART`, because + live rows hold the ids it handed out; a new name is a rename. The persistence migration scenarios + `sequence-start-change-moves-counter-forward` and `sequence-start-change-below-max-id` pin both + cases on live Postgres. The Drizzle schema template carries the start and name in the identity + column's options, the C# context and the Kotlin Exposed table carry them too, and Java and + Python, which write no DDL, leave schema to `meta migrate`. Only what + the model declares is compared, on the live, shadow and snapshot paths alike, so a model that + declares neither sees no new change and writes the same SQL and snapshots. Every port + registers both attributes and refuses either without `@generation: increment` + (`ERR_SEQUENCE_WITHOUT_INCREMENT`) and a start below 1 or past the key's range + (`ERR_SEQUENCE_START_OUT_OF_RANGE`); a name two tables declare is refused as a duplicate + database name. See `docs/features/migrations-and-drift.md`. +- **A string-stored enum's column length: `@maxLength` on `field.enum`, and `enums.maxLength`.** + `@maxLength` on a `field.enum` makes its column `VARCHAR(n)`, and `"enums": { "maxLength": n }` + in `.metaobjects/config.json` gives every enum without one a default; with neither, the column + stays unbounded text, as before. The ports that size a column resolve the length through one + core function (`resolveEnumMaxLength` in TypeScript, `EnumLength.ResolveMaxLength` in C#, + `EnumLength.resolveMaxLength` on the JVM), and `meta migrate`, the Drizzle, Prisma, EF Core and + Exposed bindings use it. Python emits no column types, so it accepts the `enums` block and + sizes nothing. A member longer than the length is refused + (`ERR_ENUM_VALUE_EXCEEDS_MAX_LENGTH`): at load for `@maxLength`, when the column is sized for + the project default, which `meta migrate` and `meta verify` report by name. `@maxLength` beside + `@intValueMap` is refused at load (`ERR_ENUM_MAX_LENGTH_WITH_INT_VALUE_MAP`). A new shared + corpus, `fixtures/enum-length-conformance/`, pins the resolution in those ports. +- **A `pascal` column rule.** `"naming": { "columns": "pascal" }` in + `.metaobjects/config.json` upper-cases a field name's first letter and changes nothing else + (`createdAt` → `CreatedAt`, `requestURL` → `RequestURL`, `npi` → `Npi`, `address_line1` → + `Address_line1`), in every port. A schema whose columns are the field names with a capital + first letter (EF Core's default, for one) then needs `@column` only where the database spells + a name differently (`@column: "NPI"`). A column rule only; `literal` tables keep an object name + verbatim. See `docs/features/migrations/physical-naming.md`. +- **Your own naming strategies, in every port (ADR-0058 Amendment 1).** The column and table + rules are now named strategies in a registry each port's application extends, and + `.metaobjects/config.json` selects a registered strategy by name exactly as it selects a + built-in: `"naming": { "columns": "pascal-acronyms" }`. A strategy is a function from a name + to a name and may wrap a built-in in one line. Register it with `namingStrategies` in + `metaobjects.config.ts` (every `meta` command registers it before reading the config) or + `registerColumnNamingStrategy` / `registerTableNamingRule` (TypeScript), + `NamingStrategies.RegisterColumns` / `RegisterTables` (C#), + `NamingStrategies.registerColumns` / `registerTables` (Java and Kotlin), or + `register_column_naming_strategy` / `register_table_naming_rule` (Python). Codegen, the + runtime, `verify` (its naming probe tries registered strategies after the built-ins), + `meta migrate` and the view and docs generators all resolve through the registry; `@column` + and `@table` still win. A name no registered strategy answers is refused when the config is + read, with one message in every port naming the setting, the name, the port and what is + registered. A built-in cannot be replaced. The shared naming corpus registers the same two + application strategies in every port and resolves the same names. Every port resolves a + strategy by name each time it applies, so a strategy registered or replaced after the config was + read is the one used. A Python provider module (`providers:` in `metaobjects.config.yaml`) that + registers a strategy when it is imported is in time for the stock `metaobjects` console script, + which imports providers before it reads the config. The C# type change and Java's new exception + are under Changed. +- **Schema conventions for the database objects no code addresses.** `migrate.conventions` in + `.metaobjects/config.json` picks how `meta migrate` names primary-key and foreign-key + constraints, whether each foreign key gets an index, and whether a unique key an FK references + is a constraint or an index. `default` is what migrate has always emitted, so nothing changes + unless you set it. `efcore` reproduces EF Core's conventions (`PK_`, `FK_`, `IX_`, its + 63-character `~` truncation, alternate keys as constraints), so a database built by EF Core + migrations and one built by `meta migrate` match. A project can supply its own conventions + object from `metaobjects.config.ts`; an unknown preset name, or an object missing a member, is + refused by name. The PK name is now introspected too, so a `baseline --from-db` snapshot of a + database whose primary keys are not named `
_pkey` records their names (not compared; + nothing churns). See `docs/features/migrations-and-drift.md`, "Schema conventions". +- **`migrate.checks.skipRedundant`: leave out the CHECKs a column type already enforces.** Set in + `.metaobjects/config.json` (default `false`), `meta migrate` and `meta verify --db` leave out a + `validator.length` maximum the column's `VARCHAR(n)` enforces (not on SQLite or D1, which do not + enforce one) and a length minimum of 0 or less, for a database whose CHECKs were written by hand + only where the column type does not already enforce the rule. A validator with a declared + `@constraintName` keeps its CHECK. A malformed `checks` block is refused when the config loads. + See `docs/features/migrations-and-drift.md`, "CHECKs from validators". - **A recipe for checking an API change against the last release.** Emit the document at the last tag and at `HEAD`, then run oasdiff. See `docs/recipes/check-api-against-last-release.md`. - **A `pydantic` extra on the Python package.** `pip install "metaobjects[pydantic]"` installs @@ -333,6 +1259,139 @@ vocabulary; upgrade every port together. The proof is a test file that `tsc` or pytest runs, so nothing reads your source and there is no new command. `examples/brownfield/` holds a runnable project for each, and the recipe ships in the `metaobjects-authoring` skill. +- **A project's own provider class, wired in every port's config, loaded by every command.** A + project that declares its own vocabulary (a new subtype, or attributes on a core type) writes a + provider class in each language whose tools load the metadata, and names it once: + `defineConfig({ providers })` in TypeScript, `providers: ["module:symbol"]` in + `metaobjects.config.yaml` for Python, the new `csharp.providers: [{ "assembly", "type" }]` list + in `.metaobjects/config.json` for C#, and for Java and Kotlin the new Maven plugin + `FQCN` list, `MetaDataTypeProvider` beans composed by + the Spring auto-configured loader, `LoaderOptions.setProviders(...)`, and a `providers` + parameter on the `metadata-ktx` loader. C#, Java and Kotlin had no project-level way to do this + before; `META-INF/services` still does not add a provider to the JVM loader. Two new conformance + fixtures, `provider-custom-vocabulary-success` and + `provider-custom-vocabulary-missing-provider-fails`, hold every port to loading a project + subtype plus attributes with its provider and refusing the same file without it. + `docs/features/extending-with-providers.md` now has a worked example per language, and the + `metaobjects-authoring` skill teaches it, with a reference file per language. + +- **C#: one property-name resolver for every generator that names a field's property.** + `GenConfig.PropertyNaming` (`Func`, default PascalCase) is read by the + entity classes, the composite `[PrimaryKey(nameof(...))]`, every `AppDbContext` model line and + the reverse finders. `DbContextGenerator` gains the `protected virtual PropertyName` hook + `EntityGenerator` already had; both default to the resolver. Before, an adopter that overrode + `EntityGenerator.PropertyName` got a context that configured the PascalCased name, which did + not compile. +- **C#: `EntityGenerator.EmitClassAttributes`,** a seam for class-level attributes of your own, + called for every class kind after the framework's attributes and before the declaration, so a + subclass no longer copies `EmitClassHeader` to add one. +- **C#: `EntityGenerator.ScopesValueObjectClosure`** (default `false`). With it set, `Include` + also applies to the value objects reached through the model root (an emitted entity's object + fields, callable arguments, template payloads), so a value object `Include` rejects gets no + POCO even when an emitted type references it, and the adopter supplies the type. The default + still emits every reached value object, so the output compiles on its own. +- **C#: `EntityGenerator.EmitsReverseFinders`** (default `true`) turns the ADR-0038 + `Queries.g.cs` finders off. + +- **C#: the DbContext and entity generators are overridable one line at a time.** An adopter that + needs one line of generated output different overrides one `protected virtual` hook, calls base and + adjusts what it returns, instead of rewriting the finished file or re-emitting a whole body. On + `DbContextGenerator`: `ContextBaseClass`, `ContextPreambleLines`, `ContextTrailerLines`, + `AlwaysEmitOnModelCreating`, `DbSetLine`, `DbColumnTypeConfig`, `ReferenceConfig`, + `DefaultValueConfig`, `EnumConversionCall` (now an instance method taking the `GenContext`), + `FieldTypeConfig`, `OwnedTypeConfig`, `TphSubtypeFieldConfig` and `EntityConfigTrailer` (new). On + `EntityGenerator`: `PropertyClrType` and `PropertyInitializer` (every scalar, enum, object and map + member), and `EmitValueObjectPoco`, which may now return `null` to drop a value object's file and is + asked about every one. The preamble comes first in `OnModelCreating`, the trailer last, and a split + model keeps its `ConfigureModelNN` calls between them. The default output is byte-identical. +- **C#: more of the generated output is one hook away.** `EntityGenerator.ValueObjectMemberAttributes` + (the `[JsonPropertyName]` line before each value-object member), `ColumnAttributeArguments` (the + argument list of a mapped property's one `[Column(...)]`; append `TypeName = "jsonb"`, or return + none to leave the attribute out) and `TphDerivedTypeAttributes` (the `[JsonDerivedType]` lines on a + TPH base). The DbContext's head, which `EmitUsings` hard-coded, is built from `ContextUsings` + (the `using` lines), `ContextNamespace`, `ContextClassName` (default `AppDbContext`; a set + `GenConfig.ContextTypeName` still names only the type callables and finders take, and an override + leaves the routes generator naming `AppDbContext`), `EmitContextConstructor`, `ContextIsPartial` + and `ContextMemberLines` (extra members, after the constructor). `NamesGenerator` is no longer `sealed`, and its per-object emit, + `Render`, is `protected virtual`; a `null` from it emits no file. The default output is + byte-identical. +- **A test-only reset of the naming registry, in every port.** `resetNamingStrategiesForTesting()` + (TypeScript), `NamingStrategies.ResetForTesting()` (C#), `NamingStrategies.resetForTesting()` (Java + and Kotlin) and `reset_naming_strategies_for_testing()` (Python) forget the strategies the + application registered and keep the built-ins. + +- **C#: the generated EF context declares the CHECK constraints `meta migrate` creates**, with the + same names and expression text: every scalar `field.enum` and every validator that can carry one + (`numeric`, `length`, `regex`, `comparison`, `requiredWhen`, `presentIff`, `atLeastOne`, + `exactlyOne`), with `@constraintName` and `@condition`. They are declared when `migrate.dialect` is + `postgres`, `sqlite` or `d1`, and `migrate.checks.skipRedundant` is followed. A new shared corpus, + `fixtures/check-constraint-conformance/`, pins the names and text per dialect; `meta migrate` is + its reference, and the C# context passes the same files (and creates them on live Postgres). +- **C#: a value object stored as JSON carries its comment into the database.** Its `@description` + (else its value object's) is an owned-type annotation, and the generated design-time services + scaffold it as `COMMENT ON COLUMN`, Up and Down; a change to that comment alone is a pending model + change, so `has-pending-model-changes` and `migrations add` see it. Off Postgres the run warns. +- **C#: the package output layout and per-package namespaces, as opt-ins.** `csharp.outputLayout: + "package"` in `.metaobjects/config.json` writes each per-object file under its metadata package + (`acme::blog::Author` is `acme/blog/Author.g.cs`), and each shared enum becomes its own + `/.g.cs`. `csharp.packageNamespaces: true` puts each packaged type in its + package's namespace even when `csharp.namespace` is set (an object maps packages explicitly), and + every reference across namespaces is written `global::`-qualified. `dotnet meta init` writes + both for a new project; a project that sets neither gets byte-identical output + ([#546](https://github.com/metaobjectsdev/metaobjects/issues/546)). +- **Python: the package output layout.** `outputLayout: "package"` in `metaobjects.config.yaml` + (`GenConfig(output_layout=...)` for a self-hosted run) writes each object in the directory of its + metadata package (`acme::blog::Author` is `generated/acme/blog/Author.py`), with relative imports + and package `__init__.py` files. The default stays flat. Two objects that would generate one module + in one directory are refused with `ERR_NAME_COLLISION`, naming both. So is a tree Python could not + import: a package directory beside a module of the same name (a top-level package `enums` would + shadow the shared `enums.py`), and a package segment that is not a Python identifier (`my-co`) + ([#546](https://github.com/metaobjectsdev/metaobjects/issues/546)). +- **Java and Kotlin: output paths keyed by metadata package, with a refusal.** Every per-object file + already landed in the directory of its metadata package; two metadata packages that would land in + one directory (a case-only difference, or `a.b` beside `a::b`) are now refused before any + generator runs, with `ERR_NAME_COLLISION` naming both objects, instead of one file overwriting the + other. Tests pin that two same-named objects in two packages are two files + ([#546](https://github.com/metaobjectsdev/metaobjects/issues/546)). +- **Kotlin: Exposed tables begin at `@sequenceStart`.** An increment key that declares + `@sequenceStart` or `@sequenceName` is `autoIncrement(Sequence("", startWith = n))` on both + Exposed lines, so a table Exposed creates begins at the start; pinned on live Postgres + ([#544](https://github.com/metaobjectsdev/metaobjects/issues/544)). + +### Documentation + +- **ADR-0015 Amendment 1: EF Core Migrations is a supported second C# path.** `meta migrate` stays + the reference engine; the EF context is held to it by the shared CHECK corpus and the identity + start rule. +- **ADR-0044 Amendment 1 and ADR-0056 Amendment 2: a value object is never renamed.** The + package-qualified collision name is gone in every port; one claim registry per run refuses a real + clash with `ERR_NAME_COLLISION`. +- **Index names and list-hook names, corrected.** The authoring reference's index examples are + table-scoped (`userByEmail`, not `byEmail`) and say an index name is schema-wide, so a repeated + one fails `meta migrate` with `ERR_DUPLICATE_SQL_NAME`. The generated list hook is + `use`, or `useList` when the plural equals the name; the reporting page had it + backwards, and the codegen and runtime-UI skills named only one form. + +- **Separate-repo model sharing (FR-023 Phase 2) close-out.** The feature page's Phase 2 section is now + the shipped per-port matrix (consume, check, publish, runtime load, transports), the deferred list + names what is still not built, and the verify, codegen, authoring, audit and capability-sheet skills + teach the Java, Kotlin and C# publish paths, the `deps` checks and the `maven` and `nuget` transports. +- **The `metaobjects-audit` skill checks that a project uses MetaObjects as documented, not only + that it installed it.** Axis F now asks whether the verify gate blocks: it looks for swallowed + exit codes, runs the project's own verify and records the error count (recommending a ratchet + for a tolerated count), lists every deploy path that skips it, and scores the gate BLOCKING, + RUNS BUT DOES NOT BLOCK or ABSENT; a project with no CI answers NO whatever untracked hooks it + has. Axis F2 reports `consumed / emitted` per generator kind and raises one + `generated-and-bypassed` finding where a hand-built page stands beside an unused generated one. + The prompt reference counts payload fields linked to entity fields (`extends: Entity.field`) + against unlinked copies. The requirements reference adds three currency checks: ledger + staleness from git history, `--require-implementers`, and live claims whose generated + implementer nothing uses. The unmodified-owned-copy check now covers Java, Kotlin, C# and + Python (the Java and Kotlin references no longer say those ports cannot eject), reported as one + line total. Phase 1b adds a shape-coverage census of every boundary shape. The scorecard gains a + "used as described" line, a re-run marks each earlier finding fixed, open or deferred against + the previous `.metaobjects/adoption-audit.json`, and the report documents the JSON's top-level + fields. - **C#: one property-name resolver for every generator that names a field's property.** `GenConfig.PropertyNaming` (`Func`, default PascalCase) is read by the @@ -660,6 +1719,110 @@ vocabulary; upgrade every port together. `drop-index` that dropped and rebuilt the object. It is now one `rename-constraints` change: `ALTER TABLE … RENAME CONSTRAINT` / `ALTER INDEX … RENAME`, and the down renames it back. SQLite cannot rename a constraint and keeps the rebuild. + +- **`meta init` and `metaobjects init` write `outputLayout: "package"`.** A new project gets one + directory per metadata package (`acme::blog` writes `src/generated/acme/blog/Author.ts`), so two + objects with one name in two packages are two files. The engine default stays `flat`, so an + existing project changes nothing. The Mongo document-store recipe's generator follows the layout. +- **The codegen-compile gate and the generated-server api-contract lanes run in both output + layouts**, flat and package, so a defect that only the non-default layout shows fails a gate. +- **TypeScript: one claim registry for every emitted name.** A generator claims each name it + writes into a shared scope (a module's exported types, an output file, a barrel entry, a route) + through `ctx.claim(scope, name, claimant, remedy)`; a second claimant of one name in one scope is + refused with `ERR_NAME_COLLISION`, naming both and the remedy. A collection-name clash keeps the + shared-ledger code `ERR_COLLECTION_NAME_COLLISION`, checked before any generator runs. The + `RenderContext` members `valueObjectNames` (now the identity map) and `packageOf` are deprecated + and kept one release so owned generator copies keep compiling; a referencing file reads the + local name through `resolveValueObjectName`. Re-eject an owned copy to drop them. +- **C#: the same claim registry, and value objects keep their names.** Each generator claims the + names it emits (a type per namespace, a file per output path, a DbSet per context, a route segment + per routes entry, a finder per class); a second claimant is refused with `ERR_NAME_COLLISION`, + naming both and the remedy. The package-qualified value-object rename and its + `ERR_PAYLOAD_NAME_COLLISION` are gone. +- **TypeScript and Python: two shared enums with one name are `ERR_NAME_COLLISION`.** Every shared + enum is generated into one module under its own name, so a second `Tier` from another package + was dropped and its fields typed with the first one's members. The pair is now refused, naming + both declarations. C# with package namespaces generates each in its own namespace. +- **A collection-name clash is `ERR_COLLECTION_NAME_COLLISION` in every port.** Java's refusal (which + Kotlin shares) and C#'s DbSet and route-segment refusals now lead with the shared-ledger code + that TypeScript and Python already raise, and name `@collectionName` as the remedy. +- **Every join a generated view or report makes is `LEFT OUTER`.** A row whose reference is null, + or whose related row is missing, used to vanish from a view that inner-joined it; it now appears + with nulls in the joined columns. A report dimension's `required` flag is read from the model, + and no longer changes the join. Expect the regenerated view bodies to differ in `meta migrate`. +- **A Postgres view qualifies a relation only when its entity declares `@schema`.** A table in the + default schema stays unqualified, so the view follows the connection's `search_path` as the + table DDL does; SQLite and MySQL view bodies are never qualified. + +- **Quieter `meta verify` advisories.** The anti-pattern scanner skips comment lines; it flags + minor-unit math (`* 100`, `/ 100`, `.toFixed(2)`, `parseFloat`) only when the operand is + money-named, so hours formatted to two places no longer read as money; and a `.reduce` counts + as a hand-rolled aggregate only when it accumulates with `+` outside `.tsx`/`.jsx` UI source. + Unindexed foreign keys are one finding naming every key and its `index.lookup`, not one per + key. With a `--format` payload on stdout, the text on stderr gives each section's header and a + pointer instead of repeating every finding. + +- **The requirements reference pages install in every stack.** They used to install only when + `meta init` saw a `requirement.*` node, which a new project has not written yet, so a project + that declared requirements later had skills pointing at pages that were not there. `meta gen` + and `meta verify` now say so for a context scaffolded that way, and name + `meta init --docs-only --refresh-docs`. +- **A shorter scaffolded `metaobjects.config.ts` comment.** It now shows the import line for the + usual data layer (`entityFile`, `namesFile`, `barrel`) and the catalog command, and drops the + rest. +- **`meta gen --list` off a terminal is unchanged.** Its default there stays the TOON document, + which tools and the skills parse for `wire.import` and `layer`; the agent context gives a + one-line filter for a compact view instead. + +- **A new top-level requirement declared into a dependency's package is refused** with + `ERR_DEPENDENCY_PACKAGE_NOT_OWNED`, as a new object there already was. An overlay of the + dependency's own requirement is still accepted. + +- **`docsSiteFile()` builds the model explorer by default.** A project that lists + `docsSiteFile()` gets a different site under `site/` on its next `meta gen`, with new page + paths (object pages move under `model/`); `meta gen` removes the old pages it wrote, as it + does any untouched generated file it no longer emits, and `meta verify --codegen` reports + drift until it has run. Pass `docsSiteFile({ site: "classic" })` to keep the earlier + site byte for byte. A project that ejected the classic theme gets a warning and the packaged + explorer theme; run `meta eject docs-site` again to copy the explorer's files. + +- **Python and Java report a missing provider's errors in the same order as the other ports.** + When a file holds both an unknown subtype and unknown attributes, Python used to drop the whole + file at the unknown subtype and never report the attributes; it now reports + `ERR_UNKNOWN_SUBTYPE` and then each `ERR_UNKNOWN_ATTR`. Java reported the attribute errors + before the subtype error; it now reports them after it, as TypeScript and C# do. A load that + failed still fails; only the list of errors differs. +- **`meta migrate` refuses a foreign key that references columns the target does not hold unique.** + Behaviour change: an `identity.reference` whose dotted `@references` names target fields that are + not the target's primary key, a plain `identity.secondary` (no `@where`, no `@expr`) or a single + `@unique` field used to emit an FK the database refuses at apply time ("there is no unique + constraint matching given keys"), after earlier statements had already run. `meta migrate` and + `meta verify --db` now fail first with `FkTargetNotUniqueError`, which lists every offending + reference at once (entity, reference, target and fields); both report it as a metadata refusal + with a hint. The check is against the table the model actually builds: a key declared on a TPH + subtype is not emitted, so it does not count (the message says to declare it on the base), and + a bare reference into a composite primary key with fewer FK fields is caught too. An FK on a + table this run does not govern (imported, or outside `migrate.scope`) is warned about, not + refused, and an FK into a table the model does not build (`@unmanaged`) is not checked. Postgres + refuses the DDL and D1 always enforces foreign keys, so both refuse. SQLite only warns: it accepts + the `CREATE TABLE`, and checks foreign keys only with `PRAGMA foreign_keys` on, which is off by + default, so the FK fails (`foreign key mismatch`) on a write with enforcement on. `meta verify + --db` gives the same verdict. Fix: declare an `identity.secondary` on those fields of the target. + This is a `meta migrate` correction; it moves no metamodel version. +- **A constraint or index whose only change is its name is renamed in place on Postgres.** A + drop plus an add of the same definition under another name, on a table that is not itself + renamed (switching schema conventions renames every FK), used to be a gated `drop-fk` / + `drop-index` that dropped and rebuilt the object. It is now one `rename-constraints` change: + `ALTER TABLE … RENAME CONSTRAINT` / `ALTER INDEX … RENAME`, and the down renames it back. SQLite + cannot rename a constraint and keeps the rebuild. The primary key's name is now compared too, + so a convention switch, or a table rename (which keeps the old `
_pkey`), renames it, and + `meta verify --db` reports a mismatch it used to pass. A unique key that changes only between + plain index and UNIQUE constraint is promoted in place (`ADD CONSTRAINT … UNIQUE USING INDEX`); + the reverse, when the conventions ask for a plain index, drops the constraint, re-creates the + index, and drops and re-adds each FK onto it, behind `--allow drop-index` and `--allow drop-fk`. + The default conventions accept either kind, so a database built with Drizzle's `unique()` + constraints is left as it is. A key that changes both its name and its kind + is renamed, then promoted or demoted, in the same migration. - **A prompt or output template that names a variable not on its payload now raises at render time.** Behaviour change: a generated render helper used to render `Hi {{nmae}}` as `Hi ` with no error when the payload declares `name`; it now raises `ERR_VAR_NOT_ON_PAYLOAD (nmae)` (`RenderError` in @@ -674,6 +1837,74 @@ vocabulary; upgrade every port together. Python, `Verify` in C#, the `verify` field of `RenderRequest` in Java and Kotlin). If a template already named a missing variable, regenerate and fix the name; the generated helper text changes (TypeScript `prompts.ts` and Python helpers gain a `verify` argument). +- **Deprecated, CLI: `tsOnly` in `meta types --format json`; read `implementedIn`.** Each row + and attr now names the ports that implement it so far (`"implementedIn": ["typescript"]`), and a + port-scoped attr carries `ports`. `tsOnly` is still emitted through 1.3.x, derived from + `implementedIn` (`true` exactly when it is `["typescript"]`), and is removed in 1.4. The text + output's `[ts-only]` marker is now `[ts; pending elsewhere]`, and a port-scoped attr shows + `[-only]` (`[java+kotlin]` for `@objectAdapter`, which names two). + +- **C#, upgrade note: the next EF migration scaffolds your indexes and comments.** The generated + context now declares every `@unique`, `identity.secondary` and `index.lookup` as an EF index + (named as `meta migrate` names them) and every `@description` as a table or column comment, which + the model never carried before. So the first `dotnet ef migrations add` after upgrading scaffolds a + `CreateIndex` for each index and an `AlterColumn`/`AlterTable` comment for each description, as + if they were new. On a database `meta migrate` (or your own SQL) already built, the indexes exist + and the migration fails on "relation already exists". If they exist under the same names, empty + the migration's `Up` and `Down` (keep the snapshot change) so EF records them as present; if they + exist under other names, rename them in the database or in the metadata first. Comments re-apply + harmlessly. A database built from the model (`EnsureCreated`, or a fresh migration chain) is + unaffected. An `@expr` index is never an EF index; `meta migrate` creates it. +- **C#, upgrade note: identity starts never RESTART, through generated design-time services.** A + Postgres project's context now carries `identity.primary @sequenceStart` in its model, and a + generated `DesignTimeServices` makes `dotnet ef migrations add` scaffold every + start-only change (a start added, changed or removed) as SQL: `SET START WITH n` (a removed start + goes back to the identity default) and, for a declared start, a forward-only move of the counter + to `GREATEST(n, max(id) + 1)` when it sits below that. It never writes `RESTART`. The first + migration after upgrading shows that SQL for each table that declares a start; it is safe to + apply. EF finds the services through an `[assembly: DesignTimeServicesReference]` generated + beside them when the migrations live in the context's project, EF's default; for any other + migrations or startup project, `dotnet meta gen` warns and prints the line to add there. Nothing + is registered at runtime. `UseIdentityStartMigrations()` is kept as an `[Obsolete]` no-op so a + call to it compiles; remove it. +- **C#, upgrade note: a self-hosted codegen runner sets `GenConfig.Dialect`.** `@sequenceStart` and + the identity-start rewrite are emitted only when the dialect is `postgres`. `CodegenCli` reads it + from `.metaobjects/config.json` `migrate.dialect`; a runner that builds its own `GenConfig` must + set `Dialect = "postgres"`, or it gets a warning and no start in the model. +- **C#, upgrade note: an unset nullable enum with `@default` starts at `@default`, not NULL** (the + same rule as a nullable scalar with `@default`, which already started at it). An entity + created without setting the field now stores the default member; an explicit `null` is still + stored as NULL. To keep NULL as the starting value, do not declare `@default` on the field. The + same holds for a value object's enum member: a stored JSON document that lacks the member reads + as `@default`, not null. +- **C#: one generated context maps each relation to one object.** Two concrete + objects of one context that resolve to the same table, view, procedure or function in the same + `@schema` are refused with `ERR_DUPLICATE_SQL_NAME`, naming both; before, they silently shared it + once `@collectionName` split their DbSet names. The same name in two schemas is two relations, and an + object that extends another and inherits its source is one EF hierarchy. A `@collectionName` that is not + a C# identifier, or names `Database`, `Model`, `ChangeTracker` or `ContextId`, is refused by name. +- **TypeScript: the collision refusal checks only the names the run emits.** The pluralized module + names are checked when entity modules, queries or a UI tier are wired, and the REST segments when + a routes generator is, so a docs-only run never refuses names no generator writes. +- **Breaking, C#: `ColumnNamingStrategy` and `TableNamingRule` are classes, not enums** + (ADR-0058 Amendment 1). They are compared by name. `ColumnNamingStrategy.SnakeCase` and the other + built-ins keep their names (`Pascal` is new). Code that switches on one, uses one as a constant + default parameter (`= ColumnNamingStrategy.Literal`) or as an `[InlineData]` argument has to + change: call `strategy.Apply(name)`, take a nullable parameter, or pass the name string. + `Apply` is an extension method, so `default(ColumnNamingStrategy)` (now `null`) applies as the + enum's default did, `Literal`, rather than throwing `NullReferenceException`; the same holds for + `TableNamingRule`. `EntityGenerator.ScalarProperty`'s `strategy` parameter is now + `ColumnNamingStrategy?` (default `Literal`), so an override changes its signature to match. + `NeutralConfig.Read` and `MetadataLocation.Resolve` gain a `validateNaming` overload that keeps a + name this process has not registered (`ColumnNamingStrategy.ByName`) for resolution to refuse. +- **Java: `ColumnNaming.apply` throws `MetaDataException` for an unknown strategy name** where it + threw `IllegalArgumentException`. +- **TypeScript: an entity's docs page names the column the naming strategy resolves.** The Fields + table's Column cell, a field's Column detail and the Storage payload printed only an explicit + `@column`, so a project that names its columns by rule (`pascal`, `snake_case`) instead of a + `@column` on every field lost them. They now print the resolved column wherever it differs from + the field name; a value object's members still show only an explicit `@column`, since each owner + maps them. A default (`snake_case`) page gains the column of each multi-word field. ### Security @@ -1269,11 +2500,407 @@ vocabulary; upgrade every port together. `pg_constraint`, pairing `conkey` with `confkey` by position. As before, only same-schema foreign keys are read (the FK descriptor carries no referenced schema). + +- **No CHECK for a derived field.** A validator on a field that carries an `origin` (or a + cross-field validator naming one) made `meta migrate` emit a CHECK on a column that does not + exist, and `CREATE TABLE` failed. The derived field is skipped; the C# context does the same. +- **View lowering, in TypeScript (which builds every port's views):** + - an origin `@filter` keeps every operator of a field clause (`{ "gte": 1, "lt": 10 }` lost + all but the first, so the view counted rows it should not); + - a projection that extends a projection outputs the inherited fields and applies the base's + `@filter`; + - a `@filter` on a base field the view does not output, or on a path of to-one hops, joins only + what it names; + - a multi-hop `origin.first` `@via` is lowered along its path, correlated on the first hop; + - a view over a TPH subtype, or a join onto one, is scoped by its discriminator, and an abstract + level by `IN` over its concrete subtypes; + - a Postgres view column takes its declared type (a bare `NULL` computed column, an `@convert` + passthrough); + - two aggregates through two references onto one target each read their own join. +- **The Zod template's shared-enum import resolves in the package layout** when the owning object's + package is inherited from its file or root (`./enums` was one directory short). +- **A docs page's References and identity-reference links reach the target page** when the target + lives in another package. +- **An entity's derived field is not a column, in every port.** A projection-reached + `origin.first` / `origin.computed` on an entity with no read source is left out of table reads + and writes by the C# entity and DbContext, the Kotlin entity, Exposed table, repository and + controller, Java OMDB's mapping and Python's `ObjectManager`. +- **C#: a reference over a member of a flattened value object** configures the foreign key on the + owned type instead of emitting a property EF rejects. A `field.duration` mapping names framework + types `global::`-qualified. + +- **Generated routes on Postgres answer 400, not 500, for bad uuid input.** On an entity with a + uuid foreign key, `?search=` ran ILIKE against the uuid column (the allowlist carries it as + `subType: "string", format: "uuid"`), and Postgres has no `uuid ~~* text` operator. The search + now skips string rules that carry a `format`. A malformed uuid in `:id` reached Postgres as a + literal ("invalid input syntax for type uuid"); `coerceIdForColumn` now rejects it, so GET, + PATCH and DELETE answer 400 `{"error":"invalid_id"}` as a malformed numeric id already did. A + `field.uuid` in the generated insert and update Zod schemas now checks the 8-4-4-4-12 shape, so + a malformed uuid foreign key in a POST or PATCH body answers 400 `validation`. SQLite stores a + uuid as text, so none of this showed there; a new integration test runs the stock + `routesFile()` output against Postgres with uuid keys and a uuid foreign key. Owned copies + pick the fix up when re-ejected. +- **`meta migrate` warns when a renamed column is still named by a view.** A rename never + rewrites a view body, so a view whose `@sql` still names the old column is recreated as + declared and the migration fails at apply. The plan now names the view, the column and its new + name, and the "recreated only because" note no longer lists that view among the harmless ones. + +- **An enum's `@default` is what an untouched record stores**. C#: a scalar enum + started at `default(TEnum)`, not at `@default`, while the EF sentinel was `@default`, so EF + wrote it: a string-stored or int-mapped enum stored its first member, a nullable one NULL, and + a `@provided` int-backed enum with no 0 member threw `cannot write 0`. It now starts at its + `@default` member, as a scalar does. Kotlin: the generated data class gave a defaulted field no + ctor default, so a create body omitting a required one answered 400 and a nullable one was + written as an explicit NULL; a literal `@default` (enum member, Boolean, String, Int, Long, + Double) is now the ctor default. Java: the DTO is a record, which cannot default a + component, so a generated create handler for an entity with a literal `@default` binds the raw + body, fills the absent defaulted fields (an explicit value, null included, is kept) and then + binds the DTO, on the vanilla and the TPH per-subtype create alike; an entity with none keeps the + direct binding. TypeScript and Python were already right (a create that omits + the field leaves it out of the INSERT, and the Python model starts at `@default`); live tests + now prove it. The new api-contract `enum-default/` sub-corpus gates it in the generated lane of + all five ports: a create that omits the enum stores its default, and a supplied value is kept. + A nullable C# enum with `@default` now starts at it too: see the upgrade note under + Changed. +- **A generated name collides only in the scope that carries it**. The run-wide + refusal of two objects whose short names pluralize alike is gone. C#: DbSet names are unique + within one generated context (the error says "rename one, or set @collectionName"), route segments + within one routes entry, reverse finders within their class. TypeScript: the pluralized names + within the entity modules' scope (one directory under the flat layout, one per package under + the package layout), REST segments across the app. Python and JVM keep one run-wide scope, + which is theirs (one flat module package; one Spring app). An abstract or sourceless object + emits nothing, so it never collides: a layered model's abstract `enterprise::Payer` beside a + concrete `core::Payer` generates. The naming-conformance corpus gains `shapeOnlyCases` and + `crossPackageCollisionCases`. +- **Doc pages are keyed by package**. TypeScript's `docsFile()` and `apiDocsFile()` now + place every page under its package path whatever the docs target's `outputLayout` (which still + places code), and Java's and Kotlin's api-docs `layout` defaults to `package` (`flat` is still + honoured). Two same-named nodes in two packages are two pages, and an index entry that shares + its short name carries its package. In every port, two page paths that differ only in case + (`ProductNdc.md`, `ProductNDC.md`: one file on macOS and Windows) are refused by name instead of + one page silently replacing the other. **Upgrade note:** a TypeScript project on the flat + default sees its doc pages move under package directories on the next `meta gen`. A Java or + Kotlin build that relied on the old `flat` default for its api-docs sees the same move; set + `layout` to `flat` on that generator to keep the old paths. +- **`@schema` reaches every mapping.** C#: a view mapping is `.ToView(name, schema)`, as a table's + `[Table]` already carried its schema. Python, TypeScript and Java: the runtime addressed a bare + table name, so an entity in `@schema: sales` was read and written in whatever `search_path` + resolved, and two entities mapping the same table name in two schemas read one table. Every read + and write now qualifies the relation: the Python ObjectManager, the TypeScript ObjectManager on + both its Kysely and Drizzle drivers, and Java OMDB (SQLite, which has no schemas, keeps bare + names). A new persistence scenario, `schema-qualified-same-name`, maps `ledger_entries` and + `archive.ledger_entries` to two entities and runs on Postgres in every port. +- **C#: `identity.primary @sequenceStart` reaches the EF model, and no start-only change ever + restarts**. On Npgsql a fresh database's identity begins at `@sequenceStart`. A Postgres + context's generated design-time services (see Changed) scaffold a start added, changed or + removed as `SET START WITH n` plus the forward-only counter move, where Npgsql's own generator + writes `RESTART WITH n` (or `RESTART WITH 1` for a removed start), which hands out ids live rows + already hold. The start and the services are emitted only for a project whose + `migrate.dialect` is `postgres`; any other project gets a warning and needs no Npgsql package. + TypeScript's `meta migrate` writes the same change, and the Kotlin Exposed table begins a fresh + table at the start ([#544](https://github.com/metaobjectsdev/metaobjects/issues/544)); see + `docs/CONFORMANCE.md`, "Split coverage". +- **C#: the EF model carries the index vocabulary and `@description`.** A field's `@unique`, an + `identity.secondary` and an `index.lookup` are EF indexes under the names `meta migrate` gives + them, with `@where` (`HasFilter`), `@orders` (`IsDescending`) and `@using` (the Npgsql index + method); `@description` is the table and column comment, on a TPH subtype's own fields too. A model over + the migrated database now declares its indexes, so a database EF builds has them (EF never + dropped them: an index its snapshot never knew is invisible to it); see Changed for the first + migration after upgrading. An `@expr` index an abstract base declares reaches each concrete + child's table. Kotlin's Exposed + table now carries an index's `@using` (`indexType`) and `@where` (`filterCondition`); what + Exposed and Drizzle cannot express is listed in `docs/CONFORMANCE.md`, "Split coverage". + +- **C#: a `Names` whose base lives in another namespace compiles.** The names artifact + extends its base's (`Names : Names`), and the base's file is emitted in the base's + own namespace, but the subtype's file carried no `using` for it: one CS0246 per artifact for a + model whose abstract bases bind to another namespace. It now writes that `using`. +- **C#: a reference declared on an abstract TPH intermediate is configured.** The DbContext's TPH + pass read only the concrete subtypes' own references, so one declared on an abstract level + between the base and its leaves reached no `ReferenceConfig` call: EF built no relationship over + the column, and its `@onDelete` and `@constraintName` were lost. Each intermediate is now + configured once: on its own builder when it is a class (`EmitAbstractShapes`), else on each + topmost concrete subtype its fields are folded into (a concrete subtype under one of those + inherits its foreign key). +- **C#: `dotnet meta verify --codegen` accepts a naming strategy only the project's codegen runner + registers.** Stock verify refused the config's `naming` value before it handed the `--codegen` + gate to `codegen/Program.cs`, which is where an application registers its strategy, so verify + failed where `gen` succeeded. It now hands off first and refuses an unknown name in its own process + only when no runner ran, or when `--templates` or `--db` (which run in that process) are asked for + too; either way it is exit 2 with the standard message, never an unhandled exception. +- **TypeScript: `viewNameFromProjection` reads the separator from the strategy.** It switched on + the name `"kebab-case"`; the separator after `v` is now the one the strategy writes between two + words, else `_`. Every built-in keeps its view name, and an application strategy gets the same + rule. +- **TypeScript: a `metaobjects.config.ts` that fails to load while the naming preload needs it is + reported.** The preload swallowed the error, and the command went on to refuse the strategy's + name as unregistered. It now stops and names the failed load, and the strategy it would have + registered when that is still missing. +- **C#: a large model's `OnModelCreating` no longer overflows the stack.** The DbContext generator put + every configuration line in one method; on a model with hundreds of converters and owned types its + stack frame was too large for a thread-pool thread in a Debug build, so a test host crashed with a + stack overflow while building the model. Past `ModelConfigChunkSize` entries (default 200) the + configuration is split into `ConfigureModelNN` methods called in order; a smaller model is emitted + as before. + +- **C#: concurrent reads of a loaded model no longer corrupt its cache.** `MetaData.Cached` + memoized derived reads (`Validators()`, `ResolvedIsArray()`, `OwnAttrs()`, …) in a plain + `Dictionary`, so two threads touching a frozen node for the first time could corrupt it, and + every later read in the process then failed with "Operations that change non-concurrent + collections must have exclusive access". A host that loads metadata once and serves requests + from it in parallel, or a parallel test run, hit this. The cache is now a + `ConcurrentDictionary`. + + +- **C#: a field's `@default` reaches the EF model.** The context configured no default at all, + so a database EF creates (`EnsureCreated`, an EF migration) had none, and an insert that relied + on one failed with a NOT NULL violation. A literal the property's CLR type holds (bool, string, + number, enum member) is now `HasDefaultValue(v).HasSentinel(v)`. The sentinel matters: EF leaves + a property with a database default out of the INSERT when its value equals the sentinel, which is + otherwise the CLR default, so a bool defaulting to `true` would have stored `true` when the app + set `false` (and a nullable one, or a string, would have lost an explicit NULL). With the + default as the sentinel, EF omits only a value the database would write anyway; a live test + sets every such property to its CLR default and reads it back. A SQL expression (`now()`, + anything function-like, `current_timestamp`; a bare `now` is `now()`), or a timestamp, date or + uuid literal, is `HasDefaultValueSql(...)` on a `@required` property only: on a nullable one EF + would replace an explicit NULL with the default, so it is left out there. Primary keys, arrays, + value objects, maps and durations get no default. A model whose database lacks a declared + default (one `meta migrate` did not build) now sees EF omit a column whose value equals it. + +- **C#: a `@required` value-object member of a value object starts as an instance.** It was + `public T X { get; set; } = default!;`, so a document that omitted it deserialized to null + behind a non-nullable type. It is now `= new T();` (an abstract target keeps `default!`, and + an entity's owned navigation is unchanged), so the member is present and its own members are + validated. + +- **C#: a value object nested inside a flattened one maps to one jsonb value.** The flattened + owner configured it as a nested owned `ToJson`, which EF Core 8 refuses inside a table-split + owned type ("All owned types containing a JSON column must be mapped to a JSON column + themselves"), so the whole context failed model validation. It is now one jsonb property + converted whole through the generated `MapJsonb.ObjectConverter`/`ObjectComparer`, pinned to the + same `` the migration creates; members keep their `[JsonPropertyName]` keys and + enums their symbols. Every other flattened member, scalar enums included, keeps its + `HasColumnName`. + +- **C#: a TPH subtype's own fields get their EF configuration.** The context configured the + fields of the TPH root only, so a field a subtype declares itself got none: a `field.object` + was left for EF to discover as an entity (model validation failed with "requires a primary + key"), and a timestamp, enum, decimal precision, array, map, duration or `@readOnly` column + lost the mapping the same field gets on the root. Each concrete subtype now configures the + fields it adds, on its own builder. The integration corpus's `CopayAuth.copayAmount` gains its + `HasPrecision(10, 2)`. + +- **C#: under `EmitAbstractShapes`, a concrete entity extends its abstract shape and keeps the + facets of the fields it inherits.** The entity class left out the fields its abstract parent + declares, expecting the shape class to carry them, but never named the shape as its base, so + those fields were on no class and the context did not compile. It now declares `: ` + (an abstract shape extending another does too). The shape carries no EF attributes, so the + context configures what the inherited fields' attributes would have: the single-column key + (`HasKey`), each column name (`HasColumnName`) and a string's `@maxLength` (`HasMaxLength`). + Models without the knob are unchanged. + +- **C#: a TPH discriminator typed by a shared or `@provided` enum compiles.** `HasValue(...)` + named the enum as a type nested in the base entity (`Vehicle.VehicleKind.Car`), which a shared + or provided enum (FR-019) is not; it now names it where it lives, as the enum conversions do. + +- **C#: a reference's `@constraintName` and non-primary-key target reach the EF model.** The + relationship line now ends in `.HasConstraintName("...")` when the `identity.reference` declares + `@constraintName` (the junction sides of an M:N too), so a database EF creates names its foreign + keys as the schema does. When `@references` names target fields that are not the target's + primary key (`"Warehouse.regionCode,siteNo"`), it carries `.HasPrincipalKey(...)`; EF paired + the FK with the primary key instead, which failed model validation for a composite FK and + joined the wrong column for a single one. The reverse finder for such a reference now types its + value by the named target field, where it used the target's primary key type and did not + compile. + +- **C#: `identity.primary @generation: assigned` configures the key `ValueGeneratedNever()`.** + EF's convention made a single integer or Guid key generated on add, so a caller-supplied key + equal to the CLR default (`0`) was left out of the INSERT and the row refused, and + `EnsureCreated` built an identity column. `increment`, `uuid` and an absent `@generation` keep + EF's convention. + +- **C#: an int-backed enum refuses to write a value its `@intValueMap` does not describe.** The + write converter was `v == A ? 1 : v == B ? 2 : 3`, so the last member was the else branch: a + cast like `(Status)99`, or a member a `@provided` C# enum declares that `@values` does not, was + stored as the last member's integer, and a single-member enum wrote its constant whatever the + value. Every member now has its own branch, ending in a generated `UnmappedEnumMember` helper + that throws, as the read side already did with `UnmappedEnumValue`. Scalars, array elements + and flattened value-object members alike. + +- **C#: the reverse finders take `GenConfig.ContextTypeName`.** They hardcoded `AppDbContext` + as their first parameter's type, so a project that renamed its context got finders that did + not compile. + +- **C#: a "-sis" entity name pluralizes to "-ses" in DbSet and finder names.** `Diagnosis` gave + `DbSet Diagnosises` and `FindDiagnosisesByPatient`; it now gives `Diagnoses` and + `FindDiagnosesByPatient` (`Analysis` → `Analyses`, `Basis` → `Bases`). The `-tion`, `-y` and + `-s` endings were already right and are now pinned by tests. The REST collection segment is a + cross-port wire contract and keeps the shared rule (`/api/diagnosises`) until every port + changes together. An adopter that aliased the old DbSet name can drop the alias. **Upgrade + note:** code that names `Diagnosises` or `FindDiagnosisesBy…` stops compiling; use the new name, + or set `"@collectionName": "Diagnosises"` on the entity to keep the old one. + +- **TypeScript: a derived flattened `field.object` no longer produces flat member keys (#524 + follow-up).** A flattened field that carries an `origin.*` owns no column (the Drizzle table and + `meta migrate` skip it), but the flat keys (`shipToStreet`) still appeared in the read, create and + update schemas, the filter and sort allowlists, the OpenAPI bodies and the form, so a write dropped + them silently. The flattened member expansion now skips a derived parent, so every generated + surface agrees with the table. +- **TypeScript: Drizzle now binds a `field.object` with `@storage: flattened` to its member columns + (#524).** The generator used to emit one `jsonb` column named for the field, while `meta migrate` + creates one column per member of the value object and none for the field, so every generated + query failed with an undefined-column error. The Drizzle table now carries one column per member, + named by the same `resolveFlattenedColumnName` the migration uses, and the Zod schemas, the + Row/Insert types and the filter allowlist expose them as flat keys (`shipToStreet`), the same + surface Prisma already has. Generated queries, Hono and Fastify routes need no change. The client filter + type, the sort allowlist, the OpenAPI filter and sort parameters and the string-decimal wire + rewrite use the same flat keys. A flattened field on a write-through entity is refused with a + `CodegenError` instead of generating code that cannot work. A flattened field declared on a TPH + subtype keeps a single column named for the field, as `meta migrate` creates it, and a value + object that declares one keeps it as one nested key. The React form and the TanStack grid + columns use the same flat keys, so a form posts `shipToStreet`, not a nested `shipTo`. + +- **TypeScript: every `meta` command now loads the providers in `metaobjects.config.ts`.** + `meta export`, `meta deps`, `meta fmt`, `meta types` and `meta upgrade` loaded the core + vocabulary only, so a project's own subtype or attribute failed there while `meta gen` accepted + it. A config that exists but fails to load is now reported as its own error by `meta verify` + (exit 2, in every mode) and `meta prompt-snapshot`, instead of continuing without its providers + and reporting an unknown subtype. +- **Python: `metaobjects fmt` reads the configured providers, and `--provider` adds to them.** + `fmt` ignored `providers:` in `metaobjects.config.yaml` (it also gains `--config`), and + `metaobjects verify --provider` replaced the configured list instead of adding to it. +- **`ERR_COLUMN_NAME_COLLISION` no longer rejects a read-only view whose columns come from `@sql`.** + The 1.2.0 check treated every field of a sourced object as a column MetaObjects creates. For a + `source.rdb @kind: view` with an `@sql` body, the author's SQL defines the columns and the fields + only read them, so two fields on one column are legal and nothing can be written. That object is + now exempt in all four ports (TypeScript, Java, C#, Python), provided every source of the object + is read-only. A derived view (no `@sql`), which emits a select list from its fields, and an object + with a writable table source plus an `@sql` view replica are still checked. When both colliding fields already carry an + explicit `@column`, the message now says to rename one field or point one `@column` at a different + column, instead of suggesting a `@column` they already have. The error code is unchanged. New + conformance fixtures: `column-name-shared-in-sql-view-ok`, `error-column-name-collision-derived-view` and + `error-column-name-collision-table-with-sql-view`. +- **C# codegen: an entity that extends another no longer loses the parent's properties.** The member + loop skipped every inherited field but the class declaration never named the base, so the fields + appeared nowhere. A child of a **concrete** parent now declares the parent's properties itself and + names no base: each concrete entity owns a table with all its columns (what `meta migrate` creates + and the other ports' models carry), and `class Child : Parent` between two mapped entities is an EF + inheritance hierarchy (one shared table, or a child table holding only its own columns). A child of + an **abstract** parent with `EmitAbstractShapes` on now emits `class Child : Base`, as the + generator always meant to, and declares only its own members. Regenerating changes those two shapes + of C# output only. An adopter override of `EmitClassDeclarationLine` that names a concrete parent as + the base now gets that parent's properties twice; drop the base from the override. +- **Test flakes fixed at their cause.** `GenCommandTests.Gen_writes_the_hash_manifest_beside_the_metadata_not_in_cwd` + (C# Cli) failed about one run in five because `DependencyCliTests` runs `gen` in process, which + changes the process-wide working directory, without joining the serial collection every other + such class is in; the two classes ran in parallel and one read the other's directory as the cwd. + The codegen-ts tests that type-check generated output with the real TypeScript compiler (28 files, + the slowest case measured at 3.3s against bun's 5s default) now run under a 30s timeout whose value + lives in one place, `test/compile-timeout.ts`. Each of those files calls `setDefaultTimeout` with + it, because bun applies that call only to the file that makes it, so the timeout holds in a plain + `bun test` as well as in CI, and a loaded machine no longer reports a timeout for correct code. +- **A cross-field `validator.comparison` between fields of different kinds is skipped in every + port, never rejected and never a 500.** Comparing a `field.date` with a `field.timestamp` (or any + two strings or temporals of different subtype) has no ordering. Java and Kotlin cast both sides + to `Comparable` inside the class-level validity check, so the cast threw `ClassCastException` and + a create answered 500 instead of 400; TypeScript compared the two as strings and Python raised a + `TypeError` that surfaced as an invalid body. All five ports now follow one rule: numerics compare + with each other, strings and temporals only with their own subtype and `@localTime` flag (a + `field.timestamp` is an instant and a `@localTime` one a wall clock, which is a different native + type in every port), boolean and enum fields test + `eq` / `ne` only (also on two `uuid`, `uri` or `inet` fields), and any other pair emits no rule, so an + ordering test on two booleans or two enums is no longer enforced by the generated validators (C# never + did). The database `CHECK` still covers the pair where the database can compare it. New shared cases + `comparison-across-kinds-is-skipped`, `comparison-instant-vs-local-timestamp-is-skipped`, + `uuid-ne-rejects-equal-ids` and `uuid-ne-accepts-different-ids` + in `fixtures/validation-conformance/`, run by every port. +- **Two `field.duration` fields order by length in every port, and a comparison inside `@condition` + follows the same kind rule.** The kind rule above listed no durations, so a `validator.comparison` + between two durations emitted no rule in any port. Durations now order with their own subtype, by + length rather than by their ISO-8601 text (`PT45M` is shorter than `PT1H`). A comparison inside an + `@condition` that reads two fields of different kinds (a date against a timestamp, or an enum + against a string) now leaves the whole validator to the database, as a field it cannot see already + did, where TypeScript, Java and Kotlin had compared the two as strings and C# had compared an enum + with a string. An `eq` / `ne` inside `@condition` on two uuid, uri or inet fields now tests + equality in every port: Python ordered the two values, so an IPv4 against an IPv6 address read as + unknown and the rule was skipped, and C# skipped those comparisons altogether. C# also gave + `field.uri` and `field.inet` no filter operators, so `@filterable` on either, or any `@condition` + that reads one, failed to load; they now take the same bands as in the other ports (uri the string + band, inet the uuid band), and the shared `filter-ops-matrix` fixture lists both. New shared cases + `duration-comparison-rejects-a-longer-span`, `duration-comparison-orders-by-length-not-text`, + `condition-comparing-across-kinds-leaves-rule-to-database`, + `condition-ne-on-ipv4-and-ipv6-addresses-enforces-the-rule` and + `condition-ne-on-equal-addresses-lets-the-record-through`. +- **Test coverage for cross-field validators.** A subtype form on a TPH hierarchy that declares a + cross-field rule now has a test proving the generated form binds the refined body schema (the rule + itself was enforced by the cross-field build). The Java check that a Patch is not held to cross-field + validators now runs the generated classes (the violating body is rejected by the Dto and accepted + by the Patch) instead of comparing generated source text. + +- **`meta migrate` refuses, at plan time, to drop a column a view it does not own still reads.** + With `--from-db`, a declared-`@unmanaged` view or one outside the scoped schemas whose live body + names the dropped column now blocks the `drop-column`, and the message names the view and the + column. Before, the migration was written and failed at apply on both Postgres (`cannot drop + column … other objects depend on it`) and SQLite (`error in view … after drop column`). A view with + no recorded body is not matched, and an offline run cannot see live views. Pass + `--allow drop-column-read-by-view` (config token `drop-column-read-by-view`) to proceed. +- **The SQLite and D1 down migration for `drop-column` re-adds the column.** It wrote a TODO comment + and still recreated the view with the old SQL, so the view failed with `no such column` after a + rollback. It now runs `ADD COLUMN` from the recorded column, as Postgres does; the data is not + restored, and a `NOT NULL` column with no default comes back nullable, which is all SQLite allows. +- **Docs: edit an `@sql` body when you remove a column it reads.** The tool never parses the body; + Postgres fails at apply and SQLite applies and leaves a broken view. + +- **Postgres introspection reads a composite foreign key's columns once each, in order.** It joined + `information_schema.key_column_usage` to `constraint_column_usage`, which has no column position, so + every FK column was paired with every referenced column: a two-column FK read back as four columns and + a three-column one as nine. `meta migrate` reads its expected side back from the shadow database, so + the doubled columns reached the emitted DDL, which Postgres refused ("foreign key referenced-columns + list must not contain duplicates"); `verify --db` misreported every composite FK. It now reads + `pg_constraint`, pairing `conkey` with `confkey` by position. As before, only same-schema foreign + keys are read (the FK descriptor carries no referenced schema). + - **Python: an array field's `default` generated a string.** A model with `field.string[]: { default: "{}" }` generated `tags: list[str] = '{}'`, which fails on first use. It now generates `tags: list[str] = []`, from the same four spellings TypeScript accepts, or from a native YAML list such as `default: [a, b]`. A default Python cannot spell as a list is left to the database. +- **Java: a bare `@objectRef` on a field declared directly under `metadata.root` now resolves.** + A root-level `field.object` (the reusable template other fields `extends`) with + `@objectRef: "Address"` failed to load in Java even when `Address` sat in the same package, + while TypeScript loaded it. A root-level node now resolves a bare reference in its own + package, as ADR-0042 specifies, and a real miss still fails with `ERR_UNRESOLVED_OBJECT_REF`. + The error no longer names the loader as the owner of a root-level node. Two new conformance + fixtures (`root-level-field-object-bare-ref`, `error-root-level-field-objectref-unresolved`) + hold every port to it; C#, Python and TypeScript already passed. + +## [1.2.1] — Python only + +_PyPI `1.2.1` only. npm, NuGet and Maven Central stay at `1.2.0` (`8.2.0`): none of them has a +product change. No vocabulary or `metamodelVersion` change._ + +### Security + +- **The generated Python routes passed raw request input to the repository.** The FastAPI + create, PATCH and PUT handlers validated the body against `Create` / `Patch` + and then handed the repository the raw body, not what was validated. Pydantic ignores a key a + model does not declare, so a client could write fields it must never touch: a client-sent `id` + on create (or on update, changing the row's identity), a `@mutability: readOnly` field, and any + made-up field such as `isAdmin` all reached the repository. Found by an external review of + 1.2.0. Every Python adopter serving the generated routes should upgrade and regenerate; an + ejected (owned) router needs the same change made by hand. + + The repository now receives only the validated input, as the TypeScript routes already do. + Each handler validates the body, then keeps only the keys the input model validated, at every + depth (a nested value object included), before any repository call, in the plain and the TPH + per-subtype handlers. A field the entity does not declare, a server-generated id, a `readOnly` + or derived field on create, and the id, `readOnly` and `writeOnce` fields on update are all + dropped silently. None of them is answered with a 400, so a client that sends an extra harmless + field keeps working; a malformed value on a field the client may set is still + `400 {"error": "validation"}`. An assigned key is still the caller's on create. Values are the + body's own, so a repository receives the same value types as in 1.2.0. + + Gated by `server/python/tests/integration/test_generated_router_validated_input.py`. ## [1.2.3] — 2026-11-15 @@ -1385,34 +3012,6 @@ file changes. No vocabulary or `metamodelVersion` change._ from it in parallel, or a parallel test run, hit this. The cache is now a `ConcurrentDictionary`. -## [1.2.1] — Python only - -_PyPI `1.2.1` only. npm, NuGet and Maven Central stay at `1.2.0` (`8.2.0`): none of them has a -product change. No vocabulary or `metamodelVersion` change._ - -### Security - -- **The generated Python routes passed raw request input to the repository.** The FastAPI - create, PATCH and PUT handlers validated the body against `Create` / `Patch` - and then handed the repository the raw body, not what was validated. Pydantic ignores a key a - model does not declare, so a client could write fields it must never touch: a client-sent `id` - on create (or on update, changing the row's identity), a `@mutability: readOnly` field, and any - made-up field such as `isAdmin` all reached the repository. Found by an external review of - 1.2.0. Every Python adopter serving the generated routes should upgrade and regenerate; an - ejected (owned) router needs the same change made by hand. - - The repository now receives only the validated input, as the TypeScript routes already do. - Each handler validates the body, then keeps only the keys the input model validated, at every - depth (a nested value object included), before any repository call, in the plain and the TPH - per-subtype handlers. A field the entity does not declare, a server-generated id, a `readOnly` - or derived field on create, and the id, `readOnly` and `writeOnce` fields on update are all - dropped silently. None of them is answered with a 400, so a client that sends an extra harmless - field keeps working; a malformed value on a field the client may set is still - `400 {"error": "validation"}`. An assigned key is still the caller's on create. Values are the - body's own, so a repository receives the same value types as in 1.2.0. - - Gated by `server/python/tests/integration/test_generated_router_validated_input.py`. - ## [1.2.0] — 2026-10-30 _npm `1.2.0` (full lockstep across all 14 `@metaobjectsdev/*` publish candidates)._ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 709cb8c33e..b2eca094c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -78,6 +78,14 @@ cd server/python && pytest # Python (in its .venv) Cross-language persistence / api-contract corpora (Docker + Testcontainers) run via `scripts/integration-test.sh`. +Throwaway test databases stay off the drives. The Docker-backed launchers (Postgres, MySQL, the +Cube stack and the `scripts/ci-local.sh` Postgres sidecar) keep each database's data directory on +a size-capped tmpfs with Postgres durability off, and remove the container when the run ends. +The Stryker mutation gate (`bun run conformance:mutation` in +`server/typescript/packages/metadata`, via `scripts/run-stryker.sh`) builds its sandbox under +`$DEV_SCRATCH` when that is set, else the system temp directory, and removes it on exit. Point +`DEV_SCRATCH` at a RAM-backed directory to keep that scratch off disk. + ### Local CI (the checks GitHub runs — run it before opening a PR) GitHub Actions is enabled on this repository. The check workflows in @@ -86,11 +94,10 @@ definition of the checks: each wrapper checks out, installs the toolchains its lane needs, and calls the script, so a local run is the same check a workflow run would be. A pull request runs the leak scan (`hygiene.yml`) and `pr-ci.yml`, which runs the unit tests and conformance corpora of only the ports the PR touches (a change -under `fixtures/`, `spec/`, `scripts/`, `.github/` or `agent-context/`, or to any file +under `fixtures/`, `spec/`, `scripts/`, `.github/`, `agent-context/` or `docs/`, or to any file outside a port's directory that the selector does not recognise, touches every port; a -change only to `docs/` or to Markdown files outside those directories runs just the -offline gates). Its `pr-ci` job is green only when every selected lane is, and a newer -push cancels the superseded run. The docker integration suites run on release tags and on +change only to the root prose files above runs just the offline gates). Its `pr-ci` job is +green only when every selected lane is, and a newer push cancels the superseded run. The docker integration suites run on release tags and on manual dispatch. Run the script locally before opening or merging a PR, so nothing red reaches `main`: @@ -102,9 +109,30 @@ scripts/ci-local.sh # full parity: hygiene.yml's leak-scan, all-port scripts/ci-local.sh --quick # hygiene.yml in full + the TypeScript half of # conformance.yml; skips the C#/Java/Kotlin/Python # ports, the java reactor and the docker suite +scripts/ci-local.sh --affected # only the lanes this change needs (see below) MO_CI_LIST_ONLY=1 scripts/ci-local.sh --quick # print the steps, run nothing ``` +**`--affected` runs only what a change can break.** It lists the paths you changed since the +merge base with the base branch (committed, uncommitted and untracked), maps each to lanes +with the table in [`scripts/ci-lane-map.txt`](scripts/ci-lane-map.txt), and prints the lanes it +selected, the lanes it skipped and the rule each path matched, so a reviewer can see what was +not run. A change confined to one port runs that port (`ts-fast` and `ts-unit` for TypeScript +and the web client, `java-slow`, `python`, `csharp`); a change to `fixtures/`, `spec/`, +`scripts/` (the map included), `.github/`, `agent-context/`, anything under `docs/` (port +tests read those pages) or any path no rule claims runs every lane, because unknown means +full; a change to only the root `README.md`, `CHANGELOG.md`, `CONTRIBUTING.md`, `AGENTS.md` +or `CLAUDE.md` runs no lane. It never runs `gates` (`--only gates` does, on every change) and +never the docker half, so a change confined to the Java port skips the Java docker +integration suites, which run on release tags and manual dispatch. When more than one port +is selected their lanes run in parallel, as the full run's do, so a change is never slower +than the full run; one port runs serially. Mutation testing is as before: diff-scoped inside +`ts-fast`. `MO_CI_FULL=1 scripts/ci-local.sh --affected` forces every lane, +`MO_CI_AFFECTED_BASE=` picks the base, and `scripts/ci-select-lanes.sh []` explains +a selection without running anything. The flagless run above is unchanged and is what +[releases](docs/RELEASING.md) use. The same map drives `pr-ci.yml`'s port detection, and +`scripts/test-ci-lane-selection.sh` (in the `gates` lane) pins what each kind of change selects. + The full run does its tree-writing steps first (install, the drift gates, one workspace build), then runs the rest as parallel lanes: at most `MO_CI_JOBS` at once, default 8. Each lane's output prints as one block when the lane finishes, so lanes never interleave. The @@ -119,12 +147,13 @@ gate and a Java pom-version drift guard on every push (activate hooks once per clone: `git config core.hooksPath .githooks`). If you drive changes through the no-mistakes validation gate, `.no-mistakes.yaml` pins its -`test` step to `scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchains` and -its `lint` step to `scripts/ci-local.sh --only gates --strict-toolchains` — together exactly -`--quick`, split so neither step repeats the other's work. `--strict-toolchains` is part of -both: it promotes a SKIP to a FAIL, so a gate host missing bun cannot report green. Those -commands are read from the **default branch**, so editing them on a feature branch has no -effect until it merges. +`test` step to `scripts/ci-local.sh --affected --strict-toolchains` and its `lint` step to +`scripts/ci-local.sh --only gates --strict-toolchains`: the lanes the change affects, then +the gates every change runs, split so the gates run after the build `test` does. +`--strict-toolchains` is part of both: it promotes a SKIP to a FAIL, so a gate host missing +bun (or, for a change to a port, that port's toolchain) cannot report green. Those commands are +read from the **default branch**, so editing them on a feature branch has no effect until it +merges. ## Releasing diff --git a/README.md b/README.md index a045a7ee4e..c253871fe9 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,11 @@ gated by `meta verify --codegen`, which is what keeps output from drifting. See [write your own generator](docs/recipes/write-your-own-generator.md). Java, Kotlin, C# and Python start the same way from their own package: see -[`docs/ports/`](docs/ports/). +[`docs/ports/`](docs/ports/). **Their schema migrations and database checks still run in the +Node `meta` tool** (`npx meta migrate`, `npx meta verify --db`), so those teams need Node where +migrations are written or applied. Where the ports behave differently (list defaults, error +bodies, field names, data access) is listed in +[What differs by language](docs/features/language-differences.md). The metamodel is the **durable spine**; generated code is the **disposable artifact**. Substrate is local-first: typed metadata lives in your repo as YAML or @@ -187,7 +191,7 @@ first-week wedge plan — and `meta init` picks up from there. | Capability requirements (`requirement.*`) | `meta verify` gate + authoring lint; `requirementTests()` stubs | `mvn metaobjects:verify` gate; JUnit Jupiter `requirement-tests` | Gate via the Java Maven goal; JUnit Jupiter `requirement-tests` | `dotnet meta verify` gate; xUnit `requirement-tests` | `metaobjects verify` gate; pytest `requirement-tests` | | Reporting vocabulary (`dimension` / `measure` / `segment` / `object.report`, FR-044) | Registered; a view-backed report becomes a SQL view in `meta migrate`, is read by `ObjectManager`, and gets generated read-only list routes and a TanStack list hook (no grid or form); the `cube-model` generator writes the vocabulary as Cube data-model files | Registered; OMDB reads a view-backed report; generates a read-only Spring controller, DTO, repository and filter allowlist | Registered (via Java); generates an Exposed table object, a row data class, a filter allowlist and a read-only Spring controller per view-backed report | Registered; generates a keyless EF Core row type, read-only routes and a filter allowlist per view-backed report | Registered; `ObjectManager` reads a view-backed report; generates a Pydantic row model, a read-only FastAPI router and a filter allowlist | | Libraries (`libraries: [...]`) | Yes | Yes | Yes (via Java) | Yes | Yes | -| Metadata dependencies (`dependencies`) | Yes (`meta deps sync`: `path`, `npm` and `python` transports) | Yes (loads the synced snapshot; `meta deps sync` is Node) | Yes (via Java) | Yes (loads the synced snapshot) | Yes (loads the synced snapshot) | +| Metadata dependencies (`dependencies`) | Yes (`meta deps sync`: `path`, `npm`, `python`, `maven` and `nuget` transports) | Yes (loads the synced snapshot; `-Dmeta.verify.mode=deps` checks drift; `meta deps sync` is Node) | Yes (via Java) | Yes (loads the synced snapshot) | Yes (loads the synced snapshot) | | Runtime metadata (ObjectManager-style) | Yes (`runtime-ts`) | Yes (OMDB) | Yes (via Java OMDB + Exposed) | Roadmap | Yes (ObjectManager) | | React / Angular UI client (browser) | React: **published** (`@metaobjectsdev/react` + `@metaobjectsdev/tanstack`), codegen + runtime. Angular 18: **source-only by decision** ([ADR-0048](spec/decisions/ADR-0048-angular-tier-source-only.md)) — `@metaobjectsdev/angular` + `@metaobjectsdev/codegen-ts-angular` build in-repo on their own `0.6.x` line but are deliberately not on npm (`npm i @metaobjectsdev/angular` will 404) until they meet the ADR's promotion bar. Consume them from source. | Consumes TS client via REST | Consumes TS client via REST | Consumes TS client via REST | Consumes TS client via REST | | Own a generator (`eject`) | Yes (`meta eject`) | Yes (`mvn metaobjects:eject`) | Yes (`mvn metaobjects:eject`) | Yes (`dotnet meta eject`) | Yes (`metaobjects eject`) | @@ -276,11 +280,11 @@ sixth ships two libraries at their own stability labels: into its `/db` layer (`["iam", "iam/db"]`). Copy one into your repo with `meta eject `. See [`docs/features/libraries.md`](docs/features/libraries.md). -**Sharing a model across your own projects** *(the TypeScript toolchain publishes; -TypeScript, Python, Java, Kotlin and C# projects consume, from an installed npm or Python -package or over a `path` dependency such as a sibling checkout)* — one project publishes -part of its model (a common `Customer`, an audited base, a set of enums) with -`sharedModelFile()`, and another declares it in `dependencies`, syncs it into a +**Sharing a model across your own projects** *(TypeScript, Java, Kotlin and C# projects +publish; TypeScript, Python, Java, Kotlin and C# projects consume, from an installed npm or +Python package or over a `path` dependency such as a sibling checkout)* — one project publishes +part of its model (a common `Customer`, an audited base, a set of enums) with its `shared-model` +generator (`sharedModelFile()` in TypeScript), and another declares it in `dependencies`, syncs it into a committed, hash-locked snapshot and builds on it with `extends` and references. When the publisher's model moves, `meta verify --deps` says so, instead of two copies drifting apart. See [`docs/features/metadata-dependencies.md`](docs/features/metadata-dependencies.md). @@ -341,6 +345,11 @@ metaobjects/ | C# | `dotnet tool install --global MetaObjects.Cli` → [`docs/ports/csharp.md`](docs/ports/csharp.md) | | Python | `pip install metaobjects` → [`docs/ports/python.md`](docs/ports/python.md) | +Every language also needs the Node `meta` CLI for the schema: `npm i -D @metaobjectsdev/cli`, +then `npx meta init --config-only` in a Maven-, .NET- or pip-rooted project, and +`npx meta migrate` / `npx meta verify --db` from there. The per-language differences are in +[What differs by language](docs/features/language-differences.md). + ## Cross-language conformance Every port runs against the same fixture corpora at [`fixtures/`](fixtures/). diff --git a/agent-context/README.md b/agent-context/README.md index c58135e9f9..f2e32b7625 100644 --- a/agent-context/README.md +++ b/agent-context/README.md @@ -2,14 +2,17 @@ This tree is the single source the assembler (`@metaobjectsdev/sdk`, `src/agent-context/`) turns into the files scaffolded into a consumer project: -the slim always-on Markdown (`.metaobjects/AGENTS.md` + `CLAUDE.md`) and the six -`metaobjects-*` Claude skills (each a universal `SKILL.md` plus the -`references/.md` fragments matching the project's resolved stack). +the slim always-on Markdown (`.metaobjects/AGENTS.md`, imported by the project's root +`AGENTS.md` / `CLAUDE.md`) and the six `metaobjects-*` skills (each a universal `SKILL.md` plus +the `references/.md` fragments matching the project's resolved stack). The skills +install under `.claude/skills/` unless `--skills-dir` names another directory (such as +`.agents/skills/`); the always-on text names the directory through `{{skillsDir}}`. -- `servers/.meta.json` — per-server install + codegen command (drives the always-on). -- `templates/always-on.md.mustache` — the slim always-on body (`{{stackLine}}`, `{{codegenCommand}}`). +- `servers/.meta.json` — per-server install, codegen command and the always-on's verify step (`verifyStep`). +- `templates/always-on.md.mustache` — the slim always-on body: a working loop first (`{{stackLine}}`, `{{stackLoops}}`, `{{verifySteps}}`), the REST conventions agents trip on, then the rules and the skill pointers (`{{skillsDir}}`). The full principles it shortens live in `metaobjects-codegen/references/principles.md`. +- `templates/loops/.md`, `templates/loops/client.md` — the generate steps of that loop, one per declared server (and one for a web client), concatenated by the assembler. - `skills//SKILL.md` — universal skill body. -- `skills//references/.md` — language/framework or concern fragment; installed iff `` is in the stack (`Stack.tokens`; concern tokens are OBSERVED from project state, e.g. `requirements` for a project declaring `requirement.*` nodes — see `SDK`'s `CONCERN_TOKENS`). +- `skills//references/.md` — language/framework fragment; installed iff `` is in the stack (`Stack.tokens`). The requirements pages are universal topic files: they install in every stack, because whether a project declares `requirement.*` nodes changes after `meta init` runs. - `skills//references/-.md` — a topic split out of a `.md` fragment; scoped by the same token. - `skills//references/.md` — any other name is a universal topic file and installs in every stack; the skill's `SKILL.md` says when to open it. @@ -17,7 +20,7 @@ The **scaffolded** set is exactly the six skills in the SDK's `SKILL_NAMES` (`src/agent-context/types.ts`) — the assembler emits only those. `skills/` additionally holds **`metaobjects-fit-assessment`**, a *pre-adoption* tool that is deliberately **not** in `SKILL_NAMES` and so is never scaffolded (a not-yet-adopted -target has no `.claude/skills/metaobjects-*` to receive it); it carries +target has no installed `metaobjects-*` skills to receive it); it carries `scaffold: false` under `metadata:` in its front-matter as the human marker (no code reads it). Its design + retro-test validation live in `docs/superpowers/specs/2026-07-12-metaobjects-fit-assessment-design.md`. diff --git a/agent-context/evals/README.md b/agent-context/evals/README.md index f4f3cc5895..355d6de9ec 100644 --- a/agent-context/evals/README.md +++ b/agent-context/evals/README.md @@ -7,6 +7,13 @@ one-message prompt plus a `tool_used: Skill` grader: positive cases require the fire, negative cases (near-misses: LLM code in a project that does not use MetaObjects prompts, model edits that need no generated output) forbid it. +Most cases are a fresh request. The `*-midtask-*` cases are the shape real work takes: the +prompt states what has already been done in the session (entities declared, `meta gen` run, a +migration applied) and then the next step. A skill that fires only on an opening request and +never once the agent is past the loop in the always-on file is the failure they catch, and the +negative ones catch the opposite: a skill loaded for a step the loop already covers (writing +business logic over generated types, running a rename migration). + - `skill-triggers//-pos-*|neg-*/` — `prompt.md` and `graders/trigger.md`, in the `claude plugin eval` case format. - `run-skill-triggers.sh` — wraps `agent-context/skills` in a throwaway plugin (all seven @@ -18,7 +25,7 @@ prompts, model edits that need no generated output) forbid it. agent-context/evals/run-skill-triggers.sh ``` -It starts real Claude sessions on your own login (25 cases x 3 runs = 75 sessions, a few +It starts real Claude sessions on your own login (31 cases x 3 runs = 93 sessions, a few minutes with `-j 4`) and writes `/result.json`. Use `--case ''` to run a subset. It is manual-only and not part of CI, because model behaviour is not deterministic. diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/graders/trigger.md new file mode 100644 index 0000000000..b8e0fb8475 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/graders/trigger.md @@ -0,0 +1,6 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-codegen +min: 1 +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/prompt.md b/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/prompt.md new file mode 100644 index 0000000000..effedb7844 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/13-pos-midtask-generated-shape-wrong/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects (it has .metaobjects/config.json and a metaobjects/ directory of meta.*.json files). Progress so far: you added the Order and OrderLine entities, ran `npx meta gen`, and wired the generated Drizzle tables into the service. The typecheck now fails because the generated OrderLine.ts exports `orderLineInsertSchema` and the service expects `OrderLineInsert` as a named type next to it. Make the generated file export that type on every regen. diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/graders/trigger.md new file mode 100644 index 0000000000..b8e0fb8475 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/graders/trigger.md @@ -0,0 +1,6 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-codegen +min: 1 +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/prompt.md b/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/prompt.md new file mode 100644 index 0000000000..01cf245256 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/14-pos-midtask-need-new-output/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects (it has .metaobjects/config.json and a metaobjects/ directory of meta.*.json files). Progress so far: entities are declared, `npx meta gen` writes the Drizzle tables, and the first migration is applied. Next on the task list: the admin service needs a TypeScript map from each entity name to its list of searchable column names, kept in step with the metadata. Nothing in `meta gen --list` emits it. Produce it. diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/graders/trigger.md new file mode 100644 index 0000000000..5a6f0d6123 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/graders/trigger.md @@ -0,0 +1,8 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-codegen +min: 0 +max: 0 +arm: both +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/prompt.md b/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/prompt.md new file mode 100644 index 0000000000..8b4e2ead6d --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/15-neg-midtask-business-logic/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects (it has .metaobjects/config.json and a metaobjects/ directory of meta.*.json files). Progress so far: the Invoice entity is declared, `npx meta gen` wrote Invoice.ts with its Drizzle table and Zod schemas, and the migration is applied. Next: in src/billing/totals.ts, write the function that sums an invoice's lines, applies the customer's discount percentage and rounds to cents. diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/graders/trigger.md new file mode 100644 index 0000000000..5a6f0d6123 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/graders/trigger.md @@ -0,0 +1,8 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-codegen +min: 0 +max: 0 +arm: both +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/prompt.md b/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/prompt.md new file mode 100644 index 0000000000..e270bf7f55 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-codegen/16-neg-midtask-rename-migration/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects (it has .metaobjects/config.json and a metaobjects/ directory of meta.*.json files). Progress so far: you renamed the Customer field `fullName` to `displayName` in metaobjects/meta.crm.json and regenerated. Now write the migration for it with `npx meta migrate` so the existing data in that column is kept. diff --git a/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/graders/trigger.md new file mode 100644 index 0000000000..ba923f268c --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/graders/trigger.md @@ -0,0 +1,6 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-prompts +min: 1 +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/prompt.md b/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/prompt.md new file mode 100644 index 0000000000..ff5fa22466 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-prompts/14-pos-midtask-inline-prompt/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects, including declared prompt templates (template.prompt nodes under metaobjects/ and their text under prompts/). Progress so far: you built the TicketSummary endpoint and it works. While wiring it you wrote the LLM call in src/tickets/summarize.ts with the prompt as a template literal that interpolates ticket.title, ticket.body and the last five comments, and you parse the reply with JSON.parse. Before you commit, bring that call in line with how this project does prompts. diff --git a/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/graders/trigger.md b/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/graders/trigger.md new file mode 100644 index 0000000000..7b6368ff0b --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/graders/trigger.md @@ -0,0 +1,8 @@ +--- +type: tool_used +tool: Skill +input_match: metaobjects-prompts +min: 0 +max: 0 +arm: both +--- diff --git a/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/prompt.md b/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/prompt.md new file mode 100644 index 0000000000..1867bf0e68 --- /dev/null +++ b/agent-context/evals/skill-triggers/metaobjects-prompts/15-neg-midtask-retry-wrapper/prompt.md @@ -0,0 +1,8 @@ +--- +max_turns: 3 +timeout_seconds: 180 +allowed_tools: [Skill] +runs: 3 +--- + +This project uses MetaObjects, including declared prompt templates (template.prompt nodes under metaobjects/ and their text under prompts/). Progress so far: the TicketSummary prompt is declared, rendered and parsed through the generated code, and its tests pass. Next: the HTTP client that sends the rendered prompt to the model sometimes gets a 529. Add a retry with exponential backoff, three attempts, around that client call in src/llm/client.ts. diff --git a/agent-context/servers/csharp.meta.json b/agent-context/servers/csharp.meta.json index aeb474cb45..6d033e575a 100644 --- a/agent-context/servers/csharp.meta.json +++ b/agent-context/servers/csharp.meta.json @@ -2,8 +2,5 @@ "displayName": "C#", "install": "install the MetaObjects .NET tool (dotnet tool install) + add the MetaObjects.Codegen package", "codegenCommand": "dotnet meta gen", - "docsCommand": "dotnet meta gen", - "docsCondition": " (when the project's generator list declares the ApiDocsGenerator)", - "docsMissing": "Declare `ApiDocsGenerator` in the generator list in codegen/Generators.cs if it is missing", - "apiSubDir": "api/csharp" + "verifyStep": "`dotnet meta verify --codegen` (the generated code and the requirements)" } diff --git a/agent-context/servers/java.meta.json b/agent-context/servers/java.meta.json index b0fffe2464..b9ee208f5b 100644 --- a/agent-context/servers/java.meta.json +++ b/agent-context/servers/java.meta.json @@ -2,8 +2,5 @@ "displayName": "Java", "install": "add com.metaobjects:metaobjects-metadata + metaobjects-codegen-spring + metaobjects-maven-plugin to your pom.xml", "codegenCommand": "mvn metaobjects:generate", - "docsCommand": "mvn metaobjects:generate", - "docsCondition": " (when the project's generator list declares the api-docs generator)", - "docsMissing": "Declare `com.metaobjects.generator.apidocs.JavaApiDocsGenerator` as a `` entry in the pom's `` if it is missing", - "apiSubDir": "api/java" + "verifyStep": "`mvn metaobjects:verify` (the generated code and the requirements)" } diff --git a/agent-context/servers/kotlin.meta.json b/agent-context/servers/kotlin.meta.json index 72beb7ef8f..2a91b8f567 100644 --- a/agent-context/servers/kotlin.meta.json +++ b/agent-context/servers/kotlin.meta.json @@ -2,8 +2,5 @@ "displayName": "Kotlin", "install": "add com.metaobjects:metaobjects-codegen-kotlin + metaobjects-metadata-ktx + metaobjects-maven-plugin to your pom.xml", "codegenCommand": "mvn metaobjects:generate", - "docsCommand": "mvn metaobjects:generate", - "docsCondition": " (when the project's generator list declares the api-docs generator)", - "docsMissing": "Declare `com.metaobjects.generator.kotlin.apidocs.KotlinApiDocsGenerator` as a `` entry in the pom's `` if it is missing", - "apiSubDir": "api/kotlin" + "verifyStep": "`mvn metaobjects:verify` (the generated code and the requirements)" } diff --git a/agent-context/servers/python.meta.json b/agent-context/servers/python.meta.json index f6ab39c486..f852f76310 100644 --- a/agent-context/servers/python.meta.json +++ b/agent-context/servers/python.meta.json @@ -2,8 +2,5 @@ "displayName": "Python", "install": "pip install metaobjects", "codegenCommand": "metaobjects gen", - "docsCommand": "metaobjects gen", - "docsCondition": " (when a target's generator list declares `api-docs`)", - "docsMissing": "Declare `api-docs` in that target's `generators` in metaobjects.config.yaml if it is missing", - "apiSubDir": "api/python" + "verifyStep": "`metaobjects verify` (the generated code and the requirements; `--codegen` is its default)" } diff --git a/agent-context/servers/typescript.meta.json b/agent-context/servers/typescript.meta.json index 65f9e1dbd2..8af887ac43 100644 --- a/agent-context/servers/typescript.meta.json +++ b/agent-context/servers/typescript.meta.json @@ -2,8 +2,5 @@ "displayName": "TypeScript", "install": "npm install -D @metaobjectsdev/cli @metaobjectsdev/codegen-ts", "codegenCommand": "npx meta gen", - "docsCommand": "npx meta gen", - "docsCondition": "", - "docsMissing": "", - "apiSubDir": "api" + "verifyStep": "`npx meta verify --codegen` (the generated code and docs pages; the requirement gate runs on every `meta verify`)" } diff --git a/agent-context/skills/metaobjects-audit/SKILL.md b/agent-context/skills/metaobjects-audit/SKILL.md index d483666b1e..36be5db541 100644 --- a/agent-context/skills/metaobjects-audit/SKILL.md +++ b/agent-context/skills/metaobjects-audit/SKILL.md @@ -25,7 +25,7 @@ Actual cutovers run through the existing skills mapped per finding tier (§ Brid | `references/calibration.md` | Before raising any finding: it lists the port gaps and non-defects that are never the adopter's fault. | | `references/surface-review-axes.md` | Working any axis (A–I) of Phase 1b. | | `references/capability-checklist.md` | On every axis: the exhaustive list of what the metamodel can express, one hunt per capability. | -| `references/drift-signatures.md` | Hunting hand-written second sources of truth (validators, mappers, comments, views, JSON bags). | +| `references/drift-signatures.md` | Hunting hand-written second sources of truth (validators, mappers, comments, views, JSON bags, physical-name literals, enum-member and event-name literals). | | `references/prompt-anti-patterns.md` | Axis D: the project builds text sent to an LLM or parses a reply. | | `references/vocabulary-hygiene.md` | Axis I: retired or deprecated authoring forms, custom vocabulary, vocabulary opportunities. | | `references/requirements.md` | Axis E2: the project declares `requirement.*` nodes. | @@ -65,7 +65,13 @@ Actual cutovers run through the existing skills mapped per finding tier (§ Brid not removed or reordered ones: confirm those from the file's history (`git log -p -- codegen/generators/.ts` shows no edit after the eject) first, and report a copy you cannot confirm as "possibly customized: check its history", not as a - copy to drop. For `entity`, + copy to drop. **A copy with lines of its own is not proof of a customization either.** + `meta eject --list` (and each port's listing) prints `DIFFERS` for BOTH a deliberate + customization and a copy gone stale by version, and its `M of your own` count includes + every line the reference has since removed or rewritten, which are older upstream lines. + Run the history check on every `DIFFERS` row, `M` above 0 included, and report the two + figures separately: lines behind the reference, and lines of the project's own that the + history confirms. A copy stale by version is a finding (`owned-generator-stale`). For `entity`, `routes` and `routes-hono` that holds only when every `codegen/runtime/` file the copy reaches is also marked identical: an edited adapter is a customization, and such a copy is not a finding. Those runtime rows appear only with `--format text` (or as the @@ -74,7 +80,13 @@ Actual cutovers run through the existing skills mapped per finding tier (§ Brid `queriesFile` / `routesFile` / `barrel` on a 1.0.x install** fails to load, because 1.0 removed those four and 1.1 restored them: there it is an upgrade blocker, fixed by upgrading to 1.1 or by ejecting. Importing anything from that subpath is otherwise - correct and is never a finding by itself. + correct and is never a finding by itself. **Every port owns generators the same way**: + run the owned-copy check in each port reference the project uses (TypeScript + `meta eject --list --format text`, Python `metaobjects gen --list`, Java / Kotlin + `mvn metaobjects:eject -Dlist`, C# `dotnet meta gen --list`), and report ONE total across + all of them: **unmodified owned-generator lines / all owned-generator lines**, where + unmodified counts only copies proven unmodified. Report the proven copies together as + one finding, `owned-generator-stock-copies`, listing each copy and the port's undo command. - [ ] **Cross-language version consistency (silent-drift check).** If the project uses MetaObjects in more than one language (e.g. a TS web client + a Java/Python/C# backend), enumerate EVERY MetaObjects package across ALL ecosystems (npm `@metaobjectsdev/*`, Maven `com.metaobjects:*`, PyPI `metaobjects`, NuGet `MetaObjects.*`) and record each version. **The version-number LINES differ by ecosystem (npm/PyPI/NuGet `0.x`/`1.x` vs Maven `7.x`/`8.x`), so you CANNOT eyeball drift** — a `0.12` next to a `7.7` looks fine but can be badly out of sync. Compare the **`metamodelVersion`** each port reports (the shared spec version on the registry manifest): a mismatch is real cross-language drift and a **finding** — the ports disagree on vocabulary/wire behavior. A match is not enough on its own: added vocabulary does not move `metamodelVersion`, so also compare each port's release (each ecosystem's version for one CHANGELOG entry). A port on an older release is a **finding** when the model uses vocabulary that release lacks. Also flag any port not on the latest release for its ecosystem. (This is a known real-world failure mode: newest backend, stale client, invisible because the numbers differ.) - [ ] Classify: **Greenfield** (none/minimal) · **Partial** · **Deep** → choose path below. @@ -103,6 +115,20 @@ code grows. The gap between "modeled + query helpers" and "has view + route + UI" is the headline lopsidedness. +**Shape coverage census.** The coverage matrix lists modelled entities only, so a shape +nobody modelled never appears in it. Count the other side too. List every shape that crosses +a boundary: database tables and views, request and response bodies, queue and socket +messages, prompt inputs, LLM replies, and file formats the project reads or writes. For each +shape, record whether it is modelled, and for each layer that states it (DDL or migration, +ORM model, validator, DTO, client type, prompt payload, reply parser) whether that statement +is **generated**, **derived** from generated code (a type built from a generated type, a +`z.infer` of a generated schema), or **hand-declared**. Report +`generated or derived statements / all statements` and list the unmodelled shapes. A table +present in the database or the migrations with no entity or projection behind it is a +finding (`unmodelled-table`). Like the leverage ratio this is a measurement, never a target: +an unmodelled shape is a finding only where the cost test in § Owned-codegen says modelling it +pays, or it is a table. + **Surface review — 8 axes (independently runnable).** Work the full `references/capability-checklist.md` on every axis. Check calibration guards (`references/calibration.md`) before raising a finding. **Verify, don't assume** — read the @@ -113,8 +139,8 @@ Axes (the full hunt for each is in `references/surface-review-axes.md` — open - **A.** Codegen candidates — API / server routes · **B.** Codegen candidates — web / client - **C.** Drift hotspot — validators, mappers, runtime models · **D.** Prompt pillar - **E.** Owned generators and scaffold-and-own · **E2.** Capability ledger (`requirement.*`, opt-in) -- **F.** Drift-gate adoption · **F2.** Over-generation (codegen waste) -- **G.** Runtime-contract anti-patterns · **G2.** `own*()` accessor discipline (a correctness defect, not advisory) +- **F.** Drift-gate adoption — does it block? · **F2.** Over-generation and generated-but-bypassed (codegen waste) +- **G.** Runtime-contract anti-patterns · **G2.** `own*()` accessor discipline (a correctness defect, not advisory) · **G3.** Guarded status transitions (every write to a status-like enum column is conditional on the current value; the fix goes through the port's ORM with generated constants, never raw SQL) - **H.** Authoring correctness / ADR conformance · **H2.** Wrong native type (`field.string` + `@dbColumnType: uuid`) - **I.** Vocabulary hygiene / modernization (advisory, never a failing finding) @@ -153,7 +179,9 @@ hidden candidate. **Stub trap:** demo-data routes have nothing to replace — cl the Phase 0 owned-generators check: recommend the package import. Importing any other generator from that subpath is correct and is not a finding. - Audit owned generators: (a) regenerate clean? (b) drifted from reference templates — - intentional (good) vs stale/accidental (missed upstream fix)? (c) hand-rolling a walk + intentional (good) vs stale/accidental (missed upstream fix)? Decide it from the copy's + history, not from the listing's `own` count: `DIFFERS` reads the same for both, and lines + the reference has since removed count as "own" (Phase 0, owned-generators check). (c) hand-rolling a walk that a declarative `scope` + `outputPattern` could replace? (d) bespoke shape better as a `templateGenerator` than a forked generator? - **Authoring ladder:** built-in fits → import it as shipped · close → **eject it and @@ -186,8 +214,8 @@ When folding hand validators into metadata, apply human judgment per constraint. A constraint enters **shared metadata** only if it is a **true cross-language domain invariant**; a one-consumer preference stays in a thin local refinement layer. -Cross-field rules **are** modelable (`comparison` / `atLeastOne` / `requiredWhen` / -`presentIff`); ratification decides *which* belong in shared metadata. Output a +Cross-field rules **are** modelable (`comparison` / `atLeastOne` / `exactlyOne` / +`requiredWhen` / `presentIff`); ratification decides *which* belong in shared metadata. Output a **ratification table**: KEEP-IN-METADATA / LOCAL-REFINEMENT / DROP + rationale — human-approved, never applied silently. Distinguish `required` from has-a-safe-default (`@default` often fixes the over-requiring bug). A core attr ripples cross-port; for a @@ -199,14 +227,36 @@ one-consumer need, read it codegen-locally. 1. **Headline MATURITY TIER** — Greenfield → Partial → Deep → Exemplary; worst-of with prerequisite gating (a missing pillar can't be averaged away); rendered with **the single - next unmet check** ("you're Partial; the next rung needs `verify` in CI"). + next unmet check** ("you're Partial; the next rung needs a blocking `verify` in CI"). 2. **Per-pillar breakdown (never rolled into one number)** — `pillar | tier | top gap` over codegen / runtime / drift-gate / prompts. This is the core deliverable. -3. **Binary CI drift gate** — prominent and separate: **"Is `meta verify` drift detection - wired into CI?"** It is binary because the risk is binary. - -Coarse bands only (none / some / most / all). Worst-of within a pillar. On re-run, grade -the delta. Lead with gaps, not the grade. +3. **Binary CI drift gate** — prominent and separate: **"Does `meta verify` drift detection + block every route to production?"** It is binary because the risk is binary. YES only + when axis F scores the gate **BLOCKING**; RUNS BUT DOES NOT BLOCK and ABSENT both answer + NO, with the reason (exit code swallowed, tolerated error count, a deploy path that + skips it, no CI). Local hooks with no tracked installer do not count. +4. **Used as described** — one line, separate from the tier: does the project use what it + adopted the way MetaObjects documents it? Built from four measurements, each shown with + its numbers: generated artifacts consumed rather than bypassed (axis F2, `consumed / + emitted` and the `generated-and-bypassed` count); the gate blocks (axis F score); prompt + payload fields linked to entity fields (axis D, `linked / (linked + unlinked copies)`); + and boundary shapes generated or derived (Phase 1b shape coverage census). Render it as + `Used as described: — generated forms 5/12 consumed · gate RUNS BUT DOES NOT + BLOCK · payload fields 6/10 linked · shapes 50% generated or derived`, banded by its worst + part. + +Coarse bands only (none / some / most / all). Worst-of within a pillar. Lead with gaps, not +the grade. + +**Re-run: compare against the previous audit.** If `.metaobjects/adoption-audit.json` +already exists, read it before starting and keep it as the baseline. Match each earlier +finding to this run's by `id` plus location, and give every earlier finding a `status`: +**fixed** (the location no longer shows it; say what changed), **open** (still present, +carrying its original `first_seen`), or **deferred** (the project recorded a decision not to +fix it now, in a commit, an ADR, a tracked issue or a code comment, quoted as +`deferred_reason`). A finding that is still present with no recorded decision is open, never +deferred. New findings are `new`. Report the counts per status at the top of the report, +and show each scorecard line beside its previous value. **Vocabulary hygiene (axis I) is advisory** — it surfaces as modernization opportunities in the roadmap, scored as such, and **never gates a tier or fails the @@ -218,8 +268,10 @@ audit.** Dated-but-working vocabulary is a quality nudge, not a defect. **Two artifacts:** `.metaobjects/adoption-audit.json` + rendered Markdown. -**Markdown sections (lead with Scorecard):** 0. Scorecard (tier + pillar table + CI gate) · -1. Triage + census · 2. Coverage matrix · 3. Per-surface classification tables · 4. Drift +**Markdown sections (lead with Scorecard):** 0. Scorecard (tier + pillar table + CI gate + +used as described; on a re-run, the fixed / open / deferred / new counts) · +1. Triage + census (including the owned-generator unmodified-lines total and the shape +coverage census) · 2. Coverage matrix · 3. Per-surface classification tables · 4. Drift findings (active bugs first) · 5. Owned-codegen + generator gaps · 6. Drift-gate adoption · 7. Runtime-contract + authoring-correctness (axes G+H) · 8. Semantic-constraint ratification · 9. Prompt-pillar assessment · 10. Prioritized roadmap: Tier 1 drift kill → Tier 2 existing @@ -230,7 +282,7 @@ Each roadmap item: LOC retired, prerequisite, **parity-gate before deleting hand | Field | Content | |---|---| -| `id` | stable kebab id (e.g. `handwritten-crud-route`, `manual-zod-validator`) | +| `id` | stable kebab id (e.g. `handwritten-crud-route`, `manual-zod-validator`, `enum-literal-spelling`, `unguarded-status-transition`, `owned-generator-stale`) | | `title` | "you hand-wrote X that metadata can generate / model" | | `pillar` | `codegen` / `runtime` / `drift` / `prompt` | | `surface` | `entity` / `route` / `validator` / `repository` / `dto` / `hooks` / `prompt` / `migration` | @@ -243,6 +295,24 @@ Each roadmap item: LOC retired, prerequisite, **parity-gate before deleting hand | `next_command` | the exact command / skill that performs the cutover (see bridge below) | | `parity_gate` | the specific check proving behavior-equivalence | | `tier` | 1–4 | +| `status` | `new` / `open` / `fixed` / `deferred` against the previous audit (`new` on a first run) | +| `first_seen` | date of the audit that first raised it (carried forward on re-runs) | +| `deferred_reason` | for `deferred` only: the recorded decision, quoted, and where it is recorded | + +Fixed findings stay in the file with `status: fixed` for one run, so the next reader sees +what closed. + +**Top-level fields in `.metaobjects/adoption-audit.json`**, beside `findings[]`: + +| Field | Content | +|---|---| +| `audited_at`, `commit` | when the audit ran and the commit it read | +| `previous` | `audited_at` and `commit` of the baseline audit, or `null` on a first run | +| `tier`, `pillars[]` | headline tier and `{ pillar, tier, top_gap }` per pillar | +| `ci_gate` | `{ score: "BLOCKING" \| "RUNS_BUT_DOES_NOT_BLOCK" \| "ABSENT", exit_code, error_count, swallowed_at[], deploy_paths_skipping[] }` | +| `used_as_described` | `{ band, generated_consumed, generated_emitted, bypassed_count, gate_score, payload_fields_linked, payload_fields_unlinked, shape_statements_generated_or_derived, shape_statements_total, unmodelled_shapes[] }` | +| `owned_generators` | `{ unmodified_lines, total_lines, copies[] }`, one total across every port | +| `status_counts` | `{ new, open, fixed, deferred }` | Within each tier, sort by impact ÷ effort (quick wins first). Tier 1 leads. diff --git a/agent-context/skills/metaobjects-audit/references/calibration.md b/agent-context/skills/metaobjects-audit/references/calibration.md index 86f6e6bdbe..6b9e72a398 100644 --- a/agent-context/skills/metaobjects-audit/references/calibration.md +++ b/agent-context/skills/metaobjects-audit/references/calibration.md @@ -10,6 +10,9 @@ - Planned, not shipped - Cross-port version-number skew - Stale upstream prose +- Include-only templates +- Owned generator copies with lines of their own +- Enum-member literals at a checked position - **Filter-operator route codegen — the baseline grammar ships in all five ports.** The `?filter[field][op]=value` grammar (all 9 operators `eq/ne/gt/gte/lt/lte/in/like/isNull`, @@ -32,3 +35,6 @@ - **Planned, not shipped** — `api.*` / `operation.*` / `binding.*` (FR-024) and MCP exposure of declared prompts/tools are not yet in the registry; their absence is not an adopter defect. - **Cross-port version-NUMBER skew is by design** — TS/C#/Python `0.x` vs Java/Kotlin `7.x` Maven is correct; never flag the *number lines* differing. But that is exactly why you can't eyeball cross-language drift: compare **`metamodelVersion`** (Phase 0 cross-language consistency item), not the package numbers. A `metamodelVersion` MISMATCH across ports *is* a finding; so is a port lagging its ecosystem's latest release. A MATCH does not prove parity: added vocabulary does not move `metamodelVersion`, so ports on one metamodel version can still disagree on which attributes they know. Also flag *intra-port* drift (mixed versions within one port, or a runtime package in `devDependencies`). - **Stale upstream prose** — "hand-write the Spring controller" (Java/Kotlin) is out of date; trust `meta gen --list`, not stale prose. +- **Include-only templates are not duplicates.** A prompt template whose body is only `{{> partial }}` includes is already the shared-partial fix the template-duplication check recommends. Identical stubs are the shape to want, never a byte-identical cluster to report (`references/prompt-anti-patterns.md`, template-text duplication). +- **An owned generator copy with lines of its own is not thereby customized.** The listing prints `DIFFERS` for a deliberate customization and for a copy stale by version, and counts lines the reference later removed as "of your own". Check the copy's history before calling either (Phase 0, owned-generators check). +- **An enum-member literal at a position the type checker verifies is not drift.** A value narrowed by the generated union or enum type breaks the build when the member is renamed. Signature 13 scores only a literal in a position nothing checks: a string-typed parameter, raw SQL, a JSON payload, an event name (`references/drift-signatures.md`). diff --git a/agent-context/skills/metaobjects-audit/references/capability-checklist.md b/agent-context/skills/metaobjects-audit/references/capability-checklist.md index e145d1ccf6..5741cf9de1 100644 --- a/agent-context/skills/metaobjects-audit/references/capability-checklist.md +++ b/agent-context/skills/metaobjects-audit/references/capability-checklist.md @@ -58,7 +58,11 @@ classify it (using the classification scheme in `SKILL.md`) and route the cutove - **`field.date` / `field.time` / `field.timestamp`** (`@autoSet`) — hunt hand-stamped `createdAt` / `updatedAt` assignments and ad-hoc temporal parsing; `@autoSet` stamps them. - **`field.enum`** (`@values`) — hunt hand-written TS unions, language `enum`s, or DB - `CHECK ... IN (...)` lists that restate a modeled enum's members. + `CHECK ... IN (...)` lists that restate a modeled enum's members. Two more hunts on the same + capability: a member or event name typed as a hand string beside the generated constant + (`drift-signatures.md`, signature 13), and a status-like enum column written without a + condition on its current value (`surface-review-axes.md`, G3: every write conditional, through + the port's ORM with generated constants, never raw SQL). - **`field.uuid`** — hunt UUIDs typed as bare strings / hand-validated. - **`field.object`** (`@objectRef`, `@storage`) — hunt hand-flattened owned columns or hand-rolled jsonb (de)serialization the `@storage` mode (`flattened`/`jsonb`/`subdocument`) @@ -182,7 +186,8 @@ soft-delete / status / type view it models. `validator.regex`** — hunt hand field-level validation (presence, length, numeric range, array bounds, `@pattern` regex) the validator subtypes model. - **Cross-field validators** — `validator.comparison` (`@left`/`@op`/`@right`, e.g. - "end ≥ start"), `validator.atLeastOne` (one-of-N present), `validator.requiredWhen` + "end ≥ start"), `validator.atLeastOne` (one-of-N present), `validator.exactlyOne` (exactly one of N + present), `validator.requiredWhen` (conditional-required), `validator.presentIff` (mutual presence). Hunt these as hand-coded multi-field rules — they ARE modelable (see the Semantic-constraint ratification section in `SKILL.md` to decide what belongs in shared metadata vs port-local). diff --git a/agent-context/skills/metaobjects-audit/references/csharp.md b/agent-context/skills/metaobjects-audit/references/csharp.md index 9d2168ca04..b2abf45c41 100644 --- a/agent-context/skills/metaobjects-audit/references/csharp.md +++ b/agent-context/skills/metaobjects-audit/references/csharp.md @@ -42,8 +42,15 @@ dotnet meta gen metaobjects --out Generated --generators entity # narrow to de dotnet meta verify --codegen # regenerate in memory, diff vs committed output dotnet meta verify --templates # check {{field}} refs vs payload VO (bare default) +dotnet meta verify --deps # shared-model dependencies vs deps.lock.json (opt-in) ``` +`verify --deps` applies when the project declares `dependencies` in `.metaobjects/config.json`: it +hashes each `path` dependency against the lock and fails with `ERR_DEPENDENCY_UPSTREAM_DRIFT` on +`drifted` or `unresolved` (a `maven`, `nuget`, `npm` or `python` dependency reports `unresolved`; +run the Node `meta deps check` for those). A project that publishes a model wires the +`SharedModelGenerator` in `codegen/Generators.cs`; `verify --codegen` drift-gates its output. + Schema migration + live-DB drift run through the **Node `meta` CLI** regardless of server language — see the migration reference. `dotnet meta verify --db` is rejected (exit 2). @@ -60,6 +67,8 @@ rejected (exit 2). | `FromSqlInterpolated(` outside `.g.cs` | stored-proc call — candidate for the `callable` generator | | `// keep in sync with` / `// mirrors the` | second-source-of-truth comment — always a finding | | `HasPrecision(` hand-coded | `field.decimal` with `@precision`/`@scale` drives this from the `entity` generator | +| a member of a generated enum typed as a hand string (`"Error"` in raw SQL, a JSON body, a topic or event name, a `switch` over a `string`) beside the generated enum constant | **signature 13.** Value-first from each enum's `@values`. A value typed as the generated C# enum is resolved and exempt; a `string` position, SQL text or a payload is compared and scores | +| a status-like column written with a property assignment then `SaveChanges`, or `ExecuteSqlRaw("UPDATE ... SET Status")`, with no condition on the current value | **axis G3.** Guard it through EF Core: `Where(x => x.Id == id && x.Status == )` then `ExecuteUpdateAsync`, with the generated enum constant, and check the affected-row count. Never raw SQL | | a table/column string in raw-SQL EF calls, or `nameof(Entity.Prop)` standing in for a column | second spelling of a declared physical name — reference `Names.g.cs` (`AuthorNames.SourcePrimaryTable` / `Column`, emitted when `codegen/Generators.cs` lists `names` — `Names.Name` is the OBJECT's name, not the table); an EF property inside LINQ is the typed handle — correct | --- @@ -73,7 +82,34 @@ copies the helper runtime the generated routes call (`FilterParser`, `EfCoreFilt `ValueObjectValidator`, `ConstraintErrors`, `Iso8601TimestampConverter`) into `codegen/runtime/` under the namespace `Codegen.Runtime`. That folder is owned code, not a hand-rolled filter parser: do not flag it. `dotnet meta gen --list` marks each owned copy -`identical` or `DIFFERS`. A generator the project WRITES is an `IGenerator` listed in +`identical` or `DIFFERS`. + +**Audit the owned copies first.** A copy exists to carry a change; one that carries none is +duplication that falls behind the reference. In `dotnet meta gen --list` an owned row reads +`[owned — identical]` or `[owned — DIFFERS: N behind, M of your own]` (`0 behind, 0 of your +own, reordered` for a copy with the same lines in another order), and `routes` adds a clause +for each `codegen/runtime/` file that differs. Only `identical`, with every runtime clause +identical too, proves a copy unmodified; that row is a **finding**: point the +`codegen/Generators.cs` entry back at the stock generator and remove the copy +(`dotnet meta eject --undo` removes every identical copy and prints the edit). `DIFFERS` +with `0 of your own` rules out added lines, not removed ones: confirm from `git log -p` on +the copy that nothing changed after the eject, else report it as **possibly customized: +check its history**. + +**`DIFFERS` is printed for BOTH a deliberate customization and a copy gone stale by version**, +so the listing cannot tell them apart, and a copy with lines of its own is NOT thereby a +customization: `M of your own` counts every line absent from today's reference, so after the +reference moved on, a line it removed or rewrote reads as "yours" and is an older upstream +line. Run the history check on any `DIFFERS` row, `M` above 0 included: lines the copy's later +commits added are the project's own; lines already in the eject commit are upstream's and +count as behind. Report two figures, ` lines behind the reference` and ` lines of the +project's own (confirmed from history)`. A copy whose own lines history does not confirm is +**possibly customized or stale: check its history**; one that is stale by version is a finding +(`owned-generator-stale`): re-eject at the current version or return to the stock entry. +Count lines for the Phase 0 total: lines in +copies proven unmodified, over all lines under `codegen/generators/` and `codegen/runtime/`. + +A generator the project WRITES is an `IGenerator` listed in `codegen/Generators.cs` the same way. With no `codegen/Generators.cs`, `dotnet meta gen` exits 2 and generates nothing. diff --git a/agent-context/skills/metaobjects-audit/references/drift-signatures.md b/agent-context/skills/metaobjects-audit/references/drift-signatures.md index 5148b26db4..492c015b65 100644 --- a/agent-context/skills/metaobjects-audit/references/drift-signatures.md +++ b/agent-context/skills/metaobjects-audit/references/drift-signatures.md @@ -13,6 +13,7 @@ - 10. N declarations of one field across objects - 11. A metadata-derived value spelled a second time by hand - 12. An open JSON bag whose readers agree on a shape +- 13. An enum member or event name typed by hand beside the generated constant Per finding: `file:line` → what → generated-equivalent exists? → recommendation. @@ -55,3 +56,12 @@ Per finding: `file:line` → what → generated-equivalent exists? → recommend **Do NOT flag:** a bag whose readers genuinely pass it through (logged, echoed, stored, forwarded to a third party) without reading a key; a third-party or LLM raw response whose shape is not the adopter's to declare; an **array of scalars**, which is `isArray: true` on the base subtype and never an object; a bag the metadata's own comment justifies as open with a reason. **Remedy — a ladder, chosen by the WRITER's declared type, and every rung gives the consumer a TYPED HANDLE rather than a string to get and set.** `list[X]` ⇒ the base subtype + `isArray: true`. `dict[str, X]` with a known `X` ⇒ **`field.map` + `@objectRef`** (a value object) or `@valueType` (a scalar) — registered vocabulary that emits `jsonb("col").$type>()` and `z.record(z.string(), X)`. **Check the CONSUMER before recommending this rung: `field.map` codegen now completes on all five ports** (Java types it `java.util.Map`; C# emits the `Dictionary` property and its EF jsonb storage mapping), **but no persistence- or api-contract-conformance fixture exercises `field.map` on ANY port, and the runtime persistence tier is uneven** — only Python's `ObjectManager` encodes a map, while `runtime-ts`, Java's OMDB and the Kotlin Exposed lane carry none. So where GENERATED CODE is the consumer, check the port before recommending this rung — nested map values are validated on every write path on every port as of 1.0.1 ([#362](https://github.com/metaobjectsdev/metaobjects/issues/362) — before that, Java skipped the cascade on TPH write paths and C# skipped it everywhere, silently accepting invalid values rather than erroring). **Check the adopter's pinned version before recommending this rung to a Java-TPH or C# consumer: on 1.0.0 the hole is open and they need their own boundary check.** Prefer a value object where a PORT RUNTIME must read the column back; a genuinely dynamic key set stays a bag. A serialized DTO / dataclass / `@Serializable` class ⇒ declare it as an `object.value` and point the field at it with `field.object` + `@objectRef` + `@storage: jsonb`. Only `dict[str, Any]` whose readers pin no key stays an open bag. **What the adopter GETS, per port** — this is the point of the conversion and worth stating in the finding: TypeScript emits the Drizzle column as `.$type()` plus the VO's own Zod schema and inferred type; Python annotates the field with the referenced VO's Pydantic model (and its `Create` on the wire, so a nested violation still validates); Kotlin emits typed Exposed jsonb codecs backed by a shared Jackson `MetaJsonbMapper`. In none of them does the consumer touch a JSON string — that is what the open bag costs them today, since `unknown` forces every reader to cast. The column stays jsonb, so this is a codegen/contract change and not necessarily a migration; what changes is that `unknown` becomes a generated type, the casts delete, and the keys become metadata-owned — which also promotes their literals into drift signature 11's scope, where the `->>'key'` sites were previously exempt because the metadata owned nothing. **Verify the column type is genuinely unchanged before promising no migration**, and parity-gate each converted read against the raw-SQL one before deleting it. Convert one column at a time: the shape is a judgment per bag, and a wrong guess declares a contract the writers do not honor. + +13. **An enum member or event name typed as a hand string beside the generated constant.** Signature 11 covers physical names; this is the same rule for a model's enum values and for the event or message names an enum member spells. A literal in non-generated code that EQUALS a member of a generated enum (or the name of a declared event) is a second spelling, and it is the commonest drift an estate that already uses the constants carries: the file imports `CouncilStatusEnum` and uses `CouncilStatusEnum.enum.complete` on one line, then writes `status: "error"` on the next. The two spellings agree today and nothing ties them together. **Hunt VALUE-first, from the declaration outward:** list every enum's members from the metadata (`@values` on each `field.enum`, plus the member names of any enum-backed event or message type), then grep the non-generated tree, config and fixtures included, for each member as a quoted literal. Distinctive members (`"edited_approved"`, `"awaiting_review"`) score on the hit; generic ones (`"error"`, `"done"`, `"active"`) only by reading the site, because the same word may belong to something the metadata does not own. **A file that already imports the enum's generated constant is the strongest tell**: its author knew the constant existed, so a bare literal of another member of that enum in the same file is almost never intentional. Count those first. + + **Apply signature 11's discriminator, then say which side of it the site is on.** Rename the member in metadata and regenerate. Where the site is RESOLVED, the regeneration breaks it before anything runs and it is not a finding: a value narrowed by the generated union (`export type = "a" | "b"` on TypeScript, a `Literal[...]` annotation on Python, a generated `enum` type on Java, Kotlin and C#) at a position the compiler or type checker actually checks. Where the site is COMPARED, it survives the regeneration and fails later, on data: a literal in a string-typed position (a `Record`, a `string` parameter, a loosely typed object spread into a `.set(...)`, a `dict`), in raw SQL (`WHERE status = 'error'`), in a JSON payload or fixture, as a broker topic or an SSE / websocket event name, in a `switch` over a `string` that the type checker cannot exhaust, or in a comparison against a column read back as `string`. **Verify the position before scoring it, never the shape of the literal:** the TypeScript case that earned the exemption (332 narrowed literals, 0 findings) and the case that earned this signature (`status: "error"` beside `CouncilStatusEnum.enum.complete`) look identical in a grep, and only the type at the site separates them. If you cannot tell which side a site is on, read the declared type of the target; report it as unverified rather than skipping it. + + **Do not flag:** a literal narrowed by the generated union or enum type at a checked position; a value the metadata does not own (an application-level state machine's label that merely coincides with a member, a page route, copy); a literal inside a generated file; and a test asserting the wire value of a member on purpose (a test that pins `"complete"` is a contract test and says so). A literal inside a `source.rdb` `@sql` body is metadata and is exempt, as in signature 11. + + **Remedy:** reference the generated constant, which is the one rule for every port: the Zod enum's member (for example `CouncilStatusEnum.enum.complete`) or the generated union type on TypeScript, the generated `Literal` alias or enum on Python, the generated enum constant on Java, Kotlin and C#. In raw SQL the value moves to a bound parameter fed from the constant (never a literal inside the SQL text), and the table and column in that statement are signature 11's names artifact. Report the site count as `/ sites` exactly as signature 11 does, and carry a deferral forward with its count. This signature needs no names artifact; it needs the generated enum type. If the project generates none, the un-wired `entity` generator is the first finding. + diff --git a/agent-context/skills/metaobjects-audit/references/java.md b/agent-context/skills/metaobjects-audit/references/java.md index 3aaa5b4ebc..84e37604d3 100644 --- a/agent-context/skills/metaobjects-audit/references/java.md +++ b/agent-context/skills/metaobjects-audit/references/java.md @@ -40,6 +40,13 @@ mvn metaobjects:verify -Dmeta.verify.mode=codegen # regen in memory, diff vs mvn metaobjects:verify -Dmeta.verify.mode=templates # {{field}} refs vs payload VO ``` +If the project declares `dependencies` in `.metaobjects/config.json` (a model shared from another +repository), also run `mvn metaobjects:verify -Dmeta.verify.mode=deps`: it hashes each `path` +dependency against `.metaobjects/deps.lock.json` and fails with `ERR_DEPENDENCY_UPSTREAM_DRIFT` on +`drifted` or `unresolved` (a `maven`, `nuget`, `npm` or `python` dependency reports `unresolved`; +run the Node `meta deps check` for those). A project that publishes a model wires the +`shared-model` generator; `verify --codegen` drift-gates its output. + Schema migration + live-DB drift run through the **Node `meta` CLI** regardless of server language — see the migration reference. `mvn metaobjects:verify -Dmeta.verify.mode=db` is rejected (exit 2). @@ -59,17 +66,50 @@ plugin `` — that is the source of truth for which generators ru | `// keep in sync with` / `// mirrors the` | second-source-of-truth comment — always a finding | | `ObjectMapper.readValue(` outside a `*Parser.java` file | check if a responding `template.prompt` (`@responseRef`) exists — output-parser codegen ships in Java | | `LIMIT ?` / `OFFSET ?` assembled by hand | generated CRUD routes handle pagination; OMDB `getObjects` accepts `QueryOptions` | +| a member of a generated enum typed as a hand string (`"ERROR"` in JDBC SQL, a JSON body, a topic or event name, a `switch` over a `String`) beside the generated enum constant | **signature 13.** Value-first from each enum's `@values`. A value typed as the generated enum is resolved and exempt; a `String` position, SQL text or a payload is compared and scores | +| a status-like column written with a JDBC `UPDATE ... SET status`, a repository `save` of an entity whose status was set freely, or a Spring Data query with no `AND status = :from` | **axis G3.** Guard it through OMDB, the generated repository or a JPA modifying query over entity attributes, with the generated enum constant, and check the updated-row count. Never raw SQL | | a table/column string in a repository implementation — JDBC SQL, jOOQ `table("authors")`, a Spring Data query | second spelling of a declared physical name — reference `Names` (`AuthorNames.SOURCE_PRIMARY_TABLE` / `_COLUMN`; opt-in `SpringNamesGenerator`): an un-wired generator is the finding first | --- ## Owned generators -Java does not scaffold-and-own generators — they are provided by -`metaobjects-codegen-spring` and wired by FQ class name in `pom.xml`. There is no -analog to the TS `codegen/generators/*.ts` pattern here. +Stock generators come from `metaobjects-codegen-spring` and are wired by fully qualified +class name in `pom.xml`. `mvn metaobjects:eject -Dnames= -Dport=java` copies one into +a separate `codegen/` Maven module under the project's own package, and `pom.xml` then names +the copy. + +**Audit the owned copies first.** A copy exists to carry a change; one that carries none is +duplication that falls behind the reference. + +```bash +mvn metaobjects:eject -Dlist # the catalog, each owned copy marked +``` -Java does, however, have **both** authoring paths, so a project needing a shape the +Each owned row is marked `[owned — identical]` or `[owned — DIFFERS: N behind, M of your +own]`, and a generator copied with companion classes (emitters, Java `entity` and +`extractor`) adds `; differing: `. Only `identical` proves a copy unmodified; that +row is a **finding**: point the `pom.xml` entry back at the stock class and remove the copy +(`mvn metaobjects:eject -Dundo=true` removes every identical copy and prints the `pom.xml` +edit). `DIFFERS` with `0 of your own` rules out added lines, not removed ones: confirm from +`git log -p` on the copy that nothing changed after the eject, else report it as **possibly +customized: check its history**. + +**`DIFFERS` is printed for BOTH a deliberate customization and a copy gone stale by version**, +so the listing cannot tell them apart, and a copy with lines of its own is NOT thereby a +customization: `M of your own` counts every line absent from today's reference, so after the +reference moved on, a line it removed or rewrote reads as "yours" and is an older upstream +line. Run the history check on any `DIFFERS` row, `M` above 0 included: lines the copy's later +commits added are the project's own; lines already in the eject commit are upstream's and +count as behind. Report two figures, ` lines behind the reference` and ` lines of the +project's own (confirmed from history)`. A copy whose own lines history does not confirm is +**possibly customized or stale: check its history**; one that is stale by version is a finding +(`owned-generator-stale`): re-eject at the current version or return to the stock entry. + +Count lines for the Phase 0 total: lines in copies proven +unmodified, over all lines under `codegen/` that eject wrote or the project wrote. + +Java also has **both** authoring paths, so a project needing a shape the built-ins do not emit has two legitimate answers and neither is a finding on its own: a **programmatic** generator (implement `com.metaobjects.generator.Generator`, name the class in a `` element — the plugin loads it from the project classpath), or a diff --git a/agent-context/skills/metaobjects-audit/references/kotlin.md b/agent-context/skills/metaobjects-audit/references/kotlin.md index ee44432105..8b94ba2482 100644 --- a/agent-context/skills/metaobjects-audit/references/kotlin.md +++ b/agent-context/skills/metaobjects-audit/references/kotlin.md @@ -44,6 +44,13 @@ mvn metaobjects:verify -Dmeta.verify.mode=codegen # regen in memory, diff vs mvn metaobjects:verify -Dmeta.verify.mode=templates # {{field}} refs vs payload VO ``` +If the project declares `dependencies` in `.metaobjects/config.json` (a model shared from another +repository), also run `mvn metaobjects:verify -Dmeta.verify.mode=deps`: it hashes each `path` +dependency against `.metaobjects/deps.lock.json` and fails with `ERR_DEPENDENCY_UPSTREAM_DRIFT` on +`drifted` or `unresolved` (a `maven`, `nuget`, `npm` or `python` dependency reports `unresolved`; +run the Node `meta deps check` for those). A project that publishes a model wires the +`shared-model` generator; `verify --codegen` drift-gates its output. + Kotlin generators run through the **same Maven plugin goal** as Java generators — both are SPI-discovered by the `metaobjects-maven-plugin`. Schema migration + live-DB drift run through the **Node `meta` CLI** regardless of server language — see the @@ -64,17 +71,49 @@ The active generator list is declared in `pom.xml` under the plugin `` in the predicate, or an `exec("UPDATE ... SET status")` | **axis G3.** Guard it through Exposed: `T.update({ (T.id eq id) and (T.status eq ) })` with the generated constant, and check the returned count. Never raw SQL | | a table/column string in `exec("…")` raw SQL or a Flyway script | reference `Names` (`KotlinNamesGenerator`, opt-in); `AuthorTable.name` inside the Exposed DSL is the typed handle — correct, not a finding | --- ## Owned generators -Kotlin does not scaffold-and-own generators — they are provided by -`metaobjects-codegen-kotlin` and wired by FQ class name in `pom.xml`. There is no -analog to the TS `codegen/generators/*.ts` pattern here. +Stock generators come from `metaobjects-codegen-kotlin` and are wired by fully qualified +class name in `pom.xml`. `mvn metaobjects:eject -Dnames= -Dport=kotlin` copies one +into a separate `codegen/` Maven module under the project's own package, and `pom.xml` then +names the copy. + +**Audit the owned copies first.** A copy exists to carry a change; one that carries none is +duplication that falls behind the reference. + +```bash +mvn metaobjects:eject -Dlist # the catalog, each owned copy marked +``` -Kotlin does, however, have **both** authoring paths — it shares the JVM engine — so a +Each owned row is marked `[owned — identical]` or `[owned — DIFFERS: N behind, M of your +own]`, and a generator copied with companion classes adds `; differing: `. Only +`identical` proves a copy unmodified; that row is a **finding**: point the `pom.xml` entry +back at the stock class and remove the copy (`mvn metaobjects:eject -Dundo=true` removes +every identical copy and prints the `pom.xml` edit). `DIFFERS` with `0 of your own` rules +out added lines, not removed ones: confirm from `git log -p` on the copy that nothing +changed after the eject, else report it as **possibly customized: check its history**. + +**`DIFFERS` is printed for BOTH a deliberate customization and a copy gone stale by version**, +so the listing cannot tell them apart, and a copy with lines of its own is NOT thereby a +customization: `M of your own` counts every line absent from today's reference, so after the +reference moved on, a line it removed or rewrote reads as "yours" and is an older upstream +line. Run the history check on any `DIFFERS` row, `M` above 0 included: lines the copy's later +commits added are the project's own; lines already in the eject commit are upstream's and +count as behind. Report two figures, ` lines behind the reference` and ` lines of the +project's own (confirmed from history)`. A copy whose own lines history does not confirm is +**possibly customized or stale: check its history**; one that is stale by version is a finding +(`owned-generator-stale`): re-eject at the current version or return to the stock entry. +Count lines +for the Phase 0 total: lines in copies proven unmodified, over all lines under `codegen/` +that eject wrote or the project wrote. + +Kotlin also has **both** authoring paths — it shares the JVM engine — so a project needing a shape the built-ins do not emit has two legitimate answers and neither is a finding on its own: a **programmatic** generator (implement `com.metaobjects.generator.Generator`, name the class in a `` element), or a diff --git a/agent-context/skills/metaobjects-audit/references/prompt-anti-patterns.md b/agent-context/skills/metaobjects-audit/references/prompt-anti-patterns.md index 92cfb4748e..af230bbb53 100644 --- a/agent-context/skills/metaobjects-audit/references/prompt-anti-patterns.md +++ b/agent-context/skills/metaobjects-audit/references/prompt-anti-patterns.md @@ -3,7 +3,7 @@ ## Contents - Census scope - Keeping the result in place -- Anti-pattern list +- Anti-pattern list (includes the unlinked-payload ratio) - Template-text duplication **The census covers EVERY module**, not only the application: test harnesses, simulators, @@ -26,6 +26,24 @@ format-built argument at the project's own LLM request call sites. **sourceless `object.projection`** carrying those origins (#210 — assembly origins on an `object.value` fail load with `ERR_SUBTYPE_RULE_VIOLATION`; `@payloadRef` accepts the sourceless projection). +- **Unlinked payload.** A declared payload shape is necessary, not sufficient: the check above + asks whether the payload IS a shape, this one asks where its fields COME FROM. For each object + a `@payloadRef` names, class every field: + - **LINKED** — a dotted `extends: Entity.field` (for example `"extends": "Customer.email"`), + or an origin that resolves to an entity field (`origin.passthrough` with + `@from: Customer.email`, or an `aggregate` / `first` origin whose `@of` names one). + - **CALLER-SUPPLIED** — no entity owns the value (the user's question, a run-time setting, a + date the caller computes). Say why for each; "the caller fills it" is not a reason when the + caller reads it off an entity. + - **UNLINKED COPY** — declared as a free-standing field, while the call site fills it from an + entity property (`payload.email = customer.email`, `email=customer.email`). + Report `linked / (linked + unlinked copies)` per payload and in total. Each unlinked copy is a + finding (`unlinked-payload-field`): renaming or re-typing the entity field will not fail + `verify --templates`, because the payload declares its own copy and the template still + matches that copy. Remedy: replace the field with `extends: Entity.field` (or a passthrough + origin on a sourceless projection). The `parity_gate` is a scratch-copy proof: rename the + entity field in a throwaway copy of the metadata and confirm the project's verify now fails, + where before the change it passed. - Silent-degradation hack (`try/except KeyError` or `?? ''` around formatting) — flag every instance. - Hand-rolled output parsing (regex / XML / ad-hoc JSON) vs a declared **responding `template.prompt`** (one carrying `@responseRef`) + generated `parse*` / `safeParse*` / @@ -41,4 +59,4 @@ format-built argument at the project's own LLM request call sites. `voRequest` / `voResponse` jsonb columns must be authored `field.object` — the loader must not mutate the tree; vendor SDK client + pricing are BYO (ADR-0024). - No `meta verify --templates` gate; no declared `@maxChars` / `@maxTokens` budget. -- **Template-text duplication.** Hash every external template file (`md5sum` the template dir) and diff within groups sharing a `payloadRef`. A byte-identical cluster, or N≥3 templates sharing an identical skeleton with only slot lines differing, is ONE prompt maintained N times — a wording fix must be applied N times and WILL be missed. Recommend a shared `{{> group/partial }}` include (the render engine inlines partials recursively) or one template + payload-carried variant fields. Do NOT flag: the per-node `payloadRef` / `@format` repetition across `template.prompt` nodes (loader-forced, not a copy); templates meant to diverge independently — require N≥3 and structural identity before flagging. +- **Template-text duplication.** Hash every external template file (`md5sum` the template dir; skip include-only files, below) and diff within groups sharing a `payloadRef`. A byte-identical cluster, or N≥3 templates sharing an identical skeleton with only slot lines differing, is ONE prompt maintained N times — a wording fix must be applied N times and WILL be missed. Recommend a shared `{{> group/partial }}` include (the render engine inlines partials recursively) or one template + payload-carried variant fields. Do NOT flag: the per-node `payloadRef` / `@format` repetition across `template.prompt` nodes (loader-forced, not a copy); templates meant to diverge independently — require N≥3 and structural identity before flagging; **an include-only template**. A template whose body is nothing but partial includes (every non-blank line is a `{{> group/partial }}` and there is no prose of its own) is already the fix this section recommends: the wording lives once in the partial, and the stub is the per-prompt entry point the loader requires. Several such stubs being byte-identical, or sharing the same include list, is the recommended shape, not a cluster. Drop include-only files from the hash groups BEFORE comparing, and apply the cluster test to what remains. A template that mixes includes with a skeleton of its own prose still counts, and its prose is what is compared. When every member of a cluster is include-only, report it as the gold standard, the way a repository that imports `Names` is called out as good. diff --git a/agent-context/skills/metaobjects-audit/references/python.md b/agent-context/skills/metaobjects-audit/references/python.md index bb110ec191..d8f9baf9e9 100644 --- a/agent-context/skills/metaobjects-audit/references/python.md +++ b/agent-context/skills/metaobjects-audit/references/python.md @@ -40,8 +40,14 @@ metaobjects gen # run every target's generators (metaobjec metaobjects gen --generators entity # narrow to declared entries metaobjects verify --codegen # regenerate in memory, diff vs each committed outDir (bare default) metaobjects verify --templates # {{field}} refs vs payload VO +metaobjects deps check # shared-model dependencies vs deps.lock.json (also: verify --deps) ``` +`deps check` applies when the project declares `dependencies` in `.metaobjects/config.json`: it +hashes each `path` dependency against the lock and fails with `ERR_DEPENDENCY_UPSTREAM_DRIFT` on +`drifted` or `unresolved` (a `maven`, `nuget`, `npm` or `python` dependency reports `unresolved`; +run the Node `meta deps check` for those). Python consumes a shared model but cannot publish one. + With no `metaobjects.config.yaml`, `gen` exits 2 and generates nothing. A target's `generators` takes stable generator names: `entity`, `routes`, `filter-allowlist`, `names`, `output-parser`, `extractor`, `output-prompt`, `render-helper`, `trace-helper`, @@ -62,6 +68,8 @@ regardless of server language — see the migration reference. | `def get_all_` / `def create_` / `def update_` / `def delete_` in non-generated files | hand-rolled CRUD — compare to the generated router | | `# keep in sync with` / `# mirrors the` | second-source-of-truth comment — always a finding | | `try: ... except KeyError` / `?? ''` around format strings in prompt code | silent-degradation hack around a prompt payload — flag it | +| a member of a generated enum typed as a hand string beside its generated `Literal` / enum (`status="error"` in a `dict`, an f-string SQL, a JSON body, an event name) | **signature 13.** Value-first from each enum's `@values`. A value at a position the type checker verifies against the generated `Literal[...]` is resolved and exempt; a `dict`, a `str` parameter or SQL text is compared and scores | +| a status-like column written with `update(T).values(status=...)` / `UPDATE ... SET status` and no condition on the current value | **axis G3.** Guard it through SQLAlchemy (`update(T).where(T.id == id, T.status == )`) or the `ObjectManager`, with the generated constant, and check `rowcount`. Never raw SQL | | a table/column string in the repository implementation (SQLAlchemy Core, asyncpg/psycopg SQL) | second spelling of a declared physical name — reference `_names.py` (`AUTHOR_SOURCE_PRIMARY_TABLE` / `AUTHOR__COLUMN`, emitted when a target lists `names`); no typed handle exists on this port, so that is never the reason to waive it | --- @@ -74,6 +82,36 @@ the same way — a `module:symbol` entry in a target's `generators` in `metaobje reading the model through `metaobjects.codegen.model_walk`. (`--provider module:symbol` registers **metamodel vocabulary**, not a generator — do not read it as one.) +**Audit the owned copies first.** A copy exists to carry a change; one that carries none is +duplication that falls behind the reference. + +```bash +metaobjects gen --list # the catalog, each owned copy marked +``` + +An owned row ends `[owned — identical]` or `[owned — DIFFERS: N behind, M of your own]`, and +a generator that reads a `codegen/runtime/` module (`routes`: `filter_parser`, +`constraint_errors`) prints an indented `runtime []` line per companion. Only +`identical`, with every companion identical too, proves a copy unmodified; that row is a +**finding**: point the `metaobjects.config.yaml` entry back at the stock name and remove the +copy (`metaobjects eject --undo` removes every identical copy and prints the config edit). +`DIFFERS` with `0 of your own` rules out added lines, not removed ones: confirm from +`git log -p` on the copy that nothing changed after the eject, else report it as **possibly +customized: check its history**. + +**`DIFFERS` is printed for BOTH a deliberate customization and a copy gone stale by version**, +so the listing cannot tell them apart, and a copy with lines of its own is NOT thereby a +customization: `M of your own` counts every line absent from today's reference, so after the +reference moved on, a line it removed or rewrote reads as "yours" and is an older upstream +line. Run the history check on any `DIFFERS` row, `M` above 0 included: lines the copy's later +commits added are the project's own; lines already in the eject commit are upstream's and +count as behind. Report two figures, ` lines behind the reference` and ` lines of the +project's own (confirmed from history)`. A copy whose own lines history does not confirm is +**possibly customized or stale: check its history**; one that is stale by version is a finding +(`owned-generator-stale`): re-eject at the current version or return to the stock entry. +Count lines for the Phase 0 total: lines in +copies proven unmodified, over all lines under `codegen/generators/` and `codegen/runtime/`. + **A finding of the form "the built-ins do not emit the shape this project needs", or a hand-written layer the model fully describes, resolves to a generator the project writes** (ADR-0034 Amendment 4), or to a declarative template (a target's `templateSpec: `, diff --git a/agent-context/skills/metaobjects-audit/references/requirements.md b/agent-context/skills/metaobjects-audit/references/requirements.md index 5c48284f2b..2bcebe9ec1 100644 --- a/agent-context/skills/metaobjects-audit/references/requirements.md +++ b/agent-context/skills/metaobjects-audit/references/requirements.md @@ -11,6 +11,7 @@ what a green run already proves. ## Contents - What verify has already proven (do not re-check by hand) +- Currency checks — run these before sampling - What only a human or an agent reading the code can catch - Scope — do NOT flag these as defects - Reporting @@ -54,12 +55,46 @@ Three limits, and each puts something back on your list: `title` is deliberately NOT flagged as an inert slot; it is chartered as the entry's label and is rendered (see item 6). Do not report a populated `title` as a defect. +## Currency checks — run these before sampling + +A green gate proves the ledger's links resolve, not that the ledger keeps up with the code. +These three checks measure that, and the first one chooses the sample for item 1 below. + +**(a) Ledger stale.** From git history, take the commits that add a feature (a `feat:` / +`feat(...)` subject under Conventional Commits; otherwise merged feature branches or PRs +labelled as features) over the last six months or the last 50 such commits, whichever is +fewer. Report two numbers: the share of those commits that also change requirement metadata +(any file holding `requirement.*` nodes), and the count of feature commits since the most +recent change to that metadata. A share **under half**, or **more than ten** feature commits +since the last ledger change, is the finding `ledger-stale`, stating both numbers. The +feature commits that did not touch the ledger are the sample for item 1: read what each one +built and check that a requirement says so with a true status. + +**(b) Nothing implements a live claim.** Run the project's verify with the strict switch: +`meta verify --require-implementers`, `metaobjects verify --require-implementers`, +`mvn metaobjects:verify -Dmeta.verify.requireImplementers=true` or +`dotnet meta verify --require-implementers` (all ports also read +`META_REQUIRE_IMPLEMENTERS=1`). Each `WARN_REQUIREMENT_NOTHING_IMPLEMENTS` on a `live` entry +is a finding (`live-claim-unimplemented`) naming the entry. State whether the project's own +gate passes the switch; if it does not and the ledger has no such entries, recommend adding +it so the ledger cannot fall behind again. + +**(c) Live claim, unwired implementer.** For each `@implementedBy` target of a `live` entry, +find the generated code that target produces and confirm hand-written code imports or calls +it. A live claim whose implementer is generated code nothing uses is the finding +`live-claim-unwired-implementer`: the claim resolves, so verify is satisfied, but the +capability is not reachable. Before raising it, rule out a runtime use: code that reaches the +entity through the runtime `ObjectManager` (or a metadata-driven admin or tool registry) +uses it without importing anything generated, so search for the entity's name in those calls +too. + ## What only a human or an agent reading the code can catch **1. Statuses that are false.** The highest-value finding in the whole dimension. A requirement marked `live` whose implementation was gutted; one marked `partial` that is now complete; one marked `planned` that was quietly built months ago. Sample the claims -and read the nodes. `status` is the only payload with controlled evidence behind it — the +and read the nodes, starting with the feature commits currency check (a) found outside the +ledger. `status` is the only payload with controlled evidence behind it — the resurrection protection rides entirely on it being true. **2. Non-violable statements.** Every requirement must state what breaking it looks like. diff --git a/agent-context/skills/metaobjects-audit/references/surface-review-axes.md b/agent-context/skills/metaobjects-audit/references/surface-review-axes.md index 98cb470638..58c7f3feb5 100644 --- a/agent-context/skills/metaobjects-audit/references/surface-review-axes.md +++ b/agent-context/skills/metaobjects-audit/references/surface-review-axes.md @@ -13,6 +13,7 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in - F2. Over-generation — unnecessary generated files - G. Runtime-contract anti-patterns - G2. `own*()` accessor discipline +- G3. Guarded status transitions - H. Authoring correctness / ADR conformance - H2. Wrong native type - I. Vocabulary hygiene / modernization (advisory) @@ -22,7 +23,9 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in grids/forms/filters vs `layout.dataGrid` / form generators / filter-allowlist. - [ ] **C. Drift hotspot — validators, mappers, runtime models.** Hand validators / DTO-mappers / dataclasses shadowing a generated shape. Diff field-by-field; the divergence is the bug. -- [ ] **D. Prompt pillar.** Every LLM prompt-construction site (see `prompt-anti-patterns.md`). +- [ ] **D. Prompt pillar.** Every LLM prompt-construction site (see `prompt-anti-patterns.md`), + including the **unlinked payload** count: for each `@payloadRef` object, how many of its + fields are linked to the entity field they copy. - [ ] **E. Owned generators & scaffold-and-own** (see "Owned-codegen & scaffold-and-own assessment" in `SKILL.md`). - [ ] **E2. Capability ledger — `requirement.*`** (see `references/requirements.md` and the Requirement axis of the capability checklist). The one axis whose hunt is hand-written @@ -34,6 +37,9 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in design, and a real estate reports most of itself unclaimed on day one). Score the prose it would replace, and prefer ONE concrete claim an author can check over a whole-estate migration. + Where a ledger exists, run the three **currency checks** in `references/requirements.md` + (ledger stale, `--require-implementers`, live claim with an unwired implementer) before + sampling statuses. **First establish the estate LOADS.** An older ledger fails the load outright, so `meta verify` never runs and everything in `references/requirements.md` is unavailable: `@violation` and `@verifiedBy` were retired in **0.24.0** (no deprecation shim — ADR-0023 @@ -53,6 +59,52 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in subverbs (`--codegen` / `--templates` / `--db`)? Committed-codegen freshness gate? Advisories heeded? Routine `--no-verify` bypass? Loader `ERR_*` / warnings addressed? Parse the stable `code` field, not message text (ADR-0009). + **No CI means NO, whatever local hooks exist.** A git hook is not part of the clone: it + counts only when a tracked setup step installs it (a `prepare` / `postinstall` script, a + `core.hooksPath` set by a committed setup script, a hook manager declared in the + project's dependencies). An untracked `.git/hooks/pre-push` on one machine is not a gate. + A project with no CI workflow and no tracked hook installer answers the Binary CI drift + gate **NO**, and that is a **Tier 1 finding** whose `next_command` is the snippet below + for the project's port, ready to paste. + + | Port | Verify commands for the snippet (one per subverb the project's artifacts need) | + |---|---| + | TypeScript | `npx meta verify --codegen --templates`; add `npx meta verify --db` against a provisioned database | + | Python | `metaobjects verify --codegen` and `metaobjects verify --templates` | + | Java / Kotlin | `mvn -B metaobjects:verify -Dmeta.verify.mode=codegen` and `-Dmeta.verify.mode=templates` | + | C# | `dotnet meta verify --codegen` and `dotnet meta verify --templates` | + + The snippet is one CI job that checks out the repo, installs the toolchain and runs those + commands with nothing after them, for example GitHub Actions steps + `- run: npx meta verify --codegen --templates`. Where the project has no CI host, it is a + tracked `pre-push` hook that runs the same commands plus the tracked setup line that + installs it. Schema drift (`--db`) runs through the Node `meta` CLI in every port. + **Does it block?** Wired is not blocking. A gate that runs and is ignored scores the same as + no gate, so answer all three before scoring this axis: + - **(a) The exit code propagates.** Search CI files, package scripts, Makefiles, shell + scripts and build files on every path that runs verify for anything that swallows its + failure: `|| true`, `|| echo`, `; exit 0`, `continue-on-error: true`, `set +e`, + `allow_failure: true`, `ignore_errors`, a step or job marked optional or non-required, + a Maven `testFailureIgnore` / `failOnError=false` style switch, an MSBuild + `ContinueOnError`, a `-Dmeta.lax=true` or other option that turns a verify failure into a + warning, and verify output piped into a command whose exit code is the one that counts + (`meta verify | tee log` without `pipefail`). Each one is a finding naming the file and + line. + - **(b) It is green now.** Run the project's own verify command, the exact one its gate + runs, and record the exit code and the error count. A non-zero exit the project tolerates + ("known errors", a baseline file, a count it compares against) is a finding that states + the count and recommends a **ratchet**: the gate stores today's count and fails when it + rises, so the number can only fall (see the CI ratchet gate in `metaobjects-verify`). A + tolerated count with no ratchet is a gate that will absorb every new error. + - **(c) Every route to production passes it.** List each deploy entry point: CI deploy + jobs, release workflows, deploy scripts, `Makefile` / package-script deploy targets, a + hosting platform's build command, a manual `deploy.sh`. Flag each one that ships without + verify having passed on the same commit (a deploy job that does not depend on the verify + job, a script that builds and pushes directly, a `skip-checks` / `--no-verify` input). + Score the gate **BLOCKING** (verify runs on every route to production and a failure stops + it), **RUNS BUT DOES NOT BLOCK** (it runs somewhere, but (a), (b) or (c) failed) or + **ABSENT**. Only **BLOCKING** passes the drift-gate pillar's tier and answers YES on the + Binary CI drift gate; report the other two as **NO** and name which of (a), (b), (c) failed. **Is any advisory half switched OFF?** A gate can be wired, green, and muted. The requirements authoring lint is advisory and mutable — `--no-requirement-lint` or `META_NO_REQUIREMENT_LINT=1` silences it while the gate above it still runs and can still @@ -96,9 +148,24 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in code imports: drop the generator rather than generate into the void. - **Wrong target / duplicate output** — the same logical artifact emitted to two places (a mis-set per-target `outDir`), one of which is orphaned. + - **Consumed / emitted, per generator kind.** For each generator kind (entity, routes, + query hooks, grid, form, and so on) report `consumed / emitted` files, where consumed is + confirmed by an import or reference from hand-written code, not by the file existing. + - **Generated and bypassed.** Where a kind is under half consumed and axis B found a + hand-written equivalent for the same entity (a hand-built admin page, form or grid + beside the unused generated one), raise ONE finding, `generated-and-bypassed`, that + names both files. This is not the same as dead output: the project needed the surface + and built it again by hand, so the generated one is a second, unused source of truth. + The app chooses per entity: **use the generated artifact** (customising the owned + generator until it fits, then deleting the hand-written page after a parity gate), or + **filter it out** with the generator's `filter` and record the hand-written page as + ACCEPTABLE with a stated reason. Emitted and unused is not an end state: the finding + closes only when each entity is on one side or the other. Recommend generating ONLY what is consumed — decide per generator: drop the ones whose whole output class nothing imports, and narrow the ones that over-emit with - their `filter`. A smaller, fully-consumed generated surface beats a large one with + their `filter`. Dropping is the remedy only when no hand-written equivalent exists; + where one does, the finding is `generated-and-bypassed` above. A smaller, + fully-consumed generated surface beats a large one with dead files (which also make the leverage ratio lie; discount them from the census). - [ ] **G. Runtime-contract anti-patterns.** Module-global `db` vs context-as-parameter (ADR-0008); wire-canonicalization in the query path vs native in-process return types @@ -134,6 +201,37 @@ The full hunt for each axis of Phase 1b (Partial / Deep path). Each axis runs in deliberately-own attribute `@dbColumnType` (a physical column-type override, never inherited). Any own read that carries a comment naming one of these cases is fine; an uncommented own read of an effective property is the defect. +- [ ] **G3. Guarded status transitions (a correctness check, `unguarded-status-transition`).** + For each model whose enum column is status-like (a `field.enum`, or a `field.string` named + `status` / `state` / `phase` / `stage`, whose members read as a lifecycle: pending, running, + complete, error), list **every write to that column** in non-generated code: an ORM + `update(...).set({ status })`, a `UPDATE ... SET status`, an entity property assignment that is + then saved, an upsert. For each write ask one question: **is it conditional on the current + value?** A guarded write names the state it moves from (`WHERE id = ? AND status = `, a + compare-and-set whose affected-row count is checked, an optimistic-lock version, a database + constraint that rejects the move). An unguarded write (`SET status = 'complete' WHERE id = ?`) + lets two workers, a retry or a late callback move a row backwards or out of a terminal state + (`complete` overwritten by `error`), and nothing reports it. An insert's initial value is not a + transition. A write that is the only possible transition and has one writer is lower + confidence, not exempt: say why it is safe to leave. Score `guarded writes / all writes` per + status column and list the unguarded ones; also state whether the allowed `from` states are + written down anywhere, because a rule held only in scattered `WHERE` clauses is a second + source of truth. + **The remedy never uses raw SQL.** Raw SQL spells the table, the column and the enum member by + hand, and those names drift. At a minimum the guarded write references the generated constants + for the table, the field and the enum member; ideally it goes through the port's ORM, which + carries them as typed handles, with the constraints the model already generates (the enum's + `CHECK`) behind it. Per port the guard is a predicate on the current value inside the ORM + update: Drizzle / Kysely `.where(and(eq(t.id, id), eq(t.status, )))` on TypeScript; + SQLAlchemy `update(T).where(T.id == id, T.status == )` or the `ObjectManager` on Python; + OMDB or the generated repository, or a JPA modifying query over entity attributes, on Java; + Exposed `T.update({ (T.id eq id) and (T.status eq ) })` on Kotlin; EF Core + `ExecuteUpdateAsync` after a `Where(x => x.Status == )` on C#. Each checks the + affected-row count. `` is the generated enum constant, never a literal (signature 13 in + `drift-signatures.md`). **If the allowed transitions need a declared form, that is a question + for the human, never a new attribute** (ADR-0023): the sketch proposes the ORM guard and + records the transition table as an open decision. Pillar `runtime`, surface `repository`. + - [ ] **H. Authoring-correctness / ADR-conformance (deep).** Invented/unregistered `@`-attrs or post-bootstrap registration (ADR-0023 — custom attrs belong in a registered provider or `attr.properties`); retired source-v2 forms (`source.dbTable` / `@name` / diff --git a/agent-context/skills/metaobjects-audit/references/typescript.md b/agent-context/skills/metaobjects-audit/references/typescript.md index ecb64ba2cb..1929a98514 100644 --- a/agent-context/skills/metaobjects-audit/references/typescript.md +++ b/agent-context/skills/metaobjects-audit/references/typescript.md @@ -70,6 +70,8 @@ here — the table is its second pass, not its definition. | the resource path in an API call or mount — `app.get("/subscribers")`, the `/subscribers` inside `fetch("/api/subscribers")`, a TanStack `queryKey` path | second spelling of `$path` on the entity module and its `.meta.ts` twin. The `/api` prefix is NOT part of the finding: the constants surface deliberately carries no prefix member — it is the provider's `baseUrl`, a deployment fact — so the prefix has no constant by design and is never a gap either | | a field name passed as text where the parameter's type is a bare `string` — `sort: "created_at"`, `filter["email"]`, a column-id string in a grid config | the per-field constants object carries `name`. Check the parameter type first: where the generated hook types it as a union of field names it is resolved and this row does not apply, exactly as a typed property access does not | | a form label or a validation limit/message re-typed in hand JSX or a hand validator (`maxLength={255}`, `"Email is required"`) | derived from `@title` and the field's validator children into `label` / `rules`; the hand copy is a second source of truth | +| a member of a generated enum typed as a hand string where the file already imports its constant (`status: "error"` beside `CouncilStatusEnum.enum.complete`), in a string-typed position, raw SQL, a JSON payload or an event name | **signature 13.** Value-first: grep the non-generated tree for each enum's `@values`. Check the declared type at the site first: a position narrowed by the generated `export type ` union is resolved and exempt; a `Record`, a `string` parameter or a `sql` fragment is compared and scores | +| a status-like column written with `.set({ status })` and no condition on the current value, or a `sql` `UPDATE ... SET status` | **axis G3.** Guard it through Drizzle / Kysely: `.where(and(eq(t.id, id), eq(t.status, )))` with the generated constant, and check the affected-row count. Never raw SQL | | **NOT a finding — the rule's consequences, not a list:** anything RESOLVED (a typed handle, a typed property access, a typed filter key, an enum member narrowed by the generated `export type ` union — measured: 332 such literals on one estate, 0 real) and anything the metadata does not OWN (a page route or link, `` / `` — 11 apparent `$path` hits on another estate, 0 real; the deployment prefix above) | rewriting a resolved reference to a string lookup is a regression; converting a page route couples the site's URL structure to the API's. Emitted `options: [...] as const` populates a dropdown, not replaces checked literals. A shape that is neither resolved nor unowned and has a constant → score it, whatever it is | --- @@ -118,8 +120,22 @@ are the `--format text` labels. In `--format json` or `toon` the same row carrie `diff -u node_modules/@metaobjectsdev/codegen-ts/src/reference/.ts codegen/generators/.ts` showing only upstream changes. Confirmed, it is the same finding. Not confirmed, report it as **possibly customized: check its history**, never as a copy to drop. -- A copy with lines of its own is an intentional customization. Check only how far behind - it is. +- A copy with lines of its own (`M > 0`) is **not** thereby an intentional customization. The + listing prints `DIFFERS` for both a deliberate customization and a copy gone stale by + version, and `M line(s) of your own` counts every line absent from today's reference: after + the reference moved on, a line it removed or rewrote reads as "yours" and is an older + upstream line. Run the same history check on any `DIFFERS` row, `M > 0` included + (`git log -p -- codegen/generators/.ts`): lines the copy's later commits added are the + project's own; lines already in the eject commit are upstream's, and count as behind. Report + ` lines behind the reference` and ` lines of the project's own (confirmed from + history)` as two figures. A copy whose own lines history does not confirm is **possibly + customized or stale: check its history**; a copy that is stale by version is a finding + (`owned-generator-stale`): re-eject at the current version or return to the package import. + +Count lines for the Phase 0 total: lines in copies proven unmodified, with the +`codegen/runtime/` files they reach, over all lines the project owns under `codegen/` +(`generators/`, `runtime/`, and the `templates/` modules an eject copies). +`meta eject --undo` removes every identical copy and prints the config edit. **`entity`, `routes` and `routes-hono` own more than the generator file.** Ejecting one also copies the HTTP adapter its output imports into `codegen/runtime/`, and a route fix diff --git a/agent-context/skills/metaobjects-authoring/SKILL.md b/agent-context/skills/metaobjects-authoring/SKILL.md index df2eadc0ff..459023b776 100644 --- a/agent-context/skills/metaobjects-authoring/SKILL.md +++ b/agent-context/skills/metaobjects-authoring/SKILL.md @@ -31,14 +31,14 @@ This file covers what almost every model needs. The topics below live in | `references/identities-and-indexes.md` | declaring a primary, secondary or reference identity, an FK, or a non-unique `index.lookup` | | `references/sources.md` | the `source.rdb` shape and `@kind`; a store MetaObjects does not manage; a derived or computed column (reach for an entity read-view first) | | `references/abstracts-and-overlay.md` | a shared `abstract` base, `extends`, or a layered `overlay` file | -| `references/declaring-reports.md` | declaring `dimension.*`, `measure.*`, `segment.filter` or an `object.report` | +| `references/declaring-reports.md` | **open first** for a report, dashboard, totals, `GROUP BY`, "per client / per month" or a read-only summary view: declaring `dimension.*`, `measure.*`, `segment.filter` or an `object.report` | | `references/model-first-rationale.md` | someone argues that hand-writing a layer is cheaper this once | | `references/relationships.md` | a many-to-many link or self-join, or a "rows that reference this one" query | -| `references/read-views-and-projections.md` | an `object.projection`, `origin.*` vocabulary, `@filter` / `@expr`, or an `@sql` / `@unmanaged` view | +| `references/read-views-and-projections.md` | an `object.projection`, `origin.*` vocabulary, `@filter` / `@expr`, or an `@sql` / `@unmanaged` view (a grouped or aggregate view is `declaring-reports.md` first) | | `references/inheritance-tph.md` | several entities are variants of one thing sharing a single table (`@discriminator`) | | `references/metadata-dependencies.md` | the project builds on another package's metadata (`dependencies`, cross-package `overlay`) | | `references/reporting.md` | what a declared report gives you: what columns a report gets, time grains, null rules, rows with no facts (`@spine`), defaults (`@default`), engine differences | -| `references/requirements.md` | installed only when the project declares `requirement.*` nodes | +| `references/requirements.md` | you add, change or review a `requirement.*` node | ## The operating principle: model-first, generate-first @@ -245,7 +245,7 @@ Reach for these before inventing anything. When no row fits, run the decision pr | Open JSON, no reader narrows it | `field.string` + `@dbColumnType: jsonb` | the LAST rung — see "A JSON column" | | URL / URI | `field.uri` | native `URI`/`Uri`; `text` column; strict absolute-URI validation (add `@lenient: true` to store any string) — a real native type + behavior, so a subtype (not a validated string) | | IP address | `field.inet` | native IP type; Postgres `inet` column; strict IPv4/IPv6-literal validation (add `@lenient: true` for a plain-string `text` column) | -| Elapsed time / timeout / delay | `field.duration` | native `TimeSpan`/`Duration`/`timedelta`; Postgres `interval` column; ISO-8601 on the wire (`PT1H30M`). Not for a calendar span ("every 3 months"): that is an int and a unit. Never a string or a count of seconds | +| Elapsed time / timeout / delay | `field.duration` | native `TimeSpan`/`Duration`/`timedelta`; Postgres `interval` column; wire form is the port's native one by default, canonical ISO-8601 (`PT1H30M`) under `wire.durations: iso`. Not for a calendar span ("every 3 months"): that is an int and a unit. Never a string or a count of seconds | | Validated plain string (email / hostname) | `field.string` + `@stringFormat` | `@stringFormat: email` or `@stringFormat: hostname` — idiomatic per-port validation; don't hand-write the `validator.regex` | Four rules behind those rows, in short (full text: `references/choosing-a-shape.md`): @@ -286,13 +286,10 @@ Reuse a constraint set across entities with an abstract `field.enum` + `extends` `field.object` embeds another `object` declaration. `@objectRef` names it; `@storage` controls persistence: -- `flattened` — one DB column per sub-field (`address_street`, `address_city`, …). - Illegal on array fields. The prefix is the field's column and `_`; - `@flattenedColumnPrefix` on the field replaces it verbatim (`""` keeps the members' - own columns). Refused on any other storage. -- `jsonb` — one `jsonb` column. +- `flattened` — one DB column per sub-field (`address_street`, …); illegal on arrays. `@flattenedColumnPrefix` + replaces the `_` prefix verbatim (`""` keeps the members' own columns). +- `jsonb` — one `jsonb` column; also the default when `@storage` is not set. - `subdocument` — single jsonb column (a hint for document-store targets). -- not set (the default) — one `jsonb` column, as `jsonb`. ```json { "field.object": { "name": "address", "@objectRef": "Address", "@storage": "flattened" } } @@ -430,25 +427,29 @@ behavior: Entity-scoped `validator.*` children declare invariants that reference sibling fields **by name** (the same name-reference pattern as `identity.*`). The backend derives the -enforcement (a CHECK constraint / cross-field assertion) — no raw expression is stored. +enforcement — no raw expression is stored. A DB `CHECK` constraint is emitted by `meta migrate`, +and the generated full create/record model also enforces the rule in every port (Zod refinement, +Bean Validation class-level constraint, `IValidatableObject`, Pydantic `model_validator`), so a +store with no `CHECK` support is still covered. PATCH and partial-update models do not enforce them +(a partial body cannot see the merged row); the DB `CHECK` is the enforcement there. | Subtype | Rule | Key attrs | |---|---|---| -| `validator.comparison` | two fields stand in a relational order (`@left @op @right`) | `@left`, `@op` (`gt`/`gte`/`lt`/`lte`/`ne`/`eq`), `@right` | +| `validator.comparison` | two fields stand in a relational order (`@left @op @right`). Numerics compare with each other; strings, temporals and durations only with the same subtype and `@localTime`; boolean, enum, uuid, uri and inet only `eq`/`ne`. Any other pair is skipped, never rejected. | `@left`, `@op` (`gt`/`gte`/`lt`/`lte`/`ne`/`eq`), `@right` | | `validator.requiredWhen` | `@field` is required when `@when` equals `@equals` | `@field`, `@when`, `@equals` | | `validator.presentIff` | `@field` is present **iff** `@when` equals `@equals` (biconditional) | `@field`, `@when`, `@equals` | -| `validator.atLeastOne` | at least one of `@fields` (2+) is present; with `@max`, at most that many (`@max: 1` = exactly one) | `@fields`, `@max` | +| `validator.atLeastOne` | at least one of `@fields` (2+) is present | `@fields` | +| `validator.exactlyOne` | exactly one of `@fields` (2+) is present | `@fields` | -All four take an optional `@condition`, an expression over the entity's fields (the -`origin.computed` grammar): the rule then holds only where the condition does. And every validator -that becomes a CHECK takes an optional db-provider `@constraintName` naming it. +All five take an optional `@condition` (the `origin.computed` grammar): the rule holds only where it does. +Every validator that becomes a CHECK takes an optional `@constraintName`. ```json { "validator.comparison": { "name": "hpInRange", "@left": "currentHp", "@op": "lte", "@right": "maxHp" } } { "validator.requiredWhen": { "name": "reasonIfRejected", "@field": "rejectReason", "@when": "status", "@equals": "rejected" } } { "validator.presentIff": { "name": "usedAtWhenUsed", "@field": "usedAt", "@when": "isUsed", "@equals": "true" } } { "validator.atLeastOne": { "name": "emailOrPhone", "@fields": ["email", "phone"] } } -{ "validator.atLeastOne": { "name": "oneOwner", "@fields": ["customerId", "accountId"], "@max": 1 } } +{ "validator.exactlyOne": { "name": "oneOwner", "@fields": ["customerId", "accountId"] } } ``` These are children of `object.entity`, alongside its fields and identities. @@ -460,6 +461,12 @@ Several variants of one thing sharing **one table**: the base `object.entity` de `@discriminatorValue`. Codegen emits per-subtype routes with the discriminator injected and immutable. Supported in all five ports; the worked example is in `references/inheritance-tph.md`. +## Your own vocabulary — a provider class, in every language + +A subtype or attribute the core does not ship (a `layout.picker`, `@searchable` on fields) is registered by a **provider class** in the project's own language — never a side file, never a loosened `strict`. Decide the shape first (`references/choosing-a-shape.md`, which also has the register/extend rules). List the provider once in the port's project configuration and every command that loads metadata — gen and its docs generators, verify, fmt — composes it. Where each port lists it, plus a worked example: `references/typescript-providers.md`, `references/python-providers.md`, `references/csharp-providers.md`, `references/java-providers.md`, `references/kotlin-providers.md` (only this stack's are installed). + +**Every port whose tools load the metadata needs its own copy**: a TypeScript-only provider leaves the Java, Python or C# side, and its docs build, failing with `ERR_UNKNOWN_SUBTYPE` / `ERR_UNKNOWN_ATTR`. + ## Requirements — capability ledger (opt-in) **This capability exists whether or not the project uses it yet.** `requirement.functional` and `requirement.architectural` are registered metadata types, declared in the metadata directory beside the entities they describe and loaded by the same loader — no side file, no bespoke parser. They record *why* each part of the model exists, so a field with no reason to exist becomes visible as one. @@ -476,7 +483,7 @@ Every requirement must be **violable**: if you cannot say what breaking it looks **A commit that adds, changes or removes behaviour updates the ledger in the same commit** (the new or changed claim, its `@status` and `@implementedBy`), or says in the commit message why it does not. `verify` checks that links resolve, not that the ledger is current. -If the project declares any `requirement.*` node, `references/requirements.md` is installed with the full authoring rules. If it does not and you are adding the first one, the shape is: +`references/requirements.md` has the full authoring rules. The shape of one node: ```yaml - requirement.architectural: diff --git a/agent-context/skills/metaobjects-authoring/references/adopting-existing-models.md b/agent-context/skills/metaobjects-authoring/references/adopting-existing-models.md index 2fb95c0853..6854ed810c 100644 --- a/agent-context/skills/metaobjects-authoring/references/adopting-existing-models.md +++ b/agent-context/skills/metaobjects-authoring/references/adopting-existing-models.md @@ -67,7 +67,7 @@ import { defineConfig } from "@metaobjectsdev/cli"; export default defineConfig({ outDir: "src/generated", // beside the existing code; nothing imports it yet - outputLayout: "flat", // the paths below; the default puts each metadata package in a directory of its own + outputLayout: "flat", // the paths below; "package" puts each metadata package in a directory of its own dialect: "postgres", timestampMode: "date", // when the existing timestamp columns read as Date generators: ["entity"], @@ -160,7 +160,7 @@ import { entityFile } from "@metaobjectsdev/codegen-ts/generators"; export default defineConfig({ outDir: "src/generated", - outputLayout: "flat", // the paths below; the default puts each metadata package in a directory of its own + outputLayout: "flat", // the paths below; "package" puts each metadata package in a directory of its own dialect: "postgres", targets: { contract: { outDir: "src/generated", runtime: false }, // Zod schemas and types, no ORM diff --git a/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md b/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md index 7ae89655d9..bb4979af93 100644 --- a/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md +++ b/agent-context/skills/metaobjects-authoring/references/choosing-a-shape.md @@ -162,6 +162,17 @@ or behavior is a **subtype**, and structural variants *within* such a subtype ar (including any `@kind` value-set) carry `allowedValues` in the gate (ADR-0036). ADR-0037 is the authority. +**What a provider does.** It names an `id` and the provider ids it depends on, then does one +or both of two things. It **registers** a new `(type, subType)` with its own attributes, which +may be required, and a node class (reuse the type's existing one unless the node has new +behaviour). It **extends** an existing `(type, subType)` with attributes, which must be +optional: a required one is `ERR_EXTEND_REQUIRED_ATTR` (ADR-0050), because removing your +provider must never weaken a type someone else owns. A new type allowed at the document root +also needs `extend` on `metadata.root` to admit it, or it fails with `ERR_CHILD_NOT_ALLOWED`. +An attribute no provider declares is `ERR_UNKNOWN_ATTR` under a strict load, and a subtype +nobody registered is `ERR_UNKNOWN_SUBTYPE`; that refusal is what keeps a typo from loading. +The per-language example and wiring is in the skill's `references/-providers.md`. + **Converge before inventing.** Search the shipped vocabulary first (`meta types `) and check the roadmap — if core already models (or plans) the concept, model yours in a fold-in-friendly shape. The type names `api`, `operation`, `surface`, and @@ -175,6 +186,14 @@ and address-free — the subtype names the *concept*; transport/protocol is a cl Declare config as the *names* of required keys (values stay in env/config) and generate a fail-closed check. Reference typed payloads instead of inlining shapes. +**Name your attributes so they cannot collide.** Two providers may not claim one attribute +name on a node type (ADR-0062): the registry refuses the second at composition with +`ERR_PROVIDER_ATTR_CONFLICT` (same `(type, subType)`) or `ERR_PROVIDER_ATTR_SHADOW` (the shared +`.base` root, or a subtype of it), naming both providers. A physical address takes your +store's own idiomatic word (`@column` relational, `@field` document), unique on that node type; +`meta types --detail` shows which provider holds each name. A store with no provider of its own +uses the registered `attr.properties` bag rather than an invented attribute. + **Lifecycle.** Register with explicit provider wiring — never loosen `strict` to free-ride ad-hoc attrs. When core later ships the concept your provider shrinks from `register` to `extend` (the `template.toolcall` precedent). A second independent diff --git a/agent-context/skills/metaobjects-authoring/references/csharp-providers.md b/agent-context/skills/metaobjects-authoring/references/csharp-providers.md new file mode 100644 index 0000000000..45896849cf --- /dev/null +++ b/agent-context/skills/metaobjects-authoring/references/csharp-providers.md @@ -0,0 +1,85 @@ +# Your own vocabulary in C# — a provider + +> Part of the `metaobjects-authoring` skill, "Your own vocabulary". Read it when the project +> needs a subtype or an attribute the core does not ship, and its C# tools load the metadata. + +A provider is a public class implementing `IMetaDataTypeProvider`, with a public parameterless +constructor: an `Id`, the provider ids it depends on, and a `RegisterTypes(registry)` body that +calls `Register` (a new subtype) and `Extend` (attributes on an existing one). Put it in its +own class library that references the `MetaObjects` package at the version your `dotnet meta` +tool runs. This one registers `layout.picker` and adds `@searchable` and `@valueLabels` to +`field.string`: + +```csharp +// vocabulary/AcmeVocabularyProvider.cs (vocabulary/Acme.Vocabulary.csproj: net8.0 class +// library with ) +using MetaObjects; +using MetaObjects.Meta; +using MetaObjects.Shared; + +namespace Acme.Vocabulary; + +public sealed class AcmeVocabularyProvider : IMetaDataTypeProvider +{ + public string Id => "acme-vocabulary"; + public IReadOnlyList Dependencies => ["metaobjects-core-types"]; + + public void RegisterTypes(TypeRegistry registry) + { + // A new subtype, with its own attribute (an own attribute may be required). + registry.Register(new TypeDefinition( + typeId: new TypeId("layout", "picker"), + description: "A picker over the owning object.", + childRules: [new ChildRule(BaseTypes.TYPE_ATTR, Structural.CHILD_RULE_WILDCARD, Structural.CHILD_RULE_WILDCARD)], + factory: (typeId, name) => new MetaLayout(typeId, name), + attributes: [new AttrSchema("displayField", "string", Required: false)])); + + // Attributes on a type another provider owns: always optional. + registry.Extend("field", "string", attributes: + [ + new AttrSchema("searchable", "boolean", Required: false), + new AttrSchema("valueLabels", "string", Required: false, IsArray: true), + ]); + } +} +``` + +Wire it once, in `.metaobjects/config.json`. `assembly` is the BUILT dll, relative to the +directory holding `.metaobjects/`; `type` is the provider's full type name: + +```json +{ + "schema_version": 1, + "csharp": { + "providers": [ + { "assembly": "vocabulary/bin/Debug/net8.0/Acme.Vocabulary.dll", "type": "Acme.Vocabulary.AcmeVocabularyProvider" } + ] + } +} +``` + +Build the vocabulary first (`dotnet build vocabulary`); a missing dll is refused with the path +and that instruction. Then `dotnet meta gen` and `verify --codegen` (through the project's +`codegen/` runner), `dotnet meta verify` (templates, requirements, field lint) and +`dotnet meta fmt` all compose the core providers plus this one. The `codegen/` project may +also reference the vocabulary project directly; the already-loaded assembly is reused. + +An application host that loads the model itself composes the registry in code: + +```csharp +var registry = Provider.ComposeRegistry([.. CoreTypes.LibraryProviders, new AcmeVocabularyProvider()]); +var load = MetaDataLoader.FromDirectory("metaobjects", registry, strict: true); +``` + +The metadata uses it like core vocabulary: + + +```json +{ "field.string": { "name": "name", "@searchable": true } } +{ "layout.picker": { "name": "contactPicker", "@displayField": "name" } } +``` + +Without the provider the same file fails `dotnet meta verify` with `ERR_UNKNOWN_SUBTYPE` on +`layout.picker` and `ERR_UNKNOWN_ATTR` on `@searchable`. If another port's tools load this +metadata too, that port needs its own copy of the provider (same id, same vocabulary). Each port's `verify` loads strict, so a clean run there proves that port's copy is complete. +Full contract: `docs/features/extending-with-providers.md`. diff --git a/agent-context/skills/metaobjects-authoring/references/declaring-reports.md b/agent-context/skills/metaobjects-authoring/references/declaring-reports.md index 544a7fbe69..ecaaa30cc1 100644 --- a/agent-context/skills/metaobjects-authoring/references/declaring-reports.md +++ b/agent-context/skills/metaobjects-authoring/references/declaring-reports.md @@ -18,6 +18,10 @@ and an `object.report` combines them by name. Four node kinds: `field.boolean` `@of`, or no `@of` and a `@filter` or `@segment`: `{ "name": "hasError", "@agg": "any", "@filter": { "success": false } }` is "some row has `success` false" (a row whose condition is null does not pass); +- `measure.derived` — `@expr` arithmetic (`add`, `subtract`, `multiply`, `divide`, two operands + each) over `{ "field": }` and `{ "value": }`: + utilization is `billableHours × 100 ÷ (weeklyCapacityHours × 52 ÷ 12)`. A dimension it reads + must be in the report's `@dimensions`; it never reads another derived measure; - `segment.filter` — a named, reusable `@filter` ("active purchase"); - `object.report` — a top-level object: `@from` an entity, `@dimensions` (`name` or `name:grain`), `@measures`. @@ -72,6 +76,11 @@ Three rules an author trips on: measure (a time dimension at a grain is ``, so `purchasedAt:day` is `purchasedAtDay`). A `field.*` or `identity.*` child on a report is an error. +**Money.** `@of` may name a member of a `@storage: flattened` value object, +`Payment.amount.amount`. A `sum`, `avg`, `min` or `max` of it loads only when the report also +lists a dimension over each non-numeric member (`Payment.amount.currency`), so currencies are +never added together. A jsonb value object's members are refused. + Two questions to answer for every report: - **Do I want the rows that have no facts?** A report's rows come from the facts, so a @@ -99,8 +108,8 @@ A report `@from` a TPH subtype is refused when its view is derived (the subtype base's table): declare it `@from` the base with an `@filter` on the discriminator field. What does not exist: no grid or form for a report (TypeScript generates a list hook; no other port has a client tier), no way to narrow which -derived fields are filterable, no `measure.derived` -(arithmetic between measures beyond `measure.ratio`), no query-time choice of dimensions or +derived fields are filterable, no product measure +(`sum(hours × rate)`), no member of a jsonb value object, no query-time choice of dimensions or measures (a report is a fixed, compiled combination), and no time-zone vocabulary (grains and relative dates are UTC). Column types, the null rules, Monday weeks and per-engine differences are in `references/reporting.md`. diff --git a/agent-context/skills/metaobjects-authoring/references/identities-and-indexes.md b/agent-context/skills/metaobjects-authoring/references/identities-and-indexes.md index f21a5d0070..22b3ef1385 100644 --- a/agent-context/skills/metaobjects-authoring/references/identities-and-indexes.md +++ b/agent-context/skills/metaobjects-authoring/references/identities-and-indexes.md @@ -42,10 +42,16 @@ An `identity.secondary` can index an **expression** instead of plain columns: us index method — `gin` / `gist` / `hash`; default `btree`) and `@where` (a partial-index predicate). +**Name every `identity.secondary` and `index.lookup` after its table.** The name is used +verbatim as the database index name, and index names are unique across the whole schema, +not per table. Two entities that both declare `byName` load and generate cleanly, then +`meta migrate` stops with `ERR_DUPLICATE_SQL_NAME`. Prefix the entity (`clientByName`, +`tagByName`). + ```json { "identity.primary": { "name": "id", "@fields": ["id"], "@generation": "increment" } } -{ "identity.secondary": { "name": "byEmail", "@fields": ["email"] } } -{ "identity.secondary": { "name": "byEmailCI", "@expr": "lower(email)" } } +{ "identity.secondary": { "name": "userByEmail", "@fields": ["email"] } } +{ "identity.secondary": { "name": "userByEmailCI", "@expr": "lower(email)" } } { "identity.reference": { "name": "fkAuthor", "@fields": ["authorId"], "@references": "Author", "@enforce": true } } ``` @@ -73,10 +79,10 @@ The db provider contributes physical-tuning attrs alongside either form: `@order `btree`), and `@where` (partial-index predicate). ```json -{ "index.lookup": { "name": "byCreatedAt", "@fields": ["createdAt"], "@orders": ["desc"] } } -{ "index.lookup": { "name": "byStatusCreatedAt", "@fields": ["status", "createdAt"] } } -{ "index.lookup": { "name": "byEmailCI", "@expr": "lower(email)" } } -{ "identity.secondary": { "name": "uniqLowerEmail", "@expr": "lower(email)" } } +{ "index.lookup": { "name": "orderByCreatedAt", "@fields": ["createdAt"], "@orders": ["desc"] } } +{ "index.lookup": { "name": "orderByStatusCreatedAt", "@fields": ["status", "createdAt"] } } +{ "index.lookup": { "name": "userByEmailCI", "@expr": "lower(email)" } } +{ "identity.secondary": { "name": "userUniqLowerEmail", "@expr": "lower(email)" } } ``` `index.lookup` is a sibling of `identity.*` — declare it as a direct child of an `object.entity`, diff --git a/agent-context/skills/metaobjects-authoring/references/java-providers.md b/agent-context/skills/metaobjects-authoring/references/java-providers.md new file mode 100644 index 0000000000..8b7b598054 --- /dev/null +++ b/agent-context/skills/metaobjects-authoring/references/java-providers.md @@ -0,0 +1,93 @@ +# Your own vocabulary in Java — a provider + +> Part of the `metaobjects-authoring` skill, "Your own vocabulary". Read it when the project +> needs a subtype or an attribute the core does not ship, and its Java tools load the metadata. + +A provider is a public class implementing `com.metaobjects.registry.MetaDataTypeProvider`, with +a public no-arg constructor: a provider id, the provider ids it depends on (the JVM ids: +`field-types` registers the field types, `layout-types` the layouts), and a `registerTypes` +body that calls `registerType` (a new subtype, backed by its own node class) and `extendType` +(attributes on an existing one). This one registers `layout.picker` and adds `@searchable` and +`@valueLabels` to `field.string`: + +```java +package com.acme.vocab; + +import com.metaobjects.attr.BooleanAttribute; +import com.metaobjects.attr.StringAttribute; +import com.metaobjects.field.StringField; +import com.metaobjects.layout.MetaLayout; +import com.metaobjects.registry.MetaDataRegistry; +import com.metaobjects.registry.MetaDataTypeProvider; + +public final class AcmeVocabulary implements MetaDataTypeProvider { + /** The node class behind layout.picker. */ + public static final class PickerLayout extends MetaLayout { + public PickerLayout(String name) { super("picker", name); } + } + + @Override public String getProviderId() { return "acme-vocabulary"; } + @Override public String[] getDependencies() { return new String[] {"field-types", "layout-types"}; } + + @Override public void registerTypes(MetaDataRegistry registry) { + // A new subtype, with its own attribute (an own attribute may be required). + registry.registerType(PickerLayout.class, def -> { + def.type("layout").subType("picker").inheritsFrom("layout", "base"); + def.optionalAttributeWithConstraints("displayField").ofType(StringAttribute.SUBTYPE_STRING).asSingle(); + }); + // Attributes on a type another provider owns: always optional. + registry.extendType(StringField.class, def -> { + def.optionalAttributeWithConstraints("searchable").ofType(BooleanAttribute.SUBTYPE_BOOLEAN).asSingle(); + def.optionalAttributeWithConstraints("valueLabels").ofType(StringAttribute.SUBTYPE_STRING).asArray(); + }); + } +} +``` + +Wire it once, in the `metaobjects-maven-plugin` configuration. The class must be on the +plugin's classpath: put the provider in its own module and add that module as a project +dependency or under the plugin's ``. A provider in the same module is not +compiled yet when `generate` runs at `generate-sources`. + +```xml + + com.metaobjects + metaobjects-maven-plugin + + + com.acme.vocab.AcmeVocabulary + + + + com.acmeacme-vocabulary1.0 + + +``` + +`metaobjects:generate` (with its docs generators), `metaobjects:verify`, `metaobjects:fmt` and +`metaobjects:editor` all compose the metamodel providers plus these. Listing a class in +`META-INF/services` does NOT add it to the loader: the strict loader composes a fixed +metamodel set plus the providers you name, so a jar on the classpath cannot change the +vocabulary by accident. + +In a Spring Boot app, declare the provider as a bean and the auto-configured loader composes +it: `@Bean MetaDataTypeProvider acmeVocabulary() { return new AcmeVocabulary(); }`. Code that +loads the model itself passes it on the options: + +```java +MetaDataLoader.fromUris("app", uris, + LoaderOptions.create(false, false, true).setProviders(List.of(new AcmeVocabulary()))); +``` + +The metadata uses it like core vocabulary: + + +```json +{ "field.string": { "name": "name", "@searchable": true } } +{ "layout.picker": { "name": "contactPicker", "@displayField": "name" } } +``` + +Without the provider the same file fails `metaobjects:verify` with `ERR_UNKNOWN_SUBTYPE` on +`layout.picker` and `ERR_UNKNOWN_ATTR` on `@searchable`. If another port's tools load this +metadata too, that port needs its own copy of the provider (the same vocabulary). Each port's `verify` loads strict, so a clean run there proves that port's copy is complete. +Full contract: `docs/features/extending-with-providers.md`. diff --git a/agent-context/skills/metaobjects-authoring/references/kotlin-providers.md b/agent-context/skills/metaobjects-authoring/references/kotlin-providers.md new file mode 100644 index 0000000000..09d6c6c4a4 --- /dev/null +++ b/agent-context/skills/metaobjects-authoring/references/kotlin-providers.md @@ -0,0 +1,77 @@ +# Your own vocabulary in Kotlin — a provider + +> Part of the `metaobjects-authoring` skill, "Your own vocabulary". Read it when the project +> needs a subtype or an attribute the core does not ship, and its Kotlin tools load the +> metadata. + +Kotlin runs on the JVM registry, so a provider is a class implementing +`com.metaobjects.registry.MetaDataTypeProvider`, written in Kotlin: a provider id, the JVM +provider ids it depends on (`field-types`, `layout-types`), and a `registerTypes` body that +calls `registerType` (a new subtype, backed by its own node class) and `extendType` +(attributes on an existing one). This one registers `layout.picker` and adds `@searchable` and +`@valueLabels` to `field.string`: + +```kotlin +package com.acme.vocab + +import com.metaobjects.field.StringField +import com.metaobjects.layout.MetaLayout +import com.metaobjects.registry.MetaDataRegistry +import com.metaobjects.registry.MetaDataTypeProvider + +/** The node class behind layout.picker. */ +class PickerLayout(name: String) : MetaLayout("picker", name) + +class AcmeVocabulary : MetaDataTypeProvider { + override fun getProviderId() = "acme-vocabulary" + override fun getDependencies() = arrayOf("field-types", "layout-types") + + override fun registerTypes(registry: MetaDataRegistry) { + // A new subtype, with its own attribute (an own attribute may be required). + registry.registerType(PickerLayout::class.java) { def -> + def.type("layout").subType("picker").inheritsFrom("layout", "base") + def.optionalAttributeWithConstraints("displayField").ofType("string").asSingle() + } + // Attributes on a type another provider owns: always optional. + registry.extendType(StringField::class.java) { def -> + def.optionalAttributeWithConstraints("searchable").ofType("boolean").asSingle() + def.optionalAttributeWithConstraints("valueLabels").ofType("string").asArray() + } + } +} +``` + +Wire it once. Kotlin generators run through `metaobjects:generate`, so the build lists it in +the `metaobjects-maven-plugin` configuration, with the provider's module on the plugin's +classpath (a project dependency or the plugin's ``; a provider in the same +module is not compiled yet at `generate-sources`): + +```xml + + + com.acme.vocab.AcmeVocabulary + + +``` + +`generate`, `verify`, `fmt` and `editor` then all load it. `META-INF/services` does not add a +provider to the loader. In a Spring Boot app, a `MetaDataTypeProvider` bean is composed into +the auto-configured loader. Code that loads the model through the `metadata-ktx` facade passes +it directly: + +```kotlin +val result = loadUris("app", uris, LoaderOptions.create(false, false, true), providers = listOf(AcmeVocabulary())) +``` + +The metadata uses it like core vocabulary: + + +```json +{ "field.string": { "name": "name", "@searchable": true } } +{ "layout.picker": { "name": "contactPicker", "@displayField": "name" } } +``` + +Without the provider the same file fails `metaobjects:verify` with `ERR_UNKNOWN_SUBTYPE` on +`layout.picker` and `ERR_UNKNOWN_ATTR` on `@searchable`. If another port's tools load this +metadata too, that port needs its own copy of the provider (the same vocabulary). Each port's `verify` loads strict, so a clean run there proves that port's copy is complete. +Full contract: `docs/features/extending-with-providers.md`. diff --git a/agent-context/skills/metaobjects-authoring/references/metadata-dependencies.md b/agent-context/skills/metaobjects-authoring/references/metadata-dependencies.md index 2574655ffe..35ac248049 100644 --- a/agent-context/skills/metaobjects-authoring/references/metadata-dependencies.md +++ b/agent-context/skills/metaobjects-authoring/references/metadata-dependencies.md @@ -9,10 +9,14 @@ committed snapshot — that snapshot loads BEFORE your own files, so a foreign abstract resolves via `extends` and a foreign node re-opens via `overlay: true` exactly like a local one. A dependency names one transport: `path` (a directory relative to the directory holding `.metaobjects/`), `npm` (an installed npm -package, e.g. `{ "name": "acme-model", "npm": "@acme/model", "dir": "metaobjects" }`) -or `python` (an installed Python package by its import name, e.g. -`{ "name": "acme-model", "python": "acme_model", "dir": "metaobjects" }`). For -`npm`/`python`, install the package with the project's package manager first; +package, e.g. `{ "name": "acme-model", "npm": "@acme/model", "dir": "metaobjects" }`), +`python` (an installed Python package by its import name, e.g. +`{ "name": "acme-model", "python": "acme_model", "dir": "metaobjects" }`), `maven` +(`{ "name": "acme-model", "maven": "com.acme:acme-model", "version": "1.0.0" }`, a JAR in the +local Maven repository) or `nuget` +(`{ "name": "acme-model", "nuget": "Acme.Model", "version": "1.0.0" }`, a package in the NuGet +global packages folder). For +`npm`/`python`/`maven`/`nuget`, install or restore the package with the project's package manager first; `meta deps sync` locates it, copies its shared model into the snapshot, and says what to install when it is missing. Prefer the package transport over a `path` into someone else's checkout when the publisher releases a package. Two rules are diff --git a/agent-context/skills/metaobjects-authoring/references/python-providers.md b/agent-context/skills/metaobjects-authoring/references/python-providers.md new file mode 100644 index 0000000000..2e0a55db54 --- /dev/null +++ b/agent-context/skills/metaobjects-authoring/references/python-providers.md @@ -0,0 +1,69 @@ +# Your own vocabulary in Python — a provider + +> Part of the `metaobjects-authoring` skill, "Your own vocabulary". Read it when the project +> needs a subtype or an attribute the core does not ship, and its Python tools load the +> metadata. + +A provider is a `metaobjects.provider.Provider`: an id, the provider ids it depends on, the +`TypeDefinition`s it adds (a new subtype), and an `on_register` hook that `extend`s existing +types. This one registers `layout.picker` and adds `@searchable` and `@valueLabels` to +`field.string`: + +```python +# acme_vocab.py (beside metaobjects.config.yaml) +from metaobjects.meta.presentation.layout.meta_layout import MetaLayout +from metaobjects.provider import Provider +from metaobjects.registry import AttrSchema, ChildRule, TypeDefinition +from metaobjects.shared.base_types import TYPE_ATTR + +provider = Provider("acme-vocabulary", dependencies=("metaobjects-core-types",)) + +# A new subtype, with its own attribute (an own attribute may be required). +provider.add(TypeDefinition( + type="layout", sub_type="picker", factory=MetaLayout, + attrs=[AttrSchema("displayField", "string", required=False)], + child_rules=[ChildRule(TYPE_ATTR, "*")], +)) + +# Attributes on a type another provider owns: always optional. +provider.on_register(lambda registry: registry.extend( + "field", "string", + attributes=[ + AttrSchema("searchable", "boolean", required=False), + AttrSchema("valueLabels", "string", required=False, is_array=True), + ], +)) +``` + +Wire it once, in `metaobjects.config.yaml`, as `module:symbol`. The module resolves relative +to the config's directory, so no `PYTHONPATH` is needed: + +```yaml +metadata: metaobjects +providers: ["acme_vocab:provider"] +``` + +`metaobjects gen` (with its docs generators), every `metaobjects verify` mode and +`metaobjects fmt` read that list; `--provider module:symbol` adds to it for one run. Code that +loads the model itself passes the full list, core first, because `providers=` is exactly the +set composed: + +```python +from metaobjects.core_types import core_providers +from metaobjects.loader.meta_data_loader import MetaDataLoader + +result = MetaDataLoader.from_directory("metaobjects", providers=[*core_providers, provider], strict=True) +``` + +The metadata uses it like core vocabulary: + + +```json +{ "field.string": { "name": "name", "@searchable": true } } +{ "layout.picker": { "name": "contactPicker", "@displayField": "name" } } +``` + +Without the provider the same file fails `metaobjects verify` with `ERR_UNKNOWN_SUBTYPE` on +`layout.picker` and `ERR_UNKNOWN_ATTR` on `@searchable`. If another port's tools load this +metadata too, that port needs its own copy of the provider (same id, same vocabulary). Each port's `verify` loads strict, so a clean run there proves that port's copy is complete. +Full contract: `docs/features/extending-with-providers.md`. diff --git a/agent-context/skills/metaobjects-authoring/references/read-views-and-projections.md b/agent-context/skills/metaobjects-authoring/references/read-views-and-projections.md index c58b0e5adc..99422ce11f 100644 --- a/agent-context/skills/metaobjects-authoring/references/read-views-and-projections.md +++ b/agent-context/skills/metaobjects-authoring/references/read-views-and-projections.md @@ -1,6 +1,6 @@ # Projections, `origin.*`, and managed views -> Part of the `metaobjects-authoring` skill. The skill covers the entity read-view, which is the right answer for most grids. Read this when you need an independent exposure (`object.projection`), the `origin.*` vocabulary, `@filter` / `@expr` shapes, or an `@sql` / `@unmanaged` view. +> Part of the `metaobjects-authoring` skill. The skill covers the entity read-view, which is the right answer for most grids. Read this when you need an independent exposure (`object.projection`), the `origin.*` vocabulary, `@filter` / `@expr` shapes, or an `@sql` / `@unmanaged` view. A grouped total or report (per client, per month) is an `object.report`: `declaring-reports.md`. ## Contents - Read-view or projection? @@ -125,8 +125,9 @@ non-aggregate-derived** projection fields: naming an undeclared field fails the **The `CREATE VIEW` body is generated from those `origin.*` children by the Node `meta migrate` — never hand-author view SQL for a shape origins can express** (an unmodeled -view is *unmanaged*, so `meta verify --db` can't even catch the drift). For a genuinely -irreducible body (recursive CTE, window function, set operation) that origins can't express, +view is *unmanaged*, so `meta verify --db` can't even catch the drift). **An `@sql` body that +`GROUP BY`s: check `declaring-reports.md` first** (`object.report`, `@spine`, `@default`). +For a genuinely irreducible body (recursive CTE, window function, set operation) that origins can't express, carry it in the `source.rdb` **`@sql`** escape (#208, ADR-0043) — a hand-written body the tool registers, fingerprints, and drift-checks (adopt a pre-existing view with `meta migrate --allow adopt-view`) — rather than a hand-edited migration file where it goes @@ -153,6 +154,13 @@ walls it off (#208).** Author an `@sql` source under these constraints or the lo - Today `meta migrate` **lowers `@sql` only on `@kind: view`**; on matview / storedProc / tableFunction it is registered but not yet migrate-managed (mark those `@unmanaged`). +**Removing a column an `@sql` body reads: edit the body in the same change.** The tool never +parses an `@sql` body, so it cannot see that the body still names the column. The migration +is still written: on Postgres it fails at apply (`column "…" does not exist`); on SQLite it +applies and leaves a view that errors when queried. An `@unmanaged` view is not rewritten +either: with `--from-db`, `meta migrate` blocks a drop of a column such a view still reads +and names the view (`--allow drop-column-read-by-view` to proceed); fix the view first. + **A `passthrough` field must match its `@from` source's type.** A passthrough forwards the source value unchanged, so the projection field's `field.` and array-ness must be identical to the source field's — a `field.uuid` source diff --git a/agent-context/skills/metaobjects-authoring/references/reporting.md b/agent-context/skills/metaobjects-authoring/references/reporting.md index 33c60ec19b..eaa55e3356 100644 --- a/agent-context/skills/metaobjects-authoring/references/reporting.md +++ b/agent-context/skills/metaobjects-authoring/references/reporting.md @@ -49,6 +49,7 @@ A report declares no fields. Its columns are one per `@dimensions` item in liste | `min` / `max` | the measure's name | the `@of` field's type | no | | `any` / `all` (boolean OR / AND, `bool_or` / `bool_and`; over a `field.boolean` `@of`, or with no `@of` over the measure's `@filter` / `@segment`) | the measure's name | `boolean` | no | | `measure.ratio` | the measure's name | `decimal` | no | +| `measure.derived` | the measure's name | `decimal` | no | | any measure above except `count`, declaring `@default` | the measure's name | as above | yes: it reads the default instead of null | | in a `@spine` report, a dimension over a column of the spine entity | the dimension's name | the `@of` field's type | yes when the field is `@required` or in that entity's `identity.primary`; no for a dimension beyond the spine entity | @@ -72,6 +73,7 @@ Add `"startOf": "day"`, `"week"` or `"month"` to cut the window to a calendar bo - A `sum` of nothing is **null**, not zero: no matching rows, or a filtered measure that matched none of a group's rows. So are `avg`, `min` and `max`. - An `any` or `all` over no rows, or only null values, is **null**, not `false`. `"@default": 0` reads `false` and `"@default": 1` reads `true` (any other number is refused). - A ratio is `numerator / NULLIF(denominator, 0)`: a zero denominator is **null**. Each operand must be a numeric measure: a `count`, a `sum`, an `avg`, or a `min` or `max` of a numeric field. An `any` or `all` (a boolean), or a `min` or `max` of a date, timestamp, string, uuid or enum, is refused as `@numerator` or `@denominator`. For a share, use an `@agg: count` with a `@filter`. +- A derived measure's `divide` divides as a ratio does (null on a zero divisor); a null operand makes it null, so default the operand measure when `0` is meant. - A report with no dimensions is one row for the whole table, and still one row over an empty table (counts `0`, sums and ratios null). **Ask: is zero true here, or is null?** If "nothing to aggregate" means zero (revenue of a program nobody bought is `0`), declare `"@default": 0` on the measure (`revenue` in the example under "Rows with no facts"). If it means unknown (the average rating of a product with no ratings is not `0`), leave it null. Do not default in the client what the model can state once. diff --git a/agent-context/skills/metaobjects-authoring/references/sources.md b/agent-context/skills/metaobjects-authoring/references/sources.md index 5f7f94c031..bff437f410 100644 --- a/agent-context/skills/metaobjects-authoring/references/sources.md +++ b/agent-context/skills/metaobjects-authoring/references/sources.md @@ -94,4 +94,6 @@ column because the filter tier runs against the view. **When you need an independent exposure** — a subset, renamed columns, a row-filtered view, a versioned or external shape — that is an `object.projection`. It, the `origin.*` vocabulary, the structured `@filter` / `@expr` shapes and the `@sql` / `@unmanaged` escapes -are in `references/read-views-and-projections.md`. +are in `references/read-views-and-projections.md`. A grouped or aggregate view (totals per client +or per month) is an `object.report` (`references/declaring-reports.md`); `@sql` is for what neither +can express (a recursive CTE, a window function, a set operation). diff --git a/agent-context/skills/metaobjects-authoring/references/typescript-providers.md b/agent-context/skills/metaobjects-authoring/references/typescript-providers.md new file mode 100644 index 0000000000..5db6706b4f --- /dev/null +++ b/agent-context/skills/metaobjects-authoring/references/typescript-providers.md @@ -0,0 +1,74 @@ +# Your own vocabulary in TypeScript — a provider + +> Part of the `metaobjects-authoring` skill, "Your own vocabulary". Read it when the project +> needs a subtype or an attribute the core does not ship, and its TypeScript tools load the +> metadata. + +A provider is an object implementing `MetaDataTypeProvider`: an `id`, the provider ids it +depends on, and a `registerTypes(registry)` body that calls `register` (a new subtype) and +`extend` (attributes on an existing one). This one registers `layout.picker` and adds +`@searchable` and `@valueLabels` to `field.string`: + +```ts +// codegen/vocabulary.ts +import { TypeId, MetaLayout, type MetaDataTypeProvider } from "@metaobjectsdev/metadata"; +import { + TYPE_FIELD, TYPE_LAYOUT, FIELD_SUBTYPE_STRING, + ATTR_SUBTYPE_STRING, ATTR_SUBTYPE_BOOLEAN, +} from "@metaobjectsdev/metadata/constants"; + +export const vocabulary: MetaDataTypeProvider = { + id: "acme-vocabulary", + dependencies: ["metaobjects-core-types"], + registerTypes(registry) { + // A new subtype, with its own attribute (an own attribute may be required). + registry.register({ + typeId: new TypeId(TYPE_LAYOUT, "picker"), + description: "A picker over the owning object.", + factory: (typeId, name) => new MetaLayout(typeId, name), + childRules: [], + attributes: [ + { name: "displayField", valueType: ATTR_SUBTYPE_STRING, required: false, description: "Field shown per choice." }, + ], + }); + // Attributes on a type another provider owns: always optional. + registry.extend(TYPE_FIELD, FIELD_SUBTYPE_STRING, { + attributes: [ + { name: "searchable", valueType: ATTR_SUBTYPE_BOOLEAN, required: false, description: "Offer in search." }, + { name: "valueLabels", valueType: ATTR_SUBTYPE_STRING, isArray: true, required: false, description: "Display labels." }, + ], + }); + }, +}; +``` + +Wire it once, in `metaobjects.config.ts`: + +```ts +import { defineConfig } from "@metaobjectsdev/cli"; +import { vocabulary } from "./codegen/vocabulary"; + +export default defineConfig({ + generators: [/* ... */], + providers: [vocabulary], +}); +``` + +Every `meta` command that loads metadata reads that list: `gen` (with the docs generators and +the docs site), `verify`, `migrate`, `fmt`, `types`, `export`, `deps`, `upgrade`. `meta types +picker` then lists the new subtype. A config that fails to load is reported as its own error, +never as an unknown subtype. Code that loads the model itself passes the same provider: +`loadMemory(root, { providers: [vocabulary] })`. + +The metadata uses it like core vocabulary: + + +```json +{ "field.string": { "name": "name", "@searchable": true } } +{ "layout.picker": { "name": "contactPicker", "@displayField": "name" } } +``` + +Without the provider the same file fails `meta verify` with `ERR_UNKNOWN_SUBTYPE` on +`layout.picker` and `ERR_UNKNOWN_ATTR` on `@searchable`. If another port's tools load this +metadata too, that port needs its own copy of the provider (same `id`, same vocabulary). Each port's `verify` loads strict, so a clean run there proves that port's copy is complete. +Full contract: `docs/features/extending-with-providers.md`. diff --git a/agent-context/skills/metaobjects-codegen/SKILL.md b/agent-context/skills/metaobjects-codegen/SKILL.md index a030b08545..4ec8b55048 100644 --- a/agent-context/skills/metaobjects-codegen/SKILL.md +++ b/agent-context/skills/metaobjects-codegen/SKILL.md @@ -35,6 +35,7 @@ exact config, generator names and commands for this project; read it. The other | File | Open it when | |---|---| +| `references/principles.md` | a rule in the always-on file does not settle the case: the full standing principles (adopting onto existing code, the schema and live database, prompts, requirements, owning and writing generators, physical names) with their reasons | | `references/any-stack.md` | **the database, data store, HTTP framework or UI framework is not one a reference generator targets** — MySQL, MongoDB, DynamoDB, Express, NestJS, Next.js, Vue, … | | `references/owning-generators.md` | generated output is wrong; your framework is not the one a reference emits for; you write or review a generator (the `own*()` accessor table) | | `references/choosing-layers.md` | the generated API does not fit, you need joined or derived data, or you are adopting onto existing code | @@ -430,6 +431,11 @@ template hack. See the decision procedure in the **`metaobjects-authoring`** ski array column type) and a native UUID is `field.uuid` (not a string + `@dbColumnType`). When you register custom vocabulary for a custom generator, the same ADR-0037 procedure decides whether it's a subtype, a `@kind` variant, or an attribute. +The vocabulary itself is a provider class, listed once in the port's project +configuration so `gen`, `verify --codegen` and the docs generators all load it (the +**`metaobjects-authoring`** skill, "Your own vocabulary", has the per-language example). +A generator then reads the custom attribute like any other: through the resolving +accessor on the node, never by re-parsing the file. ## Per-target output @@ -450,6 +456,20 @@ language-native console tool, or a build-plugin goal). A dry-run mode previews without writing; a watch mode re-runs on metadata changes where supported. Pass specific entity names to scope a run to those entities. +**`gen` skips a run when nothing changed.** After loading, every port computes a key from the +loaded model and everything the generators are built from; when it matches the last successful run +and every generated file still holds the bytes that run left, `gen` says so and writes nothing +(ADR-0064). Pass `--force` (Maven: `-Dmetaobjects.force=true`) to render anyway, and +`verify --codegen --full` to render and compare in a local run. A generator that reads something +the key does not cover declares it as an input or sets `cache: false`. + +**C#: one resolver names every property.** To spell a field's C# property differently (an +acronym, say), set `GenConfig.PropertyNaming` (`Func`). The entity classes, the +`AppDbContext`, the reverse finders, the routes, the filter map and the credential stripping all +read it, so they agree. A subclass hook (`EntityGenerator.PropertyName`, +`DbContextGenerator.PropertyName`) that disagrees with the resolver is refused rather than +emitting two spellings. + --- For this project's codegen specifics, read the `references/.md` file for each server diff --git a/agent-context/skills/metaobjects-codegen/references/csharp.md b/agent-context/skills/metaobjects-codegen/references/csharp.md index b2f0238de0..5807adbd34 100644 --- a/agent-context/skills/metaobjects-codegen/references/csharp.md +++ b/agent-context/skills/metaobjects-codegen/references/csharp.md @@ -307,7 +307,9 @@ plus finer hooks — `EmitClassHeader` / `EmitClassDeclarationLine` (class decla `partial`, marker interfaces), `EmitPropertyAttributes` (per-property C# attributes), `EmitFileUsings` (extra usings), `EmitClassBodyTrailer` (extra members). Subclass a generator and override only the seam you need rather than forking. `@default` on a -scalar emits a literal initializer; an `object.value`'s default storage is jsonb. +scalar emits a literal initializer; an override of `EmitClassDeclarationLine` must not name a +concrete parent as the C# base (the child already declares the parent's properties, so a base would +redeclare them; only an emitted abstract shape is a base); an `object.value`'s default storage is jsonb. **Shared + externally-provided enums (FR-019).** A package-level abstract `field.enum` (`abstract: true`, `@values`) extended by concrete entity fields is diff --git a/agent-context/skills/metaobjects-codegen/references/dependencies-and-shared-models.md b/agent-context/skills/metaobjects-codegen/references/dependencies-and-shared-models.md index 3d0cdc883c..89050885dc 100644 --- a/agent-context/skills/metaobjects-codegen/references/dependencies-and-shared-models.md +++ b/agent-context/skills/metaobjects-codegen/references/dependencies-and-shared-models.md @@ -41,10 +41,19 @@ replace those calls: an unmodified copy publishes the same bytes as the packaged generator. To publish through a package, point its `target` inside the package (an npm package's directory listed in `files`; a Python package's directory shipped as package data), run `meta gen`, then release the package as usual; consumers -declare an `npm` or `python` dependency on it. With no `version` option the +declare an `npm`, `python`, `maven` or `nuget` dependency on it. With no `version` option the manifest takes the nearest `package.json` version, else a `pyproject.toml` `[project]` version — pass `version` when neither is the package consumers install. -Only TypeScript can run it in Phase 1a. TypeScript, Python, Java, Kotlin (through -Java's loader and Maven plugin) and C# can *consume* a dependency, and only the -TypeScript toolchain can *publish* one. +TypeScript, Java, Kotlin and C# can *publish* with byte-identical output: the Java and Kotlin +`shared-model` generator runs through `mvn metaobjects:generate` (`SharedModelGenerator` / +`KotlinSharedModelGenerator`, args `name`, `include`, `exclude`, `files`, `version`; the version +defaults to the module ``); the C# one is `new SharedModelGenerator { ModelName, Include, +Files, OutDir }` in `codegen/Generators.cs` through `dotnet meta gen` (version from the project +``). Eject with `mvn metaobjects:eject -Dnames=shared-model -Dport=java|kotlin` or `dotnet +meta eject shared-model`. A JVM publisher ships the pair as the JAR's `metaobjects/` resources and a +C# publisher as the NuGet package's `metaobjects/` content; consumers declare +`{ "name": "x", "maven": "com.acme:model", "version": "1.0.0" }` or +`{ "name": "x", "nuget": "Acme.Model", "version": "1.0.0" }` (also `npm`/`python`/`path`). +TypeScript, Python, Java, Kotlin and C# *consume*; Python cannot publish. Node `meta deps sync` +remains the only writer of the lock and snapshot in every port. Full detail: `docs/features/metadata-dependencies.md`. diff --git a/agent-context/skills/metaobjects-codegen/references/physical-names.md b/agent-context/skills/metaobjects-codegen/references/physical-names.md index a14d2efd34..5be9c8b5c7 100644 --- a/agent-context/skills/metaobjects-codegen/references/physical-names.md +++ b/agent-context/skills/metaobjects-codegen/references/physical-names.md @@ -93,8 +93,7 @@ artifact exists *for your code*, which is the only place a physical name appears `@storage: flattened` field has no column of its own: each member of the value object is a column of the owner's table, named by core naming (the field's `@flattenedColumnPrefix`, else `_`, then the member's column). The artifact carries one constant per -member. The field's own column constant is still emitted, unchanged, but on a flattened -field it names no column of the table; read the member constants: +member, and the field itself has none, because the table has no column of that name: | Port | Reads as | |---|---| diff --git a/fixtures/agent-context-conformance/python/expected/.metaobjects/CLAUDE.md b/agent-context/skills/metaobjects-codegen/references/principles.md similarity index 66% rename from fixtures/agent-context-conformance/python/expected/.metaobjects/CLAUDE.md rename to agent-context/skills/metaobjects-codegen/references/principles.md index 8806273a19..6308156c9d 100644 --- a/fixtures/agent-context-conformance/python/expected/.metaobjects/CLAUDE.md +++ b/agent-context/skills/metaobjects-codegen/references/principles.md @@ -1,37 +1,18 @@ -# Working with MetaObjects in this project +# Standing principles -> Stack: python server, no client. -> -> Generated by MetaObjects (refresh: `meta init --refresh-docs`). Put project notes in your -> **root `CLAUDE.md`**, not here — this file is regenerated; see the note at the end before editing it. +The rules that hold in every MetaObjects project, whatever the stack and whatever the task. The +always-on file in `.metaobjects/` carries the short form; this page is the full text, with the +reasons. Read it when a rule there does not settle the case in front of you. -MetaObjects is a metadata standard: typed metadata (in `metaobjects/` unless the project -configures another directory) is the durable spine; generated code is the disposable -artifact. Regenerate with `metaobjects gen`. +## Contents -## Read the generated reference before you touch a tier -`metaobjects gen` writes ONE reference file under this project's docs output directory (when a target's generator list declares `api-docs`). It -is generated from THIS project's metadata, so it describes what the project actually is -rather than what the framework does in general — and reading it first is how you avoid -inferring the answer from generated code, which is the disposable half. There is no -separate docs command on this port either: the api reference is one more entry in the same -generator list every other generator is in. - -- **`api/python/AGENT-API.md`** — before calling generated code. The types, endpoints and - filter operators the generators actually emitted. - -Not there? Declare `api-docs` in that target's `generators` in metaobjects.config.yaml if it is missing, then run `metaobjects gen`. - -The other three pages of that reference — `agent/schema.md` (persistence), `agent/ui.md` -(forms and grids) and `agent/requirements.md` (what is already claimed, and what was -deliberately **retired**) — are written by the Node `meta gen` command, from -`agentDocsFile()` in a `metaobjects.config.ts`, which this stack does not have. Until it -does, read the metadata itself for those three: it is the source those pages are generated -from. +- Principles +- Authoring rules you must not violate ## Principles + - **Adopting onto existing code? Metadata FOLLOWS the code.** On a migration (existing working code / live DB), author metadata + tune codegen to *reproduce* what the code already is — native types (`field.uuid` when the code uses `UUID`, not `field.string`; and the type a JSON column's WRITER declares — `list[str]`, a dataclass, `dict[str, X]` — not an open jsonb bag), names, nullability — so regen changes as little existing code as possible. The only existing code that should change is the hand-written layer codegen replaces; ask when a modeling choice is ambiguous. (Greenfield: model-first, below.) -- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate. Don't hand-write divergent SQL; where a stack owns its own migration files, GENERATE them — `meta migrate --migration-format flyway` emits the paired `V__`/`U__` files a Flyway runner expects, and leaves applying them to Flyway. The one exception is a schema this project deliberately owns outside MetaObjects (hand-written migrations by rule, or another team's database): when the root `CLAUDE.md` says so, follow it, and keep `meta verify --db` catching drift. +- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate. Don't hand-write divergent SQL; where a stack owns its own migration files, GENERATE them — `meta migrate --migration-format flyway` emits the paired `V__`/`U__` files a Flyway runner expects, and leaves applying them to Flyway. The one exception is a schema this project deliberately owns outside MetaObjects (hand-written migrations by rule, or another team's database): when the root `AGENTS.md` or `CLAUDE.md` says so, follow it, and keep `meta verify --db` catching drift. - **Once this project declares any `template.prompt`, every LLM prompt is one** — the text in the template, the data in a payload value object, rendered by the render engine. A structured reply is read through a response model (`@responseRef` and its generated extractor), never a regex or string search. This covers code that does not look like MetaObjects: a format string, text block, template literal or string builder sent to an LLM, and it covers every module, including test harnesses and scripts. Changing a prompt that is still hand-built means migrating it first (snapshot its current output and keep the rendered text byte-identical), not adding a line to it; the `metaobjects-prompts` skill has the steps. - The **live database** is a derived artifact too — never hand-apply a schema change to a running DB (ad-hoc `psql`/console `ALTER`/`CREATE`/`DROP`), not even to preview a column or unblock a boot. Drive every schema change from the metadata, never ad-hoc: on the Node/TS-owned migrate stack that is `meta migrate` (metadata → DDL, ADR-0015); on a **Flyway**-owned JVM stack that is `meta migrate --migration-format flyway`, which emits the migration and deliberately refuses `--apply` because Flyway owns applying it. Hand-authoring a migration to match the generated schema is the LAST resort — for a runner MetaObjects has no writer for — never the default for Flyway. A hand-applied ad-hoc change drifts the live DB from the metadata + migration history and collides at the next migrate/boot ("column already exists") — a state no migration can reproduce. Run `meta verify --db ` after any DB-touching work to catch that drift early — the URL is required, and the bare form exits 2. - **If this project declares `requirement.*` nodes, a commit that adds, changes or removes behaviour updates them in the same commit** (the claim, its `@status` and `@implementedBy`), or says in the commit message why not. `meta verify` checks that the links resolve, not that the ledger is current. @@ -47,35 +28,9 @@ from. - **JVM:** serialize a MetaObject-backed instance (a `pojoAware`-flavor generated class, a runtime `ValueObject`, or any `MetaObjectAware` type) through the MetaObjects JSON layer — never hand-configure a Jackson/Gson mapper around the framework fields to make a default mapper cope. ## Authoring rules you must not violate + - **Search the vocabulary before concluding it cannot be expressed — `meta types `.** An unregistered TYPE or SUBTYPE fails the load in every command. An undeclared `@attr` is different: it fails `meta verify`, which loads strict, and NOT `meta gen`, which does not — so an invented attribute passes codegen silently and is caught by the drift gate rather than by the build. Either way inventing vocabulary is a failure you will hit, not a shortcut. Search names with `meta types `, names and descriptions with `--all` ("find it by what it does"), and one construct's valid `@attrs` with `meta types . --detail`; `--format json` returns the same answer as one machine-readable document, each attr with its `allowedValues`. Rows marked `[ts; pending elsewhere]` (or `[java; …]`) are cross-port vocabulary only that port implements so far: every port loads it, the others ignore it. `[-only]` (`[csharp-only]`; several ports: `[java+kotlin]`) marks vocabulary only those ports ever act on. It is the Node `meta` CLI and, like `meta migrate`, works whatever your backend — it reads the registry, so it needs no project. Ask for NEW vocabulary only once that search comes up empty. - Nodes are fused-key maps: `{".": { ... }}` (e.g. `{"field.string": {"name": "email"}}`) — never split the type and subtype into separate keys. - Attribute names are unique within a node; for multi-value use one array attr (`@values: [...]`). - An inline `@maxLength: 50` equals an `attr` child of the same name — never write both. - Package paths use `::` (`acme::common::id`). - -## Keep all MetaObjects ports in sync -MetaObjects ships as separate packages per language on DIFFERENT version lines (npm/PyPI/NuGet `0.x`/`1.x`, Maven Central `7.x`/`8.x`). Because the numbers differ by ecosystem, a stale port is INVISIBLE — an old TS client next to a new Java backend *looks* fine. A matching **Metamodel spec version** (`metamodelVersion`, on the registry manifest) means no port carries a BREAKING metamodel change the others lack. It does not move for added vocabulary, so ports on the same metamodel version can still differ in which attributes and subtypes they know: they are fully in sync only when every port is on the same release (each ecosystem's version for one CHANGELOG entry). Upgrade ALL ports together; a lagging port refuses vocabulary the others accept and can disagree on wire behavior. - -`metamodelVersion` is also the number that tells you whether YOUR METADATA needs work (it moves only for a breaking metamodel change), separately from the package version, which tells you whether your BUILD does. A package major means imports/CLI/generated-code shape may need attention; a metamodel major means your model may. A release can move one without the other — so when you upgrade, read the changelog for a metamodel-version move, not just the package number. For a 1.0.x → 1.0.x upgrade, follow https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-within-1.0.md: it covers resyncing the generators you own (`meta eject --list`), which a plain `meta gen` does not do. - -**Upgrading from 1.0 to 1.1:** read https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-1.0-to-1.1.md before you run `gen`, because the build can stay green while the result is wrong. It is the one page for every port and lists the steps in order. The changes that fail nothing when skipped: the default column and table names are now `snake_case` in every port, so a C#, Java, Kotlin or Python database whose columns are named like its fields needs `"naming": { "columns": "literal" }` in `.metaobjects/config.json`, or the regenerated code queries columns that do not exist; and a fractional validator `@min`/`@max` is refused. Upgrade to 1.1.2 or later: with no `wire` setting each port writes its language's standard JSON, and a project whose clients expect 1.1.0's canonical decimal strings declares `"wire": { "decimals": "string", "nullMembers": "omit" }` in `.metaobjects/config.json`. Documentation is a generator in the project's list, and the docs commands are removed. Then resync every generator you own (`meta eject --list` reports each copy that differs from the reference; `meta eject --force` takes the new one, and a plain `meta gen` does not): an owned copy keeps the logic it was copied with. - -## Going deeper (Claude Code) -For authoring, codegen, runtime/UI, prompts, verify, or adoption-audit work, use the -matching `metaobjects-*` skill — its body links the `references/.md` fragment -installed for this project's stack. Read only the skill your task needs, and inside it the -`SKILL.md` plus the reference file it points you to; the other `references/` files are topics -to open when they come up, not reading to do up front. A skill that `meta init` wrote during -the current session may not load by name until the next one; read -`.claude/skills//SKILL.md` directly. - -## Refreshing / customizing this generated context -This file and the `metaobjects-*` skills are **generated** by MetaObjects for this project's -stack (plain Markdown, no tools/hooks) — refresh with `meta init --refresh-docs`. Don't hand-edit -them expecting the edit to survive: a refresh leaves a file you've edited intact and writes the -new copy to `.new` (only `--force` overwrites in place — never `--force` a file with local -edits). For project-specific guidance, put it in your **root `CLAUDE.md`** (always-on concerns) or -copy a skill to a new name (skill-level overrides) — don't edit the generated originals in place. - -After a refresh, for each `.new`: diff it against ``, **keep the hand-edits and take -the upstream changes**, write the merged result back to ``, then delete `.new`. diff --git a/agent-context/skills/metaobjects-codegen/references/typescript-docs.md b/agent-context/skills/metaobjects-codegen/references/typescript-docs.md index 477959e311..ff88a88e8a 100644 --- a/agent-context/skills/metaobjects-codegen/references/typescript-docs.md +++ b/agent-context/skills/metaobjects-codegen/references/typescript-docs.md @@ -23,7 +23,7 @@ generate, docs included). Each factory is an ordinary entry in `generators`, fro | `requirementsFile()` | `requirements` | the declared `requirement.*` ledger, each entry headed by its dotted path and `title`. Writes nothing for a model with no `requirement.*` node. | | `agentDocsFile()` | `agent-docs` | `agent/schema.md`, `agent/ui.md` (only when the run also lists a client-tier generator, OR the config sets `includeUiTier: true` — the escape hatch for a docs-only config whose UI is generated by a separate config; skipping it with a UI surface in the model and `includeUiTier` unset prints an advisory naming `includeUiTier`; `includeUiTier: false` says there is no UI anywhere and skips it without one) and `agent/requirements.md` — the three `agent/` pages the always-on pointer reads before touching a tier. | | `metamodelDocsFile()` | `metamodel-docs` | the built-in vocabulary reference, under `metamodel/` (was `meta docs --metamodel`). | -| `docsSiteFile()` | `docs-site` | an HTML site under `site/` (was `meta docs --site`). Option: `prompts`. `meta eject docs-site` copies its templates and assets to `codegen/docs-site/` (was `meta docs --scaffold-site`). | +| `docsSiteFile()` | `docs-site` | an HTML site under `site/` (was `meta docs --site`): the model explorer by default (what the software does, the model map, requirement pages, matrix, trace, API, gaps), drawn from an `explorer.json` built in the same run; `site: "classic"` writes the earlier site. Options: `site`, `prompts`. `meta eject docs-site` copies its templates and assets to `codegen/docs-site/` (was `meta docs --scaffold-site`). | ```ts import { defineConfig } from "@metaobjectsdev/cli"; diff --git a/agent-context/skills/metaobjects-codegen/references/typescript-document-store.md b/agent-context/skills/metaobjects-codegen/references/typescript-document-store.md index 435337b4f9..20fb079ce3 100644 --- a/agent-context/skills/metaobjects-codegen/references/typescript-document-store.md +++ b/agent-context/skills/metaobjects-codegen/references/typescript-document-store.md @@ -55,9 +55,7 @@ What the repository does, built on the generated contract: // its wire contract (InsertSchema, UpdateSchema, FilterAllowlist); this emits the // data access over it. The collection name comes from an author-supplied `@mongo` property // bag on the entity: `"@mongo": { "collection": "orders" }`. -import { - DEFAULT_OUTPUT_LAYOUT, effectivePackage, entityOutputPath, isSourcelessEntity, perEntity, type Generator, -} from "@metaobjectsdev/codegen-ts"; +import { effectivePackage, entityOutputPath, isSourcelessEntity, perEntity, type Generator } from "@metaobjectsdev/codegen-ts"; import type { MetaObject } from "@metaobjectsdev/metadata"; function collectionOf(obj: MetaObject): string { @@ -157,9 +155,9 @@ export function mongoRepositoryGenerator(): Generator { return { name: "mongo-repository", filter: isSourcelessEntity, - // Beside the entity module it imports (`./.js`), in whichever layout the target writes. + // Beside the entity file it imports (`./.js`), in either output layout. generate: perEntity((obj, ctx) => ({ - path: entityOutputPath(ctx.config.outputLayout ?? DEFAULT_OUTPUT_LAYOUT, effectivePackage(obj), `${obj.name}.repository.ts`), + path: entityOutputPath(ctx.renderContext?.outputLayout ?? "flat", effectivePackage(obj), `${obj.name}.repository.ts`), content: render(obj), })), }; diff --git a/agent-context/skills/metaobjects-codegen/references/typescript.md b/agent-context/skills/metaobjects-codegen/references/typescript.md index 0fd2c59c03..1b908a554a 100644 --- a/agent-context/skills/metaobjects-codegen/references/typescript.md +++ b/agent-context/skills/metaobjects-codegen/references/typescript.md @@ -215,7 +215,7 @@ view binding, Zod read schema, row type, descriptor, filter and sort allowlists) `.queries.ts` (`list…` only, no by-id), `.routes.ts` (and `.routes.hono.ts` from `routesFileHono()`): GET list, `POST` answers 405, no `/:id`; `.names.ts`; and the barrel export. Every derived field with filter operators is filterable and sortable. The UI tier -writes the list hook and nothing else: `.hooks.ts` (`useList`, typed with the report's +writes the list hook and nothing else: `.hooks.ts` (`use` + the plural of the name (`useMemberUtilizations` for `MemberUtilization`), or `useList` when the name's plural is the name itself (`useSeriesList`), typed with the report's filter, no detail or mutation hook) and its `.meta.ts` descriptor, and `agent/ui.md` lists the report. The hook generator gates on `servesClientHooks`, which is true for a served report; the grid generators gate on `servesClientTier`, which is false, so there is no grid, diff --git a/agent-context/skills/metaobjects-codegen/references/wire-format.md b/agent-context/skills/metaobjects-codegen/references/wire-format.md index a27288b3d1..b0b2f91c8a 100644 --- a/agent-context/skills/metaobjects-codegen/references/wire-format.md +++ b/agent-context/skills/metaobjects-codegen/references/wire-format.md @@ -21,13 +21,16 @@ not "fix" a port to match another one, or to match the corpus. loaded root; there is no CLI flag and no generator argument. ```json -{ "schema_version": 1, "wire": { "decimals": "native", "nullMembers": "native" } } +{ "schema_version": 1, "wire": { "decimals": "native", "nullMembers": "native", "durations": "native" } } ``` - `decimals`: `native` (default) or `string`, the canonical string (`"12.5"`, zero `"0"`, no exponent, no trailing zeros). - `nullMembers`: `native` (default), `emit` or `omit`. It covers the members of an `object.value` only. A top-level entity field that is null is always written as `null`. +- `durations`: `native` (default) or `iso`, for `field.duration`. `native` writes and reads each + port's standard duration form (C# `TimeSpan` is `"01:30:00"`). `iso` writes and reads the + canonical ISO-8601 form (`PT1H30M`) in every port. - An absent block or key means `native`. An unknown key or value is refused when the config is read. There is no `"number"` value: in C#, Java and Kotlin `native` already is a number. diff --git a/agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md b/agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md index 9456eb8fd3..96836cc318 100644 --- a/agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md +++ b/agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md @@ -36,15 +36,18 @@ building block. Every generator is a reference helper an adopter selects, ejects - **Sharing a model** (`docs/features/metadata-dependencies.md`): in one repository, every port reads the same metadata directory (`sources`), so a TS service and a Java, C# or Python service can generate from one declaration today. **Across repositories**, a published model - with a hash-locked snapshot works for **TypeScript publishers only**; **TypeScript, Python, - Java, Kotlin and C# consume** it at build time (a committed `.metaobjects/deps/` snapshot loaded - ahead of the project's own files; `extends`/overlay onto a dependency's node resolves; imported - nodes are not generated unless `scope.include` names their package). The Node `meta deps sync` - is the only writer of the lock and snapshot, so a Java, Kotlin or C# consumer needs Node to - sync. Dependencies come from a `path`, an npm package or a Python package; the Maven and NuGet - transports are design only. Java, Kotlin, Python and C# cannot publish; the Spring runtime does - not yet auto-load the snapshot, and the Java/Kotlin `verify` does not yet check dependency - drift. Plain vendoring (`docs/features/metadata-sources.md`, "Vendoring") still works and + with a hash-locked snapshot works in every port: **TypeScript, Java, Kotlin and C# publish** it + (`sharedModelFile()`, or the `shared-model` generator through `metaobjects:generate` and + `dotnet meta gen`, all ejectable); **TypeScript, Python, Java, Kotlin and C# consume** it at + build time (a committed `.metaobjects/deps/` snapshot loaded ahead of the project's own files; + `extends`/overlay onto a dependency's node resolves; imported nodes are not generated unless + `scope.include` names their package), and the Spring runtime auto-loads the snapshot. Every port + can check drift (`meta deps check`, `metaobjects deps check`, `mvn metaobjects:verify + -Dmeta.verify.mode=deps`, `dotnet meta verify --deps`). The Node `meta deps sync` is the only + writer of the lock and snapshot, so a Java, Kotlin, C# or Python consumer needs Node to sync. + Dependencies come from a `path`, an npm or Python package, a Maven artifact (a JAR in the local + repository) or a NuGet package; only Node resolves the package transports in `check`. Python + cannot publish, and a JVM classpath read with no committed snapshot is not built. Plain vendoring (`docs/features/metadata-sources.md`, "Vendoring") still works and carries no upstream hash check. Source: `docs/features/metadata-dependencies.md`, "Phase 2". - **Libraries** (`docs/features/libraries.md`): `iam` (preview) and `ai` (stable) ship as declared designs; the core layer is sourceless and adds no tables. Mention one only when the diff --git a/agent-context/skills/metaobjects-runtime-ui/SKILL.md b/agent-context/skills/metaobjects-runtime-ui/SKILL.md index dd3184a870..6f0302b540 100644 --- a/agent-context/skills/metaobjects-runtime-ui/SKILL.md +++ b/agent-context/skills/metaobjects-runtime-ui/SKILL.md @@ -115,8 +115,9 @@ An `object.projection` uses the same rule, so `OrderSummary` is at their fetch URLs from the TypeScript `$path`, and every backend now mounts that same spelling, so a React/TanStack client works against any port's server. A view-backed `object.report` has a generated list route at the same rule and, in -TypeScript, a generated list hook (`useList`); it has no grid, form or detail -hook. +TypeScript, a generated list hook named `use` + the plural of the report's name +(`useMemberUtilizations` for `MemberUtilization`; `useList` only when the plural is +the name itself, as in `useSeriesList`); it has no grid, form or detail hook. **This is a change, and it was a breaking one.** Each port used to spell the segment differently and they agreed only on single regular words — which was diff --git a/agent-context/skills/metaobjects-verify/SKILL.md b/agent-context/skills/metaobjects-verify/SKILL.md index 54ffb46736..14b1f94cca 100644 --- a/agent-context/skills/metaobjects-verify/SKILL.md +++ b/agent-context/skills/metaobjects-verify/SKILL.md @@ -150,31 +150,34 @@ with `ERR_DEPENDENCY_SNAPSHOT_STALE` naming the fix: run `meta deps sync`. - **`--codegen`** — regeneration drift. Re-runs generation and diffs the result against the committed generated files; a stale generated part (someone skipped a regen) fails the build. Wire it into CI so a stale `@generated` file fails. - **A hand edit inside a generated file is NOT drift** — `meta gen` three-way-merges - hand edits by design, and the Node gate judges the *generated contribution* against - the committed `.metaobjects/.gen-state/.hashes.json`, not the bytes. So a weakened - validator passes this gate. The Node `meta verify --codegen` therefore LISTS every - generated file carrying a hand edit (count + paths, a notice that does not change - the exit code), and `--forbid-hand-edits` turns any hand edit into a failure for a - team that wants generated code untouchable. Read that list at review time. To see - one edit: delete the file, run `meta gen` (it re-emits the pristine generation), - then `git diff -R -- `; `git checkout -- ` restores it. The one - exception is an `.names.ts` artifact: a hand edit there always fails. + **A hand edit inside a generated file is reported apart from drift** — `meta gen` + three-way-merges hand edits by design, and the Node gate judges the *generated + contribution* against the committed `.metaobjects/.gen-state/.hashes.json`, not the + bytes, then lists every generated file carrying a hand edit (count + paths). Whether + that list fails the build is `verify.handEdits` in `.metaobjects/config.json`: + `"fail"` exits 1 (what `meta init` writes for a new project), `"notice"` (and a + project without the key) exits 0, so a weakened validator passes there. Check the + key; `--allow-hand-edits` relaxes `fail` for one run, `--forbid-hand-edits` forces it + for one run. If an edit changed a rule the model declares (a length, a range, a + required field), make the change in the metadata instead, so the database and every + port follow it. To see one edit: delete the file, run `meta gen` (it re-emits the + pristine generation), then `git diff -R -- `; `git checkout -- ` + restores it. An `.names.ts` artifact always fails on a hand edit. The C#, + Java, Kotlin and Python gates compare bytes, so any edit fails there. - **`--templates`** — prompt/payload drift. For every `template.prompt` / `template.output`, resolves the text, parses each `{{...}}` reference, and fails if any reference isn't on the payload VO. This is the build-time gate for the prompt-construction pillar. -- **`--deps`** — dependency drift (FR-023, **Node `meta` only** — but **any - backend**, like `--db`: the check reads only `.metaobjects/config.json` and has - no backend dependency of its own). Re-resolves each declared dependency's `path` +- **`--deps`** — dependency drift (FR-023). Re-resolves each declared dependency right now and compares its installed artifact's hash against - `.metaobjects/deps.lock.json` — the same comparison `meta deps check` runs. Only - TypeScript and Python additionally LOAD the resulting snapshot and honour the - default-exclusion it implies — a Java/Kotlin/C# project can run this gate today - even though its own codegen can't yet consume a dependency. Never part of the - bare-`verify` default: it + `.metaobjects/deps.lock.json` — the same comparison `meta deps check` runs. Node + `meta` resolves every transport (`path`, `npm`, `python`, `maven`, `nuget`); the + Python, Java/Kotlin and C# checks resolve `path` only and report any other + transport `unresolved`, naming Node `meta deps check` (a check that cannot check + must not pass). Every port also loads the committed snapshot and honours the + default-exclusion it implies. Never part of the bare-`verify` default: it needs the publisher's `path` reachable, which CI checking out only your own repo may not have. Reports `current` / `drifted` / `unresolved` per dependency; `drifted` or `unresolved` fails with `ERR_DEPENDENCY_UPSTREAM_DRIFT`, fix is @@ -188,7 +191,16 @@ port's own build tool, not the Node `meta`: | TS | `meta verify --codegen` | `meta verify --templates` | `meta verify --db ` | | Java / Kotlin | `mvn metaobjects:verify -Dmeta.verify.mode=codegen` | `mvn metaobjects:verify -Dmeta.verify.mode=templates` | Node `meta verify --db` only | | C# | `dotnet meta verify --codegen` | `dotnet meta verify --templates` | Node `meta verify --db` only | -| Python | `metaobjects verify --codegen` | `metaobjects verify --templates` | Node `meta verify --db` only | +| Python | `metaobjects verify` (`--codegen` is in the default) | n/a | Node `meta verify --db` only | + +Dependency drift (`--deps`) per port: + +| Port | Dependency drift | +|---|---| +| TS | `meta deps check`, `meta verify --deps` | +| Python | `metaobjects deps check`, `metaobjects verify --deps` | +| Java / Kotlin | `mvn metaobjects:verify -Dmeta.verify.mode=deps` | +| C# | `dotnet meta verify --deps` | Every non-TS port's `verify` rejects `--db` outright (exit 2, "schema verify is the migrate engine") — schema drift always runs through the Node `meta verify --db`, @@ -326,4 +338,5 @@ what's wrong. --- -For the migration tooling read `references/migration.md`. +For the migration tooling read `references/migration.md`. Before upgrading MetaObjects, or +when a project runs more than one port, read `references/upgrading.md`. diff --git a/agent-context/skills/metaobjects-verify/references/migration.md b/agent-context/skills/metaobjects-verify/references/migration.md index 6828d995d3..ea15ffb6e5 100644 --- a/agent-context/skills/metaobjects-verify/references/migration.md +++ b/agent-context/skills/metaobjects-verify/references/migration.md @@ -18,6 +18,7 @@ stays native to the language. - Install (Node, dev-only) - Output format - The workflow +- Renames and destructive changes - Dialects - Live-DB drift: `meta verify --db` - Index modeling (Postgres) @@ -109,8 +110,9 @@ meta migrate baseline --from-db --db postgresql://... --dialect postgres 2. **Review the SQL.** Read the emitted `up.sql` (forward) and `down.sql` (rollback) before applying. Destructive changes (drop column / drop table) are - opt-in — the engine blocks them unless explicitly allowed, and routes ambiguous - rename-vs-drop+add decisions through a prompt rather than guessing. + opt-in — the engine refuses them until you allow each kind by name (`--allow`, + below), and an ambiguous rename-vs-drop+add aborts unless you declare the rename + or choose with `--on-ambiguous`. It never guesses. 3. **Apply** the pending migrations against the DB; migration history is tracked in a ledger table: @@ -124,6 +126,39 @@ meta migrate baseline --from-db --db postgresql://... --dialect postgres meta migrate --db postgresql://... --rollback "" # roll back everything (empty target) ``` +## Renames and destructive changes + +A renamed field or object is a renamed column or table, and the diff cannot tell that +from a drop plus an add unless the names are close. Declare the rename and the data is +kept: + +```bash +meta migrate --dialect postgres --slug rename-origin --rename-column shipment.origin_city=origin_port +meta migrate --dialect postgres --slug rename-stop --rename-table stop=port_call +``` + +- `--rename-column [schema.]table.old=new` and `--rename-table [schema.]old=new` are + repeatable. For a column, `table` is the table's name in the metadata, so it is the + **new** name when the table is renamed in the same run. A declared rename needs no + `--allow drop-column`, and one that finds nothing to rename is refused rather than + falling back to drop and add. Change a column's type, nullability or default in a + later run, not in the rename's. +- `--allow ` permits a destructive change by kind. A refusal names the token it + needs. The tokens: `drop-column`, `drop-table`, `type-change`, `drop-index`, `drop-fk`, + `drop-check`, `drop-view`, `drop-view-cascade`, `drop-column-read-by-view`, + `adopt-view`, `nullable-to-not-null`, `drop-identity-default`, `drop-comment`, + `drop-unmanaged`. Changing an enum's values replaces its CHECK, so it needs + `--allow drop-check`. `drop-column` deletes the column's data: for a rename use + `--rename-column`, never `--allow drop-column`. +- `--on-ambiguous abort|rename|drop-add` (default `abort`) decides a pair the + heuristic offers as a possible rename. Declaring the rename is clearer than `rename`. +- `migrate.allow` and `migrate.onAmbiguous` in `.metaobjects/config.json` set the same + things for every run. Prefer the flag: a standing allowance hides the next destructive + change from review. + +`docs/features/migrations-and-drift.md`, "Renames and populated tables", covers what a +rename carries with it (constraint names, views) and changes that need a backfill. + ## Dialects - `postgres` (default) — native `ALTER`s. @@ -283,6 +318,6 @@ emitted, created, diffed and dropped** — derived from the model, never written SQL. `field.enum` membership (`IN (…)`, the mapped integers for an `@intValueMap` enum), `validator.numeric` min/max, `validator.length` min/max, `validator.regex` (Postgres only — SQLite has no regex operator), and the entity-level cross-field -validators (`comparison`, `requiredWhen`, `presentIff`, `atLeastOne`) each become a +validators (`comparison`, `requiredWhen`, `presentIff`, `atLeastOne`, `exactlyOne`) each become a named `CHECK`. Array columns get none (the element rules are enforced app-side). (Partial + descending **indexes** are supported too — see Index modeling above.) diff --git a/agent-context/skills/metaobjects-verify/references/upgrading.md b/agent-context/skills/metaobjects-verify/references/upgrading.md new file mode 100644 index 0000000000..23ccb45965 --- /dev/null +++ b/agent-context/skills/metaobjects-verify/references/upgrading.md @@ -0,0 +1,10 @@ +# Upgrading MetaObjects and keeping the ports in sync + +Read this before you move a project to a new MetaObjects release, and when a project runs more +than one port (a TypeScript client beside a Java backend, say). + +MetaObjects ships as separate packages per language on DIFFERENT version lines (npm/PyPI/NuGet `0.x`/`1.x`, Maven Central `7.x`/`8.x`). Because the numbers differ by ecosystem, a stale port is INVISIBLE — an old TS client next to a new Java backend *looks* fine. Ports are only truly in sync when every one implements the same **Metamodel spec version** (`metamodelVersion`, on the registry manifest). Upgrade ALL ports together and confirm they land on the same Metamodel version; a lagging port silently disagrees on vocabulary + wire behavior. + +`metamodelVersion` is also the number that tells you whether YOUR METADATA needs work, separately from the package version, which tells you whether your BUILD does. A package major means imports/CLI/generated-code shape may need attention; a metamodel major means your model may. A release can move one without the other — so when you upgrade, read the changelog for a metamodel-version move, not just the package number. For a 1.0.x → 1.0.x upgrade, follow https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-within-1.0.md: it covers resyncing the generators you own (`meta eject --list`), which a plain `meta gen` does not do. + +**Upgrading from 1.0 to 1.1:** read https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-1.0-to-1.1.md before you run `gen`, because the build can stay green while the result is wrong. It is the one page for every port and lists the steps in order. The changes that fail nothing when skipped: the default column and table names are now `snake_case` in every port, so a C#, Java, Kotlin or Python database whose columns are named like its fields needs `"naming": { "columns": "literal" }` in `.metaobjects/config.json`, or the regenerated code queries columns that do not exist; and a fractional validator `@min`/`@max` is refused. Upgrade to 1.1.2 or later: with no `wire` setting each port writes its language's standard JSON, and a project whose clients expect 1.1.0's canonical decimal strings declares `"wire": { "decimals": "string", "nullMembers": "omit" }` in `.metaobjects/config.json`. Documentation is a generator in the project's list, and the docs commands are removed. Then resync every generator you own (`meta eject --list` reports each copy that differs from the reference; `meta eject --force` takes the new one, and a plain `meta gen` does not): an owned copy keeps the logic it was copied with. diff --git a/agent-context/templates/always-on.md.mustache b/agent-context/templates/always-on.md.mustache index b4f173fb86..5f7cffe689 100644 --- a/agent-context/templates/always-on.md.mustache +++ b/agent-context/templates/always-on.md.mustache @@ -3,104 +3,84 @@ > {{stackLine}} > > Generated by MetaObjects (refresh: `meta init --refresh-docs`). Put project notes in your -> **root `CLAUDE.md`**, not here — this file is regenerated; see the note at the end before editing it. - -MetaObjects is a metadata standard: typed metadata (in `metaobjects/` unless the project -configures another directory) is the durable spine; generated code is the disposable -artifact. Regenerate with `{{codegenCommand}}`. - -## Read the generated reference before you touch a tier -{{#nodeDocsSurface}} -`meta gen` writes four reference files under this project's docs target -(`targets.docs.outDir` in `metaobjects.config.ts`) when `generators` lists the generator -for each — `agentDocsFile()` for the three `agent/` pages, `apiDocsFile()` for the api -reference. There is no separate docs command: documentation is one more entry in the same -list every other generator is in. They are generated from THIS project's metadata, so they -describe what it actually is rather than what the framework does in general — and reading -the relevant one first is how you avoid inferring the answer from generated code, which is -the disposable half. - -- **`agent/schema.md`** — before touching persistence. Tables, columns, the field each - column came from, keys, foreign keys, constraints. -- **`api/AGENT-API.md`** — before calling generated code. The types, endpoints and filter - operators the generators actually emitted. -- **`agent/ui.md`** — before touching a form or a grid. The control, label, rules and - filterability per field, and each declared grid. -- **`agent/requirements.md`** — before adding a capability. What is already claimed, and - what was deliberately **retired** — an entry saying a capability must not be rebuilt is - the one thing you cannot learn from the code, because the code is gone. - -Not there? List the missing generator — and a `docs` target, if `targets` has none — in -`generators`, then run `meta gen`. -{{/nodeDocsSurface}} -{{^nodeDocsSurface}} -`{{docsCommand}}` writes ONE reference file under this project's docs output directory{{docsCondition}}. It -is generated from THIS project's metadata, so it describes what the project actually is -rather than what the framework does in general — and reading it first is how you avoid -inferring the answer from generated code, which is the disposable half. There is no -separate docs command on this port either: the api reference is one more entry in the same -generator list every other generator is in. - -- **`{{apiSubDir}}/AGENT-API.md`** — before calling generated code. The types, endpoints and - filter operators the generators actually emitted. - -Not there? {{docsMissingAction}} `{{docsCommand}}`. - -The other three pages of that reference — `agent/schema.md` (persistence), `agent/ui.md` -(forms and grids) and `agent/requirements.md` (what is already claimed, and what was -deliberately **retired**) — are written by the Node `meta gen` command, from -`agentDocsFile()` in a `metaobjects.config.ts`, which this stack does not have. Until it -does, read the metadata itself for those three: it is the source those pages are generated -from. -{{/nodeDocsSurface}} - -## Principles -- **Adopting onto existing code? Metadata FOLLOWS the code.** On a migration (existing working code / live DB), author metadata + tune codegen to *reproduce* what the code already is — native types (`field.uuid` when the code uses `UUID`, not `field.string`; and the type a JSON column's WRITER declares — `list[str]`, a dataclass, `dict[str, X]` — not an open jsonb bag), names, nullability — so regen changes as little existing code as possible. The only existing code that should change is the hand-written layer codegen replaces; ask when a modeling choice is ambiguous. (Greenfield: model-first, below.) -- Pattern-derivable from metadata = codegen, never hand-write — FKs, CRUD, validators, finders, and the database schema and migrations. The schema is a disposable, generated artifact: change the metadata and regenerate. Don't hand-write divergent SQL; where a stack owns its own migration files, GENERATE them — `meta migrate --migration-format flyway` emits the paired `V__`/`U__` files a Flyway runner expects, and leaves applying them to Flyway. The one exception is a schema this project deliberately owns outside MetaObjects (hand-written migrations by rule, or another team's database): when the root `CLAUDE.md` says so, follow it, and keep `meta verify --db` catching drift. -- **Once this project declares any `template.prompt`, every LLM prompt is one** — the text in the template, the data in a payload value object, rendered by the render engine. A structured reply is read through a response model (`@responseRef` and its generated extractor), never a regex or string search. This covers code that does not look like MetaObjects: a format string, text block, template literal or string builder sent to an LLM, and it covers every module, including test harnesses and scripts. Changing a prompt that is still hand-built means migrating it first (snapshot its current output and keep the rendered text byte-identical), not adding a line to it; the `metaobjects-prompts` skill has the steps. -- The **live database** is a derived artifact too — never hand-apply a schema change to a running DB (ad-hoc `psql`/console `ALTER`/`CREATE`/`DROP`), not even to preview a column or unblock a boot. Drive every schema change from the metadata, never ad-hoc: on the Node/TS-owned migrate stack that is `meta migrate` (metadata → DDL, ADR-0015); on a **Flyway**-owned JVM stack that is `meta migrate --migration-format flyway`, which emits the migration and deliberately refuses `--apply` because Flyway owns applying it. Hand-authoring a migration to match the generated schema is the LAST resort — for a runner MetaObjects has no writer for — never the default for Flyway. A hand-applied ad-hoc change drifts the live DB from the metadata + migration history and collides at the next migrate/boot ("column already exists") — a state no migration can reproduce. Run `meta verify --db ` after any DB-touching work to catch that drift early — the URL is required, and the bare form exits 2. -- **If this project declares `requirement.*` nodes, a commit that adds, changes or removes behaviour updates them in the same commit** (the claim, its `@status` and `@implementedBy`), or says in the commit message why not. `meta verify` checks that the links resolve, not that the ledger is current. -- Never hand-edit generated **output** — change the metadata and regenerate. (That bounds the files codegen *emits*; it says nothing about the generator that emits them — next bullet.) What survives a regen DIFFERS BY TOOLCHAIN, so never rely on it: the Node/TS `meta gen` path three-way-merges, so an edit inside a generated file is preserved (and is refused rather than guessed at when it cannot tell yours from its own stale output); the JVM generators overwrite, and several Kotlin ones — including `.kt` — truncate unconditionally with no marker check. Put your own code in a subclass or a separate file, never in the generated one. -- **Nothing is generated until you wire it — one generator list per port, documentation included.** No port ships a default generator suite, and there is no separate docs command or docs config block on any port: a docs page is one more entry in the same list as every other generator. The list lives in `generators` in `metaobjects.config.ts` (TypeScript; a fresh `meta init` writes `generators: []`), `codegen/Generators.cs` (C#, scaffolded by `dotnet meta init`), a target's `generators` in `metaobjects.config.yaml` (Python), or `` in the Maven plugin's `` (Java, Kotlin). `meta gen --list --probe` is the catalog — it runs every generator against your model and reports how many files each would emit — and each generator runs as shipped from its package: import it on the Node/TS path (the catalog row prints the line), select it by name on the others. `--generators ` (TypeScript, C#, Python; a second Maven `` of `generate`) NARROWS a run to entries the list already declares — it never adds one, and naming an undeclared entry is refused. Copy nothing you are not going to change. `meta eject ...` copies one into your repo when you need to change what it emits. -- **Need an output the model describes that nothing here emits? WRITE A GENERATOR — that is the primary path, not an escape hatch.** Zod, DTOs, a client, a service layer, docs: MetaObjects is the core (model, loader, `verify`, `migrate`, render, extract), and the generators on it are yours to write. A generator is a name plus a function from the model to `{ path, content }` files, about 20 lines; `verify --codegen` gates it with nothing to register. Read the model through the RESOLVING accessors (`fields()`, `attr()`, `resolvedIsArray()` — never `own*()`), skip abstract objects, and resolve `@objectRef` with the port's helper. On the Node/TS path, `meta generator new ` scaffolds a working one and wires it into `metaobjects.config.ts`; the `metaobjects-codegen` skill has every port's shape. Run a reference generator as shipped when it already emits what you want, and eject one only when it is close and you need to change it; never hand-write output the model fully describes. -- **Database, store or framework not built in? Work it out — that is a supported path, not a dead end.** MySQL is a `dialect`. MongoDB, DynamoDB, Cassandra, Neo4j or a remote API: model each record as a sourceless entity (`identity.primary`, no `source.*`, store settings in your own `@` property bag) and generate its data access with a repository generator you own. Express, NestJS, Next.js, Workers, Vue, Svelte: mount or retarget a reference generator, or write one. Never invent vocabulary for it and never hand-write the layer. The procedure is the `metaobjects-codegen` skill's `references/any-stack.md`. -- **The generators are yours — editing one is ordinary work, not an escalation.** Your generator list, and any generator source in your repo (`codegen/generators/` on the Node/TS path), are your code: no `@generated` header, no upstream ownership, nothing to ask permission for. **A standing rule not to change the MetaObjects repo is not a rule about your generators** — that is a different repository, and generalising the first into the second is how an agent ends up hand-writing the exact layer it was told to generate. When generated output does not fit, in order: change the **metadata** if the model is wrong; else change **your own generator**; only then hand-write. Hand-writing what the metadata already describes is the last resort, not the first. Per-port specifics — including which ports have an eject command and which mean implementing a generator interface — are in the `metaobjects-codegen` skill. -- **A defect in generated code is a defect in YOUR generator — fix it there and keep going.** Output that does not compile, has the wrong shape, or collides with your own code is fixed in the generator that emitted it: your ejected copy on the Node/TS path (eject it first if you import it from the package), your own generator class on the JVM (subclass the reference generator, or copy its source into a codegen module on the plugin's classpath), your ejected copy or your own generator on C# and Python. Do not file it upstream, do not wait for or pin a MetaObjects release, and never branch or patch the MetaObjects repository: the reference generators are helpers you can take a copy of at any time, not a guarantee to wait on. Upstream is only for what you cannot own — the loader and metamodel, the runtime packages, the codegen engine itself (runner, merge, `verify`), and `meta migrate`. The test: if changing a generator fixes it, it is yours. -- Use the generated constants for any string that names metadata — a type, subtype or attribute name, and a **physical table or column name**: those are declared once (`@table` / `@column`) and emitted as the per-object `Names` artifact, so never respell one as a literal outside its declaration. Prefer a typed ORM handle where one exists; the constant is for raw SQL, migrations and logs. -- **Ownership has a converse — wire a generator only for output you will actually consume.** Generated code nothing imports is indistinguishable from generated code that does not COMPILE — one adopter carried 87 uncallable query helpers through two audits because a dead-file census read them as over-generation. Worse, an unused generated file still reads as an invitation: a routes file nobody mounted still says "register this as-is for stock CRUD", so the next reader adopts the thing you decided not to. If an entity needs no REST surface, grid or form, don't wire that generator at all, or narrow it with the generator's own `filter` — don't emit the file and leave it unimported. -- The loaded metadata model is READ-ONLY — never inject nodes or mutate the tree at load time (no "enrich the model on load" hooks). Need an extra field/column? Author it in the metadata, or derive it during codegen (read the metadata, emit output). Mutating the loaded model makes it diverge from what's declared — a bad practice reserved for very rare cases. -- **JVM:** serialize a MetaObject-backed instance (a `pojoAware`-flavor generated class, a runtime `ValueObject`, or any `MetaObjectAware` type) through the MetaObjects JSON layer — never hand-configure a Jackson/Gson mapper around the framework fields to make a default mapper cope. - -## Authoring rules you must not violate -- **Search the vocabulary before concluding it cannot be expressed — `meta types `.** An unregistered TYPE or SUBTYPE fails the load in every command. An undeclared `@attr` is different: it fails `meta verify`, which loads strict, and NOT `meta gen`, which does not — so an invented attribute passes codegen silently and is caught by the drift gate rather than by the build. Either way inventing vocabulary is a failure you will hit, not a shortcut. Search names with `meta types `, names and descriptions with `--all` ("find it by what it does"), and one construct's valid `@attrs` with `meta types . --detail`; `--format json` returns the same answer as one machine-readable document, each attr with its `allowedValues`. Rows marked `[ts; pending elsewhere]` (or `[java; …]`) are cross-port vocabulary only that port implements so far: every port loads it, the others ignore it. `[-only]` (`[csharp-only]`; several ports: `[java+kotlin]`) marks vocabulary only those ports ever act on. It is the Node `meta` CLI and, like `meta migrate`, works whatever your backend — it reads the registry, so it needs no project. Ask for NEW vocabulary only once that search comes up empty. -- Nodes are fused-key maps: `{".": { ... }}` (e.g. `{"field.string": {"name": "email"}}`) — never split the type and subtype into separate keys. -- Attribute names are unique within a node; for multi-value use one array attr (`@values: [...]`). -- An inline `@maxLength: 50` equals an `attr` child of the same name — never write both. -- Package paths use `::` (`acme::common::id`). - -## Keep all MetaObjects ports in sync -MetaObjects ships as separate packages per language on DIFFERENT version lines (npm/PyPI/NuGet `0.x`/`1.x`, Maven Central `7.x`/`8.x`). Because the numbers differ by ecosystem, a stale port is INVISIBLE — an old TS client next to a new Java backend *looks* fine. A matching **Metamodel spec version** (`metamodelVersion`, on the registry manifest) means no port carries a BREAKING metamodel change the others lack. It does not move for added vocabulary, so ports on the same metamodel version can still differ in which attributes and subtypes they know: they are fully in sync only when every port is on the same release (each ecosystem's version for one CHANGELOG entry). Upgrade ALL ports together; a lagging port refuses vocabulary the others accept and can disagree on wire behavior. - -`metamodelVersion` is also the number that tells you whether YOUR METADATA needs work (it moves only for a breaking metamodel change), separately from the package version, which tells you whether your BUILD does. A package major means imports/CLI/generated-code shape may need attention; a metamodel major means your model may. A release can move one without the other — so when you upgrade, read the changelog for a metamodel-version move, not just the package number. For a 1.0.x → 1.0.x upgrade, follow https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-within-1.0.md: it covers resyncing the generators you own (`meta eject --list`), which a plain `meta gen` does not do. - -**Upgrading from 1.0 to 1.1:** read https://github.com/metaobjectsdev/metaobjects/blob/main/docs/features/migrations/upgrading-1.0-to-1.1.md before you run `gen`, because the build can stay green while the result is wrong. It is the one page for every port and lists the steps in order. The changes that fail nothing when skipped: the default column and table names are now `snake_case` in every port, so a C#, Java, Kotlin or Python database whose columns are named like its fields needs `"naming": { "columns": "literal" }` in `.metaobjects/config.json`, or the regenerated code queries columns that do not exist; and a fractional validator `@min`/`@max` is refused. Upgrade to 1.1.2 or later: with no `wire` setting each port writes its language's standard JSON, and a project whose clients expect 1.1.0's canonical decimal strings declares `"wire": { "decimals": "string", "nullMembers": "omit" }` in `.metaobjects/config.json`. Documentation is a generator in the project's list, and the docs commands are removed. Then resync every generator you own (`meta eject --list` reports each copy that differs from the reference; `meta eject --force` takes the new one, and a plain `meta gen` does not): an owned copy keeps the logic it was copied with. - -## Going deeper (Claude Code) -For authoring, codegen, runtime/UI, prompts, verify, or adoption-audit work, use the -matching `metaobjects-*` skill — its body links the `references/.md` fragment -installed for this project's stack. Read only the skill your task needs, and inside it the -`SKILL.md` plus the reference file it points you to; the other `references/` files are topics -to open when they come up, not reading to do up front. A skill that `meta init` wrote during -the current session may not load by name until the next one; read -`.claude/skills//SKILL.md` directly. - -## Refreshing / customizing this generated context -This file and the `metaobjects-*` skills are **generated** by MetaObjects for this project's -stack (plain Markdown, no tools/hooks) — refresh with `meta init --refresh-docs`. Don't hand-edit -them expecting the edit to survive: a refresh leaves a file you've edited intact and writes the -new copy to `.new` (only `--force` overwrites in place — never `--force` a file with local -edits). For project-specific guidance, put it in your **root `CLAUDE.md`** (always-on concerns) or -copy a skill to a new name (skill-level overrides) — don't edit the generated originals in place. - -After a refresh, for each `.new`: diff it against ``, **keep the hand-edits and take -the upstream changes**, write the merged result back to ``, then delete `.new`. +> root `AGENTS.md` or `CLAUDE.md`, not here: this file is regenerated. + +The metadata (`metaobjects/` unless `.metaobjects/config.json` says otherwise) is the source of +truth. Code, schema and migrations are generated from it and are disposable. + +## Start here: the whole loop, in order + +{{stackLoops}} +### Schema (every stack: the Node `meta` CLI owns it, so Java, Kotlin, C# and Python projects need Node too) + +Never hand-write DDL, and never `ALTER` a live database by hand. + +- First migration (needs a reachable, empty database): + `npx meta migrate --from-db --db --dialect --slug init` writes + `.metaobjects/migrations/-init/up.sql` and `down.sql`. +- At boot or deploy: `npx meta migrate apply-pending --db `. +- A later change: edit the metadata, regenerate, then + `npx meta migrate --dialect --slug ` (offline, from the committed snapshot). + A renamed field needs `--rename-column
.=` (an object: + `--rename-table =`) to keep its data. A destructive change is refused until you + allow its kind by name: `--allow drop-check` for a changed enum, `--allow drop-column` only + when the data should go. + +### Requirements, when the metadata declares `requirement.*` nodes + +A commit that changes behaviour updates them in the same commit: `@status: live` once a claim +is built (never before), a new node for new behaviour. + +### Before you call it done + +{{verifySteps}}- `npx meta verify --db ` (the live schema matches the metadata). + +Commit the metadata, the generated code, `.metaobjects/migrations/` and +`.metaobjects/.gen-state/.hashes.json`. + +## Calling the generated REST API + +When the project serves the generated routes (any port): + +- Filter as `?filter[][]=`: `?filter[status][eq]=active`, never + `?status=active` (TypeScript refuses that with 400; the other ports ignore it). Operators: `eq`, `ne`, `isNull` (`true`/`false`), `in` (comma list, at most 100), `like` + (case-sensitive, `%` and `_`), `gt`, `gte`, `lt`, `lte`. Filters AND; only `@filterable` + fields filter. +- `?sort=:asc|desc`, `?limit=N&offset=N`; `withCount=1` returns `{"rows", "total"}`. + Always send `limit`: without it the project's `api.pagination.defaultLimit` applies, or with + none set TypeScript and C# return every row, the other ports 50; above `maxLimit` is 400. +- `PUT` is the same partial update as `PATCH`. Send only declared fields: an undeclared key is + 400 `unknown_fields` (unless `api.unknownFields` is `drop`). +- Errors are `{"error": ""}`: 400 for validation (`issues` lists each problem) and for + a bad filter or sort (`invalid_filter_field`, `_op`, `_value`, `invalid_sort`, each naming + `field`), 404 `not_found`, 409 for a unique or foreign-key conflict. + +## Rules + +- What the metadata describes is generated, never hand-written (tables, types, validators, + foreign keys, schema, migrations). Hand-write only what it cannot describe, on top. +- Never hand-edit generated output: change the metadata and regenerate. Output wrong for you, or + broken? Fix the generator: eject it and it is yours, no permission needed, nothing to wait on. +- Never spell a table or column name as a string; use the generated table or names constants. +- Wire a generator only for output you will import. +- An LLM prompt in a project that declares `template.prompt` is a declared template + (`metaobjects-prompts`); a grouped total or report view is an `object.report` + (`metaobjects-authoring`). Open the skill before writing either by hand. +- Never invent metadata vocabulary. Search it: `npx meta types `, and + `npx meta types . --detail` for one construct's valid attributes. +- Metadata nodes are fused-key maps, `{"field.string": {"name": "email"}}`. Attribute names are + unique within a node, and package paths use `::`. + +## Going deeper + +The loop above needs no skill. For less common work load a `metaobjects-*` skill by name, or open +`{{skillsDir}}//SKILL.md` if your assistant does not load skills: `metaobjects-authoring` +(unusual shapes, reports, adopting existing code), `metaobjects-codegen` (owning or writing a +generator), `metaobjects-runtime-ui` (REST routes, the web client), `metaobjects-prompts` (LLM +prompts), `metaobjects-verify` (migration edge cases, drift, upgrades), `metaobjects-audit` (an +adoption review). Each names the one reference page to open. + +`meta init --refresh-docs` regenerates this file and the skills, so keep project guidance in +the root `AGENTS.md` or `CLAUDE.md` (or copy a skill to a new name). A refresh never overwrites a +file you edited; it writes `.new` beside it, which you merge into `` and delete. +Never `--force` a refresh over local edits. diff --git a/agent-context/templates/loops/client.md b/agent-context/templates/loops/client.md new file mode 100644 index 0000000000..e543e4d437 --- /dev/null +++ b/agent-context/templates/loops/client.md @@ -0,0 +1,8 @@ +### Web client: generated by the Node `npx meta gen` + +The client tiers are generators in `metaobjects.config.ts`, whatever the backend: `formFile()` +from `@metaobjectsdev/codegen-ts-react`, `tanstackQuery()` and `tanstackGrid()` from +`@metaobjectsdev/codegen-ts-tanstack`, with the runtime packages `@metaobjectsdev/react` and +`@metaobjectsdev/tanstack`. Wrap the app in ``: +`baseUrl` is where the server mounts its routes, and leaving it out drops that prefix from every +hook without an error. The `metaobjects-runtime-ui` skill has the detail. diff --git a/agent-context/templates/loops/csharp.md b/agent-context/templates/loops/csharp.md new file mode 100644 index 0000000000..f004e5e206 --- /dev/null +++ b/agent-context/templates/loops/csharp.md @@ -0,0 +1,17 @@ +### C#: generate with `dotnet meta gen` + +1. **Config.** `codegen/Generators.cs` (written by `dotnet meta init`) is the generator list. + Nothing is generated until it is listed. The EF Core data layer and its routes: + + ```csharp + new MetaObjects.Codegen.Generators.EntityGenerator(), + new MetaObjects.Codegen.Generators.DbContextGenerator(), + new MetaObjects.Codegen.Generators.FilterAllowlistGenerator(), + new MetaObjects.Codegen.Generators.RoutesGenerator(), + ``` + + `RequirementTestsGenerator { OutDir = "/Generated" }` writes one test per + requirement; `ApiDocsGenerator` writes `api/csharp/AGENT-API.md`. `dotnet meta gen --list` + is the catalog. +2. **Generate.** `dotnet meta gen`. `dotnet meta eject ` copies a generator into the repo + to change what it emits. diff --git a/agent-context/templates/loops/java.md b/agent-context/templates/loops/java.md new file mode 100644 index 0000000000..44210fe5d2 --- /dev/null +++ b/agent-context/templates/loops/java.md @@ -0,0 +1,9 @@ +### Java: generate with `mvn metaobjects:generate` + +1. **Config.** The `metaobjects-maven-plugin`'s `` in `pom.xml` is the generator + list, one `` each, under `` pointing at the metadata. + Nothing is generated until it is listed; the build names any generator a listed one needs. + Which classes to list (the Spring REST tier, requirement tests, API docs) is in the + `metaobjects-codegen` skill's `references/java.md`. +2. **Generate.** `mvn metaobjects:generate`. `mvn metaobjects:eject -Dnames= -Dport=java` + copies a generator to change what it emits. diff --git a/agent-context/templates/loops/kotlin.md b/agent-context/templates/loops/kotlin.md new file mode 100644 index 0000000000..ffc8805caf --- /dev/null +++ b/agent-context/templates/loops/kotlin.md @@ -0,0 +1,9 @@ +### Kotlin: generate with `mvn metaobjects:generate` + +1. **Config.** The `metaobjects-maven-plugin`'s `` in `pom.xml` is the generator + list, one `` each. Nothing is generated until it is listed. Which + classes to list (the Exposed and Spring tier, requirement tests, API docs) is in the + `metaobjects-codegen` skill's `references/kotlin.md`. +2. **Generate.** `mvn metaobjects:generate`. `mvn metaobjects:eject -Dnames= -Dport=kotlin` + copies a generator to change what it emits. Several Kotlin generators truncate their output + on every run, so never put your own code in a generated file. diff --git a/agent-context/templates/loops/python.md b/agent-context/templates/loops/python.md new file mode 100644 index 0000000000..2af51299e2 --- /dev/null +++ b/agent-context/templates/loops/python.md @@ -0,0 +1,18 @@ +### Python: generate with `metaobjects gen` + +1. **Config.** `metaobjects.config.yaml` names each target's `outDir` and its generators. Nothing + is generated until it is listed: + + ```yaml + targets: + app: + outDir: generated + generators: [entity, names] # Pydantic models + physical-name constants + ``` + + `routes` and `filter-allowlist` add FastAPI routers over a repository `Protocol` you + implement; `requirement-tests` writes one pytest file per package of requirements; + `api-docs` writes `api/python/AGENT-API.md`. `metaobjects gen --list` is the catalog. + Install what the output imports: `pip install "pydantic[email]>=2" fastapi`. +2. **Generate.** `metaobjects gen`. `metaobjects eject ` copies a generator into the repo + to change what it emits. diff --git a/agent-context/templates/loops/typescript.md b/agent-context/templates/loops/typescript.md new file mode 100644 index 0000000000..f5133dc911 --- /dev/null +++ b/agent-context/templates/loops/typescript.md @@ -0,0 +1,20 @@ +### TypeScript: generate with `npx meta gen` + +1. **Config.** In `metaobjects.config.ts` set `dialect` (`"postgres" | "sqlite" | "mysql"`; D1 is + `"sqlite"`) and list the generators. Nothing is generated until it is listed. The usual data + layer: + + ```ts + import { entityFile, namesFile, barrel } from "@metaobjectsdev/codegen-ts/generators"; + // generators: [entityFile(), namesFile(), barrel()] + ``` + + Per entity: `.ts` (Drizzle table, row types, Zod schemas, enum types) and + `.names.ts` (physical names), plus an `index.ts` barrel. Install what they import: + `npm i drizzle-orm zod` and your database driver. Every other generator (CRUD `queriesFile()` + / `routesFile()`, docs, `requirementTests()`) is one line too; `npx meta gen --list` is the + catalog. `npx meta eject ` copies one into `codegen/generators/` to change it; + `npx meta generator new ` writes a new one. +2. **Generate.** `npx meta gen`. See a file's exports with `grep -n "^export" `. When + `agentDocsFile()` / `apiDocsFile()` are wired, read the `agent/*.md` or `api/AGENT-API.md` + page for the tier you touch. diff --git a/bun.lock b/bun.lock index bff1efbe72..70203375a5 100644 --- a/bun.lock +++ b/bun.lock @@ -43,7 +43,7 @@ }, "client/web/packages/react": { "name": "@metaobjectsdev/react", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/runtime-web": "workspace:*", "react-easy-crop": "^6.2.3", @@ -73,7 +73,7 @@ }, "client/web/packages/runtime-web": { "name": "@metaobjectsdev/runtime-web", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/metadata": "workspace:*", "qs": "^6.13.0", @@ -86,7 +86,7 @@ }, "client/web/packages/tanstack": { "name": "@metaobjectsdev/tanstack", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/runtime-web": "workspace:*", }, @@ -113,7 +113,7 @@ }, "server/typescript/packages/ai-runtime": { "name": "@metaobjectsdev/ai-runtime", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/metadata": "workspace:*", "@metaobjectsdev/render": "workspace:*", @@ -134,7 +134,7 @@ }, "server/typescript/packages/cli": { "name": "@metaobjectsdev/cli", - "version": "1.2.3", + "version": "1.3.0", "bin": { "meta": "./dist/bin/meta.js", }, @@ -166,6 +166,7 @@ "pg": "^8.0.0", "pg-mem": "^3.0.4", "prisma": "7.10.1", + "ts-poet": "^6.10.0", "typescript": "^5.6.0", "zod": "^4.4.3", }, @@ -179,16 +180,17 @@ }, "server/typescript/packages/codegen-ts": { "name": "@metaobjectsdev/codegen-ts", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@biomejs/js-api": "^0.7.0", "@biomejs/wasm-nodejs": "^1.9.4", + "@dprint/formatter": "^0.6.0", + "@dprint/typescript": "0.87.1", "@metaobjectsdev/docs-site": "workspace:*", "@metaobjectsdev/metadata": "workspace:*", "@metaobjectsdev/migrate-ts": "workspace:*", "@metaobjectsdev/render": "workspace:*", "@toon-format/toon": "^2.3.0", - "ts-poet": "^6.10.0", }, "devDependencies": { "@biomejs/biome": "^1.9.0", @@ -214,24 +216,19 @@ "dependencies": { "@metaobjectsdev/codegen-ts": "workspace:*", "@metaobjectsdev/metadata": "workspace:*", - "ts-poet": "^6.10.0", }, "devDependencies": { "@biomejs/biome": "^1.9.0", "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/codegen-ts-react": { "name": "@metaobjectsdev/codegen-ts-react", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/codegen-ts": "workspace:*", "@metaobjectsdev/metadata": "workspace:*", - "ts-poet": "^6.10.0", }, "devDependencies": { "@biomejs/biome": "^1.9.0", @@ -239,17 +236,13 @@ "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/codegen-ts-tanstack": { "name": "@metaobjectsdev/codegen-ts-tanstack", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/codegen-ts": "workspace:*", "@metaobjectsdev/metadata": "workspace:*", - "ts-poet": "^6.10.0", }, "devDependencies": { "@biomejs/biome": "^1.9.0", @@ -257,9 +250,6 @@ "bun-types": "latest", "typescript": "^5.6.0", }, - "peerDependencies": { - "@biomejs/biome": ">=1.9.0 <3.0.0", - }, }, "server/typescript/packages/conformance": { "name": "@metaobjectsdev/conformance", @@ -277,7 +267,7 @@ }, "server/typescript/packages/docs-site": { "name": "@metaobjectsdev/docs-site", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/metadata": "workspace:*", "@metaobjectsdev/render": "workspace:*", @@ -329,7 +319,7 @@ }, "server/typescript/packages/metadata": { "name": "@metaobjectsdev/metadata", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "yaml": "^2.9.0", }, @@ -342,7 +332,7 @@ }, "server/typescript/packages/migrate-ts": { "name": "@metaobjectsdev/migrate-ts", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@iarna/toml": "^2.2.5", "@metaobjectsdev/metadata": "workspace:*", @@ -369,7 +359,7 @@ }, "server/typescript/packages/render": { "name": "@metaobjectsdev/render", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "mustache": "^4.2.0", "nunjucks": "^3.2.4", @@ -383,7 +373,7 @@ }, "server/typescript/packages/runtime-ts": { "name": "@metaobjectsdev/runtime-ts", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/metadata": "workspace:*", "@metaobjectsdev/render": "workspace:*", @@ -422,7 +412,7 @@ }, "server/typescript/packages/sdk": { "name": "@metaobjectsdev/sdk", - "version": "1.2.3", + "version": "1.3.0", "dependencies": { "@metaobjectsdev/metadata": "workspace:*", "yaml": "^2.9.0", @@ -581,6 +571,10 @@ "@csstools/css-tokenizer": ["@csstools/css-tokenizer@4.0.2", "", {}, "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw=="], + "@dprint/formatter": ["@dprint/formatter@0.6.0", "", {}, "sha512-otnYh2jmGWbekYkAd4xiF416lpdZwNCbhkDrLQcAanvvutp0PhTNSJrwJ4DKBEu6xtP36NUX70t9YQw3oC/ONg=="], + + "@dprint/typescript": ["@dprint/typescript@0.87.1", "", {}, "sha512-XdbJCIbUdqijEgKOuFCSRwJAjHp5zUKZVzxrNn5xU9vn6Uy71JkvZT9Esw9hCEjno/vPmJ6IFhVGdoGlEzN2vQ=="], + "@electric-sql/pglite": ["@electric-sql/pglite@0.5.16", "", {}, "sha512-Nj8KcIsJL748W408U2N8q4+9IlONdpRIU8MJypIAAINMJ5nqKyqpX7Mgg/5XKkXiAib3AoZGR6hnJFlrlLBrcg=="], "@electric-sql/pglite-socket": ["@electric-sql/pglite-socket@0.1.3", "", { "peerDependencies": { "@electric-sql/pglite": "0.4.3" }, "bin": { "pglite-server": "dist/scripts/server.js" } }, "sha512-LAciWM0M1dCL8hlsxu2venbVZcdxema0BtDfpWYVqr+Y468UADw0pFWidhKw1M8sfJ8rdLT71tjMmnirf/IZRQ=="], @@ -597,13 +591,13 @@ "@fastify/error": ["@fastify/error@4.2.1", "", {}, "sha512-MYBumuIwP+5MIpXSyKm6/o1Eigcoij186lWUssX3LH5U8KWqU0ktZhzC4CErIX9EJeQeRGI+zJZQWakBlFbUcg=="], - "@fastify/fast-json-stringify-compiler": ["@fastify/fast-json-stringify-compiler@5.2.0", "", { "dependencies": { "fast-json-stringify": "^7.3.0" } }, "sha512-LPTVA0w4oPITWHAvox9NgI1rDSrjUnjxX6QN5MCb9FY+HqvDsUmgLucbj9eQakqC8lYwO7UgkDPHEQLJNl9vtg=="], + "@fastify/fast-json-stringify-compiler": ["@fastify/fast-json-stringify-compiler@5.1.1", "", { "dependencies": { "fast-json-stringify": "^7.0.0" } }, "sha512-pyxRKk7UpUnnrztP9pF4+ZYxusEQ4LifTyzRdiXmyql1QezNHxO02D25MVU2o4kMeAMYWAjG6RKRlojgkbiDAw=="], "@fastify/forwarded": ["@fastify/forwarded@3.1.2", "", {}, "sha512-89WiRG+hW3VQSfCwg4Hb8b43PeyEX15K5+lEfsZ4EUth/FyOjS/lv8HsVuswUNXWiSnxMGNouE/fq/0w3VumHQ=="], "@fastify/merge-json-schemas": ["@fastify/merge-json-schemas@0.2.2", "", { "dependencies": { "dequal": "^2.0.3" } }, "sha512-d/gx9sRbUCVgGRGzma46wLcwiY8noTqO2Nmjg/vbTARxHRE5bdh5PIL8s97Lt1X7ScRWRW52eVYxwIoPwIdVUA=="], - "@fastify/proxy-addr": ["@fastify/proxy-addr@5.1.3", "", { "dependencies": { "@fastify/forwarded": "^3.0.0", "ipaddr.js": "^2.1.0" } }, "sha512-ptgIgB+abBNTs5lsKNvFaKMCauPaTOE6ZIjxJr3FxCLehmYQQKYGg4srwwNICR9QQlFrYw59jWAo+i9GalVCaw=="], + "@fastify/proxy-addr": ["@fastify/proxy-addr@5.1.2", "", { "dependencies": { "@fastify/forwarded": "^3.0.0", "ipaddr.js": "^2.1.0" } }, "sha512-uqB4QsgVoro0XDC+DIftIMGXHdBPn+lK6Ek3xXAIxPMCJfqxnbtyEoMCm2KPUVOuIosd7Cyw9HawEqMFM/UA+g=="], "@hookform/resolvers": ["@hookform/resolvers@3.10.0", "", { "peerDependencies": { "react-hook-form": "^7.0.0" } }, "sha512-79Dv+3mDF7i+2ajj7SkypSKHhl1cbln1OGavqrsF7p6mbUv11xpqpacPsGDCTRvCSjEEIez2ef1NveSVL3b0Ag=="], @@ -683,7 +677,7 @@ "@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="], - "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.3", "", {}, "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g=="], + "@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="], "@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="], @@ -807,7 +801,7 @@ "@sec-ant/readable-stream": ["@sec-ant/readable-stream@0.4.1", "", {}, "sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg=="], - "@seriousme/openapi-schema-validator": ["@seriousme/openapi-schema-validator@2.12.0", "", { "dependencies": { "ajv": "^8.20.0", "ajv-draft-04": "^1.0.0", "ajv-formats": "^3.0.1", "yaml": "^2.9.1" }, "bin": { "bundle-api": "bin/bundle-api-cli.js", "validate-api": "bin/validate-api-cli.js" } }, "sha512-arefJr6XDthcWqYP4ZBXBIGv62mdgRaCCp6ND1ApWn6Lqbb3Yva6zFovccE+n7mDMjussDZB2jpZNoJlu9Eu7A=="], + "@seriousme/openapi-schema-validator": ["@seriousme/openapi-schema-validator@2.11.0", "", { "dependencies": { "ajv": "^8.20.0", "ajv-draft-04": "^1.0.0", "ajv-formats": "^3.0.1", "yaml": "^2.9.1" }, "bin": { "bundle-api": "bin/bundle-api-cli.js", "validate-api": "bin/validate-api-cli.js" } }, "sha512-DL8TjmjkUS76OaK/TinoRtf6PrirsWfMZiv62ifP9eq3UOpoLqSGZKpCErxMzz0i1pjECSPYY+qZ1SRYEgiEvg=="], "@sindresorhus/is": ["@sindresorhus/is@7.2.0", "", {}, "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw=="], @@ -937,7 +931,7 @@ "balanced-match": ["balanced-match@4.0.4", "", {}, "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA=="], - "baseline-browser-mapping": ["baseline-browser-mapping@2.11.37", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-QYph+vfurmaxhNwi9FprfmtkT5cx2Keg8FzZ0vnjO8ukscIybVyZGMFwdllKGlTI6qyU8ck43OM9UXh+IFJihQ=="], + "baseline-browser-mapping": ["baseline-browser-mapping@2.11.36", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-AbPFGS4K9S3meMRCLTM0Zas+e9X7b5ygUBOboDT5zevCZt9ByKSbMtKhwyVqW+oL8WemPVsbP7X3rdZcIyOa0w=="], "better-result": ["better-result@2.10.0", "", {}, "sha512-oQhh0y1qo2/ZKdAAEvHZAqKKiHOFU5k/bW96fE2ScgQOVkJRiHwB+nOS1SgFsYqRlxMDWvefXi9Q3px7QvgNDw=="], @@ -1017,7 +1011,7 @@ "data-urls": ["data-urls@7.0.0", "", { "dependencies": { "whatwg-mimetype": "^5.0.0", "whatwg-url": "^16.0.0" } }, "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA=="], - "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], + "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], "decimal.js": ["decimal.js@10.6.0", "", {}, "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg=="], @@ -1053,7 +1047,7 @@ "effect": ["effect@3.20.0", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "fast-check": "^3.23.1" } }, "sha512-qMLfDJscrNG8p/aw+IkT9W7fgj50Z4wG5bLBy0Txsxz8iUHjDIkOgO3SV0WZfnQbNG2VJYb0b+rDLMrhM4+Krw=="], - "electron-to-chromium": ["electron-to-chromium@1.5.486", "", {}, "sha512-rpybw4Ac4ak/An6G1Me2+61xzwobowDGyuJe71QHHOVpkZv4fPVobsLl7WH6zHSKusAMpaHxGKTpOvpy7+r3dQ=="], + "electron-to-chromium": ["electron-to-chromium@1.5.481", "", {}, "sha512-dNUsbAP6E2S1dHIYEuN3cQ0dViThjMtpVRheGdvv5HgHFtzLi4Cu4Mbzms85YggP3Eh2VVZTl5+XxEN8ofCbmQ=="], "elkjs": ["elkjs@0.11.1", "", {}, "sha512-zxxR9k+rx5ktMwT/FwyLdPCrq7xN6e4VGGHH8hA01vVYKjTFik7nHOxBnAYtrgYUB1RpAiLvA1/U2YraWxyKKg=="], @@ -1087,7 +1081,7 @@ "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], - "fast-json-stringify": ["fast-json-stringify@7.3.6", "", { "dependencies": { "@fastify/merge-json-schemas": "^0.2.0", "ajv": "^8.12.0", "ajv-formats": "^3.0.1", "fast-uri": "^4.0.0", "json-schema-ref-resolver": "^3.0.0", "rfdc": "^1.2.0" } }, "sha512-hXCpiZTZGiER/Xree1Tb4PY1DREPUnlWTP5Df9hgtoDnUppulV7Km8lh1/NEBuqz4JnNGSXghnABudfZ/iwIzg=="], + "fast-json-stringify": ["fast-json-stringify@7.3.5", "", { "dependencies": { "@fastify/merge-json-schemas": "^0.2.0", "ajv": "^8.12.0", "ajv-formats": "^3.0.1", "fast-uri": "^4.0.0", "json-schema-ref-resolver": "^3.0.0", "rfdc": "^1.2.0" } }, "sha512-g7H3xqJmdH9aWLWh8S3CqrRZFZ321yaeNHZp3QUDl3wtXDWjPChDXCDDTwA4M/zsU42nOhE+z5KmpCzgBaaCgw=="], "fast-querystring": ["fast-querystring@1.1.2", "", { "dependencies": { "fast-decode-uri-component": "^1.0.1" } }, "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg=="], @@ -1107,7 +1101,7 @@ "figures": ["figures@6.1.0", "", { "dependencies": { "is-unicode-supported": "^2.0.0" } }, "sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg=="], - "find-my-way": ["find-my-way@9.10.1", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", "safe-regex2": "^5.0.0" } }, "sha512-UwbZdEdk59YXIGPW/rbDn/Ayr3mJ5fPH/HJeMPlK8Ez10aUin4iyRwgJvNTSkRfpZ2h8uLX0LbvZm/YUBUpymw=="], + "find-my-way": ["find-my-way@9.10.0", "", { "dependencies": { "fast-deep-equal": "^3.1.3", "fast-querystring": "^1.0.0", "safe-regex2": "^5.0.0" } }, "sha512-eru+uCPQ2g+nLBkf84MHP/KyNNMar0BDy0j+i8Fb72GF9/YHBZ58q7FODUtfVV7XU9nfRUHXSmaM8NmZcIbZ4Q=="], "foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="], @@ -1135,7 +1129,7 @@ "gopd": ["gopd@1.2.0", "", {}, "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="], - "graceful-fs": ["graceful-fs@4.2.12", "", {}, "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw=="], + "graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="], "grammex": ["grammex@3.1.13", "", {}, "sha512-LnPnhOBLEJEVKS8WFDVaA397L9Kq55Q9oSITJiVLHVdhAclfUkWzQv74KhvZHKL2Q09Pb1XdsrOsZ4LfTFFTEg=="], @@ -1213,7 +1207,7 @@ "libsql": ["libsql@0.4.7", "", { "dependencies": { "@neon-rs/load": "^0.0.4", "detect-libc": "2.0.2" }, "optionalDependencies": { "@libsql/darwin-arm64": "0.4.7", "@libsql/darwin-x64": "0.4.7", "@libsql/linux-arm64-gnu": "0.4.7", "@libsql/linux-arm64-musl": "0.4.7", "@libsql/linux-x64-gnu": "0.4.7", "@libsql/linux-x64-musl": "0.4.7", "@libsql/win32-x64-msvc": "0.4.7" }, "os": [ "linux", "win32", "darwin", ], "cpu": [ "x64", "arm64", ] }, "sha512-T9eIRCs6b0J1SHKYIvD8+KCJMcWZ900iZyxdnSCdqxN12Z1ijzT+jY5nrk72Jw4B0HGzms2NgpryArlJqvc3Lw=="], - "light-my-request": ["light-my-request@6.8.1", "", { "dependencies": { "@fastify/deepmerge": "^3.1.0", "cookie": "^2.0.0", "process-warning": "^5.0.0", "set-cookie-parser": "^3.0.1" } }, "sha512-20biUK0HAIPG9BZOK3/4s8uVAkAoi1+qW55lciHZCR0puTWipBgyMPEUjqXDWLjsZeqfO6DGsuwW5eyfsTGtyg=="], + "light-my-request": ["light-my-request@6.8.0", "", { "dependencies": { "@fastify/deepmerge": "^3.1.0", "cookie": "^2.0.0", "process-warning": "^5.0.0", "set-cookie-parser": "^3.0.1" } }, "sha512-5Q8PjoSEdtGIB8fikZsTem5vgRo4F2mR6vUKTDW/H1g6MtAt8e3duQbg/QxL5yzg6BZhor2KOUm3hhWMWLTZwg=="], "lodash": ["lodash@4.18.1", "", {}, "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q=="], @@ -1267,7 +1261,7 @@ "node-fetch": ["node-fetch@3.3.2", "", { "dependencies": { "data-uri-to-buffer": "^4.0.0", "fetch-blob": "^3.1.4", "formdata-polyfill": "^4.0.10" } }, "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA=="], - "node-releases": ["node-releases@2.0.64", "", {}, "sha512-zAPCKqMcnqs2nGy6nlkm7JduFseiBJy3EXHGLh+8pFR+TxGCBxxiEN21+UROU5CKwX/f4TlUcYjiM+vs/tsyxw=="], + "node-releases": ["node-releases@2.0.63", "", {}, "sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q=="], "normalize-wheel": ["normalize-wheel@1.0.1", "", {}, "sha512-1OnlAPZ3zgrk8B91HyRj+eVv+kS5u+Z0SCsak6Xil/kmgEia50ga7zfkumayonZrImffAxPU/5WcyGhzetHNPA=="], @@ -1303,7 +1297,7 @@ "pg-int8": ["pg-int8@1.0.1", "", {}, "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="], - "pg-mem": ["pg-mem@3.0.14", "", { "dependencies": { "functional-red-black-tree": "^1.0.1", "immutable": "^4.3.4", "json-stable-stringify": "^1.0.1", "lru-cache": "^6.0.0", "moment": "^2.27.0", "object-hash": "^2.0.3", "pgsql-ast-parser": "^12.0.2" }, "peerDependencies": { "@mikro-orm/core": ">=4.5.3", "@mikro-orm/postgresql": ">=4.5.3", "knex": ">=0.20", "kysely": ">=0.26", "mikro-orm": "*", "pg-promise": ">=10.8.7", "pg-server": "^0.1.5", "postgres": "^3.4.4", "slonik": ">=23.0.1", "typeorm": ">=0.2.29" }, "optionalPeers": ["@mikro-orm/core", "@mikro-orm/postgresql", "knex", "kysely", "mikro-orm", "pg-promise", "pg-server", "postgres", "slonik", "typeorm"] }, "sha512-G9m8OD0A+YS083smidSUJddTX2dEDPT8mRMG3sQGNiGfS/mkvAgd9Kf1/onD5633bFN7HcQK/Tn2x7qjBMFRUQ=="], + "pg-mem": ["pg-mem@3.0.14", "", { "dependencies": { "functional-red-black-tree": "^1.0.1", "immutable": "^4.3.4", "json-stable-stringify": "^1.0.1", "lru-cache": "^6.0.0", "moment": "^2.27.0", "object-hash": "^2.0.3", "pgsql-ast-parser": "^12.0.2" }, "peerDependencies": { "@mikro-orm/core": ">=4.5.3", "@mikro-orm/postgresql": ">=4.5.3", "knex": ">=0.20", "kysely": ">=0.26", "pg-promise": ">=10.8.7", "pg-server": "^0.1.5", "postgres": "^3.4.4", "slonik": ">=23.0.1", "typeorm": ">=0.2.29" }, "optionalPeers": ["@mikro-orm/core", "@mikro-orm/postgresql", "knex", "kysely", "pg-promise", "pg-server", "postgres", "slonik", "typeorm"] }, "sha512-G9m8OD0A+YS083smidSUJddTX2dEDPT8mRMG3sQGNiGfS/mkvAgd9Kf1/onD5633bFN7HcQK/Tn2x7qjBMFRUQ=="], "pg-pool": ["pg-pool@3.14.0", "", { "peerDependencies": { "pg": ">=8.0" } }, "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw=="], @@ -1437,7 +1431,7 @@ "split2": ["split2@4.2.0", "", {}, "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg=="], - "sql-escaper": ["sql-escaper@1.6.0", "", {}, "sha512-I+WA4xb3mprpxUbLFtraZRY8L4vI0+xEOPLxHSI4wOuZ8cSpjVBzeuQpnPjW6PfdjeSkD9n/IBoYzH0LGTVSoQ=="], + "sql-escaper": ["sql-escaper@1.5.2", "", {}, "sha512-6CKD38c31SENivxOADeMNLdukOnUxUcflKtzVWzace7Riv1v7cAEym5Cx9Q7gYZ3ezIJI7ZpqecQq8cqNeSSFg=="], "std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="], @@ -1451,9 +1445,9 @@ "thread-stream": ["thread-stream@4.2.1", "", { "dependencies": { "real-require": "^1.0.0" } }, "sha512-Stg6edJXC/6/xqGwSXwFokrUhChJ18amEjpKH89WrQQ0oVFDF+pUUcTpiwWhFUrE89Vf16FBOlwhaw+lescxMQ=="], - "tldts": ["tldts@7.5.4", "", { "dependencies": { "tldts-core": "^7.5.4" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q=="], + "tldts": ["tldts@7.4.22", "", { "dependencies": { "tldts-core": "^7.4.22" }, "bin": { "tldts": "bin/cli.js" } }, "sha512-TmLwkCZ1GFMxGkKfg2ooQhPF8rDMuuXvJHSxFiOU1fofh27L6NaO5T9KSlQXCJX2eoSt14I8F4saSMILOmXmaQ=="], - "tldts-core": ["tldts-core@7.5.4", "", {}, "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA=="], + "tldts-core": ["tldts-core@7.4.22", "", {}, "sha512-NRyhrlvJcTwvoRibE0dEZvp6C5RwV4RxpsX1zbkI1k7Fk2pzIhmQ+MvswJEd5KKl3VRFRMDTipXse/ejh/ld/w=="], "toad-cache": ["toad-cache@3.7.4", "", {}, "sha512-m1TdR/rvT7kgGJZhspNtXdsdYk0fddFpJJFlG5s+UkPFo6lkLoZ3YLOaovPYjq1R75NP5JfeTlSHaOsE09peCg=="], diff --git a/client/web/packages/react/package.json b/client/web/packages/react/package.json index 9f98ac10f9..a8178b4a77 100644 --- a/client/web/packages/react/package.json +++ b/client/web/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@metaobjectsdev/react", - "version": "1.2.3", + "version": "1.3.0", "description": "React runtime for metaobjects: useEntityForm hook and CurrencyInput component.", "type": "module", "main": "./dist/index.js", diff --git a/client/web/packages/runtime-web/package.json b/client/web/packages/runtime-web/package.json index 0c11a40c76..673862a1e4 100644 --- a/client/web/packages/runtime-web/package.json +++ b/client/web/packages/runtime-web/package.json @@ -1,6 +1,6 @@ { "name": "@metaobjectsdev/runtime-web", - "version": "1.2.3", + "version": "1.3.0", "description": "Pure framework-agnostic browser core for metaobjects: currency, filter URL serialization, fetcher contract types.", "type": "module", "main": "./dist/index.js", diff --git a/client/web/packages/tanstack/package.json b/client/web/packages/tanstack/package.json index d50f7ab3a6..3297bd75ad 100644 --- a/client/web/packages/tanstack/package.json +++ b/client/web/packages/tanstack/package.json @@ -1,6 +1,6 @@ { "name": "@metaobjectsdev/tanstack", - "version": "1.2.3", + "version": "1.3.0", "description": "TanStack runtime for metaobjects: EntityFetcherProvider, EntityGrid, default cell renderers.", "type": "module", "main": "./dist/index.js", diff --git a/docs/1.0-readiness.md b/docs/1.0-readiness.md index ced552c54c..08ba4ef1d8 100644 --- a/docs/1.0-readiness.md +++ b/docs/1.0-readiness.md @@ -117,7 +117,7 @@ Status legend: ✅ done · 🔶 in progress · ⬜ not started · ❓ **[RATIFY] (attribute ⇒ PATCH, top-level type ⇒ MINOR, subtype ⇒ PATCH when inert), and Amendment 2 separates the package and metamodel axes. Trigger is *new public surface, not code size*: package **MINOR** only for newly-dependable - surface (codegen output, CLI flag, a newly-supported vocab member); package **PATCH** + surface (codegen-engine surface, CLI flag, a new top-level type); package **PATCH** for bugfix/refactor; the **Metamodel spec version** bumps only on a shared vocabulary/wire change. The fast `7.3→7.7` minor run was breaking *velocity*; decouple + this rule ends the churn. @@ -155,29 +155,11 @@ Status legend: ✅ done · 🔶 in progress · ⬜ not started · ❓ **[RATIFY] in all three non-TS ports; a Python runtime path dropped an inherited M:N) — assume more lurk, and lead every cross-port fix with a shared fixture. - **Known instance, measured 2026-09-06 — the four entity-scoped cross-field validators.** - `validator.comparison`, `requiredWhen`, `presentIff` and `atLeastOne` are registered - vocabulary in all five ports and are taught by the shipped `metaobjects-authoring` skill, - but their only enforcement is the database `CHECK` that TS-owned `migrate` emits (gated by - `migrate-ts/test/validator-check/cross-field.test.ts`, 7 tests). **No port's generated API - tier validates them:** Python's `entity_model.py` and C#'s `EntityGenerator.cs` dispatch - only on the four FIELD-scoped validators (`length`, `array`, `numeric`, `regex`), and the - shared `validation-conformance` corpus covers only those same four — **zero fixtures across - every behavioral corpus touch the cross-field family.** They are also four of the 13 entries - in `registry-conformance/coverage-report.json`'s `untestedSubTypes`, which is the same list - the `.base` defect hid in until `0.25.0`. - - Consequence for an adopter today: a request body violating a declared cross-field rule is - refused by the DATABASE, not by the API, in every port — a constraint violation rather than - a 400. - - **This does not block the cut**, and the reason is worth stating so it is not re-litigated: - the vocabulary is enforced (the CHECK reaches every port, because schema is TS-owned per - ADR-0015), and adding API-tier enforcement later changes no load verdict and no metadata — - it is additive, and reaches an adopter as a wrong request failing earlier and more clearly. - What must NOT happen is adding a cross-port `validation-conformance` fixture for these - before the ports implement the tier; that turns three lanes red to record a gap this bullet - already records. + **Known instance (measured 2026-09-06, resolved Unreleased).** The four entity-scoped cross-field + validators (`comparison`, `requiredWhen`, `presentIff`, `atLeastOne`) were enforced only by the DB + `CHECK`. The generated record model now enforces them in every port; see + [features/entities.md](features/entities.md#cross-field-validators) and the CHANGELOG `[Unreleased]` entry. + They remain among the `untestedSubTypes` in `registry-conformance/coverage-report.json`, which tracks the registry, not the generated behavior. ## F. Adoption proof (the audit as readiness signal) diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index 833c13e04a..ed885a4265 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -1,6 +1,6 @@ # Conformance coverage -The MetaObjects standard ships **39 shared conformance corpora** under +The MetaObjects standard ships **42 shared conformance corpora** under [`fixtures/`](../fixtures/). Every port runs every corpus that is *applicable to it* and asserts the same expected behaviour against the same fixtures. **This page is the inverse index**: fixture → feature doc + per-port pass status, and it is the @@ -26,7 +26,7 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor | Corpus | Fixtures | TS | Java | Kotlin | C# | Python | |---|---|---|---|---|---|---| -| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 475 | ✓ | ✓ but the rc.19 fixtures — the two reverse-hop fixtures (`origin-reverse-reference-hop`, `error-origin-reverse-hop-ambiguous`; bug R-walk), `origin-passthrough-flattened-member` and `reference-flattened-member` (bug G6), `projection-filter-unprojected-base-field`, `projection-filter-joined-path` and `error-projection-filter-path-to-many` (bug G7), `projection-extends-abstract-projection`, `projection-extends-filtered-projection` and `error-projection-extends-filter-sql-body` (bug G13; the last two from the fix round's C1), `object-collection-name` (R57), `report-dimension-required-by-model` (R62; its `expected-report-required.json` holds the model-derived `required` every port's report shape must give — Java, Kotlin and Python still derive it from the INNER-join rule), and the Tier 2 view vocabulary (R58: `entity-derived-league-gate`, `origin-computed-case-over-joined`, `origin-correlated-filter-and-segment`, `origin-filter-relative-now`, `projection-filter-relative-now`, `error-origin-computed-case-mixed-types`, `error-origin-segment-unresolved`, `error-origin-correlated-operand-unknown`) — not run in this port; expected red until [#544](https://github.com/metaobjectsdev/metaobjects/issues/544)–#549 | inherits via `metadata-ktx` (the same) | ✓ | ✓ but the same, #544–#549 | +| [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 526 | ✓ | ✓ | 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 | ✓ | — | — | — | ✓ | @@ -35,36 +35,39 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor | [`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 | ✓ | | [`fixtures/extract-conformance/`](../fixtures/extract-conformance/) | 58 | ✓ | ✓ | inherits the shared JVM engine | ✓ | ✓ | | [`fixtures/output-prompt-conformance/`](../fixtures/output-prompt-conformance/) | 17 | ✓ | ✓ | ✓ | ✓ | ✓ | -| [`fixtures/persistence-conformance/`](../fixtures/persistence-conformance/) | 59 (53 query + 6 migration) | all 59; the 24 `report-*` and the `-15` decimal scenarios also on SQLite, MySQL and D1, `decimal-exact` also on MySQL (a scenario's `engines:` key is exact) | 53 query (migrations TS-only, ADR-0015); the `report-*` and `engines:` scenarios also on SQLite and MySQL | 53 query (via Exposed); the `report-*` and `engines:` scenarios also on SQLite and MySQL | 53 query; the `report-*` and `engines:` scenarios also on SQLite and MySQL | 53 query (pg8000); the `report-*` and `engines:` scenarios also on SQLite (`sqlite3`) and MySQL (PyMySQL) | -| [`fixtures/api-contract-conformance/`](../fixtures/api-contract-conformance/) | 122 (32 core + 12 tph + 9 m2m + 5 jsonb + 2 write-through + 2 secret-fields + 12 projection + 37 report + 11 decimal) | ✓ (Fastify reference + generated lane); `report/` and `decimal/` also on SQLite, MySQL and D1 | ✓ (embedded HTTP + JDBC); `report/` and `decimal/` generated controllers over OMDB on Postgres, SQLite and MySQL | ✓ (embedded HTTP + Exposed); `report/` and `decimal/` also on SQLite and MySQL | ✓ (Kestrel + Npgsql); `report/` and `decimal/` also on SQLite and MySQL | ✓ (FastAPI + pg8000); `report/` and `decimal/` also on SQLite and MySQL | +| [`fixtures/persistence-conformance/`](../fixtures/persistence-conformance/) | 67 (55 query + 12 migration) | all 67; the 24 `report-*` and the `-15` decimal scenarios also on SQLite, MySQL and D1, `decimal-exact` also on MySQL (a scenario's `engines:` key is exact) | 55 query (migrations TS-only, ADR-0015); the `report-*` and `engines:` scenarios also on SQLite and MySQL | 55 query (via Exposed); the `report-*` and `engines:` scenarios also on SQLite and MySQL | 55 query; the `report-*` and `engines:` scenarios also on SQLite and MySQL | 55 query (pg8000); the `report-*` and `engines:` scenarios also on SQLite (`sqlite3`) and MySQL (PyMySQL) | +| [`fixtures/api-contract-conformance/`](../fixtures/api-contract-conformance/) | 139 (34 core + 14 tph + 9 m2m + 6 jsonb + 2 write-through + 2 secret-fields + 2 enum-default + 12 projection + 37 report + 11 decimal + 2 duration + 8 api-settings) | ✓ (Fastify reference + generated lane); `report/`, `decimal/` and `duration/` also on SQLite, MySQL and D1 | ✓ (embedded HTTP + JDBC); `report/`, `decimal/` and `duration/` generated controllers over OMDB on Postgres, SQLite and MySQL | ✓ (embedded HTTP + Exposed); `report/`, `decimal/` and `duration/` also on SQLite and MySQL | ✓ (Kestrel + Npgsql); `report/`, `decimal/` and `duration/` also on SQLite and MySQL | ✓ (FastAPI + pg8000); `report/`, `decimal/` and `duration/` also on SQLite and MySQL | | [`fixtures/decimal-wire/`](../fixtures/decimal-wire/) | 1 vector file (format, parse, filter operand, 15-digit read) | ✓ (`runtime-ts` and the generated helper) | ✓ (`CanonicalDecimal`) | ✓ (the generated wire file) | ✓ (`DecimalWire`) | ✓ (`decimal_wire`) | | [`fixtures/duration-wire/`](../fixtures/duration-wire/) | 1 vector file: the `wire` vectors (parse, precision, refused) every port passes, and the `codecs` groups (Postgres text read and write, stored microseconds) each port passes only for the codecs it has | ✓ (`metadata` / `runtime-ts` and the generated helper) | ✓ | ✓ | ✓ | ✓ | -| [`fixtures/validation-conformance/`](../fixtures/validation-conformance/) | 42 cases | ✓ (generated Zod + run-time `runValidators`) | ✓ | ✓ | ✓ | ✓ (generated Pydantic + run-time `run_validators`) | +| [`fixtures/validation-conformance/`](../fixtures/validation-conformance/) | 42 cases + 43 cross-field cases (`cross-field-cases.json`, generated record model only) | ✓ (generated Zod + run-time `runValidators`) | ✓ | ✓ | ✓ | ✓ (generated Pydantic + run-time `run_validators`) | | [`fixtures/registry-conformance/`](../fixtures/registry-conformance/) | 1 canonical manifest | ✓ (reference emitter) | ✓ | ✓ | ✓ | ✓ | | [`fixtures/object-model-conformance/`](../fixtures/object-model-conformance/) | 1 shared metadata fixture (per-port scenarios) | ✓ | ✓ | ✓ | ✓ | ✓ | | [`fixtures/codegen-conformance/`](../fixtures/codegen-conformance/) | 7 shared inputs; `shared-provided-enum` carries the enum-type decision table and `cross-package-binding` the reference-binding decision table (ADR-0059) every port answers; `xpkg-value-object-refs` (ruling R52) is run by C# and TypeScript only so far — Java, Kotlin and Python in [#544](https://github.com/metaobjectsdev/metaobjects/issues/544)–#549 | ✓ | ✓ | ✓ | ✓ | ✓ | | [`fixtures/template-codegen-conformance/`](../fixtures/template-codegen-conformance/) | 3 | ✓ | ✓ | ✓ | ✓ | ✓ | | [`fixtures/template-output-render-conformance/`](../fixtures/template-output-render-conformance/) | 5 | ✓ | ✓ | ✓ | ✓ | ✓ | | [`fixtures/generator-registry-conformance/`](../fixtures/generator-registry-conformance/) | 1 canonical manifest | ✓ | ✓ | ✓ | ✓ | ✓ | -| [`fixtures/provider-composition-conformance/`](../fixtures/provider-composition-conformance/) | 9 (5 error-shape + 4 compose-load) | ✓ | ✓ | — (JVM registry via Java) | ✓ | ✓ | +| [`fixtures/provider-composition-conformance/`](../fixtures/provider-composition-conformance/) | 18 (11 error-shape + 4 compose-load + 3 attr-ownership) | ✓ | ✓ | — (JVM registry via Java) | ✓ | ✓ | | [`fixtures/source-resolution-conformance/`](../fixtures/source-resolution-conformance/) | 25 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/) | 37 cases (26 resolution + 11 check) + 14 transport cases | ✓ (reference implementation; all three arms) | ✓ (resolution arm, all 26; no check, so the 11 check cases are not run) | inherits via Java | ✓ (resolution arm, all 26; no check, so the 11 check cases are not run) | ✓ (resolution arm, all 26 identically; no check yet, so the 11 check cases are not run; the transport arm is Node-only) | -| [`fixtures/shared-model-conformance/`](../fixtures/shared-model-conformance/) | 11 cases (7 publish + 4 refusal) | ✓ (reference implementation) | — (Phase 2) | — (Phase 2) | — (Phase 2) | ✓ (serializer arm: the 7 publish cases' document bytes; no publisher) | -| [`fixtures/agent-context-conformance/`](../fixtures/agent-context-conformance/) | 4 | ✓ (the emitter is TS-owned) | — | — | — | — | +| [`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/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`) | ✓ (serializer arm: the 9 publish cases' document bytes; no publisher) | +| [`fixtures/agent-context-conformance/`](../fixtures/agent-context-conformance/) | 5 | ✓ (the emitter is TS-owned) | — | — | — | — | | [`fixtures/metamodel-docs/`](../fixtures/metamodel-docs/) | 1 | ✓ (docs emit is TS-owned) | — | — | — | — | | [`fixtures/fmt-conformance/`](../fixtures/fmt-conformance/) (#304 — `meta fmt`) | 12 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | | [`fixtures/field-lint-conformance/`](../fixtures/field-lint-conformance/) (the `verify` field authoring lint) | 15 | ✓ (reference) | ✓ | inherits via Java | ✓ | ✓ | | [`fixtures/requirement-check-conformance/`](../fixtures/requirement-check-conformance/) (the `verify` requirement gate, ADR-0057) | 43 cases | ✓ (reference) | ✓ | inherits via Java (one Maven `metaobjects:verify` goal) | ✓ | ✓ | | [`fixtures/requirement-test-identity-conformance/`](../fixtures/requirement-test-identity-conformance/) (the identity, skip state and digest of each generated requirement test, and the filter seam, ADR-0057) | 26 cases | ✓ (reference) | ✓ | identity function inherits via Java; emitted names asserted by its own generator test | ✓ | ✓ | -| [`fixtures/naming-conformance/`](../fixtures/naming-conformance/) | 8 cases | ✓ | ✓ | inherits via Java (`RouteNaming.pluralize`) | ✓ | ✓ | +| [`fixtures/naming-conformance/`](../fixtures/naming-conformance/) | 8 cases + 23 collection segments (`@collectionName`, `naming.collections`) | ✓ | ✓ | inherits via Java (`RouteNaming.pluralize`, `RouteNaming.collectionSegment`) | ✓ | ✓ | | [`fixtures/wire-conformance/`](../fixtures/wire-conformance/) (the `wire` setting, ADR-0019 Amendment 2) | 6 cases + 8 refusals | ✓ | ✓ | inherits via Java (one config reader) | ✓ | ✓ | | [`fixtures/enum-length-conformance/`](../fixtures/enum-length-conformance/) (a string-stored enum's column length: `@maxLength`, else `enums.maxLength`) | 5 cases + 1 overflow + 5 refusals; run by a port that sizes the column | ✓ | ✓ | inherits via Java (one config reader, one resolver) | ✓ | — (sizes no column: emits no DDL or column type; the config reader accepts and shape-checks the `enums` block) | -| [`fixtures/check-constraint-conformance/`](../fixtures/check-constraint-conformance/) (rc.19 item 13 — the CHECKs one model gets through `meta migrate` and through a generated EF model) | 1 model, 3 expected files (Postgres, Postgres with `skipRedundant`, SQLite) | ✓ (reference: `meta migrate`) | — (declares no CHECK in a generated model) | — | ✓ (the EF context, and live Postgres) | — (declares no CHECK in a generated model) | -| [`fixtures/codegen-skip-conformance/`](../fixtures/codegen-skip-conformance/) (when `gen` may skip and what a local `verify --codegen` may answer, ADR-0062) | one case table in `cases.json` | ✓ | ✓ | ✓ (through the Java runner) | ✓ | ✓ | +| [`fixtures/check-constraint-conformance/`](../fixtures/check-constraint-conformance/) (the CHECK constraints `meta migrate` derives: name and expression text per dialect) | 1 model, 5 expected files (postgres, sqlite, d1, and both skip-redundant variants) | ✓ (reference, `migrate-ts`) | — (no CHECK in a generated model) | — (same) | ✓ (the EF context declares them; live-Postgres `EnsureCreated` lane) | — (same) | +| [`fixtures/foreign-key-index-conformance/`](../fixtures/foreign-key-index-conformance/) (the indexes `migrate.foreignKeyIndexes` adds: which foreign keys are uncovered, and each index's name per dialect, a name over 63 bytes cut on Postgres; and the name each declared `identity.secondary` / `index.lookup` is created under) | 1 model, 4 expected files (FK and declared, postgres and sqlite) | ✓ (reference, `migrate-ts`; the Drizzle tables declare the declared names) | — (no index in a generated model) | ✓ (the Exposed tables declare them) | ✓ (the EF context declares them) | — (same as Java) | +| [`fixtures/codegen-skip-conformance/`](../fixtures/codegen-skip-conformance/) (when `gen` may skip and what a local `verify --codegen` may answer, ADR-0064) | one case table in `cases.json` | ✓ | ✓ | ✓ (through the Java runner) | ✓ | ✓ | | [`fixtures/codegen-noop/`](../fixtures/codegen-noop/) (FR-044 — reporting vocabulary: what is lowered, what stays inert) | 1 model pair (`reporting/with` vs `reporting/without`) | ✓ (codegen + migrate) | ✓ | ✓ | ✓ | ✓ | | [`fixtures/cube-model/`](../fixtures/cube-model/) (FR-044 Plan 4 — the `cube-model` generator's golden Cube files, plus the canonical model's golden) | 46 cases (36 trees + 10 errors) + 1 canonical golden | ✓ (the exporter is TypeScript-only, spec R6; its `cube` lane also loads the files into a real Cube) | — | — | — | — | +| [`fixtures/writer-conformance/`](../fixtures/writer-conformance/) (ADR-0063 — the code writer generators write through) | 41 cases (31 core + 10 TypeScript) | ✓ (the first writer; core and TypeScript dialect) | — (writer not built yet) | — (writer not built yet) | — (writer not built yet) | — (writer not built yet) | | [`fixtures/contract-conformance/`](../fixtures/contract-conformance/) (FR-022 — the `contract-schema` and `openapi` generators' golden trees and refusals) | 19 cases (14 trees + 5 errors) | ✓ (one neutral engine, ADR-0034 Amendment 10; the generated API lanes also hold real traffic to the documents) | — | — | — | — | +| [`fixtures/explorer-conformance/`](../fixtures/explorer-conformance/) (the `explorer.json` data spine: `meta export --effective` + `meta verify --format json` + the generated-file manifest in, one explorer document out) | 1 case (`shop`) | ✓ (the builder is TypeScript, and reads only port-neutral inputs) | — | — | — | — | A ✓ means the port runs the corpus green; an explicit `n / m` is used where a port carries a ledgered divergence. The two ledgered YAML fixtures are documented @@ -92,11 +95,12 @@ the corpora above do two different jobs. Only the first is a promise to adopters (the canonical serializer, surfaced per-file — ADR-0034's "canonical format" is core), `field-lint-conformance/` (the advisory field lint every port's `verify` prints) and `requirement-check-conformance/` (the requirement gate every port's `verify` runs; a - drift gate is core, and it is not ejectable in any port). `codegen-skip-conformance/` (ADR-0062: which changes make `gen` render, and what a local `verify --codegen` may answer from the stored key) is core for the same reason. + drift gate is core, and it is not ejectable in any port). `codegen-skip-conformance/` (ADR-0064: which changes make `gen` render, and what a local `verify --codegen` may answer from the stored key) is core for the same reason. A red cell here is a MetaObjects bug. - **Template quality checks — not a promise.** The generated lane of `api-contract-conformance/`, `generator-registry-conformance/` (stable generator names), - `codegen-noop/` (vocabulary with no lowering yet emits nothing), `contract-conformance/` (the JSON Schema and OpenAPI output), `cube-model/` (the Cube + `codegen-noop/` (vocabulary with no lowering yet emits nothing), `writer-conformance/` (the code + writer the reference generators write through, ADR-0063), `contract-conformance/` (the JSON Schema and OpenAPI output), `cube-model/` (the Cube exporter's output, a TypeScript reference helper), `requirement-test-identity-conformance/` (which tests the `requirement-tests` reference generator yields from a ledger and what each is called; the text it writes is not @@ -112,51 +116,34 @@ corpora, or between its *vocabulary* and its *behaviour* — never gets a row of own, and its boundary ends up discoverable only from the feature doc. The split ones are recorded here instead. -**Value-object names and the claim registry** (ruling R52): no port renames a value object to -avoid a collision; a real collision (two objects emitting one name into one scope) is refused by -the run's claim registry with `ERR_NAME_COLLISION`, naming both and the remedy. - -- *Done:* C# (`GenContext.Claim`: types per namespace, DbSets per context, route segments per - routes entry, finders per class, expression indexes per schema). Since rc.19 R65 each package - is its own namespace by default, so the `xpkg-collision` pair is two types; mapping both - packages onto one namespace (`PackageNamespaces`) is what the refusal tests use. -- *Done:* TypeScript (`ctx.claim`, helpers in `codegen-ts/src/naming/name-claims.ts`: a module's - type and collection names per module directory, the barrel's re-exports per barrel, REST - segments per routes entry). The `xpkg-collision` tests use the package output layout; a file - that meets both `Note`s binds each under a package-qualified local alias - (`import type { Note as AcmeAlphaNote }`), which names no type. The UI tier - (`codegen-ts-tanstack`, `-react`, `-angular`) claims nothing yet: its hooks import the entity - modules, whose claims cover the same names. -- *TODO, Python:* still renames (`collision_names.py`, `ERR_PAYLOAD_NAME_COLLISION`) in its flat - generated package. Java and Kotlin never renamed (the Java package disambiguates). Tracked in - [#544](https://github.com/metaobjectsdev/metaobjects/issues/544)–#549. - -**`identity.primary @sequenceStart`** (rulings R36, R51, one semantic in every port): on a fresh -database the identity or sequence begins at `@sequenceStart`. When the start changes on an -existing database, the change records the new start, and, for a declared start, moves the -counter forward to `GREATEST(n, max(id) + 1)` when it is below that. It never `RESTART`s and never -moves the counter back, because live rows already hold the ids it has handed out. A database -rebuilt by replaying migrations then begins at the start, as a fresh one does. The port TODOs -below are tracked in [#544](https://github.com/metaobjectsdev/metaobjects/issues/544). - +**`identity.primary @sequenceStart`** (one semantic in every port that writes DDL): on a fresh +database the identity or sequence begins at `@sequenceStart`; when the start changes on an +existing database, the change sets `START WITH n` and moves the counter FORWARD only, to +`GREATEST(n, max(id) + 1)` when it sits below that. It never `RESTART`s and never moves a counter +back, because live rows already hold the ids it handed out. Tracked in +[#544](https://github.com/metaobjectsdev/metaobjects/issues/544). + +- *Honoured and pinned:* TypeScript (`meta migrate`). A fresh table is created `START WITH n`. A + changed start writes `ALTER SEQUENCE … START WITH n` plus an advance-only `setval`. The + persistence migration scenarios `sequence-start-change-moves-counter-forward` and + `sequence-start-change-below-max-id` pin on live Postgres that the next id is the start, or the + highest id plus one when a row already holds an id past the start. +- *Honoured, string-tested only:* the Drizzle schema template (`entityFile()`). It writes the + start into the identity column's options (`startWith: n`), and a codegen unit test asserts that + text (`codegen-ts/test/templates/drizzle-schema.test.ts`). No test creates a table from the + Drizzle mapping and reads the first id, so the option's effect is not pinned. - *Honoured and pinned:* C#. The generated context carries the start on Npgsql, and the generated - design-time services (`DesignTimeServices`, ruling R50) scaffold every - start-only change — added, changed or removed — as SQL, Up and Down (Npgsql alone writes - `RESTART WITH n`, or `RESTART WITH 1` for a removed start). `EfModelGapsTests` pins the - transitions, the adopter's own differ being kept, and, on live Postgres, a replayed database - beginning at the start, a populated table advancing to it, an explicit id above the counter, - and a lowered or removed start leaving the counter where it was. -- *TODO, TypeScript (`meta migrate`, Drizzle):* a fresh table is created `START WITH n`, and a - changed start runs `setval(seq, n, false)` when `last_value` is below it - (`emit/postgres.ts` `renderAlterSequence`). That is the semantic, except that it compares with - the counter only: bring it to `GREATEST(n, max(id) + 1)`, so an explicit id above the counter is - not handed out again, and pin it. -- *TODO, Java (OMDB) and Kotlin (Exposed):* the vocabulary loads; neither emits or honours the - start in its DDL or mapping. Add it with the same semantic and the same pin. -- *TODO, Python:* the vocabulary loads; the runtime has no DDL path. If it gains one, the same - semantic and pin apply. - -**Kind-1 vocabulary: cross-port, implemented in some ports so far** (ruling R40). Each entry + `DesignTimeServices` makes `dotnet ef migrations add` scaffold a start-only change as + `SET START WITH n` plus the same advance-only move (Npgsql alone writes `RESTART WITH n`). + `EfModelGapsTests` pins the transitions, and on live Postgres the next id after the change. +- *Honoured and pinned:* Kotlin (Exposed 0.x and 1.x). A declared start or name generates + `autoIncrement(Sequence("", startWith = n))`; a live-Postgres test pins that a fresh + table's first id is the start. Exposed generated code has no migration path, so a changed start + is `meta migrate`'s job. +- *Not applicable:* Java (OMDB is pure data access with no DDL, ADR-0015) and Python (no DDL + path). The vocabulary loads in both; schema comes from `meta migrate`. + +**Cross-port vocabulary implemented in some ports so far (`implementedIn`).** Each entry below is in the shared registry and the registry manifest, marked `implementedIn`. A port that has not implemented it must still register it and load it strictly (and then ignore it); an unregistered attr on it still fails. Gated by the conformance fixtures `view-kind1-controls`, @@ -169,25 +156,15 @@ canonical (`fixtures/registry-conformance/expected-registry.json`). `view.number`, `view.password`, `view.radio`, `view.text`, `view.web` (types, no attrs) - `view.textarea`, and its `@rows` - `view.image`, and its `@accept`, `@aspectRatio`, `@maxBytes`, `@maxEdge`, `@store` -- *Implemented in C# and TypeScript* (`implementedIn: ["csharp", "typescript"]`, rc.19 R57): - `object.entity` / `object.projection` / `object.report` `@collectionName`, with the pluggable - pluralizer (`naming.collections`). *TODO, Java, Kotlin and Python:* register the attr (the - manifest is spec-driven; Python's spec copy is synced) and derive their collection names - (REST segment, finders) from it; the loader fixture `object-collection-name` names its - reverse hop `Consignment.consignmentHistory` by it, so it is red in those ports until they do (#544–#549). - *Implemented in Java only* (`implementedIn: ["java"]`): `object.* @object` (ADR-0001), the native class an object binds to. Java's runtime acts on it; Java's own behaviour is unchanged. -- *Loads strictly, per port:* - - TypeScript and C#: every entry above loads strictly, and the manifest byte-matches - (`KindOneVocabularyTests` in C#; `registry-conformance.test.ts` and the fixtures in TS). - - *TODO, Java and Kotlin:* the view controls load, but `view.textarea @rows` and the - `view.image` attrs are not registered (`view-kind1-controls` fails with - `ERR_UNKNOWN_ATTR`), and the manifest still carves out the views, `@object` and - `@objectAdapter`, so registry-conformance fails. `object-kind1-jvm-binding-attrs` passes. - - *TODO, Python:* the same view-attr gap, plus `@object` and `@objectAdapter` are not - registered (both loading fixtures fail), and registry-conformance fails. -- *Kind 2, for comparison* (`ports`, language-specific by nature, never "pending"): - `@dbSetName` (`["csharp"]`; deprecated in rc.19 as an alias of `@collectionName`) and +- *Loads strictly in every port.* Each port registers the `metaobjects-ui-web` provider + (`view.textarea @rows`, the `view.image` attrs) and `@object` / `@objectAdapter` on + `object.*`, loads all three fixtures strictly, and emits `implementedIn` in its manifest, which + byte-matches the canonical in all five ports (`KindOneVocabularyTests` in C#; + `registry-conformance.test.ts` in TypeScript; `RegistryManifestConformanceTest` in Java and + Kotlin; `test_registry_conformance.py` in Python). +- *Port-scoped, for comparison* (`ports`, language-specific by nature, never "pending"): `@objectAdapter` (`["java", "kotlin"]`). **Generated paths keyed by package** (ruling R39). Every port's generated output is keyed by @@ -199,22 +176,26 @@ collide on an output path. State per port: package, not `PackageNamespaces`. Since rc.19 R65 the namespace follows the package too (`acme::alpha` → `Acme.Alpha`) unless a binding maps it; every cross-namespace reference is `global::`-qualified. Tests: `OutputPathsTests`, `PackageNamespaceTests`. -- *Done, TypeScript:* `outputLayout` defaults to `"package"` (`DEFAULT_OUTPUT_LAYOUT`, ruling - R63); `"flat"` stays available. Tests: `barrel-layout.test.ts` (the barrel exports the same +- *Done, TypeScript:* `outputLayout` defaults to `"flat"`; `"package"` is opt-in (ruling + R63). Tests: `barrel-layout.test.ts` (the barrel exports the same names in both layouts), `naming/name-claims.test.ts`. -- *TODO, Python:* only the flat layout exists. A package layout is new work. -- *TODO, Java and Kotlin:* files land in the mapped Java package directories, so two metadata - packages mapped to one Java package would collide. +- *Done, Python:* `outputLayout` mirrors TypeScript — `"flat"` the default, `"package"` opt-in, + and `metaobjects init` writes `outputLayout: package` into a new project. Tests: + `tests/codegen/test_package_layout.py`. +- *Done, Java and Kotlin:* every per-object file lands in the directory of its metadata package + (`a::b` → `a/b`), and a run where two metadata packages would land in one directory is + refused (`OutputPackageCollisions`), not silently overwritten. Tests: `PackageKeyedOutputTest` + (spring, kotlin). - Tracked in [#544](https://github.com/metaobjectsdev/metaobjects/issues/544)–#549. -**Native index vocabulary and `@description` in the ORM models** (R33). `meta migrate` creates +**Native index vocabulary and `@description` in the ORM models.** `meta migrate` creates every index (`identity.secondary`, `index.lookup`, a field's `@unique`, with `@where`, `@using`, `@orders`, `@expr` and the resolved name) and writes `@description` as `COMMENT ON`. What each port's ORM model carries beside it: - *C# (EF Core):* every index, with `@where`, `@orders`, `@using` and its name, and the table and - column comments. An `@expr` index is not an EF index: the `expression-indexes` generator writes it - as SQL. Pinned by `EfModelGapsTests` and `ExpressionIndexesGeneratorTests`. + column comments. An `@expr` index is not an EF index; `meta migrate` creates it. Pinned by + `EfModelGapsTests`. - *TypeScript (Drizzle):* every index, with `@where`, `@orders`, `@using`, `@expr` and its name (`templates/drizzle-schema.ts`). Not expressible: `@description`, which Drizzle has no API for; an `@expr` index on SQLite (Drizzle's `.on()` there takes columns only). @@ -330,6 +311,10 @@ manifest contains without moving these boundaries. classpath and stubbing them drowns the signal; that tier is compiled and booted over real HTTP in the api-contract integration lane instead. The boundary is one cross-port rule, not four local concessions. +- *The gate and the generated-server api-contract lanes run in both output layouts* — + the engine default `flat` and `outputLayout: "package"` (which `meta init` writes) — + so a defect only the non-default layout shows (a relative import one directory short, + two packages landing in one directory) fails a gate rather than an adopter's build. - *The prompt tier is out of scope here* because the fitness corpus declares no `template.*` nodes. Including those generators would emit nothing and read as coverage that is not there. @@ -401,7 +386,7 @@ unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker. ## Fixture-to-doc mapping -### `fixtures/conformance/` — metamodel loader + canonical serializer (460) +### `fixtures/conformance/` — metamodel loader + canonical serializer (526) | Fixture prefix | Feature doc | |---|---| @@ -425,6 +410,8 @@ unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker. | `projection-*`, `error-projection-*`, `field-readonly-on-view-projection` | [features/source-kinds.md](features/source-kinds.md) (projections + the object taxonomy, ADR-0028) | | `requirement-*`, `error-unknown-attr-requirement` | [features/requirements.md](features/requirements.md) (vocabulary only — the gate has its own corpus, `requirement-check-conformance/`; see "Split coverage" above) | | `reporting-*`, `error-dimension-*`, `error-measure-*`, `error-ratio-*`, `error-segment-*`, `error-report-*`, `error-relative-date-*` | [features/reporting.md](features/reporting.md) (the `dimension` / `measure` / `segment` / `object.report` vocabulary and its load-time rules; design in the [FR-044 spec](superpowers/specs/2026-10-02-fr-044-core-reporting-design.md)) | +| `provider-extension-*`, `provider-custom-vocabulary-*` | [features/extending-with-providers.md](features/extending-with-providers.md) (a project's own provider: a new subtype plus attributes on an existing type load with it and are refused without it, every port writing the provider in its own language) | +| `object-collection-name` | [features/migrations/physical-naming.md](features/migrations/physical-naming.md) (`@collectionName` and the `collections` pluralizer) | | `smoke-empty-metadata` | [features/entities.md](features/entities.md) | ### `fixtures/yaml-conformance/` (16) @@ -464,10 +451,10 @@ All 37 fixtures → [features/migrations-and-drift.md](features/migrations-and-d may carry `"isArray": true`; with `fields` it is a list of objects, without it a list of scalars. The six `verify-positional-accessor-*` cases pin where `-last` is available. -### `fixtures/persistence-conformance/` (59 — 53 query + 6 migration) +### `fixtures/persistence-conformance/` (67 — 55 query + 12 migration) -- `migrations/*` (6) → [features/migrations-and-drift.md](features/migrations-and-drift.md) (schema migration section) -- `queries/*` (53) → [features/source-kinds.md](features/source-kinds.md) (query semantics against `source.rdb`) +- `migrations/*` (12) → [features/migrations-and-drift.md](features/migrations-and-drift.md) (schema migration section) +- `queries/*` (55) → [features/source-kinds.md](features/source-kinds.md) (query semantics against `source.rdb`) **Engines beyond Postgres (FR-044 reports, decimals).** The twenty-four `queries/report-*.yaml` scenarios also run on SQLite and MySQL 8.4 in every port, and on D1's local runtime in @@ -483,9 +470,9 @@ REAL, a MySQL `DECIMAL` keeps its scale, a MySQL `DATETIME` is the UTC wall cloc `report-relative-date` carries a per-engine seed (`seed-data-engine`). `op: relate` and the write ops stay Postgres-only. See [features/reporting.md](features/reporting.md#what-the-corpus-gates). -### `fixtures/api-contract-conformance/` (122) +### `fixtures/api-contract-conformance/` (139) -All 122 scenarios → [features/api-contract.md](features/api-contract.md) (cross-port +All 139 scenarios → [features/api-contract.md](features/api-contract.md) (cross-port REST API URL grammar + JSON wire format). Verifies every backend's emitted CRUD routes answer identically over HTTP — list / get / create / patch+put / delete, plus pagination (`limit`/`offset`), sort (`sort=field:dir`), the `withCount=1` @@ -495,22 +482,30 @@ status codes. The corpus also covers the 9 cross-port filter operators (`eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`, `like`, `isNull`) plus the implicit-AND combinator and 2 error shapes (`invalid_filter_field` / `invalid_filter_op`) under the -URL grammar `?filter[][]=` (FR-009). On top of the 32 core -scenarios the corpus carries eight sub-corpora — `tph/` (12, single-table -inheritance; a subtype decimal filters and refuses extra digits), `m2m/` (9 — 3 plain, 5 gating TPH x M:N together, the combination +URL grammar `?filter[][]=` (FR-009). On top of the 34 core +scenarios (among them the write-input rules: server-owned keys dropped, an undeclared key +refused under the default `api.unknownFields: reject`, and every validation issue listed) +the corpus carries eleven sub-corpora — `tph/` (14, single-table +inheritance; a subtype decimal filters and refuses extra digits, and the input rules hold over +the whole hierarchy), `m2m/` (9 — 3 plain, 5 gating TPH x M:N together, the combination each corpus alone could not reach, and 1 pinning the collection-URL spelling), -`jsonb/` (5, typed value-object columns; numbers inside them: a double stays a JSON number, a decimal is the canonical string), -`write-through/` (2, table-write + view-read entities), `secret-fields/` (2, #484 + the 1.2.x input gate: a `@formExclude` or credential `view.password` field is ignored on create, PATCH and PUT, a credential is never returned, and a `@mutability: readOnly` field is ignored on write too), `projection/` (12, a +`jsonb/` (6, typed value-object columns; numbers inside them: a double stays a JSON number, a decimal is the canonical string; an undeclared member inside a value object is dropped), +`write-through/` (2, table-write + view-read entities), `secret-fields/` (2, #484: a `@formExclude` or credential `view.password` field is ignored on create, PATCH and PUT, and a credential is never returned), `enum-default/` (2, a create that omits a `field.enum` with `@default` stores the default, and a supplied value is kept), `projection/` (12, a read-only view answers reads and refuses writes with 405; a projection with no declared identity has no item route; a projection keyed on a field not named `id` is addressed by it, whether its identity names `@fields` or derives them; decimal and float fields filter), `decimal/` (11, ADR-0019 Amendment 1: a decimal, array element and undeclared-precision column included, is one -canonical string, read exactly, filtered exactly and refused past its declared digits) and `report/` (37, +canonical string, read exactly, filtered exactly and refused past its declared digits), `duration/` (2, a +`field.duration` under `"wire": { "durations": "iso" }` is one canonical ISO-8601 string, refused +in a calendar or clock spelling, and filtered and sorted as a span on every engine), `api-settings/` (8, +the project's `api` block: `api.pagination`'s default page, `limit_too_large` cap and refused +negative `limit`, an empty page for `limit=0`, and +`api.unknownFields: drop`) and `report/` (37, FR-044: a view-backed `object.report` is listed, filtered, sorted and paged on its derived fields, answers `POST` with 405 and mounts no `/{id}`; a `@spine` report keeps a row with no facts, and a measure with `@default` filters and sorts as its default). All 5 ports — TS, Java, Kotlin, C#, Python — run it in BOTH lanes: a hand-rolled reference server and the port's own GENERATED API artifact booted over HTTP. `write-through/`, -`secret-fields/`, `projection/`, `decimal/` and `report/` run the generated lane only, on all five ports: what +`secret-fields/`, `enum-default/`, `projection/`, `decimal/`, `duration/` and `report/` run the generated lane only, on all five ports: what they test is whether a port's generator emits the routes. The `report/` sub-corpus is the one that reads real views, so it runs full stack on Postgres, SQLite and MySQL (`report/schema.sqlite.sql`, `report/schema.mysql.sql`, both TypeScript-produced) in every @@ -573,55 +568,71 @@ also matches before a trailing newline. Kotlin has no runner of its own: it inhe 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. -### `fixtures/dependency-conformance/` (37 cases + 14 transport cases) +### `fixtures/dependency-conformance/` (47 cases + 32 transport cases) -All 37 cases → [features/metadata-dependencies.md](features/metadata-dependencies.md) +All 47 cases → [features/metadata-dependencies.md](features/metadata-dependencies.md) (declaring a dependency, `meta deps sync`, the committed snapshot + lock, default exclusion of imported metadata, overlay/extends across the boundary, every load- -and resolution-time failure, and the upstream check). File-shaped like `scope-conformance/` -above: one committed `cases.json`, no per-port fixture, no ledger. The corpus has three arms: +and resolution-time failure, the upstream check, and which imported requirements are the +project's own ledger). File-shaped like `scope-conformance/` above: one committed `cases.json`, +no per-port fixture. The corpus has four arms: -- **Resolution (26 cases).** Every case's `expectFiles`/`expectImported`/`expectSelected`/ +- **Resolution (36 cases).** Every case's `expectFiles`/`expectImported`/`expectSelected`/ `expectMigrateGoverned`/`expectLoadError` assertions. **TypeScript (the reference - implementation), Python, Java and C# all run all 26, identically**, with no exemption. The two + implementation), Python, Java and C# 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 for it. Kotlin inherits the Java run through the same loader and Maven plugin. +- **Ledger (7 of the resolution cases, `expectLedger` / `expectCoverageMeasured`).** Which loaded + requirements are this project's ledger (its own, plus a dependency's only when + `requirements.inherit` names the dependency's package) with each one's effective `@status`, and + 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. + 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 `unresolved` (a missing path, a bad manifest, a hash mismatch, or not yet in the lock). Run - by TypeScript only, in `cli/test/dependency-check-conformance.test.ts`; Python and Java have no - `deps check` yet and filter these cases out. The arm exists so that each port's check is - written against the same edge cases (Phase 2, #482). -- **Transport (14 cases, `transport-cases.json`).** The `npm` and `python` transports `meta deps sync` - uses to find an installed package: npm packages under a temp `node_modules`, Python packages on a - temp import path, the directory each resolves to, the exact lock written, and each refusal. Run by + by TypeScript, in `cli/test/dependency-check-conformance.test.ts`, by Java in + `DependencyCheckConformanceTest` (the engine behind `metaobjects:verify -Dmeta.verify.mode=deps`; + Kotlin runs the same goal), by **Python**, in `tests/conformance/test_dependency_conformance.py` + (`metaobjects deps check` and `verify --deps`), and by **C#**, in `DependencyConformanceTests` + (`dotnet meta verify --deps`). The arm exists so that each port's check is written against the + same edge cases (FR-023 Phase 2, #482, shipped). +- **Transport (32 cases, `transport-cases.json`).** The `npm`, `python`, `maven` and `nuget` transports + `meta deps sync` uses to find an installed package: npm packages under a temp `node_modules`, Python + packages on a temp import path, jars in a temp local Maven repository, packages in a temp NuGet cache, + the directory each resolves to, the exact lock written, and each refusal. Run by Node only, in `cli/test/dependency-transport-conformance.test.ts`, because Node `meta deps sync` is - the only writer of snapshots and the lock. `cases.json` also carries an `npm` and a `python` - dependency loading from their committed snapshot with nothing installed, which both ports run. + the only writer of snapshots and the lock. `cases.json` also carries an `npm`, a `python`, a `maven` and a `nuget` + dependency loading from their committed snapshot with nothing installed, which every port runs. **C#** (S6 of FR-023 Phase 2) runs the resolution arm on two rungs of the source ladder: the neutral one (`Resolve(null, dir)`), and the explicit metadata directory a `dotnet meta gen ` takes, where the case has one. Its runner is -`DependencyConformanceTests`; it skips the 11 check cases (C# has no `deps check` yet) and the -transport cases (C# never syncs). +`DependencyConformanceTests`; it runs the 11 check cases through `DependencyResolver.CheckDependencies` +(S7) and skips the transport cases (C# never syncs). -### `fixtures/shared-model-conformance/` (11 cases) +### `fixtures/shared-model-conformance/` (15 cases) → [features/metadata-dependencies.md](features/metadata-dependencies.md) (the publisher's `sharedModelFile()`). A source tree under `source/`, plus `files` / `include` / `exclude` / -`version`, must produce **exactly** the pinned artifact and manifest bytes (seven cases), or be -refused for the pinned reason (four: an empty selection, a reference or `extends` outside the -selection with the `referrer → target` pairs named, and vocabulary only a consumer provider -registers). `requirement.*` and `template.*` nodes are always dropped, and the order of `files` -does not change the bytes. The manifest goldens carry the token `@@METAMODEL_VERSION@@` where +`version` / `requirements`, must produce **exactly** the pinned artifact and manifest bytes (nine +cases), or be refused for the pinned reason (six: an empty selection, a requirement alone +without `requirements`, a requirement claiming a node outside the selection, a reference or +`extends` outside the selection with the `referrer → target` pairs named, and vocabulary only a +consumer provider registers). `template.*` nodes are always dropped and `requirement.*` nodes +unless `requirements` is set, and the order of `files` does not change the bytes. The manifest goldens carry the token `@@METAMODEL_VERSION@@` where the manifest records the toolchain's `metamodelVersion`, so they do not move with it. -**TypeScript runs all 11**, in `codegen-ts/test/shared-model-conformance.test.ts`. **Python runs +**TypeScript runs all 15**, in `codegen-ts/test/shared-model-conformance.test.ts`. **Python runs the serializer arm**: for each publish case it loads `files`, takes the nodes the pinned manifest lists, and `serialize_shared_document` must reproduce the artifact byte for byte (and the sha256 the manifest records). Python has no publisher, so selection and the refusals are TypeScript's. -Java, Kotlin and C# have no runner (Phase 2). +**Java runs all 15**, in `metadata`'s `SharedModelConformanceTest` against the `SharedModel` engine +the `shared-model` generator calls; **Kotlin** runs through that same engine and Maven goals and adds +only `KotlinSharedModelGeneratorTest`. **C# runs all 15**, in `SharedModelConformanceTests`. > **ADR-0055 (deferred overlay application) — SHIPPED in every port.** The nine cases added > for it (`overlay-mixed-file-base-in-later-file`, `overlay-mixed-file-base-in-earlier-file`, @@ -634,7 +645,17 @@ Java, Kotlin and C# have no runner (Phase 2). > recorded here rather than in a ledger, because ledgering a fixture the design intends to pass > is how a port quietly stays behind. -### `fixtures/naming-conformance/` (8 cases) +### `fixtures/naming-conformance/` (8 cases + 23 collection segments) + +`collection-segments.json` (23 cases) pins the REST collection segment from an object's +`@collectionName` and the project's `naming.collections` pluralizer; every port runs it (see the +corpus README). It holds segment cases only. The collection-name clash refusal +(`ERR_COLLECTION_NAME_COLLISION`, two objects mounting one collection) is not in it: each port +gates the refusal with its own unit tests, which run the corpus's `collisionCases` pairs where +the README's runner table says so. Kotlin has no refusal of its own (the Maven goal runs the +shared JVM `RouteNaming` one before the Kotlin generators), and +`codegen-kotlin`'s `KotlinRouteNamingTest` checks it refuses a model the Kotlin facade loads, +for coinciding plurals and for a declared `@collectionName` that repeats another's segment. The pluralize cases: All 8 cases → the already-plural pluralize fix (CHANGELOG `## [Unreleased]`): an entity whose name is already a plural noun (`Stats`, `Settings`, `Series`) @@ -725,12 +746,28 @@ message. The case list, with the rule each pins, is the (`server/typescript/packages/integration-tests/cube-live/cube-model.live.ts`) loads the same files into a real Cube. +### `fixtures/explorer-conformance/` (1 case) + +The `shop` case → [features/explorer-data.md](features/explorer-data.md). Its `project/` is a +small model with inheritance, a value object, a reference, a prompt with a payload and a reply, +and a five-level requirement tree that has a resolved member claim, a dangling planned claim and a +live requirement nothing implements. `effective.json` and `verify.json` are what +`meta export --effective` and `meta verify --format json` write for it, `hashes.json` is a +hand-written manifest with node provenance, and `expected.json` is the explorer document built +from the three, compared byte for byte. + +**One port runs it:** TypeScript, in +`server/typescript/packages/docs-site/test/explorer-build.test.ts` (the builder) and +`server/typescript/packages/cli/test/explorer-fixture.test.ts` (the two committed inputs are +what the CLI writes today). The builder reads no loader, so a port that writes the same effective +JSON and verify payload feeds it unchanged. + ## Orphaned fixtures (tested but not yet documented) -The fixtures in the nine corpora mapped above (metamodel 475 + yaml 16 + verify 45 -+ render 18 + persistence 59 + api-contract 122 + source-resolution 25 + scope 10 + -dependency 37) each map to a feature doc, and so do the two requirement corpora, `shared-model-conformance` and the -`cube-model` corpus, whose case lists live in their own READMEs. None are orphaned today. The remaining +The fixtures in the nine corpora mapped above (metamodel 526 + yaml 16 + verify 45 ++ render 18 + persistence 67 + api-contract 139 + 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 corpora in the totals table gate tooling contracts (registry manifests, provider composition, agent context, docs emit) rather than user-facing metamodel behaviour, so they have no feature-doc row. diff --git a/docs/README.md b/docs/README.md index 181636b8dc..782ad18387 100644 --- a/docs/README.md +++ b/docs/README.md @@ -36,6 +36,7 @@ docs/ │ ├── extending-with-providers.md # custom metamodel subtypes/attrs via MetaDataTypeProvider │ ├── yaml-authoring.md │ ├── cli.md # CLI command matrix across all five ports +│ ├── language-differences.md # what differs by language: Node for the schema, list defaults, error bodies, names, data access │ ├── codegen-concepts.md # declarative template-codegen scopes (perEntity/perPackage/perModel) │ ├── codegen-data-shapes.md # the neutral template data dict shared cross-port │ ├── downstream-metadata-decisions.md # guidance for adopters extending the metamodel @@ -47,6 +48,8 @@ docs/ │ ├── reporting.md # dimensions, measures, segments, reports: vocabulary and load rules (FR-044) │ ├── contract-emitters.md # the contract-schema and openapi generators: JSON Schema and OpenAPI for the REST contract (FR-022) │ ├── cube-export.md # the cube-model generator: reporting vocabulary as Cube data-model files (FR-044) +│ ├── explorer-data.md # explorer.json and its inputs: export --effective, the verify ledger rows, manifest provenance +│ ├── explorer-site.md # the model explorer site docsSiteFile() builds from explorer.json │ └── own-your-codegen.md # scaffold-and-own generator ownership (ADR-0034) └── ports/ # one file per language/framework port ├── typescript.md @@ -65,6 +68,7 @@ this tree is documentation, not the source of truth. | You want to … | Read | |---|---| | Pick a language and ship a small CRUD app | [`ports/.md`](ports/) | +| Know what behaves differently per language (Node for migrations, list defaults, validation errors, field names, data access) | [`features/language-differences.md`](features/language-differences.md) | | Understand what `object.entity`, `source.rdb`, `template.prompt` mean | [`features/`](features/) | | Compare what TS vs Java vs Kotlin vs C# vs Python emit for the same metadata | any [`features/*.md`](features/) — every feature shows all five ports side-by-side | | Author metadata in YAML instead of JSON | [`features/yaml-authoring.md`](features/yaml-authoring.md) | @@ -78,6 +82,8 @@ this tree is documentation, not the source of truth. | Keep Prisma as the ORM, with `schema.prisma` generated from the model and gated by `verify` (TypeScript) | [`recipes/prisma.md`](recipes/prisma.md) | | Publish the API as JSON Schema or OpenAPI, and check a change against the last release | [`features/contract-emitters.md`](features/contract-emitters.md), [`recipes/check-api-against-last-release.md`](recipes/check-api-against-last-release.md) | | Export the reporting vocabulary to Cube (`cube-model`: cubes, joins, rollups; the `cube` lane that checks it against a real Cube) | [`features/cube-export.md`](features/cube-export.md) | +| Build the data a model explorer reads (`explorer.json` from `meta export --effective`, `meta verify --format json` and the generated-file manifest) | [`features/explorer-data.md`](features/explorer-data.md) | +| Build the model explorer site: what the software does, the model map, requirement pages, the matrix, trace and gaps (`docsSiteFile()`) | [`features/explorer-site.md`](features/explorer-site.md) | | Wire prompt construction (FR-004) | [`features/templates-and-payloads.md`](features/templates-and-payloads.md) | | Share a metadata shape across multiple instances (abstracts, `extends:`) | [`features/abstracts-and-inheritance.md`](features/abstracts-and-inheritance.md) | | Add a custom metamodel subtype or attribute to a downstream project | [`features/extending-with-providers.md`](features/extending-with-providers.md) + [`recipes/extending-metaobjects-with-providers.md`](recipes/extending-metaobjects-with-providers.md) | diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 7777563dd3..7f824c5798 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -49,6 +49,21 @@ Decide explicitly for every branch the scan returns: merge it into this cut, or Note that `no-mistakes/*` branches are usually gate replays of work already on `main` — confirm rather than assume. Do not skip past the list. +**The previous maintenance branch is on `main` (minor and major cuts).** Before a minor or +major is cut, every commit on the previous `release/.` maintenance branch must be +an ancestor of `main`. Otherwise a fix shipped as a patch from that branch is missing from the +new line. Check it by hand while writing the CHANGELOG: + +```bash +git fetch origin -q +git merge-base --is-ancestor origin/release/. origin/main && echo merged || git log --oneline origin/main..origin/release/. +``` + +`scripts/release.mjs` enforces it in its preflight: cutting `X.Y.0` (or an RC of it) is refused +while the highest `release/.` below `X.Y` on origin holds a commit `HEAD` does not. A patch +is not gated. To clear it, merge the maintenance branch into `main` by PR (see "Then bring the +branch to `main`" in the maintenance-branch section). + **The eject pending list (1.1.0).** 1.1.0 does not ship while `fixtures/generator-registry-conformance/registry.json` has an entry in `eject.pending` (ADR-0034 Amendment 8). The scripted paths enforce it: `scripts/release.mjs` (first check of @@ -268,7 +283,7 @@ what they render is generator output and does not.) | Codegen **ENGINE** public surface **additive** (new `render*` primitive, new `GenContext` field, optional param) | new `render*` primitive | PATCH (MINOR if it headlines a feature release) | MINOR | | Codegen **ENGINE** public surface **breaking**, or changed **CLI semantics** | `relativeModuleSpecifier` +required param | **MINOR** | MAJOR | | A **runtime library**'s public surface (`runtime-ts`, `render`, OMDB, ObjectManager, web client) — additive / breaking | a new mount option / a removed export | PATCH / **MINOR** | MINOR / MAJOR | -| New **attribute** on an existing type/subtype | `@intValueMap`, `@lenient`, `@maxTokens` | **PATCH** | MINOR | +| New **attribute** on an existing type/subtype | `@intValueMap`, `@lenient`, `@maxTokens` | **PATCH** | **PATCH** | | New **subtype** of an existing type | `field.uri`, `index.lookup`, `attr.intMap` | **PATCH** when inert (see the vocabulary rule below); **MINOR** when it changes existing metadata's meaning/output, narrows something previously permitted, or headlines a feature | MINOR | | New top-level metadata **type** | `requirement.*`, `index.*`, `api.*` | **MINOR** | MINOR | | **Breaking** metamodel-vocabulary change (retire an attr/subtype/type; narrow what is permitted) | FR-037 `@readOnly`, FR-038 `@verifiedBy`, ADR-0052 `@promptStyle` re-homing | **MINOR** (pre-1.0 MINOR *is* the breaking slot) | **`metamodelVersion` MAJOR**, package MINOR (ADR-0035 Am. 2) | @@ -653,9 +668,12 @@ published, any version older than the newest release tag, and any release candid version that has already shipped (npm sorts it below the full release; resolved the same way the site deploy resolves its tag). It offers no non-`latest` dist-tag path. -**Then bring the fix to `main`.** A maintenance branch is never merged back wholesale (its -version bumps and CHANGELOG would collide with `main`'s). Cherry-pick or re-land each fix on -`main` by PR. +**Then bring the branch to `main`.** Re-land each fix on `main` by PR as soon as it ships. +Before the next minor or major is cut, also merge the maintenance branch itself into `main` by +PR, resolving its version bumps, site payload and CHANGELOG in `main`'s favour, so that every +commit on it is an ancestor of `main`. Step 0 checks this and `release.mjs` refuses the cut +until it holds; a fix that exists only on the maintenance branch would otherwise be missing +from the new line. ## Isolated patch (one package) diff --git a/docs/features/adopting-existing-models.md b/docs/features/adopting-existing-models.md index 1c36fe6fe4..c4412e9e75 100644 --- a/docs/features/adopting-existing-models.md +++ b/docs/features/adopting-existing-models.md @@ -76,7 +76,7 @@ import { defineConfig } from "@metaobjectsdev/cli"; export default defineConfig({ outDir: "src/generated", // beside the existing code; nothing imports it yet - outputLayout: "flat", // the paths below; the default puts each metadata package in a directory of its own + outputLayout: "flat", // the paths below; "package" puts each metadata package in a directory of its own dialect: "postgres", timestampMode: "date", // when the existing timestamp columns read as Date generators: ["entity"], @@ -169,7 +169,7 @@ import { entityFile } from "@metaobjectsdev/codegen-ts/generators"; export default defineConfig({ outDir: "src/generated", - outputLayout: "flat", // the paths below; the default puts each metadata package in a directory of its own + outputLayout: "flat", // the paths below; "package" puts each metadata package in a directory of its own dialect: "postgres", targets: { contract: { outDir: "src/generated", runtime: false }, // Zod schemas and types, no ORM diff --git a/docs/features/api-contract.md b/docs/features/api-contract.md index 4f3f91f9f3..0cddbe6ee5 100644 --- a/docs/features/api-contract.md +++ b/docs/features/api-contract.md @@ -91,7 +91,10 @@ every field. The TS mounts can restrict the update to one verb with `` is the **entity name** `snake_case`d and then pluralized. One rule, the same in all five ports, and derived from the NAME — never from the physical -`@table`: +`@table`. An object that declares `@collectionName` (or a project that configures +`naming.collections`) names its segment instead, in every port; the rule and what +each port names with it live in +[physical-naming.md](migrations/physical-naming.md#collection-names). | Name | Segment | Why | |---|---|---| @@ -215,7 +218,8 @@ or Hono `onError` the adopter installed, answer exactly as they did before. | Response | When | |---|---| | malformed JSON body | a `POST`/`PATCH`/`PUT` body that does not parse as JSON (an empty body sent as `application/json` included) → HTTP 400 `{ "error": "invalid_json" }`. An EMPTY body on a method that takes none (`GET`, `DELETE`, `HEAD`) is accepted even when the request declares `content-type: application/json`, as many clients do on every request; a non-empty `DELETE` body is still parsed. Before, Fastify answered its own `{ "statusCode": 400, "code": "FST_ERR_CTP_INVALID_JSON_BODY", … }` and Hono a Zod `validation` error about a missing object | -| malformed page bound | a `?limit=` or `?offset=` that is not a non-negative integer (`abc`, `-5`, `1.5`, an empty value) → HTTP 400 `{ "error": "pagination.invalid_value", "param": "limit", "value": "abc", "expected": "a non-negative integer (0 or more)" }`. Before, a non-numeric bound was dropped (every row came back) and a negative or fractional one reached SQL. There is no page-size maximum on an entity or a projection with declared columns; an opaque view (no declared columns, served by raw SQL) pages to at most 1000 rows, so there a `limit` above 1000 is refused too, with `"expected": "an integer from 0 to 1000"` (it used to be clamped silently). The same answer comes from the Drizzle mounts and the ObjectManager Fastify mount. The corpus sends a malformed bound only to a report (`report/bad-page-bound`), where every port answers this same envelope and also refuses `limit=0`; on an entity or a projection the other ports answer it as their framework does | +| malformed id | a `:id` the key column cannot hold (a malformed uuid on a Postgres uuid key, a non-numeric id on an integer key) → HTTP 400 `{ "error": "invalid_id" }` on GET, PATCH and DELETE. A malformed uuid in a POST or PATCH body's foreign key → HTTP 400 `{ "error": "validation" }`, from the insert/update schema's `8-4-4-4-12` hex check. Postgres used to answer 500 for both. The check is TS-only | +| malformed page bound | a `?limit=` or `?offset=` that is not a non-negative integer (`abc`, `-5`, `1.5`, an empty value) → HTTP 400 `{ "error": "pagination.invalid_value", "param": "limit", "value": "abc", "expected": "a non-negative integer (0 or more)" }`. Before, a non-numeric bound was dropped (every row came back) and a negative or fractional one reached SQL. An entity or a projection with declared columns has no page-size maximum unless the project sets `api.pagination` (see "A page size is a project setting" below, which answers `limit_too_large`); an opaque view (no declared columns, served by raw SQL) pages to at most 1000 rows, so there a `limit` above 1000 is refused too, with `"expected": "an integer from 0 to 1000"` (it used to be clamped silently). The same answer comes from the Drizzle mounts and the ObjectManager Fastify mount. The corpus sends a malformed bound only to a report (`report/bad-page-bound`), where every port answers this same envelope and also refuses `limit=0`; on an entity or a projection the other ports answer it as their framework does | | database constraint violation | a write the database itself rejects → `{ "error": "constraint_violation", "constraint": "" }`, HTTP **409** for `unique` and `foreign_key` (a conflict with another row) and HTTP **400** for `check` and `not_null` (the request's own value), per the status rule under "Error response". The body names the constraint KIND only — never the SQL, the table or the bound values. A `CHECK` the model derives (an enum, a `validator.numeric`/`length`/`regex` range) is normally refused earlier by the route's own validation, as the corpus's `{ "error": "validation" }` 400; this row is the database's backstop | | schema validation failure | a body that fails the insert/update schema → HTTP 400 `{ "error": "validation", "issues": [...] }`, each issue as Zod reports it **minus `pattern`**: Zod 4 attaches a failed `.regex()` check's source there, which for a generated `field.date` / `field.time` / `field.timestamp` check is a ~300-character calendar regex (and an authored `validator.regex` pattern is the server's to keep). The generated temporal checks carry a short `message` naming the expected format instead (`"must be an ISO date (YYYY-MM-DD)"`) | | unexpected server error | anything that is not a filter, validation, not-found or constraint answer — a query against a column the database no longer has, a driver failure → HTTP 500 `{ "error": "internal" }`, the code the cross-port reference servers already use. The body names no SQL, table, column or bound parameter; the full error goes to the server log (`console.error`). Before, Fastify's default handler echoed the driver message, which for Drizzle is the query text and its parameter values | @@ -270,17 +274,46 @@ each handler they register instead; an `HTTPException` is rethrown to your - **A report list can be exported: `?format=csv|json|xml`.** See [Report export](#report-export) below. Without `format` the response is byte-identical to the list route described here. -- **No page-size maximum on an entity, and the default is per port.** The contract pins what - an explicit `limit`/`offset` returns (`list-with-pagination`); it does not pin a - default or a ceiling, and the ports differ. With `limit` **omitted**, the - TypeScript mounts and the C# routes return **every** matching row, while the - Java, Kotlin and Python controllers return the first **50**. No port caps an - explicit `limit` on an entity — `limit=100000` is honoured as asked — except - the TS opaque-view route, which refuses a `limit` above 1000 (see "TS-only - error responses"). A list over a large table should therefore always send a - `limit`. A default page size is deliberately not introduced in a patch release: - it would silently truncate the lists of every existing client that relies on - the unpaged answer. +- **A page size is a project setting: `api.pagination`.** In `.metaobjects/config.json`: + + ```json + { "api": { "pagination": { "defaultLimit": 50, "maxLimit": 1000 } } } + ``` + + With it set, a generated entity or projection list with `limit` **omitted** answers the first + `defaultLimit` rows, and an explicit `limit` above `maxLimit` answers + `400 { "error": "limit_too_large", "maxLimit": N }`. The request is refused, not clamped: + a client that asked for more than the server serves is told so rather than handed a short page + it cannot tell from the end of the list. A negative `limit` answers the malformed-bound + envelope above (`pagination.invalid_value`) in every port, so it never reaches a store that + reads `LIMIT -1` as no limit (SQLite). The generated C# routes also answer that envelope for a + `limit` or `offset` that is present but not a whole number (`limit=abc`, `offset=x`) instead of + serving the default page; TypeScript does the same, Java and Kotlin answer Spring's type-mismatch + 400 and Python FastAPI's 422, so the corpus pins only the negative limit. + `limit=0` is a page of zero rows, not "no limit" (`api-settings/limit-zero`). `offset` and `withCount=1` page past the default as + usual, with `total` counting every row. `meta init` writes the block above for a new project; + both sizes must be positive whole numbers (`50.0` reads as `50`) no larger than 2147483647, and + `defaultLimit` may not exceed `maxLimit`; a block that breaks a rule is refused when the config + is read, in every port (shared cases: `api-settings/config-blocks.json`). A report + keeps its own row cap (above) and an opaque view its 1000, whatever the setting says. An M:N + traversal route (`GET //{id}/`) takes no `limit` or `offset` in any port + and is not paged by the setting: it answers the whole related set, as it always has. + + **Without the setting nothing changes, and the default is per port.** With `limit` omitted, + the TypeScript mounts and the C# routes return **every** matching row, while the Java, Kotlin + and Python controllers return the first **50**, and no port caps an explicit `limit` on an + entity (`limit=100000` is honoured as asked). That is the behaviour every existing project + has, so the setting is opt-in: adding a cap on upgrade would silently truncate a client that + reads a whole list. Each port's verify advises (rule `unbounded-list-pages`, never a failure) + when a routes generator is wired and the project sets no page size: `meta verify`, + `metaobjects verify`, `mvn metaobjects:verify` (Java and Kotlin) and `dotnet meta verify + --codegen` (C# knows its generator list only when it runs it). + + **Every port reads it:** the TypeScript Fastify and Hono routes, the C# minimal-API routes, the + Java and Kotlin Spring controllers and the Python FastAPI routers, packaged and ejected (an owned + copy picks it up when it is re-ejected). `fixtures/api-contract-conformance/api-settings/` pins + it in the generated lane of every port. Every per-port difference of this kind is collected in + [What differs by language](language-differences.md). - `withCount=1` — opt-in flag that switches the list response from `[...]` to `{ rows: [...], total: }` (needed for grid pagination). The grid hook always sends `withCount=1`. @@ -405,7 +438,7 @@ for the one-line change. | `field.timestamp` (`@localTime: true`) | string | Naive wall clock — `YYYY-MM-DDTHH:MM:SS[.fff]`, **no `Z`**. | | `field.currency` | **integer minor units** | Cents for USD, yen for JPY. Float arithmetic is forbidden. Server never formats. | | `field.object` (`@storage: jsonb`) | object | Nested per the sub-object schema. A null member is written per [the wire setting](#the-wire-setting) (`nullMembers`). | -| `field.object` (`@storage: flattened`) | object | Same JSON shape — only the storage differs. | +| `field.object` (`@storage: flattened`) | object | Same JSON shape in the contract — only the storage differs. The TypeScript generator exposes the members as flat keys instead (`shipToStreet`); see [field-types.md](field-types.md#what-each-port-generates). | The currency invariant is the load-bearing one: every port emits and expects integer minor units on the wire, and the @@ -431,24 +464,24 @@ compares equal: ### The wire setting -What a generated API writes for a decimal and for a value object's null member is a project +What a generated API writes for a decimal, a duration and a value object's null member is a project setting, `wire` in `.metaobjects/config.json`, read by every port's codegen the way `naming` is ([ADR-0019 Amendment 2](../../spec/decisions/ADR-0019-runtime-return-type-contract.md)): ```json -{ "schema_version": 1, "wire": { "decimals": "native", "nullMembers": "native" } } +{ "schema_version": 1, "wire": { "decimals": "native", "nullMembers": "native", "durations": "native" } } ``` -Both keys default to `native`: **each port writes what its language's standard serializer +Every key defaults to `native`: **each port writes what its language's standard serializer writes**, so a C# API looks like a C# API and a Python API like a Python API. Identical output across ports is something you opt into: ```json -{ "schema_version": 1, "wire": { "decimals": "string", "nullMembers": "omit" } } +{ "schema_version": 1, "wire": { "decimals": "string", "nullMembers": "omit", "durations": "iso" } } ``` -That is the form 1.1.0 and 1.1.1 wrote, and the form the cross-port conformance corpora pin in -their own config. Choose it when clients written in several languages share one contract, or when +For decimals and null members that is the form 1.1.0 and 1.1.1 wrote, and it is the form the +cross-port conformance corpora pin in their own config. Choose it when clients written in several languages share one contract, or when a browser client must read a decimal exactly: `JSON.parse` turns a JSON number into a double before your code sees it. @@ -466,6 +499,20 @@ before your code sees it. exactly. - `nullMembers` covers the members of an `object.value` only, and so also the jsonb that a typed serializer writes. A top-level entity field that is null is always written as `null`. +- `durations` covers `field.duration` in a request and response body, both ways: + +| Port | `durations: native` (default) | `durations: iso` | +|---|---|---| +| C# | System.Text.Json's `TimeSpan` form, both ways: `"01:30:00"`, `"1.02:00:00"`, `"-00:01:30"` | the canonical ISO-8601 form: `"PT1H30M"`, `"PT26H"`, `"-PT1M30S"` | +| Java | `Duration.toString()` and `Duration.parse`, as Spring Boot configures Jackson (`WRITE_DURATIONS_AS_TIMESTAMPS` off): `"PT1H30M"`, `"PT26H"`, `"PT-1M-30S"` | the canonical form | +| Kotlin | same as Java | the canonical form | +| Python | ISO-8601 as Pydantic v2 writes a `timedelta`, which folds 24 hours into a day: `"PT1H30M"`, `"P1DT2H"`, `"-PT1M30S"`; it also reads `"01:30:00"` | the canonical form | +| TypeScript | the canonical form: a duration is a `string` in TypeScript, so there is no other standard spelling | the canonical form | + + A filter operand (`?filter[timeout][gt]=PT1H`) is an ISO-8601 duration in every mode, because it + is the query grammar, not the body serializer. The canonical form and the accepted one are in + [`fixtures/duration-wire/`](../../fixtures/duration-wire/). Choose `iso` when clients written in + several languages share one contract. - There is no `"number"` value for `decimals`. In C#, Java and Kotlin, `native` already is a number; in Python and TypeScript, a number would be a lossy spelling those languages do not use. @@ -490,6 +537,40 @@ Non-2xx responses MUST return: - HTTP 5xx — implementation-defined (the TS mount helpers answer `{ "error": "internal" }` and nothing more — see "TS-only error responses"). +#### A validation error lists every issue + +A body that fails the create or update rules answers HTTP 400 with every problem, not the first +one, in one shape in every port: + +```json +{ + "error": "validation", + "issues": [ + { "code": "too_big", "path": ["name"], "message": "..." }, + { "code": "invalid_type", "path": ["createdAt"], "message": "..." } + ] +} +``` + +- `path` is the field's location as an array of keys (a value-object member is + `["address", "city"]`). +- `code` uses Zod's names, the vocabulary TypeScript already reported: `invalid_type` (a missing + required field, an explicit `null` on one, or a value of the wrong type), `too_small` / + `too_big` (a length, size or numeric range), `invalid_format` (a pattern, an email, a date + shape), `invalid_value` (a value outside an enum), and `custom` for anything else (a + class-level rule, for instance). A port whose validator reports a finer failure may use another + Zod name for it (`not_multiple_of`, `unrecognized_keys`, `invalid_union`); a client that does not + know a code should treat it as `custom`. +- `message` is the port's own wording and is not part of the contract. +- A port may add keys to an issue (TypeScript keeps Zod's `minimum`, `maximum`, `origin` and so + on, minus `pattern`; see "TS-only error responses"), and a client must ignore keys it does not + know. + +Before 1.3.0 only TypeScript listed issues; the C#, Java, Kotlin and Python routes answered a +bare `{ "error": "validation" }`. The corpus pins the list in `validation-lists-issues` and +`tph/tph-validation-lists-issues` (two failing fields on a create, and on a PATCH an explicit +null on a required field beside an over-long value), in both lanes. + #### Filter and sort errors name the field These four codes are a hard cross-port invariant, and each one MUST carry @@ -544,6 +625,63 @@ set (`@mutability: writeOnce` on PATCH, the TPH discriminator, `@autoSet: onCrea a generated edit form submits every field it was given, so a `400` would fail every save. A required field that is also ignored can never be created through the API, so mark such a field optional. +The same rule covers every key a client never sets, in every port, on the plain and the TPH per-subtype +routes: + +| Key in the body | Create | PATCH, PUT | +|---|---|---| +| a server-generated primary key (`@generation`) | dropped | dropped (the URL names the row) | +| an assigned primary key | **kept** (the caller chooses it) | dropped (the URL names the row) | +| `@mutability: readOnly`, a derived field | dropped | dropped | +| `@mutability: writeOnce` | kept | dropped | +| the TPH discriminator | dropped (the route's subtype is its only source) | dropped | +| a column only a sibling TPH subtype declares | dropped | dropped | + +None of these is a `400`, and none reaches the repository. Each port does it in its own idiom: TypeScript +parses with the Zod input schema (which drops keys it does not list) and writes the parsed value; Python keeps only +the keys its input model validated; Java nulls the dropped components of the bound DTO before +`repository.create` and its request-body DTOs carry `@JsonIgnoreProperties(ignoreUnknown = true)`, so the answer does not +depend on the host's `ObjectMapper`; Kotlin writes only the route's settable columns; C# resets the bound +entity's generated key, TPH discriminator and M:N navigations before `Add`, and gives a `readOnly` property +a private setter, which System.Text.Json never binds. The shared scenarios `input-server-owned-dropped` and +`tph/tph-input-server-owned-dropped` pin it, and `secret-fields/` pins a `readOnly` column beside the +credential. + +### Unknown request fields: `api.unknownFields` + +A key the entity does **not** declare is a different case, and a project setting decides it. In +`.metaobjects/config.json`: + +```json +{ "api": { "unknownFields": "reject" } } +``` + +- **`reject`, the default** (also when the key is absent). A create, PUT or PATCH body with any + undeclared top-level key answers `400 { "error": "unknown_fields", "fields": ["isAdmin", "role"] }`, + the keys sorted, and nothing is written. The check runs before validation, so a body that is both + misspelled and invalid is told about the spelling first. +- **`drop`.** Undeclared keys are ignored and the rest of the body is written, which is what every + port did before 1.3. + +A key is undeclared when no field of the entity has that name; on a TPH subtype's routes, when no +field of the base or of any subtype has it. Every key in the table above is declared, so it is +**dropped, not refused, under either value**: a client that sends back a row it read (with its `id`, +its `@autoSet` stamps and its `writeOnce` field) keeps working, and a sibling subtype's column on +another subtype's route is dropped. Only the top level is checked; a value object's members are +validated as before, and a member a value object does not declare is dropped silently, never +refused and never stored, on create and on PATCH (`jsonb/jsonb-nested-undeclared-key-dropped`, +both lanes of every port). The open JSON bag keeps every key. A key is matched the way the port +binds it: the C# routes bind with the app's System.Text.Json options, whose ASP.NET web default +ignores case, so there `Title` is the declared `title`, not an unknown key; the other ports +match the exact name. `meta init` writes `"unknownFields": "reject"` for a new project. + +Each port checks the raw body before it binds it, so the answer is the same whatever the host +framework would do with an unknown property: Java and Kotlin read the keys from the request's JSON +tree, not from Jackson's binding, and answer identically with `FAIL_ON_UNKNOWN_PROPERTIES` on or +off. The shared scenarios `input-unknown-fields-rejected` and `tph/tph-unknown-fields-rejected` +pin `reject` in both lanes of every port, and `api-settings/unknown-fields-dropped` pins `drop` in +the generated lane. + Only the generated HTTP boundary changes. The entity, its DTO and the generated queries still carry the field, so your own code writes a hash or token and reads it back. Allowlists are unchanged: a field is filterable or sortable only if you wrote `@filterable` or `@sortable` on it, so do not put those on a credential @@ -557,6 +695,16 @@ returns the column, its `report-export` output has no column for it, and it is n `fixtures/api-contract-conformance/secret-fields/` pins this in the generated lane of every port. +## Defaults on create + +A create body may leave out a field that declares a literal `@default` (an enum member, a boolean, a +number, a string). The stored row then holds the default, never `null` and never the type's zero value. +Java and Kotlin fill it in the generated handler; TypeScript, C# and Python leave the column out of the +INSERT, so the column default that `meta migrate` writes applies. A value the body does supply is +kept. + +`fixtures/api-contract-conformance/enum-default/` pins this for an enum in the generated lane of every port. + ## Read-only projections **All five ports serve an `object.projection` whose only source is a read-only @@ -816,6 +964,8 @@ api-contract-conformance suite today (see ## See also +- [`docs/features/language-differences.md`](language-differences.md) — what this + contract leaves open, port by port (list defaults, error bodies, filter extensions) - [`docs/features/metadata-api.md`](metadata-api.md) — the `GET /_meta` model-shape contract this page's row-data contract complements - [`docs/features/loaders.md`](loaders.md) — how metadata maps to the diff --git a/docs/features/cli.md b/docs/features/cli.md index e85fdcee48..35f4a755d4 100644 --- a/docs/features/cli.md +++ b/docs/features/cli.md @@ -25,20 +25,21 @@ command surface splits in two: | Capability | Tool | Invocation | Notes | |---|---|---|---| -| Project scaffold (`init`) | Node `meta` | `meta init` | TS projects | +| Project scaffold (`init`) | Node `meta` | `meta init` | TS projects; `--dialect sqlite\|postgres\|mysql\|d1` writes the codegen `dialect` in `metaobjects.config.ts` and, for sqlite, postgres and d1, `migrate.dialect` in `.metaobjects/config.json` (d1 is `--d1`; MySQL schema is not `meta migrate`'s). A new `.metaobjects/config.json` also carries `"api": { "pagination": { "defaultLimit": 50, "maxLimit": 1000 }, "unknownFields": "reject" }`, the generated list routes' page size and the refusal of undeclared write keys ([api-contract.md](api-contract.md)); `--force` over an existing config does not add it | | **Agent-context scaffold** (`agent-docs`) | **Node `meta`** | `npx meta agent-docs --server ` | **any backend** — single assembler (ADR-0033); non-Node CLIs redirect here | | **Schema migrate** | **Node `meta`** | `meta migrate` | **any backend** — schema is Node-only (ADR-0015) | | **Schema drift** (`verify --db`) | **Node `meta`** | `meta verify --db` | **any backend** — live-DB drift, Node-only | | **Codegen drift** (`verify --codegen`) | **Node `meta`** | `meta verify --codegen` | TS reference (ADR-0021 D2) — regen-to-temp + diff committed output | | **Template/prompt drift** (`verify --templates`) | **Node `meta`** | `meta verify --templates` | TS reference (ADR-0021 D2) — `{{field}}`↔payload; part of the bare-`verify` default | | **Vocabulary upgrade** (`upgrade`) | **Node `meta`** | `meta upgrade [--to ] [--apply]` | **any backend** — rewrites RETIRED metadata vocabulary (`@violation` → `@counterexample`, `@readOnly` → `@mutability`, dropping `@verifiedBy`) and resolves ATTRIBUTE CONTRADICTIONS (`@fields` beside `@expr` on an index key). Node-only because it edits the metadata documents themselves, which every port shares; a non-TS project runs `npx meta upgrade` against its own `metaobjects/`. **Canonical JSON and YAML alike.** Previews by default. Retirements needing a human decision are refused and the run exits non-zero, so CI cannot record a partial migration as finished | +| **Model export** (`export`) | **Node `meta`** | `meta export [--effective] [--out ]` | the loaded model, overlays merged, as one canonical JSON document. `--effective` also writes every inherited field, child and attribute onto the node that inherits it, which is the input the [explorer builder](explorer-data.md) reads. The output is for reading: loading an effective document back would declare each inherited member twice | | **Vocabulary search** (`types`) | **Node `meta`** | `meta types [query]` | **any backend** — apropos/`kubectl explain` over the live metamodel registry (names + descriptions + when-to-use); the vocabulary is cross-port identical (registry-conformance) | -| **Dependency sync** (`deps`) | **Node `meta`** | `meta deps sync \| check \| list` | **any backend** — resolves a declared metadata dependency (`path`, or an installed `npm` / `python` package) into a committed snapshot + lock (FR-023), so `sync`/`check`/`list` themselves stay Node-only regardless of your server language. TypeScript, Python and Java then LOAD that snapshot at every rung of their own source ladder (Kotlin loads through Java's loader and Maven plugin); C# loads the snapshot through `dotnet meta` (Phase 2 S6). On a project whose own metadata Node `meta` cannot read (a Maven `src/main/resources/metadata` directory, a C# metadata directory, or another port's vocabulary), `sync` and `check` prove the locked dependencies load together and say that the port's own `verify` is the full check. See [`metadata-dependencies.md`](metadata-dependencies.md) | +| **Dependency sync** (`deps`) | **Node `meta`** | `meta deps sync \| check \| list` | **any backend** — resolves a declared metadata dependency (`path`, an installed `npm` / `python` package, or a `maven` jar / `nuget` package already in the local Maven repository / NuGet cache; it never downloads) into a committed snapshot + lock (FR-023), so `sync`/`check`/`list` themselves stay Node-only regardless of your server language. TypeScript, Python and Java then LOAD that snapshot at every rung of their own source ladder (Kotlin loads through Java's loader and Maven plugin); C# loads the snapshot through `dotnet meta` (Phase 2 S6). On a project whose own metadata Node `meta` cannot read (a Maven `src/main/resources/metadata` directory, a C# metadata directory, or another port's vocabulary), `sync` and `check` prove the locked dependencies load together and say that the port's own `verify` is the full check. See [`metadata-dependencies.md`](metadata-dependencies.md) | | **Canonical format** (`fmt`) | every port | `meta fmt` / `dotnet meta fmt` / `mvn metaobjects:fmt` / `metaobjects fmt` | (#304) ships in **every** port — the canonical serializer already exists in all five, so formatting is local, not Node-only. `--check` lists non-canonical files and exits non-zero without changing anything. Formats each file STANDALONE — own-mode, declared-here layer only (ADR-0039); an `extends` onto another file's base is preserved as-is, never resolved or erred on; a file declaring `overlay: true` anywhere — whether or not a same-file base exists — is reported as skipped rather than merged (merging would drop the overlay marker, a structural change fmt never makes). A YAML file is always skipped — no canonical YAML emitter exists (ADR-0006). Before writing, every port reloads the whole project with the candidate swapped in and refuses the write unless the reloaded model's canonical form is byte-identical to the untouched baseline — fmt never changes meaning. See [Fixture corpus](#meta-fmt--canonical-formatting-304) below and `fixtures/fmt-conformance/README.md` | | TS codegen | Node `meta` | `meta gen` | TS projects. **No `--template-spec` flag, deliberately** — `metaobjects.config.ts` already takes generator VALUES, so a declarative template generator is declared there (`templateGenerator()`, or `templateSpecToGenerators(parseTemplateSpec(spec))` to reuse a C#/Python spec file). Keeping it in the config is what lets `meta verify --codegen` regenerate WITH it, since that gate re-runs the config's generator list; see [declarative template scopes](codegen-concepts.md#declarative-template-scopes) | | C# codegen | `dotnet meta` | `dotnet meta init` / `gen` / `verify --templates` / `verify --codegen` | a .NET tool (`ToolCommandName=dotnet-meta`); invoked `dotnet meta` so it never shadows the Node `meta`; ships the ADR-0021 D2 subverbs (`--db` rejected, exit 2; bare `verify` = `--templates` plus `--codegen` when an output directory (`csharp.outDir` in `.metaobjects/config.json`, or `--out`) and `codegen/Generators.cs` are present). **The generator list is `codegen/Generators.cs`** (ADR-0034 Amendment 9): `dotnet meta init` writes it with `codegen/Program.cs` (two lines that run it) and `codegen/Codegen.csproj`, and `gen` / `verify --codegen` always run it through `dotnet run --project codegen`. With no `codegen/Generators.cs` they exit 2 and write nothing; `--generators` only narrows the list to declared entries. Every entry may set its own output directory (`ApiDocsGenerator { OutDir = ... }`), and `verify --codegen` compares each one. A declarative Mustache template-spec (the cross-port JSON contract shared with Python) is one more entry, `TemplateSpecGenerator { Spec = "", TemplateRoot = "" }`; `gen` no longer reads `--template-spec` or a project-root `template-spec.json`, and a run that finds either with no such entry fails before writing anything; see [declarative template scopes](codegen-concepts.md#declarative-template-scopes). `dotnet meta docs` was removed in 1.1.0: it prints the line that points at [the migration section](migrations/docs-are-generators.md#c) and exits 2 | | Java/Kotlin codegen | Maven plugin | `mvn metaobjects:generate` (`metaobjects:generate`) | Kotlin generators run through the same goal — see below. **No `--template-spec` flag, deliberately** — `` already loads a consumer class from the project classpath, so the declarative surface is `com.metaobjects.generator.template.TemplateScopeGenerator` wired as an ordinary `` with `