Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions changelog.d/explorer-app-stable-bundle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **The explorer app's bundle builds the same bytes every time.** `explorer-app/assets/explorer-app.js`
is now minified for whitespace and syntax only, and keeps its identifiers' names. Bun's choice of
short names was not stable between builds of unchanged sources, so the check that the committed
bundle is what the sources build failed at random. The bundle grows from about 95 KB to about
120 KB. Every port's copy is refreshed, so the docs site's `assets/explorer-app.js` changes and
nothing else does. Generated-output change — regenerate to pick it up; three-way merge preserves
hand edits.
12 changes: 12 additions & 0 deletions changelog.d/explorer-jvm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- **Java and Kotlin: the model explorer with no Node.** The JVM builds the docs view from its
loaded model (`com.metaobjects.docsview.DocsView`), byte for byte what TypeScript builds for
every `fixtures/explorer-conformance/` case. A new `docs-site` generator
(`com.metaobjects.generator.DocsSiteGenerator`, in both the Java and Kotlin registries) writes
`explorer.json`, the explorer app, `explorer-model.js` and `explorer-stamp.js`; each object
lists the files generated for it: this execution's (it builds the site after every other
generator it runs) and the committed manifest's for the module's other executions, so
`metaobjects:verify` renders what `generate` wrote. Optional args name a
`verify --format json` payload (`verifyFile`) and the routes (`routesFile`). The running
application can serve the same view at `{apiPrefix}/_meta/docs`: `MetaEndpoint.docs(root)`
builds it once and carries its ETag, and the host mounts it as it mounts `/_meta`. The static
export and the classic site stay TypeScript's.
10 changes: 10 additions & 0 deletions changelog.d/generated-file-provenance-all-ports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- **C#, Java and Python codegen record which node each generated file came from.** After a write
run, the hash manifest entry of a per-object file names its generator and the node's resolution
key, `{ "hash", "generatedBy", "sourceNode" }` (after the JVM's `generator` and `outputDir`),
exactly as TypeScript already wrote it. A docs view built from any of these ports' manifests now
lists each node's generated files, so the explorer's "generated files" panel is filled. A file
rendered from the whole model or a package keeps the plain hash. The shared `provenance` vector in
`fixtures/codegen-skip-conformance/manifests.json` holds all four ports to the same entries.

Upgrading: the next `gen` rewrites the committed `.metaobjects/.gen-state/.hashes/` files once,
adding the two fields to each per-object entry. Commit them; generated source files do not change.
7 changes: 7 additions & 0 deletions changelog.d/rust-publish-stale-sources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- **CI: the Rust publish dry-run no longer verifies against stale source.** `cargo publish
--workspace` unpacks the crates it depends on from its temporary overlay registry into a
directory fixed per checkout, and never unpacks them again while the version is unchanged, so a
machine that had run the gate before a new module landed compiled the old `metaobjects-1.3.0`
and failed with "could not find `metamodel_docs`". The gate now first clears unpacked copies of
the workspace's own crates that differ from the tree
(`scripts/rust-clear-stale-publish-sources.sh`).
7 changes: 5 additions & 2 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ regenerate with `ls -d fixtures/<corpus>/*/ | wc -l` for directory-shaped corpor
| [`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) | 88 cases (31 core + 10 TypeScript + 9 Java + 12 Kotlin + 6 C# + 12 Python + 8 Rust) | ✓ (the first writer; core and TypeScript dialect) | ✓ (core and Java dialect; `JavaWriter` in `codegen-base`) | ✓ (core and Kotlin dialect; `KotlinWriter` in `codegen-kotlin`) | ✓ (core and C# dialect) | ✓ (core and Python dialect) | ✓ (core and Rust dialect) |
| [`fixtures/contract-conformance/`](../fixtures/contract-conformance/) (FR-022 — the `contract-schema` and `openapi` generators' golden trees and refusals) | 22 cases (17 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 docs view: a loaded project + the verify payload, manifest and routes in, one `explorer.json` out) | 3 cases (`shop`, `crm`, `model-alone`) | ✓ | — | — | — | — | — |
| [`fixtures/explorer-conformance/`](../fixtures/explorer-conformance/) (the docs view: a loaded project + the verify payload, manifest and routes in, one `explorer.json` out) | 3 cases (`shop`, `crm`, `model-alone`) | ✓ | ✓ (`DocsView`, and the `docs-site` generator end to end) | ✓ (the JVM builder, through `codegen-kotlin`'s `docs-site`) | — | — | — |

**Rust (ADR-0065)** joined the table with its service stack. Its ledgers (the metamodel
corpus's `server/rust/metaobjects/tests/conformance-expected-failures.json`, empty; the YAML
Expand Down Expand Up @@ -912,8 +912,11 @@ It also pins three id rules: a page declared before the entity it shares a name
entity its claims, a reference and a claim naming an inherited member land on the owner's row,
and a nameless member keeps its index in its label. `model-alone` carries no optional input:
its `expected.json` is the body the running application's `GET {apiPrefix}/_meta/docs` serves.
Java (`metadata`'s `DocsViewConformanceTest`, and `codegen-base`'s `ExplorerSiteTest` through the
generator) and Kotlin (`KotlinDocsSiteConformanceTest`, through its registry's `docs-site`) build
every case byte for byte; the JVM has one builder, which Kotlin calls rather than re-implements.

**One port runs it:** TypeScript, in
**TypeScript runs it** in
`server/typescript/packages/metadata/test/docs-view-conformance.test.ts` (the view) and
`server/typescript/packages/cli/test/explorer-fixture.test.ts` (the committed `verify.json` files
are what the gate writes today) and `server/typescript/packages/runtime-ts/test/meta-docs-route.test.ts`
Expand Down
13 changes: 8 additions & 5 deletions docs/features/docs-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ logic-less template such as Mustache can render it unaided. Every port that buil
writes the same bytes for the same model, and the shared corpus
[`fixtures/explorer-conformance/`](../../fixtures/explorer-conformance/) holds them to that.

TypeScript builds it today. `buildDocsView` and `serializeDocsView` are exported from
`@metaobjectsdev/metadata`, and `docsSiteFile()` writes the result as the site's
`explorer.json` (see [explorer-site.md](explorer-site.md)). The other ports build it as their
own step of the same plan. The explorer pages still render their HTML in TypeScript.
TypeScript builds it today, and so do Java and Kotlin (one JVM builder, `DocsView` in
`metadata`). `buildDocsView` and `serializeDocsView` are exported from `@metaobjectsdev/metadata`,
and `docsSiteFile()` writes the result as the site's `explorer.json` (see
[explorer-site.md](explorer-site.md)). C#, Python and Rust will build it as their own step of the same
plan ([explorer-data.md](explorer-data.md#not-built-yet)). The explorer pages still render their
HTML in TypeScript; the JVM copies the app and writes the same `explorer.json`.

A page of your own is a template over the view: the TypeScript `template` generator renders it
with the `perNode` and `perRequirement` scopes (and `data: "docsView"` on `perModel` and
Expand Down Expand Up @@ -268,7 +270,8 @@ Named node sets a map view opens on, all derived, each `{ id, kind, anchor, node
`expected.json` is the view of its project and committed inputs, byte for byte.
`server/typescript/packages/metadata/test/docs-view-conformance.test.ts` runs it, and also
checks inheritance, references, the requirement list, custom vocabulary and a build without
the optional inputs.
the optional inputs. The JVM runs the same cases in `metadata`'s `DocsViewConformanceTest` and
Kotlin in `KotlinDocsSiteConformanceTest` ([CONFORMANCE.md](../CONFORMANCE.md)).
- `server/typescript/packages/cli/test/explorer-fixture.test.ts`: the committed `verify.json`
files are what the gate writes today, and a fresh verify payload builds the committed
`shop/expected.json`.
Expand Down
25 changes: 15 additions & 10 deletions docs/features/explorer-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ comes from the `node` field. The structured payload is TypeScript-only, as the r

### Node provenance in the manifest

Each generated file now records the metadata node it was rendered from. A generator built with
`perEntity` sets this automatically. An `EmittedFile` can also name its node directly with
`sourceNode`, which is a node resolution key such as `acme::shop::Order`. `meta gen` then
writes that file's manifest entry in object form:
Each generated file now records the metadata node it was rendered from, in TypeScript, C#,
Java and Python. A per-object generator sets this automatically (TypeScript `perEntity`, C#
`PerEntityGenerator`, Python `per_entity`, and the shared writer the Java generators use). A
generated file can also name its node directly (`sourceNode` on a TypeScript `EmittedFile`,
`SourceNode` in C#, `source_node` in Python), as a node resolution key such as
`acme::shop::Order`. A write run then writes that file's manifest entry in object form:

```json
{
Expand All @@ -116,8 +118,11 @@ manifest reader takes `hash` from either form.

The provenance field is named `generatedBy`, not `generator`. In a Java or Kotlin module's
manifest, `generator` means that generator owns the file (ADR-0060), and the orphan sweep acts
on that ownership. TypeScript does not make that claim. TypeScript is the only port that writes
provenance today, and the JVM rewrites its manifest without these fields.
on that ownership, so a JVM entry carries both: `{ "hash", "generator", "outputDir",
"generatedBy", "sourceNode" }`. The four ports that write provenance write the same entry for the
same records; the shared vector `provenance` in
[`fixtures/codegen-skip-conformance/manifests.json`](../../fixtures/codegen-skip-conformance/manifests.json)
holds TypeScript, C#, Java and Python to it. Kotlin and Rust write no provenance yet.

## Building it by hand

Expand Down Expand Up @@ -151,10 +156,10 @@ malformed leaves its part of the view empty.

- **`usage`**: which hand-written modules import a generated module. The design marks it
optional, and nothing builds it yet.
- **Provenance from the JVM, Python and C# generators.** Their manifests have no `sourceNode`
yet, so for those ports a node lists no files.
- **The docs view in the other ports.** TypeScript builds it today; the corpus is what the
other ports will be held to.
- **Provenance from the Kotlin and Rust generators.** Their manifest entries have no
`sourceNode` yet, so for those ports a node lists no files.
- **The docs view in C#, Python and Rust.** TypeScript, Java and Kotlin build it today; the
corpus is what the other ports will be held to.

## Verified by

Expand Down
49 changes: 45 additions & 4 deletions docs/features/explorer-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,39 @@ opening a link in a new tab work as they do on a static site. The app files are
every port; `explorer-app/README.md` at the repository root describes them and the two data
files a port writes beside them.

### In each port

The explorer app is the same files in every port, and `explorer.json` is the same bytes for the
same model and inputs: every port that builds the docs view is held to
`fixtures/explorer-conformance/`. What differs is where each input comes from.

| Port | Generator | The app | Inputs it reads |
|---|---|---|---|
| TypeScript | `docsSiteFile()` (`meta gen`) | `output: "app"` (default) or `"static"`; `site: "classic"` for the earlier site | The model, the requirement ledger, the files and routes this run wrote and mounts |
| Java | `com.metaobjects.generator.DocsSiteGenerator` (`mvn metaobjects:generate`), no Node | The app only | The model, the files generated per node (this execution's, and what the committed hash manifest records for the module's other executions), and a `verify --format json` payload when you name one (`verifyFile`) |
| Kotlin | the same JVM `DocsSiteGenerator`, through `codegen-kotlin`'s registry | The app only | As Java; the Kotlin generators do not record provenance in the manifest yet, so their files are not listed |
| C#, Python, Rust | not yet | | |

On the JVM, wire it like any other generator, with its own output directory:

```xml
<generator>
<classname>com.metaobjects.generator.DocsSiteGenerator</classname>
<args>
<outputDir>${project.basedir}/docs/generated</outputDir>
</args>
</generator>
```

It writes `docs/generated/site/`. The JVM build has no requirement gate of its own, so without
`verifyFile` the requirement tree shows each claim but no verdict. The generator is not told the
routes the Spring controllers mount, so no node lists its REST routes unless you name them in
`routesFile` (`[{ node, method, path }]`, `node` a resolution key). The generated-file lists are the
files this execution generated, beside what the committed hash manifest records for the module's
other `<execution>`s: the execution builds the site after every other generator it runs, so
`metaobjects:verify` renders the same lists the write run wrote. The other args are in
[the Java port's generator table](../ports/java.md#generators).

### The live view

Leave the explorer open while you work. About once a second it reloads `explorer-stamp.js`,
Expand Down Expand Up @@ -264,18 +297,26 @@ a dangling link. `createExplorer` (the page table both outputs draw from) and

- An LLM-written summary, a test-result overlay, zoom levels and lenses on the map, and
publishing the site.
- The docs view route in the other ports: the contract is in
- The docs view route in C#, Python and Rust: the contract is in
[metadata-api.md](metadata-api.md#the-docs-view-endpoint-get-_metadocs), and each port serves
it once it has its docs view builder.
- The app in the other ports: its files are in each port's package already (see
it once it has its docs view builder. Java and Kotlin ship it (`MetaEndpoint.docs(root)`).
- The app in C#, Python and Rust: its files are in each port's package already (see
`explorer-app/README.md`), and each port's docs-site generator is still to write them.
- The static export and the classic site outside TypeScript.
- "Hand-written code that imports it": the site reads no import graph, so the object pages say
it was not scanned.
- Generated-file provenance from the JVM, Python and C# generators (see
- Generated-file provenance from the Kotlin and Rust generators (see
[explorer-data.md](explorer-data.md)), so for those ports the generated-file lists are empty.

## Verified by

- `server/java/metadata/src/test/java/com/metaobjects/docsview/DocsViewConformanceTest.java`:
the JVM docs view builder writes every `fixtures/explorer-conformance/` case byte for byte.
- `server/java/codegen-base/src/test/java/com/metaobjects/docs/explorer/ExplorerSiteTest.java`:
the JVM site's app files are the canonical copy, its model script has TypeScript's bytes and
stamp, an owned theme wins, and the generator lists the manifest's files.
- `server/java/metadata/src/test/java/com/metaobjects/io/json/MetaDocsEndpointTest.java`: the
JVM docs view route body is the `model-alone` view, and its ETag is TypeScript's.
- `server/typescript/packages/docs-site/test/explorer-app.test.ts`: the files the app output
writes, the model and stamp files, owned templates and theme, and the committed bundle, run
outside a browser, drawing every page the static export writes byte for byte on the shop, crm
Expand Down
39 changes: 36 additions & 3 deletions docs/features/metadata-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,42 @@ app.use(`/api${META_DOCS_ROUTE_PATH}`, requireAuth);
mountMetaDocsRouteHono({ app, root, prefix: "/api" });
```

C#, Java, Kotlin, Python and Rust serve the route once each has its docs view
builder, with the body that builder writes; their `/_meta` sections above show
where each mounts it.
Java and Kotlin ship the helper and leave the mount to the host, as for `/_meta`:
`MetaEndpoint.META_DOCS_ROUTE_PATH`, `MetaEndpoint.metaDocsJson(root)` and
`MetaEndpoint.docs(root)`, which builds the view once and carries its ETag
(`metaDocsEtag`, the value TypeScript's mounts send) and the `If-None-Match` check.

```java
// MetaDocsController.java
import com.metaobjects.io.json.MetaEndpoint;
import org.springframework.http.CacheControl;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MetaDocsController {
// root: the MetaRoot this app loaded. Built once: the model does not change after load.
private final MetaEndpoint.Docs docs = MetaEndpoint.docs(root);

@GetMapping("/api" + MetaEndpoint.META_DOCS_ROUTE_PATH)
public ResponseEntity<String> docs(@RequestHeader(value = "If-None-Match", required = false) String tag) {
ResponseEntity.BodyBuilder res = (docs.matches(tag) ? ResponseEntity.status(HttpStatus.NOT_MODIFIED) : ResponseEntity.ok())
.eTag(docs.etag()).cacheControl(CacheControl.noCache());
return docs.matches(tag) ? res.build() : res.contentType(MediaType.APPLICATION_JSON).body(docs.body());
}
}
```

Kotlin calls the same symbols through `metadata-ktx`. To let the explorer read the route from
`file://`, add `Access-Control-Allow-Origin: null` and `Access-Control-Expose-Headers: ETag` to
that response, or use Spring's CORS configuration.

C#, Python and Rust serve the route once each has its docs view builder, with the
body that builder writes; their `/_meta` sections above show where each mounts it.

## Browser consumption

Expand Down
5 changes: 3 additions & 2 deletions docs/features/own-your-codegen.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,9 @@ overwritten; an edited one is refused by name (`<handEdits>keep</handEdits>`, th
replaced (`<handEdits>overwrite</handEdits>`). There is **no three-way merge**
(TypeScript-only). **Commit the manifest.**

A TypeScript entry can also carry the node the file was rendered from,
`{ "hash", "generatedBy", "sourceNode" }`. That is provenance, not ownership, which is why it
An entry can also carry the node the file was rendered from,
`{ "hash", "generatedBy", "sourceNode" }`; the TypeScript, C#, Java and Python runs write it
(on the JVM after `generator` and `outputDir`). That is provenance, not ownership, which is why it
does not use the JVM's `generator` field. Every reader takes `hash` from either form. See
[explorer-data.md](explorer-data.md#node-provenance-in-the-manifest).

Expand Down
Loading
Loading