Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ name: conformance
# ts-fast — workspace build + typecheck, TS conformance, completeness (mutation) gate
# (the FULL pass here: MO_CI_MUTATION_SCOPE=full on that job)
# csharp / java-fast (java + kotlin) / python — each port's conformance corpora
# java-reactor — full-reactor `mvn clean install`, tests on (`--only java-slow`)
# The Java lanes point the script's Maven repository at ~/.m2/repository so setup-java's
# maven cache applies; the script's own default (~/.m2-ci) protects a developer's ~/.m2,
# which an ephemeral hosted runner does not have.
# java-reactor — full-reactor `mvn clean verify`, tests on (`--only java-slow`)
# The Java lanes make ~/.m2/repository the script's per-run Maven repository
# (METAOBJECTS_CI_M2_RUN_REPO) so setup-java's maven cache applies. That is safe only because
# a hosted runner is ephemeral: the script's own default is a private repository under
# $DEV_SCRATCH in front of a read-only shared cache, so a developer's or a self-hosted
# runner's shared repository is never written (scripts/lib/maven-private-repo.sh).
#
# WHY A SCHEDULE, given local-ci already runs nightly: local-ci's `java-slow` lane runs
# the same full reactor (`gate_java_reactor`, `mvn clean install`) — so "it does not run
# the same full reactor (`gate_java_reactor`, `mvn clean verify`) — so "it does not run
# the reactor" is NOT the gap. The gap is environmental, and it is measured. Two Java
# test defects (a test asserting on an NPE message HotSpot's fast-throw is entitled to
# stop producing once the path is hot; two test classes sharing files with nothing
Expand Down Expand Up @@ -134,7 +136,7 @@ jobs:
# changed ones ts-fast mutates elsewhere (see gate_completeness_diff).
MO_CI_MUTATION_SCOPE: full
run: |
METAOBJECTS_CI_M2_REPO="$HOME/.m2/repository" \
METAOBJECTS_CI_M2_RUN_REPO="$HOME/.m2/repository" \
scripts/ci-local.sh --only "$LANE" --no-integration --strict-toolchains

java-reactor:
Expand All @@ -157,5 +159,5 @@ jobs:
env:
MO_CI_JACOCO: '1'
run: |
METAOBJECTS_CI_M2_REPO="$HOME/.m2/repository" \
METAOBJECTS_CI_M2_RUN_REPO="$HOME/.m2/repository" \
scripts/ci-local.sh --only java-slow --no-integration --strict-toolchains
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ jobs:
MIGRATE_TS_PG_EXPECT: '1'
RUNTIME_TS_PG_EXPECT: '1'
run: |
METAOBJECTS_CI_M2_REPO="$HOME/.m2/repository" \
METAOBJECTS_CI_M2_RUN_REPO="$HOME/.m2/repository" \
scripts/ci-local.sh --only "$LANE" --integration-only --strict-toolchains
2 changes: 1 addition & 1 deletion .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
env:
LANE: ${{ matrix.lane }}
run: |
METAOBJECTS_CI_M2_REPO="$HOME/.m2/repository" \
METAOBJECTS_CI_M2_RUN_REPO="$HOME/.m2/repository" \
scripts/ci-local.sh --only "$LANE" --no-integration --strict-toolchains

python:
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ here.**
TypeScript passes both. The other ports take them on in their 1.3.0 REST-standard work. The
decision is [ADR-0068](spec/decisions/ADR-0068-list-query-cross-port-contract.md). A
scenario can now send a body that is not JSON with `rawBody`.
- **Java: the Spring controller generator writes through the code writer (ADR-0063).**
`SpringControllerGenerator` writes through `SpringJavaWriter`, a `JavaWriter` that adds the two
layouts Spring source uses and a block does not: a continuation line (two indents deeper) and an
indented `case` body. Every member of the generated controller comes from its own protected
`write*` method, so an owned copy changes one handler by overriding one method; the `append*`
helpers that took a `StringBuilder` are gone. The shared validator members and the decimal and
duration import lists in `SpringGeneratorSupport` are written through the writer too
(`writeCrossFieldValidationMembers`; `decimalAnnotationImports` and `durationAnnotationImports`
now return qualified names). A generated controller changes in two layout details only, checked
on 1,512 controllers from every fixture model: its imports are sorted, and the blank line after
`public class ... {` is gone.

