From 28683dbe8c7828359f0669924cdb692b9da32ee9 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 22:27:01 -0500 Subject: [PATCH 1/7] feat(packs): independent packs skeleton, boundary gates and TypeScript pack conformance (ADR-0069) ADR-0069 records the ruling on independent packs: Metamodel N.M names the default bundle only; an independent pack lives in packs//, carries its own version and changelog, is carried only by the ports its pack.json lists, and is never in expected-registry.json; core never depends on a pack; the provider contract is covered by core's package version. GOVERNANCE.md, extending-with-providers.md, CONFORMANCE.md, compatibility-policy.md and RELEASING.md gain the matching paragraphs. RELEASING.md's stale single-package npm patch section is replaced, and the 1.3.0 changelog line says 13 publish candidates. The skeleton, with no pack in it: - packs/*/typescript joins the root Bun workspace; the root build and typecheck scripts (and the pre-push hook, ci-local.sh and integration-test.sh, which call them) name core's workspace directories instead of --filter '*'. - scripts/check-pack-boundary.ts: core names no pack coordinate or packs/ path, no pack id or pinned type is in the bundle, and core's release gates do not see a planted pack package. - scripts/check-pack-manifests.ts: each pack.json is well formed and agrees with its ports' native manifests. - a packs lane in ci-local.sh (blocking for a pack's own change, a named non-failing SKIP canary on core changes), the lane-map row, the hosted ts matrix entry, packs/README.md and a MAINTAINERS.md area. Pack conformance in TypeScript: runCorpus, a corpus-root entry point in @metaobjectsdev/conformance; createTsAdapter(extraProviders) in the metadata test adapter; scripts/pack-vocabulary.ts (pinned vocabulary plus the leaves-core-alone check) and scripts/pack-conformance.ts. No vocabulary, metamodelVersion, expected-registry.json or package version changes. --- .githooks/pre-push | 4 +- .github/workflows/pr-ci.yml | 6 +- AGENTS.md | 11 +- CHANGELOG.md | 16 +- GOVERNANCE.md | 13 + MAINTAINERS.md | 1 + docs/CONFORMANCE.md | 13 + docs/RELEASING.md | 28 +- docs/compatibility-policy.md | 19 ++ docs/features/extending-with-providers.md | 12 + package.json | 7 +- packs/README.md | 89 ++++++ scripts/check-pack-boundary.ts | 207 +++++++++++++ scripts/check-pack-manifests.ts | 243 +++++++++++++++ scripts/ci-lane-map.txt | 7 +- scripts/ci-local.sh | 97 +++++- scripts/ci-select-lanes.sh | 6 +- scripts/integration-test.sh | 2 +- scripts/lib/packs.ts | 281 +++++++++++++++++ scripts/pack-conformance.ts | 86 ++++++ scripts/pack-vocabulary.ts | 93 ++++++ scripts/packs.test.ts | 288 ++++++++++++++++++ scripts/test-ci-lane-selection.sh | 17 +- .../packages/conformance/src/corpus.ts | 81 +++++ .../packages/conformance/src/index.ts | 1 + .../packages/conformance/test/corpus.test.ts | 60 ++++ .../metadata/test/conformance/adapter.ts | 246 ++++++++------- spec/decisions/ADR-0069-independent-packs.md | 231 ++++++++++++++ spec/decisions/README.md | 1 + 29 files changed, 2015 insertions(+), 151 deletions(-) create mode 100644 packs/README.md create mode 100644 scripts/check-pack-boundary.ts create mode 100644 scripts/check-pack-manifests.ts create mode 100644 scripts/lib/packs.ts create mode 100644 scripts/pack-conformance.ts create mode 100644 scripts/pack-vocabulary.ts create mode 100644 scripts/packs.test.ts create mode 100644 server/typescript/packages/conformance/src/corpus.ts create mode 100644 server/typescript/packages/conformance/test/corpus.test.ts create mode 100644 spec/decisions/ADR-0069-independent-packs.md diff --git a/.githooks/pre-push b/.githooks/pre-push index 6892d1a480..1cf56fadac 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -99,7 +99,7 @@ echo " (skip in an emergency with: git push --no-verify)" >&2 # typecheck resolves cross-package types through each dep's dist/, so build first — # exactly what scripts/ci-local.sh's ts-fast lane does before `typecheck`. -if ! ( cd "$ROOT" && bun run --filter '*' build ) >/tmp/metaobjects-prepush-build.log 2>&1; then +if ! ( cd "$ROOT" && bun run build ) >/tmp/metaobjects-prepush-build.log 2>&1; then echo "" >&2 echo " ✖ pre-push BLOCKED: workspace build failed. Last lines:" >&2 tail -20 /tmp/metaobjects-prepush-build.log | sed 's/^/ /' >&2 @@ -107,7 +107,7 @@ if ! ( cd "$ROOT" && bun run --filter '*' build ) >/tmp/metaobjects-prepush-buil exit 1 fi -if ! ( cd "$ROOT" && bun run --filter '*' typecheck ) >/tmp/metaobjects-prepush-tsc.log 2>&1; then +if ! ( cd "$ROOT" && bun run typecheck ) >/tmp/metaobjects-prepush-tsc.log 2>&1; then echo "" >&2 echo " ✖ pre-push BLOCKED: tsc typecheck is RED. This is the gate CI enforces; do not push red." >&2 echo "" >&2 diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index 7e30d2ce37..961f028d77 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -19,7 +19,9 @@ name: pr-ci # 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): # ts — ts-fast (build + typecheck, conformance, completeness) and ts-unit -# (the per-package suites) +# (the per-package suites), plus packs: the independent packs under +# packs/ (ADR-0069), blocking for a pack the PR touches and a canary that +# reports without failing for every other # java — java-slow: the full reactor build with tests on, which already holds the # java and kotlin conformance classes # python / csharp — the port's full test suite and conformance @@ -97,7 +99,7 @@ jobs: strategy: fail-fast: false matrix: - lane: [ts-fast, ts-unit] + lane: [ts-fast, ts-unit, packs] steps: - uses: actions/checkout@v4 with: diff --git a/AGENTS.md b/AGENTS.md index 8149e58836..43d5eb4e2d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -106,10 +106,11 @@ It blocks commits whose added lines match (`git commit --no-verify` bypasses, di **Pre-push typecheck gate** (`.githooks/pre-push`, same `core.hooksPath`): `bun test` transpiles per-file and does NOT typecheck, so type-broken code can ship green on the -test suite while `bun run --filter '*' typecheck` — the same check `scripts/ci-local.sh` +test suite while `bun run typecheck` — the same check `scripts/ci-local.sh` runs — goes red, and a direct admin push to `main` bypasses branch protection. This hook closes that hole locally: when a push touches -`server/typescript/` or `client/web/`, it runs that same `bun run --filter '*' build && -… typecheck` pair and **blocks the push when it is red** (~6s on a clean tree; +`server/typescript/` or `client/web/`, it runs that same `bun run build && bun run +typecheck` pair (the root scripts, which name core's workspace directories so a pack under +`packs/` is never in them — ADR-0069) and **blocks the push when it is red** (~6s on a clean tree; skipped entirely for non-TS pushes). Bypass in an emergency with `git push --no-verify` or `SKIP_TS_TYPECHECK=1 git push`. @@ -455,8 +456,8 @@ The Bun workspace root is the **repository root** (`/package.json`), which globs bun install # once, at the repo root cd server/typescript && bun test # server suite (per-package; a bare run over the whole server suite now exceeds 5 min — scope it) cd client/web/packages/ && bun test # a single client package -bun run --filter '*' typecheck # whole workspace, from repo root -bun run --filter '*' build # whole workspace, from repo root +bun run typecheck # core's workspace (not packs/), from repo root +bun run build # core's workspace (not packs/), from repo root ``` ## How to contribute diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fe75d6bc1..04396dbbc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,20 @@ here.** ## [Unreleased] +- **Independent packs: the `packs/` directory, its gates and its lane (ADR-0069).** A capability + that is not core vocabulary can now be built in `packs//` with its own version, changelog + and port list, outside the default bundle and outside `metamodelVersion`. No pack exists yet, + and nothing published changes. `scripts/check-pack-boundary.ts` fails a change that makes core + depend on a pack, puts a pack in the bundle, or lets core's release tooling see `packs/`. + `scripts/check-pack-manifests.ts` holds each `pack.json` to its ports' native manifests. + `scripts/pack-vocabulary.ts` pins the rows a pack adds and fails one that changes the bundle's, + and `scripts/pack-conformance.ts` runs a pack's load fixtures through the new corpus-root entry + point `runCorpus` in `@metaobjectsdev/conformance`. A new `packs` lane in `ci-local.sh` blocks + for a pack's own change and reports, without failing, a pack that a core change breaks. The + root `build` and `typecheck` scripts now name core's workspace directories instead of + `--filter '*'`. The provider contract is now named as covered by core's package version + (`docs/compatibility-policy.md`). + - **The deprecated-reference finding ends its sentence before naming the replacement.** It read `…Team: the league no longer tracks teams Replaced by acme::app::Club.`; it now reads `…tracks teams. Replaced by acme::app::Club.` A reason that already ends in `.`, `!` or `?` is left as written. - **C#: `dotnet meta verify` runs the three model authoring lints.** The overlay lint @@ -519,7 +533,7 @@ four `rules.*` and `verify.lifecycle.unreachable` settings, held to `fixtures/ru ## [1.3.0] — unreleased -_npm `1.3.0` (full lockstep across all 14 `@metaobjectsdev/*` publish candidates)._ +_npm `1.3.0` (full lockstep across all 13 `@metaobjectsdev/*` publish candidates)._ **New metamodel vocabulary, experimental: `api.*`, `operation.*`, `binding.*` and `transition.*` (ADR-0066).** It is additive: nothing that loaded before stops loading. This vocabulary ships in diff --git a/GOVERNANCE.md b/GOVERNANCE.md index 79baa84b82..72f5f59627 100644 --- a/GOVERNANCE.md +++ b/GOVERNANCE.md @@ -117,6 +117,19 @@ MetaObjects, in the way the [`library/`](library/) entries do (see which provider registers the attribute. It does not rename it or change what it does, so a model that used the attribute under the pack loads and behaves the same once core owns it. +A pack in this repository is one of two kinds +([ADR-0069](spec/decisions/ADR-0069-independent-packs.md)). A **bundled pack** (`db`, `rules`, +`reporting`, `requirements` and the others) ships inside each port's core package, is in the +default bundle and in `expected-registry.json`, and moves with core's version. An **independent +pack** lives in [`packs//`](packs/README.md), is outside the default bundle, has its own +version and changelog, and is carried only by the ports its `pack.json` lists. Metamodel N.M +names the default bundle only. A pack may depend on core; core never depends on a pack, and the +`gates` lane fails a change that makes it. A new independent pack starts at `0.1.0` `preview` and +stays unpublished until an estate project runs it with the drift gate enforced. Because they are +the rulings this rests on, changing the kinds, the one-way dependency or the naming rule is a +model-format and compatibility change, and so needs a core maintainer. Building a pack inside +those rules does not. + ### Releases The core maintainers decide when a release happens, what version it carries, and what goes in diff --git a/MAINTAINERS.md b/MAINTAINERS.md index e92bca09df..da3567a014 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -26,6 +26,7 @@ maintainer. Every area is open. | Metamodel spec and conformance corpora (core-maintainer approval always applies) | `spec/`, `fixtures/` | Maintainer wanted | | Documentation and the docs-site generator | `docs/`, `server/typescript/packages/docs-site/` | Maintainer wanted | | Libraries (`ai`, `iam`) | `library/` | Maintainer wanted | +| Independent packs (each pack its own area once it has a maintainer; [ADR-0069](spec/decisions/ADR-0069-independent-packs.md)) | `packs/` | Maintainer wanted | | Agent context (skills, `AGENTS.md` sources, `llms.txt`) | `agent-context/` | Maintainer wanted | | CI and release tooling | `scripts/`, `.github/` | Maintainer wanted | diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index e637ae10b0..2eedb1e17f 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -433,6 +433,19 @@ unit-test runners (`bun test`, `dotnet test`, `pytest`, `mvn test`) pull Docker. `scripts/integration-test.sh` is the entry point and is wired into [`docs/RELEASING.md`](RELEASING.md) §2b as the pre-`latest` gate. +### Independent packs: their own corpora, outside these counts + +An independent pack ([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)) keeps its tests +in `packs//fixtures/`, never in `fixtures/`, so pack work moves none of the totals, rows or +matrix cells on this page. Each pack has a pinned vocabulary +(`packs//fixtures/expected-vocabulary.json`, the rows it adds to the default bundle, which +every port that carries the pack byte-matches) and load fixtures in the shared format +(`packs//fixtures/conformance/`), run in TypeScript through the corpus-root entry point +`runCorpus` of `@metaobjectsdev/conformance`. The `packs` lane runs them, blocking for the +pack's own change and as a canary on core changes. The port rule differs from the bundle's here, +and only here: a port either carries the pack's provider and passes its whole corpus, or does not +carry it, and a model that uses it fails there by name. There is no row per pack on this page. + ## Fixture-to-doc mapping ### `fixtures/conformance/` — metamodel loader + canonical serializer (584) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index ee7a48897c..136792340a 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -731,9 +731,31 @@ never reach `main`. ## Isolated patch (one package) -If only one package changed (e.g. a `cli` bugfix), bump just that package, `rm bun.lock && bun -install`, verify, run `node scripts/eject-release-gate.mjs ` (it must exit 0), and -`bun publish` it. The others stay at their current version. Tag scoped (e.g. `cli-v0.5.1`). +There is no single-package release on npm. The 13 `@metaobjectsdev/*` packages move atomically: +the publish set is `scripts/publish-set.mjs`, and a fix to one of them (a `cli` bugfix, say) is a +patch release of all 13, cut by the procedure above. What a patch can leave out is a +*registry*: a registry with no changed product file sits the release out, under the +convergent-publishing rule. A package that needs a release line of its own is an independent +pack, never a core package published alone. + +## Independent packs (`packs/`) + +An independent pack ([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)) is not part of +a core release, and a core release never waits for one. Nothing in this procedure touches +`packs/`: `scripts/publish-set.mjs`, `check-publish-intent.sh` and +`check-no-prerelease-versions.sh` do not enumerate it (`scripts/check-pack-boundary.ts` proves +that in the `gates` lane), a pack's changelog is `packs//CHANGELOG.md` and not the root +one, and a red pack canary is not a reason to hold a core cut. Pack work never needs the +maintenance-branch procedure either, because core can be cut from `main` with pack work in +flight. + +A pack is released on its own, tagged `pack--v`. Core's tag patterns, the site +deploy and the metamodel gate's baseline all ignore that tag. Until a pack is published +(`"publish": false` in `pack.json`, `"private": true` on its npm package), adopter projects use +it from the private prerelease registry (`docs/features/prerelease.md`). It publishes once an +estate project runs it with the drift gate enforced. The pack release script, the pack version +gate and the test against the lowest published core in its range are built before that first +publish. # Releasing the C# packages to NuGet diff --git a/docs/compatibility-policy.md b/docs/compatibility-policy.md index d7d34d82fc..9cdc063fb2 100644 --- a/docs/compatibility-policy.md +++ b/docs/compatibility-policy.md @@ -56,6 +56,11 @@ work*. A release can move one without the other, and most releases move neither. scaffold wires: codegen is opt-in and the scaffolded selection is empty by design (ADR-0034 Amendment 2), so changing what `meta init` starts you with changes nothing for a project that already exists. +- **The provider contract** — what a provider of your own, or an independent pack, is written + against: a provider's `id`, `dependencies` and `registerTypes`; the registry's `register`, + `extend` and `registerCommonAttrs`; and the provider definition file format + ([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)). A pack's core range + (`>=1.3.0 <2.0.0`) means something because of this line. > **What this costs you, stated plainly.** Post-1.0 the caret rule stops being a gate — > `^1.0.0` accepts `1.1.0` — so a metamodel change can reach you on a routine update @@ -83,6 +88,20 @@ work*. A release can move one without the other, and most releases move neither. drift gate enforced. Until then a model that declares none of it is unaffected by any change to it. +## Independent packs (`packs/`) + +An independent pack ([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)) is **outside +both of core's numbers**. `metamodelVersion` names the default bundle only, and a pack is never +in it, so a pack's vocabulary change never moves it. A pack's npm, Maven, PyPI or NuGet package +is never in core's lockstep set, so a pack release never moves a core package. Each pack carries +one version of its own in `packs//pack.json`, the same in every port that carries it. A +break in its vocabulary, or in what a project writes to use it, is a major (a minor while `0.x`). +Added vocabulary is a minor, and a generator output change is a patch. A pack states the core it +needs as a bounded range in each port's native manifest (npm as a peer dependency), and core's +side of that range is the provider contract above. A pack starts at `0.1.0` `preview`, which +allows any change in any release, and its stability label is a fact about the pack, not about +core. + ## Shipped libraries (`libraries: [...]`) _Which pieces carry which label today is listed in [Stability labels](features/stability-labels.md); that page is a list of facts and adds no promise._ diff --git a/docs/features/extending-with-providers.md b/docs/features/extending-with-providers.md index 04313d20fc..9466e16c3e 100644 --- a/docs/features/extending-with-providers.md +++ b/docs/features/extending-with-providers.md @@ -148,6 +148,18 @@ Cross-port rules still hold. Every port registers the same default composition, `expected-registry.json` is what all five byte-match, so a pack leaves the default bundle only by a decision recorded against that manifest, never per port. +**Independent packs.** A provider maintained in this repository does not have to be in the +default bundle. An *independent pack* ([ADR-0069](../../spec/decisions/ADR-0069-independent-packs.md)) +lives in [`packs//`](../../packs/README.md) with its own version, changelog and list of +ports. A project opts in by naming its provider, exactly as it wires any provider of its own +(below). It is the same contract on the same registry. What differs is the promise: it is outside +`expected-registry.json` and `metamodelVersion`, a port carries it or does not (and then a model +that uses it fails there by name), and its own tests pin the rows it adds and check that it +changes none of the bundle's. Write a provider there when the capability belongs to the project +but is not yet core vocabulary. The contract the provider is written against (`id`, +`dependencies`, `registerTypes`, `register`, `extend`, `registerCommonAttrs` and the definition +file format) is covered by core's package version (`docs/compatibility-policy.md`). + ## Two registration modes ### `register` — declare a new `(type, subType)` diff --git a/package.json b/package.json index 0fa436d54b..3f79a665b6 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,12 @@ "workspaces": [ "server/typescript/packages/*", "client/web/packages/*", - "examples/dynamic-grid" + "examples/dynamic-grid", + "packs/*/typescript" ], "scripts": { - "build": "bun run --filter '*' build", - "typecheck": "bun run --filter '*' typecheck", + "build": "bun run --filter './server/typescript/packages/*' --filter './client/web/packages/*' --filter './examples/dynamic-grid' build", + "typecheck": "bun run --filter './server/typescript/packages/*' --filter './client/web/packages/*' --filter './examples/dynamic-grid' typecheck", "test": "cd server/typescript && bun test", "regen:showcase": "bun scripts/regen-showcase.ts", "site:payload": "bun scripts/build-site-payload.ts", diff --git a/packs/README.md b/packs/README.md new file mode 100644 index 0000000000..ca3ae1e3a4 --- /dev/null +++ b/packs/README.md @@ -0,0 +1,89 @@ +# Independent packs + +A directory here is an **independent pack**: vocabulary, generators and runtime for a capability +that is not part of core, built and versioned as if it were its own repository +([ADR-0069](../spec/decisions/ADR-0069-independent-packs.md)). None exists yet. + +An independent pack is not in the default bundle. A project opts in by naming its provider. It is +never in `fixtures/registry-conformance/expected-registry.json` and never moves +`metamodelVersion`. It has its own version, its own changelog, and its own list of the ports that +carry it. The bundled packs (`db`, `rules`, `reporting`, `requirements` and the others) are a +different kind: they ship inside each port's core package and do not live here. + +## The one rule + +A pack may depend on core and on other packs. **Core never depends on a pack.** Nothing outside +this directory names a pack package or a path in it, except the root workspace glob +`packs/*/typescript`. `scripts/check-pack-boundary.ts` (the `gates` lane) fails the build +otherwise. + +## Layout + +``` +packs// + pack.json the manifest (below) + CHANGELOG.md this pack's changelog; pack work never writes the root CHANGELOG.md + README.md + metamodel/*.json the vocabulary definition, in the spec/metamodel/ format + fixtures/ + expected-vocabulary.json the rows this pack adds to the default bundle (generated) + conformance// load fixtures, in the shared format; providers.json names the pack + ERROR-CODES.json only if the pack defines error codes of its own + typescript/ @metaobjectsdev/pack-, a member of the root Bun workspace + package.json peer @metaobjectsdev/metadata in the core range, dev workspace:*, + a "typecheck" script, "private": true while unpublished + src/index.ts exports `provider`, whose id is pack.json's id + conformance-expected-failures.json optional: the TypeScript port's known gaps + java/ kotlin/ python/ csharp/ rust/ only for the ports pack.json lists +``` + +## `pack.json` + +```json +{ + "id": "metaobjects-", + "version": "0.1.0", + "stability": "preview", + "requires": { "metamodel": ">=1.3 <2", "packs": {} }, + "ports": { + "typescript": { "package": "@metaobjectsdev/pack-", "core": ">=1.3.0 <2.0.0", "publish": false } + } +} +``` + +| Field | Rule | +|---|---| +| `id` | `metaobjects-`, the provider id | +| `version` | `X.Y.Z`; one number for every port; every pack starts at `0.1.0` | +| `stability` | `experimental`, `preview` or `stable` (`docs/features/stability-labels.md`); a pack starts `preview` | +| `requires.metamodel` | the metadata contract the vocabulary is written against, with an upper bound | +| `requires.packs` | `{ "": "" }` for packs in this directory, each range bounded | +| `ports..package` | npm `@metaobjectsdev/pack-`, Maven `com.metaobjects.packs:` (Kotlin `com.metaobjects.packs:-`), PyPI `metaobjects-pack-`, NuGet `MetaObjects.Packs.`, Cargo `metaobjects-pack-` | +| `ports..core` | the core range that port's native manifest states (npm peer range, NuGet `[1.3.0,2.0.0)`, PyPI `>=1.3,<2`, ...) | +| `ports..publish` | `false` until an estate project runs the pack with the drift gate enforced | + +`scripts/check-pack-manifests.ts` (the `gates` lane) checks every field and checks that each +native manifest agrees with it. + +## Checks + +``` +bun scripts/pack-vocabulary.ts --write # regenerate fixtures/expected-vocabulary.json +bun scripts/pack-vocabulary.ts # the pin is current and the pack leaves core alone +bun scripts/pack-conformance.ts # run fixtures/conformance/ through the TypeScript port +scripts/ci-local.sh --only packs # all of the above, plus typecheck and the pack's tests +``` + +"Leaves core alone" means that composing the pack onto the default bundle changes no row of the +bundle's own registry manifest. A pack may add types, optional attributes and child rules on +bundle types (ADR-0050), and common attributes. It may change nothing the bundle declares. + +The `packs` lane blocks for a change to a pack's own files. On a core change it runs as a +canary: a pack the change breaks is reported as a named SKIP and fixed in the pack's own pull +request. + +## The port rule + +A port either carries the pack's provider and passes its whole corpus, or does not carry it, in +which case a model that uses the pack fails there with an error naming what it does not know. +Bundled vocabulary keeps the stricter rule (every port registers it). diff --git a/scripts/check-pack-boundary.ts b/scripts/check-pack-boundary.ts new file mode 100644 index 0000000000..51651382dc --- /dev/null +++ b/scripts/check-pack-boundary.ts @@ -0,0 +1,207 @@ +#!/usr/bin/env bun +/** + * Gate — core and the independent packs stay separable (ADR-0069, "The boundary"). + * + * Core is released from `main` at any moment, with pack work in flight, only while + * these hold. Each is a property a refactor could quietly break, so each is checked: + * + * 1. Core never refers to a pack. No manifest, import or build file outside packs/ + * names a pack's coordinate (`@metaobjectsdev/pack-*`, `com.metaobjects.packs`, + * `metaobjects-pack-*`, `metaobjects_pack_*`, `MetaObjects.Packs.*`) or reaches into + * packs/ by path. The one sanctioned mention is the root workspace glob, which is + * how a pack builds against core's working tree; core's own build and typecheck + * scripts are scoped so that glob never pulls a pack into them. + * 2. No independent pack is in the default bundle. No pack's provider id appears in + * core's source or shared fixtures, and no type a pack pins appears in + * fixtures/registry-conformance/expected-registry.json, so a pack can never move + * `metamodelVersion`. + * 3. Core's release tooling does not enumerate packs/. Today that is true because the + * publish set and its two gates list two workspace directories by name; this gate + * plants a public pack package in a scratch copy of the release manifests and + * asserts none of them sees it, so a later "every package.json" refactor fails here. + * + * The fourth rule of the ADR — a pack-only change selects only the packs lane — is a + * row in scripts/ci-lane-map.txt, asserted by scripts/test-ci-lane-selection.sh. + * + * scripts/ is release and CI tooling, not core product, so it may know about packs and + * is not scanned. Markdown is not scanned: the ADR and the policy pages describe packs. + * + * Usage: bun scripts/check-pack-boundary.ts [--root ] [--skip-release-scan] + */ +import { spawnSync } from "node:child_process"; +import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { PACK_VOCABULARY, REPO_ROOT, listPackDirs, packsById } from "./lib/packs.js"; + +/** Top-level trees that hold core product, its shared corpora and its spec. */ +export const CORE_TREES = [ + "server", "client", "examples", "library", "spec", "fixtures", "templates", + "agent-context", "agent-context-shipped", "tools", "metaobjects", +] as const; + +/** Files a build, an installer or a loader reads. Prose (.md) is deliberately absent. */ +const SCANNED = /(\.(ts|tsx|mts|cts|js|mjs|cjs|json|jsonc|ya?ml|java|kt|kts|cs|csproj|props|targets|py|rs|toml|xml|gradle|sh)|(^|\/)(package\.json|pom\.xml|Cargo\.toml|pyproject\.toml))$/; + +const PACK_COORDINATE = /@metaobjectsdev\/pack-[a-z0-9]|com\.metaobjects\.packs|metaobjects-pack-[a-z0-9]|metaobjects_pack_[a-z0-9]|MetaObjects\.Packs\./; +const INTO_PACKS = /(^|[^A-Za-z0-9_.-])(\.\.\/)+packs\//; + +/** The root workspace entry that lets a pack join the Bun workspace (ADR-0069). */ +export const PACK_WORKSPACE_GLOB = "packs/*/typescript"; + +const SKIP_DIRS = new Set(["node_modules", ".git", ".stryker-tmp", "target", "obj", ".venv", "__pycache__"]); + +function walk(root: string, rel: string, out: string[]): void { + const abs = join(root, rel); + if (!existsSync(abs)) return; + if (statSync(abs).isFile()) { + out.push(rel); + return; + } + for (const n of readdirSync(abs)) { + if (SKIP_DIRS.has(n)) continue; + walk(root, rel === "" ? n : `${rel}/${n}`, out); + } +} + +/** Core's files: tracked and untracked-but-not-ignored when `root` is a git work tree, else a walk. */ +export function coreFiles(root: string): string[] { + const git = spawnSync("git", ["-C", root, "ls-files", "-co", "--exclude-standard", "--", ...CORE_TREES], { encoding: "utf8", maxBuffer: 1 << 28 }); + const files: string[] = []; + if (git.status === 0 && existsSync(join(root, ".git"))) { + files.push(...git.stdout.split("\n").filter((f) => f !== "")); + } else { + for (const t of CORE_TREES) walk(root, t, files); + } + return files.filter((f) => SCANNED.test(f) && existsSync(join(root, f))); +} + +/** Rule 1 and the source half of rule 2. */ +export function scanCore(root: string): string[] { + const out: string[] = []; + const ids = [...packsById(root).keys()]; + for (const rel of coreFiles(root)) { + const text = readFileSync(join(root, rel), "utf8"); + if (!PACK_COORDINATE.test(text) && !INTO_PACKS.test(text) && !ids.some((id) => text.includes(id))) continue; + const lines = text.split("\n"); + lines.forEach((line, i) => { + const at = `${rel}:${i + 1}`; + if (PACK_COORDINATE.test(line)) out.push(`${at}: core names a pack coordinate — core may never depend on a pack`); + else if (INTO_PACKS.test(line)) out.push(`${at}: core reaches into packs/ by path — core may never depend on a pack`); + for (const id of ids) { + if (new RegExp(`(^|[^A-Za-z0-9_-])${id}([^A-Za-z0-9_-]|$)`).test(line)) { + out.push(`${at}: names the independent pack provider "${id}" — an independent pack is never in the default bundle`); + } + } + }); + } + // The root manifest may mention packs/ exactly once: the workspace glob. + const rootPkgPath = join(root, "package.json"); + if (existsSync(rootPkgPath)) { + const pkg = JSON.parse(readFileSync(rootPkgPath, "utf8")) as { workspaces?: string[]; scripts?: Record }; + for (const ws of pkg.workspaces ?? []) { + if (ws.startsWith("packs/") && ws !== PACK_WORKSPACE_GLOB) out.push(`package.json: workspace "${ws}" — packs join only as "${PACK_WORKSPACE_GLOB}"`); + } + for (const name of ["build", "typecheck"]) { + const cmd = pkg.scripts?.[name] ?? ""; + if (/--filter\s+['"]?\*['"]?(\s|$)/.test(cmd) || /pack-/.test(cmd)) { + out.push(`package.json: the "${name}" script must name core's workspace directories, not '*' (which takes in every pack)`); + } + } + } + return out; +} + +/** The registry half of rule 2: a type a pack pins is never in the bundle's manifest. */ +export function scanRegistry(root: string): string[] { + const out: string[] = []; + const registryPath = join(root, "fixtures/registry-conformance/expected-registry.json"); + const providersPath = join(root, "fixtures/registry-conformance/providers.json"); + const bundleTypes = existsSync(registryPath) + ? new Set((JSON.parse(readFileSync(registryPath, "utf8")) as { types: { type: string; subType: string }[] }).types.map((t) => `${t.type}.${t.subType}`)) + : new Set(); + const bundleIds = existsSync(providersPath) + ? new Set(Object.keys((JSON.parse(readFileSync(providersPath, "utf8")) as { providers: Record }).providers)) + : new Set(); + for (const [id, name] of packsById(root)) { + if (bundleIds.has(id)) out.push(`packs/${name}: provider id "${id}" is a bundled provider (fixtures/registry-conformance/providers.json)`); + const pin = join(root, "packs", name, PACK_VOCABULARY); + if (!existsSync(pin)) continue; + const types = (JSON.parse(readFileSync(pin, "utf8")) as { types?: { type: string; subType: string }[] }).types ?? []; + for (const t of types) { + if (bundleTypes.has(`${t.type}.${t.subType}`)) { + out.push(`packs/${name}/${PACK_VOCABULARY}: ${t.type}.${t.subType} is also in expected-registry.json — a pack type may not enter the bundle`); + } + } + } + return out; +} + +/** Copy only what core's release gates read into a scratch root. */ +function releaseSkeleton(root: string, scratch: string): void { + const copy = (rel: string): void => { + const from = join(root, rel); + if (!existsSync(from)) return; + mkdirSync(dirname(join(scratch, rel)), { recursive: true }); + cpSync(from, join(scratch, rel)); + }; + for (const s of ["publish-set.mjs", "check-publish-intent.sh", "check-no-prerelease-versions.sh"]) copy(`scripts/${s}`); + for (const ws of ["server/typescript/packages", "client/web/packages"]) { + const dir = join(root, ws); + if (!existsSync(dir)) continue; + for (const n of readdirSync(dir)) copy(`${ws}/${n}/package.json`); + } + for (const f of ["server/python/pyproject.toml", "server/csharp/Directory.Build.props", "server/java/pom.xml", "package.json"]) copy(f); +} + +/** Rule 3: plant a public pack package next to core's manifests and assert no release gate sees it. */ +export function scanReleaseTooling(root: string): string[] { + const out: string[] = []; + if (!existsSync(join(root, "scripts/publish-set.mjs"))) return out; + const scratch = mkdtempSync(join(process.env.DEV_SCRATCH ?? tmpdir(), "mo-pack-boundary-")); + try { + releaseSkeleton(root, scratch); + const cli = JSON.parse(readFileSync(join(scratch, "server/typescript/packages/cli/package.json"), "utf8")) as { version: string }; + // Two planted packages, each the worst case for one gate: one public at core's + // lockstep version (a publish set that swept packs/ would ship it), one public and + // off the line at a pre-release version (publish-intent and the pre-release guard + // would refuse it if they read packs/). + const plant = (name: string, version: string): void => { + const dir = join(scratch, "packs", name, "typescript"); + mkdirSync(dir, { recursive: true }); + writeFileSync(join(dir, "package.json"), JSON.stringify({ name: `@metaobjectsdev/pack-${name}`, version }, null, 2)); + }; + plant("boundary-lockstep", cli.version); + plant("boundary-offline", "0.1.0-rc.1"); + + const set = spawnSync("node", ["--input-type=module", "-e", + `import { publishSet } from ${JSON.stringify(join(scratch, "scripts/publish-set.mjs"))};` + + `console.log(JSON.stringify(publishSet({ root: ${JSON.stringify(scratch)} }).set.map((p) => p.pkg.name)));`], { encoding: "utf8" }); + if (set.status !== 0) out.push(`scripts/publish-set.mjs: could not derive the publish set in a scratch root: ${set.stderr.trim()}`); + else if (/pack-/.test(set.stdout)) out.push(`scripts/publish-set.mjs: the publish set took in a package under packs/ (${set.stdout.trim()})`); + + for (const gate of ["check-publish-intent.sh", "check-no-prerelease-versions.sh"]) { + const r = spawnSync("bash", [join(scratch, "scripts", gate)], { encoding: "utf8" }); + if (r.status !== 0) out.push(`scripts/${gate}: fails once a pack package exists under packs/ — it must not enumerate packs/\n${(r.stdout + r.stderr).trim()}`); + } + } finally { + rmSync(scratch, { recursive: true, force: true }); + } + return out; +} + +export function checkPackBoundary(root: string = REPO_ROOT, opts: { releaseScan?: boolean } = {}): string[] { + return [...scanCore(root), ...scanRegistry(root), ...(opts.releaseScan === false ? [] : scanReleaseTooling(root))]; +} + +if (import.meta.main) { + const i = process.argv.indexOf("--root"); + const root = i > 0 && process.argv[i + 1] !== undefined ? process.argv[i + 1]! : REPO_ROOT; + const problems = checkPackBoundary(root, { releaseScan: !process.argv.includes("--skip-release-scan") }); + if (problems.length > 0) { + console.error(`pack boundary: ${problems.length} problem(s) (ADR-0069)`); + for (const p of problems) console.error(` ✖ ${p}`); + process.exit(1); + } + console.log(`pack boundary: OK (${listPackDirs(root).length} pack(s); core names none, the bundle holds none, the release tooling sees none)`); +} diff --git a/scripts/check-pack-manifests.ts b/scripts/check-pack-manifests.ts new file mode 100644 index 0000000000..df45d0f922 --- /dev/null +++ b/scripts/check-pack-manifests.ts @@ -0,0 +1,243 @@ +#!/usr/bin/env bun +/** + * Gate — every independent pack's `pack.json` is well formed and agrees with the + * native manifest of each port that carries it (ADR-0069). + * + * `pack.json` is the pack's one statement about itself: its provider id, its version, + * its stability, the metamodel and the other packs it needs, and which ports carry it. + * An installer never reads it; npm, Maven, PyPI, NuGet and Cargo read their own files. + * So the two can drift, and when they do the installer enforces the wrong range. This + * gate fails the build on that drift instead. + * + * Checked for every directory under packs/: + * - pack.json parses and names `metaobjects-`, an X.Y.Z version, a stability word, + * a bounded metamodel range, packs that exist here, and at least one port. + * - a port directory exists exactly for each port pack.json lists. + * - README.md and CHANGELOG.md exist (a pack's changelog never goes in the root one). + * - each native manifest carries the coordinate the naming rule gives that port, the + * pack's version, and the core range pack.json states. + * - TypeScript, in full: a `private` flag that matches `publish`, core as a bounded + * peer range (never a dependency, so a project never gets a second copy of + * `@metaobjectsdev/metadata`), a `workspace:*` dev dependency to build against core's + * working tree, a `typecheck` script, and the pinned vocabulary the pack lane checks. + * + * Usage: bun scripts/check-pack-manifests.ts [--root ] + */ +import { existsSync, readFileSync, readdirSync } from "node:fs"; +import { join } from "node:path"; +import { + PACK_MANIFEST, + PACK_PORTS, + PACK_STABILITIES, + PACK_VOCABULARY, + REPO_ROOT, + expectedPackage, + listPackDirs, + packageMatches, + packProviderId, + packsById, + type PackManifest, + type PackPort, +} from "./lib/packs.js"; + +const NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/; +const SEMVER = /^\d+\.\d+\.\d+$/; +const CORE_NPM = "@metaobjectsdev/metadata"; + +/** A range is bounded when it states an upper limit: `; + dependencies?: Record; + peerDependencies?: Record; + devDependencies?: Record; + }; + if (pkg.name !== entry.package) out.push(`${where}: name is "${pkg.name}", pack.json says "${entry.package}"`); + if (pkg.version !== m.version) out.push(`${where}: version is "${pkg.version}", pack.json says "${m.version}"`); + if ((pkg.private === true) !== !entry.publish) { + out.push(`${where}: "private" must be ${!entry.publish} while pack.json says publish: ${entry.publish}`); + } + const peer = pkg.peerDependencies?.[CORE_NPM]; + if (peer !== entry.core) out.push(`${where}: peerDependencies["${CORE_NPM}"] is "${peer}", pack.json says "${entry.core}"`); + if (pkg.devDependencies?.[CORE_NPM] !== "workspace:*") { + out.push(`${where}: devDependencies["${CORE_NPM}"] must be "workspace:*" so the pack builds against core's working tree`); + } + for (const dep of Object.keys(pkg.dependencies ?? {})) { + if (dep.startsWith("@metaobjectsdev/") && !dep.startsWith("@metaobjectsdev/pack-")) { + out.push(`${where}: "${dep}" is a dependency; a core package must be a peer dependency (one copy per project)`); + } + } + if (pkg.scripts?.typecheck === undefined) out.push(`${where}: needs a "typecheck" script (the packs lane runs it)`); + if (!existsSync(join(dir, "..", PACK_VOCABULARY))) { + out.push(`packs/${name}/${PACK_VOCABULARY}: missing — run bun scripts/pack-vocabulary.ts ${name} --write`); + } +} + +/** The first value of `` at the top level of a pom, ignoring and . */ +function pomTag(pom: string, tag: string): string | undefined { + const top = pom.replace(/[\s\S]*?<\/parent>/, "").replace(/[\s\S]*?<\/dependencies>/g, ""); + return new RegExp(`<${tag}>\\s*([^<]+?)\\s*`).exec(top)?.[1]; +} + +function checkMaven(port: "java" | "kotlin", name: string, m: PackManifest, dir: string, out: Problems): void { + const entry = m.ports[port]; + if (entry === undefined) return; + const where = `packs/${name}/${port}/pom.xml`; + const pom = readText(join(dir, "pom.xml")); + if (pom === undefined) { + out.push(`${where}: missing`); + return; + } + const coord = `${pomTag(pom, "groupId")}:${pomTag(pom, "artifactId")}`; + if (coord !== entry.package) out.push(`${where}: coordinate is "${coord}", pack.json says "${entry.package}"`); + if (pomTag(pom, "version") !== m.version) out.push(`${where}: version is "${pomTag(pom, "version")}", pack.json says "${m.version}"`); + // Maven cannot express a range an installer enforces the way npm does: the pom depends + // on core's floor with `provided` scope and pack.json carries the range. + if (!/\s*provided\s*<\/scope>/.test(pom)) out.push(`${where}: core must be a provided-scope dependency`); +} + +function checkPython(name: string, m: PackManifest, dir: string, out: Problems): void { + const entry = m.ports.python; + if (entry === undefined) return; + const where = `packs/${name}/python/pyproject.toml`; + const toml = readText(join(dir, "pyproject.toml")); + if (toml === undefined) { + out.push(`${where}: missing`); + return; + } + const field = (k: string): string | undefined => new RegExp(`^${k}\\s*=\\s*"([^"]*)"`, "m").exec(toml)?.[1]; + if (field("name") !== entry.package) out.push(`${where}: name is "${field("name")}", pack.json says "${entry.package}"`); + if (field("version") !== m.version) out.push(`${where}: version is "${field("version")}", pack.json says "${m.version}"`); + if (!toml.includes(`"metaobjects${entry.core}"`)) out.push(`${where}: dependencies must list "metaobjects${entry.core}"`); +} + +function checkCSharp(name: string, m: PackManifest, dir: string, out: Problems): void { + const entry = m.ports.csharp; + if (entry === undefined) return; + const projects = existsSync(dir) ? readdirSync(dir).filter((f) => f.endsWith(".csproj")) : []; + if (projects.length !== 1) { + out.push(`packs/${name}/csharp: needs exactly one .csproj (found ${projects.length})`); + return; + } + const where = `packs/${name}/csharp/${projects[0]}`; + const proj = readFileSync(join(dir, projects[0]!), "utf8"); + const tag = (t: string): string | undefined => new RegExp(`<${t}>\\s*([^<]+?)\\s*`).exec(proj)?.[1]; + if (tag("PackageId") !== entry.package) out.push(`${where}: PackageId is "${tag("PackageId")}", pack.json says "${entry.package}"`); + if (tag("Version") !== m.version) out.push(`${where}: Version is "${tag("Version")}", pack.json says "${m.version}"`); + const ref = / new RegExp(`^${k}\\s*=\\s*"([^"]*)"`, "m").exec(toml)?.[1]; + if (field("name") !== entry.package) out.push(`${where}: name is "${field("name")}", pack.json says "${entry.package}"`); + if (field("version") !== m.version) out.push(`${where}: version is "${field("version")}", pack.json says "${m.version}"`); + if (!new RegExp(`^metaobjects\\s*=.*"${entry.core.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}"`, "m").test(toml)) { + out.push(`${where}: the metaobjects dependency must be "${entry.core}"`); + } +} + +/** Every problem with every pack under `/packs/`; empty when all agree. */ +export function checkPackManifests(root: string = REPO_ROOT): string[] { + const out: Problems = []; + const ids = packsById(root); + for (const name of listPackDirs(root)) { + const base = join(root, "packs", name); + const where = `packs/${name}/${PACK_MANIFEST}`; + if (!NAME.test(name)) out.push(`packs/${name}: a pack directory name is lower-case kebab-case`); + let m: PackManifest; + try { + m = JSON.parse(readFileSync(join(base, PACK_MANIFEST), "utf8")) as PackManifest; + } catch (e) { + out.push(`${where}: ${existsSync(join(base, PACK_MANIFEST)) ? `does not parse (${(e as Error).message})` : "missing"}`); + continue; + } + if (m.id !== packProviderId(name)) out.push(`${where}: id is "${m.id}", must be "${packProviderId(name)}"`); + if (typeof m.version !== "string" || !SEMVER.test(m.version)) out.push(`${where}: version "${m.version}" is not X.Y.Z`); + if (!(PACK_STABILITIES as readonly string[]).includes(m.stability)) { + out.push(`${where}: stability "${m.stability}" is not one of ${PACK_STABILITIES.join(", ")}`); + } + const metamodel = m.requires?.metamodel; + if (typeof metamodel !== "string" || !bounded(metamodel)) { + out.push(`${where}: requires.metamodel "${metamodel}" must be a range with an upper bound`); + } + for (const [dep, range] of Object.entries(m.requires?.packs ?? {})) { + if (!ids.has(dep)) out.push(`${where}: requires pack "${dep}", which is not in packs/`); + if (!bounded(range)) out.push(`${where}: the range on "${dep}" ("${range}") needs an upper bound`); + } + for (const file of ["README.md", "CHANGELOG.md"]) { + if (!existsSync(join(base, file))) out.push(`packs/${name}/${file}: missing`); + } + const listed = Object.keys(m.ports ?? {}); + if (listed.length === 0) out.push(`${where}: ports lists no port`); + for (const port of listed) { + if (!(PACK_PORTS as readonly string[]).includes(port)) out.push(`${where}: unknown port "${port}"`); + } + for (const port of PACK_PORTS) { + const entry = m.ports?.[port]; + const present = existsSync(join(base, port)); + if (entry === undefined) { + if (present) out.push(`packs/${name}/${port}: the directory exists but pack.json does not list the port`); + continue; + } + if (!present) out.push(`packs/${name}/${port}: pack.json lists the port but the directory is missing`); + if (!packageMatches(port as PackPort, name, entry.package)) { + out.push(`${where}: ports.${port}.package is "${entry.package}", the naming rule gives "${expectedPackage(port as PackPort, name)}"`); + } + if (typeof entry.core !== "string" || !bounded(entry.core)) { + out.push(`${where}: ports.${port}.core "${entry.core}" must be a range with an upper bound`); + } + if (typeof entry.publish !== "boolean") out.push(`${where}: ports.${port}.publish must be true or false`); + if (!present) continue; + const dir = join(base, port); + if (port === "typescript") checkTypeScript(name, m, dir, out); + else if (port === "java" || port === "kotlin") checkMaven(port, name, m, dir, out); + else if (port === "python") checkPython(name, m, dir, out); + else if (port === "csharp") checkCSharp(name, m, dir, out); + else checkRust(name, m, dir, out); + } + } + return out; +} + +if (import.meta.main) { + const i = process.argv.indexOf("--root"); + const root = i > 0 && process.argv[i + 1] !== undefined ? process.argv[i + 1]! : REPO_ROOT; + const packs = listPackDirs(root); + const problems = checkPackManifests(root); + if (problems.length > 0) { + console.error(`pack manifests: ${problems.length} problem(s)`); + for (const p of problems) console.error(` ✖ ${p}`); + process.exit(1); + } + console.log(`pack manifests: OK (${packs.length} pack${packs.length === 1 ? "" : "s"})`); +} diff --git a/scripts/ci-lane-map.txt b/scripts/ci-lane-map.txt index f9ee7acc22..c05dc8536d 100644 --- a/scripts/ci-lane-map.txt +++ b/scripts/ci-lane-map.txt @@ -10,7 +10,7 @@ # space-separated lane names, or one of two words: # ALL every lane below # NONE no test lane (the `gates` lane still runs; see below) -# Lanes: ts-fast ts-unit java-slow python csharp rust. These are the ci-local sections a +# Lanes: ts-fast ts-unit java-slow python csharp rust packs. These are the ci-local sections a # change can select. ts-slow, cube and mutation are not selectable here: # the first two need docker, and mutation is diff-scoped # inside ts-fast already (gate_completeness_diff in ci-local.sh), which this map neither @@ -35,9 +35,10 @@ # Editing this file edits the rule above (`scripts/*` -> ALL), so a change to the map # runs everything, and scripts/test-ci-lane-selection.sh asserts the map still says so. # -server/typescript/* | ts-fast ts-unit | the TypeScript server port +packs/* | packs | an independent pack (ADR-0069): its own lane only, and core's lanes never read packs/ (scripts/check-pack-boundary.ts) +server/typescript/* | ts-fast ts-unit packs | the TypeScript server port; packs runs too, as a canary that reports a pack the change breaks and blocks nothing (ADR-0069) examples/dynamic-grid/* | ts-fast ts-unit | a workspace member: ts-fast typechecks it, ts-unit runs its suite, and no other port reads it -client/web/* | ts-fast ts-unit | the universal web client, built and tested by the TypeScript lanes +client/web/* | ts-fast ts-unit packs | the universal web client, built and tested by the TypeScript lanes; packs as for server/typescript server/java/* | java-slow | the Java and Kotlin ports (the reactor holds both conformance suites) server/python/* | python | the Python port server/csharp/* | csharp | the C# port diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 055675a827..2705e0f165 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -28,7 +28,8 @@ # # Run one or more named sections. Mutually # # exclusive with --quick (exit 2 if combined). # # gates → leak-scan, pom parity, fixture-lint, -# # doc-template drift, embedded-library drift +# # doc-template drift, embedded-library drift, +# # the pack boundary and pack manifests # # leak-scan → the public-repo leak scan ALONE # # (hygiene.yml's PR gate; also in gates) # # ts → ts build+typecheck, ts conformance, @@ -82,6 +83,17 @@ # # parallel lane; --quick and # # --no-integration drop it; no other # # section includes it +# # packs → the independent packs under packs/ +# # (ADR-0069): per pack with a TypeScript +# # port, its typecheck, its pinned +# # vocabulary (and that it leaves core +# # alone), its load corpus and its own +# # tests, against core's working tree. +# # BLOCKING for a pack whose own files the +# # change touches (or MO_CI_PACKS_BLOCKING=1); +# # otherwise a CANARY: a red pack is recorded +# # as a named SKIP and never fails the run. +# # Passes with a note when packs/ holds none # scripts/ci-local.sh --affected # AFFECTED-LANE tier: run only the lanes this change needs. # # Lists the changed paths since the merge base with the # # base branch (plus uncommitted and untracked files), @@ -90,7 +102,7 @@ # # rule each path matched, then runs the selected ones as # # `--only ... --no-integration` would. The # # selectable lanes are ts-fast, ts-unit, java-slow, -# # python, csharp and rust; a change confined to one port +# # python, csharp, rust and packs; a change confined to one port # # selects that port, anything shared, any path the map # # does not claim, or no resolvable base selects all of # # them, and a change to only the root prose files @@ -183,8 +195,8 @@ while [ $# -gt 0 ]; do --no-integration) NO_INTEG=1 ;; --integration-only) INTEG_ONLY=1 ;; --only) shift; case "${1:-}" in - gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|rust|cube) ONLY="$ONLY ${1}" ;; - *) echo "--only expects gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|rust|cube, got '${1:-}'" >&2; exit 2 ;; + gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|rust|cube|packs) ONLY="$ONLY ${1}" ;; + *) echo "--only expects gates|leak-scan|ts|ts-fast|ts-unit|ts-slow|mutation|java|java-fast|java-slow|python|csharp|rust|cube|packs, got '${1:-}'" >&2; exit 2 ;; esac ;; -h|--help) awk 'NR==1{next} /^set -uo/{exit} {sub(/^# ?/,""); print}' "$0"; exit 0 ;; *) echo "unknown arg: $1 (see --help)" >&2; exit 2 ;; @@ -607,6 +619,63 @@ gate_requirements_vocabulary() { bun_install && bun scripts/check-requirements-v # into a failing gate: adding a type, attribute or child rule under metaobjects-core-types # changes the computed view and fails with a message pointing at the pack mechanism. gate_core_vocabulary_pin() { bun_install && bun scripts/check-core-vocabulary-pin.ts && bun scripts/test-core-vocabulary-pin.ts; } +# ── independent packs (ADR-0069) ─────────────────────────────────────────────── +# The boundary: core never names a pack, the bundle holds none, and core's release tooling +# never enumerates packs/. The manifests: each pack.json agrees with the native manifest of +# every port that carries it. One test file covers both, and the pack tooling below. +gate_pack_boundary() { bun_install && bun scripts/check-pack-boundary.ts && bun test scripts/packs.test.ts; } +gate_pack_manifests() { bun_install && bun scripts/check-pack-manifests.ts; } +# One pack's TypeScript checks, against core's working tree. +gate_pack_ts() { # gate_pack_ts + local n="$1" dir="packs/$1/typescript" + ( cd "$dir" && bun run typecheck ) || return 1 + bun scripts/pack-vocabulary.ts "$n" || return 1 + bun scripts/pack-conformance.ts "$n" || return 1 + if [ -n "$(find "$dir" -path "$dir/node_modules" -prune -o \( -name '*.test.ts' -o -name '*.test.tsx' \) -print -quit)" ]; then + ( cd "$dir" && bun test ) || return 1 + fi +} +# pack_is_blocking — true when this change touches the pack's own files, when the base +# cannot be resolved (every uncertainty widens), or when MO_CI_PACKS_BLOCKING=1. +pack_is_blocking() { + [ "${MO_CI_PACKS_BLOCKING:-0}" = "1" ] && return 0 + local base mb + base="${MO_CI_AFFECTED_BASE:-$(default_base)}" + [ -n "$base" ] && mb="$(git merge-base HEAD "$base" 2>/dev/null)" || return 0 + changed_paths "$mb" | grep -q "^packs/$1/" +} +# The packs lane. A pack is a preview product on its own release line, so a core change that +# turns one red must not block core: it is reported as a named SKIP (the canary) and the pack +# is fixed in its own PR. A change to the pack itself blocks, as any product's own change does. +run_packs_steps() { + want packs || return 0 + local n canary + local -a packs=() + for n in packs/*/typescript/package.json; do + [ -f "$n" ] || continue + n="${n#packs/}"; packs+=("${n%%/*}") + done + if [ "${#packs[@]}" -eq 0 ]; then + echo ""; echo "── packs: no independent pack with a TypeScript port under packs/ — nothing to check ──" + return 0 + fi + if ! have bun; then step_if bun "packs" true; return 0; fi + if [ "${MO_CI_LIST_ONLY:-0}" != "1" ] && [ "${MO_CI_WORKSPACE_BUILT:-0}" != "1" ] \ + && ! step_passed "ts build + typecheck" && ! step_passed "ts build"; then + step "packs: core build" gate_ts_build + fi + for n in "${packs[@]}"; do + if pack_is_blocking "$n"; then + step "pack $n" gate_pack_ts "$n" + continue + fi + canary="pack $n canary: red against core's tree (non-blocking, ADR-0069)" + if [ "${MO_CI_LIST_ONLY:-0}" = "1" ]; then echo " + pack $n (canary)"; continue; fi + echo ""; echo "── ▶ pack $n (canary: this change does not touch it) ──" + if gate_pack_ts "$n"; then record PASS 0 "pack $n (canary)"; echo "── ✓ pack $n (canary)" + else record SKIP 0 "$canary"; echo " ⊘ $canary — fix it in the pack's own PR" >&2; fi + done +} # ── forward scaffolding: a requirement may come BEFORE its vocabulary ────────── # Phase 3. Author the promise and the counterexample first, then scaffold the @@ -637,13 +706,17 @@ gate_fixture_lint() { } # bun_install first: under `--only ts` this gate runs without fixture-lint # (whose install it historically piggybacked on), so it must install itself. -gate_ts_build_typecheck() { bun_install && bun run --filter '*' build && bun run --filter '*' typecheck; } +# `bun run build` / `bun run typecheck` are the root package.json scripts, which name +# core's workspace directories rather than `--filter '*'`: the workspace also holds +# packs/*/typescript, and a preview pack's red typecheck must not fail core (ADR-0069). +# The packs lane builds and checks the packs. +gate_ts_build_typecheck() { bun_install && bun run build && bun run typecheck; } # Build only (no typecheck) — the ts-slow lane needs the workspace dist/ to run the # integration tests, but the typecheck already runs in ts-fast, so don't repeat it. -gate_ts_build() { bun_install && bun run --filter '*' build; } +gate_ts_build() { bun_install && bun run build; } # The full run's other half of gate_ts_build_typecheck: it builds before its lanes fork (every # lane that runs the CLI or the integration suite reads dist/) and typechecks inside one. -gate_ts_typecheck() { bun run --filter '*' typecheck; } +gate_ts_typecheck() { bun run typecheck; } # migrate-ts real-Postgres suites — apply / lifecycle / rollback / introspection against a # real engine. ADR-0015 makes migrate-ts the project's ONLY migrate engine, so this is the @@ -1367,6 +1440,8 @@ run_gates_bun() { if want gates; then step_if bun "requirements ledger verifies" gate_requirements_ledger; fi if want gates; then step_if bun "requirements cover vocabulary" gate_requirements_vocabulary; fi if want gates; then step_if bun "core vocabulary is pinned" gate_core_vocabulary_pin; fi + if want gates; then step_if bun "pack boundary" gate_pack_boundary; fi + if want gates; then step_if bun "pack manifests agree" gate_pack_manifests; fi if want gates; then step_if bun "metamodel scaffolder" gate_scaffold_metamodel; fi if want gates; then step_if bun "requirement harness" gate_requirement_harness; fi if want gates; then step_if bun "fixture-lint" gate_fixture_lint; fi @@ -1525,6 +1600,8 @@ run_ts_serial_steps() { step_if bun "completeness-gate (mutation, changed files)" gate_completeness_diff fi } +# The packs build against the dist/ the ts steps write, so in a parallel run they share its lane. +run_ts_then_packs() { run_ts_serial_steps; run_packs_steps; } # One function per other port, shared by the serial heavy tier and the parallel --affected lanes. run_csharp_steps() { if want csharp; then step_if dotnet "conformance: csharp" gate_conf_csharp; fi; } run_python_steps() { if want python; then step_if uv "conformance: python" gate_conf_python; fi; } @@ -1542,7 +1619,7 @@ run_java_reactor_steps() { if want_any java java-slow; then step_if mvn "java-re AFFECTED_PARALLEL=0 if [ "$AFFECTED" -eq 1 ]; then _groups=0 - in_lane_any ts-fast ts-unit && _groups=$((_groups + 1)) + in_lane_any ts-fast ts-unit packs && _groups=$((_groups + 1)) for _g in java-slow python csharp rust; do in_lane "$_g" && _groups=$((_groups + 1)); done [ "$_groups" -gt 1 ] && AFFECTED_PARALLEL=1 fi @@ -1595,7 +1672,7 @@ if [ "$AFFECTED_PARALLEL" -eq 1 ]; then in_lane python && lane python "" run_python_steps in_lane csharp && lane csharp "" run_csharp_steps in_lane rust && lane rust "" run_rust_steps - in_lane_any ts-fast ts-unit && lane ts "" run_ts_serial_steps + in_lane_any ts-fast ts-unit packs && lane ts "" run_ts_then_packs run_or_list_lanes elif [ "$PARALLEL" -eq 0 ]; then # Fast tier: shared gates and TS checks, in their original order. @@ -1608,6 +1685,7 @@ elif [ "$PARALLEL" -eq 0 ]; then # (docker/sidecar integration). Isolating integration means a docker/sidecar # hiccup no longer fails the code signal, and vice versa. `--only ts` still runs both. run_ts_serial_steps + run_packs_steps run_drift_gates if [ "$QUICK" -eq 1 ]; then @@ -1730,6 +1808,7 @@ else lane java-integ java lane_java_integ lane showcase java,csharp lane_showcase lane rust "" run_rust_steps + lane packs "" run_packs_steps lane cube "" lane_cube lane gates "" lane_gates diff --git a/scripts/ci-select-lanes.sh b/scripts/ci-select-lanes.sh index e4373174ab..cd80511360 100755 --- a/scripts/ci-select-lanes.sh +++ b/scripts/ci-select-lanes.sh @@ -21,12 +21,14 @@ CI_SELECT_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" CI_LANE_MAP="${MO_CI_LANE_MAP:-$CI_SELECT_HERE/ci-lane-map.txt}" # The lanes a change can select, in the order they run. The map's `ALL` means exactly this. -CI_SELECTABLE_LANES="ts-fast ts-unit java-slow python csharp rust" +# `packs` is the independent packs under packs/ (ADR-0069): their TypeScript ports build +# against core's working tree, so the lane belongs to the ts port and runs after it. +CI_SELECTABLE_LANES="ts-fast ts-unit java-slow python csharp rust packs" # The port each lane belongs to, for callers that think in ports (the hosted workflows). lane_to_port() { case "$1" in - ts-fast|ts-unit) echo ts ;; + ts-fast|ts-unit|packs) echo ts ;; java-slow) echo java ;; python) echo python ;; csharp) echo csharp ;; diff --git a/scripts/integration-test.sh b/scripts/integration-test.sh index 9780b69b8a..c532682d82 100755 --- a/scripts/integration-test.sh +++ b/scripts/integration-test.sh @@ -100,7 +100,7 @@ run_ts() { # sets: it has just built this same tree, and other lanes are reading dist/ while this # one runs, so a second build here would rewrite it under them. if [ "${MO_CI_WORKSPACE_BUILT:-0}" != "1" ]; then - ( cd "$REPO_ROOT" && bun run --filter '*' build ) || { FAIL=1; return; } + ( cd "$REPO_ROOT" && bun run build ) || { FAIL=1; return; } fi # --parallel: the suite is ~50 files whose time sits in a dozen of them (the MySQL, # SQLite and D1 corpora), each generating and compiling its own app into a fresh diff --git a/scripts/lib/packs.ts b/scripts/lib/packs.ts new file mode 100644 index 0000000000..db6d2307d7 --- /dev/null +++ b/scripts/lib/packs.ts @@ -0,0 +1,281 @@ +/** + * Independent packs (ADR-0069): what scripts/ knows about `packs//`. + * + * A pack directory is the monorepo spelling of a separate repository. Its manifest, + * `pack.json`, is the pack's one statement about itself; every check in this file reads + * it, and none of core's release tooling does. This module is repo tooling, not product: + * core packages never import it (scripts/check-pack-boundary.ts holds that line). + * + * The vocabulary half answers the two conformance questions a pack's TypeScript port is + * held to: which manifest rows the pack ADDS when composed onto the default bundle (its + * pinned vocabulary, packs//fixtures/expected-vocabulary.json), and whether it + * leaves every row the bundle already had byte-identical ("leaves core alone"). + */ +import { existsSync, readFileSync, readdirSync, statSync } from "node:fs"; +import { dirname, join, resolve } from "node:path"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import { + buildRegistryManifest, + composeRegistry, + coreProviders, + type MetaDataTypeProvider, +} from "../../server/typescript/packages/metadata/src/index.js"; + +export const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../.."); +export const PACKS_DIR = "packs"; +export const PACK_MANIFEST = "pack.json"; +export const PACK_VOCABULARY = "fixtures/expected-vocabulary.json"; +export const PACK_CORPUS = "fixtures/conformance"; + +/** The port directories a pack may carry, by the name `pack.json` gives each. */ +export const PACK_PORTS = ["typescript", "java", "kotlin", "csharp", "python", "rust"] as const; +export type PackPort = (typeof PACK_PORTS)[number]; + +/** The stability words docs/features/stability-labels.md defines. */ +export const PACK_STABILITIES = ["experimental", "preview", "stable"] as const; + +export interface PackPortEntry { + /** The registry coordinate: npm name, Maven `group:artifact`, PyPI / NuGet / crate name. */ + readonly package: string; + /** The range of core this port's artifact accepts, in that registry's own syntax. */ + readonly core: string; + /** False while the pack is consumed only through the private prerelease registry. */ + readonly publish: boolean; +} + +export interface PackManifest { + readonly id: string; + readonly version: string; + readonly stability: string; + readonly description?: string; + readonly requires: { + /** The metamodel (`metamodelVersion`) range the pack's vocabulary is written against. */ + readonly metamodel: string; + /** Other packs this one depends on: pack id -> version range. */ + readonly packs: Readonly>; + }; + readonly ports: Readonly>>; +} + +/** `metaobjects-`: the provider id every pack registers under. */ +export function packProviderId(name: string): string { + return `metaobjects-${name}`; +} + +/** The npm name of a pack's TypeScript port. */ +export function packNpmName(name: string): string { + return `@metaobjectsdev/pack-${name}`; +} + +/** `MetaObjects.Packs.`, with the kebab-case name in PascalCase. */ +export function packNuGetName(name: string): string { + const pascal = name.split("-").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(""); + return `MetaObjects.Packs.${pascal}`; +} + +/** + * The registry coordinate each port's artifact must carry (ADR-0069, "Names"). + * Kotlin shares Java's Maven namespace; the suffix that tells its artifact apart is + * left to the first pack that ships a Kotlin port, so only the prefix is fixed here. + */ +export function packageMatches(port: PackPort, name: string, actual: string): boolean { + if (port === "kotlin") return actual.startsWith(`com.metaobjects.packs:${name}-`); + return actual === expectedPackage(port, name); +} + +export function expectedPackage(port: PackPort, name: string): string { + switch (port) { + case "typescript": + return packNpmName(name); + case "java": + return `com.metaobjects.packs:${name}`; + case "kotlin": + return `com.metaobjects.packs:${name}-`; + case "csharp": + return packNuGetName(name); + case "python": + case "rust": + return `metaobjects-pack-${name}`; + } +} + +/** Every directory under `/packs/`, sorted. A directory without pack.json is still listed. */ +export function listPackDirs(root: string = REPO_ROOT): string[] { + const dir = join(root, PACKS_DIR); + if (!existsSync(dir)) return []; + return readdirSync(dir) + .filter((n) => !n.startsWith(".") && statSync(join(dir, n)).isDirectory()) + .sort(); +} + +export function packDir(name: string, root: string = REPO_ROOT): string { + return join(root, PACKS_DIR, name); +} + +/** Parse `packs//pack.json` without validating it (scripts/check-pack-manifests.ts does). */ +export function readPackManifest(name: string, root: string = REPO_ROOT): PackManifest { + return JSON.parse(readFileSync(join(packDir(name, root), PACK_MANIFEST), "utf8")) as PackManifest; +} + +/** Pack names by provider id, for every pack that has a readable manifest. */ +export function packsById(root: string = REPO_ROOT): Map { + const out = new Map(); + for (const name of listPackDirs(root)) { + try { + out.set(readPackManifest(name, root).id, name); + } catch { + // An unreadable manifest is check-pack-manifests' finding, not this lookup's. + } + } + return out; +} + +/** The file a pack's TypeScript package resolves to under the `bun` condition. */ +export function packEntryFile(name: string, root: string = REPO_ROOT): string { + const pkgDir = join(packDir(name, root), "typescript"); + const pkg = JSON.parse(readFileSync(join(pkgDir, "package.json"), "utf8")) as { + exports?: Record; + main?: string; + }; + const dot = pkg.exports?.["."]; + const rel = typeof dot === "string" ? dot : (dot?.bun ?? dot?.default ?? pkg.main); + if (rel === undefined) throw new Error(`${packNpmName(name)}: package.json names no entry point`); + return join(pkgDir, rel); +} + +function isProvider(v: unknown): v is MetaDataTypeProvider { + return ( + typeof v === "object" && v !== null && + typeof (v as { id?: unknown }).id === "string" && + typeof (v as { registerTypes?: unknown }).registerTypes === "function" + ); +} + +/** Import one pack's TypeScript entry and return its exported `provider`. */ +export async function loadPackProvider(name: string, root: string = REPO_ROOT): Promise { + const mod = (await import(pathToFileURL(packEntryFile(name, root)).href)) as { provider?: unknown }; + if (!isProvider(mod.provider)) { + throw new Error(`${packNpmName(name)}: the entry point must export \`provider\`, a MetaDataTypeProvider`); + } + const id = readPackManifest(name, root).id; + if (mod.provider.id !== id) { + throw new Error(`${packNpmName(name)}: the exported provider's id is "${mod.provider.id}", pack.json says "${id}"`); + } + return mod.provider; +} + +/** + * The providers a pack needs, in dependency order: the packs it requires (transitively) + * and then the pack itself. Throws on a required pack that is not in this repository. + */ +export async function loadPackClosure(name: string, root: string = REPO_ROOT): Promise { + const byId = packsById(root); + const out: MetaDataTypeProvider[] = []; + const seen = new Set(); + async function visit(n: string, chain: readonly string[]): Promise { + if (chain.includes(n)) throw new Error(`pack dependency cycle: ${[...chain, n].join(" -> ")}`); + if (seen.has(n)) return; + for (const dep of Object.keys(readPackManifest(n, root).requires?.packs ?? {})) { + const depName = byId.get(dep); + if (depName === undefined) throw new Error(`pack ${n} requires "${dep}", which is not a pack in ${PACKS_DIR}/`); + await visit(depName, [...chain, n]); + } + seen.add(n); + out.push(await loadPackProvider(n, root)); + } + await visit(name, []); + return out; +} + +// ── vocabulary: rows, the pin, and "leaves core alone" ─────────────────────── + +type Manifest = ReturnType; +type ManifestType = Manifest["types"][number]; +type ManifestAttr = ManifestType["attrs"][number]; +type ManifestChild = ManifestType["children"][number]; + +const childKey = (c: ManifestChild): string => + `${c.childType}.${Array.isArray(c.childSubType) ? c.childSubType.join(",") : c.childSubType}:${c.childName}`; + +/** + * A manifest as one string per row, keyed. A row is the smallest unit a pack can add: + * a type's header (everything but its attrs and children), one attribute, one child + * rule, one common attribute, one default subtype. + */ +export function manifestRows(m: Manifest): Map { + const rows = new Map(); + for (const t of m.types) { + const { attrs, children, ...header } = t; + rows.set(`type ${t.type}.${t.subType}`, JSON.stringify(header)); + for (const a of attrs) rows.set(`attr ${t.type}.${t.subType} @${a.name}`, JSON.stringify(a)); + for (const c of children) rows.set(`child ${t.type}.${t.subType} > ${childKey(c)}`, JSON.stringify(c)); + } + for (const a of m.commonAttrs) rows.set(`common @${a.name}`, JSON.stringify(a)); + for (const [type, sub] of Object.entries(m.defaultSubTypes)) rows.set(`default ${type}`, JSON.stringify(sub)); + return rows; +} + +export interface PackVocabulary { + readonly pack: string; + /** Types the pack registers, in full. */ + readonly types: ManifestType[]; + /** Types the pack does not own and adds attributes or child rules to. */ + readonly extends: { type: string; subType: string; attrs: ManifestAttr[]; children: ManifestChild[] }[]; + readonly commonAttrs: ManifestAttr[]; + readonly defaultSubTypes: Record; +} + +export interface PackVocabularyResult { + readonly vocabulary: PackVocabulary; + /** Rows the base already had that the pack changed or removed; empty when it leaves core alone. */ + readonly coreChanges: string[]; +} + +/** + * Compose the default bundle, then the bundle plus `packProviders`, and split the + * difference. The base is the bundle plus the packs this one requires, so a pack is + * pinned only for what IT adds, and "leaves core alone" is asked of the bundle's rows. + */ +export function derivePackVocabulary( + packId: string, + requiredPacks: readonly MetaDataTypeProvider[], + pack: MetaDataTypeProvider, +): PackVocabularyResult { + const bundle = manifestRows(buildRegistryManifest(composeRegistry(coreProviders))); + const baseManifest = buildRegistryManifest(composeRegistry([...coreProviders, ...requiredPacks])); + const base = manifestRows(baseManifest); + const composed = buildRegistryManifest(composeRegistry([...coreProviders, ...requiredPacks, pack], { validate: true })); + const rows = manifestRows(composed); + + const coreChanges: string[] = []; + for (const [key, value] of bundle) { + const now = rows.get(key); + if (now === undefined) coreChanges.push(`removed: ${key}`); + else if (now !== value) coreChanges.push(`changed: ${key}\n was ${value}\n now ${now}`); + } + + const baseTypes = new Set(baseManifest.types.map((t) => `${t.type}.${t.subType}`)); + const types: ManifestType[] = []; + const ext: PackVocabulary["extends"] = []; + for (const t of composed.types) { + const key = `${t.type}.${t.subType}`; + if (!baseTypes.has(key)) { + types.push(t); + continue; + } + const attrs = t.attrs.filter((a) => !base.has(`attr ${key} @${a.name}`)); + const children = t.children.filter((c) => !base.has(`child ${key} > ${childKey(c)}`)); + if (attrs.length > 0 || children.length > 0) ext.push({ type: t.type, subType: t.subType, attrs, children }); + } + const commonAttrs = composed.commonAttrs.filter((a) => !base.has(`common @${a.name}`)); + const defaultSubTypes: Record = {}; + for (const [type, sub] of Object.entries(composed.defaultSubTypes)) { + if (!base.has(`default ${type}`)) defaultSubTypes[type] = sub; + } + return { vocabulary: { pack: packId, types, extends: ext, commonAttrs, defaultSubTypes }, coreChanges }; +} + +/** The committed form of a pack's pinned vocabulary: 2-space JSON, one trailing newline. */ +export function emitPackVocabulary(v: PackVocabulary): string { + return `${JSON.stringify(v, null, 2)}\n`; +} diff --git a/scripts/pack-conformance.ts b/scripts/pack-conformance.ts new file mode 100644 index 0000000000..87684964f1 --- /dev/null +++ b/scripts/pack-conformance.ts @@ -0,0 +1,86 @@ +#!/usr/bin/env bun +/** + * Run a pack's load fixtures through the TypeScript port (ADR-0069, "Conformance"). + * + * A pack's corpus lives at packs//fixtures/conformance/, in the shared fixture + * format (spec/conformance-tests.md), so the counts and the corpus x port matrix that + * docs/CONFORMANCE.md gates for fixtures/ never move for pack work. This drives it with + * the same engine and the same adapter as fixtures/conformance/, through the corpus-root + * entry point `runCorpus` (@metaobjectsdev/conformance): the adapter is composed with + * the pack's provider and the packs it requires, and every scenario must name the pack + * in its providers.json, because a scenario that loads only the default bundle tests + * core, not the pack. + * + * Error codes: the core list (fixtures/conformance/ERROR-CODES.json) plus the pack's own + * packs//fixtures/conformance/ERROR-CODES.json when it declares codes of its own. + * An optional packs//typescript/conformance-expected-failures.json is the port's + * ledger, in the core ledger's format. + * + * Usage: bun scripts/pack-conformance.ts | --all + */ +import { existsSync, readFileSync } from "node:fs"; +import { join } from "node:path"; +import { runCorpus, loadLedger, type CorpusResult } from "../server/typescript/packages/conformance/src/index.js"; +import { createTsAdapter } from "../server/typescript/packages/metadata/test/conformance/adapter.js"; +import type { MetaDataTypeProvider } from "../server/typescript/packages/metadata/src/index.js"; +import { PACK_CORPUS, REPO_ROOT, listPackDirs, loadPackClosure, packDir, readPackManifest } from "./lib/packs.js"; + +const ERROR_CODES = "ERROR-CODES.json"; + +function codesIn(path: string): string[] { + if (!existsSync(path)) return []; + return Object.keys((JSON.parse(readFileSync(path, "utf8")) as { codes?: Record }).codes ?? {}); +} + +/** The pack's corpus result, or undefined when the pack has no load fixtures yet. */ +export async function runPackConformance(name: string, root: string = REPO_ROOT): Promise { + const corpusRoot = join(packDir(name, root), PACK_CORPUS); + if (!existsSync(corpusRoot)) return undefined; + const closure = await loadPackClosure(name, root); + const extra: Record = {}; + for (const p of closure) extra[p.id] = p; + const errorCodes = [ + ...codesIn(join(root, "fixtures/conformance", ERROR_CODES)), + ...codesIn(join(corpusRoot, ERROR_CODES)), + ]; + return runCorpus({ + corpusRoot, + adapter: createTsAdapter(extra), + errorCodes, + ledger: await loadLedger(join(packDir(name, root), "typescript", "conformance-expected-failures.json")), + requireProviders: [readPackManifest(name, root).id], + }); +} + +if (import.meta.main) { + const args = process.argv.slice(2); + const names = args.includes("--all") + ? listPackDirs().filter((n) => existsSync(join(packDir(n), "typescript", "package.json"))) + : args.filter((a) => !a.startsWith("--")); + if (names.length === 0 && !args.includes("--all")) { + console.error("usage: bun scripts/pack-conformance.ts |--all"); + process.exit(2); + } + let failed = 0; + for (const name of names) { + const r = await runPackConformance(name); + if (r === undefined) { + console.log(`pack ${name}: no load fixtures (${PACK_CORPUS}/ is absent)`); + continue; + } + const counts = new Map(); + for (const f of r.fixtures) counts.set(f.status, (counts.get(f.status) ?? 0) + 1); + const summary = [...counts].map(([s, n]) => `${n} ${s}`).join(", "); + if (r.passed) { + console.log(`pack ${name}: conformance ${summary || "0 fixtures"}`); + continue; + } + failed++; + console.error(`pack ${name}: conformance FAILED (${summary})`); + for (const f of r.fixtures.filter((x) => x.status === "fail" || x.status === "fixed-but-listed")) { + console.error(` ✖ ${f.name} [${f.status}]: ${f.problems.join("; ")}`); + } + } + if (names.length === 0) console.log("pack conformance: no pack has a TypeScript port"); + process.exit(failed > 0 ? 1 : 0); +} diff --git a/scripts/pack-vocabulary.ts b/scripts/pack-vocabulary.ts new file mode 100644 index 0000000000..ba92391e45 --- /dev/null +++ b/scripts/pack-vocabulary.ts @@ -0,0 +1,93 @@ +#!/usr/bin/env bun +/** + * A pack's pinned vocabulary, and the check that it leaves core alone (ADR-0069). + * + * Composes the default bundle (every bundled provider, `coreProviders`), then the bundle + * plus the packs this pack requires plus this pack, and diffs the two registry + * manifests row by row: + * + * - LEAVES CORE ALONE: every row the bundle's own manifest has must still be there, + * byte-identical. A pack may add types, add attributes and child rules to types it + * does not own (which ADR-0050 requires to be optional) and add common attributes; it + * may not change or remove anything the bundle declares. This is the same composition + * invariant ADR-0050 holds bundled packs to, pointed outward. + * - THE PIN: the rows the pack adds are written to + * packs//fixtures/expected-vocabulary.json, the registry-conformance pattern + * scoped to one pack. TypeScript is the reference emitter; every port that carries the + * pack byte-matches the file. It never enters fixtures/registry-conformance/, so the + * pack never moves `metamodelVersion`. + * + * Usage: + * bun scripts/pack-vocabulary.ts # check the committed pin (the packs lane) + * bun scripts/pack-vocabulary.ts --write # regenerate it + * bun scripts/pack-vocabulary.ts --all [--write] # every pack with a TypeScript port + */ +import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, join } from "node:path"; +import { + PACK_VOCABULARY, + REPO_ROOT, + derivePackVocabulary, + emitPackVocabulary, + listPackDirs, + loadPackClosure, + packDir, + readPackManifest, +} from "./lib/packs.js"; + +export interface PackVocabularyCheck { + readonly name: string; + readonly problems: string[]; + /** The freshly derived pin, as it would be written. */ + readonly emitted: string; +} + +export async function checkPackVocabulary(name: string, root: string = REPO_ROOT): Promise { + const closure = await loadPackClosure(name, root); + const pack = closure[closure.length - 1]!; + const { vocabulary, coreChanges } = derivePackVocabulary(readPackManifest(name, root).id, closure.slice(0, -1), pack); + const emitted = emitPackVocabulary(vocabulary); + const problems = coreChanges.map((c) => `does not leave core alone — ${c}`); + const pinPath = join(packDir(name, root), PACK_VOCABULARY); + const committed = existsSync(pinPath) ? readFileSync(pinPath, "utf8").replace(/\r\n/g, "\n") : undefined; + if (committed === undefined) problems.push(`${PACK_VOCABULARY} is missing — run: bun scripts/pack-vocabulary.ts ${name} --write`); + else if (committed !== emitted) problems.push(`${PACK_VOCABULARY} is stale — the registered vocabulary changed; review it and run: bun scripts/pack-vocabulary.ts ${name} --write`); + return { name, problems, emitted }; +} + +function typescriptPacks(root: string): string[] { + return listPackDirs(root).filter((n) => existsSync(join(packDir(n, root), "typescript", "package.json"))); +} + +if (import.meta.main) { + const args = process.argv.slice(2); + const write = args.includes("--write"); + const names = args.includes("--all") ? typescriptPacks(REPO_ROOT) : args.filter((a) => !a.startsWith("--")); + if (names.length === 0 && !args.includes("--all")) { + console.error("usage: bun scripts/pack-vocabulary.ts |--all [--write]"); + process.exit(2); + } + let failed = 0; + for (const name of names) { + const r = await checkPackVocabulary(name); + const core = r.problems.filter((p) => p.startsWith("does not leave core alone")); + if (write && core.length === 0) { + const path = join(packDir(name), PACK_VOCABULARY); + mkdirSync(dirname(path), { recursive: true }); + const old = existsSync(path) ? readFileSync(path, "utf8") : undefined; + if (old !== r.emitted) writeFileSync(path, r.emitted); + console.log(`pack ${name}: ${old === r.emitted ? "pin unchanged" : `wrote ${PACK_VOCABULARY}`}`); + continue; + } + const shown = write ? core : r.problems; + if (shown.length === 0) { + console.log(`pack ${name}: vocabulary pinned, leaves core alone`); + } else { + failed++; + console.error(`pack ${name}: ${shown.length} problem(s)`); + for (const p of shown) console.error(` ✖ ${p}`); + } + } + if (names.length === 0) console.log("pack vocabulary: no pack has a TypeScript port"); + process.exit(failed > 0 ? 1 : 0); +} diff --git a/scripts/packs.test.ts b/scripts/packs.test.ts new file mode 100644 index 0000000000..aa94473e61 --- /dev/null +++ b/scripts/packs.test.ts @@ -0,0 +1,288 @@ +// Tests for the independent-pack tooling (ADR-0069): the pack.json check, the boundary +// gate, the pinned vocabulary with its "leaves core alone" check, and pack conformance. +// +// Every case builds a throwaway repository root under $DEV_SCRATCH holding one or two +// packs, so nothing here writes into the working tree. The throwaway pack's provider +// imports the metadata package's SOURCE by absolute path, as a workspace pack resolves +// it, which keeps one copy of the metamodel classes in the process. +import { afterAll, describe, expect, test } from "bun:test"; +import { cpSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { dirname, join } from "node:path"; +import { checkPackManifests } from "./check-pack-manifests.js"; +import { checkPackBoundary, scanCore, scanRegistry, scanReleaseTooling } from "./check-pack-boundary.js"; +import { checkPackVocabulary } from "./pack-vocabulary.js"; +import { runPackConformance } from "./pack-conformance.js"; +import { PACK_VOCABULARY, REPO_ROOT } from "./lib/packs.js"; + +const METADATA_SRC = join(REPO_ROOT, "server/typescript/packages/metadata/src/index.ts"); +const roots: string[] = []; +afterAll(() => { + for (const r of roots) rmSync(r, { recursive: true, force: true }); +}); + +function scratchRoot(): string { + const r = mkdtempSync(join(process.env.DEV_SCRATCH ?? tmpdir(), "mo-packs-test-")); + roots.push(r); + return r; +} + +function write(root: string, rel: string, content: string): void { + mkdirSync(dirname(join(root, rel)), { recursive: true }); + writeFileSync(join(root, rel), content); +} + +const json = (v: unknown): string => `${JSON.stringify(v, null, 2)}\n`; + +/** A provider in the shape a pack ships: a new layout subtype plus two optional field.string attrs. */ +function providerSource(id: string, opts: { breakCore?: boolean } = {}): string { + return `import { TypeId, MetaLayout } from ${JSON.stringify(METADATA_SRC)}; +export const provider = { + id: ${JSON.stringify(id)}, + dependencies: ["metaobjects-core-types"], + registerTypes(registry) { + registry.register({ + typeId: new TypeId("layout", "picker"), + description: "A picker that chooses one row of the owning object.", + factory: (typeId, name) => new MetaLayout(typeId, name), + childRules: [], + attributes: [{ name: "displayField", valueType: "string", required: false, description: "Field shown for each choice." }], + }); + registry.extend("field", "string", { + attributes: [ + { name: "searchable", valueType: "boolean", required: false, description: "Offer this field in search." }, + { name: "valueLabels", valueType: "string", isArray: true, required: false, description: "Display labels for the field's values." }, + ], + }); + ${opts.breakCore === true ? `registry.setDefaultSubType("object", "value");` : ""} + }, +}; +`; +} + +/** A complete, valid TypeScript-only pack named `name` under `root`. */ +function makePack(root: string, name: string, opts: { breakCore?: boolean; manifest?: Record; pkg?: Record } = {}): void { + const base = `packs/${name}`; + write(root, `${base}/pack.json`, json({ + id: `metaobjects-${name}`, + version: "0.1.0", + stability: "preview", + requires: { metamodel: ">=1.3 <2", packs: {} }, + ports: { typescript: { package: `@metaobjectsdev/pack-${name}`, core: ">=1.3.0 <2.0.0", publish: false } }, + ...opts.manifest, + })); + write(root, `${base}/README.md`, `# ${name}\n`); + write(root, `${base}/CHANGELOG.md`, `# Changelog\n`); + write(root, `${base}/typescript/package.json`, json({ + name: `@metaobjectsdev/pack-${name}`, + version: "0.1.0", + private: true, + type: "module", + exports: { ".": { bun: "./src/index.ts", default: "./src/index.ts" } }, + scripts: { typecheck: "tsc --noEmit" }, + peerDependencies: { "@metaobjectsdev/metadata": ">=1.3.0 <2.0.0" }, + devDependencies: { "@metaobjectsdev/metadata": "workspace:*" }, + ...opts.pkg, + })); + write(root, `${base}/typescript/src/index.ts`, providerSource(`metaobjects-${name}`, opts)); + write(root, `${base}/${PACK_VOCABULARY}`, "{}\n"); +} + +describe("pack.json check", () => { + test("a complete pack passes", () => { + const root = scratchRoot(); + makePack(root, "demo"); + expect(checkPackManifests(root)).toEqual([]); + }); + + test("an empty packs/ (or none) passes", () => { + expect(checkPackManifests(scratchRoot())).toEqual([]); + }); + + test("each disagreement with the native manifest is named", () => { + const root = scratchRoot(); + makePack(root, "demo", { + manifest: { id: "demo", requires: { metamodel: ">=1.3", packs: { "metaobjects-nope": ">=0.1.0 <0.2.0" } } }, + pkg: { + version: "0.2.0", + private: false, + peerDependencies: {}, + dependencies: { "@metaobjectsdev/codegen-ts": "^1.3.0" }, + scripts: {}, + }, + }); + mkdirSync(join(root, "packs/demo/python")); + const problems = checkPackManifests(root).join("\n"); + expect(problems).toContain('id is "demo", must be "metaobjects-demo"'); + expect(problems).toContain("requires.metamodel \">=1.3\" must be a range with an upper bound"); + expect(problems).toContain('requires pack "metaobjects-nope", which is not in packs/'); + expect(problems).toContain('version is "0.2.0", pack.json says "0.1.0"'); + expect(problems).toContain('"private" must be true while pack.json says publish: false'); + expect(problems).toContain('peerDependencies["@metaobjectsdev/metadata"] is "undefined"'); + expect(problems).toContain('"@metaobjectsdev/codegen-ts" is a dependency'); + expect(problems).toContain('needs a "typecheck" script'); + expect(problems).toContain("packs/demo/python: the directory exists but pack.json does not list the port"); + }); + + test("the naming rule fixes each registry coordinate", () => { + const root = scratchRoot(); + makePack(root, "data-flow", { + manifest: { + ports: { + typescript: { package: "@metaobjectsdev/pack-data-flow", core: ">=1.3.0 <2.0.0", publish: false }, + csharp: { package: "MetaObjects.Packs.Dataflow", core: "[1.3.0,2.0.0)", publish: false }, + }, + }, + }); + write(root, "packs/data-flow/csharp/MetaObjects.Packs.DataFlow.csproj", + `MetaObjects.Packs.Dataflow0.1.0` + + ``); + const problems = checkPackManifests(root).join("\n"); + expect(problems).toContain('the naming rule gives "MetaObjects.Packs.DataFlow"'); + expect(problems).not.toContain("MetaObjects reference"); + }); + + test("a missing README, changelog or pin is named", () => { + const root = scratchRoot(); + makePack(root, "demo"); + rmSync(join(root, "packs/demo/CHANGELOG.md")); + rmSync(join(root, `packs/demo/${PACK_VOCABULARY}`)); + const problems = checkPackManifests(root).join("\n"); + expect(problems).toContain("packs/demo/CHANGELOG.md: missing"); + expect(problems).toContain(`packs/demo/${PACK_VOCABULARY}: missing`); + }); +}); + +describe("pack boundary", () => { + test("the repository as committed is inside the boundary", () => { + expect(checkPackBoundary(REPO_ROOT)).toEqual([]); + }); + + test("core naming a pack coordinate, reaching into packs/ or naming a pack id fails", () => { + const root = scratchRoot(); + makePack(root, "demo"); + write(root, "server/typescript/packages/cli/src/a.ts", `import { x } from "@metaobjectsdev/pack-demo";\n`); + write(root, "server/python/src/b.py", `PATH = "../../packs/demo/python"\n`); + write(root, "fixtures/conformance/x/providers.json", `["metaobjects-core-types", "metaobjects-demo"]\n`); + write(root, "docs/packs.md", "@metaobjectsdev/pack-demo is described here, which is fine\n"); + const problems = scanCore(root).join("\n"); + expect(problems).toContain("server/typescript/packages/cli/src/a.ts:1: core names a pack coordinate"); + expect(problems).toContain("server/python/src/b.py:1: core reaches into packs/ by path"); + expect(problems).toContain('fixtures/conformance/x/providers.json:1: names the independent pack provider "metaobjects-demo"'); + expect(problems).not.toContain("docs/packs.md"); + }); + + test("the root workspace may hold the pack glob, and core's scripts may not filter on '*'", () => { + const root = scratchRoot(); + write(root, "package.json", json({ + workspaces: ["server/typescript/packages/*", "packs/*/typescript", "packs/demo"], + scripts: { build: "bun run --filter '*' build", typecheck: "bun run --filter './server/typescript/packages/*' typecheck" }, + })); + const problems = scanCore(root); + expect(problems).toEqual([ + 'package.json: workspace "packs/demo" — packs join only as "packs/*/typescript"', + "package.json: the \"build\" script must name core's workspace directories, not '*' (which takes in every pack)", + ]); + }); + + test("a pack id or a pinned type in the bundle's registry fails", () => { + const root = scratchRoot(); + makePack(root, "demo"); + write(root, "packs/demo/" + PACK_VOCABULARY, json({ types: [{ type: "layout", subType: "picker" }] })); + write(root, "fixtures/registry-conformance/expected-registry.json", json({ types: [{ type: "layout", subType: "picker" }] })); + write(root, "fixtures/registry-conformance/providers.json", json({ providers: { "metaobjects-demo": {} } })); + const problems = scanRegistry(root).join("\n"); + expect(problems).toContain('provider id "metaobjects-demo" is a bundled provider'); + expect(problems).toContain("layout.picker is also in expected-registry.json"); + }); + + test("a release gate that starts enumerating packs/ fails", () => { + const root = scratchRoot(); + const copy = (rel: string): void => { + mkdirSync(dirname(join(root, rel)), { recursive: true }); + cpSync(join(REPO_ROOT, rel), join(root, rel), { recursive: true }); + }; + for (const rel of ["scripts/publish-set.mjs", "scripts/check-publish-intent.sh", "scripts/check-no-prerelease-versions.sh", + "server/python/pyproject.toml", "server/csharp/Directory.Build.props", "server/java/pom.xml"]) copy(rel); + for (const ws of ["server/typescript/packages", "client/web/packages"]) { + for (const n of readdirSync(join(REPO_ROOT, ws))) { + try { copy(`${ws}/${n}/package.json`); } catch { /* a directory with no manifest */ } + } + } + expect(scanReleaseTooling(root)).toEqual([]); + const intent = join(root, "scripts/check-publish-intent.sh"); + writeFileSync(intent, readFileSync(intent, "utf8").replace( + "client/web/packages/*/package.json; do", "client/web/packages/*/package.json packs/*/typescript/package.json; do")); + const problems = scanReleaseTooling(root).join("\n"); + expect(problems).toContain("scripts/check-publish-intent.sh: fails once a pack package exists under packs/"); + }); +}); + +describe("pack vocabulary", () => { + test("the pin holds exactly what the pack adds, and it leaves core alone", async () => { + const root = scratchRoot(); + makePack(root, "demo"); + const r = await checkPackVocabulary("demo", root); + const pin = JSON.parse(r.emitted) as { + pack: string; + types: { type: string; subType: string }[]; + extends: { type: string; subType: string; attrs: { name: string }[] }[]; + commonAttrs: unknown[]; + }; + expect(pin.pack).toBe("metaobjects-demo"); + expect(pin.types.map((t) => `${t.type}.${t.subType}`)).toEqual(["layout.picker"]); + expect(pin.extends.map((e) => `${e.type}.${e.subType}:${e.attrs.map((a) => a.name).join(",")}`)).toEqual(["field.string:searchable,valueLabels"]); + expect(pin.commonAttrs).toEqual([]); + // Only the stale-pin problem: the committed placeholder is not the derived pin. + expect(r.problems).toEqual([`${PACK_VOCABULARY} is stale — the registered vocabulary changed; review it and run: bun scripts/pack-vocabulary.ts demo --write`]); + writeFileSync(join(root, "packs/demo", PACK_VOCABULARY), r.emitted); + expect((await checkPackVocabulary("demo", root)).problems).toEqual([]); + }); + + test("a pack that changes a row the bundle declares does not leave core alone", async () => { + const root = scratchRoot(); + makePack(root, "demo", { breakCore: true }); + const problems = (await checkPackVocabulary("demo", root)).problems.join("\n"); + expect(problems).toContain("does not leave core alone — changed: default object"); + }); + + test("a pack is pinned only for its own rows when it requires another pack", async () => { + const root = scratchRoot(); + makePack(root, "base"); + makePack(root, "child", { manifest: { requires: { metamodel: ">=1.3 <2", packs: { "metaobjects-base": ">=0.1.0 <0.2.0" } } } }); + // The child registers nothing of its own: same body as base would collide, so give it none. + write(root, "packs/child/typescript/src/index.ts", + `export const provider = { id: "metaobjects-child", dependencies: ["metaobjects-base"], registerTypes() {} };\n`); + const pin = JSON.parse((await checkPackVocabulary("child", root)).emitted) as { types: unknown[]; extends: unknown[] }; + expect(pin.types).toEqual([]); + expect(pin.extends).toEqual([]); + }); +}); + +describe("pack conformance", () => { + const MODEL = join(REPO_ROOT, "fixtures/conformance/provider-custom-vocabulary-success"); + + test("a pack's corpus runs through the TypeScript adapter with the pack composed in", async () => { + const root = scratchRoot(); + makePack(root, "demo"); + const corpus = "packs/demo/fixtures/conformance"; + cpSync(join(MODEL, "input"), join(root, corpus, "loads/input"), { recursive: true }); + cpSync(join(MODEL, "expected.json"), join(root, corpus, "loads/expected.json")); + write(root, `${corpus}/loads/providers.json`, json(["metaobjects-core-types", "metaobjects-demo"])); + const r = await runPackConformance("demo", root); + expect(r?.passed).toBe(true); + expect(r?.fixtures.map((f) => `${f.name}:${f.status}`)).toEqual(["loads:pass"]); + }); + + test("a scenario that does not name the pack fails, and a pack with no corpus reports none", async () => { + const root = scratchRoot(); + makePack(root, "demo"); + expect(await runPackConformance("demo", root)).toBeUndefined(); + const corpus = "packs/demo/fixtures/conformance"; + cpSync(join(MODEL, "input"), join(root, corpus, "core-only/input"), { recursive: true }); + cpSync(join(MODEL, "expected.json"), join(root, corpus, "core-only/expected.json")); + const r = await runPackConformance("demo", root); + expect(r?.passed).toBe(false); + expect(r?.fixtures[0]?.problems.join(" ")).toContain('providers.json must name "metaobjects-demo"'); + }); +}); diff --git a/scripts/test-ci-lane-selection.sh b/scripts/test-ci-lane-selection.sh index b1f26ab550..03e061b8b2 100755 --- a/scripts/test-ci-lane-selection.sh +++ b/scripts/test-ci-lane-selection.sh @@ -23,17 +23,19 @@ check() { # check "" "" "" } lanes() { select_lanes "$@"; echo "$SELECTED_LANES"; } -ALL="ts-fast ts-unit java-slow python csharp rust" +ALL="ts-fast ts-unit java-slow python csharp rust packs" # ── 1. change sets ──────────────────────────────────────────────────────────── -check "ts-fast ts-unit" "$(lanes server/typescript/packages/cli/src/x.ts)" "one port: typescript" -check "ts-fast ts-unit" "$(lanes client/web/packages/react/src/y.tsx)" "one port: the web client is typescript's" +check "ts-fast ts-unit packs" "$(lanes server/typescript/packages/cli/src/x.ts)" "one port: typescript, with the packs canary" +check "ts-fast ts-unit packs" "$(lanes client/web/packages/react/src/y.tsx)" "one port: the web client is typescript's" +check "packs" "$(lanes packs/demo/typescript/src/index.ts packs/demo/pack.json)" "a pack-only change selects only the packs lane (ADR-0069)" +check "ts-fast ts-unit" "$(lanes examples/dynamic-grid/src/a.ts)" "the dynamic-grid example runs no pack canary" check "java-slow" "$(lanes server/java/metadata/src/main/java/A.java server/java/codegen-kotlin/src/main/kotlin/B.kt)" "one port: java and kotlin" check "python" "$(lanes server/python/src/metaobjects/loader.py)" "one port: python" check "csharp" "$(lanes server/csharp/MetaObjects/Loader.cs)" "one port: csharp" check "rust" "$(lanes server/rust/metaobjects/src/loader.rs)" "one port: rust" -check "ts-fast ts-unit python" "$(lanes server/python/b.py server/typescript/a.ts)" "two ports, given out of order, run in lane order" -check "ts-fast ts-unit java-slow python csharp" "$(lanes server/csharp/a.cs server/java/b.java server/python/c.py server/typescript/d.ts)" "all four ports touched" +check "ts-fast ts-unit python packs" "$(lanes server/python/b.py server/typescript/a.ts)" "two ports, given out of order, run in lane order" +check "ts-fast ts-unit java-slow python csharp packs" "$(lanes server/csharp/a.cs server/java/b.java server/python/c.py server/typescript/d.ts)" "all four ports touched" check "$ALL" "$(lanes fixtures/conformance/foo/meta.json)" "shared fixtures run everything" check "$ALL" "$(lanes spec/metamodel.md)" "the spec runs everything" check "$ALL" "$(lanes agent-context/skills/x.md)" "agent context runs everything" @@ -61,6 +63,7 @@ esac # ports, for the hosted workflows' detect jobs: derived from the same lanes check "ts python" "$(MO_AFFECTED_TEST=1 bash -c 'source scripts/ci-affected-ports.sh; map_paths_to_ports server/typescript/a.ts server/python/b.py')" "ports derive from lanes" +check "ts" "$(MO_AFFECTED_TEST=1 bash -c 'source scripts/ci-affected-ports.sh; map_paths_to_ports packs/demo/pack.json')" "a pack change is the ts port, whose hosted job runs the packs lane" # ── 2. the map ──────────────────────────────────────────────────────────────── check "" "$(lane_map_problems)" "the committed map is well formed" @@ -95,10 +98,10 @@ check "(none)" "$(run)" "git: no change selects nothing" echo b >> "$tmp/repo/server/python/a.py"; commit python check "python" "$(run)" "git: a committed python change selects python" echo b >> "$tmp/repo/server/typescript/a.ts" -check "ts-fast ts-unit python" "$(run)" "git: an uncommitted typescript change joins it" +check "ts-fast ts-unit python packs" "$(run)" "git: an uncommitted typescript change joins it" commit typescript echo b >> "$tmp/repo/README.md" -check "ts-fast ts-unit python" "$(run)" "git: an untracked root-prose file adds no lane" +check "ts-fast ts-unit python packs" "$(run)" "git: an untracked root-prose file adds no lane" commit prose check "$ALL" "$(run MO_CI_FULL=1)" "MO_CI_FULL=1 selects every lane" check "$ALL" "$(run MO_CI_AFFECTED_BASE=no-such-ref)" "an unresolvable base selects every lane" diff --git a/server/typescript/packages/conformance/src/corpus.ts b/server/typescript/packages/conformance/src/corpus.ts new file mode 100644 index 0000000000..460b6f8581 --- /dev/null +++ b/server/typescript/packages/conformance/src/corpus.ts @@ -0,0 +1,81 @@ +// The corpus-root entry point: run every scenario under ANY corpus directory. +// +// The shared metamodel corpus (fixtures/conformance/) is driven per port by a test file +// that enumerates it as one bun test per fixture. An independent pack (ADR-0069) keeps +// its corpus inside its own directory, packs//fixtures/conformance/, so the same +// runner needs a second way in: give it a root and an adapter, get back one verdict per +// scenario. It changes nothing about how a fixture is read or checked — it is the +// discover → lint → run → classify loop the core test file performs, as a function. +// +// `requireProviders` is the independent-pack port rule made mechanical: a pack's corpus +// exists to prove the PACK, so every scenario must name the pack's provider id in its +// providers.json. A scenario with no providers.json falls back to the default bundle, +// which by definition does not carry an independent pack, and would test core instead. + +import { discoverFixtures, isContractOnlyFixture, isDocsOnlyFixture } from "./fixture.js"; +import type { ConformanceAdapter } from "./adapter.js"; +import { lintFixture } from "./fixture-lint.js"; +import { runFixture } from "./runner.js"; +import { classifyAgainstLedger } from "./expected-failures.js"; +import type { FixtureStatus } from "./report.js"; + +export interface CorpusOptions { + /** Absolute path of the corpus directory: one sub-directory per scenario. */ + readonly corpusRoot: string; + /** The port's adapter, composed with every provider id the corpus names. */ + readonly adapter: ConformanceAdapter; + /** The error codes an `expected-errors.json` may name (fixtures/conformance/ERROR-CODES.json). */ + readonly errorCodes: readonly string[]; + /** Fixture names this port expects to fail (the expected-failures ledger). Default: none. */ + readonly ledger?: readonly string[]; + /** Provider ids every scenario's providers.json must list. Default: none. */ + readonly requireProviders?: readonly string[]; +} + +/** One scenario's verdict. `skipped` is a docs-only or contract-only fixture, run elsewhere. */ +export interface CorpusFixtureResult { + readonly name: string; + readonly status: FixtureStatus | "skipped"; + /** Lint problems and failed-check details; empty on a pass. */ + readonly problems: readonly string[]; +} + +export interface CorpusResult { + readonly corpusRoot: string; + readonly fixtures: readonly CorpusFixtureResult[]; + /** True when no scenario is `fail` or `fixed-but-listed`. */ + readonly passed: boolean; +} + +/** Run every scenario under `corpusRoot` through `adapter`. */ +export async function runCorpus(opts: CorpusOptions): Promise { + const ledger = opts.ledger ?? []; + const required = opts.requireProviders ?? []; + const results: CorpusFixtureResult[] = []; + for (const fix of await discoverFixtures(opts.corpusRoot)) { + if (isDocsOnlyFixture(fix) || isContractOnlyFixture(fix)) { + results.push({ name: fix.name, status: "skipped", problems: [] }); + continue; + } + const problems = [...lintFixture(fix, opts.errorCodes)]; + for (const id of required) { + if (!fix.providers.includes(id)) { + problems.push(`providers.json must name "${id}" (it lists: ${fix.providers.join(", ")})`); + } + } + if (problems.length > 0) { + results.push({ name: fix.name, status: "fail", problems }); + continue; + } + const report = await runFixture(fix, opts.adapter); + const status = classifyAgainstLedger(report.status === "pass" ? "pass" : "fail", fix.name, ledger); + const failed = report.checks.filter((c) => !c.passed).map((c) => c.detail ?? c.kind); + results.push({ + name: fix.name, + status, + problems: status === "fixed-but-listed" ? ["passes but is listed in the expected-failures ledger"] : failed, + }); + } + const passed = results.every((r) => r.status !== "fail" && r.status !== "fixed-but-listed"); + return { corpusRoot: opts.corpusRoot, fixtures: results, passed }; +} diff --git a/server/typescript/packages/conformance/src/index.ts b/server/typescript/packages/conformance/src/index.ts index 31ff656826..6c489ab0dc 100644 --- a/server/typescript/packages/conformance/src/index.ts +++ b/server/typescript/packages/conformance/src/index.ts @@ -11,3 +11,4 @@ export * from "./fixture-lint.js"; export * from "./manifest.js"; export * from "./aggregator.js"; export * from "./generator.js"; +export * from "./corpus.js"; diff --git a/server/typescript/packages/conformance/test/corpus.test.ts b/server/typescript/packages/conformance/test/corpus.test.ts new file mode 100644 index 0000000000..560a9a1289 --- /dev/null +++ b/server/typescript/packages/conformance/test/corpus.test.ts @@ -0,0 +1,60 @@ +import { afterAll, expect, test } from "bun:test"; +import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { runCorpus } from "../src/corpus.js"; +import type { ConformanceAdapter } from "../src/adapter.js"; + +const dirs: string[] = []; +afterAll(async () => { await Promise.all(dirs.map((d) => rm(d, { recursive: true, force: true }))); }); + +// The tree is fixed, so expected.json decides each verdict. +const fake: ConformanceAdapter = { + language: "fake", + async loadFixture() { return { tree: {}, errorCodes: [], warnings: [] }; }, + canonicalSerialize() { return '{"ok":true}'; }, + canonicalSerializeEffective() { return '{"ok":true}'; }, + navigate() { return undefined; }, + invoke() { return { scalar: true }; }, +}; + +async function corpus(scenarios: Record>): Promise { + const root = await mkdtemp(join(process.env.DEV_SCRATCH ?? tmpdir(), "mo-corpus-")); + dirs.push(root); + for (const [name, files] of Object.entries(scenarios)) { + for (const [path, content] of Object.entries({ "input/m.json": "{}", ...files })) { + const full = join(root, name, path); + await mkdir(join(full, ".."), { recursive: true }); + await writeFile(full, content); + } + } + return root; +} + +test("runs every scenario under any root and reports one verdict each", async () => { + const root = await corpus({ + good: { "expected.json": '{"ok":true}' }, + bad: { "expected.json": '{"ok":false}' }, + gap: { "expected.json": '{"ok":false}' }, + }); + const r = await runCorpus({ corpusRoot: root, adapter: fake, errorCodes: [], ledger: ["gap"] }); + expect(r.fixtures.map((f) => `${f.name}:${f.status}`)).toEqual(["bad:fail", "gap:known-gap", "good:pass"]); + expect(r.passed).toBe(false); +}); + +test("a ledger entry that now passes fails the run", async () => { + const root = await corpus({ fixed: { "expected.json": '{"ok":true}' } }); + const r = await runCorpus({ corpusRoot: root, adapter: fake, errorCodes: [], ledger: ["fixed"] }); + expect(r.fixtures[0]?.status).toBe("fixed-but-listed"); + expect(r.passed).toBe(false); +}); + +test("requireProviders fails a scenario whose providers.json leaves the provider out", async () => { + const root = await corpus({ + names: { "expected.json": '{"ok":true}', "providers.json": '["metaobjects-core-types", "metaobjects-demo"]' }, + omits: { "expected.json": '{"ok":true}' }, + }); + const r = await runCorpus({ corpusRoot: root, adapter: fake, errorCodes: [], requireProviders: ["metaobjects-demo"] }); + expect(r.fixtures.map((f) => `${f.name}:${f.status}`)).toEqual(["names:pass", "omits:fail"]); + expect(r.fixtures[1]?.problems[0]).toContain('providers.json must name "metaobjects-demo"'); +}); diff --git a/server/typescript/packages/metadata/test/conformance/adapter.ts b/server/typescript/packages/metadata/test/conformance/adapter.ts index 97bfd692b3..1627ed310c 100644 --- a/server/typescript/packages/metadata/test/conformance/adapter.ts +++ b/server/typescript/packages/metadata/test/conformance/adapter.ts @@ -183,63 +183,109 @@ function errorCode(err: Error): string { return typeof code === "string" ? code : "ERR_UNKNOWN"; } -export const tsAdapter: ConformanceAdapter = { - language: "typescript", +/** + * The adapter, composed over {@link PROVIDERS} plus `extraProviders`. + * + * `extraProviders` is how an independent pack's corpus runs through this port + * (ADR-0069): scripts/pack-conformance.ts passes the pack's provider, keyed by + * its id. An extra may add an id and never replace one, so a pack cannot stand + * in for a bundled provider. + */ +export function createTsAdapter( + extraProviders: Readonly> = {}, +): ConformanceAdapter { + for (const id of Object.keys(extraProviders)) { + if (id in PROVIDERS) { + throw new Error(`createTsAdapter: provider id "${id}" is already in the adapter's provider set`); + } + } + const known: Readonly> = { ...PROVIDERS, ...extraProviders }; + return { + language: "typescript", - async loadFixture( - inputDir: string, - providers: readonly string[], - ): Promise { - const resolved: MetaDataTypeProvider[] = providers.map((id) => { - const provider = PROVIDERS[id]; - if (provider === undefined) { - throw new Error(`Unknown provider id "${id}"`); + async loadFixture( + inputDir: string, + providers: readonly string[], + ): Promise { + const resolved: MetaDataTypeProvider[] = providers.map((id) => { + const provider = known[id]; + if (provider === undefined) { + throw new Error(`Unknown provider id "${id}"`); + } + return provider; + }); + // Provider composition errors (duplicate id / missing dep / cycle) are + // first-class fixture outcomes: surface them as a code-only LoadOutcome + // so the cross-port runner can compare expected-errors.json directly. + let registry; + try { + registry = composeRegistry(resolved); + } catch (err) { + const code = (err as { code?: unknown }).code; + const codeStr = typeof code === "string" ? code : "ERR_UNKNOWN"; + const compErr: ErrorEnvelopeRecord = { + code: codeStr, + source: { format: "code", files: [] }, + }; + return { + tree: undefined as unknown as TreeHandle, + errorCodes: [codeStr], + warnings: [], + errors: [compErr], + warningEnvelopes: [], + }; } - return provider; - }); - // Provider composition errors (duplicate id / missing dep / cycle) are - // first-class fixture outcomes: surface them as a code-only LoadOutcome - // so the cross-port runner can compare expected-errors.json directly. - let registry; - try { - registry = composeRegistry(resolved); - } catch (err) { - const code = (err as { code?: unknown }).code; - const codeStr = typeof code === "string" ? code : "ERR_UNKNOWN"; - const compErr: ErrorEnvelopeRecord = { - code: codeStr, - source: { format: "code", files: [] }, - }; - return { - tree: undefined as unknown as TreeHandle, - errorCodes: [codeStr], - warnings: [], - errors: [compErr], - warningEnvelopes: [], - }; - } - // ADR-0023 — the library's own conformance corpora load STRICT: an - // undeclared @-attr is ERR_UNKNOWN_ATTR (no open-attr policy). The public - // LoadOptions.strict default stays false so a downstream app can loosen. - const result = await MetaDataLoader.fromDirectory(inputDir, { registry, strict: true }); - // FR5a — surface the full ParseError envelopes; normalize files[] to be - // relative to the fixture's inputDir so the cross-port assertion has a - // portable file token. Errors without an envelope (rare; only non-ParseError) - // synthesize a minimal $-rooted shape. - function relativize(f: string): string { - const fwd = f.replace(/\\/g, "/"); - return f.startsWith(inputDir) ? relative(inputDir, f).replace(/\\/g, "/") : fwd; - } - const envelopes: ErrorEnvelopeRecord[] = result.errors.map((err) => { - if (err instanceof ParseError) { - const src = err.source; + // ADR-0023 — the library's own conformance corpora load STRICT: an + // undeclared @-attr is ERR_UNKNOWN_ATTR (no open-attr policy). The public + // LoadOptions.strict default stays false so a downstream app can loosen. + const result = await MetaDataLoader.fromDirectory(inputDir, { registry, strict: true }); + // FR5a — surface the full ParseError envelopes; normalize files[] to be + // relative to the fixture's inputDir so the cross-port assertion has a + // portable file token. Errors without an envelope (rare; only non-ParseError) + // synthesize a minimal $-rooted shape. + function relativize(f: string): string { + const fwd = f.replace(/\\/g, "/"); + return f.startsWith(inputDir) ? relative(inputDir, f).replace(/\\/g, "/") : fwd; + } + const envelopes: ErrorEnvelopeRecord[] = result.errors.map((err) => { + if (err instanceof ParseError) { + const src = err.source; + if (src.format === "json" || src.format === "yaml" + || src.format === "merged" || src.format === "resolved") { + const files = src.files.map(relativize); + const jp = (src as { jsonPath?: string }).jsonPath; + // FR5d — surface referrer + target on resolved envelopes so the + // cross-port runner can assert byte-identical envelopes across all + // four ports. + const referrer = (src as { referrer?: string }).referrer; + const target = (src as { target?: string }).target; + const source: ErrorEnvelopeRecord["source"] = { + format: src.format, + files, + ...(jp !== undefined ? { jsonPath: jp } : {}), + ...(referrer !== undefined ? { referrer } : {}), + ...(target !== undefined ? { target } : {}), + }; + return { code: err.code, message: err.message, source }; + } + return { code: err.code, message: err.message, source: { format: src.format, files: [] } }; + } + const code = (err as { code?: unknown }).code; + return { + code: typeof code === "string" ? code : "ERR_UNKNOWN", + source: { format: "json", files: [], jsonPath: "$" }, + }; + }); + // FR5c-finalize — surface warning envelopes (same envelope shape as + // errors). Loader warnings already carry full `LoaderWarning` envelopes; + // mirror the error-envelope normalization (relativize files; preserve + // jsonPath / referrer / target when present on the source variant). + const warningEnvelopes: ErrorEnvelopeRecord[] = result.warnings.map((w) => { + const src = w.source; if (src.format === "json" || src.format === "yaml" || src.format === "merged" || src.format === "resolved") { const files = src.files.map(relativize); const jp = (src as { jsonPath?: string }).jsonPath; - // FR5d — surface referrer + target on resolved envelopes so the - // cross-port runner can assert byte-identical envelopes across all - // four ports. const referrer = (src as { referrer?: string }).referrer; const target = (src as { target?: string }).target; const source: ErrorEnvelopeRecord["source"] = { @@ -249,72 +295,46 @@ export const tsAdapter: ConformanceAdapter = { ...(referrer !== undefined ? { referrer } : {}), ...(target !== undefined ? { target } : {}), }; - return { code: err.code, message: err.message, source }; + return { code: w.code, source }; } - return { code: err.code, message: err.message, source: { format: src.format, files: [] } }; - } - const code = (err as { code?: unknown }).code; + return { code: w.code, source: { format: src.format, files: [] } }; + }); return { - code: typeof code === "string" ? code : "ERR_UNKNOWN", - source: { format: "json", files: [], jsonPath: "$" }, + tree: result.root, + errorCodes: result.errors.map(errorCode), + // ConformanceAdapter.LoadOutcome.warnings is `string[]`; the loader now + // returns LoaderWarning envelopes (FR5a). Extract the human-readable + // message for cross-port string-equality comparison. + warnings: result.warnings.map((w) => w.message), + errors: envelopes, + warningEnvelopes, }; - }); - // FR5c-finalize — surface warning envelopes (same envelope shape as - // errors). Loader warnings already carry full `LoaderWarning` envelopes; - // mirror the error-envelope normalization (relativize files; preserve - // jsonPath / referrer / target when present on the source variant). - const warningEnvelopes: ErrorEnvelopeRecord[] = result.warnings.map((w) => { - const src = w.source; - if (src.format === "json" || src.format === "yaml" - || src.format === "merged" || src.format === "resolved") { - const files = src.files.map(relativize); - const jp = (src as { jsonPath?: string }).jsonPath; - const referrer = (src as { referrer?: string }).referrer; - const target = (src as { target?: string }).target; - const source: ErrorEnvelopeRecord["source"] = { - format: src.format, - files, - ...(jp !== undefined ? { jsonPath: jp } : {}), - ...(referrer !== undefined ? { referrer } : {}), - ...(target !== undefined ? { target } : {}), - }; - return { code: w.code, source }; - } - return { code: w.code, source: { format: src.format, files: [] } }; - }); - return { - tree: result.root, - errorCodes: result.errors.map(errorCode), - // ConformanceAdapter.LoadOutcome.warnings is `string[]`; the loader now - // returns LoaderWarning envelopes (FR5a). Extract the human-readable - // message for cross-port string-equality comparison. - warnings: result.warnings.map((w) => w.message), - errors: envelopes, - warningEnvelopes, - }; - }, + }, - canonicalSerialize(tree: TreeHandle): string { - return canonicalSerialize(tree as MetaData); - }, + canonicalSerialize(tree: TreeHandle): string { + return canonicalSerialize(tree as MetaData); + }, - canonicalSerializeEffective(tree: TreeHandle): string { - return canonicalSerializeEffective(tree as MetaData); - }, + canonicalSerializeEffective(tree: TreeHandle): string { + return canonicalSerializeEffective(tree as MetaData); + }, - navigate(tree: TreeHandle, path: readonly string[]): NodeHandle | undefined { - return navigate(tree as MetaData, path); - }, + navigate(tree: TreeHandle, path: readonly string[]): NodeHandle | undefined { + return navigate(tree as MetaData, path); + }, - invoke( - node: NodeHandle, - capabilityId: string, - args: Record, - ): NormalizedResult { - const fn = binding[capabilityId]; - if (fn === undefined) { - throw new UnknownCapabilityError(capabilityId); - } - return fn(node as MetaData, args); - }, -}; + invoke( + node: NodeHandle, + capabilityId: string, + args: Record, + ): NormalizedResult { + const fn = binding[capabilityId]; + if (fn === undefined) { + throw new UnknownCapabilityError(capabilityId); + } + return fn(node as MetaData, args); + }, + }; +} + +export const tsAdapter: ConformanceAdapter = createTsAdapter(); diff --git a/spec/decisions/ADR-0069-independent-packs.md b/spec/decisions/ADR-0069-independent-packs.md new file mode 100644 index 0000000000..c08e2eed5c --- /dev/null +++ b/spec/decisions/ADR-0069-independent-packs.md @@ -0,0 +1,231 @@ +# ADR-0069: Independent packs live in `packs/`, version themselves, and core never depends on them + +## Status + +**Accepted** (2026-11-24). Registers no vocabulary: `metamodelVersion` is unchanged, and so is +every core package version. It changes what `metamodelVersion` and core's package version promise, +and how a capability that is not yet core is built, tested and released in this repository. + +## Context + +Since ADR-0050 and the 1.3.0 work, vocabulary beyond the base metamodel lives in **packs**: a +provider of its own, composed into the default bundle and individually removable (`db`, +`documentation`, `prompt`, `ui`, `ui-web`, `rules`, `view-expressions`, `reporting`, +`requirements`). Every one of them is part of core's contract. Its types are in +`fixtures/registry-conformance/expected-registry.json`, which all five ports byte-match. A change +to it moves `metamodelVersion`, and since that manifest forces every registry to publish +(`docs/RELEASING.md`), it ships only in a coordinated core release. Its generators land in +`codegen-ts` and its runtime in `runtime-ts`, so it releases in the 13-package npm lockstep and +writes to the root changelog. + +That is the right home for vocabulary core owns. It is the wrong one for a new capability that is +still finding its shape. The rules pack shows the cost: its generator and runtime work went into +core packages and could only ship with a full core release. The next capabilities (system and +delivery vocabulary, deployment generators, UI and agent packs) would pay the same cost, and every +one of their changes would also be a change to core. Core needs to stabilise while those move at +their own pace. The captain's direction for this ADR: build and version them as if they were +separate repositories, while keeping them in this monorepo. + +`docs/1.0-readiness.md` already states the principle this ADR builds on: providers added +downstream are outside the metamodel promise (ADR-0023) and do not change `metamodelVersion`, and +an application may version its own providers. An independent pack is a downstream provider that is +maintained in this repository. + +## Decision + +### 1. Two kinds of pack + +| | Bundled pack | Independent pack | +|---|---|---| +| Examples | `db`, `documentation`, `prompt`, `ui`, `ui-web`, `rules`, `view-expressions`, `reporting`, `requirements` | the first one is planned; none exists yet | +| In the default bundle | Yes | No. A project opts in by naming the provider | +| In `expected-registry.json` | Yes | Never | +| Moves `metamodelVersion` | Yes | Never | +| Version | Core's | Its own, in `pack.json` | +| Released | With core | On its own | +| Ports | All (a lagging port still registers the vocabulary) | Those its `pack.json` lists | +| Lives in | Each port's core package | `packs//` | + +**Metamodel N.M names the default bundle only.** An independent pack is outside it, carries its +own version, and may be carried by some ports and not others. + +### 2. One direction of dependency + +A pack may depend on core and on other packs. **Core never depends on a pack**: no manifest, +import or build file outside `packs/` names a pack package or a `packs/` path, no pack's provider +id is in any port's default provider list or in `fixtures/registry-conformance/`, and no type a +pack declares appears in `expected-registry.json`. Core's release tooling (the npm publish set +and its two gates) does not enumerate `packs/`. `scripts/check-pack-boundary.ts`, in the `gates` +lane, holds all of this. It holds the release-tooling clause by planting pack packages beside a +scratch copy of core's release manifests and asserting that no release gate sees them. So the +property is tested, not true by accident of how two directories are listed today. + +The same direction applies to libraries. A library layer that needs an independent pack ships +with that pack, never in `library/`, because core's embedded libraries may not require a provider +core does not carry. + +### 3. Layout and manifest + +``` +packs// + pack.json id, version, stability, what it requires, which ports carry it + CHANGELOG.md this pack's changelog (never the root CHANGELOG.md) + README.md + metamodel/*.json the vocabulary definition, in the spec/metamodel/ format + fixtures/ + expected-vocabulary.json the rows this pack adds to the default bundle + conformance// load fixtures, in the shared fixture format + typescript/ the npm package + java/ kotlin/ python/ csharp/ rust/ present only for the ports pack.json lists +``` + +```json +{ + "id": "metaobjects-", + "version": "0.1.0", + "stability": "preview", + "requires": { "metamodel": ">=1.3 <2", "packs": {} }, + "ports": { + "typescript": { "package": "@metaobjectsdev/pack-", "core": ">=1.3.0 <2.0.0", "publish": false } + } +} +``` + +The pack is the unit of ownership: one directory, one lane-map row, one changelog, and +`git subtree split --prefix packs/` lifts it out with its history if it ever leaves. +`scripts/check-pack-manifests.ts`, in the `gates` lane, checks that each `pack.json` is well formed +(provider id, `X.Y.Z` version, stability word, ranges with an upper bound, required packs that +exist, a port directory for exactly the listed ports, README and changelog). It also checks that +`pack.json` agrees with each port's native manifest, which is what an installer actually reads. + +### 4. Names, versions and ranges + +- **Names.** npm `@metaobjectsdev/pack-`; Maven `com.metaobjects.packs:`; PyPI + `metaobjects-pack-` (import name `metaobjects_pack_`); NuGet + `MetaObjects.Packs.`; provider id `metaobjects-`. A Kotlin artifact shares the Maven + namespace as `com.metaobjects.packs:-`. The first Kotlin pack names the suffix. +- **Versions.** One version per pack, the same in every port that carries it. A port's artifact + publishes when it has a changed file and takes the pack's current version, which is core's + convergent-publishing rule applied inside the pack. Every pack starts at **`0.1.0`, `preview`** + (`docs/features/stability-labels.md`). Maven takes **no `+7` offset** for packs: a new + coordinate has no 7.x history to stay ahead of. A break in the pack's vocabulary, or in what a + project must write to use the pack, is a major (a minor while `0.x`). Added vocabulary is a + minor, and a change to generator output is a patch. +- **Ranges.** `requires.metamodel` states the metadata contract the pack's vocabulary is written + against. Each port's own manifest states the core range an installer enforces: npm as a + **peer** dependency on `@metaobjectsdev/metadata` (never a dependency, so a project never gets + a second copy of the metamodel classes, the `instanceof` hazard `AGENTS.md` describes), plus a + `workspace:*` dev dependency so the pack builds against core's working tree. Maven uses a + `provided`-scope dependency on the floor version, NuGet `[1.3.0,2.0.0)`, PyPI + `metaobjects>=1.3,<2`, and crates.io the same range once core crates are published at all + (ADR-0065). + +### 5. The provider contract is covered by core's package version + +A range like `>=1.3.0 <2.0.0` means something only if what a pack is built on is promised. The +**provider contract** (a provider's `id`, `dependencies` and `registerTypes`; the registry's +`register`, `extend` and `registerCommonAttrs`; and the provider definition file format) is +therefore part of what core's package version promises, beside the CLI and the `Generator` +interface (`docs/compatibility-policy.md`). Breaking it is a core package major. + +### 6. Conformance per pack, and the port rule for independent packs + +A pack's tests live in the pack, outside `fixtures/`, so the gated corpus counts in `AGENTS.md` +and `docs/CONFORMANCE.md` never move for pack work. + +- **Pinned vocabulary.** `packs//fixtures/expected-vocabulary.json` is the + registry-conformance pattern scoped to one pack: the rows this pack (with the packs it requires + already composed) adds to the default bundle, and only those. `scripts/pack-vocabulary.ts` + derives it in TypeScript, the reference emitter, and every port that carries the pack + byte-matches it. +- **Leaves core alone.** The same script composes the bundle with and without the pack and fails + if any row of the bundle's own manifest changes or disappears. A pack may add types, add + optional attributes and child rules to bundle types (ADR-0050), and add common attributes. It + may not change anything the bundle declares. This is ADR-0050's composition invariant pointed + outward. +- **Load fixtures.** `packs//fixtures/conformance//` uses the shared fixture + format, and each scenario's `providers.json` must name the pack, because a scenario that loads + only the bundle tests core. TypeScript runs them with `runCorpus` (`@metaobjectsdev/conformance`, + the corpus-root entry point) through the same adapter as `fixtures/conformance/`, composed with + the pack's provider (`scripts/pack-conformance.ts`). Another port gets the same entry point + when a pack first ships there. +- **The port rule.** The bundle rule is unchanged: a lagging port still registers the bundle's + vocabulary and loads it strictly. **For an independent pack, a port either carries the provider + and passes the pack's whole corpus, or does not carry it, and a model that uses the pack fails + there with an error naming what it does not know.** This is the one place the design departs + from "every port, every type", and it applies to independent packs only. + +### 7. CI: a lane of its own, and a canary on core changes + +`packs` is a lane in `scripts/ci-local.sh`, selectable by `--affected` and run by the hosted +TypeScript job (`.github/workflows/pr-ci.yml`). The lane map gives `packs/*` that lane only, so a +pack-only change selects no core lane (asserted by `scripts/test-ci-lane-selection.sh`). For each +pack with a TypeScript port, the lane runs the pack's typecheck, the pinned-vocabulary and +leaves-core-alone check, its load corpus and its own tests, against core's working tree. + +- **Blocking** for a pack whose own files the change touches. A pack's own next change must be + green against core's working tree, by fixing the pack or raising its floor. +- **A canary everywhere else.** A core change (`server/typescript/`, `client/web/`) also runs the + lane. A pack it turns red is recorded as a named SKIP that reports the break and never fails the + run. Blocking core on a preview pack's tests would recreate the coupling this ADR removes. A + pack that reaches `stable` can be made blocking by decision, since breaking a stable pack + through the covered surface is a core compatibility bug. + +Core's own `build` and `typecheck` (the root `package.json` scripts, used by the pre-push hook, +`ci-local.sh` and `integration-test.sh`) name core's workspace directories instead of +`--filter '*'`, so a pack's red typecheck never fails core's. + +### 8. Publishing + +A pack stays **unpublished** (`"publish": false`, its npm package `private`) and is used by +adopter projects through the private prerelease registry (`docs/features/prerelease.md`) until +one estate project runs it with the drift gate enforced. Only then does it publish, as `0.x` +`preview`. This is the bar a `preview` library meets before promotion (`docs/features/libraries.md`), and the one ADR-0035 Amendment 6 sets for new vocabulary (ruling 3) and for a helper leaving `0.x` (ruling 2). A pack release +is tagged `pack--v`, which the core release tags (`v..

