diff --git a/.claude/rules/cross-language-porting.md b/.claude/rules/cross-language-porting.md index 4966f27c3b..685d923a42 100644 --- a/.claude/rules/cross-language-porting.md +++ b/.claude/rules/cross-language-porting.md @@ -31,7 +31,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; 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`). +- 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, C#, Java (OMDB) and Kotlin (Exposed) persist it on every engine, Python on Postgres only; 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/CHANGELOG.md b/CHANGELOG.md index db97cda069..560d541db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -288,6 +288,13 @@ Each item below is described in full under Security, Added, Changed or Fixed; th ### Added +- **Java and Kotlin: `mvn metaobjects:init`.** The Maven plugin now has the scaffold goal the other + ports have. It writes `.metaobjects/config.json` (the new-project settings every port's init + writes) and an empty, loadable `metaobjects/meta.app.json`, each only when missing, and prints the + `` entry to add to the pom with an empty ``: codegen stays opt-in + (ADR-0034 Amendment 2). `-Dmeta.init.withDocs=true` adds the api reference generator to that + printed entry. It never edits the pom. + - **The hash manifest is one file per package (ADR-0064 Amendment 1).** Every port that keeps hash state, TypeScript, C#, Java, Kotlin, Python and Rust, writes `.gen-state/.hashes/.json` instead of one `.gen-state/.hashes.json`. The file name is the package's `::` segments joined with @@ -628,10 +635,12 @@ Each item below is described in full under Security, Added, Changed or Fixed; th 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. + - Java: OMDB stores an int-backed enum array as a native `integer[]` on Postgres and a JSON array + of numbers on SQLite, MySQL and Derby; a member with no declared integer is refused on write, + and a stored integer with no member fails the read. Kotlin: the Exposed table generator emits an + integer array column for it (`portableIntEnumArray`, in a `MetaIntEnumArrayColumnType.kt` support + file written only into a package that has such a column), where it used to emit a scalar column + that did not compile. The new scenario runs in both. Gated by the positive conformance fixtures `enum-int-backed-array` and `enum-int-backed-array-inherited`, and the persistence scenario `roundtrip-int-enum-array`. @@ -2008,6 +2017,20 @@ Each item below is described in full under Security, Added, Changed or Fixed; th only a view can hold (a cast, a function other than `coalesce`, a dotted path). Python-written models are unaffected unless they used these nodes, which never loaded. +- **The Java and Kotlin loader accepts every view function and cast, not only `coalesce`.** Java + validated only `coalesce` inside a computed expression, so a model using `cast`, `lower`, + `concat`, `substring` and the rest of the function set, an `origin.function`, `@union` / + `@grain`, or a correlated filter that walks a reference was refused by the JVM ports while + TypeScript and C# loaded it. The Java loader now checks them the way TypeScript does (the + function arities and parameter kinds, the cast legality table, an int-stored enum cast, the + `dbColumnType` text spellings). The five conformance fixtures the Java ledger excused now + pass and its list is empty. No Java generator lowers these nodes to a view yet. +- **Quoted number-like text keeps its quotes in the Java loader.** A quoted value such as + `"007"` or `"true"` on a string attribute (`column: "007"`) was read as the integer `7` or the + boolean, so the canonical output differed from every other port. Quoted text is text; only an + unquoted number or boolean is inferred. The `yaml-quoted-leading-zero` fixture passes in Java + and the YAML ledger is empty. + - **A credential is never filterable or sortable, in every port.** A field that declares a `view.password` and that a model also marked `@filterable` or `@sortable` was on the generated filter and sort allowlists, so a client could learn its value by probing (`filter[pinHash][eq]=...`, diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index 9aabdda1cd..c05c5d10c8 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -27,7 +27,7 @@ regenerate with `ls -d fixtures//*/ | wc -l` for directory-shaped corpor | Corpus | Fixtures | TS | Java | Kotlin | C# | Python | |---|---|---|---|---|---|---| | [`fixtures/conformance/`](../fixtures/conformance/) (metamodel) | 578 | ✓ | ✓ | inherits via `metadata-ktx` | ✓ | ✓ | -| [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 19 | 19 / 19 | 18 / 19 (1 ledgered: `yaml-quoted-leading-zero` — Java pipeline strips quotes off `"007"`) | inherits via Java | 18 / 19 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 19 / 19 | +| [`fixtures/yaml-conformance/`](../fixtures/yaml-conformance/) | 19 | 19 / 19 | 19 / 19 | inherits via Java | 18 / 19 (1 ledgered: `error-yaml-coerced-hex-in-string` — YamlDotNet doesn't coerce `0xFF`) | 19 / 19 | | [`fixtures/verify-conformance/`](../fixtures/verify-conformance/) | 45 | ✓ | ✓ | inherits via Java | ✓ | ✓ | | [`fixtures/verify-strict-conformance/`](../fixtures/verify-strict-conformance/) | 1 | ✓ | — | — | — | ✓ | | [`fixtures/render-conformance/`](../fixtures/render-conformance/) | 18 | ✓ | ✓ | inherits via Java | ✓ | ✓ | @@ -93,11 +93,10 @@ still fails: the ledger's `minPassing` (578) is the number of fixtures known to run fails when fewer do. The column joins this table when the port leaves preview. 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 -library-vs-pipeline divergences (see the `_comment` block in each port's -`yaml-conformance-expected-failures.json` for the full reconciliation note). They -are tracked as known-gaps rather than silently patched — the runner treats listed -fixtures as passing, but a future port-level reconciliation pass would close them. +carries a ledgered divergence. The ledgered YAML fixtures are documented divergences (see the +`_comment` or `notes` in each port's `yaml-conformance-expected-failures.json` for the full +reconciliation note). They are tracked as known-gaps rather than silently patched — the runner +treats listed fixtures as passing, but a future port-level reconciliation pass would close them. ### Core corpora and template quality checks diff --git a/docs/features/cli.md b/docs/features/cli.md index 2cb7085229..f43e702ac1 100644 --- a/docs/features/cli.md +++ b/docs/features/cli.md @@ -39,6 +39,7 @@ command surface splits in two: | 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 `