The DTO, value-object and shared-enum generators follow (`SpringDtoGenerator`,
`SpringValueObjectGenerator`, `Fr019SharedEnum`). A record, patch class, stamping helper and
enum declaration each come from a protected method, and the string-returning helpers they used
are replaced by writer ones: `SpringTypeMapper.enumDeclaration` by `writeEnumDeclaration`,
`SpringRecordBuilder.members` by `writeMembers` (with `applies` to ask first), and an owned DTO
generator customizes every file it writes by overriding `newWriter`. Their output changes in
layout only, checked on every fixture model in two wire and API configurations: sorted imports
with no blank between groups, no blank line after `public final class ...Patch {` or a doubled
one in a patch with no settable fields, no trailing indent on the blank lines of a nested enum,
and no leading blank line in a file with no package.
- **runtime-ts: one list-query parse for every mount.** `parseListQuery` (exported from
`@metaobjectsdev/runtime-ts`; it does not depend on Drizzle) reads a list request into a
port-neutral `ListQuery`, and each mount compiles that for its own query library. The Drizzle
Expand All @@ -112,6 +134,28 @@ here.**
and refuses what the Drizzle mount refuses, with the same bodies;
- `pagination`: the `api.pagination` page size.

The names, repository and report-export generators follow (`SpringNamesGenerator`,
`SpringRepositoryGenerator`, `SpringReportExportGenerator`), each finder, constant block and
writer section from its own protected method; the one layout change in their output is that
the blank line after the class or interface opener is gone. So does the output-parser generator
(`SpringOutputParserGenerator`), whose `StringBuilder` seams (`emitMapperMethods`, `emitMapper`,
`appendMapperHelpers`) now take the writer, and whose parsers gain a blank line after the
leading `// GENERATED` comment besides sorted imports. The filter-allowlist, response-format and
render-helper generators follow: the allowlist output is unchanged, and the other two gain the
same blank after the leading comment, sorted imports and no blank after the class opener.
`SpringNaming.packageHeader` is removed; the writer's `packageName` replaces it. The LLM-trace
helper and the `requirement-tests` generator follow with the same layout changes, and the
witness-key collision error now lists its colliding pairs on one line, separated by `; `.
In `codegen-base`, the entity extractor (`ExtractorCodeGenerator`, whose `write*` seams now take
a `JavaWriter`, and whose `writeHeader` no longer takes the extractor name or writes the class
opener) and the generated `ObjectClassBindingProvider` move to the writer too, with sorted imports
and no blank after the class opener; the older object code writers take their indentation unit
from `WriterOptions` (`JAVA`, and the new two-space `DIRECT`) instead of a typed string. Every
Java generator now writes through the code writer, so the layout ratchet's `unconverted` list
is empty. `CodeWriter`, `JavaWriter`, `WriterOptions` and `SpringJavaWriter` join the Java
engine surface (`eject.engineSurface.java.engine`), so an ejected generator imports them from
the package rather than copying them.

With no sort, the `ObjectManager` mount now orders by the primary key. The `ObjectManager`
`Filter` gains `$or` and a case-insensitive `$ilike`, and the class gains `keyFields()` and
`fieldNames()`.
Expand Down
7 changes: 4 additions & 3 deletions docs/RELEASING-java.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@ git push origin main
### 3. Local smoke build

```bash
cd server/java && mvn clean install
cd server/java && mvn clean verify
```