`), the site deploy +and the metamodel gate's baseline all ignore. The per-registry release path (a pack release +script, a pack version gate against its last tag, and a test against the lowest published core +in the range) is later work, built before the first publish. + +### 9. What does not change + +- **The bundled packs stay where they are.** The rules pack stays bundled and `experimental` in + 1.3.0. Whether it becomes bundled-stable or independent is decided when it is promoted. The + experimental label already allows moving it in a minor. +- **Libraries stay embedded in core** (section 2 gives the one rule that follows for a library + layer that needs a pack). +- **No load-time check yet.** A provider stating its version and needs, with the loader refusing a + mismatch by name, is the right end state. It is a change to the provider contract in six ports, + and an installer's range is enough while every user of a pack is an estate project. + +## Consequences + +- Pack work never moves `metamodelVersion`, a core package version, the npm lockstep set or the + root changelog, and never needs the maintenance-branch procedure. Core can be released from + `main` at any moment with pack work in flight. +- A pack joins the root Bun workspace (`packs/*/typescript`). That gives one install, and it lets + a pack import core from source, as a workspace member does. The cost is a shared `bun.lock`, so + a pack's third-party dependency can move a resolved version in core's lockfile. A separate + workspace root under `packs/` was tried and does not work: Bun cannot resolve core's own + `workspace:*` dev dependencies from outside the root workspace, so it would need published core + packages and could not build against the working tree. +- A pack in a port other than TypeScript needs a hand-written provider in that port until the + port can register vocabulary from a definition file (TypeScript and Rust can today). +- Core can break a preview pack without knowing it until the canary reports, and the pack is then + fixed in its own pull request. That is the trade a separate repository would make, made + visible. +- The boundary is held by gates, not by convention. A refactor that makes a core release script + sweep every `package.json`, or a core file that imports a pack, fails the `gates` lane. + +## Related + +- [ADR-0023](ADR-0023-strict-metadata-provenance.md): downstream providers are outside the + library's promise; this ADR brings one inside the repository without bringing it inside the bundle. +- [ADR-0035](ADR-0035-one-zero-stability-commitment-and-version-unification.md) Amendments 2 and 6: the two contracts, + and the estate bar for publishing. +- [ADR-0050](ADR-0050-own-vs-projected-attributes.md): the composition invariant that "leaves core + alone" points outward. +- [GOVERNANCE.md](../../GOVERNANCE.md#extension-packs-and-the-core-metamodel), + [docs/features/extending-with-providers.md](../../docs/features/extending-with-providers.md), + [docs/compatibility-policy.md](../../docs/compatibility-policy.md), + [docs/CONFORMANCE.md](../../docs/CONFORMANCE.md), [docs/RELEASING.md](../../docs/RELEASING.md), + [packs/README.md](../../packs/README.md). diff --git a/spec/decisions/README.md b/spec/decisions/README.md index c77a80a50f..1440e0a116 100644 --- a/spec/decisions/README.md +++ b/spec/decisions/README.md @@ -65,6 +65,7 @@ Write one when a decision is **cross-cutting** (affects more than one language p - [ADR-0066 — Business rules: operations, permission points and lifecycles](ADR-0066-business-rules-operations-and-lifecycles.md) — *Accepted* (registers `api.*`, `operation.*`, `binding.*` and `transition.*` in all five ports, experimental, with eleven loader errors and a rules gate in every `verify`; the lifecycle, its states and a transition's command are derived; `transition.timed` reserved; TypeScript's service generator enforces them; the other ports' services are later work) - [ADR-0067 — Generated code is layered, and hand-written code attaches at the service seam](ADR-0067-layering-and-the-service-seam.md) — *Accepted* (layers 0 to 6; a service module per metadata package whose surface is its operations; hand-written bodies, policy and event handling implement generated interfaces and are passed in, in every language; a layer is a generator an app chooses, per package, with no named sets; the actor is an app-defined type; amends ADR-0045) - [ADR-0068 — The list query is part of the cross-port REST contract](ADR-0068-list-query-cross-port-contract.md) — *Accepted* (`?search`, `filter[or]`/`filter[and]`, the nesting cap, the bare-field and leading-`%` refusals, the value-format check, the `in` cap and the invalid_json / invalid_id / pagination.invalid_value / constraint_violation responses are contract in every port; `fixtures/list-query-conformance/` and the api-contract `list-query/` sub-corpus are the authority; each port passes both before rc.4) +- [ADR-0069 — Independent packs live in `packs/`, version themselves, and core never depends on them](ADR-0069-independent-packs.md) — *Accepted* (Metamodel N.M names the default bundle only; an independent pack has its own version, may be carried by some ports and not others, and is outside `expected-registry.json`; core never depends on a pack, held by `scripts/check-pack-boundary.ts`; the provider contract is covered by core's package version; a `packs` lane that blocks for a pack's own change and is a canary on core changes; unpublished until an estate project runs it with the drift gate enforced) > **Index gap — ADR-0031 through ADR-0051 are on disk but not listed above.** The index stopped > being maintained after ADR-0030; the files are authoritative, this list is not. Read From 5618914a4973f93da81c387d1bae1539a903f9d7 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 22:28:38 -0500 Subject: [PATCH 2/7] ci(packs): run the packs lane on pushes to main in local-ci.yml A packs job on the self-hosted runner, gated on the ts port and mapped in ci-ports-to-run.sh so a red packs lane on main is re-run by the known-green selection. The blocking/canary decision diffs against the push's before SHA; nightly and dispatch runs treat every pack as a canary. --- .github/workflows/local-ci.yml | 21 +++++++++++++++++++- scripts/ci-ports-to-run.sh | 4 ++-- scripts/test-ci-ports-to-run.sh | 14 ++++++------- spec/decisions/ADR-0069-independent-packs.md | 6 ++++-- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/.github/workflows/local-ci.yml b/.github/workflows/local-ci.yml index 63a147b6a9..afaf8b1afd 100644 --- a/.github/workflows/local-ci.yml +++ b/.github/workflows/local-ci.yml @@ -335,8 +335,27 @@ jobs: export PATH="$HOME/.cargo/bin:$PATH" scripts/ci-local.sh --only rust --strict-toolchains + # PACKS lane — the independent packs under packs/ (ADR-0069), against main's core. + # Blocking for a pack this push touched; a named non-failing SKIP (the canary) for a + # pack a core change broke. MO_CI_AFFECTED_BASE is the push's `before`, so "touched" + # means this push; on the nightly and on dispatch it is empty and every pack is a + # canary. With no pack under packs/ the lane passes with a note. + packs: + needs: detect + if: contains(needs.detect.outputs.ports, 'ts') + runs-on: [self-hosted, linux] + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # the blocking/canary decision diffs against the push's base + persist-credentials: false + - env: + MO_CI_AFFECTED_BASE: ${{ github.event.before }} + run: scripts/ci-local.sh --only packs --strict-toolchains + notify: - needs: [detect, gates, ts-fast, ts-unit, ts-slow, java-slow, python, csharp, rust] + needs: [detect, gates, ts-fast, ts-unit, ts-slow, java-slow, python, csharp, rust, packs] if: always() && contains(needs.*.result, 'failure') runs-on: [self-hosted, linux] steps: diff --git a/scripts/ci-ports-to-run.sh b/scripts/ci-ports-to-run.sh index 6abe85abf3..b6d0e43fc9 100755 --- a/scripts/ci-ports-to-run.sh +++ b/scripts/ci-ports-to-run.sh @@ -45,7 +45,7 @@ RUN_WINDOW="${MO_PORTS_RUN_WINDOW:-20}" # asserted against the workflow's real job list by scripts/test-ci-ports-to-run.sh. lane_port() { case "$1" in - ts-fast|ts-unit|ts-slow) echo ts ;; + ts-fast|ts-unit|ts-slow|packs) echo ts ;; java-slow) echo java ;; python) echo python ;; csharp) echo csharp ;; @@ -54,7 +54,7 @@ lane_port() { esac } -all_lanes() { echo "ts-fast ts-unit ts-slow java-slow python csharp rust"; } +all_lanes() { echo "ts-fast ts-unit ts-slow java-slow python csharp rust packs"; } # Canonical order, deduplicated, unknown tokens dropped. The order is FIXED rather than # sorted because the workflow tests the result with `contains(..., 'ts')` — a substring diff --git a/scripts/test-ci-ports-to-run.sh b/scripts/test-ci-ports-to-run.sh index 44a85dbecf..979706fdbc 100755 --- a/scripts/test-ci-ports-to-run.sh +++ b/scripts/test-ci-ports-to-run.sh @@ -25,36 +25,36 @@ check "ts" "$(union_ports ts bogus)" "union dro # ── not_green_ports: newest verdict per lane wins ───────────────────────────── all_green() { - printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python csharp rust + printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python csharp rust packs } check "" "$(all_green | not_green_ports)" "every lane green -> nothing to re-run" # The defect this file exists for: a docs-only run SKIPS the code lanes, so the # newest run says nothing about them and the verdict must come from the run before. -check "java" "$( { printf '%s\tskipped\n' ts-fast ts-unit ts-slow java-slow python csharp rust - printf '%s\tsuccess\n' ts-fast ts-unit ts-slow python csharp rust +check "java" "$( { printf '%s\tskipped\n' ts-fast ts-unit ts-slow java-slow python csharp rust packs + printf '%s\tsuccess\n' ts-fast ts-unit ts-slow python csharp rust packs printf '%s\tfailure\n' java-slow; } | not_green_ports )" \ "docs-only run skips a red java -> java still not green" -check "ts" "$( { printf '%s\tsuccess\n' ts-fast ts-unit java-slow python csharp rust +check "ts" "$( { printf '%s\tsuccess\n' ts-fast ts-unit java-slow python csharp rust packs printf 'ts-slow\tfailure\n'; } | not_green_ports )" \ "one red ts lane selects the whole ts port" # `skipped` is walked past, never counted as a verdict — it describes the # selection, not the code. check "" "$( { printf 'ts-fast\tskipped\n' - printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python csharp rust; } | not_green_ports )" \ + printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python csharp rust packs; } | not_green_ports )" \ "skipped is walked past to the real verdict" # A lane that was cancelled was never verified. cancel-in-progress makes this # common, so counting it as green would reopen the hole from the other side. -check "csharp" "$( { printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python rust +check "csharp" "$( { printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow python rust packs printf 'csharp\tcancelled\n'; } | not_green_ports )" \ "cancelled is not green" # No verdict at all in the window is UNKNOWN, and unknown must widen. -check "python" "$(printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow csharp rust | not_green_ports)" \ +check "python" "$(printf '%s\tsuccess\n' ts-fast ts-unit ts-slow java-slow csharp rust packs | not_green_ports)" \ "a lane with no verdict in the window is not green" check "ts java python csharp rust" "$(printf '' | not_green_ports)" "no history at all -> everything" diff --git a/spec/decisions/ADR-0069-independent-packs.md b/spec/decisions/ADR-0069-independent-packs.md index c08e2eed5c..6a1065f668 100644 --- a/spec/decisions/ADR-0069-independent-packs.md +++ b/spec/decisions/ADR-0069-independent-packs.md @@ -157,8 +157,10 @@ and `docs/CONFORMANCE.md` never move for pack work. ### 7. CI: a lane of its own, and a canary on core changes -`packs` is a lane in `scripts/ci-local.sh`, selectable by `--affected` and run by the hosted -TypeScript job (`.github/workflows/pr-ci.yml`). The lane map gives `packs/*` that lane only, so a +`packs` is a lane in `scripts/ci-local.sh`, selectable by `--affected`, run on every pull +request by the hosted TypeScript job (`.github/workflows/pr-ci.yml`) and on every push to `main` +by its own job in `.github/workflows/local-ci.yml`, which is in the known-green lane map +(`scripts/ci-ports-to-run.sh`) like every other lane. The lane map gives `packs/*` that lane only, so a pack-only change selects no core lane (asserted by `scripts/test-ci-lane-selection.sh`). For each pack with a TypeScript port, the lane runs the pack's typecheck, the pinned-vocabulary and leaves-core-alone check, its load corpus and its own tests, against core's working tree. From 80147edc24ff4b5589fa2931abbc2dfebd3b974a Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 22:34:30 -0500 Subject: [PATCH 3/7] fix(packs): fold code-review findings - pack_is_blocking captures the changed-path list before grepping, so pipefail plus grep -q can no longer turn a pack's own change into a non-blocking canary. - the leaves-core-alone check fails a child rule with a lower bound added to a type the pack does not own (the registry already refuses a required projected attribute). - runCorpus applies requireProviders before skipping docs-only and contract-only scenarios, does not pass a corpus with nothing runnable, and reports an adapter throw as that scenario's failure. - check-pack-manifests accepts caret, tilde, ~= and bounded intervals. - the live build and typecheck instructions say bun run build / bun run typecheck instead of --filter '*'. - ADR-0069 and the lane map say the pack-only selection holds under --affected; the hosted workflows select by port. --- docs/llms/llms-full.txt | 2 +- scripts/bench-load/stages.py | 2 +- scripts/check-install-size.mjs | 4 +-- scripts/check-pack-manifests.ts | 12 +++++-- scripts/check-scripts-typecheck.ts | 2 +- scripts/ci-lane-map.txt | 2 +- scripts/ci-local.sh | 9 +++-- scripts/lib/packs.ts | 5 +++ scripts/pack-conformance.ts | 4 +++ scripts/packs.test.ts | 19 +++++++++-- scripts/regen-showcase.ts | 2 +- server/typescript/README.md | 2 +- .../cli/test/integration/support/built-cli.ts | 4 +-- .../packages/conformance/src/corpus.ts | 33 +++++++++++++------ .../packages/conformance/test/corpus.test.ts | 16 +++++++++ spec/decisions/ADR-0069-independent-packs.md | 13 +++++--- tsconfig.scripts.json | 2 +- 17 files changed, 98 insertions(+), 35 deletions(-) diff --git a/docs/llms/llms-full.txt b/docs/llms/llms-full.txt index cd040daba1..8a0de2e3d3 100644 --- a/docs/llms/llms-full.txt +++ b/docs/llms/llms-full.txt @@ -208,7 +208,7 @@ bun test Bun-first dev workflow; no separate build step. Typecheck across the workspace: ```bash -bun run --filter '*' typecheck +bun run typecheck ``` Distribution artifacts remain Node-compatible -- consumers can install via npm/pnpm/bun. diff --git a/scripts/bench-load/stages.py b/scripts/bench-load/stages.py index 81dffca815..873589397c 100644 --- a/scripts/bench-load/stages.py +++ b/scripts/bench-load/stages.py @@ -188,7 +188,7 @@ def _meta(self): def load(self, model, runs): dist = REPO / "server/typescript/packages/metadata/dist" if not (dist / "index.js").exists(): - raise NotAvailable("the metadata package is not built (bun run --filter '*' build)") + raise NotAvailable("the metadata package is not built (bun run build)") return drive(["node", str(HERE / "ts-load.mjs"), str(model), str(runs)], {**os.environ, "MO_TS_DIST": str(dist)}) def prepare(self, work, model): diff --git a/scripts/check-install-size.mjs b/scripts/check-install-size.mjs index 569f6ba8c3..35eaa9322b 100644 --- a/scripts/check-install-size.mjs +++ b/scripts/check-install-size.mjs @@ -29,7 +29,7 @@ // The packages under test are this checkout's, packed with `bun pm pack` (which writes `workspace:` // ranges as versions), so nothing here depends on a release having been published. // -// Build first (`bun run --filter '*' build`): a package is packed from its built `dist/`. +// Build first (`bun run build`): a package is packed from its built `dist/`. import { execFileSync } from "node:child_process"; import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; @@ -156,7 +156,7 @@ function measure() { const dir = dirs.get(name); if (dir === undefined) throw new Error(`${name} is required by ${ENTRY} but is not a workspace package`); if (!existsSync(join(ROOT, dir, "dist"))) { - throw new Error(`${name} has no dist/: run \`bun run --filter '*' build\` first`); + throw new Error(`${name} has no dist/: run \`bun run build\` first`); } execFileSync("bun", ["pm", "pack", "--destination", tarballs, "--quiet"], { cwd: join(ROOT, dir), stdio: ["ignore", "ignore", "inherit"] }); } diff --git a/scripts/check-pack-manifests.ts b/scripts/check-pack-manifests.ts index df45d0f922..7afdc45288 100644 --- a/scripts/check-pack-manifests.ts +++ b/scripts/check-pack-manifests.ts @@ -44,9 +44,15 @@ const NAME = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/; const SEMVER = /^\d+\.\d+\.\d+$/; const CORE_NPM = "@metaobjectsdev/metadata"; -/** A range is bounded when it states an upper limit: ` ALL), so a change to the map # runs everything, and scripts/test-ci-lane-selection.sh asserts the map still says so. # -packs/* | packs | an independent pack (ADR-0069): its own lane only, and core's lanes never read packs/ (scripts/check-pack-boundary.ts) +packs/* | packs | an independent pack (ADR-0069): its own lane only under --affected (the hosted workflows select by port, where packs/ is ts); core never reads packs/ (scripts/check-pack-boundary.ts) server/typescript/* | ts-fast ts-unit packs | the TypeScript server port; packs runs too, as a canary that reports a pack the change breaks and blocks nothing (ADR-0069) examples/dynamic-grid/* | ts-fast ts-unit | a workspace member: ts-fast typechecks it, ts-unit runs its suite, and no other port reads it client/web/* | ts-fast ts-unit packs | the universal web client, built and tested by the TypeScript lanes; packs as for server/typescript diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 2705e0f165..907f47b33c 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -574,7 +574,7 @@ gate_site_reference() { bun_install && bun scripts/build-site-reference.ts --che gate_release_tag() { bun test scripts/finish-release.test.ts scripts/eject-release-gate.test.ts && node scripts/test-maven-coordinate.mjs && node scripts/test-prerelease-version.mjs && node scripts/test-check-release-tag.mjs && node scripts/test-changelog-promote.mjs && node scripts/test-release-branch.mjs && bash tools/prerelease/test-prerelease-link.sh && bash tools/prerelease/test-estate-run.sh; } # ── repo-root scripts/ typechecks ───────────────────────────────────────────── -# `bun test` transpiles per file and never typechecks, and `bun run --filter '*' +# `bun test` transpiles per file and never typechecks, and `bun run # typecheck` walks WORKSPACE PACKAGES only — so every script here, including every # gate in this lane, was checked by nothing. Two accessor defects came straight out # of that gap in one session: a property read that does not exist on the type, so it @@ -639,10 +639,13 @@ gate_pack_ts() { # gate_pack_ts # cannot be resolved (every uncertainty widens), or when MO_CI_PACKS_BLOCKING=1. pack_is_blocking() { [ "${MO_CI_PACKS_BLOCKING:-0}" = "1" ] && return 0 - local base mb + local base mb paths base="${MO_CI_AFFECTED_BASE:-$(default_base)}" [ -n "$base" ] && mb="$(git merge-base HEAD "$base" 2>/dev/null)" || return 0 - changed_paths "$mb" | grep -q "^packs/$1/" + # Captured, not piped: under pipefail, `grep -q` exiting on its first match can kill the + # writer with SIGPIPE and turn a match into "not blocking"; a failed listing widens. + paths="$(changed_paths "$mb")" || return 0 + grep -q "^packs/$1/" <<<"$paths" } # The packs lane. A pack is a preview product on its own release line, so a core change that # turns one red must not block core: it is reported as a named SKIP (the canary) and the pack diff --git a/scripts/lib/packs.ts b/scripts/lib/packs.ts index db6d2307d7..f5193d9436 100644 --- a/scripts/lib/packs.ts +++ b/scripts/lib/packs.ts @@ -266,6 +266,11 @@ export function derivePackVocabulary( const attrs = t.attrs.filter((a) => !base.has(`attr ${key} @${a.name}`)); const children = t.children.filter((c) => !base.has(`child ${key} > ${childKey(c)}`)); if (attrs.length > 0 || children.length > 0) ext.push({ type: t.type, subType: t.subType, attrs, children }); + // ADR-0050: what a pack projects onto a type it does not own must be optional, or every + // model that loaded before the pack was composed stops loading once it is. The registry + // refuses a required projected attribute itself (ERR_EXTEND_REQUIRED_ATTR); a child rule + // with a lower bound it does not check, so this does. + for (const c of children) if ((c.min ?? 0) > 0) coreChanges.push(`required: child ${key} > ${childKey(c)} (min ${c.min}) — a child rule added to a type the pack does not own must allow zero`); } const commonAttrs = composed.commonAttrs.filter((a) => !base.has(`common @${a.name}`)); const defaultSubTypes: Record = {}; diff --git a/scripts/pack-conformance.ts b/scripts/pack-conformance.ts index 87684964f1..b6b21ad2bd 100644 --- a/scripts/pack-conformance.ts +++ b/scripts/pack-conformance.ts @@ -76,6 +76,10 @@ if (import.meta.main) { continue; } failed++; + if (r.fixtures.every((f) => f.status === "skipped")) { + console.error(`pack ${name}: conformance FAILED — ${PACK_CORPUS}/ holds no runnable scenario${summary ? ` (${summary})` : ""}, so it tests nothing`); + continue; + } console.error(`pack ${name}: conformance FAILED (${summary})`); for (const f of r.fixtures.filter((x) => x.status === "fail" || x.status === "fixed-but-listed")) { console.error(` ✖ ${f.name} [${f.status}]: ${f.problems.join("; ")}`); diff --git a/scripts/packs.test.ts b/scripts/packs.test.ts index aa94473e61..7219f747d9 100644 --- a/scripts/packs.test.ts +++ b/scripts/packs.test.ts @@ -9,7 +9,7 @@ import { afterAll, describe, expect, test } from "bun:test"; import { cpSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; -import { checkPackManifests } from "./check-pack-manifests.js"; +import { bounded, checkPackManifests } from "./check-pack-manifests.js"; import { checkPackBoundary, scanCore, scanRegistry, scanReleaseTooling } from "./check-pack-boundary.js"; import { checkPackVocabulary } from "./pack-vocabulary.js"; import { runPackConformance } from "./pack-conformance.js"; @@ -35,7 +35,7 @@ function write(root: string, rel: string, content: string): void { const json = (v: unknown): string => `${JSON.stringify(v, null, 2)}\n`; /** A provider in the shape a pack ships: a new layout subtype plus two optional field.string attrs. */ -function providerSource(id: string, opts: { breakCore?: boolean } = {}): string { +function providerSource(id: string, opts: { breakCore?: boolean; requireOnCore?: boolean } = {}): string { return `import { TypeId, MetaLayout } from ${JSON.stringify(METADATA_SRC)}; export const provider = { id: ${JSON.stringify(id)}, @@ -55,13 +55,14 @@ export const provider = { ], }); ${opts.breakCore === true ? `registry.setDefaultSubType("object", "value");` : ""} + ${opts.requireOnCore === true ? `registry.extend("object", "entity", { childRules: [{ childType: "layout", childSubType: "picker", childName: "*", min: 1 }] });` : ""} }, }; `; } /** A complete, valid TypeScript-only pack named `name` under `root`. */ -function makePack(root: string, name: string, opts: { breakCore?: boolean; manifest?: Record; pkg?: Record } = {}): void { +function makePack(root: string, name: string, opts: { breakCore?: boolean; requireOnCore?: boolean; manifest?: Record; pkg?: Record } = {}): void { const base = `packs/${name}`; write(root, `${base}/pack.json`, json({ id: `metaobjects-${name}`, @@ -89,6 +90,11 @@ function makePack(root: string, name: string, opts: { breakCore?: boolean; manif } describe("pack.json check", () => { + test("a range is bounded in every registry's own spelling", () => { + for (const r of [">=1.3.0 <2.0.0", ">=1.3,<2", "^1.3.0", "~1.3", "~=1.3", "[1.3.0,2.0.0)", "(1.3,2.0]"]) expect(bounded(r)).toBe(true); + for (const r of [">=1.3.0", "[1.3.0,)", "*", "1.3.0"]) expect(bounded(r)).toBe(false); + }); + test("a complete pack passes", () => { const root = scratchRoot(); makePack(root, "demo"); @@ -246,6 +252,13 @@ describe("pack vocabulary", () => { expect(problems).toContain("does not leave core alone — changed: default object"); }); + test("a pack that adds a required child rule to a bundle type does not leave core alone (ADR-0050)", async () => { + const root = scratchRoot(); + makePack(root, "demo", { requireOnCore: true }); + const problems = (await checkPackVocabulary("demo", root)).problems.join("\n"); + expect(problems).toContain("does not leave core alone — required: child object.entity > layout.picker:* (min 1)"); + }); + test("a pack is pinned only for its own rows when it requires another pack", async () => { const root = scratchRoot(); makePack(root, "base"); diff --git a/scripts/regen-showcase.ts b/scripts/regen-showcase.ts index afba7becc2..5d4efb0a84 100644 --- a/scripts/regen-showcase.ts +++ b/scripts/regen-showcase.ts @@ -13,7 +13,7 @@ * tree whose `dist/` predates a codegen change this script regenerates through the OLD * emitter, reports every file `unchanged`, and `--check` passes against committed output * the current source would no longer produce — a vacuous green. Run - * `bun run --filter '*' build` first. `ci-local.sh` has `gate_ts_build_typecheck`, but it + * `bun run build` first. `ci-local.sh` has `gate_ts_build_typecheck`, but it * is in a different lane, so `--only gates` does not imply it. * bun scripts/regen-showcase.ts --bun-only # only the ports bun alone can drive * diff --git a/server/typescript/README.md b/server/typescript/README.md index 22a20c2814..5bb4fe3a83 100644 --- a/server/typescript/README.md +++ b/server/typescript/README.md @@ -25,7 +25,7 @@ Bun workspace — the workspace root is the **repository root** (run `bun instal ```bash bun install # once, at the repo root bun test # the server suite (from this directory) -bun run --filter '*' typecheck # whole workspace (from the repo root) +bun run typecheck # core's workspace (from the repo root) ``` ## CLI diff --git a/server/typescript/packages/cli/test/integration/support/built-cli.ts b/server/typescript/packages/cli/test/integration/support/built-cli.ts index 0bafd44cfc..297b7a3542 100644 --- a/server/typescript/packages/cli/test/integration/support/built-cli.ts +++ b/server/typescript/packages/cli/test/integration/support/built-cli.ts @@ -79,7 +79,7 @@ export function requireFreshDist(): void { throw new Error( `${stale.map((s) => s.name).join(", ")}: dist is missing or older than src. This gate runs ` + "the BUILT CLI under node, so it cannot be trusted against a stale build.\n" + - "Run: bun run --filter '*' build", + "Run: bun run build", ); } @@ -103,7 +103,7 @@ export function ensureFreshDist(): void { if (build.exitCode !== 0 || isStale(pkg)) { throw new Error( `${name} dist is missing or older than its src and the in-place rebuild did not fix it — ` + - `this gate runs the built CLI under node; run: bun run --filter '*' build\n${build.stderr.toString()}`, + `this gate runs the built CLI under node; run: bun run build\n${build.stderr.toString()}`, ); } } diff --git a/server/typescript/packages/conformance/src/corpus.ts b/server/typescript/packages/conformance/src/corpus.ts index 460b6f8581..7a79ba665d 100644 --- a/server/typescript/packages/conformance/src/corpus.ts +++ b/server/typescript/packages/conformance/src/corpus.ts @@ -43,7 +43,11 @@ export interface CorpusFixtureResult { export interface CorpusResult { readonly corpusRoot: string; readonly fixtures: readonly CorpusFixtureResult[]; - /** True when no scenario is `fail` or `fixed-but-listed`. */ + /** + * True when at least one scenario ran and none is `fail` or `fixed-but-listed`. A corpus + * with nothing runnable (empty, or docs-only and contract-only scenarios alone) tests + * nothing, so it does not pass. + */ readonly passed: boolean; } @@ -53,21 +57,29 @@ export async function runCorpus(opts: CorpusOptions): Promise { const required = opts.requireProviders ?? []; const results: CorpusFixtureResult[] = []; for (const fix of await discoverFixtures(opts.corpusRoot)) { + // The provider rule comes first, so a docs-only or contract-only scenario in a pack's + // corpus must name the pack too. + const missing = required + .filter((id) => !fix.providers.includes(id)) + .map((id) => `providers.json must name "${id}" (it lists: ${fix.providers.join(", ")})`); if (isDocsOnlyFixture(fix) || isContractOnlyFixture(fix)) { - results.push({ name: fix.name, status: "skipped", problems: [] }); + results.push(missing.length > 0 ? { name: fix.name, status: "fail", problems: missing } : { name: fix.name, status: "skipped", problems: [] }); continue; } - const problems = [...lintFixture(fix, opts.errorCodes)]; - for (const id of required) { - if (!fix.providers.includes(id)) { - problems.push(`providers.json must name "${id}" (it lists: ${fix.providers.join(", ")})`); - } - } + const problems = [...lintFixture(fix, opts.errorCodes), ...missing]; if (problems.length > 0) { results.push({ name: fix.name, status: "fail", problems }); continue; } - const report = await runFixture(fix, opts.adapter); + let report: Awaited>; + try { + report = await runFixture(fix, opts.adapter); + } catch (e) { + // An adapter that throws (an unknown provider id, say) is this scenario's failure, + // not the run's: every other scenario still gets its verdict. + results.push({ name: fix.name, status: "fail", problems: [`the adapter threw: ${(e as Error).message}`] }); + continue; + } const status = classifyAgainstLedger(report.status === "pass" ? "pass" : "fail", fix.name, ledger); const failed = report.checks.filter((c) => !c.passed).map((c) => c.detail ?? c.kind); results.push({ @@ -76,6 +88,7 @@ export async function runCorpus(opts: CorpusOptions): Promise { problems: status === "fixed-but-listed" ? ["passes but is listed in the expected-failures ledger"] : failed, }); } - const passed = results.every((r) => r.status !== "fail" && r.status !== "fixed-but-listed"); + const ran = results.some((r) => r.status !== "skipped"); + const passed = ran && results.every((r) => r.status !== "fail" && r.status !== "fixed-but-listed"); return { corpusRoot: opts.corpusRoot, fixtures: results, passed }; } diff --git a/server/typescript/packages/conformance/test/corpus.test.ts b/server/typescript/packages/conformance/test/corpus.test.ts index 560a9a1289..0c5981fe0a 100644 --- a/server/typescript/packages/conformance/test/corpus.test.ts +++ b/server/typescript/packages/conformance/test/corpus.test.ts @@ -58,3 +58,19 @@ test("requireProviders fails a scenario whose providers.json leaves the provider expect(r.fixtures.map((f) => `${f.name}:${f.status}`)).toEqual(["names:pass", "omits:fail"]); expect(r.fixtures[1]?.problems[0]).toContain('providers.json must name "metaobjects-demo"'); }); + +test("a corpus with nothing runnable does not pass, and an adapter that throws fails one scenario", async () => { + const empty = await corpus({}); + expect((await runCorpus({ corpusRoot: empty, adapter: fake, errorCodes: [] })).passed).toBe(false); + const root = await corpus({ a: { "expected.json": '{"ok":true}' }, b: { "expected.json": '{"ok":true}' } }); + const throwing: ConformanceAdapter = { + ...fake, + async loadFixture(inputDir, providers) { + if (inputDir.includes("/a/")) throw new Error('unknown provider "x"'); + return fake.loadFixture(inputDir, providers); + }, + }; + const r = await runCorpus({ corpusRoot: root, adapter: throwing, errorCodes: [] }); + expect(r.fixtures.map((f) => `${f.name}:${f.status}`)).toEqual(["a:fail", "b:pass"]); + expect(r.fixtures[0]?.problems[0]).toContain("the adapter threw: unknown provider"); +}); diff --git a/spec/decisions/ADR-0069-independent-packs.md b/spec/decisions/ADR-0069-independent-packs.md index 6a1065f668..75bdd03e7b 100644 --- a/spec/decisions/ADR-0069-independent-packs.md +++ b/spec/decisions/ADR-0069-independent-packs.md @@ -157,11 +157,14 @@ and `docs/CONFORMANCE.md` never move for pack work. ### 7. CI: a lane of its own, and a canary on core changes -`packs` is a lane in `scripts/ci-local.sh`, selectable by `--affected`, run on every pull -request by the hosted TypeScript job (`.github/workflows/pr-ci.yml`) and on every push to `main` -by its own job in `.github/workflows/local-ci.yml`, which is in the known-green lane map -(`scripts/ci-ports-to-run.sh`) like every other lane. The lane map gives `packs/*` that lane only, so a -pack-only change selects no core lane (asserted by `scripts/test-ci-lane-selection.sh`). For each +`packs` is a lane in `scripts/ci-local.sh`. It runs on every pull request in the hosted +TypeScript job (`.github/workflows/pr-ci.yml`), and on every push to `main` in its own job in +`.github/workflows/local-ci.yml`, which is in the known-green lane map +(`scripts/ci-ports-to-run.sh`) like every other lane. The lane map gives `packs/*` that lane +only, so a pack-only change runs no core lane under `ci-local.sh --affected` (asserted by +`scripts/test-ci-lane-selection.sh`). The hosted workflows choose by port, not by lane, and +`packs/*` is the TypeScript port there, so a pack-only pull request also runs `ts-fast` and +`ts-unit`. That costs time and never makes a core lane depend on a pack. For each pack with a TypeScript port, the lane runs the pack's typecheck, the pinned-vocabulary and leaves-core-alone check, its load corpus and its own tests, against core's working tree. diff --git a/tsconfig.scripts.json b/tsconfig.scripts.json index 5017d91fd0..789944193a 100644 --- a/tsconfig.scripts.json +++ b/tsconfig.scripts.json @@ -2,7 +2,7 @@ "//": [ "Typecheck for scripts/ \u2014 the repo-root tooling that no package tsconfig covers.", "", - "`bun test` transpiles per file and never typechecks, and `bun run --filter '*'", + "`bun test` transpiles per file and never typechecks, and `bun run", "typecheck` walks WORKSPACE PACKAGES only, so every script here was unchecked. Two", "defects in one session came straight out of that gap: `node.title` read as an", "accessor that does not exist (always undefined, silently reporting the wrong", From 428b08410a84f9f3e6a911bd39d7ad20467ab717 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 22:39:49 -0500 Subject: [PATCH 4/7] refactor(packs): fold simplify findings - conformance: runAndClassify and loadErrorCodes are the shared step; the core metadata conformance test and runCorpus both call them, so the classification lives in one place. - lib/packs: typescriptPackNames and packNamesFromArgs replace the copies in pack-vocabulary and pack-conformance. - pack-vocabulary returns core problems and the committed pin directly instead of re-deriving them by message prefix and a second read. - ci-local: step_canary is a step mode (timed, list-only aware); the change's path list is computed once per run, not once per pack. - check-pack-boundary parses the manifests once and builds each id regex once; the test no longer repeats the full-repo scan the gate runs. - check-pack-manifests dispatches native checks from a per-port table. --- scripts/check-pack-boundary.ts | 16 ++++--- scripts/check-pack-manifests.ts | 20 +++++--- scripts/ci-local.sh | 47 ++++++++++++------- scripts/lib/packs.ts | 16 +++++++ scripts/pack-conformance.ts | 24 +++------- scripts/pack-vocabulary.ts | 40 ++++++++-------- scripts/packs.test.ts | 6 +-- .../packages/conformance/src/corpus.ts | 41 +++++++++++----- .../metadata/test/conformance.test.ts | 25 ++-------- 9 files changed, 128 insertions(+), 107 deletions(-) diff --git a/scripts/check-pack-boundary.ts b/scripts/check-pack-boundary.ts index 51651382dc..180f617b56 100644 --- a/scripts/check-pack-boundary.ts +++ b/scripts/check-pack-boundary.ts @@ -77,9 +77,10 @@ export function coreFiles(root: string): string[] { } /** Rule 1 and the source half of rule 2. */ -export function scanCore(root: string): string[] { +export function scanCore(root: string, packs: Map = packsById(root)): string[] { const out: string[] = []; - const ids = [...packsById(root).keys()]; + const ids = [...packs.keys()]; + const idRes = ids.map((id) => [id, new RegExp(`(^|[^A-Za-z0-9_-])${id}([^A-Za-z0-9_-]|$)`)] as const); for (const rel of coreFiles(root)) { const text = readFileSync(join(root, rel), "utf8"); if (!PACK_COORDINATE.test(text) && !INTO_PACKS.test(text) && !ids.some((id) => text.includes(id))) continue; @@ -88,8 +89,8 @@ export function scanCore(root: string): string[] { const at = `${rel}:${i + 1}`; if (PACK_COORDINATE.test(line)) out.push(`${at}: core names a pack coordinate — core may never depend on a pack`); else if (INTO_PACKS.test(line)) out.push(`${at}: core reaches into packs/ by path — core may never depend on a pack`); - for (const id of ids) { - if (new RegExp(`(^|[^A-Za-z0-9_-])${id}([^A-Za-z0-9_-]|$)`).test(line)) { + for (const [id, re] of idRes) { + if (line.includes(id) && re.test(line)) { out.push(`${at}: names the independent pack provider "${id}" — an independent pack is never in the default bundle`); } } @@ -113,7 +114,7 @@ export function scanCore(root: string): string[] { } /** The registry half of rule 2: a type a pack pins is never in the bundle's manifest. */ -export function scanRegistry(root: string): string[] { +export function scanRegistry(root: string, packs: Map = packsById(root)): string[] { const out: string[] = []; const registryPath = join(root, "fixtures/registry-conformance/expected-registry.json"); const providersPath = join(root, "fixtures/registry-conformance/providers.json"); @@ -123,7 +124,7 @@ export function scanRegistry(root: string): string[] { const bundleIds = existsSync(providersPath) ? new Set(Object.keys((JSON.parse(readFileSync(providersPath, "utf8")) as { providers: Record }).providers)) : new Set(); - for (const [id, name] of packsById(root)) { + for (const [id, name] of packs) { if (bundleIds.has(id)) out.push(`packs/${name}: provider id "${id}" is a bundled provider (fixtures/registry-conformance/providers.json)`); const pin = join(root, "packs", name, PACK_VOCABULARY); if (!existsSync(pin)) continue; @@ -191,7 +192,8 @@ export function scanReleaseTooling(root: string): string[] { } export function checkPackBoundary(root: string = REPO_ROOT, opts: { releaseScan?: boolean } = {}): string[] { - return [...scanCore(root), ...scanRegistry(root), ...(opts.releaseScan === false ? [] : scanReleaseTooling(root))]; + const packs = packsById(root); + return [...scanCore(root, packs), ...scanRegistry(root, packs), ...(opts.releaseScan === false ? [] : scanReleaseTooling(root))]; } if (import.meta.main) { diff --git a/scripts/check-pack-manifests.ts b/scripts/check-pack-manifests.ts index 7afdc45288..86ba17588b 100644 --- a/scripts/check-pack-manifests.ts +++ b/scripts/check-pack-manifests.ts @@ -172,6 +172,16 @@ function checkRust(name: string, m: PackManifest, dir: string, out: Problems): v } } +/** Each port's native-manifest check, one per port so a new port cannot fall through to another's. */ +const NATIVE_CHECKS: Record void> = { + typescript: checkTypeScript, + java: (name, m, dir, out) => checkMaven("java", name, m, dir, out), + kotlin: (name, m, dir, out) => checkMaven("kotlin", name, m, dir, out), + python: checkPython, + csharp: checkCSharp, + rust: checkRust, +}; + /** Every problem with every pack under `/packs/`; empty when all agree. */ export function checkPackManifests(root: string = REPO_ROOT): string[] { const out: Problems = []; @@ -216,8 +226,8 @@ export function checkPackManifests(root: string = REPO_ROOT): string[] { continue; } if (!present) out.push(`packs/${name}/${port}: pack.json lists the port but the directory is missing`); - if (!packageMatches(port as PackPort, name, entry.package)) { - out.push(`${where}: ports.${port}.package is "${entry.package}", the naming rule gives "${expectedPackage(port as PackPort, name)}"`); + if (!packageMatches(port, name, entry.package)) { + out.push(`${where}: ports.${port}.package is "${entry.package}", the naming rule gives "${expectedPackage(port, name)}"`); } if (typeof entry.core !== "string" || !bounded(entry.core)) { out.push(`${where}: ports.${port}.core "${entry.core}" must be a range with an upper bound`); @@ -225,11 +235,7 @@ export function checkPackManifests(root: string = REPO_ROOT): string[] { if (typeof entry.publish !== "boolean") out.push(`${where}: ports.${port}.publish must be true or false`); if (!present) continue; const dir = join(base, port); - if (port === "typescript") checkTypeScript(name, m, dir, out); - else if (port === "java" || port === "kotlin") checkMaven(port, name, m, dir, out); - else if (port === "python") checkPython(name, m, dir, out); - else if (port === "csharp") checkCSharp(name, m, dir, out); - else checkRust(name, m, dir, out); + NATIVE_CHECKS[port](name, m, dir, out); } } return out; diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index 907f47b33c..a5acc07b03 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -297,6 +297,20 @@ step_if() { # step_if "" — SKIP (or FAIL under --stric fi } +step_canary() { # step_canary "" "" — like step, but red records a named SKIP + local name="$1" red="$2"; shift 2 + local t0=$SECONDS dt + echo "" + echo "── ▶ $name ──────────────────────────────────────────────" + if "$@"; then + dt=$((SECONDS - t0)); record PASS "$dt" "$name" + echo "── ✓ $name ($(fmt_dur "$dt"))" + else + dt=$((SECONDS - t0)); record SKIP "$dt" "$red" + echo " ⊘ $red ($(fmt_dur "$dt"))" >&2 + fi +} + # ── hygiene.yml: public-repo leak scan (the SECURITY gate kept in CI) ────────── gate_leak_scan() { local base="${MO_CI_LEAK_BASE:-origin/main}" @@ -635,24 +649,20 @@ gate_pack_ts() { # gate_pack_ts ( cd "$dir" && bun test ) || return 1 fi } -# pack_is_blocking — true when this change touches the pack's own files, when the base -# cannot be resolved (every uncertainty widens), or when MO_CI_PACKS_BLOCKING=1. -pack_is_blocking() { - [ "${MO_CI_PACKS_BLOCKING:-0}" = "1" ] && return 0 - local base mb paths +# packs_changed_paths — print this change's paths, once per run for every pack; fail when the +# base cannot be resolved or the listing fails, so every uncertainty makes every pack block. +packs_changed_paths() { + local base mb base="${MO_CI_AFFECTED_BASE:-$(default_base)}" - [ -n "$base" ] && mb="$(git merge-base HEAD "$base" 2>/dev/null)" || return 0 - # Captured, not piped: under pipefail, `grep -q` exiting on its first match can kill the - # writer with SIGPIPE and turn a match into "not blocking"; a failed listing widens. - paths="$(changed_paths "$mb")" || return 0 - grep -q "^packs/$1/" <<<"$paths" + [ -n "$base" ] && mb="$(git merge-base HEAD "$base" 2>/dev/null)" && [ -n "$mb" ] || return 1 + changed_paths "$mb" } # The packs lane. A pack is a preview product on its own release line, so a core change that # turns one red must not block core: it is reported as a named SKIP (the canary) and the pack # is fixed in its own PR. A change to the pack itself blocks, as any product's own change does. run_packs_steps() { want packs || return 0 - local n canary + local n paths="" all_block=0 local -a packs=() for n in packs/*/typescript/package.json; do [ -f "$n" ] || continue @@ -667,16 +677,16 @@ run_packs_steps() { && ! step_passed "ts build + typecheck" && ! step_passed "ts build"; then step "packs: core build" gate_ts_build fi + # A pack blocks when this change touches its own files, when MO_CI_PACKS_BLOCKING=1, or when + # the change cannot be listed. Captured once, not piped: under pipefail, `grep -q` exiting on + # its first match can kill the writer with SIGPIPE and turn a match into "not blocking". + if [ "${MO_CI_PACKS_BLOCKING:-0}" = "1" ] || ! paths="$(packs_changed_paths)"; then all_block=1; fi for n in "${packs[@]}"; do - if pack_is_blocking "$n"; then + if [ "$all_block" -eq 1 ] || grep -q "^packs/$n/" <<<"$paths"; then step "pack $n" gate_pack_ts "$n" - continue + else + step_canary "pack $n (canary)" "pack $n canary: red against core's tree (non-blocking, ADR-0069; fix it in the pack's own PR)" gate_pack_ts "$n" fi - canary="pack $n canary: red against core's tree (non-blocking, ADR-0069)" - if [ "${MO_CI_LIST_ONLY:-0}" = "1" ]; then echo " + pack $n (canary)"; continue; fi - echo ""; echo "── ▶ pack $n (canary: this change does not touch it) ──" - if gate_pack_ts "$n"; then record PASS 0 "pack $n (canary)"; echo "── ✓ pack $n (canary)" - else record SKIP 0 "$canary"; echo " ⊘ $canary — fix it in the pack's own PR" >&2; fi done } @@ -1647,6 +1657,7 @@ echo "metaobjects local CI (mode: $_mode)" # without running them, then exit 0. Useful for verifying section selection. if [ "${MO_CI_LIST_ONLY:-0}" = "1" ]; then step() { echo " + $1"; } + step_canary() { echo " + $1"; } step_if() { local t="$1" n="$2"; have "$t" && echo " + $n" || echo " ⊘ $n (no $t, would skip)"; } run_integration_for() { local label="$1"; shift; local r; for r in "$@"; do echo " + integration-tests ($r)"; done; } run_cube_lane() { echo " + cube-model live check (Cube + Postgres)"; } diff --git a/scripts/lib/packs.ts b/scripts/lib/packs.ts index f5193d9436..79ccf5cec3 100644 --- a/scripts/lib/packs.ts +++ b/scripts/lib/packs.ts @@ -108,6 +108,22 @@ export function listPackDirs(root: string = REPO_ROOT): string[] { .sort(); } +/** The packs that carry a TypeScript port (the ones the packs lane runs). */ +export function typescriptPackNames(root: string = REPO_ROOT): string[] { + return listPackDirs(root).filter((n) => existsSync(join(packDir(n, root), "typescript", "package.json"))); +} + +/** The pack names a script's arguments select (`...` or `--all`); exits 2 with `usage` when none is given. */ +export function packNamesFromArgs(args: readonly string[], usage: string): string[] { + if (args.includes("--all")) return typescriptPackNames(); + const names = args.filter((a) => !a.startsWith("--")); + if (names.length === 0) { + console.error(`usage: ${usage}`); + process.exit(2); + } + return names; +} + export function packDir(name: string, root: string = REPO_ROOT): string { return join(root, PACKS_DIR, name); } diff --git a/scripts/pack-conformance.ts b/scripts/pack-conformance.ts index b6b21ad2bd..18f5d3e0dd 100644 --- a/scripts/pack-conformance.ts +++ b/scripts/pack-conformance.ts @@ -18,20 +18,15 @@ * * Usage: bun scripts/pack-conformance.ts | --all */ -import { existsSync, readFileSync } from "node:fs"; +import { existsSync } from "node:fs"; import { join } from "node:path"; -import { runCorpus, loadLedger, type CorpusResult } from "../server/typescript/packages/conformance/src/index.js"; +import { runCorpus, loadErrorCodes, loadLedger, type CorpusResult } from "../server/typescript/packages/conformance/src/index.js"; import { createTsAdapter } from "../server/typescript/packages/metadata/test/conformance/adapter.js"; import type { MetaDataTypeProvider } from "../server/typescript/packages/metadata/src/index.js"; -import { PACK_CORPUS, REPO_ROOT, listPackDirs, loadPackClosure, packDir, readPackManifest } from "./lib/packs.js"; +import { PACK_CORPUS, REPO_ROOT, loadPackClosure, packDir, packNamesFromArgs, readPackManifest } from "./lib/packs.js"; const ERROR_CODES = "ERROR-CODES.json"; -function codesIn(path: string): string[] { - if (!existsSync(path)) return []; - return Object.keys((JSON.parse(readFileSync(path, "utf8")) as { codes?: Record }).codes ?? {}); -} - /** The pack's corpus result, or undefined when the pack has no load fixtures yet. */ export async function runPackConformance(name: string, root: string = REPO_ROOT): Promise { const corpusRoot = join(packDir(name, root), PACK_CORPUS); @@ -40,8 +35,8 @@ export async function runPackConformance(name: string, root: string = REPO_ROOT) const extra: Record = {}; for (const p of closure) extra[p.id] = p; const errorCodes = [ - ...codesIn(join(root, "fixtures/conformance", ERROR_CODES)), - ...codesIn(join(corpusRoot, ERROR_CODES)), + ...(await loadErrorCodes(join(root, "fixtures/conformance", ERROR_CODES))), + ...(await loadErrorCodes(join(corpusRoot, ERROR_CODES))), ]; return runCorpus({ corpusRoot, @@ -53,14 +48,7 @@ export async function runPackConformance(name: string, root: string = REPO_ROOT) } if (import.meta.main) { - const args = process.argv.slice(2); - const names = args.includes("--all") - ? listPackDirs().filter((n) => existsSync(join(packDir(n), "typescript", "package.json"))) - : args.filter((a) => !a.startsWith("--")); - if (names.length === 0 && !args.includes("--all")) { - console.error("usage: bun scripts/pack-conformance.ts |--all"); - process.exit(2); - } + const names = packNamesFromArgs(process.argv.slice(2), "bun scripts/pack-conformance.ts |--all"); let failed = 0; for (const name of names) { const r = await runPackConformance(name); diff --git a/scripts/pack-vocabulary.ts b/scripts/pack-vocabulary.ts index ba92391e45..8cb406cb88 100644 --- a/scripts/pack-vocabulary.ts +++ b/scripts/pack-vocabulary.ts @@ -29,17 +29,21 @@ import { REPO_ROOT, derivePackVocabulary, emitPackVocabulary, - listPackDirs, loadPackClosure, packDir, + packNamesFromArgs, readPackManifest, } from "./lib/packs.js"; export interface PackVocabularyCheck { readonly name: string; + /** Every problem: the core changes, then the pin's. */ readonly problems: string[]; - /** The freshly derived pin, as it would be written. */ + /** The rows of the bundle the pack changes; `--write` refuses while any remain. */ + readonly coreProblems: string[]; + /** The freshly derived pin, as it would be written, and the committed one (undefined when absent). */ readonly emitted: string; + readonly committed: string | undefined; } export async function checkPackVocabulary(name: string, root: string = REPO_ROOT): Promise { @@ -47,39 +51,33 @@ export async function checkPackVocabulary(name: string, root: string = REPO_ROOT const pack = closure[closure.length - 1]!; const { vocabulary, coreChanges } = derivePackVocabulary(readPackManifest(name, root).id, closure.slice(0, -1), pack); const emitted = emitPackVocabulary(vocabulary); - const problems = coreChanges.map((c) => `does not leave core alone — ${c}`); + const coreProblems = coreChanges.map((c) => `does not leave core alone — ${c}`); + const problems = [...coreProblems]; const pinPath = join(packDir(name, root), PACK_VOCABULARY); const committed = existsSync(pinPath) ? readFileSync(pinPath, "utf8").replace(/\r\n/g, "\n") : undefined; if (committed === undefined) problems.push(`${PACK_VOCABULARY} is missing — run: bun scripts/pack-vocabulary.ts ${name} --write`); else if (committed !== emitted) problems.push(`${PACK_VOCABULARY} is stale — the registered vocabulary changed; review it and run: bun scripts/pack-vocabulary.ts ${name} --write`); - return { name, problems, emitted }; -} - -function typescriptPacks(root: string): string[] { - return listPackDirs(root).filter((n) => existsSync(join(packDir(n, root), "typescript", "package.json"))); + return { name, problems, coreProblems, emitted, committed }; } if (import.meta.main) { const args = process.argv.slice(2); const write = args.includes("--write"); - const names = args.includes("--all") ? typescriptPacks(REPO_ROOT) : args.filter((a) => !a.startsWith("--")); - if (names.length === 0 && !args.includes("--all")) { - console.error("usage: bun scripts/pack-vocabulary.ts |--all [--write]"); - process.exit(2); - } + const names = packNamesFromArgs(args, "bun scripts/pack-vocabulary.ts |--all [--write]"); let failed = 0; for (const name of names) { const r = await checkPackVocabulary(name); - const core = r.problems.filter((p) => p.startsWith("does not leave core alone")); - if (write && core.length === 0) { - const path = join(packDir(name), PACK_VOCABULARY); - mkdirSync(dirname(path), { recursive: true }); - const old = existsSync(path) ? readFileSync(path, "utf8") : undefined; - if (old !== r.emitted) writeFileSync(path, r.emitted); - console.log(`pack ${name}: ${old === r.emitted ? "pin unchanged" : `wrote ${PACK_VOCABULARY}`}`); + if (write && r.coreProblems.length === 0) { + const unchanged = r.committed === r.emitted; + if (!unchanged) { + const path = join(packDir(name), PACK_VOCABULARY); + mkdirSync(dirname(path), { recursive: true }); + writeFileSync(path, r.emitted); + } + console.log(`pack ${name}: ${unchanged ? "pin unchanged" : `wrote ${PACK_VOCABULARY}`}`); continue; } - const shown = write ? core : r.problems; + const shown = write ? r.coreProblems : r.problems; if (shown.length === 0) { console.log(`pack ${name}: vocabulary pinned, leaves core alone`); } else { diff --git a/scripts/packs.test.ts b/scripts/packs.test.ts index 7219f747d9..524378a482 100644 --- a/scripts/packs.test.ts +++ b/scripts/packs.test.ts @@ -10,7 +10,7 @@ import { cpSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writ import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { bounded, checkPackManifests } from "./check-pack-manifests.js"; -import { checkPackBoundary, scanCore, scanRegistry, scanReleaseTooling } from "./check-pack-boundary.js"; +import { scanCore, scanRegistry, scanReleaseTooling } from "./check-pack-boundary.js"; import { checkPackVocabulary } from "./pack-vocabulary.js"; import { runPackConformance } from "./pack-conformance.js"; import { PACK_VOCABULARY, REPO_ROOT } from "./lib/packs.js"; @@ -160,10 +160,6 @@ describe("pack.json check", () => { }); describe("pack boundary", () => { - test("the repository as committed is inside the boundary", () => { - expect(checkPackBoundary(REPO_ROOT)).toEqual([]); - }); - test("core naming a pack coordinate, reaching into packs/ or naming a pack id fails", () => { const root = scratchRoot(); makePack(root, "demo"); diff --git a/server/typescript/packages/conformance/src/corpus.ts b/server/typescript/packages/conformance/src/corpus.ts index 7a79ba665d..60349427e7 100644 --- a/server/typescript/packages/conformance/src/corpus.ts +++ b/server/typescript/packages/conformance/src/corpus.ts @@ -12,7 +12,8 @@ // providers.json. A scenario with no providers.json falls back to the default bundle, // which by definition does not carry an independent pack, and would test core instead. -import { discoverFixtures, isContractOnlyFixture, isDocsOnlyFixture } from "./fixture.js"; +import { readFile } from "node:fs/promises"; +import { discoverFixtures, isContractOnlyFixture, isDocsOnlyFixture, type Fixture } from "./fixture.js"; import type { ConformanceAdapter } from "./adapter.js"; import { lintFixture } from "./fixture-lint.js"; import { runFixture } from "./runner.js"; @@ -51,6 +52,33 @@ export interface CorpusResult { readonly passed: boolean; } +/** The codes an `ERROR-CODES.json` defines (`{ "codes": { CODE: description } }`); none when it is absent. */ +export async function loadErrorCodes(path: string): Promise { + let raw: string; + try { + raw = await readFile(path, "utf8"); + } catch { + return []; + } + return Object.keys((JSON.parse(raw) as { codes?: Record }).codes ?? {}); +} + +/** + * Run one fixture and classify it against the ledger: the step every runner shares + * (the core metadata test, one `bun test` per fixture, and `runCorpus` below). The + * problems are the failed checks' details, or the ledger note for `fixed-but-listed`. + */ +export async function runAndClassify( + fix: Fixture, + adapter: ConformanceAdapter, + ledger: readonly string[], +): Promise<{ status: FixtureStatus; problems: string[] }> { + const report = await runFixture(fix, adapter); + const status = classifyAgainstLedger(report.status === "pass" ? "pass" : "fail", fix.name, ledger); + if (status === "fixed-but-listed") return { status, problems: ["passes but is listed in the expected-failures ledger"] }; + return { status, problems: report.checks.filter((c) => !c.passed).map((c) => c.detail ?? c.kind) }; +} + /** Run every scenario under `corpusRoot` through `adapter`. */ export async function runCorpus(opts: CorpusOptions): Promise { const ledger = opts.ledger ?? []; @@ -71,22 +99,13 @@ export async function runCorpus(opts: CorpusOptions): Promise { results.push({ name: fix.name, status: "fail", problems }); continue; } - let report: Awaited>; try { - report = await runFixture(fix, opts.adapter); + results.push({ name: fix.name, ...(await runAndClassify(fix, opts.adapter, ledger)) }); } catch (e) { // An adapter that throws (an unknown provider id, say) is this scenario's failure, // not the run's: every other scenario still gets its verdict. results.push({ name: fix.name, status: "fail", problems: [`the adapter threw: ${(e as Error).message}`] }); - continue; } - const status = classifyAgainstLedger(report.status === "pass" ? "pass" : "fail", fix.name, ledger); - const failed = report.checks.filter((c) => !c.passed).map((c) => c.detail ?? c.kind); - results.push({ - name: fix.name, - status, - problems: status === "fixed-but-listed" ? ["passes but is listed in the expected-failures ledger"] : failed, - }); } const ran = results.some((r) => r.status !== "skipped"); const passed = ran && results.every((r) => r.status !== "fail" && r.status !== "fixed-but-listed"); diff --git a/server/typescript/packages/metadata/test/conformance.test.ts b/server/typescript/packages/metadata/test/conformance.test.ts index bbe9fc7ada..38998e6494 100644 --- a/server/typescript/packages/metadata/test/conformance.test.ts +++ b/server/typescript/packages/metadata/test/conformance.test.ts @@ -12,13 +12,13 @@ import { expect, test } from "bun:test"; import { join } from "node:path"; import { - classifyAgainstLedger, discoverFixtures, isContractOnlyFixture, isDocsOnlyFixture, lintFixture, + loadErrorCodes, loadLedger, - runFixture, + runAndClassify, } from "@metaobjectsdev/conformance"; import { tsAdapter } from "./conformance/adapter.js"; @@ -29,13 +29,7 @@ const CORPUS = process.env.METAOBJECTS_CONFORMANCE_CORPUS ?? join(import.meta.dir, "../../../../../fixtures/conformance"); const LEDGER = join(import.meta.dir, "../conformance-expected-failures.json"); -const ERROR_CODES = Object.keys( - ( - (await Bun.file(join(CORPUS, "ERROR-CODES.json")).json()) as { - codes: Record; - } - ).codes, -); +const ERROR_CODES = await loadErrorCodes(join(CORPUS, "ERROR-CODES.json")); const fixtures = await discoverFixtures(CORPUS); const ledger = await loadLedger(LEDGER); @@ -54,18 +48,9 @@ for (const fix of fixtures) { expect(lintFixture(fix, ERROR_CODES)).toEqual([]); }); test(`conformance: ${fix.name}`, async () => { - const report = await runFixture(fix, tsAdapter); - const status = classifyAgainstLedger( - report.status === "pass" ? "pass" : "fail", - fix.name, - ledger, - ); + const { status, problems } = await runAndClassify(fix, tsAdapter, ledger); if (status === "fail" || status === "fixed-but-listed") { - const detail = report.checks - .filter((c) => !c.passed) - .map((c) => c.detail) - .join("; "); - throw new Error(`${fix.name} [${status}]: ${detail}`); + throw new Error(`${fix.name} [${status}]: ${problems.join("; ")}`); } expect(["pass", "known-gap"]).toContain(status); }); From e2401dd6631e360f4483202662f8ce01a2f929e0 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 23:17:53 -0500 Subject: [PATCH 5/7] no-mistakes(document): docs: refresh RELEASING and READMEs for packs --- AGENTS.md | 2 +- docs/RELEASING.md | 12 +++++++----- examples/advanced-modeling/README.md | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 43d5eb4e2d..026c1ffb61 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -450,7 +450,7 @@ its own canonical serializer already, so `fmt` runs locally everywhere: ## Running tests -The Bun workspace root is the **repository root** (`/package.json`), which globs `server/typescript/packages/*`, `client/web/packages/*` and the `examples/dynamic-grid` example. Java/Python/C# live outside the JS workspace (not globbed). Run `bun install` **once at the repo root**. Run `bun test` **scoped** — `cd server/typescript && bun test` for the server suite (this also picks up `server/typescript/bunfig.toml`'s test preload), and per-package for `client/web`. **Never run a bare `bun test` at the repo root**: it walks `java/`, `python/`, `csharp/`, and `fixtures/` looking for test files, turning a fast per-package run into many minutes. +The Bun workspace root is the **repository root** (`/package.json`), which globs `server/typescript/packages/*`, `client/web/packages/*`, the `examples/dynamic-grid` example and `packs/*/typescript` (the independent packs, ADR-0069). Java/Python/C# live outside the JS workspace (not globbed). Run `bun install` **once at the repo root**. Run `bun test` **scoped** — `cd server/typescript && bun test` for the server suite (this also picks up `server/typescript/bunfig.toml`'s test preload), and per-package for `client/web`. **Never run a bare `bun test` at the repo root**: it walks `java/`, `python/`, `csharp/`, `packs/`, and `fixtures/` looking for test files, turning a fast per-package run into many minutes. ``` bun install # once, at the repo root diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 136792340a..21152128e1 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -73,8 +73,8 @@ workflows (the step after checkout) refuse a version with no prerelease suffix w holds an entry. A release candidate (`1.1.0-rc.3`, or `1.1.0rc3` on PyPI) is allowed. A publish you type by hand passes through none of those, so run the gate yourself as the -command before it. This document has it before each of the four: the npm promote in step 3, -the isolated one-package `bun publish`, the PyPI fallback `uv publish`, and the local +command before it. This document has it before each of the three: the npm promote in step 3, +the PyPI fallback `uv publish`, and the local `mvn -Prelease deploy`. It exits non-zero on a refusal: ``` @@ -102,8 +102,9 @@ each one cost a broken/burned release to learn. ## What gets published -The publish-candidate packages (versioned in lockstep unless a package gets an -isolated patch). **Enumerate the set each release — do not trust this count** (it +The publish-candidate packages, versioned in lockstep — there is no single-package +release (see [Isolated patch (one package)](#isolated-patch-one-package) below). +**Enumerate the set each release — do not trust this count** (it was **13** at 0.11.5); the lockstep set is "every non-`private` package at the previous version": @@ -441,7 +442,8 @@ diff explained. - The JS/TS **workspace root is the repo root** (`/package.json`), globbing `server/typescript/packages/*` + `client/web/packages/*` (and the private `examples/dynamic-grid`, - which publishes nothing). This is what makes `workspace:*` + plus the private pack workspaces under `packs/*/typescript` (ADR-0069) — no core release + publishes anything from either). This is what makes `workspace:*` resolve uniformly at publish time — don't move it. - npm auth as an owner of the `metaobjectsdev` org. The account has 2FA **auth-and-writes**, so for an unattended publish use a **Granular/Automation token with the bypass-2FA option**, scoped diff --git a/examples/advanced-modeling/README.md b/examples/advanced-modeling/README.md index 5e0d1f24d9..323a9af5d0 100644 --- a/examples/advanced-modeling/README.md +++ b/examples/advanced-modeling/README.md @@ -61,8 +61,8 @@ resolves at generation time — not `verify`'s own `prompts/` default. See "Gotchas" below.) `examples/advanced-modeling/` is **not** part of the Bun workspace (the repo-root -`package.json` globs `server/typescript/packages/*`, `client/web/packages/*` and -`examples/dynamic-grid`, not this example), so there is no local install step — the CLI's +`package.json` globs `server/typescript/packages/*`, `client/web/packages/*`, +`examples/dynamic-grid` and `packs/*/typescript`, not this example), so there is no local install step — the CLI's config loader resolves the `@metaobjectsdev/*` imports in `metaobjects.config.ts` from the CLI's own install regardless of the example's `node_modules` (which doesn't exist). From c42338d29e4da3c6413fa25f8fffa59e01de5f6b Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Tue, 24 Nov 2026 23:20:17 -0500 Subject: [PATCH 6/7] no-mistakes(document): docs: mark pack prerelease path not built --- docs/RELEASING.md | 13 +++++++------ spec/decisions/ADR-0069-independent-packs.md | 9 +++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 21152128e1..b3f9f8dfbe 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -752,12 +752,13 @@ maintenance-branch procedure either, because core can be cut from `main` with pa flight. A pack is released on its own, tagged `pack--v`. Core's tag patterns, the site -deploy and the metamodel gate's baseline all ignore that tag. Until a pack is published -(`"publish": false` in `pack.json`, `"private": true` on its npm package), adopter projects use -it from the private prerelease registry (`docs/features/prerelease.md`). It publishes once an -estate project runs it with the drift gate enforced. The pack release script, the pack version -gate and the test against the lowest published core in its range are built before that first -publish. +deploy and the metamodel gate's baseline all ignore that tag. A pack stays unpublished +(`"publish": false` in `pack.json`, `"private": true` on its npm package) until an estate +project runs it with the drift gate enforced. A pack's prerelease path — publishing it to the +private registry for that adopter run — does not exist yet (`docs/features/prerelease.md` +covers the core lockstep set only) and is built in a follow-up before the first adopter run. +The pack release script, the pack version gate and the test against the lowest published core +in its range are built before that first publish. # Releasing the C# packages to NuGet diff --git a/spec/decisions/ADR-0069-independent-packs.md b/spec/decisions/ADR-0069-independent-packs.md index 75bdd03e7b..677f5059a7 100644 --- a/spec/decisions/ADR-0069-independent-packs.md +++ b/spec/decisions/ADR-0069-independent-packs.md @@ -182,10 +182,11 @@ Core's own `build` and `typecheck` (the root `package.json` scripts, used by the ### 8. Publishing -A pack stays **unpublished** (`"publish": false`, its npm package `private`) and is used by -adopter projects through the private prerelease registry (`docs/features/prerelease.md`) until -one estate project runs it with the drift gate enforced. Only then does it publish, as `0.x` -`preview`. This is the bar a `preview` library meets before promotion (`docs/features/libraries.md`), and the one ADR-0035 Amendment 6 sets for new vocabulary (ruling 3) and for a helper leaving `0.x` (ruling 2). A pack release +A pack stays **unpublished** (`"publish": false`, its npm package `private`) until one estate +project runs it with the drift gate enforced; only then does it publish, as `0.x` `preview`. +A pack's prerelease path — publishing it to the private registry for that adopter run — does +not exist yet (`docs/features/prerelease.md` covers the core lockstep set only) and is built in +a follow-up before the first adopter run. This is the bar a `preview` library meets before promotion (`docs/features/libraries.md`), and the one ADR-0035 Amendment 6 sets for new vocabulary (ruling 3) and for a helper leaving `0.x` (ruling 2). A pack release is tagged `pack--v`, which the core release tags (`v..

`), the site deploy and the metamodel gate's baseline all ignore. The per-registry release path (a pack release script, a pack version gate against its last tag, and a test against the lowest published core From d9dd9eb550635118f1166494a84259464bbce2ed Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Wed, 25 Nov 2026 01:32:53 -0500 Subject: [PATCH 7/7] no-mistakes(document): docs: fix packs-lane, glob and npm-count drift --- .no-mistakes.yaml | 9 +++++---- AGENTS.md | 4 ++-- CONTRIBUTING.md | 3 ++- README.md | 2 ++ docs/llms/llms.txt | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.no-mistakes.yaml b/.no-mistakes.yaml index 8420058c3d..336a9c6c1d 100644 --- a/.no-mistakes.yaml +++ b/.no-mistakes.yaml @@ -10,8 +10,9 @@ # 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 +# runs only those (ts-fast + ts-unit, plus the packs lane as a canary, for a TypeScript or +# web-client change; java-slow, python or csharp for a change confined to that port; only +# packs for a change under packs/ (ADR-0069); 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 @@ -37,9 +38,9 @@ # reports a false red. # # --strict-toolchains closes a SKIP hole, and only that. These selections run two kinds of -# step. The `step_if bun` ones — every step in `ts-fast` and `ts-unit`, and 17 of the 32 in +# step. The `step_if bun` ones — every step in `ts-fast` and `ts-unit`, and 19 of the 36 in # `gates` — are the hazard: without the flag, a host with no bun on PATH SKIPS them and the -# step still reports GREEN. Strict turns that false green into a loud failure. The other 15 +# step still reports GREEN. Strict turns that false green into a loud failure. The other 17 # `gates` steps run under plain `step`, so they were never at risk either way: a missing # binary just makes the command fail. Most are shell-only (grep/sed — `check-pom-versions.sh` # and `check-uv-lock-version.sh` are deliberately toolchain-free so they need no lane), but diff --git a/AGENTS.md b/AGENTS.md index d00ad7541c..cc97fb8c91 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -129,8 +129,8 @@ for a TYPED boolean, since `-f` sends the string `"true"` and 422s.) hosted checks — every check workflow in `.github/workflows/` is a thin wrapper that calls it. `--quick` covers `hygiene.yml` in full plus the TypeScript half of `conformance.yml`, and the flagless full run -adds the C#/Java/Kotlin/Python conformance lanes, the Java reactor and `integration-tests.yml`'s -Testcontainers matrix. Run `--quick` before opening a PR and the full script before a tag; +adds the C#/Java/Kotlin/Python conformance lanes, the Java reactor, the `packs` lane (ADR-0069) and +`integration-tests.yml`'s 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 `test` command runs `--affected` (only the lanes the change touches, per diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 630b683d58..f899b13a90 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,7 +129,8 @@ merge base with the base branch (committed, uncommitted and untracked), maps eac 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/`, +and the web client, plus the `packs` lane as a canary, `java-slow`, `python`, `csharp`); a change +to an independent pack under `packs/` runs only `packs` (ADR-0069); 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` diff --git a/README.md b/README.md index 768cbff558..b98068d97a 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,8 @@ metaobjects/ ├── library/ # shipped libraries, opt-in per project via `libraries: [...]` │ ├── ai/ # the LLM-call trace envelope (stable) │ └── iam/ # users, groups, roles, grants (preview) +├── packs/ # independent packs, outside the default bundle, each with its +│ # own version (ADR-0069; none shipped yet) ├── templates/ # canonical api/docs Mustache templates (the SSOT the │ # ports embed; byte-gated so copies cannot drift) ├── agent-context/ # the shared source the per-port AI-assistant context diff --git a/docs/llms/llms.txt b/docs/llms/llms.txt index dd88eba1e4..3cd72913c6 100644 --- a/docs/llms/llms.txt +++ b/docs/llms/llms.txt @@ -67,7 +67,7 @@ MetaObjects pillars are capabilities of one metadata model, not separate product ## Implementations (npm `1.3.0` / Maven Central `8.3.0`) -- [TypeScript](https://github.com/metaobjectsdev/metaobjects/tree/main/server/typescript): the reference implementation. Published to npm at `1.3.0` across 14 `@metaobjectsdev/*` packages on the `latest` tag. 2500+ tests passing across the workspace. Bun-first dev workflow. Owns the reference schema-migration helper, one option beside each port's native tool (ADR-0015). +- [TypeScript](https://github.com/metaobjectsdev/metaobjects/tree/main/server/typescript): the reference implementation. Published to npm at `1.3.0` across 13 `@metaobjectsdev/*` packages on the `latest` tag. 2500+ tests passing across the workspace. Bun-first dev workflow. Owns the reference schema-migration helper, one option beside each port's native tool (ADR-0015). - [Java](https://github.com/metaobjectsdev/metaobjects/tree/main/server/java): 14 publishable Maven modules under `com.metaobjects:*` at `8.3.0` on Maven Central (15 artifacts with the parent POM). Spring REST + DTO + repository-interface codegen, OMDB runtime persistence (pure data-access) with Spring-tx, full FR-003 + FR-006 + FR-010/011 + FR-018 + FR5 family. Fully green across all conformance corpora. - [Kotlin](https://github.com/metaobjectsdev/metaobjects/tree/main/server/java/codegen-kotlin): a Kotlin codegen pipeline on KotlinPoet plus `metadata-ktx` — a Kotlin facade over the Java MetaObjects core. Ships via the Java reactor (`metaobjects-metadata-ktx`, `metaobjects-codegen-kotlin`). Persistence-conformance runs against Testcontainers Postgres through Exposed. - [C#](https://github.com/metaobjectsdev/metaobjects/tree/main/server/csharp): loader + canonical serializer + EF Core + ASP.NET codegen + render/verify. The `dotnet meta` tool ships `gen` and the codegen-side `verify` subverbs (`--codegen`, `--templates`); schema migration is Node `meta` only (ADR-0015).