diff --git a/changelog.d/bun-1-3-14-package-manager.md b/changelog.d/bun-1-3-14-package-manager.md new file mode 100644 index 0000000000..1958f0fcb1 --- /dev/null +++ b/changelog.d/bun-1-3-14-package-manager.md @@ -0,0 +1,6 @@ +- **Repository: Bun 1.3.14 is the declared package manager.** The root `package.json` now + declares `bun@1.3.14`, the version every workflow pins, in place of 1.3.8 (which segfaults on + exit). Rebuilding or checking the explorer app (`server/typescript/packages/docs-site/scripts/build-app.ts`, + the `explorer app copies` gate and its unit test) requires that exact version, because the + committed bundle is minified and minified output follows the Bun version; any other Bun stops + with an error naming 1.3.14. diff --git a/changelog.d/explorer-3d-map.md b/changelog.d/explorer-3d-map.md new file mode 100644 index 0000000000..fdb55c8545 --- /dev/null +++ b/changelog.d/explorer-3d-map.md @@ -0,0 +1,9 @@ +- **docs-site: a 3D model map.** The explorer's map has a **View** control that switches + between the flat map and a 3D one drawn from the same nodes, edges, slice and colouring + (`#/map.html?view=3d`); click a node for the side panel and again to open its page. The 3D + library, 3d-force-graph 1.77.0 (MIT, bundling three.js; the licences of everything it bundles + head the file), ships with the site as `assets/3d-force-graph.min.js` and loads only when a + reader first chooses 3D, so it works offline and no other page pays for its size. A static + export given an `assetBase` loads it from the mirror instead. An owned + `explorer-map.html.mustache` without the control simply has no 3D mode. Generated-output + change — regenerate to pick it up; three-way merge preserves hand edits. diff --git a/changelog.d/explorer-app.md b/changelog.d/explorer-app.md new file mode 100644 index 0000000000..2536a21b47 --- /dev/null +++ b/changelog.d/explorer-app.md @@ -0,0 +1,21 @@ +- **docs-site: the model explorer is one browser app.** `docsSiteFile()` now writes the + explorer as a few files (a shell, the app, the theme, Cytoscape and three data files: + `explorer.json`, `explorer-model.js`, `explorer-stamp.js`) in place of a page per screen. + The app draws every page when it is visited, with the same page code and templates, so each + page is byte-for-byte the one the static site wrote. It runs from `file://` with no server, + addresses each page as `index.html#/`, and follows the model while it is open: it polls + the stamp file about once a second and draws the current page again when `meta gen` rewrites + the model. Cytoscape 3.30.2 (MIT) ships with the site, so the graphs draw offline and the + CDN notice is gone. `docsSiteFile({ output: "static" })` (and `generateExplorerSite({ output: + "static" })`) writes the earlier page-per-screen site from the same code, for publishing + without scripts or for Pagefind; `assetBase` now applies to that export only, which given one + loads Cytoscape from it and ships no copy. The app's files live once at `explorer-app/` and + in every port's package (`scripts/sync-explorer-app.sh`, gated by `explorer app copies`); + the other ports' docs-site generators are still to write them. Generated-output change: the + next `meta gen` replaces the explorer's pages with the app's files, and `meta verify + --codegen` holds the new files to the model as before. + If you ejected the theme on a 1.3.0 candidate, your `codegen/docs-site/assets/explorer.js` + predates the app, which calls `window.MO_THEME` each time it draws a page: without that hook + search, the theme toggle and the graphs do nothing. Copy it again with `meta eject docs-site + --force` and carry your edits into the new copy (the app also needs its `window.MO_APP` link, + query and listener hooks, so adding the one line is not enough). diff --git a/changelog.d/explorer-live-source.md b/changelog.d/explorer-live-source.md new file mode 100644 index 0000000000..d87befbc62 --- /dev/null +++ b/changelog.d/explorer-live-source.md @@ -0,0 +1,10 @@ +- **runtime-ts: `GET {apiPrefix}/_meta/docs` serves the loaded model's docs view, and the + explorer follows it.** New `mountMetaDocsRoute` (Fastify) and `mountMetaDocsRouteHono` mount + it beside `/_meta`, opt-in and guarded the same way, with `META_DOCS_ROUTE_PATH` and + `metaDocsJson(root, { routes })` for other hosts. The response carries an ETag and answers a + matching `If-None-Match` with `304`; `allowOrigin` opts in to cross-origin reads. Open the + explorer app as `index.html?source=` and it reads the running application's model + instead of the generated file, once a second, drawing the open page again when the + application restarts on a changed model. The route's shape is a cross-port contract + (`docs/features/metadata-api.md`); the other ports serve it once they have their docs view + builders. diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index 695f20f473..6fd17c37ae 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -73,7 +73,7 @@ regenerate with `ls -d fixtures//*/ | 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) | 2 cases (`shop`, `crm`) | ✓ | — | — | — | — | — | +| [`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`) | ✓ | — | — | — | — | — | **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 @@ -897,7 +897,7 @@ 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/` (2 cases) +### `fixtures/explorer-conformance/` (3 cases) The docs view → [features/docs-view.md](features/docs-view.md). Each case is a `project/` and its optional committed inputs (`verify.json`, what `meta verify --format json` writes for it; @@ -910,12 +910,14 @@ data-driven provider for vocabulary the core does not register (`page.list`, `bl `capability.module`): its members and references must appear with no docs code that names them. It also pins three id rules: a page declared before the entity it shares a name with leaves the 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. +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. **One port runs it:** TypeScript, 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). A port loads the project with the provider applied, builds its +are what the gate writes today) and `server/typescript/packages/runtime-ts/test/meta-docs-route.test.ts` +(the docs view route serves `model-alone/expected.json`). A port loads the project with the provider applied, builds its own view and compares; the view reads the port's own loaded model, so it is a port's step, not a shared input. diff --git a/docs/features/explorer-site.md b/docs/features/explorer-site.md index 9bf9aa9556..9bdae2d391 100644 --- a/docs/features/explorer-site.md +++ b/docs/features/explorer-site.md @@ -1,10 +1,14 @@ # The model explorer site -`docsSiteFile()` builds a static site that shows one project: what the software does, how the +`docsSiteFile()` builds a site that shows one project: what the software does, how the model is put together, and whether each requirement claim holds. Every page is drawn from one data file, [`explorer.json`](docs-view.md) (the docs view), which the generator builds during the same `meta gen` run. A page never works a model fact out for itself. +By default the site is one browser app: a handful of files that draw every page when it is +visited, from `file://` with no server, and follow the model while it is open. `output: +"static"` writes every page as its own HTML file instead, from the same page code. + The explorer is the default site. The earlier site (package navigation, a page per object, the Mermaid ER diagrams) is still there as `docsSiteFile({ site: "classic" })`. @@ -35,26 +39,105 @@ generator in the run, wherever it appears in the list, because it reads what the | Generated files per node | The files this run wrote, with the node each came from. Files under a target whose `outDir` lies outside the project are left out, under `meta gen` and `verify --codegen` alike | | Routes per node | The REST routes this run's routes generator mounts; none if the run has no routes generator | -Open `site/index.html` in a browser, or serve the directory. The pages use relative links, so -the site works from any path and from `file://`. +Open `site/index.html` in a browser, or serve the directory. The site uses relative links, so +it works from any path and from `file://`. + +### What it writes + +| File | What it is | +|---|---| +| `index.html` | The app's shell | +| `assets/explorer-app.js` | The app: the explorer's page code and templates, and a router | +| `assets/explorer.css`, `assets/explorer.js` | The theme (yours, when you own it) | +| `assets/cytoscape.min.js` | [Cytoscape.js](https://js.cytoscape.org/) 3.30.2 (MIT), so the graphs draw offline | +| `assets/3d-force-graph.min.js` | [3d-force-graph](https://github.com/vasturiano/3d-force-graph) 1.77.0 (MIT; it bundles three.js and its other dependencies, whose licences head the file), for the map's 3D mode | +| `explorer.json` | The docs view | +| `explorer-model.js` | The view, the prompt texts, the title and any owned templates, as a script | +| `explorer-stamp.js` | A hash of the model file | + +Every page is an address inside the app: `index.html#/model/acme/shop/Order.html`, with the +map's and the trace's query and a member's anchor after it +(`#/map.html?slice=…`, `#/model/acme/shop/Order.html#m-total`). Back, forward, bookmarks and +opening a link in a new tab work as they do on a static site. The app files are the same in +every port; `explorer-app/README.md` at the repository root describes them and the two data +files a port writes beside them. + +### The live view + +Leave the explorer open while you work. About once a second it reloads `explorer-stamp.js`, +and when the stamp has moved (a `meta gen` rewrote the model) it reloads `explorer-model.js` +and draws the page you are on again, keeping the address and the scroll position. A model +file caught half-written is not taken: the app waits for one that carries the new stamp. + +### The 3D map + +The map's **View** control switches between the flat map and a 3D one. Both draw the same +nodes and edges, with the same slice, colouring and filters, and the choice stays in the +address (`#/map.html?view=3d`). In 3D, drag to turn, scroll to zoom and right-drag to pan; +hover a node for its name, click it for the side panel, and click it again to open its page. +The 3D library is loaded only when you first switch to 3D, so no other page pays for its size +(1.2 MB), and it ships with the site like Cytoscape, so it works offline. + +A third dimension does not make a large model easier to read: past a few dozen nodes both maps +are a tangle, and a slice is what makes either one useful. + +### A running application + +The explorer can also read the model a running application has loaded, instead of the +`explorer-model.js` beside it. Mount the docs view route in the application (`GET +{apiPrefix}/_meta/docs`, [metadata-api.md](metadata-api.md#the-docs-view-endpoint-get-_metadocs)), +then open the explorer with the route's address as `source`: + +``` +docs/generated/site/index.html?source=http://localhost:3000/api/_meta/docs +``` + +The app reads the route once a second and draws the page you are on again when the view +changes, as it does for the model file: restart the application on a changed model and the +open page follows it. While the application is down the page stays as it was and a note in +the corner says the route cannot be read. The title is the generated site's, else the +application's host. + +The route serves the model the application loaded, and it never re-reads the metadata files: +an edit on disk does not reach it while the application runs. To see a model edit, regenerate +and restart the application (or run it under a watcher that restarts it). Reloading the +application is the host's job; the open page picks up the restarted application's model by +itself. To follow edits on disk with no application running, open the site without `source` +and use [the live view](#the-live-view). + +A running application's view is built from the model alone, so it has no gate verdicts and no +generated-file lists, and prompt text comes from the generated site's `explorer-model.js` when +it is there. Opened from `file://`, the app is a page of origin `null`, so the route has to +allow it: `mountMetaDocsRoute({ …, allowOrigin: "null" })`. Served from the application +itself, it needs nothing. + +### The static export + +`docsSiteFile({ output: "static" })` writes the earlier layout: a page per screen, the theme, +`assets/cytoscape.min.js`, `assets/3d-force-graph.min.js`, `assets/explorer-data.js` (the map's +data) and `explorer.json`. It +draws its pages with the same code as the app, and the two are held to each other page for +page. Use it to publish the site where scripts are not wanted, or to index it for full-text +search. ### Options | Option | Default | What it does | |---|---|---| | `site` | `"explorer"` | `"classic"` builds the earlier site instead | +| `output` | `"app"` | The explorer only: `"static"` writes a page per screen (see "The static export") | | `subDir` | `"site"` | The directory under the `docs` target | | `title` | the project directory's name | The name in the header and the page titles | | `prompts` | none | An extra directory of prompt `.mustache` sources, so the prompt pages can show the text | | `stamp` | none | Footer text. With none, the pages depend on the model alone | -| `assetBase` | `https://cdn.jsdelivr.net/npm` | Where the graph library loads from (see "Offline use") | +| `assetBase` | none | A static explorer only: load the graph libraries from this base and ship no copies (see "Offline use"). The classic site's CDN base | | `target` | `"docs"` | The output target | ### Search Every page has a search box over a built-in index of objects, fields, prompts and -requirements; press `/` to jump to it. For full-text search, run -[Pagefind](https://pagefind.app/) over the output after `meta gen`: +requirements; press `/` to jump to it. For full-text search, build the static export and run +[Pagefind](https://pagefind.app/) over it after `meta gen`: ```bash npx pagefind --site docs/generated/site @@ -70,21 +153,25 @@ Pagefind's output is not generated by `meta gen`, so leave `pagefind/` out of th ### Offline use The map, the mini-maps and the trace draw with [Cytoscape.js](https://js.cytoscape.org/), -loaded from `${assetBase}/cytoscape@3.30.2/dist/cytoscape.min.js`. Only those three kinds of -page load it. Opened without network access, every page still renders and the graphs show a -notice in their place. To serve the file yourself, put -`cytoscape@3.30.2/dist/cytoscape.min.js` under a path of your own and pass that path: +which the site ships as `assets/cytoscape.min.js`, so the explorer needs no network access. +A static export loads it only on those three kinds of page. The map's 3D mode loads +`assets/3d-force-graph.min.js` when a reader first chooses it. To load both from a mirror of +your own instead, give a static export an `assetBase`: its pages then load +`${assetBase}/cytoscape@3.30.2/dist/cytoscape.min.js` and +`${assetBase}/3d-force-graph@1.77.0/dist/3d-force-graph.min.js`, and the site ships no copies. ```ts -docsSiteFile({ assetBase: "/vendor/npm" }) +docsSiteFile({ output: "static", assetBase: "/vendor/npm" }) ``` +If a library does not load, every page still renders and the graph shows a notice. + ## The screens | Screen | Page | What it shows | |---|---|---| | What it does | `index.html` | Six count tiles, the features (`requirement.functional`) as cards by level with their roll-up, and the qualities (`requirement.architectural`). A folded summary slot stays empty: this build makes no LLM call | -| Model map | `map.html` | Every top-level node and the edges between them. Open a slice (a package, a requirement subtree, a prompt), colour by kind, API, claims, capability or status, and hide or show value objects and nodes outside the slice. The URL keeps the choice (`?slice=&colour=&focus=`) | +| Model map | `map.html` | Every top-level node and the edges between them. Open a slice (a package, a requirement subtree, a prompt), colour by kind, API, claims, capability or status, hide or show value objects and nodes outside the slice, and view it flat or in 3D. The URL keeps the choice (`?slice=&colour=&focus=&view=`) | | Object | `model//.html` | Why it exists (the requirements that claim it), its fields, inherited ones marked, relationships, indexes, a one-hop mini-map, its routes and the files generated from it. A projection shows its read model and each field's origin; a report shows where its rows come from, its dimensions and its measures | | Prompt | `model//.html` | The payload and reply types, the template text with each variable marked, and which payload fields the text never uses | | Any other node | `model//.html` | A generic page for every other top-level type, including vocabulary an application registers itself (a `capability.module`, a `page.list`): its attributes, each one linked when the loader resolves it as a reference, its members, the requirements that claim it, what references it and the files generated from it | @@ -130,16 +217,27 @@ copies the templates of both sites to `codegen/docs-site/templates/` (the explor `explorer-*.mustache` files) and their CSS and JS to `codegen/docs-site/assets/` (`explorer.css`, `explorer.js`). Only files that are not there yet are written (`--force` overwrites). `docsSiteFile()` renders with your copies, and a file you did not copy falls back -to the packaged one. A project that ejected the theme before the explorer existed has only the +to the packaged one. The app carries your templates in `explorer-model.js` and draws every +page with them, and writes your CSS and JS in place of its own. The app keeps only each drawn +page's title and body, so what an owned `explorer-head.mustache` adds to `` (a stylesheet, +a `