All 14 publishable modules should reach SUCCESS with the full test suite green. The build also installs
locally into `~/.m2/repository/com/metaobjects/*/7.X.Y/`.
All 14 publishable modules should reach SUCCESS with the full test suite green. Use `verify`, not
`install`: a reactor build needs no installed artifacts, and installing writes this version into the
shared `~/.m2`, where every other checkout building the same number then resolves it.

### 4. Tag the release

Expand Down
2 changes: 1 addition & 1 deletion docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ versioned on its own major line — npm major + 7, so `7.x` while npm was `0.x`
that happens to share the number.)
Then assert the excluded modules are in sync: `scripts/check-pom-versions.sh`
(also enforced on every push by `.githooks/pre-push` and by `scripts/ci-local.sh`).
2. **Validate locally:** `cd server/java && mvn -q clean install -DskipTests` (or with tests / `scripts/integration-test.sh java` if runtime changed).
2. **Validate locally:** `cd server/java && mvn -q clean verify -DskipTests` (or with tests / `scripts/integration-test.sh java` if runtime changed). Use `verify`, not `install`: installing writes this unreleased version into the shared `~/.m2` ([RELEASING-java.md](RELEASING-java.md#3-local-smoke-build)).
3. **Deploy — ONE of two routes, never both** (a second deploy of a published version fails
with `Component … already exists`): push a `java-v<maven-version>` tag, and
`publish-java.yml` runs the deploy below in CI with the signing secrets (how `8.0.4`
Expand Down
9 changes: 6 additions & 3 deletions docs/features/own-your-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,9 @@ flavor, so the writers come with it:
| `JavaCodeWriter` | The Java type of each field; accessor, parameter, class and package names; the body of the interface flavor. |
| `PojoAwareCodeWriter`, `ValueObjectCodeWriter` | The fields, the constructor and the accessor bodies of the two concrete flavors. |

All seven land in one package and use one another, never the packaged classes: eject
rewrites the package line of each and, where one imports another, that import. To change a
All seven land in one package and use one another, never the packaged copies: eject
rewrites the package line of each and, where one imports another, that import. They do call
the code writer (`JavaWriter`, `WriterOptions`), which is engine and stays in the package. To change a
field, a constructor or an accessor, edit the writer. You subclass nothing. `-Dlist` gives
`entity` one verdict over all seven files.

Expand Down Expand Up @@ -1327,7 +1328,9 @@ the packaged sibling classes they still call, so they compile from any package.
**What stays in the package is the engine**, public and unchanged: the generator base and
runner types, the naming and type-mapping tables (`SpringNaming`, `SpringTypeMapper`,
`KotlinNaming`, `KotlinTypeMapper`), the questions a generator asks of the model
(`FindInbound`, `TphPlan`, the M:N support, `RestSurfaceGate`), and the Kotlin
(`FindInbound`, `TphPlan`, the M:N support, `RestSurfaceGate`), the code writer the Java
generators lay their output out with (`CodeWriter`, `JavaWriter`, `WriterOptions`, and
`SpringJavaWriter` for Spring source), and the Kotlin
`Fr019SharedEnum`. Anything that returns emitted text is handed over; a table or a model
question is not. The Kotlin `Fr019SharedEnum` writes no output. It answers where a shared or
`@provided` enum lives, and the type mapper and the generator utilities take its
Expand Down
4 changes: 2 additions & 2 deletions docs/ports/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -884,11 +884,11 @@ engine, `com.metaobjects.config.SharedModel`, stays in the package, so the owned

**Own a generator.** `mvn metaobjects:eject -Dnames=<name,...>` copies a reference generator into a `codegen/` Maven module under your own package, and prints the module, dependency and `<classname>` to wire. See [Own your codegen → Java and Kotlin](../features/own-your-codegen.md#java-and-kotlin-mvn-metaobjectseject). Every generator in the table above can be ejected except `template` and the deprecated `mustache` (see [the primitive](../features/own-your-codegen.md#java-and-kotlin-mvn-metaobjectseject)).

**`entity` and `extractor` eject from `metaobjects-codegen-base`, each with the rest of its emit.** `mvn metaobjects:eject -Dnames=entity,extractor -Dport=java` (pass `-Dport`: both names are ejectable on both JVM ports). `entity` copies seven files into one package: `JavaObjectCodeGenerator`, the bases it extends (`JavaCodeGenerator`, `BaseObjectCodeGenerator`) and the four writers that emit each class body (`BaseObjectCodeWriter`, `JavaCodeWriter`, `PojoAwareCodeWriter`, `ValueObjectCodeWriter`). The copies use one another, never the packaged classes, so you change a field, a constructor or an accessor by editing the writer. `extractor` copies `ExtractorCodeGenerator` with `JavaCodeWriter` and `BaseObjectCodeWriter`, where it reads class names from; in the same package as `entity` the two share those writers. The file-by-file table is in [Own your codegen → Java `entity` and `extractor`](../features/own-your-codegen.md#java-entity-and-extractor).
**`entity` and `extractor` eject from `metaobjects-codegen-base`, each with the rest of its emit.** `mvn metaobjects:eject -Dnames=entity,extractor -Dport=java` (pass `-Dport`: both names are ejectable on both JVM ports). `entity` copies seven files into one package: `JavaObjectCodeGenerator`, the bases it extends (`JavaCodeGenerator`, `BaseObjectCodeGenerator`) and the four writers that emit each class body (`BaseObjectCodeWriter`, `JavaCodeWriter`, `PojoAwareCodeWriter`, `ValueObjectCodeWriter`). The copies use one another, never the packaged copies, so you change a field, a constructor or an accessor by editing the writer. (The code writer they call, `JavaWriter` and `WriterOptions`, is engine and comes from the package.) `extractor` copies `ExtractorCodeGenerator` with `JavaCodeWriter` and `BaseObjectCodeWriter`, where it reads class names from; in the same package as `entity` the two share those writers. The file-by-file table is in [Own your codegen → Java `entity` and `extractor`](../features/own-your-codegen.md#java-entity-and-extractor).

**Class headers changed once, and `mvn metaobjects:verify` no longer depends on the clock.** The header comment of every class `entity` writes used to carry an `ObjectCodeWriter:` line (the writer's class name) and a `Generated On:` line (the wall-clock second of the run). Both are gone, so the first regeneration after upgrading changes every generated class file in its header comment and nowhere else. Because of the timestamp, `mvn metaobjects:verify` reported `[content-differs]` for every one of those files unless it ran in the same second as the generate it was checking. Output now holds nothing that varies between runs: regenerating an unchanged model writes the same bytes, and verify passes whenever it runs.

**Ejecting hands over the shared emit rules.** The `routes`, `dto`, `repository` and `value-object` generators apply rules they share (which fields a DTO and a patch carry, validation annotations, M:N finder names) through `SpringGeneratorSupport`. Ejecting any of them writes one copy of that class beside the owned generators, in their package, and points each owned generator's import at it, so an owned generator never calls the packaged rules and you can change them. The engine classes the copies still import (`SpringNaming`, `SpringTypeMapper`, `SpringM2mSupport`, `AutoSetSupport`, `TphPlan`) never call `SpringGeneratorSupport`; `SpringTypeMapper.mapValueObjectRefOf` is a type-mapping fact and stays engine. The copy is left alone without `-Dforce`, `-Dlist` marks it `identical` or `DIFFERS`, and `mvn metaobjects:verify` does not report it as stale output.
**Ejecting hands over the shared emit rules.** The `routes`, `dto`, `repository` and `value-object` generators apply rules they share (which fields a DTO and a patch carry, validation annotations, M:N finder names) through `SpringGeneratorSupport`. Ejecting any of them writes one copy of that class beside the owned generators, in their package, and points each owned generator's import at it, so an owned generator never calls the packaged rules and you can change them. The engine classes the copies still import (`SpringNaming`, `SpringTypeMapper`, `SpringM2mSupport`, `AutoSetSupport`, `TphPlan`, and the code writer `SpringJavaWriter` with `JavaWriter`) never call `SpringGeneratorSupport`; `SpringTypeMapper.mapValueObjectRefOf` is a type-mapping fact and stays engine. The copy is left alone without `-Dforce`, `-Dlist` marks it `identical` or `DIFFERS`, and `mvn metaobjects:verify` does not report it as stale output.

**Ejecting hands over the helper runtime too.** The `routes`, `dto` and `repository` output imports helper classes from `com.metaobjects.generator.spring.runtime` (`FilterParser`, `FilterParseResult`, `FilterPredicate`, `PatchValidationException`, `ConstraintErrors`, `RecordComponentNames`). These are helpers, not core. Ejecting one of those generators copies the classes its output imports into `src/main/java/<runtimePackage>/` (default `<groupId>.runtime`) of the module that compiles the generated code, and the owned generator's output imports that copy. The copies are JDK-only. The owned web tier then builds with no MetaObjects artifact on the application classpath, and you can fix a helper bug in your copy without waiting for a release. A packaged generator that must use the same copy takes `<args><runtimePackage>…</runtimePackage></args>`. What stays core: the loader and registry, render and extract, OMDB and `metaobjects-om`. `mvn metaobjects:verify` treats the copies as owned code, not stale output. The table, the aggregator rule and a diff recipe for pulling an upstream fix are in [Own your codegen → What eject hands over](../features/own-your-codegen.md#what-eject-hands-over-and-what-stays-core).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"generated/csharp/SubscriberRoutes.g.cs": "2a217ff5a37674ce5038802631b1d8fd90b22b9849e0288f7daf3bba7f9e862f",
"generated/python/Subscriber.py": "9dd4c0acea47f99d1daf79930f9de2e400f30780ebce6c63f023be528a72b762",
"generated/python/SubscriberBlurbPayload.py": "a5ef8a08e63efbe0f73e39a21a368cff5150c68cc8beeea6e8aab0c755f8bbdd",
"generated/python/subscriber_filter_allowlist.py": "b0414cc95ff3982c80a0e1a06839f090c0b423e41f5a94275df93426cea09df5",
"generated/python/subscriber_filter_allowlist.py": "1762fb8b41516c9ca4d4384563046b73c25ed681e4e5da3db19d7d290f9e8b25",
"generated/python/subscriber_names.py": "269637a02bf9b46f55658b58cb42f83196c03a877e1e2101337847fd406c1561",
"generated/python/subscriber_router.py": "16502ff815bf9ae29c7dba4700d0465d06058a9fd7ea8db5f98334d52d284851",
"generated/ts/Subscriber.queries.ts": {
Expand Down
1 change: 0 additions & 1 deletion examples/showcase/generated/java/acme/SubscriberPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

/** GENERATED — presence-tracked partial-update (PATCH) shape for Subscriber. Do not hand-edit; regenerated from metadata. */
public final class SubscriberPatch {

private final Map<String, Object> assigned;

private SubscriberPatch(Map<String, Object> assigned) { this.assigned = assigned; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""GENERATED — per-entity FR-009 filter allowlist for Subscriber.

SUBSCRIBER_FILTER_FIELDS lists the filterable field names; SUBSCRIBER_FILTER_OPS_BY_FIELD
constrains the operator vocabulary for each field by its subtype."""
constrains the operator vocabulary for each field by its subtype.
"""

from __future__ import annotations

Expand Down
10 changes: 10 additions & 0 deletions examples/showcase/jvm/.metaobjects/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Gen-state bodies are a second full copy of all generated output — not worth
# committing. The MANIFEST is: the `.hashes/` directory (one file per model
# package) is 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 (CLAUDE.md, Storage format).
#
# The glob matters. Git will not descend into an excluded DIRECTORY, so a
# negation under `.gen-state/` can never apply — it has to be `.gen-state/*`.
.gen-state/*
!.gen-state/.hashes/
Loading
Loading